Datasets:
AI4M
/

text
stringlengths
0
3.34M
Require Import Ctl.BinaryRelations. Require Import Ctl.Paths. Require Import Ctl.Definition. Require Import Ctl.Basic. Require Import Ctl.Tactics. Require Import Glib.Glib. Require Import Lia. Section Properties. Open Scope tprop_scope. Context {state: Type}. Variable R: relation state. Context {t: transition R}. (* Properties of implication *) Theorem timpl_refl : forall (s: state) a, R @s ⊨ a ⟶ a. Proof using. intros. tintro. assumption. Qed. Theorem timpl_trans : forall (s: state) a b c, R @s ⊨ (a ⟶ b) ⟶ (b ⟶ c) ⟶ a ⟶ c. Proof using. intros s a b c. tintros Hab Hbc Ha. tapplyc Hbc. tapplyc Hab. assumption. Qed. Theorem timpl_trans' : forall (s: state) a b c, R @s ⊨ a ⟶ b -> R @s ⊨ b ⟶ c -> R @s ⊨ a ⟶ c. Proof using. intros s a b c Hab Hbc. tintros Ha. tapplyc Hbc. tapplyc Hab. assumption. Qed. Ltac treflexivity := simple apply timpl_refl. Ltac treflexive := match goal with | |- _ @_ ⊨ ?a ⟶ ?a => treflexivity | |- _ @_ ⊨ ?a ⟶ ?b => replace a with b; [ treflexivity | try easy; symmetry ] end. Ltac ttransitivity x := match goal with | |- ?R @?s ⊨ ?a ⟶ ?b => simple apply (timpl_trans' R s a x b) end. Ltac ettransitivity := match goal with | |- ?R @?s ⊨ ?a ⟶ ?b => simple eapply (timpl_trans' R s a _ b) end. Theorem textensionality : forall s P Q, R @s ⊨ P ⟷ Q -> (R @s ⊨ P) = (R @s ⊨ Q). Proof using. intros. extensionality. assumption. Qed. Lemma tNNPP : forall s P, (* TODO: fix precedence so parantheses not necessary *) R @s ⊨ (¬¬P) ⟶ P. Proof using. intros *. tintro H. now apply NNPP. Qed. Lemma rew_tNNPP : forall s P, (R @s ⊨ ¬¬P) = (R @s ⊨ P). Proof using. intros *. extensionality. split. - tapply tNNPP. - intro. tintro contra. now tapply contra. Qed. (* Properties of CTL path-quantifying formulas *) Theorem star__AG : forall s P, (forall s', R^* s s' -> R @s' ⊨ P) -> R @s ⊨ AG P. Proof using. intros * H. tsimpl. intros * Hin. applyc H. enow eapply in_path__star. Qed. Theorem AG__star : forall s P, R @s ⊨ AG P -> forall s', R^* s s' -> R @s' ⊨ P. Proof using. intros * H. intros s' Hstar. apply (star__in_path _ _ _ trans_serial) in Hstar. destruct exists Hstar p. enow etapply H. Qed. Theorem rew_AG_star : forall s P, R @s ⊨ AG P = forall s', R^* s s' -> R @s' ⊨ P. Proof using. intros *. extensionality. split. - now apply AG__star. - apply star__AG. Qed. Theorem star__EF : forall s P, (exists s', R^* s s' /\ R @s' ⊨ P) -> R @s ⊨ EF P. Proof using. intros * H. tsimpl. destruct H as (s' & Hstar & H). apply (star__in_path _ _ _ trans_serial) in Hstar. destruct exists Hstar p. now exists p s'. Qed. Theorem EF__star : forall s P, R @s ⊨ EF P -> exists s', R^* s s' /\ R @s' ⊨ P. Proof using. intros * H. tsimpl in *. destruct H as (p & s' & Hin & H). exists s'. split. - enow eapply in_path__star. - assumption. Qed. Theorem rew_EF_star : forall s P, R @s ⊨ EF P = exists s', R^* s s' /\ R @s' ⊨ P. Proof using. intros *. extensionality. split. - now apply EF__star. - apply star__EF. Qed. Theorem AU_trivial : forall s P Q, R @s ⊨ Q ⟶ A[P U Q]. Proof using. intros *. tintro H. tsimpl. intros. exists s 0. split; [|split]. - destruct p. constructor. - intros * Hin_before. now inv Hin_before. - assumption. Qed. (* Extract the first satisfactory state *) Lemma first_state : forall s (p: path R s) P, (exists s', in_path s' p /\ R @s' ⊨ P) -> exists s' i, in_path_at s' i p /\ (forall x, in_path_before x i p -> R @x ⊨ ¬P) /\ R @s' ⊨ P. Proof using. intros * H. destruct H as (s'' & Hin & H). induction Hin. - exists s 0. max split. + constructor. + intros * contra. now inv contra. + assumption. - forward IHHin by assumption. destruct IHHin as (s'0 & i & Hin' & IH1 & IH2). destruct classic (R @s ⊨ P) as case. + exists s 0. max split. * constructor. * intros * contra. now inv contra. * assumption. + exists s'0 (S i). max split. * now constructor. * intros * Hbefore. destruct Hbefore as (m & Hlt & Hin''). destruct m. -- now inv Hin''. -- apply IH1. dependent invc Hin''. exists m. split. ++ lia. ++ assumption. * assumption. Qed. Theorem seq__AW : forall s P Q, (R @s ⊨ P ∨ Q -> forall s' (seq: R#* s s'), (forall x, in_seq x seq -> R @x ⊨ P ∧ ¬Q) -> forall s'', R s' s'' -> R @s'' ⊨ P ∨ Q) -> R @s ⊨ A[P W Q]. Proof using. tsimpl. intros * H *. (* Proceed by classical destruction on whether there exists some state sQ in p entailing Q. *) destruct classic ( exists sQ, in_path sQ p /\ R @sQ ⊨ Q ) as case. - right. (* Need to strengthen case to the *first* such sQ *) apply first_state in case. destruct case as (sQ & i & Hin & Hbefore_entails & HsQ). exists sQ i. max split; try assumption. intros * Hbefore. (* Strategy: get prefix sequence including state before sQ. reflect in_path_before to in_seq Induct over in_seq. apply to H to get P ∨ Q. Show Q contradicts that sQ is first. Therefore, P *) copy Hin _temp; apply in_path_at__seq'' in _temp as [seq Hbefore_seq]. destruct seq as [|s sQ' sQ]. { exfalso; clear - Hbefore_seq Hbefore. destruct (path_at R p 1) as [y Hat]. specialize (Hbefore_seq y 1). forward Hbefore_seq. - contradict goal. transform contra (i = 0) by lia. now inv Hbefore. - rewrite Hbefore_seq in Hat. dependent invc Hat. discriminate H2. } assert (Hbefore': in_seq sP seq) by todo. (* Inconvenient induction principle. Should start from the beginning *) (* induction Hbefore'. *) todo. - overwrite case (not_ex_all_not _ _ case); simpl in case. transform case (forall s', in_path s' p -> R @s' ⊨ ¬Q). { clear - case. intros s' Hin. specialize (case s'). apply not_and_or in case. now destruct case. } left. intros * Hin. induction Hin. + specialize (case s). forward case by constructor. split; [|assumption]. (* specialize (H s (seq_refl R s)). forward H. * intros * contra. dependent invc contra. *) Admitted. (* Theorem seq__AW : forall s P Q, (forall s' (seq: R#* s s'), (forall x, in_seq x seq -> R @x ⊨ P ∧ ¬Q) -> forall s'', R s' s'' -> R @s'' ⊨ P ∨ Q) -> R @s ⊨ A[P W Q]. Proof using. intros * H. tsimpl. unfold_tdisj. (* Wait, is this correct? What if it's AG on some paths, and AU on others? I think I may need to redefine. *) intros *. Theorem AW__seq : forall s P Q, R @s ⊨ A[P W Q] -> forall s' (seq: R#* s s'), (forall x, in_seq x seq -> R @x ⊨ P ∧ ¬Q) -> forall s'', R s' s'' -> R @s'' ⊨ P ∨ Q. Proof using. intros * H * H' * Hstep. tsimpl in H. destruct or H. - apply tentails_tdisj_l. rewrite rew_AG_star in H. applyc H. transitivity s'. + now apply seq__star. + now apply star_lift. - tsimpl in H. pose proof (prefix := seq_prefix _ _ _ trans_serial (seq_step R s s' s'' Hstep seq)). destruct exists prefix p. specialize (H p). destruct H as (sQ & i & Hin_at & Hin_before & H). destruct classic (in_path_before s'' i p) as Hbefore. + apply tentails_tdisj_l. now apply Hin_before. + clear Hin_before. (* s'' is in p (by prefix), but not before i. Therefore, it must be after i. This means i/sP is before s''. Which means i/sP is in the prefix. It is therefore either in `seq`, in which case we get the contradiction `R @sQ ⊨ ¬Q` from H', or sQ = s'', in which case solve goal by right. *) pose proof (in_prefix _ _ _ _ _ s'' prefix) as Hin. forward Hin by constructor. todo. (* contradict H. specialize (H' sQ). applyc H'. *) Admitted. *) (* Lemma in_path_combine {state}: forall (R: relation state), forall s (p: path R s) s' (p': path R s') s'', in_path s' p -> in_path s'' p' -> in_path s'' p. Proof using. intros * Hin Hin'. induct Hin. - - apply in_tail. find eapplyc. find eapplyc. *) (* TODO: demorgans tactic which uses an extensible hint database for rewriting? *) Theorem AG_idempotent : forall s P, R @s ⊨ AG P ⟶ AG (AG P). Proof using. intros *. tintro H. tsimpl. intros * Hin * Hin'. etapply H. Admitted. (* De Morgan's Laws *) Theorem AF_EG : forall s P, R @s ⊨ AF (¬P) ⟶ ¬EG P. Proof using. intros *. tintros H Hcontra. tsimpl in *. destruct exists Hcontra p. specialize (H p). destruct exists H s'. destruct H; auto. Qed. Theorem AF_EG' : forall s P, R @s ⊨ ¬AF P ⟶ EG (¬P). Proof using. intros *. tintro H. tsimpl in *. overwrite H (not_all_ex_not _ _ H); simpl in H. destruct exists H p. exists p. intros s' Hin contra. overwrite H (not_ex_all_not _ _ H); simpl in H. enow eapply H. Qed. Theorem EG_AF : forall s P, R @s ⊨ EG (¬P) ⟶ ¬AF P. Proof using. intros *. tintros H Hcontra. tsimpl in *. destruct exists H p. specialize (Hcontra p). destruct exists Hcontra s'. destruct Hcontra. enow etapply H. Qed. Theorem EG_AF' : forall s P, R @s ⊨ ¬EG P ⟶ AF (¬P). Proof using. intros *. tintro H. tsimpl in *. intros p. overwrite H (not_ex_all_not _ _ H); simpl in H. specialize (H p). overwrite H (not_all_ex_not _ _ H); simpl in H. destruct exists H s'. exists s'. split. - enow eapply not_imply_elim. - enow eapply not_imply_elim2. Qed. Theorem rew_AF_EG : forall s P, (R @s ⊨ AF (¬P)) = (R @s ⊨ ¬EG P). Proof using. intros. apply textensionality. split. - tapply AF_EG. - tapply EG_AF'. Qed. Theorem rew_EG_AF : forall s P, (R @s ⊨ EG (¬P)) = (R @s ⊨ ¬AF P). Proof using. intros. apply textensionality. split. - tapply EG_AF. - tapply AF_EG'. Qed. Theorem AG_EF : forall s P, R @s ⊨ AG (¬P) ⟶ ¬EF P. Proof using. intros *. tintros H Hcontra. tsimpl in *. destruct exists Hcontra p s'. specialize (H p s'). now destruct H. Qed. Theorem AG_EF' : forall s P, R @s ⊨ ¬AG P ⟶ EF (¬P). Proof using. intros *. tintro H. tsimpl in *. overwrite H (not_all_ex_not _ _ H); simpl in H. destruct exists H p. overwrite H (not_all_ex_not _ _ H); simpl in H. destruct exists H s'. exists p s'. split. - enow eapply not_imply_elim. - enow eapply not_imply_elim2. Qed. Theorem EF_AG : forall s P, R @s ⊨ EF (¬P) ⟶ ¬AG P. Proof using. intros *. tintros H Hcontra. tsimpl in *. destruct exists H p s'. specialize (Hcontra p s'). destruct H as [H1 H2]. enow etapply H2. Qed. Theorem EF_AG' : forall s P, R @s ⊨ ¬EF P ⟶ AG (¬P). Proof using. intros *. tintro H. tsimpl in *. intros p s' Hin contra. overwrite H (not_ex_all_not _ _ H); simpl in H. specialize (H p). overwrite H (not_ex_all_not _ _ H); simpl in H. enow eapply H. Qed. Theorem rew_AG_EF : forall s P, (R @s ⊨ AG (¬P)) = (R @s ⊨ ¬EF P). Proof using. intros. apply textensionality. split. - tapply AG_EF. - tapply EF_AG'. Qed. Theorem rew_EF_AG : forall s P, (R @s ⊨ EF (¬P)) = (R @s ⊨ ¬AG P). Proof using. intros. apply textensionality. split. - tapply EF_AG. - tapply AG_EF'. Qed. Theorem AX_EX : forall s P, R @s ⊨ AX (¬P) ⟶ ¬EX P. Proof using. intros *. tintros H Hcontra. tsimpl in *. destruct exists Hcontra s'. specialize (H s'). destruct Hcontra. now apply H. Qed. Theorem AX_EX' : forall s P, R @s ⊨ ¬AX P ⟶ EX (¬P). Proof using. intros *. tintro H. tsimpl in *. overwrite H (not_all_ex_not _ _ H); simpl in H. destruct exists H s'. exists s'. split. - enow eapply not_imply_elim. - enow eapply not_imply_elim2. Qed. Theorem EX_AX : forall s P, R @s ⊨ EX (¬P) ⟶ ¬AX P. Proof using. intros *. tintros H Hcontra. tsimpl in *. destruct exists H s'. specialize (Hcontra s'). destruct H as [H1 H2]. enow etapply H2. Qed. Theorem EX_AX' : forall s P, R @s ⊨ ¬EX P ⟶ AX (¬P). Proof using. intros *. tintro H. tsimpl in *. intros s' Hin contra. overwrite H (not_ex_all_not _ _ H); simpl in H. specialize (H s'). enow eapply H. Qed. Theorem rew_AX_EX : forall s P, (R @s ⊨ AX (¬P)) = (R @s ⊨ ¬EX P). Proof using. intros. apply textensionality. split. - tapply AX_EX. - tapply EX_AX'. Qed. Theorem rew_EX_AX : forall s P, (R @s ⊨ EX (¬P)) = (R @s ⊨ ¬AX P). Proof using. intros. apply textensionality. split. - tapply EX_AX. - tapply AX_EX'. Qed. (* Expansion Laws *) Theorem expand_AG : forall s P, R @s ⊨ AG P ⟶ P ∧ AX (AG P). Proof. intros *. tintro H. rewrite rew_AG_star in H. split. - apply H. reflexivity. - unfold_AX. intros * Hstep. rewrite rew_AG_star. intros * Hstar. apply H. etransitivity; [|eassumption]. econstructor. + eassumption. + constructor. Qed. Theorem unexpand_AG : forall s P, R @s ⊨ P ∧ AX (AG P) ⟶ AG P. Proof. intros *. tintro H. destruct H as [H1 H2]. unfold_AX in H2. rewrite rew_AG_star. intros * Hstar. apply star_rt1n in Hstar. inv Hstar. - assumption. - specialize (H2 y H). rewrite rew_AG_star in H2. apply H2. now apply rt1n_star. Qed. Theorem rew_expand_AG : forall s P, (R @s ⊨ AG P) = (R @s ⊨ P ∧ AX (AG P)). Proof. intros *. apply textensionality. split. - tapply expand_AG. - tapply unexpand_AG. Qed. Close Scope tprop_scope. End Properties.
-- Andreas, 2017-07-29, issue and test case by Nisse {-# OPTIONS --profile=interactive #-} A : Set A = {!Set!} -- Give to provoke error -- This issue concerns the AgdaInfo buffer, -- the behavior on the command line might be different. -- ERROR WAS (note the "Total 0ms"): -- Set₁ != Set -- when checking that the expression Set has type SetTotal 0ms -- Expected: -- Set₁ != Set -- when checking that the expression Set has type Set -- Issue2602.out: -- ... -- ((last . 1) . (agda2-goals-action '(0))) -- (agda2-verbose "Total 0ms ") -- (agda2-info-action "*Error*" "1,1-4 Set₁ != Set when checking that the expression Set has type Set" nil) -- ...
(* This file is generated by Cogent and manually editted to provide a proper definition for heap_rel *) theory SumRandom_CorresSetup imports "CogentCRefinement.Deep_Embedding_Auto" "CogentCRefinement.Cogent_Corres" "CogentCRefinement.Tidy" "CogentCRefinement.Heap_Relation_Generation" "CogentCRefinement.Type_Relation_Generation" "../build_random_seed/Random_seed_master_ACInstall" "../build_random_seed/Random_seed_master_TypeProof" begin (* MANUAL addition: Abstract function environment *) (*NOTE: what's up with heap_rel generation? check that this is done correctly *) consts val_rel_Seed_C_body :: "(char list, abstyp, 32 word) uval \<Rightarrow> Seed_C \<Rightarrow> bool" instantiation Seed_C :: cogent_C_val begin definition type_rel_Seed_C_def: "\<And> typ. type_rel typ (_ :: Seed_C itself) \<equiv> (typ = RCon ''Seed'' [] )" definition val_rel_Seed_C_def: "\<And> uv x. val_rel uv (x :: Seed_C) \<equiv> val_rel_Seed_C_body uv x" instance .. end (* END of manual addition *) (* C type and value relations *) instantiation unit_t_C :: cogent_C_val begin definition type_rel_unit_t_C_def: "\<And> r. type_rel r (_ :: unit_t_C itself) \<equiv> r = RUnit" definition val_rel_unit_t_C_def: "\<And> uv. val_rel uv (_ :: unit_t_C) \<equiv> uv = UUnit" instance .. end instantiation bool_t_C :: cogent_C_val begin definition type_rel_bool_t_C_def: "\<And> typ. type_rel typ (_ :: bool_t_C itself) \<equiv> (typ = RPrim Bool)" definition val_rel_bool_t_C_def: "\<And> uv x. val_rel uv (x :: bool_t_C) \<equiv> (boolean_C x = 0 \<or> boolean_C x = 1) \<and> uv = UPrim (LBool (boolean_C x \<noteq> 0))" instance .. end (* MANUAL ADDITION *) (* instantiation Seed_C :: cogent_C_val begin definition type_rel_Seed_C_def: "\<And> typ. type_rel typ (_ :: Seed_C itself) \<equiv> (typ = RCon ''Seed'' [] )" definition val_rel_Seed_C_def: "\<And> uv x. val_rel uv (x :: Seed_C) \<equiv> uv = UAbstract a" instance .. end *) context update_sem_init begin lemmas corres_if = corres_if_base[where bool_val' = boolean_C, OF _ _ val_rel_bool_t_C_def[THEN meta_eq_to_obj_eq, THEN iffD1]] end (* C heap type class *) class cogent_C_heap = cogent_C_val + fixes is_valid :: "lifted_globals \<Rightarrow> 'a ptr \<Rightarrow> bool" fixes heap :: "lifted_globals \<Rightarrow> 'a ptr \<Rightarrow> 'a" local_setup \<open> local_setup_val_rel_type_rel_put_them_in_buckets "../build_random_seed/random_seed_master_pp_inferred.c" \<close> local_setup \<open> local_setup_instantiate_cogent_C_heaps_store_them_in_buckets "../build_random_seed/random_seed_master_pp_inferred.c" \<close> locale Random_seed_master = "random_seed_master_pp_inferred" + update_sem_init begin (* Relation between program heaps *) definition heap_rel_ptr :: "(funtyp, abstyp, ptrtyp) store \<Rightarrow> lifted_globals \<Rightarrow> ('a :: cogent_C_heap) ptr \<Rightarrow> bool" where "\<And> \<sigma> h p. heap_rel_ptr \<sigma> h p \<equiv> (\<forall> uv. \<sigma> (ptr_val p) = Some uv \<longrightarrow> type_rel (uval_repr uv) TYPE('a) \<longrightarrow> is_valid h p \<and> val_rel uv (heap h p))" lemma heap_rel_ptr_meta: "heap_rel_ptr = heap_rel_meta is_valid heap" by (simp add: heap_rel_ptr_def[abs_def] heap_rel_meta_def[abs_def]) local_setup \<open> local_setup_heap_rel "../build_random_seed/random_seed_master_pp_inferred.c" \<close> print_theorems definition state_rel :: "((funtyp, abstyp, ptrtyp) store \<times> lifted_globals) set" where "state_rel = {(\<sigma>, h). heap_rel \<sigma> h}" lemmas val_rel_simps[ValRelSimp] = val_rel_word val_rel_ptr_def val_rel_unit_def val_rel_unit_t_C_def val_rel_bool_t_C_def val_rel_fun_tag lemmas type_rel_simps[TypeRelSimp] = type_rel_word type_rel_ptr_def type_rel_unit_def type_rel_unit_t_C_def type_rel_bool_t_C_def (* Generating the specialised take and put lemmas *) local_setup \<open> local_setup_take_put_member_case_esac_specialised_lemmas "../build_random_seed/random_seed_master_pp_inferred.c" \<close> local_setup \<open> fold tidy_C_fun_def' Cogent_functions \<close> end (* of locale *) end
= = = = Protein disorder and <unk> prediction = = = =
lemma convex_hull_singleton[simp]: "convex hull {a} = {a}"
D = 2; % we consider a two-dimensional problem N = 100; % we will generate 100 observations %% Generate a random Covariance matrix tmp = randn(D); Sigma = tmp.' * tmp; %% Sample from the corresponding Gaussian X = mvnrnd(zeros(D, 1), Sigma, N); %% Estimate the leading component comp = grassmann_average(M, 1); % the second input is the number of component to estimate comp = trimmed_grassmann_average(M', 50, 1); show_2dvideo(comp,m,n); show_2dvideo(comp(:,1),m,n); show_2dvideo(comp(:,2),m,n); show_2dvideo(comp(:,3),m,n); show_2dvideo(comp(:,4),m,n); show_2dvideo(comp(:,5),m,n); %% Plot the results plot(X(:, 1), X(:, 2), 'ko', 'markerfacecolor', [255,153,51]./255); axis equal hold on plot(3*[-comp(1), comp(1)], 3*[-comp(2), comp(2)], 'k', 'linewidth', 2) hold off axis off
/- Copyright (c) 2019 Gabriel Ebner. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Gabriel Ebner, Sébastien Gouëzel -/ import analysis.calculus.fderiv import data.polynomial.derivative import linear_algebra.affine_space.slope /-! # One-dimensional derivatives This file defines the derivative of a function `f : 𝕜 → F` where `𝕜` is a normed field and `F` is a normed space over this field. The derivative of such a function `f` at a point `x` is given by an element `f' : F`. The theory is developed analogously to the [Fréchet derivatives](./fderiv.html). We first introduce predicates defined in terms of the corresponding predicates for Fréchet derivatives: - `has_deriv_at_filter f f' x L` states that the function `f` has the derivative `f'` at the point `x` as `x` goes along the filter `L`. - `has_deriv_within_at f f' s x` states that the function `f` has the derivative `f'` at the point `x` within the subset `s`. - `has_deriv_at f f' x` states that the function `f` has the derivative `f'` at the point `x`. - `has_strict_deriv_at f f' x` states that the function `f` has the derivative `f'` at the point `x` in the sense of strict differentiability, i.e., `f y - f z = (y - z) • f' + o (y - z)` as `y, z → x`. For the last two notions we also define a functional version: - `deriv_within f s x` is a derivative of `f` at `x` within `s`. If the derivative does not exist, then `deriv_within f s x` equals zero. - `deriv f x` is a derivative of `f` at `x`. If the derivative does not exist, then `deriv f x` equals zero. The theorems `fderiv_within_deriv_within` and `fderiv_deriv` show that the one-dimensional derivatives coincide with the general Fréchet derivatives. We also show the existence and compute the derivatives of: - constants - the identity function - linear maps - addition - sum of finitely many functions - negation - subtraction - multiplication - inverse `x → x⁻¹` - multiplication of two functions in `𝕜 → 𝕜` - multiplication of a function in `𝕜 → 𝕜` and of a function in `𝕜 → E` - composition of a function in `𝕜 → F` with a function in `𝕜 → 𝕜` - composition of a function in `F → E` with a function in `𝕜 → F` - inverse function (assuming that it exists; the inverse function theorem is in `inverse.lean`) - division - polynomials For most binary operations we also define `const_op` and `op_const` theorems for the cases when the first or second argument is a constant. This makes writing chains of `has_deriv_at`'s easier, and they more frequently lead to the desired result. We set up the simplifier so that it can compute the derivative of simple functions. For instance, ```lean example (x : ℝ) : deriv (λ x, cos (sin x) * exp x) x = (cos(sin(x))-sin(sin(x))*cos(x))*exp(x) := by { simp, ring } ``` ## Implementation notes Most of the theorems are direct restatements of the corresponding theorems for Fréchet derivatives. The strategy to construct simp lemmas that give the simplifier the possibility to compute derivatives is the same as the one for differentiability statements, as explained in `fderiv.lean`. See the explanations there. -/ universes u v w noncomputable theory open_locale classical topology big_operators filter ennreal polynomial open filter asymptotics set open continuous_linear_map (smul_right smul_right_one_eq_iff) variables {𝕜 : Type u} [nontrivially_normed_field 𝕜] section variables {F : Type v} [normed_add_comm_group F] [normed_space 𝕜 F] variables {E : Type w} [normed_add_comm_group E] [normed_space 𝕜 E] /-- `f` has the derivative `f'` at the point `x` as `x` goes along the filter `L`. That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges along the filter `L`. -/ def has_deriv_at_filter (f : 𝕜 → F) (f' : F) (x : 𝕜) (L : filter 𝕜) := has_fderiv_at_filter f (smul_right (1 : 𝕜 →L[𝕜] 𝕜) f') x L /-- `f` has the derivative `f'` at the point `x` within the subset `s`. That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges to `x` inside `s`. -/ def has_deriv_within_at (f : 𝕜 → F) (f' : F) (s : set 𝕜) (x : 𝕜) := has_deriv_at_filter f f' x (𝓝[s] x) /-- `f` has the derivative `f'` at the point `x`. That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges to `x`. -/ def has_deriv_at (f : 𝕜 → F) (f' : F) (x : 𝕜) := has_deriv_at_filter f f' x (𝓝 x) /-- `f` has the derivative `f'` at the point `x` in the sense of strict differentiability. That is, `f y - f z = (y - z) • f' + o(y - z)` as `y, z → x`. -/ def has_strict_deriv_at (f : 𝕜 → F) (f' : F) (x : 𝕜) := has_strict_fderiv_at f (smul_right (1 : 𝕜 →L[𝕜] 𝕜) f') x /-- Derivative of `f` at the point `x` within the set `s`, if it exists. Zero otherwise. If the derivative exists (i.e., `∃ f', has_deriv_within_at f f' s x`), then `f x' = f x + (x' - x) • deriv_within f s x + o(x' - x)` where `x'` converges to `x` inside `s`. -/ def deriv_within (f : 𝕜 → F) (s : set 𝕜) (x : 𝕜) := fderiv_within 𝕜 f s x 1 /-- Derivative of `f` at the point `x`, if it exists. Zero otherwise. If the derivative exists (i.e., `∃ f', has_deriv_at f f' x`), then `f x' = f x + (x' - x) • deriv f x + o(x' - x)` where `x'` converges to `x`. -/ def deriv (f : 𝕜 → F) (x : 𝕜) := fderiv 𝕜 f x 1 variables {f f₀ f₁ g : 𝕜 → F} variables {f' f₀' f₁' g' : F} variables {x : 𝕜} variables {s t : set 𝕜} variables {L L₁ L₂ : filter 𝕜} /-- Expressing `has_fderiv_at_filter f f' x L` in terms of `has_deriv_at_filter` -/ lemma has_fderiv_at_filter_iff_has_deriv_at_filter {f' : 𝕜 →L[𝕜] F} : has_fderiv_at_filter f f' x L ↔ has_deriv_at_filter f (f' 1) x L := by simp [has_deriv_at_filter] lemma has_fderiv_at_filter.has_deriv_at_filter {f' : 𝕜 →L[𝕜] F} : has_fderiv_at_filter f f' x L → has_deriv_at_filter f (f' 1) x L := has_fderiv_at_filter_iff_has_deriv_at_filter.mp /-- Expressing `has_fderiv_within_at f f' s x` in terms of `has_deriv_within_at` -/ lemma has_fderiv_within_at_iff_has_deriv_within_at {f' : 𝕜 →L[𝕜] F} : has_fderiv_within_at f f' s x ↔ has_deriv_within_at f (f' 1) s x := has_fderiv_at_filter_iff_has_deriv_at_filter /-- Expressing `has_deriv_within_at f f' s x` in terms of `has_fderiv_within_at` -/ lemma has_deriv_within_at_iff_has_fderiv_within_at {f' : F} : has_deriv_within_at f f' s x ↔ has_fderiv_within_at f (smul_right (1 : 𝕜 →L[𝕜] 𝕜) f') s x := iff.rfl lemma has_fderiv_within_at.has_deriv_within_at {f' : 𝕜 →L[𝕜] F} : has_fderiv_within_at f f' s x → has_deriv_within_at f (f' 1) s x := has_fderiv_within_at_iff_has_deriv_within_at.mp lemma has_deriv_within_at.has_fderiv_within_at {f' : F} : has_deriv_within_at f f' s x → has_fderiv_within_at f (smul_right (1 : 𝕜 →L[𝕜] 𝕜) f') s x := has_deriv_within_at_iff_has_fderiv_within_at.mp /-- Expressing `has_fderiv_at f f' x` in terms of `has_deriv_at` -/ lemma has_fderiv_at_iff_has_deriv_at {f' : 𝕜 →L[𝕜] F} : has_fderiv_at f f' x ↔ has_deriv_at f (f' 1) x := has_fderiv_at_filter_iff_has_deriv_at_filter lemma has_fderiv_at.has_deriv_at {f' : 𝕜 →L[𝕜] F} : has_fderiv_at f f' x → has_deriv_at f (f' 1) x := has_fderiv_at_iff_has_deriv_at.mp lemma has_strict_fderiv_at_iff_has_strict_deriv_at {f' : 𝕜 →L[𝕜] F} : has_strict_fderiv_at f f' x ↔ has_strict_deriv_at f (f' 1) x := by simp [has_strict_deriv_at, has_strict_fderiv_at] protected lemma has_strict_fderiv_at.has_strict_deriv_at {f' : 𝕜 →L[𝕜] F} : has_strict_fderiv_at f f' x → has_strict_deriv_at f (f' 1) x := has_strict_fderiv_at_iff_has_strict_deriv_at.mp lemma has_strict_deriv_at_iff_has_strict_fderiv_at : has_strict_deriv_at f f' x ↔ has_strict_fderiv_at f (smul_right (1 : 𝕜 →L[𝕜] 𝕜) f') x := iff.rfl alias has_strict_deriv_at_iff_has_strict_fderiv_at ↔ has_strict_deriv_at.has_strict_fderiv_at _ /-- Expressing `has_deriv_at f f' x` in terms of `has_fderiv_at` -/ lemma has_deriv_at_iff_has_fderiv_at {f' : F} : has_deriv_at f f' x ↔ has_fderiv_at f (smul_right (1 : 𝕜 →L[𝕜] 𝕜) f') x := iff.rfl alias has_deriv_at_iff_has_fderiv_at ↔ has_deriv_at.has_fderiv_at _ lemma deriv_within_zero_of_not_differentiable_within_at (h : ¬ differentiable_within_at 𝕜 f s x) : deriv_within f s x = 0 := by { unfold deriv_within, rw fderiv_within_zero_of_not_differentiable_within_at, simp, assumption } lemma differentiable_within_at_of_deriv_within_ne_zero (h : deriv_within f s x ≠ 0) : differentiable_within_at 𝕜 f s x := not_imp_comm.1 deriv_within_zero_of_not_differentiable_within_at h lemma deriv_zero_of_not_differentiable_at (h : ¬ differentiable_at 𝕜 f x) : deriv f x = 0 := by { unfold deriv, rw fderiv_zero_of_not_differentiable_at, simp, assumption } lemma differentiable_at_of_deriv_ne_zero (h : deriv f x ≠ 0) : differentiable_at 𝕜 f x := not_imp_comm.1 deriv_zero_of_not_differentiable_at h theorem unique_diff_within_at.eq_deriv (s : set 𝕜) (H : unique_diff_within_at 𝕜 s x) (h : has_deriv_within_at f f' s x) (h₁ : has_deriv_within_at f f₁' s x) : f' = f₁' := smul_right_one_eq_iff.mp $ unique_diff_within_at.eq H h h₁ theorem has_deriv_at_filter_iff_is_o : has_deriv_at_filter f f' x L ↔ (λ x' : 𝕜, f x' - f x - (x' - x) • f') =o[L] (λ x', x' - x) := iff.rfl theorem has_deriv_at_filter_iff_tendsto : has_deriv_at_filter f f' x L ↔ tendsto (λ x' : 𝕜, ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) L (𝓝 0) := has_fderiv_at_filter_iff_tendsto theorem has_deriv_within_at_iff_is_o : has_deriv_within_at f f' s x ↔ (λ x' : 𝕜, f x' - f x - (x' - x) • f') =o[𝓝[s] x] (λ x', x' - x) := iff.rfl theorem has_deriv_within_at_iff_tendsto : has_deriv_within_at f f' s x ↔ tendsto (λ x', ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) (𝓝[s] x) (𝓝 0) := has_fderiv_at_filter_iff_tendsto theorem has_deriv_at_iff_is_o : has_deriv_at f f' x ↔ (λ x' : 𝕜, f x' - f x - (x' - x) • f') =o[𝓝 x] (λ x', x' - x) := iff.rfl theorem has_deriv_at_iff_tendsto : has_deriv_at f f' x ↔ tendsto (λ x', ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) (𝓝 x) (𝓝 0) := has_fderiv_at_filter_iff_tendsto theorem has_strict_deriv_at.has_deriv_at (h : has_strict_deriv_at f f' x) : has_deriv_at f f' x := h.has_fderiv_at /-- If the domain has dimension one, then Fréchet derivative is equivalent to the classical definition with a limit. In this version we have to take the limit along the subset `-{x}`, because for `y=x` the slope equals zero due to the convention `0⁻¹=0`. -/ lemma has_deriv_at_filter_iff_tendsto_slope {x : 𝕜} {L : filter 𝕜} : has_deriv_at_filter f f' x L ↔ tendsto (slope f x) (L ⊓ 𝓟 {x}ᶜ) (𝓝 f') := begin conv_lhs { simp only [has_deriv_at_filter_iff_tendsto, (norm_inv _).symm, (norm_smul _ _).symm, tendsto_zero_iff_norm_tendsto_zero.symm] }, conv_rhs { rw [← nhds_translation_sub f', tendsto_comap_iff] }, refine (tendsto_inf_principal_nhds_iff_of_forall_eq $ by simp).symm.trans (tendsto_congr' _), refine (eventually_principal.2 $ λ z hz, _).filter_mono inf_le_right, simp only [(∘)], rw [smul_sub, ← mul_smul, inv_mul_cancel (sub_ne_zero.2 hz), one_smul, slope_def_module] end lemma has_deriv_within_at_iff_tendsto_slope : has_deriv_within_at f f' s x ↔ tendsto (slope f x) (𝓝[s \ {x}] x) (𝓝 f') := begin simp only [has_deriv_within_at, nhds_within, diff_eq, inf_assoc.symm, inf_principal.symm], exact has_deriv_at_filter_iff_tendsto_slope end lemma has_deriv_within_at_iff_tendsto_slope' (hs : x ∉ s) : has_deriv_within_at f f' s x ↔ tendsto (slope f x) (𝓝[s] x) (𝓝 f') := begin convert ← has_deriv_within_at_iff_tendsto_slope, exact diff_singleton_eq_self hs end lemma has_deriv_at_iff_tendsto_slope : has_deriv_at f f' x ↔ tendsto (slope f x) (𝓝[≠] x) (𝓝 f') := has_deriv_at_filter_iff_tendsto_slope theorem has_deriv_within_at_congr_set {s t u : set 𝕜} (hu : u ∈ 𝓝 x) (h : s ∩ u = t ∩ u) : has_deriv_within_at f f' s x ↔ has_deriv_within_at f f' t x := by simp_rw [has_deriv_within_at, nhds_within_eq_nhds_within' hu h] alias has_deriv_within_at_congr_set ↔ has_deriv_within_at.congr_set _ @[simp] lemma has_deriv_within_at_diff_singleton : has_deriv_within_at f f' (s \ {x}) x ↔ has_deriv_within_at f f' s x := by simp only [has_deriv_within_at_iff_tendsto_slope, sdiff_idem] @[simp] lemma has_deriv_within_at_Ioi_iff_Ici [partial_order 𝕜] : has_deriv_within_at f f' (Ioi x) x ↔ has_deriv_within_at f f' (Ici x) x := by rw [← Ici_diff_left, has_deriv_within_at_diff_singleton] alias has_deriv_within_at_Ioi_iff_Ici ↔ has_deriv_within_at.Ici_of_Ioi has_deriv_within_at.Ioi_of_Ici @[simp] lemma has_deriv_within_at_Iio_iff_Iic [partial_order 𝕜] : has_deriv_within_at f f' (Iio x) x ↔ has_deriv_within_at f f' (Iic x) x := by rw [← Iic_diff_right, has_deriv_within_at_diff_singleton] alias has_deriv_within_at_Iio_iff_Iic ↔ has_deriv_within_at.Iic_of_Iio has_deriv_within_at.Iio_of_Iic theorem has_deriv_within_at.Ioi_iff_Ioo [linear_order 𝕜] [order_closed_topology 𝕜] {x y : 𝕜} (h : x < y) : has_deriv_within_at f f' (Ioo x y) x ↔ has_deriv_within_at f f' (Ioi x) x := has_deriv_within_at_congr_set (is_open_Iio.mem_nhds h) $ by { rw [Ioi_inter_Iio, inter_eq_left_iff_subset], exact Ioo_subset_Iio_self } alias has_deriv_within_at.Ioi_iff_Ioo ↔ has_deriv_within_at.Ioi_of_Ioo has_deriv_within_at.Ioo_of_Ioi theorem has_deriv_at_iff_is_o_nhds_zero : has_deriv_at f f' x ↔ (λh, f (x + h) - f x - h • f') =o[𝓝 0] (λh, h) := has_fderiv_at_iff_is_o_nhds_zero theorem has_deriv_at_filter.mono (h : has_deriv_at_filter f f' x L₂) (hst : L₁ ≤ L₂) : has_deriv_at_filter f f' x L₁ := has_fderiv_at_filter.mono h hst theorem has_deriv_within_at.mono (h : has_deriv_within_at f f' t x) (hst : s ⊆ t) : has_deriv_within_at f f' s x := has_fderiv_within_at.mono h hst theorem has_deriv_at.has_deriv_at_filter (h : has_deriv_at f f' x) (hL : L ≤ 𝓝 x) : has_deriv_at_filter f f' x L := has_fderiv_at.has_fderiv_at_filter h hL theorem has_deriv_at.has_deriv_within_at (h : has_deriv_at f f' x) : has_deriv_within_at f f' s x := has_fderiv_at.has_fderiv_within_at h lemma has_deriv_within_at.differentiable_within_at (h : has_deriv_within_at f f' s x) : differentiable_within_at 𝕜 f s x := has_fderiv_within_at.differentiable_within_at h lemma has_deriv_at.differentiable_at (h : has_deriv_at f f' x) : differentiable_at 𝕜 f x := has_fderiv_at.differentiable_at h @[simp] lemma has_deriv_within_at_univ : has_deriv_within_at f f' univ x ↔ has_deriv_at f f' x := has_fderiv_within_at_univ theorem has_deriv_at.unique (h₀ : has_deriv_at f f₀' x) (h₁ : has_deriv_at f f₁' x) : f₀' = f₁' := smul_right_one_eq_iff.mp $ h₀.has_fderiv_at.unique h₁ lemma has_deriv_within_at_inter' (h : t ∈ 𝓝[s] x) : has_deriv_within_at f f' (s ∩ t) x ↔ has_deriv_within_at f f' s x := has_fderiv_within_at_inter' h lemma has_deriv_within_at_inter (h : t ∈ 𝓝 x) : has_deriv_within_at f f' (s ∩ t) x ↔ has_deriv_within_at f f' s x := has_fderiv_within_at_inter h lemma has_deriv_within_at.union (hs : has_deriv_within_at f f' s x) (ht : has_deriv_within_at f f' t x) : has_deriv_within_at f f' (s ∪ t) x := hs.has_fderiv_within_at.union ht.has_fderiv_within_at lemma has_deriv_within_at.nhds_within (h : has_deriv_within_at f f' s x) (ht : s ∈ 𝓝[t] x) : has_deriv_within_at f f' t x := (has_deriv_within_at_inter' ht).1 (h.mono (inter_subset_right _ _)) lemma has_deriv_within_at.has_deriv_at (h : has_deriv_within_at f f' s x) (hs : s ∈ 𝓝 x) : has_deriv_at f f' x := has_fderiv_within_at.has_fderiv_at h hs lemma differentiable_within_at.has_deriv_within_at (h : differentiable_within_at 𝕜 f s x) : has_deriv_within_at f (deriv_within f s x) s x := h.has_fderiv_within_at.has_deriv_within_at lemma differentiable_at.has_deriv_at (h : differentiable_at 𝕜 f x) : has_deriv_at f (deriv f x) x := h.has_fderiv_at.has_deriv_at @[simp] lemma has_deriv_at_deriv_iff : has_deriv_at f (deriv f x) x ↔ differentiable_at 𝕜 f x := ⟨λ h, h.differentiable_at, λ h, h.has_deriv_at⟩ @[simp] lemma has_deriv_within_at_deriv_within_iff : has_deriv_within_at f (deriv_within f s x) s x ↔ differentiable_within_at 𝕜 f s x := ⟨λ h, h.differentiable_within_at, λ h, h.has_deriv_within_at⟩ lemma differentiable_on.has_deriv_at (h : differentiable_on 𝕜 f s) (hs : s ∈ 𝓝 x) : has_deriv_at f (deriv f x) x := (h.has_fderiv_at hs).has_deriv_at lemma has_deriv_at.deriv (h : has_deriv_at f f' x) : deriv f x = f' := h.differentiable_at.has_deriv_at.unique h lemma deriv_eq {f' : 𝕜 → F} (h : ∀ x, has_deriv_at f (f' x) x) : deriv f = f' := funext $ λ x, (h x).deriv lemma has_deriv_within_at.deriv_within (h : has_deriv_within_at f f' s x) (hxs : unique_diff_within_at 𝕜 s x) : deriv_within f s x = f' := hxs.eq_deriv _ h.differentiable_within_at.has_deriv_within_at h lemma fderiv_within_deriv_within : (fderiv_within 𝕜 f s x : 𝕜 → F) 1 = deriv_within f s x := rfl lemma deriv_within_fderiv_within : smul_right (1 : 𝕜 →L[𝕜] 𝕜) (deriv_within f s x) = fderiv_within 𝕜 f s x := by simp [deriv_within] lemma fderiv_deriv : (fderiv 𝕜 f x : 𝕜 → F) 1 = deriv f x := rfl lemma deriv_fderiv : smul_right (1 : 𝕜 →L[𝕜] 𝕜) (deriv f x) = fderiv 𝕜 f x := by simp [deriv] lemma differentiable_at.deriv_within (h : differentiable_at 𝕜 f x) (hxs : unique_diff_within_at 𝕜 s x) : deriv_within f s x = deriv f x := by { unfold deriv_within deriv, rw h.fderiv_within hxs } theorem has_deriv_within_at.deriv_eq_zero (hd : has_deriv_within_at f 0 s x) (H : unique_diff_within_at 𝕜 s x) : deriv f x = 0 := (em' (differentiable_at 𝕜 f x)).elim deriv_zero_of_not_differentiable_at $ λ h, H.eq_deriv _ h.has_deriv_at.has_deriv_within_at hd lemma deriv_within_subset (st : s ⊆ t) (ht : unique_diff_within_at 𝕜 s x) (h : differentiable_within_at 𝕜 f t x) : deriv_within f s x = deriv_within f t x := ((differentiable_within_at.has_deriv_within_at h).mono st).deriv_within ht @[simp] lemma deriv_within_univ : deriv_within f univ = deriv f := by { ext, unfold deriv_within deriv, rw fderiv_within_univ } lemma deriv_within_inter (ht : t ∈ 𝓝 x) (hs : unique_diff_within_at 𝕜 s x) : deriv_within f (s ∩ t) x = deriv_within f s x := by { unfold deriv_within, rw fderiv_within_inter ht hs } lemma deriv_within_of_open (hs : is_open s) (hx : x ∈ s) : deriv_within f s x = deriv f x := by { unfold deriv_within, rw fderiv_within_of_open hs hx, refl } lemma deriv_mem_iff {f : 𝕜 → F} {s : set F} {x : 𝕜} : deriv f x ∈ s ↔ (differentiable_at 𝕜 f x ∧ deriv f x ∈ s) ∨ (¬differentiable_at 𝕜 f x ∧ (0 : F) ∈ s) := by by_cases hx : differentiable_at 𝕜 f x; simp [deriv_zero_of_not_differentiable_at, *] lemma deriv_within_mem_iff {f : 𝕜 → F} {t : set 𝕜} {s : set F} {x : 𝕜} : deriv_within f t x ∈ s ↔ (differentiable_within_at 𝕜 f t x ∧ deriv_within f t x ∈ s) ∨ (¬differentiable_within_at 𝕜 f t x ∧ (0 : F) ∈ s) := by by_cases hx : differentiable_within_at 𝕜 f t x; simp [deriv_within_zero_of_not_differentiable_within_at, *] lemma differentiable_within_at_Ioi_iff_Ici [partial_order 𝕜] : differentiable_within_at 𝕜 f (Ioi x) x ↔ differentiable_within_at 𝕜 f (Ici x) x := ⟨λ h, h.has_deriv_within_at.Ici_of_Ioi.differentiable_within_at, λ h, h.has_deriv_within_at.Ioi_of_Ici.differentiable_within_at⟩ lemma deriv_within_Ioi_eq_Ici {E : Type*} [normed_add_comm_group E] [normed_space ℝ E] (f : ℝ → E) (x : ℝ) : deriv_within f (Ioi x) x = deriv_within f (Ici x) x := begin by_cases H : differentiable_within_at ℝ f (Ioi x) x, { have A := H.has_deriv_within_at.Ici_of_Ioi, have B := (differentiable_within_at_Ioi_iff_Ici.1 H).has_deriv_within_at, simpa using (unique_diff_on_Ici x).eq le_rfl A B }, { rw [deriv_within_zero_of_not_differentiable_within_at H, deriv_within_zero_of_not_differentiable_within_at], rwa differentiable_within_at_Ioi_iff_Ici at H } end section congr /-! ### Congruence properties of derivatives -/ theorem filter.eventually_eq.has_deriv_at_filter_iff (h₀ : f₀ =ᶠ[L] f₁) (hx : f₀ x = f₁ x) (h₁ : f₀' = f₁') : has_deriv_at_filter f₀ f₀' x L ↔ has_deriv_at_filter f₁ f₁' x L := h₀.has_fderiv_at_filter_iff hx (by simp [h₁]) lemma has_deriv_at_filter.congr_of_eventually_eq (h : has_deriv_at_filter f f' x L) (hL : f₁ =ᶠ[L] f) (hx : f₁ x = f x) : has_deriv_at_filter f₁ f' x L := by rwa hL.has_deriv_at_filter_iff hx rfl lemma has_deriv_within_at.congr_mono (h : has_deriv_within_at f f' s x) (ht : ∀x ∈ t, f₁ x = f x) (hx : f₁ x = f x) (h₁ : t ⊆ s) : has_deriv_within_at f₁ f' t x := has_fderiv_within_at.congr_mono h ht hx h₁ lemma has_deriv_within_at.congr (h : has_deriv_within_at f f' s x) (hs : ∀x ∈ s, f₁ x = f x) (hx : f₁ x = f x) : has_deriv_within_at f₁ f' s x := h.congr_mono hs hx (subset.refl _) lemma has_deriv_within_at.congr_of_mem (h : has_deriv_within_at f f' s x) (hs : ∀x ∈ s, f₁ x = f x) (hx : x ∈ s) : has_deriv_within_at f₁ f' s x := h.congr hs (hs _ hx) lemma has_deriv_within_at.congr_of_eventually_eq (h : has_deriv_within_at f f' s x) (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : has_deriv_within_at f₁ f' s x := has_deriv_at_filter.congr_of_eventually_eq h h₁ hx lemma has_deriv_within_at.congr_of_eventually_eq_of_mem (h : has_deriv_within_at f f' s x) (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : x ∈ s) : has_deriv_within_at f₁ f' s x := h.congr_of_eventually_eq h₁ (h₁.eq_of_nhds_within hx) lemma has_deriv_at.congr_of_eventually_eq (h : has_deriv_at f f' x) (h₁ : f₁ =ᶠ[𝓝 x] f) : has_deriv_at f₁ f' x := has_deriv_at_filter.congr_of_eventually_eq h h₁ (mem_of_mem_nhds h₁ : _) lemma filter.eventually_eq.deriv_within_eq (hs : unique_diff_within_at 𝕜 s x) (hL : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : deriv_within f₁ s x = deriv_within f s x := by { unfold deriv_within, rw hL.fderiv_within_eq hs hx } lemma deriv_within_congr (hs : unique_diff_within_at 𝕜 s x) (hL : ∀y∈s, f₁ y = f y) (hx : f₁ x = f x) : deriv_within f₁ s x = deriv_within f s x := by { unfold deriv_within, rw fderiv_within_congr hs hL hx } lemma filter.eventually_eq.deriv_eq (hL : f₁ =ᶠ[𝓝 x] f) : deriv f₁ x = deriv f x := by { unfold deriv, rwa filter.eventually_eq.fderiv_eq } protected lemma filter.eventually_eq.deriv (h : f₁ =ᶠ[𝓝 x] f) : deriv f₁ =ᶠ[𝓝 x] deriv f := h.eventually_eq_nhds.mono $ λ x h, h.deriv_eq end congr section id /-! ### Derivative of the identity -/ variables (s x L) theorem has_deriv_at_filter_id : has_deriv_at_filter id 1 x L := (has_fderiv_at_filter_id x L).has_deriv_at_filter theorem has_deriv_within_at_id : has_deriv_within_at id 1 s x := has_deriv_at_filter_id _ _ theorem has_deriv_at_id : has_deriv_at id 1 x := has_deriv_at_filter_id _ _ theorem has_deriv_at_id' : has_deriv_at (λ (x : 𝕜), x) 1 x := has_deriv_at_filter_id _ _ theorem has_strict_deriv_at_id : has_strict_deriv_at id 1 x := (has_strict_fderiv_at_id x).has_strict_deriv_at lemma deriv_id : deriv id x = 1 := has_deriv_at.deriv (has_deriv_at_id x) @[simp] lemma deriv_id' : deriv (@id 𝕜) = λ _, 1 := funext deriv_id @[simp] lemma deriv_id'' : deriv (λ x : 𝕜, x) = λ _, 1 := deriv_id' lemma deriv_within_id (hxs : unique_diff_within_at 𝕜 s x) : deriv_within id s x = 1 := (has_deriv_within_at_id x s).deriv_within hxs end id section const /-! ### Derivative of constant functions -/ variables (c : F) (s x L) theorem has_deriv_at_filter_const : has_deriv_at_filter (λ x, c) 0 x L := (has_fderiv_at_filter_const c x L).has_deriv_at_filter theorem has_strict_deriv_at_const : has_strict_deriv_at (λ x, c) 0 x := (has_strict_fderiv_at_const c x).has_strict_deriv_at theorem has_deriv_within_at_const : has_deriv_within_at (λ x, c) 0 s x := has_deriv_at_filter_const _ _ _ theorem has_deriv_at_const : has_deriv_at (λ x, c) 0 x := has_deriv_at_filter_const _ _ _ lemma deriv_const : deriv (λ x, c) x = 0 := has_deriv_at.deriv (has_deriv_at_const x c) @[simp] lemma deriv_const' : deriv (λ x:𝕜, c) = λ x, 0 := funext (λ x, deriv_const x c) lemma deriv_within_const (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (λ x, c) s x = 0 := (has_deriv_within_at_const _ _ _).deriv_within hxs end const section continuous_linear_map /-! ### Derivative of continuous linear maps -/ variables (e : 𝕜 →L[𝕜] F) protected lemma continuous_linear_map.has_deriv_at_filter : has_deriv_at_filter e (e 1) x L := e.has_fderiv_at_filter.has_deriv_at_filter protected lemma continuous_linear_map.has_strict_deriv_at : has_strict_deriv_at e (e 1) x := e.has_strict_fderiv_at.has_strict_deriv_at protected lemma continuous_linear_map.has_deriv_at : has_deriv_at e (e 1) x := e.has_deriv_at_filter protected lemma continuous_linear_map.has_deriv_within_at : has_deriv_within_at e (e 1) s x := e.has_deriv_at_filter @[simp] protected lemma continuous_linear_map.deriv : deriv e x = e 1 := e.has_deriv_at.deriv protected lemma continuous_linear_map.deriv_within (hxs : unique_diff_within_at 𝕜 s x) : deriv_within e s x = e 1 := e.has_deriv_within_at.deriv_within hxs end continuous_linear_map section linear_map /-! ### Derivative of bundled linear maps -/ variables (e : 𝕜 →ₗ[𝕜] F) protected lemma linear_map.has_deriv_at_filter : has_deriv_at_filter e (e 1) x L := e.to_continuous_linear_map₁.has_deriv_at_filter protected lemma linear_map.has_strict_deriv_at : has_strict_deriv_at e (e 1) x := e.to_continuous_linear_map₁.has_strict_deriv_at protected lemma linear_map.has_deriv_at : has_deriv_at e (e 1) x := e.has_deriv_at_filter protected lemma linear_map.has_deriv_within_at : has_deriv_within_at e (e 1) s x := e.has_deriv_at_filter @[simp] protected lemma linear_map.deriv : deriv e x = e 1 := e.has_deriv_at.deriv protected lemma linear_map.deriv_within (hxs : unique_diff_within_at 𝕜 s x) : deriv_within e s x = e 1 := e.has_deriv_within_at.deriv_within hxs end linear_map section add /-! ### Derivative of the sum of two functions -/ theorem has_deriv_at_filter.add (hf : has_deriv_at_filter f f' x L) (hg : has_deriv_at_filter g g' x L) : has_deriv_at_filter (λ y, f y + g y) (f' + g') x L := by simpa using (hf.add hg).has_deriv_at_filter theorem has_strict_deriv_at.add (hf : has_strict_deriv_at f f' x) (hg : has_strict_deriv_at g g' x) : has_strict_deriv_at (λ y, f y + g y) (f' + g') x := by simpa using (hf.add hg).has_strict_deriv_at theorem has_deriv_within_at.add (hf : has_deriv_within_at f f' s x) (hg : has_deriv_within_at g g' s x) : has_deriv_within_at (λ y, f y + g y) (f' + g') s x := hf.add hg theorem has_deriv_at.add (hf : has_deriv_at f f' x) (hg : has_deriv_at g g' x) : has_deriv_at (λ x, f x + g x) (f' + g') x := hf.add hg lemma deriv_within_add (hxs : unique_diff_within_at 𝕜 s x) (hf : differentiable_within_at 𝕜 f s x) (hg : differentiable_within_at 𝕜 g s x) : deriv_within (λy, f y + g y) s x = deriv_within f s x + deriv_within g s x := (hf.has_deriv_within_at.add hg.has_deriv_within_at).deriv_within hxs @[simp] lemma deriv_add (hf : differentiable_at 𝕜 f x) (hg : differentiable_at 𝕜 g x) : deriv (λy, f y + g y) x = deriv f x + deriv g x := (hf.has_deriv_at.add hg.has_deriv_at).deriv theorem has_deriv_at_filter.add_const (hf : has_deriv_at_filter f f' x L) (c : F) : has_deriv_at_filter (λ y, f y + c) f' x L := add_zero f' ▸ hf.add (has_deriv_at_filter_const x L c) theorem has_deriv_within_at.add_const (hf : has_deriv_within_at f f' s x) (c : F) : has_deriv_within_at (λ y, f y + c) f' s x := hf.add_const c theorem has_deriv_at.add_const (hf : has_deriv_at f f' x) (c : F) : has_deriv_at (λ x, f x + c) f' x := hf.add_const c lemma deriv_within_add_const (hxs : unique_diff_within_at 𝕜 s x) (c : F) : deriv_within (λy, f y + c) s x = deriv_within f s x := by simp only [deriv_within, fderiv_within_add_const hxs] lemma deriv_add_const (c : F) : deriv (λy, f y + c) x = deriv f x := by simp only [deriv, fderiv_add_const] @[simp] lemma deriv_add_const' (c : F) : deriv (λ y, f y + c) = deriv f := funext $ λ x, deriv_add_const c theorem has_deriv_at_filter.const_add (c : F) (hf : has_deriv_at_filter f f' x L) : has_deriv_at_filter (λ y, c + f y) f' x L := zero_add f' ▸ (has_deriv_at_filter_const x L c).add hf theorem has_deriv_within_at.const_add (c : F) (hf : has_deriv_within_at f f' s x) : has_deriv_within_at (λ y, c + f y) f' s x := hf.const_add c theorem has_deriv_at.const_add (c : F) (hf : has_deriv_at f f' x) : has_deriv_at (λ x, c + f x) f' x := hf.const_add c lemma deriv_within_const_add (hxs : unique_diff_within_at 𝕜 s x) (c : F) : deriv_within (λy, c + f y) s x = deriv_within f s x := by simp only [deriv_within, fderiv_within_const_add hxs] lemma deriv_const_add (c : F) : deriv (λy, c + f y) x = deriv f x := by simp only [deriv, fderiv_const_add] @[simp] lemma deriv_const_add' (c : F) : deriv (λ y, c + f y) = deriv f := funext $ λ x, deriv_const_add c end add section sum /-! ### Derivative of a finite sum of functions -/ open_locale big_operators variables {ι : Type*} {u : finset ι} {A : ι → (𝕜 → F)} {A' : ι → F} theorem has_deriv_at_filter.sum (h : ∀ i ∈ u, has_deriv_at_filter (A i) (A' i) x L) : has_deriv_at_filter (λ y, ∑ i in u, A i y) (∑ i in u, A' i) x L := by simpa [continuous_linear_map.sum_apply] using (has_fderiv_at_filter.sum h).has_deriv_at_filter theorem has_strict_deriv_at.sum (h : ∀ i ∈ u, has_strict_deriv_at (A i) (A' i) x) : has_strict_deriv_at (λ y, ∑ i in u, A i y) (∑ i in u, A' i) x := by simpa [continuous_linear_map.sum_apply] using (has_strict_fderiv_at.sum h).has_strict_deriv_at theorem has_deriv_within_at.sum (h : ∀ i ∈ u, has_deriv_within_at (A i) (A' i) s x) : has_deriv_within_at (λ y, ∑ i in u, A i y) (∑ i in u, A' i) s x := has_deriv_at_filter.sum h theorem has_deriv_at.sum (h : ∀ i ∈ u, has_deriv_at (A i) (A' i) x) : has_deriv_at (λ y, ∑ i in u, A i y) (∑ i in u, A' i) x := has_deriv_at_filter.sum h lemma deriv_within_sum (hxs : unique_diff_within_at 𝕜 s x) (h : ∀ i ∈ u, differentiable_within_at 𝕜 (A i) s x) : deriv_within (λ y, ∑ i in u, A i y) s x = ∑ i in u, deriv_within (A i) s x := (has_deriv_within_at.sum (λ i hi, (h i hi).has_deriv_within_at)).deriv_within hxs @[simp] lemma deriv_sum (h : ∀ i ∈ u, differentiable_at 𝕜 (A i) x) : deriv (λ y, ∑ i in u, A i y) x = ∑ i in u, deriv (A i) x := (has_deriv_at.sum (λ i hi, (h i hi).has_deriv_at)).deriv end sum section pi /-! ### Derivatives of functions `f : 𝕜 → Π i, E i` -/ variables {ι : Type*} [fintype ι] {E' : ι → Type*} [Π i, normed_add_comm_group (E' i)] [Π i, normed_space 𝕜 (E' i)] {φ : 𝕜 → Π i, E' i} {φ' : Π i, E' i} @[simp] lemma has_strict_deriv_at_pi : has_strict_deriv_at φ φ' x ↔ ∀ i, has_strict_deriv_at (λ x, φ x i) (φ' i) x := has_strict_fderiv_at_pi' @[simp] lemma has_deriv_at_filter_pi : has_deriv_at_filter φ φ' x L ↔ ∀ i, has_deriv_at_filter (λ x, φ x i) (φ' i) x L := has_fderiv_at_filter_pi' lemma has_deriv_at_pi : has_deriv_at φ φ' x ↔ ∀ i, has_deriv_at (λ x, φ x i) (φ' i) x:= has_deriv_at_filter_pi lemma has_deriv_within_at_pi : has_deriv_within_at φ φ' s x ↔ ∀ i, has_deriv_within_at (λ x, φ x i) (φ' i) s x:= has_deriv_at_filter_pi lemma deriv_within_pi (h : ∀ i, differentiable_within_at 𝕜 (λ x, φ x i) s x) (hs : unique_diff_within_at 𝕜 s x) : deriv_within φ s x = λ i, deriv_within (λ x, φ x i) s x := (has_deriv_within_at_pi.2 (λ i, (h i).has_deriv_within_at)).deriv_within hs lemma deriv_pi (h : ∀ i, differentiable_at 𝕜 (λ x, φ x i) x) : deriv φ x = λ i, deriv (λ x, φ x i) x := (has_deriv_at_pi.2 (λ i, (h i).has_deriv_at)).deriv end pi section smul /-! ### Derivative of the multiplication of a scalar function and a vector function -/ variables {𝕜' : Type*} [nontrivially_normed_field 𝕜'] [normed_algebra 𝕜 𝕜'] [normed_space 𝕜' F] [is_scalar_tower 𝕜 𝕜' F] {c : 𝕜 → 𝕜'} {c' : 𝕜'} theorem has_deriv_within_at.smul (hc : has_deriv_within_at c c' s x) (hf : has_deriv_within_at f f' s x) : has_deriv_within_at (λ y, c y • f y) (c x • f' + c' • f x) s x := by simpa using (has_fderiv_within_at.smul hc hf).has_deriv_within_at theorem has_deriv_at.smul (hc : has_deriv_at c c' x) (hf : has_deriv_at f f' x) : has_deriv_at (λ y, c y • f y) (c x • f' + c' • f x) x := begin rw [← has_deriv_within_at_univ] at *, exact hc.smul hf end theorem has_strict_deriv_at.smul (hc : has_strict_deriv_at c c' x) (hf : has_strict_deriv_at f f' x) : has_strict_deriv_at (λ y, c y • f y) (c x • f' + c' • f x) x := by simpa using (hc.smul hf).has_strict_deriv_at lemma deriv_within_smul (hxs : unique_diff_within_at 𝕜 s x) (hc : differentiable_within_at 𝕜 c s x) (hf : differentiable_within_at 𝕜 f s x) : deriv_within (λ y, c y • f y) s x = c x • deriv_within f s x + (deriv_within c s x) • f x := (hc.has_deriv_within_at.smul hf.has_deriv_within_at).deriv_within hxs lemma deriv_smul (hc : differentiable_at 𝕜 c x) (hf : differentiable_at 𝕜 f x) : deriv (λ y, c y • f y) x = c x • deriv f x + (deriv c x) • f x := (hc.has_deriv_at.smul hf.has_deriv_at).deriv theorem has_strict_deriv_at.smul_const (hc : has_strict_deriv_at c c' x) (f : F) : has_strict_deriv_at (λ y, c y • f) (c' • f) x := begin have := hc.smul (has_strict_deriv_at_const x f), rwa [smul_zero, zero_add] at this, end theorem has_deriv_within_at.smul_const (hc : has_deriv_within_at c c' s x) (f : F) : has_deriv_within_at (λ y, c y • f) (c' • f) s x := begin have := hc.smul (has_deriv_within_at_const x s f), rwa [smul_zero, zero_add] at this end theorem has_deriv_at.smul_const (hc : has_deriv_at c c' x) (f : F) : has_deriv_at (λ y, c y • f) (c' • f) x := begin rw [← has_deriv_within_at_univ] at *, exact hc.smul_const f end lemma deriv_within_smul_const (hxs : unique_diff_within_at 𝕜 s x) (hc : differentiable_within_at 𝕜 c s x) (f : F) : deriv_within (λ y, c y • f) s x = (deriv_within c s x) • f := (hc.has_deriv_within_at.smul_const f).deriv_within hxs lemma deriv_smul_const (hc : differentiable_at 𝕜 c x) (f : F) : deriv (λ y, c y • f) x = (deriv c x) • f := (hc.has_deriv_at.smul_const f).deriv end smul section const_smul variables {R : Type*} [semiring R] [module R F] [smul_comm_class 𝕜 R F] [has_continuous_const_smul R F] theorem has_strict_deriv_at.const_smul (c : R) (hf : has_strict_deriv_at f f' x) : has_strict_deriv_at (λ y, c • f y) (c • f') x := by simpa using (hf.const_smul c).has_strict_deriv_at theorem has_deriv_at_filter.const_smul (c : R) (hf : has_deriv_at_filter f f' x L) : has_deriv_at_filter (λ y, c • f y) (c • f') x L := by simpa using (hf.const_smul c).has_deriv_at_filter theorem has_deriv_within_at.const_smul (c : R) (hf : has_deriv_within_at f f' s x) : has_deriv_within_at (λ y, c • f y) (c • f') s x := hf.const_smul c theorem has_deriv_at.const_smul (c : R) (hf : has_deriv_at f f' x) : has_deriv_at (λ y, c • f y) (c • f') x := hf.const_smul c lemma deriv_within_const_smul (hxs : unique_diff_within_at 𝕜 s x) (c : R) (hf : differentiable_within_at 𝕜 f s x) : deriv_within (λ y, c • f y) s x = c • deriv_within f s x := (hf.has_deriv_within_at.const_smul c).deriv_within hxs lemma deriv_const_smul (c : R) (hf : differentiable_at 𝕜 f x) : deriv (λ y, c • f y) x = c • deriv f x := (hf.has_deriv_at.const_smul c).deriv end const_smul section neg /-! ### Derivative of the negative of a function -/ theorem has_deriv_at_filter.neg (h : has_deriv_at_filter f f' x L) : has_deriv_at_filter (λ x, -f x) (-f') x L := by simpa using h.neg.has_deriv_at_filter theorem has_deriv_within_at.neg (h : has_deriv_within_at f f' s x) : has_deriv_within_at (λ x, -f x) (-f') s x := h.neg theorem has_deriv_at.neg (h : has_deriv_at f f' x) : has_deriv_at (λ x, -f x) (-f') x := h.neg theorem has_strict_deriv_at.neg (h : has_strict_deriv_at f f' x) : has_strict_deriv_at (λ x, -f x) (-f') x := by simpa using h.neg.has_strict_deriv_at lemma deriv_within.neg (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (λy, -f y) s x = - deriv_within f s x := by simp only [deriv_within, fderiv_within_neg hxs, continuous_linear_map.neg_apply] lemma deriv.neg : deriv (λy, -f y) x = - deriv f x := by simp only [deriv, fderiv_neg, continuous_linear_map.neg_apply] @[simp] lemma deriv.neg' : deriv (λy, -f y) = (λ x, - deriv f x) := funext $ λ x, deriv.neg end neg section neg2 /-! ### Derivative of the negation function (i.e `has_neg.neg`) -/ variables (s x L) theorem has_deriv_at_filter_neg : has_deriv_at_filter has_neg.neg (-1) x L := has_deriv_at_filter.neg $ has_deriv_at_filter_id _ _ theorem has_deriv_within_at_neg : has_deriv_within_at has_neg.neg (-1) s x := has_deriv_at_filter_neg _ _ theorem has_deriv_at_neg : has_deriv_at has_neg.neg (-1) x := has_deriv_at_filter_neg _ _ theorem has_deriv_at_neg' : has_deriv_at (λ x, -x) (-1) x := has_deriv_at_filter_neg _ _ theorem has_strict_deriv_at_neg : has_strict_deriv_at has_neg.neg (-1) x := has_strict_deriv_at.neg $ has_strict_deriv_at_id _ lemma deriv_neg : deriv has_neg.neg x = -1 := has_deriv_at.deriv (has_deriv_at_neg x) @[simp] lemma deriv_neg' : deriv (has_neg.neg : 𝕜 → 𝕜) = λ _, -1 := funext deriv_neg @[simp] lemma deriv_neg'' : deriv (λ x : 𝕜, -x) x = -1 := deriv_neg x lemma deriv_within_neg (hxs : unique_diff_within_at 𝕜 s x) : deriv_within has_neg.neg s x = -1 := (has_deriv_within_at_neg x s).deriv_within hxs lemma differentiable_neg : differentiable 𝕜 (has_neg.neg : 𝕜 → 𝕜) := differentiable.neg differentiable_id lemma differentiable_on_neg : differentiable_on 𝕜 (has_neg.neg : 𝕜 → 𝕜) s := differentiable_on.neg differentiable_on_id end neg2 section sub /-! ### Derivative of the difference of two functions -/ theorem has_deriv_at_filter.sub (hf : has_deriv_at_filter f f' x L) (hg : has_deriv_at_filter g g' x L) : has_deriv_at_filter (λ x, f x - g x) (f' - g') x L := by simpa only [sub_eq_add_neg] using hf.add hg.neg theorem has_deriv_within_at.sub (hf : has_deriv_within_at f f' s x) (hg : has_deriv_within_at g g' s x) : has_deriv_within_at (λ x, f x - g x) (f' - g') s x := hf.sub hg theorem has_deriv_at.sub (hf : has_deriv_at f f' x) (hg : has_deriv_at g g' x) : has_deriv_at (λ x, f x - g x) (f' - g') x := hf.sub hg theorem has_strict_deriv_at.sub (hf : has_strict_deriv_at f f' x) (hg : has_strict_deriv_at g g' x) : has_strict_deriv_at (λ x, f x - g x) (f' - g') x := by simpa only [sub_eq_add_neg] using hf.add hg.neg lemma deriv_within_sub (hxs : unique_diff_within_at 𝕜 s x) (hf : differentiable_within_at 𝕜 f s x) (hg : differentiable_within_at 𝕜 g s x) : deriv_within (λy, f y - g y) s x = deriv_within f s x - deriv_within g s x := (hf.has_deriv_within_at.sub hg.has_deriv_within_at).deriv_within hxs @[simp] lemma deriv_sub (hf : differentiable_at 𝕜 f x) (hg : differentiable_at 𝕜 g x) : deriv (λ y, f y - g y) x = deriv f x - deriv g x := (hf.has_deriv_at.sub hg.has_deriv_at).deriv theorem has_deriv_at_filter.is_O_sub (h : has_deriv_at_filter f f' x L) : (λ x', f x' - f x) =O[L] (λ x', x' - x) := has_fderiv_at_filter.is_O_sub h theorem has_deriv_at_filter.is_O_sub_rev (hf : has_deriv_at_filter f f' x L) (hf' : f' ≠ 0) : (λ x', x' - x) =O[L] (λ x', f x' - f x) := suffices antilipschitz_with ‖f'‖₊⁻¹ (smul_right (1 : 𝕜 →L[𝕜] 𝕜) f'), from hf.is_O_sub_rev this, add_monoid_hom_class.antilipschitz_of_bound (smul_right (1 : 𝕜 →L[𝕜] 𝕜) f') $ λ x, by simp [norm_smul, ← div_eq_inv_mul, mul_div_cancel _ (mt norm_eq_zero.1 hf')] theorem has_deriv_at_filter.sub_const (hf : has_deriv_at_filter f f' x L) (c : F) : has_deriv_at_filter (λ x, f x - c) f' x L := by simpa only [sub_eq_add_neg] using hf.add_const (-c) theorem has_deriv_within_at.sub_const (hf : has_deriv_within_at f f' s x) (c : F) : has_deriv_within_at (λ x, f x - c) f' s x := hf.sub_const c theorem has_deriv_at.sub_const (hf : has_deriv_at f f' x) (c : F) : has_deriv_at (λ x, f x - c) f' x := hf.sub_const c lemma deriv_within_sub_const (hxs : unique_diff_within_at 𝕜 s x) (c : F) : deriv_within (λy, f y - c) s x = deriv_within f s x := by simp only [deriv_within, fderiv_within_sub_const hxs] lemma deriv_sub_const (c : F) : deriv (λ y, f y - c) x = deriv f x := by simp only [deriv, fderiv_sub_const] theorem has_deriv_at_filter.const_sub (c : F) (hf : has_deriv_at_filter f f' x L) : has_deriv_at_filter (λ x, c - f x) (-f') x L := by simpa only [sub_eq_add_neg] using hf.neg.const_add c theorem has_deriv_within_at.const_sub (c : F) (hf : has_deriv_within_at f f' s x) : has_deriv_within_at (λ x, c - f x) (-f') s x := hf.const_sub c theorem has_strict_deriv_at.const_sub (c : F) (hf : has_strict_deriv_at f f' x) : has_strict_deriv_at (λ x, c - f x) (-f') x := by simpa only [sub_eq_add_neg] using hf.neg.const_add c theorem has_deriv_at.const_sub (c : F) (hf : has_deriv_at f f' x) : has_deriv_at (λ x, c - f x) (-f') x := hf.const_sub c lemma deriv_within_const_sub (hxs : unique_diff_within_at 𝕜 s x) (c : F) : deriv_within (λy, c - f y) s x = -deriv_within f s x := by simp [deriv_within, fderiv_within_const_sub hxs] lemma deriv_const_sub (c : F) : deriv (λ y, c - f y) x = -deriv f x := by simp only [← deriv_within_univ, deriv_within_const_sub (unique_diff_within_at_univ : unique_diff_within_at 𝕜 _ _)] end sub section continuous /-! ### Continuity of a function admitting a derivative -/ theorem has_deriv_at_filter.tendsto_nhds (hL : L ≤ 𝓝 x) (h : has_deriv_at_filter f f' x L) : tendsto f L (𝓝 (f x)) := h.tendsto_nhds hL theorem has_deriv_within_at.continuous_within_at (h : has_deriv_within_at f f' s x) : continuous_within_at f s x := has_deriv_at_filter.tendsto_nhds inf_le_left h theorem has_deriv_at.continuous_at (h : has_deriv_at f f' x) : continuous_at f x := has_deriv_at_filter.tendsto_nhds le_rfl h protected theorem has_deriv_at.continuous_on {f f' : 𝕜 → F} (hderiv : ∀ x ∈ s, has_deriv_at f (f' x) x) : continuous_on f s := λ x hx, (hderiv x hx).continuous_at.continuous_within_at end continuous section cartesian_product /-! ### Derivative of the cartesian product of two functions -/ variables {G : Type w} [normed_add_comm_group G] [normed_space 𝕜 G] variables {f₂ : 𝕜 → G} {f₂' : G} lemma has_deriv_at_filter.prod (hf₁ : has_deriv_at_filter f₁ f₁' x L) (hf₂ : has_deriv_at_filter f₂ f₂' x L) : has_deriv_at_filter (λ x, (f₁ x, f₂ x)) (f₁', f₂') x L := hf₁.prod hf₂ lemma has_deriv_within_at.prod (hf₁ : has_deriv_within_at f₁ f₁' s x) (hf₂ : has_deriv_within_at f₂ f₂' s x) : has_deriv_within_at (λ x, (f₁ x, f₂ x)) (f₁', f₂') s x := hf₁.prod hf₂ lemma has_deriv_at.prod (hf₁ : has_deriv_at f₁ f₁' x) (hf₂ : has_deriv_at f₂ f₂' x) : has_deriv_at (λ x, (f₁ x, f₂ x)) (f₁', f₂') x := hf₁.prod hf₂ lemma has_strict_deriv_at.prod (hf₁ : has_strict_deriv_at f₁ f₁' x) (hf₂ : has_strict_deriv_at f₂ f₂' x) : has_strict_deriv_at (λ x, (f₁ x, f₂ x)) (f₁', f₂') x := hf₁.prod hf₂ end cartesian_product section composition /-! ### Derivative of the composition of a vector function and a scalar function We use `scomp` in lemmas on composition of vector valued and scalar valued functions, and `comp` in lemmas on composition of scalar valued functions, in analogy for `smul` and `mul` (and also because the `comp` version with the shorter name will show up much more often in applications). The formula for the derivative involves `smul` in `scomp` lemmas, which can be reduced to usual multiplication in `comp` lemmas. -/ /- For composition lemmas, we put x explicit to help the elaborator, as otherwise Lean tends to get confused since there are too many possibilities for composition -/ variables {𝕜' : Type*} [nontrivially_normed_field 𝕜'] [normed_algebra 𝕜 𝕜'] [normed_space 𝕜' F] [is_scalar_tower 𝕜 𝕜' F] {s' t' : set 𝕜'} {h : 𝕜 → 𝕜'} {h₁ : 𝕜 → 𝕜} {h₂ : 𝕜' → 𝕜'} {h' h₂' : 𝕜'} {h₁' : 𝕜} {g₁ : 𝕜' → F} {g₁' : F} {L' : filter 𝕜'} (x) theorem has_deriv_at_filter.scomp (hg : has_deriv_at_filter g₁ g₁' (h x) L') (hh : has_deriv_at_filter h h' x L) (hL : tendsto h L L'): has_deriv_at_filter (g₁ ∘ h) (h' • g₁') x L := by simpa using ((hg.restrict_scalars 𝕜).comp x hh hL).has_deriv_at_filter theorem has_deriv_within_at.scomp_has_deriv_at (hg : has_deriv_within_at g₁ g₁' s' (h x)) (hh : has_deriv_at h h' x) (hs : ∀ x, h x ∈ s') : has_deriv_at (g₁ ∘ h) (h' • g₁') x := hg.scomp x hh $ tendsto_inf.2 ⟨hh.continuous_at, tendsto_principal.2 $ eventually_of_forall hs⟩ theorem has_deriv_within_at.scomp (hg : has_deriv_within_at g₁ g₁' t' (h x)) (hh : has_deriv_within_at h h' s x) (hst : maps_to h s t') : has_deriv_within_at (g₁ ∘ h) (h' • g₁') s x := hg.scomp x hh $ hh.continuous_within_at.tendsto_nhds_within hst /-- The chain rule. -/ theorem has_deriv_at.scomp (hg : has_deriv_at g₁ g₁' (h x)) (hh : has_deriv_at h h' x) : has_deriv_at (g₁ ∘ h) (h' • g₁') x := hg.scomp x hh hh.continuous_at theorem has_strict_deriv_at.scomp (hg : has_strict_deriv_at g₁ g₁' (h x)) (hh : has_strict_deriv_at h h' x) : has_strict_deriv_at (g₁ ∘ h) (h' • g₁') x := by simpa using ((hg.restrict_scalars 𝕜).comp x hh).has_strict_deriv_at theorem has_deriv_at.scomp_has_deriv_within_at (hg : has_deriv_at g₁ g₁' (h x)) (hh : has_deriv_within_at h h' s x) : has_deriv_within_at (g₁ ∘ h) (h' • g₁') s x := has_deriv_within_at.scomp x hg.has_deriv_within_at hh (maps_to_univ _ _) lemma deriv_within.scomp (hg : differentiable_within_at 𝕜' g₁ t' (h x)) (hh : differentiable_within_at 𝕜 h s x) (hs : maps_to h s t') (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (g₁ ∘ h) s x = deriv_within h s x • deriv_within g₁ t' (h x) := (has_deriv_within_at.scomp x hg.has_deriv_within_at hh.has_deriv_within_at hs).deriv_within hxs lemma deriv.scomp (hg : differentiable_at 𝕜' g₁ (h x)) (hh : differentiable_at 𝕜 h x) : deriv (g₁ ∘ h) x = deriv h x • deriv g₁ (h x) := (has_deriv_at.scomp x hg.has_deriv_at hh.has_deriv_at).deriv /-! ### Derivative of the composition of a scalar and vector functions -/ theorem has_deriv_at_filter.comp_has_fderiv_at_filter {f : E → 𝕜'} {f' : E →L[𝕜] 𝕜'} (x) {L'' : filter E} (hh₂ : has_deriv_at_filter h₂ h₂' (f x) L') (hf : has_fderiv_at_filter f f' x L'') (hL : tendsto f L'' L') : has_fderiv_at_filter (h₂ ∘ f) (h₂' • f') x L'' := by { convert (hh₂.restrict_scalars 𝕜).comp x hf hL, ext x, simp [mul_comm] } theorem has_strict_deriv_at.comp_has_strict_fderiv_at {f : E → 𝕜'} {f' : E →L[𝕜] 𝕜'} (x) (hh : has_strict_deriv_at h₂ h₂' (f x)) (hf : has_strict_fderiv_at f f' x) : has_strict_fderiv_at (h₂ ∘ f) (h₂' • f') x := begin rw has_strict_deriv_at at hh, convert (hh.restrict_scalars 𝕜).comp x hf, ext x, simp [mul_comm] end theorem has_deriv_at.comp_has_fderiv_at {f : E → 𝕜'} {f' : E →L[𝕜] 𝕜'} (x) (hh : has_deriv_at h₂ h₂' (f x)) (hf : has_fderiv_at f f' x) : has_fderiv_at (h₂ ∘ f) (h₂' • f') x := hh.comp_has_fderiv_at_filter x hf hf.continuous_at theorem has_deriv_at.comp_has_fderiv_within_at {f : E → 𝕜'} {f' : E →L[𝕜] 𝕜'} {s} (x) (hh : has_deriv_at h₂ h₂' (f x)) (hf : has_fderiv_within_at f f' s x) : has_fderiv_within_at (h₂ ∘ f) (h₂' • f') s x := hh.comp_has_fderiv_at_filter x hf hf.continuous_within_at theorem has_deriv_within_at.comp_has_fderiv_within_at {f : E → 𝕜'} {f' : E →L[𝕜] 𝕜'} {s t} (x) (hh : has_deriv_within_at h₂ h₂' t (f x)) (hf : has_fderiv_within_at f f' s x) (hst : maps_to f s t) : has_fderiv_within_at (h₂ ∘ f) (h₂' • f') s x := hh.comp_has_fderiv_at_filter x hf $ hf.continuous_within_at.tendsto_nhds_within hst /-! ### Derivative of the composition of two scalar functions -/ theorem has_deriv_at_filter.comp (hh₂ : has_deriv_at_filter h₂ h₂' (h x) L') (hh : has_deriv_at_filter h h' x L) (hL : tendsto h L L') : has_deriv_at_filter (h₂ ∘ h) (h₂' * h') x L := by { rw mul_comm, exact hh₂.scomp x hh hL } theorem has_deriv_within_at.comp (hh₂ : has_deriv_within_at h₂ h₂' s' (h x)) (hh : has_deriv_within_at h h' s x) (hst : maps_to h s s') : has_deriv_within_at (h₂ ∘ h) (h₂' * h') s x := by { rw mul_comm, exact hh₂.scomp x hh hst, } /-- The chain rule. -/ theorem has_deriv_at.comp (hh₂ : has_deriv_at h₂ h₂' (h x)) (hh : has_deriv_at h h' x) : has_deriv_at (h₂ ∘ h) (h₂' * h') x := hh₂.comp x hh hh.continuous_at theorem has_strict_deriv_at.comp (hh₂ : has_strict_deriv_at h₂ h₂' (h x)) (hh : has_strict_deriv_at h h' x) : has_strict_deriv_at (h₂ ∘ h) (h₂' * h') x := by { rw mul_comm, exact hh₂.scomp x hh } theorem has_deriv_at.comp_has_deriv_within_at (hh₂ : has_deriv_at h₂ h₂' (h x)) (hh : has_deriv_within_at h h' s x) : has_deriv_within_at (h₂ ∘ h) (h₂' * h') s x := hh₂.has_deriv_within_at.comp x hh (maps_to_univ _ _) lemma deriv_within.comp (hh₂ : differentiable_within_at 𝕜' h₂ s' (h x)) (hh : differentiable_within_at 𝕜 h s x) (hs : maps_to h s s') (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (h₂ ∘ h) s x = deriv_within h₂ s' (h x) * deriv_within h s x := (hh₂.has_deriv_within_at.comp x hh.has_deriv_within_at hs).deriv_within hxs lemma deriv.comp (hh₂ : differentiable_at 𝕜' h₂ (h x)) (hh : differentiable_at 𝕜 h x) : deriv (h₂ ∘ h) x = deriv h₂ (h x) * deriv h x := (hh₂.has_deriv_at.comp x hh.has_deriv_at).deriv protected lemma has_deriv_at_filter.iterate {f : 𝕜 → 𝕜} {f' : 𝕜} (hf : has_deriv_at_filter f f' x L) (hL : tendsto f L L) (hx : f x = x) (n : ℕ) : has_deriv_at_filter (f^[n]) (f'^n) x L := begin have := hf.iterate hL hx n, rwa [continuous_linear_map.smul_right_one_pow] at this end protected lemma has_deriv_at.iterate {f : 𝕜 → 𝕜} {f' : 𝕜} (hf : has_deriv_at f f' x) (hx : f x = x) (n : ℕ) : has_deriv_at (f^[n]) (f'^n) x := begin have := has_fderiv_at.iterate hf hx n, rwa [continuous_linear_map.smul_right_one_pow] at this end protected lemma has_deriv_within_at.iterate {f : 𝕜 → 𝕜} {f' : 𝕜} (hf : has_deriv_within_at f f' s x) (hx : f x = x) (hs : maps_to f s s) (n : ℕ) : has_deriv_within_at (f^[n]) (f'^n) s x := begin have := has_fderiv_within_at.iterate hf hx hs n, rwa [continuous_linear_map.smul_right_one_pow] at this end protected lemma has_strict_deriv_at.iterate {f : 𝕜 → 𝕜} {f' : 𝕜} (hf : has_strict_deriv_at f f' x) (hx : f x = x) (n : ℕ) : has_strict_deriv_at (f^[n]) (f'^n) x := begin have := hf.iterate hx n, rwa [continuous_linear_map.smul_right_one_pow] at this end end composition section composition_vector /-! ### Derivative of the composition of a function between vector spaces and a function on `𝕜` -/ open continuous_linear_map variables {l : F → E} {l' : F →L[𝕜] E} variable (x) /-- The composition `l ∘ f` where `l : F → E` and `f : 𝕜 → F`, has a derivative within a set equal to the Fréchet derivative of `l` applied to the derivative of `f`. -/ theorem has_fderiv_within_at.comp_has_deriv_within_at {t : set F} (hl : has_fderiv_within_at l l' t (f x)) (hf : has_deriv_within_at f f' s x) (hst : maps_to f s t) : has_deriv_within_at (l ∘ f) (l' f') s x := by simpa only [one_apply, one_smul, smul_right_apply, coe_comp', (∘)] using (hl.comp x hf.has_fderiv_within_at hst).has_deriv_within_at theorem has_fderiv_at.comp_has_deriv_within_at (hl : has_fderiv_at l l' (f x)) (hf : has_deriv_within_at f f' s x) : has_deriv_within_at (l ∘ f) (l' f') s x := hl.has_fderiv_within_at.comp_has_deriv_within_at x hf (maps_to_univ _ _) /-- The composition `l ∘ f` where `l : F → E` and `f : 𝕜 → F`, has a derivative equal to the Fréchet derivative of `l` applied to the derivative of `f`. -/ theorem has_fderiv_at.comp_has_deriv_at (hl : has_fderiv_at l l' (f x)) (hf : has_deriv_at f f' x) : has_deriv_at (l ∘ f) (l' f') x := has_deriv_within_at_univ.mp $ hl.comp_has_deriv_within_at x hf.has_deriv_within_at theorem has_strict_fderiv_at.comp_has_strict_deriv_at (hl : has_strict_fderiv_at l l' (f x)) (hf : has_strict_deriv_at f f' x) : has_strict_deriv_at (l ∘ f) (l' f') x := by simpa only [one_apply, one_smul, smul_right_apply, coe_comp', (∘)] using (hl.comp x hf.has_strict_fderiv_at).has_strict_deriv_at lemma fderiv_within.comp_deriv_within {t : set F} (hl : differentiable_within_at 𝕜 l t (f x)) (hf : differentiable_within_at 𝕜 f s x) (hs : maps_to f s t) (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (l ∘ f) s x = (fderiv_within 𝕜 l t (f x) : F → E) (deriv_within f s x) := (hl.has_fderiv_within_at.comp_has_deriv_within_at x hf.has_deriv_within_at hs).deriv_within hxs lemma fderiv.comp_deriv (hl : differentiable_at 𝕜 l (f x)) (hf : differentiable_at 𝕜 f x) : deriv (l ∘ f) x = (fderiv 𝕜 l (f x) : F → E) (deriv f x) := (hl.has_fderiv_at.comp_has_deriv_at x hf.has_deriv_at).deriv end composition_vector section mul /-! ### Derivative of the multiplication of two functions -/ variables {𝕜' 𝔸 : Type*} [normed_field 𝕜'] [normed_ring 𝔸] [normed_algebra 𝕜 𝕜'] [normed_algebra 𝕜 𝔸] {c d : 𝕜 → 𝔸} {c' d' : 𝔸} {u v : 𝕜 → 𝕜'} theorem has_deriv_within_at.mul (hc : has_deriv_within_at c c' s x) (hd : has_deriv_within_at d d' s x) : has_deriv_within_at (λ y, c y * d y) (c' * d x + c x * d') s x := begin have := (has_fderiv_within_at.mul' hc hd).has_deriv_within_at, rwa [continuous_linear_map.add_apply, continuous_linear_map.smul_apply, continuous_linear_map.smul_right_apply, continuous_linear_map.smul_right_apply, continuous_linear_map.smul_right_apply, continuous_linear_map.one_apply, one_smul, one_smul, add_comm] at this, end theorem has_deriv_at.mul (hc : has_deriv_at c c' x) (hd : has_deriv_at d d' x) : has_deriv_at (λ y, c y * d y) (c' * d x + c x * d') x := begin rw [← has_deriv_within_at_univ] at *, exact hc.mul hd end theorem has_strict_deriv_at.mul (hc : has_strict_deriv_at c c' x) (hd : has_strict_deriv_at d d' x) : has_strict_deriv_at (λ y, c y * d y) (c' * d x + c x * d') x := begin have := (has_strict_fderiv_at.mul' hc hd).has_strict_deriv_at, rwa [continuous_linear_map.add_apply, continuous_linear_map.smul_apply, continuous_linear_map.smul_right_apply, continuous_linear_map.smul_right_apply, continuous_linear_map.smul_right_apply, continuous_linear_map.one_apply, one_smul, one_smul, add_comm] at this, end lemma deriv_within_mul (hxs : unique_diff_within_at 𝕜 s x) (hc : differentiable_within_at 𝕜 c s x) (hd : differentiable_within_at 𝕜 d s x) : deriv_within (λ y, c y * d y) s x = deriv_within c s x * d x + c x * deriv_within d s x := (hc.has_deriv_within_at.mul hd.has_deriv_within_at).deriv_within hxs @[simp] lemma deriv_mul (hc : differentiable_at 𝕜 c x) (hd : differentiable_at 𝕜 d x) : deriv (λ y, c y * d y) x = deriv c x * d x + c x * deriv d x := (hc.has_deriv_at.mul hd.has_deriv_at).deriv theorem has_deriv_within_at.mul_const (hc : has_deriv_within_at c c' s x) (d : 𝔸) : has_deriv_within_at (λ y, c y * d) (c' * d) s x := begin convert hc.mul (has_deriv_within_at_const x s d), rw [mul_zero, add_zero] end theorem has_deriv_at.mul_const (hc : has_deriv_at c c' x) (d : 𝔸) : has_deriv_at (λ y, c y * d) (c' * d) x := begin rw [← has_deriv_within_at_univ] at *, exact hc.mul_const d end theorem has_deriv_at_mul_const (c : 𝕜) : has_deriv_at (λ x, x * c) c x := by simpa only [one_mul] using (has_deriv_at_id' x).mul_const c theorem has_strict_deriv_at.mul_const (hc : has_strict_deriv_at c c' x) (d : 𝔸) : has_strict_deriv_at (λ y, c y * d) (c' * d) x := begin convert hc.mul (has_strict_deriv_at_const x d), rw [mul_zero, add_zero] end lemma deriv_within_mul_const (hxs : unique_diff_within_at 𝕜 s x) (hc : differentiable_within_at 𝕜 c s x) (d : 𝔸) : deriv_within (λ y, c y * d) s x = deriv_within c s x * d := (hc.has_deriv_within_at.mul_const d).deriv_within hxs lemma deriv_mul_const (hc : differentiable_at 𝕜 c x) (d : 𝔸) : deriv (λ y, c y * d) x = deriv c x * d := (hc.has_deriv_at.mul_const d).deriv lemma deriv_mul_const_field (v : 𝕜') : deriv (λ y, u y * v) x = deriv u x * v := begin by_cases hu : differentiable_at 𝕜 u x, { exact deriv_mul_const hu v }, { rw [deriv_zero_of_not_differentiable_at hu, zero_mul], rcases eq_or_ne v 0 with rfl|hd, { simp only [mul_zero, deriv_const] }, { refine deriv_zero_of_not_differentiable_at (mt (λ H, _) hu), simpa only [mul_inv_cancel_right₀ hd] using H.mul_const v⁻¹ } } end @[simp] lemma deriv_mul_const_field' (v : 𝕜') : deriv (λ x, u x * v) = λ x, deriv u x * v := funext $ λ _, deriv_mul_const_field v theorem has_deriv_within_at.const_mul (c : 𝔸) (hd : has_deriv_within_at d d' s x) : has_deriv_within_at (λ y, c * d y) (c * d') s x := begin convert (has_deriv_within_at_const x s c).mul hd, rw [zero_mul, zero_add] end theorem has_deriv_at.const_mul (c : 𝔸) (hd : has_deriv_at d d' x) : has_deriv_at (λ y, c * d y) (c * d') x := begin rw [← has_deriv_within_at_univ] at *, exact hd.const_mul c end theorem has_strict_deriv_at.const_mul (c : 𝔸) (hd : has_strict_deriv_at d d' x) : has_strict_deriv_at (λ y, c * d y) (c * d') x := begin convert (has_strict_deriv_at_const _ _).mul hd, rw [zero_mul, zero_add] end lemma deriv_within_const_mul (hxs : unique_diff_within_at 𝕜 s x) (c : 𝔸) (hd : differentiable_within_at 𝕜 d s x) : deriv_within (λ y, c * d y) s x = c * deriv_within d s x := (hd.has_deriv_within_at.const_mul c).deriv_within hxs lemma deriv_const_mul (c : 𝔸) (hd : differentiable_at 𝕜 d x) : deriv (λ y, c * d y) x = c * deriv d x := (hd.has_deriv_at.const_mul c).deriv lemma deriv_const_mul_field (u : 𝕜') : deriv (λ y, u * v y) x = u * deriv v x := by simp only [mul_comm u, deriv_mul_const_field] @[simp] lemma deriv_const_mul_field' (u : 𝕜') : deriv (λ x, u * v x) = λ x, u * deriv v x := funext (λ x, deriv_const_mul_field u) end mul section inverse /-! ### Derivative of `x ↦ x⁻¹` -/ theorem has_strict_deriv_at_inv (hx : x ≠ 0) : has_strict_deriv_at has_inv.inv (-(x^2)⁻¹) x := begin suffices : (λ p : 𝕜 × 𝕜, (p.1 - p.2) * ((x * x)⁻¹ - (p.1 * p.2)⁻¹)) =o[𝓝 (x, x)] (λ p, (p.1 - p.2) * 1), { refine this.congr' _ (eventually_of_forall $ λ _, mul_one _), refine eventually.mono (is_open.mem_nhds (is_open_ne.prod is_open_ne) ⟨hx, hx⟩) _, rintro ⟨y, z⟩ ⟨hy, hz⟩, simp only [mem_set_of_eq] at hy hz, -- hy : y ≠ 0, hz : z ≠ 0 field_simp [hx, hy, hz], ring, }, refine (is_O_refl (λ p : 𝕜 × 𝕜, p.1 - p.2) _).mul_is_o ((is_o_one_iff _).2 _), rw [← sub_self (x * x)⁻¹], exact tendsto_const_nhds.sub ((continuous_mul.tendsto (x, x)).inv₀ $ mul_ne_zero hx hx) end theorem has_deriv_at_inv (x_ne_zero : x ≠ 0) : has_deriv_at (λy, y⁻¹) (-(x^2)⁻¹) x := (has_strict_deriv_at_inv x_ne_zero).has_deriv_at theorem has_deriv_within_at_inv (x_ne_zero : x ≠ 0) (s : set 𝕜) : has_deriv_within_at (λx, x⁻¹) (-(x^2)⁻¹) s x := (has_deriv_at_inv x_ne_zero).has_deriv_within_at lemma differentiable_at_inv : differentiable_at 𝕜 (λx, x⁻¹) x ↔ x ≠ 0:= ⟨λ H, normed_field.continuous_at_inv.1 H.continuous_at, λ H, (has_deriv_at_inv H).differentiable_at⟩ lemma differentiable_within_at_inv (x_ne_zero : x ≠ 0) : differentiable_within_at 𝕜 (λx, x⁻¹) s x := (differentiable_at_inv.2 x_ne_zero).differentiable_within_at lemma differentiable_on_inv : differentiable_on 𝕜 (λx:𝕜, x⁻¹) {x | x ≠ 0} := λx hx, differentiable_within_at_inv hx lemma deriv_inv : deriv (λx, x⁻¹) x = -(x^2)⁻¹ := begin rcases eq_or_ne x 0 with rfl|hne, { simp [deriv_zero_of_not_differentiable_at (mt differentiable_at_inv.1 (not_not.2 rfl))] }, { exact (has_deriv_at_inv hne).deriv } end @[simp] lemma deriv_inv' : deriv (λ x : 𝕜, x⁻¹) = λ x, -(x ^ 2)⁻¹ := funext (λ x, deriv_inv) lemma deriv_within_inv (x_ne_zero : x ≠ 0) (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (λx, x⁻¹) s x = -(x^2)⁻¹ := begin rw differentiable_at.deriv_within (differentiable_at_inv.2 x_ne_zero) hxs, exact deriv_inv end lemma has_fderiv_at_inv (x_ne_zero : x ≠ 0) : has_fderiv_at (λx, x⁻¹) (smul_right (1 : 𝕜 →L[𝕜] 𝕜) (-(x^2)⁻¹) : 𝕜 →L[𝕜] 𝕜) x := has_deriv_at_inv x_ne_zero lemma has_fderiv_within_at_inv (x_ne_zero : x ≠ 0) : has_fderiv_within_at (λx, x⁻¹) (smul_right (1 : 𝕜 →L[𝕜] 𝕜) (-(x^2)⁻¹) : 𝕜 →L[𝕜] 𝕜) s x := (has_fderiv_at_inv x_ne_zero).has_fderiv_within_at lemma fderiv_inv : fderiv 𝕜 (λx, x⁻¹) x = smul_right (1 : 𝕜 →L[𝕜] 𝕜) (-(x^2)⁻¹) := by rw [← deriv_fderiv, deriv_inv] lemma fderiv_within_inv (x_ne_zero : x ≠ 0) (hxs : unique_diff_within_at 𝕜 s x) : fderiv_within 𝕜 (λx, x⁻¹) s x = smul_right (1 : 𝕜 →L[𝕜] 𝕜) (-(x^2)⁻¹) := begin rw differentiable_at.fderiv_within (differentiable_at_inv.2 x_ne_zero) hxs, exact fderiv_inv end variables {c : 𝕜 → 𝕜} {h : E → 𝕜} {c' : 𝕜} {z : E} {S : set E} lemma has_deriv_within_at.inv (hc : has_deriv_within_at c c' s x) (hx : c x ≠ 0) : has_deriv_within_at (λ y, (c y)⁻¹) (- c' / (c x)^2) s x := begin convert (has_deriv_at_inv hx).comp_has_deriv_within_at x hc, field_simp end lemma has_deriv_at.inv (hc : has_deriv_at c c' x) (hx : c x ≠ 0) : has_deriv_at (λ y, (c y)⁻¹) (- c' / (c x)^2) x := begin rw ← has_deriv_within_at_univ at *, exact hc.inv hx end lemma differentiable_within_at.inv (hf : differentiable_within_at 𝕜 h S z) (hz : h z ≠ 0) : differentiable_within_at 𝕜 (λx, (h x)⁻¹) S z := (differentiable_at_inv.mpr hz).comp_differentiable_within_at z hf @[simp] lemma differentiable_at.inv (hf : differentiable_at 𝕜 h z) (hz : h z ≠ 0) : differentiable_at 𝕜 (λx, (h x)⁻¹) z := (differentiable_at_inv.mpr hz).comp z hf lemma differentiable_on.inv (hf : differentiable_on 𝕜 h S) (hz : ∀ x ∈ S, h x ≠ 0) : differentiable_on 𝕜 (λx, (h x)⁻¹) S := λx h, (hf x h).inv (hz x h) @[simp] lemma differentiable.inv (hf : differentiable 𝕜 h) (hz : ∀ x, h x ≠ 0) : differentiable 𝕜 (λx, (h x)⁻¹) := λx, (hf x).inv (hz x) lemma deriv_within_inv' (hc : differentiable_within_at 𝕜 c s x) (hx : c x ≠ 0) (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (λx, (c x)⁻¹) s x = - (deriv_within c s x) / (c x)^2 := (hc.has_deriv_within_at.inv hx).deriv_within hxs @[simp] lemma deriv_inv'' (hc : differentiable_at 𝕜 c x) (hx : c x ≠ 0) : deriv (λx, (c x)⁻¹) x = - (deriv c x) / (c x)^2 := (hc.has_deriv_at.inv hx).deriv end inverse section division /-! ### Derivative of `x ↦ c x / d x` -/ variables {𝕜' : Type*} [nontrivially_normed_field 𝕜'] [normed_algebra 𝕜 𝕜'] {c d : 𝕜 → 𝕜'} {c' d' : 𝕜'} lemma has_deriv_within_at.div (hc : has_deriv_within_at c c' s x) (hd : has_deriv_within_at d d' s x) (hx : d x ≠ 0) : has_deriv_within_at (λ y, c y / d y) ((c' * d x - c x * d') / (d x)^2) s x := begin convert hc.mul ((has_deriv_at_inv hx).comp_has_deriv_within_at x hd), { simp only [div_eq_mul_inv] }, { field_simp, ring } end lemma has_strict_deriv_at.div (hc : has_strict_deriv_at c c' x) (hd : has_strict_deriv_at d d' x) (hx : d x ≠ 0) : has_strict_deriv_at (λ y, c y / d y) ((c' * d x - c x * d') / (d x)^2) x := begin convert hc.mul ((has_strict_deriv_at_inv hx).comp x hd), { simp only [div_eq_mul_inv] }, { field_simp, ring } end lemma has_deriv_at.div (hc : has_deriv_at c c' x) (hd : has_deriv_at d d' x) (hx : d x ≠ 0) : has_deriv_at (λ y, c y / d y) ((c' * d x - c x * d') / (d x)^2) x := begin rw ← has_deriv_within_at_univ at *, exact hc.div hd hx end lemma differentiable_within_at.div (hc : differentiable_within_at 𝕜 c s x) (hd : differentiable_within_at 𝕜 d s x) (hx : d x ≠ 0) : differentiable_within_at 𝕜 (λx, c x / d x) s x := ((hc.has_deriv_within_at).div (hd.has_deriv_within_at) hx).differentiable_within_at @[simp] lemma differentiable_at.div (hc : differentiable_at 𝕜 c x) (hd : differentiable_at 𝕜 d x) (hx : d x ≠ 0) : differentiable_at 𝕜 (λx, c x / d x) x := ((hc.has_deriv_at).div (hd.has_deriv_at) hx).differentiable_at lemma differentiable_on.div (hc : differentiable_on 𝕜 c s) (hd : differentiable_on 𝕜 d s) (hx : ∀ x ∈ s, d x ≠ 0) : differentiable_on 𝕜 (λx, c x / d x) s := λx h, (hc x h).div (hd x h) (hx x h) @[simp] lemma differentiable.div (hc : differentiable 𝕜 c) (hd : differentiable 𝕜 d) (hx : ∀ x, d x ≠ 0) : differentiable 𝕜 (λx, c x / d x) := λx, (hc x).div (hd x) (hx x) lemma deriv_within_div (hc : differentiable_within_at 𝕜 c s x) (hd : differentiable_within_at 𝕜 d s x) (hx : d x ≠ 0) (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (λx, c x / d x) s x = ((deriv_within c s x) * d x - c x * (deriv_within d s x)) / (d x)^2 := ((hc.has_deriv_within_at).div (hd.has_deriv_within_at) hx).deriv_within hxs @[simp] lemma deriv_div (hc : differentiable_at 𝕜 c x) (hd : differentiable_at 𝕜 d x) (hx : d x ≠ 0) : deriv (λx, c x / d x) x = ((deriv c x) * d x - c x * (deriv d x)) / (d x)^2 := ((hc.has_deriv_at).div (hd.has_deriv_at) hx).deriv lemma has_deriv_at.div_const (hc : has_deriv_at c c' x) (d : 𝕜') : has_deriv_at (λ x, c x / d) (c' / d) x := by simpa only [div_eq_mul_inv] using hc.mul_const d⁻¹ lemma has_deriv_within_at.div_const (hc : has_deriv_within_at c c' s x) (d : 𝕜') : has_deriv_within_at (λ x, c x / d) (c' / d) s x := by simpa only [div_eq_mul_inv] using hc.mul_const d⁻¹ lemma has_strict_deriv_at.div_const (hc : has_strict_deriv_at c c' x) (d : 𝕜') : has_strict_deriv_at (λ x, c x / d) (c' / d) x := by simpa only [div_eq_mul_inv] using hc.mul_const d⁻¹ lemma differentiable_within_at.div_const (hc : differentiable_within_at 𝕜 c s x) (d : 𝕜') : differentiable_within_at 𝕜 (λx, c x / d) s x := (hc.has_deriv_within_at.div_const _).differentiable_within_at @[simp] lemma differentiable_at.div_const (hc : differentiable_at 𝕜 c x) (d : 𝕜') : differentiable_at 𝕜 (λ x, c x / d) x := (hc.has_deriv_at.div_const _).differentiable_at lemma differentiable_on.div_const (hc : differentiable_on 𝕜 c s) (d : 𝕜') : differentiable_on 𝕜 (λx, c x / d) s := λ x hx, (hc x hx).div_const d @[simp] lemma differentiable.div_const (hc : differentiable 𝕜 c) (d : 𝕜') : differentiable 𝕜 (λx, c x / d) := λ x, (hc x).div_const d lemma deriv_within_div_const (hc : differentiable_within_at 𝕜 c s x) (d : 𝕜') (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (λx, c x / d) s x = (deriv_within c s x) / d := by simp [div_eq_inv_mul, deriv_within_const_mul, hc, hxs] @[simp] lemma deriv_div_const (d : 𝕜') : deriv (λx, c x / d) x = (deriv c x) / d := by simp only [div_eq_mul_inv, deriv_mul_const_field] end division section clm_comp_apply /-! ### Derivative of the pointwise composition/application of continuous linear maps -/ open continuous_linear_map variables {G : Type*} [normed_add_comm_group G] [normed_space 𝕜 G] {c : 𝕜 → F →L[𝕜] G} {c' : F →L[𝕜] G} {d : 𝕜 → E →L[𝕜] F} {d' : E →L[𝕜] F} {u : 𝕜 → F} {u' : F} lemma has_strict_deriv_at.clm_comp (hc : has_strict_deriv_at c c' x) (hd : has_strict_deriv_at d d' x) : has_strict_deriv_at (λ y, (c y).comp (d y)) (c'.comp (d x) + (c x).comp d') x := begin have := (hc.has_strict_fderiv_at.clm_comp hd.has_strict_fderiv_at).has_strict_deriv_at, rwa [add_apply, comp_apply, comp_apply, smul_right_apply, smul_right_apply, one_apply, one_smul, one_smul, add_comm] at this, end lemma has_deriv_within_at.clm_comp (hc : has_deriv_within_at c c' s x) (hd : has_deriv_within_at d d' s x) : has_deriv_within_at (λ y, (c y).comp (d y)) (c'.comp (d x) + (c x).comp d') s x := begin have := (hc.has_fderiv_within_at.clm_comp hd.has_fderiv_within_at).has_deriv_within_at, rwa [add_apply, comp_apply, comp_apply, smul_right_apply, smul_right_apply, one_apply, one_smul, one_smul, add_comm] at this, end lemma has_deriv_at.clm_comp (hc : has_deriv_at c c' x) (hd : has_deriv_at d d' x) : has_deriv_at (λ y, (c y).comp (d y)) (c'.comp (d x) + (c x).comp d') x := begin rw [← has_deriv_within_at_univ] at *, exact hc.clm_comp hd end lemma deriv_within_clm_comp (hc : differentiable_within_at 𝕜 c s x) (hd : differentiable_within_at 𝕜 d s x) (hxs : unique_diff_within_at 𝕜 s x): deriv_within (λ y, (c y).comp (d y)) s x = ((deriv_within c s x).comp (d x) + (c x).comp (deriv_within d s x)) := (hc.has_deriv_within_at.clm_comp hd.has_deriv_within_at).deriv_within hxs lemma deriv_clm_comp (hc : differentiable_at 𝕜 c x) (hd : differentiable_at 𝕜 d x) : deriv (λ y, (c y).comp (d y)) x = ((deriv c x).comp (d x) + (c x).comp (deriv d x)) := (hc.has_deriv_at.clm_comp hd.has_deriv_at).deriv lemma has_strict_deriv_at.clm_apply (hc : has_strict_deriv_at c c' x) (hu : has_strict_deriv_at u u' x) : has_strict_deriv_at (λ y, (c y) (u y)) (c' (u x) + c x u') x := begin have := (hc.has_strict_fderiv_at.clm_apply hu.has_strict_fderiv_at).has_strict_deriv_at, rwa [add_apply, comp_apply, flip_apply, smul_right_apply, smul_right_apply, one_apply, one_smul, one_smul, add_comm] at this, end lemma has_deriv_within_at.clm_apply (hc : has_deriv_within_at c c' s x) (hu : has_deriv_within_at u u' s x) : has_deriv_within_at (λ y, (c y) (u y)) (c' (u x) + c x u') s x := begin have := (hc.has_fderiv_within_at.clm_apply hu.has_fderiv_within_at).has_deriv_within_at, rwa [add_apply, comp_apply, flip_apply, smul_right_apply, smul_right_apply, one_apply, one_smul, one_smul, add_comm] at this, end lemma has_deriv_at.clm_apply (hc : has_deriv_at c c' x) (hu : has_deriv_at u u' x) : has_deriv_at (λ y, (c y) (u y)) (c' (u x) + c x u') x := begin have := (hc.has_fderiv_at.clm_apply hu.has_fderiv_at).has_deriv_at, rwa [add_apply, comp_apply, flip_apply, smul_right_apply, smul_right_apply, one_apply, one_smul, one_smul, add_comm] at this, end lemma deriv_within_clm_apply (hxs : unique_diff_within_at 𝕜 s x) (hc : differentiable_within_at 𝕜 c s x) (hu : differentiable_within_at 𝕜 u s x) : deriv_within (λ y, (c y) (u y)) s x = (deriv_within c s x (u x) + c x (deriv_within u s x)) := (hc.has_deriv_within_at.clm_apply hu.has_deriv_within_at).deriv_within hxs lemma deriv_clm_apply (hc : differentiable_at 𝕜 c x) (hu : differentiable_at 𝕜 u x) : deriv (λ y, (c y) (u y)) x = (deriv c x (u x) + c x (deriv u x)) := (hc.has_deriv_at.clm_apply hu.has_deriv_at).deriv end clm_comp_apply theorem has_strict_deriv_at.has_strict_fderiv_at_equiv {f : 𝕜 → 𝕜} {f' x : 𝕜} (hf : has_strict_deriv_at f f' x) (hf' : f' ≠ 0) : has_strict_fderiv_at f (continuous_linear_equiv.units_equiv_aut 𝕜 (units.mk0 f' hf') : 𝕜 →L[𝕜] 𝕜) x := hf theorem has_deriv_at.has_fderiv_at_equiv {f : 𝕜 → 𝕜} {f' x : 𝕜} (hf : has_deriv_at f f' x) (hf' : f' ≠ 0) : has_fderiv_at f (continuous_linear_equiv.units_equiv_aut 𝕜 (units.mk0 f' hf') : 𝕜 →L[𝕜] 𝕜) x := hf /-- If `f (g y) = y` for `y` in some neighborhood of `a`, `g` is continuous at `a`, and `f` has an invertible derivative `f'` at `g a` in the strict sense, then `g` has the derivative `f'⁻¹` at `a` in the strict sense. This is one of the easy parts of the inverse function theorem: it assumes that we already have an inverse function. -/ theorem has_strict_deriv_at.of_local_left_inverse {f g : 𝕜 → 𝕜} {f' a : 𝕜} (hg : continuous_at g a) (hf : has_strict_deriv_at f f' (g a)) (hf' : f' ≠ 0) (hfg : ∀ᶠ y in 𝓝 a, f (g y) = y) : has_strict_deriv_at g f'⁻¹ a := (hf.has_strict_fderiv_at_equiv hf').of_local_left_inverse hg hfg /-- If `f` is a local homeomorphism defined on a neighbourhood of `f.symm a`, and `f` has a nonzero derivative `f'` at `f.symm a` in the strict sense, then `f.symm` has the derivative `f'⁻¹` at `a` in the strict sense. This is one of the easy parts of the inverse function theorem: it assumes that we already have an inverse function. -/ lemma local_homeomorph.has_strict_deriv_at_symm (f : local_homeomorph 𝕜 𝕜) {a f' : 𝕜} (ha : a ∈ f.target) (hf' : f' ≠ 0) (htff' : has_strict_deriv_at f f' (f.symm a)) : has_strict_deriv_at f.symm f'⁻¹ a := htff'.of_local_left_inverse (f.symm.continuous_at ha) hf' (f.eventually_right_inverse ha) /-- If `f (g y) = y` for `y` in some neighborhood of `a`, `g` is continuous at `a`, and `f` has an invertible derivative `f'` at `g a`, then `g` has the derivative `f'⁻¹` at `a`. This is one of the easy parts of the inverse function theorem: it assumes that we already have an inverse function. -/ theorem has_deriv_at.of_local_left_inverse {f g : 𝕜 → 𝕜} {f' a : 𝕜} (hg : continuous_at g a) (hf : has_deriv_at f f' (g a)) (hf' : f' ≠ 0) (hfg : ∀ᶠ y in 𝓝 a, f (g y) = y) : has_deriv_at g f'⁻¹ a := (hf.has_fderiv_at_equiv hf').of_local_left_inverse hg hfg /-- If `f` is a local homeomorphism defined on a neighbourhood of `f.symm a`, and `f` has an nonzero derivative `f'` at `f.symm a`, then `f.symm` has the derivative `f'⁻¹` at `a`. This is one of the easy parts of the inverse function theorem: it assumes that we already have an inverse function. -/ lemma local_homeomorph.has_deriv_at_symm (f : local_homeomorph 𝕜 𝕜) {a f' : 𝕜} (ha : a ∈ f.target) (hf' : f' ≠ 0) (htff' : has_deriv_at f f' (f.symm a)) : has_deriv_at f.symm f'⁻¹ a := htff'.of_local_left_inverse (f.symm.continuous_at ha) hf' (f.eventually_right_inverse ha) lemma has_deriv_at.eventually_ne (h : has_deriv_at f f' x) (hf' : f' ≠ 0) : ∀ᶠ z in 𝓝[≠] x, f z ≠ f x := (has_deriv_at_iff_has_fderiv_at.1 h).eventually_ne ⟨‖f'‖⁻¹, λ z, by field_simp [norm_smul, mt norm_eq_zero.1 hf']⟩ lemma has_deriv_at.tendsto_punctured_nhds (h : has_deriv_at f f' x) (hf' : f' ≠ 0) : tendsto f (𝓝[≠] x) (𝓝[≠] (f x)) := tendsto_nhds_within_of_tendsto_nhds_of_eventually_within _ h.continuous_at.continuous_within_at (h.eventually_ne hf') theorem not_differentiable_within_at_of_local_left_inverse_has_deriv_within_at_zero {f g : 𝕜 → 𝕜} {a : 𝕜} {s t : set 𝕜} (ha : a ∈ s) (hsu : unique_diff_within_at 𝕜 s a) (hf : has_deriv_within_at f 0 t (g a)) (hst : maps_to g s t) (hfg : f ∘ g =ᶠ[𝓝[s] a] id) : ¬differentiable_within_at 𝕜 g s a := begin intro hg, have := (hf.comp a hg.has_deriv_within_at hst).congr_of_eventually_eq_of_mem hfg.symm ha, simpa using hsu.eq_deriv _ this (has_deriv_within_at_id _ _) end theorem not_differentiable_at_of_local_left_inverse_has_deriv_at_zero {f g : 𝕜 → 𝕜} {a : 𝕜} (hf : has_deriv_at f 0 (g a)) (hfg : f ∘ g =ᶠ[𝓝 a] id) : ¬differentiable_at 𝕜 g a := begin intro hg, have := (hf.comp a hg.has_deriv_at).congr_of_eventually_eq hfg.symm, simpa using this.unique (has_deriv_at_id a) end end namespace polynomial /-! ### Derivative of a polynomial -/ variables {x : 𝕜} {s : set 𝕜} variable (p : 𝕜[X]) /-- The derivative (in the analysis sense) of a polynomial `p` is given by `p.derivative`. -/ protected lemma has_strict_deriv_at (x : 𝕜) : has_strict_deriv_at (λx, p.eval x) (p.derivative.eval x) x := begin apply p.induction_on, { simp [has_strict_deriv_at_const] }, { assume p q hp hq, convert hp.add hq; simp }, { assume n a h, convert h.mul (has_strict_deriv_at_id x), { ext y, simp [pow_add, mul_assoc] }, { simp only [pow_add, pow_one, derivative_mul, derivative_C, zero_mul, derivative_X_pow, derivative_X, mul_one, zero_add, eval_mul, eval_C, eval_add, eval_nat_cast, eval_pow, eval_X, id.def], ring } } end /-- The derivative (in the analysis sense) of a polynomial `p` is given by `p.derivative`. -/ protected lemma has_deriv_at (x : 𝕜) : has_deriv_at (λx, p.eval x) (p.derivative.eval x) x := (p.has_strict_deriv_at x).has_deriv_at protected theorem has_deriv_within_at (x : 𝕜) (s : set 𝕜) : has_deriv_within_at (λx, p.eval x) (p.derivative.eval x) s x := (p.has_deriv_at x).has_deriv_within_at protected lemma differentiable_at : differentiable_at 𝕜 (λx, p.eval x) x := (p.has_deriv_at x).differentiable_at protected lemma differentiable_within_at : differentiable_within_at 𝕜 (λx, p.eval x) s x := p.differentiable_at.differentiable_within_at protected lemma differentiable : differentiable 𝕜 (λx, p.eval x) := λx, p.differentiable_at protected lemma differentiable_on : differentiable_on 𝕜 (λx, p.eval x) s := p.differentiable.differentiable_on @[simp] protected lemma deriv : deriv (λx, p.eval x) x = p.derivative.eval x := (p.has_deriv_at x).deriv protected lemma deriv_within (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (λx, p.eval x) s x = p.derivative.eval x := begin rw differentiable_at.deriv_within p.differentiable_at hxs, exact p.deriv end protected lemma has_fderiv_at (x : 𝕜) : has_fderiv_at (λx, p.eval x) (smul_right (1 : 𝕜 →L[𝕜] 𝕜) (p.derivative.eval x)) x := p.has_deriv_at x protected lemma has_fderiv_within_at (x : 𝕜) : has_fderiv_within_at (λx, p.eval x) (smul_right (1 : 𝕜 →L[𝕜] 𝕜) (p.derivative.eval x)) s x := (p.has_fderiv_at x).has_fderiv_within_at @[simp] protected lemma fderiv : fderiv 𝕜 (λx, p.eval x) x = smul_right (1 : 𝕜 →L[𝕜] 𝕜) (p.derivative.eval x) := (p.has_fderiv_at x).fderiv protected lemma fderiv_within (hxs : unique_diff_within_at 𝕜 s x) : fderiv_within 𝕜 (λx, p.eval x) s x = smul_right (1 : 𝕜 →L[𝕜] 𝕜) (p.derivative.eval x) := (p.has_fderiv_within_at x).fderiv_within hxs end polynomial section pow /-! ### Derivative of `x ↦ x^n` for `n : ℕ` -/ variables {x : 𝕜} {s : set 𝕜} {c : 𝕜 → 𝕜} {c' : 𝕜} variable (n : ℕ) lemma has_strict_deriv_at_pow (n : ℕ) (x : 𝕜) : has_strict_deriv_at (λx, x^n) ((n : 𝕜) * x^(n-1)) x := begin convert (polynomial.C (1 : 𝕜) * (polynomial.X)^n).has_strict_deriv_at x, { simp }, { rw [polynomial.derivative_C_mul_X_pow], simp } end lemma has_deriv_at_pow (n : ℕ) (x : 𝕜) : has_deriv_at (λx, x^n) ((n : 𝕜) * x^(n-1)) x := (has_strict_deriv_at_pow n x).has_deriv_at theorem has_deriv_within_at_pow (n : ℕ) (x : 𝕜) (s : set 𝕜) : has_deriv_within_at (λx, x^n) ((n : 𝕜) * x^(n-1)) s x := (has_deriv_at_pow n x).has_deriv_within_at lemma differentiable_at_pow : differentiable_at 𝕜 (λx, x^n) x := (has_deriv_at_pow n x).differentiable_at lemma differentiable_within_at_pow : differentiable_within_at 𝕜 (λx, x^n) s x := (differentiable_at_pow n).differentiable_within_at lemma differentiable_pow : differentiable 𝕜 (λx:𝕜, x^n) := λ x, differentiable_at_pow n lemma differentiable_on_pow : differentiable_on 𝕜 (λx, x^n) s := (differentiable_pow n).differentiable_on lemma deriv_pow : deriv (λ x, x^n) x = (n : 𝕜) * x^(n-1) := (has_deriv_at_pow n x).deriv @[simp] lemma deriv_pow' : deriv (λ x, x^n) = λ x, (n : 𝕜) * x^(n-1) := funext $ λ x, deriv_pow n lemma deriv_within_pow (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (λx, x^n) s x = (n : 𝕜) * x^(n-1) := (has_deriv_within_at_pow n x s).deriv_within hxs lemma has_deriv_within_at.pow (hc : has_deriv_within_at c c' s x) : has_deriv_within_at (λ y, (c y)^n) ((n : 𝕜) * (c x)^(n-1) * c') s x := (has_deriv_at_pow n (c x)).comp_has_deriv_within_at x hc lemma has_deriv_at.pow (hc : has_deriv_at c c' x) : has_deriv_at (λ y, (c y)^n) ((n : 𝕜) * (c x)^(n-1) * c') x := by { rw ← has_deriv_within_at_univ at *, exact hc.pow n } lemma deriv_within_pow' (hc : differentiable_within_at 𝕜 c s x) (hxs : unique_diff_within_at 𝕜 s x) : deriv_within (λx, (c x)^n) s x = (n : 𝕜) * (c x)^(n-1) * (deriv_within c s x) := (hc.has_deriv_within_at.pow n).deriv_within hxs @[simp] lemma deriv_pow'' (hc : differentiable_at 𝕜 c x) : deriv (λx, (c x)^n) x = (n : 𝕜) * (c x)^(n-1) * (deriv c x) := (hc.has_deriv_at.pow n).deriv end pow section zpow /-! ### Derivative of `x ↦ x^m` for `m : ℤ` -/ variables {E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E] {x : 𝕜} {s : set 𝕜} {m : ℤ} lemma has_strict_deriv_at_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) : has_strict_deriv_at (λx, x^m) ((m : 𝕜) * x^(m-1)) x := begin have : ∀ m : ℤ, 0 < m → has_strict_deriv_at (λx, x^m) ((m:𝕜) * x^(m-1)) x, { assume m hm, lift m to ℕ using (le_of_lt hm), simp only [zpow_coe_nat, int.cast_coe_nat], convert has_strict_deriv_at_pow _ _ using 2, rw [← int.coe_nat_one, ← int.coe_nat_sub, zpow_coe_nat], norm_cast at hm, exact nat.succ_le_of_lt hm }, rcases lt_trichotomy m 0 with hm|hm|hm, { have hx : x ≠ 0, from h.resolve_right hm.not_le, have := (has_strict_deriv_at_inv _).scomp _ (this (-m) (neg_pos.2 hm)); [skip, exact zpow_ne_zero_of_ne_zero hx _], simp only [(∘), zpow_neg, one_div, inv_inv, smul_eq_mul] at this, convert this using 1, rw [sq, mul_inv, inv_inv, int.cast_neg, neg_mul, neg_mul_neg, ← zpow_add₀ hx, mul_assoc, ← zpow_add₀ hx], congr, abel }, { simp only [hm, zpow_zero, int.cast_zero, zero_mul, has_strict_deriv_at_const] }, { exact this m hm } end lemma has_deriv_at_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) : has_deriv_at (λx, x^m) ((m : 𝕜) * x^(m-1)) x := (has_strict_deriv_at_zpow m x h).has_deriv_at theorem has_deriv_within_at_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) (s : set 𝕜) : has_deriv_within_at (λx, x^m) ((m : 𝕜) * x^(m-1)) s x := (has_deriv_at_zpow m x h).has_deriv_within_at lemma differentiable_at_zpow : differentiable_at 𝕜 (λx, x^m) x ↔ x ≠ 0 ∨ 0 ≤ m := ⟨λ H, normed_field.continuous_at_zpow.1 H.continuous_at, λ H, (has_deriv_at_zpow m x H).differentiable_at⟩ lemma differentiable_within_at_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) : differentiable_within_at 𝕜 (λx, x^m) s x := (differentiable_at_zpow.mpr h).differentiable_within_at lemma differentiable_on_zpow (m : ℤ) (s : set 𝕜) (h : (0 : 𝕜) ∉ s ∨ 0 ≤ m) : differentiable_on 𝕜 (λx, x^m) s := λ x hxs, differentiable_within_at_zpow m x $ h.imp_left $ ne_of_mem_of_not_mem hxs lemma deriv_zpow (m : ℤ) (x : 𝕜) : deriv (λ x, x ^ m) x = m * x ^ (m - 1) := begin by_cases H : x ≠ 0 ∨ 0 ≤ m, { exact (has_deriv_at_zpow m x H).deriv }, { rw deriv_zero_of_not_differentiable_at (mt differentiable_at_zpow.1 H), push_neg at H, rcases H with ⟨rfl, hm⟩, rw [zero_zpow _ ((sub_one_lt _).trans hm).ne, mul_zero] } end @[simp] lemma deriv_zpow' (m : ℤ) : deriv (λ x : 𝕜, x ^ m) = λ x, m * x ^ (m - 1) := funext $ deriv_zpow m lemma deriv_within_zpow (hxs : unique_diff_within_at 𝕜 s x) (h : x ≠ 0 ∨ 0 ≤ m) : deriv_within (λx, x^m) s x = (m : 𝕜) * x^(m-1) := (has_deriv_within_at_zpow m x h s).deriv_within hxs @[simp] lemma iter_deriv_zpow' (m : ℤ) (k : ℕ) : deriv^[k] (λ x : 𝕜, x ^ m) = λ x, (∏ i in finset.range k, (m - i)) * x ^ (m - k) := begin induction k with k ihk, { simp only [one_mul, int.coe_nat_zero, id, sub_zero, finset.prod_range_zero, function.iterate_zero] }, { simp only [function.iterate_succ_apply', ihk, deriv_const_mul_field', deriv_zpow', finset.prod_range_succ, int.coe_nat_succ, ← sub_sub, int.cast_sub, int.cast_coe_nat, mul_assoc], } end lemma iter_deriv_zpow (m : ℤ) (x : 𝕜) (k : ℕ) : deriv^[k] (λ y, y ^ m) x = (∏ i in finset.range k, (m - i)) * x ^ (m - k) := congr_fun (iter_deriv_zpow' m k) x lemma iter_deriv_pow (n : ℕ) (x : 𝕜) (k : ℕ) : deriv^[k] (λx:𝕜, x^n) x = (∏ i in finset.range k, (n - i)) * x^(n-k) := begin simp only [← zpow_coe_nat, iter_deriv_zpow, int.cast_coe_nat], cases le_or_lt k n with hkn hnk, { rw int.coe_nat_sub hkn }, { have : ∏ i in finset.range k, (n - i : 𝕜) = 0, from finset.prod_eq_zero (finset.mem_range.2 hnk) (sub_self _), simp only [this, zero_mul] } end @[simp] lemma iter_deriv_pow' (n k : ℕ) : deriv^[k] (λ x : 𝕜, x ^ n) = λ x, (∏ i in finset.range k, (n - i)) * x ^ (n - k) := funext $ λ x, iter_deriv_pow n x k lemma iter_deriv_inv (k : ℕ) (x : 𝕜) : deriv^[k] has_inv.inv x = (∏ i in finset.range k, (-1 - i)) * x ^ (-1 - k : ℤ) := by simpa only [zpow_neg_one, int.cast_neg, int.cast_one] using iter_deriv_zpow (-1) x k @[simp] lemma iter_deriv_inv' (k : ℕ) : deriv^[k] has_inv.inv = λ x : 𝕜, (∏ i in finset.range k, (-1 - i)) * x ^ (-1 - k : ℤ) := funext (iter_deriv_inv k) variables {f : E → 𝕜} {t : set E} {a : E} lemma differentiable_within_at.zpow (hf : differentiable_within_at 𝕜 f t a) (h : f a ≠ 0 ∨ 0 ≤ m) : differentiable_within_at 𝕜 (λ x, f x ^ m) t a := (differentiable_at_zpow.2 h).comp_differentiable_within_at a hf lemma differentiable_at.zpow (hf : differentiable_at 𝕜 f a) (h : f a ≠ 0 ∨ 0 ≤ m) : differentiable_at 𝕜 (λ x, f x ^ m) a := (differentiable_at_zpow.2 h).comp a hf lemma differentiable_on.zpow (hf : differentiable_on 𝕜 f t) (h : (∀ x ∈ t, f x ≠ 0) ∨ 0 ≤ m) : differentiable_on 𝕜 (λ x, f x ^ m) t := λ x hx, (hf x hx).zpow $ h.imp_left (λ h, h x hx) lemma differentiable.zpow (hf : differentiable 𝕜 f) (h : (∀ x, f x ≠ 0) ∨ 0 ≤ m) : differentiable 𝕜 (λ x, f x ^ m) := λ x, (hf x).zpow $ h.imp_left (λ h, h x) end zpow /-! ### Support of derivatives -/ section support open function variables {F : Type*} [normed_add_comm_group F] [normed_space 𝕜 F] {f : 𝕜 → F} lemma support_deriv_subset : support (deriv f) ⊆ tsupport f := begin intros x, rw [← not_imp_not], intro h2x, rw [not_mem_tsupport_iff_eventually_eq] at h2x, exact nmem_support.mpr (h2x.deriv_eq.trans (deriv_const x 0)) end lemma has_compact_support.deriv (hf : has_compact_support f) : has_compact_support (deriv f) := hf.mono' support_deriv_subset end support /-! ### Upper estimates on liminf and limsup -/ section real variables {f : ℝ → ℝ} {f' : ℝ} {s : set ℝ} {x : ℝ} {r : ℝ} lemma has_deriv_within_at.limsup_slope_le (hf : has_deriv_within_at f f' s x) (hr : f' < r) : ∀ᶠ z in 𝓝[s \ {x}] x, slope f x z < r := has_deriv_within_at_iff_tendsto_slope.1 hf (is_open.mem_nhds is_open_Iio hr) lemma has_deriv_within_at.limsup_slope_le' (hf : has_deriv_within_at f f' s x) (hs : x ∉ s) (hr : f' < r) : ∀ᶠ z in 𝓝[s] x, slope f x z < r := (has_deriv_within_at_iff_tendsto_slope' hs).1 hf (is_open.mem_nhds is_open_Iio hr) lemma has_deriv_within_at.liminf_right_slope_le (hf : has_deriv_within_at f f' (Ici x) x) (hr : f' < r) : ∃ᶠ z in 𝓝[>] x, slope f x z < r := (hf.Ioi_of_Ici.limsup_slope_le' (lt_irrefl x) hr).frequently end real section real_space open metric variables {E : Type u} [normed_add_comm_group E] [normed_space ℝ E] {f : ℝ → E} {f' : E} {s : set ℝ} {x r : ℝ} /-- If `f` has derivative `f'` within `s` at `x`, then for any `r > ‖f'‖` the ratio `‖f z - f x‖ / ‖z - x‖` is less than `r` in some neighborhood of `x` within `s`. In other words, the limit superior of this ratio as `z` tends to `x` along `s` is less than or equal to `‖f'‖`. -/ lemma has_deriv_within_at.limsup_norm_slope_le (hf : has_deriv_within_at f f' s x) (hr : ‖f'‖ < r) : ∀ᶠ z in 𝓝[s] x, ‖z - x‖⁻¹ * ‖f z - f x‖ < r := begin have hr₀ : 0 < r, from lt_of_le_of_lt (norm_nonneg f') hr, have A : ∀ᶠ z in 𝓝[s \ {x}] x, ‖(z - x)⁻¹ • (f z - f x)‖ ∈ Iio r, from (has_deriv_within_at_iff_tendsto_slope.1 hf).norm (is_open.mem_nhds is_open_Iio hr), have B : ∀ᶠ z in 𝓝[{x}] x, ‖(z - x)⁻¹ • (f z - f x)‖ ∈ Iio r, from mem_of_superset self_mem_nhds_within (singleton_subset_iff.2 $ by simp [hr₀]), have C := mem_sup.2 ⟨A, B⟩, rw [← nhds_within_union, diff_union_self, nhds_within_union, mem_sup] at C, filter_upwards [C.1], simp only [norm_smul, mem_Iio, norm_inv], exact λ _, id end /-- If `f` has derivative `f'` within `s` at `x`, then for any `r > ‖f'‖` the ratio `(‖f z‖ - ‖f x‖) / ‖z - x‖` is less than `r` in some neighborhood of `x` within `s`. In other words, the limit superior of this ratio as `z` tends to `x` along `s` is less than or equal to `‖f'‖`. This lemma is a weaker version of `has_deriv_within_at.limsup_norm_slope_le` where `‖f z‖ - ‖f x‖` is replaced by `‖f z - f x‖`. -/ lemma has_deriv_within_at.limsup_slope_norm_le (hf : has_deriv_within_at f f' s x) (hr : ‖f'‖ < r) : ∀ᶠ z in 𝓝[s] x, ‖z - x‖⁻¹ * (‖f z‖ - ‖f x‖) < r := begin apply (hf.limsup_norm_slope_le hr).mono, assume z hz, refine lt_of_le_of_lt (mul_le_mul_of_nonneg_left (norm_sub_norm_le _ _) _) hz, exact inv_nonneg.2 (norm_nonneg _) end /-- If `f` has derivative `f'` within `(x, +∞)` at `x`, then for any `r > ‖f'‖` the ratio `‖f z - f x‖ / ‖z - x‖` is frequently less than `r` as `z → x+0`. In other words, the limit inferior of this ratio as `z` tends to `x+0` is less than or equal to `‖f'‖`. See also `has_deriv_within_at.limsup_norm_slope_le` for a stronger version using limit superior and any set `s`. -/ lemma has_deriv_within_at.liminf_right_norm_slope_le (hf : has_deriv_within_at f f' (Ici x) x) (hr : ‖f'‖ < r) : ∃ᶠ z in 𝓝[>] x, ‖z - x‖⁻¹ * ‖f z - f x‖ < r := (hf.Ioi_of_Ici.limsup_norm_slope_le hr).frequently /-- If `f` has derivative `f'` within `(x, +∞)` at `x`, then for any `r > ‖f'‖` the ratio `(‖f z‖ - ‖f x‖) / (z - x)` is frequently less than `r` as `z → x+0`. In other words, the limit inferior of this ratio as `z` tends to `x+0` is less than or equal to `‖f'‖`. See also * `has_deriv_within_at.limsup_norm_slope_le` for a stronger version using limit superior and any set `s`; * `has_deriv_within_at.liminf_right_norm_slope_le` for a stronger version using `‖f z - f x‖` instead of `‖f z‖ - ‖f x‖`. -/ lemma has_deriv_within_at.liminf_right_slope_norm_le (hf : has_deriv_within_at f f' (Ici x) x) (hr : ‖f'‖ < r) : ∃ᶠ z in 𝓝[>] x, (z - x)⁻¹ * (‖f z‖ - ‖f x‖) < r := begin have := (hf.Ioi_of_Ici.limsup_slope_norm_le hr).frequently, refine this.mp (eventually.mono self_mem_nhds_within _), assume z hxz hz, rwa [real.norm_eq_abs, abs_of_pos (sub_pos_of_lt hxz)] at hz end end real_space
[STATEMENT] theorem "map g (map f xs) = map (f o g) xs" [PROOF STATE] proof (prove) goal (1 subgoal): 1. map g (map f xs) = map (f \<circ> g) xs [PROOF STEP] quickcheck[random, expect = counterexample] [PROOF STATE] proof (prove) goal (1 subgoal): 1. map g (map f xs) = map (f \<circ> g) xs [PROOF STEP] quickcheck[exhaustive, expect = counterexample] [PROOF STATE] proof (prove) goal (1 subgoal): 1. map g (map f xs) = map (f \<circ> g) xs [PROOF STEP] oops
/** * Copyright (C) 2018-present MongoDB, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the Server Side Public License, version 1, * as published by MongoDB, Inc. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Server Side Public License for more details. * * You should have received a copy of the Server Side Public License * along with this program. If not, see * <http://www.mongodb.com/licensing/server-side-public-license>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the Server Side Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #include "mongo/platform/basic.h" #include "mongo/db/storage/remove_saver.h" #include <boost/filesystem/operations.hpp> #include <fstream> #include <ios> #include "mongo/db/service_context.h" #include "mongo/db/storage/encryption_hooks.h" #include "mongo/db/storage/storage_options.h" #include "mongo/logv2/log.h" #include "mongo/util/errno_util.h" #define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kStorage using std::ios_base; using std::ofstream; using std::string; using std::stringstream; namespace mongo { RemoveSaver::RemoveSaver(const string& a, const string& b, const string& why, std::unique_ptr<Storage> storage) : _storage(std::move(storage)) { static int NUM = 0; _root = storageGlobalParams.dbpath; if (a.size()) _root /= a; if (b.size()) _root /= b; verify(a.size() || b.size()); _file = _root; stringstream ss; ss << why << "." << terseCurrentTimeForFilename() << "." << NUM++ << ".bson"; _file /= ss.str(); auto encryptionHooks = EncryptionHooks::get(getGlobalServiceContext()); if (encryptionHooks->enabled()) { _protector = encryptionHooks->getDataProtector(); _file += encryptionHooks->getProtectedPathSuffix(); } } RemoveSaver::~RemoveSaver() { if (_protector && _out) { auto encryptionHooks = EncryptionHooks::get(getGlobalServiceContext()); invariant(encryptionHooks->enabled()); size_t protectedSizeMax = encryptionHooks->additionalBytesForProtectedBuffer(); std::unique_ptr<uint8_t[]> protectedBuffer(new uint8_t[protectedSizeMax]); size_t resultLen; Status status = _protector->finalize(protectedBuffer.get(), protectedSizeMax, &resultLen); if (!status.isOK()) { LOGV2_FATAL(34350, "Unable to finalize DataProtector while closing RemoveSaver: {error}", "Unable to finalize DataProtector while closing RemoveSaver", "error"_attr = redact(status)); } _out->write(reinterpret_cast<const char*>(protectedBuffer.get()), resultLen); if (_out->fail()) { auto ec = lastSystemError(); LOGV2_FATAL(34351, "Couldn't write finalized DataProtector data to: {file} for remove " "saving: {error}", "Couldn't write finalized DataProtector for remove saving", "file"_attr = _file.generic_string(), "error"_attr = redact(errorMessage(ec))); } protectedBuffer.reset(new uint8_t[protectedSizeMax]); status = _protector->finalizeTag(protectedBuffer.get(), protectedSizeMax, &resultLen); if (!status.isOK()) { LOGV2_FATAL( 34352, "Unable to get finalizeTag from DataProtector while closing RemoveSaver: {error}", "Unable to get finalizeTag from DataProtector while closing RemoveSaver", "error"_attr = redact(status)); } if (resultLen != _protector->getNumberOfBytesReservedForTag()) { LOGV2_FATAL(34353, "Attempted to write tag of size {sizeBytes} when DataProtector only " "reserved {reservedBytes} bytes", "Attempted to write tag of larger size than DataProtector reserved size", "sizeBytes"_attr = resultLen, "reservedBytes"_attr = _protector->getNumberOfBytesReservedForTag()); } _out->seekp(0); _out->write(reinterpret_cast<const char*>(protectedBuffer.get()), resultLen); if (_out->fail()) { auto ec = lastSystemError(); LOGV2_FATAL(34354, "Couldn't write finalizeTag from DataProtector to: {file} for " "remove saving: {error}", "Couldn't write finalizeTag from DataProtector for remove saving", "file"_attr = _file.generic_string(), "error"_attr = redact(errorMessage(ec))); } _storage->dumpBuffer(); } } Status RemoveSaver::goingToDelete(const BSONObj& o) { if (!_out) { _out = _storage->makeOstream(_file, _root); if (_out->fail()) { auto ec = lastSystemError(); string msg = str::stream() << "couldn't create file: " << _file.string() << " for remove saving: " << redact(errorMessage(ec)); LOGV2_ERROR(23734, "Failed to create file for remove saving", "file"_attr = _file.generic_string(), "error"_attr = redact(errorMessage(ec))); _out.reset(); _out = nullptr; return Status(ErrorCodes::FileNotOpen, msg); } } const uint8_t* data = reinterpret_cast<const uint8_t*>(o.objdata()); size_t dataSize = o.objsize(); std::unique_ptr<uint8_t[]> protectedBuffer; if (_protector) { auto encryptionHooks = EncryptionHooks::get(getGlobalServiceContext()); invariant(encryptionHooks->enabled()); size_t protectedSizeMax = dataSize + encryptionHooks->additionalBytesForProtectedBuffer(); protectedBuffer.reset(new uint8_t[protectedSizeMax]); size_t resultLen; Status status = _protector->protect( data, dataSize, protectedBuffer.get(), protectedSizeMax, &resultLen); if (!status.isOK()) { return status; } data = protectedBuffer.get(); dataSize = resultLen; } _out->write(reinterpret_cast<const char*>(data), dataSize); if (_out->fail()) { auto errorStr = redact(errorMessage(lastSystemError())); string msg = str::stream() << "couldn't write document to file: " << _file.string() << " for remove saving: " << errorStr; LOGV2_ERROR(23735, "Couldn't write document to file for remove saving", "file"_attr = _file.generic_string(), "error"_attr = errorStr); return Status(ErrorCodes::OperationFailed, msg); } return Status::OK(); } std::unique_ptr<std::ostream> RemoveSaver::Storage::makeOstream( const boost::filesystem::path& file, const boost::filesystem::path& root) { // We don't expect to ever pass "" to create_directories below, but catch // this anyway as per SERVER-26412. invariant(!root.empty()); boost::filesystem::create_directories(root); return std::make_unique<std::ofstream>(file.string().c_str(), std::ios_base::out | std::ios_base::binary); } } // namespace mongo
theorem le_trans (a b c : mynat) (hab : a ≤ b) (hbc : b ≤ c) : a ≤ c := begin cases hab with s hs, cases hbc with t ht, use (s + t), rwa [ht, hs, add_assoc], end
The derivative of the part of a circle path from $s$ to $t$ is $\iota r (t - s) \exp(\iota \text{ linepath } s t x)$.
import tactic import data.int.parity import data.int.modeq import data.nat.factorization.basic import number_theory.legendre_symbol.quadratic_reciprocity import Mordell.CongruencesMod4 -- this should be PR'ed in Kevin's opinion! lemma int.modeq_def {a b n : ℤ} : a ≡ b [ZMOD n] ↔ a % n = b % n := iff.rfl -- as should this lemma nat.modeq_def {a b n : ℕ} : a ≡ b [MOD n] ↔ a % n = b % n := iff.rfl lemma int.exists_nat_of_nonneg {z : ℤ} (hz : 0 ≤ z) : ∃ n : ℕ, (n : ℤ) = z := ⟨z.nat_abs, int.nat_abs_of_nonneg hz⟩ theorem modeq_add_fac_self {a t n : ℤ} : a + n * t ≡ a [ZMOD n] := int.modeq_add_fac _ int.modeq.rfl theorem modeq_iff_add_fac {a b n : ℤ} : a ≡ b [ZMOD n] ↔ ∃ t, b = a + n * t := begin rw int.modeq_iff_dvd, exact exists_congr (λ t, sub_eq_iff_eq_add'), end lemma prime_factor_congr_3_mod_4 (x a : ℤ) (h : x^2 - a*x + a^2 ≡ 3 [ZMOD 4]) : ∃ (p : ℕ), p.prime ∧ (p : ℤ) ∣ (x^2 - a*x + a^2) ∧ p ≡ 3 [MOD 4] := begin have h2 : 0 ≤ x^2 - a*x + a^2 := by nlinarith, obtain ⟨n, hn⟩ := int.exists_nat_of_nonneg h2, rw ← hn at h, have h3 : n ≡ 3 [MOD 4], { rw int.modeq_def at h, rw nat.modeq_def, assumption_mod_cast }, obtain ⟨p, hp1, hp2, hp3⟩ := three_modulo_four_prime_factor n h3, refine ⟨p, hp1, _, hp3⟩, rwa [← hn, int.coe_nat_dvd], end lemma cube_minus_one_no_solns_aux (x y n a : ℤ) (hx : n ≡ 3 [ZMOD 4]) (ha : a ≡ 2 [ZMOD 4]) (hy : n + 1 = a^3): y^2 ≠ x^3 + n := begin intro heq, have oddx: odd x, { apply int.odd_iff_not_even.2, intro h, rw even_iff_two_dvd at h, have h3: 0 < 3:= by norm_num, rw ← int.pow_dvd_pow_iff h3 at h, norm_num at h, rw ← int.modeq_zero_iff_dvd at h, have h2 := int.modeq.add_right n h, rw ← heq at h2, norm_num at h2, apply int.square_ne_three_mod_four y, have h6: (4 : ℤ ) ∣ 8:= by norm_num, have h5:= int.modeq.modeq_of_dvd h6 h2, unfold int.modeq at h5 ⊢, rw h5, rw int.modeq at hx, exact hx, }, have h2 : y^2+1=(x+a)*(x^2 - a*x + a^2), { rw heq, ring_nf, rw hy, }, have h6 : x^2 - a*x + a^2 ≡ 3 [ZMOD 4], { rcases oddx with ⟨b,rfl⟩, ring_nf, symmetry, rcases modeq_iff_add_fac.1 ha.symm with ⟨t, rfl⟩, have htemp : (4 * b + (-(2 * (2 + 4 * t)) + 4)) * b + ((2 + 4 * t - 1) * (2 + 4 * t) + 1) = 3 + 4 * (b^2 - 2*t*b + (4*t^2 + 3*t)), { ring }, rw htemp, exact modeq_add_fac_self.symm, }, obtain ⟨p, hp, hpd, hp4⟩ := prime_factor_congr_3_mod_4 x a h6, have h9 : ↑p∣y^2 + 1, { rw h2, exact dvd_mul_of_dvd_right hpd (x + a), }, haveI : fact (nat.prime p) := ⟨hp⟩, set yp : zmod p := y with hyp0, have hyp : yp^2 = -1, { rw ← zmod.int_coe_zmod_eq_zero_iff_dvd at h9, push_cast at h9, linear_combination h9, }, apply zmod.mod_four_ne_three_of_sq_eq_neg_one hyp, rw nat.modeq at hp4, norm_num at hp4, assumption, end theorem cube_minus_one_no_solns : ¬ ∃ x y t : ℤ, y^2 = x^3 + 64*t^3 + 96*t^2 + 48*t + 7 := begin rintro ⟨x, y, t, h⟩, apply cube_minus_one_no_solns_aux x y (64*t^3 + 96*t^2 + 48*t + 7) (4*t+2), { rw (show 64*t^3 + 96*t^2 + 48*t + 7 = 3 + 4 * (16*t^3 + 24*t^2 + 12*t + 1), by ring), apply modeq_add_fac_self, }, { rw add_comm, apply modeq_add_fac_self, }, { ring, }, { linear_combination h, }, end example : ¬ ∃ x y : ℤ, y^2=x^3-9 := begin rintro ⟨x, y, h⟩, apply cube_minus_one_no_solns, use [x,y,-1], rw h, ring, end
/** * * @file testing_zcungesv.c * * PLASMA testing routines * PLASMA is a software package provided by Univ. of Tennessee, * Univ. of California Berkeley and Univ. of Colorado Denver * * @version 2.6.0 * @author Emmanuel Agullo * @date 2010-11-15 * @precisions mixed zc -> ds * **/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <plasma.h> #include <cblas.h> #include <lapacke.h> #include <core_blas.h> #include "testing_zmain.h" static int check_solution(int, int, PLASMA_Complex64_t*, int, PLASMA_Complex64_t*, PLASMA_Complex64_t*, int, double); int testing_zcungesv(int argc, char **argv) { /* Check for number of arguments*/ if (argc != 4){ USAGE("CUNGESV", "N LDA NRHS LDB", " - N : the size of the matrix\n" " - LDA : leading dimension of the matrix A\n" " - NRHS : number of RHS\n" " - LDB : leading dimension of the RHS B\n"); return -1; } int N = atoi(argv[0]); int LDA = atoi(argv[1]); int NRHS = atoi(argv[2]); int LDB = atoi(argv[3]); int ITER; double eps; int info, info_solution; int i,j; int LDAxN = LDA*N; int LDBxNRHS = LDB*NRHS; PLASMA_Complex64_t *A1 = (PLASMA_Complex64_t *)malloc(LDA*N *sizeof(PLASMA_Complex64_t)); PLASMA_Complex64_t *A2 = (PLASMA_Complex64_t *)malloc(LDA*N *sizeof(PLASMA_Complex64_t)); PLASMA_Complex64_t *B1 = (PLASMA_Complex64_t *)malloc(LDB*NRHS*sizeof(PLASMA_Complex64_t)); PLASMA_Complex64_t *B2 = (PLASMA_Complex64_t *)malloc(LDB*NRHS*sizeof(PLASMA_Complex64_t)); /* Check if unable to allocate memory */ if ( (!A1) || (!A2) || (!B1) || (!B2) ) { printf("Out of Memory \n "); exit(0); } eps = LAPACKE_dlamch_work('e'); /*---------------------------------------------------------- * TESTING ZCGELS */ /* Initialize A1 and A2 */ LAPACKE_zlarnv_work(IONE, ISEED, LDAxN, A1); for (i = 0; i < N; i++) for (j = 0; j < N; j++) A2[LDA*j+i] = A1[LDA*j+i] ; /* Initialize B1 and B2 */ LAPACKE_zlarnv_work(IONE, ISEED, LDBxNRHS, B1); for (i = 0; i < N; i++) for (j = 0; j < NRHS; j++) B2[LDB*j+i] = B1[LDB*j+i] ; printf("\n"); printf("------ TESTS FOR PLASMA ZCUNGESV ROUTINE ------- \n"); printf(" Size of the Matrix %d by %d\n", N, N); printf("\n"); printf(" The matrix A is randomly generated for each test.\n"); printf("============\n"); printf(" The relative machine precision (eps) is to be %e \n",eps); printf(" Computational tests pass if scaled residuals are less than 60.\n"); /* PLASMA ZCUNGESV */ info = PLASMA_zcungesv(PlasmaNoTrans, N, NRHS, A2, LDA, B1, LDB, B2, LDB, &ITER); if (info != PLASMA_SUCCESS ) { printf("PLASMA_zcposv is not completed: info = %d\n", info); info_solution = 1; } else { printf(" Solution obtained with %d iterations\n", ITER); /* Check the orthogonality, factorization and the solution */ info_solution = check_solution(N, NRHS, A1, LDA, B1, B2, LDB, eps); } if (info_solution == 0) { printf("***************************************************\n"); printf(" ---- TESTING ZCUNGESV.................... PASSED !\n"); printf("***************************************************\n"); } else { printf("************************************************\n"); printf(" - TESTING ZCUNGESV .. FAILED !\n"); printf("************************************************\n"); } free(A1); free(A2); free(B1); free(B2); return 0; } /*-------------------------------------------------------------- * Check the solution */ static int check_solution(int N, int NRHS, PLASMA_Complex64_t *A1, int LDA, PLASMA_Complex64_t *B1, PLASMA_Complex64_t *B2, int LDB, double eps ) { int info_solution; double Rnorm, Anorm, Xnorm, Bnorm, result; PLASMA_Complex64_t alpha, beta; double *work = (double *)malloc(N*sizeof(double)); alpha = 1.0; beta = -1.0; Anorm = LAPACKE_zlange_work(LAPACK_COL_MAJOR, lapack_const(PlasmaInfNorm), N, N, A1, LDA, work); Xnorm = LAPACKE_zlange_work(LAPACK_COL_MAJOR, lapack_const(PlasmaInfNorm), N, NRHS, B2, LDB, work); Bnorm = LAPACKE_zlange_work(LAPACK_COL_MAJOR, lapack_const(PlasmaInfNorm), N, NRHS, B1, LDB, work); cblas_zgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, N, NRHS, N, CBLAS_SADDR(alpha), A1, LDA, B2, LDB, CBLAS_SADDR(beta), B1, LDB); Rnorm = LAPACKE_zlange_work(LAPACK_COL_MAJOR, lapack_const(PlasmaInfNorm), N, NRHS, B1, LDB, work); if (getenv("PLASMA_TESTING_VERBOSE")) printf( "||A||_oo=%f\n||X||_oo=%f\n||B||_oo=%f\n||A X - B||_oo=%e\n", Anorm, Xnorm, Bnorm, Rnorm ); result = Rnorm / ( (Anorm*Xnorm+Bnorm)*N*eps ) ; printf("============\n"); printf("Checking the Residual of the solution \n"); printf("-- ||Ax-B||_oo/((||A||_oo||x||_oo+||B||_oo).N.eps) = %e \n", result); if ( isnan(Xnorm) || isinf(Xnorm) || isnan(result) || isinf(result) || (result > 60.0) ) { printf("-- The solution is suspicious ! \n"); info_solution = 1; } else{ printf("-- The solution is CORRECT ! \n"); info_solution = 0; } free(work); return info_solution; }
PROGRAM findcenter implicit none include 'gbvtd_parameter.f' INTEGER IMAX,JMAX,KMAX,i,j real SX,SY,SZ,XZ,YZ,ZZ,ox(20),oy(20),Eps,x_len(20),y_len(20) real dz(nx,ny),ve(nx,ny),hgt,radii,value,ox_inc(20),oy_inc(20) real mwind(50),mean_wind_new Integer flag1,flag2,iz1,numgap,gap(5),kc,k,k1,k2,n integer ring_start,ring_end,It_max,rflag,iii,ii,ring Integer*2 id(510),ni,n_vol real vert_x, vert_y, vert_x_mean, vert_y_mean,a,b,ring_width complex vert_sum,vert_mean,vert_good,ai real gooddone,sd,mean_std,mean_std_new real vert_x_mean_new,vert_y_mean_new,vert_std_new,wind,mean_wind real ox1,oy1,radii_temp,vert_std,xctr(50),yctr(50),zone integer radi_beg, radi_end, radi_inc,num_x,num_y integer nargs,iargc integer*2 field1,field2 logical P_Max character*80 fname(20),infile,outfile_sum(20),outfile_ind(20) c common /gbvtd_p/ flag1,flag2,gap,id,ring_start,ring_end,rflag, X zone,num_x, num_y common /CRITR/Eps,It_Max common /MaxMin/P_Max common /goodverts/ k1,k2,radi_beg,radi_end common /std/ sd imax=nx jmax=ny kmax=nz c C read parameter file nargs=iargc() if(nargs.gt.0) then call getarg(1,infile) else print *, 'Please enter input file name:' read *, infile endif OPEN(12,FILE=infile,STATUS='OLD') read(12,111)flag1 read(12,111)flag2 read(12,115)field1,field2 read(12,111)K1 !lower z-level read(12,111)K2 !upper z-level read(12,111)numgap do i=1,numgap read(12,111)gap(i) enddo read(12,111)radi_beg read(12,111)radi_end read(12,113)zone read(12,111)rflag !write GBVTD results or not 111 format(i3) 112 format(a20) read(12,111)P_Max read(12,113)radii !radius of influence for circle of SIMPLEX read(12,113)Eps !converging criteria (initial value 0.001) read(12,111)It_Max !Max number of iterations read(12,111)n_vol 113 format(f8.2, f8.2) 115 format(a2,/,a2) call intswap(field1,field1) call intswap(field2,field2) do ni=1,n_vol READ(12,'(a80)')FNAME(ni) read(12,113)ox(ni),oy(ni) read(12,113)ox_inc(ni), oy_inc(ni) read(12,113)x_len(ni),y_len(ni) read(12,'(a80)') outfile_ind(ni) read(12,'(a80)') outfile_sum(ni) OPEN(60,FILE=outfile_ind(ni),STATUS='unknown',FORM='FORMATTED') OPEN(70,FILE=outfile_sum(ni),STATUS='unknown',FORM='FORMATTED') OPEN(10,FILE=fname(ni),STATUS='UNKNOWN',FORM='FORMATTED') c DO ring=radi_beg, radi_end ring_start=ring ring_end=ring write(70,114) ring_start, zone write(60,114) ring_start, zone 114 format(i3,'-',f8.2) c print *, 'Eps=',Eps,' It_Max=',It_Max DO K=k1,k2 write(1,'("Processing data from level #",i2/)') k CALL READDATA(DZ,VE,10,K,id,imax,jmax,2,field1,field2) num_x=id(162) num_y=id(167) c altitude HGT=float(id(170)+(k-1)*id(173))/1000. write(60,61) HGT 61 format('Height= ', f8.2) c c xctr,yctr : position of first guess center location c in 3-D Doppler arrays use olat,olon c rad : influence radius for circle that circumscribes the simplex c typically use 4 km c data : array of wd/ws values form one level in the 3-D Doppler array c imax,jmax : data array dimensions c sx,sy : resolution of the data array c radi (2) : inner and outer radial limits for computation of TANW c write(*,'(" * Finding center on level #",i2/)') k write(*,'("* Finding center at",f4.1," km")') hgt vert_x=0. vert_y=0. iii=0 ii=0 vert_std=0. vert_std_new=0. vert_x_mean=0. vert_y_mean=0. vert_x_mean_new=0. vert_y_mean_new=0. wind=0. mean_wind=0. mean_wind_new=0. mean_std=0. mean_std_new=0. do i=1,int(x_len(ni)/ox_inc(ni))+1 do j=1,int(y_len(ni)/oy_inc(ni))+1 radii_temp=radii !reset radius of influence to initial value ox1=ox(ni)+(i-1)*ox_inc(ni) oy1=oy(ni)+(j-1)*oy_inc(ni) print *, 'processing initial center guess at', ox1,oy1 call SIMCON(ox1,oy1,radii_temp,dz,ve,imax,jmax,sx,sy, X value,wind) if (wind .le. 100.) then iii=iii+1 xctr(iii)=ox1 yctr(iii)=oy1 mwind(iii)=wind vert_x=vert_x+xctr(iii) vert_y=vert_y+yctr(iii) mean_wind=mean_wind+mwind(iii) endif enddo enddo vert_x_mean=vert_x/float(iii) vert_y_mean=vert_y/float(iii) mean_wind=mean_wind/float(iii) do i=1,iii vert_std=vert_std+(xctr(i)-vert_x_mean)**2 X +(yctr(i)-vert_y_mean)**2 mean_std=mean_std+(mwind(i)-mean_wind)**2 enddo vert_std=sqrt(vert_std/float(iii)) mean_std=sqrt(mean_std/float(iii)) do i=1,iii if(sqrt((xctr(i)-vert_x_mean)**2 X +(yctr(i)-vert_y_mean)**2).lt. vert_std) then c X .and.abs(mwind(i)-mean_wind).lt.mean_std) then ii=ii+1 xctr(ii)=xctr(i) yctr(ii)=yctr(i) mwind(ii)=mwind(i) vert_x_mean_new=vert_x_mean_new+xctr(ii) vert_y_mean_new=vert_y_mean_new+yctr(ii) mean_wind_new=mean_wind_new+mwind(ii) endif enddo if(ii.gt.0) then vert_x_mean_new=vert_x_mean_new/float(ii) vert_y_mean_new=vert_y_mean_new/float(ii) mean_wind_new=mean_wind_new/float(ii) do i=1,ii vert_std_new=vert_std_new+(xctr(i)-vert_x_mean_new)**2 X +(yctr(i)-vert_y_mean_new)**2 mean_std_new=mean_std_new+(mwind(i)-mean_wind_new)**2 enddo vert_std_new=sqrt(vert_std_new/float(ii)) mean_std_new=sqrt(mean_std_new/float(ii)) else vert_x_mean_new=-999. vert_y_mean_new=-999. mean_wind_new=0. vert_std_new=99. mean_std_new=99. endif write(60,161) vert_x_mean, vert_y_mean, vert_std,iii, X vert_x_mean_new, vert_y_mean_new,vert_std_new, ii 161 format(' Mean X:',f8.3, ' Mean Y:', f8.3, ' STD:', f8.3, X ' #=',i5,/,' Mean X New:', f8.3, ' Mean Y New:', f8.3, X ' STD_NEW:' ,f8.3, ' #=',i5) write(60,162) mean_wind,mean_std,mean_wind_new,mean_std_new 162 format('Mean VT:',f8.3,16x,' STD:', f8.3,/, X 'Mean VT New:', f8.3,20x,' STD_NEW:' ,f8.3) write(*,161) vert_x_mean_new, vert_y_mean_new, vert_std,iii, X vert_x_mean_new, vert_y_mean_new,vert_std_new, ii WRITE (1,'("Finished level:",I2)') k write(70,163)k,vert_x_mean_new,vert_y_mean_new,vert_std_new, X ii, iii,mean_wind_new 163 format(2x, i2, 5x, f9.3, 4x, f9.3, 4x, f6.3, 3x,i2,'/',i2 X ,4x,f9.2) c Add good array to check final centers 03/02/01 MB c call goodvert(vert_x_mean_new,vert_y_mean_new, c X dz,ve,ring,k) ENDDO ENDDO c Add new loops to process stddev c do ring=ring_start,ring_end c do k=k1,k2 c gooddone=-999. c call goodvert(gooddone,gooddone,ring,k) c print *,'good:',vert_good c enddo c enddo close(10) close(60) close(70) enddo stop c c *********************** C Error Messages: c 998 print *, 'cannot open ideal input file' stop END subroutine goodvert(vx,vy,dz,ve,ring,k) implicit none include 'gbvtd_parameter.f' real vx,vy,rleg,dz(nx,ny),ve(nx,ny),origsd,percent real sd,goodsd,xrsd,xlsd,yusd,ydsd,goodwind complex*8 good,good_xr,good_xl,good_yu,good_yd,best integer ring,k,k1,k2,radi_beg,radi_end,sdflag,first integer count common /goodverts/ k1,k2,radi_beg,radi_end common /std/ sd real x_good(radi_beg:radi_end,k1:k2) real y_good(radi_beg:radi_end,k1:k2) complex ai c Add good array to check final centers 03/02/01 MB if((vx.ne.0.0).or.(vy.ne.0.0)) then x_good(ring,k)=vx y_good(ring,k)=vy sdflag=1 ai=(0,1.0) best=(-999.,-999.) first=0 count=0 do while ((best.eq.(-999.,-999.)).and.(count.le.100)) good=x_good(ring,k)+ai*y_good(ring,k) good_xr=(x_good(ring,k)+.1)+ai*y_good(ring,k) good_xl=(x_good(ring,k)-.1)+ai*y_good(ring,k) good_yu=x_good(ring,k)+ai*(y_good(ring,k)+.1) good_yd=x_good(ring,k)+ai*(y_good(ring,k)-.1) call gbvtd(good,goodwind,dz,ve,sdflag) goodsd=sd if (first.eq.0) then origsd=goodsd first=1 endif call gbvtd(good_xr,rleg,dz,ve,sdflag) xrsd=sd call gbvtd(good_xl,rleg,dz,ve,sdflag) xlsd=sd call gbvtd(good_yu,rleg,dz,ve,sdflag) yusd=sd call gbvtd(good_yd,rleg,dz,ve,sdflag) ydsd=sd print *,'good=',goodsd,' r=',xrsd,' l=',xlsd print *,'u=',yusd,' d=',ydsd if ((xrsd.lt.goodsd).and.(xrsd.lt.xlsd).and. X (xrsd.lt.yusd).and.(xrsd.lt.ydsd)) then x_good(ring,k)=x_good(ring,k)+.1 elseif ((xlsd.lt.goodsd).and.(xlsd.lt.xrsd).and. X (xlsd.lt.yusd).and.(xlsd.lt.ydsd)) then x_good(ring,k)=x_good(ring,k)-.1 elseif ((yusd.lt.goodsd).and.(yusd.lt.xrsd).and. X (yusd.lt.xlsd).and.(yusd.lt.ydsd)) then y_good(ring,k)=y_good(ring,k)+.1 elseif ((ydsd.lt.goodsd).and.(ydsd.lt.xrsd).and. X (ydsd.lt.xlsd).and.(ydsd.lt.yusd)) then y_good(ring,k)=y_good(ring,k)-.1 else if(((x_good(ring,k)-vx)**2 X +(y_good(ring,k)-vy)**2).lt.1.) then best=good print *,'best center= ',best percent=(origsd-goodsd)/origsd*100 vx = REAL(best) vy = AIMAG(best) write(70,164)vx,vy,goodsd,percent,goodwind else best=vx+ai*vy call gbvtd(best,goodwind,dz,ve,sdflag) percent=0 write(70,164)vx,vy,goodsd,percent,goodwind endif endif count=count+1 enddo if(count.ge.100) then best=vx+ai*vy call gbvtd(best,goodwind,dz,ve,sdflag) percent=0 write(70,164)vx,vy,goodsd,percent,goodwind endif endif 164 format ('Adjusted-',f9.3,4x,f9.3,4x,f6.3,3x,f5.2,'%',3x,f9.2) end ***************************************************************** * READDATA ***************************************************************** subroutine readdata(dz,ve,unit,ik,id,ix,iy,flag, X field1,field2) implicit none include 'gbvtd_parameter.f' integer ik,i,j,ix,iy,j1,N1,k,n real special integer flag,unit,index,indexdz,indexve real dz(nx,ny),ve(nx,ny),verel(nx,ny) integer*2 id(510) integer*2 field1,field2 c data field1,field2 /'MD','EV'/ special=-999. read(unit,116)id 116 format(10i8) ix=id(162) iy=id(167) do j=1,id(175) !id(175):total number of fields in the ascii file index=176+(j-1)*5 if(id(index).eq.field1) indexdz=j if(id(index).eq.field2) indexve=j enddo do k=1,ik read(unit,117)N1 117 format(5x,i2) if(n1.ne.k) then print *, 'Height index not match', N1,k stop endif do j=1,iy read(unit,18)j1 c print *, j1,j if(j1.ne.j) then print *, j1,j,' second index does not match' stop endif 18 format(7x,i3) do n=1,id(175) if(n.eq.indexdz) then read(unit,19)id(176),id(177),id(178),id(179), X (dz(i,j),i=1,ix) c write(*,19)id(176),id(177),id(178),id(179),(dz(i,j),i=1,ix) elseif(n.eq.indexve) then read(unit,19)id(181),id(182),id(183),id(184), X (ve(i,j),i=1,ix) c write(*,19)id(181),id(182),id(183),id(184),(ve(i,j),i=1,ix) else read(unit,19)id(186),id(187),id(188),id(189), X (verel(i,j),i=1,ix) endif enddo enddo enddo 19 format(4a2,/,(8E10.3)) return end c ********************** subroutine SIMCON (xctr,yctr,rad,dz,ve,imax,jmax,sx,sy,value, X wind) real dz(imax,jmax), ve(imax,jmax),radi(2),rad_temp complex*8 Vert(3),Rvert,Xvert,Cvert,Svert(3) complex*8 temp,temp1 real LegAr(3),Rleg,Xleg,Cleg,RCoef,XCoef,CCoef,SCoef,wind logical Done,DOIT !Mod 04SEP86 integer iwrit,i character*3 CMxn integer sdflag data RCoef,XCoef,CCoef,SCoef/-1.0,-2.0,0.5,0.5/, iwrit/1/ c c xctr,yctr : position of first guess center location c in 3-D Doppler arrays use olat,olon c rad : influence radius for circle that circumscribes the simplex c typically use 4 km c DZ,VE : array of wd/ws values form one level in the 3-D Doppler array c imax,jmax : data array dimensions c sx,sy : resolution of the data array c radi (2) : inner and outer radial limits for computation of TANW c sdflag=0 xctr_ini=xctr yctr_ini=yctr call SETUP(xctr,yctr,rad,dz,ve,imax,jmax,sx,sy,radi, # Vert,LegAr,Done,I_Bst,I_Wst,Kount,CMxn) c do while (.NOT. Done) Kount = Kount + 1 print *, 'Kcount, VERT,LegAr', kount,vert,LegAr c write (iwrit,10)Kount call SIZE(Vert,Rvert,RCoef,I_Bst,I_Wst) c call ALSAND(data,imax,jmax,sx,sy,radi,Rvert,Rleg) call gbvtd(Rvert,Rleg,dz,ve,sdflag) print *, 'Rvert,Rleg', rvert,rleg if (DOIT(Rleg,LegAr(I_Bst))) then !Mod 04SEP86 call SIZE(Vert,Xvert,XCoef,I_Bst,I_Wst) c call ALSAND(data,imax,jmax,sx,sy,radi,Xvert,Xleg) call gbvtd(Xvert,Xleg,dz,ve,sdflag) print *,'Xvert,Xleg',xvert,xleg if (DOIT(Xleg,LegAr(I_Bst))) then !Mod 04SEP86 call STASH(Vert,LegAr,Xvert,Xleg,I_Wst) else call STASH(Vert,LegAr,Rvert,Rleg,I_Wst) endif else if (DOIT(Rleg,LegAr(I_Wst))) then !Mod 04SEP86 call STASH(Vert,LegAr,Rvert,Rleg,I_Wst) else call SIZE(Vert,Cvert,CCoef,I_Bst,I_Wst) c call ALSAND(data,imax,jmax,sx,sy,radi,Cvert,Cleg) call gbvtd(Cvert,Cleg,dz,ve,sdflag) print *, 'Cvert,Cleg', cvert,cleg if(DOIT(Cleg,LegAr(I_Wst)).AND.DOIT(Cleg,Rleg))then !Mod 04SEP86 call STASH(Vert,LegAr,Cvert,Cleg,I_Wst) else call SHRINK(Vert,Svert,SCoef,I_Bst,I_Wst) c call ALSAND(data,imax,jmax,sx,sy,radi,Svert(2),LegAr(2)) call gbvtd(Svert(2),LegAr(2),dz,ve,sdflag) print *,'Svert(2),LegAr(2)',svert(2),legar(2) Vert(2) = Svert(2) c call ALSAND(data,imax,jmax,sx,sy,radi,Svert(I_Wst), c @ LegAr(I_Wst)) call gbvtd(Svert(I_Wst),LegAr(I_Wst),dz,ve,sdflag) print *,'Svert(I_Wst),LegAr(I_Wst)',Svert(I_Wst),LegAr(I_Wst) Vert(I_Wst) = Svert(I_Wst) endif endif endif call RNKVRT(Vert,LegAr) call CONTST(Kount,Done,Vert) c write(iwrit,11)Kount,LegAr(I_Bst),Vert(I_Bst) value=LegAr(I_bst) xctr=real(Vert(I_bst)) yctr=aimag(Vert(I_bst)) print *,'xctr,yctr',xctr,yctr temp1=vert(1)-vert(2) rad_temp=cabs(temp1) if(rad_temp.le.rad) rad=rad_temp temp1=vert(1)-vert(3) rad_temp=cabs(temp1) if(rad_temp.le.rad) rad=rad_temp temp1=vert(2)-vert(3) rad_temp=cabs(temp1) if(rad_temp.le.rad) rad=rad_temp enddo wind=LegAr(I_Bst) write(iwrit,10)Kount write(iwrit,13) CMxn,LegAr(I_Bst),Vert(I_Bst) write(*,10)Kount write(*,13) CMxn,LegAr(I_Bst),Vert(I_Bst) 10 format(' - - Iteration #',i4) c11 format(' Iter:',i4,'; Max. Value: ',g12.5,' at ', 2F10.5) 13 format(' Reporting ',a3,' of ',g12.5,' at ',2f10.5//) write(60,61) xctr_ini,yctr_ini,Kount,Vert(I_Bst),rad, X LegAr(I_Bst) 61 format(2f8.2,i5,2f8.3,3x,f8.3,f10.5) return end subroutine SETUP(xctr,yctr,rad,dz,ve,imax,jmax,sx,sy,radi, # Vert,LegAr,Done,I_Bst,I_Wst,Kount,CMxn) real dz(imax,jmax), ve(imax,jmax), radi(2) c common/CRITR/Eps,It_Max common /MaxMin/P_Max complex*8 Vert(3),ai character*3 CMxn real LegAr(3),xctr,yctr,rad,sqr32 logical Done,P_Max data sqr32/0.866025/ !squareroot of 3 divided by 2 c Done = .FALSE. c P_Max = .TRUE. c P_Max = .FALSE. if (P_Max)then I_Bst = 3 I_Wst = 1 CMxn = 'Max' else I_Bst = 1 I_Wst = 3 CMxn = 'Min' endif Kount = 0 c c initial vertices are at the points of an equilateral triangle c circumscribed in a circle with radius "rad" c ai=(0,1.0) Vert(1) = xctr + ai*(yctr+rad) Vert(2) = xctr + sqr32*rad + ai*(yctr-.5*rad) Vert(3) = xctr - sqr32*rad + ai*(yctr-.5*rad) c Eps = 0.001 c It_Max = 60 do i = 1,3 c call ALSAND(data,imax,jmax,sx,sy,radi,Vert(i),LegAr(i)) call gbvtd(Vert(i),LegAr(i),dz,ve,sdflag) enddo call RNKVRT(Vert,LegAr) return end subroutine RNKVRT(Vert,LegAr) complex*8 Vert(3),Tvert real LegAr(3),Tleg do i = 1,3 do j = 1,2 if (LegAr(j) .GT. LegAr(j+1)) then Tvert = Vert(j) Tleg = LegAr(j) Vert(j) = Vert(j+1) LegAr(j) = LegAr(j+1) Vert(j+1) = Tvert LegAr(j+1) = Tleg endif enddo enddo c do i = 1,3 c write(1,10)i,Vert(i),LegAr(i) c enddo c10 format(' RNKVRT: Vertex# ',i2,' Vert = ',2f10.5,' LegAr = 'g12.5) return end subroutine STASH(Vert,LegAr,Nvert,Nleg,I_Wst) complex*8 Vert(3),Nvert real LegAr(3),Nleg c c write(iwrit,9)Vert(I_Wst),LegAr(I_Wst) Vert(I_Wst) = Nvert LegAr(I_Wst) = Nleg c write(iwrit,10)Vert(I_Wst),LegAr(I_Wst) c9 format(' STASH: Old Vert(I_Wst) and LegAr(I_Wst) ',2f10.5,g12.5) c10 format(' STASH: New Vert(I_Wst) and LegAr(I_Wst) ',2f10.5,g12.5) return end subroutine SIZE(Vert,Nvert,Coef,I_Bst,I_Wst) complex*8 Vert(3),Nvert,Bvert Bvert = 0.5 * (Vert(I_Bst) + Vert(2)) Nvert = Bvert + Coef*(Vert(I_Wst)-Bvert) c write(iwrit,10)Coef,Vert(I_Wst),Nvert c10 format(' SIZE: Coef =',f10.5,' Old =',2f10.5,' New =',2f10.5) return end subroutine SHRINK(Vert,Svert,SCoef,I_Bst,I_Wst) complex*8 Vert(3),Svert(3) Svert(2)=Vert(I_Bst)+SCoef*(Vert(2)-Vert(I_Bst)) c write(iwrit,10)2,Vert(2),Svert(2) Svert(I_Wst)=Vert(I_Bst)+SCoef*(Vert(I_Wst)-Vert(I_Bst)) c write(iwrit,10)I_Wst,Vert(I_Wst),Svert(I_Wst) c10 format(' SHRINK: Vertex#',i2,' Old =',2f10.5,' New =',2f10.5) return end subroutine CONTST(Kount,Done,Vert) complex*8 Vert(3) Logical Done common/CRITR/Eps,It_Max SMax = 0.0 do i = 1,3 j = i + 1 if (j .GT. 3) j = j - 3 SS = CABS(Vert(i)-Vert(j)) SMax = amax1(SS,SMax) c write(iwrit,10)i,j,SS enddo Done = (SMax .LT. Eps).OR.(Kount.GE.It_Max) c10 format('CONTST: Side between ',i2,' and ',i2,' has length ',F10.5) return end logical function DOIT(ALn,ALo) common /MaxMin/P_Max logical P_Max if(P_Max) then DOIT = ALn .GT. ALo else DOIT = ALn .LT. ALo endif return end ******************************************************************** * Subroutine GBVTD ******************************************************************** subroutine gbvtd(Vert,Rleg,dz,vd,sdflag) C ****** OBJECT:TO GET THE VORTEX STRUCTURE USING VDAD METHOD ****** C ****** NAME: VD.f ****** C ****** COMPLETED DATE: 1995/11/1 ****** C ****** AUTHOR:CHANG BAU_LUNG, WEN-CHAU LEE C ****** All angles (theta and si) are in GBVTD coordinate, C ****** i.e., not in math coordiate. 0 deg is TA see lee et al. (1997) C ****** So, when plotting the results, you need to rotate the C ****** coordinate systems by theta_t (atan2(yc,xc)). C ****** VD is the Doppler velocity C ****** VA is VT plus the component of VM implicit none INCLUDE 'gbvtd_parameter.f' integer K,nn,i,numcoeff,n real pi,xc,yc,dummy,vrcoef,vm,s,theta_t,rad_lat,rad_long REAL THETAZ(thetamax),d REAL DZ(nx,ny),DDZ(thetamax),XDD(thetamax),A(maxrays) real x(thetamax),sd real YDD(thetamax),THETAV(maxrays),dddz(rmax,thetamax) real xdddz(thetamax), ydddz(thetamax),VT(rmax,thetamax) REAL XS(maxcoeffs,maxrays),YS(maxrays),WEIGHT(maxrays) real CC(maxcoeffs),STAND_ERR(maxcoeffs),theta,dist REAL TH(maxrays),AZ(maxrays),VTCOEF(maxcoeffs),xdist,ydist real VD(nx,ny),DVD(maxrays),DDVD(rmax,thetamax),dvd1(thetamax) real temp,ddz1(thetamax) real ampvt1,angle,zone real phasevt1,dtor,ampvt2,phasevt2,ampvt3,phasevt3,vorticity real ampvr1,phasevr1,ampvr2,phasevr2,ampvr3,phasevr3 real meanflow,radi(2),vrmean,xctemp,yctemp real meanangle,r_t,ar,rleg character inputfile*80,outfiledz,outfileve real vt0max,vt1max,vr0max INTEGER NDATA,gap(5),flag1,j,flag2,rflag,num_ray integer iori,jori,ring_start, ring_end,iii,num_x,num_y integer sdflag integer*2 id(510),sf,af,id1(510) complex*8 Vert LOGICAL FLAG,P_Max data rad_lat, rad_long /25.0694,121.2083/ data sf, af /100,64/ common /ideal/vorticity,ar,meanflow,meanangle,phasevt1,ampvt1, X phasevt2,ampvt2,phasevt3,ampvt3,phasevr1,ampvr1, X phasevr2,ampvr2,phasevr3,ampvr3 common /gbvtd_p/ flag1,flag2,gap,id,ring_start,ring_end,rflag, X zone,num_x,num_y common /MaxMin/ P_Max common /std/ sd c CALL OPNGKS print *, maxrays PI=ACOS(-1.) DUMMY=-999. dtor=pi/180. vt0max=.0 vt1max=.0 vr0max=.0 c CALL READDATA(DZ,VD,10,N,id,nx,ny,2) iori=id(309)/sf jori=id(310)/sf iii=0 if(flag2.eq.2 .and. (flag1.eq.3 .or. flag1.eq.4)) then c print *, 'please enter ideal input filename:' c read *, inputfile inputfile='/scr/science9/wlee/gbvtd/ideal/rankine.sym.inp' OPEN(1200,file=inputfile,status='old',form='formatted', + err=998) READ(1200,'(A80/A80/f7.2,1x,f7.2)') outfiledz,outfileve, + xctemp,yctemp read(1200,'(f8.1,/,f5.1)') vorticity,ar read(1200,'(f8.1,/,f8.1)')meanflow,meanangle read(1200,'(f8.1,/,f8.1)')phasevt1,ampvt1 read(1200,'(f8.1,/,f8.1)')phasevt2,ampvt2 read(1200,'(f8.1,/,f8.1)')phasevt3,ampvt3 read(1200,'(f8.1)')vrmean read(1200,'(f8.1,/,f8.1)')phasevr1,ampvr1 read(1200,'(f8.1,/,f8.1)')phasevr2,ampvr2 read(1200,'(f8.1,/,f8.1)')phasevr3,ampvr3 close(1200) c print *,xctemp,yctemp,vorticity,ar endif OPEN(13,file='result_coeff',status='unknown', + form='formatted') xc = REAL(Vert) yc = AIMAG(Vert) if(rflag.eq.1) then print *, 'Process GBVTD on center:', Vert endif cc do k=1,ring_end cc do j=1,thetamax cc dddz(k,j)=dummy cc ddvd(k,j)=dummy cc vt(k,j)=dummy cc enddo cc enddo C radius of GBVTD rings from ring_start to ring_end km every 1 km do K=ring_start,ring_end C ****** GRID POINT ****** C ****** Calculate grid point location for VDAD or GBVTD C ****** the grid point is in corresponding si coordinate for GBVTD C ****** theta is angle array (si for GBVTD and theta for VDAD) cc CALL GRID(XC,YC,XDD,YDD,FLOAT(K),THETAV,theta_t,flag1, cc X thetamax) cc call grid(xc,yc,xdddz,ydddz,float(k),thetaZ,theta_t,1, cc X thetamax) C ****** GET GRID POINT DATA FROM Doppler Velocity Field ****** cc CALL INTE(DZ,DUMMY,XDDdz,YDDdz,thetamax,DDZ,2.0,0.5, cc X iori,jori,id(162),id(167)) cc CALL INTE(VD,DUMMY,XDD,YDD,thetamax,DVD,2.0,0.5,iori, cc X jori,id(162),id(167)) cc if(flag1.eq.1 .or. flag1.eq.3) then !vdad cc r_t=sqrt(xc*xc+yc*yc) ccc print *, 'int' cc do i=1,thetamax ccc print *, dvd(i),xdd(i),ydd(i),iori,jori,d,r_t cc d=sqrt((xdd(i))**2.+(ydd(i))**2.) cc dvd(i) = dvd(i)*d/r_t cc enddo cc endif cc if(flag2.eq.2) then cc if(flag1.eq.3 .or. flag1.eq.4) then !use analytic wind ccc call analytic(VD,dummy,xdd,ydd,thetamax,dvd1,2.0,0.5, ccc X iori,jori,xc,yc,k,ddz1,flag1) cc call analytic(VD,dummy,xdd,ydd,thetamax,dvd1,2.0,0.5, cc X iori,jori,xctemp,yctemp,k,ddz1,flag1) cc do i=1,thetamax c c DVD(i)=dvd1(i) cc DDZ(i)=DDZ1(i) cc enddo cc endif cc endif num_ray=0 do i=1,num_x do j=1,num_y xdist=i-(xc+iori) ydist=j-(yc+jori) dist=sqrt(xdist**2+ydist**2) if(dist.ge.(k-zone).and.dist.le.(k+zone))then angle=atan2(ydist, xdist) call fixangle(angle) c angle=amod((2.5*pi-angle),2.*pi)-theta_t angle=angle-theta_t call fixangle(angle) if(flag1.eq.2 .or. flag1.eq.4) then !gbvtd call theta2si(k,angle,xc,yc,theta,theta_t) c print *, i,j,angle/dtor,theta_t/dtor,theta/dtor, c X vd(i,j) else theta=angle endif num_ray=num_ray+1 thetav(num_ray)=theta DVD(num_ray)=VD(i,j) c print *, i,j,k,num_ray,angle/dtor, c X thetav(num_ray)/dtor,dvd(num_ray), dist endif enddo enddo call goodcirc(thetaV,DVD,num_ray,GAP,FLAG,numcoeff) c Modified 1/11/01 to test result of flag if (flag) then C GET GOOD DATA NUMBER C DVD is the original array, TH is the cleaned up angle array CALL GOODDATA(DVD,THETAV,AZ,TH,NN,num_ray,dummy) C ****** LEASTSQURRE CURVE FIT AND FIND COE. OF FOURIER sqrt.o ****** CALL CALCULATE_XY(NN,numcoeff,TH,AZ,XS,YS,NDATA,WEIGHT) CALL LLS(numcoeff,NDATA,NDATA,XS,YS,WEIGHT,S,STAND_ERR, X CC,FLAG) CALL FINAL1(CC,VTCOEF,VRCOEF,VM,XC,YC,K,numcoeff,flag1,rflag) C Added std_dev call to test final center, 03/02/01 MB C X is the theta array converted from si (has NN point in deg) if (sdflag.eq.1) then call std_dvi(A,CC,X,AZ,TH,numcoeff,sd,xc,yc, X flag1,k,theta_t,dummy) endif else xc=-999.0 yc=-999.0 do n=1,8 vtcoef(n)=0.0 enddo vrcoef=0.0 VM=0.0 endif c-- modified 9/30/98 to use P_Max to determine the minimization/maximization C-- criteria. if P_Max is .true., then, Rleg is the mean tangential wind. C-- If P_Max is .false., then, Rleg is the amplitude of the wavenumber 1. write(13, 1202) xc,yc,(vtcoef(n),n=1,8),vrcoef,VM 1202 format(3f8.3, 9f6.1) c if(P_Max.eq. .true.) then !maximize mean tangential wind c if(vtcoef(1).gt.0.) then c vt0max=vt0max+vtcoef(1) c iii=iii+1 cc print *,k,vtcoef(1),ddz(1) c endif c elseif(P_Max.eq. .false.) then !minimize wavenumber 1 amplitude c temp=sqrt(vtcoef(3)*vtcoef(3)+vtcoef(4)*vtcoef(4)) c if(temp.gt.0.0001) then c vt1max=vt1max+temp c iii=iii+1 c endif c endif ENDDO c if(iii.gt.0) then if(P_Max.eqv. .true.) then Rleg=vtcoef(1) else Rleg=sqrt(vtcoef(3)*vtcoef(3)+vtcoef(4)*vtcoef(4)) endif c else c Rleg=0. c endif 999 CONTINUE rewind(10) return 998 print *, 'cannot open ideal input file' END ************************************************************************ * OPENFILE ************************************************************************ Subroutine openfile(l,numloc,kc,prefix) integer l, numloc,kc,iz,lnblnk CHARACTER FNAME*80,STR*2,XFNAME*30 character prefix*20 if(iz.lt.10) then str='0' write(str,'(i1)')IZ else write(str,'(i2)')IZ endif xfname=prefix(:len_trim(prefix))//'f'//STR if(L.lt.10) then str='0' write(str,'(i1)')L else write(str,'(i2)')L endif xfname=xfname(:len_trim(xfname))//'c' xfname=xfname(:len_trim(xfname))//STR OPEN(15,FILE=xfname,STATUS='UNKNOWN',FORM='FORMATTED') if(iz.lt.10) then str='0' write(str,'(i1)')IZ else write(str,'(i2)')IZ endif xfname=prefix(:len_trim(prefix))//'f'//STR if(L.lt.10) then str='0' write(str,'(i1)')L else write(str,'(i2)')L endif xfname=xfname(:len_trim(xfname))//'z' xfname=xfname(:len_trim(xfname))//STR OPEN(16,FILE=xfname,STATUS='UNKNOWN',FORM='FORMATTED') if(iz.lt.10) then str='0' write(str,'(i1)')IZ else write(str,'(i2)')IZ endif xfname=prefix(:len_trim(prefix))//'f'//STR if(L.lt.10) then str='0' write(str,'(i1)')L else write(str,'(i2)')L endif xfname=prefix(:len_trim(prefix))//STR xfname=xfname(:len_trim(xfname))//'.out' OPEN(14,FILE=xfname,STATUS='UNKNOWN',FORM='FORMATTED') xfname=xfname(:len_trim(xfname)-3)//'point1' open(171,file=xfname,status='unknown',form='formatted') xfname=xfname(:len_trim(xfname)-1)//'2' open(172,file=xfname,status='unknown',form='formatted') xfname=xfname(:len_trim(xfname)-1)//'3' open(173,file=xfname,status='unknown',form='formatted') return end CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C Calculate Typhoon center lat and long based on the radar lat and C long and the relative coordinate XC and YC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC subroutine latlong(rad_lat,rad_long,xc,yc,ori_lat,ori_long) implicit none real rad, rad_lat, rad_long, ori_lat, ori_long, xc, yc real pi, rad_laty, rad_longx,radr RAD=6371.25 PI=ACOS(-1.) C Lat and Long of the CAA radar RAD_LAT=25.0694 RAD_LONG=121.2083 rad_laty=yc/rad*180./pi !calculate delta lat from the center y coord. radr=rad*cos((rad_lat+rad_laty)*pi/180.) !calculate radius at the typhoon C !latitude rad_longx=xc/radr*180./pi !calculate delta long from the center x coord. ori_lat=rad_lat+rad_laty !typhoon lat. ori_long=rad_long+rad_longx !typhoon long. return end ************************************************************* * DATA ************************************************************* subroutine data(dddz,thetamax) implicit none integer kk,nn1,nn2,index,i,k,thetamax real dddz(thetamax) nn1=0 nn2=0 do kk=1,thetamax if (int(dddz(kk)).ne.99) then nn1=kk goto 12 endif enddo 12 do kk=thetamax,1,-1 if (int(dddz(kk)).ne.99) then INDEX=1 nn2=kk goto 13 endif enddo 13 if (nn1.eq.0)then INDEX=0 dddz(i)=0. goto 30 endif do i=nn1+1,nn2-1 if (int(dddz(i)).eq.99) then do k=i+1,nn2 if (int(dddz(k)).ne.99) then dddz(i)=dddz(i-1)+(dddz(k)-dddz(i-1))/(k-i+1) goto 10 endif enddo endif 10 enddo 30 return end ************************************************************** * INTE *************************************************************** SUBROUTINE INTE(dz,dummy,xd,yd,nx,gdz,rang,gama,iori,jori, X xmax,ymax) implicit none real rang, gama,dummy,pi,wt,det0,diff,totdiff integer nx, idummy, ik1, ik2, ij1, ij2, i integer iori,jori real dz(241,241),xd(nx),yd(nx) real gdz(nx),temp1,temp2,ave1,ave2,ave3 integer*2 xmax,ymax C real tme(nx) PI=ACOS(-1.) idummy=dummy wt=-4.*gama/(rang*rang) DET0=PI/210. do 100 i=1,nx ik1=int(xd(i))+iori ik2=int(xd(i))+1+iori ij1=int(yd(i))+jori ij2=int(yd(i))+1+jori if (ik1.lt.1)goto 99 if (ij1.lt.1)goto 99 if (ik2.gt.xmax)goto 99 if (ij2.gt.ymax)goto 99 C----------------------------------------------------- C Commented by wcl 8/9/97 because closest point interpolation C produced a bias on the pattern which is not tolerant by GBVTD analysis C So, change it to bi-linear interpolation. C-------------------------------------------------------------- c if ((dz(ik1,ij1)-dummy).gt.0.0001) then c gdz(i)=dz(ik1,ij1) c else c gdz(i)=dummy c endif temp1=dz(ik1,ij1) temp2=dz(ik1,ij2) totdiff=float(ij2-ij1) diff=yd(i)-int(yd(i)) call ave(temp1,temp2,diff,totdiff,ave1,dummy) temp1=dz(ik2,ij1) temp2=dz(ik2,ij2) call ave(temp1,temp2,diff,totdiff,ave2,dummy) totdiff=float(ik2-ik1) diff=xd(i)-int(xd(i)) call ave(ave1,ave2,diff,totdiff,ave3,dummy) gdz(i)=ave3 c print *,i,ave1,ave2,ave3,gdz(i) goto 100 99 gdz(i)=dummy 100 continue return end ******************************************************************** *ANALYTIC ******************************************************************** subroutine analytic(dz,dummy,xd,yd,nx,gdz,rang,gama,iori,jori, X xc,yc,k,ddz,flag) implicit none real rang, gama,dummy,pi integer nx, i integer iori,jori,k,flag real dz(241,241),xd(nx),yd(nx),rt,xg,yg,theta real gdz(nx),radius,ddz(nx),xc,yc,asymvt,ampvt1 real phasevt1,dtor,ampvt2,phasevt2,ampvt3,phasevt3,a,vorticity real ampvr1,phasevr1,ampvr2,phasevr2,ampvr3,phasevr3 real rad_v,vrmean,u,meanu,v,special,rg,meanflow real meanangle,meanv,r_t,vta,angle,theta_t,asymvr character outfiledz*80,outfileve*80,inputfile*80 common /ideal/vorticity,a,meanflow,meanangle,phasevt1,ampvt1, X phasevt2,ampvt2,phasevt3,ampvt3,phasevr1,ampvr1, X phasevr2,ampvr2,phasevr3,ampvr3 PI=ACOS(-1.) dtor=pi/180. rt=sqrt(xc*xc+yc*yc) theta_t=atan2(yc,xc)/dtor c print *, theta_t meanu=meanflow*sin(meanangle*dtor-pi) meanv=meanflow*cos(meanangle*dtor-pi) c print *, 'ana' do i=1,nx xg=(xd(i)) yg=(yd(i)) angle=360./float(nx)*float(i-1)*dtor if(flag.eq.2 .or. flag.eq.4) then call si2theta(k,angle,xc,yc,angle,theta_t) endif theta=amod((angle/dtor+theta_t),360.)*dtor radius=float(k) asymvt=ampvt1*cos(theta-(phasevt1*dtor)) X +ampvt2*cos(2*(theta-(phasevt2*dtor))) X +ampvt3*cos(3*(theta-(phasevt3*dtor))) c print *, i,j, theta/dtor, asym,phase1,phase2,phase3 asymvr=ampvr1*cos(theta-(phasevr1*dtor)) X +ampvr2*cos(2*(theta-(phasevr2*dtor))) X +ampvr3*cos(3*(theta-(phasevr3*dtor))) if(radius.le.a) then !solid rotation VTa=0.5*vorticity*radius*(1.+asymvt) c rad_v=0.5*radius rad_v=-vrmean*(1.+asymvr) else VTa=0.5*vorticity*a*a/radius*(1.+asymvt) c rad_v=-0.5*a*a/radius rad_v=vrmean*(1.+asymvr) endif if(radius.ge. 2.) then u=meanu-vta*sin(theta)+rad_v*cos(theta) v=meanv+vta*cos(theta)+rad_v*sin(theta) rg=sqrt(xg*xg+yg*yg) if(rg.ge.0.01) then gdz(i)=(u*xg+v*yg)/rg else gdz(i)=dummy endif else gdz(i)=dummy endif ddz(i)=sqrt(u*u+v*v) IF (abs(gdz(i)-dummy).gt.0.001) then c print *, angle/dtor,theta/dtor,vta,u,v,gdz(i) c print *, gdz(i), xd(i),yd(i),iori,jori,rg,rt if(flag.eq.1 .or. flag.eq.3) then !vdad gdz(i) = gdz(i)*rg/RT elseif(flag.ne.2 .and. flag.ne.4) then ! not gbvtd or reflectivity print *, 'flag out of range' endif endif c print *, gdz(i),xd(i),yd(i),xg,yg,rg,rt enddo return end ***************************************************************** * AVE Perform linear interpolation between two points ***************************************************************** subroutine ave(temp1,temp2,diff,totdiff,temp,dummy) implicit none real diff,totdiff,temp1,temp2,temp,dummy if(abs(temp1-dummy).ge.0.01) then if(abs(temp2-dummy).ge.0.01) then if(abs(totdiff).le.0.0001) then print *,'totdiff=0.' stop endif temp=(temp1*(totdiff-diff)+temp2*diff)/totdiff else temp=temp1 endif elseif(abs(temp2-dummy).ge.0.01) then temp=temp2 else temp=dummy endif return end ****************************************************************** * GRID ****************************************************************** subroutine grid(xc,yc,xdd,ydd,rmeter,tth,theta_t,status, X thetamax) implicit none real pi,rt,r,rmeter,xc,yc,theta_t,alpha integer i,status,thetamax real xdd(thetamax),ydd(thetamax) real theta,tth(thetamax) pi=acos(-1.) rt=sqrt(xc**2+yc**2) r=rmeter theta_t=atan2(yc,xc) C A total of 90 points around a ring C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C tth(i) is the angle thetaprime (VDAD) or si (gbvtd) in the C hurricane coordinate C theta is the math. angle counterclockwise from east to a point E C in the gbvtd formulation, thetaprime=alpha+si (see Lee et al. 1997) CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC do i=1,thetamax tth(i)=(i-1)*(360./float(thetamax))*pi/180. if(status.eq.1 .or. status.eq.3) then ! VDAD theta=amod((tth(i)+theta_t),2.*pi) elseif(status.eq.2 .or. status.eq.4) then !gbvtd, calculate theta for a given si alpha=asin(r/rt*sin(tth(i))) !law of sine theta=amod((tth(i)+alpha+theta_t),2.*pi) endif xdd(i)=xc+r*cos(theta) ydd(i)=yc+r*sin(theta) enddo return end subroutine intswap(oldint,newint) implicit none integer*2 intfix integer*2 oldint,int1,int2,newint intfix = 256 int1 = mod(oldint,intfix) int2 = (oldint - int1)/intfix newint = int1*intfix + int2 return end
open int example : 2 + 3 = 5:=begin generalize h:3=x,generalize g:2=y,rw ← h,rw ← g,← end
--- author: Nathan Carter ([email protected]) --- This answer assumes you have imported SymPy as follows. ```python from sympy import * # load all math functions init_printing( use_latex='mathjax' ) # use pretty math output ``` SymPy has support for piecewise functions built in, using `Piecewise`. The function above would be written as follows. ```python var( 'x' ) formula = Piecewise( (x**2, x>2), (1+x, x<=2) ) formula ``` $\displaystyle \begin{cases} x^{2} & \text{for}\: x > 2 \\x + 1 & \text{otherwise} \end{cases}$ We can test to be sure the function works correctly by plugging in a few $x$ values and ensuring the correct $y$ values result. Here we're using the method from how to substitute a value for a symbolic variable. ```python formula.subs(x,1), formula.subs(x,2), formula.subs(x,3) ``` $\displaystyle \left( 2, \ 3, \ 9\right)$ For $x=1$ we got $1+1=2$. For $x=2$ we got $2+1=3$. For $x=3$, we got $3^2=9$.
[STATEMENT] lemma fixes s :: "'a :: {nat_power_normed_field,banach,euclidean_space}" assumes "s \<bullet> 1 > 1" shows euler_product_fds_zeta: "(\<lambda>n. \<Prod>p\<le>n. if prime p then inverse (1 - 1 / nat_power p s) else 1) \<longlonglongrightarrow> eval_fds fds_zeta s" (is ?th1) and eval_fds_zeta_nonzero: "eval_fds fds_zeta s \<noteq> 0" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s &&& eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (2 subgoals): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s 2. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] have *: "completely_multiplicative_function (fds_nth fds_zeta)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. completely_multiplicative_function (fds_nth fds_zeta) [PROOF STEP] by standard auto [PROOF STATE] proof (state) this: completely_multiplicative_function (fds_nth fds_zeta) goal (2 subgoals): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s 2. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] have lim: "(\<lambda>n. \<Prod>p\<le>n. if prime p then inverse (1 - fds_nth fds_zeta p / nat_power p s) else 1) \<longlonglongrightarrow> eval_fds fds_zeta s" (is "filterlim ?g _ _") [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - fds_nth fds_zeta p / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: 1 < s \<bullet> (1::'a) goal (1 subgoal): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - fds_nth fds_zeta p / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s [PROOF STEP] by (intro fds_euler_product_LIMSEQ' * fds_abs_summable_zeta) [PROOF STATE] proof (state) this: (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - fds_nth fds_zeta p / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s goal (2 subgoals): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s 2. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] also [PROOF STATE] proof (state) this: (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - fds_nth fds_zeta p / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s goal (2 subgoals): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s 2. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] have "?g = (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse (1 - 1 / nat_power p s) else 1)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - fds_nth fds_zeta p / nat_power p s) else (1::'a)) = (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) [PROOF STEP] by (intro ext prod.cong refl) (auto simp: fds_zeta_def fds_nth_fds) [PROOF STATE] proof (state) this: (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - fds_nth fds_zeta p / nat_power p s) else (1::'a)) = (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) goal (2 subgoals): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s 2. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] finally [PROOF STATE] proof (chain) picking this: (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s [PROOF STEP] show ?th1 [PROOF STATE] proof (prove) using this: (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s goal (1 subgoal): 1. (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s [PROOF STEP] . [PROOF STATE] proof (state) this: (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] { [PROOF STATE] proof (state) this: (\<lambda>n. \<Prod>p\<le>n. if prime p then inverse ((1::'a) - (1::'a) / nat_power p s) else (1::'a)) \<longlonglongrightarrow> eval_fds fds_zeta s goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] fix p :: nat [PROOF STATE] proof (state) goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] assume "prime p" [PROOF STATE] proof (state) this: prime p goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] from this [PROOF STATE] proof (chain) picking this: prime p [PROOF STEP] have "p > 1" [PROOF STATE] proof (prove) using this: prime p goal (1 subgoal): 1. 1 < p [PROOF STEP] by (simp add: prime_gt_Suc_0_nat) [PROOF STATE] proof (state) this: 1 < p goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] hence "norm (nat_power p s) = real p powr (s \<bullet> 1)" [PROOF STATE] proof (prove) using this: 1 < p goal (1 subgoal): 1. norm (nat_power p s) = real p powr (s \<bullet> (1::'a)) [PROOF STEP] by (simp add: norm_nat_power) [PROOF STATE] proof (state) this: norm (nat_power p s) = real p powr (s \<bullet> (1::'a)) goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] also [PROOF STATE] proof (state) this: norm (nat_power p s) = real p powr (s \<bullet> (1::'a)) goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] have "\<dots> > real p powr 0" [PROOF STATE] proof (prove) goal (1 subgoal): 1. real p powr 0 < real p powr (s \<bullet> (1::'a)) [PROOF STEP] using assms and \<open>p > 1\<close> [PROOF STATE] proof (prove) using this: 1 < s \<bullet> (1::'a) 1 < p goal (1 subgoal): 1. real p powr 0 < real p powr (s \<bullet> (1::'a)) [PROOF STEP] by (intro powr_less_mono) auto [PROOF STATE] proof (state) this: real p powr 0 < real p powr (s \<bullet> (1::'a)) goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] finally [PROOF STATE] proof (chain) picking this: real p powr 0 < norm (nat_power p s) [PROOF STEP] have "nat_power p s \<noteq> 1" [PROOF STATE] proof (prove) using this: real p powr 0 < norm (nat_power p s) goal (1 subgoal): 1. nat_power p s \<noteq> (1::'a) [PROOF STEP] using \<open>p > 1\<close> [PROOF STATE] proof (prove) using this: real p powr 0 < norm (nat_power p s) 1 < p goal (1 subgoal): 1. nat_power p s \<noteq> (1::'a) [PROOF STEP] by auto [PROOF STATE] proof (state) this: nat_power p s \<noteq> (1::'a) goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] } [PROOF STATE] proof (state) this: prime ?p3 \<Longrightarrow> nat_power ?p3 s \<noteq> (1::'a) goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] hence **: "\<nexists>p. prime p \<and> fds_nth fds_zeta p = nat_power p s" [PROOF STATE] proof (prove) using this: prime ?p3 \<Longrightarrow> nat_power ?p3 s \<noteq> (1::'a) goal (1 subgoal): 1. \<nexists>p. prime p \<and> fds_nth fds_zeta p = nat_power p s [PROOF STEP] by (auto simp: fds_zeta_def fds_nth_fds) [PROOF STATE] proof (state) this: \<nexists>p. prime p \<and> fds_nth fds_zeta p = nat_power p s goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] show "eval_fds fds_zeta s \<noteq> 0" [PROOF STATE] proof (prove) goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] using assms * ** [PROOF STATE] proof (prove) using this: 1 < s \<bullet> (1::'a) completely_multiplicative_function (fds_nth fds_zeta) \<nexists>p. prime p \<and> fds_nth fds_zeta p = nat_power p s goal (1 subgoal): 1. eval_fds fds_zeta s \<noteq> (0::'a) [PROOF STEP] by (subst fds_abs_convergent_zero_iff) simp_all [PROOF STATE] proof (state) this: eval_fds fds_zeta s \<noteq> (0::'a) goal: No subgoals! [PROOF STEP] qed
\section{Theme options} The theme comes with several options, all of which can be given in a comma-separated list like in \begin{lstlisting} \usetheme[options]{UniversiteitAntwerpen} \end{lstlisting} \begin{center} \begin{tabulary}{12cm}{p{3cm}L}\toprule \lstinline!dark! & Just like the Universiteit Antwerpen itself provides two different flavors of PowerPoint\textsuperscript{\textregistered} presentations, one with a light background and one with a darker, this \texttt{beamer} themes inherits options for both. By default, the theme applies the light theme, this options switches to the dark counterpart. See figure~\ref{fig:example1}.\\\midrule \lstinline!darktitle! & With \lstinline!darktitle! (and not \lstinline!dark!), the title page will have a dark background while all other slides will retain the light background.\\\midrule \lstinline!framenumber! & The \lstinline!framenumber! option makes sure that the number of the current frame is displayed. In the light scheme the current frame is displayed in the lower right corner of each frame, the dark scheme places them in the upper right corner.\\\midrule \lstinline!totalframenumber! & With \lstinline!framenumber! turned on, the \lstinline!totalframenumber! option makes sure that the total number of frames is displayed alongside with the current frame number.\\\bottomrule \end{tabulary} \end{center} \begin{note} The \texttt{beamer} option \lstinline!compress! is respected in the sense that, if it is provided, header and footer will take less space such that there is more space for actual frame content. \end{note}
const file = joinpath((@__FILE__) |> dirname |> dirname, "example", "examples.bib") |> readstring using BenchmarkTools using BibTeX @benchmark parse_bibtex(file)
theory connectedness imports separation begin (**The sets A and B constitute a separation of a set S.*) definition Separation ("Separation[_]") where "Separation[\<C>] S A B \<equiv> nonEmpty A \<and> nonEmpty B \<and> Sep[\<C>] A B \<and> S \<approx> A \<^bold>\<or> B" (**A set is called separated if it has a separation.*) definition Separated ("Separated[_]") where "Separated[\<C>] S \<equiv> \<exists>A B. Separation[\<C>] S A B" (**A set is called connected if it has no separation.*) abbreviation Connected ("Connected[_]") where "Connected[\<C>] S \<equiv> \<not>Separated[\<C>] S" (**Empty sets and singletons are connected.*) lemma conn_prop1: "Connected[\<C>] \<^bold>\<bottom>" by (smt (verit, best) L10 L6 Separated_def Separation_def bottom_def setequ_equ subset_def) lemma conn_prop2: "Cl_2 \<C> \<Longrightarrow> \<forall>x. Connected[\<C>] {x}" by (smt (verit, best) singleton_def Disj_def Sep_disj Separated_def Separation_def bottom_def join_def meet_def setequ_equ) (**A connected subset of a separated set X = (A|B) is contained in either A or B. *) lemma conn_prop3: assumes mono: "MONO \<C>" shows "\<forall>S X. Connected[\<C>] S \<and> S \<preceq> X \<longrightarrow> (\<forall>A B. Separation[\<C>] X A B \<longrightarrow> (S \<preceq> A \<or> S \<preceq> B))" proof - { fix S X { assume conn: "Connected[\<C>] S" and subset: "S \<preceq> X" { fix A B { assume sep: "Separation[\<C>] X A B" from subset sep have aux: "S \<approx> (S \<^bold>\<and> A) \<^bold>\<or> (S \<^bold>\<and> B)" by (smt (verit, best) BA_distr1 L10 Separation_def meet_def setequ_char) from this mono sep conn have "Disj S A \<or> Disj S B" unfolding Separated_def by (smt (verit, best) Disj_char L3 L5 Sep_sub Separation_def bottom_def setequ_char) hence "(S \<preceq> A \<or> S \<preceq> B)" by (smt (verit) Disj_def L14 L5 aux join_def setequ_equ subset_def) }}}} thus ?thesis by blast qed (**If S is connected and @{text "S \<preceq> X \<preceq> \<C>(S)"} then X is connected too.*) lemma conn_prop4: assumes mono: "MONO \<C>" shows "\<forall>S X. Connected[\<C>] S \<and> S \<preceq> X \<and> X \<preceq> \<C> S \<longrightarrow> Connected[\<C>] X" proof - { fix S X { assume conn: "Connected[\<C>] S" and SsubsetX: "S \<preceq> X" and XsubsetCS: "X \<preceq> \<C> S" from mono conn SsubsetX have aux: "(\<forall>A B. Separation[\<C>] X A B \<longrightarrow> (S \<preceq> A \<or> S \<preceq> B))" using conn_prop3 by blast have "Connected[\<C>] X" proof assume "Separated[\<C>] X" from this obtain A and B where sepXAB: "Separation[\<C>] X A B" using Separated_def by blast from this aux have "(S \<preceq> A \<or> S \<preceq> B)" by blast thus "False" proof assume assm: "S \<preceq> A" from this mono have "\<C> S \<preceq> \<C> A" by (simp add: MONO_def) from this assm sepXAB have 1: "Disj (\<C> S) B" by (metis (mono_tags) Sep_def Sep_sub Separation_def mono subset_def) from sepXAB XsubsetCS have 2: "B \<preceq> \<C> S" by (simp add: Separation_def join_def setequ_equ subset_def) from sepXAB have 3: "nonEmpty B" by (simp add: Separation_def) from 1 2 3 show "False" by (metis Disj_char L10 bottom_def setequ_equ) next assume assm: "S \<preceq> B" (*same reasoning as previous case*) from this mono have "\<C> S \<preceq> \<C> B" by (simp add: MONO_def) from this assm sepXAB have 1: "Disj (\<C> S) A" by (metis (mono_tags) Sep_def Sep_sub Separation_def mono subset_def) from sepXAB XsubsetCS have 2: "A \<preceq> \<C> S" by (simp add: Separation_def join_def setequ_equ subset_def) from sepXAB have 3: "nonEmpty A" by (simp add: Separation_def) from 1 2 3 show "False" by (metis Disj_char L10 bottom_def setequ_equ) qed qed }} thus ?thesis by blast qed (**If every two points of a set X are contained in some connected subset of X then X is connected.*) lemma conn_prop5: assumes mono: \<open>MONO \<C>\<close> and cl2: \<open>Cl_2 \<C>\<close> shows \<open>(\<forall>p q. X p \<and> X q \<and> (\<exists>S. S \<preceq> X \<and> Connected[\<C>] S \<and> S p \<and> S q)) \<longrightarrow> Connected[\<C>] X\<close> proof - { assume premise: \<open>\<forall>p q. X p \<and> X q \<and> (\<exists>S. S \<preceq> X \<and> Connected[\<C>] S \<and> S p \<and> S q)\<close> have \<open>Connected[\<C>] X\<close> proof assume \<open>Separated[\<C>] X\<close> then obtain A and B where sepXAB: \<open>Separation[\<C>] X A B\<close> using Separated_def by blast hence nonempty: \<open>nonEmpty A \<and> nonEmpty B\<close> by (simp add: Separation_def) let ?p = \<open>SOME a. A a\<close> and ?q = \<open>SOME b. B b\<close> (*since A and B are non-empty*) from nonempty have \<open>X ?p \<and> X ?q\<close> by (simp add: premise) hence \<open>\<exists>S. S \<preceq> X \<and> Connected[\<C>] S \<and> S ?p \<and> S ?q\<close> by (simp add: premise) then obtain S where aux: \<open>S \<preceq> X \<and> Connected[\<C>] S \<and> S ?p \<and> S ?q\<close> .. from aux nonempty have \<open>\<not>Disj S A \<and> \<not>Disj S B\<close> by (metis Disj_def someI) moreover from aux mono sepXAB have \<open>S \<preceq> A \<or> S \<preceq> B\<close> using conn_prop3 by blast moreover from cl2 sepXAB have \<open>Disj A B\<close> by (simp add: Sep_disj Separation_def) ultimately show False by (metis (mono_tags, lifting) Disj_def subset_def) qed } thus ?thesis .. qed end
theory Examples3 imports Examples begin subsection {* Third Version: Local Interpretation \label{sec:local-interpretation} *} text {* In the above example, the fact that @{term "op \<le>"} is a partial order for the integers was used in the second goal to discharge the premise in the definition of @{text "op \<sqsubset>"}. In general, proofs of the equations not only may involve definitions from the interpreted locale but arbitrarily complex arguments in the context of the locale. Therefore it would be convenient to have the interpreted locale conclusions temporarily available in the proof. This can be achieved by a locale interpretation in the proof body. The command for local interpretations is \isakeyword{interpret}. We repeat the example from the previous section to illustrate this. *} interpretation %visible int: partial_order "op \<le> :: int \<Rightarrow> int \<Rightarrow> bool" where "int.less x y = (x < y)" proof - show "partial_order (op \<le> :: int \<Rightarrow> int \<Rightarrow> bool)" by unfold_locales auto then interpret int: partial_order "op \<le> :: [int, int] \<Rightarrow> bool" . show "int.less x y = (x < y)" unfolding int.less_def by auto qed text {* The inner interpretation is immediate from the preceding fact and proved by assumption (Isar short hand ``.''). It enriches the local proof context by the theorems also obtained in the interpretation from Section~\ref{sec:po-first}, and @{text int.less_def} may directly be used to unfold the definition. Theorems from the local interpretation disappear after leaving the proof context --- that is, after the succeeding \isakeyword{next} or \isakeyword{qed} statement. *} subsection {* Further Interpretations *} text {* Further interpretations are necessary for the other locales. In @{text lattice} the operations~@{text \<sqinter>} and~@{text \<squnion>} are substituted by @{term "min :: int \<Rightarrow> int \<Rightarrow> int"} and @{term "max :: int \<Rightarrow> int \<Rightarrow> int"}. The entire proof for the interpretation is reproduced to give an example of a more elaborate interpretation proof. Note that the equations are named so they can be used in a later example. *} interpretation %visible int: lattice "op \<le> :: int \<Rightarrow> int \<Rightarrow> bool" where int_min_eq: "int.meet x y = min x y" and int_max_eq: "int.join x y = max x y" proof - show "lattice (op \<le> :: int \<Rightarrow> int \<Rightarrow> bool)" txt {* \normalsize We have already shown that this is a partial order, *} apply unfold_locales txt {* \normalsize hence only the lattice axioms remain to be shown. @{subgoals [display]} By @{text is_inf} and @{text is_sup}, *} apply (unfold int.is_inf_def int.is_sup_def) txt {* \normalsize the goals are transformed to these statements: @{subgoals [display]} This is Presburger arithmetic, which can be solved by the method @{text arith}. *} by arith+ txt {* \normalsize In order to show the equations, we put ourselves in a situation where the lattice theorems can be used in a convenient way. *} then interpret int: lattice "op \<le> :: int \<Rightarrow> int \<Rightarrow> bool" . show "int.meet x y = min x y" by (bestsimp simp: int.meet_def int.is_inf_def) show "int.join x y = max x y" by (bestsimp simp: int.join_def int.is_sup_def) qed text {* Next follows that @{text "op \<le>"} is a total order, again for the integers. *} interpretation %visible int: total_order "op \<le> :: int \<Rightarrow> int \<Rightarrow> bool" by unfold_locales arith text {* Theorems that are available in the theory at this point are shown in Table~\ref{tab:int-lattice}. Two points are worth noting: \begin{table} \hrule \vspace{2ex} \begin{center} \begin{tabular}{l} @{thm [source] int.less_def} from locale @{text partial_order}: \\ \quad @{thm int.less_def} \\ @{thm [source] int.meet_left} from locale @{text lattice}: \\ \quad @{thm int.meet_left} \\ @{thm [source] int.join_distr} from locale @{text distrib_lattice}: \\ \quad @{thm int.join_distr} \\ @{thm [source] int.less_total} from locale @{text total_order}: \\ \quad @{thm int.less_total} \end{tabular} \end{center} \hrule \caption{Interpreted theorems for~@{text \<le>} on the integers.} \label{tab:int-lattice} \end{table} \begin{itemize} \item Locale @{text distrib_lattice} was also interpreted. Since the locale hierarchy reflects that total orders are distributive lattices, the interpretation of the latter was inserted automatically with the interpretation of the former. In general, interpretation traverses the locale hierarchy upwards and interprets all encountered locales, regardless whether imported or proved via the \isakeyword{sublocale} command. Existing interpretations are skipped avoiding duplicate work. \item The predicate @{term "op <"} appears in theorem @{thm [source] int.less_total} although an equation for the replacement of @{text "op \<sqsubset>"} was only given in the interpretation of @{text partial_order}. The interpretation equations are pushed downwards the hierarchy for related interpretations --- that is, for interpretations that share the instances of parameters they have in common. \end{itemize} *} text {* The interpretations for a locale $n$ within the current theory may be inspected with \isakeyword{print\_interps}~$n$. This prints the list of instances of $n$, for which interpretations exist. For example, \isakeyword{print\_interps} @{term partial_order} outputs the following: \begin{small} \begin{alltt} int! : partial_order "op \(\le\)" \end{alltt} \end{small} Of course, there is only one interpretation. The interpretation qualifier on the left is decorated with an exclamation point. This means that it is mandatory. Qualifiers can either be \emph{mandatory} or \emph{optional}, designated by ``!'' or ``?'' respectively. Mandatory qualifiers must occur in a name reference while optional ones need not. Mandatory qualifiers prevent accidental hiding of names, while optional qualifiers can be more convenient to use. For \isakeyword{interpretation}, the default is ``!''. *} section {* Locale Expressions \label{sec:expressions} *} text {* A map~@{term \<phi>} between partial orders~@{text \<sqsubseteq>} and~@{text \<preceq>} is called order preserving if @{text "x \<sqsubseteq> y"} implies @{text "\<phi> x \<preceq> \<phi> y"}. This situation is more complex than those encountered so far: it involves two partial orders, and it is desirable to use the existing locale for both. A locale for order preserving maps requires three parameters: @{text le}~(\isakeyword{infixl}~@{text \<sqsubseteq>}) and @{text le'}~(\isakeyword{infixl}~@{text \<preceq>}) for the orders and~@{text \<phi>} for the map. In order to reuse the existing locale for partial orders, which has the single parameter~@{text le}, it must be imported twice, once mapping its parameter to~@{text le} from the new locale and once to~@{text le'}. This can be achieved with a compound locale expression. In general, a locale expression is a sequence of \emph{locale instances} separated by~``$\textbf{+}$'' and followed by a \isakeyword{for} clause. An instance has the following format: \begin{quote} \textit{qualifier} \textbf{:} \textit{locale-name} \textit{parameter-instantiation} \end{quote} We have already seen locale instances as arguments to \isakeyword{interpretation} in Section~\ref{sec:interpretation}. As before, the qualifier serves to disambiguate names from different instances of the same locale. While in \isakeyword{interpretation} qualifiers default to mandatory, in import and in the \isakeyword{sublocale} command, they default to optional. Since the parameters~@{text le} and~@{text le'} are to be partial orders, our locale for order preserving maps will import the these instances: \begin{small} \begin{alltt} le: partial_order le le': partial_order le' \end{alltt} \end{small} For matter of convenience we choose to name parameter names and qualifiers alike. This is an arbitrary decision. Technically, qualifiers and parameters are unrelated. Having determined the instances, let us turn to the \isakeyword{for} clause. It serves to declare locale parameters in the same way as the context element \isakeyword{fixes} does. Context elements can only occur after the import section, and therefore the parameters referred to in the instances must be declared in the \isakeyword{for} clause. The \isakeyword{for} clause is also where the syntax of these parameters is declared. Two context elements for the map parameter~@{text \<phi>} and the assumptions that it is order preserving complete the locale declaration. *} locale order_preserving = le: partial_order le + le': partial_order le' for le (infixl "\<sqsubseteq>" 50) and le' (infixl "\<preceq>" 50) + fixes \<phi> assumes hom_le: "x \<sqsubseteq> y \<Longrightarrow> \<phi> x \<preceq> \<phi> y" text (in order_preserving) {* Here are examples of theorems that are available in the locale: \hspace*{1em}@{thm [source] hom_le}: @{thm hom_le} \hspace*{1em}@{thm [source] le.less_le_trans}: @{thm le.less_le_trans} \hspace*{1em}@{thm [source] le'.less_le_trans}: @{thm [display, indent=4] le'.less_le_trans} While there is infix syntax for the strict operation associated to @{term "op \<sqsubseteq>"}, there is none for the strict version of @{term "op \<preceq>"}. The abbreviation @{text less} with its infix syntax is only available for the original instance it was declared for. We may introduce the abbreviation @{text less'} with infix syntax~@{text \<prec>} with the following declaration: *} abbreviation (in order_preserving) less' (infixl "\<prec>" 50) where "less' \<equiv> partial_order.less le'" text (in order_preserving) {* Now the theorem is displayed nicely as @{thm [source] le'.less_le_trans}: @{thm [display, indent=2] le'.less_le_trans} *} text {* There are short notations for locale expressions. These are discussed in the following. *} subsection {* Default Instantiations *} text {* It is possible to omit parameter instantiations. The instantiation then defaults to the name of the parameter itself. For example, the locale expression @{text partial_order} is short for @{text "partial_order le"}, since the locale's single parameter is~@{text le}. We took advantage of this in the \isakeyword{sublocale} declarations of Section~\ref{sec:changing-the-hierarchy}. *} subsection {* Implicit Parameters \label{sec:implicit-parameters} *} text {* In a locale expression that occurs within a locale declaration, omitted parameters additionally extend the (possibly empty) \isakeyword{for} clause. The \isakeyword{for} clause is a general construct of Isabelle/Isar to mark names occurring in the preceding declaration as ``arbitrary but fixed''. This is necessary for example, if the name is already bound in a surrounding context. In a locale expression, names occurring in parameter instantiations should be bound by a \isakeyword{for} clause whenever these names are not introduced elsewhere in the context --- for example, on the left hand side of a \isakeyword{sublocale} declaration. There is an exception to this rule in locale declarations, where the \isakeyword{for} clause serves to declare locale parameters. Here, locale parameters for which no parameter instantiation is given are implicitly added, with their mixfix syntax, at the beginning of the \isakeyword{for} clause. For example, in a locale declaration, the expression @{text partial_order} is short for \begin{small} \begin{alltt} partial_order le \isakeyword{for} le (\isakeyword{infixl} "\(\sqsubseteq\)" 50)\textrm{.} \end{alltt} \end{small} This short hand was used in the locale declarations throughout Section~\ref{sec:import}. *} text{* The following locale declarations provide more examples. A map~@{text \<phi>} is a lattice homomorphism if it preserves meet and join. *} locale lattice_hom = le: lattice + le': lattice le' for le' (infixl "\<preceq>" 50) + fixes \<phi> assumes hom_meet: "\<phi> (x \<sqinter> y) = le'.meet (\<phi> x) (\<phi> y)" and hom_join: "\<phi> (x \<squnion> y) = le'.join (\<phi> x) (\<phi> y)" text {* The parameter instantiation in the first instance of @{term lattice} is omitted. This causes the parameter~@{text le} to be added to the \isakeyword{for} clause, and the locale has parameters~@{text le},~@{text le'} and, of course,~@{text \<phi>}. Before turning to the second example, we complete the locale by providing infix syntax for the meet and join operations of the second lattice. *} context lattice_hom begin abbreviation meet' (infixl "\<sqinter>''" 50) where "meet' \<equiv> le'.meet" abbreviation join' (infixl "\<squnion>''" 50) where "join' \<equiv> le'.join" end text {* The next example makes radical use of the short hand facilities. A homomorphism is an endomorphism if both orders coincide. *} locale lattice_end = lattice_hom _ le text {* The notation~@{text _} enables to omit a parameter in a positional instantiation. The omitted parameter,~@{text le} becomes the parameter of the declared locale and is, in the following position, used to instantiate the second parameter of @{text lattice_hom}. The effect is that of identifying the first in second parameter of the homomorphism locale. *} text {* The inheritance diagram of the situation we have now is shown in Figure~\ref{fig:hom}, where the dashed line depicts an interpretation which is introduced below. Parameter instantiations are indicated by $\sqsubseteq \mapsto \preceq$ etc. By looking at the inheritance diagram it would seem that two identical copies of each of the locales @{text partial_order} and @{text lattice} are imported by @{text lattice_end}. This is not the case! Inheritance paths with identical morphisms are automatically detected and the conclusions of the respective locales appear only once. \begin{figure} \hrule \vspace{2ex} \begin{center} \begin{tikzpicture} \node (o) at (0,0) {@{text partial_order}}; \node (oh) at (1.5,-2) {@{text order_preserving}}; \node (oh1) at (1.5,-0.7) {$\scriptscriptstyle \sqsubseteq \mapsto \sqsubseteq$}; \node (oh2) at (0,-1.3) {$\scriptscriptstyle \sqsubseteq \mapsto \preceq$}; \node (l) at (-1.5,-2) {@{text lattice}}; \node (lh) at (0,-4) {@{text lattice_hom}}; \node (lh1) at (0,-2.7) {$\scriptscriptstyle \sqsubseteq \mapsto \sqsubseteq$}; \node (lh2) at (-1.5,-3.3) {$\scriptscriptstyle \sqsubseteq \mapsto \preceq$}; \node (le) at (0,-6) {@{text lattice_end}}; \node (le1) at (0,-4.8) [anchor=west]{$\scriptscriptstyle \sqsubseteq \mapsto \sqsubseteq$}; \node (le2) at (0,-5.2) [anchor=west]{$\scriptscriptstyle \preceq \mapsto \sqsubseteq$}; \draw (o) -- (l); \draw[dashed] (oh) -- (lh); \draw (lh) -- (le); \draw (o) .. controls (oh1.south west) .. (oh); \draw (o) .. controls (oh2.north east) .. (oh); \draw (l) .. controls (lh1.south west) .. (lh); \draw (l) .. controls (lh2.north east) .. (lh); \end{tikzpicture} \end{center} \hrule \caption{Hierarchy of Homomorphism Locales.} \label{fig:hom} \end{figure} *} text {* It can be shown easily that a lattice homomorphism is order preserving. As the final example of this section, a locale interpretation is used to assert this: *} sublocale lattice_hom \<subseteq> order_preserving proof unfold_locales fix x y assume "x \<sqsubseteq> y" then have "y = (x \<squnion> y)" by (simp add: le.join_connection) then have "\<phi> y = (\<phi> x \<squnion>' \<phi> y)" by (simp add: hom_join [symmetric]) then show "\<phi> x \<preceq> \<phi> y" by (simp add: le'.join_connection) qed text (in lattice_hom) {* Theorems and other declarations --- syntax, in particular --- from the locale @{text order_preserving} are now active in @{text lattice_hom}, for example @{thm [source] hom_le}: @{thm [display, indent=2] hom_le} This theorem will be useful in the following section. *} section {* Conditional Interpretation *} text {* There are situations where an interpretation is not possible in the general case since the desired property is only valid if certain conditions are fulfilled. Take, for example, the function @{text "\<lambda>i. n * i"} that scales its argument by a constant factor. This function is order preserving (and even a lattice endomorphism) with respect to @{term "op \<le>"} provided @{text "n \<ge> 0"}. It is not possible to express this using a global interpretation, because it is in general unspecified whether~@{term n} is non-negative, but one may make an interpretation in an inner context of a proof where full information is available. This is not fully satisfactory either, since potentially interpretations may be required to make interpretations in many contexts. What is required is an interpretation that depends on the condition --- and this can be done with the \isakeyword{sublocale} command. For this purpose, we introduce a locale for the condition. *} locale non_negative = fixes n :: int assumes non_neg: "0 \<le> n" text {* It is again convenient to make the interpretation in an incremental fashion, first for order preserving maps, the for lattice endomorphisms. *} sublocale non_negative \<subseteq> order_preserving "op \<le>" "op \<le>" "\<lambda>i. n * i" using non_neg by unfold_locales (rule mult_left_mono) text {* While the proof of the previous interpretation is straightforward from monotonicity lemmas for~@{term "op *"}, the second proof follows a useful pattern. *} sublocale %visible non_negative \<subseteq> lattice_end "op \<le>" "\<lambda>i. n * i" proof (unfold_locales, unfold int_min_eq int_max_eq) txt {* \normalsize Unfolding the locale predicates \emph{and} the interpretation equations immediately yields two subgoals that reflect the core conjecture. @{subgoals [display]} It is now necessary to show, in the context of @{term non_negative}, that multiplication by~@{term n} commutes with @{term min} and @{term max}. *} qed (auto simp: hom_le) text (in order_preserving) {* The lemma @{thm [source] hom_le} simplifies a proof that would have otherwise been lengthy and we may consider making it a default rule for the simplifier: *} lemmas (in order_preserving) hom_le [simp] subsection {* Avoiding Infinite Chains of Interpretations \label{sec:infinite-chains} *} text {* Similar situations arise frequently in formalisations of abstract algebra where it is desirable to express that certain constructions preserve certain properties. For example, polynomials over rings are rings, or --- an example from the domain where the illustrations of this tutorial are taken from --- a partial order may be obtained for a function space by point-wise lifting of the partial order of the co-domain. This corresponds to the following interpretation: *} sublocale %visible partial_order \<subseteq> f: partial_order "\<lambda>f g. \<forall>x. f x \<sqsubseteq> g x" oops text {* Unfortunately this is a cyclic interpretation that leads to an infinite chain, namely @{text [display, indent=2] "partial_order \<subseteq> partial_order (\<lambda>f g. \<forall>x. f x \<sqsubseteq> g x) \<subseteq> partial_order (\<lambda>f g. \<forall>x y. f x y \<sqsubseteq> g x y) \<subseteq> \<dots>"} and the interpretation is rejected. Instead it is necessary to declare a locale that is logically equivalent to @{term partial_order} but serves to collect facts about functions spaces where the co-domain is a partial order, and to make the interpretation in its context: *} locale fun_partial_order = partial_order sublocale fun_partial_order \<subseteq> f: partial_order "\<lambda>f g. \<forall>x. f x \<sqsubseteq> g x" by unfold_locales (fast,rule,fast,blast intro: trans) text {* It is quite common in abstract algebra that such a construction maps a hierarchy of algebraic structures (or specifications) to a related hierarchy. By means of the same lifting, a function space is a lattice if its co-domain is a lattice: *} locale fun_lattice = fun_partial_order + lattice sublocale fun_lattice \<subseteq> f: lattice "\<lambda>f g. \<forall>x. f x \<sqsubseteq> g x" proof unfold_locales fix f g have "partial_order.is_inf (\<lambda>f g. \<forall>x. f x \<sqsubseteq> g x) f g (\<lambda>x. f x \<sqinter> g x)" apply (rule is_infI) apply rule+ apply (drule spec, assumption)+ done then show "\<exists>inf. partial_order.is_inf (\<lambda>f g. \<forall>x. f x \<sqsubseteq> g x) f g inf" by fast next fix f g have "partial_order.is_sup (\<lambda>f g. \<forall>x. f x \<sqsubseteq> g x) f g (\<lambda>x. f x \<squnion> g x)" apply (rule is_supI) apply rule+ apply (drule spec, assumption)+ done then show "\<exists>sup. partial_order.is_sup (\<lambda>f g. \<forall>x. f x \<sqsubseteq> g x) f g sup" by fast qed section {* Further Reading *} text {* More information on locales and their interpretation is available. For the locale hierarchy of import and interpretation dependencies see~@{cite Ballarin2006a}; interpretations in theories and proofs are covered in~@{cite Ballarin2006b}. In the latter, I show how interpretation in proofs enables to reason about families of algebraic structures, which cannot be expressed with locales directly. Haftmann and Wenzel~@{cite HaftmannWenzel2007} overcome a restriction of axiomatic type classes through a combination with locale interpretation. The result is a Haskell-style class system with a facility to generate ML and Haskell code. Classes are sufficient for simple specifications with a single type parameter. The locales for orders and lattices presented in this tutorial fall into this category. Order preserving maps, homomorphisms and vector spaces, on the other hand, do not. The locales reimplementation for Isabelle 2009 provides, among other improvements, a clean integration with Isabelle/Isar's local theory mechanisms, which are described in another paper by Haftmann and Wenzel~@{cite HaftmannWenzel2009}. The original work of Kamm\"uller on locales~@{cite KammullerEtAl1999} may be of interest from a historical perspective. My previous report on locales and locale expressions~@{cite Ballarin2004a} describes a simpler form of expressions than available now and is outdated. The mathematical background on orders and lattices is taken from Jacobson's textbook on algebra~@{cite \<open>Chapter~8\<close> Jacobson1985}. The sources of this tutorial, which include all proofs, are available with the Isabelle distribution at @{url "http://isabelle.in.tum.de"}. *} text {* \begin{table} \hrule \vspace{2ex} \begin{center} \begin{tabular}{l>$c<$l} \multicolumn{3}{l}{Miscellaneous} \\ \textit{attr-name} & ::= & \textit{name} $|$ \textit{attribute} $|$ \textit{name} \textit{attribute} \\ \textit{qualifier} & ::= & \textit{name} [``\textbf{?}'' $|$ ``\textbf{!}''] \\[2ex] \multicolumn{3}{l}{Context Elements} \\ \textit{fixes} & ::= & \textit{name} [ ``\textbf{::}'' \textit{type} ] [ ``\textbf{(}'' \textbf{structure} ``\textbf{)}'' $|$ \textit{mixfix} ] \\ \begin{comment} \textit{constrains} & ::= & \textit{name} ``\textbf{::}'' \textit{type} \\ \end{comment} \textit{assumes} & ::= & [ \textit{attr-name} ``\textbf{:}'' ] \textit{proposition} \\ \begin{comment} \textit{defines} & ::= & [ \textit{attr-name} ``\textbf{:}'' ] \textit{proposition} \\ \textit{notes} & ::= & [ \textit{attr-name} ``\textbf{=}'' ] ( \textit{qualified-name} [ \textit{attribute} ] )$^+$ \\ \end{comment} \textit{element} & ::= & \textbf{fixes} \textit{fixes} ( \textbf{and} \textit{fixes} )$^*$ \\ \begin{comment} & | & \textbf{constrains} \textit{constrains} ( \textbf{and} \textit{constrains} )$^*$ \\ \end{comment} & | & \textbf{assumes} \textit{assumes} ( \textbf{and} \textit{assumes} )$^*$ \\[2ex] %\begin{comment} % & | % & \textbf{defines} \textit{defines} ( \textbf{and} \textit{defines} )$^*$ \\ % & | % & \textbf{notes} \textit{notes} ( \textbf{and} \textit{notes} )$^*$ \\ %\end{comment} \multicolumn{3}{l}{Locale Expressions} \\ \textit{pos-insts} & ::= & ( \textit{term} $|$ ``\textbf{\_}'' )$^*$ \\ \textit{named-insts} & ::= & \textbf{where} \textit{name} ``\textbf{=}'' \textit{term} ( \textbf{and} \textit{name} ``\textbf{=}'' \textit{term} )$^*$ \\ \textit{instance} & ::= & [ \textit{qualifier} ``\textbf{:}'' ] \textit{name} ( \textit{pos-insts} $|$ \textit{named-inst} ) \\ \textit{expression} & ::= & \textit{instance} ( ``\textbf{+}'' \textit{instance} )$^*$ [ \textbf{for} \textit{fixes} ( \textbf{and} \textit{fixes} )$^*$ ] \\[2ex] \multicolumn{3}{l}{Declaration of Locales} \\ \textit{locale} & ::= & \textit{element}$^+$ \\ & | & \textit{expression} [ ``\textbf{+}'' \textit{element}$^+$ ] \\ \textit{toplevel} & ::= & \textbf{locale} \textit{name} [ ``\textbf{=}'' \textit{locale} ] \\[2ex] \multicolumn{3}{l}{Interpretation} \\ \textit{equation} & ::= & [ \textit{attr-name} ``\textbf{:}'' ] \textit{prop} \\ \textit{equations} & ::= & \textbf{where} \textit{equation} ( \textbf{and} \textit{equation} )$^*$ \\ \textit{toplevel} & ::= & \textbf{sublocale} \textit{name} ( ``$<$'' $|$ ``$\subseteq$'' ) \textit{expression} \textit{proof} \\ & | & \textbf{interpretation} \textit{expression} [ \textit{equations} ] \textit{proof} \\ & | & \textbf{interpret} \textit{expression} \textit{proof} \\[2ex] \multicolumn{3}{l}{Diagnostics} \\ \textit{toplevel} & ::= & \textbf{print\_locales} \\ & | & \textbf{print\_locale} [ ``\textbf{!}'' ] \textit{name} \\ & | & \textbf{print\_interps} \textit{name} \end{tabular} \end{center} \hrule \caption{Syntax of Locale Commands.} \label{tab:commands} \end{table} *} text {* \textbf{Revision History.} For the present third revision of the tutorial, much of the explanatory text was rewritten. Inheritance of interpretation equations is available with the forthcoming release of Isabelle, which at the time of editing these notes is expected for the end of 2009. The second revision accommodates changes introduced by the locales reimplementation for Isabelle 2009. Most notably locale expressions have been generalised from renaming to instantiation. *} text {* \textbf{Acknowledgements.} Alexander Krauss, Tobias Nipkow, Randy Pollack, Andreas Schropp, Christian Sternagel and Makarius Wenzel have made useful comments on earlier versions of this document. The section on conditional interpretation was inspired by a number of e-mail enquiries the author received from locale users, and which suggested that this use case is important enough to deserve explicit explanation. The term \emph{conditional interpretation} is due to Larry Paulson. *} end
################################################## ## Project: Collect API data on fire incidents ## Author: Christopher Hench ################################################## flatten_json <- function(df) { for (col in names(df)) { if (is.list(df[[col]])) { i <- 1 for (row in df[[col]]) { df[[col]][i] <- paste(row, collapse = '; ') i <- i + 1 } df[[col]] <- unlist(df[[col]]) } } return (df) } base_url <- 'https://data.sfgov.org/resource/wbb6-uh78.json?' incident_date <- '2017-10-22T00:00:00.000' incident_date <- URLencode(URL = incident_date, reserved = TRUE) get_request <- paste0(base_url, "incident_date=", incident_date) print(get_request) response <- httr::GET(url = get_request) response <- httr::content(x = response, as = "text") response_df <- data.frame(jsonlite::fromJSON(txt = response, simplifyDataFrame = TRUE, flatten = TRUE)) flattened <- flatten_json(response_df) write.csv(flattened, file='fire-incidents.csv')
\<comment>\<open> * Copyright 2016, NTU * * This software may be distributed and modified according to the terms of * the BSD 2-Clause license. Note that NO WARRANTY is provided. * See "LICENSE_BSD2.txt" for details. * * Author: Zhe Hou. \<close> text {* SPARC V8 TSO memory model*} theory Memory_Model imports Main Processor_Execution begin text {* This theory models the SPARC TSO memory model. *} text {* The sequence of executed meomry operation blocks. *} type_synonym executed_mem_ops = "op_id list" text {* Given a sequence of executed mem_op_block, the memory order op1 m< op2 is true when op1 is in the sequence before op2. If both are not in the sequence, the result is None. If one of them is not in the sequence, then it is later than the one that occurs in the sequence. *} definition memory_order_before:: "op_id \<Rightarrow> executed_mem_ops \<Rightarrow> op_id \<Rightarrow> bool option" ("_ m<_ _") where "op1 m<xseq op2 \<equiv> if (List.member xseq op1) \<and> (List.member xseq op2) then if list_before op1 xseq op2 then Some True else Some False else if List.member xseq op1 then Some True else if List.member xseq op2 then Some False else None" definition memory_order_before_pred:: "(op_id \<Rightarrow> bool) \<Rightarrow> executed_mem_ops \<Rightarrow> op_id \<Rightarrow> op_id set" ("_ m<;_ _") where "P m<;xseq op \<equiv> {a. P a \<and> ((a m<xseq op) = Some True)}" definition max_memory_order_before::"(op_id \<Rightarrow> bool) \<Rightarrow> executed_mem_ops \<Rightarrow> op_id \<Rightarrow> op_id option" ("_ M<;_ _") where "P M<;xseq op1 \<equiv> if (P m<;xseq op1)\<noteq>{} then Some (THE x. (x \<in>(P m<;xseq op1)) \<and> (\<forall>x'\<in> (P m<;xseq op1). (x' m<xseq x) = Some True)) else None" lemma memory_order_before_tran: assumes a0:"distinct xseq" and a1:"(op1 m<xseq op2) = Some True" and a2:"(op2 m<xseq op3) = Some True" shows "(op1 m<xseq op3) = Some True" unfolding memory_order_before_def using a0 a1 a2 by (metis list_before_tran memory_order_before_def option.distinct(1) option.inject) lemma mem_order_not_sym: assumes a0:"distinct xseq" and a1:"(op1 m<xseq op2) = Some True" shows "\<not> ((op2 m<xseq op1) = Some True)" using a0 a1 unfolding memory_order_before_def apply auto by (metis list_before_not_sym option.inject) lemma exists_mem_order_list_member: "finite z \<Longrightarrow> z\<noteq>{} \<Longrightarrow> distinct l \<Longrightarrow> z\<subseteq>{x. List.member l x} \<Longrightarrow> \<exists>x. x\<in>z \<and> (\<forall>x'\<in>z. x'\<noteq>x \<longrightarrow> (x' m<l x) = Some True)" proof(induction rule: Finite_Set.finite_ne_induct) case (singleton x) then show ?case by blast next case (insert x F) then obtain x1 where hp:"x1\<in>F \<and> (\<forall>x'\<in>F. x'\<noteq>x1 \<longrightarrow> (x' m<l x1) = Some True)" by auto then have neq:"x\<noteq>x1" using insert by auto { assume "(x m<l x1) = Some True" then have ?case using hp neq by fastforce }note l1 =this { assume assm:"(x1 m<l x) = Some True" then have ?case using hp neq insert(3) memory_order_before_tran by (metis (full_types) insert.prems(1) insert_iff) }note l2 = this show ?case by (metis insert.prems(2) insert_subset l1 l2 list_elements_before mem_Collect_eq memory_order_before_def neq) qed lemma unique_max_order_before: assumes a2:"distinct l" and a4:"x\<in>z \<and> (\<forall>x'\<in>z. x'\<noteq>x \<longrightarrow> (x' m<l x) = Some True)" shows "\<forall>x'. x'\<in>z \<and> (\<forall>x''\<in>z. x''\<noteq>x' \<longrightarrow> (x'' m<l x') = Some True) \<longrightarrow> x' = x " using mem_order_not_sym[OF a2] a4 by metis lemma exists_unique_mem_order_list:"distinct l \<Longrightarrow> z\<subseteq>{x. List.member l x} \<Longrightarrow> z\<noteq>{} \<Longrightarrow> \<exists>!x. x\<in>z \<and> (\<forall>x'\<in>z. x'\<noteq>x \<longrightarrow> (x' m<l x) = Some True)" apply (frule exists_mem_order_list_member[OF finite_subset_list],assumption+) apply clarsimp by (frule unique_max_order_before, auto simp add: Ex1_def) lemma mem_order_false_cond: "(op1 m<xseq op2) = Some False \<Longrightarrow> ((List.member xseq op1) \<and> (List.member xseq op2) \<and> \<not>(list_before op1 xseq op2)) \<or> (\<not>(List.member xseq op1) \<and> (List.member xseq op2))" unfolding memory_order_before_def by (metis option.distinct(1) option.inject) lemma mem_order_true_cond: "(op1 m<xseq op2) = Some True \<Longrightarrow> ((List.member xseq op1) \<and> (List.member xseq op2) \<and> (list_before op1 xseq op2)) \<or> ((List.member xseq op1) \<and> \<not>(List.member xseq op2))" unfolding memory_order_before_def by (metis option.distinct(1) option.inject) lemma mem_order_true_cond_rev: "((List.member xseq op1) \<and> (List.member xseq op2) \<and> (list_before op1 xseq op2)) \<or> ((List.member xseq op1) \<and> \<not>(List.member xseq op2)) \<Longrightarrow> (op1 m<xseq op2) = Some True" unfolding memory_order_before_def by auto lemma mem_order_true_cond_equiv: "(op1 m<xseq op2) = Some True = ((List.member xseq op1) \<and> (List.member xseq op2) \<and> (list_before op1 xseq op2)) \<or> ((List.member xseq op1) \<and> \<not>(List.member xseq op2))" using mem_order_true_cond mem_order_true_cond_rev by auto section{* The axiomatic model. *} text {* This section gives an axiomatic definition of the TSO model a la SPARCv8 manual. *} definition axiom_order:: "op_id \<Rightarrow> op_id \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> bool" where "axiom_order opid opid' xseq pbm \<equiv> ((type_of_mem_op_block (pbm opid) \<in> {st_block, ast_block}) \<and> (type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}) \<and> (opid \<in> (set xseq) \<and> opid' \<in> (set xseq) \<and> opid \<noteq> opid')) \<longrightarrow> ((opid m<xseq opid') = Some True \<or> (opid' m<xseq opid) = Some True)" text {* A new version of axiom_order for code export. *} definition axiom_atomicity:: "op_id \<Rightarrow> op_id \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> bool" where "axiom_atomicity opid opid' po xseq pbm \<equiv> ((atom_pair_id (pbm opid') = Some opid) \<and> (type_of_mem_op_block (pbm opid) = ald_block) \<and> (type_of_mem_op_block (pbm opid') = ast_block) \<and> (opid ;po^(proc_of_op opid pbm) opid')) \<longrightarrow> (((opid m<xseq opid') = Some True) \<and> (\<forall>opid''. ((type_of_mem_op_block (pbm opid'') \<in> {st_block, ast_block}) \<and> List.member xseq opid'' \<and> \<comment>\<open> opid'' \<noteq> opid is true because their types are different. \<close> opid'' \<noteq> opid') \<longrightarrow> ((opid'' m<xseq opid) = Some True \<or> (opid' m<xseq opid'') = Some True)))" definition axiom_storestore:: "op_id \<Rightarrow> op_id \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> bool" where "axiom_storestore opid opid' po xseq pbm \<equiv> ((type_of_mem_op_block (pbm opid) \<in> {st_block, ast_block}) \<and> (type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}) \<and> (opid ;po^(proc_of_op opid pbm) opid')) \<longrightarrow> (opid m<xseq opid') = Some True" text {* A new version of axiom_storestore for code export. *} text {* Since our operational semantics always terminate, the axiom Termination is trivialised to whether a store is eventually committed by the memory. Thus we only need to check if it is in the (final) executed sequence or not. *} definition axiom_termination:: "op_id \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> bool" where "axiom_termination opid po xseq pbm \<equiv> ( (\<exists>p. List.member (po p) opid \<and> p<(Suc max_proc)) \<and> (type_of_mem_op_block (pbm opid) \<in> {st_block, ast_block})) \<longrightarrow> List.member xseq opid" definition max_mem_order:: "op_id set \<Rightarrow> proc \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> op_id option" where "max_mem_order opids p po xseq \<equiv> if opids \<noteq> {} then Some (THE opid. (opid \<in> opids \<and> (\<forall>opid'. ((opid' \<in> opids \<and> opid' \<noteq> opid) \<longrightarrow> ((opid' m<xseq opid) = Some True \<or> (opid' ;po^p opid)))))) else None" text {* A new definition for max_mem_order for code export. *} \<comment>\<open> primrec max_mem_order_list:: "op_id list \<Rightarrow> proc \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> op_id option \<Rightarrow> op_id option" where "max_mem_order_list [] p po xseq opidop = opidop" |"max_mem_order_list (x#xl) p po xseq opidop = ( case opidop of None \<Rightarrow> max_mem_order_list xl p po xseq (Some x) |Some opid \<Rightarrow> (if (x m<2xseq opid) = Some True \<or> (x 2;po^p opid) then max_mem_order_list xl p po xseq (Some opid) else max_mem_order_list xl p po xseq (Some x)))" lemma max_mem_order_code_equal1: "x=max_mem_order_list opids p po xseq None \<Longrightarrow> x= max_mem_order (set opids) p po xseq" sorry lemma max_mem_order_code_equal2: "x= max_mem_order (set opids) p po xseq \<Longrightarrow> x=max_mem_order_list opids p po xseq None" unfolding max_mem_order_def sorry lemma max_mem_order_code_equal3: "max_mem_order (set opids) p po xseq = max_mem_order_list opids p po xseq None" using max_mem_order_code_equal1 max_mem_order_code_equal2 by auto definition max_mem_order2:: "op_id set \<Rightarrow> proc \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> op_id option" where "max_mem_order2 opids p po xseq \<equiv> max_mem_order_list (sorted_list_of_set opids) p po xseq None" \<close> lemma xx:"finite opids \<Longrightarrow> set (sorted_list_of_set opids) = opids" by simp lemma list_before_x: "list_before x xlist opid \<Longrightarrow> list_before x (a#xlist) opid" unfolding list_before_def by (metis Suc_less_eq le0 length_Cons nth_Cons_Suc) lemma list_before_x': "x\<noteq>a \<Longrightarrow> list_before x (a#xlist) opid \<Longrightarrow> list_before x xlist opid" unfolding list_before_def proof auto fix i :: nat and j :: nat assume a1: "(a # xlist) ! i \<noteq> a" assume a2: "i < j" assume a3: "j < Suc (length xlist)" have "\<forall>n na. \<not> (n::nat) < na \<or> na \<noteq> 0" by linarith then have f4: "j \<noteq> 0" using a2 by metis obtain nn :: "nat \<Rightarrow> nat \<Rightarrow> nat" where f5: "\<forall>x0 x1. (\<exists>v2. x1 = Suc v2 \<and> v2 < x0) = (x1 = Suc (nn x0 x1) \<and> nn x0 x1 < x0)" by moura have "i < Suc (length xlist)" using a3 a2 dual_order.strict_trans by blast then show "\<exists>n<length xlist. \<exists>na<length xlist. xlist ! n = (a # xlist) ! i \<and> xlist ! na = xlist ! (j - Suc 0) \<and> n < na" using f5 f4 a3 a2 a1 by (metis (no_types) One_nat_def diff_Suc_1 less_Suc_eq_0_disj nth_Cons') qed definition axiom_value:: "proc \<Rightarrow> op_id \<Rightarrow> virtual_address \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> sparc_state \<Rightarrow> memory_value option" where "axiom_value p opid addr po xseq pbm state \<equiv> case (max_mem_order ({opid'. (opid' m<xseq opid) = Some True \<and> (type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}) \<and> Some addr = op_addr (get_mem_op_state opid' state)} \<union> {opid''. (opid'' ;po^p opid) \<and> (type_of_mem_op_block (pbm opid'') \<in> {st_block, ast_block}) \<and> Some addr = op_addr (get_mem_op_state opid'' state)}) p po xseq) of Some opid''' \<Rightarrow> op_val (get_mem_op_state opid''' state) |None \<Rightarrow> None" definition st_blocks_addr::"virtual_address \<Rightarrow> program_block_map \<Rightarrow> sparc_state \<Rightarrow> op_id \<Rightarrow> bool" where "st_blocks_addr addr pbm s \<equiv> \<lambda>opid. (type_of_mem_op_block (pbm opid) \<in> {st_block, ast_block}) \<and> Some addr = op_addr (get_mem_op_state opid s)" definition axiom_value'::"proc \<Rightarrow> op_id \<Rightarrow> virtual_address \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> sparc_state \<Rightarrow> memory_value option" where "axiom_value' p opid addr po xseq pbm state \<equiv> case (max_mem_order (((st_blocks_addr addr pbm state) m<;xseq opid) \<union> {opid''. (opid'' ;po^p opid) \<and> st_blocks_addr addr pbm state opid''}) p po xseq) of Some opid''' \<Rightarrow> op_val (get_mem_op_state opid''' state) |None \<Rightarrow> None" lemma eq_mem_order_before_pred: "(st_blocks_addr addr pbm state) m<;xseq opid = {opid'. (opid' m<xseq opid) = Some True \<and> (type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}) \<and> Some addr = op_addr (get_mem_op_state opid' state)}" unfolding st_blocks_addr_def memory_order_before_pred_def by auto lemma "axiom_value' = axiom_value" unfolding axiom_value'_def axiom_value_def using eq_mem_order_before_pred by (auto simp add: st_blocks_addr_def) definition axiom_loadop:: "op_id \<Rightarrow> op_id \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> bool" where "axiom_loadop opid opid' po xseq pbm \<equiv> ((type_of_mem_op_block (pbm opid) \<in> {ld_block, ald_block}) \<and> (opid ;po^(proc_of_op opid pbm) opid')) \<longrightarrow> (opid m<xseq opid') = Some True" section {* Operational model. *} text {* This section defines an inference rule based operational TSO model. *} text {* Given an address and the executed sequence of mem_op_block ids, return the id of the first store in the executed sequence at the same address. If there are none, return None. N.B. We could formulate the below functions more mathematically (i.e., using sets and first-order logic), but we choose the define it in a more operational way for performance reasons. *} primrec get_first_store:: "virtual_address \<Rightarrow> op_id list \<Rightarrow> program_block_map \<Rightarrow> sparc_state \<Rightarrow> op_id option" where "get_first_store addr [] pbm state = None" |"get_first_store addr (x#xs) pbm state = ( if Some addr = (op_addr (get_mem_op_state x state)) \<and> type_of_mem_op_block (pbm x) \<in> {st_block, ast_block} then Some x else get_first_store addr xs pbm state)" definition mem_most_recent_store:: "virtual_address \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> sparc_state \<Rightarrow> op_id option" where "mem_most_recent_store addr xseq pbm state \<equiv> get_first_store addr (List.rev xseq) pbm state" text {* Given a load operation id and the program order, return the id of most recent store at the same address in the program order that is before the load. If there are none, return None. *} definition proc_most_recent_store:: "proc \<Rightarrow> virtual_address \<Rightarrow> op_id \<Rightarrow> program_order \<Rightarrow> program_block_map \<Rightarrow> sparc_state \<Rightarrow> op_id option" where "proc_most_recent_store p addr opid po pbm state \<equiv> get_first_store addr (List.rev (sub_list_before opid (po p))) pbm state" text {* The value of the load operation based on the axiom value. *} definition load_value:: "proc \<Rightarrow> virtual_address \<Rightarrow> op_id \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> sparc_state \<Rightarrow> memory_value option" where "load_value p addr opid po xseq pbm state \<equiv> case ((mem_most_recent_store addr xseq pbm state),(proc_most_recent_store p addr opid po pbm state)) of (Some s1, Some s2) \<Rightarrow> (case (s1 m<xseq s2) of Some True \<Rightarrow> op_val (get_mem_op_state s2 state) |Some False \<Rightarrow> op_val (get_mem_op_state s1 state) |None \<Rightarrow> None) |(None, Some s2) \<Rightarrow> op_val (get_mem_op_state s2 state) |(Some s1, None) \<Rightarrow> op_val (get_mem_op_state s1 state) |(None, None) \<Rightarrow> None" text {* A new version of load_value for code export. *} text {* Assuming that when calling this function, the address and value of the store is already computed in the process of proc_exe_to. Commit the store to the memory. *} definition mem_commit:: "op_id \<Rightarrow> sparc_state \<Rightarrow> sparc_state" where "mem_commit opid s \<equiv> let opr = get_mem_op_state opid s in case ((op_addr opr),(op_val opr)) of (Some addr, Some val) \<Rightarrow> mem_mod val addr s |_ \<Rightarrow> s" text {* Definition of the "inference rules" in our operational TSO model. *} inductive "mem_op"::"[program_order, program_block_map, op_id, executed_mem_ops, sparc_state, executed_mem_ops, sparc_state] \<Rightarrow> bool" ("_ _ _ \<turnstile>m (_ _ \<rightarrow>/ _ _)" 100) for po::"program_order" and pbm::"program_block_map" and opid::"op_id" where load_op: "\<lbrakk>p = proc_of_op opid pbm; (type_of_mem_op_block (pbm opid) = ld_block); \<forall>opid'. (((opid' ;po^p opid) \<and> (type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block})) \<longrightarrow> (List.member xseq opid')); s' = proc_exe_to_previous p po pbm (non_repeat_list_pos opid (po p)) s; addr = load_addr p (List.last (insts (pbm opid))) s'; vop = axiom_value p opid addr po xseq pbm s'\<rbrakk> \<Longrightarrow> po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (proc_exe_to_last p po pbm (non_repeat_list_pos opid (po p)) vop (Some addr) s')" |store_op: "\<lbrakk>p = proc_of_op opid pbm; (type_of_mem_op_block (pbm opid) = st_block); (atomic_flag_val s) = None; \<forall>opid'. (((opid' ;po^p opid) \<and> (type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block, st_block, ast_block})) \<longrightarrow> (List.member xseq opid'))\<rbrakk> \<Longrightarrow> po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (mem_commit opid (proc_exe_to p po pbm (non_repeat_list_pos opid (po p)) s))" |atom_load_op: "\<lbrakk>p = proc_of_op opid pbm; (type_of_mem_op_block (pbm opid) = ald_block); (atomic_flag_val s) = None; \<forall>opid'. (((opid' ;po^p opid) \<and> (type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block, st_block, ast_block})) \<longrightarrow> (List.member xseq opid')); s' = proc_exe_to_previous p po pbm (non_repeat_list_pos opid (po p)) s; addr = atomic_load_addr p (List.last (insts (pbm opid))) s'; vop = axiom_value p opid addr po xseq pbm s'\<rbrakk> \<Longrightarrow> po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (atomic_flag_mod (Some opid) (proc_exe_to_last p po pbm (non_repeat_list_pos opid (po p)) vop (Some addr) s'))" |atom_store_op: "\<lbrakk>p = proc_of_op opid pbm; (type_of_mem_op_block (pbm opid) = ast_block); (atomic_flag_val s) = Some opid'; atom_pair_id (pbm opid) = Some opid'; \<forall>opid'. (((opid' ;po^p opid) \<and> (type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block, st_block, ast_block})) \<longrightarrow> (List.member xseq opid'))\<rbrakk> \<Longrightarrow> po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (mem_commit opid (atomic_flag_mod None (proc_exe_to p po pbm (non_repeat_list_pos opid (po p)) s)))" |o_op: "\<lbrakk>p = proc_of_op opid pbm; (type_of_mem_op_block (pbm opid) = o_block); \<forall>opid'. (((opid' ;po^p opid) \<and> (type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block, st_block, ast_block})) \<longrightarrow> (List.member xseq opid'))\<rbrakk> \<Longrightarrow> po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (proc_exe_to p po pbm (non_repeat_list_pos opid (po p)) s)" text {* The lemmas below are for inverse inference of the above rules. *} inductive_cases mem_op_elim_cases: "(po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" lemma mem_op_elim_load_op: assumes a1: "(po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" and a2: "(type_of_mem_op_block (pbm opid) = ld_block)" and a3: "(xseq' = xseq @ [opid] \<Longrightarrow> s' = proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) (axiom_value (proc_of_op opid pbm) opid (load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) po xseq pbm (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) (Some (load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s) \<Longrightarrow> type_of_mem_op_block (pbm opid) = ld_block \<Longrightarrow> (\<forall>opid'. ((opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block)) \<longrightarrow> List.member xseq opid') \<Longrightarrow> P)" shows "P" using a2 a3 by (auto intro:mem_op_elim_cases[OF a1]) lemma mem_op_elim_store_op: assumes a1: "(po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" and a2: "(type_of_mem_op_block (pbm opid) = st_block)" and a3: "(xseq' = xseq @ [opid] \<Longrightarrow> s' = mem_commit opid (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s) \<Longrightarrow> type_of_mem_op_block (pbm opid) = st_block \<Longrightarrow> atomic_flag_val s = None \<Longrightarrow> \<forall>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> List.member xseq opid' \<Longrightarrow> P)" shows "P" using a2 a3 by (auto intro:mem_op_elim_cases[OF a1]) lemma mem_op_elim_atom_load_op: assumes a1: "(po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" and a2: "(type_of_mem_op_block (pbm opid) = ald_block)" and a3: "xseq' = xseq @ [opid] \<Longrightarrow> s' = atomic_flag_mod (Some opid) (proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) (axiom_value (proc_of_op opid pbm) opid (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) po xseq pbm (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) (Some (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) \<Longrightarrow> type_of_mem_op_block (pbm opid) = ald_block \<Longrightarrow> atomic_flag_val s = None \<Longrightarrow> \<forall>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> List.member xseq opid' \<Longrightarrow> P" shows "P" using a2 a3 by (auto intro:mem_op_elim_cases[OF a1]) lemma mem_op_elim_atom_store_op: assumes a1: "(po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" and a2: "(type_of_mem_op_block (pbm opid) = ast_block)" and a3: "(\<And>opid'. xseq' = xseq @ [opid] \<Longrightarrow> s' = mem_commit opid (atomic_flag_mod None (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) \<Longrightarrow> type_of_mem_op_block (pbm opid) = ast_block \<Longrightarrow> atomic_flag_val s = Some opid' \<Longrightarrow> atom_pair_id (pbm opid) = Some opid' \<Longrightarrow> \<forall>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> List.member xseq opid' \<Longrightarrow> P)" shows "P" using a2 a3 by (auto intro:mem_op_elim_cases[OF a1]) lemma mem_op_elim_o_op: assumes a1: "(po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" and a2: "(type_of_mem_op_block (pbm opid) = o_block)" and a3: "(xseq' = xseq @ [opid] \<Longrightarrow> s' = proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s \<Longrightarrow> type_of_mem_op_block (pbm opid) = o_block \<Longrightarrow> \<forall>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> List.member xseq opid' \<Longrightarrow> P)" shows "P" using a2 a3 by (auto intro:mem_op_elim_cases[OF a1]) lemma atomic_flag_mod_state: "s' = atomic_flag_mod (Some opid) s \<Longrightarrow> atomic_flag (glob_var s') = Some opid" unfolding atomic_flag_mod_def by auto lemma mem_op_atom_load_op_atomic_flag: assumes a1: "(po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" and a2: "(type_of_mem_op_block (pbm opid) = ald_block)" shows "atomic_flag (glob_var s') = Some opid" proof - have "xseq' = xseq @ [opid] \<Longrightarrow> s' = atomic_flag_mod (Some opid) (proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) (axiom_value (proc_of_op opid pbm) opid (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) po xseq pbm (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) (Some (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) \<Longrightarrow> type_of_mem_op_block (pbm opid) = ald_block \<Longrightarrow> atomic_flag_val s = None \<Longrightarrow> \<forall>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> List.member xseq opid' \<Longrightarrow> atomic_flag (glob_var s') = Some opid" using atomic_flag_mod_state by auto then show ?thesis using a1 a2 mem_op_elim_atom_load_op by metis qed text {* Given a program_order, define a transition from (xseq, rops, state) to (xseq', rops', state'), where xseq is the executed sequence of memory operations, rops is the set of remaining unexecuted memory operations. *} definition mem_state_trans:: "program_order \<Rightarrow> program_block_map \<Rightarrow> (executed_mem_ops \<times> (op_id set) \<times> sparc_state) \<Rightarrow> (executed_mem_ops \<times> (op_id set) \<times> sparc_state) \<Rightarrow> bool" ("_ _ \<turnstile>t (_ \<rightarrow>/ _)" 100) where "po pbm \<turnstile>t pre \<rightarrow> post \<equiv> (\<exists>opid. opid \<in> (fst (snd pre)) \<and> (po pbm opid \<turnstile>m (fst pre) (snd (snd pre)) \<rightarrow> (fst post) (snd (snd post))) \<and> (fst (snd post)) = (fst (snd pre)) - {opid})" text {* Define the conditions for a program to be valid. *} definition valid_program:: "program_order \<Rightarrow> program_block_map \<Rightarrow> bool" where "valid_program po pbm \<equiv> (\<forall>opid opid' opid''. (atom_pair_id (pbm opid) = Some opid' \<and> opid \<noteq> opid'') \<longrightarrow> (atom_pair_id (pbm opid'') \<noteq> Some opid')) \<and> (\<forall>opid p. (List.member (po p) opid \<and> type_of_mem_op_block (pbm opid) = ald_block) \<longrightarrow> (\<exists>opid'. (opid ;po^p opid') \<and> type_of_mem_op_block (pbm opid') = ast_block \<and> atom_pair_id (pbm opid') = Some opid)) \<and> (\<forall>opid' p. (List.member (po p) opid' \<and> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> (\<exists>opid. (opid ;po^p opid') \<and> type_of_mem_op_block (pbm opid) = ald_block \<and> atom_pair_id (pbm opid') = Some opid)) \<and> (\<forall>p. non_repeat_list (po p)) \<and> (\<forall>opid opid' p. (opid ;po^p opid') \<longrightarrow> (proc_of_op opid pbm = proc_of_op opid' pbm \<and> p = proc_of_op opid pbm)) \<and> (\<forall>opid p. (List.member (po p) opid) \<longrightarrow> (proc_of_op opid pbm = p))" text {* The definition of a valid complete sequence of memory executions. *} definition valid_mem_exe_seq:: "program_order \<Rightarrow> program_block_map \<Rightarrow> (executed_mem_ops \<times> (op_id set) \<times> sparc_state) list \<Rightarrow> bool" where "valid_mem_exe_seq po pbm exe_list \<equiv> valid_program po pbm \<and> List.length exe_list > 0 \<and> fst (List.hd exe_list) = [] \<and> \<comment>\<open> Nothing has been executed in the initial state. \<close> (\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (List.hd exe_list)))) \<and> \<comment>\<open> Initially the *to be executed* set of op_ids include every op_id in the program order. \<close> \<comment>\<open>non_repeat_list (fst (last exe_list)) \<and> Each op_id is unique. \<close> (atomic_flag_val (snd (snd (hd exe_list))) = None) \<and> \<comment>\<open> In the initial state, the atomic flag is None. \<close> \<comment>\<open>fst (snd (List.last exe_list)) = {} \<and> Nothing is remaining to be executed in the final state. (Redundant)\<close> (\<forall>i. i < (List.length exe_list) - 1 \<longrightarrow> \<comment>\<open> Each adjacent states are from a mem_state_trans. \<close> (po pbm \<turnstile>t (exe_list!i) \<rightarrow> (exe_list!(i+1))))" definition valid_mem_exe_seq_final:: "program_order \<Rightarrow> program_block_map \<Rightarrow> (executed_mem_ops \<times> (op_id set) \<times> sparc_state) list \<Rightarrow> bool" where "valid_mem_exe_seq_final po pbm exe_list \<equiv> valid_mem_exe_seq po pbm exe_list \<and> fst (snd (List.hd exe_list)) = set (fst (List.last exe_list)) \<comment>\<open> Everything has been executed in the final state. \<close>" section {* The equivalence of the axiomatic model and the operational model. *} subsection {* Soundness of the operational TSO model *} text {* This subsection shows that every valid sequence of memory operations executed by the operational TSO model satisfies the TSO axioms. *} text {* First, we show that each valid_mem_exe_seq satisfies all the axioms. *} lemma mem_op_exe: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s' \<Longrightarrow> xseq' = xseq@[opid]" unfolding mem_op.simps by auto lemma mem_state_trans_op: "po pbm \<turnstile>t (xseq,rops,s) \<rightarrow> (xseq',rops',s') \<Longrightarrow> List.butlast xseq' = xseq \<and> {List.last xseq'} \<union> rops' = rops" unfolding mem_state_trans_def apply simp using mem_op_exe by fastforce lemma mem_state_trans_op2: assumes a1: "po pbm \<turnstile>t (xseq,rops,s) \<rightarrow> (xseq',rops',s')" shows "xseq' = xseq@(List.sorted_list_of_set (rops - rops'))" proof - from a1 have f1: "\<exists>opid. opid \<in> rops \<and> (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s') \<and> rops' = rops - {opid}" using mem_state_trans_def by simp then obtain opid::op_id where f2: "opid \<in> rops \<and> (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s') \<and> rops' = rops - {opid}" by auto then have f3: "xseq' = xseq@[opid]" using mem_op_exe by auto from f2 have "rops - rops' = {opid}" by auto then have f4: "List.sorted_list_of_set (rops - rops') = [opid]" by auto then show ?thesis using f3 by auto qed lemma mem_state_trans_op3: assumes a1: "po pbm \<turnstile>t (xseq,rops,s) \<rightarrow> (xseq',rops',s')" shows "\<exists>opid. xseq' = xseq@[opid] \<and> rops = rops' \<union> {opid}" proof - from a1 have f1: "\<exists>opid. opid \<in> rops \<and> (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s') \<and> rops' = rops - {opid}" using mem_state_trans_def by simp then obtain opid::op_id where f2: "opid \<in> rops \<and> (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s') \<and> rops' = rops - {opid}" by auto then have f3: "xseq' = xseq@[opid]" using mem_op_exe by auto then show ?thesis using f2 by auto qed lemma mem_state_trans_op4: assumes a1: "po pbm \<turnstile>t (xseq,rops,s) \<rightarrow> (xseq',rops',s')" shows "(set xseq) \<union> rops = (set xseq') \<union> rops'" proof - show ?thesis using a1 mem_state_trans_op3 by fastforce qed lemma mem_state_trans_unique_op_id: assumes a1:"\<forall>opid. opid \<in> rops \<longrightarrow> \<not>(List.member xseq opid)" and a2:"non_repeat_list xseq" and a3:"po pbm \<turnstile>t (xseq,rops,s) \<rightarrow> (xseq',rops',s')" shows "non_repeat_list xseq' \<and> (\<forall>opid. opid \<in> rops' \<longrightarrow> \<not>(List.member xseq' opid))" proof - from a3 have "\<exists>opid. xseq' = xseq@[opid] \<and> opid \<in> (rops - rops')" using mem_state_trans_op2 mem_state_trans_op3 apply auto by (metis DiffD2 mem_op_exe mem_state_trans_def prod.sel(1) prod.sel(2) singletonI) then obtain opid::op_id where f1: "xseq' = xseq@[opid] \<and> opid \<in> (rops - rops')" by auto then have "\<not>(List.member xseq opid)" using a1 by auto then have f2: "non_repeat_list xseq'" using f1 a2 non_repeat_list_extend by fastforce from f1 a3 mem_state_trans_op have f3: "rops' = rops - {opid}" apply auto apply blast by fastforce then have f4: "\<forall>opid'. opid' \<in> rops - {opid} \<longrightarrow> \<not>(List.member (xseq@[opid]) opid')" using a1 by (metis DiffD1 DiffD2 UnE list.set(1) list.simps(15) member_def set_append) then show ?thesis using f2 f3 f1 by auto qed lemma mem_exe_seq_op_unique: assumes a1: "List.length exe_list > 0" and a2: "(\<forall>i. i < (List.length exe_list) - 1 \<longrightarrow> (po pbm \<turnstile>t (List.nth exe_list i) \<rightarrow> (List.nth exe_list (i+1))))" and a3: "non_repeat_list (fst (List.hd exe_list))" and a4: "\<forall>opid. opid \<in> (fst (snd (List.hd exe_list))) \<longrightarrow> \<not>(List.member (fst (List.hd exe_list)) opid)" shows "non_repeat_list (fst (List.last exe_list)) \<and> (\<forall>opid. opid \<in> (fst (snd (List.last exe_list))) \<longrightarrow> \<not>(List.member (fst (List.last exe_list)) opid))" proof (insert assms, induction "exe_list" arbitrary: po rule: rev_induct) case Nil then show ?case by auto next case (snoc x xs) then show ?case proof (cases "List.length xs > 0") case True then have f1: "List.length xs > 0" by auto then have f2: "hd (xs@[x]) = hd xs" by auto from f1 have f3: "\<forall>i<(length xs - 1). (po pbm \<turnstile>t (xs ! i) \<rightarrow> (xs ! (i + 1)))" using snoc(3) proof - { fix nn :: nat have ff1: "\<forall>n. 1 + n = Suc n" by (metis One_nat_def add.left_neutral plus_nat.simps(2)) have "\<forall>n. \<not> n < length (butlast xs) \<or> Suc n < length xs" by (metis (no_types) One_nat_def Suc_less_eq Suc_pred f1 length_butlast) then have "\<not> nn < length xs - 1 \<or> (po pbm \<turnstile>t (xs ! nn) \<rightarrow> (xs ! (nn + 1)))" using ff1 by (metis (no_types) Suc_less_eq add.commute butlast_snoc length_butlast less_Suc_eq nth_append snoc.prems(2)) } then show ?thesis by meson qed from f2 have f4: "non_repeat_list (fst (hd xs))" using snoc(4) by auto from f2 have f5: "\<forall>opid. opid \<in> fst (snd (hd xs)) \<longrightarrow> \<not> List.member (fst (hd xs)) opid" using snoc(5) by auto define xseq where "xseq = (fst (List.last xs))" define rops where "rops = (fst (snd (List.last xs)))" define s where "s = (snd (snd (List.last xs)))" define xseq' where "xseq' = (fst (List.last (xs@[x])))" define rops' where "rops' = (fst (snd (List.last (xs@[x]))))" define s' where "s' = (snd (snd (List.last (xs@[x]))))" from f1 f3 f4 f5 have f6: "non_repeat_list xseq \<and> (\<forall>opid. opid \<in> rops \<longrightarrow> \<not> List.member xseq opid)" using snoc(1) xseq_def rops_def by auto have f7: "List.last xs = (xs@[x])!(List.length (xs@[x]) - 2)" by (metis (no_types, lifting) One_nat_def Suc_pred butlast_snoc diff_diff_left f1 last_conv_nth length_butlast length_greater_0_conv lessI nat_1_add_1 nth_append) have f8: "List.last (xs@[x]) = (xs@[x])!(List.length (xs@[x]) - 1)" by simp from snoc(3) f7 f8 have "po pbm \<turnstile>t (List.last xs) \<rightarrow> (List.last (xs@[x]))" by (metis (no_types, lifting) Nat.add_0_right One_nat_def Suc_pred add_Suc_right butlast_snoc diff_diff_left f1 length_butlast lessI nat_1_add_1) then have "po pbm \<turnstile>t (xseq,rops,s) \<rightarrow> (xseq',rops',s')" using xseq_def rops_def s_def xseq'_def rops'_def s'_def by auto then have "non_repeat_list xseq' \<and> (\<forall>opid. opid \<in> rops' \<longrightarrow> \<not>(List.member xseq' opid))" using f6 mem_state_trans_unique_op_id by blast then show ?thesis using xseq'_def rops'_def by auto next case False then have "List.length xs = 0" by auto then have "xs@[x] = [x]" by auto then have "hd (xs@[x]) = last (xs@[x])" by auto then show ?thesis using snoc by auto qed qed lemma valid_mem_exe_seq_op_unique0: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list) - 1" shows "non_repeat_list (fst (exe_list!i)) \<and> (\<forall>opid. opid \<in> (fst (snd (exe_list!i))) \<longrightarrow> \<not>(List.member (fst (exe_list!i)) opid))" proof (insert assms, induction i) case 0 then have "(fst (exe_list!0)) = []" unfolding valid_mem_exe_seq_def proof - assume "valid_program po pbm \<and> 0 < length exe_list \<and> fst (hd exe_list) = [] \<and> (\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (hd exe_list)))) \<and> (atomic_flag_val (snd (snd (hd exe_list))) = None) \<and> (\<forall>i<length exe_list - 1. (po pbm \<turnstile>t exe_list ! i \<rightarrow> (exe_list ! (i + 1))))" then show ?thesis by (metis hd_conv_nth length_greater_0_conv) qed then show ?case using non_repeat_list_emp by (simp add: member_rec(2)) next case (Suc i) have f1: "non_repeat_list (fst (exe_list ! i)) \<and> (\<forall>opid. opid \<in> fst (snd (exe_list ! i)) \<longrightarrow> \<not> List.member (fst (exe_list ! i)) opid)" using Suc by auto have f2: "(po pbm \<turnstile>t exe_list ! i \<rightarrow> (exe_list ! (i + 1)))" using Suc unfolding valid_mem_exe_seq_def by auto define xseq where "xseq \<equiv> (fst (exe_list ! i))" define rops where "rops \<equiv> (fst (snd (exe_list ! i)))" define s where "s \<equiv> (snd (snd (exe_list ! i)))" define xseq' where "xseq' \<equiv> (fst (exe_list ! (i+1)))" define rops' where "rops' \<equiv> (fst (snd (exe_list ! (i+1))))" define s' where "s' \<equiv> (snd (snd (exe_list ! (i+1))))" from f1 have f3: "\<forall>opid. opid \<in> rops \<longrightarrow> \<not>(List.member xseq opid) \<and> non_repeat_list xseq" using rops_def xseq_def by auto from f2 have f4: "po pbm \<turnstile>t (xseq,rops,s) \<rightarrow> (xseq',rops',s')" using xseq_def xseq'_def rops_def rops'_def s_def s'_def by auto from f3 f4 have "non_repeat_list xseq' \<and> (\<forall>opid. opid \<in> rops' \<longrightarrow> \<not>(List.member xseq' opid))" using mem_state_trans_unique_op_id by (metis f1 xseq_def) then show ?case using xseq'_def rops'_def by auto qed lemma valid_mem_exe_seq_op_unique: assumes a1: "valid_mem_exe_seq po pbm exe_list" shows "non_repeat_list (fst (List.last exe_list))" proof - have f1: "non_repeat_list (fst (List.hd exe_list))" using a1 unfolding valid_mem_exe_seq_def using non_repeat_list_emp by auto have f2: "\<forall>opid. opid \<in> (fst (snd (List.hd exe_list))) \<longrightarrow> \<not>(List.member (fst (List.hd exe_list)) opid)" using a1 unfolding valid_mem_exe_seq_def apply auto by (simp add: member_rec(2)) show ?thesis using mem_exe_seq_op_unique a1 f1 f2 unfolding valid_mem_exe_seq_def by auto qed lemma valid_mem_exe_seq_op_unique1: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list)" shows "non_repeat_list (fst (exe_list!i))" proof - show ?thesis using a1 using valid_mem_exe_seq_op_unique0 valid_mem_exe_seq_op_unique by (metis (no_types, hide_lams) One_nat_def Suc_pred a2 last_conv_nth length_0_conv less_Suc_eq less_irrefl_nat valid_mem_exe_seq_def) qed lemma valid_mem_exe_seq_op_unique2: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "(po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" and a3: "i < (List.length exe_list) - 1" shows "\<not> (List.member (fst (exe_list!i)) opid)" proof (rule ccontr) assume "\<not> \<not> List.member (fst (exe_list ! i)) opid" then have "List.member (fst (exe_list ! i)) opid" by auto then have f1: "\<exists>n. n \<le> length (fst (exe_list ! i)) - 1 \<and> (fst (exe_list ! i))!n = opid" by (metis (no_types, lifting) One_nat_def Suc_pred eq_imp_le in_set_conv_nth in_set_member length_pos_if_in_set less_Suc_eq less_imp_le) have f2: "(fst (exe_list!(i+1))) = (fst (exe_list!i))@[opid]" using a2 mem_op_exe by auto from f1 f2 have f3: "\<exists>n. n \<le> length (fst (exe_list!(i+1))) - 2 \<and> (fst (exe_list!(i+1)))!n = opid" by (metis (no_types, hide_lams) Suc_1 Suc_eq_plus1 diff_diff_add last_conv_nth le_less_trans length_butlast not_less nth_append snoc_eq_iff_butlast) from f2 have f4: "\<exists>m. m = length (fst (exe_list!(i+1))) - 1 \<and> (fst (exe_list!(i+1)))!m = opid" by auto then have f5: "\<exists>m. m > length (fst (exe_list!(i+1))) - 2 \<and> m = length (fst (exe_list!(i+1))) - 1 \<and> (fst (exe_list!(i+1)))!m = opid" by (metis (no_types, lifting) One_nat_def Suc_eq_plus1 \<open>\<not> \<not> List.member (fst (exe_list ! i)) opid\<close> add_diff_cancel_right diff_add_inverse2 diff_less f2 length_append length_pos_if_in_set lessI list.size(3) list.size(4) member_def nat_1_add_1) from f3 f5 have "\<exists>m n. m \<noteq> n \<and> n \<le> length (fst (exe_list!(i+1))) - 2 \<and> m = length (fst (exe_list!(i+1))) - 1 \<and> ((fst (exe_list!(i+1)))!m = (fst (exe_list!(i+1)))!n)" by (metis not_less) then have "\<exists>m n. m \<noteq> n \<and> n < length (fst (exe_list!(i+1))) \<and> m < length (fst (exe_list!(i+1))) \<and> ((fst (exe_list!(i+1)))!m = (fst (exe_list!(i+1)))!n)" by (metis (no_types, hide_lams) One_nat_def diff_less f5 le_antisym length_0_conv length_greater_0_conv lessI less_imp_diff_less less_irrefl_nat not_less zero_diff) then have f6: "\<not> (non_repeat_list (fst (exe_list!(i+1))))" unfolding non_repeat_list_def using nth_eq_iff_index_eq by auto \<comment>\<open> by auto \<close> from a3 have f7: "i+1 < length exe_list" by auto then have f7: "non_repeat_list (fst (exe_list!(i+1)))" using valid_mem_exe_seq_op_unique1 a1 by auto then show False using f6 by auto qed lemma valid_exe_op_include: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "(opid m<(fst (List.last exe_list)) opid') = Some True" and a3: "(opid \<in> fst (snd (List.hd exe_list)) \<and> opid' \<in> fst (snd (List.hd exe_list)) \<and> opid \<noteq> opid')" shows "(List.member (fst (last exe_list)) opid) \<and> (List.member (fst (last exe_list)) opid')" proof - show ?thesis using assms unfolding valid_mem_exe_seq_final_def valid_mem_exe_seq_def memory_order_before_def apply simp using in_set_member by fastforce qed lemma valid_exe_all_order: "valid_mem_exe_seq_final po pbm exe_list \<Longrightarrow> \<forall>opid opid'. (opid \<in> fst (snd (List.hd exe_list)) \<and> opid' \<in> fst (snd (List.hd exe_list)) \<and> opid \<noteq> opid') \<longrightarrow> ((opid m<(fst (List.last exe_list)) opid') = Some True \<or> (opid' m<(fst (List.last exe_list)) opid) = Some True)" unfolding valid_mem_exe_seq_final_def valid_mem_exe_seq_def apply auto apply (subgoal_tac "List.member (fst (last exe_list)) opid' \<and> List.member (fst (last exe_list)) opid") unfolding memory_order_before_def apply simp prefer 2 using in_set_member apply fastforce apply auto using valid_mem_exe_seq_op_unique list_elements_before by metis text {* The lemma below shows that the axiom Order is satisfied in any valid execution sequence of our operational model. We assume that each op_id is unique in executed_mem_ops. As a consequence, for any two op_ids in executed_mem_ops, either op_id1 < op_id2 or op_id2 < op_id1 in the list. *} lemma axiom_order_sat: "valid_mem_exe_seq_final po pbm exe_list \<Longrightarrow> axiom_order opid opid' (fst (List.last exe_list)) pbm" proof - assume a1: "valid_mem_exe_seq_final po pbm exe_list" show ?thesis unfolding axiom_order_def proof (rule impI) assume a2: "type_of_mem_op_block (pbm opid) \<in> {st_block, ast_block} \<and> type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block} \<and> opid \<in> set (fst (last exe_list)) \<and> opid' \<in> set (fst (last exe_list)) \<and> opid \<noteq> opid'" then have "(opid \<in> fst (snd (List.hd exe_list)) \<and> opid' \<in> fst (snd (List.hd exe_list)) \<and> opid \<noteq> opid')" using a1 unfolding valid_mem_exe_seq_final_def valid_mem_exe_seq_def by auto then show "(opid m<(fst (last exe_list)) opid') = Some True \<or> (opid' m<(fst (last exe_list)) opid) = Some True" using a1 valid_exe_all_order by auto qed qed lemma valid_mem_exe_seq_ops: "valid_mem_exe_seq_final po pbm exe_list \<Longrightarrow> (\<forall>opid. (\<exists>p. List.member (po p) opid \<and> p<(Suc max_proc)) \<longrightarrow> (List.member (fst (List.last exe_list)) opid))" unfolding valid_mem_exe_seq_final_def valid_mem_exe_seq_def using in_set_member by fastforce text {* The lemma below shows that the axiom Termination is (trivially) satisfied in any valid execution sequence of our operational model. *} lemma axiom_termination_sat: "valid_mem_exe_seq_final po pbm exe_list \<Longrightarrow> axiom_termination opid po (fst (List.last exe_list)) pbm" unfolding axiom_termination_def using valid_mem_exe_seq_ops by auto text {* The axiom Value is trivially satisfied in our operational model because our operational model directly uses the axiom to obtain the value of load operations. *} lemma valid_exe_xseq_sublist: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "i < (List.length exe_list) - 1" shows "(set (fst (List.nth exe_list i))) \<union> (fst (snd (List.nth exe_list i))) = (set (fst (last exe_list)))" proof (insert assms, induction i) case 0 then show ?case unfolding valid_mem_exe_seq_final_def valid_mem_exe_seq_def proof - assume a1: "(valid_program po pbm \<and> 0 < length exe_list \<and> fst (hd exe_list) = [] \<and> (\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (hd exe_list)))) \<and> (atomic_flag_val (snd (snd (hd exe_list))) = None) \<and> (\<forall>i<length exe_list - 1. (po pbm \<turnstile>t (exe_list ! i) \<rightarrow> (exe_list ! (i + 1))))) \<and> fst (snd (hd exe_list)) = set (fst (last exe_list))" then have a1f: "valid_program po pbm \<and> 0 < length exe_list \<and> fst (hd exe_list) = [] \<and> (\<forall>n. (\<forall>na. \<not> List.member (po na) n) \<or> n \<in> fst (snd (hd exe_list))) \<and> fst (snd (hd exe_list)) = set (fst (last exe_list)) \<and> (atomic_flag_val (snd (snd (hd exe_list))) = None) \<and> (\<forall>n. \<not> n < length exe_list - 1 \<or> (po pbm \<turnstile>t exe_list ! n \<rightarrow> (exe_list ! (n + 1))))" by blast assume a2: "0 < length exe_list - 1" then show ?thesis using a1f by (metis (no_types) hd_conv_nth length_greater_0_conv list.set(1) sup_bot.left_neutral) qed next case (Suc i) have f1: "(po pbm \<turnstile>t (List.nth exe_list i) \<rightarrow> (List.nth exe_list (i+1)))" using Suc unfolding valid_mem_exe_seq_final_def valid_mem_exe_seq_def using Suc_lessD by blast have f2: "(set (fst (exe_list ! i))) \<union> (fst (snd (exe_list ! i))) = (set (fst (exe_list ! (i+1)))) \<union> (fst (snd (exe_list ! (i+1))))" using f1 mem_state_trans_op4 by (metis prod.collapse) then show ?case using Suc by auto qed lemma valid_exe_xseq_sublist2: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list) - 1" shows "\<exists>opid. (fst (exe_list!i))@[opid] = (fst (exe_list!(i+1)))" proof - have f1: "(po pbm \<turnstile>t (List.nth exe_list i) \<rightarrow> (List.nth exe_list (i+1)))" using a1 a2 unfolding valid_mem_exe_seq_def by auto then show ?thesis using mem_state_trans_op3 mem_op_exe by (metis (no_types) f1 mem_op_exe mem_state_trans_def) qed lemma valid_exe_xseq_sublist3: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < j" and a3: "j < (List.length exe_list)" shows "is_sublist (fst (exe_list!i)) (fst (exe_list!j))" proof (insert assms, induction j arbitrary: i) case 0 then show ?case by auto next case (Suc j) then show ?case proof (cases "i = j") case True then have "\<exists>opid. (fst (exe_list!i))@[opid] = (fst (exe_list!(j+1)))" using Suc(2) Suc(4) valid_exe_xseq_sublist2 by (metis Suc_eq_plus1 less_diff_conv) then show ?thesis unfolding is_sublist_def by auto next case False then have f1: "i < j" using Suc(3) by auto have f2: "j < length exe_list" using Suc(4) by auto from f1 f2 have f3: "is_sublist (fst (exe_list ! i)) (fst (exe_list ! j))" using Suc(1) Suc(2) by auto have f4: "\<exists>opid. (fst (exe_list!j))@[opid] = (fst (exe_list!(j+1)))" using Suc(2) Suc(4) valid_exe_xseq_sublist2 by auto then show ?thesis using f3 unfolding is_sublist_def by (metis Suc_eq_plus1 append.assoc) qed qed lemma valid_exe_xseq_sublist4: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list)" shows "is_sublist (fst (exe_list!i)) (fst (List.last exe_list))" proof (cases "i = (List.length exe_list) - 1") case True then have "(fst (exe_list!i)) = (fst (List.last exe_list))" using a1 last_conv_nth valid_mem_exe_seq_def by fastforce then show ?thesis using is_sublist_id by auto next case False then have "i < (List.length exe_list) - 1" using a2 by auto then have "is_sublist (fst (exe_list!i)) (fst (exe_list!((List.length exe_list) - 1)))" using a1 valid_exe_xseq_sublist3 by auto then show ?thesis using a1 last_conv_nth valid_mem_exe_seq_def by fastforce qed lemma valid_exe_xseq_sublist5: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < j" and a3: "j < (List.length exe_list)" and a4: "po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))" shows "List.member (fst (exe_list!j)) opid" proof - from a4 have "(fst (exe_list!(i+1))) = (fst (exe_list!i))@[opid]" using mem_op_exe by auto then have f1: "List.member (fst (exe_list!(i+1))) opid" by (metis One_nat_def Suc_eq_plus1 in_set_member length_append less_add_one list.size(3) list.size(4) nth_append_length nth_mem) show ?thesis proof (cases "i + 1 = j") case True then show ?thesis using f1 by auto next case False then have "i+1 < j" using a2 by auto then have f2: "is_sublist (fst (exe_list!(i+1))) (fst (exe_list!j))" using a1 a3 valid_exe_xseq_sublist3 by auto then show ?thesis using f1 sublist_member by auto qed qed lemma valid_exe_xseq_sublist6: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list) - 1" shows "(set (fst (List.nth exe_list i))) \<union> (fst (snd (List.nth exe_list i))) = (fst (snd (hd exe_list)))" proof (insert assms, induction i) case 0 then show ?case unfolding valid_mem_exe_seq_def proof - assume a1: "(valid_program po pbm \<and> 0 < length exe_list \<and> fst (hd exe_list) = [] \<and> (\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (hd exe_list)))) \<and> (atomic_flag_val (snd (snd (hd exe_list))) = None) \<and> (\<forall>i<length exe_list - 1. (po pbm \<turnstile>t (exe_list ! i) \<rightarrow> (exe_list ! (i + 1)))))" then have a1f: "valid_program po pbm \<and> 0 < length exe_list \<and> fst (hd exe_list) = [] \<and> (\<forall>n. (\<forall>na. \<not> List.member (po na) n) \<or> n \<in> fst (snd (hd exe_list))) \<and> (atomic_flag_val (snd (snd (hd exe_list))) = None) \<and> (\<forall>n. \<not> n < length exe_list - 1 \<or> (po pbm \<turnstile>t exe_list ! n \<rightarrow> (exe_list ! (n + 1))))" by blast assume a2: "0 < length exe_list - 1" then show ?thesis using a1f by (metis (no_types) hd_conv_nth length_greater_0_conv list.set(1) sup_bot.left_neutral) qed next case (Suc i) have f1: "(po pbm \<turnstile>t (List.nth exe_list i) \<rightarrow> (List.nth exe_list (i+1)))" using Suc unfolding valid_mem_exe_seq_final_def valid_mem_exe_seq_def using Suc_lessD by blast have f2: "(set (fst (exe_list ! i))) \<union> (fst (snd (exe_list ! i))) = (set (fst (exe_list ! (i+1)))) \<union> (fst (snd (exe_list ! (i+1))))" using f1 mem_state_trans_op4 by (metis prod.collapse) then show ?case using Suc by auto qed lemma valid_exe_xseq_sublist7: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list)" shows "(set (fst (List.nth exe_list i))) \<union> (fst (snd (List.nth exe_list i))) = (fst (snd (hd exe_list)))" proof (cases "i < (List.length exe_list) - 1") case True then show ?thesis using valid_exe_xseq_sublist6[OF a1 True] by auto next case False then have f1: "i = (List.length exe_list) - 1" using a2 by auto then show ?thesis proof (cases "(List.length exe_list) > 1") case True then obtain j where f2: "0 \<le> j \<and> j = i - 1" using f1 by auto then have f3: "(set (fst (List.nth exe_list j))) \<union> (fst (snd (List.nth exe_list j))) = (fst (snd (hd exe_list)))" using valid_exe_xseq_sublist6[OF a1] f1 using True by auto from a1 f1 f2 True have f4: "(po pbm \<turnstile>t (exe_list!j) \<rightarrow> (exe_list!i))" unfolding valid_mem_exe_seq_def by (metis diff_add diff_diff_cancel diff_is_0_eq le_eq_less_or_eq less_one nat_neq_iff) then have f5: "(set (fst (exe_list!j))) \<union> (fst (snd (exe_list!j))) = (set (fst (exe_list!i))) \<union> (fst (snd (exe_list!i)))" using mem_state_trans_op4 by (metis surjective_pairing) then show ?thesis using f3 by auto next case False then have f6: "(length exe_list) = 1" using a1 unfolding valid_mem_exe_seq_def by linarith then have f7: "(exe_list!i) = (hd exe_list)" using f1 by (metis diff_self_eq_0 hd_conv_nth list.size(3) zero_neq_one) then show ?thesis using a1 unfolding valid_mem_exe_seq_def by auto qed qed lemma valid_exe_xseq_sublist_last: assumes a1: "valid_mem_exe_seq po pbm exe_list" shows "(set (fst (last exe_list))) \<union> (fst (snd (last exe_list))) = (fst (snd (hd exe_list)))" proof - from a1 have f1: "length exe_list > 0" unfolding valid_mem_exe_seq_def by auto then obtain i where f2: "i \<ge> 0 \<and> i = (length exe_list) - 1" by simp then have f3: "i < length exe_list" using f1 by auto then have "(set (fst (exe_list!i))) \<union> (fst (snd (exe_list!i))) = (fst (snd (hd exe_list)))" using valid_exe_xseq_sublist7[OF a1 f3] by auto then show ?thesis using f1 f2 by (simp add: last_conv_nth) qed lemma valid_exe_xseq_sublist_length: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list)" shows "List.length (fst (exe_list!i)) = i" proof (insert assms, induction i) case 0 then show ?case unfolding valid_mem_exe_seq_def proof - assume "valid_program po pbm \<and> 0 < length exe_list \<and> fst (hd exe_list) = [] \<and> (\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (hd exe_list)))) \<and> (atomic_flag_val (snd (snd (hd exe_list))) = None) \<and> (\<forall>i<length exe_list - 1. (po pbm \<turnstile>t exe_list ! i \<rightarrow> (exe_list ! (i + 1))))" then show ?thesis by (metis (no_types) gr_implies_not0 hd_conv_nth length_0_conv) qed next case (Suc i) have f1: "length (fst (exe_list ! i)) = i" using Suc by auto from Suc(3) have "i < length exe_list - 1" by auto then have "(po pbm \<turnstile>t (exe_list!i) \<rightarrow> (exe_list!(i+1)))" using Suc(2) unfolding valid_mem_exe_seq_def by auto then have "length (fst (exe_list ! i)) + 1 = length (fst (exe_list ! (i+1)))" using mem_state_trans_op by (metis (no_types, lifting) One_nat_def Suc.prems(1) Suc_eq_plus1 \<open>i < length exe_list - 1\<close> length_append list.size(3) list.size(4) valid_exe_xseq_sublist2) then show ?case using f1 by auto qed lemma valid_exe_xseq_sublist_length2: assumes a1: "valid_mem_exe_seq po pbm exe_list" shows "List.length (fst (List.last exe_list)) = (List.length exe_list) - 1" proof - from a1 have "List.length exe_list > 0" unfolding valid_mem_exe_seq_def by auto then have "(List.length exe_list) - 1 < (List.length exe_list)" by auto then show ?thesis using a1 valid_exe_xseq_sublist_length \<open>0 < length exe_list\<close> last_conv_nth by fastforce qed lemma op_exe_xseq: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "opid \<noteq> opid'" and a3: "\<not> (List.member xseq opid')" shows "\<not> (List.member xseq' opid')" proof - show ?thesis using mem_op_exe by (metis a1 a2 a3 in_set_member rotate1.simps(2) set_ConsD set_rotate1) qed lemma valid_exe_op_exe_exist0: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "\<forall>opid i. ((i < (List.length exe_list - 1)) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))) \<longrightarrow> opid \<noteq> opid'" and a3: "n < (List.length exe_list - 1)" shows "\<not> (List.member (fst (exe_list!n)) opid')" proof - have f1: "\<forall>i<length exe_list - 1. (po pbm \<turnstile>t (exe_list ! i) \<rightarrow> (exe_list ! (i + 1)))" using a1 unfolding valid_mem_exe_seq_def by auto then have f2: "\<forall>i<length exe_list - 1. (\<exists>opid. opid \<in> (fst (snd (List.nth exe_list i))) \<and> (po pbm opid \<turnstile>m (fst (List.nth exe_list i)) (snd (snd (List.nth exe_list i))) \<rightarrow> (fst (List.nth exe_list (i+1))) (snd (snd (List.nth exe_list (i+1))))) \<and> (fst (snd (List.nth exe_list (i+1)))) = (fst (snd (List.nth exe_list i))) - {opid})" unfolding mem_state_trans_def by auto then have f3: "\<forall>i<length exe_list - 1. (\<exists>opid. opid \<in> (fst (snd (List.nth exe_list i))) \<and> (po pbm opid \<turnstile>m (fst (List.nth exe_list i)) (snd (snd (List.nth exe_list i))) \<rightarrow> (fst (List.nth exe_list (i+1))) (snd (snd (List.nth exe_list (i+1))))) \<and> (fst (snd (List.nth exe_list (i+1)))) = (fst (snd (List.nth exe_list i))) - {opid} \<and> opid \<noteq> opid')" using a2 by meson show ?thesis proof (insert a3, induction n) case 0 then show ?case using a1 unfolding valid_mem_exe_seq_def apply auto by (metis (no_types) hd_conv_nth member_rec(2)) next case (Suc n) obtain opid where f4: "(po pbm opid \<turnstile>m (fst (exe_list ! n)) (snd (snd (exe_list ! n))) \<rightarrow> (fst (exe_list ! Suc n)) (snd (snd (exe_list ! Suc n)))) \<and> opid \<noteq> opid'" using f3 Suc by (metis Suc_eq_plus1 Suc_lessD) then show ?case using Suc(1) op_exe_xseq Suc.prems Suc_lessD by blast qed qed lemma valid_exe_op_exe_exist1: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "\<forall>opid i. ((i < (List.length exe_list - 1)) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))) \<longrightarrow> opid \<noteq> opid'" shows "\<not> (List.member (fst (List.last exe_list)) opid')" proof - have f1: "\<not> (List.member (fst (exe_list!(List.length exe_list - 2))) opid')" using assms valid_exe_op_exe_exist0 proof - have f1: "Suc (Suc 0) = 2" by linarith have "0 < length exe_list" using a1 valid_mem_exe_seq_def by blast then have f2: "length exe_list - 2 = length (butlast (butlast exe_list))" using f1 by (metis (no_types) One_nat_def Suc_pred diff_Suc_Suc length_butlast) have "\<forall>ps f fa n. \<exists>na. \<forall>nb nc. (\<not> valid_mem_exe_seq f fa ps \<or> \<not> List.member (fst (ps ! nb)) n \<or> \<not> nb < length ps - 1 \<or> na < length ps - 1) \<and> (\<not> valid_mem_exe_seq f fa ps \<or> \<not> List.member (fst (ps ! nc)) n \<or> \<not> nc < length ps - 1 \<or> (f fa n \<turnstile>m (fst (ps ! na)) (snd (snd (ps ! na))) \<rightarrow> (fst (ps ! (na + 1))) (snd (snd (ps ! (na + 1))))))" using valid_exe_op_exe_exist0 by blast then show ?thesis using f2 by (metis (no_types, lifting) \<open>0 < length exe_list\<close> a1 a2 add_lessD1 diff_less in_set_member length_butlast length_pos_if_in_set less_diff_conv less_numeral_extra(1) valid_exe_xseq_sublist_length zero_less_numeral) qed then show ?thesis proof (cases "List.length exe_list > 1") case True then have "(List.length exe_list - 2) < (List.length exe_list - 1)" by auto then obtain opid where "(po pbm opid \<turnstile>m (fst (exe_list!(List.length exe_list - 2))) (snd (snd (exe_list!(List.length exe_list - 2)))) \<rightarrow> (fst (exe_list!(List.length exe_list - 1))) (snd (snd (exe_list!(List.length exe_list - 1))))) \<and> opid \<noteq> opid'" using a1 a2 unfolding valid_mem_exe_seq_def mem_state_trans_def apply auto by (metis (no_types, hide_lams) Suc_1 Suc_diff_Suc True numeral_1_eq_Suc_0 numeral_One) then have "\<not> (List.member (fst (exe_list!(List.length exe_list - 1))) opid')" using op_exe_xseq f1 by blast then show ?thesis using True a1 last_conv_nth valid_mem_exe_seq_def by fastforce next case False then have "length exe_list = 1" using a1 less_linear valid_mem_exe_seq_def by fastforce then have "(fst (last exe_list)) = (fst (hd exe_list))" by (metis cancel_comm_monoid_add_class.diff_cancel hd_conv_nth last_conv_nth length_0_conv zero_neq_one) then show ?thesis using a1 unfolding valid_mem_exe_seq_def by (simp add: member_rec(2)) qed qed lemma valid_exe_op_exe_exist2: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "opid \<in> fst (snd (List.hd exe_list))" shows "\<exists>i. (i < (List.length exe_list - 1)) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" proof (rule ccontr) assume a3: "\<not> (\<exists>i. (i < (List.length exe_list - 1)) \<and> (po pbm opid \<turnstile>m (fst (List.nth exe_list i)) (snd (snd (List.nth exe_list i))) \<rightarrow> (fst (List.nth exe_list (i+1))) (snd (snd (List.nth exe_list (i+1))))))" have f1: "\<forall>i<length exe_list - 1. (\<exists>opid.(po pbm opid \<turnstile>m (fst (List.nth exe_list i)) (snd (snd (List.nth exe_list i))) \<rightarrow> (fst (List.nth exe_list (i+1))) (snd (snd (List.nth exe_list (i+1))))))" using a1 unfolding valid_mem_exe_seq_final_def valid_mem_exe_seq_def mem_state_trans_def by auto then have f2: "\<forall>i<length exe_list - 1. (\<forall>opid'.(po pbm opid' \<turnstile>m (fst (List.nth exe_list i)) (snd (snd (List.nth exe_list i))) \<rightarrow> (fst (List.nth exe_list (i+1))) (snd (snd (List.nth exe_list (i+1))))) \<longrightarrow> opid' \<noteq> opid)" using a3 by auto then have f3: "\<forall>opid' i. ((i < (List.length exe_list - 1)) \<and> (po pbm opid' \<turnstile>m (fst (List.nth exe_list i)) (snd (snd (List.nth exe_list i))) \<rightarrow> (fst (List.nth exe_list (i+1))) (snd (snd (List.nth exe_list (i+1)))))) \<longrightarrow> opid \<noteq> opid'" by auto then have f4: "\<not> (List.member (fst (List.last exe_list)) opid)" using valid_exe_op_exe_exist1 a1 valid_mem_exe_seq_final_def by blast have f5: "List.member (fst (List.last exe_list)) opid" using a2 a1 unfolding valid_mem_exe_seq_final_def valid_mem_exe_seq_def by (simp add: in_set_member) show False using f4 f5 by auto qed lemma valid_exe_op_exe_unique: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "opid \<in> fst (snd (List.hd exe_list))" and a3: "i < (List.length exe_list - 1)" and a4: "po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))" and a5: "i \<noteq> j \<and> j < (List.length exe_list - 1)" shows "\<not> (po pbm opid \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1)))))" proof (rule ccontr) assume "\<not> \<not>(po pbm opid \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1)))))" then have f1: "po pbm opid \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))" by auto from a5 have "i < j \<or> j < i" by auto then show False proof (rule disjE) assume a6: "i < j" then have f2: "List.member (fst (exe_list!j)) opid" using a1 a4 a5 valid_exe_xseq_sublist5 by auto from f1 have f3: "(fst (exe_list!(j+1))) = (fst (exe_list!j))@[opid]" using mem_op_exe by auto then have f4: "\<not> (non_repeat_list (fst (exe_list!(j+1))))" using f2 unfolding non_repeat_list_def apply auto using a1 a5 f1 valid_mem_exe_seq_op_unique2 by auto from a1 a5 have "is_sublist (fst (exe_list!(j+1))) (fst (List.last exe_list))" using valid_exe_xseq_sublist4 by auto then have "\<not> (non_repeat_list (fst (List.last exe_list)))" using f4 sublist_repeat by auto then show False using a1 valid_mem_exe_seq_op_unique by auto next assume a7: "j < i" then have f2: "List.member (fst (exe_list!i)) opid" using a1 a3 a5 f1 valid_exe_xseq_sublist5 by auto then have f5: "(fst (exe_list!(i+1))) = (fst (exe_list!i))@[opid]" using a4 mem_op_exe by auto then have f4: "\<not> (non_repeat_list (fst (exe_list!(i+1))))" using f2 unfolding non_repeat_list_def apply auto using a1 a3 a4 valid_mem_exe_seq_op_unique2 by auto from a1 a3 have "is_sublist (fst (exe_list!(i+1))) (fst (List.last exe_list))" using valid_exe_xseq_sublist4 by auto then have "\<not> (non_repeat_list (fst (List.last exe_list)))" using f4 sublist_repeat by auto then show False using a1 valid_mem_exe_seq_op_unique by auto qed qed lemma valid_exe_op_exe_pos: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "(fst (List.last exe_list))!i = opid" and a3: "i < (List.length exe_list - 1)" shows "(po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" proof - have "(po pbm \<turnstile>t (exe_list!i) \<rightarrow> (exe_list!(i+1)))" using a1 a3 unfolding valid_mem_exe_seq_def by auto then have "\<exists>opid. opid \<in> (fst (snd (exe_list!i))) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> (fst (snd (exe_list!(i+1)))) = (fst (snd (exe_list!i))) - {opid}" unfolding mem_state_trans_def by auto then have f1: "\<exists>opid. opid \<in> (fst (snd (exe_list!i))) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> (fst (snd (exe_list!(i+1)))) = (fst (snd (exe_list!i))) - {opid} \<and> (fst (exe_list!(i+1))) = (fst (exe_list!i))@[opid]" using mem_op_exe by fastforce then have f2: "List.length (fst (exe_list!(i+1))) = i + 1" using valid_exe_xseq_sublist_length a1 a3 by auto also have f3: "is_sublist (fst (exe_list!(i+1))) (fst (List.last exe_list))" using a1 a3 valid_exe_xseq_sublist4 by auto then have "(fst (exe_list!(i+1)))!i = (fst (List.last exe_list))!i" using sublist_element f2 by fastforce then have "(fst (exe_list!(i+1)))!i = opid" using a2 by auto then have "List.last (fst (exe_list!(i+1))) = opid" using f2 by (metis add_diff_cancel_right' append_is_Nil_conv f1 last_conv_nth list.distinct(1)) then have "opid \<in> (fst (snd (exe_list!i))) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> (fst (snd (exe_list!(i+1)))) = (fst (snd (exe_list!i))) - {opid} \<and> (fst (exe_list!(i+1))) = (fst (exe_list!i))@[opid]" using f1 by fastforce then show ?thesis by blast qed lemma valid_exe_op_exe_pos2: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list - 1)" shows "(po pbm ((fst (List.last exe_list))!i) \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" using a1 a2 valid_exe_op_exe_pos by blast lemma valid_exe_op_exe_pos3: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list - 1)" and a3: "(po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" shows "((fst (List.last exe_list))!i) = opid" proof - from a1 a2 have "(po pbm ((fst (List.last exe_list))!i) \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" using valid_exe_op_exe_pos2 by auto then have f1: "(fst (exe_list!(i+1))) = (fst (exe_list!i))@[((fst (List.last exe_list))!i)]" using mem_op_exe by auto from a3 have "(fst (exe_list!(i+1))) = (fst (exe_list!i))@[opid]" using mem_op_exe by auto then show ?thesis using f1 by auto qed lemma valid_exe_op_exe_pos_unique: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list - 1) \<and> j < (List.length exe_list - 1) \<and> i \<noteq> j" and a3: "po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))" and a4: "po pbm opid' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))" shows "opid \<noteq> opid'" proof (rule ccontr) assume "\<not> opid \<noteq> opid'" then have f0: "opid = opid'" by auto from a1 a2 have f01: "i < length (fst (last exe_list)) \<and> j < length (fst (last exe_list))" using valid_exe_xseq_sublist_length2 by auto from a1 have f1: "non_repeat_list (fst (List.last exe_list))" using valid_mem_exe_seq_op_unique by auto from a1 a2 a3 have f2: "((fst (List.last exe_list))!i) = opid" using valid_exe_op_exe_pos3 by auto from a1 a2 a4 have f3: "((fst (List.last exe_list))!j) = opid'" using valid_exe_op_exe_pos3 by auto from f0 f2 f3 have "((fst (List.last exe_list))!i) = ((fst (List.last exe_list))!j)" by auto then show False using a2 f1 f01 unfolding non_repeat_list_def using nth_eq_iff_index_eq by auto \<comment>\<open> by auto \<close> qed lemma valid_exe_op_order0: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "(opid m<(fst (List.last exe_list)) opid') = Some True" and a3: "(opid \<in> fst (snd (List.hd exe_list)) \<and> opid' \<in> fst (snd (List.hd exe_list)) \<and> opid \<noteq> opid')" shows "\<exists>i j.(i < (List.length exe_list - 1)) \<and> (j < (List.length exe_list - 1)) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> (po pbm opid' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))) \<and> i < j" proof - from a1 a3 have "opid \<in> set (fst (List.last exe_list)) \<and> opid' \<in> set (fst (List.last exe_list)) \<and> opid \<noteq> opid'" unfolding valid_mem_exe_seq_def valid_mem_exe_seq_final_def by auto then have "List.member (fst (List.last exe_list)) opid \<and> List.member (fst (List.last exe_list)) opid' \<and> opid \<noteq> opid'" by (simp add: in_set_member) then have "list_before opid (fst (List.last exe_list)) opid'" using a2 unfolding memory_order_before_def apply auto using option.inject by fastforce then have "\<exists>i j. 0 \<le> i \<and> i < length (fst (List.last exe_list)) \<and> 0 \<le> j \<and> j < length (fst (List.last exe_list)) \<and> ((fst (List.last exe_list))!i) = opid \<and> ((fst (List.last exe_list))!j) = opid' \<and> i < j" unfolding list_before_def by simp then have "\<exists>i j. 0 \<le> i \<and> i < length exe_list - 1 \<and> 0 \<le> j \<and> j < length exe_list - 1 \<and> ((fst (List.last exe_list))!i) = opid \<and> ((fst (List.last exe_list))!j) = opid' \<and> i < j" using valid_exe_xseq_sublist_length a1 valid_mem_exe_seq_final_def by (metis valid_exe_xseq_sublist_length2) then have "\<exists>i j. 0 \<le> i \<and> i < length exe_list - 1 \<and> 0 \<le> j \<and> j < length exe_list - 1 \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> (po pbm opid' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))) \<and> i < j" using valid_exe_op_exe_pos a1 valid_mem_exe_seq_final_def by blast then show ?thesis by auto qed lemma valid_exe_op_order: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "(opid m<(fst (List.last exe_list)) opid') = Some True" and a3: "(opid \<in> fst (snd (List.hd exe_list)) \<and> opid' \<in> fst (snd (List.hd exe_list)) \<and> opid \<noteq> opid')" shows "\<exists>i. (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> \<not> (List.member (fst (exe_list!i)) opid')" proof (rule ccontr) assume a4: "\<nexists>i. (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> \<not> List.member (fst (exe_list ! i)) opid'" obtain i j where f1: "(i < (List.length exe_list - 1)) \<and> (j < (List.length exe_list - 1)) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> (po pbm opid' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))) \<and> i < j" using assms valid_exe_op_order0 by blast from a4 f1 have f2: "List.member (fst (exe_list ! i)) opid'" by auto from a1 f1 have f3: "is_sublist (fst (exe_list!i)) (fst (exe_list!j))" using valid_exe_xseq_sublist3 valid_mem_exe_seq_final_def by auto then have f4: "List.member (fst (exe_list ! j)) opid'" using f2 sublist_member by fastforce then show False using a1 f1 valid_mem_exe_seq_op_unique2 valid_mem_exe_seq_final_def by blast qed lemma valid_exe_op_order2: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "(List.member (fst (List.last exe_list)) opid \<and> List.member (fst (List.last exe_list)) opid' \<and> opid \<noteq> opid')" shows "((opid m<(fst (List.last exe_list)) opid') = Some True \<or> (opid' m<(fst (List.last exe_list)) opid) = Some True)" proof - from a2 have "(opid \<in> set (fst (List.last exe_list))) \<and> (opid' \<in> set (fst (List.last exe_list)))" by (simp add: in_set_member) then have "(opid \<in> fst (snd (List.hd exe_list))) \<and> (opid' \<in> fst (snd (List.hd exe_list)))" using a1 unfolding valid_mem_exe_seq_def valid_mem_exe_seq_final_def by auto then show ?thesis using a1 valid_exe_all_order a2 by auto qed lemma valid_exe_op_order_3ops: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "(opid m<(fst (List.last exe_list)) opid') = Some True" and a3: "(opid \<in> fst (snd (List.hd exe_list)) \<and> opid' \<in> fst (snd (List.hd exe_list)) \<and> opid \<noteq> opid')" and a4: "(opid' m<(fst (List.last exe_list)) opid'') = Some True" and a5: "opid'' \<in> fst (snd (List.hd exe_list)) \<and> opid' \<noteq> opid''" shows "\<exists>i j k.(i < (List.length exe_list - 1)) \<and> (j < (List.length exe_list - 1)) \<and> (k < (List.length exe_list - 1)) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> (po pbm opid' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))) \<and> (po pbm opid'' \<turnstile>m (fst (exe_list!k)) (snd (snd (exe_list!k))) \<rightarrow> (fst (exe_list!(k+1))) (snd (snd (exe_list!(k+1))))) \<and> i < j \<and> j < k" proof- from a3 a5 have f0: "opid \<noteq> opid' \<and> opid' \<noteq> opid''" by auto from a1 a3 a5 have "opid \<in> set (fst (List.last exe_list)) \<and> opid' \<in> set (fst (List.last exe_list)) \<and> opid'' \<in> set (fst (List.last exe_list))" unfolding valid_mem_exe_seq_def valid_mem_exe_seq_final_def by auto then have f1: "List.member (fst (List.last exe_list)) opid \<and> List.member (fst (List.last exe_list)) opid' \<and> List.member (fst (List.last exe_list)) opid''" by (simp add: in_set_member) then have f2: "list_before opid (fst (List.last exe_list)) opid' \<and> list_before opid' (fst (List.last exe_list)) opid''" using a2 a4 unfolding memory_order_before_def apply auto using option.inject apply fastforce using option.inject by fastforce then have f3: "\<exists>i j. 0 \<le> i \<and> i < length (fst (List.last exe_list)) \<and> 0 \<le> j \<and> j < length (fst (List.last exe_list)) \<and> ((fst (List.last exe_list))!i) = opid \<and> ((fst (List.last exe_list))!j) = opid' \<and> i < j" unfolding list_before_def by simp from f2 have f4: "\<exists>jb k. 0 \<le> jb \<and> jb < length (fst (List.last exe_list)) \<and> 0 \<le> k \<and> k < length (fst (List.last exe_list)) \<and> ((fst (List.last exe_list))!jb) = opid' \<and> ((fst (List.last exe_list))!k) = opid'' \<and> jb < k" unfolding list_before_def by simp from a1 have "non_repeat_list (fst (List.last exe_list))" using valid_mem_exe_seq_op_unique valid_mem_exe_seq_final_def by auto then have "\<exists>i j k. 0 \<le> i \<and> i < length (fst (List.last exe_list)) \<and> 0 \<le> j \<and> j < length (fst (List.last exe_list)) \<and> 0 \<le> k \<and> k < length (fst (List.last exe_list)) \<and> ((fst (List.last exe_list))!i) = opid \<and> ((fst (List.last exe_list))!j) = opid' \<and> ((fst (List.last exe_list))!k) = opid'' \<and> i < j \<and> j < k" using non_repeat_list_pos_unique f3 f4 by metis then have "\<exists>i j k. 0 \<le> i \<and> i < length exe_list - 1 \<and> 0 \<le> j \<and> j < length exe_list - 1 \<and> 0 \<le> k \<and> k < length exe_list - 1 \<and> ((fst (List.last exe_list))!i) = opid \<and> ((fst (List.last exe_list))!j) = opid' \<and> ((fst (List.last exe_list))!k) = opid'' \<and> i < j \<and> j < k" using valid_exe_xseq_sublist_length a1 valid_mem_exe_seq_final_def by (metis valid_exe_xseq_sublist_length2) then have "\<exists>i j k. 0 \<le> i \<and> i < length exe_list - 1 \<and> 0 \<le> j \<and> j < length exe_list - 1 \<and> 0 \<le> k \<and> k < length exe_list - 1 \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> (po pbm opid' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))) \<and> (po pbm opid'' \<turnstile>m (fst (exe_list!k)) (snd (snd (exe_list!k))) \<rightarrow> (fst (exe_list!(k+1))) (snd (snd (exe_list!(k+1))))) \<and> i < j \<and> j < k" using valid_exe_op_exe_pos a1 valid_mem_exe_seq_final_def by blast then show ?thesis by auto qed lemma prog_order_op_unique: assumes a1: "valid_program po pbm" and a2: "opid ;po^p opid'" shows "opid \<noteq> opid'" proof - from a1 a2 have f1: "non_repeat_list (po p)" unfolding valid_program_def by blast from a2 have "\<exists>i j. 0 \<le> i \<and> i < length (po p) \<and> 0 \<le> j \<and> j < length (po p) \<and> ((po p)!i) = opid \<and> ((po p)!j) = opid' \<and> i < j" unfolding program_order_before_def list_before_def by auto then show ?thesis using f1 unfolding non_repeat_list_def using nth_eq_iff_index_eq by auto \<comment>\<open> by auto \<close> qed lemma prog_order_op_exe: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "opid ;po^p opid'" shows "List.member (fst (List.last exe_list)) opid \<and> List.member (fst (List.last exe_list)) opid'" proof - from a2 have "\<exists>i j. 0 \<le> i \<and> i < length (po p) \<and> 0 \<le> j \<and> j < length (po p) \<and> ((po p)!i) = opid \<and> ((po p)!j) = opid' \<and> i < j" unfolding program_order_before_def list_before_def by auto then have "List.member (po p) opid \<and> List.member (po p) opid'" using list_mem_range_rev by metis then have "(opid \<in> fst (snd (List.hd exe_list))) \<and> (opid' \<in> fst (snd (List.hd exe_list)))" using a1 unfolding valid_mem_exe_seq_def valid_mem_exe_seq_final_def by auto then have "(opid \<in> set (fst (List.last exe_list))) \<and> (opid' \<in> set (fst (List.last exe_list)))" using a1 unfolding valid_mem_exe_seq_def valid_mem_exe_seq_final_def by auto then show ?thesis by (simp add: in_set_member) qed lemma prog_order_op_exe2: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "opid ;po^p opid'" shows "((opid m<(fst (List.last exe_list)) opid') = Some True \<or> (opid' m<(fst (List.last exe_list)) opid) = Some True)" proof - from assms have f1: "List.member (fst (List.last exe_list)) opid \<and> List.member (fst (List.last exe_list)) opid'" using prog_order_op_exe by auto have f4: "opid \<noteq> opid'" using prog_order_op_unique a1 a2 valid_mem_exe_seq_def valid_mem_exe_seq_final_def by blast then show ?thesis using a1 f1 valid_exe_op_order2 by auto qed text {* The lemma below shows that the LoadOp axiom is satisfied in every valid sequence of executions in the operational TSO model. *} lemma axiom_loadop_sat: "valid_mem_exe_seq_final po pbm exe_list \<Longrightarrow> axiom_loadop opid opid' po (fst (List.last exe_list)) pbm" proof - assume a1: "valid_mem_exe_seq_final po pbm exe_list" show "axiom_loadop opid opid' po (fst (List.last exe_list)) pbm" proof (rule ccontr) assume a2: "\<not>(axiom_loadop opid opid' po (fst (List.last exe_list)) pbm)" then obtain p where f1: "(type_of_mem_op_block (pbm opid) \<in> {ld_block, ald_block}) \<and> (p = proc_of_op opid pbm) \<and> (opid ;po^p opid') \<and> \<not> ((opid m<(fst (List.last exe_list)) opid') = Some True)" unfolding axiom_loadop_def by auto from a1 f1 have f2: "(opid' m<(fst (List.last exe_list)) opid) = Some True" using prog_order_op_exe2 by blast from a1 f1 have f3: "List.member (fst (List.last exe_list)) opid \<and> List.member (fst (List.last exe_list)) opid' \<and> opid \<noteq> opid'" using prog_order_op_exe prog_order_op_unique valid_mem_exe_seq_def valid_mem_exe_seq_final_def by blast then obtain i where f4: "(po pbm opid' \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> \<not> (List.member (fst (exe_list!i)) opid)" using f2 a1 valid_exe_op_order valid_mem_exe_seq_final_def by (metis in_set_member) then have f5: "(po pbm opid' \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" by auto have "(\<forall>opid''. ((opid'' ;po^(proc_of_op opid pbm) opid') \<and> (type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = ald_block)) \<longrightarrow> List.member (fst (exe_list!i)) opid'') \<Longrightarrow> False" using f1 f4 by auto then have f6: "(\<forall>opid''. ((opid'' ;po^(proc_of_op opid' pbm) opid') \<and> (type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = ald_block)) \<longrightarrow> List.member (fst (exe_list!i)) opid'') \<Longrightarrow> False" using a1 unfolding valid_mem_exe_seq_def valid_program_def valid_mem_exe_seq_final_def using f1 by force have "\<forall>opid'a. (opid'a ;po^(proc_of_op opid pbm) opid') \<and> (type_of_mem_op_block (pbm opid'a) = ld_block \<or> type_of_mem_op_block (pbm opid'a) = ald_block \<or> type_of_mem_op_block (pbm opid'a) = st_block \<or> type_of_mem_op_block (pbm opid'a) = ast_block) \<longrightarrow> List.member (fst (exe_list!i)) opid'a \<Longrightarrow> False" using f1 f4 by auto then have f7: "\<forall>opid'a. (opid'a ;po^(proc_of_op opid' pbm) opid') \<and> (type_of_mem_op_block (pbm opid'a) = ld_block \<or> type_of_mem_op_block (pbm opid'a) = ald_block \<or> type_of_mem_op_block (pbm opid'a) = st_block \<or> type_of_mem_op_block (pbm opid'a) = ast_block) \<longrightarrow> List.member (fst (exe_list!i)) opid'a \<Longrightarrow> False" using a1 unfolding valid_mem_exe_seq_def valid_program_def valid_mem_exe_seq_final_def using f1 by force show False proof (cases "type_of_mem_op_block (pbm opid')") case ld_block then show ?thesis using mem_op_elim_load_op[OF f5 ld_block] f6 by (metis (full_types)) next case st_block then show ?thesis using mem_op_elim_store_op[OF f5 st_block] f7 by (metis (full_types)) next case ald_block then show ?thesis using mem_op_elim_atom_load_op[OF f5 ald_block] f7 by (metis (full_types)) next case ast_block then show ?thesis using mem_op_elim_atom_store_op[OF f5 ast_block] f7 by (metis (full_types)) next case o_block then show ?thesis using mem_op_elim_o_op[OF f5 o_block] f7 by (metis (full_types)) qed qed qed text {* The lemma below shows that the StoreStore axiom is satisfied in every valid sequence of executions in the operational TSO model. *} lemma axiom_storestore_sat: "valid_mem_exe_seq_final po pbm exe_list \<Longrightarrow> axiom_storestore opid opid' po (fst (List.last exe_list)) pbm" proof - assume a1: "valid_mem_exe_seq_final po pbm exe_list" show "axiom_storestore opid opid' po (fst (List.last exe_list)) pbm" proof (rule ccontr) assume a2: "\<not>(axiom_storestore opid opid' po (fst (List.last exe_list)) pbm)" then obtain p where f1: "((type_of_mem_op_block (pbm opid) \<in> {st_block, ast_block}) \<and> (type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}) \<and> ((p = proc_of_op opid pbm) \<and> (opid ;po^p opid'))) \<and> \<not> ((opid m<(fst (List.last exe_list)) opid') = Some True)" unfolding axiom_storestore_def by auto from a1 f1 have f2: "(opid' m<(fst (List.last exe_list)) opid) = Some True" using prog_order_op_exe2 by blast from a1 f1 have f3: "List.member (fst (List.last exe_list)) opid \<and> List.member (fst (List.last exe_list)) opid' \<and> opid \<noteq> opid'" using prog_order_op_exe prog_order_op_unique valid_mem_exe_seq_def valid_mem_exe_seq_final_def by blast then obtain i where f4: "(po pbm opid' \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> \<not> (List.member (fst (exe_list!i)) opid)" using f2 a1 valid_exe_op_order by (metis in_set_member valid_mem_exe_seq_final_def) then have f5: "(po pbm opid' \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" by auto have "\<forall>opid'a. (opid'a ;po^(proc_of_op opid pbm) opid') \<and> (type_of_mem_op_block (pbm opid'a) = ld_block \<or> type_of_mem_op_block (pbm opid'a) = ald_block \<or> type_of_mem_op_block (pbm opid'a) = st_block \<or> type_of_mem_op_block (pbm opid'a) = ast_block) \<longrightarrow> List.member (fst (exe_list!i)) opid'a \<Longrightarrow> False" using f1 f4 by auto then have f7: "\<forall>opid'a. (opid'a ;po^(proc_of_op opid' pbm) opid') \<and> (type_of_mem_op_block (pbm opid'a) = ld_block \<or> type_of_mem_op_block (pbm opid'a) = ald_block \<or> type_of_mem_op_block (pbm opid'a) = st_block \<or> type_of_mem_op_block (pbm opid'a) = ast_block) \<longrightarrow> List.member (fst (exe_list!i)) opid'a \<Longrightarrow> False" using a1 unfolding valid_mem_exe_seq_def valid_program_def valid_mem_exe_seq_final_def using f1 by force show False proof (cases "type_of_mem_op_block (pbm opid')") case ld_block then show ?thesis using f1 by auto next case st_block then show ?thesis using mem_op_elim_store_op[OF f5 st_block] f7 by (metis (full_types)) next case ald_block then show ?thesis using f1 by auto next case ast_block then show ?thesis using mem_op_elim_atom_store_op[OF f5 ast_block] f7 by (metis (full_types)) next case o_block then show ?thesis using f1 by auto qed qed qed lemma axiom_atomicity_sub1: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "(atom_pair_id (pbm opid') = Some opid) \<and> (type_of_mem_op_block (pbm opid) = ald_block) \<and> (type_of_mem_op_block (pbm opid') = ast_block) \<and> (opid ;po^(proc_of_op opid pbm) opid')" shows "(opid m<(fst (List.last exe_list)) opid') = Some True" proof (rule ccontr) assume a3: "\<not> ((opid m<(fst (List.last exe_list)) opid') = Some True)" then have f1: "(opid' m<(fst (List.last exe_list)) opid) = Some True" using a1 a2 prog_order_op_exe2 by fastforce from a1 a2 have f2: "List.member (fst (List.last exe_list)) opid \<and> List.member (fst (List.last exe_list)) opid' \<and> opid \<noteq> opid'" using prog_order_op_exe prog_order_op_unique valid_mem_exe_seq_def valid_mem_exe_seq_final_def by blast then obtain i where f3: "(po pbm opid' \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> \<not> (List.member (fst (exe_list!i)) opid)" using f1 a1 valid_exe_op_order by (metis in_set_member valid_mem_exe_seq_final_def) then have f4: "(po pbm opid' \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" by auto have "\<forall>opid'a. (opid'a ;po^(proc_of_op opid pbm) opid') \<and> (type_of_mem_op_block (pbm opid'a) = ld_block \<or> type_of_mem_op_block (pbm opid'a) = ald_block \<or> type_of_mem_op_block (pbm opid'a) = st_block \<or> type_of_mem_op_block (pbm opid'a) = ast_block) \<longrightarrow> List.member (fst (exe_list!i)) opid'a \<Longrightarrow> False" using a1 a2 f3 by auto then have f5: "\<forall>opid'a. (opid'a ;po^(proc_of_op opid' pbm) opid') \<and> (type_of_mem_op_block (pbm opid'a) = ld_block \<or> type_of_mem_op_block (pbm opid'a) = ald_block \<or> type_of_mem_op_block (pbm opid'a) = st_block \<or> type_of_mem_op_block (pbm opid'a) = ast_block) \<longrightarrow> List.member (fst (exe_list!i)) opid'a \<Longrightarrow> False" using a1 unfolding valid_mem_exe_seq_def valid_program_def valid_mem_exe_seq_final_def using a1 a2 by force from a2 have f6: "(type_of_mem_op_block (pbm opid') = ast_block)" by auto show False using mem_op_elim_atom_store_op[OF f4 f6] f5 by (metis (full_types)) qed text {* The below block of proofs show that the following operations do not modify the atomic flag in the state. *} lemma gen_reg_mod_atomic_flag: "atomic_flag_val s = r \<Longrightarrow> atomic_flag_val (gen_reg_mod p val reg s) = r" unfolding atomic_flag_val_def gen_reg_mod_def by auto lemma mem_op_addr_mod_atomic_flag: "atomic_flag_val s = r \<Longrightarrow> atomic_flag_val (mem_op_addr_mod addr opid' s) = r" unfolding atomic_flag_val_def mem_op_addr_mod_def by auto lemma mem_op_val_mod_atomic_flag: "atomic_flag_val s = r \<Longrightarrow> atomic_flag_val (mem_op_val_mod addr opid' s) = r" unfolding atomic_flag_val_def mem_op_val_mod_def by auto lemma annul_mod_atomic_flag: "atomic_flag_val s = r \<Longrightarrow> atomic_flag_val (annul_mod p b s) = r" unfolding annul_mod_def atomic_flag_val_def by auto lemma ctl_reg_mod_atomic_flag: "atomic_flag_val s = r \<Longrightarrow> atomic_flag_val (ctl_reg_mod p val reg s) = r" unfolding ctl_reg_mod_def atomic_flag_val_def by auto lemma next_proc_op_pos_mod_atomic_flag: "atomic_flag_val s = r \<Longrightarrow> atomic_flag_val (next_proc_op_pos_mod p pos s) = r" unfolding next_proc_op_pos_mod_def atomic_flag_val_def by auto lemma mem_mod_atomic_flag: "atomic_flag_val s = r \<Longrightarrow> atomic_flag_val (mem_mod v a s) = r" unfolding mem_mod_def atomic_flag_val_def by auto lemma mem_commit_atomic_flag: "atomic_flag_val s = r \<Longrightarrow> atomic_flag_val (mem_commit opid s) = r" unfolding mem_commit_def using mem_mod_atomic_flag apply auto apply (simp add: Let_def) apply (cases "op_addr (get_mem_op_state opid s)") apply auto apply (cases "op_val (get_mem_op_state opid s)") by auto lemma atomic_flag_mod_none: "atomic_flag_val (atomic_flag_mod None s) = None" unfolding atomic_flag_mod_def atomic_flag_val_def by auto lemma atomic_flag_mod_some: "atomic_flag_val (atomic_flag_mod (Some opid) s) = Some opid" unfolding atomic_flag_mod_def atomic_flag_val_def by auto lemma load_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (load_instr p instr opid' a v s) = r" using a1 unfolding load_instr_def Let_def atomic_flag_val_def apply auto apply (cases "a") apply auto apply (cases "v") apply auto using gen_reg_mod_atomic_flag mem_op_addr_mod_atomic_flag mem_op_val_mod_atomic_flag apply ( simp add: atomic_flag_val_def) using mem_op_addr_mod_atomic_flag mem_op_val_mod_atomic_flag by (simp add: atomic_flag_val_def) lemma store_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (store_instr p instr opid' s) = r" using a1 unfolding store_instr_def Let_def atomic_flag_val_def using mem_op_addr_mod_atomic_flag mem_op_val_mod_atomic_flag by (simp add: atomic_flag_val_def) lemma sethi_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (sethi_instr p instr s) = r" using a1 unfolding sethi_instr_def Let_def atomic_flag_val_def apply (cases "get_operand_w5 (snd instr ! 1) \<noteq> 0") apply auto using gen_reg_mod_atomic_flag by (simp add: atomic_flag_val_def) lemma nop_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (nop_instr p instr s) = r" using a1 unfolding nop_instr_def by auto lemma logical_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (logical_instr p instr s) = r" using a1 unfolding logical_instr_def Let_def apply (cases "fst instr \<in> {logic_type ANDcc, logic_type ANDNcc, logic_type ORcc, logic_type ORNcc, logic_type XORcc, logic_type XNORcc}") apply clarsimp apply (cases "get_operand_w5 (snd instr ! 3) \<noteq> 0") apply clarsimp using ctl_reg_mod_atomic_flag atomic_flag_val_def gen_reg_mod_atomic_flag apply auto[1] using ctl_reg_mod_atomic_flag atomic_flag_val_def gen_reg_mod_atomic_flag apply auto[1] apply auto using atomic_flag_val_def gen_reg_mod_atomic_flag by auto lemma shift_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (shift_instr p instr s) = r" using a1 unfolding shift_instr_def Let_def apply auto using atomic_flag_val_def gen_reg_mod_atomic_flag by auto lemma add_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (add_instr p instr s) = r" using a1 unfolding add_instr_def Let_def apply auto using ctl_reg_mod_atomic_flag atomic_flag_val_def gen_reg_mod_atomic_flag by auto lemma sub_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (sub_instr p instr s) = r" using a1 unfolding sub_instr_def Let_def apply auto using ctl_reg_mod_atomic_flag atomic_flag_val_def gen_reg_mod_atomic_flag by auto lemma mul_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (mul_instr p instr s) = r" using a1 unfolding mul_instr_def Let_def apply auto using ctl_reg_mod_atomic_flag atomic_flag_val_def gen_reg_mod_atomic_flag by auto lemma div_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (div_instr p instr s) = r" using a1 unfolding div_instr_def Let_def apply auto using atomic_flag_val_def apply auto unfolding div_comp_def apply auto apply (cases "get_operand_w5 (snd instr ! 3) \<noteq> 0") apply auto unfolding Let_def using ctl_reg_mod_atomic_flag atomic_flag_val_def gen_reg_mod_atomic_flag by auto lemma jmpl_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (jmpl_instr p instr s) = r" using a1 unfolding jmpl_instr_def Let_def apply auto using ctl_reg_mod_atomic_flag atomic_flag_val_def gen_reg_mod_atomic_flag by auto lemma branch_instr_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (branch_instr p instr s) = r" using a1 unfolding branch_instr_def Let_def apply auto using ctl_reg_mod_atomic_flag atomic_flag_val_def gen_reg_mod_atomic_flag annul_mod_atomic_flag by auto lemma swap_load_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (swap_load p instr opid' a v s) = r" using a1 unfolding swap_load_def Let_def atomic_flag_val_def apply auto apply (cases "a") apply auto apply (cases "v") apply auto using gen_reg_mod_atomic_flag mem_op_addr_mod_atomic_flag mem_op_val_mod_atomic_flag atomic_rd_mod_def apply ( simp add: atomic_flag_val_def) using mem_op_addr_mod_atomic_flag mem_op_val_mod_atomic_flag atomic_rd_mod_def by (simp add: atomic_flag_val_def) lemma swap_store_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (swap_store p instr opid' s) = r" using a1 unfolding swap_store_def Let_def atomic_flag_val_def using mem_op_addr_mod_atomic_flag mem_op_val_mod_atomic_flag atomic_rd_val_def by (simp add: atomic_flag_val_def) lemma casa_load_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (casa_load p instr opid' a v s) = r" using a1 unfolding casa_load_def Let_def apply auto apply (cases "a") apply (simp add: atomic_flag_val_def) apply (cases "v") apply (simp add: atomic_flag_val_def) using gen_reg_mod_atomic_flag mem_op_addr_mod_atomic_flag mem_op_val_mod_atomic_flag gen_reg_val_def atomic_rd_mod_def by (simp add: atomic_flag_val_def) lemma casa_store_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (casa_store p instr opid' s) = r" proof (cases "(atomic_flag_val s)") case None then show ?thesis using a1 unfolding casa_store_def Let_def apply auto by (simp add: atomic_flag_val_def) next case (Some a) then have f1: "atomic_flag_val s = Some a" by auto then show ?thesis proof (cases "op_val (mem_ops s a)") case None then show ?thesis using a1 unfolding casa_store_def Let_def apply auto using Some None by (simp add: atomic_flag_val_def) next case (Some a) then show ?thesis using a1 unfolding casa_store_def Let_def apply auto using f1 Some mem_op_addr_mod_atomic_flag mem_op_val_mod_atomic_flag by (simp add: atomic_flag_val_def ) qed qed lemma proc_exe_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (proc_exe p instr opid' a v s) = r" using a1 unfolding proc_exe_def Let_def apply (cases "fst instr \<in> {load_store_type LD}") apply (simp add: load_instr_atomic_flag) apply (cases "fst instr \<in> {load_store_type ST}") apply (simp add: store_instr_atomic_flag) apply (cases "fst instr \<in> {sethi_type SETHI}") apply (simp add: sethi_instr_atomic_flag) apply (cases "fst instr \<in> {nop_type NOP}") apply (simp add: nop_instr_atomic_flag) apply (cases "fst instr \<in> {logic_type ANDs, logic_type ANDcc, logic_type ANDN, logic_type ANDNcc, logic_type ORs, logic_type ORcc, logic_type ORN, logic_type XORs, logic_type XNOR}") apply (simp add: logical_instr_atomic_flag) apply (cases "fst instr \<in> {shift_type SLL, shift_type SRL, shift_type SRA}") apply (simp add: shift_instr_atomic_flag) apply (cases "fst instr \<in> {arith_type ADD, arith_type ADDcc, arith_type ADDX}") apply (simp add: add_instr_atomic_flag) apply (cases "fst instr \<in> {arith_type SUB, arith_type SUBcc, arith_type SUBX}") apply (simp add: sub_instr_atomic_flag) apply (cases "fst instr \<in> {arith_type UMUL, arith_type SMUL, arith_type SMULcc}") apply (simp add: mul_instr_atomic_flag) apply (cases "fst instr \<in> {arith_type UDIV, arith_type UDIVcc, arith_type SDIV}") apply (simp add: div_instr_atomic_flag) apply (cases "fst instr \<in> {ctrl_type JMPL}") apply (simp add: jmpl_instr_atomic_flag) apply (cases "fst instr \<in> {bicc_type BE, bicc_type BNE, bicc_type BGU, bicc_type BLE, bicc_type BL, bicc_type BGE, bicc_type BNEG, bicc_type BG, bicc_type BCS, bicc_type BLEU, bicc_type BCC, bicc_type BA, bicc_type BN}") apply (simp add: branch_instr_atomic_flag) apply (cases "fst instr \<in> {load_store_type SWAP_LD}") apply (simp add: swap_load_atomic_flag) apply (cases "fst instr \<in> {load_store_type SWAP_ST}") apply (simp add: swap_store_atomic_flag) apply (cases "fst instr \<in> {load_store_type CASA_LD}") apply (simp add: casa_load_atomic_flag) apply (cases "fst instr \<in> {load_store_type CASA_ST}") apply (simp add: casa_store_atomic_flag) by auto lemma seq_proc_exe_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (seq_proc_exe p l opid' a v s) = r" proof (insert assms, induction l arbitrary: s) case Nil then show ?case unfolding seq_proc_exe.simps using a1 by auto next case (Cons a l) then show ?case unfolding seq_proc_exe.simps using a1 proc_exe_atomic_flag by auto qed lemma seq_proc_blk_exe_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (seq_proc_blk_exe p po pbm n a v s) = r" proof (insert assms, induction n arbitrary: "(s::sparc_state)") case 0 then show ?case unfolding seq_proc_blk_exe.simps by auto next case (Suc n) then show ?case unfolding seq_proc_blk_exe.simps Let_def apply (cases "proc_exe_pos s p < length (po p)") prefer 2 apply auto[1] apply clarsimp using next_proc_op_pos_mod_atomic_flag seq_proc_exe_atomic_flag by auto qed lemma proc_exe_to_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (proc_exe_to p po pbm pos s) = r" unfolding proc_exe_to_def Let_def using a1 seq_proc_blk_exe_atomic_flag by auto lemma seq_proc_blk_exe_except_last_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (seq_proc_blk_exe_except_last p po pbm n a v s) = r" proof (insert assms, induction n arbitrary: "(s::sparc_state)") case 0 then show ?case unfolding seq_proc_blk_exe.simps by auto next case (Suc n) then show ?case unfolding seq_proc_blk_exe.simps Let_def apply (cases "proc_exe_pos s p < length (po p)") prefer 2 apply auto[1] apply clarsimp apply (cases "n = 0") apply (simp add: Let_def) using next_proc_op_pos_mod_atomic_flag seq_proc_exe_atomic_flag apply auto apply (simp add: Let_def) using next_proc_op_pos_mod_atomic_flag seq_proc_exe_atomic_flag using seq_proc_blk_exe_atomic_flag by auto qed lemma proc_exe_to_previous_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (proc_exe_to_previous p po pbm pos s) = r" unfolding proc_exe_to_previous_def Let_def using seq_proc_blk_exe_except_last_atomic_flag[OF a1] by auto lemma proc_exe_to_last_atomic_flag: assumes a1: "atomic_flag_val s = r" shows "atomic_flag_val (proc_exe_to_last p po pbm pos v a s) = r" unfolding proc_exe_to_last_def using a1 apply auto apply (simp add: Let_def) using next_proc_op_pos_mod_atomic_flag proc_exe_atomic_flag by auto text {* The above finishes the proof that atomic_flag is not modified in processor_execution. *} lemma ast_op_unique: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "opid' \<noteq> opid" and a3: "atom_pair_id (pbm opid) = Some opid''" shows "atom_pair_id (pbm opid') \<noteq> Some opid''" using a1 unfolding valid_mem_exe_seq_def valid_program_def using a2 a3 by blast lemma atomic_flag_exe_ld: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s = None" and a3: "type_of_mem_op_block (pbm opid) = ld_block" shows "atomic_flag_val s' = None" proof - from a1 a3 have "s' = proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) (axiom_value (proc_of_op opid pbm) opid (load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) po xseq pbm (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) (Some (load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)" using mem_op_elim_load_op by metis then show ?thesis using a2 proc_exe_to_atomic_flag proc_exe_to_previous_atomic_flag proc_exe_to_last_atomic_flag by auto qed lemma atomic_flag_exe_st: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s = None" and a3: "type_of_mem_op_block (pbm opid) = st_block" shows "atomic_flag_val s' = None" proof - from a1 a3 have "s' = mem_commit opid (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)" using mem_op_elim_store_op by metis then show ?thesis using a2 proc_exe_to_atomic_flag mem_commit_atomic_flag by auto qed lemma atomic_flag_exe_ald: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s = None" and a3: "type_of_mem_op_block (pbm opid) = ald_block" shows "atomic_flag_val s' = Some opid" proof - from a1 a3 have "s' = atomic_flag_mod (Some opid) (proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) (axiom_value (proc_of_op opid pbm) opid (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) po xseq pbm (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) (Some (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))" using mem_op_elim_atom_load_op by metis then show ?thesis using atomic_flag_mod_some by auto qed lemma atomic_flag_exe_ast: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s = None" shows "type_of_mem_op_block (pbm opid) \<noteq> ast_block" proof (rule ccontr) assume "\<not> type_of_mem_op_block (pbm opid) \<noteq> ast_block" then have "type_of_mem_op_block (pbm opid) = ast_block" by auto then have "(\<exists>opid'. atomic_flag_val s = Some opid')" using a1 mem_op_elim_atom_store_op by metis then show False using a2 by auto qed lemma atomic_flag_exe_o: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s = None" and a3: "type_of_mem_op_block (pbm opid) = o_block" shows "atomic_flag_val s' = None" proof - from a1 a3 have "s' = proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s" using mem_op_elim_o_op by metis then show ?thesis using a2 proc_exe_to_atomic_flag by auto qed lemma atomic_flag_exe1: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s = Some opid'" shows "type_of_mem_op_block (pbm opid) = ld_block \<or> type_of_mem_op_block (pbm opid) = o_block \<or> (type_of_mem_op_block (pbm opid) = ast_block \<and> atom_pair_id (pbm opid) = Some opid')" proof (rule ccontr) assume a3: "\<not> (type_of_mem_op_block (pbm opid) = ld_block \<or> type_of_mem_op_block (pbm opid) = o_block \<or> type_of_mem_op_block (pbm opid) = ast_block \<and> atom_pair_id (pbm opid) = Some opid')" then have "\<not> (type_of_mem_op_block (pbm opid) = ld_block) \<and> \<not> (type_of_mem_op_block (pbm opid) = o_block) \<and> (\<not> (type_of_mem_op_block (pbm opid) = ast_block) \<or> atom_pair_id (pbm opid) \<noteq> Some opid')" by auto then have f1: "(type_of_mem_op_block (pbm opid) = st_block) \<or> (type_of_mem_op_block (pbm opid) = ald_block) \<or> (type_of_mem_op_block (pbm opid) = ast_block \<and> atom_pair_id (pbm opid) \<noteq> Some opid')" using mem_op_block_type.exhaust by blast show False proof (rule disjE[OF f1]) assume a4: "type_of_mem_op_block (pbm opid) = st_block" from a2 have "atomic_flag_val s = None \<Longrightarrow> False" by auto then show False using a1 a4 mem_op_elim_store_op by fastforce next assume a5: "type_of_mem_op_block (pbm opid) = ald_block \<or> (type_of_mem_op_block (pbm opid) = ast_block \<and> atom_pair_id (pbm opid) \<noteq> Some opid')" show False proof (rule disjE[OF a5]) assume a6: "type_of_mem_op_block (pbm opid) = ald_block" from a2 have "atomic_flag_val s = None \<Longrightarrow> False" by auto then show False using a1 a6 mem_op_elim_atom_load_op by fastforce next assume a7: "type_of_mem_op_block (pbm opid) = ast_block \<and> atom_pair_id (pbm opid) \<noteq> Some opid'" then have "\<And>opid'. atomic_flag_val s = Some opid' \<Longrightarrow> atom_pair_id (pbm opid) = Some opid' \<Longrightarrow> False" using a2 by auto then show False using a1 a7 mem_op_elim_atom_store_op by metis qed qed qed lemma atomic_flag_exe2: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s = Some opid'" and a3: "type_of_mem_op_block (pbm opid) = ld_block \<or> type_of_mem_op_block (pbm opid) = o_block" shows "atomic_flag_val s' = Some opid'" proof - from a1 a3 have f1: "(\<exists>vop. s' = proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) vop (Some (load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) \<or> (s' = proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)" using mem_op_elim_load_op mem_op_elim_o_op by meson then show ?thesis apply (rule disjE) using proc_exe_to_atomic_flag proc_exe_to_previous_atomic_flag proc_exe_to_last_atomic_flag a2 by auto qed lemma atomic_flag_exe3: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s = Some opid'" and a3: "(type_of_mem_op_block (pbm opid) = ast_block \<and> atom_pair_id (pbm opid) = Some opid')" shows "atomic_flag_val s' = None" proof - from a1 a3 have f1: "s' = mem_commit opid (atomic_flag_mod None (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))" using mem_op_elim_atom_store_op by metis then have "s' = mem_commit opid (atomic_flag_mod None (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))" using a3 by auto then show ?thesis using atomic_flag_mod_none mem_commit_atomic_flag by auto qed lemma atomic_flag_exe4: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s = None" and a3: "atomic_flag_val s' = Some opid'" shows "type_of_mem_op_block (pbm opid) = ald_block" proof (rule ccontr) assume a4: "type_of_mem_op_block (pbm opid) \<noteq> ald_block" then have "type_of_mem_op_block (pbm opid) = ld_block \<or> type_of_mem_op_block (pbm opid) = st_block \<or> type_of_mem_op_block (pbm opid) = ast_block \<or> type_of_mem_op_block (pbm opid) = o_block" using mem_op_block_type.exhaust by blast then show False proof (auto) assume a5: "type_of_mem_op_block (pbm opid) = ld_block" then have "atomic_flag_val s' = None" using a1 a2 atomic_flag_exe_ld by auto then show False using a3 by auto next assume a6: "type_of_mem_op_block (pbm opid) = st_block" then have "atomic_flag_val s' = None" using a1 a2 atomic_flag_exe_st by auto then show False using a3 by auto next assume a7: "type_of_mem_op_block (pbm opid) = ast_block" then show False using a1 a2 atomic_flag_exe_ast by auto next assume a8: "type_of_mem_op_block (pbm opid) = o_block" then have "atomic_flag_val s' = None" using a1 a2 atomic_flag_exe_o by auto then show False using a3 by auto qed qed lemma atomic_flag_exe5: assumes a1: "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'" and a2: "atomic_flag_val s \<noteq> Some opid'" and a3: "opid \<noteq> opid'" shows "atomic_flag_val s' \<noteq> Some opid'" proof - from a2 have f1: "atomic_flag_val s = None \<or> (\<exists>opid''. atomic_flag_val s = Some opid'' \<and> opid'' \<noteq> opid')" using option.collapse by fastforce then show ?thesis proof (rule disjE) assume a4: "atomic_flag_val s = None" show ?thesis proof (cases "type_of_mem_op_block (pbm opid)") case ld_block then have "atomic_flag_val s' = None" using atomic_flag_exe_ld[OF a1 a4 ld_block] by auto then show ?thesis by auto next case st_block then have "atomic_flag_val s' = None" using atomic_flag_exe_st[OF a1 a4 st_block] by auto then show ?thesis by auto next case ald_block then have "atomic_flag_val s' = Some opid" using atomic_flag_exe_ald[OF a1 a4 ald_block] by auto then show ?thesis using a3 by auto next case ast_block then show ?thesis using atomic_flag_exe_ast[OF a1 a4] by auto next case o_block then have "atomic_flag_val s' = None" using atomic_flag_exe_o[OF a1 a4 o_block] by auto then show ?thesis by auto qed next assume a5: "\<exists>opid''. atomic_flag_val s = Some opid'' \<and> opid'' \<noteq> opid'" then obtain opid'' where f2: "atomic_flag_val s = Some opid'' \<and> opid'' \<noteq> opid'" by auto then have "(type_of_mem_op_block (pbm opid) = ld_block \<or> type_of_mem_op_block (pbm opid) = o_block) \<or> (type_of_mem_op_block (pbm opid) = ast_block \<and> atom_pair_id (pbm opid) = Some opid'')" using atomic_flag_exe1 a1 by auto then show ?thesis proof (rule disjE) assume a6: "type_of_mem_op_block (pbm opid) = ld_block \<or> type_of_mem_op_block (pbm opid) = o_block" then show ?thesis using atomic_flag_exe2[OF a1] f2 by auto next assume a7: "type_of_mem_op_block (pbm opid) = ast_block \<and> atom_pair_id (pbm opid) = Some opid''" then show ?thesis using atomic_flag_exe3[OF a1] f2 by auto qed qed qed lemma atom_exe_valid_type1: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list - 1) \<and> k < (List.length exe_list - 1) \<and> i < k" and a3: "(po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" and a4: "(po pbm opid' \<turnstile>m (fst (exe_list!k)) (snd (snd (exe_list!k))) \<rightarrow> (fst (exe_list!(k+1))) (snd (snd (exe_list!(k+1)))))" and a5: "(atom_pair_id (pbm opid') = Some opid) \<and> (type_of_mem_op_block (pbm opid) = ald_block) \<and> (type_of_mem_op_block (pbm opid') = ast_block)" and a6: "(i < j \<and> j < k \<and> (po pbm opid'' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))))" and a7: "atomic_flag_val (snd (snd (exe_list!(i+1)))) = Some opid" and a8: "opid \<noteq> opid'' \<and> opid'' \<noteq> opid'" shows "(type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = o_block) \<and> atomic_flag_val (snd (snd (exe_list!j))) = Some opid" proof (insert assms, induction "j - i" arbitrary: opid'' j) case 0 then show ?case by auto next case (Suc x) then show ?case proof (cases "j - 1 = i") case True then have "j = i + 1" using Suc.prems(6) by linarith then have f1: "atomic_flag_val (snd (snd (exe_list!j))) = Some opid" using a7 by auto then have f2: "type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = o_block \<or> (type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid)" using Suc(8) atomic_flag_exe1 by blast from a1 Suc(10) Suc(7) have "atom_pair_id (pbm opid'') \<noteq> Some opid" using ast_op_unique by auto then have "type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = o_block" using f2 by auto then show ?thesis using f1 by auto next case False then have f3: "j-1 > i" using Suc(8) by auto then have f003: "j > 0" by auto from Suc(2) have f03: "x = (j-1) - i" by auto from Suc(4) Suc(8) have f4: "j-1 < length exe_list - 1" by auto then obtain opid''' where "(po pbm opid''' \<turnstile>m (fst (exe_list ! (j-1))) (snd (snd (exe_list ! (j-1)))) \<rightarrow> (fst (exe_list ! j)) (snd (snd (exe_list ! j))))" using a1 unfolding valid_mem_exe_seq_def mem_state_trans_def by (metis (no_types, lifting) add.commute add_diff_inverse_nat f3 gr_implies_not_zero nat_diff_split_asm) then have f05: "(po pbm opid''' \<turnstile>m (fst (exe_list ! (j-1))) (snd (snd (exe_list ! (j-1)))) \<rightarrow> (fst (exe_list ! ((j-1)+1))) (snd (snd (exe_list ! ((j-1)+1)))))" using f003 by auto then have f5: "i < j-1 \<and> j-1 < k \<and> (po pbm opid''' \<turnstile>m (fst (exe_list ! (j-1))) (snd (snd (exe_list ! (j-1)))) \<rightarrow> (fst (exe_list ! ((j-1)+1))) (snd (snd (exe_list ! ((j-1)+1)))))" using f3 Suc(8) f003 by auto from a1 f4 Suc(4) f5 Suc(5) have f6: "opid''' \<noteq> opid" using valid_exe_op_exe_pos_unique False by (metis One_nat_def Suc_eq_plus1) from a1 f4 Suc(4) f5 Suc(6) Suc(8) have f7: "opid''' \<noteq> opid'" using valid_exe_op_exe_pos_unique by (metis One_nat_def not_le order_less_imp_le) from f6 f7 have f8: "opid \<noteq> opid''' \<and> opid''' \<noteq> opid'" by auto have f9: "(type_of_mem_op_block (pbm opid''') = ld_block \<or> type_of_mem_op_block (pbm opid''') = o_block) \<and> atomic_flag_val (snd (snd (exe_list ! (j-1)))) = Some opid" using Suc(1)[OF f03 a1 Suc(4) Suc(5) Suc(6) Suc(7) f5 Suc(9) f8] by auto then have "atomic_flag_val (snd (snd (exe_list ! ((j-1)+1)))) = Some opid" using atomic_flag_exe2 f05 by auto then have f10: "atomic_flag_val (snd (snd (exe_list ! j))) = Some opid" using f003 by auto from Suc(8) have f11: "po pbm opid'' \<turnstile>m (fst (exe_list ! j)) (snd (snd (exe_list ! j))) \<rightarrow> (fst (exe_list ! (j + 1))) (snd (snd (exe_list ! (j + 1))))" by auto have f12: "type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = o_block \<or> (type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid)" using atomic_flag_exe1[OF f11 f10] by auto have f13: "atom_pair_id (pbm opid'') \<noteq> Some opid" using ast_op_unique[OF a1] Suc(10) Suc(7) by auto from f12 f13 show ?thesis by (simp add: f10) qed qed lemma axiom_atomicity_sub2: assumes a1: "valid_mem_exe_seq_final po pbm exe_list" and a2: "(atom_pair_id (pbm opid') = Some opid) \<and> (type_of_mem_op_block (pbm opid) = ald_block) \<and> (type_of_mem_op_block (pbm opid') = ast_block) \<and> (opid ;po^(proc_of_op opid pbm) opid')" and a3: "(opid m<(fst (List.last exe_list)) opid') = Some True" shows "(\<forall>opid''. ((type_of_mem_op_block (pbm opid'') \<in> {st_block, ast_block}) \<and> List.member (fst (List.last exe_list)) opid'' \<and> opid'' \<noteq> opid') \<longrightarrow> ((opid'' m<(fst (List.last exe_list)) opid) = Some True \<or> (opid' m<(fst (List.last exe_list)) opid'') = Some True))" proof (rule ccontr) assume a4: "\<not> (\<forall>opid''. ((type_of_mem_op_block (pbm opid'') \<in> {st_block, ast_block}) \<and> List.member (fst (List.last exe_list)) opid'' \<and> opid'' \<noteq> opid') \<longrightarrow> ((opid'' m<(fst (List.last exe_list)) opid) = Some True \<or> (opid' m<(fst (List.last exe_list)) opid'') = Some True))" then obtain opid'' where f1: "(type_of_mem_op_block (pbm opid'') \<in> {st_block, ast_block}) \<and> List.member (fst (List.last exe_list)) opid'' \<and> opid'' \<noteq> opid' \<and> \<not> ((opid'' m<(fst (List.last exe_list)) opid) = Some True \<or> (opid' m<(fst (List.last exe_list)) opid'') = Some True)" by auto from a2 f1 have f2: "opid'' \<noteq> opid" by auto from a2 have f3: "List.member (fst (List.last exe_list)) opid \<and> List.member (fst (List.last exe_list)) opid'" using a1 prog_order_op_exe by auto from f1 f2 f3 a1 have f4: "((opid m<(fst (List.last exe_list)) opid'') = Some True \<or> (opid'' m<(fst (List.last exe_list)) opid) = Some True)" using valid_exe_op_order2 by blast from f1 f3 a1 have f5: "((opid' m<(fst (List.last exe_list)) opid'') = Some True \<or> (opid'' m<(fst (List.last exe_list)) opid') = Some True)" using valid_exe_op_order2 by blast from f4 f5 f1 have f6: "(type_of_mem_op_block (pbm opid'') \<in> {st_block, ast_block}) \<and> List.member (fst (List.last exe_list)) opid'' \<and> opid'' \<noteq> opid' \<and> (opid m<(fst (List.last exe_list)) opid'') = Some True \<and> (opid'' m<(fst (List.last exe_list)) opid') = Some True" by auto from a1 a4 f3 have f7: "opid \<in> fst (snd (List.hd exe_list)) \<and> opid' \<in> fst (snd (List.hd exe_list)) \<and> opid'' \<in> fst (snd (List.hd exe_list))" unfolding valid_mem_exe_seq_def valid_mem_exe_seq_final_def by (simp add: f1 in_set_member) from a1 f6 f7 f2 obtain i j k where f8: "(i < (List.length exe_list - 1)) \<and> (j < (List.length exe_list - 1)) \<and> (k < (List.length exe_list - 1)) \<and> (po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1))))) \<and> (po pbm opid'' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))) \<and> (po pbm opid' \<turnstile>m (fst (exe_list!k)) (snd (snd (exe_list!k))) \<rightarrow> (fst (exe_list!(k+1))) (snd (snd (exe_list!(k+1))))) \<and> i < j \<and> j < k" using valid_exe_op_order_3ops by blast from a1 a2 f8 have f9: "atomic_flag (glob_var (snd (snd (exe_list!(i+1))))) = Some opid" using mem_op_atom_load_op_atomic_flag by auto from f8 have f10: "i < length exe_list - 1 \<and> k < length exe_list - 1 \<and> i < k" by auto from f8 have f11: "(po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" by auto from f8 have f12: "(po pbm opid'' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1)))))" by auto from f8 have f13: "(po pbm opid' \<turnstile>m (fst (exe_list!k)) (snd (snd (exe_list!k))) \<rightarrow> (fst (exe_list!(k+1))) (snd (snd (exe_list!(k+1)))))" by auto from a2 have f14: "atom_pair_id (pbm opid') = Some opid \<and> type_of_mem_op_block (pbm opid) = ald_block \<and> type_of_mem_op_block (pbm opid') = ast_block" by auto from f8 have f15: "i < j \<and> j < k \<and> (po pbm opid'' \<turnstile>m (fst (exe_list ! j)) (snd (snd (exe_list ! j))) \<rightarrow> (fst (exe_list ! (j + 1))) (snd (snd (exe_list ! (j + 1)))))" by auto from f9 have f16: "atomic_flag_val (snd (snd (exe_list ! (i + 1)))) = Some opid " unfolding atomic_flag_val_def by auto from f2 f6 have f17: "opid \<noteq> opid'' \<and> opid'' \<noteq> opid'" by auto from a1 have a1f: "valid_mem_exe_seq po pbm exe_list" unfolding valid_mem_exe_seq_final_def by auto have "(type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = o_block)" using atom_exe_valid_type1[OF a1f f10 f11 f13 f14 f15 f16 f17] by auto then show False using f1 by force qed text {* The lemma below shows that the Atomicity axiom is satisfied in every valid sequence of executions in the operational TSO model. *} lemma axiom_atomicity_sat: "valid_mem_exe_seq_final po pbm exe_list \<Longrightarrow> axiom_atomicity opid opid' po (fst (List.last exe_list)) pbm" unfolding axiom_atomicity_def using axiom_atomicity_sub1 axiom_atomicity_sub2 by auto text {* The theorem below gives the soundness proof. Note that it does not concern the axiom Value, because it is directly incorporated in the operational TSO model, and it's trivially true. *} theorem operational_model_sound: "valid_mem_exe_seq_final po pbm exe_list \<Longrightarrow> (\<forall>opid opid'. axiom_order opid opid' (fst (List.last exe_list)) pbm) \<and> (\<forall>opid. axiom_termination opid po (fst (List.last exe_list)) pbm) \<and> (\<forall>opid opid'. axiom_loadop opid opid' po (fst (List.last exe_list)) pbm) \<and> (\<forall>opid opid'. axiom_storestore opid opid' po (fst (List.last exe_list)) pbm) \<and> (\<forall>opid opid'. axiom_atomicity opid opid' po (fst (List.last exe_list)) pbm)" using axiom_order_sat axiom_termination_sat axiom_loadop_sat axiom_storestore_sat axiom_atomicity_sat by auto subsection {* Completeness of the operational TSO model *} text {* This subsection shows that if a sequence of memory operations satisfies the TSO axioms, then there exists an execution for it in the operational TSO model. N.B. We are only concerned with memory operations in this proof. The order to o_blocks are uninteresting here. We shall just assume that the o_block of a processor is executed after the last memory operation, which is consistent with the rule o_op. But we will not discuss it in the proof. *} text {* The following are the conditions that a complete sequence of memory operations must satisfy. *} definition op_seq_final:: "op_id list \<Rightarrow> program_order \<Rightarrow> program_block_map \<Rightarrow> bool" where "op_seq_final op_seq po pbm \<equiv> valid_program po pbm \<and> List.length op_seq > 0 \<and> (\<forall>opid. (\<exists>p. List.member (po p) opid) = (List.member op_seq opid)) \<and> non_repeat_list op_seq \<and> (\<forall>opid. (\<exists>p. List.member (po p) opid) \<longrightarrow> (type_of_mem_op_block (pbm opid) \<in> {ld_block, st_block, ald_block, ast_block}))" text {* First we show the conditions that falsify each "inference rule" in the operational model. *} lemma load_op_contra: assumes a1: "(type_of_mem_op_block (pbm opid) = ld_block)" and a2: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'))" shows "\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block) \<and> \<not> (List.member xseq opid')" proof (rule ccontr) assume a3: "\<nexists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block) \<and> \<not> List.member xseq opid'" then have f0: "\<forall>opid'. ((opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block)) \<longrightarrow> (List.member xseq opid')" by auto from mem_op.simps have f1: "(type_of_mem_op_block (pbm opid) = ld_block) \<Longrightarrow> \<forall>opid'. ((opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block)) \<longrightarrow> (List.member xseq opid') \<Longrightarrow> (po pbm opid \<turnstile>m xseq s \<rightarrow> (xseq @ [opid]) (proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) (axiom_value (proc_of_op opid pbm) opid (load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) po xseq pbm (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) (Some (load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)))" by (metis (full_types) empty_iff insert_iff load_op) from a1 a2 f0 f1 have f2: "(po pbm opid \<turnstile>m xseq s \<rightarrow> (xseq @ [opid]) (proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) (axiom_value (proc_of_op opid pbm) opid (load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) s) po xseq pbm s) (Some (load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) s)) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm)) - Suc 0) s)))" by auto then have "\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" by auto then show False using a2 by auto qed lemma store_op_contra: assumes a1: "(type_of_mem_op_block (pbm opid) = st_block)" and a2: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'))" shows "atomic_flag_val s \<noteq> None \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member xseq opid'))" proof (rule ccontr) assume a3: "\<not> (atomic_flag_val s \<noteq> None \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> List.member xseq opid'))" then have f0: "atomic_flag_val s = None \<and> (\<forall>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> List.member xseq opid')" by auto from mem_op.simps have f1: "(type_of_mem_op_block (pbm opid) = st_block) \<Longrightarrow> (atomic_flag_val s) = None \<Longrightarrow> \<forall>opid'. (((opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block, st_block, ast_block})) \<longrightarrow> (List.member xseq opid')) \<Longrightarrow> po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (mem_commit opid (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))" by auto from a1 f0 f1 have "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (mem_commit opid (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))" by auto then have "\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" by auto then show False using a2 by auto qed lemma atom_load_op_contra: assumes a1: "(type_of_mem_op_block (pbm opid) = ald_block)" and a2: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'))" shows "atomic_flag_val s \<noteq> None \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member xseq opid'))" proof (rule ccontr) assume a4: "\<not> (atomic_flag_val s \<noteq> None \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> List.member xseq opid'))" then have f0: "atomic_flag_val s = None \<and> (\<forall>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> List.member xseq opid')" by auto from mem_op.simps have f1: "(type_of_mem_op_block (pbm opid) = ald_block) \<Longrightarrow> (atomic_flag_val s) = None \<Longrightarrow> (\<forall>opid'. (((opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block, st_block, ast_block})) \<longrightarrow> (List.member xseq opid'))) \<Longrightarrow> (po pbm opid \<turnstile>m xseq s \<rightarrow> (xseq@[opid]) (atomic_flag_mod (Some opid) (proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) (axiom_value (proc_of_op opid pbm) opid (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) po xseq pbm (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)) (Some (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))))" by auto from a1 a2 f0 f1 have "(po pbm opid \<turnstile>m xseq s \<rightarrow> (xseq@[opid]) (atomic_flag_mod (Some opid) (proc_exe_to_last (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) (axiom_value (proc_of_op opid pbm) opid (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) s) po xseq pbm s) (Some (atomic_load_addr (proc_of_op opid pbm) (last (insts (pbm opid))) s)) (proc_exe_to_previous (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s))))" by auto then have "\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" by auto then show False using a2 by auto qed lemma atom_store_op_contra: assumes a1: "(type_of_mem_op_block (pbm opid) = ast_block)" and a2: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'))" shows "(atomic_flag_val s) = None \<or> (atomic_flag_val s) \<noteq> atom_pair_id (pbm opid) \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member xseq opid'))" proof (rule ccontr) assume a3: "\<not> (atomic_flag_val s = None \<or> atomic_flag_val s \<noteq> atom_pair_id (pbm opid) \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> List.member xseq opid'))" then have f0: "atomic_flag_val s \<noteq> None \<and> atomic_flag_val s = atom_pair_id (pbm opid) \<and> (\<forall>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> List.member xseq opid')" by auto then obtain opid' where f1: "atomic_flag_val s = Some opid'" by blast from mem_op.simps have f2: "(type_of_mem_op_block (pbm opid) = ast_block) \<Longrightarrow> (atomic_flag_val s) = Some opid' \<Longrightarrow> atom_pair_id (pbm opid) = Some opid' \<Longrightarrow> \<forall>opid'. (((opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block, st_block, ast_block})) \<longrightarrow> (List.member xseq opid')) \<Longrightarrow> po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (mem_commit opid (atomic_flag_mod None (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)))" by auto then have "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (mem_commit opid (atomic_flag_mod None (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)))" using a1 f0 f1 by auto then have "\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" by auto then show False using a2 by auto qed lemma atom_o_op_contra: assumes a1: "(type_of_mem_op_block (pbm opid) = o_block)" and a2: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'))" shows "(\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member xseq opid'))" proof (rule ccontr) assume a3: "\<nexists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> List.member xseq opid'" then have f0: "\<forall>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<longrightarrow> List.member xseq opid'" by auto from mem_op.simps have f1: "(type_of_mem_op_block (pbm opid) = o_block) \<Longrightarrow> \<forall>opid'. (((opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block, st_block, ast_block})) \<longrightarrow> (List.member xseq opid')) \<Longrightarrow> po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)" by auto then have "po pbm opid \<turnstile>m xseq s \<rightarrow> xseq@[opid] (proc_exe_to (proc_of_op opid pbm) po pbm (non_repeat_list_pos opid (po (proc_of_op opid pbm))) s)" using a1 f0 by auto then have "\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s')" by auto then show False using a2 by auto qed text {* The lemmas below use the above lemmas to derive that if a rule is not applicable, then at least one axiom is violated. *} text {* First, we define conditions where a partial execution violates the axioms and that no matter how the execution continues the axioms will be violated in a complete execution. We do this because it is possible that the negation of an axiom holds in a partial execution but it doesn't hold in a continuation of the partial execution. The main reason for this to happen is because memory order is only partially observed in the partial execution. So we need to define conditions such that once they are violated in a partial execution, they will be violated in any continuation of the partial execution. *} definition axiom_loadop_violate:: "op_id \<Rightarrow> op_id \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> bool" where "axiom_loadop_violate opid opid' po xseq pbm \<equiv> (type_of_mem_op_block (pbm opid) \<in> {ld_block, ald_block}) \<and> (opid ;po^(proc_of_op opid pbm) opid') \<and> (opid m<xseq opid') = Some False" definition axiom_storestore_violate:: "op_id \<Rightarrow> op_id \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> bool" where "axiom_storestore_violate opid opid' po xseq pbm \<equiv> (type_of_mem_op_block (pbm opid) \<in> {st_block, ast_block}) \<and> (type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}) \<and> (opid ;po^(proc_of_op opid pbm) opid') \<and> (opid m<xseq opid') = Some False" definition axiom_atomicity_violate:: "op_id \<Rightarrow> op_id \<Rightarrow> program_order \<Rightarrow> executed_mem_ops \<Rightarrow> program_block_map \<Rightarrow> bool" where "axiom_atomicity_violate opid opid' po xseq pbm \<equiv> (atom_pair_id (pbm opid') = Some opid) \<and> (type_of_mem_op_block (pbm opid) = ald_block) \<and> (type_of_mem_op_block (pbm opid') = ast_block) \<and> (opid ;po^(proc_of_op opid pbm) opid') \<and> (((opid m<xseq opid') = Some False) \<or> (\<exists>opid''. type_of_mem_op_block (pbm opid'') \<in> {st_block, ast_block} \<and> List.member xseq opid'' \<and> opid'' \<noteq> opid' \<and> (opid'' m<xseq opid) = Some False \<and> (opid' m<xseq opid'') = Some False))" text {* Now we show that the above conditions persist through any continuation of execution. *} lemma mem_order_before_false_persist: assumes a1: "non_repeat_list (xseq@xseq')" and a2: "opid \<noteq> opid'" and a3: "(opid m<xseq opid') = Some False" shows "(opid m<(xseq@xseq') opid') = Some False" proof (insert assms, induction xseq' rule: rev_induct) case Nil then show ?case by auto next case (snoc x xs) define thisseq where "thisseq \<equiv> xseq @ xs" from snoc(2) have f0: "non_repeat_list thisseq" using non_repeat_list_sublist append.assoc thisseq_def by blast then have f1: "(opid m<thisseq opid') = Some False" using snoc(1) thisseq_def a2 a3 by auto then have f2: "((List.member thisseq opid) \<and> (List.member thisseq opid') \<and> \<not>(list_before opid thisseq opid')) \<or> (\<not>(List.member thisseq opid) \<and> (List.member thisseq opid'))" using mem_order_false_cond by auto then have f3: "((List.member thisseq opid) \<and> (List.member thisseq opid') \<and> (list_before opid' thisseq opid)) \<or> (\<not>(List.member thisseq opid) \<and> (List.member thisseq opid'))" using dist_elem_not_before a2 by auto then show ?case proof (rule disjE) assume a4: "List.member thisseq opid \<and> List.member thisseq opid' \<and> list_before opid' thisseq opid" then have f4: "List.member (thisseq@[x]) opid" unfolding list_before_def by (simp add: member_def) from a4 have f5: "List.member (thisseq@[x]) opid'" unfolding list_before_def by (simp add: member_def) from a4 have f8: "list_before opid' (thisseq@[x]) opid" using list_before_extend by auto then have f9: "\<not>(list_before opid (thisseq@[x]) opid')" using non_repeat_list_before snoc(2) thisseq_def by fastforce from a2 f4 f5 f9 have f10: "(opid m<(thisseq@[x]) opid') = Some False" unfolding memory_order_before_def by auto then show ?thesis unfolding axiom_loadop_violate_def thisseq_def by auto next assume a5: "\<not> List.member thisseq opid \<and> List.member thisseq opid'" then have f11: "List.member (thisseq@[x]) opid'" by (simp add: member_def) then show ?thesis proof (cases "x = opid") case True then have f12: "List.member (thisseq@[x]) opid" by (simp add: member_def) have f13: "list_before opid' (thisseq@[x]) opid" using a5 True unfolding list_before_def apply auto by (metis a2 f11 in_set_conv_nth in_set_member length_append_singleton less_Suc_eq nth_append_length) then have f14: "\<not>(list_before opid (thisseq@[x]) opid')" using non_repeat_list_before snoc(2) thisseq_def by fastforce then show ?thesis unfolding memory_order_before_def using f11 f12 f13 thisseq_def by auto next case False then have f15: "\<not>(List.member (thisseq@[x]) opid)" using thisseq_def a5 by (metis insert_iff list.set(2) member_def rotate1.simps(2) set_rotate1) then show ?thesis unfolding memory_order_before_def using f11 thisseq_def by auto qed qed qed lemma axiom_loadop_violate_imp: assumes a1: "axiom_loadop_violate opid opid' po xseq pbm" shows "\<not>(axiom_loadop opid opid' po xseq pbm)" using a1 unfolding axiom_loadop_def axiom_loadop_violate_def by auto lemma axiom_storestore_violate_imp: assumes a1: "axiom_storestore_violate opid opid' po xseq pbm" shows "\<not>(axiom_storestore opid opid' po xseq pbm)" using a1 unfolding axiom_storestore_def axiom_storestore_violate_def by auto lemma axiom_atomicity_violate_imp: assumes a1: "axiom_atomicity_violate opid opid' po xseq pbm" shows "\<not>(axiom_atomicity opid opid' po xseq pbm)" using a1 unfolding axiom_atomicity_def axiom_atomicity_violate_def by auto lemma axiom_loadop_violate_persist: assumes a0: "valid_program po pbm" assumes a1: "axiom_loadop_violate opid opid' po xseq pbm" assumes a2: "non_repeat_list (xseq@xseq')" shows "axiom_loadop_violate opid opid' po (xseq@xseq') pbm" proof - from a1 have f1: "(type_of_mem_op_block (pbm opid) \<in> {ld_block, ald_block}) \<and> (opid ;po^(proc_of_op opid pbm) opid') \<and> (opid m<xseq opid') = Some False" unfolding axiom_loadop_violate_def by auto from a0 f1 have f2: "opid \<noteq> opid'" using prog_order_op_unique by blast from f1 f2 a2 have f3: "(opid m<(xseq@xseq') opid') = Some False" using mem_order_before_false_persist by auto then show ?thesis unfolding axiom_loadop_violate_def using f1 by auto qed lemma axiom_storestore_violate_persist: assumes a0: "valid_program po pbm" assumes a1: "axiom_storestore_violate opid opid' po xseq pbm" assumes a2: "non_repeat_list (xseq@xseq')" shows "axiom_storestore_violate opid opid' po (xseq@xseq') pbm" proof - from a1 have f1: "(type_of_mem_op_block (pbm opid) \<in> {st_block, ast_block}) \<and> (type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}) \<and> (opid ;po^(proc_of_op opid pbm) opid') \<and> (opid m<xseq opid') = Some False" using axiom_storestore_violate_def by auto from a0 f1 have f2: "opid \<noteq> opid'" using prog_order_op_unique by blast from f1 f2 a2 have f3: "(opid m<(xseq@xseq') opid') = Some False" using mem_order_before_false_persist by auto then show ?thesis unfolding axiom_storestore_violate_def using f1 by auto qed lemma axiom_atomicity_violate_persist: assumes a0: "valid_program po pbm" assumes a1: "axiom_atomicity_violate opid opid' po xseq pbm" assumes a2: "non_repeat_list (xseq@xseq')" shows "axiom_atomicity_violate opid opid' po (xseq@xseq') pbm" proof - from a1 have f1: "(atom_pair_id (pbm opid') = Some opid) \<and> (type_of_mem_op_block (pbm opid) = ald_block) \<and> (type_of_mem_op_block (pbm opid') = ast_block) \<and> (opid ;po^(proc_of_op opid pbm) opid') \<and> (((opid m<xseq opid') = Some False) \<or> (\<exists>opid''. type_of_mem_op_block (pbm opid'') \<in> {st_block, ast_block} \<and> List.member xseq opid'' \<and> opid'' \<noteq> opid' \<and> (opid'' m<xseq opid) = Some False \<and> (opid' m<xseq opid'') = Some False))" using axiom_atomicity_violate_def by auto from a0 f1 have f2: "opid \<noteq> opid'" using prog_order_op_unique by blast show ?thesis proof (cases "((opid m<xseq opid') = Some False)") case True from True f2 a2 have f3: "(opid m<(xseq@xseq') opid') = Some False" using mem_order_before_false_persist by auto then show ?thesis unfolding axiom_atomicity_violate_def using f1 by auto next case False then obtain opid'' where f4: "type_of_mem_op_block (pbm opid'') \<in> {st_block, ast_block} \<and> List.member xseq opid'' \<and> opid'' \<noteq> opid' \<and> (opid'' m<xseq opid) = Some False \<and> (opid' m<xseq opid'') = Some False" using f1 by auto then have f5: "List.member (xseq@xseq') opid''" by (meson is_sublist_def sublist_member) from f4 have f6: "opid'' \<noteq> opid'" by auto from f1 f4 have f7: "opid'' \<noteq> opid" by auto from a2 f7 f4 have f8: "(opid'' m<(xseq@xseq') opid) = Some False" using mem_order_before_false_persist by auto from a2 f6 f4 have f9: "(opid' m<(xseq@xseq') opid'') = Some False" using mem_order_before_false_persist by auto then show ?thesis unfolding axiom_atomicity_violate_def using f1 f4 f5 f8 f9 by auto qed qed text {* We now show lemmas that says if a rule is not applicable, then at least one axiom is violated. *} lemma load_op_contra_violate_sub1: assumes a1: "type_of_mem_op_block (pbm opid) = ld_block" and a2: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'))" and a3: "valid_program po pbm" shows "\<exists>opid'. (axiom_loadop_violate opid' opid po (xseq@[opid]) pbm)" proof - from a1 a2 obtain opid' where f1: "(opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block) \<and> \<not> (List.member xseq opid')" using load_op_contra by blast then have f2: "opid \<noteq> opid'" using a3 prog_order_op_unique by blast then have f3: "\<not> (List.member (xseq@[opid]) opid')" using f1 by (metis in_set_member rotate1.simps(2) set_ConsD set_rotate1) have f4: "List.member (xseq@[opid]) opid" using in_set_member by force then have f5: "(opid' m<(xseq@[opid]) opid) = Some False" using f3 unfolding memory_order_before_def by auto from a3 f1 have f6: "proc_of_op opid pbm = proc_of_op opid' pbm" unfolding valid_program_def by fastforce then have "\<exists>opid'. type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block} \<and> (opid' ;po^(proc_of_op opid' pbm) opid) \<and> ((opid' m<(xseq @ [opid]) opid) = Some False)" using f1 f5 by auto then show ?thesis unfolding axiom_loadop_violate_def by simp qed lemma load_op_contra_violate: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "type_of_mem_op_block (pbm opid) = ld_block" and a3: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> xseq' s'))" shows "\<exists>opid'. (axiom_loadop_violate opid' opid po ((fst (last exe_list))@[opid]) pbm)" proof - from a1 have f1: "valid_program po pbm" unfolding valid_mem_exe_seq_def by auto show ?thesis using load_op_contra_violate_sub1[OF a2 a3 f1] by auto qed lemma atom_load_executed_sub1: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "atomic_flag_val (snd (snd (last exe_list))) = Some opid'" shows "List.member (fst (last exe_list)) opid' \<and> type_of_mem_op_block (pbm opid') = ald_block" proof (insert assms, induction exe_list rule: rev_induct) case Nil then show ?case unfolding valid_mem_exe_seq_def by auto next case (snoc x xs) then show ?case proof (cases "xs = []") case True then have f1: "valid_mem_exe_seq po pbm [x] \<and> atomic_flag_val (snd (snd (last [x]))) = Some opid'" using snoc(2) snoc(3) by auto then have f2: "(atomic_flag_val (snd (snd (hd [x]))) = None)" unfolding valid_mem_exe_seq_def by auto then show ?thesis using f1 by simp next case False then have f3: "length xs > 0" by auto from snoc(2) have f4: "valid_program po pbm \<and> fst (List.hd (xs@[x])) = [] \<and> (\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (List.hd (xs@[x]))))) \<and> (atomic_flag_val (snd (snd (hd (xs@[x])))) = None) \<and> (\<forall>i. i < (List.length (xs@[x])) - 1 \<longrightarrow> (po pbm \<turnstile>t ((xs@[x])!i) \<rightarrow> ((xs@[x])!(i+1))))" unfolding valid_mem_exe_seq_def by auto then have f5: "fst (List.hd xs) = []" using f3 by auto have f6: "(\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (List.hd xs))))" using f3 f4 by auto have f7: "(atomic_flag_val (snd (snd (hd xs))) = None)" using f3 f4 by auto have f8: "(\<forall>i. i < (List.length xs) - 1 \<longrightarrow> (po pbm \<turnstile>t (xs!i) \<rightarrow> (xs!(i+1))))" using f3 f4 proof - { fix nn :: nat have "Suc (length (butlast xs)) = length xs" using f3 by auto then have "\<not> nn < length xs - 1 \<or> (po pbm \<turnstile>t xs ! nn \<rightarrow> (xs ! (nn + 1)))" by (metis (no_types) Suc_eq_plus1 Suc_less_eq butlast_snoc f4 length_butlast less_Suc_eq nth_append) } then show ?thesis by meson qed then have f9: "valid_mem_exe_seq po pbm xs" using valid_mem_exe_seq_def f3 f4 f5 f6 f7 f8 by auto from snoc(2) have "\<forall>i < (List.length (xs@[x])) - 1. (po pbm \<turnstile>t ((xs@[x])!i) \<rightarrow> ((xs@[x])!(i+1)))" unfolding valid_mem_exe_seq_def by auto then have f11: "(po pbm \<turnstile>t (last xs) \<rightarrow> x)" by (metis (no_types, lifting) False One_nat_def Suc_eq_plus1 Suc_pred append_butlast_last_id butlast_snoc diff_self_eq_0 f3 hd_conv_nth length_butlast lessI less_not_refl2 list.distinct(1) list.sel(1) nth_append) then have f09: "\<exists>opid. (fst x) = (fst (last xs))@[opid]" unfolding mem_state_trans_def using mem_op_exe by meson from f11 obtain opid''' where f13: "po pbm opid''' \<turnstile>m (fst (last xs)) (snd (snd (last xs))) \<rightarrow> (fst x) (snd (snd x))" unfolding mem_state_trans_def by auto then show ?thesis proof (cases "atomic_flag_val (snd (snd (last xs))) = Some opid'") case True then have f10: "List.member (fst (last xs)) opid' \<and> type_of_mem_op_block (pbm opid') = ald_block" using f9 snoc(1) by auto then show ?thesis using f3 f10 f09 by (metis (no_types, lifting) insert_iff last_snoc list.set(2) member_def rotate1.simps(2) set_rotate1) next case False then have "(\<exists>opid''. atomic_flag_val (snd (snd (last xs))) = Some opid'' \<and> opid'' \<noteq> opid') \<or> atomic_flag_val (snd (snd (last xs))) = None" by auto then show ?thesis proof (rule disjE) assume a3: "\<exists>opid''. atomic_flag_val (snd (snd (last xs))) = Some opid'' \<and> opid'' \<noteq> opid'" then obtain opid'' where f12: "atomic_flag_val (snd (snd (last xs))) = Some opid'' \<and> opid'' \<noteq> opid'" by auto have f14: "type_of_mem_op_block (pbm opid''') = ld_block \<or> type_of_mem_op_block (pbm opid''') = o_block \<or> (type_of_mem_op_block (pbm opid''') = ast_block \<and> atom_pair_id (pbm opid''') = Some opid'')" using atomic_flag_exe1 f12 f13 by auto then have "atomic_flag_val (snd (snd x)) = Some opid'' \<or> atomic_flag_val (snd (snd x)) = None" using atomic_flag_exe2 atomic_flag_exe3 f13 f12 by auto then have "atomic_flag_val (snd (snd x)) \<noteq> Some opid'" using f12 by auto then show ?thesis using snoc(3) by auto next assume a4: "atomic_flag_val (snd (snd (last xs))) = None" from snoc(3) have f15: "atomic_flag_val (snd (snd x)) = Some opid'" by auto then have f16: "type_of_mem_op_block (pbm opid''') = ald_block" using atomic_flag_exe4[OF f13 a4] by auto then have "atomic_flag_val (snd (snd x)) = Some opid'''" using atomic_flag_exe_ald[OF f13 a4] by auto then have f17: "opid' = opid'''" using f15 by auto then have f18: "type_of_mem_op_block (pbm opid') = ald_block" using f16 by auto from f13 f17 have "(fst x) = (fst (last xs))@[opid']" using mem_op_exe by auto then have "List.member (fst x) opid'" using in_set_member by fastforce then show ?thesis using f18 by auto qed qed qed qed lemma atom_load_executed_sub2_sub1: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "j < (List.length exe_list - 1)" and a3: "(k > j \<and> k < (length exe_list - 1))" and a4: "\<forall>k'. (k' > j \<and> k' < (length exe_list - 1)) \<longrightarrow> ((fst (List.last exe_list))!k') \<noteq> opid'" and a5: "atomic_flag_val (snd (snd (exe_list ! (j + 1)))) \<noteq> Some opid'" shows "atomic_flag_val (snd (snd (exe_list!(k+1)))) \<noteq> Some opid'" proof (insert assms, induction k) case 0 then show ?case by auto next case (Suc k) from Suc(4) have "k = j \<or> j < k" by auto then have f1: "atomic_flag_val (snd (snd (exe_list ! (k + 1)))) \<noteq> Some opid'" using Suc by auto from Suc(4) have f2: "(po pbm ((fst (List.last exe_list))!(k+1)) \<turnstile>m (fst (exe_list!(k+1))) (snd (snd (exe_list!(k+1)))) \<rightarrow> (fst (exe_list!((k+1)+1))) (snd (snd (exe_list!((k+1)+1)))))" using valid_exe_op_exe_pos2[OF Suc(2)] by auto from a4 have "((fst (List.last exe_list))!(k+1)) \<noteq> opid'" using Suc(4) by auto then have "atomic_flag_val (snd (snd (exe_list ! ((k+1) + 1)))) \<noteq> Some opid'" using atomic_flag_exe5[OF f2 f1] by auto then show ?case by auto qed lemma atom_load_executed_sub2: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "atomic_flag_val (snd (snd (last exe_list))) = Some opid'" and a3: "type_of_mem_op_block (pbm opid'') = ast_block" and a4: "atom_pair_id (pbm opid'') = Some opid'" and a5: "(opid' ;po^(proc_of_op opid' pbm) opid'')" and f0: "List.member (fst (last exe_list)) opid''" shows "axiom_loadop_violate opid' opid'' po (fst (last exe_list)) pbm" proof - from a1 a2 have f1: "List.member (fst (last exe_list)) opid' \<and> type_of_mem_op_block (pbm opid') = ald_block" using atom_load_executed_sub1 by auto then obtain i where f2: "i < (List.length exe_list - 1) \<and> (fst (List.last exe_list))!i = opid'" by (metis a1 in_set_conv_nth in_set_member valid_exe_xseq_sublist_length2) then have f3: "(po pbm opid' \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" using valid_exe_op_exe_pos f2 a1 by auto from f0 obtain j where f4: "j < (List.length exe_list - 1) \<and> (fst (List.last exe_list))!j = opid''" by (metis a1 in_set_conv_nth in_set_member valid_exe_xseq_sublist_length2) then have f5: "(po pbm opid'' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1)))))" using valid_exe_op_exe_pos f4 a1 by auto from a1 have f6: "non_repeat_list (fst (List.last exe_list))" using valid_mem_exe_seq_op_unique by auto from a1 a5 have f7: "opid' \<noteq> opid''" unfolding valid_mem_exe_seq_def using prog_order_op_unique by blast then have f8: "i \<noteq> j" using f2 f4 f6 unfolding non_repeat_list_def by auto then have "i < j \<or> i > j" by auto then show ?thesis proof (rule disjE) assume a7: "i > j" then have "\<nexists>k. k < length (fst (last exe_list)) \<and> fst (last exe_list) ! k = opid' \<and> k < j" using f6 f2 f4 unfolding non_repeat_list_def using a1 le0 valid_exe_xseq_sublist_length2 using nth_eq_iff_index_eq by (metis (mono_tags, hide_lams) not_less_iff_gr_or_eq) \<comment>\<open>by auto \<close> then have "\<nexists>k k'. k < length (fst (last exe_list)) \<and> k' < length (fst (last exe_list)) \<and> fst (last exe_list) ! k = opid' \<and> fst (last exe_list) ! k' = opid'' \<and> k < k'" using f6 f2 f4 unfolding non_repeat_list_def using nth_eq_iff_index_eq by fastforce \<comment>\<open> by auto \<close> then have "\<not> (list_before opid' (fst (last exe_list)) opid'')" unfolding list_before_def by blast then have "(opid' m<(fst (last exe_list)) opid'') = Some False" unfolding memory_order_before_def using f2 f0 f1 by auto then show ?thesis using f1 a5 unfolding axiom_loadop_violate_def by auto next assume a6: "i < j" have f9: "(snd (snd (exe_list ! (j + 1)))) = mem_commit opid'' (atomic_flag_mod None (proc_exe_to (proc_of_op opid'' pbm) po pbm (non_repeat_list_pos opid'' (po (proc_of_op opid'' pbm))) (snd (snd (exe_list ! j)))))" using mem_op_elim_atom_store_op[OF f5 a3] by auto then have f10: "atomic_flag_val (snd (snd (exe_list ! (j + 1)))) = None" using atomic_flag_mod_none mem_commit_atomic_flag by auto have f11: "\<forall>k. (k > j \<and> k < (length exe_list - 1)) \<longrightarrow> ((fst (List.last exe_list))!k) \<noteq> opid'" using f6 f2 a6 unfolding non_repeat_list_def using a1 not_less_iff_gr_or_eq valid_exe_xseq_sublist_length2 using nth_eq_iff_index_eq by metis \<comment>\<open>by auto\<close> have f12: "\<forall>(k::nat). (k > j \<and> k < (length exe_list - 1)) \<longrightarrow> atomic_flag_val (snd (snd (exe_list!(k+1)))) \<noteq> Some opid'" using atom_load_executed_sub2_sub1[OF a1] f4 f11 f10 by auto show ?thesis proof (cases "j = (length exe_list - 1) - 1") case True then have "atomic_flag_val (snd (snd (exe_list ! (length exe_list - 1)))) = None" using f10 by (metis (no_types, lifting) One_nat_def \<open>\<And>thesis. (\<And>i. i < length exe_list - 1 \<and> fst (last exe_list) ! i = opid' \<Longrightarrow> thesis) \<Longrightarrow> thesis\<close> a1 add.right_neutral add_Suc_right gr_implies_not0 list_exhaust_size_gt0 nth_Cons' nth_Cons_Suc valid_mem_exe_seq_def) then show ?thesis using a2 using a1 last_conv_nth valid_mem_exe_seq_def by fastforce next case False then have "j < (length exe_list - 1 - 1)" using f4 by auto then have "atomic_flag_val (snd (snd (exe_list!((length exe_list - 1 - 1)+1)))) \<noteq> Some opid'" using f12 by auto then have "atomic_flag_val (snd (snd (exe_list!(length exe_list - 1)))) \<noteq> Some opid'" by (metis (no_types, lifting) One_nat_def \<open>\<And>thesis. (\<And>i. i < length exe_list - 1 \<and> fst (last exe_list) ! i = opid' \<Longrightarrow> thesis) \<Longrightarrow> thesis\<close> a1 add.right_neutral add_Suc_right gr_implies_not0 list_exhaust_size_gt0 nth_Cons' nth_Cons_Suc valid_mem_exe_seq_def) then show ?thesis using a2 using a1 last_conv_nth valid_mem_exe_seq_def by fastforce qed qed qed lemma atom_load_executed0: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "atomic_flag_val (snd (snd (last exe_list))) = Some opid'" and a4: "\<exists>opid''. type_of_mem_op_block (pbm opid') = ald_block \<and> type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid' \<and> (opid' ;po^(proc_of_op opid' pbm) opid'') \<and> List.member (fst (last exe_list)) opid' \<and> (List.member (fst (last exe_list)) opid'')" shows "\<exists>opid''. axiom_loadop_violate opid' opid'' po (fst (last exe_list)) pbm" proof - from a4 obtain opid'' where f0: "type_of_mem_op_block (pbm opid') = ald_block \<and> type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid' \<and> (opid' ;po^(proc_of_op opid' pbm) opid'') \<and> List.member (fst (last exe_list)) opid' \<and> (List.member (fst (last exe_list)) opid'')" by auto then show ?thesis using atom_load_executed_sub2[OF a1 a2] by blast qed lemma atom_load_executed: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "atomic_flag_val (snd (snd (last exe_list))) = Some opid'" and a3: "\<not>(\<exists>opid''. axiom_loadop_violate opid' opid'' po (fst (last exe_list)) pbm)" shows "\<exists>opid''. type_of_mem_op_block (pbm opid') = ald_block \<and> type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid' \<and> (opid' ;po^(proc_of_op opid' pbm) opid'') \<and> List.member (fst (last exe_list)) opid' \<and> \<not> (List.member (fst (last exe_list)) opid'')" proof - have f0: "\<not>(\<exists>opid''. type_of_mem_op_block (pbm opid') = ald_block \<and> type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid' \<and> (opid' ;po^(proc_of_op opid' pbm) opid'') \<and> List.member (fst (last exe_list)) opid' \<and> (List.member (fst (last exe_list)) opid''))" using atom_load_executed0[OF a1 a2] using a3 by auto from a1 a2 have f1: "List.member (fst (last exe_list)) opid' \<and> type_of_mem_op_block (pbm opid') = ald_block" using atom_load_executed_sub1 by auto from a1 have f2: "(set (fst (last exe_list))) \<union> (fst (snd (last exe_list))) = (fst (snd (hd exe_list)))" using valid_exe_xseq_sublist_last by auto then have f3: "opid' \<in> (fst (snd (hd exe_list)))" using f1 in_set_member by fastforce then obtain p where f4: "(List.member (po p) opid')" using a1 unfolding valid_mem_exe_seq_def by auto then obtain opid'' where f5: "(opid' ;po^p opid'') \<and> type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid'" using a1 f1 unfolding valid_mem_exe_seq_def valid_program_def by meson then have f6: "p = proc_of_op opid' pbm" using a1 unfolding valid_mem_exe_seq_def valid_program_def by blast from f5 have f7: "type_of_mem_op_block (pbm opid'') = ast_block" by auto from f5 have f8: "atom_pair_id (pbm opid'') = Some opid'" by simp from f5 f6 have f9: "opid' ;po^(proc_of_op opid' pbm) opid''" by auto have f10: "\<not> (List.member (fst (last exe_list)) opid'')" using f1 f7 f8 f9 f0 by auto show ?thesis using f1 f7 f8 f9 f0 f10 by auto qed lemma store_op_contra_violate_sub2: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "atomic_flag_val (snd (snd (last exe_list))) = Some opid'" and a3: "type_of_mem_op_block (pbm opid) = st_block" and a6: "\<not> (List.member (fst (last exe_list)) opid)" and a7: "op_seq_final (((fst (last exe_list))@[opid])@remainder) po pbm" shows "\<exists>opid''. (axiom_atomicity_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_loadop_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm)" proof (cases "(\<exists>opid''. axiom_loadop_violate opid' opid'' po (fst (last exe_list)) pbm)") case True then obtain opid'' where f0_0: "axiom_loadop_violate opid' opid'' po (fst (last exe_list)) pbm" by auto have f0_1: "valid_program po pbm" using a1 unfolding valid_mem_exe_seq_def by auto have f0: "non_repeat_list (((fst (last exe_list))@[opid])@remainder)" using a7 unfolding op_seq_final_def by auto then have f1: "non_repeat_list ((fst (last exe_list))@[opid])" using non_repeat_list_sublist by blast show ?thesis using axiom_loadop_violate_persist[OF f0_1 f0_0 f1] by auto next case False obtain opid'' where f1: "type_of_mem_op_block (pbm opid') = ald_block \<and> type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid' \<and> (opid' ;po^(proc_of_op opid' pbm) opid'') \<and> List.member (fst (last exe_list)) opid' \<and> \<not>(List.member (fst (last exe_list)) opid'')" using atom_load_executed[OF a1 a2 False] by auto from a3 f1 have f2: "opid \<noteq> opid'" by auto from a3 f1 have f3: "opid \<noteq> opid''" by auto from f1 have f4: "List.member ((fst (last exe_list))@[opid]) opid'" by (metis UnCI in_set_member set_append) from f1 f3 have f5: "\<not>(List.member ((fst (last exe_list))@[opid]) opid'')" by (metis in_set_member insert_iff list.simps(15) rotate1.simps(2) set_rotate1) have f6: "List.member ((fst (last exe_list))@[opid]) opid" using in_set_member by fastforce then have f7: "list_before opid' ((fst (last exe_list))@[opid]) opid" using f1 unfolding list_before_def by (metis f2 f4 in_set_member length_append_singleton length_pos_if_in_set less_Suc_eq less_imp_le list_mem_range nth_append_length) have f8: "non_repeat_list (fst (last exe_list))" using valid_mem_exe_seq_op_unique a1 by auto have f9: "non_repeat_list ((fst (last exe_list))@[opid])" using non_repeat_list_extend[OF f8 a6] by auto have f10: "\<not>(list_before opid ((fst (last exe_list))@[opid]) opid')" using non_repeat_list_before[OF f9 f7] by auto then have f11: "(opid m<(fst (last exe_list) @ [opid]) opid') = Some False" unfolding memory_order_before_def using f6 f4 by auto from f6 f5 have f12: "(opid'' m<(fst (last exe_list) @ [opid]) opid) = Some False" unfolding memory_order_before_def by auto then show ?thesis unfolding axiom_atomicity_violate_def using f1 a3 f6 f3 f11 f12 by auto qed lemma store_op_contra_violate_sub1: assumes a1: "type_of_mem_op_block (pbm opid) = st_block" and a2: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m xseq s \<rightarrow> xseq' s'))" and a3: "valid_program po pbm" and a4: "atomic_flag_val s = None" shows "\<exists>opid'. (axiom_loadop_violate opid' opid po (xseq@[opid]) pbm) \<or> (axiom_storestore_violate opid' opid po (xseq@[opid]) pbm)" proof - from a1 a2 have f1: "atomic_flag_val s \<noteq> None \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member xseq opid'))" using store_op_contra by auto then obtain opid' where f2: "(opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member xseq opid')" using a4 by auto then have f3: "opid \<noteq> opid'" using a3 prog_order_op_unique by blast then have f4: "\<not> (List.member (xseq@[opid]) opid')" using f2 by (metis in_set_member rotate1.simps(2) set_ConsD set_rotate1) have f5: "List.member (xseq@[opid]) opid" using in_set_member by force then have f6: "(opid' m<(xseq@[opid]) opid) = Some False" using f4 unfolding memory_order_before_def by auto from a3 f2 have f7: "proc_of_op opid pbm = proc_of_op opid' pbm" unfolding valid_program_def by fastforce from f2 have f8: "type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block} \<or> type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}" by auto then show ?thesis proof (rule disjE) assume a5: "type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block}" then have "type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block} \<and> (opid' ;po^(proc_of_op opid' pbm) opid) \<and> ((opid' m<(xseq @ [opid]) opid) = Some False)" using f2 f6 f7 by auto then have "\<exists>opid'. (axiom_loadop_violate opid' opid po (xseq@[opid]) pbm)" unfolding axiom_loadop_violate_def by auto then show ?thesis by auto next assume a6: "type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}" then have "(type_of_mem_op_block (pbm opid) \<in> {st_block, ast_block}) \<and> (type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}) \<and> (opid' ;po^(proc_of_op opid' pbm) opid) \<and> (opid' m<(xseq @ [opid]) opid) = Some False" using f2 f6 f7 a1 by auto then have "\<exists>opid'. (axiom_storestore_violate opid' opid po (xseq@[opid]) pbm)" unfolding axiom_storestore_violate_def by auto then show ?thesis by auto qed qed lemma store_op_contra_violate: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "type_of_mem_op_block (pbm opid) = st_block" and a3: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> xseq' s'))" and a5: "\<not> (List.member (fst (last exe_list)) opid)" and a6: "op_seq_final (((fst (last exe_list))@[opid])@remainder) po pbm" shows "\<exists>opid' opid''. (axiom_loadop_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_storestore_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_atomicity_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm)" proof - from a2 a3 have f1: "atomic_flag_val (snd (snd (last exe_list))) \<noteq> None \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member (fst (last exe_list)) opid'))" using store_op_contra by auto then show ?thesis proof (cases "atomic_flag_val (snd (snd (last exe_list))) \<noteq> None") case True then obtain opid' where f2: "atomic_flag_val (snd (snd (last exe_list))) = Some opid'" by auto show ?thesis using store_op_contra_violate_sub2[OF a1 f2 a2 a5 a6] by auto next case False then have f5: "atomic_flag_val (snd (snd (last exe_list))) = None" by auto from a1 have f4: "valid_program po pbm" unfolding valid_mem_exe_seq_def by auto show ?thesis using store_op_contra_violate_sub1[OF a2 a3 f4 f5] by auto qed qed lemma atom_load_op_contra_violate_sub1: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "type_of_mem_op_block (pbm opid) = ald_block" and a3: "atomic_flag_val (snd (snd (last exe_list))) = Some opid'" and a5: "List.member (po (proc_of_op opid pbm)) opid" and a6: "\<not> (List.member (fst (last exe_list)) opid)" and a7: "op_seq_final (((fst (last exe_list))@[opid])@remainder) po pbm" shows "\<exists>opid' opid''. (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_loadop_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm)" proof (cases "(\<exists>opid''. axiom_loadop_violate opid' opid'' po (fst (last exe_list)) pbm)") case True then obtain opid'' where f0_0: "axiom_loadop_violate opid' opid'' po (fst (last exe_list)) pbm" by auto have f0_1: "valid_program po pbm" using a1 unfolding valid_mem_exe_seq_def by auto have f0: "non_repeat_list (((fst (last exe_list))@[opid])@remainder)" using a7 unfolding op_seq_final_def by auto then have f1: "non_repeat_list ((fst (last exe_list))@[opid])" using non_repeat_list_sublist by blast show ?thesis using axiom_loadop_violate_persist[OF f0_1 f0_0 f1] by auto next case False then obtain opid'_st where f1: "type_of_mem_op_block (pbm opid') = ald_block \<and> type_of_mem_op_block (pbm opid'_st) = ast_block \<and> atom_pair_id (pbm opid'_st) = Some opid' \<and> (opid' ;po^(proc_of_op opid' pbm) opid'_st) \<and> List.member (fst (last exe_list)) opid' \<and> \<not>(List.member (fst (last exe_list)) opid'_st)" using atom_load_executed[OF a1 a3] by auto from a1 a2 a5 obtain opid_st where f2: "(opid ;po^(proc_of_op opid pbm) opid_st) \<and> type_of_mem_op_block (pbm opid_st) = ast_block \<and> atom_pair_id (pbm opid_st) = Some opid" unfolding valid_mem_exe_seq_def valid_program_def by blast from a6 f1 have f3: "opid \<noteq> opid'" by auto from a2 f1 have f4: "opid \<noteq> opid'_st" by auto from f1 f2 have f5: "opid_st \<noteq> opid'" by auto from f1 f2 f3 have f6: "opid_st \<noteq> opid'_st" by auto from a2 f2 have f7: "opid \<noteq> opid_st" by auto have f8: "non_repeat_list (fst (last exe_list))" using valid_mem_exe_seq_op_unique[OF a1] by auto then have f9: "non_repeat_list ((fst (last exe_list))@[opid])" using a6 non_repeat_list_extend by fastforce from f2 have "List.member (po (proc_of_op opid pbm)) opid_st" unfolding program_order_before_def list_before_def by (meson list_mem_range_rev) then have f91: "List.member (((fst (last exe_list))@[opid])@remainder) opid_st" using f2 a7 unfolding op_seq_final_def by auto from f1 have "List.member (po (proc_of_op opid' pbm)) opid'_st" unfolding program_order_before_def list_before_def by (meson list_mem_range_rev) then have f92: "List.member (((fst (last exe_list))@[opid])@remainder) opid'_st" using f2 a7 unfolding op_seq_final_def by auto show ?thesis proof (cases "(List.member (fst (last exe_list)) opid_st)") case True then have f10: "(opid m<(fst (last exe_list)) opid_st) = Some False" unfolding memory_order_before_def using a6 by auto then have "(atom_pair_id (pbm opid_st) = Some opid) \<and> (type_of_mem_op_block (pbm opid) = ald_block) \<and> (type_of_mem_op_block (pbm opid_st) = ast_block) \<and> (opid ;po^(proc_of_op opid pbm) opid_st) \<and> ((opid m<(fst (last exe_list)) opid_st) = Some False)" using f2 a2 by auto then have "axiom_atomicity_violate opid opid_st po (fst (last exe_list)) pbm" unfolding axiom_atomicity_violate_def by auto then show ?thesis using axiom_atomicity_violate_persist a1 a7 unfolding valid_mem_exe_seq_def op_seq_final_def by (metis append.assoc) next case False then have f11: "list_before opid' (((fst (last exe_list))@[opid])@remainder) opid_st" using f1 f91 list_before_extend2 by auto then have f12: "\<not>(list_before opid_st (((fst (last exe_list))@[opid])@remainder) opid')" using a7 unfolding op_seq_final_def by (simp add: non_repeat_list_before) from f1 f4 have f13: "\<not> List.member ((fst (last exe_list))@[opid]) opid'_st" by (metis in_set_member insert_iff list.simps(15) rotate1.simps(2) set_rotate1) have f14: "List.member ((fst (last exe_list))@[opid]) opid" using in_set_member by fastforce have f15: "list_before opid (((fst (last exe_list))@[opid])@remainder) opid'_st" using list_before_extend2[OF f14 f13 f92] by auto then have f16: "\<not>(list_before opid'_st (((fst (last exe_list))@[opid])@remainder) opid)" using a7 unfolding op_seq_final_def by (simp add: non_repeat_list_before) have f16_1: "non_repeat_list (((fst (last exe_list))@[opid])@remainder)" using a7 unfolding op_seq_final_def by auto have f17: "list_before opid_st (((fst (last exe_list))@[opid])@remainder) opid'_st \<or> list_before opid'_st (((fst (last exe_list))@[opid])@remainder) opid_st" using list_elements_before[OF f91 f92 f6] by auto then show ?thesis proof (rule disjE) assume f18: "list_before opid_st (((fst (last exe_list))@[opid])@remainder) opid'_st" have f181: "\<not>(list_before opid'_st (((fst (last exe_list))@[opid])@remainder) opid_st)" using non_repeat_list_before[OF f16_1 f18] by auto have f182: "List.member ((fst (last exe_list) @ [opid]) @ remainder) opid'" using f1 by (metis UnCI in_set_member set_append) from f91 f182 f12 have f183: "(opid_st m<(((fst (last exe_list))@[opid])@remainder) opid') = Some False" unfolding memory_order_before_def by auto from f91 f92 f181 have f184: "(opid'_st m<(((fst (last exe_list))@[opid])@remainder) opid_st) = Some False" unfolding memory_order_before_def by auto then show ?thesis unfolding axiom_atomicity_violate_def using f1 f2 f91 f6 f184 f183 by auto next assume f19: "list_before opid'_st (((fst (last exe_list))@[opid])@remainder) opid_st" have f191: "\<not>(list_before opid_st (((fst (last exe_list))@[opid])@remainder) opid'_st)" using non_repeat_list_before[OF f16_1 f19] by auto have f192: "List.member ((fst (last exe_list) @ [opid]) @ remainder) opid" using f14 by (metis UnCI in_set_member set_append) from f92 f192 f16 have f193: "(opid'_st m<(((fst (last exe_list))@[opid])@remainder) opid) = Some False" unfolding memory_order_before_def by auto from f91 f92 f191 have f194: "(opid_st m<(((fst (last exe_list))@[opid])@remainder) opid'_st) = Some False" unfolding memory_order_before_def by auto then show ?thesis unfolding axiom_atomicity_violate_def using f2 a2 f1 f92 f6 f193 f194 by auto qed qed qed lemma atom_load_op_contra_violate_sub2: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "type_of_mem_op_block (pbm opid) = ald_block" and a3: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> xseq' s'))" and a4: "(opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member (fst (last exe_list)) opid')" and a6: "op_seq_final (((fst (last exe_list))@[opid])@remainder) po pbm" shows "\<exists>opid' opid''. (axiom_loadop_violate opid' opid po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_storestore_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" proof - have a5: "List.member (po (proc_of_op opid pbm)) opid" using a4 program_order_before_def list_before_def by (metis list_mem_range_rev) have f0: "opid \<noteq> opid'" using a4 a1 prog_order_op_unique unfolding valid_mem_exe_seq_def by blast then have f01: "\<not> (List.member ((fst (last exe_list))@[opid]) opid')" using a4 by (metis in_set_member insert_iff list.simps(15) rotate1.simps(2) set_rotate1) have f02: "List.member ((fst (last exe_list))@[opid]) opid" using in_set_member by force then have f03: "(opid' m<((fst (last exe_list))@[opid]) opid) = Some False" using f01 unfolding memory_order_before_def by auto from a1 a4 have f04: "proc_of_op opid pbm = proc_of_op opid' pbm" unfolding valid_mem_exe_seq_def valid_program_def by blast from a6 have f05: "non_repeat_list (((fst (last exe_list))@[opid])@remainder)" unfolding op_seq_final_def by auto from a4 have f1: "type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block} \<or> type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}" by auto then show ?thesis proof (rule disjE) assume f2: "type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block}" then show ?thesis unfolding axiom_loadop_violate_def using a4 f03 f04 by auto next assume f3: "type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}" from a1 have f30: "non_repeat_list (po (proc_of_op opid pbm))" unfolding valid_mem_exe_seq_def valid_program_def by auto from a1 a2 a5 obtain opid_st where f31: "(opid ;po^(proc_of_op opid pbm) opid_st) \<and> type_of_mem_op_block (pbm opid_st) = ast_block \<and> atom_pair_id (pbm opid_st) = Some opid" unfolding valid_mem_exe_seq_def valid_program_def by blast then have f32: "opid' ;po^(proc_of_op opid pbm) opid_st" using a4 f30 prog_order_before_trans by blast from a1 a4 have f33: "(proc_of_op opid pbm) = (proc_of_op opid' pbm)" unfolding valid_mem_exe_seq_def valid_program_def by blast from a4 have f34: "List.member (po (proc_of_op opid pbm)) opid'" unfolding program_order_before_def list_before_def by (meson list_mem_range_rev) then have f35: "List.member (((fst (last exe_list))@[opid])@remainder) opid'" using a4 a6 unfolding op_seq_final_def by auto from f32 have "List.member (po (proc_of_op opid pbm)) opid_st" unfolding program_order_before_def list_before_def by (meson list_mem_range_rev) then have f36: "List.member (((fst (last exe_list))@[opid])@remainder) opid_st" using a4 a6 unfolding op_seq_final_def by auto from f35 obtain i where f37: "i < length (((fst (last exe_list))@[opid])@remainder) \<and> ((((fst (last exe_list))@[opid])@remainder)!i) = opid'" by (meson in_set_conv_nth in_set_member) from f36 obtain j where f38: "j < length (((fst (last exe_list))@[opid])@remainder) \<and> ((((fst (last exe_list))@[opid])@remainder)!j) = opid_st" by (meson in_set_conv_nth in_set_member) from f32 a1 have f39: "opid' \<noteq> opid_st" unfolding valid_mem_exe_seq_def using prog_order_op_unique by blast then have "i \<noteq> j" using f37 f38 by auto then have "i < j \<or> i > j" by auto then show ?thesis proof (rule disjE) assume f41: "i < j" then have f42: "list_before opid' (((fst (last exe_list))@[opid])@remainder) opid_st" using f37 f38 unfolding list_before_def by blast have f43: "\<not>(list_before opid_st (((fst (last exe_list))@[opid])@remainder) opid')" using non_repeat_list_before[OF f05 f42] by auto then have f44: "(opid_st m<(((fst (last exe_list))@[opid])@remainder) opid') = Some False" unfolding memory_order_before_def using f35 f36 by auto then show ?thesis unfolding axiom_atomicity_violate_def using f31 a2 f3 f35 f39 f03 by (metis f0 f05 mem_order_before_false_persist) next assume f51: "i > j" then have f52: "list_before opid_st (((fst (last exe_list))@[opid])@remainder) opid'" using f37 f38 unfolding list_before_def by blast then have f53: "\<not>(list_before opid' (((fst (last exe_list))@[opid])@remainder) opid_st)" using non_repeat_list_before[OF f05 f52] by auto then have f44: "(opid' m<(((fst (last exe_list))@[opid])@remainder) opid_st) = Some False" unfolding memory_order_before_def using f35 f36 by auto then show ?thesis unfolding axiom_storestore_violate_def using f31 f3 f32 f33 by auto qed qed qed lemma atom_load_op_contra_violate: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "type_of_mem_op_block (pbm opid) = ald_block" and a3: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> xseq' s'))" and a5: "List.member (po (proc_of_op opid pbm)) opid" and a6: "\<not> (List.member (fst (last exe_list)) opid)" and a7: "op_seq_final (((fst (last exe_list))@[opid])@remainder) po pbm" shows "\<exists>opid' opid''. (axiom_loadop_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_storestore_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" proof - from a2 a3 have f1: "atomic_flag_val (snd (snd (last exe_list))) \<noteq> None \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member (fst (last exe_list)) opid'))" using atom_load_op_contra by auto then show ?thesis proof (rule disjE) assume f2: "atomic_flag_val (snd (snd (last exe_list))) \<noteq> None" then obtain opid' where f21: "atomic_flag_val (snd (snd (last exe_list))) = Some opid'" by auto show ?thesis using atom_load_op_contra_violate_sub1[OF a1 a2 f21 a5 a6 a7] by auto next assume f3: "(\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member (fst (last exe_list)) opid'))" then obtain opid' where f31: "(opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member (fst (last exe_list)) opid')" by auto show ?thesis using atom_load_op_contra_violate_sub2[OF a1 a2 a3 f31 a7] by auto qed qed lemma atom_exe_valid_type2: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "i < (List.length exe_list - 1)" and a3: "(po pbm opid \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" and a5: "(atom_pair_id (pbm opid') = Some opid) \<and> (type_of_mem_op_block (pbm opid) = ald_block) \<and> (type_of_mem_op_block (pbm opid') = ast_block)" and a6: "(i < j \<and> j < (List.length exe_list - 1) \<and> (po pbm opid'' \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))))" and a7: "atomic_flag_val (snd (snd (exe_list!(i+1)))) = Some opid" and a8: "opid \<noteq> opid'' \<and> opid'' \<noteq> opid'" and a9: "\<not>(List.member (fst (last exe_list)) opid')" shows "(type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = o_block) \<and> atomic_flag_val (snd (snd (exe_list!j))) = Some opid" proof (insert assms, induction "j - i" arbitrary: opid'' j) case 0 then show ?case by auto next case (Suc x) then show ?case proof (cases "j - 1 = i") case True then have "j = i + 1" using Suc.prems(5) by linarith then have f1: "atomic_flag_val (snd (snd (exe_list!j))) = Some opid" using a7 by auto then have f2: "type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = o_block \<or> (type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid)" using Suc(7) atomic_flag_exe1 by blast from a1 Suc(9) Suc(6) have "atom_pair_id (pbm opid'') \<noteq> Some opid" using ast_op_unique by auto then have "type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = o_block" using f2 by auto then show ?thesis using f1 by auto next case False then have f3: "j-1 > i" using Suc(7) by auto then have f003: "j > 0" by auto from Suc(2) have f03: "x = (j-1) - i" by auto from Suc(3) Suc(7) have f4: "j-1 < length exe_list - 1" by auto then obtain opid''' where "(po pbm opid''' \<turnstile>m (fst (exe_list ! (j-1))) (snd (snd (exe_list ! (j-1)))) \<rightarrow> (fst (exe_list ! j)) (snd (snd (exe_list ! j))))" using a1 unfolding valid_mem_exe_seq_def mem_state_trans_def by (metis (no_types, lifting) add.commute add_diff_inverse_nat f3 gr_implies_not_zero nat_diff_split_asm) then have f05: "(po pbm opid''' \<turnstile>m (fst (exe_list ! (j-1))) (snd (snd (exe_list ! (j-1)))) \<rightarrow> (fst (exe_list ! ((j-1)+1))) (snd (snd (exe_list ! ((j-1)+1)))))" using f003 by auto then have f5: "i < j-1 \<and> j-1 < (List.length exe_list - 1) \<and> (po pbm opid''' \<turnstile>m (fst (exe_list ! (j-1))) (snd (snd (exe_list ! (j-1)))) \<rightarrow> (fst (exe_list ! ((j-1)+1))) (snd (snd (exe_list ! ((j-1)+1)))))" using f3 Suc(7) f003 by auto from a1 f4 Suc(4) f5 Suc(5) have f6: "opid''' \<noteq> opid" using valid_exe_op_exe_pos_unique False by (metis One_nat_def Suc_eq_plus1) from f5 have f5_1: "opid''' = ((fst (List.last exe_list))!(j-1))" using a1 valid_exe_op_exe_pos3 by blast then have f5_2: "List.member (fst (List.last exe_list)) opid'''" using f5 a1 in_set_member valid_exe_xseq_sublist_length2 by fastforce then have f7: "opid''' \<noteq> opid'" using a9 by auto from f6 f7 have f8: "opid \<noteq> opid''' \<and> opid''' \<noteq> opid'" by auto have f9: "(type_of_mem_op_block (pbm opid''') = ld_block \<or> type_of_mem_op_block (pbm opid''') = o_block) \<and> atomic_flag_val (snd (snd (exe_list ! (j-1)))) = Some opid" using Suc(1)[OF f03 a1 Suc(4) Suc(5) Suc(6) f5 Suc(8) f8 a9] by auto then have "atomic_flag_val (snd (snd (exe_list ! ((j-1)+1)))) = Some opid" using atomic_flag_exe2 f05 by auto then have f10: "atomic_flag_val (snd (snd (exe_list ! j))) = Some opid" using f003 by auto from Suc(7) have f11: "po pbm opid'' \<turnstile>m (fst (exe_list ! j)) (snd (snd (exe_list ! j))) \<rightarrow> (fst (exe_list ! (j + 1))) (snd (snd (exe_list ! (j + 1))))" by auto have f12: "type_of_mem_op_block (pbm opid'') = ld_block \<or> type_of_mem_op_block (pbm opid'') = o_block \<or> (type_of_mem_op_block (pbm opid'') = ast_block \<and> atom_pair_id (pbm opid'') = Some opid)" using atomic_flag_exe1[OF f11 f10] by auto have f13: "atom_pair_id (pbm opid'') \<noteq> Some opid" using ast_op_unique[OF a1] Suc(9) Suc(6) by auto from f12 f13 show ?thesis by (simp add: f10) qed qed lemma atom_store_op_contra_violate_sub1: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "type_of_mem_op_block (pbm opid) = ast_block" and a3: "atom_pair_id (pbm opid) = Some opid_ald" and a4: "List.member (fst (last exe_list)) opid_ald" and a5: "\<not>(List.member (fst (last exe_list)) opid)" and a6: "List.member (po (proc_of_op opid pbm)) opid" shows "(atomic_flag_val (snd (snd (last exe_list)))) = atom_pair_id (pbm opid)" proof - from a4 obtain i where f1: "i < length (fst (last exe_list)) \<and> (fst (last exe_list))!i = opid_ald" by (meson list_mem_range) then have f2: "i < (List.length exe_list) - 1" using a1 valid_exe_xseq_sublist_length2 by auto then have f3: "(po pbm opid_ald \<turnstile>m (fst (exe_list!i)) (snd (snd (exe_list!i))) \<rightarrow> (fst (exe_list!(i+1))) (snd (snd (exe_list!(i+1)))))" using a1 f1 valid_exe_op_exe_pos by auto from a1 a2 a6 have f4: "(\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> type_of_mem_op_block (pbm opid') = ald_block \<and> atom_pair_id (pbm opid) = Some opid')" unfolding valid_mem_exe_seq_def valid_program_def by blast then have f5: "(opid_ald ;po^(proc_of_op opid pbm) opid) \<and> type_of_mem_op_block (pbm opid_ald) = ald_block" using a3 by auto from a2 a3 f1 f5 have f1_1: "(atom_pair_id (pbm opid) = Some opid_ald) \<and> (type_of_mem_op_block (pbm opid_ald) = ald_block) \<and> (type_of_mem_op_block (pbm opid) = ast_block)" by auto have f6: "atomic_flag_val (snd (snd (exe_list!i))) = None" using mem_op_elim_atom_load_op[OF f3] f5 by blast have f7: "atomic_flag_val (snd (snd (exe_list!(i+1)))) = Some opid_ald" using atomic_flag_exe_ald[OF f3 f6] f5 by auto show ?thesis proof (cases "i = (List.length exe_list - 2)") case True then have "atomic_flag_val (snd (snd (exe_list!((List.length exe_list - 2)+1)))) = Some opid_ald" using f7 by auto then have "atomic_flag_val (snd (snd (exe_list!(List.length exe_list - 1)))) = Some opid_ald" by (metis Nat.add_0_right One_nat_def Suc_diff_Suc \<open>\<And>thesis. (\<And>i. i < length (fst (last exe_list)) \<and> fst (last exe_list) ! i = opid_ald \<Longrightarrow> thesis) \<Longrightarrow> thesis\<close> a1 add_Suc_right gr_implies_not_zero length_0_conv length_greater_0_conv numeral_2_eq_2 valid_exe_xseq_sublist_length2 zero_less_diff) then show ?thesis using a3 using a1 last_conv_nth valid_mem_exe_seq_def by fastforce next case False then have f2_0: "i < length exe_list - 2" using f2 by auto define j where "j \<equiv> length exe_list - 2" then have f8: "j < (List.length exe_list - 1)" using \<open>i < length exe_list - 2\<close> by linarith then have f8_1: "j < length (fst (last exe_list))" using a1 valid_exe_xseq_sublist_length2 by auto have f8_2: "j = length (fst (last exe_list)) - 1" using j_def valid_exe_xseq_sublist_length2[OF a1] by auto have f9: "(po pbm ((fst (List.last exe_list))!j) \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1)))))" using valid_exe_op_exe_pos2[OF a1 f8] by auto define opid_j where "opid_j \<equiv> ((fst (List.last exe_list))!j)" have f10: "non_repeat_list (fst (List.last exe_list))" using valid_mem_exe_seq_op_unique[OF a1] by auto then have f11: "opid_ald \<noteq> opid_j" using f1 opid_j_def f8_1 False j_def unfolding non_repeat_list_def using nth_eq_iff_index_eq by blast have f12: "List.member (fst (List.last exe_list)) opid_j" using opid_j_def j_def using f8_1 in_set_member by fastforce then have f13: "opid_j \<noteq> opid" using a5 by auto from f2_0 j_def f8 f9 opid_j_def have f13_1: "(i < j \<and> j < (List.length exe_list - 1) \<and> (po pbm opid_j \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1))))))" by auto from f11 f13 have f13_2: "opid_ald \<noteq> opid_j \<and> opid_j \<noteq> opid" by auto from f13_1 have f13_3: "(po pbm opid_j \<turnstile>m (fst (exe_list!j)) (snd (snd (exe_list!j))) \<rightarrow> (fst (exe_list!(j+1))) (snd (snd (exe_list!(j+1)))))" by auto have f14: "atomic_flag_val (snd (snd (exe_list!j))) = Some opid_ald" using atom_exe_valid_type2[OF a1 f2 f3 f1_1 f13_1 f7 f13_2 a5] by auto have f15: "type_of_mem_op_block (pbm opid_j) = ld_block \<or> type_of_mem_op_block (pbm opid_j) = o_block \<or> (type_of_mem_op_block (pbm opid_j) = ast_block \<and> atom_pair_id (pbm opid_j) = Some opid_ald)" using atomic_flag_exe1[OF f13_3 f14] by auto from a1 f13 a3 have "(atom_pair_id (pbm opid_j) \<noteq> Some opid_ald)" unfolding valid_mem_exe_seq_def valid_program_def by blast then have f15_1: "type_of_mem_op_block (pbm opid_j) = ld_block \<or> type_of_mem_op_block (pbm opid_j) = o_block" using f15 by auto have "atomic_flag_val (snd (snd (exe_list!(j+1)))) = Some opid_ald" using atomic_flag_exe2[OF f13_3 f14 f15_1] by auto then have "atomic_flag_val (snd (snd (exe_list!(length exe_list - 1)))) = Some opid_ald" using j_def by (metis One_nat_def Suc_diff_Suc \<open>\<And>thesis. (\<And>i. i < length (fst (last exe_list)) \<and> fst (last exe_list) ! i = opid_ald \<Longrightarrow> thesis) \<Longrightarrow> thesis\<close> a1 add.right_neutral add_Suc_right f8_2 gr_implies_not0 length_0_conv length_greater_0_conv minus_nat.diff_0 valid_exe_xseq_sublist_length2) then show ?thesis by (metis (full_types) a3 f2_0 last_conv_nth list.size(3) not_less_zero zero_diff) qed qed lemma atom_store_op_contra_violate: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "type_of_mem_op_block (pbm opid) = ast_block" and a3: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> xseq' s'))" and a5: "List.member (po (proc_of_op opid pbm)) opid" and a6: "\<not> (List.member (fst (last exe_list)) opid)" and a7: "op_seq_final (((fst (last exe_list))@[opid])@remainder) po pbm" shows "\<exists>opid' opid''. (axiom_loadop_violate opid' opid po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_storestore_violate opid' opid po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" proof - from a1 have f0: "valid_program po pbm" unfolding valid_mem_exe_seq_def by auto from a7 have f0_1: "non_repeat_list (((fst (last exe_list))@[opid])@remainder)" unfolding op_seq_final_def by auto from a2 a3 have f1: "(atomic_flag_val (snd (snd (last exe_list)))) = None \<or> (atomic_flag_val (snd (snd (last exe_list)))) \<noteq> atom_pair_id (pbm opid) \<or> (\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member (fst (last exe_list)) opid'))" using atom_store_op_contra by auto from a1 a2 a5 have f2: "(\<exists>opid'. (opid' ;po^(proc_of_op opid pbm) opid) \<and> type_of_mem_op_block (pbm opid') = ald_block \<and> atom_pair_id (pbm opid) = Some opid')" unfolding valid_mem_exe_seq_def valid_program_def by blast then obtain opid_ald where f3: "(opid_ald ;po^(proc_of_op opid pbm) opid) \<and> type_of_mem_op_block (pbm opid_ald) = ald_block \<and> atom_pair_id (pbm opid) = Some opid_ald" using a3 by auto from f3 have f3_0: "(opid_ald ;po^(proc_of_op opid_ald pbm) opid)" using a1 unfolding valid_mem_exe_seq_def valid_program_def by metis from f3 have f3_1: "atom_pair_id (pbm opid) = Some opid_ald" by auto have f3_2: "opid_ald \<noteq> opid" using f3 a2 by auto have f5_2: "List.member ((fst (last exe_list))@[opid]) opid" using in_set_member by fastforce show ?thesis proof (cases "List.member (fst (last exe_list)) opid_ald") case True have f4_1: "(atomic_flag_val (snd (snd (last exe_list)))) = atom_pair_id (pbm opid)" using atom_store_op_contra_violate_sub1[OF a1 a2 f3_1 True a6 a5] by auto then obtain opid' where f1_1: "(opid' ;po^(proc_of_op opid pbm) opid) \<and> (type_of_mem_op_block (pbm opid') = ld_block \<or> type_of_mem_op_block (pbm opid') = ald_block \<or> type_of_mem_op_block (pbm opid') = st_block \<or> type_of_mem_op_block (pbm opid') = ast_block) \<and> \<not> (List.member (fst (last exe_list)) opid')" using f1 f3 by auto then have f1_2: "opid' \<noteq> opid" using prog_order_op_unique[OF f0] using f1_1 by auto then have f1_3: "\<not> List.member ((fst (last exe_list))@[opid]) opid'" using f1_1 by (metis (mono_tags, hide_lams) in_set_member insert_iff list.simps(15) rotate1.simps(2) set_rotate1) then have f1_4: "(opid' m<((fst (last exe_list))@[opid]) opid) = Some False" using f5_2 unfolding memory_order_before_def by auto from f1_1 have f1_5: "(opid' ;po^(proc_of_op opid' pbm) opid)" using f0 unfolding valid_program_def by metis from f1_1 have f1_6: "type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block} \<or> type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}" by auto then show ?thesis proof (rule disjE) assume a8: "type_of_mem_op_block (pbm opid') \<in> {ld_block, ald_block}" then have f8_1: "axiom_loadop_violate opid' opid po ((fst (last exe_list))@[opid]) pbm" unfolding axiom_loadop_violate_def using f1_4 f1_5 by auto then show ?thesis by auto next assume a9: "type_of_mem_op_block (pbm opid') \<in> {st_block, ast_block}" then have f9_1: "axiom_storestore_violate opid' opid po ((fst (last exe_list))@[opid]) pbm" unfolding axiom_storestore_violate_def using f1_4 f1_5 a2 by auto then show ?thesis by auto qed next case False then have f5_1: "\<not> List.member ((fst (last exe_list))@[opid]) opid_ald" using f3_2 by (metis in_set_member rotate1.simps(2) set_ConsD set_rotate1) from f5_1 f5_2 have f5_3: "(opid_ald m<((fst (last exe_list))@[opid]) opid) = Some False" unfolding memory_order_before_def by auto then have f5_4: "axiom_atomicity_violate opid_ald opid po ((fst (last exe_list))@[opid]) pbm" unfolding axiom_atomicity_violate_def using f3 a2 f3_0 by auto show ?thesis using axiom_atomicity_violate_persist[OF f0 f5_4 f0_1] by auto qed qed text {* The lemma below combines the *_contra_violate lemmas of all above operations. *} lemma mem_op_contra_violate: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "op_seq_final (((fst (last exe_list))@[opid])@remainder) po pbm" and a3: "\<not> (\<exists>xseq' s'. (po pbm opid \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> xseq' s'))" shows "\<exists>opid' opid''. (axiom_loadop_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_storestore_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" proof - have f0: "valid_program po pbm" using a2 unfolding op_seq_final_def by auto have f1: "List.member (((fst (last exe_list))@[opid])@remainder) opid" using in_set_member by fastforce then have f2: "\<exists>p. List.member (po p) opid" using a2 unfolding op_seq_final_def by auto then have f2_1: "List.member (po (proc_of_op opid pbm)) opid" using f0 unfolding valid_program_def by blast then have f3: "type_of_mem_op_block (pbm opid) \<in> {ld_block, st_block, ald_block, ast_block}" using a2 unfolding op_seq_final_def by auto have f4: "non_repeat_list ((fst (last exe_list) @ [opid]) @ remainder)" using a2 unfolding op_seq_final_def by auto then have f4_1: "non_repeat_list (fst (last exe_list) @ [opid])" using non_repeat_list_sublist by blast have af5_4: "(fst (last exe_list) @ [opid])!(length (fst (last exe_list) @ [opid]) - 1) = opid" by simp then have af5_5: "(fst (last exe_list) @ [opid])!(length (fst (last exe_list))) = opid" by simp have f5: "\<not>(List.member (fst (last exe_list)) opid)" proof (rule ccontr) assume af5: "\<not>\<not>(List.member (fst (last exe_list)) opid)" then have af5_1: "List.member (fst (last exe_list)) opid" by auto then obtain i where af5_2: "i < length (fst (last exe_list)) \<and> (fst (last exe_list))!i = opid" by (meson in_set_conv_nth in_set_member) then have af5_3: "i < length (fst (last exe_list)) \<and> (fst (last exe_list) @ [opid])!i = opid" by (simp add: nth_append) show False using f4_1 af5_3 af5_5 unfolding non_repeat_list_def using nth_eq_iff_index_eq by (metis (mono_tags, hide_lams) le0 length_append_singleton less_Suc_eq less_irrefl) qed then show ?thesis proof (cases "type_of_mem_op_block (pbm opid)") case ld_block obtain opid' where f6_1: "axiom_loadop_violate opid' opid po ((fst (last exe_list))@[opid]) pbm" using load_op_contra_violate[OF a1 ld_block a3] by auto have "axiom_loadop_violate opid' opid po (((fst (last exe_list))@[opid])@remainder) pbm" using axiom_loadop_violate_persist[OF f0 f6_1 f4] by auto then show ?thesis by auto next case st_block obtain opid' opid'' where f7_1: "(axiom_loadop_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_storestore_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_atomicity_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm)" using store_op_contra_violate[OF a1 st_block a3 f5 a2] by auto then have f7_2: "(axiom_loadop_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_storestore_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" proof (rule disjE) assume af7_1: "axiom_loadop_violate opid' opid'' po (fst (last exe_list) @ [opid]) pbm" have "axiom_loadop_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm" using axiom_loadop_violate_persist[OF f0 af7_1 f4] by auto then show ?thesis by auto next assume "axiom_storestore_violate opid' opid'' po (fst (last exe_list) @ [opid]) pbm \<or> axiom_atomicity_violate opid' opid'' po (fst (last exe_list) @ [opid]) pbm" then show ?thesis proof (rule disjE) assume af7_2: "axiom_storestore_violate opid' opid'' po (fst (last exe_list) @ [opid]) pbm" have "axiom_storestore_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm" using axiom_storestore_violate_persist[OF f0 af7_2 f4] by auto then show ?thesis by auto next assume af7_3: "axiom_atomicity_violate opid' opid'' po (fst (last exe_list) @ [opid]) pbm" have "axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm" using axiom_atomicity_violate_persist[OF f0 af7_3 f4] by auto then show ?thesis by auto qed qed then show ?thesis by auto next case ald_block obtain opid' opid'' where f8_1: "(axiom_loadop_violate opid' opid'' po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_storestore_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" using atom_load_op_contra_violate[OF a1 ald_block a3 f2_1 f5 a2] by auto then have f8_2: "(axiom_loadop_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_storestore_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" proof (rule disjE) assume af8_1: "axiom_loadop_violate opid' opid'' po (fst (last exe_list) @ [opid]) pbm" have "axiom_loadop_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm" using axiom_loadop_violate_persist[OF f0 af8_1 f4] by auto then show ?thesis by auto next assume af8_2: "axiom_storestore_violate opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm \<or> axiom_atomicity_violate opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm" then show ?thesis by auto qed then show ?thesis by auto next case ast_block obtain opid' opid'' where f9_1: "(axiom_loadop_violate opid' opid po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_storestore_violate opid' opid po ((fst (last exe_list))@[opid]) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" using atom_store_op_contra_violate[OF a1 ast_block a3 f2_1 f5 a2] by auto then have "(axiom_loadop_violate opid' opid po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_storestore_violate opid' opid po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" proof (rule disjE) assume af9_1: "axiom_loadop_violate opid' opid po (fst (last exe_list) @ [opid]) pbm" have "axiom_loadop_violate opid' opid po (((fst (last exe_list))@[opid])@remainder) pbm" using axiom_loadop_violate_persist[OF f0 af9_1 f4] by auto then show ?thesis by auto next assume "axiom_storestore_violate opid' opid po (fst (last exe_list) @ [opid]) pbm \<or> axiom_atomicity_violate opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm" then show ?thesis proof (rule disjE) assume af9_2: "axiom_storestore_violate opid' opid po (fst (last exe_list) @ [opid]) pbm" have "axiom_storestore_violate opid' opid po (((fst (last exe_list))@[opid])@remainder) pbm" using axiom_storestore_violate_persist[OF f0 af9_2 f4] by auto then show ?thesis by auto next assume "axiom_atomicity_violate opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm" then show ?thesis by auto qed qed then show ?thesis by auto next case o_block then show ?thesis using f3 by auto qed qed lemma mem_op_exists: assumes a1: "valid_mem_exe_seq po pbm exe_list" and a2: "op_seq_final (((fst (last exe_list))@[opid])@remainder) po pbm" and a3: "\<forall>opid' opid''. (axiom_loadop opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<and> (axiom_storestore opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<and> (axiom_atomicity opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" shows "(\<exists>xseq' s'. (po pbm opid \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> xseq' s'))" proof (rule ccontr) assume a4: "\<not>(\<exists>xseq' s'. (po pbm opid \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> xseq' s'))" obtain opid' opid'' where f1: "(axiom_loadop_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_storestore_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm) \<or> (axiom_atomicity_violate opid' opid'' po (((fst (last exe_list))@[opid])@remainder) pbm)" using mem_op_contra_violate[OF a1 a2 a4] by auto then show False proof (rule disjE) assume a5: "axiom_loadop_violate opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm" have f5_1: "\<not>(axiom_loadop opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm)" using axiom_loadop_violate_imp[OF a5] by auto then show ?thesis using a3 by auto next assume "axiom_storestore_violate opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm \<or> axiom_atomicity_violate opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm" then show ?thesis proof (rule disjE) assume a6: "axiom_storestore_violate opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm" have f6_1: "\<not>(axiom_storestore opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm)" using axiom_storestore_violate_imp[OF a6] by auto then show ?thesis using a3 by auto next assume a7: "axiom_atomicity_violate opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm" have f7_1: "\<not>(axiom_atomicity opid' opid'' po ((fst (last exe_list) @ [opid]) @ remainder) pbm)" using axiom_atomicity_violate_imp[OF a7] by auto then show ?thesis using a3 by auto qed qed qed text {* The definition of a valid initial execution. *} definition emp_ctl_reg:: "proc \<Rightarrow> control_register" where "emp_ctl_reg p r \<equiv> 0" definition emp_gen_reg:: "proc \<Rightarrow> general_register" where "emp_gen_reg p r \<equiv> 0" definition emp_mem:: "memory" where "emp_mem addr \<equiv> None" definition zero_mem:: "memory" where "zero_mem addr \<equiv> Some 0" definition emp_mem_ops:: "op_id \<Rightarrow> mem_op_state" where "emp_mem_ops opid \<equiv> \<lparr>op_addr = None, op_val = None\<rparr>" definition init_proc_exe_pos:: "proc \<Rightarrow> nat" where "init_proc_exe_pos p \<equiv> 0" definition init_proc_var:: "proc \<Rightarrow> sparc_proc_var" where "init_proc_var p \<equiv> \<lparr>annul = False\<rparr>" definition init_glob_var:: "global_var" where "init_glob_var \<equiv> \<lparr>atomic_flag = None, atomic_rd = 0\<rparr>" definition valid_initial_state:: "sparc_state" where "valid_initial_state \<equiv> \<lparr>ctl_reg = emp_ctl_reg, gen_reg = emp_gen_reg, mem = emp_mem, mem_ops = emp_mem_ops, proc_exe_pos = init_proc_exe_pos, proc_var = init_proc_var, glob_var = init_glob_var, undef = False\<rparr>" definition valid_initial_state_zero_mem:: "sparc_state" where "valid_initial_state_zero_mem \<equiv> \<lparr>ctl_reg = emp_ctl_reg, gen_reg = emp_gen_reg, mem = zero_mem, mem_ops = emp_mem_ops, proc_exe_pos = init_proc_exe_pos, proc_var = init_proc_var, glob_var = init_glob_var, undef = False\<rparr>" definition valid_initial_exe:: "program_order \<Rightarrow> (executed_mem_ops \<times> (op_id set) \<times> sparc_state)" where "valid_initial_exe po \<equiv> ([], {opid. (\<exists>p. List.member (po p) opid)}, valid_initial_state)" definition valid_initial_exe_zero_mem:: "program_order \<Rightarrow> (executed_mem_ops \<times> (op_id set) \<times> sparc_state)" where "valid_initial_exe_zero_mem po \<equiv> ([], {opid. (\<exists>p. List.member (po p) opid)}, valid_initial_state_zero_mem)" lemma valid_initial_exe_seq: "valid_program po pbm \<Longrightarrow> valid_mem_exe_seq po pbm [valid_initial_exe po]" unfolding valid_mem_exe_seq_def valid_initial_exe_def valid_initial_state_def atomic_flag_val_def init_glob_var_def by auto lemma operational_model_complete_sub1: assumes a1: "op_seq_final op_seq po pbm" and a2: "(\<forall>opid opid'. axiom_loadop opid opid' po op_seq pbm)" and a3: "(\<forall>opid opid'. axiom_storestore opid opid' po op_seq pbm)" and a4: "(\<forall>opid opid'. axiom_atomicity opid opid' po op_seq pbm)" and a5: "is_sublist op_sub_seq op_seq" and a6: "op_sub_seq \<noteq> []" shows "(\<exists>exe_list. valid_mem_exe_seq po pbm exe_list \<and> (fst (List.last exe_list)) = op_sub_seq)" proof (insert assms, induction op_sub_seq rule: rev_induct) case Nil then show ?case by auto next case (snoc x xs) have f0: "valid_program po pbm" using a1 unfolding op_seq_final_def by auto show ?case proof (cases "xs = []") case True then have f1_1: "x = hd op_seq" using snoc(6) unfolding is_sublist_def by auto then obtain remainder where f1_2: "op_seq = [x]@remainder" by (metis True append_self_conv2 is_sublist_def snoc.prems(5)) from f0 have f1_3: "valid_mem_exe_seq po pbm [valid_initial_exe po]" using valid_initial_exe_seq by auto have f1_4: "(fst (last [valid_initial_exe po])) = []" unfolding valid_initial_exe_def by auto then have f1_4_1: "op_seq = (((fst (last [valid_initial_exe po]))@[x])@remainder)" using f1_2 by auto have f1_5: "op_seq_final (((fst (last [valid_initial_exe po]))@[x])@remainder) po pbm" using a1 f1_4_1 by auto have f1_6: "\<forall>opid' opid''. axiom_loadop opid' opid'' po ((fst (last [valid_initial_exe po]) @ [x]) @ remainder) pbm \<and> axiom_storestore opid' opid'' po ((fst (last [valid_initial_exe po]) @ [x]) @ remainder) pbm \<and> axiom_atomicity opid' opid'' po ((fst (last [valid_initial_exe po]) @ [x]) @ remainder) pbm" using a2 a3 a4 f1_4_1 by auto obtain xseq' s' where f1_7: "(po pbm x \<turnstile>m (fst (last [valid_initial_exe po])) (snd (snd (last [valid_initial_exe po]))) \<rightarrow> xseq' s')" using mem_op_exists[OF f1_3 f1_5 f1_6] by auto then have f1_8: "(po pbm x \<turnstile>m (fst (valid_initial_exe po)) (snd (snd (last [valid_initial_exe po]))) \<rightarrow> [x] s')" using mem_op_exe f1_4 by fastforce have f1_9: "(\<exists>p. List.member (po p) x)" using op_seq_final_def f1_1 using in_set_member snoc.prems(1) by fastforce have f1_10: "x \<in> (fst (snd (valid_initial_exe po)))" unfolding valid_initial_exe_def using f1_9 by auto have f1_11: "po pbm \<turnstile>t (valid_initial_exe po) \<rightarrow> ([x], ((fst (snd (valid_initial_exe po))) - {x}), s')" unfolding mem_state_trans_def using f1_8 f1_10 by auto have f1_12: "length ([valid_initial_exe po]@ [([x], ((fst (snd (valid_initial_exe po))) - {x}), s')]) > 0" by simp have f1_13: "fst (List.hd ([valid_initial_exe po]@ [([x], ((fst (snd (valid_initial_exe po))) - {x}), s')])) = []" using f1_4 by auto have f1_14: "(\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (List.hd ([valid_initial_exe po]@ [([x], ((fst (snd (valid_initial_exe po))) - {x}), s')])))))" using f1_3 unfolding valid_mem_exe_seq_def by auto have f1_15: "(atomic_flag_val (snd (snd (hd ([valid_initial_exe po]@ [([x], ((fst (snd (valid_initial_exe po))) - {x}), s')])))) = None)" using f1_3 unfolding valid_mem_exe_seq_def by auto have f1_16: "(\<forall>i. i < (List.length ([valid_initial_exe po]@ [([x], ((fst (snd (valid_initial_exe po))) - {x}), s')])) - 1 \<longrightarrow> (po pbm \<turnstile>t (([valid_initial_exe po]@ [([x], ((fst (snd (valid_initial_exe po))) - {x}), s')])!i) \<rightarrow> (([valid_initial_exe po]@ [([x], ((fst (snd (valid_initial_exe po))) - {x}), s')])!(i+1))))" using f1_11 by auto have f1_17: "valid_mem_exe_seq po pbm ([valid_initial_exe po]@ [([x], ((fst (snd (valid_initial_exe po))) - {x}), s')])" using f0 f1_12 f1_13 f1_14 f1_15 f1_16 unfolding valid_mem_exe_seq_def by auto then show ?thesis using True by auto next case False have f2_1: "is_sublist xs op_seq" using snoc(6) unfolding is_sublist_def by auto obtain exe_list where f2_2: "valid_mem_exe_seq po pbm exe_list \<and> fst (last exe_list) = xs" using snoc(1)[OF a1 snoc(3) snoc(4) snoc(5) f2_1 False] by auto then have f2_2_1: "valid_mem_exe_seq po pbm exe_list" by auto obtain remainder where f2_3: "((fst (last exe_list))@[x])@remainder = op_seq" using snoc(6) f2_2 unfolding is_sublist_def by auto have f2_4: "op_seq_final (((fst (last exe_list))@[x])@remainder) po pbm" using a1 f2_3 by auto have f2_5: "\<forall>opid' opid''. (axiom_loadop opid' opid'' po (((fst (last exe_list))@[x])@remainder) pbm) \<and> (axiom_storestore opid' opid'' po (((fst (last exe_list))@[x])@remainder) pbm) \<and> (axiom_atomicity opid' opid'' po (((fst (last exe_list))@[x])@remainder) pbm)" using a2 a3 a4 f2_3 by auto obtain xseq' s' where f2_6: "po pbm x \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> xseq' s'" using mem_op_exists[OF f2_2_1 f2_4 f2_5] by auto then have f2_7: "po pbm x \<turnstile>m (fst (last exe_list)) (snd (snd (last exe_list))) \<rightarrow> ((fst (last exe_list))@[x]) s'" using mem_op_exe by auto have f2_8: "(set (fst (last exe_list))) \<union> (fst (snd (last exe_list))) = (fst (snd (hd exe_list)))" using valid_exe_xseq_sublist_last[OF f2_2_1] by auto have f2_9: "non_repeat_list (((fst (last exe_list))@[x])@remainder)" using a1 f2_3 unfolding op_seq_final_def by auto then have f2_10: "\<not>(List.member (fst (last exe_list)) x)" by (simp add: non_repeat_list_sublist_mem) have f2_11: "(\<exists>p. List.member (po p) x)" using op_seq_final_def f2_3 in_set_member snoc.prems(1) by fastforce then have f2_12: "x \<in> fst (snd (List.hd exe_list))" using f2_2_1 unfolding valid_mem_exe_seq_def by auto then have f2_13: "x \<in> (fst (snd (last exe_list)))" using f2_8 f2_10 in_set_member by fastforce then have f2_14: "po pbm \<turnstile>t (last exe_list) \<rightarrow> (((fst (last exe_list))@[x]), ((fst (snd (last exe_list))) - {x}), s')" unfolding mem_state_trans_def using f2_7 by auto define exe_list' where "exe_list' \<equiv> exe_list@[(((fst (last exe_list))@[x]), ((fst (snd (last exe_list))) - {x}), s')]" have f2_14_1: "po pbm \<turnstile>t (last exe_list) \<rightarrow> (last exe_list')" using f2_14 exe_list'_def by auto have f2_15: "List.length exe_list' > 0" using exe_list'_def by auto have f2_16: "fst (List.hd exe_list') = []" using exe_list'_def f2_2_1 unfolding valid_mem_exe_seq_def by simp have f2_17: "(\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (List.hd exe_list'))))" using exe_list'_def f2_2_1 unfolding valid_mem_exe_seq_def by simp have f2_18: "(atomic_flag_val (snd (snd (hd exe_list'))) = None)" using exe_list'_def f2_2_1 unfolding valid_mem_exe_seq_def by simp have f2_19: "(\<forall>i. i < (List.length exe_list') - 1 \<longrightarrow> (po pbm \<turnstile>t (exe_list'!i) \<rightarrow> (exe_list'!(i+1))))" proof - {fix i have "i < (List.length exe_list') - 1 \<longrightarrow> (po pbm \<turnstile>t (exe_list'!i) \<rightarrow> (exe_list'!(i+1)))" proof (cases "i < (List.length exe_list') - 2") case True then have f2_19_1: "i < (List.length exe_list) - 1" unfolding exe_list'_def by auto then have f2_19_2: "(po pbm \<turnstile>t (exe_list!i) \<rightarrow> (exe_list!(i+1)))" using f2_2_1 unfolding valid_mem_exe_seq_def by auto then have f2_19_3: "(po pbm \<turnstile>t (exe_list'!i) \<rightarrow> (exe_list'!(i+1)))" using True unfolding exe_list'_def by (metis add_lessD1 f2_19_1 less_diff_conv nth_append) then show ?thesis by auto next case False show ?thesis proof (auto) assume f2_19_4: "i < length exe_list' - Suc 0" then have f2_19_5: "i = length exe_list' - 2" using False by auto show "po pbm \<turnstile>t (exe_list' ! i) \<rightarrow> (exe_list' ! Suc i)" using f2_14_1 f2_19_5 unfolding exe_list'_def by (metis (no_types, lifting) Nat.add_0_right One_nat_def Suc_diff_Suc add_Suc_right append_is_Nil_conv butlast_snoc diff_diff_left exe_list'_def f2_19_4 f2_2 last_conv_nth length_butlast length_greater_0_conv nth_append numeral_2_eq_2 valid_mem_exe_seq_def) qed qed } then show ?thesis by auto qed have f2_20: "valid_mem_exe_seq po pbm exe_list'" using f0 f2_15 f2_16 f2_17 f2_18 f2_19 unfolding valid_mem_exe_seq_def by auto then show ?thesis unfolding exe_list'_def using f2_2 by auto qed qed text {* The theorem below shows the completeness proof. *} theorem operational_model_complete_sub2: "op_seq_final op_seq po pbm \<Longrightarrow> (\<forall>opid opid'. axiom_loadop opid opid' po op_seq pbm) \<Longrightarrow> (\<forall>opid opid'. axiom_storestore opid opid' po op_seq pbm) \<Longrightarrow> (\<forall>opid opid'. axiom_atomicity opid opid' po op_seq pbm) \<Longrightarrow> (\<exists>exe_list. valid_mem_exe_seq po pbm exe_list \<and> (fst (List.last exe_list)) = op_seq)" proof - assume a1: "op_seq_final op_seq po pbm" assume a2: "(\<forall>opid opid'. axiom_loadop opid opid' po op_seq pbm)" assume a3: "(\<forall>opid opid'. axiom_storestore opid opid' po op_seq pbm)" assume a4: "(\<forall>opid opid'. axiom_atomicity opid opid' po op_seq pbm)" have f1: "is_sublist op_seq op_seq" unfolding is_sublist_def by auto have f2: "op_seq \<noteq> []" using a1 unfolding op_seq_final_def by auto show ?thesis using operational_model_complete_sub1[OF a1 a2 a3 a4 f1 f2] by auto qed theorem operational_model_complete: "op_seq_final op_seq po pbm \<Longrightarrow> (\<forall>opid opid'. axiom_loadop opid opid' po op_seq pbm) \<Longrightarrow> (\<forall>opid opid'. axiom_storestore opid opid' po op_seq pbm) \<Longrightarrow> (\<forall>opid opid'. axiom_atomicity opid opid' po op_seq pbm) \<Longrightarrow> (\<exists>exe_list. valid_mem_exe_seq_final po pbm exe_list \<and> (fst (List.last exe_list)) = op_seq)" proof - assume a1: "op_seq_final op_seq po pbm" assume a2: "(\<forall>opid opid'. axiom_loadop opid opid' po op_seq pbm)" assume a3: "(\<forall>opid opid'. axiom_storestore opid opid' po op_seq pbm)" assume a4: "(\<forall>opid opid'. axiom_atomicity opid opid' po op_seq pbm)" then obtain exe_list where f1: "valid_mem_exe_seq po pbm exe_list \<and> (fst (List.last exe_list)) = op_seq" using operational_model_complete_sub2[OF a1 a2 a3 a4] by auto then have f1_1: "List.length exe_list > 0" unfolding valid_mem_exe_seq_def by auto from a1 have f2: "(\<forall>opid. (\<exists>p. List.member (po p) opid) = (List.member op_seq opid))" unfolding op_seq_final_def by auto from f1 have f3: "(\<forall>opid. (\<exists>p. List.member (po p) opid) = (opid \<in> fst (snd (List.hd exe_list))))" unfolding valid_mem_exe_seq_def by auto from f2 f3 have f4: "\<forall>opid. (List.member op_seq opid) = (opid \<in> fst (snd (List.hd exe_list)))" by auto then have f5: "\<forall>opid. (List.member (fst (List.last exe_list)) opid) = (opid \<in> fst (snd (List.hd exe_list)))" using f1 by auto then have f6: "\<forall>opid. (opid \<in> fst (snd (List.hd exe_list))) = (opid \<in> set (fst (List.last exe_list)))" by (simp add: in_set_member) then have f7: "fst (snd (List.hd exe_list)) = set (fst (List.last exe_list))" by auto show ?thesis using f1 f7 unfolding valid_mem_exe_seq_final_def by auto qed end
Clinical trial word cloud . Clinical Trials - Illustration of a medicine bottle with the. V.24.1.7 Page loaded in 0.006 seconds.
[STATEMENT] lemma vlrestrictionE[elim]: assumes "x \<in>\<^sub>\<circ> vlrestriction D" and "D \<subseteq>\<^sub>\<circ> R \<times>\<^sub>\<circ> X" obtains r A where "x = \<langle>\<langle>r, A\<rangle>, r \<restriction>\<^sup>l\<^sub>\<circ> A\<rangle>" and "r \<in>\<^sub>\<circ> R" and "A \<in>\<^sub>\<circ> X" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<And>r A. \<lbrakk>x = \<langle>\<langle>r, A\<rangle>, r \<restriction>\<^sup>l\<^sub>\<circ> A\<rangle>; r \<in>\<^sub>\<circ> R; A \<in>\<^sub>\<circ> X\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: x \<in>\<^sub>\<circ> vlrestriction D D \<subseteq>\<^sub>\<circ> R \<times>\<^sub>\<circ> X goal (1 subgoal): 1. (\<And>r A. \<lbrakk>x = \<langle>\<langle>r, A\<rangle>, r \<restriction>\<^sup>l\<^sub>\<circ> A\<rangle>; r \<in>\<^sub>\<circ> R; A \<in>\<^sub>\<circ> X\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] unfolding vlrestriction_def [PROOF STATE] proof (prove) using this: x \<in>\<^sub>\<circ> (\<lambda>\<langle>r, A\<rangle>\<in>\<^sub>\<circ>D. set {\<langle>a, b\<rangle> |a b. a \<in>\<^sub>\<circ> A \<and> \<langle>a, b\<rangle> \<in>\<^sub>\<circ> r}) D \<subseteq>\<^sub>\<circ> R \<times>\<^sub>\<circ> X goal (1 subgoal): 1. (\<And>r A. \<lbrakk>x = \<langle>\<langle>r, A\<rangle>, (\<lambda>\<langle>r, A\<rangle>\<in>\<^sub>\<circ>set {\<langle>r, A\<rangle>}. set {\<langle>a, b\<rangle> |a b. a \<in>\<^sub>\<circ> A \<and> \<langle>a, b\<rangle> \<in>\<^sub>\<circ> r})\<lparr>\<langle>r, A\<rangle>\<rparr>\<rangle>; r \<in>\<^sub>\<circ> R; A \<in>\<^sub>\<circ> X\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis [PROOF STEP] by auto
theory Digraph_Summary imports Graph_Theory.Graph_Theory "../Graph_Theory/Directed_Tree" "../TA_Graphs/TA_Graph_Library_Adaptor" begin text \<open>This theory collects basic concepts about directed graphs in Noschinski's digraph library.\<close> chapter \<open>digraph\<close> text \<open>We will mostly cover finite digraphs (@{term fin_digraph}), which might include loops and multi-edges. It is basically a @{type pre_digraph} featuring a set of vertices, a set of arcs and functions that map arcs to their head and tail. There are several other sorts of digraphs: e.g. @{term loopfree_digraph}, @{term nomulti_digraph}, @{term digraph}\<close> context fin_digraph begin section \<open>Walks and Paths\<close> subsection \<open>Arc-walks\<close> text \<open>An @{term "awalk u p v"} is any valid arc walk \<open>p\<close> from \<open>u\<close> to \<open>v\<close>, a @{term trail} uses each arc at most once and a @{term apath} visits any vertex at most once.\<close> thm awalkI_apath \<comment> \<open>Any @{term apath} is an @{term awalk}\<close> text \<open>You can eliminate cycles from a path:\<close> thm apath_awalk_to_apath \<comment> \<open>Get a @{term apath} from an @{term awalk}\<close> thm awalk_to_apath_induct \<comment> \<open>Induction principle\<close> thm awalk_appendI \<comment> \<open>@{term awalk} can be joined\<close> thm awalk_append_iff \<comment> \<open>@{term awalk} can be split\<close> text \<open>Is every @{term apath} a @{term trail}?\<close> text \<open>Defines @{term cycle}. Note: a loop is not a cycle!\<close> subsection \<open>Vertex-walks\<close> text \<open>A list of vertices \<open>p\<close> is a @{term "vwalk p G"} if for all adjacent elements in the list there is an arc in \<open>G\<close>. A @{term vpath} visits any vertex at most once.\<close> thm awalk_imp_vwalk \<comment> \<open>you can get a @{term vwalk} from a @{term awalk}\<close> subsection \<open>Infinite paths\<close> text \<open>TODO\<close> section \<open>Reachability\<close> text \<open> We have@{term "(u,v) \<in> arcs_ends G"} iff there is an arc from \<open>u\<close> to \<open>v\<close>. The predicates @{term reachable} and @{term reachable1} capture reachability, and reachability over at least one arc. They are defined by the reflexive transitive closure, respectively the transitive closure of @{term arcs_ends}.\<close> subsection \<open>Reachability with paths\<close> thm reachable_vwalk_conv thm reachable_awalk section \<open>Subgraphs and various graph properties\<close> subsection \<open>Subgraphs\<close> thm subgraph_def thm spanning_def thm spanning_tree_def text \<open>subgraphs and interaction with concepts\<close> thm subgraph_del_arc thm subgraph_del_vert lemma subgraph_add_vert: "subgraph G (add_vert u)" using wf_digraph_add_vert by(auto simp add: add_vert_def wf_digraph_axioms compatible_def intro!: subgraphI) lemma subgraph_add_arc: "subgraph G (add_arc a)" using wf_digraph_add_arc by (auto simp add: add_arc_def wf_digraph_axioms compatible_def intro!: subgraphI) thm subgraph_cycle thm vpathI_subgraph thm subgraph_apath_imp_apath thm reachable_mono text \<open>interaction between insertion/deletion and paths\<close> thm vpathI_subgraph[OF _ subgraph_add_vert] thm vpathI_subgraph[OF _ subgraph_del_vert] thm vpathI_subgraph[OF _ subgraph_del_arc] thm vpathI_subgraph[OF _ subgraph_add_arc] thm subgraph_apath_imp_apath[OF _ subgraph_del_vert] thm subgraph_apath_imp_apath[OF _ subgraph_del_arc] subsection \<open>Graph properties\<close> text \<open>aka cycle free aka DAG. Note that this definition should be renamed to something more appropriate such as dag since there is no reasonable definition of forests in a general digraph. Forests and trees should only be defined in @{locale sym_digraph}}.\<close> thm forest_def text \<open>Every DAG has a topological numbering:\<close> thm fin_dag_def lemma (in -) forest_dag_conv: "forest G = dag G" oops thm dag.topological_numbering \<comment> \<open> This theorem exists because has because it has been transferred from the \<open>TA_Graph\<close> library. But it should be re-proved for better comparison.\<close> subsubsection \<open>Strongly Connected Components\<close> thm strongly_connected_def \<comment> \<open>Q: why does the graph have to be non-empty to be strongly connected?\<close> thm sccs_def sccs_altdef2 thm sccs_verts_def sccs_verts_conv text \<open>The graph of strongly connected components forms a DAG/has a topological ordering.\<close> thm scc_num_topological \<comment> \<open>See note for @{thm dag.topological_numbering} above\<close> thm scc_digraphI lemma "forest scc_graph" sorry subsection \<open>The underlying undirected/symmetric graph of a digraph\<close> thm mk_symmetric_def thm reachable_mk_symmetric_eq text \<open>A graph \<open>G\<close> is @{term connected} if its underlying undirected graph (i.e. symmetric graph) is @{term strongly_connected}\<close> thm tree_def section \<open>In- and out-degrees\<close> thm in_degree_def out_degree_def find_theorems in_degree lemma cycle_of_indegree_ge_1_: assumes "\<forall> y \<in> verts G. in_degree G y \<ge> 1" shows "\<not> forest G" sorry text \<open>Characterization of Euler trails:\<close> thm closed_euler thm open_euler section \<open>Rooted directed tree\<close> thm directed_tree_def thm directed_tree.finite_directed_tree_induct \<comment> \<open>an induction rule\<close> section \<open>A BFS algorithm for finding a rooted directed tree.\<close> section \<open>A DFS algorithm finding a rooted directed tree and computing DFS numberings.\<close> section \<open>An algorithm for finding the SCCs.\<close> end end
! { dg-do run } ! { dg-options "-fcheck-array-temporaries" } program test implicit none integer :: a(3,3) call foo(a(:,1)) ! OK, no temporary created call foo(a(1,:)) ! BAD, temporary var created contains subroutine foo(x) integer :: x(3) x = 5 end subroutine foo end program test ! { dg-output "At line 7 of file .*array_temporaries_2.f90(\n|\r\n|\r)Fortran runtime warning: An array temporary was created for argument 'x' of procedure 'foo'" }
# ------------ Attribute alias and APIs ------------ # const Attribute = MLIR.API.MlirAttribute get_context(attr::Attribute) = MLIR.API.mlirAttributeGetContext(attr) get_type(attr::Attribute) = MLIR.API.mlirAttributeGetType(attr) is_null(attr::Attribute) = MLIR.API.mlirAttributeIsNull(attr) Base.:(==)(attr1::Attribute, attr2::Attribute) = MLIR.API.mlirAttributeEqual(attr1, attr2) function parse_attribute(ctx::Context, attr::String) ref = StringRef(attr) MLIR.API.mlirAttributeParseGet(ctx, ref) end dump(attr::Attribute) = MLIR.API.mlirAttributeDump(attr) # Constructor. Attribute(ctx::Context, attr::String) = parse_attribute(ctx, attr) @doc( """ const Attribute = MLIR.API.MlirAttribute """, Attribute) # ------------ Named attribute alias and APIs ------------ # const NamedAttribute = MLIR.API.MlirNamedAttribute create_named_attribute(name, attr::Attribute) = MLIR.API.mlirNamedAttributeGet(name, attr) # Constructor. function NamedAttribute(ctx::Context, name::String, attr::Attribute) id = MLIR.IR.Identifier(ctx, name) # owned by MLIR create_named_attribute(id, attr) end @doc( """ const NamedAttribute = MLIR.API.MlirNamedAttribute """, NamedAttribute)
State Before: α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α ⊢ Continuous fun p => edist p.fst p.snd State After: α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α ⊢ ∀ (x y : α × α), edist x.fst x.snd ≤ edist y.fst y.snd + 2 * edist x y Tactic: apply continuous_of_le_add_edist 2 (by norm_num) State Before: α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α ⊢ ∀ (x y : α × α), edist x.fst x.snd ≤ edist y.fst y.snd + 2 * edist x y State After: case mk.mk α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α x y x' y' : α ⊢ edist (x, y).fst (x, y).snd ≤ edist (x', y').fst (x', y').snd + 2 * edist (x, y) (x', y') Tactic: rintro ⟨x, y⟩ ⟨x', y'⟩ State Before: case mk.mk α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α x y x' y' : α ⊢ edist (x, y).fst (x, y).snd ≤ edist (x', y').fst (x', y').snd + 2 * edist (x, y) (x', y') State After: no goals Tactic: calc edist x y ≤ edist x x' + edist x' y' + edist y' y := edist_triangle4 _ _ _ _ _ = edist x' y' + (edist x x' + edist y y') := by simp only [edist_comm]; ac_rfl _ ≤ edist x' y' + (edist (x, y) (x', y') + edist (x, y) (x', y')) := (add_le_add_left (add_le_add (le_max_left _ _) (le_max_right _ _)) _) _ = edist x' y' + 2 * edist (x, y) (x', y') := by rw [← mul_two, mul_comm] State Before: α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α ⊢ 2 ≠ ⊤ State After: no goals Tactic: norm_num State Before: α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α x y x' y' : α ⊢ edist x x' + edist x' y' + edist y' y = edist x' y' + (edist x x' + edist y y') State After: α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α x y x' y' : α ⊢ edist x x' + edist x' y' + edist y y' = edist x' y' + (edist x x' + edist y y') Tactic: simp only [edist_comm] State Before: α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α x y x' y' : α ⊢ edist x x' + edist x' y' + edist y y' = edist x' y' + (edist x x' + edist y y') State After: no goals Tactic: ac_rfl State Before: α : Type u_1 β : Type ?u.422280 γ : Type ?u.422283 inst✝ : PseudoEMetricSpace α x y x' y' : α ⊢ edist x' y' + (edist (x, y) (x', y') + edist (x, y) (x', y')) = edist x' y' + 2 * edist (x, y) (x', y') State After: no goals Tactic: rw [← mul_two, mul_comm]
Formal statement is: lemma complex_cnj_i [simp]: "cnj \<i> = - \<i>" Informal statement is: The complex conjugate of $\i$ is $-\i$.
||| https://idris2.readthedocs.io/en/latest/ffi/ffi.html module Main import System.FFI libsmall : String -> String libsmall fn = "Dart:" ++ fn ++ ",./libsmall.dart" ||| A pure foreign function. %foreign (libsmall "add") add : Int -> Int -> Int ||| An effectful foreign function. %foreign (libsmall "addWithMessage") prim__addWithMessage : String -> Int -> Int -> PrimIO Int addWithMessage : HasIO io => String -> Int -> Int -> io Int addWithMessage s x y = primIO $ prim__addWithMessage s x y ||| An effectful foreign function that takes a pure callback. %foreign (libsmall "applyFn") prim__applyFn : String -> Int -> (String -> Int -> String) -> PrimIO String applyFn : HasIO io => String -> Int -> (String -> Int -> String) -> io String applyFn c i f = primIO $ prim__applyFn c i f ||| An effectful foreign function that takes an effectful callback. %foreign (libsmall "applyFn") prim__applyFnIO : String -> Int -> (String -> Int -> PrimIO String) -> PrimIO String applyFnIO : HasIO io => String -> Int -> (String -> Int -> IO String) -> io String applyFnIO c i f = primIO $ prim__applyFnIO c i (\s, i => toPrim $ f s i) pluralise : String -> Int -> String pluralise str x = show x ++ " " ++ if x == 1 then str else str ++ "s" pluraliseIO : String -> Int -> IO String pluraliseIO str x = pure (pluralise str x) ||| A static member of the dart:core library. DateTime : Type DateTime = Struct "DateTime,dart:core" [("hour", Int)] %foreign "Dart:DateTime.parse,dart:core" prim__parseDateTime : String -> PrimIO DateTime namespace DateTime export parse : HasIO io => String -> io DateTime parse s = primIO $ prim__parseDateTime s export hour : DateTime -> Int hour dt = getField dt "hour" Point : Type Point = Struct "Point,./libsmall.dart" [("x", Int), ("y", Int)] %foreign (libsmall "Point") prim__mkPoint : Int -> Int -> PrimIO Point mkPoint : Int -> Int -> IO Point mkPoint x y = primIO $ prim__mkPoint x y %foreign "Dart:.moveTo" prim__moveTo : Point -> Int -> Int -> PrimIO () %foreign "Dart:.accept" prim__accept : Point -> (Point -> PrimIO ()) -> PrimIO () moveTo : HasIO io => Point -> Int -> Int -> io () moveTo p x y = primIO $ prim__moveTo p x y accept : HasIO io => Point -> (Point -> IO ()) -> io () accept p c = primIO $ prim__accept p (\p => toPrim $ c p) Show Point where show pt = show (the Int (getField pt "x"), the Int (getField pt "y")) PaintingStyle : Type PaintingStyle = Struct "PaintingStyle,./libsmall.dart" [("index", Int)] namespace PaintingStyle export %foreign (libsmall "const PaintingStyle.fill") fill : PaintingStyle export %foreign (libsmall "const PaintingStyle.stroke") stroke : PaintingStyle export index : PaintingStyle -> Int index ps = getField ps "index" main : IO () main = do printLn (add 70 24) addWithMessage "Sum" 70 24 >>= printLn applyFn "Biscuit" 10 pluralise >>= putStrLn applyFn "Tree" 1 pluralise >>= putStrLn applyFnIO "Biscuit" 10 pluraliseIO >>= putStrLn applyFnIO "Tree" 1 pluraliseIO >>= putStrLn -- Dart classes as records moonLanding <- DateTime.parse "1969-07-20 20:18:04Z" printLn (hour moonLanding) pt <- mkPoint 0 1 printLn pt setField pt "x" (the Int 2) setField pt "y" (the Int 3) printLn pt accept pt (\pt => moveTo pt 4 5) printLn pt -- Dart enums printLn (index PaintingStyle.fill, index PaintingStyle.stroke)
% OP_U_OTIMES_N_V_OTIMES_N: assemble the matrix A = [A(i,j)], A(i,j) = (epsilon (u \otimes n)_j, (v \otimes n)_i ). % % A = op_u_otimes_n_v_otimes_n (spu, spv, msh, coeff); % % INPUT: % % spu: structure representing the space of trial functions (see sp_vector/sp_eval_boundary_side) % spv: structure representing the space of test functions (see sp_vector/sp_eval_boundary_side) % msh: structure containing the domain partition and the quadrature rule for the boundary, % since it must contain the normal vector (see msh_cartesian/msh_eval_boundary_side) % coeff: vector-valued function f, evaluated at the quadrature points % % OUTPUT: % % A: assembled matrix % % Copyright (C) 2015, Rafael, 2017 Vazquez % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program. If not, see <http://www.gnu.org/licenses/>. function varargout = op_u_otimes_n_v_otimes_n (spu, spv, msh, mshv, coeff) shpu = reshape (spu.shape_functions, spu.ncomp, msh.nqn, spu.nsh_max, msh.nel); shpv = reshape (spv.shape_functions, spv.ncomp, msh.nqn, spv.nsh_max, msh.nel); rows = zeros (msh.nel * spu.nsh_max * spv.nsh_max, 1); cols = zeros (msh.nel * spu.nsh_max * spv.nsh_max, 1); values = zeros (msh.nel * spu.nsh_max * spv.nsh_max, 1); jacdet_weights = msh.jacdet .* msh.quad_weights .* coeff; ncounter = 0; for iel = 1:msh.nel if (all (msh.jacdet(:, iel))) shpu_iel = reshape (shpu(:, :, :, iel), spu.ncomp, msh.nqn, spu.nsh_max); shpv_iel = reshape (shpv(:, :, :, iel), spv.ncomp, msh.nqn, spv.nsh_max); u_otimes_n_iel = zeros (spu.ncomp, spu.ncomp, msh.nqn, spu.nsh_max); v_otimes_n_iel = zeros (spv.ncomp, spv.ncomp, msh.nqn, spv.nsh_max); % I need the normal from both sides normalu_iel = msh.normal (:, :, iel); normalv_iel = mshv.normal (:, :, iel); for ii = 1:spu.ncomp for jj = 1:spu.ncomp u_otimes_n_iel(ii,jj,:,:) = bsxfun (@times, shpu_iel(ii,:,:), normalu_iel(jj,:)); v_otimes_n_iel(ii,jj,:,:) = bsxfun (@times, shpv_iel(ii,:,:), normalv_iel(jj,:)); end end % Should I permute it, before reshaping? u_otimes_n_iel = reshape (u_otimes_n_iel, spu.ncomp*spu.ncomp, msh.nqn, 1, spu.nsh_max); v_otimes_n_iel = reshape (v_otimes_n_iel, spv.ncomp*spv.ncomp, msh.nqn, spv.nsh_max, 1); jacdet_iel = reshape (jacdet_weights(:,iel), [1, msh.nqn, 1, 1]); v_oxn_times_jw = bsxfun (@times, jacdet_iel, v_otimes_n_iel); tmp1 = sum (bsxfun (@times, v_oxn_times_jw, u_otimes_n_iel), 1); elementary_values = reshape (sum (tmp1, 2), spv.nsh_max, spu.nsh_max); [rows_loc, cols_loc] = ndgrid (spv.connectivity(:,iel), spu.connectivity(:,iel)); indices = rows_loc & cols_loc; rows(ncounter+(1:spu.nsh(iel)*spv.nsh(iel))) = rows_loc(indices); cols(ncounter+(1:spu.nsh(iel)*spv.nsh(iel))) = cols_loc(indices); values(ncounter+(1:spu.nsh(iel)*spv.nsh(iel))) = elementary_values(indices); ncounter = ncounter + spu.nsh(iel)*spv.nsh(iel); else warning ('geopdes:jacdet_zero_at_quad_node', 'op_u_otimes_n_v_otimes_n: singular map in element number %d', iel) end end if (nargout == 1 || nargout == 0) varargout{1} = sparse (rows(1:ncounter), cols(1:ncounter), ... values(1:ncounter), spv.ndof, spu.ndof); elseif (nargout == 3) varargout{1} = rows(1:ncounter); varargout{2} = cols(1:ncounter); varargout{3} = values(1:ncounter); else error ('op_u_otimes_n_v_otimes_n: wrong number of output arguments') end end
# Copyright (c) 2018-2021, Carnegie Mellon University # See LICENSE for details #F CondPat(<obj>, <pat1>, <result1>, ..., <patN>, <resultN>, [<resultElse>]) #F #F CondPat is a conditional control-flow construct similar to Cond, but instead #F of normal boolean conditions it uses patterns that are matched against its #F first argument <obj>. CondPat returns the result that corresponds to the #F first matched pattern. If nothing matches <resultElse> is returned. #F #F Note: resultElse is optional #F #F CondPat is implemented as a function with delayed evaluation, and will #F only evaluate the result that corresponds to the matched patterns, all #F other results will not be evaluated, for example: #F #F CondPat(mul(X,2), [mul, @, 2], Print("yes"), [add, @, 2], Print("no")); #F #F will only execute Print("yes") -- as expected. #F CondPat := UnevalArgs(function(arg) local usage, i, pat, obj; usage := "CondPat(<obj>, <pat1>, <result1>, ..., <patN>, <resultN>, <resultElse>)"; if Length(arg) < 3 then Error(usage); fi; obj := Eval(arg[1]); i := 2; while i <= Length(arg)-1 do pat := Eval(arg[i]); if PatternMatch(obj, pat, empty_cx()) then return Eval(arg[i+1]); fi; i := i+2; od; if i=Length(arg) then return Eval(Last(arg)); else Error("CondPat: No 'else' result, and no patterns match"); fi; end);
module Noether.Lemmata.Prelude ( module X , fromInteger , fromString ) where import Data.Complex as X import Data.Monoid as X ((<>)) import Prelude as X hiding (Eq, Monoid, fromInteger, negate, recip, (&&), (*), (+), (-), (/), (==), (||)) import Data.Ratio as X import Data.Int as X import qualified Data.String as S import qualified Prelude as P fromInteger :: Num a => Integer -> a fromInteger = P.fromInteger fromString :: S.IsString a => String -> a fromString = S.fromString
module Integer10 where open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl) -- 整数の素朴な定義 --(succ (succ (pred zero))などが有効、という弱点がある) data ℤ : Set where zero : ℤ succ : ℤ → ℤ pred : ℤ → ℤ -- 加法 _+_ : ℤ → ℤ → ℤ zero + y = y succ x + zero = succ x succ x + succ y = succ (succ x + y) succ x + pred y = x + y pred x + zero = pred x pred x + succ y = x + y pred x + pred y = pred (pred x + y) -- 反数 opposite : ℤ → ℤ opposite zero = zero opposite (succ x) = pred (opposite x) opposite (pred x) = succ (opposite x) -- 乗法 _*_ : ℤ → ℤ → ℤ x * zero = zero x * succ y = (x * y) + x x * pred y = (x * y) + (opposite x) infixl 40 _+_ infixl 60 _*_ -- (-1) * (-1) = (+1) theorem : pred zero * pred zero ≡ succ zero theorem = refl
A January 2012 Oxfam report said that a half a million Haitians remained homeless , still living under tarps and in tents . Watchdog groups have criticized the reconstruction process saying that part of the problem is that charities spent a considerable amount of money on " soaring rents , board members ' needs , overpriced supplies and imported personnel " . The Miami Herald reports . " A lot of good work was done ; the money clearly didn 't all get squandered , " but , " A lot just wasn 't responding to needs on the ground . Millions were spent on ad campaigns telling people to wash their hands . Telling them to wash their hands when there 's no water or soap is a slap in the face . "
module Language.LSP.CodeAction.GenerateDef import Core.Context import Core.Core import Core.Env import Core.Metadata import Core.UnifyState import Data.String import Idris.REPL.Opts import Idris.Resugar import Idris.Syntax import Language.JSON import Language.LSP.CodeAction import Language.LSP.CodeAction.Utils import Language.LSP.Message import Parser.Unlit import Server.Configuration import Server.Log import Server.Utils import TTImp.Interactive.GenerateDef import TTImp.TTImp import TTImp.TTImp.Functor printClause : Ref Ctxt Defs => Ref Syn SyntaxInfo => Maybe String -> Nat -> ImpClause -> Core String printClause l i (PatClause _ lhsraw rhsraw) = do lhs <- pterm $ map defaultKindedName lhsraw rhs <- pterm $ map defaultKindedName rhsraw pure (relit l (pack (replicate i ' ') ++ show lhs ++ " = " ++ show rhs)) printClause l i (WithClause _ lhsraw wvraw prf flags csraw) = do lhs <- pterm $ map defaultKindedName lhsraw wval <- pterm $ map defaultKindedName wvraw cs <- traverse (printClause l (i + 2)) csraw pure (relit l ((pack (replicate i ' ') ++ show lhs ++ " with (" ++ show wval ++ ")" ++ maybe "" (\ nm => " proof " ++ show nm) prf ++ "\n")) ++ showSep "\n" cs) printClause l i (ImpossibleClause _ lhsraw) = do do lhs <- pterm $ map defaultKindedName lhsraw pure (relit l (pack (replicate i ' ') ++ show lhs ++ " impossible")) number : Nat -> List a -> List (Nat, a) number n [] = [] number n (x :: xs) = (n,x) :: number (S n) xs export generateDef : Ref LSPConf LSPConfiguration => Ref MD Metadata => Ref Ctxt Defs => Ref UST UState => Ref Syn SyntaxInfo => Ref ROpts REPLOpts => CodeActionParams -> Core (List CodeAction) generateDef params = do logI GenerateDef "Checking for \{show params.textDocument.uri} at \{show params.range}" withSingleLine GenerateDef params (pure []) $ \line => do withMultipleCache GenerateDef params GenerateDef $ do defs <- branch Just (_, n, _, _) <- findTyDeclAt (\p, n => onLine line p) | Nothing => do logD GenerateDef "No name found at line \{show line}" pure [] logD CaseSplit "Found type declaration \{show n}" fuel <- gets LSPConf searchLimit solutions <- case !(lookupDefExact n defs.gamma) of Just None => do catch (do searchdefs@((fc, _) :: _) <- makeDefN (\p, n => onLine line p) fuel n | _ => pure [] let l : Nat = integerToNat $ cast $ startCol (toNonEmptyFC fc) Just srcLine <- getSourceLine (line + 1) | Nothing => do logE GenerateDef "Source line \{show line} not found" pure [] let (markM, srcLineUnlit) = isLitLine srcLine for searchdefs $ \(_, cs) => do traverse (printClause markM l) cs) (\case Timeout _ => do logI GenerateDef "Timed out" pure [] err => do logC GenerateDef "Unexpected error while searching" throw err) Just _ => do logD GenerateDef "There is already a definition for \{show n}" pure [] Nothing => do logD GenerateDef "Couldn't find type declaration at line \{show line}" pure [] put Ctxt defs let docURI = params.textDocument.uri let rng = MkRange (MkPosition (line + 1) 0) (MkPosition (line + 1) 0) -- insert actions <- for (number 1 solutions) $ \(i,funcDef) => do let lastLine = fromMaybe "" (last' funcDef) let edit = MkTextEdit rng (String.unlines funcDef ++ "\n") -- extra newline let workspaceEdit = MkWorkspaceEdit { changes = Just (singleton docURI [edit]) , documentChanges = Nothing , changeAnnotations = Nothing } pure $ MkCodeAction { title = "Generate definition #\{show i} as ~ \{strSubstr 0 50 lastLine} ..." , kind = Just RefactorRewrite , diagnostics = Just [] , isPreferred = Just False , disabled = Nothing , edit = Just workspaceEdit , command = Nothing , data_ = Nothing } -- TODO: retrieve the line length efficiently pure [(MkRange (MkPosition line 0) (MkPosition line 1000), actions)]
import data.real.irrational import topology.basic import algebra.order.floor --OUTPUT 1 theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := begin have h1 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ≠ (int.fract (α * ↑j)), from assume (i j : ℤ) (h : i ≠ j), have h1 : (α * ↑i) - (int.floor (α * ↑i)) = (int.fract (α * ↑i)), from int.fract_eq_of_floor_sub_eq (int.floor_le (α * ↑i)), have h2 : (α * ↑j) - (int.floor (α * ↑j)) = (int.fract (α * ↑j)), from int.fract_eq_of_floor_sub_eq (int.floor_le (α * ↑j)), have h3 : (α * ↑i) - (int.floor (α * ↑i)) = (α * ↑j) - (int.floor (α * ↑j)), from by rw [h1,h2], have h4 : (α * ↑i) - (int.floor (α * ↑i)) = (α * ↑j) - (int.floor (α * ↑j)), from by rw [h1,h2], have h5 : α = (int.floor (α * ↑i) - int.floor (α * ↑j)) / (i - j), from by rw [mul_comm α i,mul_comm α j,mul_sub,mul_div_cancel (ne_of_gt (int.cast_pos.2 (int.coe_nat_pos.2 (nat.succ_pos 0)))),mul_comm (i - j) α,h4], have h6 : α ∈ ℚ, from by rw [h5], have h7 : irrational α, from hα_irrat, have h8 : ¬ (α ∈ ℚ), from h7, show (int.fract (α * ↑i)) ≠ (int.fract (α * ↑j)), from by {apply h8,exact h6}, have h2 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from assume (i j : ℤ) (h : i ≠ j), have h1 : (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from by {apply set.mem_cons_of_ne,exact h1 h}, show (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from h1, have h3 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from assume (i j : ℤ) (h : i ≠ j), have h1 : (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from by {apply set.mem_cons_of_ne,exact h1 h}, show (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from h1, have h4 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from assume (i j : ℤ) (h : i ≠ j), have h1 : (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from by {apply set.mem_cons_of_ne,exact h1 h}, show (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from h1, have h5 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from assume (i j : ℤ) (h : i ≠ j), have h1 : (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from by {apply set.mem_cons_of_ne,exact h1 h}, show (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from h1, have h6 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from assume (i j : ℤ) (h : i ≠ j), have h1 : (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from by {apply set.mem_cons_of_ne,exact h1 h}, show (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from h1, have h7 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from assume (i j : ℤ) (h : i ≠ j), have h1 : (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from by {apply set.mem_cons_of_ne,exact h1 h}, show (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from h1, have h8 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from assume (i j : ℤ) (h : i ≠ j), have h1 : (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from by {apply set.mem_cons_of_ne,exact h1 h}, show (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from h1, have h9 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from assume (i j : ℤ) (h : i ≠ j), have h1 : (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from by {apply set.mem_cons_of_ne,exact h1 h}, show (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from h1, have h10 : ∀ (i j : ℤ), i ≠ j → (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from assume (i j : ℤ) (h : i ≠ j), have h1 : (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from by {apply set.mem_cons_of_ne,exact h1 h}, show (int.fract (α * ↑i)) ∉ (int.fract (α * ↑j)) :: set.univ, from h1, have h11 : ∀ (i end --Needs more than 2000 tokens! --OUTPUT 2 theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := begin have h1 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from assume (i j : ℤ) (h2 : i ≠ j), have h3 : α ≠ (int.fract (α * ↑i) - int.fract (α * ↑j)) / (i - j), from by { assume h4 : α = (int.fract (α * ↑i) - int.fract (α * ↑j)) / (i - j), have h5 : (int.fract (α * ↑i) - int.fract (α * ↑j)) / (i - j) ∈ ℚ, from by { rw h4, exact ℚ.coe_nat_rat, }, have h6 : (int.fract (α * ↑i) - int.fract (α * ↑j)) / (i - j) ∈ ℝ, from by { rw h4, exact ℝ.coe_nat_rat, }, have h7 : (int.fract (α * ↑i) - int.fract (α * ↑j)) / (i - j) ∈ ℝ ∩ ℚ, from by { split, exact h6, exact h5, }, have h8 : (int.fract (α * ↑i) - int.fract (α * ↑j)) / (i - j) ∈ ℝ ∩ ℚ ∩ {x : ℝ | irrational x}, from by { split, exact h7, exact hα_irrat, }, have h9 : (int.fract (α * ↑i) - int.fract (α * ↑j)) / (i - j) ∈ ∅, from by { apply set.not_mem_empty, exact h8, }, have h10 : false, from by { rw h9, }, exact h10, }, have h11 : int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume h12 : int.fract (α * ↑i) = int.fract (α * ↑j), have h13 : α = (int.fract (α * ↑i) - int.fract (α * ↑j)) / (i - j), from by { rw h12, ring, }, exact h3 h13, }, exact h11, have h14 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h15 : i ≠ j, exact h1 i j h15, }, have h16 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h17 : i ≠ j, exact h14 j i (ne.symm h17), }, have h18 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h19 : i ≠ j, exact h16 j i (ne.symm h19), }, have h20 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h21 : i ≠ j, exact h18 i j h21, }, have h22 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h23 : i ≠ j, exact h20 j i (ne.symm h23), }, have h24 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h25 : i ≠ j, exact h22 i j h25, }, have h26 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h27 : i ≠ j, exact h24 j i (ne.symm h27), }, have h28 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h29 : i ≠ j, exact h26 i j h29, }, have h30 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h31 : i ≠ j, exact h28 j i (ne.symm h31), }, have h32 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h33 : i ≠ j, exact h30 i j h33, }, have h34 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h35 : i ≠ j, exact h32 j i (ne.symm h35), }, have h36 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h37 : i ≠ j, exact h34 i j h37, }, have h38 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h39 : i ≠ j, exact h36 j i (ne.symm h39), }, have h40 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h41 : i ≠ j, exact h38 i j h41, }, have h42 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h43 : i ≠ j, exact h40 j i (ne.symm h43), }, have h44 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h45 : i ≠ j, exact h42 i j h45, }, have h46 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume h47 : i ≠ j, exact h44 j i (ne.symm h47), }, have h48 : ∀ i j : ℤ, i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by { assume i j, assume end --Needs more than 2000 tokens! --OUTPUT 3 theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := begin have h1 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) ≠ int.fract (α * ↑j), from assume (i j : ℤ) (h2 : i ≠ j), have h3 : α = (int.fract (α * ↑i) - int.fract (α * ↑j)) / (i - j), from by { rw [int.fract_eq_sub_floor, int.fract_eq_sub_floor], ring, }, have h4 : (i - j) ≠ 0, from by { assume h5 : (i - j) = 0, have h6 : α = 0, from by {rw [h5, sub_eq_zero] at h3, rw [h3, div_zero]}, have h7 : α ≠ 0, from by {apply hα_irrat.ne,}, contradiction, }, have h8 : α ∈ ℚ, from by {rw [h3, ← int.coe_nat_eq_coe_int_of_nonneg (int.coe_nat_lt_coe_int_of_lt (int.coe_nat_pos_of_ne_zero h4))], apply_instance}, have h9 : α ∉ ℚ, from by {apply hα_irrat.ne,}, contradiction, have h10 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) - int.fract (α * ↑j) ≠ 0, from assume (i j : ℤ) (h11 : i ≠ j), have h12 : int.fract (α * ↑i) ≠ int.fract (α * ↑j), from by {apply h1, exact h11,}, have h13 : int.fract (α * ↑i) - int.fract (α * ↑j) ≠ 0, from by {apply sub_ne_zero_of_ne, exact h12,}, show int.fract (α * ↑i) - int.fract (α * ↑j) ≠ 0, from by {apply h13,}, have h14 : ∀ (i j : ℤ), i ≠ j → int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc 0 1, from assume (i j : ℤ) (h15 : i ≠ j), have h16 : int.fract (α * ↑i) - int.fract (α * ↑j) ≠ 0, from by {apply h10, exact h15,}, have h17 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc 0 1, from by { have h18 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-1) 1, from by { have h19 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-1) 2, from by { have h20 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-2) 2, from by { have h21 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-2) 3, from by { have h22 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-3) 3, from by { have h23 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-3) 4, from by { have h24 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-4) 4, from by { have h25 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-4) 5, from by { have h26 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-5) 5, from by { have h27 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-5) 6, from by { have h28 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-6) 6, from by { have h29 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-6) 7, from by { have h30 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-7) 7, from by { have h31 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-7) 8, from by { have h32 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-8) 8, from by { have h33 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-8) 9, from by { have h34 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-9) 9, from by { have h35 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-9) 10, from by { have h36 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-10) 10, from by { have h37 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-10) 11, from by { have h38 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-11) 11, from by { have h39 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-11) 12, from by { have h40 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-12) 12, from by { have h41 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-12) 13, from by { have h42 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-13) 13, from by { have h43 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-13) 14, from by { have h44 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-14) 14, from by { have h45 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-14) 15, from by { have h46 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-15) 15, from by { have h47 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-15) 16, from by { have h48 : int.fract (α * ↑i) - int.fract (α * ↑j) ∈ set.Icc (-16 end --Needs more than 2000 tokens! /- FEW SHOT PROMPTS TO CODEX(START) /--`theorem` Power Set is Closed under Intersection Let $S$ be a set. Let $\powerset S$ be the power set of $S$. Then: :$\forall A, B \in \powerset S: A \cap B \in \powerset S$ `proof` Let $A, B \in \powerset S$. Then by the definition of power set, $A \subseteq S$ and $B \subseteq S$. From Intersection is Subset we have that $A \cap B \subseteq A$. It follows from Subset Relation is Transitive that $A \cap B \subseteq S$. Thus $A \cap B \in \powerset S$ and closure is proved. {{qed}} -/ theorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S := begin assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S), have h1 : (A ⊆ S) ∧ (B ⊆ S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB}, have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left, have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left}, show (A ∩ B) ∈ 𝒫 S, from by {apply set.mem_powerset h3}, end /--`theorem` Square of Sum :$\forall x, y \in \R: \paren {x + y}^2 = x^2 + 2 x y + y^2$ `proof` Follows from the distribution of multiplication over addition: {{begin-eqn}} {{eqn | l = \left({x + y}\right)^2 | r = \left({x + y}\right) \cdot \left({x + y}\right) }} {{eqn | r = x \cdot \left({x + y}\right) + y \cdot \left({x + y}\right) | c = Real Multiplication Distributes over Addition }} {{eqn | r = x \cdot x + x \cdot y + y \cdot x + y \cdot y | c = Real Multiplication Distributes over Addition }} {{eqn | r = x^2 + 2xy + y^2 | c = }} {{end-eqn}} {{qed}} -/ theorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := begin calc (x + y)^2 = (x+y)*(x+y) : by rw sq ... = x*(x+y) + y*(x+y) : by rw add_mul ... = x*x + x*y + y*x + y*y : by {rw [mul_comm x (x+y),mul_comm y (x+y)], rw [add_mul,add_mul], ring} ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring} end /--`theorem` Identity of Group is Unique Let $\struct {G, \circ}$ be a group. Then there is a unique identity element $e \in G$. `proof` From Group has Latin Square Property, there exists a unique $x \in G$ such that: :$a x = b$ and there exists a unique $y \in G$ such that: :$y a = b$ Setting $b = a$, this becomes: There exists a unique $x \in G$ such that: :$a x = a$ and there exists a unique $y \in G$ such that: :$y a = a$ These $x$ and $y$ are both $e$, by definition of identity element. {{qed}} -/ theorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a := begin have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by { assume a b : G, use a⁻¹ * b, obviously, }, have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by { assume a b : G, use b * a⁻¹, obviously, }, have h3 : ∀ a : G, ∃! x : G, a * x = a, from assume a : G, h1 a a, have h4 : ∀ a : G, ∃! y : G, y * a = a, from assume a : G, h2 a a, have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G, exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a))) (mul_one a), have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G, exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by { use (1 : G), have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by { assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a), have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G), exists_unique.unique (h3 a) (hident a).right (classical.some_spec (exists_unique.exists (h3 a))), have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G), exists_unique.unique (h4 a) (hident a).left (classical.some_spec (exists_unique.exists (h4 a))), show e = (1 : G), from eq.trans (h9 e) (h6 _), }, exact ⟨by obviously, h7⟩, } end /--`theorem` Squeeze Theorem for Real Numbers Let $\sequence {x_n}$, $\sequence {y_n}$ and $\sequence {z_n}$ be sequences in $\R$. Let $\sequence {y_n}$ and $\sequence {z_n}$ both be convergent to the following limit: :$\ds \lim_{n \mathop \to \infty} y_n = l, \lim_{n \mathop \to \infty} z_n = l$ Suppose that: :$\forall n \in \N: y_n \le x_n \le z_n$ Then: :$x_n \to l$ as $n \to \infty$ that is: :$\ds \lim_{n \mathop \to \infty} x_n = l$ `proof` From Negative of Absolute Value: :$\size {x - l} < \epsilon \iff l - \epsilon < x < l + \epsilon$ Let $\epsilon > 0$. We need to prove that: :$\exists N: \forall n > N: \size {x_n - l} < \epsilon$ As $\ds \lim_{n \mathop \to \infty} y_n = l$ we know that: :$\exists N_1: \forall n > N_1: \size {y_n - l} < \epsilon$ As $\ds \lim_{n \mathop \to \infty} z_n = l$ we know that: :$\exists N_2: \forall n > N_2: \size {z_n - l} < \epsilon$ Let $N = \max \set {N_1, N_2}$. Then if $n > N$, it follows that $n > N_1$ and $n > N_2$. So: :$\forall n > N: l - \epsilon < y_n < l + \epsilon$ :$\forall n > N: l - \epsilon < z_n < l + \epsilon$ But: :$\forall n \in \N: y_n \le x_n \le z_n$ So: :$\forall n > N: l - \epsilon < y_n \le x_n \le z_n < l + \epsilon$ and so: :$\forall n > N: l - \epsilon < x_n < l + \epsilon$ So: :$\forall n > N: \size {x_n - l} < \epsilon$ Hence the result. {{qed}} -/ theorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) : let seq_limit : (ℕ → ℝ) → ℝ → Prop := λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in seq_limit y l → seq_limit z l → (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l := begin assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε), have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))), from by { intro x0, have h6 : |x0 - l| < ε ↔ ((x0 - l) < ε) ∧ ((l - x0) < ε), from abs_sub_lt_iff, rw h6, split, rintro ⟨ S_1, S_2 ⟩, split; linarith, rintro ⟨ S_3, S_4 ⟩, split; linarith, }, assume (h7 : ε > 0), cases h2 ε h7 with N1 h8, cases h3 ε h7 with N2 h9, let N := max N1 N2, use N, have h10 : ∀ n > N, n > N1 ∧ n > N2 := by { assume n h, split, exact lt_of_le_of_lt (le_max_left N1 N2) h, exact lt_of_le_of_lt (le_max_right N1 N2) h, }, have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)), from by { intros n h12, split, { have h13 := (h8 n (h10 n h12).left), rw h5 (y n) at h13, split, exact h13.left, exact (h4 n).left, }, { have h14 := (h9 n (h10 n h12).right),rw h5 (z n) at h14, split, exact (h4 n).right, exact h14.right, }, }, have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)), from by { intros n1 h16, cases (h11 n1 h16); split; linarith, }, show ∀ (n : ℕ), n > N → |x n - l| < ε, from by { intros n h17, cases h5 (x n) with h18 h19, apply h19, exact h15 n h17, }, end /--`theorem` Density of irrational orbit The fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval `proof` Let $\alpha$ be an irrational number. Then for distinct $i, j \in \mathbb{Z}$, we must have $\{i \alpha\} \neq\{j \alpha\}$. If this were not true, then $$ i \alpha-\lfloor i \alpha\rfloor=\{i \alpha\}=\{j \alpha\}=j \alpha-\lfloor j \alpha\rfloor, $$ which yields the false statement $\alpha=\frac{\lfloor i \alpha\rfloor-\lfloor j \alpha\rfloor}{i-j} \in \mathbb{Q}$. Hence, $$ S:=\{\{i \alpha\} \mid i \in \mathbb{Z}\} $$ is an infinite subset of $\left[0,1\right]$. By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$. One can thus find pairs of elements of $S$ that are arbitrarily close. Since (the absolute value of) the difference of any two elements of $S$ is also an element of $S$, it follows that $0$ is a limit point of $S$. To show that $S$ is dense in $[0, 1]$, consider $y \in[0,1]$, and $\epsilon>0$. Then by selecting $x \in S$ such that $\{x\}<\epsilon$ (which exists as $0$ is a limit point), and $N$ such that $N \cdot\{x\} \leq y<(N+1) \cdot\{x\}$, we get: $|y-\{N x\}|<\epsilon$. QED -/ theorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 := FEW SHOT PROMPTS TO CODEX(END)-/
/- Copyright (c) 2018 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin ! This file was ported from Lean 3 source module topology.instances.nnreal ! leanprover-community/mathlib commit 32253a1a1071173b33dc7d6a218cf722c6feb514 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Topology.Algebra.InfiniteSum.Order import Mathlib.Topology.Algebra.InfiniteSum.Ring import Mathlib.Topology.Instances.Real /-! # Topology on `ℝ≥0` The natural topology on `ℝ≥0` (the one induced from `ℝ`), and a basic API. ## Main definitions Instances for the following typeclasses are defined: * `TopologicalSpace ℝ≥0` * `TopologicalSemiring ℝ≥0` * `TopologicalSpace.SecondCountableTopology ℝ≥0` * `OrderTopology ℝ≥0` * `ContinuousSub ℝ≥0` * `HasContinuousInv₀ ℝ≥0` (continuity of `x⁻¹` away from `0`) * `ContinuousSMul ℝ≥0 α` (whenever `α` has a continuous `MulAction ℝ α`) Everything is inherited from the corresponding structures on the reals. ## Main statements Various mathematically trivial lemmas are proved about the compatibility of limits and sums in `ℝ≥0` and `ℝ`. For example * `tendsto_coe {f : Filter α} {m : α → ℝ≥0} {x : ℝ≥0} : Filter.Tendsto (fun a, (m a : ℝ)) f (𝓝 (x : ℝ)) ↔ Filter.Tendsto m f (𝓝 x)` says that the limit of a filter along a map to `ℝ≥0` is the same in `ℝ` and `ℝ≥0`, and * `coe_tsum {f : α → ℝ≥0} : ((∑'a, f a) : ℝ) = (∑'a, (f a : ℝ))` says that says that a sum of elements in `ℝ≥0` is the same in `ℝ` and `ℝ≥0`. Similarly, some mathematically trivial lemmas about infinite sums are proved, a few of which rely on the fact that subtraction is continuous. -/ noncomputable section open Set TopologicalSpace Metric Filter open Topology namespace NNReal open NNReal BigOperators Filter instance : TopologicalSpace ℝ≥0 := inferInstance -- short-circuit type class inference instance : TopologicalSemiring ℝ≥0 where toContinuousAdd := continuousAdd_induced toRealHom toContinuousMul := continuousMul_induced toRealHom instance : SecondCountableTopology ℝ≥0 := inferInstanceAs (SecondCountableTopology { x : ℝ | 0 ≤ x }) instance : OrderTopology ℝ≥0 := orderTopology_of_ordConnected (t := Ici 0) section coe variable {α : Type _} open Filter Finset theorem _root_.continuous_real_toNNReal : Continuous Real.toNNReal := (continuous_id.max continuous_const).subtype_mk _ #align continuous_real_to_nnreal continuous_real_toNNReal theorem continuous_coe : Continuous ((↑) : ℝ≥0 → ℝ) := continuous_subtype_val #align nnreal.continuous_coe NNReal.continuous_coe /-- Embedding of `ℝ≥0` to `ℝ` as a bundled continuous map. -/ @[simps (config := { fullyApplied := false })] def _root_.ContinuousMap.coeNNRealReal : C(ℝ≥0, ℝ) := ⟨(↑), continuous_coe⟩ #align continuous_map.coe_nnreal_real ContinuousMap.coeNNRealReal #align continuous_map.coe_nnreal_real_apply ContinuousMap.coeNNRealReal_apply instance ContinuousMap.canLift {X : Type _} [TopologicalSpace X] : CanLift C(X, ℝ) C(X, ℝ≥0) ContinuousMap.coeNNRealReal.comp fun f => ∀ x, 0 ≤ f x where prf f hf := ⟨⟨fun x => ⟨f x, hf x⟩, f.2.subtype_mk _⟩, FunLike.ext' rfl⟩ #align nnreal.continuous_map.can_lift NNReal.ContinuousMap.canLift @[simp, norm_cast] theorem tendsto_coe {f : Filter α} {m : α → ℝ≥0} {x : ℝ≥0} : Tendsto (fun a => (m a : ℝ)) f (𝓝 (x : ℝ)) ↔ Tendsto m f (𝓝 x) := tendsto_subtype_rng.symm #align nnreal.tendsto_coe NNReal.tendsto_coe theorem tendsto_coe' {f : Filter α} [NeBot f] {m : α → ℝ≥0} {x : ℝ} : Tendsto (fun a => m a : α → ℝ) f (𝓝 x) ↔ ∃ hx : 0 ≤ x, Tendsto m f (𝓝 ⟨x, hx⟩) := ⟨fun h => ⟨ge_of_tendsto' h fun c => (m c).2, tendsto_coe.1 h⟩, fun ⟨_, hm⟩ => tendsto_coe.2 hm⟩ #align nnreal.tendsto_coe' NNReal.tendsto_coe' @[simp] theorem map_coe_atTop : map toReal atTop = atTop := map_val_Ici_atTop 0 #align nnreal.map_coe_at_top NNReal.map_coe_atTop theorem comap_coe_atTop : comap toReal atTop = atTop := (atTop_Ici_eq 0).symm #align nnreal.comap_coe_at_top NNReal.comap_coe_atTop @[simp, norm_cast] theorem tendsto_coe_atTop {f : Filter α} {m : α → ℝ≥0} : Tendsto (fun a => (m a : ℝ)) f atTop ↔ Tendsto m f atTop := tendsto_Ici_atTop.symm #align nnreal.tendsto_coe_at_top NNReal.tendsto_coe_atTop theorem _root_.tendsto_real_toNNReal {f : Filter α} {m : α → ℝ} {x : ℝ} (h : Tendsto m f (𝓝 x)) : Tendsto (fun a => Real.toNNReal (m a)) f (𝓝 (Real.toNNReal x)) := (continuous_real_toNNReal.tendsto _).comp h #align tendsto_real_to_nnreal tendsto_real_toNNReal theorem _root_.tendsto_real_toNNReal_atTop : Tendsto Real.toNNReal atTop atTop := by rw [← tendsto_coe_atTop] exact tendsto_atTop_mono Real.le_coe_toNNReal tendsto_id #align tendsto_real_to_nnreal_at_top tendsto_real_toNNReal_atTop theorem nhds_zero : 𝓝 (0 : ℝ≥0) = ⨅ (a : ℝ≥0) (_h : a ≠ 0), 𝓟 (Iio a) := nhds_bot_order.trans <| by simp only [bot_lt_iff_ne_bot]; rfl #align nnreal.nhds_zero NNReal.nhds_zero theorem nhds_zero_basis : (𝓝 (0 : ℝ≥0)).HasBasis (fun a : ℝ≥0 => 0 < a) fun a => Iio a := nhds_bot_basis #align nnreal.nhds_zero_basis NNReal.nhds_zero_basis instance : ContinuousSub ℝ≥0 := ⟨((continuous_coe.fst'.sub continuous_coe.snd').max continuous_const).subtype_mk _⟩ instance : HasContinuousInv₀ ℝ≥0 := inferInstance instance [TopologicalSpace α] [MulAction ℝ α] [ContinuousSMul ℝ α] : ContinuousSMul ℝ≥0 α where continuous_smul := continuous_induced_dom.fst'.smul continuous_snd @[norm_cast] theorem hasSum_coe {f : α → ℝ≥0} {r : ℝ≥0} : HasSum (fun a => (f a : ℝ)) (r : ℝ) ↔ HasSum f r := by simp only [HasSum, ← coe_sum, tendsto_coe] #align nnreal.has_sum_coe NNReal.hasSum_coe protected theorem _root_.HasSum.toNNReal {f : α → ℝ} {y : ℝ} (hf₀ : ∀ n, 0 ≤ f n) (hy : HasSum f y) : HasSum (fun x => Real.toNNReal (f x)) y.toNNReal := by lift y to ℝ≥0 using hy.nonneg hf₀ lift f to α → ℝ≥0 using hf₀ simpa [hasSum_coe] using hy theorem hasSum_real_toNNReal_of_nonneg {f : α → ℝ} (hf_nonneg : ∀ n, 0 ≤ f n) (hf : Summable f) : HasSum (fun n => Real.toNNReal (f n)) (Real.toNNReal (∑' n, f n)) := hf.hasSum.toNNReal hf_nonneg #align nnreal.has_sum_real_to_nnreal_of_nonneg NNReal.hasSum_real_toNNReal_of_nonneg @[norm_cast] theorem summable_coe {f : α → ℝ≥0} : (Summable fun a => (f a : ℝ)) ↔ Summable f := by constructor exact fun ⟨a, ha⟩ => ⟨⟨a, ha.nonneg fun x => (f x).2⟩, hasSum_coe.1 ha⟩ exact fun ⟨a, ha⟩ => ⟨a.1, hasSum_coe.2 ha⟩ #align nnreal.summable_coe NNReal.summable_coe theorem summable_mk {f : α → ℝ} (hf : ∀ n, 0 ≤ f n) : (@Summable ℝ≥0 _ _ _ fun n => ⟨f n, hf n⟩) ↔ Summable f := Iff.symm <| summable_coe (f := fun x => ⟨f x, hf x⟩) #align nnreal.summable_coe_of_nonneg NNReal.summable_mk open Classical @[norm_cast] theorem coe_tsum {f : α → ℝ≥0} : ↑(∑' a, f a) = ∑' a, (f a : ℝ) := if hf : Summable f then Eq.symm <| (hasSum_coe.2 <| hf.hasSum).tsum_eq else by simp [tsum_def, hf, mt summable_coe.1 hf] #align nnreal.coe_tsum NNReal.coe_tsum theorem coe_tsum_of_nonneg {f : α → ℝ} (hf₁ : ∀ n, 0 ≤ f n) : (⟨∑' n, f n, tsum_nonneg hf₁⟩ : ℝ≥0) = (∑' n, ⟨f n, hf₁ n⟩ : ℝ≥0) := NNReal.eq <| Eq.symm <| coe_tsum (f := fun x => ⟨f x, hf₁ x⟩) #align nnreal.coe_tsum_of_nonneg NNReal.coe_tsum_of_nonneg nonrec theorem tsum_mul_left (a : ℝ≥0) (f : α → ℝ≥0) : (∑' x, a * f x) = a * ∑' x, f x := NNReal.eq <| by simp only [coe_tsum, NNReal.coe_mul, tsum_mul_left] #align nnreal.tsum_mul_left NNReal.tsum_mul_left nonrec theorem tsum_mul_right (f : α → ℝ≥0) (a : ℝ≥0) : (∑' x, f x * a) = (∑' x, f x) * a := NNReal.eq <| by simp only [coe_tsum, NNReal.coe_mul, tsum_mul_right] #align nnreal.tsum_mul_right NNReal.tsum_mul_right theorem summable_comp_injective {β : Type _} {f : α → ℝ≥0} (hf : Summable f) {i : β → α} (hi : Function.Injective i) : Summable (f ∘ i) := by rw [← summable_coe] at hf ⊢ exact hf.comp_injective hi #align nnreal.summable_comp_injective NNReal.summable_comp_injective theorem summable_nat_add (f : ℕ → ℝ≥0) (hf : Summable f) (k : ℕ) : Summable fun i => f (i + k) := summable_comp_injective hf <| add_left_injective k #align nnreal.summable_nat_add NNReal.summable_nat_add nonrec theorem summable_nat_add_iff {f : ℕ → ℝ≥0} (k : ℕ) : (Summable fun i => f (i + k)) ↔ Summable f := by rw [← summable_coe, ← summable_coe] exact @summable_nat_add_iff ℝ _ _ _ (fun i => (f i : ℝ)) k #align nnreal.summable_nat_add_iff NNReal.summable_nat_add_iff nonrec theorem hasSum_nat_add_iff {f : ℕ → ℝ≥0} (k : ℕ) {a : ℝ≥0} : HasSum (fun n => f (n + k)) a ↔ HasSum f (a + ∑ i in range k, f i) := by rw [← hasSum_coe, hasSum_nat_add_iff (f := fun n => toReal (f n)) k]; norm_cast #align nnreal.has_sum_nat_add_iff NNReal.hasSum_nat_add_iff theorem sum_add_tsum_nat_add {f : ℕ → ℝ≥0} (k : ℕ) (hf : Summable f) : (∑' i, f i) = (∑ i in range k, f i) + ∑' i, f (i + k) := (sum_add_tsum_nat_add' <| (summable_nat_add_iff k).2 hf).symm #align nnreal.sum_add_tsum_nat_add NNReal.sum_add_tsum_nat_add theorem infᵢ_real_pos_eq_infᵢ_nnreal_pos [CompleteLattice α] {f : ℝ → α} : (⨅ (n : ℝ) (_h : 0 < n), f n) = ⨅ (n : ℝ≥0) (_h : 0 < n), f n := le_antisymm (infᵢ_mono' fun r => ⟨r, le_rfl⟩) (infᵢ₂_mono' fun r hr => ⟨⟨r, hr.le⟩, hr, le_rfl⟩) #align nnreal.infi_real_pos_eq_infi_nnreal_pos NNReal.infᵢ_real_pos_eq_infᵢ_nnreal_pos end coe theorem tendsto_cofinite_zero_of_summable {α} {f : α → ℝ≥0} (hf : Summable f) : Tendsto f cofinite (𝓝 0) := by simp only [← summable_coe, ← tendsto_coe] at hf ⊢ exact hf.tendsto_cofinite_zero #align nnreal.tendsto_cofinite_zero_of_summable NNReal.tendsto_cofinite_zero_of_summable theorem tendsto_atTop_zero_of_summable {f : ℕ → ℝ≥0} (hf : Summable f) : Tendsto f atTop (𝓝 0) := by rw [← Nat.cofinite_eq_atTop] exact tendsto_cofinite_zero_of_summable hf #align nnreal.tendsto_at_top_zero_of_summable NNReal.tendsto_atTop_zero_of_summable /-- The sum over the complement of a finset tends to `0` when the finset grows to cover the whole space. This does not need a summability assumption, as otherwise all sums are zero. -/ nonrec theorem tendsto_tsum_compl_atTop_zero {α : Type _} (f : α → ℝ≥0) : Tendsto (fun s : Finset α => ∑' b : { x // x ∉ s }, f b) atTop (𝓝 0) := by simp_rw [← tendsto_coe, coe_tsum, NNReal.coe_zero] exact tendsto_tsum_compl_atTop_zero fun a : α => (f a : ℝ) #align nnreal.tendsto_tsum_compl_at_top_zero NNReal.tendsto_tsum_compl_atTop_zero /-- `x ↦ x ^ n` as an order isomorphism of `ℝ≥0`. -/ def powOrderIso (n : ℕ) (hn : n ≠ 0) : ℝ≥0 ≃o ℝ≥0 := StrictMono.orderIsoOfSurjective (fun x ↦ x ^ n) (fun x y h => strictMonoOn_pow hn.bot_lt (zero_le x) (zero_le y) h) <| (continuous_id.pow _).surjective (tendsto_pow_atTop hn) <| by simpa [OrderBot.atBot_eq, pos_iff_ne_zero] #align nnreal.pow_order_iso NNReal.powOrderIso end NNReal
lemma complex_unimodular_polar: assumes "norm z = 1" obtains t where "0 \<le> t" "t < 2 * pi" "z = Complex (cos t) (sin t)"
------------------------------------------------------------------------------ -- Definition of the gcd of two natural numbers using the Euclid's algorithm ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module LTC-PCF.Program.GCD.Partial.GCD where open import LTC-PCF.Base open import LTC-PCF.Data.Nat open import LTC-PCF.Data.Nat.Inequalities open import LTC-PCF.Loop ------------------------------------------------------------------------------ -- In GHC ≤ 7.0.4 the gcd is a partial function, i.e. gcd 0 0 = undefined. -- Let T = D → D → D be a type. Instead of defining gcdh : T → T, we -- use the LTC-PCF λ-abstraction and application to avoid use a -- polymorphic fixed-point operator. gcdh : D → D gcdh g = lam (λ m → lam (λ n → if (iszero₁ n) then (if (iszero₁ m) then error else m) else (if (iszero₁ m) then n else (if (gt m n) then g · (m ∸ n) · n else g · m · (n ∸ m))))) gcd : D → D → D gcd m n = fix gcdh · m · n
#pragma once #include <VFSPP/core.hpp> #include <boost/unordered_map.hpp> #include <boost/shared_array.hpp> #include <boost/shared_ptr.hpp> namespace vfspp { namespace memory { class MemoryFileSystem; class VFSPP_EXPORT MemoryFileEntry : public IFileSystemEntry { private: EntryType type; std::vector<boost::shared_ptr<MemoryFileEntry> > fileEntries; boost::unordered_map<string_type, size_t> indexMapping; size_t dataSize; boost::shared_array<char> data; time_t writeTime; MemoryFileEntry(const string_type& path) : IFileSystemEntry(path), dataSize(0), writeTime(0), type(UNKNOWN) {} FileEntryPointer getChildInternal(const string_type& path); public: virtual ~MemoryFileEntry() {} virtual FileEntryPointer getChild(const string_type& path) VFSPP_OVERRIDE; virtual size_t numChildren() VFSPP_OVERRIDE; virtual void listChildren(std::vector<FileEntryPointer>& outVector) VFSPP_OVERRIDE; virtual boost::shared_ptr<std::streambuf> open(int mode = MODE_READ) VFSPP_OVERRIDE; virtual EntryType getType() const VFSPP_OVERRIDE; virtual bool deleteChild(const string_type& name) VFSPP_OVERRIDE; virtual FileEntryPointer createEntry(EntryType type, const string_type& name) VFSPP_OVERRIDE; virtual void rename(const string_type& newPath) VFSPP_OVERRIDE; virtual time_t lastWriteTime() VFSPP_OVERRIDE { return writeTime; } boost::shared_ptr<MemoryFileEntry> addChild(const string_type& name, EntryType type, time_t write_time = 0, void* data = 0, size_t dataSize = 0); friend class MemoryFileSystem; }; class VFSPP_EXPORT MemoryFileSystem : public IFileSystem { private: boost::scoped_ptr<MemoryFileEntry> rootEntry; public: MemoryFileSystem(); virtual ~MemoryFileSystem() {} virtual MemoryFileEntry* getRootEntry() VFSPP_OVERRIDE { return rootEntry.get(); } virtual int supportedOperations() const VFSPP_OVERRIDE{ return OP_READ; } virtual string_type getName() const { return "Memory filesystem"; }; }; } }
(*<*) theory CodeGen imports Main begin (*>*) section{*Case Study: Compiling Expressions*} text{*\label{sec:ExprCompiler} \index{compiling expressions example|(}% The task is to develop a compiler from a generic type of expressions (built from variables, constants and binary operations) to a stack machine. This generic type of expressions is a generalization of the boolean expressions in \S\ref{sec:boolex}. This time we do not commit ourselves to a particular type of variables or values but make them type parameters. Neither is there a fixed set of binary operations: instead the expression contains the appropriate function itself. *} type_synonym 'v binop = "'v \<Rightarrow> 'v \<Rightarrow> 'v" datatype (dead 'a, 'v) expr = Cex 'v | Vex 'a | Bex "'v binop" "('a,'v)expr" "('a,'v)expr" text{*\noindent The three constructors represent constants, variables and the application of a binary operation to two subexpressions. The value of an expression with respect to an environment that maps variables to values is easily defined: *} primrec "value" :: "('a,'v)expr \<Rightarrow> ('a \<Rightarrow> 'v) \<Rightarrow> 'v" where "value (Cex v) env = v" | "value (Vex a) env = env a" | "value (Bex f e1 e2) env = f (value e1 env) (value e2 env)" text{* The stack machine has three instructions: load a constant value onto the stack, load the contents of an address onto the stack, and apply a binary operation to the two topmost elements of the stack, replacing them by the result. As for @{text"expr"}, addresses and values are type parameters: *} datatype (dead 'a, 'v) instr = Const 'v | Load 'a | Apply "'v binop" text{* The execution of the stack machine is modelled by a function @{text"exec"} that takes a list of instructions, a store (modelled as a function from addresses to values, just like the environment for evaluating expressions), and a stack (modelled as a list) of values, and returns the stack at the end of the execution --- the store remains unchanged: *} primrec exec :: "('a,'v)instr list \<Rightarrow> ('a\<Rightarrow>'v) \<Rightarrow> 'v list \<Rightarrow> 'v list" where "exec [] s vs = vs" | "exec (i#is) s vs = (case i of Const v \<Rightarrow> exec is s (v#vs) | Load a \<Rightarrow> exec is s ((s a)#vs) | Apply f \<Rightarrow> exec is s ((f (hd vs) (hd(tl vs)))#(tl(tl vs))))" text{*\noindent Recall that @{term"hd"} and @{term"tl"} return the first element and the remainder of a list. Because all functions are total, \cdx{hd} is defined even for the empty list, although we do not know what the result is. Thus our model of the machine always terminates properly, although the definition above does not tell us much about the result in situations where @{term"Apply"} was executed with fewer than two elements on the stack. The compiler is a function from expressions to a list of instructions. Its definition is obvious: *} primrec compile :: "('a,'v)expr \<Rightarrow> ('a,'v)instr list" where "compile (Cex v) = [Const v]" | "compile (Vex a) = [Load a]" | "compile (Bex f e1 e2) = (compile e2) @ (compile e1) @ [Apply f]" text{* Now we have to prove the correctness of the compiler, i.e.\ that the execution of a compiled expression results in the value of the expression: *} theorem "exec (compile e) s [] = [value e s]" (*<*)oops(*>*) text{*\noindent This theorem needs to be generalized: *} theorem "\<forall>vs. exec (compile e) s vs = (value e s) # vs" txt{*\noindent It will be proved by induction on @{term"e"} followed by simplification. First, we must prove a lemma about executing the concatenation of two instruction sequences: *} (*<*)oops(*>*) lemma exec_app[simp]: "\<forall>vs. exec (xs@ys) s vs = exec ys s (exec xs s vs)" txt{*\noindent This requires induction on @{term"xs"} and ordinary simplification for the base cases. In the induction step, simplification leaves us with a formula that contains two @{text"case"}-expressions over instructions. Thus we add automatic case splitting, which finishes the proof: *} apply(induct_tac xs, simp, simp split: instr.split) (*<*)done(*>*) text{*\noindent Note that because both \methdx{simp_all} and \methdx{auto} perform simplification, they can be modified in the same way as @{text simp}. Thus the proof can be rewritten as *} (*<*) declare exec_app[simp del] We could now go back and prove @{prop"exec (compile e) s [] = [value e s]"} merely by simplification with the generalized version we just proved. However, this is unnecessary because the generalized version fully subsumes its instance.% \index{compiling expressions example|)} *} (*<*) theorem "\<forall>vs. exec (compile e) s vs = (value e s) # vs" by(induct_tac e, auto) end (*>*)
import tactic import data.set.finite import data.real.basic import data.real.ereal import linear_algebra.affine_space.independent import analysis.convex.basic import topology.sequences noncomputable theory open set affine topological_space open_locale affine filter big_operators variables {V : Type*} [add_comm_group V] [module ℝ V] variables [affine_space V V] variables {k n : ℕ} variables (Δ : simplex ℝ V n) def pts (C : simplex ℝ V k) : set V := convex_hull (C.points '' univ) structure triangulation := (simps : set (@simplex ℝ V V _ _ _ _ n) ) (cov : (⋃ s ∈ simps, (pts s)) = pts Δ) --(inter : ∀ s t ∈ simps, (pts s) ∩ (pts t) ≠ ∅ → ∃ (m : ℕ) (st m), -- (pts s) ∩ (pts t) = pts st) -- exercici: escriure la condició d'intersecció fent servir "face". lemma fixed_point_of_epsilon_fixed (X : Type) [metric_space X] [hsq : seq_compact_space X] (f : X → X) (hf : continuous f) (h : ∀ (ε : ℝ), 0 < ε → ∃ x, dist x (f x) < ε) : ∃ x : X, f x = x := begin have hpos : ∀ (n : ℕ), 0 < 1 / ((n+1) : ℝ), by apply nat.one_div_pos_of_nat, let a : ℕ → X := λ n, classical.some (h (1 / ((n+1) : ℝ)) (hpos n)), have ha : ∀ n, dist (a n) (f (a n)) < 1 / ((n+1) : ℝ) := λ n, classical.some_spec (h (1 / ((n+1) : ℝ)) (hpos n)), have exists_lim : ∃ (z ∈ univ) (Φ : ℕ → ℕ), strict_mono Φ ∧ filter.tendsto (a ∘ Φ) filter.at_top (nhds z), { apply hsq.seq_compact_univ, exact λ n, by tauto, }, obtain ⟨z, ⟨_, ⟨Φ, ⟨hΦ1, hΦ2⟩⟩⟩ ⟩ := exists_lim, use z, suffices : ∀ ε > 0, dist z (f z) ≤ ε, { rw [←dist_le_zero, dist_comm], exact le_of_forall_le_of_dense this, }, intros ε hε, have H1 : ∀ δ, 0 < δ → ∃ (n : ℕ), ∀ m ≥ n, dist z ((a ∘ Φ) m) < δ, { intros δ hδ, rw seq_tendsto_iff at hΦ2, specialize hΦ2 (metric.ball z (δ)) (by rwa [metric.mem_ball, dist_self]) (metric.is_open_ball), simp [metric.mem_ball, dist_comm] at hΦ2, simp only [function.comp_app], exact hΦ2, }, have H2 : ∃ (n : ℕ), ∀ m ≥ n, dist ((a∘Φ) m) (f ((a∘Φ) m)) ≤ ε/3, { have hkey : ∃ (n : ℕ), 1 / ((n+1):ℝ) < ε/3, { have hnlarge : ∃ (n : ℕ), (n :ℝ) > 3 / ε := exists_nat_gt (3 / ε), obtain ⟨n, hn⟩:= hnlarge, use n, have hn' : (n+1 : ℝ) > 3 / ε, by linarith, refine (inv_lt_inv _ (hpos n)).mp _, by linarith, field_simp, linarith, }, obtain ⟨n, hn⟩ := hkey, use n, intros m hm, specialize ha (Φ m), have hmn : 1 / ((m + 1) : ℝ) ≤ 1 / ((n + 1) : ℝ), by apply nat.one_div_le_one_div hm, have hinc : 1 / ((Φ m) + 1:ℝ) ≤ 1 / ((m + 1):ℝ), by exact nat.one_div_le_one_div (strict_mono.id_le hΦ1 m), linarith, }, have H3 : ∃ (n : ℕ), ∀ m ≥ n, dist (f ((a∘Φ) m)) (f z) < ε/3 := let ⟨δ, ⟨hδpos, h'⟩⟩ := (metric.continuous_iff.1 hf) z (ε/3) (by linarith), ⟨n1, hn1⟩ := H1 δ hδpos in ⟨n1, λ m hm, let h := hn1 m hm in h' (a (Φ m)) (by rwa dist_comm)⟩, obtain ⟨⟨n1, hn1⟩, ⟨n2, hn2⟩, ⟨n3, hn3⟩⟩ := ⟨H1 (ε / 3) (by linarith), H2, H3⟩, let n := max (max n1 n2) n3, specialize hn1 n (le_of_max_le_left (le_max_left (max n1 n2) n3)), specialize hn2 n (le_trans (le_max_right n1 n2) (le_max_left (max n1 n2) n3)), specialize hn3 n (le_max_right (max n1 n2) n3), calc dist z (f z) ≤ dist z ((a ∘ Φ) n) + dist ((a ∘ Φ) n) (f ((a ∘ Φ) n)) + dist (f ((a ∘ Φ) n)) (f z) : dist_triangle4 z ((a ∘ Φ) n) (f ((a ∘ Φ) n)) (f z) ... ≤ ε/3 + ε/3 + ε/3 : by { linarith [hn1, hn2, hn3] } ... = ε : by {ring}, end lemma le_min_right_or_left {α : Type*} [linear_order α] (a b : α) : a ≤ min a b ∨ b ≤ min a b := by cases (le_total a b) with h; simp [true_or, le_min rfl.ge h]; exact or.inr h lemma max_le_right_or_left {α : Type*} [linear_order α] (a b : α) : max a b ≤ a ∨ max a b ≤ b := by cases (le_total a b) with h; simp [true_or, max_le rfl.ge h]; exact or.inr h lemma edist_lt_of_diam_lt {X : Type*} [pseudo_emetric_space X] (s : set X) {d : ennreal} : emetric.diam s < d → ∀ (x ∈ s) (y ∈ s), edist x y < d := λ h x hx y hy, gt_of_gt_of_ge h (emetric.edist_le_diam_of_mem hx hy) lemma enndiameter_growth' {X : Type} [pseudo_emetric_space X] {S : set X} {f : X → X} (hf : uniform_continuous_on f S) : ∀ ε > 0, ∃ δ > 0, ∀ T ⊆ S, emetric.diam T < δ → emetric.diam (f '' T) ≤ ε := λ ε hε, let ⟨δ, hδ, H⟩ := emetric.uniform_continuous_on_iff.1 hf ε hε in ⟨δ, hδ, λ R hR hdR, emetric.diam_image_le_iff.2 (λ x hx y hy, le_of_lt (H (hR hx) (hR hy) (edist_lt_of_diam_lt R hdR x hx y hy)))⟩ lemma enndiameter_growth {X : Type} [pseudo_emetric_space X] {S : set X} {f : X → X} (hf : uniform_continuous_on f S) : ∀ ε > 0, ∃ δ > 0, ∀ T ⊆ S, emetric.diam T < δ → emetric.diam (f '' T) < ε := begin intros ε hε, set γ := min 1 (ε/2) with hhγ, have hγ : γ > 0, { cases (le_min_right_or_left 1 (ε/2)), { exact lt_of_lt_of_le (ennreal.zero_lt_one) h }, { exact lt_of_lt_of_le (ennreal.div_pos_iff.2 ⟨ne_of_gt hε, ennreal.two_ne_top⟩) h } }, obtain ⟨δ, hδ, H⟩ := enndiameter_growth' hf γ hγ, have hγε: γ < ε, { cases (lt_or_ge 1 ε), { exact lt_of_le_of_lt (min_le_left 1 (ε/2)) h }, { have hεtop := ne_of_lt (lt_of_le_of_lt h (lt_of_le_of_ne le_top ennreal.one_ne_top)), exact lt_of_le_of_lt (min_le_right 1 (ε/2)) (ennreal.half_lt_self (ne_of_gt hε) hεtop) } }, exact ⟨δ, hδ, (λ R hR hdR, lt_of_le_of_lt (H R hR hdR) hγε)⟩, end lemma diameter_growth (X : Type) [metric_space X] (S : set X) (f : X → X) (hf : uniform_continuous_on f S) (ε : ℝ) (hε : 0 < ε) : ∃ δ > 0, ∀ T ⊆ S, metric.bounded T → metric.diam T ≤ δ → metric.bounded (f '' T) ∧ metric.diam (f '' T) ≤ ε := begin sorry end variables {d : ℕ} local notation `E` := fin d → ℝ def H := { x: E | (∑ (i : fin d), x i) = 1} variables (f: E → E) example (a b : real) (r : ennreal) (h1 : (a : ereal) ≤ (b : ereal) + r) (h2 : (a : ereal) ≥ (b : ereal) - r) : ennreal.of_real (abs (a - b)) ≤ r := begin sorry end lemma points_coordinates_bounded_distance (x y : E) (i : fin d) : ennreal.of_real (abs (x i - y i)) ≤ edist x y := begin sorry end lemma points_coordinates_bounded_diam (S : set E) (x y : E) (hx : x ∈ S) (hy : y ∈ S) (i : fin d) : ennreal.of_real (abs (x i - y i)) ≤ emetric.diam S := begin sorry end -- per tota coordenada i, existeix un vertex v tal que la coordenada i-èssima -- és la primera que complex que f(v)_i < f(v) def is_sperner_set (f: E → E) (S : set E) := ∀ i: fin d, ∃ v : E, v ∈ S ∧ (∀ j < i, (f v) j ≥ (v j)) ∧ (((f v) i) < v i) lemma epsilon_fixed_condition {f : E → E} {S : set E} (hs : S ⊆ H) (hd : 0 < d) (hf : uniform_continuous_on f S) {ε : real} (hε : 0 < ε) : ∃ δ, 0 < δ ∧ ∀ T ⊆ S, metric.bounded T → metric.diam T < δ → is_sperner_set f T → ∀ x ∈ T, dist (f x) x < ε := begin let ε₁ := ε / (2 * d), have h₁ := div_pos hε (mul_pos zero_lt_two (nat.cast_pos.mpr hd)), obtain ⟨δ₀, hδ₀pos, hδ₀⟩ := metric.uniform_continuous_on_iff.mp hf ε₁ h₁, let δ := min δ₀ (ε₁/2), use δ, split, { cases le_min_right_or_left δ₀ (ε₁/2), { exact gt_of_ge_of_gt h hδ₀pos }, { exact lt_min hδ₀pos (half_pos h₁) } }, intros T hTS hbT hdT hfT x hx, have hmost : ∀ (i : fin d) (hi : (i : ℕ) ≠ d-1), abs (((f x) i)-(x i)) ≤ δ + (metric.diam (f '' T)), { intros i hi, rw abs_sub_le_iff, split, { sorry }, { sorry } }, have hlast : abs(((f x) ⟨d-1, buffer.lt_aux_2 hd⟩)) - x ⟨d-1, buffer.lt_aux_2 hd⟩ ≤ (d-1) * (δ + (metric.diam (f '' T))), { sorry }, sorry end
[GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ↑⁅I, N⁆ = Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] apply le_antisymm [GOAL] case a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ↑⁅I, N⁆ ≤ Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] let s := {m : M | ∃ (x : ↥I) (n : ↥N), ⁅(x : L), (n : M)⁆ = m} [GOAL] case a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊢ ↑⁅I, N⁆ ≤ Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] have aux : ∀ (y : L), ∀ m' ∈ Submodule.span R s, ⁅y, m'⁆ ∈ Submodule.span R s := by intro y m' hm' refine Submodule.span_induction (R := R) (M := M) (s := s) (p := fun m' ↦ ⁅y, m'⁆ ∈ Submodule.span R s) hm' ?_ ?_ ?_ ?_ · rintro m'' ⟨x, n, hm''⟩; rw [← hm'', leibniz_lie] refine Submodule.add_mem _ ?_ ?_ <;> apply Submodule.subset_span · use⟨⁅y, ↑x⁆, I.lie_mem x.property⟩, n · use x, ⟨⁅y, ↑n⁆, N.lie_mem n.property⟩ · simp only [lie_zero, Submodule.zero_mem] · intro m₁ m₂ hm₁ hm₂; rw [lie_add]; exact Submodule.add_mem _ hm₁ hm₂ · intro t m'' hm''; rw [lie_smul]; exact Submodule.smul_mem _ t hm'' [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊢ ∀ (y : L) (m' : M), m' ∈ Submodule.span R s → ⁅y, m'⁆ ∈ Submodule.span R s [PROOFSTEP] intro y m' hm' [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s ⊢ ⁅y, m'⁆ ∈ Submodule.span R s [PROOFSTEP] refine Submodule.span_induction (R := R) (M := M) (s := s) (p := fun m' ↦ ⁅y, m'⁆ ∈ Submodule.span R s) hm' ?_ ?_ ?_ ?_ [GOAL] case refine_1 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s ⊢ ∀ (x : M), x ∈ s → (fun m' => ⁅y, m'⁆ ∈ Submodule.span R s) x [PROOFSTEP] rintro m'' ⟨x, n, hm''⟩ [GOAL] case refine_1.intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s m'' : M x : { x // x ∈ I } n : { x // x ∈ N } hm'' : ⁅↑x, ↑n⁆ = m'' ⊢ ⁅y, m''⁆ ∈ Submodule.span R s [PROOFSTEP] rw [← hm'', leibniz_lie] [GOAL] case refine_1.intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s m'' : M x : { x // x ∈ I } n : { x // x ∈ N } hm'' : ⁅↑x, ↑n⁆ = m'' ⊢ ⁅⁅y, ↑x⁆, ↑n⁆ + ⁅↑x, ⁅y, ↑n⁆⁆ ∈ Submodule.span R s [PROOFSTEP] refine Submodule.add_mem _ ?_ ?_ [GOAL] case refine_1.intro.intro.refine_1 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s m'' : M x : { x // x ∈ I } n : { x // x ∈ N } hm'' : ⁅↑x, ↑n⁆ = m'' ⊢ ⁅⁅y, ↑x⁆, ↑n⁆ ∈ Submodule.span R s [PROOFSTEP] apply Submodule.subset_span [GOAL] case refine_1.intro.intro.refine_2 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s m'' : M x : { x // x ∈ I } n : { x // x ∈ N } hm'' : ⁅↑x, ↑n⁆ = m'' ⊢ ⁅↑x, ⁅y, ↑n⁆⁆ ∈ Submodule.span R s [PROOFSTEP] apply Submodule.subset_span [GOAL] case refine_1.intro.intro.refine_1.a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s m'' : M x : { x // x ∈ I } n : { x // x ∈ N } hm'' : ⁅↑x, ↑n⁆ = m'' ⊢ ⁅⁅y, ↑x⁆, ↑n⁆ ∈ s [PROOFSTEP] use⟨⁅y, ↑x⁆, I.lie_mem x.property⟩, n [GOAL] case refine_1.intro.intro.refine_2.a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s m'' : M x : { x // x ∈ I } n : { x // x ∈ N } hm'' : ⁅↑x, ↑n⁆ = m'' ⊢ ⁅↑x, ⁅y, ↑n⁆⁆ ∈ s [PROOFSTEP] use x, ⟨⁅y, ↑n⁆, N.lie_mem n.property⟩ [GOAL] case refine_2 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s ⊢ (fun m' => ⁅y, m'⁆ ∈ Submodule.span R s) 0 [PROOFSTEP] simp only [lie_zero, Submodule.zero_mem] [GOAL] case refine_3 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s ⊢ ∀ (x y_1 : M), (fun m' => ⁅y, m'⁆ ∈ Submodule.span R s) x → (fun m' => ⁅y, m'⁆ ∈ Submodule.span R s) y_1 → (fun m' => ⁅y, m'⁆ ∈ Submodule.span R s) (x + y_1) [PROOFSTEP] intro m₁ m₂ hm₁ hm₂ [GOAL] case refine_3 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s m₁ m₂ : M hm₁ : ⁅y, m₁⁆ ∈ Submodule.span R s hm₂ : ⁅y, m₂⁆ ∈ Submodule.span R s ⊢ ⁅y, m₁ + m₂⁆ ∈ Submodule.span R s [PROOFSTEP] rw [lie_add] [GOAL] case refine_3 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s m₁ m₂ : M hm₁ : ⁅y, m₁⁆ ∈ Submodule.span R s hm₂ : ⁅y, m₂⁆ ∈ Submodule.span R s ⊢ ⁅y, m₁⁆ + ⁅y, m₂⁆ ∈ Submodule.span R s [PROOFSTEP] exact Submodule.add_mem _ hm₁ hm₂ [GOAL] case refine_4 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s ⊢ ∀ (a : R) (x : M), (fun m' => ⁅y, m'⁆ ∈ Submodule.span R s) x → (fun m' => ⁅y, m'⁆ ∈ Submodule.span R s) (a • x) [PROOFSTEP] intro t m'' hm'' [GOAL] case refine_4 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s t : R m'' : M hm'' : ⁅y, m''⁆ ∈ Submodule.span R s ⊢ ⁅y, t • m''⁆ ∈ Submodule.span R s [PROOFSTEP] rw [lie_smul] [GOAL] case refine_4 R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} y : L m' : M hm' : m' ∈ Submodule.span R s t : R m'' : M hm'' : ⁅y, m''⁆ ∈ Submodule.span R s ⊢ t • ⁅y, m''⁆ ∈ Submodule.span R s [PROOFSTEP] exact Submodule.smul_mem _ t hm'' [GOAL] case a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} aux : ∀ (y : L) (m' : M), m' ∈ Submodule.span R s → ⁅y, m'⁆ ∈ Submodule.span R s ⊢ ↑⁅I, N⁆ ≤ Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] change _ ≤ ({ Submodule.span R s with lie_mem := fun hm' => aux _ _ hm' } : LieSubmodule R L M) [GOAL] case a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} aux : ∀ (y : L) (m' : M), m' ∈ Submodule.span R s → ⁅y, m'⁆ ∈ Submodule.span R s ⊢ ⁅I, N⁆ ≤ let src := Submodule.span R s; { toSubmodule := { toAddSubmonoid := src.toAddSubmonoid, smul_mem' := (_ : ∀ (c : R) {x : M}, x ∈ src.carrier → c • x ∈ src.carrier) }, lie_mem := (_ : ∀ {x : L} {m : M}, m ∈ { toAddSubmonoid := src.toAddSubmonoid, smul_mem' := (_ : ∀ (c : R) {x : M}, x ∈ src.carrier → c • x ∈ src.carrier) }.toAddSubmonoid.toAddSubsemigroup.carrier → ⁅x, m⁆ ∈ Submodule.span R s) } [PROOFSTEP] rw [lieIdeal_oper_eq_span, lieSpan_le] [GOAL] case a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ s : Set M := {m | ∃ x n, ⁅↑x, ↑n⁆ = m} aux : ∀ (y : L) (m' : M), m' ∈ Submodule.span R s → ⁅y, m'⁆ ∈ Submodule.span R s ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑(let src := Submodule.span R s; { toSubmodule := { toAddSubmonoid := src.toAddSubmonoid, smul_mem' := (_ : ∀ (c : R) {x : M}, x ∈ src.carrier → c • x ∈ src.carrier) }, lie_mem := (_ : ∀ {x : L} {m : M}, m ∈ { toAddSubmonoid := src.toAddSubmonoid, smul_mem' := (_ : ∀ (c : R) {x : M}, x ∈ src.carrier → c • x ∈ src.carrier) }.toAddSubmonoid.toAddSubsemigroup.carrier → ⁅x, m⁆ ∈ Submodule.span R s) }) [PROOFSTEP] exact Submodule.subset_span [GOAL] case a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ≤ ↑⁅I, N⁆ [PROOFSTEP] rw [lieIdeal_oper_eq_span] [GOAL] case a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ≤ ↑(lieSpan R L {m | ∃ x n, ⁅↑x, ↑n⁆ = m}) [PROOFSTEP] apply submodule_span_le_lieSpan [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ↑⁅I, N⁆ = Submodule.span R {m | ∃ x, x ∈ I ∧ ∃ n, n ∈ N ∧ ⁅x, n⁆ = m} [PROOFSTEP] rw [lieIdeal_oper_eq_linear_span] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m} = Submodule.span R {m | ∃ x, x ∈ I ∧ ∃ n, n ∈ N ∧ ⁅x, n⁆ = m} [PROOFSTEP] congr [GOAL] case e_s R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} = {m | ∃ x, x ∈ I ∧ ∃ n, n ∈ N ∧ ⁅x, n⁆ = m} [PROOFSTEP] ext m [GOAL] case e_s.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ m : M ⊢ m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ↔ m ∈ {m | ∃ x, x ∈ I ∧ ∃ n, n ∈ N ∧ ⁅x, n⁆ = m} [PROOFSTEP] constructor [GOAL] case e_s.h.mp R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ m : M ⊢ m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} → m ∈ {m | ∃ x, x ∈ I ∧ ∃ n, n ∈ N ∧ ⁅x, n⁆ = m} [PROOFSTEP] rintro ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩ [GOAL] case e_s.h.mp.intro.mk.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ x : L hx : x ∈ I n : M hn : n ∈ N ⊢ ⁅↑{ val := x, property := hx }, ↑{ val := n, property := hn }⁆ ∈ {m | ∃ x, x ∈ I ∧ ∃ n, n ∈ N ∧ ⁅x, n⁆ = m} [PROOFSTEP] exact ⟨x, hx, n, hn, rfl⟩ [GOAL] case e_s.h.mpr R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ m : M ⊢ m ∈ {m | ∃ x, x ∈ I ∧ ∃ n, n ∈ N ∧ ⁅x, n⁆ = m} → m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rintro ⟨x, hx, n, hn, rfl⟩ [GOAL] case e_s.h.mpr.intro.intro.intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ x : L hx : x ∈ I n : M hn : n ∈ N ⊢ ⁅x, n⁆ ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] exact ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩ [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ≤ N' ↔ ∀ (x : L), x ∈ I → ∀ (m : M), m ∈ N → ⁅x, m⁆ ∈ N' [PROOFSTEP] rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N' ↔ ∀ (x : L), x ∈ I → ∀ (m : M), m ∈ N → ⁅x, m⁆ ∈ N' [PROOFSTEP] refine' ⟨fun h x hx m hm => h ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩, _⟩ [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ (∀ (x : L), x ∈ I → ∀ (m : M), m ∈ N → ⁅x, m⁆ ∈ N') → {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N' [PROOFSTEP] rintro h _ ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩ [GOAL] case intro.mk.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ∀ (x : L), x ∈ I → ∀ (m : M), m ∈ N → ⁅x, m⁆ ∈ N' x : L hx : x ∈ I m : M hm : m ∈ N ⊢ ⁅↑{ val := x, property := hx }, ↑{ val := m, property := hm }⁆ ∈ ↑N' [PROOFSTEP] exact h x hx m hm [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ x : { x // x ∈ I } m : { x // x ∈ N } ⊢ ⁅↑x, ↑m⁆ ∈ ⁅I, N⁆ [PROOFSTEP] rw [lieIdeal_oper_eq_span] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ x : { x // x ∈ I } m : { x // x ∈ N } ⊢ ⁅↑x, ↑m⁆ ∈ lieSpan R L {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] apply subset_lieSpan [GOAL] case a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ x : { x // x ∈ I } m : { x // x ∈ N } ⊢ ⁅↑x, ↑m⁆ ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] use x, m [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, J⁆ = ⁅J, I⁆ [PROOFSTEP] suffices ∀ I J : LieIdeal R L, ⁅I, J⁆ ≤ ⁅J, I⁆ by exact le_antisymm (this I J) (this J I) [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ this : ∀ (I J : LieIdeal R L), ⁅I, J⁆ ≤ ⁅J, I⁆ ⊢ ⁅I, J⁆ = ⁅J, I⁆ [PROOFSTEP] exact le_antisymm (this I J) (this J I) [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ∀ (I J : LieIdeal R L), ⁅I, J⁆ ≤ ⁅J, I⁆ [PROOFSTEP] clear! I J [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M N₂ : LieSubmodule R L M₂ ⊢ ∀ (I J : LieIdeal R L), ⁅I, J⁆ ≤ ⁅J, I⁆ [PROOFSTEP] intro I J [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M N₂ : LieSubmodule R L M₂ I J : LieIdeal R L ⊢ ⁅I, J⁆ ≤ ⁅J, I⁆ [PROOFSTEP] rw [lieIdeal_oper_eq_span, lieSpan_le] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M N₂ : LieSubmodule R L M₂ I J : LieIdeal R L ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑⁅J, I⁆ [PROOFSTEP] rintro x ⟨y, z, h⟩ [GOAL] case intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M N₂ : LieSubmodule R L M₂ I J : LieIdeal R L x : L y : { x // x ∈ I } z : { x // x ∈ J } h : ⁅↑y, ↑z⁆ = x ⊢ x ∈ ↑⁅J, I⁆ [PROOFSTEP] rw [← h] [GOAL] case intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M N₂ : LieSubmodule R L M₂ I J : LieIdeal R L x : L y : { x // x ∈ I } z : { x // x ∈ J } h : ⁅↑y, ↑z⁆ = x ⊢ ⁅↑y, ↑z⁆ ∈ ↑⁅J, I⁆ [PROOFSTEP] rw [← lie_skew, ← lie_neg, ← LieSubmodule.coe_neg] [GOAL] case intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M N₂ : LieSubmodule R L M₂ I J : LieIdeal R L x : L y : { x // x ∈ I } z : { x // x ∈ J } h : ⁅↑y, ↑z⁆ = x ⊢ ⁅↑z, ↑(-y)⁆ ∈ ↑⁅J, I⁆ [PROOFSTEP] apply lie_coe_mem_lie [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ≤ N [PROOFSTEP] rw [lieIdeal_oper_eq_span, lieSpan_le] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N [PROOFSTEP] rintro m ⟨x, n, hn⟩ [GOAL] case intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ m : M x : { x // x ∈ I } n : { x // x ∈ N } hn : ⁅↑x, ↑n⁆ = m ⊢ m ∈ ↑N [PROOFSTEP] rw [← hn] [GOAL] case intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ m : M x : { x // x ∈ I } n : { x // x ∈ N } hn : ⁅↑x, ↑n⁆ = m ⊢ ⁅↑x, ↑n⁆ ∈ ↑N [PROOFSTEP] exact N.lie_mem n.property [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, J⁆ ≤ I [PROOFSTEP] rw [lie_comm] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅J, I⁆ ≤ I [PROOFSTEP] exact lie_le_right I J [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, J⁆ ≤ I ⊓ J [PROOFSTEP] rw [le_inf_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, J⁆ ≤ I ∧ ⁅I, J⁆ ≤ J [PROOFSTEP] exact ⟨lie_le_left I J, lie_le_right J I⟩ [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, ⊥⁆ = ⊥ [PROOFSTEP] rw [eq_bot_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ∀ (m : M), m ∈ ⁅I, ⊥⁆ → m = 0 [PROOFSTEP] apply lie_le_right [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅⊥, N⁆ = ⊥ [PROOFSTEP] suffices ⁅(⊥ : LieIdeal R L), N⁆ ≤ ⊥ by exact le_bot_iff.mp this [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ this : ⁅⊥, N⁆ ≤ ⊥ ⊢ ⁅⊥, N⁆ = ⊥ [PROOFSTEP] exact le_bot_iff.mp this [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅⊥, N⁆ ≤ ⊥ [PROOFSTEP] rw [lieIdeal_oper_eq_span, lieSpan_le] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑⊥ [PROOFSTEP] rintro m ⟨⟨x, hx⟩, n, hn⟩ [GOAL] case intro.mk.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ m : M x : L hx : x ∈ ⊥ n : { x // x ∈ N } hn : ⁅↑{ val := x, property := hx }, ↑n⁆ = m ⊢ m ∈ ↑⊥ [PROOFSTEP] rw [← hn] [GOAL] case intro.mk.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ m : M x : L hx : x ∈ ⊥ n : { x // x ∈ N } hn : ⁅↑{ val := x, property := hx }, ↑n⁆ = m ⊢ ⁅↑{ val := x, property := hx }, ↑n⁆ ∈ ↑⊥ [PROOFSTEP] change x ∈ (⊥ : LieIdeal R L) at hx [GOAL] case intro.mk.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ m : M x : L n : { x // x ∈ N } hx : x ∈ ⊥ hn : ⁅↑{ val := x, property := hx }, ↑n⁆ = m ⊢ ⁅↑{ val := x, property := hx }, ↑n⁆ ∈ ↑⊥ [PROOFSTEP] rw [mem_bot] at hx [GOAL] case intro.mk.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ m : M x : L n : { x // x ∈ N } hx✝ : x ∈ ⊥ hx : x = 0 hn : ⁅↑{ val := x, property := hx✝ }, ↑n⁆ = m ⊢ ⁅↑{ val := x, property := hx✝ }, ↑n⁆ ∈ ↑⊥ [PROOFSTEP] simp [hx] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ = ⊥ ↔ ∀ (x : L), x ∈ I → ∀ (m : M), m ∈ N → ⁅x, m⁆ = 0 [PROOFSTEP] rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_eq_bot_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ (∀ (m : M), m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} → m = 0) ↔ ∀ (x : L), x ∈ I → ∀ (m : M), m ∈ N → ⁅x, m⁆ = 0 [PROOFSTEP] refine' ⟨fun h x hx m hm => h ⁅x, m⁆ ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩, _⟩ [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ (∀ (x : L), x ∈ I → ∀ (m : M), m ∈ N → ⁅x, m⁆ = 0) → ∀ (m : M), m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} → m = 0 [PROOFSTEP] rintro h - ⟨⟨x, hx⟩, ⟨⟨n, hn⟩, rfl⟩⟩ [GOAL] case intro.mk.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ∀ (x : L), x ∈ I → ∀ (m : M), m ∈ N → ⁅x, m⁆ = 0 x : L hx : x ∈ I n : M hn : n ∈ N ⊢ ⁅↑{ val := x, property := hx }, ↑{ val := n, property := hn }⁆ = 0 [PROOFSTEP] exact h x hx n hn [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h₁ : I ≤ J h₂ : N ≤ N' ⊢ ⁅I, N⁆ ≤ ⁅J, N'⁆ [PROOFSTEP] intro m h [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h₁ : I ≤ J h₂ : N ≤ N' m : M h : m ∈ ⁅I, N⁆ ⊢ m ∈ ⁅J, N'⁆ [PROOFSTEP] rw [lieIdeal_oper_eq_span, mem_lieSpan] at h [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h₁ : I ≤ J h₂ : N ≤ N' m : M h : ∀ (N_1 : LieSubmodule R L M), {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N_1 → m ∈ N_1 ⊢ m ∈ ⁅J, N'⁆ [PROOFSTEP] rw [lieIdeal_oper_eq_span, mem_lieSpan] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h₁ : I ≤ J h₂ : N ≤ N' m : M h : ∀ (N_1 : LieSubmodule R L M), {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N_1 → m ∈ N_1 ⊢ ∀ (N : LieSubmodule R L M), {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N → m ∈ N [PROOFSTEP] intro N hN [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N✝ N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h₁ : I ≤ J h₂ : N✝ ≤ N' m : M h : ∀ (N : LieSubmodule R L M), {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N → m ∈ N N : LieSubmodule R L M hN : {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N ⊢ m ∈ N [PROOFSTEP] apply h [GOAL] case a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N✝ N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h₁ : I ≤ J h₂ : N✝ ≤ N' m : M h : ∀ (N : LieSubmodule R L M), {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N → m ∈ N N : LieSubmodule R L M hN : {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N [PROOFSTEP] rintro m' ⟨⟨x, hx⟩, ⟨n, hn⟩, hm⟩ [GOAL] case a.intro.mk.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N✝ N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h₁ : I ≤ J h₂ : N✝ ≤ N' m : M h : ∀ (N : LieSubmodule R L M), {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N → m ∈ N N : LieSubmodule R L M hN : {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N m' : M x : L hx : x ∈ I n : M hn : n ∈ N✝ hm : ⁅↑{ val := x, property := hx }, ↑{ val := n, property := hn }⁆ = m' ⊢ m' ∈ ↑N [PROOFSTEP] rw [← hm] [GOAL] case a.intro.mk.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N✝ N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h₁ : I ≤ J h₂ : N✝ ≤ N' m : M h : ∀ (N : LieSubmodule R L M), {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N → m ∈ N N : LieSubmodule R L M hN : {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N m' : M x : L hx : x ∈ I n : M hn : n ∈ N✝ hm : ⁅↑{ val := x, property := hx }, ↑{ val := n, property := hn }⁆ = m' ⊢ ⁅↑{ val := x, property := hx }, ↑{ val := n, property := hn }⁆ ∈ ↑N [PROOFSTEP] apply hN [GOAL] case a.intro.mk.intro.mk.a R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N✝ N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h₁ : I ≤ J h₂ : N✝ ≤ N' m : M h : ∀ (N : LieSubmodule R L M), {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N → m ∈ N N : LieSubmodule R L M hN : {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑N m' : M x : L hx : x ∈ I n : M hn : n ∈ N✝ hm : ⁅↑{ val := x, property := hx }, ↑{ val := n, property := hn }⁆ = m' ⊢ ⁅↑{ val := x, property := hx }, ↑{ val := n, property := hn }⁆ ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] use⟨x, h₁ hx⟩, ⟨n, h₂ hn⟩ [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N ⊔ N'⁆ = ⁅I, N⁆ ⊔ ⁅I, N'⁆ [PROOFSTEP] have h : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ := by rw [sup_le_iff]; constructor <;> apply mono_lie_right <;> [exact le_sup_left; exact le_sup_right] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ [PROOFSTEP] rw [sup_le_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ≤ ⁅I, N ⊔ N'⁆ ∧ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ [PROOFSTEP] constructor <;> apply mono_lie_right <;> [exact le_sup_left; exact le_sup_right] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ≤ ⁅I, N ⊔ N'⁆ ∧ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ [PROOFSTEP] constructor [GOAL] case left R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ≤ ⁅I, N ⊔ N'⁆ [PROOFSTEP] apply mono_lie_right [GOAL] case right R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ [PROOFSTEP] apply mono_lie_right [GOAL] case left.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ N ≤ N ⊔ N' [PROOFSTEP] exact le_sup_left [GOAL] case right.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ N' ≤ N ⊔ N' [PROOFSTEP] exact le_sup_right [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ ⊢ ⁅I, N ⊔ N'⁆ = ⁅I, N⁆ ⊔ ⁅I, N'⁆ [PROOFSTEP] suffices ⁅I, N ⊔ N'⁆ ≤ ⁅I, N⁆ ⊔ ⁅I, N'⁆ by exact le_antisymm this h [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ this : ⁅I, N ⊔ N'⁆ ≤ ⁅I, N⁆ ⊔ ⁅I, N'⁆ ⊢ ⁅I, N ⊔ N'⁆ = ⁅I, N⁆ ⊔ ⁅I, N'⁆ [PROOFSTEP] exact le_antisymm this h [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ ⊢ ⁅I, N ⊔ N'⁆ ≤ ⁅I, N⁆ ⊔ ⁅I, N'⁆ [PROOFSTEP] rw [lieIdeal_oper_eq_span, lieSpan_le] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑(⁅I, N⁆ ⊔ ⁅I, N'⁆) [PROOFSTEP] rintro m ⟨x, ⟨n, hn⟩, h⟩ [GOAL] case intro.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn : n ∈ N ⊔ N' h : ⁅↑x, ↑{ val := n, property := hn }⁆ = m ⊢ m ∈ ↑(⁅I, N⁆ ⊔ ⁅I, N'⁆) [PROOFSTEP] erw [LieSubmodule.mem_sup] [GOAL] case intro.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn : n ∈ N ⊔ N' h : ⁅↑x, ↑{ val := n, property := hn }⁆ = m ⊢ ∃ y, y ∈ ⁅I, N⁆ ∧ ∃ z, z ∈ ⁅I, N'⁆ ∧ y + z = m [PROOFSTEP] erw [LieSubmodule.mem_sup] at hn [GOAL] case intro.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn✝ : n ∈ N ⊔ N' hn : ∃ y, y ∈ N ∧ ∃ z, z ∈ N' ∧ y + z = n h : ⁅↑x, ↑{ val := n, property := hn✝ }⁆ = m ⊢ ∃ y, y ∈ ⁅I, N⁆ ∧ ∃ z, z ∈ ⁅I, N'⁆ ∧ y + z = m [PROOFSTEP] rcases hn with ⟨n₁, hn₁, n₂, hn₂, hn'⟩ [GOAL] case intro.intro.mk.intro.intro.intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn : n ∈ N ⊔ N' h : ⁅↑x, ↑{ val := n, property := hn }⁆ = m n₁ : M hn₁ : n₁ ∈ N n₂ : M hn₂ : n₂ ∈ N' hn' : n₁ + n₂ = n ⊢ ∃ y, y ∈ ⁅I, N⁆ ∧ ∃ z, z ∈ ⁅I, N'⁆ ∧ y + z = m [PROOFSTEP] use⁅(x : L), (⟨n₁, hn₁⟩ : N)⁆ [GOAL] case h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn : n ∈ N ⊔ N' h : ⁅↑x, ↑{ val := n, property := hn }⁆ = m n₁ : M hn₁ : n₁ ∈ N n₂ : M hn₂ : n₂ ∈ N' hn' : n₁ + n₂ = n ⊢ ⁅↑x, ↑{ val := n₁, property := hn₁ }⁆ ∈ ⁅I, N⁆ ∧ ∃ z, z ∈ ⁅I, N'⁆ ∧ ⁅↑x, ↑{ val := n₁, property := hn₁ }⁆ + z = m [PROOFSTEP] constructor [GOAL] case h.left R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn : n ∈ N ⊔ N' h : ⁅↑x, ↑{ val := n, property := hn }⁆ = m n₁ : M hn₁ : n₁ ∈ N n₂ : M hn₂ : n₂ ∈ N' hn' : n₁ + n₂ = n ⊢ ⁅↑x, ↑{ val := n₁, property := hn₁ }⁆ ∈ ⁅I, N⁆ [PROOFSTEP] apply lie_coe_mem_lie [GOAL] case h.right R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn : n ∈ N ⊔ N' h : ⁅↑x, ↑{ val := n, property := hn }⁆ = m n₁ : M hn₁ : n₁ ∈ N n₂ : M hn₂ : n₂ ∈ N' hn' : n₁ + n₂ = n ⊢ ∃ z, z ∈ ⁅I, N'⁆ ∧ ⁅↑x, ↑{ val := n₁, property := hn₁ }⁆ + z = m [PROOFSTEP] use⁅(x : L), (⟨n₂, hn₂⟩ : N')⁆ [GOAL] case h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn : n ∈ N ⊔ N' h : ⁅↑x, ↑{ val := n, property := hn }⁆ = m n₁ : M hn₁ : n₁ ∈ N n₂ : M hn₂ : n₂ ∈ N' hn' : n₁ + n₂ = n ⊢ ⁅↑x, ↑{ val := n₂, property := hn₂ }⁆ ∈ ⁅I, N'⁆ ∧ ⁅↑x, ↑{ val := n₁, property := hn₁ }⁆ + ⁅↑x, ↑{ val := n₂, property := hn₂ }⁆ = m [PROOFSTEP] constructor [GOAL] case h.left R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn : n ∈ N ⊔ N' h : ⁅↑x, ↑{ val := n, property := hn }⁆ = m n₁ : M hn₁ : n₁ ∈ N n₂ : M hn₂ : n₂ ∈ N' hn' : n₁ + n₂ = n ⊢ ⁅↑x, ↑{ val := n₂, property := hn₂ }⁆ ∈ ⁅I, N'⁆ [PROOFSTEP] apply lie_coe_mem_lie [GOAL] case h.right R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ m : M x : { x // x ∈ I } n : M hn : n ∈ N ⊔ N' h : ⁅↑x, ↑{ val := n, property := hn }⁆ = m n₁ : M hn₁ : n₁ ∈ N n₂ : M hn₂ : n₂ ∈ N' hn' : n₁ + n₂ = n ⊢ ⁅↑x, ↑{ val := n₁, property := hn₁ }⁆ + ⁅↑x, ↑{ val := n₂, property := hn₂ }⁆ = m [PROOFSTEP] simp [← h, ← hn'] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I ⊔ J, N⁆ = ⁅I, N⁆ ⊔ ⁅J, N⁆ [PROOFSTEP] have h : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ := by rw [sup_le_iff]; constructor <;> apply mono_lie_left <;> [exact le_sup_left; exact le_sup_right] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ [PROOFSTEP] rw [sup_le_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ≤ ⁅I ⊔ J, N⁆ ∧ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ [PROOFSTEP] constructor <;> apply mono_lie_left <;> [exact le_sup_left; exact le_sup_right] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ≤ ⁅I ⊔ J, N⁆ ∧ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ [PROOFSTEP] constructor [GOAL] case left R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N⁆ ≤ ⁅I ⊔ J, N⁆ [PROOFSTEP] apply mono_lie_left [GOAL] case right R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ [PROOFSTEP] apply mono_lie_left [GOAL] case left.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ I ≤ I ⊔ J [PROOFSTEP] exact le_sup_left [GOAL] case right.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ J ≤ I ⊔ J [PROOFSTEP] exact le_sup_right [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ ⊢ ⁅I ⊔ J, N⁆ = ⁅I, N⁆ ⊔ ⁅J, N⁆ [PROOFSTEP] suffices ⁅I ⊔ J, N⁆ ≤ ⁅I, N⁆ ⊔ ⁅J, N⁆ by exact le_antisymm this h [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ this : ⁅I ⊔ J, N⁆ ≤ ⁅I, N⁆ ⊔ ⁅J, N⁆ ⊢ ⁅I ⊔ J, N⁆ = ⁅I, N⁆ ⊔ ⁅J, N⁆ [PROOFSTEP] exact le_antisymm this h [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ ⊢ ⁅I ⊔ J, N⁆ ≤ ⁅I, N⁆ ⊔ ⁅J, N⁆ [PROOFSTEP] rw [lieIdeal_oper_eq_span, lieSpan_le] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑(⁅I, N⁆ ⊔ ⁅J, N⁆) [PROOFSTEP] rintro m ⟨⟨x, hx⟩, n, h⟩ [GOAL] case intro.mk.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx : x ∈ I ⊔ J n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx }, ↑n⁆ = m ⊢ m ∈ ↑(⁅I, N⁆ ⊔ ⁅J, N⁆) [PROOFSTEP] erw [LieSubmodule.mem_sup] [GOAL] case intro.mk.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx : x ∈ I ⊔ J n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx }, ↑n⁆ = m ⊢ ∃ y, y ∈ ⁅I, N⁆ ∧ ∃ z, z ∈ ⁅J, N⁆ ∧ y + z = m [PROOFSTEP] erw [LieSubmodule.mem_sup] at hx [GOAL] case intro.mk.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx✝ : x ∈ I ⊔ J hx : ∃ y, y ∈ I ∧ ∃ z, z ∈ J ∧ y + z = x n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx✝ }, ↑n⁆ = m ⊢ ∃ y, y ∈ ⁅I, N⁆ ∧ ∃ z, z ∈ ⁅J, N⁆ ∧ y + z = m [PROOFSTEP] rcases hx with ⟨x₁, hx₁, x₂, hx₂, hx'⟩ [GOAL] case intro.mk.intro.intro.intro.intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx : x ∈ I ⊔ J n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx }, ↑n⁆ = m x₁ : L hx₁ : x₁ ∈ I x₂ : L hx₂ : x₂ ∈ J hx' : x₁ + x₂ = x ⊢ ∃ y, y ∈ ⁅I, N⁆ ∧ ∃ z, z ∈ ⁅J, N⁆ ∧ y + z = m [PROOFSTEP] use⁅((⟨x₁, hx₁⟩ : I) : L), (n : N)⁆ [GOAL] case h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx : x ∈ I ⊔ J n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx }, ↑n⁆ = m x₁ : L hx₁ : x₁ ∈ I x₂ : L hx₂ : x₂ ∈ J hx' : x₁ + x₂ = x ⊢ ⁅↑{ val := x₁, property := hx₁ }, ↑n⁆ ∈ ⁅I, N⁆ ∧ ∃ z, z ∈ ⁅J, N⁆ ∧ ⁅↑{ val := x₁, property := hx₁ }, ↑n⁆ + z = m [PROOFSTEP] constructor [GOAL] case h.left R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx : x ∈ I ⊔ J n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx }, ↑n⁆ = m x₁ : L hx₁ : x₁ ∈ I x₂ : L hx₂ : x₂ ∈ J hx' : x₁ + x₂ = x ⊢ ⁅↑{ val := x₁, property := hx₁ }, ↑n⁆ ∈ ⁅I, N⁆ [PROOFSTEP] apply lie_coe_mem_lie [GOAL] case h.right R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx : x ∈ I ⊔ J n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx }, ↑n⁆ = m x₁ : L hx₁ : x₁ ∈ I x₂ : L hx₂ : x₂ ∈ J hx' : x₁ + x₂ = x ⊢ ∃ z, z ∈ ⁅J, N⁆ ∧ ⁅↑{ val := x₁, property := hx₁ }, ↑n⁆ + z = m [PROOFSTEP] use⁅((⟨x₂, hx₂⟩ : J) : L), (n : N)⁆ [GOAL] case h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx : x ∈ I ⊔ J n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx }, ↑n⁆ = m x₁ : L hx₁ : x₁ ∈ I x₂ : L hx₂ : x₂ ∈ J hx' : x₁ + x₂ = x ⊢ ⁅↑{ val := x₂, property := hx₂ }, ↑n⁆ ∈ ⁅J, N⁆ ∧ ⁅↑{ val := x₁, property := hx₁ }, ↑n⁆ + ⁅↑{ val := x₂, property := hx₂ }, ↑n⁆ = m [PROOFSTEP] constructor [GOAL] case h.left R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx : x ∈ I ⊔ J n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx }, ↑n⁆ = m x₁ : L hx₁ : x₁ ∈ I x₂ : L hx₂ : x₂ ∈ J hx' : x₁ + x₂ = x ⊢ ⁅↑{ val := x₂, property := hx₂ }, ↑n⁆ ∈ ⁅J, N⁆ [PROOFSTEP] apply lie_coe_mem_lie [GOAL] case h.right R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ h✝ : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ m : M x : L hx : x ∈ I ⊔ J n : { x // x ∈ N } h : ⁅↑{ val := x, property := hx }, ↑n⁆ = m x₁ : L hx₁ : x₁ ∈ I x₂ : L hx₂ : x₂ ∈ J hx' : x₁ + x₂ = x ⊢ ⁅↑{ val := x₁, property := hx₁ }, ↑n⁆ + ⁅↑{ val := x₂, property := hx₂ }, ↑n⁆ = m [PROOFSTEP] simp [← h, ← hx'] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N ⊓ N'⁆ ≤ ⁅I, N⁆ ⊓ ⁅I, N'⁆ [PROOFSTEP] rw [le_inf_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N ⊓ N'⁆ ≤ ⁅I, N⁆ ∧ ⁅I, N ⊓ N'⁆ ≤ ⁅I, N'⁆ [PROOFSTEP] constructor <;> apply mono_lie_right <;> [exact inf_le_left; exact inf_le_right] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N ⊓ N'⁆ ≤ ⁅I, N⁆ ∧ ⁅I, N ⊓ N'⁆ ≤ ⁅I, N'⁆ [PROOFSTEP] constructor [GOAL] case left R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N ⊓ N'⁆ ≤ ⁅I, N⁆ [PROOFSTEP] apply mono_lie_right [GOAL] case right R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I, N ⊓ N'⁆ ≤ ⁅I, N'⁆ [PROOFSTEP] apply mono_lie_right [GOAL] case left.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ N ⊓ N' ≤ N [PROOFSTEP] exact inf_le_left [GOAL] case right.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ N ⊓ N' ≤ N' [PROOFSTEP] exact inf_le_right [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I ⊓ J, N⁆ ≤ ⁅I, N⁆ ⊓ ⁅J, N⁆ [PROOFSTEP] rw [le_inf_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I ⊓ J, N⁆ ≤ ⁅I, N⁆ ∧ ⁅I ⊓ J, N⁆ ≤ ⁅J, N⁆ [PROOFSTEP] constructor <;> apply mono_lie_left <;> [exact inf_le_left; exact inf_le_right] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I ⊓ J, N⁆ ≤ ⁅I, N⁆ ∧ ⁅I ⊓ J, N⁆ ≤ ⁅J, N⁆ [PROOFSTEP] constructor [GOAL] case left R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I ⊓ J, N⁆ ≤ ⁅I, N⁆ [PROOFSTEP] apply mono_lie_left [GOAL] case right R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ ⁅I ⊓ J, N⁆ ≤ ⁅J, N⁆ [PROOFSTEP] apply mono_lie_left [GOAL] case left.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ I ⊓ J ≤ I [PROOFSTEP] exact inf_le_left [GOAL] case right.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ ⊢ I ⊓ J ≤ J [PROOFSTEP] exact inf_le_right [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ ⊢ map f ⁅I, N⁆ = ⁅I, map f N⁆ [PROOFSTEP] rw [← coe_toSubmodule_eq_iff, coeSubmodule_map, lieIdeal_oper_eq_linear_span, lieIdeal_oper_eq_linear_span, Submodule.map_span] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ ⊢ Submodule.span R (↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m}) = Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] congr [GOAL] case e_s R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ ⊢ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} = {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] ext m [GOAL] case e_s.h R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ m : M₂ ⊢ m ∈ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ↔ m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] constructor [GOAL] case e_s.h.mp R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ m : M₂ ⊢ m ∈ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} → m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rintro ⟨-, ⟨⟨x, ⟨n, hn⟩, rfl⟩, hm⟩⟩ [GOAL] case e_s.h.mp.intro.intro.intro.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ m : M₂ x : { x // x ∈ I } n : M hn : n ∈ N hm : ↑↑f ⁅↑x, ↑{ val := n, property := hn }⁆ = m ⊢ m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] simp only [LieModuleHom.coe_toLinearMap, LieModuleHom.map_lie] at hm [GOAL] case e_s.h.mp.intro.intro.intro.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ m : M₂ x : { x // x ∈ I } n : M hn : n ∈ N hm : ⁅↑x, ↑f n⁆ = m ⊢ m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] exact ⟨x, ⟨f n, (mem_map (f n)).mpr ⟨n, hn, rfl⟩⟩, hm⟩ [GOAL] case e_s.h.mpr R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ m : M₂ ⊢ m ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} → m ∈ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rintro ⟨x, ⟨m₂, hm₂ : m₂ ∈ map f N⟩, rfl⟩ [GOAL] case e_s.h.mpr.intro.intro.mk R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ x : { x // x ∈ I } m₂ : M₂ hm₂ : m₂ ∈ map f N ⊢ ⁅↑x, ↑{ val := m₂, property := hm₂ }⁆ ∈ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] obtain ⟨n, hn, rfl⟩ := (mem_map m₂).mp hm₂ [GOAL] case e_s.h.mpr.intro.intro.mk.intro.intro R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ x : { x // x ∈ I } n : M hn : n ∈ N hm₂ : ↑f n ∈ map f N ⊢ ⁅↑x, ↑{ val := ↑f n, property := hm₂ }⁆ ∈ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] exact ⟨⁅x, n⁆, ⟨x, ⟨n, hn⟩, rfl⟩, by simp⟩ [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ x : { x // x ∈ I } n : M hn : n ∈ N hm₂ : ↑f n ∈ map f N ⊢ ↑↑f ⁅x, n⁆ = ⁅↑x, ↑{ val := ↑f n, property := hm₂ }⁆ [PROOFSTEP] simp [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ hf : N₂ ≤ LieModuleHom.range f ⊢ map f (comap f N₂) = N₂ [PROOFSTEP] rw [SetLike.ext'_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ hf : N₂ ≤ LieModuleHom.range f ⊢ ↑(map f (comap f N₂)) = ↑N₂ [PROOFSTEP] exact Set.image_preimage_eq_of_subset hf [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ hf : LieModuleHom.ker f = ⊥ ⊢ comap f (map f N) = N [PROOFSTEP] rw [SetLike.ext'_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ hf : LieModuleHom.ker f = ⊥ ⊢ ↑(comap f (map f N)) = ↑N [PROOFSTEP] exact (N : Set M).preimage_image_eq (f.ker_eq_bot.mp hf) [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ hf₁ : LieModuleHom.ker f = ⊥ hf₂ : N₂ ≤ LieModuleHom.range f ⊢ comap f ⁅I, N₂⁆ = ⁅I, comap f N₂⁆ [PROOFSTEP] conv_lhs => rw [← map_comap_eq N₂ f hf₂] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ hf₁ : LieModuleHom.ker f = ⊥ hf₂ : N₂ ≤ LieModuleHom.range f | comap f ⁅I, N₂⁆ [PROOFSTEP] rw [← map_comap_eq N₂ f hf₂] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ hf₁ : LieModuleHom.ker f = ⊥ hf₂ : N₂ ≤ LieModuleHom.range f | comap f ⁅I, N₂⁆ [PROOFSTEP] rw [← map_comap_eq N₂ f hf₂] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ hf₁ : LieModuleHom.ker f = ⊥ hf₂ : N₂ ≤ LieModuleHom.range f | comap f ⁅I, N₂⁆ [PROOFSTEP] rw [← map_comap_eq N₂ f hf₂] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ hf₁ : LieModuleHom.ker f = ⊥ hf₂ : N₂ ≤ LieModuleHom.range f ⊢ comap f ⁅I, map f (comap f N₂)⁆ = ⁅I, comap f N₂⁆ [PROOFSTEP] rw [← map_bracket_eq, comap_map_eq _ f hf₁] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ ⊢ map (incl N) (comap (incl N) N') = N ⊓ N' [PROOFSTEP] rw [← coe_toSubmodule_eq_iff] [GOAL] R : Type u L : Type v M : Type w M₂ : Type w₁ inst✝¹⁰ : CommRing R inst✝⁹ : LieRing L inst✝⁸ : LieAlgebra R L inst✝⁷ : AddCommGroup M inst✝⁶ : Module R M inst✝⁵ : LieRingModule L M inst✝⁴ : LieModule R L M inst✝³ : AddCommGroup M₂ inst✝² : Module R M₂ inst✝¹ : LieRingModule L M₂ inst✝ : LieModule R L M₂ N N' : LieSubmodule R L M I J : LieIdeal R L N₂ : LieSubmodule R L M₂ f : M →ₗ⁅R,L⁆ M₂ ⊢ ↑(map (incl N) (comap (incl N) N')) = ↑(N ⊓ N') [PROOFSTEP] exact (N : Submodule R M).map_comap_subtype N' [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ map f ⁅I₁, I₂⁆ ≤ ⁅map f I₁, map f I₂⁆ [PROOFSTEP] rw [map_le_iff_le_comap] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ ⁅I₁, I₂⁆ ≤ comap f ⁅map f I₁, map f I₂⁆ [PROOFSTEP] erw [LieSubmodule.lieSpan_le] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑(comap f ⁅map f I₁, map f I₂⁆) [PROOFSTEP] intro x hx [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L x : L hx : x ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊢ x ∈ ↑(comap f ⁅map f I₁, map f I₂⁆) [PROOFSTEP] obtain ⟨⟨y₁, hy₁⟩, ⟨y₂, hy₂⟩, hx⟩ := hx [GOAL] case intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L x y₁ : L hy₁ : y₁ ∈ I₁ y₂ : L hy₂ : y₂ ∈ I₂ hx : ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ = x ⊢ x ∈ ↑(comap f ⁅map f I₁, map f I₂⁆) [PROOFSTEP] rw [← hx] [GOAL] case intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L x y₁ : L hy₁ : y₁ ∈ I₁ y₂ : L hy₂ : y₂ ∈ I₂ hx : ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ = x ⊢ ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ ∈ ↑(comap f ⁅map f I₁, map f I₂⁆) [PROOFSTEP] let fy₁ : ↥(map f I₁) := ⟨f y₁, mem_map hy₁⟩ [GOAL] case intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L x y₁ : L hy₁ : y₁ ∈ I₁ y₂ : L hy₂ : y₂ ∈ I₂ hx : ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ = x fy₁ : { x // x ∈ map f I₁ } := { val := ↑f y₁, property := (_ : ↑f y₁ ∈ map f I₁) } ⊢ ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ ∈ ↑(comap f ⁅map f I₁, map f I₂⁆) [PROOFSTEP] let fy₂ : ↥(map f I₂) := ⟨f y₂, mem_map hy₂⟩ [GOAL] case intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L x y₁ : L hy₁ : y₁ ∈ I₁ y₂ : L hy₂ : y₂ ∈ I₂ hx : ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ = x fy₁ : { x // x ∈ map f I₁ } := { val := ↑f y₁, property := (_ : ↑f y₁ ∈ map f I₁) } fy₂ : { x // x ∈ map f I₂ } := { val := ↑f y₂, property := (_ : ↑f y₂ ∈ map f I₂) } ⊢ ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ ∈ ↑(comap f ⁅map f I₁, map f I₂⁆) [PROOFSTEP] change _ ∈ comap f ⁅map f I₁, map f I₂⁆ [GOAL] case intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L x y₁ : L hy₁ : y₁ ∈ I₁ y₂ : L hy₂ : y₂ ∈ I₂ hx : ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ = x fy₁ : { x // x ∈ map f I₁ } := { val := ↑f y₁, property := (_ : ↑f y₁ ∈ map f I₁) } fy₂ : { x // x ∈ map f I₂ } := { val := ↑f y₂, property := (_ : ↑f y₂ ∈ map f I₂) } ⊢ ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ ∈ comap f ⁅map f I₁, map f I₂⁆ [PROOFSTEP] simp only [Submodule.coe_mk, mem_comap, LieHom.map_lie] [GOAL] case intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L x y₁ : L hy₁ : y₁ ∈ I₁ y₂ : L hy₂ : y₂ ∈ I₂ hx : ⁅↑{ val := y₁, property := hy₁ }, ↑{ val := y₂, property := hy₂ }⁆ = x fy₁ : { x // x ∈ map f I₁ } := { val := ↑f y₁, property := (_ : ↑f y₁ ∈ map f I₁) } fy₂ : { x // x ∈ map f I₂ } := { val := ↑f y₂, property := (_ : ↑f y₂ ∈ map f I₂) } ⊢ ⁅↑f y₁, ↑f y₂⁆ ∈ ⁅map f I₁, map f I₂⁆ [PROOFSTEP] exact LieSubmodule.lie_coe_mem_lie _ _ fy₁ fy₂ [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h : Function.Surjective ↑f ⊢ map f ⁅I₁, I₂⁆ = ⁅map f I₁, map f I₂⁆ [PROOFSTEP] suffices ⁅map f I₁, map f I₂⁆ ≤ map f ⁅I₁, I₂⁆ by exact le_antisymm (map_bracket_le f) this [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h : Function.Surjective ↑f this : ⁅map f I₁, map f I₂⁆ ≤ map f ⁅I₁, I₂⁆ ⊢ map f ⁅I₁, I₂⁆ = ⁅map f I₁, map f I₂⁆ [PROOFSTEP] exact le_antisymm (map_bracket_le f) this [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h : Function.Surjective ↑f ⊢ ⁅map f I₁, map f I₂⁆ ≤ map f ⁅I₁, I₂⁆ [PROOFSTEP] rw [← LieSubmodule.coeSubmodule_le_coeSubmodule, coe_map_of_surjective h, LieSubmodule.lieIdeal_oper_eq_linear_span, LieSubmodule.lieIdeal_oper_eq_linear_span, LinearMap.map_span] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h : Function.Surjective ↑f ⊢ Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ≤ Submodule.span R (↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m}) [PROOFSTEP] apply Submodule.span_mono [GOAL] case h R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h : Function.Surjective ↑f ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ⊆ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rintro x ⟨⟨z₁, h₁⟩, ⟨z₂, h₂⟩, rfl⟩ [GOAL] case h.intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h : Function.Surjective ↑f z₁ : L' h₁ : z₁ ∈ map f I₁ z₂ : L' h₂ : z₂ ∈ map f I₂ ⊢ ⁅↑{ val := z₁, property := h₁ }, ↑{ val := z₂, property := h₂ }⁆ ∈ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] obtain ⟨y₁, rfl⟩ := mem_map_of_surjective h h₁ [GOAL] case h.intro.mk.intro.mk.intro R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h : Function.Surjective ↑f z₂ : L' h₂ : z₂ ∈ map f I₂ y₁ : { x // x ∈ I₁ } h₁ : ↑f ↑y₁ ∈ map f I₁ ⊢ ⁅↑{ val := ↑f ↑y₁, property := h₁ }, ↑{ val := z₂, property := h₂ }⁆ ∈ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] obtain ⟨y₂, rfl⟩ := mem_map_of_surjective h h₂ [GOAL] case h.intro.mk.intro.mk.intro.intro R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h : Function.Surjective ↑f y₁ : { x // x ∈ I₁ } h₁ : ↑f ↑y₁ ∈ map f I₁ y₂ : { x // x ∈ I₂ } h₂ : ↑f ↑y₂ ∈ map f I₂ ⊢ ⁅↑{ val := ↑f ↑y₁, property := h₁ }, ↑{ val := ↑f ↑y₂, property := h₂ }⁆ ∈ ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] exact ⟨⁅(y₁ : L), (y₂ : L)⁆, ⟨y₁, y₂, rfl⟩, by apply f.map_lie⟩ [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h : Function.Surjective ↑f y₁ : { x // x ∈ I₁ } h₁ : ↑f ↑y₁ ∈ map f I₁ y₂ : { x // x ∈ I₂ } h₂ : ↑f ↑y₂ ∈ map f I₂ ⊢ ↑↑f ⁅↑y₁, ↑y₂⁆ = ⁅↑{ val := ↑f ↑y₁, property := h₁ }, ↑{ val := ↑f ↑y₂, property := h₂ }⁆ [PROOFSTEP] apply f.map_lie [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' ⊢ ⁅comap f J₁, comap f J₂⁆ ≤ comap f ⁅J₁, J₂⁆ [PROOFSTEP] rw [← map_le_iff_le_comap] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' ⊢ map f ⁅comap f J₁, comap f J₂⁆ ≤ ⁅J₁, J₂⁆ [PROOFSTEP] exact le_trans (map_bracket_le f) (LieSubmodule.mono_lie _ _ _ _ map_comap_le map_comap_le) [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ map (incl I₁) (comap (incl I₁) I₂) = I₁ ⊓ I₂ [PROOFSTEP] conv_rhs => rw [← I₁.incl_idealRange] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | I₁ ⊓ I₂ [PROOFSTEP] rw [← I₁.incl_idealRange] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | I₁ ⊓ I₂ [PROOFSTEP] rw [← I₁.incl_idealRange] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | I₁ ⊓ I₂ [PROOFSTEP] rw [← I₁.incl_idealRange] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ map (incl I₁) (comap (incl I₁) I₂) = LieHom.idealRange (incl I₁) ⊓ I₂ [PROOFSTEP] rw [← map_comap_eq] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ LieHom.IsIdealMorphism (incl I₁) [PROOFSTEP] exact I₁.incl_isIdealMorphism [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f ⊢ comap f ⁅LieHom.idealRange f ⊓ J₁, LieHom.idealRange f ⊓ J₂⁆ = ⁅comap f J₁, comap f J₂⁆ ⊔ LieHom.ker f [PROOFSTEP] rw [← LieSubmodule.coe_toSubmodule_eq_iff, comap_coeSubmodule, LieSubmodule.sup_coe_toSubmodule, f.ker_coeSubmodule, ← Submodule.comap_map_eq, LieSubmodule.lieIdeal_oper_eq_linear_span, LieSubmodule.lieIdeal_oper_eq_linear_span, LinearMap.map_span] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f ⊢ Submodule.comap (↑f) (Submodule.span R {m | ∃ x n, ⁅↑x, ↑n⁆ = m}) = Submodule.comap (↑f) (Submodule.span R (↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m})) [PROOFSTEP] congr [GOAL] case e_p.e_s R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} = ↑↑f '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] simp only [LieHom.coe_toLinearMap, Set.mem_setOf_eq] [GOAL] case e_p.e_s R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f ⊢ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} = (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] ext y [GOAL] case e_p.e_s.h R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' ⊢ y ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} ↔ y ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] constructor [GOAL] case e_p.e_s.h.mp R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' ⊢ y ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} → y ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rintro ⟨⟨x₁, hx₁⟩, ⟨x₂, hx₂⟩, hy⟩ [GOAL] case e_p.e_s.h.mp.intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y x₁ : L' hx₁ : x₁ ∈ LieHom.idealRange f ⊓ J₁ x₂ : L' hx₂ : x₂ ∈ LieHom.idealRange f ⊓ J₂ hy : ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂ }⁆ = y ⊢ y ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rw [← hy] [GOAL] case e_p.e_s.h.mp.intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y x₁ : L' hx₁ : x₁ ∈ LieHom.idealRange f ⊓ J₁ x₂ : L' hx₂ : x₂ ∈ LieHom.idealRange f ⊓ J₂ hy : ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂ }⁆ = y ⊢ ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂ }⁆ ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] erw [LieSubmodule.mem_inf, f.mem_idealRange_iff h] at hx₁ hx₂ [GOAL] case e_p.e_s.h.mp.intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y x₁ : L' hx₁✝ : x₁ ∈ LieHom.idealRange f ⊓ J₁ hx₁ : (∃ x, ↑f x = x₁) ∧ x₁ ∈ J₁ x₂ : L' hx₂✝ : x₂ ∈ LieHom.idealRange f ⊓ J₂ hx₂ : (∃ x, ↑f x = x₂) ∧ x₂ ∈ J₂ hy : ⁅↑{ val := x₁, property := hx₁✝ }, ↑{ val := x₂, property := hx₂✝ }⁆ = y ⊢ ⁅↑{ val := x₁, property := hx₁✝ }, ↑{ val := x₂, property := hx₂✝ }⁆ ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] obtain ⟨⟨z₁, hz₁⟩, hz₁'⟩ := hx₁ [GOAL] case e_p.e_s.h.mp.intro.mk.intro.mk.intro.intro R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y x₁ : L' hx₁ : x₁ ∈ LieHom.idealRange f ⊓ J₁ x₂ : L' hx₂✝ : x₂ ∈ LieHom.idealRange f ⊓ J₂ hx₂ : (∃ x, ↑f x = x₂) ∧ x₂ ∈ J₂ hy : ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂✝ }⁆ = y hz₁' : x₁ ∈ J₁ z₁ : L hz₁ : ↑f z₁ = x₁ ⊢ ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂✝ }⁆ ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rw [← hz₁] at hz₁' [GOAL] case e_p.e_s.h.mp.intro.mk.intro.mk.intro.intro R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y x₁ : L' hx₁ : x₁ ∈ LieHom.idealRange f ⊓ J₁ x₂ : L' hx₂✝ : x₂ ∈ LieHom.idealRange f ⊓ J₂ hx₂ : (∃ x, ↑f x = x₂) ∧ x₂ ∈ J₂ hy : ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂✝ }⁆ = y z₁ : L hz₁' : ↑f z₁ ∈ J₁ hz₁ : ↑f z₁ = x₁ ⊢ ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂✝ }⁆ ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] obtain ⟨⟨z₂, hz₂⟩, hz₂'⟩ := hx₂ [GOAL] case e_p.e_s.h.mp.intro.mk.intro.mk.intro.intro.intro.intro R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y x₁ : L' hx₁ : x₁ ∈ LieHom.idealRange f ⊓ J₁ x₂ : L' hx₂ : x₂ ∈ LieHom.idealRange f ⊓ J₂ hy : ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂ }⁆ = y z₁ : L hz₁' : ↑f z₁ ∈ J₁ hz₁ : ↑f z₁ = x₁ hz₂' : x₂ ∈ J₂ z₂ : L hz₂ : ↑f z₂ = x₂ ⊢ ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂ }⁆ ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rw [← hz₂] at hz₂' [GOAL] case e_p.e_s.h.mp.intro.mk.intro.mk.intro.intro.intro.intro R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y x₁ : L' hx₁ : x₁ ∈ LieHom.idealRange f ⊓ J₁ x₂ : L' hx₂ : x₂ ∈ LieHom.idealRange f ⊓ J₂ hy : ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂ }⁆ = y z₁ : L hz₁' : ↑f z₁ ∈ J₁ hz₁ : ↑f z₁ = x₁ z₂ : L hz₂' : ↑f z₂ ∈ J₂ hz₂ : ↑f z₂ = x₂ ⊢ ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂ }⁆ ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] refine ⟨⁅z₁, z₂⁆, ⟨⟨z₁, hz₁'⟩, ⟨z₂, hz₂'⟩, rfl⟩, ?_⟩ [GOAL] case e_p.e_s.h.mp.intro.mk.intro.mk.intro.intro.intro.intro R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y x₁ : L' hx₁ : x₁ ∈ LieHom.idealRange f ⊓ J₁ x₂ : L' hx₂ : x₂ ∈ LieHom.idealRange f ⊓ J₂ hy : ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂ }⁆ = y z₁ : L hz₁' : ↑f z₁ ∈ J₁ hz₁ : ↑f z₁ = x₁ z₂ : L hz₂' : ↑f z₂ ∈ J₂ hz₂ : ↑f z₂ = x₂ ⊢ (fun a => ↑f a) ⁅z₁, z₂⁆ = ⁅↑{ val := x₁, property := hx₁ }, ↑{ val := x₂, property := hx₂ }⁆ [PROOFSTEP] simp only [hz₁, hz₂, Submodule.coe_mk, LieHom.map_lie] [GOAL] case e_p.e_s.h.mpr R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' ⊢ y ∈ (fun a => ↑f a) '' {m | ∃ x n, ⁅↑x, ↑n⁆ = m} → y ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rintro ⟨x, ⟨⟨z₁, hz₁⟩, ⟨z₂, hz₂⟩, hx⟩, hy⟩ [GOAL] case e_p.e_s.h.mpr.intro.intro.intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' x : L hy : (fun a => ↑f a) x = y z₁ : L hz₁ : z₁ ∈ comap f J₁ z₂ : L hz₂ : z₂ ∈ comap f J₂ hx : ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ = x ⊢ y ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] rw [← hy, ← hx] [GOAL] case e_p.e_s.h.mpr.intro.intro.intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' x : L hy : (fun a => ↑f a) x = y z₁ : L hz₁ : z₁ ∈ comap f J₁ z₂ : L hz₂ : z₂ ∈ comap f J₂ hx : ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ = x ⊢ (fun a => ↑f a) ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] have hz₁' : f z₁ ∈ f.idealRange ⊓ J₁ := by rw [LieSubmodule.mem_inf]; exact ⟨f.mem_idealRange, hz₁⟩ [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' x : L hy : (fun a => ↑f a) x = y z₁ : L hz₁ : z₁ ∈ comap f J₁ z₂ : L hz₂ : z₂ ∈ comap f J₂ hx : ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ = x ⊢ ↑f z₁ ∈ LieHom.idealRange f ⊓ J₁ [PROOFSTEP] rw [LieSubmodule.mem_inf] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' x : L hy : (fun a => ↑f a) x = y z₁ : L hz₁ : z₁ ∈ comap f J₁ z₂ : L hz₂ : z₂ ∈ comap f J₂ hx : ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ = x ⊢ ↑f z₁ ∈ LieHom.idealRange f ∧ ↑f z₁ ∈ J₁ [PROOFSTEP] exact ⟨f.mem_idealRange, hz₁⟩ [GOAL] case e_p.e_s.h.mpr.intro.intro.intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' x : L hy : (fun a => ↑f a) x = y z₁ : L hz₁ : z₁ ∈ comap f J₁ z₂ : L hz₂ : z₂ ∈ comap f J₂ hx : ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ = x hz₁' : ↑f z₁ ∈ LieHom.idealRange f ⊓ J₁ ⊢ (fun a => ↑f a) ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] have hz₂' : f z₂ ∈ f.idealRange ⊓ J₂ := by rw [LieSubmodule.mem_inf]; exact ⟨f.mem_idealRange, hz₂⟩ [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' x : L hy : (fun a => ↑f a) x = y z₁ : L hz₁ : z₁ ∈ comap f J₁ z₂ : L hz₂ : z₂ ∈ comap f J₂ hx : ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ = x hz₁' : ↑f z₁ ∈ LieHom.idealRange f ⊓ J₁ ⊢ ↑f z₂ ∈ LieHom.idealRange f ⊓ J₂ [PROOFSTEP] rw [LieSubmodule.mem_inf] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' x : L hy : (fun a => ↑f a) x = y z₁ : L hz₁ : z₁ ∈ comap f J₁ z₂ : L hz₂ : z₂ ∈ comap f J₂ hx : ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ = x hz₁' : ↑f z₁ ∈ LieHom.idealRange f ⊓ J₁ ⊢ ↑f z₂ ∈ LieHom.idealRange f ∧ ↑f z₂ ∈ J₂ [PROOFSTEP] exact ⟨f.mem_idealRange, hz₂⟩ [GOAL] case e_p.e_s.h.mpr.intro.intro.intro.mk.intro.mk R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' x : L hy : (fun a => ↑f a) x = y z₁ : L hz₁ : z₁ ∈ comap f J₁ z₂ : L hz₂ : z₂ ∈ comap f J₂ hx : ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ = x hz₁' : ↑f z₁ ∈ LieHom.idealRange f ⊓ J₁ hz₂' : ↑f z₂ ∈ LieHom.idealRange f ⊓ J₂ ⊢ (fun a => ↑f a) ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ ∈ {m | ∃ x n, ⁅↑x, ↑n⁆ = m} [PROOFSTEP] use⟨f z₁, hz₁'⟩, ⟨f z₂, hz₂'⟩ [GOAL] case h R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f y : L' x : L hy : (fun a => ↑f a) x = y z₁ : L hz₁ : z₁ ∈ comap f J₁ z₂ : L hz₂ : z₂ ∈ comap f J₂ hx : ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ = x hz₁' : ↑f z₁ ∈ LieHom.idealRange f ⊓ J₁ hz₂' : ↑f z₂ ∈ LieHom.idealRange f ⊓ J₂ ⊢ ⁅↑{ val := ↑f z₁, property := hz₁' }, ↑{ val := ↑f z₂, property := hz₂' }⁆ = (fun a => ↑f a) ⁅↑{ val := z₁, property := hz₁ }, ↑{ val := z₂, property := hz₂ }⁆ [PROOFSTEP] simp only [Submodule.coe_mk, LieHom.map_lie] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f ⊢ map f ⁅comap f J₁, comap f J₂⁆ = ⁅LieHom.idealRange f ⊓ J₁, LieHom.idealRange f ⊓ J₂⁆ [PROOFSTEP] rw [← map_sup_ker_eq_map, ← comap_bracket_eq h, map_comap_eq h, inf_eq_right] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J J₁ J₂ : LieIdeal R L' h : LieHom.IsIdealMorphism f ⊢ ⁅LieHom.idealRange f ⊓ J₁, LieHom.idealRange f ⊓ J₂⁆ ≤ LieHom.idealRange f [PROOFSTEP] exact le_trans (LieSubmodule.lie_le_left _ _) inf_le_left [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ ⁅comap (incl I) I₁, comap (incl I) I₂⁆ = comap (incl I) ⁅I ⊓ I₁, I ⊓ I₂⁆ [PROOFSTEP] conv_rhs => congr next => skip rw [← I.incl_idealRange] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | comap (incl I) ⁅I ⊓ I₁, I ⊓ I₂⁆ [PROOFSTEP] congr next => skip rw [← I.incl_idealRange] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | comap (incl I) ⁅I ⊓ I₁, I ⊓ I₂⁆ [PROOFSTEP] congr next => skip rw [← I.incl_idealRange] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | comap (incl I) ⁅I ⊓ I₁, I ⊓ I₂⁆ [PROOFSTEP] congr [GOAL] case f R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | incl I case J R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | ⁅I ⊓ I₁, I ⊓ I₂⁆ [PROOFSTEP] next => skip [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | incl I [PROOFSTEP] skip [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | incl I [PROOFSTEP] skip [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | incl I [PROOFSTEP] skip [GOAL] case J R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L | ⁅I ⊓ I₁, I ⊓ I₂⁆ [PROOFSTEP] rw [← I.incl_idealRange] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ ⁅comap (incl I) I₁, comap (incl I) I₂⁆ = comap (incl I) ⁅LieHom.idealRange (incl I) ⊓ I₁, LieHom.idealRange (incl I) ⊓ I₂⁆ [PROOFSTEP] rw [comap_bracket_eq] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ ⁅comap (incl I) I₁, comap (incl I) I₂⁆ = ⁅comap (incl I) I₁, comap (incl I) I₂⁆ ⊔ LieHom.ker (incl I) R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ LieHom.IsIdealMorphism (incl I) [PROOFSTEP] simp only [ker_incl, sup_bot_eq] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L ⊢ LieHom.IsIdealMorphism (incl I) [PROOFSTEP] exact I.incl_isIdealMorphism [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h₁ : I₁ ≤ I h₂ : I₂ ≤ I ⊢ ⁅comap (incl I) I₁, comap (incl I) I₂⁆ = comap (incl I) ⁅I₁, I₂⁆ [PROOFSTEP] rw [comap_bracket_incl] [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h₁ : I₁ ≤ I h₂ : I₂ ≤ I ⊢ comap (incl I) ⁅I ⊓ I₁, I ⊓ I₂⁆ = comap (incl I) ⁅I₁, I₂⁆ [PROOFSTEP] rw [← inf_eq_right] at h₁ h₂ [GOAL] R : Type u L : Type v L' : Type w₂ inst✝⁴ : CommRing R inst✝³ : LieRing L inst✝² : LieAlgebra R L inst✝¹ : LieRing L' inst✝ : LieAlgebra R L' f : L →ₗ⁅R⁆ L' I : LieIdeal R L J : LieIdeal R L' I₁ I₂ : LieIdeal R L h₁ : I ⊓ I₁ = I₁ h₂ : I ⊓ I₂ = I₂ ⊢ comap (incl I) ⁅I ⊓ I₁, I ⊓ I₂⁆ = comap (incl I) ⁅I₁, I₂⁆ [PROOFSTEP] rw [h₁, h₂]
[STATEMENT] lemma mset_nths: assumes l_r: "l \<le> r \<and> r \<le> List.length xs" assumes left: "\<forall> i. i < l \<longrightarrow> (xs::'a list) ! i = ys ! i" assumes right: "\<forall> i. i \<ge> r \<longrightarrow> (xs::'a list) ! i = ys ! i" assumes multiset: "mset xs = mset ys" shows "mset (nths' l r xs) = mset (nths' l r ys)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] from l_r [PROOF STATE] proof (chain) picking this: l \<le> r \<and> r \<le> length xs [PROOF STEP] have xs_def: "xs = (nths' 0 l xs) @ (nths' l r xs) @ (nths' r (List.length xs) xs)" (is "_ = ?xs_long") [PROOF STATE] proof (prove) using this: l \<le> r \<and> r \<le> length xs goal (1 subgoal): 1. xs = nths' 0 l xs @ nths' l r xs @ nths' r (length xs) xs [PROOF STEP] by (simp add: nths'_append) [PROOF STATE] proof (state) this: xs = nths' 0 l xs @ nths' l r xs @ nths' r (length xs) xs goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] from multiset [PROOF STATE] proof (chain) picking this: mset xs = mset ys [PROOF STEP] have length_eq: "List.length xs = List.length ys" [PROOF STATE] proof (prove) using this: mset xs = mset ys goal (1 subgoal): 1. length xs = length ys [PROOF STEP] by (rule mset_eq_length) [PROOF STATE] proof (state) this: length xs = length ys goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] with l_r [PROOF STATE] proof (chain) picking this: l \<le> r \<and> r \<le> length xs length xs = length ys [PROOF STEP] have ys_def: "ys = (nths' 0 l ys) @ (nths' l r ys) @ (nths' r (List.length ys) ys)" (is "_ = ?ys_long") [PROOF STATE] proof (prove) using this: l \<le> r \<and> r \<le> length xs length xs = length ys goal (1 subgoal): 1. ys = nths' 0 l ys @ nths' l r ys @ nths' r (length ys) ys [PROOF STEP] by (simp add: nths'_append) [PROOF STATE] proof (state) this: ys = nths' 0 l ys @ nths' l r ys @ nths' r (length ys) ys goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] from xs_def ys_def multiset [PROOF STATE] proof (chain) picking this: xs = nths' 0 l xs @ nths' l r xs @ nths' r (length xs) xs ys = nths' 0 l ys @ nths' l r ys @ nths' r (length ys) ys mset xs = mset ys [PROOF STEP] have "mset ?xs_long = mset ?ys_long" [PROOF STATE] proof (prove) using this: xs = nths' 0 l xs @ nths' l r xs @ nths' r (length xs) xs ys = nths' 0 l ys @ nths' l r ys @ nths' r (length ys) ys mset xs = mset ys goal (1 subgoal): 1. mset (nths' 0 l xs @ nths' l r xs @ nths' r (length xs) xs) = mset (nths' 0 l ys @ nths' l r ys @ nths' r (length ys) ys) [PROOF STEP] by simp [PROOF STATE] proof (state) this: mset (nths' 0 l xs @ nths' l r xs @ nths' r (length xs) xs) = mset (nths' 0 l ys @ nths' l r ys @ nths' r (length ys) ys) goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] moreover [PROOF STATE] proof (state) this: mset (nths' 0 l xs @ nths' l r xs @ nths' r (length xs) xs) = mset (nths' 0 l ys @ nths' l r ys @ nths' r (length ys) ys) goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] from left l_r length_eq [PROOF STATE] proof (chain) picking this: \<forall>i<l. xs ! i = ys ! i l \<le> r \<and> r \<le> length xs length xs = length ys [PROOF STEP] have "nths' 0 l xs = nths' 0 l ys" [PROOF STATE] proof (prove) using this: \<forall>i<l. xs ! i = ys ! i l \<le> r \<and> r \<le> length xs length xs = length ys goal (1 subgoal): 1. nths' 0 l xs = nths' 0 l ys [PROOF STEP] by (auto simp add: length_nths' nth_nths' intro!: nth_equalityI) [PROOF STATE] proof (state) this: nths' 0 l xs = nths' 0 l ys goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] moreover [PROOF STATE] proof (state) this: nths' 0 l xs = nths' 0 l ys goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] from right l_r length_eq [PROOF STATE] proof (chain) picking this: \<forall>i\<ge>r. xs ! i = ys ! i l \<le> r \<and> r \<le> length xs length xs = length ys [PROOF STEP] have "nths' r (List.length xs) xs = nths' r (List.length ys) ys" [PROOF STATE] proof (prove) using this: \<forall>i\<ge>r. xs ! i = ys ! i l \<le> r \<and> r \<le> length xs length xs = length ys goal (1 subgoal): 1. nths' r (length xs) xs = nths' r (length ys) ys [PROOF STEP] by (auto simp add: length_nths' nth_nths' intro!: nth_equalityI) [PROOF STATE] proof (state) this: nths' r (length xs) xs = nths' r (length ys) ys goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: mset (nths' 0 l xs @ nths' l r xs @ nths' r (length xs) xs) = mset (nths' 0 l ys @ nths' l r ys @ nths' r (length ys) ys) nths' 0 l xs = nths' 0 l ys nths' r (length xs) xs = nths' r (length ys) ys [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: mset (nths' 0 l xs @ nths' l r xs @ nths' r (length xs) xs) = mset (nths' 0 l ys @ nths' l r ys @ nths' r (length ys) ys) nths' 0 l xs = nths' 0 l ys nths' r (length xs) xs = nths' r (length ys) ys goal (1 subgoal): 1. mset (nths' l r xs) = mset (nths' l r ys) [PROOF STEP] by (simp add: mset_append) [PROOF STATE] proof (state) this: mset (nths' l r xs) = mset (nths' l r ys) goal: No subgoals! [PROOF STEP] qed
Require Import Coq.Lists.List. Require Export SystemFR.Judgments. Require Export SystemFR.AnnotatedTactics. Require Export SystemFR.ErasedFix. Opaque reducible_values. Lemma annotated_reducible_fix_strong_induction: forall Θ Γ ts T n y p, ~(n ∈ fv_context Γ) -> ~(y ∈ fv_context Γ) -> ~(p ∈ fv_context Γ) -> ~(n ∈ fv T) -> ~(n ∈ fv ts) -> ~(y ∈ fv T) -> ~(y ∈ fv ts) -> ~(p ∈ fv T) -> ~(p ∈ fv ts) -> ~(n ∈ Θ) -> ~(y ∈ Θ) -> ~(p ∈ Θ) -> NoDup (n :: y :: p :: nil) -> wf (erase_term ts) 1 -> wf T 1 -> subset (fv T) (support Γ) -> subset (fv ts) (support Γ) -> is_annotated_type T -> is_annotated_term ts -> cbv_value (erase_term ts) -> [[ Θ; (p, T_equiv (fvar y term_var) (tfix T ts)) :: (y, T_forall (T_refine T_nat (binary_primitive Lt (lvar 0 term_var) (fvar n term_var))) T) :: (n, T_nat) :: Γ ⊨ open 0 (open 1 ts (fvar n term_var)) (fvar y term_var) : open 0 T (fvar n term_var) ]] -> [[ Θ; Γ ⊨ tfix T ts : T_forall T_nat T ]]. Proof. intros; apply open_reducible_fix_strong_induction with n y p; repeat step || erase_open || (rewrite (open_none (erase_term ts)) in * by auto) || (rewrite erase_type_shift in *); side_conditions. Qed.
{-# LANGUAGE BangPatterns, LambdaCase #-} module Main where import Help import Input import Fractals import Colors import Data.Complex import qualified Graphics.Image as I import qualified Graphics.Image.Interface as I import System.IO import Data.Word import System.Environment import System.Directory import Data.Time -- Entry point for program main :: IO () main = do args <- getArgs if not (length args == 0) && ( head args == "h" || head args == "-h" || head args == "help" || head args == "-help" || head args == "?" || head args == "-?" ) then do putStrLn $ help args hFlush stdout else do let options = processArgs args putStrLn $ pPrintOptions options hFlush stdout fractal args options fractal :: [String] -> Options -> IO () fractal args options@(Options fractalType (numRows, numColumns) (centerReal :+ centerImag) range iterations power aaIn normalization color animation cValue setColor framesIn startingFrame) = do currentDir <- getCurrentDirectory {- Path is generated by finding the current date/time, replacing colons (an invalid character in Windows paths) with an alternate Unicode colon, and removing the last 12 digits (which contain the fractional part of the seconds and the "UTC" code) -} path <- fmap ( ((currentDir ++ "\\Generated Fractals\\") ++) . reverse . drop 12 . reverse . map (\case ':' -> '\xA789'; x -> x) . show ) getCurrentTime createDirectoryIfMissing True path setCurrentDirectory path writeFile "data.txt" $ (pPrintOptions options) ++ '\n' : "Arguments: " ++ (unwords args) putStr $ (show $ startingFrame - 1) ++ '/' : (show $ floor frames) hFlush stdout mapM_ (\frame -> do I.writeImageExact (I.PNG) [] (path ++ '\\' : (take ((countDigits $ floor frames) - (countDigits $ frame)) $ repeat '0') ++ show (frame) ++ ".png") $ I.toManifest $ I.toWord8I $ I.makeImageR I.RPS (numRows, numColumns) (\point -> colorFunc $ fractalFunction frame point) putStr $ '\r' : (show $ frame + 1) ++ '/' : (show $ floor frames) hFlush stdout ) [startingFrame - 1 .. (truncate frames) - 1] putStrLn "" where frames = case animation of NoAnimation -> 1 otherwise -> fromIntegral framesIn colorFunc = case color of Greyscale -> colorGrey setColor Hue -> colorHue setColor Gradient isCircular colors -> colorGrad setColor isCircular colors . fmap (case normalization of Linear -> normLinear iterations Sigmoid center power -> normSigmoid center power Periodic period -> normPeriodic period Sine period -> normSine period ) aa = case aaIn of AAEnabled -> True AADisabled -> False animVals = map (case animation of Zoom final _ -> ((exp $ (log (final / range)) / (frames - 1)) **) Grid rIni rFnl _ _ rNum _ -> interpolate rIni rFnl . (/ (fromIntegral rNum - 1)) . fromIntegral . (`mod` rNum) . floor otherwise -> case animation of NoAnimation -> \x -> 1 Power final -> interpolate power final Iterations final -> interpolate (fromIntegral iterations) (fromIntegral final) Theta final _ -> interpolate (phase cValue) (final * pi / 180) LinearC final -> interpolate (realPart cValue) (realPart final) . if frames /= 1 then (/ (frames - 1)) else id ) [fromIntegral startingFrame - 1 .. frames - 1] altAnimVals = map (case animation of Grid _ _ iIni iFnl rNum iNum -> interpolate iIni iFnl . (/ (fromIntegral iNum - 1)) . fromIntegral . (`div` rNum) . floor otherwise -> case animation of Zoom _ (Just finalIter) -> interpolate (fromIntegral iterations) (fromIntegral finalIter) Zoom _ Nothing -> \x -> fromIntegral iterations Theta _ (Just final) -> interpolate (magnitude cValue) final Theta _ Nothing -> \x -> magnitude cValue LinearC final -> interpolate (imagPart cValue) (imagPart final) . if frames /= 1 then (/ (frames - 1)) else id ) [fromIntegral startingFrame - 1 .. frames - 1] fractalFunction :: Int -> (Int, Int) -> Maybe Double fractalFunction frame (r, c) = case (fractalType, animation) of -- Mandelbrot animation functions (Mandelbrot, NoAnimation) -> pMandelbrot aa pixelSize iterations power $ pairToComplex (r, c) (Mandelbrot, Power _) -> pMandelbrot aa pixelSize iterations value $ pairToComplex (r, c) (Mandelbrot, Zoom _ _) -> pMandelbrot aa (pixelSize * value) (round $ altValue) power $ pairToComplexZ (r, c) value (Mandelbrot, Iterations _) -> pMandelbrot aa pixelSize (round value) power $ pairToComplex (r, c) (Mandelbrot, Theta _ _) -> error "Theta animations can only be generated for Julia fractals" (Mandelbrot, LinearC _) -> error "Linear C-Value animations can only be generated for Julia fractals" (Mandelbrot, Grid _ _ _ _ _ _) -> error "Grided c-values can only be generated for Julia fractals" -- Julia animation functions (Julia, NoAnimation) -> pJulia aa pixelSize iterations power cValue $ pairToComplex (r, c) (Julia, Power _) -> pJulia aa pixelSize iterations value cValue $ pairToComplex (r, c) (Julia, Zoom _ _) -> pJulia aa (pixelSize * value) (round $ altValue) power cValue $ pairToComplexZ (r, c) value (Julia, Iterations _) -> pJulia aa pixelSize (round value) power cValue $ pairToComplex (r, c) (Julia, Theta _ _) -> pJulia aa pixelSize iterations power (mkPolar altValue value) $ pairToComplex (r, c) (Julia, LinearC _) -> pJulia aa pixelSize iterations power (value :+ altValue) $ pairToComplex (r, c) (Julia, Grid _ _ _ _ _ _) -> pJulia aa pixelSize iterations power (value :+ altValue) $ pairToComplex (r, c) where -- The value being animated value = animVals !! frame altValue = altAnimVals !! frame -- Other values pixelSize = (2 * range) / (fromIntegral $ numColumns - 1) halfV = 0.5 * fromIntegral numRows halfH = 0.5 * fromIntegral numColumns -- Function to get a complex point from a pixel coordinate pair pairToComplex (r, c) = (centerReal - range + fromIntegral c * pixelSize) :+ (centerImag + (pixelSize * (fromIntegral (numRows - 1) / 2)) - fromIntegral r * pixelSize) -- Same as above but for zoom animations pairToComplexZ (r, c) zoomFactor = ((fromIntegral c - halfH) * pixelSize * zoomFactor + centerReal) :+ ((fromIntegral r - halfV) * pixelSize * zoomFactor - centerImag) -- Helper function for interpolating from the start to the end of an animation's value range interpolate :: RealFloat a => a -> a -> a -> a interpolate i f = (i +) . (*) (f - i) -- Helper funtion to count the number of digits in an integer when expressed in base 10 countDigits :: Integral a => a -> a countDigits = (+ 1) . floor . logBase 10 . fromIntegral
// // FILE NAME: $HeadURL: svn+ssh://svn.cm.aol.com/advertising/adlearn/gen1/trunk/lib/cpp/DataProxy/DataProxyClient.hpp $ // // REVISION: $Revision: 297940 $ // // COPYRIGHT: (c) 2006 Advertising.com All Rights Reserved. // // LAST UPDATED: $Date: 2014-03-11 20:56:14 -0400 (Tue, 11 Mar 2014) $ // UPDATED BY: $Author: sstrick $ #ifndef _DATA_PROXY_CLIENT_HPP_ #define _DATA_PROXY_CLIENT_HPP_ #include "MVCommon.hpp" #include "MVException.hpp" #include "detail/DPLVisibility.hpp" #include "detail/DatabaseConnectionManager.hpp" #include "detail/NodeFactory.hpp" #include <xercesc/dom/DOM.hpp> #include <boost/shared_ptr.hpp> #include <boost/noncopyable.hpp> #include <boost/thread/thread.hpp> #include <map> #include <vector> MV_MAKEEXCEPTIONCLASS( DataProxyClientException, MVException ); MV_MAKEEXCEPTIONCLASS( BadStreamException, DataProxyClientException ); MV_MAKEEXCEPTIONCLASS( PartialCommitException, DataProxyClientException ); class ParameterTranslator; class TransformerManager; class Database; class AbstractNode; class DLL_DPL_PUBLIC DataProxyClient : public boost::noncopyable { public: DataProxyClient( bool i_DoNotInitializeXerces = false ); virtual ~DataProxyClient(); virtual void Initialize( const std::string& i_rConfigFileSpec ); virtual void Ping( const std::string& i_rName, int i_Mode ) const; virtual void Load( const std::string& i_rName, const std::map<std::string,std::string>& i_rParameters, std::ostream& o_rData ) const; virtual void Store( const std::string& i_rName, const std::map<std::string,std::string>& i_rParameters, std::istream& i_rData ) const; virtual void Delete( const std::string& i_rName, const std::map<std::string,std::string>& i_rParameters ) const; virtual bool InsideTransaction(); virtual void BeginTransaction( bool i_AbortCurrent = false ); virtual void Commit(); virtual void Rollback(); #ifdef DPL_TEST protected: virtual void Initialize( const std::string& i_rConfigFileSpec, INodeFactory& i_rNodeFactory ); virtual void Initialize( const std::string& i_rConfigFileSpec, INodeFactory& i_rNodeFactory, DatabaseConnectionManager& i_rDatabaseConnectionManager ); #endif private: friend class RequestForwarder; void PingImpl( const std::string& i_rName, int i_Mode ) const; void LoadImpl( const std::string& i_rName, const std::map<std::string,std::string>& i_rParameters, std::ostream& o_rData ) const; void StoreImpl( const std::string& i_rName, const std::map<std::string,std::string>& i_rParameters, std::istream& i_rData ) const; void DeleteImpl( const std::string& i_rName, const std::map<std::string,std::string>& i_rParameters ) const; typedef std::map< std::string, boost::shared_ptr< AbstractNode > > NodesMap; void PrivateRollback( bool i_ObtainLock ); void InitializeImplementation( const std::string& i_rConfigFileSpec, INodeFactory& i_rNodeFactory, DatabaseConnectionManager& i_rDatabaseConnectionManager ); std::string ExtractName( xercesc::DOMNode* i_pNode ) const; void CheckForCycles( const NodesMap::const_iterator& i_rIter, int i_WhichPath, const std::vector< std::string >& i_rNamePath ) const; void HandleResult( const std::string& i_rName, const NodesMap::const_iterator& i_rNodeIter, bool i_bSuccess, const std::string i_Operation ) const; bool m_Initialized; NodesMap m_Nodes; bool m_DoNotInitializeXerces; bool m_InsideTransaction; std::string m_ConfigFileMD5; DatabaseConnectionManager m_DatabaseConnectionManager; NodeFactory m_NodeFactory; mutable std::vector< std::string > m_PendingCommitNodes; mutable std::vector< std::string > m_PendingRollbackNodes; mutable std::vector< std::string > m_AutoCommittedNodes; mutable boost::shared_mutex m_ConfigMutex; }; #endif //_DATA_PROXY_CLIENT_HPP_
The Visual argument is one of the most popular assignments among students' documents. If you are stuck with writing or missing ideas, scroll down and find inspiration in the best samples. Visual argument is quite a rare and popular topic for writing an essay, but it certainly is in our database. 500 essays on "Visual argument" What is an Visual argument? Visual argument is a type of students written assignments that requires several steps to be completed. How can an Visual argument be written faster? Typical Visual argument would take you 3 to 6 hours to complete. That includes 2 hours of thorough research, 30 minutes for creating an outline, 2 hours of writing, and 1,5 hours for editing, proofreading and proper formatting. Ideas. By downloading several Visual argument papers you’ll get a multiple choice of ideas to elaborate in own essay. Don't reinvent the wheel. Go through several essays uploaded by other students and grab the best ideas. Students, who are voluntarily sharing their works with others, uploaded each Visual argument samples from our database. We encourage you to use them as essay samples, but please, do not submit them as own. Our contributors most surely have already submitted them and now they are open for view to thousands of users. Let us find you essays on topic Visual argument for FREE!
The Canadian Chamber of Commerce in Korea (CanCham Korea) hosted its annual Maple Gala on the evening of March 21, 2014 at the Banyan Tree Club and Spa in Seoul. More than 200 guests from Canada and Korea attended the black tie affair. They included Canadian Ambassador to Seoul David Chatterson, Chairwoman Genny S. Kim of Canadian Chamber of Commerce in Korea, Sen. Yonah Martin from British Columbia, and former Korean Prime Minister Chung Un-Chan . “We sincerely thank you for many attendances including general manager of Air Canada Young Lee, President Amy Jackson of American Chamber of Commerce in Korea, president Kim Hang-Kyung of Korea-Canada Society, etc.” said Genny Kim, canCham Chairwoman. She said as well: Additionally another special thanks to sponsors such as Air Canada, Bombardier, Jouviance, LG Electronics, Shin&Kim, Natural Factors, etc. Upon recently-concluded FTA between Korea and Canada from her standpoint as CanCham chairwoman, she mentioned that the Korea-Canada Free Trade Agreement would bring bilateral dynamic growth for the business communities of the two countries. Starting his welcoming remarks with comments regarding the 50th anniversary of diplomatic ties between Korea and Canada last year which were filled with many commemorative events, Amb. Chatterson said: “Bilateral relations have blossomed over the last 50 years, grounded in our strong political and economic partnership and cooperation." "With more than 50 years of diplomatic relations between Canada and South Korea, a free trade agreement is the natural next step in a dynamic relationship between two nations committed to economic growth and development through free trade,” the Canadian envoy said. "I am very pleased to see more increasing partnerships with Canadian Chamber of Commerce in Korea like tonight's event, hoping continuing friendship between the two countries and for the CanCham members to enjoy good food and wine during the function all the time," he added. After Amb. Chatterson’s welcoming remarks, special screening "The Feast of Aurora" by Astro-photographer O-Chul Kwon provided participanting guests with fantastic aurora scenes of Canada. By her toast, Sen. Yonah Martin from British Columbia, Canada who was on hand, also congratulated Korea-Canada FTA conclusion as a milestone to pave the way for the prosperity between the two countries. Canada-born new age pianist Steve Barakatt enthralled guests with his sweetish special performance including Rainbow Bridge Story. Last but not least, lucky draw and cocktail hour by SKYY became pleasant times to enhance amusement and to harden friendship between chamber members until the Maple Gala was finalized by late night. The Canadian Chamber is a non-profit organization dedicated to nurturing a strong Canadian community in Korea and to promote Canadian business interests. Founded in 1995, the Chamber opens its membership to Canadians and Koreans alike. It organizes a number of fun and informative networking and social events each year, while also advocating on behalf of the Canadian business community and in close collaboration with the Canadian Embassy on a range of issues.
||| Algebra.Magma: A representation of magmas. ||| ||| A magma is more-or-less the simplest non-trivial example of a algebraic ||| structure. It is simply a set together with a lawless binary operation over ||| it. More formally, it is *any* pair ||| \\(\mathscr{M} = (M:\mathscr{V}, \* : M^2 \to M)\\). It doesn't matter what ||| the function \\(\*\\) is. It can have any properties whatsoever; the only ||| reuirement is that it be a function of the specified type. That is, it must ||| be a total co-injective relation with domain \\(M^2\\) and codomain \\(M\\), ||| where by \"co-injective\" I mean that for every input, there is no more than ||| one output. Together with totality, which states that every input has at ||| least one output, this means that a function is a relation where every input ||| has exactly one output. ||| ||| Magmas aren't especially interesting in and of themselves. Because there are ||| no magma axioms, just a type, there isn't much that can be said about magmas ||| in general. However, they give a useful way to talk about other algebraic ||| structures. A group, for example, is a magma satisfying certain laws. In ||| other words, talking in terms of magmas and related lawless algebraic ||| structures just gives us a more convenient way to talk about the signature ||| of the more interesting ones. (Of course, all of this leads naturally to ||| groups, semigroups, monoids, etc. being extensions of the `Magma` ||| record.) ||| ||| That's not to say there's nothing interesting about magmas. There are ||| interesting combinatorial questions arising from freely generated magmas. ||| That is, consider a magma generated by three elements, \\(a, b, c\\). By ||| \"freely generated\", we mean that there are no equalities except those ||| directly entailed by the axioms; since there aren't any axioms, there aren't ||| any (non-reflexive) equalities! E.g., in a freely generated magma, we know ||| that \\((x\*y)\*z \neq x\*(y\*z)\\) for every \\(x, y, z\\). If they were ||| equal, it would still be a magma, but not a freely generated one. Now, for ||| the free magma with 3 generating elements, how many elements are there with ||| exactly \\(k\\) applications of the operation \\(\*\\)? Or more generally, ||| what if there are \\(n\\) generating elements? If you like combinatorics, ||| you might enjoy working these and related questions out\-\-\-and, as usual, ||| there's a connection to the Catalan numbers. module Algebra.Magma %default total infix 7 |*| ||| The record representing magmas. Note that there are no proofs to be ||| automatically filled in; magmas don't have any extra properties beyond their ||| signature. public export record Magma where constructor MkMagma Set' : Type op' : Set' -> Set' -> Set' public export Set : {magma : Magma} -> Type Set {magma} = Set' magma public export (|*|) : {magma : Magma} -> Set {magma} -> Set {magma} -> Set {magma} (|*|) {magma} = op' magma {- public export AddMagma : (Num ty) => Magma AddMagma {ty} = MkMagma ty (+) public export MultMagma : (Num ty) => Magma MultMagma {ty} = MkMagma ty (*) -- -} -- data Magma : (Set : Type) -> (Set -> Set -> Set) -> Type where -- Magmoid : -- {-
// Copyright (c) 2001-2008 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(BOOST_SPIRIT_LEX_STATE_SWITCHER_SEP_23_2007_0714PM) #define BOOST_SPIRIT_LEX_STATE_SWITCHER_SEP_23_2007_0714PM #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once // MS compatible compilers support #pragma once #endif #include <boost/spirit/home/qi/domain.hpp> #include <boost/spirit/home/lex/set_state.hpp> #include <boost/spirit/home/support/attribute_of.hpp> #include <boost/spirit/home/support/detail/to_narrow.hpp> namespace boost { namespace spirit { namespace qi { /////////////////////////////////////////////////////////////////////////// // parser, which switches the state of the underlying lexer component // this parser gets used for the set_state(...) construct. /////////////////////////////////////////////////////////////////////////// namespace detail { template <typename Iterator> inline std::size_t set_lexer_state(Iterator& it, std::size_t state) { return it.set_state(state); } template <typename Iterator, typename Char> inline std::size_t set_lexer_state(Iterator& it, Char const* statename) { std::size_t state = it.map_state(statename); // If the following assertion fires you probably used the // set_state(...) or in_state(...)[...] lexer state switcher with // a lexer state name unknown to the lexer (no token definitions // have been associated with this lexer state). BOOST_ASSERT(static_cast<std::size_t>(~0) != state); return it.set_state(state); } } /////////////////////////////////////////////////////////////////////////// struct state_switcher { template <typename Component, typename Context, typename Iterator> struct attribute { typedef unused_type type; }; template < typename Component , typename Iterator, typename Context , typename Skipper, typename Attribute> static bool parse( Component const& component , Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper , Attribute& /*attr*/) { qi::skip(first, last, skipper); // always do a pre-skip // just switch the state and return success detail::set_lexer_state(first, spirit::left(component).name); return true; } template <typename Component, typename Context> static std::string what(Component const& component, Context const& ctx) { std::string result("set_state(\""); result += spirit::detail::to_narrow_string( spirit::left(component).name); result += "\")"; return result; } }; /////////////////////////////////////////////////////////////////////////// // Parser, which switches the state of the underlying lexer component // for the execution of the embedded sub-parser, switching the state back // afterwards. This parser gets used for the in_state(...)[p] construct. /////////////////////////////////////////////////////////////////////////// namespace detail { template <typename Iterator> struct reset_state_on_exit { template <typename State> reset_state_on_exit(Iterator& it_, State state_) : it(it_), state(detail::set_lexer_state(it_, state_)) { } ~reset_state_on_exit() { // reset the state of the underlying lexer instance it.set_state(state); } Iterator& it; std::size_t state; }; } /////////////////////////////////////////////////////////////////////////// struct state_switcher_context { template <typename Component, typename Context, typename Iterator> struct attribute { typedef typename result_of::subject<Component>::type subject_type; typedef typename traits::attribute_of< qi::domain, subject_type, Context, Iterator>::type type; }; template < typename Component , typename Iterator, typename Context , typename Skipper, typename Attribute> static bool parse( Component const& component , Iterator& first, Iterator const& last , Context& context, Skipper const& skipper , Attribute& attr) { qi::skip(first, last, skipper); // always do a pre-skip typedef typename spirit::result_of::subject<Component>::type::director director; // the state has to be reset at exit in any case detail::reset_state_on_exit<Iterator> guard( first, proto::arg_c<0>(argument1(component)).name); return director::parse(spirit::subject(component), first, last, context, skipper, attr); } template <typename Component, typename Context> static std::string what(Component const& component, Context const& ctx) { std::string result("in_state(\""); result += spirit::detail::to_narrow_string( proto::arg_c<0>(argument1(component)).name); result += "\")["; typedef typename spirit::result_of::subject<Component>::type::director director; result += director::what(subject(component), ctx); result += "]"; return result; } }; }}} #endif
[STATEMENT] lemma nth_append_take_drop_is_nth_conv: assumes "i \<le> length xs" and "j \<le> length xs" and "i \<noteq> j" shows "(take j xs @ y # drop (Suc j) xs)!i = xs!i" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (take j xs @ y # drop (Suc j) xs) ! i = xs ! i [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. (take j xs @ y # drop (Suc j) xs) ! i = xs ! i [PROOF STEP] from assms [PROOF STATE] proof (chain) picking this: i \<le> length xs j \<le> length xs i \<noteq> j [PROOF STEP] have "i < j \<or> i > j" [PROOF STATE] proof (prove) using this: i \<le> length xs j \<le> length xs i \<noteq> j goal (1 subgoal): 1. i < j \<or> j < i [PROOF STEP] by auto [PROOF STATE] proof (state) this: i < j \<or> j < i goal (1 subgoal): 1. (take j xs @ y # drop (Suc j) xs) ! i = xs ! i [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: i < j \<or> j < i goal (1 subgoal): 1. (take j xs @ y # drop (Suc j) xs) ! i = xs ! i [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: i < j \<or> j < i i \<le> length xs j \<le> length xs i \<noteq> j goal (1 subgoal): 1. (take j xs @ y # drop (Suc j) xs) ! i = xs ! i [PROOF STEP] by (auto simp: nth_append_take_is_nth_conv nth_append_drop_is_nth_conv) [PROOF STATE] proof (state) this: (take j xs @ y # drop (Suc j) xs) ! i = xs ! i goal: No subgoals! [PROOF STEP] qed
import data.real.basic example (x y : ℝ) (H1 : x = 2) (H2 : y < 5) : x ^ 2 + y < 10 := begin sorry end
[GOAL] w : EssSurj uliftFunctor.{u, v} a : Type (max u v) ⊢ Small.{v, max u v} a [PROOFSTEP] obtain ⟨a', ⟨m⟩⟩ := w.mem_essImage a [GOAL] case intro.intro w : EssSurj uliftFunctor.{u, v} a : Type (max u v) a' : Type v m : uliftFunctor.{u, v}.obj a' ≅ a ⊢ Small.{v, max u v} a [PROOFSTEP] exact ⟨a', ⟨(Iso.toEquiv m).symm.trans Equiv.ulift⟩⟩
# REML estimation of variance components # there are two basic packages for mixed models # nlme, with the lme function # lme4, with the lmer function # the syntax to specify random effects differs slightly. # the following illustrates lmer, which is slightly more flexible # and a lot faster wool <- read.table('wool.txt',header=T) # after reshaping wool.txt into row column format library(lme4) # there is an outlier, remove that before continuing # (could also use subset=() in the lmer call wool2 <- wool[wool$clean < 62,] wool.vc <- lmer(clean~(1|bale),data=wool2) wool.vc # random effects in lmer are specified as the quantity that # varies (here the intercept) and the grouping variable # here the bale. # for simple (e.g. 1-way random effects) uses, does not need # to be a factor. Does't hurt to make it so. # because bale is numeric, it isn't automatically convert to # a factor in read.table() # lmer only allows REML (or full ML) estimation. # bale needs to be a factor to use Nested effects (wool2.r) wool2$bale.f <- as.factor(wool2$bale) wool.vc <- lmer(clean~(1|bale.f),data=wool2) wool.vc
import torch from skimage.morphology import disk @torch.no_grad() def binary_dilation(im: torch.Tensor, kernel: torch.Tensor): assert len(im.shape) == 4 assert len(kernel.shape) == 2 kernel = kernel.unsqueeze(0).unsqueeze(0) padding = kernel.shape[-1]//2 assert kernel.shape[-1] % 2 != 0 if torch.cuda.is_available(): im, kernel = im.half(), kernel.half() else: im, kernel = im.float(), kernel.float() im = torch.nn.functional.conv2d( im, kernel, groups=im.shape[1], padding=padding) im = im.clamp(0, 1).bool() return im def test_dilation(): from skimage.morphology import binary_dilation as skimage_binary_dilation from kornia.morphology import dilation as kornia_dilation import numpy as np import time im = np.random.randint(0, 1, size=(512, 512)).astype(np.bool) sizes = [3, 9, 21, 91] for s in sizes: kernel_np = disk(s).astype(np.bool) kernel_torch = torch.from_numpy(kernel_np) im_torch = torch.from_numpy(im)[None, None] s = time.time() result_skimage = skimage_binary_dilation(im, kernel_np) print("Skimage", time.time() - s) s = time.time() result_kornia = kornia_dilation(im_torch.float(), kernel_torch.float()).bool().cpu().numpy().squeeze() print("Kornia", time.time() - s) s = time.time() result_ours = binary_dilation(im_torch, kernel_torch).cpu().numpy().squeeze() print("Ours", time.time() - s) np.testing.assert_almost_equal(result_skimage, result_kornia) np.testing.assert_almost_equal(result_skimage, result_ours) if __name__ == "__main__": test_dilation()
lemma lift_trans': assumes "f \<in> L F (\<lambda>x. t x (g x))" assumes "g \<in> L F (h)" assumes "\<And>g h. g \<in> L F (h) \<Longrightarrow> (\<lambda>x. t x (g x)) \<in> L F (\<lambda>x. t x (h x))" shows "f \<in> L F (\<lambda>x. t x (h x))"
import IMO2020.N5.additive_map extra.number_theory.ord_compl_zmod /-! # `p`-regular maps Fix a commutative additive monoid `M` and a prime `p`. Given `(c, χ) : M × (additive (zmod p)ˣ →+ M)`, the **regular map** `regular_map M p (c, χ)` is the additive map given by `p^k t ↦ k • c + χ(t : (zmod p)ˣ)` for any `k ≥ 1` and `t` coprime with `p`. We will show that map `regular_map M p` is additive and injective with `regular_map M p 0 = 0`. Then, we construct `regular_hom M p` as a bundled homomorphism version of `regular_map M p`. We also define the predicate `is_regular_map M p` and prove an equivalent condition: an additive map is regular iff `f(t) = f(t % p)` for any `t` coprime with `p`. Lastly, we prove that `is_regular_map M p f` and `is_regular_map M q f` for `p ≠ q` yields `f = 0`. -/ namespace IMOSL namespace IMO2020N5 open extra additive /-- `p`-regular maps -/ def regular_map (M : Type*) [add_comm_monoid M] (p : ℕ) [fact p.prime] (pair : M × (additive (zmod p)ˣ →+ M)) : additive_map M := { to_fun := λ n, ite (n = 0) 0 (padic_val_nat p n • pair.1 + pair.2 (of_mul $ zmod.ord_compl p n)), map_zero' := if_pos rfl, map_one' := by rw [if_neg (nat.succ_ne_zero 0), padic_val_nat.one, zero_nsmul, zero_add, zmod.ord_compl.map_one, of_mul_one, add_monoid_hom.map_zero], map_mul' := λ x y hx hy, by rw [if_neg (mul_ne_zero hx hy), if_neg hx, if_neg hy, add_add_add_comm, ← add_smul, ← @padic_val_nat.mul p x y _inst_2 hx hy, ← add_monoid_hom.map_add, ← of_mul_mul, zmod.ord_compl.map_mul hx hy] } namespace regular_map variables {M : Type*} [add_comm_monoid M] {p : ℕ} [fact p.prime] (pair pair' : M × (additive (zmod p)ˣ →+ M)) theorem map_def (n : ℕ) : regular_map M p pair n = ite (n = 0) 0 (padic_val_nat p n • pair.1 + pair.2 (of_mul (zmod.ord_compl p n))) := rfl @[simp] theorem map_zero : regular_map M p pair 0 = 0 := rfl @[simp] theorem map_ne_zero {n : ℕ} (hn : n ≠ 0) : regular_map M p pair n = padic_val_nat p n • pair.1 + pair.2 (of_mul (zmod.ord_compl p n)) := if_neg hn @[simp] theorem map_one : regular_map M p pair 1 = 0 := additive_map.map_one (regular_map M p pair) @[simp] theorem map_mul {m n : ℕ} (hm : m ≠ 0) (hn : n ≠ 0) : regular_map M p pair (m * n) = regular_map M p pair m + regular_map M p pair n := additive_map.map_mul (regular_map M p pair) hm hn @[simp] theorem map_pow (m k : ℕ) : regular_map M p pair (m ^ k) = k • regular_map M p pair m := additive_map.map_pow (regular_map M p pair) m k theorem map_p : regular_map M p pair p = pair.1 := by rw [map_ne_zero pair (fact.out p.prime).ne_zero, padic_val_nat_self, one_nsmul, zmod.ord_compl.map_self, of_mul_one, add_monoid_hom.map_zero, add_zero] theorem map_coprime' {t : ℕ} (h : t.coprime p) : regular_map M p pair t = pair.2 (of_mul $ zmod.ord_compl p t) := begin have h0 : ¬p ∣ t := by rwa [← nat.prime.coprime_iff_not_dvd (fact.out p.prime), nat.coprime_comm], rw [map_ne_zero, padic_val_nat.eq_zero_of_not_dvd h0, zero_nsmul, zero_add], rintros rfl; exact h0 (dvd_zero p) end theorem map_coprime {t : ℕ} (h : t.coprime p) : regular_map M p pair t = pair.2 (of_mul $ zmod.unit_of_coprime t h) := by rw [map_coprime' pair h, zmod.ord_compl.map_coprime h] theorem map_coprime_mod_p_eq {t : ℕ} (h : t.coprime p) : regular_map M p pair t = regular_map M p pair (t % p) := begin rw [map_coprime' pair h, zmod.ord_compl.map_coprime_mod_p h, map_coprime' pair], rwa [nat.coprime, ← nat.gcd_rec, nat.gcd_comm] end theorem map_zmod_unit_val (x : (zmod p)ˣ) : regular_map M p pair (x : zmod p).val = pair.2 x := by rw [map_coprime' pair (zmod.val_coe_unit_coprime x), zmod.ord_compl.map_zmod_unit_val]; refl theorem map_pair_add : regular_map M p (pair + pair') = regular_map M p pair + regular_map M p pair' := begin ext x; rcases eq_or_ne x 0 with rfl | h, rw [additive_map.map_zero, additive_map.map_zero], rw [map_ne_zero _ h, additive_map.add_apply, map_ne_zero _ h, map_ne_zero _ h], rw [add_add_add_comm, ← add_monoid_hom.add_apply, ← nsmul_add, prod.fst_add, prod.snd_add] end theorem map_pair_zero : regular_map M p 0 = 0 := additive_map.ext (λ x, by rw [map_def, prod.fst_zero, nsmul_zero, zero_add, prod.snd_zero, add_monoid_hom.zero_apply, additive_map.zero_apply, if_t_t]) theorem injective : function.injective (regular_map M p) := begin rintros ⟨c, χ⟩ ⟨d, ρ⟩ h, rw additive_map.ext_iff at h, rw prod.mk.inj_iff; split, replace h := h p; rwa [map_p, map_p] at h, refine add_monoid_hom.ext (λ x, _), replace h := h (to_mul x : zmod p).val, rwa [map_zmod_unit_val, map_zmod_unit_val] at h end theorem inj : regular_map M p pair = regular_map M p pair' ↔ pair = pair' := ⟨λ h, injective h, congr_arg _⟩ theorem fst_eq_iff : pair.1 = pair'.1 ↔ regular_map M p pair p = regular_map M p pair' p := by rw [map_p, map_p] theorem fst_eq_zero_iff : pair.1 = 0 ↔ regular_map M p pair p = 0 := by rw map_p theorem snd_eq_iff : pair.2 = pair'.2 ↔ ∀ k : ℕ, k ≠ 0 → k < p → regular_map M p pair k = regular_map M p pair' k := begin refine ⟨λ h k h0 h1, _, λ h, _⟩, { replace h1 := nat.not_dvd_of_pos_of_lt (zero_lt_iff.mpr h0) h1, rwa [← (fact.out p.prime).coprime_iff_not_dvd, nat.coprime_comm] at h1, rw [map_coprime pair h1, map_coprime pair' h1, h] }, { refine add_monoid_hom.ext (λ x, _), have h0 : (to_mul x : zmod p).val ≠ 0 := by rw [ne.def, zmod.val_eq_zero]; exact (to_mul x).ne_zero, replace h := h (to_mul x : zmod p).val h0 (to_mul x : zmod p).val_lt, rwa [map_zmod_unit_val, map_zmod_unit_val] at h } end theorem snd_eq_zero_iff : pair.2 = 0 ↔ ∀ k : ℕ, k ≠ 0 → k < p → regular_map M p pair k = 0 := by change pair.snd = (0 : M × (additive (zmod p)ˣ →+ M)).snd ↔ _; rw [snd_eq_iff, map_pair_zero]; refl theorem eq_iff : pair = pair' ↔ ∀ k : ℕ, k ≠ 0 → k ≤ p → regular_map M p pair k = regular_map M p pair' k := begin rw [prod.ext_iff, fst_eq_iff, snd_eq_iff], refine ⟨λ h k h1 h2, _, λ h, ⟨h p (fact.out p.prime).ne_zero (le_refl p), λ k h0 h1, h k h0 (le_of_lt h1)⟩⟩, rw le_iff_eq_or_lt at h2; rcases h2 with h2 | h2, rw [h2, h.1], exact h.2 k h1 h2 end end regular_map open regular_map /-- `p`-regular mapping as a homomorphism -/ def regular_hom (M : Type*) [add_comm_monoid M] (p : ℕ) [fact p.prime] : M × (additive (zmod p)ˣ →+ M) →+ additive_map M := ⟨regular_map M p, map_pair_zero, map_pair_add⟩ /-- `p`-regularity predicate -/ def is_regular_map (M : Type*) [add_comm_monoid M] (p : ℕ) [fact p.prime] (f : additive_map M) := ∃ pair : M × (additive (zmod p)ˣ →+ M), f = regular_map M p pair namespace is_regular_map variables {M : Type*} [add_comm_monoid M] {p q : ℕ} [fact p.prime] [fact q.prime] /-- The zero additive map is `p`-regular -/ theorem zero : is_regular_map M p 0 := ⟨0, map_pair_zero.symm⟩ /-- An equivalent condition for `p`-regularity -/ theorem iff (f : additive_map M) : is_regular_map M p f ↔ ∀ t : ℕ, t.coprime p → f t = f (t % p) := begin refine ⟨λ h t h0, _, λ h, ⟨⟨f p, ⟨λ x, f (to_mul x : zmod p).val, _, λ x y, _⟩⟩, _⟩⟩, rcases h with ⟨pair, rfl⟩; exact map_coprime_mod_p_eq pair h0, rw [to_mul_zero, units.coe_one, zmod.val_one, additive_map.map_one], { have h0 := λ x : (zmod p)ˣ, zmod.val_coe_unit_coprime (to_mul x), suffices : ∀ x : ℕ, x.coprime p → x ≠ 0, rw [to_mul_add, units.coe_mul, zmod.val_mul, ← h _ ((h0 x).mul $ h0 y), additive_map.map_mul _ (this _ $ h0 x) (this _ $ h0 y)], rintros x h1 rfl, rw [nat.coprime_comm, (fact.out p.prime).coprime_iff_not_dvd] at h1, exact h1 (dvd_zero p) }, { refine additive_map.ext (λ n, _), rcases eq_or_ne n 0 with rfl | h0, rw [additive_map.map_zero, regular_map.map_zero], rw regular_map.map_ne_zero _ h0, nth_rewrite 0 ← nat.ord_proj_mul_ord_compl_eq_self n p, have hp := fact.out p.prime, rw [f.map_mul (pow_ne_zero _ hp.ne_zero) (ne_of_gt $ p.ord_compl_pos h0), additive_map.map_pow, add_monoid_hom.coe_mk, to_mul_of_mul, ← nat.factorization_def _ hp, zmod.ord_compl.map_ne_zero_val h0, ← h], rw nat.coprime_comm; exact nat.coprime_ord_compl hp h0 } end /-- Condition for two `p`-regular maps to be equal -/ theorem ext_iff_at_le_p {f g : additive_map M} (hf : is_regular_map M p f) (hg : is_regular_map M p g) : f = g ↔ ∀ k : ℕ, k ≠ 0 → k ≤ p → f k = g k := begin rcases hf with ⟨⟨c, χ⟩, rfl⟩, rcases hg with ⟨⟨c', χ'⟩, rfl⟩, rw [regular_map.inj, regular_map.eq_iff] end /-- Condition for a `p`-regular map to be zero -/ theorem zero_iff_at_le_p {f : additive_map M} (hf : is_regular_map M p f) : f = 0 ↔ ∀ k : ℕ, k ≠ 0 → k ≤ p → f k = 0 := by rw ext_iff_at_le_p hf zero; refl /-- (Private) small lemma for values of `p`-regular map at two `nat` congruent modulo `p` -/ private lemma map_modeq_coprime {f : additive_map M} (hf : is_regular_map M p f) {m n : ℕ} (h : m % p = n % p) (h0 : n.coprime p) : f m = f n := begin rw iff at hf, rw [hf n h0, ← h, ← hf], unfold nat.coprime at h0 ⊢, rw ← nat.modeq at h, rw [nat.modeq.gcd_eq_of_modeq h, h0] end /-- Distinction between `p`-regular and `q`-regular for `p < q` -/ private lemma distinction' {f : additive_map M} (hpf : is_regular_map M p f) (hqf : is_regular_map M q f) (h : p < q) : f = 0 := begin have hp := fact.out p.prime, have hq := fact.out q.prime, have hpq := (nat.coprime_primes hp hq).mpr (ne_of_lt h), rw zero_iff_at_le_p hpf, suffices : ∃ c : M, f p + c = 0, { cases this with c h0, replace hpf : ∀ k : ℕ, f (q + k * p) = f q := λ k, map_modeq_coprime hpf (by rw nat.add_mul_mod_self_right) hpq.symm, suffices : ∀ k : ℕ, k ≠ 0 → k ≤ p → f q = f k + f p, { intros k h1 h2, rw [← add_zero (f k), ← h0, ← add_assoc, ← this k h1 h2, this 1 one_ne_zero (le_of_lt hp.one_lt), additive_map.map_one, zero_add] }, intros k h1 h2, rw [← hpf k, ← additive_map.map_mul f h1 hp.ne_zero], apply map_modeq_coprime hqf, rw nat.add_mod_left, refine nat.coprime.mul _ hpq, rw [nat.coprime_comm, hq.coprime_iff_not_dvd], exact nat.not_dvd_of_pos_of_lt (zero_lt_iff.mpr h1) (lt_of_le_of_lt h2 h) }, obtain ⟨n, h0⟩ := nat.exists_mul_mod_eq_one_of_coprime hpq hq.one_lt, use f n, rw ← nat.mod_eq_of_lt hq.one_lt at h0, rw [← additive_map.map_mul f hp.ne_zero, map_modeq_coprime hqf h0 q.coprime_one_left], exact f.map_one, rintros rfl, rw [mul_zero, nat.zero_mod, nat.mod_eq_of_lt hq.one_lt] at h0, revert h0; exact zero_ne_one end /-- Distinction between `p`-regular and `q`-regular for `p ≠ q` -/ theorem distinction {f : additive_map M} (h : is_regular_map M p f) (h0 : is_regular_map M q f) (h1 : p ≠ q) : f = 0 := begin rw ne_iff_lt_or_gt at h1; cases h1 with h1 h1, exacts [distinction' h h0 h1, distinction' h0 h h1] end end is_regular_map end IMO2020N5 end IMOSL
import numpy as np import pytransform3d.coordinates as pc from nose.tools import assert_less_equal from numpy.testing import assert_array_almost_equal def test_cylindrical_from_cartesian_edge_cases(): q = pc.cylindrical_from_cartesian(np.zeros(3)) assert_array_almost_equal(q, np.zeros(3)) def test_cartesian_from_cylindrical_edge_cases(): q = pc.cartesian_from_cylindrical(np.zeros(3)) assert_array_almost_equal(q, np.zeros(3)) def test_convert_cartesian_cylindrical(): random_state = np.random.RandomState(0) for i in range(1000): rho = random_state.randn() phi = random_state.rand() * 4 * np.pi - 2 * np.pi z = random_state.randn() p = np.array([rho, phi, z]) q = pc.cartesian_from_cylindrical(p) r = pc.cylindrical_from_cartesian(q) assert_less_equal(0, r[0]) assert_less_equal(-np.pi, r[1]) assert_less_equal(r[1], np.pi) s = pc.cartesian_from_cylindrical(r) assert_array_almost_equal(q, s) def test_spherical_from_cartesian_edge_cases(): q = pc.spherical_from_cartesian(np.zeros(3)) assert_array_almost_equal(q, np.zeros(3)) def test_cartesian_from_spherical_edge_cases(): q = pc.cartesian_from_spherical(np.zeros(3)) assert_array_almost_equal(q, np.zeros(3)) def test_convert_cartesian_spherical(): random_state = np.random.RandomState(1) for i in range(1000): rho = random_state.randn() theta = random_state.rand() * 4 * np.pi - 2 * np.pi phi = random_state.rand() * 4 * np.pi - 2 * np.pi p = np.array([rho, theta, phi]) q = pc.cartesian_from_spherical(p) r = pc.spherical_from_cartesian(q) assert_less_equal(0, r[0]) assert_less_equal(0, r[1]) assert_less_equal(r[1], np.pi) assert_less_equal(-np.pi, r[2]) assert_less_equal(r[2], np.pi) s = pc.cartesian_from_spherical(r) assert_array_almost_equal(q, s) def test_spherical_from_cylindrical_edge_cases(): q = pc.spherical_from_cylindrical(np.zeros(3)) assert_array_almost_equal(q, np.zeros(3)) def test_cylindrical_from_spherical_edge_cases(): q = pc.cylindrical_from_spherical(np.zeros(3)) assert_array_almost_equal(q, np.zeros(3)) def test_convert_cylindrical_spherical(): random_state = np.random.RandomState(2) for i in range(1000): rho = random_state.randn() theta = random_state.rand() * 4 * np.pi - 2 * np.pi phi = random_state.rand() * 4 * np.pi - 2 * np.pi p = np.array([rho, theta, phi]) q = pc.cylindrical_from_spherical(p) r = pc.spherical_from_cylindrical(q) s = pc.cylindrical_from_spherical(r) assert_array_almost_equal(q, s)
[STATEMENT] lemma add_mset_inter_add_mset [simp]: "add_mset a A \<inter># add_mset a B = add_mset a (A \<inter># B)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. add_mset a A \<inter># add_mset a B = add_mset a (A \<inter># B) [PROOF STEP] by (rule multiset_eqI) simp
# Exercise 1 # # Time: 5 minutes # The following command creates a vector of 100 random numbers between 1 and 1000: my_vector <- c(sample(1:1000, 100)) # Answer the following questions about the vector: # 1) Extract the third through the sixth elements from the vector: # 2) Check to see if the numbers 99, 66, and 287 exist in this vector: # 3) How many elements are greater than 500?
import Lean.Elab.Command import Lib.Logic.Classical macro "obtain " p:term " from " d:term : tactic => `(tactic| match $d:term with | $p:term => ?_) -- macro "left" : tactic => -- `(tactic| apply Or.inl) -- macro "right" : tactic => -- `(tactic| apply Or.inr) -- macro "refl" : tactic => -- `(tactic| apply rfl) -- macro "exfalso" : tactic => -- `(tactic| apply False.elim) macro "byContradiction" h: ident : tactic => `(tactic| apply Classical.byContradiction; intro h) theorem swapHyp {p q : Prop} (h : p) (h' : ¬ p) : q := by cases h' h macro "swapHyp" h:term "as" h':ident : tactic => `(tactic| apply Classical.byContradiction; intro $h' <;> first | apply $h ; clear $h | apply swapHyp $h <;> clear $h ) -- open Lean Parser.Tactic Elab Command Elab.Tactic Meta -- macro "fail" : tactic => pure $ throwError "foo" namespace Option @[simp] theorem map_none {f : α → β} : Option.map f none = none := rfl @[simp] theorem map_some {f : α → β} {x} : Option.map f (some x) = some (f x) := rfl attribute [simp] map_id end Option inductive EqvGen (R : α → α → Prop) : α → α → Prop := | rfl {x} : EqvGen R x x | step {x y z} : R x y → EqvGen R y z → EqvGen R x z | symm_step {x y z} : R y x → EqvGen R y z → EqvGen R x z namespace EqvGen variable {R : α → α → Prop} theorem once (h : R x y) : EqvGen R x y := EqvGen.step h EqvGen.rfl theorem once_symm (h : R y x) : EqvGen R x y := EqvGen.symm_step h EqvGen.rfl theorem trans : EqvGen R x y → EqvGen R y z → EqvGen R x z := by intros h₀ h₁ induction h₀ with | rfl => exact h₁ | step hR hGen IH => exact step hR (IH h₁) | symm_step hR hGen IH => exact symm_step hR (IH h₁) theorem symm_step_r : EqvGen R x y → R z y → EqvGen R x z := by intros h₀ h₁ have h₁ := once_symm h₁ apply trans <;> assumption theorem step_r : EqvGen R x y → R y z → EqvGen R x z := by intros h₀ h₁ have h₁ := once h₁ apply trans <;> assumption theorem symm : EqvGen R x y → EqvGen R y x := by intros h induction h with | rfl => exact rfl | step hR hGen IH => exact trans IH (symm_step hR rfl) | symm_step hR hGen IH => exact trans IH (step hR rfl) end EqvGen namespace Quot variable {r : α → α → Prop} variable {r' : α' → α' → Prop} def liftOn₂ (x : Quot r) (y : Quot r') (f : α → α' → β) (h : ∀ (a b : α) (a' : α'), r a b → f a a' = f b a') (h' : ∀ (a : α) (a' b' : α'), r' a' b' → f a a' = f a b') : β := Quot.liftOn x (λ x => Quot.liftOn y (f x) $ by intros; apply h'; assumption) $ by intros induction y using Quot.inductionOn simp [Quot.liftOn] apply h; assumption @[simp] def liftOn₂_beta {x : α} {y : α'} (f : α → α' → β) (h : ∀ (a b : α) (a' : α'), r a b → f a a' = f b a') (h' : ∀ (a : α) (a' b' : α'), r' a' b' → f a a' = f a b') : liftOn₂ (Quot.mk _ x) (Quot.mk _ y) f h h' = f x y := by simp [liftOn₂] noncomputable def out (x : Quot r) : α := Classical.choose (exists_rep x) theorem eq' : Quot.mk r x = Quot.mk r y ↔ EqvGen r x y := by constructor focus intros h have Hlift : ∀ (a b : α), r a b → EqvGen r x a = EqvGen r x b := by intros a b Hab apply propext constructor <;> intro h focus apply EqvGen.step_r <;> assumption focus apply EqvGen.symm_step_r <;> assumption rw [← Quot.liftBeta (r := r) (EqvGen r x) Hlift, ← h, Quot.liftBeta (r := r) _ Hlift] exact EqvGen.rfl focus intros h induction h with | rfl => refl | step Hr Hgen IH => rw [← IH] apply Quot.sound; assumption | symm_step Hr Hgen IH => apply Eq.symm rw [← IH] apply Quot.sound; assumption theorem eq : Quot.mk r x = Quot.mk r y ↔ EqvGen r x y := by constructor focus intros h rewrite [← liftOn₂_beta (r:=r) (r':=r) (EqvGen r), h, liftOn₂_beta] focus exact EqvGen.rfl focus intros x y z Hxy apply propext constructor <;> intro h focus apply EqvGen.symm_step <;> assumption focus apply EqvGen.step <;> assumption focus intros x y z Hxy apply propext constructor <;> intro h focus apply EqvGen.step_r <;> assumption focus apply EqvGen.symm_step_r <;> assumption focus intros h induction h with | rfl => refl | step Hr Hgen IH => rw [← IH] apply Quot.sound; assumption | symm_step Hr Hgen IH => apply Eq.symm rw [← IH] apply Quot.sound; assumption end Quot class WellOrdered (α : Type) where R : α → α → Prop wf : WellFounded R total x y : R x y ∨ x = y ∨ R y x instance [WellOrdered α] : LT α := ⟨ WellOrdered.R ⟩ instance [WellOrdered α] : LE α where le x y := x = y ∨ x < y namespace WellOrdered variable [Hwo : WellOrdered α] theorem le_of_lt {x y : α} : x < y → x ≤ y := Or.inr theorem lt_irrefl (x : α) : ¬ x < x := by have := WellOrdered.wf.apply x induction this with | intro x h ih => intro h' apply ih _ h' h' theorem le_refl (x : α) : x ≤ x := by left; refl theorem lt_antisymm {x y : α} : x < y → y < x → False := by revert y have := WellOrdered.wf.apply x induction this with | intro x h ih => intros y Hxy Hyx cases ih _ Hyx Hyx Hxy theorem le_antisymm {x y : α} : x ≤ y → y ≤ x → x = y := by intros Hxy Hyx; match x, Hxy, Hyx with | x, Or.inl rfl, _ => intros; refl | x, Or.inr Hx_lt, Or.inl rfl => refl | x, Or.inr Hx_lt, Or.inr Hy_lt => cases lt_antisymm Hx_lt Hy_lt section open Classical theorem bottom_exists [inst : Nonempty α] : ∃ x : α, ∀ y : α, ¬ y < x := by cases inst with | intro x => have h := Hwo.wf.apply x induction h with | intro y h ih => exact if h : ∃ z, z < y then by cases h with | intro z hz => apply ih _ hz else by rewrite [not_exists] at h exists y; assumption noncomputable def bottom (α) [WellOrdered α] [inst : Nonempty α] : α := choose bottom_exists theorem lt_iff_not_lt [h : WellOrdered α] (x y : α) : x < y ↔ ¬ y ≤ x := by constructor focus intros h₀ h₁ match y, h₁ with | y, Or.inr h₁ => apply lt_antisymm h₀ h₁ | _, Or.inl rfl => apply lt_irrefl _ h₀ focus intros h₀ have := WellOrdered.total x y match y, this with | y, Or.inl h₀ => assumption | _, Or.inr (Or.inl rfl) => exfalso apply h₀; clear h₀ apply le_refl | y, Or.inr (Or.inr h₁) => exfalso apply h₀; clear h₀ right; assumption theorem not_lt_bottom [inst : Nonempty α] : ¬ x < bottom α := choose_spec bottom_exists x theorem bottom_le [inst : Nonempty α] : bottom α ≤ x := by have H := not_lt_bottom (α := α) (x := x) simp [lt_iff_not_lt] at H assumption end theorem lt_trans {x y z : α} : x < y → y < z → x < z := by rewrite [lt_iff_not_lt x z] intros hxy hyz hxz cases hxz with | inl hxz => subst hxz apply lt_antisymm hxy hyz | inr hxz => have := WellOrdered.wf.apply x induction this generalizing y z with | intro x h ih => apply @ih _ hxz x y <;> assumption theorem le_trans {x y z : α} : x ≤ y → y ≤ z → x ≤ z := by intros hxy hyz cases hxy with | inl hxy => cases hyz with | inl hyz => subst hxy hyz; left; refl | inr hyz => subst hxy; right; assumption | inr hxy => cases hyz with | inl hyz => subst hyz; right; assumption | inr hyz => right; apply lt_trans <;> assumption section Classical open Classical -- noncomputable -- def max (x y : α) : α := -- if x < y -- then y -- else x theorem max_le_iff (x y z : α) : max x y ≤ z ↔ x ≤ z ∧ y ≤ z := by byCases Hyz : y < x focus have := le_of_lt Hyz simp [max, *] constructor focus intros h constructor <;> try assumption apply le_trans <;> assumption focus intro h; cases h; assumption focus simp [max, *] simp [lt_iff_not_lt] at Hyz constructor focus intros h constructor <;> try assumption apply le_trans <;> assumption focus intros h; cases h; assumption end Classical end WellOrdered def WellOrder := Sigma WellOrdered noncomputable instance : CoeSort WellOrder (Type) := ⟨ Sigma.fst ⟩ instance (α : WellOrder) : WellOrdered α := α.snd structure WellOrderHom (α β : WellOrder) where hom : α.1 → β.1 hom_preserve x y : α.2.R x y → β.2.R (hom x) (hom y) namespace WellOrderHom instance : CoeFun (WellOrderHom a b) (λ _ => a → b) where coe f := f.hom theorem ext {f g : WellOrderHom a b} (h : ∀ x, f x = g x) : f = g := by have d : f.hom = g.hom := funext h cases f with | mk f hf => cases g with | mk g hg => simp at d; revert hf hg; rewrite [d]; intros; exact rfl theorem ext_iff {f g : WellOrderHom a b} (h : f = g) : ∀ x, f x = g x := by subst h; intros; refl def id : WellOrderHom α α where hom := _root_.id hom_preserve x y hxy := hxy def comp (f : WellOrderHom β γ) (g : WellOrderHom α β) : WellOrderHom α γ where hom := f.hom ∘ g.hom hom_preserve x y hxy := f.hom_preserve _ _ (g.hom_preserve _ _ hxy) variable {X Y Z W : WellOrder} variable (f : WellOrderHom X Y) variable (g : WellOrderHom Y Z) variable (h : WellOrderHom Z W) @[simp] theorem id_comp : id.comp f = f := by apply ext; intro x; exact rfl @[simp] theorem comp_id : f.comp id = f := by apply ext; intro x; exact rfl @[simp] theorem comp_assoc : (h.comp g).comp f = h.comp (g.comp f) := by apply ext; intro x; exact rfl end WellOrderHom class IsMono {X Y} (f : WellOrderHom X Y) where mono : ∀ W (g₁ g₂ : WellOrderHom W X), f.comp g₁ = f.comp g₂ → g₁ = g₂ namespace IsMono variable {X Y Z : WellOrder} variable (f : WellOrderHom X Y) variable (g : WellOrderHom Y Z) variable (gZY : WellOrderHom Z Y) variable (gZX : WellOrderHom Z X) open WellOrderHom instance : IsMono (@WellOrderHom.id X) where mono W g₁ g₂ := by simp; apply _root_.id instance [IsMono f] [IsMono g] : IsMono (g.comp f) where mono W g₁ g₂ := by simp; intro h have h := mono _ _ _ h apply mono _ _ _ h end IsMono class IsIso {X Y} (f : WellOrderHom X Y) where inv : WellOrderHom Y X to_inv : f.comp inv = WellOrderHom.id inv_to : inv.comp f = WellOrderHom.id export IsIso (inv) namespace IsIso attribute [simp] to_inv inv_to open WellOrderHom variable {X Y Z : WellOrder} variable (f : WellOrderHom X Y) variable (g : WellOrderHom Y Z) variable (gZY : WellOrderHom Z Y) variable (gZX : WellOrderHom Z X) @[simp] theorem to_inv_reassoc [IsIso f] : f.comp ((inv f).comp gZY) = gZY := by rw [← WellOrderHom.comp_assoc, to_inv, id_comp] @[simp] theorem inv_to_reassoc [IsIso f] : (inv f).comp (f.comp gZX) = gZX := by rw [← WellOrderHom.comp_assoc, inv_to, id_comp] instance [IsIso f] : IsIso (inv f) where inv := f to_inv := inv_to inv_to := to_inv instance : IsIso (@WellOrderHom.id X) where inv := id to_inv := by simp inv_to := by simp instance [IsIso f] [IsIso g] : IsIso (g.comp f) where inv := (inv f).comp (inv g) to_inv := by simp inv_to := by simp instance (priority := low) [IsIso f] : IsMono f where mono W g₁ g₂ Heq := by rw [← inv_to_reassoc f g₁, Heq, inv_to_reassoc] end IsIso section HasArrow -- set_option checkBinderAnnotations false inductive HasArrow X Y (cl : WellOrderHom X Y → Type u) : Prop := | intro (f : WellOrderHom X Y) : cl f → HasArrow X Y cl end HasArrow def WellOrderMono (α β : WellOrder) := HasArrow α β IsMono @[matchPattern] def WellOrderMono.intro (f : WellOrderHom x y) [IsMono f] : WellOrderMono x y := HasArrow.intro f inferInstance def WellOrderIso (α β : WellOrder) := HasArrow α β IsIso @[matchPattern] def WellOrderIso.intro (f : WellOrderHom x y) [IsIso f] : WellOrderIso x y := HasArrow.intro f inferInstance -- namespace WellOrderIso -- variable {X Y : WellOrder} -- def flip (f : WellOrderIso X Y) : WellOrderIso Y X where -- to := f.inv -- inv := f.to -- to_inv := f.inv_to -- inv_to := f.to_inv -- def toMono (f : WellOrderIso X Y) : WellOrderMono X Y where -- to := f.to -- mono Z g₀ g₁ h := _ -- end WellOrderIso -- inductive Erased (α : Type u) : Prop := -- | intro (x : α) : Erased α -- theorem Erased_impl {α β} (f : α → β) : Erased α → Erased β -- | ⟨ x ⟩ => ⟨ f x ⟩ def WOEqv (α β : WellOrder) : Prop := WellOrderIso α β def Ordinal := Quot WOEqv namespace Ordinal protected def mk (α : Type) [WellOrdered α] : Ordinal := Quot.mk _ { fst := α, snd := inferInstance } def zero : Ordinal := Quot.mk _ { fst := Empty, snd := { R := by {intro x; cases x}, wf := by { constructor; intro x; cases x }, total := by {intro x; cases x} } } inductive Option.R (r : α → α → Prop) : Option α → Option α → Prop where | top x : R r (some x) none | lifted x y : r x y → R r (some x) (some y) theorem Option.R_acc {r : α → α → Prop} x (h : Acc r x) : Acc (Option.R r) (some x) := by induction h with | intro y h' ih => constructor; intros z Hr; cases Hr apply ih; assumption theorem Option.R_wf {r : α → α → Prop} (h : WellFounded r) : WellFounded (Option.R r) := by constructor; intro x match x with | none => constructor; intro y h'; cases h' apply Option.R_acc apply h.apply | some x => apply Option.R_acc apply h.apply instance [WellOrdered α] : WellOrdered (Option α) where R := Option.R (WellOrdered.R) wf := Option.R_wf (WellOrdered.wf) total := λ x y => match x, y with | none, none => by apply Or.inr; apply Or.inl constructor | none, some _ => by apply Or.inr; apply Or.inr constructor | some _, none => by apply Or.inl constructor | some x, some y => match WellOrdered.total x y with | Or.inl h => Or.inl $ Option.R.lifted _ _ h | Or.inr (Or.inl h) => Or.inr $ Or.inl $ congrArg _ h | Or.inr (Or.inr h) => Or.inr $ Or.inr $ Option.R.lifted _ _ h def impl.S : WellOrder → WellOrder | ⟨α, Hα⟩ => let _ : WellOrdered α := Hα { fst := Option α, snd := inferInstance } def S_hom (h : WellOrderHom a b) : WellOrderHom (impl.S a) (impl.S b) where hom := Option.map h hom_preserve := by intros x y h; cases x <;> cases y <;> cases h <;> constructor <;> apply h.hom_preserve <;> assumption @[simp] theorem id_hom : (@WellOrderHom.id a).hom = id := rfl @[simp] theorem S_hom_hom (h : WellOrderHom a b) : (S_hom h).hom = Option.map h.hom := rfl @[simp] theorem comp_hom (f : WellOrderHom b c) (g : WellOrderHom a b) : (f.comp g).hom = f.hom ∘ g.hom := rfl @[simp] theorem comp_S_hom (f : WellOrderHom b c) (g : WellOrderHom a b) : (S_hom f).comp (S_hom g) = S_hom (f.comp g) := WellOrderHom.ext $ by intro x cases x <;> simp [WellOrderHom.comp, S_hom] @[simp] theorem S_hom_id {α} : S_hom (@WellOrderHom.id α) = WellOrderHom.id := WellOrderHom.ext $ by intro x rw [S_hom_hom, id_hom, id_hom] simp instance [@IsIso x y f] : IsIso (S_hom f) where inv := S_hom (inv f) to_inv := by simp inv_to := by simp def S_iso : WellOrderIso a b → WellOrderIso (impl.S a) (impl.S b) | ⟨f, h⟩ => have h' := h ⟨S_hom f, inferInstance⟩ -- to := S_hom h.to -- inv := S_hom h.inv -- to_inv := by simp [h.to_inv] -- inv_to := by simp [h.inv_to] def S : Ordinal → Ordinal := Quot.lift (Quot.mk _ ∘ impl.S) λ a b Heqv => by simp apply Quot.sound exact S_iso Heqv def Le (x y : Ordinal) : Prop := Quot.liftOn₂ x y (λ x y => WellOrderMono x y) (by intros a b x f cases f with | intro f hf => simp; apply propext constructor <;> intros g { cases g with | intro g hg => have hf := hf have hg := hg exact ⟨g.comp (inv f), inferInstance⟩ } { cases g with | intro g hg => have hf := hf have hg := hg exact ⟨g.comp f, inferInstance⟩ } ) (by intros x a b f cases f with | intro f hf => simp; apply propext constructor <;> intros g { cases g with | intro g hg => have hf := hf have hg := hg exact ⟨f.comp g, inferInstance⟩ } { cases g with | intro g hg => have hf := hf have hg := hg exact ⟨(inv f).comp g, inferInstance⟩ } ) def Lt (x y : Ordinal) : Prop := Le x y ∧ ¬ Le y x -- structure StrictInclusion (a b : WellOrder) : Type where -- inclusion : WellOrderHom a b -- [incl_mono : IsMono inclusion] -- strict : ¬ WellOrderMono b a -- attribute [instance] StrictInclusion.incl_mono instance : LE Ordinal := ⟨ Le ⟩ instance : LT Ordinal := ⟨ Lt ⟩ theorem le_refl (x : Ordinal) : x ≤ x := by cases x using Quot.ind simp [LE.le,Le] exists @WellOrderHom.id _ exact inferInstance infix:25 " ⟶ " => WellOrderHom instance : WellOrdered Unit where R _ _ := False wf := ⟨ λ a => ⟨ _, by intros _ h; cases h ⟩ ⟩ total := by intros; right; left; refl def Unit : WellOrder := ⟨_root_.Unit,inferInstance⟩ def const {β : WellOrder} (x : β) : Unit ⟶ β where hom := λ i => x hom_preserve := by intros _ _ h; cases h section inverse open Classical noncomputable def inverse [Nonempty α] (f : α → β) (x : β) : α := epsilon λ y => f y = x end inverse section schroeder_bernstein open Classical def injective (f : α → β) : Prop := ∀ x y, f x = f y → x = y def surjective (f : α → β) : Prop := ∀ y, ∃ x, f x = y def bijective (f : α → β) : Prop := injective f ∧ surjective f variable [Nonempty α] [Nonempty β] variable (f : α → β) (hf : injective f) variable (g : β → α) (hg : injective g) theorem left_inv_of_injective : inverse f ∘ f = id := by apply funext; intro x simp [Function.comp, inverse] apply hf apply Classical.epsilon_spec (p := λ y => f y = f x) exists x; refl theorem right_inv_of_surjective (hf' : surjective f) : f ∘ inverse f = id := by apply funext; intro x specialize (hf' x) apply Classical.epsilon_spec (p := λ y => f y = x) assumption theorem injective_of_left_inv (h : g ∘ f = id) : injective f := by intros x y Hxy have Hxy : (g ∘ f) x = (g ∘ f) y := congrArg g Hxy rewrite [h] at Hxy; assumption theorem injective_of_right_inv (h : g ∘ f = id) : surjective g := by intros x exists (f x) show (g ∘ f) x = x rewrite [h]; refl -- def lonely (b : β) := ∀ a, f a ≠ b -- def iterate (n : Nat) (b : β) : β := -- match n with -- | 0 => b -- | Nat.succ n => iterate n (f (g b)) -- -- #exit -- def descendent (b₀ b₁ : β) : Prop := -- ∃ n, iterate f g n b₀ = b₁ -- -- #exit -- theorem schroeder_bernstein : -- ∃ h : α → β, bijective h := by -- let p x y := lonely f y ∧ descendent f g y (f x) -- let h x := -- if ∃ y, p x y -- then inverse g x -- else f x -- exists h; constructor -- focus -- intro x y; simp -- -- focus -- -- intros x y -- -- -- simp at Hxy -- -- simp -- -- -- have : (∃ z, p x z) ↔ (∃ z, p y z) := by -- -- -- constructor <;> intros h -- -- -- focus -- -- -- cases h with -- -- -- | intro z hz => unfold p at * -- -- -- admit -- byCases hx : (∃ z, p x z) <;> -- byCases hy : (∃ z, p y z) <;> -- simp [*] <;> intro h3 -- focus -- clear h -- cases hx with | intro x' hx' => -- cases hy with | intro y' hy' => -- cases hy'; cases hx' -- clear p -- admit -- abort -- -- match propDecidable (∃ z, p x z), propDecidable (∃ z, p y z), Hxy with -- -- | isTrue ⟨x', hx, hx'⟩, isTrue ⟨y', hy, hy'⟩, Hxy => _ -- -- | isTrue _, isFalse _, Hxy => _ -- -- | isFalse _, isTrue _, Hxy => _ -- -- | isFalse _, isFalse _, Hxy => _ -- -- -- { admit } -- -- simp [h] at Hxy } -- -- exists (inverse g ∘ f) end schroeder_bernstein theorem comp_const (f : WellOrderHom a b) x : f.comp (const x) = const (f x) := rfl theorem injective_of_monomorphism (f : WellOrderHom a b) [IsMono f] : injective f.hom := by intros x y Hxy have := @IsMono.mono _ _ f _ _ (const x) (const y) simp [comp_const, Hxy] at this have := WellOrderHom.ext_iff this () assumption -- Need Schroeder-Bernstein Theorem theorem le_antisymm (x y : Ordinal) (Hxy : x ≤ y) (Hyx : y ≤ x) : x = y := by cases x using Quot.ind cases y using Quot.ind simp [LE.le,Le] at * apply Quot.sound cases Hxy with | intro f hf => cases Hyx with | intro g hg => _ admit theorem le_trans (x y z : Ordinal) (Hxy : x ≤ y) (Hyz : y ≤ z) : x ≤ z := by cases x using Quot.ind cases y using Quot.ind cases z using Quot.ind simp [LE.le,Le] at * cases Hxy with | intro f hf => cases Hyz with | intro g hg => have hf := hf have hg := hg exists g.comp f exact inferInstance theorem lt_total (x y : Ordinal) : x < y ∨ x = y ∨ y < x := by byCases hxy : (x ≤ y) <;> byCases hyx : (y ≤ x) focus right; left apply le_antisymm <;> assumption focus left; constructor <;> assumption focus right; right constructor <;> assumption focus admit -- Todo: -- Le is a total order -- Limits -- zero is a limit? (no) -- zero, Succ, Limit are distinct -- recursor / induction principle namespace WellOrdered variable [WellOrdered α] theorem le_iff_forall_le (x y : α) : x ≤ y ↔ ∀ z, y ≤ z → x ≤ z := by constructor <;> intros h focus intros z h' apply WellOrdered.le_trans <;> assumption focus apply h apply WellOrdered.le_refl theorem le_iff_forall_ge (x y : α) : x ≤ y ↔ ∀ z, z ≤ x → z ≤ y := by constructor <;> intros h focus intros z h' apply WellOrdered.le_trans <;> assumption focus apply h apply WellOrdered.le_refl theorem le_total (x y : α) : x ≤ y ∨ y ≤ x := sorry section Classical open Classical theorem le_max_l {x y : α} : x ≤ max x y := by rw [le_iff_forall_le]; intros z rw [WellOrdered.max_le_iff] intros h; cases h; assumption theorem le_max_r {x y : α} : y ≤ max x y := by rw [le_iff_forall_le]; intros z rw [WellOrdered.max_le_iff] intros h; cases h; assumption instance : @Reflexive α LE.le where refl := WellOrdered.le_refl theorem max_eq_of_le {x y : α} : x ≤ y → max x y = y := by intros h apply WellOrdered.le_antisymm focus rw [WellOrdered.max_le_iff] auto focus apply WellOrdered.le_max_r theorem max_eq_of_ge {x y : α} : y ≤ x → max x y = x := by intros h apply WellOrdered.le_antisymm focus rw [WellOrdered.max_le_iff] auto focus apply WellOrdered.le_max_l end Classical end WellOrdered noncomputable instance : CoeSort WellOrder Type := ⟨ Sigma.fst ⟩ structure Seq where index : Type [wo : WellOrdered index] ords : index → WellOrder increasing (i j : index) : i ≤ j → ords i ⟶ ords j [mono (i j : index) h : IsMono (increasing i j h)] strict (i j : index) : i < j → ¬ WellOrderMono (ords i) (ords j) increasing_refl (i : index) h : increasing i i h = WellOrderHom.id increasing_trans (i j k : index) (h : i ≤ j) (h' : j ≤ k) : (increasing _ _ h').comp (increasing _ _ h) = increasing _ _ (WellOrdered.le_trans h h') bottom : index next : index → index infinite i : i < next i nothing_below_bottom x : ¬ x < bottom consecutive i j : j < next i → j < i ∨ j = i attribute [instance] Seq.wo Seq.mono -- theorem Seq.increasing' (i j : s.index) : -- i ≤ j → ords i ⟶ ords j theorem Seq.bottom_le (s : Seq) x : s.bottom ≤ x := by have := s.nothing_below_bottom x simp [WellOrdered.lt_iff_not_lt] at this assumption def Lim.Eqv (s : Seq) : (Σ i : s.index, s.ords i) → (Σ i, s.ords i) → Prop | ⟨i, x⟩, ⟨j, y⟩ => (∃ h : i < j, s.increasing _ _ (WellOrdered.le_of_lt h) x = y) ∨ (∃ h : i = j, cast (by rw [h]) x = y) ∨ (∃ h : i > j, s.increasing _ _ (WellOrdered.le_of_lt h) y = x) def Lim (s : Seq) := Quot (Lim.Eqv s) namespace Lim variable (s : Seq) theorem Eqv.intro i j (h : i ≤ j) x y (h' : s.increasing i j h x = y) : Eqv s ⟨i, x⟩ ⟨j, y⟩ := by cases h with | inl h => subst h; right; left exists @rfl _ i simp [cast] simp [Seq.increasing_refl, WellOrderHom.id] at h' assumption | inr h => left; exists h assumption theorem cast_cast {a b} (h : a = b) (h' : b = a) x : cast h (cast h' x) = x := by cases h; cases h'; refl theorem Eqv.symm x y : Eqv s x y → Eqv s y x := by intros h; cases h with | inl h => right; right; assumption | inr h => cases h with | inl h => right; left cases h with | intro h h' => exists h.symm rewrite [← h', cast_cast] refl | inr h => left; assumption section open Classical theorem Eqv.intro' i j Hi Hj x y (h' : s.increasing i (max i j) Hi x = s.increasing j (max i j) Hj y) : Eqv s ⟨i, x⟩ ⟨j, y⟩ := by cases WellOrdered.le_total i j with | inl h => have h₂ := WellOrdered.max_eq_of_le h revert Hi Hj h' rewrite [h₂]; intros Hi Hj rewrite [s.increasing_refl j]; intros h' apply Eqv.intro; assumption | inr h => have h₂ := WellOrdered.max_eq_of_ge h revert Hi Hj h' rewrite [h₂]; intros Hi Hj rewrite [s.increasing_refl i]; intros h' apply Lim.Eqv.symm apply Eqv.intro apply Eq.symm; assumption end theorem EqvGen_Eqv x y : EqvGen (Eqv s) x y ↔ Eqv s x y := by constructor <;> intros h focus induction h with | @rfl a => cases a right; left exists @rfl _ _; simp [cast] | @step x y z a _ b => cases x cases y cases z | symm_step a => skip end Lim namespace Lim variable (s : Seq) open Classical theorem mk_eq_mk_max_l i j x : Quot.mk (Lim.Eqv s) ⟨i, x⟩ = Quot.mk _ ⟨max i j, s.increasing i (max i j) WellOrdered.le_max_l x⟩ := by rw [Quot.eq] apply EqvGen.once; apply Eqv.intro { refl } theorem mk_eq_mk_max_r i j x : Quot.mk (Lim.Eqv s) ⟨i, x⟩ = Quot.mk _ ⟨max j i, s.increasing i (max j i) WellOrdered.le_max_r x⟩ := by rw [Quot.eq] apply EqvGen.once; apply Eqv.intro { refl } -- theorem mk_eq_mk_max_r i j x : -- Quot.mk (Lim.Eqv s) ⟨i, x⟩ = -- Quot.mk _ ⟨max j i, s.increasing i (max j i) protected inductive R : Lim s → Lim s → Prop := | intro i (x y : s.ords i) : x < y → Lim.R (Quot.mk _ ⟨i, x⟩) (Quot.mk _ ⟨i, y⟩) -- protected def SigmaT := PSigma (λ i => s.ords i) -- protected def toSigma : Lim s → Lim.SigmaT s -- | ⟨a,b,h⟩ => ⟨a,b⟩ -- protected def SigmaT.R : Lim.SigmaT s → Lim.SigmaT s → Prop := -- PSigma.Lex LT.lt (λ _ => LT.lt) -- protected theorem SigmaT.R_Subrelation : -- Subrelation (Lim.R s) (InvImage (SigmaT.R s) (Lim.toSigma s)) := by -- intros x y h -- cases h with -- | same i j k => -- simp [InvImage, Lim.toSigma] -- apply PSigma.Lex.right; assumption -- | lt x y => -- cases x; cases y -- constructor; assumption protected theorem R_wf : WellFounded (Lim.R s) := by -- Subrelation.wf _ (InvImage.wf _ _) constructor; intro a cases a using Quot.ind with | mk a => cases a with | mk a b => have Hacc := WellOrdered.wf.apply b -- let f b := Quot.mk (Eqv s) { fst := a, snd := b } -- have Hacc := InvImage.accessible f Hacc -- apply Acc induction Hacc with | intro b h ih => -- clear h constructor; intros y generalize Hx : (Quot.mk (Eqv s) { fst := a, snd := b }) = x intros Hr cases Hr with | intro i x => rw [Quot.eq] at Hx -- cases Hr -- apply ih skip -- let lex : WellFounded (Lim.SigmaT.R s) := -- (PSigma.lex WellOrdered.wf (λ i => WellOrdered.wf)) -- Subrelation.wf -- (SigmaT.R_Subrelation s) -- (InvImage.wf (Lim.toSigma s) lex) protected theorem R_total x y : Lim.R s x y ∨ x = y ∨ Lim.R s y x := match x, y with | ⟨x,x',hx⟩, ⟨y,y',hy⟩ => match x, y, WellOrdered.total x y with | _, _, Or.inl h => by left; constructor; assumption | _, _, Or.inr (Or.inr h) => by right; right; constructor; assumption | a, _, Or.inr (Or.inl rfl) => match WellOrdered.total x' y' with | Or.inl h => by left; constructor; assumption | Or.inr (Or.inl h) => by subst h; right; left; refl | Or.inr (Or.inr h) => by right; right; constructor; assumption instance : WellOrdered (Lim s) where R := Lim.R s wf := Lim.R_wf s total := Lim.R_total s theorem exists_in_inclusion (h : StrictInclusion a b) : ∃ x : b, True := by apply Classical.byContradiction; intro h₀ rewrite [Classical.not_exists] at h₀ apply h.strict let f (x : b) : a := False.elim (h₀ x trivial) refine' ⟨⟨f, _⟩,_⟩ focus intros x; cases h₀ x trivial focus constructor intros W g₁ g₂ _ apply WellOrderHom.ext; intro a cases h₀ (g₁ a) trivial section open Classical -- #print prefix theorem exists_in_inclusion' (h : StrictInclusion a b) : ∃ x : b, ∀ y, ¬ h.inclusion y = x := by byCases Ha : Nonempty a focus apply Classical.byContradiction; intro h₀ simp at h₀ apply h.strict -- revert Ha; intro Ha have : injective h.inclusion.hom := injective_of_monomorphism _ let f : b → a := inverse h.inclusion.hom have hf : ∀ i, f (h.inclusion i) = i := congrFun (left_inv_of_injective _ this) refine' ⟨⟨f, _⟩,_⟩ focus intros x y Hxy have Hx := h₀ x have Hy := h₀ y have : ∀ α [WellOrdered α] (a b : α), WellOrdered.R a b ↔ a < b := λ _ _ _ _ => Iff.rfl cases Hx with | intro x' Hx => cases Hy with | intro y' Hy => rewrite [← Hx, ← Hy, hf, hf] rewrite [this, WellOrdered.lt_iff_not_lt] at * rewrite [← Hx, ← Hy] at Hxy intros Hxy'; apply Hxy; clear Hxy x y Hx Hy this cases Hxy' with | inl h => subst h; left; refl | inr h => right; apply WellOrderHom.hom_preserve assumption focus constructor intros W g₁ g₂ Hg apply WellOrderHom.ext; intros x have Hg := WellOrderHom.ext_iff Hg x simp [WellOrderHom.hom, WellOrderHom.comp] at Hg have := right_inv_of_surjective (WellOrderHom.hom h.inclusion) h₀ have := congrFun this; simp at this have Hg := congrArg h.inclusion.hom Hg rewrite [this, this] at Hg; assumption focus have := exists_in_inclusion h cases this with | intro x => exists x; intros y _ apply Ha; clear Ha constructor; assumption end -- intros x; cases h₀ x trivial -- focus -- constructor -- intros W g₁ g₂ _ -- apply WellOrderHom.ext; intro a -- cases h₀ (g₁ a) trivial -- if h₀ : Nonempty a then by -- cases h₀ with | intro x => -- exists h.inclusion x -- -- exact intro -- trivial -- else by -- -- cases h with | ⟨h₀, h₁⟩ => -- apply Classical.byContradiction -- rewrite [not_exists]; intros h₁ -- apply h.strict -- constructor noncomputable def witness (x : StrictInclusion a b) : b := Classical.choose (exists_in_inclusion' x) protected noncomputable def default : Lim s where idx := s.next s.bottom val := witness (s.increasing _ _ (s.infinite _)) min_idx j x h := by let f := s.increasing _ _ (s.infinite s.bottom) cases s.consecutive _ _ h with | inl h => cases s.nothing_below_bottom _ h | inr h => subst j intros h₀ apply Classical.choose_spec (exists_in_inclusion' f) _ h₀ noncomputable instance : Inhabited (Lim s) where default := Lim.default s end Lim def lim (s : Seq) : Ordinal := Quot.mk _ { fst := Lim s, snd := inferInstance } theorem WO_is_equiv : EqvGen WOEqv x y → WOEqv x y := by intro h induction h with | rfl => exact ⟨WellOrderHom.id, inferInstance⟩ | step h₀ _ ih => cases h₀ with | intro f h₀ => cases ih with | intro g ih => exists g.comp f have h₀ := h₀; have ih := ih exact inferInstance | symm_step h₀ _ ih => cases h₀ with | intro f h₀ => cases ih with | intro g ih => have h₀ := h₀; have ih := ih exists g.comp (inv f) exact inferInstance theorem zero_ne_succ (x : Ordinal) : zero ≠ S x := by intros h cases x using Quot.ind with | mk x => cases x with | mk a b => simp [S] at h have h := WO_is_equiv $ Quot.eq.1 h simp [impl.S] at h cases h with | intro a b => have b := b have f := (inv a).hom none cases f theorem succ_ne_self (x : Ordinal) : x ≠ S x := by intros h cases x using Quot.ind with | mk x => cases x with | mk a Ha => revert Ha h; intros Ha h let Ha' : WellOrdered (Option a) := inferInstance let Ha'' : LT (Option a) := instLT simp [S] at h have h := WO_is_equiv $ Quot.eq.1 h cases h with | intro f hf => have hf := hf have f := inv f have hf := f.hom_preserve simp [WellOrdered.R] at hf suffices H : ∀ x : Option a, some (f x) < x → False by apply H none simp only [LT.lt] constructor intros x have Hacc : Acc LT.lt x := WellOrdered.wf.apply _ induction Hacc with | intro x _ ih => intros h' apply ih _ h' constructor apply f.hom_preserve (some (f x)) x h' open Classical theorem zero_ne_lim (s : Seq) : zero ≠ lim s := by intros h -- rewrite [Quot.eq] at h have h := WO_is_equiv $ Quot.eq.1 h cases h with | intro f hf => revert hf; intros hf have f := inv f have hf := f.hom_preserve cases f Inhabited.default -- TODO: -- succ ≠ lim -- 0 ≠ lim -- recursor -- Lemma no Ordinal between x and S x? -- #check Le -- set_option trace.simp_rewrite true -- #check getLocal -- #check Lean.Expr.fvar -- set_option trace.Ma -- set_option trace.Elab.definition true theorem S_consecutive y : y ≤ x ∧ y < S x ∨ x < y ∧ S x ≤ y := by match lt_total x y with | Or.inl Hlt => right refine' ⟨Hlt, _⟩ cases Hlt with | intro Hle Hnot_ge => cases x using Quot.ind with | mk x => cases y using Quot.ind with | mk y => simp [Le] at Hle Hnot_ge have : (¬ Nonempty (y → x)) ∨ (∃ f : y → x, ¬ Nonempty (y ⟶ x)) ∨ (∃ f : y ⟶ x, IsMono f → False) := by apply byContradiction; intros h₀ apply Hnot_ge; clear Hnot_ge simp at h₀ match h₀ with | ⟨⟨f⟩, h₁, h₂⟩ => cases h₁ f with | intro g => cases h₂ g with | intro z => -- weird pretty printing: not -- printing the type means that -- we're not giving the ∀ variable a -- name -- cases z -- clear h₁ constructor; assumption match this with | Or.inl h₀ => cases Hle with | intro f Hf => revert Hf; intros Hf have : StrictInclusion x y := ⟨f, Hnot_ge⟩ let w := Lim.witness this simp [LE.le, S, Le] have : x → False := by intros a let f (b : y) := a apply h₀; constructor; assumption let g (_ : impl.S x) := w -- have : IsMono g := by -- intros let g' : impl.S x ⟶ y := by refine' ⟨g, _⟩ intros a b Hab cases Hab with | top h => cases this h | lifted h => cases this h have hg : IsMono g' := by constructor; intros W g₁ g₂ Hg apply WellOrderHom.ext; intros x cases g₁ x with | some x => cases this x | none => cases g₂ x with | some x => cases this x | none => refl constructor; assumption | Or.inr (Or.inl ⟨f, h₀⟩) => clear this swapHyp h₀ as h₁ constructor exists f skip | Or.inr (Or.inr h₀) => skip | Or.inr (Or.inl Heq) => _ | Or.inr (Or.inr Hgt) => _ theorem lt_lim (s : Seq) x : lim s ≤ x ↔ ∀ i, Ordinal.mk (s.ords i) ≤ x := by constructor focus intros h i cases x using Quot.ind with | mk x => simp [lim, LE.le, Le] at h cases h with | intro a b => skip focus intros h admit theorem lim_not_consecutive (s : Seq) x : x < lim s → ∃ y, x < y ∧ y < lim s := by admit theorem S_ne_lim (s : Seq) : S x ≠ lim s := by admit
The state of Pennsylvania acquired Central State Normal School in 1915 and renamed it Lock Haven State Teachers College in 1927 . Between 1942 and 1970 , the student population grew from 146 to more than 2 @,@ 300 ; the number of teaching faculty rose from 25 to 170 , and the college carried out a large building program . The school 's name was changed to Lock Haven State College in 1960 , and its emphasis shifted to include the humanities , fine arts , mathematics , and social sciences , as well as teacher education . Becoming Lock Haven University of Pennsylvania in 1983 , it opened a branch campus in Clearfield , 48 miles ( 77 km ) west of Lock Haven , in 1989 .
#!/usr/bin/env python # coding: utf-8 import os import time import os.path as op import argparse import torch import numpy as np from torchvision import transforms as trans from tqdm import tqdm from Learner import face_learner from config import get_config from utils import hflip_batch from data.datasets_crop_and_save import CropAndSaveIJBAVeriImgsDataset os.environ['CUDA_VISIBLE_DEVICES'] = '0' def process_batch_original(batch, tta=False): if tta: fliped = hflip_batch(batch) feat_orig = learner.model.get_original_feature(batch.to(conf.device)) feat_flip = learner.model.get_original_feature(fliped.to(conf.device)) feat = (feat_orig + feat_flip) / 2 else: feat = learner.model.get_original_feature(batch.to(conf.device)) return feat def process_batch_xcos(batch, tta=False): if tta: fliped = hflip_batch(batch) flattened_feature1, feat_map1 = learner.model(batch.to(conf.device)) flattened_feature2, feat_map2 = learner.model(fliped.to(conf.device)) feat_map = (feat_map1 + feat_map2) / 2 flattened_feature = (flattened_feature1 + flattened_feature2) / 2 else: flattened_feature, feat_map = learner.model(batch.to(conf.device)) return flattened_feature, feat_map # ## Init Learner and conf # In[4]: conf = get_config(training=False) conf.batch_size=20 # Why bs_size can only be the number that divide 6000 well? learner = face_learner(conf, inference=True) # # IJB-A # Extract features for IJB-A dataset def run_ours_IJBA(loader, img_output_root, split_name, only_first_image=True): # if not only_first_image: # assert loader.batch_size == 1 # dst_dir = op.join(img_output_root, # f'IJB-A_full_template/{split_name}/{model_name}/') # os.makedirs(dst_dir, exist_ok=True) with torch.no_grad(): for i, batch in tqdm(enumerate(loader), total=len(loader)): x = 1 # Do nothing! # if i % 50 == 0: # print(f"Elapsed {time.time() - begin_time:.1f} seconds.") # t1_tensors = batch['t1_tensors'] # t2_tensors = batch['t2_tensors'] # if not only_first_image: # t1_tensors, t2_tensors = t1_tensors.squeeze(0), t2_tensors.squeeze(0) # comparison_idx = batch['comparison_idx'] # is_same = batch['is_same'] # if xCos_or_original == 'xCos': # _, feat1 = process_batch_xcos(t1_tensors, tta=True) # _, feat2 = process_batch_xcos(t2_tensors, tta=True) # elif xCos_or_original == 'original': # feat1 = process_batch_original(t1_tensors, tta=True) # feat2 = process_batch_original(t2_tensors, tta=True) # else: # raise NotImplementedError # if not only_first_image: # feat1, feat2 = feat1.unsqueeze(0), feat2.unsqueeze(0) # # print(feat1.shape, t1_tensors.shape) # for idx, f1, f2, same in zip(comparison_idx, feat1, feat2, is_same): # target_path = op.join(dst_dir, str(int(idx.cpu().numpy()))) + '.npz' # if op.exists(target_path): # if i % 50 == 0: # print(f"Skipping {target_path} because it exists.") # continue # # if i % 50 == 0: # # print(f'Saving to {target_path}') # np.savez(target_path, idx=idx.cpu().numpy(), # same=same.cpu().numpy(), # f1=f1.cpu().numpy(), f2=f2.cpu().numpy(), ) if __name__ == '__main__': parser = argparse.ArgumentParser(description='feature extraction') # general parser.add_argument('--split', default='1', help='split to test') parser.add_argument('--cropped_img_dir', default='data/IJB_A_cropped_imgs', help='output dir') args = parser.parse_args() n_splits = int(args.split) for i in range(n_splits): # Skip split1 because it is done. # if i == 0: # continue split_num = i + 1 print(f'Extracting split{split_num}...') split_name = f'split{split_num}' loader_IJBA = torch.utils.data.DataLoader( CropAndSaveIJBAVeriImgsDataset(only_first_image=False, ijba_data_root='data/IJB-A', output_dir=args.cropped_img_dir, split_name=split_name), batch_size=1, num_workers=1 ) run_ours_IJBA(loader_IJBA, args.cropped_img_dir, split_name, only_first_image=False)
[GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ ⊢ dualMap id = id [PROOFSTEP] ext [GOAL] case h.h R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ x✝¹ : Dual R M₁ x✝ : M₁ ⊢ ↑(↑(dualMap id) x✝¹) x✝ = ↑(↑id x✝¹) x✝ [PROOFSTEP] rfl [GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ hf : Function.Surjective ↑f ⊢ Function.Injective ↑(dualMap f) [PROOFSTEP] intro φ ψ h [GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ hf : Function.Surjective ↑f φ ψ : Dual R M₂ h : ↑(dualMap f) φ = ↑(dualMap f) ψ ⊢ φ = ψ [PROOFSTEP] ext x [GOAL] case h R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ hf : Function.Surjective ↑f φ ψ : Dual R M₂ h : ↑(dualMap f) φ = ↑(dualMap f) ψ x : M₂ ⊢ ↑φ x = ↑ψ x [PROOFSTEP] obtain ⟨y, rfl⟩ := hf x [GOAL] case h.intro R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ hf : Function.Surjective ↑f φ ψ : Dual R M₂ h : ↑(dualMap f) φ = ↑(dualMap f) ψ y : M₁ ⊢ ↑φ (↑f y) = ↑ψ (↑f y) [PROOFSTEP] exact congr_arg (fun g : Module.Dual R M₁ => g y) h [GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ ≃ₗ[R] M₂ src✝ : Dual R M₂ →ₗ[R] Dual R M₁ := LinearMap.dualMap ↑f ⊢ Function.LeftInverse ↑(LinearMap.dualMap ↑(symm f)) { toAddHom := src✝.toAddHom, map_smul' := (_ : ∀ (r : R) (x : Dual R M₂), AddHom.toFun src✝.toAddHom (r • x) = ↑(RingHom.id R) r • AddHom.toFun src✝.toAddHom x) }.toAddHom.toFun [PROOFSTEP] intro φ [GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ ≃ₗ[R] M₂ src✝ : Dual R M₂ →ₗ[R] Dual R M₁ := LinearMap.dualMap ↑f φ : Dual R M₂ ⊢ ↑(LinearMap.dualMap ↑(symm f)) (AddHom.toFun { toAddHom := src✝.toAddHom, map_smul' := (_ : ∀ (r : R) (x : Dual R M₂), AddHom.toFun src✝.toAddHom (r • x) = ↑(RingHom.id R) r • AddHom.toFun src✝.toAddHom x) }.toAddHom φ) = φ [PROOFSTEP] ext x [GOAL] case h R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ ≃ₗ[R] M₂ src✝ : Dual R M₂ →ₗ[R] Dual R M₁ := LinearMap.dualMap ↑f φ : Dual R M₂ x : M₂ ⊢ ↑(↑(LinearMap.dualMap ↑(symm f)) (AddHom.toFun { toAddHom := src✝.toAddHom, map_smul' := (_ : ∀ (r : R) (x : Dual R M₂), AddHom.toFun src✝.toAddHom (r • x) = ↑(RingHom.id R) r • AddHom.toFun src✝.toAddHom x) }.toAddHom φ)) x = ↑φ x [PROOFSTEP] simp only [LinearMap.dualMap_apply, LinearEquiv.coe_toLinearMap, LinearMap.toFun_eq_coe, LinearEquiv.apply_symm_apply] [GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ ≃ₗ[R] M₂ src✝ : Dual R M₂ →ₗ[R] Dual R M₁ := LinearMap.dualMap ↑f ⊢ Function.RightInverse ↑(LinearMap.dualMap ↑(symm f)) { toAddHom := src✝.toAddHom, map_smul' := (_ : ∀ (r : R) (x : Dual R M₂), AddHom.toFun src✝.toAddHom (r • x) = ↑(RingHom.id R) r • AddHom.toFun src✝.toAddHom x) }.toAddHom.toFun [PROOFSTEP] intro φ [GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ ≃ₗ[R] M₂ src✝ : Dual R M₂ →ₗ[R] Dual R M₁ := LinearMap.dualMap ↑f φ : Dual R M₁ ⊢ AddHom.toFun { toAddHom := src✝.toAddHom, map_smul' := (_ : ∀ (r : R) (x : Dual R M₂), AddHom.toFun src✝.toAddHom (r • x) = ↑(RingHom.id R) r • AddHom.toFun src✝.toAddHom x) }.toAddHom (↑(LinearMap.dualMap ↑(symm f)) φ) = φ [PROOFSTEP] ext x [GOAL] case h R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ ≃ₗ[R] M₂ src✝ : Dual R M₂ →ₗ[R] Dual R M₁ := LinearMap.dualMap ↑f φ : Dual R M₁ x : M₁ ⊢ ↑(AddHom.toFun { toAddHom := src✝.toAddHom, map_smul' := (_ : ∀ (r : R) (x : Dual R M₂), AddHom.toFun src✝.toAddHom (r • x) = ↑(RingHom.id R) r • AddHom.toFun src✝.toAddHom x) }.toAddHom (↑(LinearMap.dualMap ↑(symm f)) φ)) x = ↑φ x [PROOFSTEP] simp only [LinearMap.dualMap_apply, LinearEquiv.coe_toLinearMap, LinearMap.toFun_eq_coe, LinearEquiv.symm_apply_apply] [GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ ⊢ dualMap (refl R M₁) = refl R (Dual R M₁) [PROOFSTEP] ext [GOAL] case h.h R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ x✝¹ : Dual R M₁ x✝ : M₁ ⊢ ↑(↑(dualMap (refl R M₁)) x✝¹) x✝ = ↑(↑(refl R (Dual R M₁)) x✝¹) x✝ [PROOFSTEP] rfl [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M i j : ι ⊢ ↑(↑(toDual b) (↑b i)) (↑b j) = if i = j then 1 else 0 [PROOFSTEP] erw [constr_basis b, constr_basis b] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M i j : ι ⊢ (if j = i then 1 else 0) = if i = j then 1 else 0 [PROOFSTEP] simp only [eq_comm] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι ⊢ ↑(↑(toDual b) (↑(Finsupp.total ι M R ↑b) f)) (↑b i) = ↑f i [PROOFSTEP] rw [Finsupp.total_apply, Finsupp.sum, LinearMap.map_sum, LinearMap.sum_apply] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι ⊢ ∑ d in f.support, ↑(↑(toDual b) (↑f d • ↑b d)) (↑b i) = ↑f i [PROOFSTEP] simp_rw [LinearMap.map_smul, LinearMap.smul_apply, toDual_apply, smul_eq_mul, mul_boole, Finset.sum_ite_eq'] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι ⊢ (if i ∈ f.support then ↑f i else 0) = ↑f i [PROOFSTEP] split_ifs with h [GOAL] case pos R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι h : i ∈ f.support ⊢ ↑f i = ↑f i [PROOFSTEP] rfl [GOAL] case neg R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι h : ¬i ∈ f.support ⊢ 0 = ↑f i [PROOFSTEP] rw [Finsupp.not_mem_support_iff.mp h] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι ⊢ ↑(↑(toDual b) (↑b i)) (↑(Finsupp.total ι M R ↑b) f) = ↑f i [PROOFSTEP] rw [Finsupp.total_apply, Finsupp.sum, LinearMap.map_sum] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι ⊢ ∑ i_1 in f.support, ↑(↑(toDual b) (↑b i)) (↑f i_1 • ↑b i_1) = ↑f i [PROOFSTEP] simp_rw [LinearMap.map_smul, toDual_apply, smul_eq_mul, mul_boole, Finset.sum_ite_eq] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι ⊢ (if i ∈ f.support then ↑f i else 0) = ↑f i [PROOFSTEP] split_ifs with h [GOAL] case pos R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι h : i ∈ f.support ⊢ ↑f i = ↑f i [PROOFSTEP] rfl [GOAL] case neg R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M f : ι →₀ R i : ι h : ¬i ∈ f.support ⊢ 0 = ↑f i [PROOFSTEP] rw [Finsupp.not_mem_support_iff.mp h] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M m : M i : ι ⊢ ↑(↑(toDual b) m) (↑b i) = ↑(↑b.repr m) i [PROOFSTEP] rw [← b.toDual_total_left, b.total_repr] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M i : ι m : M ⊢ ↑(↑(toDual b) (↑b i)) m = ↑(↑b.repr m) i [PROOFSTEP] rw [← b.toDual_total_right, b.total_repr] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M i : ι ⊢ ↑(toDual b) (↑b i) = coord b i [PROOFSTEP] ext [GOAL] case h R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M i : ι x✝ : M ⊢ ↑(↑(toDual b) (↑b i)) x✝ = ↑(coord b i) x✝ [PROOFSTEP] apply toDual_apply_right [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommSemiring R inst✝³ : AddCommMonoid M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : Fintype ι m : M i : ι ⊢ ↑(↑(toDual b) m) (↑b i) = ↑(equivFun b) m i [PROOFSTEP] rw [b.equivFun_apply, toDual_eq_repr] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M m : M a : ↑(toDual b) m = 0 ⊢ m = 0 [PROOFSTEP] rw [← mem_bot R, ← b.repr.ker, mem_ker, LinearEquiv.coe_coe] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M m : M a : ↑(toDual b) m = 0 ⊢ ↑b.repr m = 0 [PROOFSTEP] apply Finsupp.ext [GOAL] case h R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b : Basis ι R M m : M a : ↑(toDual b) m = 0 ⊢ ∀ (a : ι), ↑(↑b.repr m) a = ↑0 a [PROOFSTEP] intro b [GOAL] case h R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b✝ : Basis ι R M m : M a : ↑(toDual b✝) m = 0 b : ι ⊢ ↑(↑b✝.repr m) b = ↑0 b [PROOFSTEP] rw [← toDual_eq_repr, a] [GOAL] case h R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : DecidableEq ι b✝ : Basis ι R M m : M a : ↑(toDual b✝) m = 0 b : ι ⊢ ↑0 (↑b✝ b) = ↑0 b [PROOFSTEP] rfl [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommSemiring R inst✝³ : AddCommMonoid M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι ⊢ range (toDual b) = ⊤ [PROOFSTEP] cases nonempty_fintype ι [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommSemiring R inst✝³ : AddCommMonoid M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι val✝ : Fintype ι ⊢ range (toDual b) = ⊤ [PROOFSTEP] refine' eq_top_iff'.2 fun f => _ [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommSemiring R inst✝³ : AddCommMonoid M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι val✝ : Fintype ι f : Dual R M ⊢ f ∈ range (toDual b) [PROOFSTEP] rw [LinearMap.mem_range] [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommSemiring R inst✝³ : AddCommMonoid M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι val✝ : Fintype ι f : Dual R M ⊢ ∃ y, ↑(toDual b) y = f [PROOFSTEP] let lin_comb : ι →₀ R := Finsupp.equivFunOnFinite.symm fun i => f.toFun (b i) [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommSemiring R inst✝³ : AddCommMonoid M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι val✝ : Fintype ι f : Dual R M lin_comb : ι →₀ R := ↑Finsupp.equivFunOnFinite.symm fun i => AddHom.toFun f.toAddHom (↑b i) ⊢ ∃ y, ↑(toDual b) y = f [PROOFSTEP] refine' ⟨Finsupp.total ι M R b lin_comb, b.ext fun i => _⟩ [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommSemiring R inst✝³ : AddCommMonoid M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι val✝ : Fintype ι f : Dual R M lin_comb : ι →₀ R := ↑Finsupp.equivFunOnFinite.symm fun i => AddHom.toFun f.toAddHom (↑b i) i : ι ⊢ ↑(↑(toDual b) (↑(Finsupp.total ι M R ↑b) lin_comb)) (↑b i) = ↑f (↑b i) [PROOFSTEP] rw [b.toDual_eq_repr _ i, repr_total b] [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommSemiring R inst✝³ : AddCommMonoid M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι val✝ : Fintype ι f : Dual R M lin_comb : ι →₀ R := ↑Finsupp.equivFunOnFinite.symm fun i => AddHom.toFun f.toAddHom (↑b i) i : ι ⊢ ↑lin_comb i = ↑f (↑b i) [PROOFSTEP] rfl [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : Fintype ι b : Basis ι R M f : Dual R M ⊢ ∑ x : ι, ↑f (↑b x) • coord b x = f [PROOFSTEP] ext m [GOAL] case h R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommSemiring R inst✝² : AddCommMonoid M inst✝¹ : Module R M inst✝ : Fintype ι b : Basis ι R M f : Dual R M m : M ⊢ ↑(∑ x : ι, ↑f (↑b x) • coord b x) m = ↑f m [PROOFSTEP] simp_rw [LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul, mul_comm (f _), ← smul_eq_mul, ← f.map_smul, ← f.map_sum, Basis.coord_apply, Basis.sum_repr] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι i j : ι ⊢ ↑(↑(dualBasis b) i) (↑b j) = if j = i then 1 else 0 [PROOFSTEP] convert b.toDual_apply i j using 2 [GOAL] case h.e'_3.h₁.a R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι i j : ι ⊢ j = i ↔ i = j [PROOFSTEP] rw [@eq_comm _ j i] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι f : ι →₀ R i : ι ⊢ ↑(↑(Finsupp.total ι (Dual R M) R ↑(dualBasis b)) f) (↑b i) = ↑f i [PROOFSTEP] cases nonempty_fintype ι [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι f : ι →₀ R i : ι val✝ : Fintype ι ⊢ ↑(↑(Finsupp.total ι (Dual R M) R ↑(dualBasis b)) f) (↑b i) = ↑f i [PROOFSTEP] rw [Finsupp.total_apply, Finsupp.sum_fintype, LinearMap.sum_apply] [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι f : ι →₀ R i : ι val✝ : Fintype ι ⊢ ∑ d : ι, ↑(↑f d • ↑(dualBasis b) d) (↑b i) = ↑f i [PROOFSTEP] simp_rw [LinearMap.smul_apply, smul_eq_mul, dualBasis_apply_self, mul_boole, Finset.sum_ite_eq, if_pos (Finset.mem_univ i)] [GOAL] case intro.h R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι f : ι →₀ R i : ι val✝ : Fintype ι ⊢ ∀ (i : ι), 0 • ↑(dualBasis b) i = 0 [PROOFSTEP] intro [GOAL] case intro.h R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι f : ι →₀ R i : ι val✝ : Fintype ι i✝ : ι ⊢ 0 • ↑(dualBasis b) i✝ = 0 [PROOFSTEP] rw [zero_smul] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι l : Dual R M i : ι ⊢ ↑(↑(dualBasis b).repr l) i = ↑l (↑b i) [PROOFSTEP] rw [← total_dualBasis b, Basis.total_repr b.dualBasis l] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι ⊢ ↑(dualBasis b) = coord b [PROOFSTEP] ext i x [GOAL] case h.h R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι i : ι x : M ⊢ ↑(↑(dualBasis b) i) x = ↑(coord b i) x [PROOFSTEP] apply dualBasis_apply [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι ⊢ LinearMap.comp (toDual (dualBasis b)) (toDual b) = Dual.eval R M [PROOFSTEP] refine' b.ext fun i => b.dualBasis.ext fun j => _ [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : _root_.Finite ι i j : ι ⊢ ↑(↑(LinearMap.comp (toDual (dualBasis b)) (toDual b)) (↑b i)) (↑(dualBasis b) j) = ↑(↑(Dual.eval R M) (↑b i)) (↑(dualBasis b) j) [PROOFSTEP] rw [LinearMap.comp_apply, toDual_apply_left, coe_toDual_self, ← coe_dualBasis, Dual.eval_apply, Basis.repr_self, Finsupp.single_apply, dualBasis_apply_self] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι b : Basis ι R M inst✝ : Fintype ι l : Dual R M i : ι ⊢ ↑(equivFun (dualBasis b)) l i = ↑l (↑b i) [PROOFSTEP] rw [Basis.equivFun_apply, dualBasis_repr] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι✝ : Type w inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : DecidableEq ι✝ b✝ : Basis ι✝ R M ι : Type u_1 b : Basis ι R M ⊢ ker (Dual.eval R M) = ⊥ [PROOFSTEP] rw [ker_eq_bot'] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι✝ : Type w inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : DecidableEq ι✝ b✝ : Basis ι✝ R M ι : Type u_1 b : Basis ι R M ⊢ ∀ (m : M), ↑(Dual.eval R M) m = 0 → m = 0 [PROOFSTEP] intro m hm [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι✝ : Type w inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : DecidableEq ι✝ b✝ : Basis ι✝ R M ι : Type u_1 b : Basis ι R M m : M hm : ↑(Dual.eval R M) m = 0 ⊢ m = 0 [PROOFSTEP] simp_rw [LinearMap.ext_iff, Dual.eval_apply, zero_apply] at hm [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι✝ : Type w inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : DecidableEq ι✝ b✝ : Basis ι✝ R M ι : Type u_1 b : Basis ι R M m : M hm : ∀ (x : Dual R M), ↑x m = 0 ⊢ m = 0 [PROOFSTEP] exact (Basis.forall_coord_eq_zero_iff _).mp fun i => hm (b.coord i) [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι✝ : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι✝ b✝ : Basis ι✝ R M ι : Type u_1 inst✝ : _root_.Finite ι b : Basis ι R M ⊢ range (Dual.eval R M) = ⊤ [PROOFSTEP] classical cases nonempty_fintype ι rw [← b.toDual_toDual, range_comp, b.toDual_range, Submodule.map_top, toDual_range _] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι✝ : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι✝ b✝ : Basis ι✝ R M ι : Type u_1 inst✝ : _root_.Finite ι b : Basis ι R M ⊢ range (Dual.eval R M) = ⊤ [PROOFSTEP] cases nonempty_fintype ι [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι✝ : Type w inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : DecidableEq ι✝ b✝ : Basis ι✝ R M ι : Type u_1 inst✝ : _root_.Finite ι b : Basis ι R M val✝ : Fintype ι ⊢ range (Dual.eval R M) = ⊤ [PROOFSTEP] rw [← b.toDual_toDual, range_comp, b.toDual_range, Submodule.map_top, toDual_range _] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : _root_.Finite ι b : Basis ι R M f : ι →₀ R i : ι ⊢ ↑(↑(Finsupp.total ι (Dual R M) R (coord b)) f) (↑b i) = ↑f i [PROOFSTEP] haveI := Classical.decEq ι [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M inst✝ : _root_.Finite ι b : Basis ι R M f : ι →₀ R i : ι this : DecidableEq ι ⊢ ↑(↑(Finsupp.total ι (Dual R M) R (coord b)) f) (↑b i) = ↑f i [PROOFSTEP] rw [← coe_dualBasis, total_dualBasis] [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : _root_.Finite ι b : Basis ι K V ⊢ lift (Module.rank K V) = Module.rank K (Dual K V) [PROOFSTEP] classical cases nonempty_fintype ι have := LinearEquiv.lift_rank_eq b.toDualEquiv rw [Cardinal.lift_umax.{u₂, u₁}] at this rw [this, ← Cardinal.lift_umax] apply Cardinal.lift_id [GOAL] R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : _root_.Finite ι b : Basis ι K V ⊢ lift (Module.rank K V) = Module.rank K (Dual K V) [PROOFSTEP] cases nonempty_fintype ι [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : _root_.Finite ι b : Basis ι K V val✝ : Fintype ι ⊢ lift (Module.rank K V) = Module.rank K (Dual K V) [PROOFSTEP] have := LinearEquiv.lift_rank_eq b.toDualEquiv [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : _root_.Finite ι b : Basis ι K V val✝ : Fintype ι this : lift (Module.rank K V) = lift (Module.rank K (Dual K V)) ⊢ lift (Module.rank K V) = Module.rank K (Dual K V) [PROOFSTEP] rw [Cardinal.lift_umax.{u₂, u₁}] at this [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : _root_.Finite ι b : Basis ι K V val✝ : Fintype ι this : lift (Module.rank K V) = lift (Module.rank K (Dual K V)) ⊢ lift (Module.rank K V) = Module.rank K (Dual K V) [PROOFSTEP] rw [this, ← Cardinal.lift_umax] [GOAL] case intro R : Type u M : Type v K : Type u₁ V : Type u₂ ι : Type w inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : _root_.Finite ι b : Basis ι K V val✝ : Fintype ι this : lift (Module.rank K V) = lift (Module.rank K (Dual K V)) ⊢ lift (Module.rank K (Dual K V)) = Module.rank K (Dual K V) [PROOFSTEP] apply Cardinal.lift_id [GOAL] K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V ⊢ ker (eval K V) = ⊥ [PROOFSTEP] classical exact (Module.Free.chooseBasis K V).eval_ker [GOAL] K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V ⊢ ker (eval K V) = ⊥ [PROOFSTEP] exact (Module.Free.chooseBasis K V).eval_ker [GOAL] K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V ⊢ Function.Injective (Submodule.map (eval K V)) [PROOFSTEP] apply Submodule.map_injective_of_injective [GOAL] case hf K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V ⊢ Function.Injective ↑(eval K V) [PROOFSTEP] rw [← LinearMap.ker_eq_bot] [GOAL] case hf K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V ⊢ ker (eval K V) = ⊥ [PROOFSTEP] apply eval_ker K V [GOAL] K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V ⊢ Function.Surjective (Submodule.comap (eval K V)) [PROOFSTEP] apply Submodule.comap_surjective_of_injective [GOAL] case hf K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V ⊢ Function.Injective ↑(eval K V) [PROOFSTEP] rw [← LinearMap.ker_eq_bot] [GOAL] case hf K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V ⊢ ker (eval K V) = ⊥ [PROOFSTEP] apply eval_ker K V [GOAL] K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V v : V ⊢ ↑(eval K V) v = 0 ↔ v = 0 [PROOFSTEP] simpa only using SetLike.ext_iff.mp (eval_ker K V) v [GOAL] K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V v : V ⊢ (∀ (φ : Dual K V), ↑φ v = 0) ↔ v = 0 [PROOFSTEP] rw [← eval_apply_eq_zero_iff K v, LinearMap.ext_iff] [GOAL] K : Type u₁ V : Type u₂ inst✝³ : CommRing K inst✝² : AddCommGroup V inst✝¹ : Module K V inst✝ : Free K V v : V ⊢ (∀ (φ : Dual K V), ↑φ v = 0) ↔ ∀ (x : Dual K V), ↑(↑(eval K V) v) x = ↑0 x [PROOFSTEP] rfl [GOAL] K : Type u₁ V : Type u₂ inst✝⁹ : CommRing K inst✝⁸ : AddCommGroup V inst✝⁷ : Module K V inst✝⁶ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁵ : CommRing R inst✝⁴ : AddCommGroup M inst✝³ : AddCommGroup N inst✝² : Module R M inst✝¹ : Module R N inst✝ : IsReflexive R M f : Dual R M g : Dual R (Dual R M) ⊢ ↑f (↑(LinearEquiv.symm (evalEquiv R M)) g) = ↑g f [PROOFSTEP] set m := (evalEquiv R M).symm g [GOAL] K : Type u₁ V : Type u₂ inst✝⁹ : CommRing K inst✝⁸ : AddCommGroup V inst✝⁷ : Module K V inst✝⁶ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁵ : CommRing R inst✝⁴ : AddCommGroup M inst✝³ : AddCommGroup N inst✝² : Module R M inst✝¹ : Module R N inst✝ : IsReflexive R M f : Dual R M g : Dual R (Dual R M) m : M := ↑(LinearEquiv.symm (evalEquiv R M)) g ⊢ ↑f m = ↑g f [PROOFSTEP] rw [← (evalEquiv R M).apply_symm_apply g, evalEquiv_apply, Dual.eval_apply] [GOAL] K : Type u₁ V : Type u₂ inst✝⁹ : CommRing K inst✝⁸ : AddCommGroup V inst✝⁷ : Module K V inst✝⁶ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁵ : CommRing R inst✝⁴ : AddCommGroup M inst✝³ : AddCommGroup N inst✝² : Module R M inst✝¹ : Module R N inst✝ : IsReflexive R M ⊢ ↑(LinearEquiv.dualMap (LinearEquiv.symm (evalEquiv R M))) = Dual.eval R (Dual R M) [PROOFSTEP] ext [GOAL] case h.h K : Type u₁ V : Type u₂ inst✝⁹ : CommRing K inst✝⁸ : AddCommGroup V inst✝⁷ : Module K V inst✝⁶ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁵ : CommRing R inst✝⁴ : AddCommGroup M inst✝³ : AddCommGroup N inst✝² : Module R M inst✝¹ : Module R N inst✝ : IsReflexive R M x✝¹ : Dual R M x✝ : Dual R (Dual R M) ⊢ ↑(↑↑(LinearEquiv.dualMap (LinearEquiv.symm (evalEquiv R M))) x✝¹) x✝ = ↑(↑(Dual.eval R (Dual R M)) x✝¹) x✝ [PROOFSTEP] simp [GOAL] K : Type u₁ V : Type u₂ inst✝⁹ : CommRing K inst✝⁸ : AddCommGroup V inst✝⁷ : Module K V inst✝⁶ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁵ : CommRing R inst✝⁴ : AddCommGroup M inst✝³ : AddCommGroup N inst✝² : Module R M inst✝¹ : Module R N inst✝ : IsReflexive R M ⊢ Bijective ↑(eval R (Dual R M)) [PROOFSTEP] simpa only [← symm_dualMap_evalEquiv] using (evalEquiv R M).dualMap.symm.bijective [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ : IsReflexive R M inst✝ : IsReflexive R N ⊢ Bijective ↑(Dual.eval R (M × N)) [PROOFSTEP] let e : Dual R (Dual R (M × N)) ≃ₗ[R] Dual R (Dual R M) × Dual R (Dual R N) := (dualProdDualEquivDual R M N).dualMap.trans (dualProdDualEquivDual R (Dual R M) (Dual R N)).symm [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ : IsReflexive R M inst✝ : IsReflexive R N e : Dual R (Dual R (M × N)) ≃ₗ[R] Dual R (Dual R M) × Dual R (Dual R N) := LinearEquiv.trans (LinearEquiv.dualMap (dualProdDualEquivDual R M N)) (LinearEquiv.symm (dualProdDualEquivDual R (Dual R M) (Dual R N))) ⊢ Bijective ↑(Dual.eval R (M × N)) [PROOFSTEP] have : Dual.eval R (M × N) = e.symm.comp ((Dual.eval R M).prodMap (Dual.eval R N)) := by ext m f <;> simp [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ : IsReflexive R M inst✝ : IsReflexive R N e : Dual R (Dual R (M × N)) ≃ₗ[R] Dual R (Dual R M) × Dual R (Dual R N) := LinearEquiv.trans (LinearEquiv.dualMap (dualProdDualEquivDual R M N)) (LinearEquiv.symm (dualProdDualEquivDual R (Dual R M) (Dual R N))) ⊢ Dual.eval R (M × N) = LinearMap.comp (↑(LinearEquiv.symm e)) (prodMap (Dual.eval R M) (Dual.eval R N)) [PROOFSTEP] ext m f [GOAL] case hl.h.h K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ : IsReflexive R M inst✝ : IsReflexive R N e : Dual R (Dual R (M × N)) ≃ₗ[R] Dual R (Dual R M) × Dual R (Dual R N) := LinearEquiv.trans (LinearEquiv.dualMap (dualProdDualEquivDual R M N)) (LinearEquiv.symm (dualProdDualEquivDual R (Dual R M) (Dual R N))) m : M f : Dual R (M × N) ⊢ ↑(↑(LinearMap.comp (Dual.eval R (M × N)) (inl R M N)) m) f = ↑(↑(LinearMap.comp (LinearMap.comp (↑(LinearEquiv.symm e)) (prodMap (Dual.eval R M) (Dual.eval R N))) (inl R M N)) m) f [PROOFSTEP] simp [GOAL] case hr.h.h K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ : IsReflexive R M inst✝ : IsReflexive R N e : Dual R (Dual R (M × N)) ≃ₗ[R] Dual R (Dual R M) × Dual R (Dual R N) := LinearEquiv.trans (LinearEquiv.dualMap (dualProdDualEquivDual R M N)) (LinearEquiv.symm (dualProdDualEquivDual R (Dual R M) (Dual R N))) m : N f : Dual R (M × N) ⊢ ↑(↑(LinearMap.comp (Dual.eval R (M × N)) (inr R M N)) m) f = ↑(↑(LinearMap.comp (LinearMap.comp (↑(LinearEquiv.symm e)) (prodMap (Dual.eval R M) (Dual.eval R N))) (inr R M N)) m) f [PROOFSTEP] simp [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ : IsReflexive R M inst✝ : IsReflexive R N e : Dual R (Dual R (M × N)) ≃ₗ[R] Dual R (Dual R M) × Dual R (Dual R N) := LinearEquiv.trans (LinearEquiv.dualMap (dualProdDualEquivDual R M N)) (LinearEquiv.symm (dualProdDualEquivDual R (Dual R M) (Dual R N))) this : Dual.eval R (M × N) = LinearMap.comp (↑(LinearEquiv.symm e)) (prodMap (Dual.eval R M) (Dual.eval R N)) ⊢ Bijective ↑(Dual.eval R (M × N)) [PROOFSTEP] simp only [this, LinearEquiv.trans_symm, LinearEquiv.symm_symm, LinearEquiv.dualMap_symm, coe_comp, LinearEquiv.coe_coe, EquivLike.comp_bijective] [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ : IsReflexive R M inst✝ : IsReflexive R N e : Dual R (Dual R (M × N)) ≃ₗ[R] Dual R (Dual R M) × Dual R (Dual R N) := LinearEquiv.trans (LinearEquiv.dualMap (dualProdDualEquivDual R M N)) (LinearEquiv.symm (dualProdDualEquivDual R (Dual R M) (Dual R N))) this : Dual.eval R (M × N) = LinearMap.comp (↑(LinearEquiv.symm e)) (prodMap (Dual.eval R M) (Dual.eval R N)) ⊢ Bijective ↑(prodMap (Dual.eval R M) (Dual.eval R N)) [PROOFSTEP] exact Bijective.Prod_map (bijective_dual_eval R M) (bijective_dual_eval R N) [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ inst✝ : IsReflexive R M e : M ≃ₗ[R] N ⊢ Bijective ↑(Dual.eval R N) [PROOFSTEP] let ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := e.symm.dualMap.dualMap [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ inst✝ : IsReflexive R M e : M ≃ₗ[R] N ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := LinearEquiv.dualMap (LinearEquiv.dualMap (LinearEquiv.symm e)) ⊢ Bijective ↑(Dual.eval R N) [PROOFSTEP] have : Dual.eval R N = ed.symm.comp ((Dual.eval R M).comp e.symm.toLinearMap) := by ext m f exact FunLike.congr_arg f (e.apply_symm_apply m).symm [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ inst✝ : IsReflexive R M e : M ≃ₗ[R] N ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := LinearEquiv.dualMap (LinearEquiv.dualMap (LinearEquiv.symm e)) ⊢ Dual.eval R N = LinearMap.comp (↑(LinearEquiv.symm ed)) (LinearMap.comp (Dual.eval R M) ↑(LinearEquiv.symm e)) [PROOFSTEP] ext m f [GOAL] case h.h K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ inst✝ : IsReflexive R M e : M ≃ₗ[R] N ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := LinearEquiv.dualMap (LinearEquiv.dualMap (LinearEquiv.symm e)) m : N f : Dual R N ⊢ ↑(↑(Dual.eval R N) m) f = ↑(↑(LinearMap.comp (↑(LinearEquiv.symm ed)) (LinearMap.comp (Dual.eval R M) ↑(LinearEquiv.symm e))) m) f [PROOFSTEP] exact FunLike.congr_arg f (e.apply_symm_apply m).symm [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ inst✝ : IsReflexive R M e : M ≃ₗ[R] N ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := LinearEquiv.dualMap (LinearEquiv.dualMap (LinearEquiv.symm e)) this : Dual.eval R N = LinearMap.comp (↑(LinearEquiv.symm ed)) (LinearMap.comp (Dual.eval R M) ↑(LinearEquiv.symm e)) ⊢ Bijective ↑(Dual.eval R N) [PROOFSTEP] simp only [this, LinearEquiv.trans_symm, LinearEquiv.symm_symm, LinearEquiv.dualMap_symm, coe_comp, LinearEquiv.coe_coe, EquivLike.comp_bijective] [GOAL] K : Type u₁ V : Type u₂ inst✝¹⁰ : CommRing K inst✝⁹ : AddCommGroup V inst✝⁸ : Module K V inst✝⁷ : Free K V R : Type u_1 M : Type u_2 N : Type u_3 inst✝⁶ : CommRing R inst✝⁵ : AddCommGroup M inst✝⁴ : AddCommGroup N inst✝³ : Module R M inst✝² : Module R N inst✝¹ inst✝ : IsReflexive R M e : M ≃ₗ[R] N ed : Dual R (Dual R N) ≃ₗ[R] Dual R (Dual R M) := LinearEquiv.dualMap (LinearEquiv.dualMap (LinearEquiv.symm e)) this : Dual.eval R N = LinearMap.comp (↑(LinearEquiv.symm ed)) (LinearMap.comp (Dual.eval R M) ↑(LinearEquiv.symm e)) ⊢ Bijective (↑(Dual.eval R M) ∘ ↑(LinearEquiv.symm e)) [PROOFSTEP] refine Bijective.comp (bijective_dual_eval R M) (LinearEquiv.bijective _) [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε m : M ⊢ ∀ (a : ι), a ∈ Set.Finite.toFinset (_ : Set.Finite {i | ↑(ε i) m ≠ 0}) ↔ (fun i => ↑(ε i) m) a ≠ 0 [PROOFSTEP] intro i [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε m : M i : ι ⊢ i ∈ Set.Finite.toFinset (_ : Set.Finite {i | ↑(ε i) m ≠ 0}) ↔ (fun i => ↑(ε i) m) i ≠ 0 [PROOFSTEP] rw [Set.Finite.mem_toFinset, Set.mem_setOf_eq] [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε l : ι →₀ R i : ι ⊢ ↑(ε i) (lc e l) = ↑l i [PROOFSTEP] erw [LinearMap.map_sum] -- Porting note: cannot get at • -- simp only [h.eval, map_smul, smul_eq_mul] [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε l : ι →₀ R i : ι ⊢ (Finset.sum l.support fun i_1 => ↑(ε i) ((fun i a => a • e i) i_1 (↑l i_1))) = ↑l i [PROOFSTEP] rw [Finset.sum_eq_single i] [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε l : ι →₀ R i : ι ⊢ ↑(ε i) ((fun i a => a • e i) i (↑l i)) = ↑l i [PROOFSTEP] simp [h.eval, smul_eq_mul] [GOAL] case h₀ R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε l : ι →₀ R i : ι ⊢ ∀ (b : ι), b ∈ l.support → b ≠ i → ↑(ε i) ((fun i a => a • e i) b (↑l b)) = 0 [PROOFSTEP] intro q _ q_ne [GOAL] case h₀ R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε l : ι →₀ R i q : ι a✝ : q ∈ l.support q_ne : q ≠ i ⊢ ↑(ε i) ((fun i a => a • e i) q (↑l q)) = 0 [PROOFSTEP] simp [q_ne.symm, h.eval, smul_eq_mul] [GOAL] case h₁ R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε l : ι →₀ R i : ι ⊢ ¬i ∈ l.support → ↑(ε i) ((fun i a => a • e i) i (↑l i)) = 0 [PROOFSTEP] intro p_not_in [GOAL] case h₁ R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε l : ι →₀ R i : ι p_not_in : ¬i ∈ l.support ⊢ ↑(ε i) ((fun i a => a • e i) i (↑l i)) = 0 [PROOFSTEP] simp [Finsupp.not_mem_support_iff.1 p_not_in] [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε l : ι →₀ R ⊢ coeffs h (lc e l) = l [PROOFSTEP] ext i [GOAL] case h R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε l : ι →₀ R i : ι ⊢ ↑(coeffs h (lc e l)) i = ↑l i [PROOFSTEP] rw [h.coeffs_apply, h.dual_lc] [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε m : M ⊢ lc e (coeffs h m) = m [PROOFSTEP] refine' eq_of_sub_eq_zero (h.Total _) [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε m : M ⊢ ∀ (i : ι), ↑(ε i) (lc e (coeffs h m) - m) = 0 [PROOFSTEP] intro i [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε m : M i : ι ⊢ ↑(ε i) (lc e (coeffs h m) - m) = 0 [PROOFSTEP] simp [LinearMap.map_sub, h.dual_lc, sub_eq_zero] [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε v w : M ⊢ coeffs h (v + w) = coeffs h v + coeffs h w [PROOFSTEP] ext i [GOAL] case h R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε v w : M i : ι ⊢ ↑(coeffs h (v + w)) i = ↑(coeffs h v + coeffs h w) i [PROOFSTEP] exact (ε i).map_add v w [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε c : R v : M ⊢ AddHom.toFun { toFun := coeffs h, map_add' := (_ : ∀ (v w : M), coeffs h (v + w) = coeffs h v + coeffs h w) } (c • v) = ↑(RingHom.id R) c • AddHom.toFun { toFun := coeffs h, map_add' := (_ : ∀ (v w : M), coeffs h (v + w) = coeffs h v + coeffs h w) } v [PROOFSTEP] ext i [GOAL] case h R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε c : R v : M i : ι ⊢ ↑(AddHom.toFun { toFun := coeffs h, map_add' := (_ : ∀ (v w : M), coeffs h (v + w) = coeffs h v + coeffs h w) } (c • v)) i = ↑(↑(RingHom.id R) c • AddHom.toFun { toFun := coeffs h, map_add' := (_ : ∀ (v w : M), coeffs h (v + w) = coeffs h v + coeffs h w) } v) i [PROOFSTEP] exact (ε i).map_smul c v [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε ⊢ ↑(basis h) = e [PROOFSTEP] ext i [GOAL] case h R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε i : ι ⊢ ↑(basis h) i = e i [PROOFSTEP] rw [Basis.apply_eq_iff] [GOAL] case h R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε i : ι ⊢ ↑(basis h).repr (e i) = Finsupp.single i 1 [PROOFSTEP] ext j [GOAL] case h.h R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε i j : ι ⊢ ↑(↑(basis h).repr (e i)) j = ↑(Finsupp.single i 1) j [PROOFSTEP] rw [h.basis_repr_apply, coeffs_apply, h.eval, Finsupp.single_apply] [GOAL] case h.h R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε i j : ι ⊢ (if j = i then 1 else 0) = if i = j then 1 else 0 [PROOFSTEP] convert if_congr (eq_comm (a := j) (b := i)) rfl rfl [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε H : Set ι x : M hmem : x ∈ Submodule.span R (e '' H) ⊢ ∀ (i : ι), ↑(ε i) x ≠ 0 → i ∈ H [PROOFSTEP] intro i hi [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε H : Set ι x : M hmem : x ∈ Submodule.span R (e '' H) i : ι hi : ↑(ε i) x ≠ 0 ⊢ i ∈ H [PROOFSTEP] rcases(Finsupp.mem_span_image_iff_total _).mp hmem with ⟨l, supp_l, rfl⟩ [GOAL] case intro.intro R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε H : Set ι i : ι l : ι →₀ R supp_l : l ∈ Finsupp.supported R R H hmem : ↑(Finsupp.total ι M R e) l ∈ Submodule.span R (e '' H) hi : ↑(ε i) (↑(Finsupp.total ι M R e) l) ≠ 0 ⊢ i ∈ H [PROOFSTEP] apply not_imp_comm.mp ((Finsupp.mem_supported' _ _).mp supp_l i) [GOAL] case intro.intro R : Type u_1 M : Type u_2 ι : Type u_3 inst✝³ : CommRing R inst✝² : AddCommGroup M inst✝¹ : Module R M e : ι → M ε : ι → Dual R M inst✝ : DecidableEq ι h : DualBases e ε H : Set ι i : ι l : ι →₀ R supp_l : l ∈ Finsupp.supported R R H hmem : ↑(Finsupp.total ι M R e) l ∈ Submodule.span R (e '' H) hi : ↑(ε i) (↑(Finsupp.total ι M R e) l) ≠ 0 ⊢ ¬↑l i = 0 [PROOFSTEP] rwa [← lc_def, h.dual_lc] at hi [GOAL] R : Type u_1 M : Type u_2 ι : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M e : ι → M ε : ι → Dual R M inst✝¹ : DecidableEq ι h : DualBases e ε inst✝ : Fintype ι i j : ι ⊢ ↑(↑(Basis.dualBasis (basis h)) i) (↑(basis h) j) = ↑(ε i) (↑(basis h) j) [PROOFSTEP] rw [h.basis.dualBasis_apply_self, h.coe_basis, h.eval, if_congr eq_comm rfl rfl] [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M φ : Module.Dual R M ⊢ φ ∈ dualAnnihilator W ↔ ∀ (w : M), w ∈ W → ↑φ w = 0 [PROOFSTEP] refine' LinearMap.mem_ker.trans _ [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M φ : Module.Dual R M ⊢ ↑(dualRestrict W) φ = 0 ↔ ∀ (w : M), w ∈ W → ↑φ w = 0 [PROOFSTEP] simp_rw [LinearMap.ext_iff, dualRestrict_apply] [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M φ : Module.Dual R M ⊢ (∀ (x : { x // x ∈ W }), ↑φ ↑x = ↑0 x) ↔ ∀ (w : M), w ∈ W → ↑φ w = 0 [PROOFSTEP] exact ⟨fun h w hw => h ⟨w, hw⟩, fun h w => h w.1 w.2⟩ [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M Φ : Submodule R (Module.Dual R M) x : M ⊢ x ∈ dualCoannihilator Φ ↔ ∀ (φ : Module.Dual R M), φ ∈ Φ → ↑φ x = 0 [PROOFSTEP] simp_rw [dualCoannihilator, mem_comap, mem_dualAnnihilator, Module.Dual.eval_apply] [GOAL] R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M ⊢ GaloisConnection (↑OrderDual.toDual ∘ dualAnnihilator) (dualCoannihilator ∘ ↑OrderDual.ofDual) [PROOFSTEP] intro a b [GOAL] R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M b : (Submodule R (Module.Dual R M))ᵒᵈ ⊢ (↑OrderDual.toDual ∘ dualAnnihilator) a ≤ b ↔ a ≤ (dualCoannihilator ∘ ↑OrderDual.ofDual) b [PROOFSTEP] induction b using OrderDual.rec [GOAL] case h₂ R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) ⊢ (↑OrderDual.toDual ∘ dualAnnihilator) a ≤ ↑OrderDual.toDual a✝ ↔ a ≤ (dualCoannihilator ∘ ↑OrderDual.ofDual) (↑OrderDual.toDual a✝) [PROOFSTEP] simp only [Function.comp_apply, OrderDual.toDual_le_toDual, OrderDual.ofDual_toDual] [GOAL] case h₂ R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) ⊢ a✝ ≤ dualAnnihilator a ↔ a ≤ dualCoannihilator a✝ [PROOFSTEP] constructor [GOAL] case h₂.mp R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) ⊢ a✝ ≤ dualAnnihilator a → a ≤ dualCoannihilator a✝ [PROOFSTEP] intro h x hx [GOAL] case h₂.mp R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a✝ ≤ dualAnnihilator a x : M hx : x ∈ a ⊢ x ∈ dualCoannihilator a✝ [PROOFSTEP] simp only [mem_dualAnnihilator, mem_dualCoannihilator] [GOAL] case h₂.mp R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a✝ ≤ dualAnnihilator a x : M hx : x ∈ a ⊢ ∀ (φ : Module.Dual R M), φ ∈ a✝ → ↑φ x = 0 [PROOFSTEP] intro y hy [GOAL] case h₂.mp R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a✝ ≤ dualAnnihilator a x : M hx : x ∈ a y : Module.Dual R M hy : y ∈ a✝ ⊢ ↑y x = 0 [PROOFSTEP] have := h hy [GOAL] case h₂.mp R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a✝ ≤ dualAnnihilator a x : M hx : x ∈ a y : Module.Dual R M hy : y ∈ a✝ this : y ∈ dualAnnihilator a ⊢ ↑y x = 0 [PROOFSTEP] simp only [mem_dualAnnihilator, mem_dualCoannihilator] at this [GOAL] case h₂.mp R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a✝ ≤ dualAnnihilator a x : M hx : x ∈ a y : Module.Dual R M hy : y ∈ a✝ this : ∀ (w : M), w ∈ a → ↑y w = 0 ⊢ ↑y x = 0 [PROOFSTEP] exact this x hx [GOAL] case h₂.mpr R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) ⊢ a ≤ dualCoannihilator a✝ → a✝ ≤ dualAnnihilator a [PROOFSTEP] intro h x hx [GOAL] case h₂.mpr R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a ≤ dualCoannihilator a✝ x : Module.Dual R M hx : x ∈ a✝ ⊢ x ∈ dualAnnihilator a [PROOFSTEP] simp only [mem_dualAnnihilator, mem_dualCoannihilator] [GOAL] case h₂.mpr R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a ≤ dualCoannihilator a✝ x : Module.Dual R M hx : x ∈ a✝ ⊢ ∀ (w : M), w ∈ a → ↑x w = 0 [PROOFSTEP] intro y hy [GOAL] case h₂.mpr R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a ≤ dualCoannihilator a✝ x : Module.Dual R M hx : x ∈ a✝ y : M hy : y ∈ a ⊢ ↑x y = 0 [PROOFSTEP] have := h hy [GOAL] case h₂.mpr R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a ≤ dualCoannihilator a✝ x : Module.Dual R M hx : x ∈ a✝ y : M hy : y ∈ a this : y ∈ dualCoannihilator a✝ ⊢ ↑x y = 0 [PROOFSTEP] simp only [mem_dualAnnihilator, mem_dualCoannihilator] at this [GOAL] case h₂.mpr R✝ : Type u M✝ : Type v inst✝⁵ : CommSemiring R✝ inst✝⁴ : AddCommMonoid M✝ inst✝³ : Module R✝ M✝ W : Submodule R✝ M✝ R : Type u_1 M : Type u_2 inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M a : Submodule R M a✝ : Submodule R (Module.Dual R M) h : a ≤ dualCoannihilator a✝ x : Module.Dual R M hx : x ∈ a✝ y : M hy : y ∈ a this : ∀ (φ : Module.Dual R M), φ ∈ a✝ → ↑φ y = 0 ⊢ ↑x y = 0 [PROOFSTEP] exact this x hx [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M ⊢ dualAnnihilator ⊤ = ⊥ [PROOFSTEP] rw [eq_bot_iff] [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M ⊢ dualAnnihilator ⊤ ≤ ⊥ [PROOFSTEP] intro v [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M v : Module.Dual R M ⊢ v ∈ dualAnnihilator ⊤ → v ∈ ⊥ [PROOFSTEP] simp_rw [mem_dualAnnihilator, mem_bot, mem_top, forall_true_left] [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M v : Module.Dual R M ⊢ (∀ (w : M), ↑v w = 0) → v = 0 [PROOFSTEP] exact fun h => LinearMap.ext h [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W U V : Submodule R M ⊢ dualAnnihilator U ⊔ dualAnnihilator V ≤ dualAnnihilator (U ⊓ V) [PROOFSTEP] rw [le_dualAnnihilator_iff_le_dualCoannihilator, dualCoannihilator_sup_eq] [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W U V : Submodule R M ⊢ U ⊓ V ≤ dualCoannihilator (dualAnnihilator U) ⊓ dualCoannihilator (dualAnnihilator V) [PROOFSTEP] apply inf_le_inf [GOAL] case h₁ R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W U V : Submodule R M ⊢ U ≤ dualCoannihilator (dualAnnihilator U) [PROOFSTEP] exact le_dualAnnihilator_dualCoannihilator _ [GOAL] case h₂ R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W U V : Submodule R M ⊢ V ≤ dualCoannihilator (dualAnnihilator V) [PROOFSTEP] exact le_dualAnnihilator_dualCoannihilator _ [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M ι : Type u_1 U : ι → Submodule R M ⊢ ⨆ (i : ι), dualAnnihilator (U i) ≤ dualAnnihilator (⨅ (i : ι), U i) [PROOFSTEP] rw [le_dualAnnihilator_iff_le_dualCoannihilator, dualCoannihilator_iSup_eq] [GOAL] R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M ι : Type u_1 U : ι → Submodule R M ⊢ ⨅ (i : ι), U i ≤ ⨅ (i : ι), dualCoannihilator (dualAnnihilator (U i)) [PROOFSTEP] apply iInf_mono [GOAL] case h R : Type u M : Type v inst✝² : CommSemiring R inst✝¹ : AddCommMonoid M inst✝ : Module R M W : Submodule R M ι : Type u_1 U : ι → Submodule R M ⊢ ∀ (i : ι), U i ≤ dualCoannihilator (dualAnnihilator (U i)) [PROOFSTEP] exact fun i : ι => le_dualAnnihilator_dualCoannihilator (U i) [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V ⊢ dualCoannihilator ⊤ = ⊥ [PROOFSTEP] rw [dualCoannihilator, dualAnnihilator_top, comap_bot, Module.eval_ker] [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V ⊢ dualCoannihilator (dualAnnihilator W) = W [PROOFSTEP] refine' le_antisymm _ (le_dualAnnihilator_dualCoannihilator _) [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V ⊢ dualCoannihilator (dualAnnihilator W) ≤ W [PROOFSTEP] intro v [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V v : V ⊢ v ∈ dualCoannihilator (dualAnnihilator W) → v ∈ W [PROOFSTEP] simp only [mem_dualAnnihilator, mem_dualCoannihilator] [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V v : V ⊢ (∀ (φ : Module.Dual K V), (∀ (w : V), w ∈ W → ↑φ w = 0) → ↑φ v = 0) → v ∈ W [PROOFSTEP] contrapose! [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V v : V ⊢ ¬v ∈ W → ∃ φ, (∀ (w : V), w ∈ W → ↑φ w = 0) ∧ ↑φ v ≠ 0 [PROOFSTEP] intro hv [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V v : V hv : ¬v ∈ W ⊢ ∃ φ, (∀ (w : V), w ∈ W → ↑φ w = 0) ∧ ↑φ v ≠ 0 [PROOFSTEP] obtain ⟨W', hW⟩ := Submodule.exists_isCompl W [GOAL] case intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V v : V hv : ¬v ∈ W W' : Submodule K V hW : IsCompl W W' ⊢ ∃ φ, (∀ (w : V), w ∈ W → ↑φ w = 0) ∧ ↑φ v ≠ 0 [PROOFSTEP] obtain ⟨⟨w, w'⟩, rfl, -⟩ := existsUnique_add_of_isCompl_prod hW v [GOAL] case intro.intro.mk.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W ⊢ ∃ φ, (∀ (w : V), w ∈ W → ↑φ w = 0) ∧ ↑φ (↑(w, w').fst + ↑(w, w').snd) ≠ 0 [PROOFSTEP] have hw'n : (w' : V) ∉ W := by contrapose! hv exact Submodule.add_mem W w.2 hv [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W ⊢ ¬↑w' ∈ W [PROOFSTEP] contrapose! hv [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ↑w' ∈ W ⊢ ↑w + ↑w' ∈ W [PROOFSTEP] exact Submodule.add_mem W w.2 hv [GOAL] case intro.intro.mk.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W ⊢ ∃ φ, (∀ (w : V), w ∈ W → ↑φ w = 0) ∧ ↑φ (↑(w, w').fst + ↑(w, w').snd) ≠ 0 [PROOFSTEP] have hw'nz : w' ≠ 0 := by rintro rfl exact hw'n (Submodule.zero_mem W) [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W ⊢ w' ≠ 0 [PROOFSTEP] rintro rfl [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } hv : ¬↑(w, 0).fst + ↑(w, 0).snd ∈ W hw'n : ¬↑0 ∈ W ⊢ False [PROOFSTEP] exact hw'n (Submodule.zero_mem W) [GOAL] case intro.intro.mk.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W hw'nz : w' ≠ 0 ⊢ ∃ φ, (∀ (w : V), w ∈ W → ↑φ w = 0) ∧ ↑φ (↑(w, w').fst + ↑(w, w').snd) ≠ 0 [PROOFSTEP] rw [Ne.def, ← Module.forall_dual_apply_eq_zero_iff K w'] at hw'nz [GOAL] case intro.intro.mk.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W hw'nz : ¬∀ (φ : Module.Dual K { x // x ∈ W' }), ↑φ w' = 0 ⊢ ∃ φ, (∀ (w : V), w ∈ W → ↑φ w = 0) ∧ ↑φ (↑(w, w').fst + ↑(w, w').snd) ≠ 0 [PROOFSTEP] push_neg at hw'nz [GOAL] case intro.intro.mk.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W hw'nz : ∃ φ, ↑φ w' ≠ 0 ⊢ ∃ φ, (∀ (w : V), w ∈ W → ↑φ w = 0) ∧ ↑φ (↑(w, w').fst + ↑(w, w').snd) ≠ 0 [PROOFSTEP] obtain ⟨φ, hφ⟩ := hw'nz [GOAL] case intro.intro.mk.intro.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W φ : Module.Dual K { x // x ∈ W' } hφ : ↑φ w' ≠ 0 ⊢ ∃ φ, (∀ (w : V), w ∈ W → ↑φ w = 0) ∧ ↑φ (↑(w, w').fst + ↑(w, w').snd) ≠ 0 [PROOFSTEP] exists ((LinearMap.ofIsComplProd hW).comp (LinearMap.inr _ _ _)) φ [GOAL] case intro.intro.mk.intro.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W φ : Module.Dual K { x // x ∈ W' } hφ : ↑φ w' ≠ 0 ⊢ (∀ (w : V), w ∈ W → ↑(↑(comp (ofIsComplProd hW) (inr K ({ x // x ∈ W } →ₗ[K] K) ({ x // x ∈ W' } →ₗ[K] K))) φ) w = 0) ∧ ↑(↑(comp (ofIsComplProd hW) (inr K ({ x // x ∈ W } →ₗ[K] K) ({ x // x ∈ W' } →ₗ[K] K))) φ) (↑(w, w').fst + ↑(w, w').snd) ≠ 0 [PROOFSTEP] simp only [coe_comp, coe_inr, Function.comp_apply, ofIsComplProd_apply, map_add, ofIsCompl_left_apply, zero_apply, ofIsCompl_right_apply, zero_add, Ne.def] [GOAL] case intro.intro.mk.intro.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W φ : Module.Dual K { x // x ∈ W' } hφ : ↑φ w' ≠ 0 ⊢ (∀ (w : V), w ∈ W → ↑(ofIsCompl hW 0 φ) w = 0) ∧ ¬↑φ w' = 0 [PROOFSTEP] refine' ⟨_, hφ⟩ [GOAL] case intro.intro.mk.intro.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W φ : Module.Dual K { x // x ∈ W' } hφ : ↑φ w' ≠ 0 ⊢ ∀ (w : V), w ∈ W → ↑(ofIsCompl hW 0 φ) w = 0 [PROOFSTEP] intro v hv [GOAL] case intro.intro.mk.intro.intro K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V W' : Submodule K V hW : IsCompl W W' w : { x // x ∈ W } w' : { x // x ∈ W' } hv✝ : ¬↑(w, w').fst + ↑(w, w').snd ∈ W hw'n : ¬↑w' ∈ W φ : Module.Dual K { x // x ∈ W' } hφ : ↑φ w' ≠ 0 v : V hv : v ∈ W ⊢ ↑(ofIsCompl hW 0 φ) v = 0 [PROOFSTEP] apply LinearMap.ofIsCompl_left_apply hW ⟨v, hv⟩ [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V v : V ⊢ (∀ (φ : Module.Dual K V), φ ∈ dualAnnihilator W → ↑φ v = 0) ↔ v ∈ W [PROOFSTEP] rw [← SetLike.ext_iff.mp dualAnnihilator_dualCoannihilator_eq v, mem_dualCoannihilator] [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W W' : Subspace K V ⊢ dualAnnihilator W = dualAnnihilator W' ↔ W = W' [PROOFSTEP] constructor [GOAL] case mp K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W W' : Subspace K V ⊢ dualAnnihilator W = dualAnnihilator W' → W = W' [PROOFSTEP] apply (dualAnnihilatorGci K V).l_injective [GOAL] case mpr K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W W' : Subspace K V ⊢ W = W' → dualAnnihilator W = dualAnnihilator W' [PROOFSTEP] rintro rfl [GOAL] case mpr K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V ⊢ dualAnnihilator W = dualAnnihilator W [PROOFSTEP] rfl [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V φ : Module.Dual K { x // x ∈ W } w : { x // x ∈ W } ⊢ ↑(↑(dualLift W) φ) ↑w = ↑φ w [PROOFSTEP] erw [ofIsCompl_left_apply _ w] [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V φ : Module.Dual K { x // x ∈ W } w : { x // x ∈ W } ⊢ ↑(↑(inl K (Module.Dual K { x // x ∈ W }) ({ x // x ∈ ↑(Classical.indefiniteDescription (fun x => IsCompl W x) (_ : ∃ q, IsCompl W q)) } →ₗ[K] K)) φ).fst w = ↑φ w [PROOFSTEP] rfl [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W : Subspace K V φ : Module.Dual K { x // x ∈ W } w : V hw : w ∈ W ⊢ ↑(↑(dualLift W) φ) w = ↑φ { val := w, property := hw } [PROOFSTEP] convert dualLift_of_subtype ⟨w, hw⟩ [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W✝ W : Subspace K V ⊢ comp (dualRestrict W) (dualLift W) = 1 [PROOFSTEP] ext φ x [GOAL] case h.h K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W✝ W : Subspace K V φ : Module.Dual K { x // x ∈ W } x : { x // x ∈ W } ⊢ ↑(↑(comp (dualRestrict W) (dualLift W)) φ) x = ↑(↑1 φ) x [PROOFSTEP] simp [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W✝ W : Subspace K V x : Module.Dual K { x // x ∈ W } ⊢ ↑(comp (dualRestrict W) (dualLift W)) x = x [PROOFSTEP] rw [dualRestrict_comp_dualLift] [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W✝ W : Subspace K V x : Module.Dual K { x // x ∈ W } ⊢ ↑1 x = x [PROOFSTEP] rfl [GOAL] K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W✝ W : Subspace K V φ : Module.Dual K V ⊢ ↑(quotAnnihilatorEquiv W) (Submodule.Quotient.mk φ) = ↑(dualRestrict W) φ [PROOFSTEP] ext [GOAL] case h K : Type u V : Type v inst✝² : Field K inst✝¹ : AddCommGroup V inst✝ : Module K V W✝ W : Subspace K V φ : Module.Dual K V x✝ : { x // x ∈ W } ⊢ ↑(↑(quotAnnihilatorEquiv W) (Submodule.Quotient.mk φ)) x✝ = ↑(↑(dualRestrict W) φ) x✝ [PROOFSTEP] rfl [GOAL] K : Type u V : Type v inst✝⁴ : Field K inst✝³ : AddCommGroup V inst✝² : Module K V W : Subspace K V V₁ : Type u_1 inst✝¹ : AddCommGroup V₁ inst✝ : Module K V₁ H : FiniteDimensional K V ⊢ FiniteDimensional K (Module.Dual K V) [PROOFSTEP] infer_instance [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W✝ : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ W : Subspace K V ⊢ dualAnnihilator (dualAnnihilator W) = ↑(Module.mapEvalEquiv K V) W [PROOFSTEP] have : _ = W := Subspace.dualAnnihilator_dualCoannihilator_eq [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W✝ : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ W : Subspace K V this : dualCoannihilator (dualAnnihilator W) = W ⊢ dualAnnihilator (dualAnnihilator W) = ↑(Module.mapEvalEquiv K V) W [PROOFSTEP] rw [dualCoannihilator, ← Module.mapEvalEquiv_symm_apply] at this [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W✝ : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ W : Subspace K V this : ↑(OrderIso.symm (Module.mapEvalEquiv K V)) (dualAnnihilator (dualAnnihilator W)) = W ⊢ dualAnnihilator (dualAnnihilator W) = ↑(Module.mapEvalEquiv K V) W [PROOFSTEP] rwa [← OrderIso.symm_apply_eq] [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ ⊢ finrank K (Module.Dual K V) = finrank K V [PROOFSTEP] classical exact LinearEquiv.finrank_eq (Basis.ofVectorSpace K V).toDualEquiv.symm [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ ⊢ finrank K (Module.Dual K V) = finrank K V [PROOFSTEP] exact LinearEquiv.finrank_eq (Basis.ofVectorSpace K V).toDualEquiv.symm [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ Φ : Subspace K (Module.Dual K V) ⊢ finrank K { x // x ∈ dualCoannihilator Φ } = finrank K { x // x ∈ dualAnnihilator Φ } [PROOFSTEP] rw [Submodule.dualCoannihilator, ← Module.evalEquiv_toLinearMap] [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ Φ : Subspace K (Module.Dual K V) ⊢ finrank K { x // x ∈ comap (↑(Module.evalEquiv K V)) (dualAnnihilator Φ) } = finrank K { x // x ∈ dualAnnihilator Φ } [PROOFSTEP] exact LinearEquiv.finrank_eq (LinearEquiv.ofSubmodule' _ _) [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W✝ : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ W : Subspace K (Module.Dual K V) ⊢ finrank K { x // x ∈ W } + finrank K { x // x ∈ dualCoannihilator W } = finrank K V [PROOFSTEP] rw [finrank_dualCoannihilator_eq] -- Porting note: LinearEquiv.finrank_eq needs help [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W✝ : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ W : Subspace K (Module.Dual K V) ⊢ finrank K { x // x ∈ W } + finrank K { x // x ∈ dualAnnihilator W } = finrank K V [PROOFSTEP] let equiv := W.quotEquivAnnihilator [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W✝ : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ W : Subspace K (Module.Dual K V) equiv : (Module.Dual K V ⧸ W) ≃ₗ[K] { x // x ∈ dualAnnihilator W } := quotEquivAnnihilator W ⊢ finrank K { x // x ∈ W } + finrank K { x // x ∈ dualAnnihilator W } = finrank K V [PROOFSTEP] have eq := LinearEquiv.finrank_eq (R := K) (M := (Module.Dual K V) ⧸ W) (M₂ := { x // x ∈ dualAnnihilator W }) equiv [GOAL] K : Type u V : Type v inst✝⁶ : Field K inst✝⁵ : AddCommGroup V inst✝⁴ : Module K V W✝ : Subspace K V V₁ : Type u_1 inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : FiniteDimensional K V inst✝ : FiniteDimensional K V₁ W : Subspace K (Module.Dual K V) equiv : (Module.Dual K V ⧸ W) ≃ₗ[K] { x // x ∈ dualAnnihilator W } := quotEquivAnnihilator W eq : finrank K (Module.Dual K V ⧸ W) = finrank K { x // x ∈ dualAnnihilator W } ⊢ finrank K { x // x ∈ W } + finrank K { x // x ∈ dualAnnihilator W } = finrank K V [PROOFSTEP] rw [eq.symm, add_comm, Submodule.finrank_quotient_add_finrank, Subspace.dual_finrank_eq] [GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ ⊢ ker (dualMap f) = Submodule.dualAnnihilator (range f) [PROOFSTEP] ext φ [GOAL] case h R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ ⊢ φ ∈ ker (dualMap f) ↔ φ ∈ Submodule.dualAnnihilator (range f) [PROOFSTEP] constructor [GOAL] case h.mp R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ ⊢ φ ∈ ker (dualMap f) → φ ∈ Submodule.dualAnnihilator (range f) [PROOFSTEP] intro hφ [GOAL] case h.mpr R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ ⊢ φ ∈ Submodule.dualAnnihilator (range f) → φ ∈ ker (dualMap f) [PROOFSTEP] intro hφ [GOAL] case h.mp R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ hφ : φ ∈ ker (dualMap f) ⊢ φ ∈ Submodule.dualAnnihilator (range f) [PROOFSTEP] rw [mem_ker] at hφ [GOAL] case h.mp R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ hφ : ↑(dualMap f) φ = 0 ⊢ φ ∈ Submodule.dualAnnihilator (range f) [PROOFSTEP] rw [Submodule.mem_dualAnnihilator] [GOAL] case h.mp R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ hφ : ↑(dualMap f) φ = 0 ⊢ ∀ (w : M₂), w ∈ range f → ↑φ w = 0 [PROOFSTEP] rintro y ⟨x, rfl⟩ [GOAL] case h.mp.intro R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ hφ : ↑(dualMap f) φ = 0 x : M₁ ⊢ ↑φ (↑f x) = 0 [PROOFSTEP] rw [← dualMap_apply, hφ, zero_apply] [GOAL] case h.mpr R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ hφ : φ ∈ Submodule.dualAnnihilator (range f) ⊢ φ ∈ ker (dualMap f) [PROOFSTEP] ext x [GOAL] case h.mpr.h R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ hφ : φ ∈ Submodule.dualAnnihilator (range f) x : M₁ ⊢ ↑(↑(dualMap f) φ) x = ↑0 x [PROOFSTEP] rw [dualMap_apply] [GOAL] case h.mpr.h R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ hφ : φ ∈ Submodule.dualAnnihilator (range f) x : M₁ ⊢ ↑φ (↑f x) = ↑0 x [PROOFSTEP] rw [Submodule.mem_dualAnnihilator] at hφ [GOAL] case h.mpr.h R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ φ : Dual R M₂ hφ : ∀ (w : M₂), w ∈ range f → ↑φ w = 0 x : M₁ ⊢ ↑φ (↑f x) = ↑0 x [PROOFSTEP] exact hφ (f x) ⟨x, rfl⟩ [GOAL] R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ ⊢ range (dualMap f) ≤ Submodule.dualAnnihilator (ker f) [PROOFSTEP] rintro _ ⟨ψ, rfl⟩ [GOAL] case intro R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ ψ : Dual R M₂ ⊢ ↑(dualMap f) ψ ∈ Submodule.dualAnnihilator (ker f) [PROOFSTEP] simp_rw [Submodule.mem_dualAnnihilator, mem_ker] [GOAL] case intro R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ ψ : Dual R M₂ ⊢ ∀ (w : M₁), ↑f w = 0 → ↑(↑(dualMap f) ψ) w = 0 [PROOFSTEP] rintro x hx [GOAL] case intro R : Type u inst✝⁴ : CommSemiring R M₁ : Type v M₂ : Type v' inst✝³ : AddCommMonoid M₁ inst✝² : Module R M₁ inst✝¹ : AddCommMonoid M₂ inst✝ : Module R M₂ f : M₁ →ₗ[R] M₂ ψ : Dual R M₂ x : M₁ hx : ↑f x = 0 ⊢ ↑(↑(dualMap f) ψ) x = 0 [PROOFSTEP] rw [dualMap_apply, hx, map_zero] [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M ⊢ W ≤ LinearMap.ker (LinearMap.flip (LinearMap.domRestrict (dualPairing R M) (dualAnnihilator W))) [PROOFSTEP] intro w hw [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M w : M hw : w ∈ W ⊢ w ∈ LinearMap.ker (LinearMap.flip (LinearMap.domRestrict (dualPairing R M) (dualAnnihilator W))) [PROOFSTEP] ext ⟨φ, hφ⟩ [GOAL] case h.mk R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M w : M hw : w ∈ W φ : Dual R M hφ : φ ∈ dualAnnihilator W ⊢ ↑(↑(LinearMap.flip (LinearMap.domRestrict (dualPairing R M) (dualAnnihilator W))) w) { val := φ, property := hφ } = ↑0 { val := φ, property := hφ } [PROOFSTEP] exact (mem_dualAnnihilator φ).mp hφ w hw [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M φ ψ : { x // x ∈ dualAnnihilator W } h : (fun φ => ↑↑φ) φ = (fun φ => ↑↑φ) ψ ⊢ φ = ψ [PROOFSTEP] ext [GOAL] case a.h R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M φ ψ : { x // x ∈ dualAnnihilator W } h : (fun φ => ↑↑φ) φ = (fun φ => ↑↑φ) ψ x✝ : M ⊢ ↑↑φ x✝ = ↑↑ψ x✝ [PROOFSTEP] simp only [Function.funext_iff] at h [GOAL] case a.h R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M φ ψ : { x // x ∈ dualAnnihilator W } x✝ : M h : ∀ (a : M), ↑↑φ a = ↑↑ψ a ⊢ ↑↑φ x✝ = ↑↑ψ x✝ [PROOFSTEP] exact h _ [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M ⊢ LinearMap.range (LinearMap.dualMap (mkQ W)) = dualAnnihilator W [PROOFSTEP] ext φ [GOAL] case h R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M φ : Dual R M ⊢ φ ∈ LinearMap.range (LinearMap.dualMap (mkQ W)) ↔ φ ∈ dualAnnihilator W [PROOFSTEP] rw [LinearMap.mem_range] [GOAL] case h R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M φ : Dual R M ⊢ (∃ y, ↑(LinearMap.dualMap (mkQ W)) y = φ) ↔ φ ∈ dualAnnihilator W [PROOFSTEP] constructor [GOAL] case h.mp R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M φ : Dual R M ⊢ (∃ y, ↑(LinearMap.dualMap (mkQ W)) y = φ) → φ ∈ dualAnnihilator W [PROOFSTEP] rintro ⟨ψ, rfl⟩ [GOAL] case h.mp.intro R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M ψ : Dual R (M ⧸ W) ⊢ ↑(LinearMap.dualMap (mkQ W)) ψ ∈ dualAnnihilator W [PROOFSTEP] have := LinearMap.mem_range_self W.mkQ.dualMap ψ [GOAL] case h.mp.intro R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M ψ : Dual R (M ⧸ W) this : ↑(LinearMap.dualMap (mkQ W)) ψ ∈ LinearMap.range (LinearMap.dualMap (mkQ W)) ⊢ ↑(LinearMap.dualMap (mkQ W)) ψ ∈ dualAnnihilator W [PROOFSTEP] simpa only [ker_mkQ] using LinearMap.range_dualMap_le_dualAnnihilator_ker W.mkQ this [GOAL] case h.mpr R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M φ : Dual R M ⊢ φ ∈ dualAnnihilator W → ∃ y, ↑(LinearMap.dualMap (mkQ W)) y = φ [PROOFSTEP] intro hφ [GOAL] case h.mpr R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M φ : Dual R M hφ : φ ∈ dualAnnihilator W ⊢ ∃ y, ↑(LinearMap.dualMap (mkQ W)) y = φ [PROOFSTEP] exists W.dualCopairing ⟨φ, hφ⟩ [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M ⊢ LinearMap.comp (LinearMap.codRestrict (dualAnnihilator W) (LinearMap.dualMap (mkQ W)) (_ : ∀ (φ : Dual R (M ⧸ W)), ↑(LinearMap.dualMap (mkQ W)) φ ∈ dualAnnihilator W)) (dualCopairing W) = LinearMap.id [PROOFSTEP] ext [GOAL] case h.a.h R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M x✝¹ : { x // x ∈ dualAnnihilator W } x✝ : M ⊢ ↑↑(↑(LinearMap.comp (LinearMap.codRestrict (dualAnnihilator W) (LinearMap.dualMap (mkQ W)) (_ : ∀ (φ : Dual R (M ⧸ W)), ↑(LinearMap.dualMap (mkQ W)) φ ∈ dualAnnihilator W)) (dualCopairing W)) x✝¹) x✝ = ↑↑(↑LinearMap.id x✝¹) x✝ [PROOFSTEP] rfl [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M ⊢ LinearMap.comp (dualCopairing W) (LinearMap.codRestrict (dualAnnihilator W) (LinearMap.dualMap (mkQ W)) (_ : ∀ (φ : Dual R (M ⧸ W)), ↑(LinearMap.dualMap (mkQ W)) φ ∈ dualAnnihilator W)) = LinearMap.id [PROOFSTEP] ext [GOAL] case h.h.h R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' W : Submodule R M x✝¹ : Dual R (M ⧸ W) x✝ : M ⊢ ↑(LinearMap.comp (↑(LinearMap.comp (dualCopairing W) (LinearMap.codRestrict (dualAnnihilator W) (LinearMap.dualMap (mkQ W)) (_ : ∀ (φ : Dual R (M ⧸ W)), ↑(LinearMap.dualMap (mkQ W)) φ ∈ dualAnnihilator W))) x✝¹) (mkQ W)) x✝ = ↑(LinearMap.comp (↑LinearMap.id x✝¹) (mkQ W)) x✝ [PROOFSTEP] rfl [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑f ⊢ range (dualMap f) = dualAnnihilator (ker f) [PROOFSTEP] rw [← f.ker.range_dualMap_mkQ_eq] [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑f ⊢ range (dualMap f) = range (dualMap (mkQ (ker f))) [PROOFSTEP] let f' := LinearMap.quotKerEquivOfSurjective f hf [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑f f' : (M ⧸ ker f) ≃ₗ[R] M' := quotKerEquivOfSurjective f hf ⊢ range (dualMap f) = range (dualMap (mkQ (ker f))) [PROOFSTEP] trans LinearMap.range (f.dualMap.comp f'.symm.dualMap.toLinearMap) [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑f f' : (M ⧸ ker f) ≃ₗ[R] M' := quotKerEquivOfSurjective f hf ⊢ range (dualMap f) = range (comp (dualMap f) ↑(LinearEquiv.dualMap (LinearEquiv.symm f'))) [PROOFSTEP] rw [LinearMap.range_comp_of_range_eq_top] [GOAL] case hf R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑f f' : (M ⧸ ker f) ≃ₗ[R] M' := quotKerEquivOfSurjective f hf ⊢ range ↑(LinearEquiv.dualMap (LinearEquiv.symm f')) = ⊤ [PROOFSTEP] apply LinearEquiv.range [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑f f' : (M ⧸ ker f) ≃ₗ[R] M' := quotKerEquivOfSurjective f hf ⊢ range (comp (dualMap f) ↑(LinearEquiv.dualMap (LinearEquiv.symm f'))) = range (dualMap (mkQ (ker f))) [PROOFSTEP] apply congr_arg [GOAL] case h R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑f f' : (M ⧸ ker f) ≃ₗ[R] M' := quotKerEquivOfSurjective f hf ⊢ comp (dualMap f) ↑(LinearEquiv.dualMap (LinearEquiv.symm f')) = dualMap (mkQ (ker f)) [PROOFSTEP] ext φ x [GOAL] case h.h.h R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑f f' : (M ⧸ ker f) ≃ₗ[R] M' := quotKerEquivOfSurjective f hf φ : Dual R (M ⧸ ker f) x : M ⊢ ↑(↑(comp (dualMap f) ↑(LinearEquiv.dualMap (LinearEquiv.symm f'))) φ) x = ↑(↑(dualMap (mkQ (ker f))) φ) x [PROOFSTEP] simp only [LinearMap.coe_comp, LinearEquiv.coe_toLinearMap, LinearMap.dualMap_apply, LinearEquiv.dualMap_apply, mkQ_apply, LinearMap.quotKerEquivOfSurjective, LinearEquiv.trans_symm, LinearEquiv.trans_apply, LinearEquiv.ofTop_symm_apply, LinearMap.quotKerEquivRange_symm_apply_image, mkQ_apply, Function.comp] [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑(dualMap (Submodule.subtype (range f))) ⊢ range (dualMap f) = dualAnnihilator (ker f) [PROOFSTEP] have rr_surj : Function.Surjective f.rangeRestrict := by rw [← LinearMap.range_eq_top, LinearMap.range_rangeRestrict] [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑(dualMap (Submodule.subtype (range f))) ⊢ Function.Surjective ↑(rangeRestrict f) [PROOFSTEP] rw [← LinearMap.range_eq_top, LinearMap.range_rangeRestrict] [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑(dualMap (Submodule.subtype (range f))) rr_surj : Function.Surjective ↑(rangeRestrict f) ⊢ range (dualMap f) = dualAnnihilator (ker f) [PROOFSTEP] have := range_dualMap_eq_dualAnnihilator_ker_of_surjective f.rangeRestrict rr_surj [GOAL] R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑(dualMap (Submodule.subtype (range f))) rr_surj : Function.Surjective ↑(rangeRestrict f) this : range (dualMap (rangeRestrict f)) = dualAnnihilator (ker (rangeRestrict f)) ⊢ range (dualMap f) = dualAnnihilator (ker f) [PROOFSTEP] convert this using 1 -- Porting note: broken dot notation lean4#1910 [GOAL] case h.e'_2 R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑(dualMap (Submodule.subtype (range f))) rr_surj : Function.Surjective ↑(rangeRestrict f) this : range (dualMap (rangeRestrict f)) = dualAnnihilator (ker (rangeRestrict f)) ⊢ range (dualMap f) = range (dualMap (rangeRestrict f)) [PROOFSTEP] change LinearMap.range ((Submodule.subtype <| LinearMap.range f).comp f.rangeRestrict).dualMap = _ [GOAL] case h.e'_2 R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑(dualMap (Submodule.subtype (range f))) rr_surj : Function.Surjective ↑(rangeRestrict f) this : range (dualMap (rangeRestrict f)) = dualAnnihilator (ker (rangeRestrict f)) ⊢ range (dualMap (comp (Submodule.subtype (range f)) (rangeRestrict f))) = range (dualMap (rangeRestrict f)) [PROOFSTEP] rw [← LinearMap.dualMap_comp_dualMap, LinearMap.range_comp_of_range_eq_top] [GOAL] case h.e'_2.hf R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑(dualMap (Submodule.subtype (range f))) rr_surj : Function.Surjective ↑(rangeRestrict f) this : range (dualMap (rangeRestrict f)) = dualAnnihilator (ker (rangeRestrict f)) ⊢ range (dualMap (Submodule.subtype (range f))) = ⊤ [PROOFSTEP] rwa [LinearMap.range_eq_top] [GOAL] case h.e'_3 R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑(dualMap (Submodule.subtype (range f))) rr_surj : Function.Surjective ↑(rangeRestrict f) this : range (dualMap (rangeRestrict f)) = dualAnnihilator (ker (rangeRestrict f)) ⊢ dualAnnihilator (ker f) = dualAnnihilator (ker (rangeRestrict f)) [PROOFSTEP] apply congr_arg [GOAL] case h.e'_3.h R : Type u_1 M : Type u_2 M' : Type u_3 inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : Module R M inst✝¹ : AddCommGroup M' inst✝ : Module R M' f : M →ₗ[R] M' hf : Function.Surjective ↑(dualMap (Submodule.subtype (range f))) rr_surj : Function.Surjective ↑(rangeRestrict f) this : range (dualMap (rangeRestrict f)) = dualAnnihilator (ker (rangeRestrict f)) ⊢ ker f = ker (rangeRestrict f) [PROOFSTEP] exact (LinearMap.ker_rangeRestrict f).symm [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ f : V₁ →ₗ[K] V₂ hf : Function.Injective ↑f ⊢ Function.Surjective ↑(dualMap f) [PROOFSTEP] intro φ [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ f : V₁ →ₗ[K] V₂ hf : Function.Injective ↑f φ : Dual K V₁ ⊢ ∃ a, ↑(dualMap f) a = φ [PROOFSTEP] let f' := LinearEquiv.ofInjective f hf [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ f : V₁ →ₗ[K] V₂ hf : Function.Injective ↑f φ : Dual K V₁ f' : V₁ ≃ₗ[K] { x // x ∈ range f } := LinearEquiv.ofInjective f hf ⊢ ∃ a, ↑(dualMap f) a = φ [PROOFSTEP] use Subspace.dualLift (range f) (f'.symm.dualMap φ) [GOAL] case h K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ f : V₁ →ₗ[K] V₂ hf : Function.Injective ↑f φ : Dual K V₁ f' : V₁ ≃ₗ[K] { x // x ∈ range f } := LinearEquiv.ofInjective f hf ⊢ ↑(dualMap f) (↑(Subspace.dualLift (range f)) (↑(LinearEquiv.dualMap (LinearEquiv.symm f')) φ)) = φ [PROOFSTEP] ext x [GOAL] case h.h K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ f : V₁ →ₗ[K] V₂ hf : Function.Injective ↑f φ : Dual K V₁ f' : V₁ ≃ₗ[K] { x // x ∈ range f } := LinearEquiv.ofInjective f hf x : V₁ ⊢ ↑(↑(dualMap f) (↑(Subspace.dualLift (range f)) (↑(LinearEquiv.dualMap (LinearEquiv.symm f')) φ))) x = ↑φ x [PROOFSTEP] rw [LinearMap.dualMap_apply, Subspace.dualLift_of_mem (mem_range_self f x), LinearEquiv.dualMap_apply] [GOAL] case h.h K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ f : V₁ →ₗ[K] V₂ hf : Function.Injective ↑f φ : Dual K V₁ f' : V₁ ≃ₗ[K] { x // x ∈ range f } := LinearEquiv.ofInjective f hf x : V₁ ⊢ ↑φ (↑(LinearEquiv.symm f') { val := ↑f x, property := (_ : ↑f x ∈ range f) }) = ↑φ x [PROOFSTEP] congr 1 [GOAL] case h.h.h.e_6.h K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ f : V₁ →ₗ[K] V₂ hf : Function.Injective ↑f φ : Dual K V₁ f' : V₁ ≃ₗ[K] { x // x ∈ range f } := LinearEquiv.ofInjective f hf x : V₁ ⊢ ↑(LinearEquiv.symm f') { val := ↑f x, property := (_ : ↑f x ∈ range f) } = x [PROOFSTEP] exact LinearEquiv.symm_apply_apply f' x [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ f : V₁ →ₗ[K] V₂ ⊢ Function.Surjective ↑(dualMap f) ↔ Function.Injective ↑f [PROOFSTEP] rw [← LinearMap.range_eq_top, range_dualMap_eq_dualAnnihilator_ker, ← Submodule.dualAnnihilator_bot, Subspace.dualAnnihilator_inj, LinearMap.ker_eq_bot] [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ ⊢ Submodule.dualPairing W = ↑(quotAnnihilatorEquiv W) [PROOFSTEP] ext [GOAL] case h.h.h K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ x✝¹ : Dual K V₁ x✝ : { x // x ∈ W } ⊢ ↑(↑(LinearMap.comp (Submodule.dualPairing W) (mkQ (dualAnnihilator W))) x✝¹) x✝ = ↑(↑(LinearMap.comp (↑(quotAnnihilatorEquiv W)) (mkQ (dualAnnihilator W))) x✝¹) x✝ [PROOFSTEP] rfl [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ ⊢ LinearMap.Nondegenerate (Submodule.dualPairing W) [PROOFSTEP] constructor [GOAL] case left K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ ⊢ LinearMap.SeparatingLeft (Submodule.dualPairing W) [PROOFSTEP] rw [LinearMap.separatingLeft_iff_ker_eq_bot, dualPairing_eq] [GOAL] case left K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ ⊢ LinearMap.ker ↑(quotAnnihilatorEquiv W) = ⊥ [PROOFSTEP] apply LinearEquiv.ker [GOAL] case right K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ ⊢ LinearMap.SeparatingRight (Submodule.dualPairing W) [PROOFSTEP] intro x h [GOAL] case right K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ x : { x // x ∈ W } h : ∀ (x_1 : Dual K V₁ ⧸ dualAnnihilator W), ↑(↑(Submodule.dualPairing W) x_1) x = 0 ⊢ x = 0 [PROOFSTEP] rw [← forall_dual_apply_eq_zero_iff K x] [GOAL] case right K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ x : { x // x ∈ W } h : ∀ (x_1 : Dual K V₁ ⧸ dualAnnihilator W), ↑(↑(Submodule.dualPairing W) x_1) x = 0 ⊢ ∀ (φ : Dual K { x // x ∈ W }), ↑φ x = 0 [PROOFSTEP] intro φ [GOAL] case right K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ x : { x // x ∈ W } h : ∀ (x_1 : Dual K V₁ ⧸ dualAnnihilator W), ↑(↑(Submodule.dualPairing W) x_1) x = 0 φ : Dual K { x // x ∈ W } ⊢ ↑φ x = 0 [PROOFSTEP] simpa only [Submodule.dualPairing_apply, dualLift_of_subtype] using h (Submodule.Quotient.mk (W.dualLift φ)) [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ ⊢ LinearMap.Nondegenerate (dualCopairing W) [PROOFSTEP] constructor [GOAL] case left K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ ⊢ LinearMap.SeparatingLeft (dualCopairing W) [PROOFSTEP] rw [LinearMap.separatingLeft_iff_ker_eq_bot, dualCopairing_eq] [GOAL] case left K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ ⊢ LinearMap.ker ↑(LinearEquiv.symm (dualQuotEquivDualAnnihilator W)) = ⊥ [PROOFSTEP] apply LinearEquiv.ker [GOAL] case right K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ ⊢ LinearMap.SeparatingRight (dualCopairing W) [PROOFSTEP] rintro ⟨x⟩ [GOAL] case right.mk K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ y✝ : V₁ ⧸ W x : V₁ ⊢ (∀ (x_1 : { x // x ∈ dualAnnihilator W }), ↑(↑(dualCopairing W) x_1) (Quot.mk Setoid.r x) = 0) → Quot.mk Setoid.r x = 0 [PROOFSTEP] simp only [Quotient.quot_mk_eq_mk, dualCopairing_apply, Quotient.mk_eq_zero] [GOAL] case right.mk K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ y✝ : V₁ ⧸ W x : V₁ ⊢ (∀ (x_1 : { x // x ∈ dualAnnihilator W }), ↑x_1 x = 0) → x ∈ W [PROOFSTEP] rw [← forall_mem_dualAnnihilator_apply_eq_zero_iff, SetLike.forall] [GOAL] case right.mk K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : Subspace K V₁ y✝ : V₁ ⧸ W x : V₁ ⊢ (∀ (x_1 : Dual K V₁) (h : x_1 ∈ dualAnnihilator W), ↑{ val := x_1, property := h } x = 0) → ∀ (φ : Dual K V₁), φ ∈ dualAnnihilator W → ↑φ x = 0 [PROOFSTEP] exact id [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ ⊢ dualAnnihilator (W ⊓ W') = dualAnnihilator W ⊔ dualAnnihilator W' [PROOFSTEP] refine' le_antisymm _ (sup_dualAnnihilator_le_inf W W') [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ ⊢ dualAnnihilator (W ⊓ W') ≤ dualAnnihilator W ⊔ dualAnnihilator W' [PROOFSTEP] let F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := (Submodule.mkQ W).prod (Submodule.mkQ W') -- Porting note: broken dot notation lean4#1910 LinearMap.ker [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') ⊢ dualAnnihilator (W ⊓ W') ≤ dualAnnihilator W ⊔ dualAnnihilator W' [PROOFSTEP] have : LinearMap.ker F = W ⊓ W' := by simp only [LinearMap.ker_prod, ker_mkQ] [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') ⊢ LinearMap.ker F = W ⊓ W' [PROOFSTEP] simp only [LinearMap.ker_prod, ker_mkQ] [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' ⊢ dualAnnihilator (W ⊓ W') ≤ dualAnnihilator W ⊔ dualAnnihilator W' [PROOFSTEP] rw [← this, ← LinearMap.range_dualMap_eq_dualAnnihilator_ker] [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' ⊢ LinearMap.range (LinearMap.dualMap F) ≤ dualAnnihilator W ⊔ dualAnnihilator W' [PROOFSTEP] intro φ [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' φ : Dual K V₁ ⊢ φ ∈ LinearMap.range (LinearMap.dualMap F) → φ ∈ dualAnnihilator W ⊔ dualAnnihilator W' [PROOFSTEP] rw [LinearMap.mem_range] [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' φ : Dual K V₁ ⊢ (∃ y, ↑(LinearMap.dualMap F) y = φ) → φ ∈ dualAnnihilator W ⊔ dualAnnihilator W' [PROOFSTEP] rintro ⟨x, rfl⟩ [GOAL] case intro K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' x : Dual K ((V₁ ⧸ W) × V₁ ⧸ W') ⊢ ↑(LinearMap.dualMap F) x ∈ dualAnnihilator W ⊔ dualAnnihilator W' [PROOFSTEP] rw [Submodule.mem_sup] [GOAL] case intro K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' x : Dual K ((V₁ ⧸ W) × V₁ ⧸ W') ⊢ ∃ y, y ∈ dualAnnihilator W ∧ ∃ z, z ∈ dualAnnihilator W' ∧ y + z = ↑(LinearMap.dualMap F) x [PROOFSTEP] obtain ⟨⟨a, b⟩, rfl⟩ := (dualProdDualEquivDual K (V₁ ⧸ W) (V₁ ⧸ W')).surjective x [GOAL] case intro.intro.mk K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' a : Dual K (V₁ ⧸ W) b : Dual K (V₁ ⧸ W') ⊢ ∃ y, y ∈ dualAnnihilator W ∧ ∃ z, z ∈ dualAnnihilator W' ∧ y + z = ↑(LinearMap.dualMap F) (↑(dualProdDualEquivDual K (V₁ ⧸ W) (V₁ ⧸ W')) (a, b)) [PROOFSTEP] obtain ⟨a', rfl⟩ := (dualQuotEquivDualAnnihilator W).symm.surjective a [GOAL] case intro.intro.mk.intro K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' b : Dual K (V₁ ⧸ W') a' : { x // x ∈ dualAnnihilator W } ⊢ ∃ y, y ∈ dualAnnihilator W ∧ ∃ z, z ∈ dualAnnihilator W' ∧ y + z = ↑(LinearMap.dualMap F) (↑(dualProdDualEquivDual K (V₁ ⧸ W) (V₁ ⧸ W')) (↑(LinearEquiv.symm (dualQuotEquivDualAnnihilator W)) a', b)) [PROOFSTEP] obtain ⟨b', rfl⟩ := (dualQuotEquivDualAnnihilator W').symm.surjective b [GOAL] case intro.intro.mk.intro.intro K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' a' : { x // x ∈ dualAnnihilator W } b' : { x // x ∈ dualAnnihilator W' } ⊢ ∃ y, y ∈ dualAnnihilator W ∧ ∃ z, z ∈ dualAnnihilator W' ∧ y + z = ↑(LinearMap.dualMap F) (↑(dualProdDualEquivDual K (V₁ ⧸ W) (V₁ ⧸ W')) (↑(LinearEquiv.symm (dualQuotEquivDualAnnihilator W)) a', ↑(LinearEquiv.symm (dualQuotEquivDualAnnihilator W')) b')) [PROOFSTEP] use a', a'.property, b', b'.property [GOAL] case right K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ F : V₁ →ₗ[K] (V₁ ⧸ W) × V₁ ⧸ W' := LinearMap.prod (mkQ W) (mkQ W') this : LinearMap.ker F = W ⊓ W' a' : { x // x ∈ dualAnnihilator W } b' : { x // x ∈ dualAnnihilator W' } ⊢ ↑a' + ↑b' = ↑(LinearMap.dualMap F) (↑(dualProdDualEquivDual K (V₁ ⧸ W) (V₁ ⧸ W')) (↑(LinearEquiv.symm (dualQuotEquivDualAnnihilator W)) a', ↑(LinearEquiv.symm (dualQuotEquivDualAnnihilator W')) b')) [PROOFSTEP] rfl [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ ι : Type u_1 inst✝ : _root_.Finite ι W : ι → Subspace K V₁ ⊢ dualAnnihilator (⨅ (i : ι), W i) = ⨆ (i : ι), dualAnnihilator (W i) [PROOFSTEP] revert ι [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ ⊢ ∀ {ι : Type u_1} [inst : _root_.Finite ι] (W : ι → Subspace K V₁), dualAnnihilator (⨅ (i : ι), W i) = ⨆ (i : ι), dualAnnihilator (W i) [PROOFSTEP] refine' @Finite.induction_empty_option _ _ _ _ [GOAL] case refine'_1 K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ ⊢ ∀ {α β : Type u_1}, α ≃ β → (∀ (W : α → Subspace K V₁), dualAnnihilator (⨅ (i : α), W i) = ⨆ (i : α), dualAnnihilator (W i)) → ∀ (W : β → Subspace K V₁), dualAnnihilator (⨅ (i : β), W i) = ⨆ (i : β), dualAnnihilator (W i) [PROOFSTEP] intro α β h hyp W [GOAL] case refine'_1 K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ α β : Type u_1 h : α ≃ β hyp : ∀ (W : α → Subspace K V₁), dualAnnihilator (⨅ (i : α), W i) = ⨆ (i : α), dualAnnihilator (W i) W : β → Subspace K V₁ ⊢ dualAnnihilator (⨅ (i : β), W i) = ⨆ (i : β), dualAnnihilator (W i) [PROOFSTEP] rw [← h.iInf_comp, hyp _, ← h.iSup_comp] [GOAL] case refine'_2 K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ ⊢ ∀ (W : PEmpty → Subspace K V₁), dualAnnihilator (⨅ (i : PEmpty), W i) = ⨆ (i : PEmpty), dualAnnihilator (W i) [PROOFSTEP] intro W [GOAL] case refine'_2 K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W : PEmpty → Subspace K V₁ ⊢ dualAnnihilator (⨅ (i : PEmpty), W i) = ⨆ (i : PEmpty), dualAnnihilator (W i) [PROOFSTEP] rw [iSup_of_empty', iInf_of_empty', sInf_empty, sSup_empty, dualAnnihilator_top] [GOAL] case refine'_3 K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ ⊢ ∀ {α : Type u_1} [inst : Fintype α], (∀ (W : α → Subspace K V₁), dualAnnihilator (⨅ (i : α), W i) = ⨆ (i : α), dualAnnihilator (W i)) → ∀ (W : Option α → Subspace K V₁), dualAnnihilator (⨅ (i : Option α), W i) = ⨆ (i : Option α), dualAnnihilator (W i) [PROOFSTEP] intro α _ h W [GOAL] case refine'_3 K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ α : Type u_1 inst✝ : Fintype α h : ∀ (W : α → Subspace K V₁), dualAnnihilator (⨅ (i : α), W i) = ⨆ (i : α), dualAnnihilator (W i) W : Option α → Subspace K V₁ ⊢ dualAnnihilator (⨅ (i : Option α), W i) = ⨆ (i : Option α), dualAnnihilator (W i) [PROOFSTEP] rw [iInf_option, iSup_option, dualAnnihilator_inf_eq, h] [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ h : IsCompl W W' ⊢ IsCompl (dualAnnihilator W) (dualAnnihilator W') [PROOFSTEP] rw [isCompl_iff, disjoint_iff, codisjoint_iff] at h ⊢ [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ h : W ⊓ W' = ⊥ ∧ W ⊔ W' = ⊤ ⊢ dualAnnihilator W ⊓ dualAnnihilator W' = ⊥ ∧ dualAnnihilator W ⊔ dualAnnihilator W' = ⊤ [PROOFSTEP] rw [← dualAnnihilator_inf_eq, ← dualAnnihilator_sup_eq, h.1, h.2, dualAnnihilator_top, dualAnnihilator_bot] [GOAL] K : Type u inst✝⁴ : Field K V₁ : Type v' V₂ : Type v'' inst✝³ : AddCommGroup V₁ inst✝² : Module K V₁ inst✝¹ : AddCommGroup V₂ inst✝ : Module K V₂ W W' : Subspace K V₁ h : W ⊓ W' = ⊥ ∧ W ⊔ W' = ⊤ ⊢ ⊥ = ⊥ ∧ ⊤ = ⊤ [PROOFSTEP] exact ⟨rfl, rfl⟩ [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ ⊢ finrank K { x // x ∈ range (dualMap f) } = finrank K { x // x ∈ range f } [PROOFSTEP] have that := Submodule.finrank_quotient_add_finrank (LinearMap.range f) -- Porting note: Again LinearEquiv.finrank_eq needs help [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K (V₂ ⧸ range f) + finrank K { x // x ∈ range f } = finrank K V₂ ⊢ finrank K { x // x ∈ range (dualMap f) } = finrank K { x // x ∈ range f } [PROOFSTEP] let equiv := (Subspace.quotEquivAnnihilator <| LinearMap.range f) [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K (V₂ ⧸ range f) + finrank K { x // x ∈ range f } = finrank K V₂ equiv : (V₂ ⧸ range f) ≃ₗ[K] { x // x ∈ Submodule.dualAnnihilator (range f) } := Subspace.quotEquivAnnihilator (range f) ⊢ finrank K { x // x ∈ range (dualMap f) } = finrank K { x // x ∈ range f } [PROOFSTEP] have eq := LinearEquiv.finrank_eq (R := K) (M := (V₂ ⧸ range f)) (M₂ := { x // x ∈ Submodule.dualAnnihilator (range f) }) equiv [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K (V₂ ⧸ range f) + finrank K { x // x ∈ range f } = finrank K V₂ equiv : (V₂ ⧸ range f) ≃ₗ[K] { x // x ∈ Submodule.dualAnnihilator (range f) } := Subspace.quotEquivAnnihilator (range f) eq : finrank K (V₂ ⧸ range f) = finrank K { x // x ∈ Submodule.dualAnnihilator (range f) } ⊢ finrank K { x // x ∈ range (dualMap f) } = finrank K { x // x ∈ range f } [PROOFSTEP] rw [eq, ← ker_dualMap_eq_dualAnnihilator_range] at that [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K { x // x ∈ ker (dualMap f) } + finrank K { x // x ∈ range f } = finrank K V₂ equiv : (V₂ ⧸ range f) ≃ₗ[K] { x // x ∈ Submodule.dualAnnihilator (range f) } := Subspace.quotEquivAnnihilator (range f) eq : finrank K (V₂ ⧸ range f) = finrank K { x // x ∈ Submodule.dualAnnihilator (range f) } ⊢ finrank K { x // x ∈ range (dualMap f) } = finrank K { x // x ∈ range f } [PROOFSTEP] conv_rhs at that => rw [← Subspace.dual_finrank_eq] [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K { x // x ∈ ker (dualMap f) } + finrank K { x // x ∈ range f } = finrank K V₂ equiv : (V₂ ⧸ range f) ≃ₗ[K] { x // x ∈ Submodule.dualAnnihilator (range f) } := Subspace.quotEquivAnnihilator (range f) eq : finrank K (V₂ ⧸ range f) = finrank K { x // x ∈ Submodule.dualAnnihilator (range f) } | finrank K V₂ [PROOFSTEP] rw [← Subspace.dual_finrank_eq] [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K { x // x ∈ ker (dualMap f) } + finrank K { x // x ∈ range f } = finrank K V₂ equiv : (V₂ ⧸ range f) ≃ₗ[K] { x // x ∈ Submodule.dualAnnihilator (range f) } := Subspace.quotEquivAnnihilator (range f) eq : finrank K (V₂ ⧸ range f) = finrank K { x // x ∈ Submodule.dualAnnihilator (range f) } | finrank K V₂ [PROOFSTEP] rw [← Subspace.dual_finrank_eq] [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K { x // x ∈ ker (dualMap f) } + finrank K { x // x ∈ range f } = finrank K V₂ equiv : (V₂ ⧸ range f) ≃ₗ[K] { x // x ∈ Submodule.dualAnnihilator (range f) } := Subspace.quotEquivAnnihilator (range f) eq : finrank K (V₂ ⧸ range f) = finrank K { x // x ∈ Submodule.dualAnnihilator (range f) } | finrank K V₂ [PROOFSTEP] rw [← Subspace.dual_finrank_eq] [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K { x // x ∈ ker (dualMap f) } + finrank K { x // x ∈ range f } = finrank K (Dual K V₂) equiv : (V₂ ⧸ range f) ≃ₗ[K] { x // x ∈ Submodule.dualAnnihilator (range f) } := Subspace.quotEquivAnnihilator (range f) eq : finrank K (V₂ ⧸ range f) = finrank K { x // x ∈ Submodule.dualAnnihilator (range f) } ⊢ finrank K { x // x ∈ range (dualMap f) } = finrank K { x // x ∈ range f } [PROOFSTEP] refine' add_left_injective (finrank K <| LinearMap.ker f.dualMap) _ [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K { x // x ∈ ker (dualMap f) } + finrank K { x // x ∈ range f } = finrank K (Dual K V₂) equiv : (V₂ ⧸ range f) ≃ₗ[K] { x // x ∈ Submodule.dualAnnihilator (range f) } := Subspace.quotEquivAnnihilator (range f) eq : finrank K (V₂ ⧸ range f) = finrank K { x // x ∈ Submodule.dualAnnihilator (range f) } ⊢ (fun x => x + finrank K { x // x ∈ ker (dualMap f) }) (finrank K { x // x ∈ range (dualMap f) }) = (fun x => x + finrank K { x // x ∈ ker (dualMap f) }) (finrank K { x // x ∈ range f }) [PROOFSTEP] change _ + _ = _ + _ [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ that : finrank K { x // x ∈ ker (dualMap f) } + finrank K { x // x ∈ range f } = finrank K (Dual K V₂) equiv : (V₂ ⧸ range f) ≃ₗ[K] { x // x ∈ Submodule.dualAnnihilator (range f) } := Subspace.quotEquivAnnihilator (range f) eq : finrank K (V₂ ⧸ range f) = finrank K { x // x ∈ Submodule.dualAnnihilator (range f) } ⊢ finrank K { x // x ∈ range (dualMap f) } + finrank K { x // x ∈ ker (dualMap f) } = finrank K { x // x ∈ range f } + finrank K { x // x ∈ ker (dualMap f) } [PROOFSTEP] rw [finrank_range_add_finrank_ker f.dualMap, add_comm, that] [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ ⊢ Function.Injective ↑(dualMap f) ↔ Function.Surjective ↑f [PROOFSTEP] refine' ⟨_, fun h => dualMap_injective_of_surjective h⟩ [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ ⊢ Function.Injective ↑(dualMap f) → Function.Surjective ↑f [PROOFSTEP] rw [← range_eq_top, ← ker_eq_bot] [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ ⊢ ker (dualMap f) = ⊥ → range f = ⊤ [PROOFSTEP] intro h [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ h : ker (dualMap f) = ⊥ ⊢ range f = ⊤ [PROOFSTEP] apply Submodule.eq_top_of_finrank_eq [GOAL] case h K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ h : ker (dualMap f) = ⊥ ⊢ finrank K { x // x ∈ range f } = finrank K V₂ [PROOFSTEP] rw [← finrank_eq_zero] at h [GOAL] case h K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ h : finrank K { x // x ∈ ker (dualMap f) } = 0 ⊢ finrank K { x // x ∈ range f } = finrank K V₂ [PROOFSTEP] rw [← add_zero (FiniteDimensional.finrank K <| LinearMap.range f), ← h, ← LinearMap.finrank_range_dualMap_eq_finrank_range, LinearMap.finrank_range_add_finrank_ker, Subspace.dual_finrank_eq] [GOAL] K : Type u inst✝⁵ : Field K V₁ : Type v' V₂ : Type v'' inst✝⁴ : AddCommGroup V₁ inst✝³ : Module K V₁ inst✝² : AddCommGroup V₂ inst✝¹ : Module K V₂ inst✝ : FiniteDimensional K V₂ f : V₁ →ₗ[K] V₂ ⊢ Function.Bijective ↑(dualMap f) ↔ Function.Bijective ↑f [PROOFSTEP] simp_rw [Function.Bijective, dualMap_surjective_iff, dualMap_injective_iff, and_comm] [GOAL] R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N f : Dual R (M ⊗[R] N) ⊢ ↑(dualDistribInvOfBasis b c) f = ∑ i : ι, ∑ j : κ, ↑f (↑b i ⊗ₜ[R] ↑c j) • ↑(Basis.dualBasis b) i ⊗ₜ[R] ↑(Basis.dualBasis c) j [PROOFSTEP] simp [dualDistribInvOfBasis] [GOAL] R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N ⊢ comp (dualDistrib R M N) (dualDistribInvOfBasis b c) = LinearMap.id [PROOFSTEP] apply (b.tensorProduct c).dualBasis.ext [GOAL] R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N ⊢ ∀ (i : ι × κ), ↑(comp (dualDistrib R M N) (dualDistribInvOfBasis b c)) (↑(Basis.dualBasis (Basis.tensorProduct b c)) i) = ↑LinearMap.id (↑(Basis.dualBasis (Basis.tensorProduct b c)) i) [PROOFSTEP] rintro ⟨i, j⟩ [GOAL] case mk R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ↑(comp (dualDistrib R M N) (dualDistribInvOfBasis b c)) (↑(Basis.dualBasis (Basis.tensorProduct b c)) (i, j)) = ↑LinearMap.id (↑(Basis.dualBasis (Basis.tensorProduct b c)) (i, j)) [PROOFSTEP] apply (b.tensorProduct c).ext [GOAL] case mk R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∀ (i_1 : ι × κ), ↑(↑(comp (dualDistrib R M N) (dualDistribInvOfBasis b c)) (↑(Basis.dualBasis (Basis.tensorProduct b c)) (i, j))) (↑(Basis.tensorProduct b c) i_1) = ↑(↑LinearMap.id (↑(Basis.dualBasis (Basis.tensorProduct b c)) (i, j))) (↑(Basis.tensorProduct b c) i_1) [PROOFSTEP] rintro ⟨i', j'⟩ [GOAL] case mk.mk R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ↑(↑(comp (dualDistrib R M N) (dualDistribInvOfBasis b c)) (↑(Basis.dualBasis (Basis.tensorProduct b c)) (i, j))) (↑(Basis.tensorProduct b c) (i', j')) = ↑(↑LinearMap.id (↑(Basis.dualBasis (Basis.tensorProduct b c)) (i, j))) (↑(Basis.tensorProduct b c) (i', j')) [PROOFSTEP] simp only [dualDistrib, Basis.coe_dualBasis, coe_comp, Function.comp_apply, dualDistribInvOfBasis_apply, Basis.coord_apply, Basis.tensorProduct_repr_tmul_apply, Basis.repr_self, ne_eq, LinearMap.map_sum, map_smul, homTensorHomMap_apply, compRight_apply, Basis.tensorProduct_apply, coeFn_sum, Finset.sum_apply, smul_apply, LinearEquiv.coe_coe, map_tmul, lid_tmul, smul_eq_mul, id_coe, id_eq] [GOAL] case mk.mk R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ∑ x : ι, ∑ x_1 : κ, ↑(Finsupp.single x 1) i * ↑(Finsupp.single x_1 1) j * (↑(Finsupp.single i' 1) x * ↑(Finsupp.single j' 1) x_1) = ↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) j [PROOFSTEP] rw [Finset.sum_eq_single i, Finset.sum_eq_single j] [GOAL] case mk.mk R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) j) = ↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) j case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ∀ (b : κ), b ∈ Finset.univ → b ≠ j → ↑(Finsupp.single i 1) i * ↑(Finsupp.single b 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) b) = 0 case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ¬j ∈ Finset.univ → ↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) j) = 0 case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ∀ (b : ι), b ∈ Finset.univ → b ≠ i → ∑ x : κ, ↑(Finsupp.single b 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) b * ↑(Finsupp.single j' 1) x) = 0 case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ¬i ∈ Finset.univ → ∑ x : κ, ↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) x) = 0 [PROOFSTEP] simp [GOAL] case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ∀ (b : κ), b ∈ Finset.univ → b ≠ j → ↑(Finsupp.single i 1) i * ↑(Finsupp.single b 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) b) = 0 case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ¬j ∈ Finset.univ → ↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) j) = 0 case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ∀ (b : ι), b ∈ Finset.univ → b ≠ i → ∑ x : κ, ↑(Finsupp.single b 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) b * ↑(Finsupp.single j' 1) x) = 0 case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ¬i ∈ Finset.univ → ∑ x : κ, ↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) x) = 0 [PROOFSTEP] all_goals {intros; simp [*] at * } -- Porting note: introduced to help with timeout in dualDistribEquivOfBasis [GOAL] case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ∀ (b : κ), b ∈ Finset.univ → b ≠ j → ↑(Finsupp.single i 1) i * ↑(Finsupp.single b 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) b) = 0 [PROOFSTEP] {intros; simp [*] at * } -- Porting note: introduced to help with timeout in dualDistribEquivOfBasis [GOAL] case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ∀ (b : κ), b ∈ Finset.univ → b ≠ j → ↑(Finsupp.single i 1) i * ↑(Finsupp.single b 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) b) = 0 [PROOFSTEP] intros [GOAL] case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' b✝ : κ a✝¹ : b✝ ∈ Finset.univ a✝ : b✝ ≠ j ⊢ ↑(Finsupp.single i 1) i * ↑(Finsupp.single b✝ 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) b✝) = 0 [PROOFSTEP] simp [*] at * [GOAL] case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ¬j ∈ Finset.univ → ↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) j) = 0 [PROOFSTEP] {intros; simp [*] at * } -- Porting note: introduced to help with timeout in dualDistribEquivOfBasis [GOAL] case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ¬j ∈ Finset.univ → ↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) j) = 0 [PROOFSTEP] intros [GOAL] case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ a✝ : ¬j ∈ Finset.univ ⊢ ↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) j) = 0 [PROOFSTEP] simp [*] at * [GOAL] case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ∀ (b : ι), b ∈ Finset.univ → b ≠ i → ∑ x : κ, ↑(Finsupp.single b 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) b * ↑(Finsupp.single j' 1) x) = 0 [PROOFSTEP] {intros; simp [*] at * } -- Porting note: introduced to help with timeout in dualDistribEquivOfBasis [GOAL] case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ∀ (b : ι), b ∈ Finset.univ → b ≠ i → ∑ x : κ, ↑(Finsupp.single b 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) b * ↑(Finsupp.single j' 1) x) = 0 [PROOFSTEP] intros [GOAL] case mk.mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ b✝ : ι a✝¹ : b✝ ∈ Finset.univ a✝ : b✝ ≠ i ⊢ ∑ x : κ, ↑(Finsupp.single b✝ 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) b✝ * ↑(Finsupp.single j' 1) x) = 0 [PROOFSTEP] simp [*] at * [GOAL] case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ¬i ∈ Finset.univ → ∑ x : κ, ↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) x) = 0 [PROOFSTEP] {intros; simp [*] at * } -- Porting note: introduced to help with timeout in dualDistribEquivOfBasis [GOAL] case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ ⊢ ¬i ∈ Finset.univ → ∑ x : κ, ↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) x) = 0 [PROOFSTEP] intros [GOAL] case mk.mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ i' : ι j' : κ a✝ : ¬i ∈ Finset.univ ⊢ ∑ x : κ, ↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j * (↑(Finsupp.single i' 1) i * ↑(Finsupp.single j' 1) x) = 0 [PROOFSTEP] simp [*] at * [GOAL] R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N ⊢ comp (dualDistribInvOfBasis b c) (dualDistrib R M N) = LinearMap.id [PROOFSTEP] apply (b.dualBasis.tensorProduct c.dualBasis).ext [GOAL] R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N ⊢ ∀ (i : ι × κ), ↑(comp (dualDistribInvOfBasis b c) (dualDistrib R M N)) (↑(Basis.tensorProduct (Basis.dualBasis b) (Basis.dualBasis c)) i) = ↑LinearMap.id (↑(Basis.tensorProduct (Basis.dualBasis b) (Basis.dualBasis c)) i) [PROOFSTEP] rintro ⟨i, j⟩ [GOAL] case mk R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ↑(comp (dualDistribInvOfBasis b c) (dualDistrib R M N)) (↑(Basis.tensorProduct (Basis.dualBasis b) (Basis.dualBasis c)) (i, j)) = ↑LinearMap.id (↑(Basis.tensorProduct (Basis.dualBasis b) (Basis.dualBasis c)) (i, j)) [PROOFSTEP] simp only [Basis.tensorProduct_apply, Basis.coe_dualBasis, coe_comp, Function.comp_apply, dualDistribInvOfBasis_apply, dualDistrib_apply, Basis.coord_apply, Basis.repr_self, ne_eq, id_coe, id_eq] [GOAL] case mk R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∑ x : ι, ∑ x_1 : κ, (↑(Finsupp.single x 1) i * ↑(Finsupp.single x_1 1) j) • Basis.coord b x ⊗ₜ[R] Basis.coord c x_1 = Basis.coord b i ⊗ₜ[R] Basis.coord c j [PROOFSTEP] rw [Finset.sum_eq_single i, Finset.sum_eq_single j] [GOAL] case mk R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ (↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c j = Basis.coord b i ⊗ₜ[R] Basis.coord c j case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∀ (b_1 : κ), b_1 ∈ Finset.univ → b_1 ≠ j → (↑(Finsupp.single i 1) i * ↑(Finsupp.single b_1 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c b_1 = 0 case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ¬j ∈ Finset.univ → (↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c j = 0 case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∀ (b_1 : ι), b_1 ∈ Finset.univ → b_1 ≠ i → ∑ x : κ, (↑(Finsupp.single b_1 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b b_1 ⊗ₜ[R] Basis.coord c x = 0 case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ¬i ∈ Finset.univ → ∑ x : κ, (↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c x = 0 [PROOFSTEP] simp [GOAL] case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∀ (b_1 : κ), b_1 ∈ Finset.univ → b_1 ≠ j → (↑(Finsupp.single i 1) i * ↑(Finsupp.single b_1 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c b_1 = 0 case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ¬j ∈ Finset.univ → (↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c j = 0 case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∀ (b_1 : ι), b_1 ∈ Finset.univ → b_1 ≠ i → ∑ x : κ, (↑(Finsupp.single b_1 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b b_1 ⊗ₜ[R] Basis.coord c x = 0 case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ¬i ∈ Finset.univ → ∑ x : κ, (↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c x = 0 [PROOFSTEP] all_goals {intros; simp [*] at * } [GOAL] case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∀ (b_1 : κ), b_1 ∈ Finset.univ → b_1 ≠ j → (↑(Finsupp.single i 1) i * ↑(Finsupp.single b_1 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c b_1 = 0 [PROOFSTEP] {intros; simp [*] at * } [GOAL] case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∀ (b_1 : κ), b_1 ∈ Finset.univ → b_1 ≠ j → (↑(Finsupp.single i 1) i * ↑(Finsupp.single b_1 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c b_1 = 0 [PROOFSTEP] intros [GOAL] case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j b✝ : κ a✝¹ : b✝ ∈ Finset.univ a✝ : b✝ ≠ j ⊢ (↑(Finsupp.single i 1) i * ↑(Finsupp.single b✝ 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c b✝ = 0 [PROOFSTEP] simp [*] at * [GOAL] case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ¬j ∈ Finset.univ → (↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c j = 0 [PROOFSTEP] {intros; simp [*] at * } [GOAL] case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ¬j ∈ Finset.univ → (↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c j = 0 [PROOFSTEP] intros [GOAL] case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ a✝ : ¬j ∈ Finset.univ ⊢ (↑(Finsupp.single i 1) i * ↑(Finsupp.single j 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c j = 0 [PROOFSTEP] simp [*] at * [GOAL] case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∀ (b_1 : ι), b_1 ∈ Finset.univ → b_1 ≠ i → ∑ x : κ, (↑(Finsupp.single b_1 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b b_1 ⊗ₜ[R] Basis.coord c x = 0 [PROOFSTEP] {intros; simp [*] at * } [GOAL] case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ∀ (b_1 : ι), b_1 ∈ Finset.univ → b_1 ≠ i → ∑ x : κ, (↑(Finsupp.single b_1 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b b_1 ⊗ₜ[R] Basis.coord c x = 0 [PROOFSTEP] intros [GOAL] case mk.h₀ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ b✝ : ι a✝¹ : b✝ ∈ Finset.univ a✝ : b✝ ≠ i ⊢ ∑ x : κ, (↑(Finsupp.single b✝ 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b b✝ ⊗ₜ[R] Basis.coord c x = 0 [PROOFSTEP] simp [*] at * [GOAL] case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ¬i ∈ Finset.univ → ∑ x : κ, (↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c x = 0 [PROOFSTEP] {intros; simp [*] at * } [GOAL] case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ ⊢ ¬i ∈ Finset.univ → ∑ x : κ, (↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c x = 0 [PROOFSTEP] intros [GOAL] case mk.h₁ R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N i : ι j : κ a✝ : ¬i ∈ Finset.univ ⊢ ∑ x : κ, (↑(Finsupp.single i 1) i * ↑(Finsupp.single x 1) j) • Basis.coord b i ⊗ₜ[R] Basis.coord c x = 0 [PROOFSTEP] simp [*] at * [GOAL] R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N ⊢ Dual R M ⊗[R] Dual R N ≃ₗ[R] Dual R (M ⊗[R] N) [PROOFSTEP] refine' LinearEquiv.ofLinear (dualDistrib R M N) (dualDistribInvOfBasis b c) _ _ [GOAL] case refine'_1 R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N ⊢ comp (dualDistrib R M N) (dualDistribInvOfBasis b c) = LinearMap.id [PROOFSTEP] exact dualDistrib_dualDistribInvOfBasis_left_inverse _ _ [GOAL] case refine'_2 R : Type u_1 A : Type u_2 M : Type u_3 N : Type u_4 ι : Type u_5 κ : Type u_6 inst✝⁸ : DecidableEq ι inst✝⁷ : DecidableEq κ inst✝⁶ : Fintype ι inst✝⁵ : Fintype κ inst✝⁴ : CommRing R inst✝³ : AddCommGroup M inst✝² : AddCommGroup N inst✝¹ : Module R M inst✝ : Module R N b : Basis ι R M c : Basis κ R N ⊢ comp (dualDistribInvOfBasis b c) (dualDistrib R M N) = LinearMap.id [PROOFSTEP] exact dualDistrib_dualDistribInvOfBasis_right_inverse _ _
import MyNat.Power import MyNat.Addition -- add_zero import MultiplicationWorld.Level2 -- mul_one import MultiplicationWorld.Level5 -- mul_assoc namespace MyNat open MyNat /-! # Power World ## Level 5: `pow_add` ## Lemma For all naturals `a`, `m`, `n`, we have `a^(m + n) = a ^ m a ^ n`. -/ lemma pow_add (a m n : MyNat) : a ^ (m + n) = a ^ m * a ^ n := by induction n with | zero => rw [zero_is_0] rw [add_zero] rw [pow_zero] rw [mul_one] | succ n ih => rw [add_succ] rw [pow_succ] rw [pow_succ] rw [ih] rw [mul_assoc] /-! Remember you can combine all the `rw` rules into one with `rw [add_succ, pow_succ, pow_succ, ih, mul_assoc]` but we have broken it out here so you can more easily see all the intermediate goal states. Next up [Level 6](./Level6.lean.md) -/
State Before: α : Type u_1 inst✝³ : Group α s t : Subgroup α H : Type u_2 inst✝² : Group H inst✝¹ : Fintype α inst✝ : Fintype H f : α →* H hf : Injective ↑f ⊢ card α ∣ card H State After: no goals Tactic: classical calc card α = card (f.range : Subgroup H) := card_congr (Equiv.ofInjective f hf) _ ∣ card H := card_subgroup_dvd_card _ State Before: α : Type u_1 inst✝³ : Group α s t : Subgroup α H : Type u_2 inst✝² : Group H inst✝¹ : Fintype α inst✝ : Fintype H f : α →* H hf : Injective ↑f ⊢ card α ∣ card H State After: no goals Tactic: calc card α = card (f.range : Subgroup H) := card_congr (Equiv.ofInjective f hf) _ ∣ card H := card_subgroup_dvd_card _
-- binary search trees (not balanced) open import bool open import bool-thms2 open import eq open import maybe open import product open import product-thms open import bool-relations using (transitive ; total) module z05-01-bst (A : Set) -- type of elements (_≤A_ : A → A → 𝔹) -- ordering function (≤A-trans : transitive _≤A_) -- proof of transitivity of given ordering (≤A-total : total _≤A_) -- proof of totality of given ordering where {- IAL - relations.agda - models binary relation on A as functions from A to A to Set - bool-relations.agda - models binary realtion on A as functions from A to A to 𝔹 Cannot use A→A→Set relations here because code cannot manipulate types. But code can pattern match on values of type 𝔹, so boolean relations more useful. -} open import bool-relations _≤A_ hiding (transitive ; total) open import minmax _≤A_ ≤A-trans ≤A-total -- able to store values in bounds 'l' and 'u' -- l(ower) bound -- | u(upper) bound -- v v data bst : A → A → Set where bst-leaf : ∀ {l u : A} → l ≤A u ≡ tt → bst l u bst-node : ∀ {l l' u' u : A} → (d : A) -- value stored in this node → bst l' d -- left subtree of values ≤ stored value → bst d u' -- right subtree of values ≥ stored value → l ≤A l' ≡ tt → u' ≤A u ≡ tt → bst l u ------------------------------------------------------------------------------ bst-search : ∀ {l u : A} → (d : A) -- find a node that is isomorphic (_=A_) to d → bst l u → maybe (Σ A (λ d' → d iso𝔹 d' ≡ tt)) -- return that node or nothing bst-search d (bst-leaf _) = nothing -- could return proof not in tree instead -- compare given element with stored element bst-search d (bst-node d' L R _ _) with keep (d ≤A d') -- compare given element with stored element (other direction) bst-search d (bst-node d' L R _ _) | tt , p1 with keep (d' ≤A d) -- both are true implying iso, so return that element and proof bst-search d (bst-node d' L R _ _) | tt , p1 | tt , p2 = just (d' , iso𝔹-intro p1 p2) -- if either is false then search the appropriate branch bst-search d (bst-node d' L R _ _) | tt , p1 | ff , p2 = bst-search d L -- search in left bst-search d (bst-node d' L R _ _) | ff , p1 = bst-search d R -- search in right ------------------------------------------------------------------------------ -- change the lower bound from l' to l bst-dec-lb : ∀ {l l' u' : A} → bst l' u' → l ≤A l' ≡ tt → bst l u' bst-dec-lb (bst-leaf p) q = bst-leaf (≤A-trans q p) bst-dec-lb (bst-node d L R p1 p2) q = bst-node d L R (≤A-trans q p1) p2 -- change the upper bound from u' to u bst-inc-ub : ∀ {l' u' u : A} → bst l' u' → u' ≤A u ≡ tt → bst l' u bst-inc-ub (bst-leaf p) q = bst-leaf (≤A-trans p q) bst-inc-ub (bst-node d L R p1 p2) q = bst-node d L R p1 (≤A-trans p2 q) bst-insert : ∀{l u : A} → (d : A) -- insert 'd' → bst l u -- into this 'bst' → bst (min d l) (max d u) -- type might change bst-insert d (bst-leaf p) = bst-node d (bst-leaf ≤A-refl) (bst-leaf ≤A-refl) min-≤1 max-≤1 bst-insert d (bst-node d' L R p1 p2) with keep (d ≤A d') bst-insert d (bst-node d' L R p1 p2) | tt , p with bst-insert d L bst-insert d (bst-node d' L R p1 p2) | tt , p | L' rewrite p = bst-node d' L' (bst-inc-ub R (≤A-trans p2 max-≤2)) (min2-mono p1) ≤A-refl bst-insert d (bst-node d' L R p1 p2) | ff , p with bst-insert d R bst-insert d (bst-node d' L R p1 p2) | ff , p | R' rewrite p = bst-node d' (bst-dec-lb L p1) R' min-≤2 (max2-mono p2)
//---------------------------------------------------------------------------// // Copyright (c) 2013 Kyle Lutz <[email protected]> // // Distributed under the Boost Software License, Version 1.0 // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // // See http://kylelutz.github.com/compute for more information. //---------------------------------------------------------------------------// #ifndef BOOST_COMPUTE_PLATFORM_HPP #define BOOST_COMPUTE_PLATFORM_HPP #include <string> #include <vector> #include <boost/range/algorithm.hpp> #include <boost/algorithm/string.hpp> #include <boost/compute/cl.hpp> #include <boost/compute/device.hpp> #include <boost/compute/detail/get_object_info.hpp> namespace boost { namespace compute { /// \class platform /// \brief A compute platform. /// /// The platform class provides an interface to an OpenCL platform. /// /// To obtain a list of all platforms on the system use the /// system::platforms() method. /// /// \see device, context class platform { public: /// Creates a new platform object for \p id. explicit platform(cl_platform_id id) : m_platform(id) { } /// Creates a new platform as a copy of \p other. platform(const platform &other) : m_platform(other.m_platform) { } /// Copies the platform id from \p other. platform& operator=(const platform &other) { if(this != &other){ m_platform = other.m_platform; } return *this; } /// Destroys the platform object. ~platform() { } /// Returns the ID of the platform. cl_platform_id id() const { return m_platform; } /// Returns the name of the platform. std::string name() const { return get_info<std::string>(CL_PLATFORM_NAME); } /// Returns the name of the vendor for the platform. std::string vendor() const { return get_info<std::string>(CL_PLATFORM_VENDOR); } /// Returns the profile string for the platform. std::string profile() const { return get_info<std::string>(CL_PLATFORM_PROFILE); } /// Returns the version string for the platform. std::string version() const { return get_info<std::string>(CL_PLATFORM_VERSION); } /// Returns a list of extensions supported by the platform. std::vector<std::string> extensions() const { std::string extensions_string = get_info<std::string>(CL_PLATFORM_EXTENSIONS); std::vector<std::string> extensions_vector; boost::split(extensions_vector, extensions_string, boost::is_any_of("\t "), boost::token_compress_on); return extensions_vector; } /// Returns \c true if the platform supports the extension with /// \p name. bool supports_extension(const std::string &name) const { const std::vector<std::string> extensions = this->extensions(); return boost::find(extensions, name) != extensions.end(); } /// Returns a list of devices on the platform. std::vector<device> devices(cl_device_type type = CL_DEVICE_TYPE_ALL) const { size_t count = device_count(type); if(count == 0){ // no devices for this platform return std::vector<device>(); } std::vector<cl_device_id> device_ids(count); cl_int ret = clGetDeviceIDs(m_platform, type, static_cast<cl_uint>(count), &device_ids[0], 0); if(ret != CL_SUCCESS){ BOOST_THROW_EXCEPTION(opencl_error(ret)); } std::vector<device> devices; for(cl_uint i = 0; i < count; i++){ devices.push_back(device(device_ids[i])); } return devices; } /// Returns the number of devices on the platform. size_t device_count(cl_device_type type = CL_DEVICE_TYPE_ALL) const { cl_uint count = 0; cl_int ret = clGetDeviceIDs(m_platform, type, 0, 0, &count); if(ret != CL_SUCCESS){ if(ret == CL_DEVICE_NOT_FOUND){ // no devices for this platform return 0; } else { // something else went wrong BOOST_THROW_EXCEPTION(opencl_error(ret)); } } return count; } /// Returns information about the platform. /// /// \see_opencl_ref{clGetPlatformInfo} template<class T> T get_info(cl_platform_info info) const { return detail::get_object_info<T>(clGetPlatformInfo, m_platform, info); } /// \overload template<int Enum> typename detail::get_object_info_type<platform, Enum>::type get_info() const; /// Returns the address of the \p function_name extension /// function. Returns \c 0 if \p function_name is invalid. void* get_extension_function_address(const char *function_name) const { #ifdef CL_VERSION_1_2 return clGetExtensionFunctionAddressForPlatform(m_platform, function_name); #else return clGetExtensionFunctionAddress(function_name); #endif } /// Requests that the platform unload any compiler resources. void unload_compiler() { #ifdef CL_VERSION_1_2 clUnloadPlatformCompiler(m_platform); #else clUnloadCompiler(); #endif } /// Returns \c true if the platform is the same at \p other. bool operator==(const platform &other) const { return m_platform == other.m_platform; } /// Returns \c true if the platform is different from \p other. bool operator!=(const platform &other) const { return m_platform != other.m_platform; } private: cl_platform_id m_platform; }; /// \internal_ define get_info() specializations for platform BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(platform, ((std::string, CL_PLATFORM_PROFILE)) ((std::string, CL_PLATFORM_VERSION)) ((std::string, CL_PLATFORM_NAME)) ((std::string, CL_PLATFORM_VENDOR)) ((std::string, CL_PLATFORM_EXTENSIONS)) ) } // end compute namespace } // end boost namespace #endif // BOOST_COMPUTE_PLATFORM_HPP
[STATEMENT] lemma disc_opposite_ocircline [simp]: shows "disc (opposite_ocircline H) = disc_compl H" [PROOF STATE] proof (prove) goal (1 subgoal): 1. disc (opposite_ocircline H) = disc_compl H [PROOF STEP] using disc_compl_opposite_ocircline[of "opposite_ocircline H"] [PROOF STATE] proof (prove) using this: disc_compl (opposite_ocircline (opposite_ocircline H)) = disc (opposite_ocircline H) goal (1 subgoal): 1. disc (opposite_ocircline H) = disc_compl H [PROOF STEP] by simp
(* *********************************************************************) (* *) (* The CertiKOS Certified Kit Operating System *) (* *) (* The FLINT Group, Yale University *) (* *) (* Copyright The FLINT Group, Yale University. All rights reserved. *) (* This file is distributed under the terms of the Yale University *) (* Non-Commercial License Agreement. *) (* *) (* *********************************************************************) Require Import LinkSourceTemplate. Require Import PThread. Require Import PThreadCSource. Require Import CDataTypes. Definition PIPCIntro_module: link_module := {| lm_cfun := lcf get_sync_chan_to f_get_sync_chan_to :: lcf get_sync_chan_paddr f_get_sync_chan_paddr :: lcf get_sync_chan_count f_get_sync_chan_count :: lcf set_sync_chan_to f_set_sync_chan_to :: lcf set_sync_chan_paddr f_set_sync_chan_paddr :: lcf set_sync_chan_count f_set_sync_chan_count :: lcf init_sync_chan f_init_sync_chan :: lcf get_kernel_pa f_get_kernel_pa :: nil; lm_asmfun := nil; lm_gvar := lgv SYNCCHPOOL_LOC syncchpool_loc_type :: nil |}. Definition PIPCIntro_impl `{CompCertiKOS} `{RealParams} := link_impl PIPCIntro_module pthread.
module AI.GeneticAlgorithm ( Genome , Individual , Population , individualGenome , individualFitness , mutate , proportionalSelection , getBasePopulation , evolve , evolves , bestAverageWorst ) where import AI.NeuralNetwork as NN import Control.Lens import Control.Monad.State import Control.Parallel.Strategies import Data.Function import Data.Functor.Identity import Data.Maybe import Data.Random.Normal import qualified Data.Vector as V import qualified Data.Vector.Generic as VG import Numeric.LinearAlgebra import System.Random type Genome = NN.Network -- An individual with a genome and fitness data Individual a = Individual Genome a deriving (Eq, Show) type Population a = V.Vector (Individual a) mut :: Double -> Double -> Double -> State StdGen Double mut rate amount val = do rRate <- state random if rRate < rate then fmap (\x -> val + x * amount) (state normal) else return val toIndividual :: (Genome -> a) -> Genome -> Individual a toIndividual fitfunc genome = Individual genome (fitfunc genome) toPopulation :: (Genome -> a) -> V.Vector Genome -> V.Vector (Individual a) toPopulation fitfunc genomes = let pop = V.map (toIndividual fitfunc) genomes in pop `using` parTraversable rseq individualGenome :: Individual a -> Genome individualGenome (Individual g _) = g individualFitness :: Individual a -> a individualFitness (Individual _ f) = f mutate :: Double -> Double -> Genome -> State StdGen Genome mutate rate amount genome = do let cmut = mut rate amount newBiases <- mapM (VG.mapM cmut) (genome^.biases) newWeights <- mapM (mapMatrixM cmut) (genome^.weights) let newNN = execState (biases .= newBiases >> weights .= newWeights) genome return newNN proportionalSelection :: (Random a, Ord a, Num a, NFData a) => Population a -> State StdGen (Population a) proportionalSelection pop = let fitness = individualFitness <$> pop accFit = V.scanl1 (+) fitness choose p = snd $ fromJust $ V.find (\t -> p <= fst t) (V.zip accFit pop) in forM pop $ \_ -> do p <- state $ randomR (0, V.last accFit) return $ choose p getBasePopulation :: (Genome -> a) -> State StdGen Genome -> Int -> State StdGen (Population a) getBasePopulation fitfunc genomeGen popSize = toPopulation fitfunc <$> V.replicateM popSize genomeGen evolve :: (Genome -> Double) -> (Genome -> State StdGen Genome) -> Population Double -> State StdGen (Population Double) evolve fitfunc mutfunc pop = do selected <- proportionalSelection pop mutated <- mapM (\(Individual g _) -> mutfunc g) selected return $ toPopulation fitfunc mutated evolves :: Int -> Int -> State StdGen Genome -> (Genome -> Double) -> (Genome -> State StdGen Genome) -> State StdGen [Population Double] evolves generations popSize genomeGen fitfunc mutfunc = do basePop <- getBasePopulation fitfunc genomeGen popSize let evofunc = evolve fitfunc mutfunc evolutions <- V.iterateNM generations evofunc basePop return $ V.toList evolutions bestAverageWorst :: (Fractional a, Ord a) => [Population a] -> [(Individual a, a, Individual a)] bestAverageWorst = reverse . foldl (\acc pop -> let fitness = individualFitness <$> pop best = V.maximumBy (compare `on` individualFitness) pop avgFit = sum fitness / fromIntegral (V.length fitness) worst = V.minimumBy (compare `on` individualFitness) pop in (best, avgFit, worst) : acc) [] mapMatrixM :: (Element a, Element b, Monad m) => (a -> m b) -> Matrix a -> m (Matrix b) mapMatrixM f m = let ll = toLists m mmM = mapM . mapM in fromLists <$> mmM f ll
module TestDivideAtMean using Random using TapirBenchmarks using Test using Statistics tests = [ (label = "1:10", xs = 1:10, smaller = 1:5, larger = 6:10), (label = "10:-1:1", xs = 10:-1:1, smaller = 6:10, larger = 1:5), let xs = shuffle(1:10) m = mean(xs) ( label = "shuffle(1:10)", xs = xs, smaller = findall(xs .<= m), larger = findall(xs .> m), ) end, ] @testset "$(t.label)" for t in tests @testset for f in [divide_at_mean_seq, divide_at_mean_threads, divide_at_mean_tapir] smaller, larger = f(t.xs) @test smaller == t.smaller @test larger == t.larger end end end
import Mathbin.Data.Finsupp.Basic section inductive Vars : Type | α : Vars | β : Vars | γ : Vars | δ : Vars instance : DecidableEq Vars := fun a b => match a, b with | .α, .α => isTrue rfl | .α, .β => isFalse (fun h => Vars.noConfusion h) | .α, .γ => isFalse (fun h => Vars.noConfusion h) | .α, .δ => isFalse (fun h => Vars.noConfusion h) | .β, .α => isFalse (fun h => Vars.noConfusion h) | .β, .β => isTrue rfl | .β, .γ => isFalse (fun h => Vars.noConfusion h) | .β, .δ => isFalse (fun h => Vars.noConfusion h) | .δ, .α => isFalse (fun h => Vars.noConfusion h) | .δ, .β => isFalse (fun h => Vars.noConfusion h) | .δ, .γ => isFalse (fun h => Vars.noConfusion h) | .δ, .δ => isTrue rfl | .γ, .δ => isFalse (fun h => Vars.noConfusion h) | .γ, .γ => isTrue rfl | .γ, .β => isFalse (fun h => Vars.noConfusion h) | .γ, .α => isFalse (fun h => Vars.noConfusion h) lemma finsupp_vars_eq_ext (f g : Vars →₀ ℕ) : (f = g) ↔ (f Vars.α = g Vars.α ∧ f Vars.β = g Vars.β ∧ f Vars.γ = g Vars.γ ∧ f Vars.δ = g Vars.δ) := by rw [Finsupp.ext_iff] apply Iff.intro · intro h apply And.intro exact h Vars.α apply And.intro exact h Vars.β apply And.intro exact h Vars.γ exact h Vars.δ · intro h intro a induction a apply And.left h apply And.left (And.right h) apply And.left (And.right (And.right h)) apply And.right (And.right (And.right h))
function chebyshev_polynomial_test09 ( ) %*****************************************************************************80 % %% CHEBYSHEV_POLYNOMIAL_TEST09 compares a function and projection over [-1,+1]. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 13 April 2012 % % Author: % % John Burkardt % fprintf ( 1, '\n' ); fprintf ( 1, 'CHEBYSHEV_POLYNOMIAL_TEST09:\n' ); fprintf ( 1, ' T_PROJECT_COEFFICIENTS computes the Chebyshev interpolant C(F)(N,X)\n' ); fprintf ( 1, ' of a function F(X) defined over [-1,+1].\n' ); fprintf ( 1, ' T_PROJECT_VALUE evaluates that projection.\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' Compute projections of order N to exp(x) over [-1,+1],\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' N Max||F(X)-C(F)(N,X)||\n' ); fprintf ( 1, '\n' ); for n = 0 : 10 c = t_project_coefficients ( n, @exp ); m = 101; x = ( linspace ( -1.0, +1.0, m ) )'; v = t_project_value ( m, n, x, c ); r = v - exp ( x ); fprintf ( 1, ' %2d %12.4g\n', n, max ( abs ( r ) ) ); end return end
[STATEMENT] lemma is_empty_Set [code]: "Set.is_empty (Set t) = RBT.is_empty t" [PROOF STATE] proof (prove) goal (1 subgoal): 1. Set.is_empty (Set t) = RBT.is_empty t [PROOF STEP] unfolding Set.is_empty_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. (Set t = {}) = RBT.is_empty t [PROOF STEP] by (auto simp: fun_eq_iff Set_def intro: lookup_empty_empty[THEN iffD1])
\section{Conclusions}% % \begin{frame}% \frametitle{Conclusions}% \begin{itemize}% \item I have presented an initial version of the evaluator GUI component of the \optimizationBenchmarking\ framework% \item<2-> It can already load and evaluate performance data from \emph{your} optimization or Machine Learning algorithm% \item<3-> It can help \emph{you} to understand what the strengths and weaknesses of \emph{your} algorithm are% \item<4-> It produces figures ready for use in \emph{your} publication% \item<5-> {\dots}and these figures are optimized (size, fonts) for the journal or conference \emph{you} want to submit to.% \end{itemize}% %% \end{frame} % % \begin{frame}% \frametitle{Future Work}% \begin{itemize}% \item We will add more evaluation modules, to reach the power of \tspSuite\expandafter\scitep{\tspSuiteReferences}, e.g., add automated algorithm ranking% \item<2-> We will publicize the use of \optimizationBenchmarking\ to our colleagues, e.g., for use in competitions% \item<3-> We want to position our tool as a central quality control utility for optimization and Machine Learning applications% \item<4-> We will improve the tool and add features based on feedback% \end{itemize}% %% \end{frame}%
################################################################################################################## #### Purpose: Final Project - Classification - KKNN #### Group: Ravi P., Derek P., Aneesh K., Ninad K. #### Date: 11/28/2018 #### Comment: #### setwd("~/Stevens/Fall2018/CS513_Knowledge_Discovery/Final Project/Classification") #### ################################################################################################################## setwd("~/Stevens/Fall2018/CS513_Knowledge_Discovery/Final Project/Classification") #### 0. Clean environment #### rm(list = ls()) #### 1. Import libraries and datasets #### library(kknn) df_train <- read.csv("./data/train_new.csv") df_test <- read.csv("./data/test_new.csv") #### 2. Remove unwanted column #### df_train <- df_train[,-1] df_test <- df_test[,-1] summary(df_test) df_train$SimpleColor <- as.integer(df_train$SimpleColor) df_test$SimpleColor<- as.integer(df_test$SimpleColor) df_k1 <- kknn(OutcomeType~ AnimalType + AgeinDays + HasName + IsNeutered + IsMix + Gender + SimpleColor, df_train, df_test, k = 1) fit <- fitted(df_k1) table(df_test$OutcomeType, fit) wrong<- (df_test[,2] != fit) rate<-sum(wrong)/length(wrong) print(rate) #### 3. KKNN Test and Error Rate #### for(i in c(1,5,10,20,30,40,50,60,70,80,90,100)){ predict<- kknn(OutcomeType~ AnimalType + AgeinDays + HasName + IsNeutered + IsMix + Gender +SimpleColor, train = df_train, test = df_test, k = i) fit<- fitted(predict) wrong<- (df_test[,2] != fit) rate<-sum(wrong)/length(wrong) cat(sprintf("k = %f Performance: %f \n",i, rate)) } predict<- kknn(OutcomeType~ AnimalType + AgeinDays + HasName + IsNeutered + IsMix + Gender +SimpleColor, train = df_train, test = df_test, k = 70) fit<- fitted(predict) wrong<- (df_test[,2] != fit) rate<-sum(wrong)/length(wrong) cat(sprintf("k = %f Performance: %f \n",70, rate)) table(df_test$OutcomeType, fit)
[PlusNatSemi] Semigroup Nat where (<+>) x y = x + y [MultNatSemi] Semigroup Nat where (<+>) x y = x * y [PlusNatMonoid] Monoid Nat using PlusNatSemi where neutral = 0 [MultNatMonoid] Monoid Nat using MultNatSemi where neutral = 1
module Data.Profunctor.Morphism import public Data.Morphisms import Data.Profunctor import Data.Profunctor.Choice public export by : (Morphism a b -> Morphism c d) -> (a -> b) -> (c -> d) by f = applyMor . f . Mor export Profunctor Morphism where lmap pre = Mor . (. pre) . applyMor rmap post = Mor . (post .) . applyMor export Choice Morphism where right' = Mor . map . applyMor
(* -------------------------------------------------------------------------- * * Vellvm - the Verified LLVM project * * * * Copyright (c) 2017 Steve Zdancewic <[email protected]> * * Copyright (c) 2017 Joachim Breitner <[email protected]> * * * * This file is distributed under the terms of the GNU General Public * * License as published by the Free Software Foundation, either version * * 3 of the License, or (at your option) any later version. * ---------------------------------------------------------------------------- *) Require Import Ascii String. Extraction Language Haskell. Require Import Vellvm.LLVMAst. Extract Inductive option => "Prelude.Maybe" [ "Nothing" "Just" ]. Extract Inductive list => "[]" [ "[]" "(:)" ]. Extract Inductive prod => "(,)" [ "(,)" ]. Extract Inductive string => "Prelude.String" [ "[]" "(:)" ]. Extract Inductive bool => "Prelude.Bool" [ "False" "True" ]. Extract Inlined Constant int => "Prelude.Int". Extract Inlined Constant float => "Prelude.Float". Extraction Library Datatypes. Extraction Library LLVMAst.
"DataType for program registers." type Reg op::Op name::Symbol args::Vector{Symbol} cond::Expr argv::Vector{Int} plist::Dict{Symbol,Any} out; out0; dif; dif0; tmp; end Reg(op::Op,name::Symbol,args::Vector{Symbol},cond::Expr)= Reg(op,name,args,cond,Int[],Dict{Symbol,Any}(), nothing,nothing,nothing,nothing,nothing) # Stack entries will be triples consisting of: # 1. the :forw flag, indicating whether the operation was performed # 2. the argv array indicating which inputs were used # 3. the output array, if :save was set # Both :forw and argv may change based on runtime conditions, and # the stack has to record these for back which does not have access # to runtime conditions. "DataType for stack entries." type StackEntry forw::Bool argv::Vector{Int} out end "DataType for a compiled network." type Net reg::Vector{Reg} stack::Vector{StackEntry} sp::Int lastforw lastback Net(reg::Vector{Reg})=new(reg, Any[], 0) end import Base: length, get, eltype, pop!, push! regs(f::Net)=f.reg length(f::Net)=length(f.reg) reg(f::Net,i)=f.reg[i] # i could be an array or any other type of index expression params(f::Net)=filter(x->isa(x.op,Par),f.reg) ninputs(f::Net)=count(x->(isa(x.op,Input) && getp(x,:forw)),f.reg) eltype(f::Net)=(r=f.reg[1];!isvoid(r,:out0)?eltype(r.out0):error("Uninitialized Net")) function reg(f::Net,k::Symbol) i = findlast(f.reg) do p getp(p,:forw) && p.name==k end return i==0 ? nothing : f.reg[i] end get(f::Net,k)=(r=reg(f,k); r==nothing ? r : r.out) # to_host(r.out)) dif(f::Net,k)=(r=reg(f,k); r==nothing ? r : r.dif) inputregs(f::Net,p::Reg)=f.reg[p.argv] # map too slow? # inputs(f::Net,p::Reg)=map(x->x.out, inputregs(f,p)) inputs(f::Net,p::Reg)=outs(inputregs(f,p)) function outs(pp::Vector{Reg}) n = length(pp) a = cell(n) @inbounds for i=1:n; a[i]=pp[i].out; end return a end function difs(pp::Vector{Reg}) n = length(pp) a = cell(n) @inbounds for i=1:n r = pp[i] a[i]=(!getp(r,:grad) ? nothing : getp(r,:incr) ? r.tmp : r.dif0) end return a end getp(p::Reg,k::Symbol,v=false)=get(p.plist,k,v) incp(p::Reg,k::Symbol)=setp(p,k,1+getp(p,k,0)) setp(p::Reg,k::Symbol,v)=(p.plist[k]=v) setp(p::Reg; o...)=(for (k,v) in o; setp(p,k,v); end) setp(f::Net; o...)=(for p in regs(f); setp(p; o...); end) function setp(f::Net,k; o...) r=reg(f,k) if isa(r,Reg) setp(r;o...) elseif isa(r,Array) for p in r; setp(p;o...); end end end ### Cleanup at the beginning/end of sequence function reset!(f::Net; keepstate=false) f.sp = 0 for p in regs(f) p.dif = nothing getp(p,:incr) && !isvoid(p,:dif0) && fillsync!(p.dif0, 0) if keepstate p.out = p.out0 push!(f,p) else p.out = nothing end end end function push!(f::Net,p::Reg) if length(f.stack) < f.sp error("Stack error") elseif length(f.stack) == f.sp push!(f.stack, StackEntry(false, Int[], nothing)) end s = f.stack[f.sp+=1] s.forw = getp(p,:forw) if s.forw s.argv = (issimilar(s.argv,p.argv) ? copy!(s.argv,p.argv) : copy(p.argv)) s.out = (!getp(p,:save) ? s.out : # won't be used so keep the storage p.out == nothing ? # nothing represents zero array (s.out!=nothing && Base.warn_once("Writing nothing over array"); nothing) : ispersistent(p) ? p.out : # no need to copy Par or Arr, they won't change during forw/back issimilar(s.out, p.out) ? copysync!(s.out, p.out) : copysync!(similar(p.out), p.out)) # this is the only allocation end end stack_length(f::Net)=f.sp stack_empty!(f::Net)=(f.sp=0) stack_isempty(f::Net)=(f.sp==0) function update!(m::Net; gclip=0, gscale=1, o...) # TODO: implement callbacks if gclip > 0 g = gnorm(m) gscale *= (g > gclip ? gclip/g : 1) end for p in params(m) isvoid(p,:dif) && continue # may happen when a conditional part of the model never runs update!(p; o..., gscale=gscale) end end vnorm(x)=(x==nothing ? 0 : vecnorm(x)) wnorm(m::Net,w=0)=(for p in params(m); w += vnorm(p.out); end; w) # t:317 gnorm(m::Net,g=0)=(for p in params(m); g += vnorm(p.dif); end; g) # t:332 function Base.isequal(a::Union{Net,Reg,StackEntry}, b::Union{Net,Reg,StackEntry}) for n in fieldnames(a) if isdefined(a,n) && isdefined(b,n) isequal(a.(n), b.(n)) || return false elseif isdefined(a,n) || isdefined(b,n) return false end end return true end ### File I/O using JLD function clean(net::Net) a = Array(Reg, length(net)) for i=1:length(net) r = net.reg[i] a[i] = Reg(r.op, r.name, r.args, r.cond, r.argv, r.plist, ispersistent(r) ? r.out : nothing, ispersistent(r) ? r.out0 : nothing, nothing, nothing, nothing) end return Net(a) end ### DEBUGGING Base.writemime(io::IO, ::MIME"text/plain", f::Net)=netprint(f) function netprint(f::Net) # vecnorm1(x,n)=(!isdefined(x,n)? Inf : x.(n)==nothing ? NaN : vecnorm(x.(n))) for i=1:length(f) r=reg(f,i) @printf("%d %s%s name=>%s", i, typeof(r.op), tuple(r.argv...), r.name) !isempty(r.args) && @printf(",args=>(%s)", join(r.args,",")) !isvoid(r,:out0) && @printf(",dims=>%s", size(r.out0)) !isvoid(r,:out) && @printf(",norm=>%g", vecnorm(r.out)) !isvoid(r,:dif) && @printf(",norm=>%g", vecnorm(r.dif)) !isempty(r.cond.args) && @printf(",cond=>%s", r.cond.args) for (k,v) in r.plist; @printf(",%s=>%s", string(k), v); end println() end end ptr16(x)=hex(x==nothing ? 0 : hash(pointer(x)) % 0xffff, 4) ptr8(x)=hex(x==nothing ? 0 : hash(pointer(x)) % 0xff, 2) idx1(x)=(x==nothing ? -1 : atype(x)==CudaArray ? to_host(x)[1] : atype(x)==Array ? x[1] : error("$(typeof(x))")) vecnorm0(x,y...)=map(vecnorm0,(x,y...)) vecnorm0(x::Vector)=map(vecnorm0,x) vecnorm0(x::Tuple)=map(vecnorm0,x) vecnorm0(x::Par)= ((!isvoid(x,:out)? vecnorm0(x.out) : 0), (!isvoid(x,:dif)? vecnorm0(x.dif) : 0)) vecnorm0(::Void)=0 vecnorm0(x)=(@sprintf("%.8f",vecnorm(x))) #floor(1e6*vecnorm(x))/1e6 ### DEAD CODE # isempty(f.stack) || (warn("Stack not empty"); empty!(f.stack)) # isempty(f.sdict) || (warn("Sdict not empty"); empty!(f.sdict)) # function push!(f::Net,a) # push!(f.stack,a) # if a!=nothing # isa(a,NTuple{3}) || error("Expected NTuple{3} got $a") # (y, xsave, ysave) = a # ysave == nothing || (f.sdict[ysave]=true) # xsave == nothing || (for x in xsave; f.sdict[x]=true; end) # end # end # function pop!(f::Net) # a = pop!(f.stack) # if isempty(f.stack) # f.sfree = collect(keys(f.sdict)) # empty!(f.sdict) # end # return a # end # Too expensive: # function pop!(f::Net) # a = pop!(f.stack) # if a!=nothing # isa(a,NTuple{3}) || error("Expected NTuple{3} got $a") # (y, xsave, ysave) = a # ysave == nothing || dec!(f.sdict,ysave) # xsave == nothing || (for x in xsave; dec!(f.sdict,x); end) # end # return a # end # inc!(p::ObjectIdDict,k)=(p[k]=1+getp(p,k,0)) # function dec!(p::ObjectIdDict,k) # haskey(p,k) || (warn("Object not in dict"); return) # n = getp(p,k,0) # if n > 1 # p[k] = n-1 # elseif n == 1 # delete!(p,k) # else # warn("Bad count for object: $n") # delete!(p,k) # end # end # op(f::Net,n::Int)=f.reg[n].op # inputs(f::Net,n::Int)=f.reg[n].inputs # output(f::Net,n::Int)=f.reg[n].output # forwref(f::Net,n::Int)=any(i->in(output(f,n),inputs(f,i)), 1:n-1) # regs(f::Net)=values(f.reg) # output_register(f::Net,p::Ins)=reg(f.reg,p.output,nothing) # inputregs(f::Net,p::Ins)=map(s->reg(f.reg,s,nothing), p.inputs) # input_arrays(f::Net,p::Ins)=map(s->(haskey(f.reg,s) ? f.reg[s].out : nothing), p.inputs) # nops(f::Net)=length(f.reg) # getprop(p::Ins,k,d=false)=get(p.plist,k,d) # setprop!(p::Ins,k,v=true)=(p.plist[k]=v) # set!(p::Ins,k,v=true)=setprop!(p,k,v) # getprop(p::Reg,k,d=false)=get(p.plist,k,d) # setprop!(p::Reg,k,v=true)=(p.plist[k]=v) # set!(p::Reg,k,v=true)=setprop!(p,k,v) # inc!(p::Reg,k)=set!(p,k,1+get(p,k)) # getreg(f::Net,k::Symbol)=reg(f.reg,k,nothing) # getdif(f::Net,k::Symbol)=(haskey(f.reg,k) ? f.reg[k].dif : nothing) # getout(f::Net,k::Symbol)=(haskey(f.reg,k) ? f.reg[k].out : nothing) # getreg(f::Net,p::Ins)=getreg(f,p.output) # getdif(f::Net,p::Ins)=getdif(f,p.output) # getout(f::Net,p::Ins)=getout(f,p.output) # Base.reg(f::Net,k)=getout(f,k) # Base.get(p::Ins,k,d=false)=getprop(p,k,d) # Base.get(p::Reg,k,d=false)=getprop(p,k,d) # Base.copysync!(r::Reg,x)=(r.out=copysync!(r.out0,x)) # type Ins # output::Symbol # op::Op # inputs::Vector{Symbol} # cond::Expr # plist::Dict # out; out0; dif; dif0; tmp # function Ins(output::Symbol,op::Op,inputs::Vector{Symbol},cond::Expr) # new(output,op,inputs,cond,Dict(),nothing,nothing,nothing,nothing,nothing) # end # end # type Net # op::Vector{Ins} # sp::Int # stack::Vector # end # """ # tosave(op, inputs) returns tosave[n] which is true if the result of # op[n] would be needed for back calculation. We find this out using # back_reads_x and back_reads_y on each op. Note that Par registers # are persistent and do not need to be saved. # """ # function tosave(op, inputs) # N = length(op) # tosave = falses(N) # for n=1:length(op) # back_reads_y(op[n]) && (tosave[n] = true) # if back_reads_x(op[n]) # for i in inputs[n] # if !isa(op[i], Par) # tosave[i] = true # end # end # end # end # return tosave # end # """ # outputs(inputs) returns an array of output indices for each register. # Note that the final register is the network output, so it could be # read externally even if outputs[N] is empty. # """ # function outputs(inputs) # N = length(inputs) # outputs = [ Int[] for n=1:N ] # for n=1:N # for i in inputs[n] # push!(outputs[i], n) # end # end # push!(outputs[N], 0) # for network output # return outputs # end # """ # Net(::Expr) compiles a quoted block of net language to a Net object # """ # function Net(a::Expr) # (op, inputs) = netcomp(a) # N = length(op) # Net(op, inputs, outputs(inputs), # count(x->isa(x,Input), op), # filter(x->isa(x,Par), op), # tosave(op, inputs), # falses(N), # toback: depends on dx # falses(N), # toincr: depends on seq # falses(N), # sparse: depends on input # cell(N), cell(N), cell(N), cell(N), cell(N), # Any[], 0) # end # """ # netcomp(::Expr) compiles Expr and returns (ops, opinputs) # where inputs are represented as integer indices. # """ # function netcomp(a::Expr) # (op,innames,outname) = netcomp1(a) # dict = Dict{Symbol,Int}() # for n=1:length(outname) # dict[outname[n]] = n # end # inputidx = Array(Vector{Int}, length(innames)) # for n=1:length(innames) # inputidx[n] = map(x->dict[x], innames[n]) # end # (op, inputidx) # end # """ # netcomp1(::Expr) compiles Expr and returns (ops, inputs, output) # where inputs and outputs are gensyms # """ # function netcomp1(block::Expr) # @assert block.head == :block # dict = Dict{Symbol,Symbol}() # ops = Op[] # inputs = Vector{Symbol}[] # output = Symbol[] # for stmt in block.args # isa(stmt, LineNumberNode) && continue # @assert isa(stmt, Expr) # (opoutput, func, opinputs, params) = netstmt(stmt, dict) # ev = eval(current_module(), Expr(:call, func, params...)) # if isa(ev, Op) # @assert length(opinputs) == ninputs(ev) # push!(ops, ev) # push!(inputs, opinputs) # push!(output, opoutput) # elseif isa(ev, Expr) # (subops, subinputs, suboutput) = subcomp(ev, opinputs, opoutput) # append!(ops, subops) # append!(inputs, subinputs) # append!(output, suboutput) # else # error("Compiler error: $ev, $func, $params") # end # end # (ops, inputs, output) # end # """ # subcomp(::Expr, netinputs, netoutput): compiles a subroutine with # input/output symbols given by the caller. # """ # function subcomp(block::Expr, netinputs, netoutput) # (ops, inputs, output) = netcomp1(block) # @assert length(netinputs) == count(op->isa(op,Input), ops) # substitute = Dict{Symbol,Symbol}() # nextinput = 0 # for i=1:length(ops) # isa(ops[i], Input) || continue # substitute[output[i]] = netinputs[nextinput += 1] # end # substitute[output[end]] = netoutput # newops = Any[] # newinputs = Any[] # newoutput = Any[] # for i=1:length(ops) # isa(ops[i], Input) && continue # input ops can be dropped, inputs are now caller symbols # push!(newops, ops[i]) # push!(newinputs, map(x->get(substitute,x,x), inputs[i])) # push!(newoutput, get(substitute, output[i], output[i])) # end # (newops, newinputs, newoutput) # end # """ # netstmt(::Expr,::Dict): parses a single assignment statement converting # variables to gensyms. Returns (target, func, args, pars). # """ # function netstmt(stmt::Expr, dict::Dict{Symbol,Symbol}) # @assert stmt.head == :(=) # @assert length(stmt.args) == 2 # (target, expr) = stmt.args # @assert isa(target, Symbol) # target = get!(dict, target) do # gensym(target) # end # @assert expr.head == :call # func = expr.args[1] # args = Any[] # pars = Any[] # for a in expr.args[2:end] # isa(a, Symbol) ? # push!(args, a) : # push!(pars, a) # end # for i=1:length(args) # args[i] = get!(dict, args[i]) do # gensym(args[i]) # end # end # (target, func, args, pars) # end # """ # multi(op, inputs) returns a bool vector which is true if op[n] has # fanout > 1, in which case its dif should be incrementally updated. # """ # function multi(op, inputs) # N = length(op) # nout = zeros(Int, N) # nout[N] = 1 # count network output as a read # for n=1:N # for i in inputs[n] # nout[i] += 1 # end # end # return (nout .> 1) # end # """ # Neural network compiler. # """ # type Net0 # op::Vector{Op} # inputs::Vector{Vector{Int}} # outputs::Vector{Vector{Int}} # netinputs::Int # params::Vector{Par} # tosave::Vector{Bool} # result of op[n] needed for back calculation. # toback::Vector{Bool} # dif[n] should be calculated during back calculation # toincr::Vector{Bool} # dif[n] should be incrementally updated: multiple outputs or Par in a sequence model # sparse::Vector # a parameter dotted with sparse input # out::Vector # dif::Vector # out0::Vector # dif0::Vector # tmp::Vector # stack::Vector # sp::Int # Net0()=new() # end # function Net(f::Function; ninputs=1, o...) # x = [ gensym("x") for i=1:ninputs ] # y = gensym("y") # p = f(x..., y; o...) # b = Expr(:block) # for i in x; push!(b.args, :($i = input())); end # append!(b.args, p.args) # Net(b) # end # function Net(b::Expr) # net = Net() # reg = _knet(b) # net.op = map(first, reg) # N = length(reg) # dict = Dict{Symbol,Int}() # for i=1:N; dict[last(reg[i])] = i; end # net.inputs = [ Int[] for i=1:N ] # for i=1:N; for j=2:length(reg[i])-1; push!(net.inputs[i], dict[reg[i][j]]); end; end # net.outputs = outputs(net.inputs) # net.netinputs = count(x->isa(x,Input), net.op) # net.params = filter(x->isa(x,Par), net.op) # net.tosave = tosave(net.op, net.inputs) # todo: does this not depend on dx as well? # net.toback = falses(N) # toback: depends on dx # net.toincr = falses(N) # toincr: depends on seq # net.sparse = nothings(N) # sparse: depends on input # for f in (:out,:dif,:out0,:dif0,:tmp); net.(f) = nothings(N); end # net.stack = Any[] # net.sp = 0 # return net # end # No longer true, we are switching to user controlled register based sharing: # Two registers may share their out0 arrays but not dif0 or vice-versa # So each symbol should correspond to a unique register, sharing # optimization can be done at the array level, not the register level. # "DataType for regram registers." # type Reg # size #::Dims prevents us from using nothing during size inference, TODO; use empty tuple instead, TODO: should we put these into plist? # eltype::DataType # outtype::DataType # diftype::DataType # tmptype::DataType # Reg()=(r=new();r.plist=Dict();r.saved=false;r) # end # # TODO: retire savenet and loadnet, we just need clean. # function savenet(fname::AbstractString, net::Net; o...) # a = Array(Reg, length(net)) # for i=1:length(net) # r = net.reg[i] # a[i] = Reg(r.op, r.name, r.args, r.cond, r.argv, r.plist, # ispersistent(r) ? r.out : nothing, # ispersistent(r) ? r.out0 : nothing, # nothing, nothing, nothing) # end # save(fname, "knetmodel", Net(a); o...) # end # loadnet(fname::AbstractString)=load(fname, "knetmodel")
import Base: size, length, reshape, hcat, vcat, fill # Let the user get the `size` and `length` of `Node`s. Base.size(x::Node, dims...) = size(unbox(x), dims...) Base.length(x::Node) = length(unbox(x)) # Sensitivity for the first argument of `reshape`. @explicit_intercepts reshape Tuple{∇Array, Vararg{Int}} [true, false] @explicit_intercepts reshape Tuple{∇Array, Tuple{Vararg{Int}}} [true, false] ∇(::typeof(reshape), ::Type{Arg{1}}, _, y, ȳ, A::∇Array, args...) = reshape(ȳ, size(A)...) @union_intercepts hcat Tuple{Vararg{∇Array}} Tuple{Vararg{AbstractArray}} function Nabla.∇( ::typeof(hcat), ::Type{Arg{i}}, _, y, ȳ, A::AbstractArray... ) where i l = sum([size(A[j], 2) for j in 1:(i - 1)]) u = l + size(A[i], 2) # Using copy materializes the views returned by selectdim return copy(u > l + 1 ? selectdim(ȳ, 2, (l+1):u) : selectdim(ȳ, 2, u)) end @union_intercepts vcat Tuple{Vararg{∇Array}} Tuple{Vararg{AbstractArray}} function Nabla.∇( ::typeof(vcat), ::Type{Arg{i}}, _, y, ȳ, A::AbstractArray... ) where i l = sum([size(A[j], 1) for j in 1:(i - 1)]) u = l + size(A[i], 1) return copy(selectdim(ȳ, 1, (l+1):u)) end @explicit_intercepts fill Tuple{Any, Tuple{Vararg{Integer}}} [true, false] ∇(::typeof(fill), ::Type{Arg{1}}, p, y, ȳ, value, dims...) = sum(ȳ)
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.List open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite variable A B : Set x y z : A xs ys zs : List A f : A → B m n : Nat cong : (f : A → B) → x ≡ y → f x ≡ f y cong f refl = refl trans : x ≡ y → y ≡ z → x ≡ z trans refl refl = refl +zero : m + zero ≡ m +zero {zero} = refl +zero {suc m} = cong suc +zero suc+zero : suc m + zero ≡ suc m suc+zero = +zero +suc : m + (suc n) ≡ suc (m + n) +suc {zero} = refl +suc {suc m} = cong suc +suc zero+suc : zero + (suc n) ≡ suc n zero+suc = refl suc+suc : (suc m) + (suc n) ≡ suc (suc (m + n)) suc+suc = cong suc +suc {-# REWRITE +zero +suc suc+zero zero+suc suc+suc #-} map : (A → B) → List A → List B map f [] = [] map f (x ∷ xs) = (f x) ∷ (map f xs) _++_ : List A → List A → List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) ++-[] : xs ++ [] ≡ xs ++-[] {xs = []} = refl ++-[] {xs = x ∷ xs} = cong (_∷_ x) ++-[] ∷-++-[] : (x ∷ xs) ++ [] ≡ x ∷ xs ∷-++-[] = ++-[] map-id : map (λ x → x) xs ≡ xs map-id {xs = []} = refl map-id {xs = x ∷ xs} = cong (_∷_ x) map-id map-id-∷ : map (λ x → x) (x ∷ xs) ≡ x ∷ xs map-id-∷ = map-id {-# REWRITE ++-[] ∷-++-[] #-} {-# REWRITE map-id map-id-∷ #-}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Yury Kudryashov -/ import analysis.complex.basic import analysis.normed_space.finite_dimension import measure_theory.function.ae_measurable_sequence import measure_theory.group.arithmetic import measure_theory.lattice import measure_theory.measure.open_pos import topology.algebra.order.liminf_limsup import topology.continuous_function.basic import topology.instances.ereal import topology.G_delta import topology.order.lattice import topology.semicontinuous import topology.metric_space.metrizable /-! # Borel (measurable) space ## Main definitions * `borel α` : the least `σ`-algebra that contains all open sets; * `class borel_space` : a space with `topological_space` and `measurable_space` structures such that `‹measurable_space α› = borel α`; * `class opens_measurable_space` : a space with `topological_space` and `measurable_space` structures such that all open sets are measurable; equivalently, `borel α ≤ ‹measurable_space α›`. * `borel_space` instances on `empty`, `unit`, `bool`, `nat`, `int`, `rat`; * `measurable` and `borel_space` instances on `ℝ`, `ℝ≥0`, `ℝ≥0∞`. ## Main statements * `is_open.measurable_set`, `is_closed.measurable_set`: open and closed sets are measurable; * `continuous.measurable` : a continuous function is measurable; * `continuous.measurable2` : if `f : α → β` and `g : α → γ` are measurable and `op : β × γ → δ` is continuous, then `λ x, op (f x, g y)` is measurable; * `measurable.add` etc : dot notation for arithmetic operations on `measurable` predicates, and similarly for `dist` and `edist`; * `ae_measurable.add` : similar dot notation for almost everywhere measurable functions; * `measurable.ennreal*` : special cases for arithmetic operations on `ℝ≥0∞`. -/ noncomputable theory open classical set filter measure_theory open_locale classical big_operators topological_space nnreal ennreal measure_theory universes u v w x y variables {α β γ γ₂ δ : Type*} {ι : Sort y} {s t u : set α} open measurable_space topological_space /-- `measurable_space` structure generated by `topological_space`. -/ def borel (α : Type u) [topological_space α] : measurable_space α := generate_from {s : set α | is_open s} lemma borel_eq_top_of_discrete [topological_space α] [discrete_topology α] : borel α = ⊤ := top_le_iff.1 $ λ s hs, generate_measurable.basic s (is_open_discrete s) lemma borel_eq_top_of_encodable [topological_space α] [t1_space α] [encodable α] : borel α = ⊤ := begin refine (top_le_iff.1 $ λ s hs, bUnion_of_singleton s ▸ _), apply measurable_set.bUnion s.countable_encodable, intros x hx, apply measurable_set.of_compl, apply generate_measurable.basic, exact is_closed_singleton.is_open_compl end lemma borel_eq_generate_from_of_subbasis {s : set (set α)} [t : topological_space α] [second_countable_topology α] (hs : t = generate_from s) : borel α = generate_from s := le_antisymm (generate_from_le $ assume u (hu : t.is_open u), begin rw [hs] at hu, induction hu, case generate_open.basic : u hu { exact generate_measurable.basic u hu }, case generate_open.univ { exact @measurable_set.univ α (generate_from s) }, case generate_open.inter : s₁ s₂ _ _ hs₁ hs₂ { exact @measurable_set.inter α (generate_from s) _ _ hs₁ hs₂ }, case generate_open.sUnion : f hf ih { rcases is_open_sUnion_countable f (by rwa hs) with ⟨v, hv, vf, vu⟩, rw ← vu, exact @measurable_set.sUnion α (generate_from s) _ hv (λ x xv, ih _ (vf xv)) } end) (generate_from_le $ assume u hu, generate_measurable.basic _ $ show t.is_open u, by rw [hs]; exact generate_open.basic _ hu) lemma topological_space.is_topological_basis.borel_eq_generate_from [topological_space α] [second_countable_topology α] {s : set (set α)} (hs : is_topological_basis s) : borel α = generate_from s := borel_eq_generate_from_of_subbasis hs.eq_generate_from lemma is_pi_system_is_open [topological_space α] : is_pi_system (is_open : set α → Prop) := λ s hs t ht hst, is_open.inter hs ht lemma borel_eq_generate_from_is_closed [topological_space α] : borel α = generate_from {s | is_closed s} := le_antisymm (generate_from_le $ λ t ht, @measurable_set.of_compl α _ (generate_from {s | is_closed s}) (generate_measurable.basic _ $ is_closed_compl_iff.2 ht)) (generate_from_le $ λ t ht, @measurable_set.of_compl α _ (borel α) (generate_measurable.basic _ $ is_open_compl_iff.2 ht)) section order_topology variable (α) variables [topological_space α] [second_countable_topology α] [linear_order α] [order_topology α] lemma borel_eq_generate_from_Iio : borel α = generate_from (range Iio) := begin refine le_antisymm _ (generate_from_le _), { rw borel_eq_generate_from_of_subbasis (@order_topology.topology_eq_generate_intervals α _ _ _), letI : measurable_space α := measurable_space.generate_from (range Iio), have H : ∀ a : α, measurable_set (Iio a) := λ a, generate_measurable.basic _ ⟨_, rfl⟩, refine generate_from_le _, rintro _ ⟨a, rfl | rfl⟩; [skip, apply H], by_cases h : ∃ a', ∀ b, a < b ↔ a' ≤ b, { rcases h with ⟨a', ha'⟩, rw (_ : Ioi a = (Iio a')ᶜ), { exact (H _).compl }, simp [set.ext_iff, ha'] }, { rcases is_open_Union_countable (λ a' : {a' : α // a < a'}, {b | a'.1 < b}) (λ a', is_open_lt' _) with ⟨v, ⟨hv⟩, vu⟩, simp [set.ext_iff] at vu, have : Ioi a = ⋃ x : v, (Iio x.1.1)ᶜ, { simp [set.ext_iff], refine λ x, ⟨λ ax, _, λ ⟨a', ⟨h, av⟩, ax⟩, lt_of_lt_of_le h ax⟩, rcases (vu x).2 _ with ⟨a', h₁, h₂⟩, { exact ⟨a', h₁, le_of_lt h₂⟩ }, refine not_imp_comm.1 (λ h, _) h, exact ⟨x, λ b, ⟨λ ab, le_of_not_lt (λ h', h ⟨b, ab, h'⟩), lt_of_lt_of_le ax⟩⟩ }, rw this, resetI, apply measurable_set.Union, exact λ _, (H _).compl } }, { rw forall_range_iff, intro a, exact generate_measurable.basic _ is_open_Iio } end lemma borel_eq_generate_from_Ioi : borel α = generate_from (range Ioi) := @borel_eq_generate_from_Iio (order_dual α) _ (by apply_instance : second_countable_topology α) _ _ end order_topology lemma borel_comap {f : α → β} {t : topological_space β} : @borel α (t.induced f) = (@borel β t).comap f := comap_generate_from.symm lemma continuous.borel_measurable [topological_space α] [topological_space β] {f : α → β} (hf : continuous f) : @measurable α β (borel α) (borel β) f := measurable.of_le_map $ generate_from_le $ λ s hs, generate_measurable.basic (f ⁻¹' s) (hs.preimage hf) /-- A space with `measurable_space` and `topological_space` structures such that all open sets are measurable. -/ class opens_measurable_space (α : Type*) [topological_space α] [h : measurable_space α] : Prop := (borel_le : borel α ≤ h) /-- A space with `measurable_space` and `topological_space` structures such that the `σ`-algebra of measurable sets is exactly the `σ`-algebra generated by open sets. -/ class borel_space (α : Type*) [topological_space α] [measurable_space α] : Prop := (measurable_eq : ‹measurable_space α› = borel α) namespace tactic /-- Add instances `borel α : measurable_space α` and `⟨rfl⟩ : borel_space α`. -/ meta def add_borel_instance (α : expr) : tactic unit := do n1 ← get_unused_name "_inst", to_expr ``(borel %%α) >>= pose n1, reset_instance_cache, n2 ← get_unused_name "_inst", v ← to_expr ``(borel_space.mk rfl : borel_space %%α), note n2 none v, reset_instance_cache /-- Given a type `α`, an assumption `i : measurable_space α`, and an instance `[borel_space α]`, replace `i` with `borel α`. -/ meta def borel_to_refl (α i : expr) : tactic unit := do n ← get_unused_name "h", to_expr ``(%%i = borel %%α) >>= assert n, applyc `borel_space.measurable_eq, unfreezing (tactic.subst i), n1 ← get_unused_name "_inst", to_expr ``(borel %%α) >>= pose n1, reset_instance_cache /-- Given a type `α`, if there is an assumption `[i : measurable_space α]`, then try to prove `[borel_space α]` and replace `i` with `borel α`. Otherwise, add instances `borel α : measurable_space α` and `⟨rfl⟩ : borel_space α`. -/ meta def borelize (α : expr) : tactic unit := do i ← optional (to_expr ``(measurable_space %%α) >>= find_assumption), i.elim (add_borel_instance α) (borel_to_refl α) namespace interactive setup_tactic_parser /-- The behaviour of `borelize α` depends on the existing assumptions on `α`. - if `α` is a topological space with instances `[measurable_space α] [borel_space α]`, then `borelize α` replaces the former instance by `borel α`; - otherwise, `borelize α` adds instances `borel α : measurable_space α` and `⟨rfl⟩ : borel_space α`. Finally, `borelize [α, β, γ]` runs `borelize α, borelize β, borelize γ`. -/ meta def borelize (ts : parse pexpr_list_or_texpr) : tactic unit := mmap' (λ t, to_expr t >>= tactic.borelize) ts add_tactic_doc { name := "borelize", category := doc_category.tactic, decl_names := [`tactic.interactive.borelize], tags := ["type class"] } end interactive end tactic @[priority 100] instance order_dual.opens_measurable_space {α : Type*} [topological_space α] [measurable_space α] [h : opens_measurable_space α] : opens_measurable_space (order_dual α) := { borel_le := h.borel_le } @[priority 100] instance order_dual.borel_space {α : Type*} [topological_space α] [measurable_space α] [h : borel_space α] : borel_space (order_dual α) := { measurable_eq := h.measurable_eq } /-- In a `borel_space` all open sets are measurable. -/ @[priority 100] instance borel_space.opens_measurable {α : Type*} [topological_space α] [measurable_space α] [borel_space α] : opens_measurable_space α := ⟨ge_of_eq $ borel_space.measurable_eq⟩ instance subtype.borel_space {α : Type*} [topological_space α] [measurable_space α] [hα : borel_space α] (s : set α) : borel_space s := ⟨by { rw [hα.1, subtype.measurable_space, ← borel_comap], refl }⟩ instance subtype.opens_measurable_space {α : Type*} [topological_space α] [measurable_space α] [h : opens_measurable_space α] (s : set α) : opens_measurable_space s := ⟨by { rw [borel_comap], exact comap_mono h.1 }⟩ theorem _root_.measurable_set.induction_on_open [topological_space α] [measurable_space α] [borel_space α] {C : set α → Prop} (h_open : ∀ U, is_open U → C U) (h_compl : ∀ t, measurable_set t → C t → C tᶜ) (h_union : ∀ f : ℕ → set α, pairwise (disjoint on f) → (∀ i, measurable_set (f i)) → (∀ i, C (f i)) → C (⋃ i, f i)) : ∀ ⦃t⦄, measurable_set t → C t := measurable_space.induction_on_inter borel_space.measurable_eq is_pi_system_is_open (h_open _ is_open_empty) h_open h_compl h_union section variables [topological_space α] [measurable_space α] [opens_measurable_space α] [topological_space β] [measurable_space β] [opens_measurable_space β] [topological_space γ] [measurable_space γ] [borel_space γ] [topological_space γ₂] [measurable_space γ₂] [borel_space γ₂] [measurable_space δ] lemma is_open.measurable_set (h : is_open s) : measurable_set s := opens_measurable_space.borel_le _ $ generate_measurable.basic _ h @[measurability] lemma measurable_set_interior : measurable_set (interior s) := is_open_interior.measurable_set lemma is_Gδ.measurable_set (h : is_Gδ s) : measurable_set s := begin rcases h with ⟨S, hSo, hSc, rfl⟩, exact measurable_set.sInter hSc (λ t ht, (hSo t ht).measurable_set) end lemma measurable_set_of_continuous_at {β} [emetric_space β] (f : α → β) : measurable_set {x | continuous_at f x} := (is_Gδ_set_of_continuous_at f).measurable_set lemma is_closed.measurable_set (h : is_closed s) : measurable_set s := h.is_open_compl.measurable_set.of_compl lemma is_compact.measurable_set [t2_space α] (h : is_compact s) : measurable_set s := h.is_closed.measurable_set @[measurability] lemma measurable_set_closure : measurable_set (closure s) := is_closed_closure.measurable_set lemma measurable_of_is_open {f : δ → γ} (hf : ∀ s, is_open s → measurable_set (f ⁻¹' s)) : measurable f := by { rw [‹borel_space γ›.measurable_eq], exact measurable_generate_from hf } lemma measurable_of_is_closed {f : δ → γ} (hf : ∀ s, is_closed s → measurable_set (f ⁻¹' s)) : measurable f := begin apply measurable_of_is_open, intros s hs, rw [← measurable_set.compl_iff, ← preimage_compl], apply hf, rw [is_closed_compl_iff], exact hs end lemma measurable_of_is_closed' {f : δ → γ} (hf : ∀ s, is_closed s → s.nonempty → s ≠ univ → measurable_set (f ⁻¹' s)) : measurable f := begin apply measurable_of_is_closed, intros s hs, cases eq_empty_or_nonempty s with h1 h1, { simp [h1] }, by_cases h2 : s = univ, { simp [h2] }, exact hf s hs h1 h2 end instance nhds_is_measurably_generated (a : α) : (𝓝 a).is_measurably_generated := begin rw [nhds, infi_subtype'], refine @filter.infi_is_measurably_generated _ _ _ _ (λ i, _), exact i.2.2.measurable_set.principal_is_measurably_generated end /-- If `s` is a measurable set, then `𝓝[s] a` is a measurably generated filter for each `a`. This cannot be an `instance` because it depends on a non-instance `hs : measurable_set s`. -/ lemma measurable_set.nhds_within_is_measurably_generated {s : set α} (hs : measurable_set s) (a : α) : (𝓝[s] a).is_measurably_generated := by haveI := hs.principal_is_measurably_generated; exact filter.inf_is_measurably_generated _ _ @[priority 100] -- see Note [lower instance priority] instance opens_measurable_space.to_measurable_singleton_class [t1_space α] : measurable_singleton_class α := ⟨λ x, is_closed_singleton.measurable_set⟩ instance pi.opens_measurable_space_encodable {ι : Type*} {π : ι → Type*} [encodable ι] [t' : Π i, topological_space (π i)] [Π i, measurable_space (π i)] [∀ i, second_countable_topology (π i)] [∀ i, opens_measurable_space (π i)] : opens_measurable_space (Π i, π i) := begin constructor, have : Pi.topological_space = generate_from {t | ∃(s:Πa, set (π a)) (i : finset ι), (∀a∈i, s a ∈ countable_basis (π a)) ∧ t = pi ↑i s}, { rw [funext (λ a, @eq_generate_from_countable_basis (π a) _ _), pi_generate_from_eq] }, rw [borel_eq_generate_from_of_subbasis this], apply generate_from_le, rintros _ ⟨s, i, hi, rfl⟩, refine measurable_set.pi i.countable_to_set (λ a ha, is_open.measurable_set _), rw [eq_generate_from_countable_basis (π a)], exact generate_open.basic _ (hi a ha) end instance pi.opens_measurable_space_fintype {ι : Type*} {π : ι → Type*} [fintype ι] [t' : Π i, topological_space (π i)] [Π i, measurable_space (π i)] [∀ i, second_countable_topology (π i)] [∀ i, opens_measurable_space (π i)] : opens_measurable_space (Π i, π i) := by { letI := fintype.encodable ι, apply_instance } instance prod.opens_measurable_space [second_countable_topology α] [second_countable_topology β] : opens_measurable_space (α × β) := begin constructor, rw [((is_basis_countable_basis α).prod (is_basis_countable_basis β)).borel_eq_generate_from], apply generate_from_le, rintros _ ⟨u, v, hu, hv, rfl⟩, exact (is_open_of_mem_countable_basis hu).measurable_set.prod (is_open_of_mem_countable_basis hv).measurable_set end variables {α' : Type*} [topological_space α'] [measurable_space α'] lemma measure_interior_of_null_bdry {μ : measure α'} {s : set α'} (h_nullbdry : μ (frontier s) = 0) : μ (interior s) = μ s := measure_eq_measure_smaller_of_between_null_diff interior_subset subset_closure h_nullbdry lemma measure_closure_of_null_bdry {μ : measure α'} {s : set α'} (h_nullbdry : μ (frontier s) = 0) : μ (closure s) = μ s := (measure_eq_measure_larger_of_between_null_diff interior_subset subset_closure h_nullbdry).symm section preorder variables [preorder α] [order_closed_topology α] {a b x : α} @[simp, measurability] lemma measurable_set_Ici : measurable_set (Ici a) := is_closed_Ici.measurable_set @[simp, measurability] lemma measurable_set_Iic : measurable_set (Iic a) := is_closed_Iic.measurable_set @[simp, measurability] lemma measurable_set_Icc : measurable_set (Icc a b) := is_closed_Icc.measurable_set instance nhds_within_Ici_is_measurably_generated : (𝓝[Ici b] a).is_measurably_generated := measurable_set_Ici.nhds_within_is_measurably_generated _ instance nhds_within_Iic_is_measurably_generated : (𝓝[Iic b] a).is_measurably_generated := measurable_set_Iic.nhds_within_is_measurably_generated _ instance nhds_within_Icc_is_measurably_generated : is_measurably_generated (𝓝[Icc a b] x) := by { rw [← Ici_inter_Iic, nhds_within_inter], apply_instance } instance at_top_is_measurably_generated : (filter.at_top : filter α).is_measurably_generated := @filter.infi_is_measurably_generated _ _ _ _ $ λ a, (measurable_set_Ici : measurable_set (Ici a)).principal_is_measurably_generated instance at_bot_is_measurably_generated : (filter.at_bot : filter α).is_measurably_generated := @filter.infi_is_measurably_generated _ _ _ _ $ λ a, (measurable_set_Iic : measurable_set (Iic a)).principal_is_measurably_generated end preorder section partial_order variables [partial_order α] [order_closed_topology α] [second_countable_topology α] {a b : α} @[measurability] lemma measurable_set_le' : measurable_set {p : α × α | p.1 ≤ p.2} := order_closed_topology.is_closed_le'.measurable_set @[measurability] lemma measurable_set_le {f g : δ → α} (hf : measurable f) (hg : measurable g) : measurable_set {a | f a ≤ g a} := hf.prod_mk hg measurable_set_le' end partial_order section linear_order variables [linear_order α] [order_closed_topology α] {a b x : α} -- we open this locale only here to avoid issues with list being treated as intervals above open_locale interval @[simp, measurability] lemma measurable_set_Iio : measurable_set (Iio a) := is_open_Iio.measurable_set @[simp, measurability] lemma measurable_set_Ioi : measurable_set (Ioi a) := is_open_Ioi.measurable_set @[simp, measurability] lemma measurable_set_Ioo : measurable_set (Ioo a b) := is_open_Ioo.measurable_set @[simp, measurability] lemma measurable_set_Ioc : measurable_set (Ioc a b) := measurable_set_Ioi.inter measurable_set_Iic @[simp, measurability] lemma measurable_set_Ico : measurable_set (Ico a b) := measurable_set_Ici.inter measurable_set_Iio instance nhds_within_Ioi_is_measurably_generated : (𝓝[Ioi b] a).is_measurably_generated := measurable_set_Ioi.nhds_within_is_measurably_generated _ instance nhds_within_Iio_is_measurably_generated : (𝓝[Iio b] a).is_measurably_generated := measurable_set_Iio.nhds_within_is_measurably_generated _ instance nhds_within_interval_is_measurably_generated : is_measurably_generated (𝓝[[a, b]] x) := nhds_within_Icc_is_measurably_generated @[measurability] lemma measurable_set_lt' [second_countable_topology α] : measurable_set {p : α × α | p.1 < p.2} := (is_open_lt continuous_fst continuous_snd).measurable_set @[measurability] lemma measurable_set_lt [second_countable_topology α] {f g : δ → α} (hf : measurable f) (hg : measurable g) : measurable_set {a | f a < g a} := hf.prod_mk hg measurable_set_lt' lemma set.ord_connected.measurable_set (h : ord_connected s) : measurable_set s := begin let u := ⋃ (x ∈ s) (y ∈ s), Ioo x y, have huopen : is_open u := is_open_bUnion (λ x hx, is_open_bUnion (λ y hy, is_open_Ioo)), have humeas : measurable_set u := huopen.measurable_set, have hfinite : (s \ u).finite, { refine set.finite_of_forall_between_eq_endpoints (s \ u) (λ x hx y hy z hz hxy hyz, _), by_contra' h, exact hy.2 (mem_Union₂.mpr ⟨x, hx.1, mem_Union₂.mpr ⟨z, hz.1, lt_of_le_of_ne hxy h.1, lt_of_le_of_ne hyz h.2⟩⟩) }, have : u ⊆ s := Union₂_subset (λ x hx, Union₂_subset (λ y hy, Ioo_subset_Icc_self.trans (h.out hx hy))), rw ← union_diff_cancel this, exact humeas.union hfinite.measurable_set end lemma is_preconnected.measurable_set (h : is_preconnected s) : measurable_set s := h.ord_connected.measurable_set lemma generate_from_Ico_mem_le_borel {α : Type*} [topological_space α] [linear_order α] [order_closed_topology α] (s t : set α) : measurable_space.generate_from {S | ∃ (l ∈ s) (u ∈ t) (h : l < u), Ico l u = S} ≤ borel α := begin apply generate_from_le, borelize α, rintro _ ⟨a, -, b, -, -, rfl⟩, exact measurable_set_Ico end lemma dense.borel_eq_generate_from_Ico_mem_aux {α : Type*} [topological_space α] [linear_order α] [order_topology α] [second_countable_topology α] {s : set α} (hd : dense s) (hbot : ∀ x, is_bot x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → y ∈ s) : borel α = generate_from {S : set α | ∃ (l ∈ s) (u ∈ s) (h : l < u), Ico l u = S} := begin set S : set (set α) := {S | ∃ (l ∈ s) (u ∈ s) (h : l < u), Ico l u = S}, refine le_antisymm _ (generate_from_Ico_mem_le_borel _ _), letI : measurable_space α := generate_from S, rw borel_eq_generate_from_Iio, refine generate_from_le (forall_range_iff.2 $ λ a, _), rcases hd.exists_countable_dense_subset_bot_top with ⟨t, hts, hc, htd, htb, htt⟩, by_cases ha : ∀ b < a, (Ioo b a).nonempty, { convert_to measurable_set (⋃ (l ∈ t) (u ∈ t) (hlu : l < u) (hu : u ≤ a), Ico l u), { ext y, simp only [mem_Union, mem_Iio, mem_Ico], split, { intro hy, rcases htd.exists_le' (λ b hb, htb _ hb (hbot b hb)) y with ⟨l, hlt, hly⟩, rcases htd.exists_mem_open is_open_Ioo (ha y hy) with ⟨u, hut, hyu, hua⟩, exact ⟨l, hlt, u, hut, hly.trans_lt hyu, hua.le, hly, hyu⟩ }, { rintro ⟨l, -, u, -, -, hua, -, hyu⟩, exact hyu.trans_le hua } }, { refine measurable_set.bUnion hc (λ a ha, measurable_set.bUnion hc $ λ b hb, _), refine measurable_set.Union_Prop (λ hab, measurable_set.Union_Prop $ λ hb', _), exact generate_measurable.basic _ ⟨a, hts ha, b, hts hb, hab, mem_singleton _⟩ } }, { simp only [not_forall, not_nonempty_iff_eq_empty] at ha, replace ha : a ∈ s := hIoo ha.some a ha.some_spec.fst ha.some_spec.snd, convert_to measurable_set (⋃ (l ∈ t) (hl : l < a), Ico l a), { symmetry, simp only [← Ici_inter_Iio, ← Union_inter, inter_eq_right_iff_subset, subset_def, mem_Union, mem_Ici, mem_Iio], intros x hx, rcases htd.exists_le' (λ b hb, htb _ hb (hbot b hb)) x with ⟨z, hzt, hzx⟩, exact ⟨z, hzt, hzx.trans_lt hx, hzx⟩ }, { refine measurable_set.bUnion hc (λ x hx, measurable_set.Union_Prop $ λ hlt, _), exact generate_measurable.basic _ ⟨x, hts hx, a, ha, hlt, mem_singleton _⟩ } } end lemma dense.borel_eq_generate_from_Ico_mem {α : Type*} [topological_space α] [linear_order α] [order_topology α] [second_countable_topology α] [densely_ordered α] [no_min_order α] {s : set α} (hd : dense s) : borel α = generate_from {S : set α | ∃ (l ∈ s) (u ∈ s) (h : l < u), Ico l u = S} := hd.borel_eq_generate_from_Ico_mem_aux (by simp) $ λ x y hxy H, ((nonempty_Ioo.2 hxy).ne_empty H).elim lemma borel_eq_generate_from_Ico (α : Type*) [topological_space α] [second_countable_topology α] [linear_order α] [order_topology α] : borel α = generate_from {S : set α | ∃ l u (h : l < u), Ico l u = S} := by simpa only [exists_prop, mem_univ, true_and] using (@dense_univ α _).borel_eq_generate_from_Ico_mem_aux (λ _ _, mem_univ _) (λ _ _ _ _, mem_univ _) lemma dense.borel_eq_generate_from_Ioc_mem_aux {α : Type*} [topological_space α] [linear_order α] [order_topology α] [second_countable_topology α] {s : set α} (hd : dense s) (hbot : ∀ x, is_top x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → x ∈ s) : borel α = generate_from {S : set α | ∃ (l ∈ s) (u ∈ s) (h : l < u), Ioc l u = S} := begin convert hd.order_dual.borel_eq_generate_from_Ico_mem_aux hbot (λ x y hlt he, hIoo y x hlt _), { ext s, split; rintro ⟨l, hl, u, hu, hlt, rfl⟩, exacts [⟨u, hu, l, hl, hlt, dual_Ico⟩, ⟨u, hu, l, hl, hlt, dual_Ioc⟩] }, { erw dual_Ioo, exact he } end lemma dense.borel_eq_generate_from_Ioc_mem {α : Type*} [topological_space α] [linear_order α] [order_topology α] [second_countable_topology α] [densely_ordered α] [no_max_order α] {s : set α} (hd : dense s) : borel α = generate_from {S : set α | ∃ (l ∈ s) (u ∈ s) (h : l < u), Ioc l u = S} := hd.borel_eq_generate_from_Ioc_mem_aux (by simp) $ λ x y hxy H, ((nonempty_Ioo.2 hxy).ne_empty H).elim lemma borel_eq_generate_from_Ioc (α : Type*) [topological_space α] [second_countable_topology α] [linear_order α] [order_topology α] : borel α = generate_from {S : set α | ∃ l u (h : l < u), Ioc l u = S} := by simpa only [exists_prop, mem_univ, true_and] using (@dense_univ α _).borel_eq_generate_from_Ioc_mem_aux (λ _ _, mem_univ _) (λ _ _ _ _, mem_univ _) namespace measure_theory.measure /-- Two finite measures on a Borel space are equal if they agree on all closed-open intervals. If `α` is a conditionally complete linear order with no top element, `measure_theory.measure..ext_of_Ico` is an extensionality lemma with weaker assumptions on `μ` and `ν`. -/ lemma ext_of_Ico_finite {α : Type*} [topological_space α] {m : measurable_space α} [second_countable_topology α] [linear_order α] [order_topology α] [borel_space α] (μ ν : measure α) [is_finite_measure μ] (hμν : μ univ = ν univ) (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν := begin refine ext_of_generate_finite _ (borel_space.measurable_eq.trans (borel_eq_generate_from_Ico α)) (is_pi_system_Ico (id : α → α) id) _ hμν, { rintro - ⟨a, b, hlt, rfl⟩, exact h hlt } end /-- Two finite measures on a Borel space are equal if they agree on all open-closed intervals. If `α` is a conditionally complete linear order with no top element, `measure_theory.measure..ext_of_Ioc` is an extensionality lemma with weaker assumptions on `μ` and `ν`. -/ lemma ext_of_Ioc_finite {α : Type*} [topological_space α] {m : measurable_space α} [second_countable_topology α] [linear_order α] [order_topology α] [borel_space α] (μ ν : measure α) [is_finite_measure μ] (hμν : μ univ = ν univ) (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν := begin refine @ext_of_Ico_finite (order_dual α) _ _ _ _ _ ‹_› μ ν _ hμν (λ a b hab, _), erw dual_Ico, exact h hab end /-- Two measures which are finite on closed-open intervals are equal if the agree on all closed-open intervals. -/ lemma ext_of_Ico' {α : Type*} [topological_space α] {m : measurable_space α} [second_countable_topology α] [linear_order α] [order_topology α] [borel_space α] [no_max_order α] (μ ν : measure α) (hμ : ∀ ⦃a b⦄, a < b → μ (Ico a b) ≠ ∞) (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν := begin rcases exists_countable_dense_bot_top α with ⟨s, hsc, hsd, hsb, hst⟩, have : countable (⋃ (l ∈ s) (u ∈ s) (h : l < u), {Ico l u} : set (set α)), from hsc.bUnion (λ l hl, hsc.bUnion (λ u hu, countable_Union_Prop $ λ _, countable_singleton _)), simp only [← set_of_eq_eq_singleton, ← set_of_exists] at this, refine measure.ext_of_generate_from_of_cover_subset (borel_space.measurable_eq.trans (borel_eq_generate_from_Ico α)) (is_pi_system_Ico id id) _ this _ _ _, { rintro _ ⟨l, -, u, -, h, rfl⟩, exact ⟨l, u, h, rfl⟩ }, { refine sUnion_eq_univ_iff.2 (λ x, _), rcases hsd.exists_le' hsb x with ⟨l, hls, hlx⟩, rcases hsd.exists_gt x with ⟨u, hus, hxu⟩, exact ⟨_, ⟨l, hls, u, hus, hlx.trans_lt hxu, rfl⟩, hlx, hxu⟩ }, { rintro _ ⟨l, -, u, -, hlt, rfl⟩, exact hμ hlt }, { rintro _ ⟨l, u, hlt, rfl⟩, exact h hlt } end /-- Two measures which are finite on closed-open intervals are equal if the agree on all open-closed intervals. -/ lemma ext_of_Ioc' {α : Type*} [topological_space α] {m : measurable_space α} [second_countable_topology α] [linear_order α] [order_topology α] [borel_space α] [no_min_order α] (μ ν : measure α) (hμ : ∀ ⦃a b⦄, a < b → μ (Ioc a b) ≠ ∞) (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν := begin refine @ext_of_Ico' (order_dual α) _ _ _ _ _ ‹_› _ μ ν _ _; intros a b hab; erw dual_Ico, exacts [hμ hab, h hab] end /-- Two measures which are finite on closed-open intervals are equal if the agree on all closed-open intervals. -/ lemma ext_of_Ico {α : Type*} [topological_space α] {m : measurable_space α} [second_countable_topology α] [conditionally_complete_linear_order α] [order_topology α] [borel_space α] [no_max_order α] (μ ν : measure α) [is_locally_finite_measure μ] (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν := μ.ext_of_Ico' ν (λ a b hab, measure_Ico_lt_top.ne) h /-- Two measures which are finite on closed-open intervals are equal if the agree on all open-closed intervals. -/ lemma ext_of_Ioc {α : Type*} [topological_space α] {m : measurable_space α} [second_countable_topology α] [conditionally_complete_linear_order α] [order_topology α] [borel_space α] [no_min_order α] (μ ν : measure α) [is_locally_finite_measure μ] (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν := μ.ext_of_Ioc' ν (λ a b hab, measure_Ioc_lt_top.ne) h /-- Two finite measures on a Borel space are equal if they agree on all left-infinite right-closed intervals. -/ lemma ext_of_Iic {α : Type*} [topological_space α] {m : measurable_space α} [second_countable_topology α] [linear_order α] [order_topology α] [borel_space α] (μ ν : measure α) [is_finite_measure μ] (h : ∀ a, μ (Iic a) = ν (Iic a)) : μ = ν := begin refine ext_of_Ioc_finite μ ν _ (λ a b hlt, _), { rcases exists_countable_dense_bot_top α with ⟨s, hsc, hsd, -, hst⟩, have : directed_on (≤) s, from directed_on_iff_directed.2 (directed_of_sup $ λ _ _, id), simp only [← bsupr_measure_Iic hsc (hsd.exists_ge' hst) this, h] }, rw [← Iic_diff_Iic, measure_diff (Iic_subset_Iic.2 hlt.le) measurable_set_Iic, measure_diff (Iic_subset_Iic.2 hlt.le) measurable_set_Iic, h a, h b], { rw ← h a, exact (measure_lt_top μ _).ne }, { exact (measure_lt_top μ _).ne } end /-- Two finite measures on a Borel space are equal if they agree on all left-closed right-infinite intervals. -/ lemma ext_of_Ici {α : Type*} [topological_space α] {m : measurable_space α} [second_countable_topology α] [linear_order α] [order_topology α] [borel_space α] (μ ν : measure α) [is_finite_measure μ] (h : ∀ a, μ (Ici a) = ν (Ici a)) : μ = ν := @ext_of_Iic (order_dual α) _ _ _ _ _ ‹_› _ _ _ h end measure_theory.measure end linear_order section linear_order variables [linear_order α] [order_closed_topology α] @[measurability] lemma measurable_set_interval {a b : α} : measurable_set (interval a b) := measurable_set_Icc @[measurability] lemma measurable_set_interval_oc {a b : α} : measurable_set (interval_oc a b) := measurable_set_Ioc variables [second_countable_topology α] @[measurability] lemma measurable.max {f g : δ → α} (hf : measurable f) (hg : measurable g) : measurable (λ a, max (f a) (g a)) := by simpa only [max_def] using hf.piecewise (measurable_set_le hg hf) hg @[measurability] lemma ae_measurable.max {f g : δ → α} {μ : measure δ} (hf : ae_measurable f μ) (hg : ae_measurable g μ) : ae_measurable (λ a, max (f a) (g a)) μ := ⟨λ a, max (hf.mk f a) (hg.mk g a), hf.measurable_mk.max hg.measurable_mk, eventually_eq.comp₂ hf.ae_eq_mk _ hg.ae_eq_mk⟩ @[measurability] lemma measurable.min {f g : δ → α} (hf : measurable f) (hg : measurable g) : measurable (λ a, min (f a) (g a)) := by simpa only [min_def] using hf.piecewise (measurable_set_le hf hg) hg @[measurability] lemma ae_measurable.min {f g : δ → α} {μ : measure δ} (hf : ae_measurable f μ) (hg : ae_measurable g μ) : ae_measurable (λ a, min (f a) (g a)) μ := ⟨λ a, min (hf.mk f a) (hg.mk g a), hf.measurable_mk.min hg.measurable_mk, eventually_eq.comp₂ hf.ae_eq_mk _ hg.ae_eq_mk⟩ end linear_order /-- A continuous function from an `opens_measurable_space` to a `borel_space` is measurable. -/ lemma continuous.measurable {f : α → γ} (hf : continuous f) : measurable f := hf.borel_measurable.mono opens_measurable_space.borel_le (le_of_eq $ borel_space.measurable_eq) /-- A continuous function from an `opens_measurable_space` to a `borel_space` is ae-measurable. -/ lemma continuous.ae_measurable {f : α → γ} (h : continuous f) (μ : measure α) : ae_measurable f μ := h.measurable.ae_measurable lemma closed_embedding.measurable {f : α → γ} (hf : closed_embedding f) : measurable f := hf.continuous.measurable lemma continuous.is_open_pos_measure_map {f : β → γ} (hf : continuous f) (hf_surj : function.surjective f) {μ : measure β} [μ.is_open_pos_measure] : (measure.map f μ).is_open_pos_measure := begin refine ⟨λ U hUo hUne, _⟩, rw [measure.map_apply hf.measurable hUo.measurable_set], exact (hUo.preimage hf).measure_ne_zero μ (hf_surj.nonempty_preimage.mpr hUne) end /-- If a function is defined piecewise in terms of functions which are continuous on their respective pieces, then it is measurable. -/ lemma continuous_on.measurable_piecewise {f g : α → γ} {s : set α} [Π (j : α), decidable (j ∈ s)] (hf : continuous_on f s) (hg : continuous_on g sᶜ) (hs : measurable_set s) : measurable (s.piecewise f g) := begin refine measurable_of_is_open (λ t ht, _), rw [piecewise_preimage, set.ite], apply measurable_set.union, { rcases _root_.continuous_on_iff'.1 hf t ht with ⟨u, u_open, hu⟩, rw hu, exact u_open.measurable_set.inter hs }, { rcases _root_.continuous_on_iff'.1 hg t ht with ⟨u, u_open, hu⟩, rw [diff_eq_compl_inter, inter_comm, hu], exact u_open.measurable_set.inter hs.compl } end @[priority 100, to_additive] instance has_continuous_mul.has_measurable_mul [has_mul γ] [has_continuous_mul γ] : has_measurable_mul γ := { measurable_const_mul := λ c, (continuous_const.mul continuous_id).measurable, measurable_mul_const := λ c, (continuous_id.mul continuous_const).measurable } @[priority 100] instance has_continuous_sub.has_measurable_sub [has_sub γ] [has_continuous_sub γ] : has_measurable_sub γ := { measurable_const_sub := λ c, (continuous_const.sub continuous_id).measurable, measurable_sub_const := λ c, (continuous_id.sub continuous_const).measurable } @[priority 100, to_additive] instance topological_group.has_measurable_inv [group γ] [topological_group γ] : has_measurable_inv γ := ⟨continuous_inv.measurable⟩ @[priority 100] instance has_continuous_smul.has_measurable_smul {M α} [topological_space M] [topological_space α] [measurable_space M] [measurable_space α] [opens_measurable_space M] [borel_space α] [has_scalar M α] [has_continuous_smul M α] : has_measurable_smul M α := ⟨λ c, (continuous_const_smul _).measurable, λ y, (continuous_id.smul continuous_const).measurable⟩ section lattice @[priority 100] instance has_continuous_sup.has_measurable_sup [has_sup γ] [has_continuous_sup γ] : has_measurable_sup γ := { measurable_const_sup := λ c, (continuous_const.sup continuous_id).measurable, measurable_sup_const := λ c, (continuous_id.sup continuous_const).measurable } @[priority 100] instance has_continuous_sup.has_measurable_sup₂ [second_countable_topology γ] [has_sup γ] [has_continuous_sup γ] : has_measurable_sup₂ γ := ⟨continuous_sup.measurable⟩ @[priority 100] instance has_continuous_inf.has_measurable_inf [has_inf γ] [has_continuous_inf γ] : has_measurable_inf γ := { measurable_const_inf := λ c, (continuous_const.inf continuous_id).measurable, measurable_inf_const := λ c, (continuous_id.inf continuous_const).measurable } @[priority 100] instance has_continuous_inf.has_measurable_inf₂ [second_countable_topology γ] [has_inf γ] [has_continuous_inf γ] : has_measurable_inf₂ γ := ⟨continuous_inf.measurable⟩ end lattice section homeomorph @[measurability] protected lemma homeomorph.measurable (h : α ≃ₜ γ) : measurable h := h.continuous.measurable /-- A homeomorphism between two Borel spaces is a measurable equivalence.-/ def homeomorph.to_measurable_equiv (h : γ ≃ₜ γ₂) : γ ≃ᵐ γ₂ := { measurable_to_fun := h.measurable, measurable_inv_fun := h.symm.measurable, to_equiv := h.to_equiv } @[simp] lemma homeomorph.to_measurable_equiv_coe (h : γ ≃ₜ γ₂) : (h.to_measurable_equiv : γ → γ₂) = h := rfl @[simp] lemma homeomorph.to_measurable_equiv_symm_coe (h : γ ≃ₜ γ₂) : (h.to_measurable_equiv.symm : γ₂ → γ) = h.symm := rfl end homeomorph @[measurability] lemma continuous_map.measurable (f : C(α, γ)) : measurable f := f.continuous.measurable lemma measurable_of_continuous_on_compl_singleton [t1_space α] {f : α → γ} (a : α) (hf : continuous_on f {a}ᶜ) : measurable f := measurable_of_measurable_on_compl_singleton a (continuous_on_iff_continuous_restrict.1 hf).measurable lemma continuous.measurable2 [second_countable_topology α] [second_countable_topology β] {f : δ → α} {g : δ → β} {c : α → β → γ} (h : continuous (λ p : α × β, c p.1 p.2)) (hf : measurable f) (hg : measurable g) : measurable (λ a, c (f a) (g a)) := h.measurable.comp (hf.prod_mk hg) lemma continuous.ae_measurable2 [second_countable_topology α] [second_countable_topology β] {f : δ → α} {g : δ → β} {c : α → β → γ} {μ : measure δ} (h : continuous (λ p : α × β, c p.1 p.2)) (hf : ae_measurable f μ) (hg : ae_measurable g μ) : ae_measurable (λ a, c (f a) (g a)) μ := h.measurable.comp_ae_measurable (hf.prod_mk hg) @[priority 100] instance has_continuous_inv₀.has_measurable_inv [group_with_zero γ] [t1_space γ] [has_continuous_inv₀ γ] : has_measurable_inv γ := ⟨measurable_of_continuous_on_compl_singleton 0 continuous_on_inv₀⟩ @[priority 100, to_additive] instance has_continuous_mul.has_measurable_mul₂ [second_countable_topology γ] [has_mul γ] [has_continuous_mul γ] : has_measurable_mul₂ γ := ⟨continuous_mul.measurable⟩ @[priority 100] instance has_continuous_sub.has_measurable_sub₂ [second_countable_topology γ] [has_sub γ] [has_continuous_sub γ] : has_measurable_sub₂ γ := ⟨continuous_sub.measurable⟩ @[priority 100] instance has_continuous_smul.has_measurable_smul₂ {M α} [topological_space M] [second_countable_topology M] [measurable_space M] [opens_measurable_space M] [topological_space α] [second_countable_topology α] [measurable_space α] [borel_space α] [has_scalar M α] [has_continuous_smul M α] : has_measurable_smul₂ M α := ⟨continuous_smul.measurable⟩ end section borel_space variables [topological_space α] [measurable_space α] [borel_space α] [topological_space β] [measurable_space β] [borel_space β] [topological_space γ] [measurable_space γ] [borel_space γ] [measurable_space δ] lemma pi_le_borel_pi {ι : Type*} {π : ι → Type*} [Π i, topological_space (π i)] [Π i, measurable_space (π i)] [∀ i, borel_space (π i)] : measurable_space.pi ≤ borel (Π i, π i) := begin have : ‹Π i, measurable_space (π i)› = λ i, borel (π i) := funext (λ i, borel_space.measurable_eq), rw [this], exact supr_le (λ i, comap_le_iff_le_map.2 $ (continuous_apply i).borel_measurable) end lemma prod_le_borel_prod : prod.measurable_space ≤ borel (α × β) := begin rw [‹borel_space α›.measurable_eq, ‹borel_space β›.measurable_eq], refine sup_le _ _, { exact comap_le_iff_le_map.mpr continuous_fst.borel_measurable }, { exact comap_le_iff_le_map.mpr continuous_snd.borel_measurable } end instance pi.borel_space_fintype_encodable {ι : Type*} {π : ι → Type*} [encodable ι] [t' : Π i, topological_space (π i)] [Π i, measurable_space (π i)] [∀ i, second_countable_topology (π i)] [∀ i, borel_space (π i)] : borel_space (Π i, π i) := ⟨le_antisymm pi_le_borel_pi opens_measurable_space.borel_le⟩ instance pi.borel_space_fintype {ι : Type*} {π : ι → Type*} [fintype ι] [t' : Π i, topological_space (π i)] [Π i, measurable_space (π i)] [∀ i, second_countable_topology (π i)] [∀ i, borel_space (π i)] : borel_space (Π i, π i) := ⟨le_antisymm pi_le_borel_pi opens_measurable_space.borel_le⟩ instance prod.borel_space [second_countable_topology α] [second_countable_topology β] : borel_space (α × β) := ⟨le_antisymm prod_le_borel_prod opens_measurable_space.borel_le⟩ protected lemma embedding.measurable_embedding {f : α → β} (h₁ : embedding f) (h₂ : measurable_set (range f)) : measurable_embedding f := show measurable_embedding (coe ∘ (homeomorph.of_embedding f h₁).to_measurable_equiv), from (measurable_embedding.subtype_coe h₂).comp (measurable_equiv.measurable_embedding _) protected lemma closed_embedding.measurable_embedding {f : α → β} (h : closed_embedding f) : measurable_embedding f := h.to_embedding.measurable_embedding h.closed_range.measurable_set protected lemma open_embedding.measurable_embedding {f : α → β} (h : open_embedding f) : measurable_embedding f := h.to_embedding.measurable_embedding h.open_range.measurable_set section linear_order variables [linear_order α] [order_topology α] [second_countable_topology α] lemma measurable_of_Iio {f : δ → α} (hf : ∀ x, measurable_set (f ⁻¹' Iio x)) : measurable f := begin convert measurable_generate_from _, exact borel_space.measurable_eq.trans (borel_eq_generate_from_Iio _), rintro _ ⟨x, rfl⟩, exact hf x end lemma upper_semicontinuous.measurable [topological_space δ] [opens_measurable_space δ] {f : δ → α} (hf : upper_semicontinuous f) : measurable f := measurable_of_Iio (λ y, (hf.is_open_preimage y).measurable_set) lemma measurable_of_Ioi {f : δ → α} (hf : ∀ x, measurable_set (f ⁻¹' Ioi x)) : measurable f := begin convert measurable_generate_from _, exact borel_space.measurable_eq.trans (borel_eq_generate_from_Ioi _), rintro _ ⟨x, rfl⟩, exact hf x end lemma lower_semicontinuous.measurable [topological_space δ] [opens_measurable_space δ] {f : δ → α} (hf : lower_semicontinuous f) : measurable f := measurable_of_Ioi (λ y, (hf.is_open_preimage y).measurable_set) lemma measurable_of_Iic {f : δ → α} (hf : ∀ x, measurable_set (f ⁻¹' Iic x)) : measurable f := begin apply measurable_of_Ioi, simp_rw [← compl_Iic, preimage_compl, measurable_set.compl_iff], assumption end lemma measurable_of_Ici {f : δ → α} (hf : ∀ x, measurable_set (f ⁻¹' Ici x)) : measurable f := begin apply measurable_of_Iio, simp_rw [← compl_Ici, preimage_compl, measurable_set.compl_iff], assumption end lemma measurable.is_lub {ι} [encodable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, measurable (f i)) (hg : ∀ b, is_lub {a | ∃ i, f i b = a} (g b)) : measurable g := begin change ∀ b, is_lub (range $ λ i, f i b) (g b) at hg, rw [‹borel_space α›.measurable_eq, borel_eq_generate_from_Ioi α], apply measurable_generate_from, rintro _ ⟨a, rfl⟩, simp_rw [set.preimage, mem_Ioi, lt_is_lub_iff (hg _), exists_range_iff, set_of_exists], exact measurable_set.Union (λ i, hf i (is_open_lt' _).measurable_set) end private lemma ae_measurable.is_lub_of_nonempty {ι} (hι : nonempty ι) {μ : measure δ} [encodable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, ae_measurable (f i) μ) (hg : ∀ᵐ b ∂μ, is_lub {a | ∃ i, f i b = a} (g b)) : ae_measurable g μ := begin let p : δ → (ι → α) → Prop := λ x f', is_lub {a | ∃ i, f' i = a} (g x), let g_seq := λ x, ite (x ∈ ae_seq_set hf p) (g x) (⟨g x⟩ : nonempty α).some, have hg_seq : ∀ b, is_lub {a | ∃ i, ae_seq hf p i b = a} (g_seq b), { intro b, haveI hα : nonempty α := nonempty.map g ⟨b⟩, simp only [ae_seq, g_seq], split_ifs, { have h_set_eq : {a : α | ∃ (i : ι), (hf i).mk (f i) b = a} = {a : α | ∃ (i : ι), f i b = a}, { ext x, simp_rw [set.mem_set_of_eq, ae_seq.mk_eq_fun_of_mem_ae_seq_set hf h], }, rw h_set_eq, exact ae_seq.fun_prop_of_mem_ae_seq_set hf h, }, { have h_singleton : {a : α | ∃ (i : ι), hα.some = a} = {hα.some}, { ext1 x, exact ⟨λ hx, hx.some_spec.symm, λ hx, ⟨hι.some, hx.symm⟩⟩, }, rw h_singleton, exact is_lub_singleton, }, }, refine ⟨g_seq, measurable.is_lub (ae_seq.measurable hf p) hg_seq, _⟩, exact (ite_ae_eq_of_measure_compl_zero g (λ x, (⟨g x⟩ : nonempty α).some) (ae_seq_set hf p) (ae_seq.measure_compl_ae_seq_set_eq_zero hf hg)).symm, end lemma ae_measurable.is_lub {ι} {μ : measure δ} [encodable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, ae_measurable (f i) μ) (hg : ∀ᵐ b ∂μ, is_lub {a | ∃ i, f i b = a} (g b)) : ae_measurable g μ := begin by_cases hμ : μ = 0, { rw hμ, exact ae_measurable_zero_measure }, haveI : μ.ae.ne_bot, { simpa [ne_bot_iff] }, by_cases hι : nonempty ι, { exact ae_measurable.is_lub_of_nonempty hι hf hg, }, suffices : ∃ x, g =ᵐ[μ] λ y, g x, by { exact ⟨(λ y, g this.some), measurable_const, this.some_spec⟩, }, have h_empty : ∀ x, {a : α | ∃ (i : ι), f i x = a} = ∅, { intro x, ext1 y, rw [set.mem_set_of_eq, set.mem_empty_eq, iff_false], exact λ hi, hι (nonempty_of_exists hi), }, simp_rw h_empty at hg, exact ⟨hg.exists.some, hg.mono (λ y hy, is_lub.unique hy hg.exists.some_spec)⟩, end lemma measurable.is_glb {ι} [encodable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, measurable (f i)) (hg : ∀ b, is_glb {a | ∃ i, f i b = a} (g b)) : measurable g := begin change ∀ b, is_glb (range $ λ i, f i b) (g b) at hg, rw [‹borel_space α›.measurable_eq, borel_eq_generate_from_Iio α], apply measurable_generate_from, rintro _ ⟨a, rfl⟩, simp_rw [set.preimage, mem_Iio, is_glb_lt_iff (hg _), exists_range_iff, set_of_exists], exact measurable_set.Union (λ i, hf i (is_open_gt' _).measurable_set) end private lemma ae_measurable.is_glb_of_nonempty {ι} (hι : nonempty ι) {μ : measure δ} [encodable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, ae_measurable (f i) μ) (hg : ∀ᵐ b ∂μ, is_glb {a | ∃ i, f i b = a} (g b)) : ae_measurable g μ := begin let p : δ → (ι → α) → Prop := λ x f', is_glb {a | ∃ i, f' i = a} (g x), let g_seq := λ x, ite (x ∈ ae_seq_set hf p) (g x) (⟨g x⟩ : nonempty α).some, have hg_seq : ∀ b, is_glb {a | ∃ i, ae_seq hf p i b = a} (g_seq b), { intro b, haveI hα : nonempty α := nonempty.map g ⟨b⟩, simp only [ae_seq, g_seq], split_ifs, { have h_set_eq : {a : α | ∃ (i : ι), (hf i).mk (f i) b = a} = {a : α | ∃ (i : ι), f i b = a}, { ext x, simp_rw [set.mem_set_of_eq, ae_seq.mk_eq_fun_of_mem_ae_seq_set hf h], }, rw h_set_eq, exact ae_seq.fun_prop_of_mem_ae_seq_set hf h, }, { have h_singleton : {a : α | ∃ (i : ι), hα.some = a} = {hα.some}, { ext1 x, exact ⟨λ hx, hx.some_spec.symm, λ hx, ⟨hι.some, hx.symm⟩⟩, }, rw h_singleton, exact is_glb_singleton, }, }, refine ⟨g_seq, measurable.is_glb (ae_seq.measurable hf p) hg_seq, _⟩, exact (ite_ae_eq_of_measure_compl_zero g (λ x, (⟨g x⟩ : nonempty α).some) (ae_seq_set hf p) (ae_seq.measure_compl_ae_seq_set_eq_zero hf hg)).symm, end lemma ae_measurable.is_glb {ι} {μ : measure δ} [encodable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, ae_measurable (f i) μ) (hg : ∀ᵐ b ∂μ, is_glb {a | ∃ i, f i b = a} (g b)) : ae_measurable g μ := begin by_cases hμ : μ = 0, { rw hμ, exact ae_measurable_zero_measure }, haveI : μ.ae.ne_bot, { simpa [ne_bot_iff] }, by_cases hι : nonempty ι, { exact ae_measurable.is_glb_of_nonempty hι hf hg, }, suffices : ∃ x, g =ᵐ[μ] λ y, g x, by { exact ⟨(λ y, g this.some), measurable_const, this.some_spec⟩, }, have h_empty : ∀ x, {a : α | ∃ (i : ι), f i x = a} = ∅, { intro x, ext1 y, rw [set.mem_set_of_eq, set.mem_empty_eq, iff_false], exact λ hi, hι (nonempty_of_exists hi), }, simp_rw h_empty at hg, exact ⟨hg.exists.some, hg.mono (λ y hy, is_glb.unique hy hg.exists.some_spec)⟩, end protected lemma monotone.measurable [linear_order β] [order_closed_topology β] {f : β → α} (hf : monotone f) : measurable f := suffices h : ∀ x, ord_connected (f ⁻¹' Ioi x), from measurable_of_Ioi (λ x, (h x).measurable_set), λ x, ord_connected_def.mpr (λ a ha b hb c hc, lt_of_lt_of_le ha (hf hc.1)) lemma ae_measurable_restrict_of_monotone_on [linear_order β] [order_closed_topology β] {μ : measure β} {s : set β} (hs : measurable_set s) {f : β → α} (hf : monotone_on f s) : ae_measurable f (μ.restrict s) := have this : monotone (f ∘ coe : s → α), from λ ⟨x, hx⟩ ⟨y, hy⟩ (hxy : x ≤ y), hf hx hy hxy, ae_measurable_restrict_of_measurable_subtype hs this.measurable protected lemma antitone.measurable [linear_order β] [order_closed_topology β] {f : β → α} (hf : antitone f) : measurable f := @monotone.measurable (order_dual α) β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ hf lemma ae_measurable_restrict_of_antitone_on [linear_order β] [order_closed_topology β] {μ : measure β} {s : set β} (hs : measurable_set s) {f : β → α} (hf : antitone_on f s) : ae_measurable f (μ.restrict s) := @ae_measurable_restrict_of_monotone_on (order_dual α) β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ _ hs _ hf end linear_order @[measurability] lemma measurable.supr_Prop {α} [measurable_space α] [complete_lattice α] (p : Prop) {f : δ → α} (hf : measurable f) : measurable (λ b, ⨆ h : p, f b) := classical.by_cases (assume h : p, begin convert hf, funext, exact supr_pos h end) (assume h : ¬p, begin convert measurable_const, funext, exact supr_neg h end) @[measurability] lemma measurable.infi_Prop {α} [measurable_space α] [complete_lattice α] (p : Prop) {f : δ → α} (hf : measurable f) : measurable (λ b, ⨅ h : p, f b) := classical.by_cases (assume h : p, begin convert hf, funext, exact infi_pos h end ) (assume h : ¬p, begin convert measurable_const, funext, exact infi_neg h end) section complete_linear_order variables [complete_linear_order α] [order_topology α] [second_countable_topology α] @[measurability] lemma measurable_supr {ι} [encodable ι] {f : ι → δ → α} (hf : ∀ i, measurable (f i)) : measurable (λ b, ⨆ i, f i b) := measurable.is_lub hf $ λ b, is_lub_supr @[measurability] lemma ae_measurable_supr {ι} {μ : measure δ} [encodable ι] {f : ι → δ → α} (hf : ∀ i, ae_measurable (f i) μ) : ae_measurable (λ b, ⨆ i, f i b) μ := ae_measurable.is_lub hf $ (ae_of_all μ (λ b, is_lub_supr)) @[measurability] lemma measurable_infi {ι} [encodable ι] {f : ι → δ → α} (hf : ∀ i, measurable (f i)) : measurable (λ b, ⨅ i, f i b) := measurable.is_glb hf $ λ b, is_glb_infi @[measurability] lemma ae_measurable_infi {ι} {μ : measure δ} [encodable ι] {f : ι → δ → α} (hf : ∀ i, ae_measurable (f i) μ) : ae_measurable (λ b, ⨅ i, f i b) μ := ae_measurable.is_glb hf $ (ae_of_all μ (λ b, is_glb_infi)) lemma measurable_bsupr {ι} (s : set ι) {f : ι → δ → α} (hs : countable s) (hf : ∀ i, measurable (f i)) : measurable (λ b, ⨆ i ∈ s, f i b) := by { haveI : encodable s := hs.to_encodable, simp only [supr_subtype'], exact measurable_supr (λ i, hf i) } lemma ae_measurable_bsupr {ι} {μ : measure δ} (s : set ι) {f : ι → δ → α} (hs : countable s) (hf : ∀ i, ae_measurable (f i) μ) : ae_measurable (λ b, ⨆ i ∈ s, f i b) μ := begin haveI : encodable s := hs.to_encodable, simp only [supr_subtype'], exact ae_measurable_supr (λ i, hf i), end lemma measurable_binfi {ι} (s : set ι) {f : ι → δ → α} (hs : countable s) (hf : ∀ i, measurable (f i)) : measurable (λ b, ⨅ i ∈ s, f i b) := by { haveI : encodable s := hs.to_encodable, simp only [infi_subtype'], exact measurable_infi (λ i, hf i) } lemma ae_measurable_binfi {ι} {μ : measure δ} (s : set ι) {f : ι → δ → α} (hs : countable s) (hf : ∀ i, ae_measurable (f i) μ) : ae_measurable (λ b, ⨅ i ∈ s, f i b) μ := begin haveI : encodable s := hs.to_encodable, simp only [infi_subtype'], exact ae_measurable_infi (λ i, hf i), end /-- `liminf` over a general filter is measurable. See `measurable_liminf` for the version over `ℕ`. -/ lemma measurable_liminf' {ι ι'} {f : ι → δ → α} {u : filter ι} (hf : ∀ i, measurable (f i)) {p : ι' → Prop} {s : ι' → set ι} (hu : u.has_countable_basis p s) (hs : ∀ i, (s i).countable) : measurable (λ x, liminf u (λ i, f i x)) := begin simp_rw [hu.to_has_basis.liminf_eq_supr_infi], refine measurable_bsupr _ hu.countable _, exact λ i, measurable_binfi _ (hs i) hf end /-- `limsup` over a general filter is measurable. See `measurable_limsup` for the version over `ℕ`. -/ lemma measurable_limsup' {ι ι'} {f : ι → δ → α} {u : filter ι} (hf : ∀ i, measurable (f i)) {p : ι' → Prop} {s : ι' → set ι} (hu : u.has_countable_basis p s) (hs : ∀ i, (s i).countable) : measurable (λ x, limsup u (λ i, f i x)) := begin simp_rw [hu.to_has_basis.limsup_eq_infi_supr], refine measurable_binfi _ hu.countable _, exact λ i, measurable_bsupr _ (hs i) hf end /-- `liminf` over `ℕ` is measurable. See `measurable_liminf'` for a version with a general filter. -/ @[measurability] lemma measurable_liminf {f : ℕ → δ → α} (hf : ∀ i, measurable (f i)) : measurable (λ x, liminf at_top (λ i, f i x)) := measurable_liminf' hf at_top_countable_basis (λ i, countable_encodable _) /-- `limsup` over `ℕ` is measurable. See `measurable_limsup'` for a version with a general filter. -/ @[measurability] lemma measurable_limsup {f : ℕ → δ → α} (hf : ∀ i, measurable (f i)) : measurable (λ x, limsup at_top (λ i, f i x)) := measurable_limsup' hf at_top_countable_basis (λ i, countable_encodable _) end complete_linear_order section conditionally_complete_linear_order variables [conditionally_complete_linear_order α] [order_topology α] [second_countable_topology α] lemma measurable_cSup {ι} {f : ι → δ → α} {s : set ι} (hs : s.countable) (hf : ∀ i, measurable (f i)) (bdd : ∀ x, bdd_above ((λ i, f i x) '' s)) : measurable (λ x, Sup ((λ i, f i x) '' s)) := begin cases eq_empty_or_nonempty s with h2s h2s, { simp [h2s, measurable_const] }, { apply measurable_of_Iic, intro y, simp_rw [preimage, mem_Iic, cSup_le_iff (bdd _) (h2s.image _), ball_image_iff, set_of_forall], exact measurable_set.bInter hs (λ i hi, measurable_set_le (hf i) measurable_const) } end end conditionally_complete_linear_order /-- Convert a `homeomorph` to a `measurable_equiv`. -/ def homemorph.to_measurable_equiv (h : α ≃ₜ β) : α ≃ᵐ β := { to_equiv := h.to_equiv, measurable_to_fun := h.continuous_to_fun.measurable, measurable_inv_fun := h.continuous_inv_fun.measurable } protected lemma is_finite_measure_on_compacts.map {α : Type*} {m0 : measurable_space α} [topological_space α] [opens_measurable_space α] {β : Type*} [measurable_space β] [topological_space β] [borel_space β] [t2_space β] (μ : measure α) [is_finite_measure_on_compacts μ] (f : α ≃ₜ β) : is_finite_measure_on_compacts (measure.map f μ) := ⟨begin assume K hK, rw [measure.map_apply f.measurable hK.measurable_set], apply is_compact.measure_lt_top, rwa f.compact_preimage end⟩ end borel_space instance empty.borel_space : borel_space empty := ⟨borel_eq_top_of_discrete.symm⟩ instance unit.borel_space : borel_space unit := ⟨borel_eq_top_of_discrete.symm⟩ instance bool.borel_space : borel_space bool := ⟨borel_eq_top_of_discrete.symm⟩ instance nat.borel_space : borel_space ℕ := ⟨borel_eq_top_of_discrete.symm⟩ instance int.borel_space : borel_space ℤ := ⟨borel_eq_top_of_discrete.symm⟩ instance rat.borel_space : borel_space ℚ := ⟨borel_eq_top_of_encodable.symm⟩ @[priority 900] instance is_R_or_C.measurable_space {𝕜 : Type*} [is_R_or_C 𝕜] : measurable_space 𝕜 := borel 𝕜 @[priority 900] instance is_R_or_C.borel_space {𝕜 : Type*} [is_R_or_C 𝕜] : borel_space 𝕜 := ⟨rfl⟩ /- Instances on `real` and `complex` are special cases of `is_R_or_C` but without these instances, Lean fails to prove `borel_space (ι → ℝ)`, so we leave them here. -/ instance real.measurable_space : measurable_space ℝ := borel ℝ instance real.borel_space : borel_space ℝ := ⟨rfl⟩ instance nnreal.measurable_space : measurable_space ℝ≥0 := subtype.measurable_space instance nnreal.borel_space : borel_space ℝ≥0 := subtype.borel_space _ instance ennreal.measurable_space : measurable_space ℝ≥0∞ := borel ℝ≥0∞ instance ennreal.borel_space : borel_space ℝ≥0∞ := ⟨rfl⟩ instance ereal.measurable_space : measurable_space ereal := borel ereal instance ereal.borel_space : borel_space ereal := ⟨rfl⟩ instance complex.measurable_space : measurable_space ℂ := borel ℂ instance complex.borel_space : borel_space ℂ := ⟨rfl⟩ /-- One can cut out `ℝ≥0∞` into the sets `{0}`, `Ico (t^n) (t^(n+1))` for `n : ℤ` and `{∞}`. This gives a way to compute the measure of a set in terms of sets on which a given function `f` does not fluctuate by more than `t`. -/ lemma measure_eq_measure_preimage_add_measure_tsum_Ico_zpow [measurable_space α] (μ : measure α) {f : α → ℝ≥0∞} (hf : measurable f) {s : set α} (hs : measurable_set s) {t : ℝ≥0} (ht : 1 < t) : μ s = μ (s ∩ f⁻¹' {0}) + μ (s ∩ f⁻¹' {∞}) + ∑' (n : ℤ), μ (s ∩ f⁻¹' (Ico (t^n) (t^(n+1)))) := begin have A : μ s = μ (s ∩ f⁻¹' {0}) + μ (s ∩ f⁻¹' (Ioi 0)), { rw ← measure_union, { congr' 1, ext x, have : 0 = f x ∨ 0 < f x := eq_or_lt_of_le bot_le, rw eq_comm at this, simp only [←and_or_distrib_left, this, mem_singleton_iff, mem_inter_eq, and_true, mem_union_eq, mem_Ioi, mem_preimage], }, { apply disjoint_left.2 (λ x hx h'x, _), have : 0 < f x := h'x.2, exact lt_irrefl 0 (this.trans_le hx.2.le) }, { exact hs.inter (hf measurable_set_Ioi) } }, have B : μ (s ∩ f⁻¹' (Ioi 0)) = μ (s ∩ f⁻¹' {∞}) + μ (s ∩ f⁻¹' (Ioo 0 ∞)), { rw ← measure_union, { rw ← inter_union_distrib_left, congr, ext x, simp only [mem_singleton_iff, mem_union_eq, mem_Ioo, mem_Ioi, mem_preimage], have H : f x = ∞ ∨ f x < ∞ := eq_or_lt_of_le le_top, cases H, { simp only [H, eq_self_iff_true, or_false, with_top.zero_lt_top, not_top_lt, and_false] }, { simp only [H, H.ne, and_true, false_or] } }, { apply disjoint_left.2 (λ x hx h'x, _), have : f x < ∞ := h'x.2.2, exact lt_irrefl _ (this.trans_le (le_of_eq hx.2.symm)) }, { exact hs.inter (hf measurable_set_Ioo) } }, have C : μ (s ∩ f⁻¹' (Ioo 0 ∞)) = ∑' (n : ℤ), μ (s ∩ f⁻¹' (Ico (t^n) (t^(n+1)))), { rw [← measure_Union, ennreal.Ioo_zero_top_eq_Union_Ico_zpow (ennreal.one_lt_coe_iff.2 ht) ennreal.coe_ne_top, preimage_Union, inter_Union], { assume i j, simp only [function.on_fun], wlog h : i ≤ j := le_total i j using [i j, j i] tactic.skip, { assume hij, replace hij : i + 1 ≤ j := lt_of_le_of_ne h hij, apply disjoint_left.2 (λ x hx h'x, lt_irrefl (f x) _), calc f x < t ^ (i + 1) : hx.2.2 ... ≤ t ^ j : ennreal.zpow_le_of_le (ennreal.one_le_coe_iff.2 ht.le) hij ... ≤ f x : h'x.2.1 }, { assume hij, rw disjoint.comm, exact this hij.symm } }, { assume n, exact hs.inter (hf measurable_set_Ico) } }, rw [A, B, C, add_assoc], end section metric_space variables [metric_space α] [measurable_space α] [opens_measurable_space α] variables [measurable_space β] {x : α} {ε : ℝ} open metric @[measurability] lemma measurable_set_ball : measurable_set (metric.ball x ε) := metric.is_open_ball.measurable_set @[measurability] lemma measurable_set_closed_ball : measurable_set (metric.closed_ball x ε) := metric.is_closed_ball.measurable_set @[measurability] lemma measurable_inf_dist {s : set α} : measurable (λ x, inf_dist x s) := (continuous_inf_dist_pt s).measurable @[measurability] lemma measurable.inf_dist {f : β → α} (hf : measurable f) {s : set α} : measurable (λ x, inf_dist (f x) s) := measurable_inf_dist.comp hf @[measurability] lemma measurable_inf_nndist {s : set α} : measurable (λ x, inf_nndist x s) := (continuous_inf_nndist_pt s).measurable @[measurability] lemma measurable.inf_nndist {f : β → α} (hf : measurable f) {s : set α} : measurable (λ x, inf_nndist (f x) s) := measurable_inf_nndist.comp hf section variables [second_countable_topology α] @[measurability] lemma measurable_dist : measurable (λ p : α × α, dist p.1 p.2) := continuous_dist.measurable @[measurability] lemma measurable.dist {f g : β → α} (hf : measurable f) (hg : measurable g) : measurable (λ b, dist (f b) (g b)) := (@continuous_dist α _).measurable2 hf hg @[measurability] lemma measurable_nndist : measurable (λ p : α × α, nndist p.1 p.2) := continuous_nndist.measurable @[measurability] lemma measurable.nndist {f g : β → α} (hf : measurable f) (hg : measurable g) : measurable (λ b, nndist (f b) (g b)) := (@continuous_nndist α _).measurable2 hf hg end /-- If a set has a closed thickening with finite measure, then the measure of its `r`-closed thickenings converges to the measure of its closure as `r` tends to `0`. -/ lemma tendsto_measure_cthickening {μ : measure α} {s : set α} (hs : ∃ R > 0, μ (cthickening R s) ≠ ∞) : tendsto (λ r, μ (cthickening r s)) (𝓝 0) (𝓝 (μ (closure s))) := begin have A : tendsto (λ r, μ (cthickening r s)) (𝓝[Ioi 0] 0) (𝓝 (μ (closure s))), { rw closure_eq_Inter_cthickening, exact tendsto_measure_bInter_gt (λ r hr, is_closed_cthickening.measurable_set) (λ i j ipos ij, cthickening_mono ij _) hs }, have B : tendsto (λ r, μ (cthickening r s)) (𝓝[Iic 0] 0) (𝓝 (μ (closure s))), { apply tendsto.congr' _ tendsto_const_nhds, filter_upwards [self_mem_nhds_within] with _ hr, rw cthickening_of_nonpos hr, }, convert B.sup A, exact (nhds_left_sup_nhds_right' 0).symm, end /-- If a closed set has a closed thickening with finite measure, then the measure of its `r`-closed thickenings converges to its measure as `r` tends to `0`. -/ lemma tendsto_measure_cthickening_of_is_closed {μ : measure α} {s : set α} (hs : ∃ R > 0, μ (cthickening R s) ≠ ∞) (h's : is_closed s) : tendsto (λ r, μ (cthickening r s)) (𝓝 0) (𝓝 (μ s)) := begin convert tendsto_measure_cthickening hs, exact h's.closure_eq.symm end /-- Given a compact set in a proper space, the measure of its `r`-closed thickenings converges to its measure as `r` tends to `0`. -/ lemma tendsto_measure_cthickening_of_is_compact [proper_space α] {μ : measure α} [is_finite_measure_on_compacts μ] {s : set α} (hs : is_compact s) : tendsto (λ r, μ (cthickening r s)) (𝓝 0) (𝓝 (μ s)) := tendsto_measure_cthickening_of_is_closed ⟨1, zero_lt_one, (bounded.measure_lt_top hs.bounded.cthickening).ne⟩ hs.is_closed end metric_space section emetric_space variables [emetric_space α] [measurable_space α] [opens_measurable_space α] variables [measurable_space β] {x : α} {ε : ℝ≥0∞} open emetric @[measurability] lemma measurable_set_eball : measurable_set (emetric.ball x ε) := emetric.is_open_ball.measurable_set @[measurability] lemma measurable_edist_right : measurable (edist x) := (continuous_const.edist continuous_id).measurable @[measurability] lemma measurable_edist_left : measurable (λ y, edist y x) := (continuous_id.edist continuous_const).measurable @[measurability] lemma measurable_inf_edist {s : set α} : measurable (λ x, inf_edist x s) := continuous_inf_edist.measurable @[measurability] lemma measurable.inf_edist {f : β → α} (hf : measurable f) {s : set α} : measurable (λ x, inf_edist (f x) s) := measurable_inf_edist.comp hf variables [second_countable_topology α] @[measurability] lemma measurable_edist : measurable (λ p : α × α, edist p.1 p.2) := continuous_edist.measurable @[measurability] lemma measurable.edist {f g : β → α} (hf : measurable f) (hg : measurable g) : measurable (λ b, edist (f b) (g b)) := (@continuous_edist α _).measurable2 hf hg @[measurability] lemma ae_measurable.edist {f g : β → α} {μ : measure β} (hf : ae_measurable f μ) (hg : ae_measurable g μ) : ae_measurable (λ a, edist (f a) (g a)) μ := (@continuous_edist α _).ae_measurable2 hf hg end emetric_space namespace real open measurable_space measure_theory lemma borel_eq_generate_from_Ioo_rat : borel ℝ = generate_from (⋃(a b : ℚ) (h : a < b), {Ioo a b}) := is_topological_basis_Ioo_rat.borel_eq_generate_from lemma is_pi_system_Ioo_rat : @is_pi_system ℝ (⋃ (a b : ℚ) (h : a < b), {Ioo a b}) := begin convert is_pi_system_Ioo (coe : ℚ → ℝ) (coe : ℚ → ℝ), ext x, simp [eq_comm] end /-- The intervals `(-(n + 1), (n + 1))` form a finite spanning sets in the set of open intervals with rational endpoints for a locally finite measure `μ` on `ℝ`. -/ def finite_spanning_sets_in_Ioo_rat (μ : measure ℝ) [is_locally_finite_measure μ] : μ.finite_spanning_sets_in (⋃ (a b : ℚ) (h : a < b), {Ioo a b}) := { set := λ n, Ioo (-(n + 1)) (n + 1), set_mem := λ n, begin simp only [mem_Union, mem_singleton_iff], refine ⟨-(n + 1), n + 1, _, by norm_cast⟩, exact (neg_nonpos.2 (@nat.cast_nonneg ℚ _ (n + 1))).trans_lt n.cast_add_one_pos end, finite := λ n, measure_Ioo_lt_top, spanning := Union_eq_univ_iff.2 $ λ x, ⟨⌊|x|⌋₊, neg_lt.1 ((neg_le_abs_self x).trans_lt (nat.lt_floor_add_one _)), (le_abs_self x).trans_lt (nat.lt_floor_add_one _)⟩ } lemma measure_ext_Ioo_rat {μ ν : measure ℝ} [is_locally_finite_measure μ] (h : ∀ a b : ℚ, μ (Ioo a b) = ν (Ioo a b)) : μ = ν := (finite_spanning_sets_in_Ioo_rat μ).ext borel_eq_generate_from_Ioo_rat is_pi_system_Ioo_rat $ by { simp only [mem_Union, mem_singleton_iff], rintro _ ⟨a, b, -, rfl⟩, apply h } lemma borel_eq_generate_from_Iio_rat : borel ℝ = generate_from (⋃ a : ℚ, {Iio a}) := begin let g : measurable_space ℝ := generate_from (⋃ a : ℚ, {Iio a}), refine le_antisymm _ _, { rw borel_eq_generate_from_Ioo_rat, refine generate_from_le (λ t, _), simp only [mem_Union, mem_singleton_iff], rintro ⟨a, b, h, rfl⟩, rw (set.ext (λ x, _) : Ioo (a : ℝ) b = (⋃c>a, (Iio c)ᶜ) ∩ Iio b), { have hg : ∀ q : ℚ, g.measurable_set' (Iio q) := λ q, generate_measurable.basic (Iio q) (by simp), refine @measurable_set.inter _ g _ _ _ (hg _), refine @measurable_set.bUnion _ _ g _ _ (countable_encodable _) (λ c h, _), exact @measurable_set.compl _ _ g (hg _) }, { suffices : x < ↑b → (↑a < x ↔ ∃ (i : ℚ), a < i ∧ ↑i ≤ x), by simpa, refine λ _, ⟨λ h, _, λ ⟨i, hai, hix⟩, (rat.cast_lt.2 hai).trans_le hix⟩, rcases exists_rat_btwn h with ⟨c, ac, cx⟩, exact ⟨c, rat.cast_lt.1 ac, cx.le⟩ } }, { refine measurable_space.generate_from_le (λ _, _), simp only [mem_Union, mem_singleton_iff], rintro ⟨r, rfl⟩, exact measurable_set_Iio } end end real variable [measurable_space α] @[measurability] lemma measurable_real_to_nnreal : measurable (real.to_nnreal) := continuous_real_to_nnreal.measurable @[measurability] lemma measurable.real_to_nnreal {f : α → ℝ} (hf : measurable f) : measurable (λ x, real.to_nnreal (f x)) := measurable_real_to_nnreal.comp hf @[measurability] lemma ae_measurable.real_to_nnreal {f : α → ℝ} {μ : measure α} (hf : ae_measurable f μ) : ae_measurable (λ x, real.to_nnreal (f x)) μ := measurable_real_to_nnreal.comp_ae_measurable hf @[measurability] lemma measurable_coe_nnreal_real : measurable (coe : ℝ≥0 → ℝ) := nnreal.continuous_coe.measurable @[measurability] lemma measurable.coe_nnreal_real {f : α → ℝ≥0} (hf : measurable f) : measurable (λ x, (f x : ℝ)) := measurable_coe_nnreal_real.comp hf @[measurability] lemma ae_measurable.coe_nnreal_real {f : α → ℝ≥0} {μ : measure α} (hf : ae_measurable f μ) : ae_measurable (λ x, (f x : ℝ)) μ := measurable_coe_nnreal_real.comp_ae_measurable hf @[measurability] lemma measurable_coe_nnreal_ennreal : measurable (coe : ℝ≥0 → ℝ≥0∞) := ennreal.continuous_coe.measurable @[measurability] lemma measurable.coe_nnreal_ennreal {f : α → ℝ≥0} (hf : measurable f) : measurable (λ x, (f x : ℝ≥0∞)) := ennreal.continuous_coe.measurable.comp hf @[measurability] lemma ae_measurable.coe_nnreal_ennreal {f : α → ℝ≥0} {μ : measure α} (hf : ae_measurable f μ) : ae_measurable (λ x, (f x : ℝ≥0∞)) μ := ennreal.continuous_coe.measurable.comp_ae_measurable hf @[measurability] lemma measurable.ennreal_of_real {f : α → ℝ} (hf : measurable f) : measurable (λ x, ennreal.of_real (f x)) := ennreal.continuous_of_real.measurable.comp hf /-- The set of finite `ℝ≥0∞` numbers is `measurable_equiv` to `ℝ≥0`. -/ def measurable_equiv.ennreal_equiv_nnreal : {r : ℝ≥0∞ | r ≠ ∞} ≃ᵐ ℝ≥0 := ennreal.ne_top_homeomorph_nnreal.to_measurable_equiv namespace ennreal lemma measurable_of_measurable_nnreal {f : ℝ≥0∞ → α} (h : measurable (λ p : ℝ≥0, f p)) : measurable f := measurable_of_measurable_on_compl_singleton ∞ (measurable_equiv.ennreal_equiv_nnreal.symm.measurable_comp_iff.1 h) /-- `ℝ≥0∞` is `measurable_equiv` to `ℝ≥0 ⊕ unit`. -/ def ennreal_equiv_sum : ℝ≥0∞ ≃ᵐ ℝ≥0 ⊕ unit := { measurable_to_fun := measurable_of_measurable_nnreal measurable_inl, measurable_inv_fun := measurable_sum measurable_coe_nnreal_ennreal (@measurable_const ℝ≥0∞ unit _ _ ∞), .. equiv.option_equiv_sum_punit ℝ≥0 } open function (uncurry) lemma measurable_of_measurable_nnreal_prod [measurable_space β] [measurable_space γ] {f : ℝ≥0∞ × β → γ} (H₁ : measurable (λ p : ℝ≥0 × β, f (p.1, p.2))) (H₂ : measurable (λ x, f (∞, x))) : measurable f := let e : ℝ≥0∞ × β ≃ᵐ ℝ≥0 × β ⊕ unit × β := (ennreal_equiv_sum.prod_congr (measurable_equiv.refl β)).trans (measurable_equiv.sum_prod_distrib _ _ _) in e.symm.measurable_comp_iff.1 $ measurable_sum H₁ (H₂.comp measurable_id.snd) lemma measurable_of_measurable_nnreal_nnreal [measurable_space β] {f : ℝ≥0∞ × ℝ≥0∞ → β} (h₁ : measurable (λ p : ℝ≥0 × ℝ≥0, f (p.1, p.2))) (h₂ : measurable (λ r : ℝ≥0, f (∞, r))) (h₃ : measurable (λ r : ℝ≥0, f (r, ∞))) : measurable f := measurable_of_measurable_nnreal_prod (measurable_swap_iff.1 $ measurable_of_measurable_nnreal_prod (h₁.comp measurable_swap) h₃) (measurable_of_measurable_nnreal h₂) @[measurability] lemma measurable_of_real : measurable ennreal.of_real := ennreal.continuous_of_real.measurable @[measurability] lemma measurable_to_real : measurable ennreal.to_real := ennreal.measurable_of_measurable_nnreal measurable_coe_nnreal_real @[measurability] lemma measurable_to_nnreal : measurable ennreal.to_nnreal := ennreal.measurable_of_measurable_nnreal measurable_id instance : has_measurable_mul₂ ℝ≥0∞ := begin refine ⟨measurable_of_measurable_nnreal_nnreal _ _ _⟩, { simp only [← ennreal.coe_mul, measurable_mul.coe_nnreal_ennreal] }, { simp only [ennreal.top_mul, ennreal.coe_eq_zero], exact measurable_const.piecewise (measurable_set_singleton _) measurable_const }, { simp only [ennreal.mul_top, ennreal.coe_eq_zero], exact measurable_const.piecewise (measurable_set_singleton _) measurable_const } end instance : has_measurable_sub₂ ℝ≥0∞ := ⟨by apply measurable_of_measurable_nnreal_nnreal; simp [← with_top.coe_sub, continuous_sub.measurable.coe_nnreal_ennreal]⟩ instance : has_measurable_inv ℝ≥0∞ := ⟨continuous_inv.measurable⟩ end ennreal @[measurability] lemma measurable.ennreal_to_nnreal {f : α → ℝ≥0∞} (hf : measurable f) : measurable (λ x, (f x).to_nnreal) := ennreal.measurable_to_nnreal.comp hf @[measurability] lemma ae_measurable.ennreal_to_nnreal {f : α → ℝ≥0∞} {μ : measure α} (hf : ae_measurable f μ) : ae_measurable (λ x, (f x).to_nnreal) μ := ennreal.measurable_to_nnreal.comp_ae_measurable hf lemma measurable_coe_nnreal_ennreal_iff {f : α → ℝ≥0} : measurable (λ x, (f x : ℝ≥0∞)) ↔ measurable f := ⟨λ h, h.ennreal_to_nnreal, λ h, h.coe_nnreal_ennreal⟩ @[measurability] lemma measurable.ennreal_to_real {f : α → ℝ≥0∞} (hf : measurable f) : measurable (λ x, ennreal.to_real (f x)) := ennreal.measurable_to_real.comp hf @[measurability] lemma ae_measurable.ennreal_to_real {f : α → ℝ≥0∞} {μ : measure α} (hf : ae_measurable f μ) : ae_measurable (λ x, ennreal.to_real (f x)) μ := ennreal.measurable_to_real.comp_ae_measurable hf /-- note: `ℝ≥0∞` can probably be generalized in a future version of this lemma. -/ @[measurability] lemma measurable.ennreal_tsum {ι} [encodable ι] {f : ι → α → ℝ≥0∞} (h : ∀ i, measurable (f i)) : measurable (λ x, ∑' i, f i x) := by { simp_rw [ennreal.tsum_eq_supr_sum], apply measurable_supr, exact λ s, s.measurable_sum (λ i _, h i) } @[measurability] lemma measurable.ennreal_tsum' {ι} [encodable ι] {f : ι → α → ℝ≥0∞} (h : ∀ i, measurable (f i)) : measurable (∑' i, f i) := begin convert measurable.ennreal_tsum h, ext1 x, exact tsum_apply (pi.summable.2 (λ _, ennreal.summable)), end @[measurability] lemma measurable.nnreal_tsum {ι} [encodable ι] {f : ι → α → ℝ≥0} (h : ∀ i, measurable (f i)) : measurable (λ x, ∑' i, f i x) := begin simp_rw [nnreal.tsum_eq_to_nnreal_tsum], exact (measurable.ennreal_tsum (λ i, (h i).coe_nnreal_ennreal)).ennreal_to_nnreal, end @[measurability] lemma ae_measurable.ennreal_tsum {ι} [encodable ι] {f : ι → α → ℝ≥0∞} {μ : measure α} (h : ∀ i, ae_measurable (f i) μ) : ae_measurable (λ x, ∑' i, f i x) μ := by { simp_rw [ennreal.tsum_eq_supr_sum], apply ae_measurable_supr, exact λ s, finset.ae_measurable_sum s (λ i _, h i) } @[measurability] lemma measurable_coe_real_ereal : measurable (coe : ℝ → ereal) := continuous_coe_real_ereal.measurable @[measurability] lemma measurable.coe_real_ereal {f : α → ℝ} (hf : measurable f) : measurable (λ x, (f x : ereal)) := measurable_coe_real_ereal.comp hf @[measurability] lemma ae_measurable.coe_real_ereal {f : α → ℝ} {μ : measure α} (hf : ae_measurable f μ) : ae_measurable (λ x, (f x : ereal)) μ := measurable_coe_real_ereal.comp_ae_measurable hf /-- The set of finite `ereal` numbers is `measurable_equiv` to `ℝ`. -/ def measurable_equiv.ereal_equiv_real : ({⊥, ⊤} : set ereal).compl ≃ᵐ ℝ := ereal.ne_bot_top_homeomorph_real.to_measurable_equiv lemma ereal.measurable_of_measurable_real {f : ereal → α} (h : measurable (λ p : ℝ, f p)) : measurable f := measurable_of_measurable_on_compl_finite {⊥, ⊤} (by simp) (measurable_equiv.ereal_equiv_real.symm.measurable_comp_iff.1 h) @[measurability] lemma measurable_ereal_to_real : measurable ereal.to_real := ereal.measurable_of_measurable_real (by simpa using measurable_id) @[measurability] lemma measurable.ereal_to_real {f : α → ereal} (hf : measurable f) : measurable (λ x, (f x).to_real) := measurable_ereal_to_real.comp hf @[measurability] lemma ae_measurable.ereal_to_real {f : α → ereal} {μ : measure α} (hf : ae_measurable f μ) : ae_measurable (λ x, (f x).to_real) μ := measurable_ereal_to_real.comp_ae_measurable hf @[measurability] lemma measurable_coe_ennreal_ereal : measurable (coe : ℝ≥0∞ → ereal) := continuous_coe_ennreal_ereal.measurable @[measurability] lemma measurable.coe_ereal_ennreal {f : α → ℝ≥0∞} (hf : measurable f) : measurable (λ x, (f x : ereal)) := measurable_coe_ennreal_ereal.comp hf @[measurability] lemma ae_measurable.coe_ereal_ennreal {f : α → ℝ≥0∞} {μ : measure α} (hf : ae_measurable f μ) : ae_measurable (λ x, (f x : ereal)) μ := measurable_coe_ennreal_ereal.comp_ae_measurable hf section normed_group variables [normed_group α] [opens_measurable_space α] [measurable_space β] @[measurability] lemma measurable_norm : measurable (norm : α → ℝ) := continuous_norm.measurable @[measurability] lemma measurable.norm {f : β → α} (hf : measurable f) : measurable (λ a, norm (f a)) := measurable_norm.comp hf @[measurability] lemma ae_measurable.norm {f : β → α} {μ : measure β} (hf : ae_measurable f μ) : ae_measurable (λ a, norm (f a)) μ := measurable_norm.comp_ae_measurable hf @[measurability] lemma measurable_nnnorm : measurable (nnnorm : α → ℝ≥0) := continuous_nnnorm.measurable @[measurability] lemma measurable.nnnorm {f : β → α} (hf : measurable f) : measurable (λ a, nnnorm (f a)) := measurable_nnnorm.comp hf @[measurability] lemma ae_measurable.nnnorm {f : β → α} {μ : measure β} (hf : ae_measurable f μ) : ae_measurable (λ a, nnnorm (f a)) μ := measurable_nnnorm.comp_ae_measurable hf @[measurability] lemma measurable_ennnorm : measurable (λ x : α, (nnnorm x : ℝ≥0∞)) := measurable_nnnorm.coe_nnreal_ennreal @[measurability] lemma measurable.ennnorm {f : β → α} (hf : measurable f) : measurable (λ a, (nnnorm (f a) : ℝ≥0∞)) := hf.nnnorm.coe_nnreal_ennreal @[measurability] lemma ae_measurable.ennnorm {f : β → α} {μ : measure β} (hf : ae_measurable f μ) : ae_measurable (λ a, (nnnorm (f a) : ℝ≥0∞)) μ := measurable_ennnorm.comp_ae_measurable hf end normed_group section limits variables [measurable_space β] [metric_space β] [borel_space β] open metric /-- A limit (over a general filter) of measurable `ℝ≥0∞` valued functions is measurable. -/ lemma measurable_of_tendsto_ennreal' {ι} {f : ι → α → ℝ≥0∞} {g : α → ℝ≥0∞} (u : filter ι) [ne_bot u] [is_countably_generated u] (hf : ∀ i, measurable (f i)) (lim : tendsto f u (𝓝 g)) : measurable g := begin rcases u.exists_seq_tendsto with ⟨x, hx⟩, rw [tendsto_pi_nhds] at lim, have : (λ y, liminf at_top (λ n, (f (x n) y : ℝ≥0∞))) = g := by { ext1 y, exact ((lim y).comp hx).liminf_eq, }, rw ← this, show measurable (λ y, liminf at_top (λ n, (f (x n) y : ℝ≥0∞))), exact measurable_liminf (λ n, hf (x n)), end /-- A sequential limit of measurable `ℝ≥0∞` valued functions is measurable. -/ lemma measurable_of_tendsto_ennreal {f : ℕ → α → ℝ≥0∞} {g : α → ℝ≥0∞} (hf : ∀ i, measurable (f i)) (lim : tendsto f at_top (𝓝 g)) : measurable g := measurable_of_tendsto_ennreal' at_top hf lim /-- A limit (over a general filter) of measurable `ℝ≥0` valued functions is measurable. -/ lemma measurable_of_tendsto_nnreal' {ι} {f : ι → α → ℝ≥0} {g : α → ℝ≥0} (u : filter ι) [ne_bot u] [is_countably_generated u] (hf : ∀ i, measurable (f i)) (lim : tendsto f u (𝓝 g)) : measurable g := begin simp_rw [← measurable_coe_nnreal_ennreal_iff] at hf ⊢, refine measurable_of_tendsto_ennreal' u hf _, rw tendsto_pi_nhds at lim ⊢, exact λ x, (ennreal.continuous_coe.tendsto (g x)).comp (lim x), end /-- A sequential limit of measurable `ℝ≥0` valued functions is measurable. -/ lemma measurable_of_tendsto_nnreal {f : ℕ → α → ℝ≥0} {g : α → ℝ≥0} (hf : ∀ i, measurable (f i)) (lim : tendsto f at_top (𝓝 g)) : measurable g := measurable_of_tendsto_nnreal' at_top hf lim /-- A limit (over a general filter) of measurable functions valued in a metric space is measurable. -/ lemma measurable_of_tendsto_metric' {ι} {f : ι → α → β} {g : α → β} (u : filter ι) [ne_bot u] [is_countably_generated u] (hf : ∀ i, measurable (f i)) (lim : tendsto f u (𝓝 g)) : measurable g := begin apply measurable_of_is_closed', intros s h1s h2s h3s, have : measurable (λ x, inf_nndist (g x) s), { suffices : tendsto (λ i x, inf_nndist (f i x) s) u (𝓝 (λ x, inf_nndist (g x) s)), from measurable_of_tendsto_nnreal' u (λ i, (hf i).inf_nndist) this, rw [tendsto_pi_nhds] at lim ⊢, intro x, exact ((continuous_inf_nndist_pt s).tendsto (g x)).comp (lim x) }, have h4s : g ⁻¹' s = (λ x, inf_nndist (g x) s) ⁻¹' {0}, { ext x, simp [h1s, ← h1s.mem_iff_inf_dist_zero h2s, ← nnreal.coe_eq_zero] }, rw [h4s], exact this (measurable_set_singleton 0), end /-- A sequential limit of measurable functions valued in a metric space is measurable. -/ lemma measurable_of_tendsto_metric {f : ℕ → α → β} {g : α → β} (hf : ∀ i, measurable (f i)) (lim : tendsto f at_top (𝓝 g)) : measurable g := measurable_of_tendsto_metric' at_top hf lim /-- A limit (over a general filter) of measurable functions valued in a metrizable space is measurable. -/ lemma measurable_of_tendsto_metrizable' {β : Type*} [topological_space β] [metrizable_space β] [measurable_space β] [borel_space β] {ι} {f : ι → α → β} {g : α → β} (u : filter ι) [ne_bot u] [is_countably_generated u] (hf : ∀ i, measurable (f i)) (lim : tendsto f u (𝓝 g)) : measurable g := begin letI : metric_space β := metrizable_space_metric β, exact measurable_of_tendsto_metric' u hf lim end /-- A sequential limit of measurable functions valued in a metrizable space is measurable. -/ lemma measurable_of_tendsto_metrizable {β : Type*} [topological_space β] [metrizable_space β] [measurable_space β] [borel_space β] {f : ℕ → α → β} {g : α → β} (hf : ∀ i, measurable (f i)) (lim : tendsto f at_top (𝓝 g)) : measurable g := measurable_of_tendsto_metrizable' at_top hf lim lemma ae_measurable_of_tendsto_metric_ae {ι : Type*} {μ : measure α} {f : ι → α → β} {g : α → β} (u : filter ι) [hu : ne_bot u] [is_countably_generated u] (hf : ∀ n, ae_measurable (f n) μ) (h_tendsto : ∀ᵐ x ∂μ, tendsto (λ n, f n x) u (𝓝 (g x))) : ae_measurable g μ := begin rcases u.exists_seq_tendsto with ⟨v, hv⟩, have h'f : ∀ n, ae_measurable (f (v n)) μ := λ n, hf (v n), set p : α → (ℕ → β) → Prop := λ x f', tendsto (λ n, f' n) at_top (𝓝 (g x)), have hp : ∀ᵐ x ∂μ, p x (λ n, f (v n) x), by filter_upwards [h_tendsto] with x hx using hx.comp hv, set ae_seq_lim := λ x, ite (x ∈ ae_seq_set h'f p) (g x) (⟨f (v 0) x⟩ : nonempty β).some with hs, refine ⟨ae_seq_lim, measurable_of_tendsto_metric' at_top (@ae_seq.measurable α β _ _ _ (λ n x, f (v n) x) μ h'f p) (tendsto_pi_nhds.mpr (λ x, _)), _⟩, { simp_rw [ae_seq, ae_seq_lim], split_ifs with hx, { simp_rw ae_seq.mk_eq_fun_of_mem_ae_seq_set h'f hx, exact @ae_seq.fun_prop_of_mem_ae_seq_set α β _ _ _ _ _ _ h'f x hx, }, { exact tendsto_const_nhds } }, { exact (ite_ae_eq_of_measure_compl_zero g (λ x, (⟨f (v 0) x⟩ : nonempty β).some) (ae_seq_set h'f p) (ae_seq.measure_compl_ae_seq_set_eq_zero h'f hp)).symm }, end lemma ae_measurable_of_tendsto_metric_ae' {μ : measure α} {f : ℕ → α → β} {g : α → β} (hf : ∀ n, ae_measurable (f n) μ) (h_ae_tendsto : ∀ᵐ x ∂μ, tendsto (λ n, f n x) at_top (𝓝 (g x))) : ae_measurable g μ := ae_measurable_of_tendsto_metric_ae at_top hf h_ae_tendsto lemma ae_measurable_of_unif_approx {μ : measure α} {g : α → β} (hf : ∀ ε > (0 : ℝ), ∃ (f : α → β), ae_measurable f μ ∧ ∀ᵐ x ∂μ, dist (f x) (g x) ≤ ε) : ae_measurable g μ := begin obtain ⟨u, u_anti, u_pos, u_lim⟩ : ∃ (u : ℕ → ℝ), strict_anti u ∧ (∀ (n : ℕ), 0 < u n) ∧ tendsto u at_top (𝓝 0) := exists_seq_strict_anti_tendsto (0 : ℝ), choose f Hf using λ (n : ℕ), hf (u n) (u_pos n), have : ∀ᵐ x ∂μ, tendsto (λ n, f n x) at_top (𝓝 (g x)), { have : ∀ᵐ x ∂ μ, ∀ n, dist (f n x) (g x) ≤ u n := ae_all_iff.2 (λ n, (Hf n).2), filter_upwards [this], assume x hx, rw tendsto_iff_dist_tendsto_zero, exact squeeze_zero (λ n, dist_nonneg) hx u_lim }, exact ae_measurable_of_tendsto_metric_ae' (λ n, (Hf n).1) this, end lemma measurable_of_tendsto_metric_ae {μ : measure α} [μ.is_complete] {f : ℕ → α → β} {g : α → β} (hf : ∀ n, measurable (f n)) (h_ae_tendsto : ∀ᵐ x ∂μ, tendsto (λ n, f n x) at_top (𝓝 (g x))) : measurable g := ae_measurable_iff_measurable.mp (ae_measurable_of_tendsto_metric_ae' (λ i, (hf i).ae_measurable) h_ae_tendsto) lemma measurable_limit_of_tendsto_metric_ae {ι} [encodable ι] [nonempty ι] {μ : measure α} {f : ι → α → β} {L : filter ι} [L.is_countably_generated] (hf : ∀ n, ae_measurable (f n) μ) (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, tendsto (λ n, f n x) L (𝓝 l)) : ∃ (f_lim : α → β) (hf_lim_meas : measurable f_lim), ∀ᵐ x ∂μ, tendsto (λ n, f n x) L (𝓝 (f_lim x)) := begin inhabit ι, unfreezingI { rcases eq_or_ne L ⊥ with rfl | hL }, { exact ⟨(hf default).mk _, (hf default).measurable_mk, eventually_of_forall $ λ x, tendsto_bot⟩ }, haveI : ne_bot L := ⟨hL⟩, let p : α → (ι → β) → Prop := λ x f', ∃ l : β, tendsto (λ n, f' n) L (𝓝 l), have hp_mem : ∀ x ∈ ae_seq_set hf p, p x (λ n, f n x), from λ x hx, ae_seq.fun_prop_of_mem_ae_seq_set hf hx, have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, ae_seq hf p n x = f n x, from ae_seq.ae_seq_eq_fun_ae hf h_ae_tendsto, let f_lim : α → β := λ x, dite (x ∈ ae_seq_set hf p) (λ h, (hp_mem x h).some) (λ h, (⟨f default x⟩ : nonempty β).some), have hf_lim : ∀ x, tendsto (λ n, ae_seq hf p n x) L (𝓝 (f_lim x)), { intros x, simp only [f_lim, ae_seq], split_ifs, { refine (hp_mem x h).some_spec.congr (λ n, _), exact (ae_seq.mk_eq_fun_of_mem_ae_seq_set hf h n).symm }, { exact tendsto_const_nhds, }, }, have h_ae_tendsto_f_lim : ∀ᵐ x ∂μ, tendsto (λ n, f n x) L (𝓝 (f_lim x)), from h_ae_eq.mono (λ x hx, (hf_lim x).congr hx), have h_f_lim_meas : measurable f_lim, from measurable_of_tendsto_metric' L (ae_seq.measurable hf p) (tendsto_pi_nhds.mpr (λ x, hf_lim x)), exact ⟨f_lim, h_f_lim_meas, h_ae_tendsto_f_lim⟩, end end limits namespace continuous_linear_map variables {𝕜 : Type*} [normed_field 𝕜] variables {E : Type*} [normed_group E] [normed_space 𝕜 E] [measurable_space E] variables [opens_measurable_space E] variables {F : Type*} [normed_group F] [normed_space 𝕜 F] [measurable_space F] [borel_space F] @[measurability] protected lemma measurable (L : E →L[𝕜] F) : measurable L := L.continuous.measurable lemma measurable_comp (L : E →L[𝕜] F) {φ : α → E} (φ_meas : measurable φ) : measurable (λ (a : α), L (φ a)) := L.measurable.comp φ_meas end continuous_linear_map namespace continuous_linear_map variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜] variables {E : Type*} [normed_group E] [normed_space 𝕜 E] {F : Type*} [normed_group F] [normed_space 𝕜 F] instance : measurable_space (E →L[𝕜] F) := borel _ instance : borel_space (E →L[𝕜] F) := ⟨rfl⟩ @[measurability] lemma measurable_apply [measurable_space F] [borel_space F] (x : E) : measurable (λ f : E →L[𝕜] F, f x) := (apply 𝕜 F x).continuous.measurable @[measurability] lemma measurable_apply' [measurable_space E] [opens_measurable_space E] [measurable_space F] [borel_space F] : measurable (λ (x : E) (f : E →L[𝕜] F), f x) := measurable_pi_lambda _ $ λ f, f.measurable @[measurability] lemma measurable_coe [measurable_space F] [borel_space F] : measurable (λ (f : E →L[𝕜] F) (x : E), f x) := measurable_pi_lambda _ measurable_apply end continuous_linear_map section continuous_linear_map_nondiscrete_normed_field variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜] variables {E : Type*} [normed_group E] [normed_space 𝕜 E] [measurable_space E] [borel_space E] variables {F : Type*} [normed_group F] [normed_space 𝕜 F] @[measurability] lemma measurable.apply_continuous_linear_map {φ : α → F →L[𝕜] E} (hφ : measurable φ) (v : F) : measurable (λ a, φ a v) := (continuous_linear_map.apply 𝕜 E v).measurable.comp hφ @[measurability] lemma ae_measurable.apply_continuous_linear_map {φ : α → F →L[𝕜] E} {μ : measure α} (hφ : ae_measurable φ μ) (v : F) : ae_measurable (λ a, φ a v) μ := (continuous_linear_map.apply 𝕜 E v).measurable.comp_ae_measurable hφ end continuous_linear_map_nondiscrete_normed_field section normed_space variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜] [complete_space 𝕜] [measurable_space 𝕜] variables [borel_space 𝕜] variables {E : Type*} [normed_group E] [normed_space 𝕜 E] [measurable_space E] [borel_space E] lemma measurable_smul_const {f : α → 𝕜} {c : E} (hc : c ≠ 0) : measurable (λ x, f x • c) ↔ measurable f := (closed_embedding_smul_left hc).measurable_embedding.measurable_comp_iff lemma ae_measurable_smul_const {f : α → 𝕜} {μ : measure α} {c : E} (hc : c ≠ 0) : ae_measurable (λ x, f x • c) μ ↔ ae_measurable f μ := (closed_embedding_smul_left hc).measurable_embedding.ae_measurable_comp_iff end normed_space
module InstanceArgumentsSections where postulate A : Set module Basic where record B : Set where field bA : A open B {{...}} bA' : B → A bA' _ = bA module Parameterised (a : A) where record C : Set where field cA : A open C {{...}} cA' : C → A cA' _ = cA module RecordFromParameterised where postulate a : A open Parameterised a open C {{...}} cA'' : C → A cA'' _ = cA module RecordFromParameterisedInParameterised (a : A) where open Parameterised a open C {{...}} cA'' : C → A cA'' _ = cA module RecordFromParameterised' (a : A) where open Parameterised open C {{...}} cA'' : C a → A cA'' _ = cA a module AppliedRecord (a : A) where open Parameterised D : Set D = C a module D = C a open D {{...}} dA' : D → A dA' _ = cA
Prayer and private offerings are generally called " personal piety " : acts that reflect a close relationship between an individual and a god . Evidence of personal piety is scant before the New Kingdom . Votive offerings and personal names , many of which are <unk> , suggest that commoners felt some connection between themselves and their gods . But firm evidence of devotion to deities became visible only in the New Kingdom , reaching a peak late in that era . Scholars disagree about the meaning of this change — whether direct interaction with the gods was a new development or an outgrowth of older traditions . Egyptians now expressed their devotion through a new variety of activities in and around temples . They recorded their prayers and their thanks for divine help on stelae . They gave offerings of figurines that represented the gods they were praying to , or that symbolized the result they desired ; thus a relief image of Hathor and a statuette of a woman could both represent a prayer for fertility . Occasionally , a person took a particular god as a patron , dedicating his or her property or labor to the god 's cult . These practices continued into the latest periods of Egyptian history . These later eras saw more religious innovations , including the practice of giving animal mummies as offerings to deities depicted in animal form , such as the cat mummies given to the feline goddess Bastet . Some of the major deities from myth and official religion were rarely invoked in popular worship , but many of the great state gods were important in popular tradition .
State Before: V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u u' : V hu : u = u' ⊢ Walk.copy nil hu hu = nil State After: V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u' : V ⊢ Walk.copy nil (_ : u' = u') (_ : u' = u') = nil Tactic: subst_vars State Before: V : Type u V' : Type v V'' : Type w G : SimpleGraph V G' : SimpleGraph V' G'' : SimpleGraph V'' u' : V ⊢ Walk.copy nil (_ : u' = u') (_ : u' = u') = nil State After: no goals Tactic: rfl
func $foo ( var %i i32 #var %i1 i32, var %j1 i32, var %k1 i32 ) i32 { return ( depositbits i32 1 23( constval i32 0xfff, constval i32 0x11))} # EXEC: %irbuild Main.mpl # EXEC: %irbuild Main.irb.mpl # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl
port P passive component C { sync input port p: P drop }
= = Creation and casting = =
/* Copyright (C) 2012-2020 IBM Corp. * This program is Licensed under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. See accompanying LICENSE file. */ #include <iostream> #include <NTL/BasicThreadPool.h> #include <helib/intraSlot.h> #include <helib/tableLookup.h> #include <helib/debugging.h> #include "gtest/gtest.h" #include "test_common.h" namespace { struct Parameters { Parameters(long prm, long bitSize, long outSize, long nTests, bool bootstrap, long seed, long nthreads) : prm(prm), bitSize(bitSize), outSize(outSize), nTests(nTests), bootstrap(bootstrap), seed(seed), nthreads(nthreads){}; long prm; // parameter size (0-tiny,...,4-huge) long bitSize; // bitSize of input integers (<=32) long outSize; // bitSize of output integers long nTests; // number of tests to run bool bootstrap; // test multiplication with bootstrapping long seed; // PRG seed long nthreads; // number of threads friend std::ostream& operator<<(std::ostream& os, const Parameters& params) { return os << "{" << "prm=" << params.prm << "," << "bitSize=" << params.bitSize << "," << "outSize=" << params.outSize << "," << "nTests=" << params.nTests << "," << "bootstrap=" << params.bootstrap << "," << "seed=" << params.seed << "," << "nthreads=" << params.nthreads << "}"; }; }; class GTestTableLookup : public ::testing::TestWithParam<Parameters> { protected: // clang-format off static constexpr long mValues[][15] = { // {p,phi(m), m, d, m1, m2, m3, g1, g2, g3,ord1,ord2,ord3, B, c} {2, 48, 105, 12, 3, 35, 0, 71, 76, 0, 2, 2, 0, 25, 2}, {2, 600, 1023, 10, 11, 93, 0, 838, 584, 0, 10, 6, 0, 25, 2}, {2, 2304, 4641, 24, 7, 3,221, 3979, 3095, 3760, 6, 2, -8, 25, 3}, {2, 15004,15709, 22, 23,683, 0, 4099,13663, 0, 22, 31, 0, 25, 3}, {2, 27000,32767, 15, 31, 7,151,11628,28087,25824, 30, 6, -10, 28, 4} }; // clang-format on // Utility encryption/decryption methods static void encryptIndex(std::vector<helib::Ctxt>& ei, long index, const helib::SecKey& sKey) { for (long i = 0; i < helib::lsize(ei); i++) sKey.Encrypt(ei[i], NTL::to_ZZX((index >> i) & 1)); // i'th bit of index } static long decryptIndex(std::vector<helib::Ctxt>& ei, const helib::SecKey& sKey) { long num = 0; for (long i = 0; i < helib::lsize(ei); i++) { NTL::ZZX poly; sKey.Decrypt(poly, ei[i]); num += to_long(NTL::ConstTerm(poly)) << i; } return num; } static long validatePrm(const long prm) { if (prm < 0 || prm >= 5) throw std::invalid_argument("Invalid prm value"); return prm; }; static long validateBitSize(const long bitSize) { if (bitSize > 7) throw std::invalid_argument("Invalid bitSize value: must be <=7"); else if (bitSize <= 0) throw std::invalid_argument("Invalid bitSize value: must be >0"); return bitSize; }; static NTL::Vec<long> calculateMvec(const long* vals) { NTL::Vec<long> mvec; append(mvec, vals[4]); if (vals[5] > 1) append(mvec, vals[5]); if (vals[6] > 1) append(mvec, vals[6]); return mvec; }; static std::vector<long> calculateGens(const long* vals) { std::vector<long> gens; gens.push_back(vals[7]); if (vals[8] > 1) gens.push_back(vals[8]); if (vals[9] > 1) gens.push_back(vals[9]); return gens; }; static std::vector<long> calculateOrds(const long* vals) { std::vector<long> ords; ords.push_back(vals[10]); if (abs(vals[11]) > 1) ords.push_back(vals[11]); if (abs(vals[12]) > 1) ords.push_back(vals[12]); return ords; }; static long calculateLevels(const bool bootstrap, const long bitSize) { long L; if (bootstrap) L = 900; // that should be enough else L = 30 * (5 + bitSize); return L; }; static void printPreContextPrepDiagnostics(const long bitSize, const long outSize, const long nTests, const long nthreads) { if (helib_test::verbose) { std::cout << "input bitSize=" << bitSize << ", output size bound=" << outSize << ", running " << nTests << " tests for each function\n"; if (nthreads > 1) std::cout << " using " << NTL::AvailableThreads() << " threads\n"; std::cout << "computing key-independent tables..." << std::flush; } }; static void printPostContextPrepDiagnostics(const helib::Context& context, const long L) { if (helib_test::verbose) { std::cout << " done.\n"; context.zMStar.printout(); std::cout << " L=" << L << std::endl; }; } // Not static as many instance variables are required. helib::Context& prepareContext(helib::Context& context) { printPreContextPrepDiagnostics(bitSize, outSize, nTests, nthreads); helib::buildModChain(context, L, c, /*willBeBootstrappable*/ bootstrap); if (bootstrap) { context.enableBootStrapping(mvec); } helib::buildUnpackSlotEncoding(unpackSlotEncoding, *context.ea); printPostContextPrepDiagnostics(context, L); return context; }; static void prepareSecKey(helib::SecKey& secretKey, const bool bootstrap) { if (helib_test::verbose) std::cout << "\ncomputing key-dependent tables..." << std::flush; secretKey.GenSecKey(); helib::addSome1DMatrices(secretKey); // compute key-switching matrices helib::addFrbMatrices(secretKey); if (bootstrap) secretKey.genRecryptData(); if (helib_test::verbose) std::cout << " done\n"; }; static void setSeedIfNeeded(const long seed) { if (seed) NTL::SetSeed(NTL::ZZ(seed)); ; }; static void setThreadsIfNeeded(const long nthreads) { if (nthreads > 1) NTL::SetNumThreads(nthreads); }; GTestTableLookup() : prm(validatePrm(GetParam().prm)), bitSize(validateBitSize(GetParam().bitSize)), outSize(GetParam().outSize), nTests(GetParam().nTests), bootstrap(GetParam().bootstrap), seed((setSeedIfNeeded(GetParam().seed), GetParam().seed)), nthreads((setThreadsIfNeeded(GetParam().nthreads), GetParam().nthreads)), vals(mValues[prm]), p(vals[0]), m(vals[2]), mvec(calculateMvec(vals)), gens(calculateGens(vals)), ords(calculateOrds(vals)), c(vals[14]), L(calculateLevels(bootstrap, bitSize)), context(m, p, /*r=*/1, gens, ords), secretKey(prepareContext(context)) { prepareSecKey(secretKey, bootstrap); }; std::vector<helib::zzX> unpackSlotEncoding; const long prm; const long bitSize; const long outSize; const long nTests; const bool bootstrap; const long seed; const long nthreads; const long* vals; const long p; const long m; const NTL::Vec<long> mvec; const std::vector<long> gens; const std::vector<long> ords; const long c; const long L; helib::Context context; helib::SecKey secretKey; void SetUp() override { helib::activeContext = &context; // make things a little easier sometimes helib::setupDebugGlobals(&secretKey, context.ea); }; virtual void TearDown() override { #ifdef HELIB_DEBUG helib::cleanupDebugGlobals(); #endif } public: static void TearDownTestCase() { if (helib_test::verbose) { helib::printAllTimers(std::cout); } }; }; constexpr long GTestTableLookup::mValues[][15]; TEST_P(GTestTableLookup, lookupFunctionsCorrectly) { // Build a table s.t. T[i] = 2^{outSize -1}/(i+1), i=0,...,2^bitSize -1 std::vector<helib::zzX> T; helib::buildLookupTable( T, [](double x) { return 1 / (x + 1.0); }, bitSize, /*scale_in=*/0, /*sign_in=*/0, outSize, /*scale_out=*/1 - outSize, /*sign_out=*/0, *(secretKey.getContext().ea)); ASSERT_EQ(helib::lsize(T), 1L << bitSize); for (long i = 0; i < helib::lsize(T); i++) { helib::Ctxt c(secretKey); std::vector<helib::Ctxt> ei(bitSize, c); encryptIndex(ei, i, secretKey); // encrypt the index helib::tableLookup(c, T, helib::CtPtrs_vectorCt(ei)); // get the encrypted entry // decrypt and compare NTL::ZZX poly; secretKey.Decrypt(poly, c); // decrypt helib::zzX poly2; helib::convert(poly2, poly); // convert to zzX EXPECT_EQ(poly2, T[i]) << "testLookup error: decrypted T[" << i << "]\n"; } } TEST_P(GTestTableLookup, writeinFunctionsCorrectly) { long tSize = 1L << bitSize; // table size // encrypt a random table std::vector<long> pT(tSize, 0); // plaintext table std::vector<helib::Ctxt> T(tSize, helib::Ctxt(secretKey)); // encrypted table for (long i = 0; i < bitSize; i++) { long bit = NTL::RandomBits_long(1); // a random bit secretKey.Encrypt(T[i], NTL::to_ZZX(bit)); pT[i] = bit; } // Add 1 to 20 random entries in the table for (long count = 0; count < nTests; count++) { // encrypt a random index into the table long index = NTL::RandomBnd(tSize); // 0 <= index < tSize std::vector<helib::Ctxt> I(bitSize, helib::Ctxt(secretKey)); encryptIndex(I, index, secretKey); // do the table write-in tableWriteIn(helib::CtPtrs_vectorCt(T), helib::CtPtrs_vectorCt(I), &unpackSlotEncoding); pT[index]++; // add 1 to entry 'index' in the plaintext table } // Check that the ciphertext and plaintext tables still match for (int i = 0; i < tSize; i++) { NTL::ZZX poly; secretKey.Decrypt(poly, T[i]); long decrypted = to_long(NTL::ConstTerm(poly)); long p = T[i].getPtxtSpace(); ASSERT_EQ((pT[i] - decrypted) % p, 0) // should be equal mod p << "testWritein error: decrypted T[" << i << "]=" << decrypted << " but should be " << pT[i] << " (mod " << p << ")\n"; } } INSTANTIATE_TEST_SUITE_P(typicalParameters, GTestTableLookup, ::testing::Values( // SLOW Parameters(1, 5, 0, 3, false, 0, 1) // FAST // Parameters(0, 5, 0, 3, false, 0, 1) )); } // namespace
State Before: d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a ⊢ IsCoprime b.re b.im State After: case nonzero d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a ⊢ ¬(b.re = 0 ∧ b.im = 0) case H d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a ⊢ ∀ (z : ℤ), z ∈ nonunits ℤ → z ≠ 0 → z ∣ b.re → ¬z ∣ b.im Tactic: apply isCoprime_of_dvd State Before: case nonzero d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a ⊢ ¬(b.re = 0 ∧ b.im = 0) State After: case nonzero.intro d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a hre : b.re = 0 him : b.im = 0 ⊢ False Tactic: rintro ⟨hre, him⟩ State Before: case nonzero.intro d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a hre : b.re = 0 him : b.im = 0 ⊢ False State After: case nonzero.intro d : ℤ a : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : 0 ∣ a hre : 0.re = 0 him : 0.im = 0 ⊢ False Tactic: obtain rfl : b = 0 := by simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re] State Before: case nonzero.intro d : ℤ a : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : 0 ∣ a hre : 0.re = 0 him : 0.im = 0 ⊢ False State After: case nonzero.intro d : ℤ a : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : a = 0 hre : 0.re = 0 him : 0.im = 0 ⊢ False Tactic: rw [zero_dvd_iff] at hdvd State Before: case nonzero.intro d : ℤ a : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : a = 0 hre : 0.re = 0 him : 0.im = 0 ⊢ False State After: no goals Tactic: simp [hdvd, zero_im, zero_re, not_isCoprime_zero_zero] at hcoprime State Before: d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a hre : b.re = 0 him : b.im = 0 ⊢ b = 0 State After: no goals Tactic: simp only [ext, hre, eq_self_iff_true, zero_im, him, and_self_iff, zero_re] State Before: case H d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a ⊢ ∀ (z : ℤ), z ∈ nonunits ℤ → z ≠ 0 → z ∣ b.re → ¬z ∣ b.im State After: case H d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ False Tactic: rintro z hz - hzdvdu hzdvdv State Before: case H d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ False State After: case H d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ IsUnit z Tactic: apply hz State Before: case H d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ IsUnit z State After: case H.intro d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ha : z ∣ a.re hb : z ∣ a.im ⊢ IsUnit z Tactic: obtain ⟨ha, hb⟩ : z ∣ a.re ∧ z ∣ a.im := by rw [← coe_int_dvd_iff] apply dvd_trans _ hdvd rw [coe_int_dvd_iff] exact ⟨hzdvdu, hzdvdv⟩ State Before: case H.intro d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ha : z ∣ a.re hb : z ∣ a.im ⊢ IsUnit z State After: no goals Tactic: exact hcoprime.isUnit_of_dvd' ha hb State Before: d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ z ∣ a.re ∧ z ∣ a.im State After: d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ ↑z ∣ a Tactic: rw [← coe_int_dvd_iff] State Before: d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ ↑z ∣ a State After: d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ ↑z ∣ b Tactic: apply dvd_trans _ hdvd State Before: d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ ↑z ∣ b State After: d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ z ∣ b.re ∧ z ∣ b.im Tactic: rw [coe_int_dvd_iff] State Before: d : ℤ a b : ℤ√d hcoprime : IsCoprime a.re a.im hdvd : b ∣ a z : ℤ hz : z ∈ nonunits ℤ hzdvdu : z ∣ b.re hzdvdv : z ∣ b.im ⊢ z ∣ b.re ∧ z ∣ b.im State After: no goals Tactic: exact ⟨hzdvdu, hzdvdv⟩
using Random Random.rand!(A::MtlArray) = Random.rand!(GPUArrays.default_rng(MtlArray), A) Random.randn!(A::MtlArray) = Random.randn!(GPUArrays.default_rng(MtlArray), A)
[STATEMENT] lemma ctx_subtype_v_aux: fixes v::v assumes "\<Theta>; \<B>; \<Gamma>'@((x,b0,c0')#\<^sub>\<Gamma>\<Gamma>) \<turnstile> v \<Rightarrow> t1" and "\<Theta>; \<B>; \<Gamma>'@(x,b0,c0)#\<^sub>\<Gamma>\<Gamma> \<Turnstile> c0'" shows "\<Theta>; \<B>; \<Gamma>'@((x,b0,c0)#\<^sub>\<Gamma>\<Gamma>) \<turnstile> v \<Rightarrow> t1" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> t1 [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> t1 \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> t1 [PROOF STEP] proof(nominal_induct "\<Gamma>'@((x,b0,c0')#\<^sub>\<Gamma>\<Gamma>)" v t1 avoiding: c0 rule: infer_v.strong_induct) [PROOF STATE] proof (state) goal (5 subgoals): 1. \<And>\<Theta> \<B> b c xa z c0. \<lbrakk>atom z \<sharp> c0; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa; atom z \<sharp> xa; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>\<Theta> \<B> l \<tau> c0. \<lbrakk> \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; \<turnstile> l \<Rightarrow> \<tau>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> 3. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 4. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 5. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] case (infer_v_varI \<Theta> \<B> b c xa z) [PROOF STATE] proof (state) this: atom z \<sharp> c0 \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa atom z \<sharp> xa atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (5 subgoals): 1. \<And>\<Theta> \<B> b c xa z c0. \<lbrakk>atom z \<sharp> c0; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa; atom z \<sharp> xa; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>\<Theta> \<B> l \<tau> c0. \<lbrakk> \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; \<turnstile> l \<Rightarrow> \<tau>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> 3. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 4. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 5. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] have wf:\<open> \<Theta>; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> [PROOF STEP] using wfG_inside_valid2 infer_v_varI [PROOF STATE] proof (prove) using this: \<lbrakk> ?\<Theta> ; ?B \<turnstile>\<^sub>w\<^sub>f ?\<Gamma>' @ (?x, ?b0.0, ?c0') #\<^sub>\<Gamma> ?\<Gamma> ; ?\<Theta> ; ?B ; ?\<Gamma>' @ (?x, ?b0.0, ?c0.0) #\<^sub>\<Gamma> ?\<Gamma> \<Turnstile> ?c0' \<rbrakk> \<Longrightarrow> ?\<Theta> ; ?B \<turnstile>\<^sub>w\<^sub>f ?\<Gamma>' @ (?x, ?b0.0, ?c0.0) #\<^sub>\<Gamma> ?\<Gamma> atom z \<sharp> c0 \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa atom z \<sharp> xa atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> [PROOF STEP] by metis [PROOF STATE] proof (state) this: \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> goal (5 subgoals): 1. \<And>\<Theta> \<B> b c xa z c0. \<lbrakk>atom z \<sharp> c0; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa; atom z \<sharp> xa; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>\<Theta> \<B> l \<tau> c0. \<lbrakk> \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; \<turnstile> l \<Rightarrow> \<tau>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> 3. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 4. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 5. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] have xf1:\<open>atom z \<sharp> xa\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. atom z \<sharp> xa [PROOF STEP] using infer_v_varI [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa atom z \<sharp> xa atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. atom z \<sharp> xa [PROOF STEP] by metis [PROOF STATE] proof (state) this: atom z \<sharp> xa goal (5 subgoals): 1. \<And>\<Theta> \<B> b c xa z c0. \<lbrakk>atom z \<sharp> c0; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa; atom z \<sharp> xa; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>\<Theta> \<B> l \<tau> c0. \<lbrakk> \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; \<turnstile> l \<Rightarrow> \<tau>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> 3. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 4. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 5. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] have xf2: \<open>atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>)\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) [PROOF STEP] apply( fresh_mth add: infer_v_varI ) [PROOF STATE] proof (prove) goal (4 subgoals): 1. atom z \<in> supp \<Gamma>' \<Longrightarrow> False 2. atom z \<in> supp x \<Longrightarrow> False 3. atom z \<in> supp c0 \<Longrightarrow> False 4. atom z \<in> supp \<Gamma> \<Longrightarrow> False [PROOF STEP] using fresh_def infer_v_varI wfG_supp fresh_append_g fresh_GCons fresh_prodN [PROOF STATE] proof (prove) using this: ?a \<sharp> ?x \<equiv> ?a \<notin> supp ?x atom z \<sharp> c0 \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa atom z \<sharp> xa atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' ?\<Theta> ; ?\<B> \<turnstile>\<^sub>w\<^sub>f ?\<Gamma> \<Longrightarrow> atom_dom ?\<Gamma> \<subseteq> supp ?\<Gamma> ?a \<sharp> ?xs @ ?ys = (?a \<sharp> ?xs \<and> ?a \<sharp> ?ys) ?a \<sharp> ?x #\<^sub>\<Gamma> ?xs = (?a \<sharp> ?x \<and> ?a \<sharp> ?xs) ?a \<sharp> (?x, ?y) = (?a \<sharp> ?x \<and> ?a \<sharp> ?y) ?x \<sharp> (?a, ?b, ?c) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c) ?x \<sharp> (?a, ?b, ?c, ?d) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d) ?x \<sharp> (?a, ?b, ?c, ?d, ?e) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j, ?k, ?l) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j \<and> ?x \<sharp> ?k \<and> ?x \<sharp> ?l) goal (4 subgoals): 1. atom z \<in> supp \<Gamma>' \<Longrightarrow> False 2. atom z \<in> supp x \<Longrightarrow> False 3. atom z \<in> supp c0 \<Longrightarrow> False 4. atom z \<in> supp \<Gamma> \<Longrightarrow> False [PROOF STEP] by metis+ [PROOF STATE] proof (state) this: atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) goal (5 subgoals): 1. \<And>\<Theta> \<B> b c xa z c0. \<lbrakk>atom z \<sharp> c0; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa; atom z \<sharp> xa; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>\<Theta> \<B> l \<tau> c0. \<lbrakk> \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; \<turnstile> l \<Rightarrow> \<tau>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> 3. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 4. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 5. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] proof (cases "x=xa") [PROOF STATE] proof (state) goal (2 subgoals): 1. x = xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] case True [PROOF STATE] proof (state) this: x = xa goal (2 subgoals): 1. x = xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] moreover [PROOF STATE] proof (state) this: x = xa goal (2 subgoals): 1. x = xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] have "b = b0" [PROOF STATE] proof (prove) goal (1 subgoal): 1. b = b0 [PROOF STEP] using infer_v_varI True [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa atom z \<sharp> xa atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' x = xa goal (1 subgoal): 1. b = b0 [PROOF STEP] by simp [PROOF STATE] proof (state) this: b = b0 goal (2 subgoals): 1. x = xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] moreover [PROOF STATE] proof (state) this: b = b0 goal (2 subgoals): 1. x = xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] hence \<open>Some (b, c0) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa\<close> [PROOF STATE] proof (prove) using this: b = b0 goal (1 subgoal): 1. Some (b, c0) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa [PROOF STEP] using lookup_inside_wf[OF wf] infer_v_varI True [PROOF STATE] proof (prove) using this: b = b0 Some (b0, c0) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) x atom z \<sharp> c0 \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa atom z \<sharp> xa atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' x = xa goal (1 subgoal): 1. Some (b, c0) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa [PROOF STEP] by auto [PROOF STATE] proof (state) this: Some (b, c0) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa goal (2 subgoals): 1. x = xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: x = xa b = b0 Some (b, c0) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: x = xa b = b0 Some (b, c0) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] using wf xf1 xf2 Typing.infer_v_varI [PROOF STATE] proof (prove) using this: x = xa b = b0 Some (b, c0) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> xa atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) \<lbrakk> ?\<Theta> ; ?\<B> \<turnstile>\<^sub>w\<^sub>f ?\<Gamma> ; Some (?b, ?c) = lookup ?\<Gamma> ?x; atom ?z \<sharp> ?x; atom ?z \<sharp> (?\<Theta>, ?\<B>, ?\<Gamma>)\<rbrakk> \<Longrightarrow> ?\<Theta> ; ?\<B> ; ?\<Gamma> \<turnstile> [ ?x ]\<^sup>v \<Rightarrow> \<lbrace> ?z : ?b | [ [ ?z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ ?x ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] by metis [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> goal (1 subgoal): 1. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] case False [PROOF STATE] proof (state) this: x \<noteq> xa goal (1 subgoal): 1. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] moreover [PROOF STATE] proof (state) this: x \<noteq> xa goal (1 subgoal): 1. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] hence \<open>Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa\<close> [PROOF STATE] proof (prove) using this: x \<noteq> xa goal (1 subgoal): 1. Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa [PROOF STEP] using lookup_inside2 infer_v_varI [PROOF STATE] proof (prove) using this: x \<noteq> xa \<lbrakk>Some (?b1.0, ?c1.0) = lookup (?\<Gamma>' @ (?x, ?b0.0, ?c0.0) #\<^sub>\<Gamma> ?\<Gamma>) ?y; ?x \<noteq> ?y\<rbrakk> \<Longrightarrow> Some (?b1.0, ?c1.0) = lookup (?\<Gamma>' @ (?x, ?b0.0, ?c0') #\<^sub>\<Gamma> ?\<Gamma>) ?y atom z \<sharp> c0 \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>) xa atom z \<sharp> xa atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa [PROOF STEP] by metis [PROOF STATE] proof (state) this: Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa goal (1 subgoal): 1. x \<noteq> xa \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: x \<noteq> xa Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) using this: x \<noteq> xa Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] using wf xf1 xf2 Typing.infer_v_varI [PROOF STATE] proof (prove) using this: x \<noteq> xa Some (b, c) = lookup (\<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) xa \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> xa atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) \<lbrakk> ?\<Theta> ; ?\<B> \<turnstile>\<^sub>w\<^sub>f ?\<Gamma> ; Some (?b, ?c) = lookup ?\<Gamma> ?x; atom ?z \<sharp> ?x; atom ?z \<sharp> (?\<Theta>, ?\<B>, ?\<Gamma>)\<rbrakk> \<Longrightarrow> ?\<Theta> ; ?\<B> ; ?\<Gamma> \<turnstile> [ ?x ]\<^sup>v \<Rightarrow> \<lbrace> ?z : ?b | [ [ ?z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ ?x ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ xa ]\<^sup>v \<Rightarrow> \<lbrace> z : b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ xa ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> goal (4 subgoals): 1. \<And>\<Theta> \<B> l \<tau> c0. \<lbrakk> \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; \<turnstile> l \<Rightarrow> \<tau>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> 2. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 3. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 4. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] next [PROOF STATE] proof (state) goal (4 subgoals): 1. \<And>\<Theta> \<B> l \<tau> c0. \<lbrakk> \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; \<turnstile> l \<Rightarrow> \<tau>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> 2. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 3. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 4. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] case (infer_v_litI \<Theta> \<B> l \<tau>) [PROOF STATE] proof (state) this: \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> l \<Rightarrow> \<tau> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (4 subgoals): 1. \<And>\<Theta> \<B> l \<tau> c0. \<lbrakk> \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> ; \<turnstile> l \<Rightarrow> \<tau>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> 2. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 3. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 4. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] thus ?case [PROOF STATE] proof (prove) using this: \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> l \<Rightarrow> \<tau> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> [PROOF STEP] using Typing.infer_v_litI wfG_inside_valid2 [PROOF STATE] proof (prove) using this: \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> l \<Rightarrow> \<tau> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<lbrakk> ?\<Theta> ; ?\<B> \<turnstile>\<^sub>w\<^sub>f ?\<Gamma> ; \<turnstile> ?l \<Rightarrow> ?\<tau>\<rbrakk> \<Longrightarrow> ?\<Theta> ; ?\<B> ; ?\<Gamma> \<turnstile> [ ?l ]\<^sup>v \<Rightarrow> ?\<tau> \<lbrakk> ?\<Theta> ; ?B \<turnstile>\<^sub>w\<^sub>f ?\<Gamma>' @ (?x, ?b0.0, ?c0') #\<^sub>\<Gamma> ?\<Gamma> ; ?\<Theta> ; ?B ; ?\<Gamma>' @ (?x, ?b0.0, ?c0.0) #\<^sub>\<Gamma> ?\<Gamma> \<Turnstile> ?c0' \<rbrakk> \<Longrightarrow> ?\<Theta> ; ?B \<turnstile>\<^sub>w\<^sub>f ?\<Gamma>' @ (?x, ?b0.0, ?c0.0) #\<^sub>\<Gamma> ?\<Gamma> goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ l ]\<^sup>v \<Rightarrow> \<tau> goal (3 subgoals): 1. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 3. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] next [PROOF STATE] proof (state) goal (3 subgoals): 1. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 3. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] case (infer_v_pairI z v1 v2 \<Theta> \<B> t1' t2' c0) [PROOF STATE] proof (state) this: atom z \<sharp> c0 atom z \<sharp> v1 atom z \<sharp> v2 atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (3 subgoals): 1. \<And>z v1 v2 \<Theta> \<B> t1 t2 c0. \<lbrakk>atom z \<sharp> c0; atom z \<sharp> v1; atom z \<sharp> v2; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1 , b_of t2 ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 3. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1' , b_of t2' ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] proof [PROOF STATE] proof (state) goal (4 subgoals): 1. atom z \<sharp> (v1, v2) 2. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) 3. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' 4. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' [PROOF STEP] show "atom z \<sharp> (v1, v2)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. atom z \<sharp> (v1, v2) [PROOF STEP] using infer_v_pairI fresh_Pair [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 atom z \<sharp> v1 atom z \<sharp> v2 atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' ?a \<sharp> (?x, ?y) = (?a \<sharp> ?x \<and> ?a \<sharp> ?y) goal (1 subgoal): 1. atom z \<sharp> (v1, v2) [PROOF STEP] by simp [PROOF STATE] proof (state) this: atom z \<sharp> (v1, v2) goal (3 subgoals): 1. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) 2. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' 3. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' [PROOF STEP] show "atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) [PROOF STEP] apply( fresh_mth add: infer_v_pairI ) [PROOF STATE] proof (prove) goal (4 subgoals): 1. atom z \<in> supp \<Gamma>' \<Longrightarrow> False 2. atom z \<in> supp x \<Longrightarrow> False 3. atom z \<in> supp c0 \<Longrightarrow> False 4. atom z \<in> supp \<Gamma> \<Longrightarrow> False [PROOF STEP] using fresh_def infer_v_pairI wfG_supp fresh_append_g fresh_GCons fresh_prodN [PROOF STATE] proof (prove) using this: ?a \<sharp> ?x \<equiv> ?a \<notin> supp ?x atom z \<sharp> c0 atom z \<sharp> v1 atom z \<sharp> v2 atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' ?\<Theta> ; ?\<B> \<turnstile>\<^sub>w\<^sub>f ?\<Gamma> \<Longrightarrow> atom_dom ?\<Gamma> \<subseteq> supp ?\<Gamma> ?a \<sharp> ?xs @ ?ys = (?a \<sharp> ?xs \<and> ?a \<sharp> ?ys) ?a \<sharp> ?x #\<^sub>\<Gamma> ?xs = (?a \<sharp> ?x \<and> ?a \<sharp> ?xs) ?a \<sharp> (?x, ?y) = (?a \<sharp> ?x \<and> ?a \<sharp> ?y) ?x \<sharp> (?a, ?b, ?c) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c) ?x \<sharp> (?a, ?b, ?c, ?d) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d) ?x \<sharp> (?a, ?b, ?c, ?d, ?e) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j, ?k, ?l) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j \<and> ?x \<sharp> ?k \<and> ?x \<sharp> ?l) goal (4 subgoals): 1. atom z \<in> supp \<Gamma>' \<Longrightarrow> False 2. atom z \<in> supp x \<Longrightarrow> False 3. atom z \<in> supp c0 \<Longrightarrow> False 4. atom z \<in> supp \<Gamma> \<Longrightarrow> False [PROOF STEP] by metis+ [PROOF STATE] proof (state) this: atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) goal (2 subgoals): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' 2. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' [PROOF STEP] show "\<Theta>; \<B>; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1'" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' [PROOF STEP] using infer_v_pairI [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 atom z \<sharp> v1 atom z \<sharp> v2 atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' [PROOF STEP] show "\<Theta>; \<B>; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2'" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' [PROOF STEP] using infer_v_pairI [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 atom z \<sharp> v1 atom z \<sharp> v2 atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v1 \<Rightarrow> t1' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v2 \<Rightarrow> t2' goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> [ v1 , v2 ]\<^sup>v \<Rightarrow> \<lbrace> z : [ b_of t1' , b_of t2' ]\<^sup>b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ [ v1 , v2 ]\<^sup>v ]\<^sup>c\<^sup>e \<rbrace> goal (2 subgoals): 1. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] next [PROOF STATE] proof (state) goal (2 subgoals): 1. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] case (infer_v_consI s dclist \<Theta> dc tc \<B> v tv z) [PROOF STATE] proof (state) this: atom z \<sharp> c0 AF_typedef s dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc atom z \<sharp> v atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (2 subgoals): 1. \<And>s dclist \<Theta> dc tc \<B> v tv z c0. \<lbrakk>atom z \<sharp> c0; AF_typedef s dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc; atom z \<sharp> v; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> 2. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] proof [PROOF STATE] proof (state) goal (6 subgoals): 1. AF_typedef s ?dclist \<in> set \<Theta> 2. (dc, ?tc) \<in> set ?dclist 3. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> ?tv 4. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> ?tv \<lesssim> ?tc 5. atom z \<sharp> v 6. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) [PROOF STEP] show \<open>AF_typedef s dclist \<in> set \<Theta>\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. AF_typedef s dclist \<in> set \<Theta> [PROOF STEP] using infer_v_consI [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 AF_typedef s dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc atom z \<sharp> v atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. AF_typedef s dclist \<in> set \<Theta> [PROOF STEP] by auto [PROOF STATE] proof (state) this: AF_typedef s dclist \<in> set \<Theta> goal (5 subgoals): 1. (dc, ?tc) \<in> set dclist 2. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> ?tv 3. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> ?tv \<lesssim> ?tc 4. atom z \<sharp> v 5. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) [PROOF STEP] show \<open>(dc, tc) \<in> set dclist\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. (dc, tc) \<in> set dclist [PROOF STEP] using infer_v_consI [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 AF_typedef s dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc atom z \<sharp> v atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. (dc, tc) \<in> set dclist [PROOF STEP] by auto [PROOF STATE] proof (state) this: (dc, tc) \<in> set dclist goal (4 subgoals): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> ?tv 2. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> ?tv \<lesssim> tc 3. atom z \<sharp> v 4. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) [PROOF STEP] show \<open> \<Theta>; \<B>; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv [PROOF STEP] using infer_v_consI [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 AF_typedef s dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc atom z \<sharp> v atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv goal (3 subgoals): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc 2. atom z \<sharp> v 3. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) [PROOF STEP] show \<open>\<Theta>; \<B>; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc [PROOF STEP] using infer_v_consI ctx_subtype_subtype [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 AF_typedef s dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc atom z \<sharp> v atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<lbrakk>?\<Theta> ; ?\<B> ; ?G \<turnstile> ?t1.0 \<lesssim> ?t2.0; ?G = ?\<Gamma>' @ (?x, ?b0.0, ?c0') #\<^sub>\<Gamma> ?\<Gamma>; ?\<Theta> ; ?\<B> ; ?\<Gamma>' @ (?x, ?b0.0, ?c0.0) #\<^sub>\<Gamma> ?\<Gamma> \<Turnstile> ?c0' \<rbrakk> \<Longrightarrow> ?\<Theta> ; ?\<B> ; ?\<Gamma>' @ (?x, ?b0.0, ?c0.0) #\<^sub>\<Gamma> ?\<Gamma> \<turnstile> ?t1.0 \<lesssim> ?t2.0 goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc goal (2 subgoals): 1. atom z \<sharp> v 2. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) [PROOF STEP] show \<open>atom z \<sharp> v\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. atom z \<sharp> v [PROOF STEP] using infer_v_consI [PROOF STATE] proof (prove) using this: atom z \<sharp> c0 AF_typedef s dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc atom z \<sharp> v atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. atom z \<sharp> v [PROOF STEP] by auto [PROOF STATE] proof (state) this: atom z \<sharp> v goal (1 subgoal): 1. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) [PROOF STEP] show \<open>atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>)\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) [PROOF STEP] apply( fresh_mth add: infer_v_consI ) [PROOF STATE] proof (prove) goal (4 subgoals): 1. atom z \<in> supp \<Gamma>' \<Longrightarrow> False 2. atom z \<in> supp x \<Longrightarrow> False 3. atom z \<in> supp c0 \<Longrightarrow> False 4. atom z \<in> supp \<Gamma> \<Longrightarrow> False [PROOF STEP] using fresh_def infer_v_consI wfG_supp fresh_append_g fresh_GCons fresh_prodN [PROOF STATE] proof (prove) using this: ?a \<sharp> ?x \<equiv> ?a \<notin> supp ?x atom z \<sharp> c0 AF_typedef s dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc atom z \<sharp> v atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' ?\<Theta> ; ?\<B> \<turnstile>\<^sub>w\<^sub>f ?\<Gamma> \<Longrightarrow> atom_dom ?\<Gamma> \<subseteq> supp ?\<Gamma> ?a \<sharp> ?xs @ ?ys = (?a \<sharp> ?xs \<and> ?a \<sharp> ?ys) ?a \<sharp> ?x #\<^sub>\<Gamma> ?xs = (?a \<sharp> ?x \<and> ?a \<sharp> ?xs) ?a \<sharp> (?x, ?y) = (?a \<sharp> ?x \<and> ?a \<sharp> ?y) ?x \<sharp> (?a, ?b, ?c) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c) ?x \<sharp> (?a, ?b, ?c, ?d) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d) ?x \<sharp> (?a, ?b, ?c, ?d, ?e) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j, ?k, ?l) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j \<and> ?x \<sharp> ?k \<and> ?x \<sharp> ?l) goal (4 subgoals): 1. atom z \<in> supp \<Gamma>' \<Longrightarrow> False 2. atom z \<in> supp x \<Longrightarrow> False 3. atom z \<in> supp c0 \<Longrightarrow> False 4. atom z \<in> supp \<Gamma> \<Longrightarrow> False [PROOF STEP] by metis+ [PROOF STATE] proof (state) this: atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>) goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_cons s dc v \<Rightarrow> \<lbrace> z : B_id s | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_cons s dc v ]\<^sup>c\<^sup>e \<rbrace> goal (1 subgoal): 1. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] next [PROOF STATE] proof (state) goal (1 subgoal): 1. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] case (infer_v_conspI s bv dclist \<Theta> dc tc \<B> v tv b z) [PROOF STATE] proof (state) this: atom bv \<sharp> c0 atom z \<sharp> c0 AF_typedef_poly s bv dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> v atom z \<sharp> b atom bv \<sharp> \<Theta> atom bv \<sharp> \<B> atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom bv \<sharp> v atom bv \<sharp> b \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. \<And>s bv dclist \<Theta> dc tc \<B> v tv b z c0. \<lbrakk>atom bv \<sharp> c0; atom z \<sharp> c0; AF_typedef_poly s bv dclist \<in> set \<Theta>; (dc, tc) \<in> set dclist; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<And>b. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b; atom z \<sharp> \<Theta>; atom z \<sharp> \<B>; atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom z \<sharp> v; atom z \<sharp> b; atom bv \<sharp> \<Theta>; atom bv \<sharp> \<B>; atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma>; atom bv \<sharp> v; atom bv \<sharp> b; \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b ; \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<rbrakk> \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] show ?case [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> [PROOF STEP] proof [PROOF STATE] proof (state) goal (7 subgoals): 1. AF_typedef_poly s ?bv ?dclist \<in> set \<Theta> 2. (dc, ?tc) \<in> set ?dclist 3. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> ?tv 4. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> ?tv \<lesssim> ?tc[?bv::=b]\<^sub>\<tau>\<^sub>b 5. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 6. atom ?bv \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 7. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b [PROOF STEP] show \<open>AF_typedef_poly s bv dclist \<in> set \<Theta>\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. AF_typedef_poly s bv dclist \<in> set \<Theta> [PROOF STEP] using infer_v_conspI [PROOF STATE] proof (prove) using this: atom bv \<sharp> c0 atom z \<sharp> c0 AF_typedef_poly s bv dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> v atom z \<sharp> b atom bv \<sharp> \<Theta> atom bv \<sharp> \<B> atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom bv \<sharp> v atom bv \<sharp> b \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. AF_typedef_poly s bv dclist \<in> set \<Theta> [PROOF STEP] by auto [PROOF STATE] proof (state) this: AF_typedef_poly s bv dclist \<in> set \<Theta> goal (6 subgoals): 1. (dc, ?tc) \<in> set dclist 2. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> ?tv 3. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> ?tv \<lesssim> ?tc[bv::=b]\<^sub>\<tau>\<^sub>b 4. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 5. atom bv \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 6. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b [PROOF STEP] show \<open>(dc, tc) \<in> set dclist\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. (dc, tc) \<in> set dclist [PROOF STEP] using infer_v_conspI [PROOF STATE] proof (prove) using this: atom bv \<sharp> c0 atom z \<sharp> c0 AF_typedef_poly s bv dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> v atom z \<sharp> b atom bv \<sharp> \<Theta> atom bv \<sharp> \<B> atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom bv \<sharp> v atom bv \<sharp> b \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. (dc, tc) \<in> set dclist [PROOF STEP] by auto [PROOF STATE] proof (state) this: (dc, tc) \<in> set dclist goal (5 subgoals): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> ?tv 2. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> ?tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b 3. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 4. atom bv \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 5. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b [PROOF STEP] show \<open> \<Theta>; \<B>; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv [PROOF STEP] using infer_v_conspI [PROOF STATE] proof (prove) using this: atom bv \<sharp> c0 atom z \<sharp> c0 AF_typedef_poly s bv dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> v atom z \<sharp> b atom bv \<sharp> \<Theta> atom bv \<sharp> \<B> atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom bv \<sharp> v atom bv \<sharp> b \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv goal (4 subgoals): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b 2. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 3. atom bv \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 4. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b [PROOF STEP] show \<open>\<Theta>; \<B>; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b [PROOF STEP] using infer_v_conspI ctx_subtype_subtype [PROOF STATE] proof (prove) using this: atom bv \<sharp> c0 atom z \<sharp> c0 AF_typedef_poly s bv dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> v atom z \<sharp> b atom bv \<sharp> \<Theta> atom bv \<sharp> \<B> atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom bv \<sharp> v atom bv \<sharp> b \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<lbrakk>?\<Theta> ; ?\<B> ; ?G \<turnstile> ?t1.0 \<lesssim> ?t2.0; ?G = ?\<Gamma>' @ (?x, ?b0.0, ?c0') #\<^sub>\<Gamma> ?\<Gamma>; ?\<Theta> ; ?\<B> ; ?\<Gamma>' @ (?x, ?b0.0, ?c0.0) #\<^sub>\<Gamma> ?\<Gamma> \<Turnstile> ?c0' \<rbrakk> \<Longrightarrow> ?\<Theta> ; ?\<B> ; ?\<Gamma>' @ (?x, ?b0.0, ?c0.0) #\<^sub>\<Gamma> ?\<Gamma> \<turnstile> ?t1.0 \<lesssim> ?t2.0 goal (1 subgoal): 1. \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b goal (3 subgoals): 1. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 2. atom bv \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 3. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b [PROOF STEP] show \<open>atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b)\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) [PROOF STEP] apply( fresh_mth add: infer_v_conspI ) [PROOF STATE] proof (prove) goal (4 subgoals): 1. atom z \<in> supp \<Gamma>' \<Longrightarrow> False 2. atom z \<in> supp x \<Longrightarrow> False 3. atom z \<in> supp c0 \<Longrightarrow> False 4. atom z \<in> supp \<Gamma> \<Longrightarrow> False [PROOF STEP] using fresh_def infer_v_conspI wfG_supp fresh_append_g fresh_GCons fresh_prodN [PROOF STATE] proof (prove) using this: ?a \<sharp> ?x \<equiv> ?a \<notin> supp ?x atom bv \<sharp> c0 atom z \<sharp> c0 AF_typedef_poly s bv dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> v atom z \<sharp> b atom bv \<sharp> \<Theta> atom bv \<sharp> \<B> atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom bv \<sharp> v atom bv \<sharp> b \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' ?\<Theta> ; ?\<B> \<turnstile>\<^sub>w\<^sub>f ?\<Gamma> \<Longrightarrow> atom_dom ?\<Gamma> \<subseteq> supp ?\<Gamma> ?a \<sharp> ?xs @ ?ys = (?a \<sharp> ?xs \<and> ?a \<sharp> ?ys) ?a \<sharp> ?x #\<^sub>\<Gamma> ?xs = (?a \<sharp> ?x \<and> ?a \<sharp> ?xs) ?a \<sharp> (?x, ?y) = (?a \<sharp> ?x \<and> ?a \<sharp> ?y) ?x \<sharp> (?a, ?b, ?c) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c) ?x \<sharp> (?a, ?b, ?c, ?d) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d) ?x \<sharp> (?a, ?b, ?c, ?d, ?e) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j, ?k, ?l) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j \<and> ?x \<sharp> ?k \<and> ?x \<sharp> ?l) goal (4 subgoals): 1. atom z \<in> supp \<Gamma>' \<Longrightarrow> False 2. atom z \<in> supp x \<Longrightarrow> False 3. atom z \<in> supp c0 \<Longrightarrow> False 4. atom z \<in> supp \<Gamma> \<Longrightarrow> False [PROOF STEP] by metis+ [PROOF STATE] proof (state) this: atom z \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) goal (2 subgoals): 1. atom bv \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) 2. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b [PROOF STEP] show \<open>atom bv \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b)\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. atom bv \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) [PROOF STEP] apply( fresh_mth add: infer_v_conspI ) [PROOF STATE] proof (prove) goal (1 subgoal): 1. atom bv \<sharp> \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> [PROOF STEP] using fresh_def infer_v_conspI wfG_supp fresh_append_g fresh_GCons fresh_prodN [PROOF STATE] proof (prove) using this: ?a \<sharp> ?x \<equiv> ?a \<notin> supp ?x atom bv \<sharp> c0 atom z \<sharp> c0 AF_typedef_poly s bv dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> v atom z \<sharp> b atom bv \<sharp> \<Theta> atom bv \<sharp> \<B> atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom bv \<sharp> v atom bv \<sharp> b \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' ?\<Theta> ; ?\<B> \<turnstile>\<^sub>w\<^sub>f ?\<Gamma> \<Longrightarrow> atom_dom ?\<Gamma> \<subseteq> supp ?\<Gamma> ?a \<sharp> ?xs @ ?ys = (?a \<sharp> ?xs \<and> ?a \<sharp> ?ys) ?a \<sharp> ?x #\<^sub>\<Gamma> ?xs = (?a \<sharp> ?x \<and> ?a \<sharp> ?xs) ?a \<sharp> (?x, ?y) = (?a \<sharp> ?x \<and> ?a \<sharp> ?y) ?x \<sharp> (?a, ?b, ?c) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c) ?x \<sharp> (?a, ?b, ?c, ?d) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d) ?x \<sharp> (?a, ?b, ?c, ?d, ?e) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j) ?x \<sharp> (?a, ?b, ?c, ?d, ?e, ?f, ?g, ?h, ?i, ?j, ?k, ?l) = (?x \<sharp> ?a \<and> ?x \<sharp> ?b \<and> ?x \<sharp> ?c \<and> ?x \<sharp> ?d \<and> ?x \<sharp> ?e \<and> ?x \<sharp> ?f \<and> ?x \<sharp> ?g \<and> ?x \<sharp> ?h \<and> ?x \<sharp> ?i \<and> ?x \<sharp> ?j \<and> ?x \<sharp> ?k \<and> ?x \<sharp> ?l) goal (1 subgoal): 1. atom bv \<sharp> \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> [PROOF STEP] by metis+ [PROOF STATE] proof (state) this: atom bv \<sharp> (\<Theta>, \<B>, \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma>, v, b) goal (1 subgoal): 1. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b [PROOF STEP] show \<open> \<Theta>; \<B> \<turnstile>\<^sub>w\<^sub>f b \<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b [PROOF STEP] using infer_v_conspI [PROOF STATE] proof (prove) using this: atom bv \<sharp> c0 atom z \<sharp> c0 AF_typedef_poly s bv dclist \<in> set \<Theta> (dc, tc) \<in> set dclist \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' \<Longrightarrow> \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, ?b) #\<^sub>\<Gamma> \<Gamma> \<turnstile> v \<Rightarrow> tv \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> \<turnstile> tv \<lesssim> tc[bv::=b]\<^sub>\<tau>\<^sub>b atom z \<sharp> \<Theta> atom z \<sharp> \<B> atom z \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom z \<sharp> v atom z \<sharp> b atom bv \<sharp> \<Theta> atom bv \<sharp> \<B> atom bv \<sharp> \<Gamma>' @ (x, b0, c0') #\<^sub>\<Gamma> \<Gamma> atom bv \<sharp> v atom bv \<sharp> b \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<Turnstile> c0' goal (1 subgoal): 1. \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<Theta> ; \<B> \<turnstile>\<^sub>w\<^sub>f b goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: \<Theta> ; \<B> ; \<Gamma>' @ (x, b0, c0) #\<^sub>\<Gamma> \<Gamma> \<turnstile> V_consp s dc b v \<Rightarrow> \<lbrace> z : B_app s b | [ [ z ]\<^sup>v ]\<^sup>c\<^sup>e == [ V_consp s dc b v ]\<^sup>c\<^sup>e \<rbrace> goal: No subgoals! [PROOF STEP] qed
/- Copyright (c) 2021 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies ! This file was ported from Lean 3 source module analysis.convex.strict ! leanprover-community/mathlib commit 84dc0bd6619acaea625086d6f53cb35cdd554219 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Analysis.Convex.Basic import Mathlib.Topology.Algebra.Order.Group /-! # Strictly convex sets This file defines strictly convex sets. A set is strictly convex if the open segment between any two distinct points lies in its interior. -/ open Set open Convex Pointwise variable {𝕜 𝕝 E F β : Type _} open Function Set open Convex section OrderedSemiring variable [OrderedSemiring 𝕜] [TopologicalSpace E] [TopologicalSpace F] section AddCommMonoid variable [AddCommMonoid E] [AddCommMonoid F] section SMul variable (𝕜) variable [SMul 𝕜 E] [SMul 𝕜 F] (s : Set E) /-- A set is strictly convex if the open segment between any two distinct points lies is in its interior. This basically means "convex and not flat on the boundary". -/ def StrictConvex : Prop := s.Pairwise fun x y => ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 → a • x + b • y ∈ interior s #align strict_convex StrictConvex variable {𝕜 s} variable {x y : E} {a b : 𝕜} theorem strictConvex_iff_openSegment_subset : StrictConvex 𝕜 s ↔ s.Pairwise fun x y => openSegment 𝕜 x y ⊆ interior s := forall₅_congr fun _ _ _ _ _ => (openSegment_subset_iff 𝕜).symm #align strict_convex_iff_open_segment_subset strictConvex_iff_openSegment_subset theorem StrictConvex.openSegment_subset (hs : StrictConvex 𝕜 s) (hx : x ∈ s) (hy : y ∈ s) (h : x ≠ y) : openSegment 𝕜 x y ⊆ interior s := strictConvex_iff_openSegment_subset.1 hs hx hy h #align strict_convex.open_segment_subset StrictConvex.openSegment_subset theorem strictConvex_empty : StrictConvex 𝕜 (∅ : Set E) := pairwise_empty _ #align strict_convex_empty strictConvex_empty theorem strictConvex_univ : StrictConvex 𝕜 (univ : Set E) := by intro x _ y _ _ a b _ _ _ rw [interior_univ] exact mem_univ _ #align strict_convex_univ strictConvex_univ protected nonrec theorem StrictConvex.eq (hs : StrictConvex 𝕜 s) (hx : x ∈ s) (hy : y ∈ s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) (h : a • x + b • y ∉ interior s) : x = y := hs.eq hx hy fun H => h <| H ha hb hab #align strict_convex.eq StrictConvex.eq protected theorem StrictConvex.inter {t : Set E} (hs : StrictConvex 𝕜 s) (ht : StrictConvex 𝕜 t) : StrictConvex 𝕜 (s ∩ t) := by intro x hx y hy hxy a b ha hb hab rw [interior_inter] exact ⟨hs hx.1 hy.1 hxy ha hb hab, ht hx.2 hy.2 hxy ha hb hab⟩ #align strict_convex.inter StrictConvex.inter theorem Directed.strictConvex_unionᵢ {ι : Sort _} {s : ι → Set E} (hdir : Directed (· ⊆ ·) s) (hs : ∀ ⦃i : ι⦄, StrictConvex 𝕜 (s i)) : StrictConvex 𝕜 (⋃ i, s i) := by rintro x hx y hy hxy a b ha hb hab rw [mem_unionᵢ] at hx hy obtain ⟨i, hx⟩ := hx obtain ⟨j, hy⟩ := hy obtain ⟨k, hik, hjk⟩ := hdir i j exact interior_mono (subset_unionᵢ s k) (hs (hik hx) (hjk hy) hxy ha hb hab) #align directed.strict_convex_Union Directed.strictConvex_unionᵢ theorem DirectedOn.strictConvex_unionₛ {S : Set (Set E)} (hdir : DirectedOn (· ⊆ ·) S) (hS : ∀ s ∈ S, StrictConvex 𝕜 s) : StrictConvex 𝕜 (⋃₀ S) := by rw [unionₛ_eq_unionᵢ] exact (directedOn_iff_directed.1 hdir).strictConvex_unionᵢ fun s => hS _ s.2 #align directed_on.strict_convex_sUnion DirectedOn.strictConvex_unionₛ end SMul section Module variable [Module 𝕜 E] [Module 𝕜 F] {s : Set E} protected theorem StrictConvex.convex (hs : StrictConvex 𝕜 s) : Convex 𝕜 s := convex_iff_pairwise_pos.2 fun _ hx _ hy hxy _ _ ha hb hab => interior_subset <| hs hx hy hxy ha hb hab #align strict_convex.convex StrictConvex.convex /-- An open convex set is strictly convex. -/ protected theorem Convex.strictConvex_of_open (h : IsOpen s) (hs : Convex 𝕜 s) : StrictConvex 𝕜 s := fun _ hx _ hy _ _ _ ha hb hab => h.interior_eq.symm ▸ hs hx hy ha.le hb.le hab #align convex.strict_convex_of_open Convex.strictConvex_of_open theorem IsOpen.strictConvex_iff (h : IsOpen s) : StrictConvex 𝕜 s ↔ Convex 𝕜 s := ⟨StrictConvex.convex, Convex.strictConvex_of_open h⟩ #align is_open.strict_convex_iff IsOpen.strictConvex_iff theorem strictConvex_singleton (c : E) : StrictConvex 𝕜 ({c} : Set E) := pairwise_singleton _ _ #align strict_convex_singleton strictConvex_singleton theorem Set.Subsingleton.strictConvex (hs : s.Subsingleton) : StrictConvex 𝕜 s := hs.pairwise _ #align set.subsingleton.strict_convex Set.Subsingleton.strictConvex theorem StrictConvex.linear_image [Semiring 𝕝] [Module 𝕝 E] [Module 𝕝 F] [LinearMap.CompatibleSMul E F 𝕜 𝕝] (hs : StrictConvex 𝕜 s) (f : E →ₗ[𝕝] F) (hf : IsOpenMap f) : StrictConvex 𝕜 (f '' s) := by rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ hxy a b ha hb hab refine' hf.image_interior_subset _ ⟨a • x + b • y, hs hx hy (ne_of_apply_ne _ hxy) ha hb hab, _⟩ rw [map_add, f.map_smul_of_tower a, f.map_smul_of_tower b] #align strict_convex.linear_image StrictConvex.linear_image theorem StrictConvex.is_linear_image (hs : StrictConvex 𝕜 s) {f : E → F} (h : IsLinearMap 𝕜 f) (hf : IsOpenMap f) : StrictConvex 𝕜 (f '' s) := hs.linear_image (h.mk' f) hf #align strict_convex.is_linear_image StrictConvex.is_linear_image theorem StrictConvex.linear_preimage {s : Set F} (hs : StrictConvex 𝕜 s) (f : E →ₗ[𝕜] F) (hf : Continuous f) (hfinj : Injective f) : StrictConvex 𝕜 (s.preimage f) := by intro x hx y hy hxy a b ha hb hab refine' preimage_interior_subset_interior_preimage hf _ rw [mem_preimage, f.map_add, f.map_smul, f.map_smul] exact hs hx hy (hfinj.ne hxy) ha hb hab #align strict_convex.linear_preimage StrictConvex.linear_preimage theorem StrictConvex.is_linear_preimage {s : Set F} (hs : StrictConvex 𝕜 s) {f : E → F} (h : IsLinearMap 𝕜 f) (hf : Continuous f) (hfinj : Injective f) : StrictConvex 𝕜 (s.preimage f) := hs.linear_preimage (h.mk' f) hf hfinj #align strict_convex.is_linear_preimage StrictConvex.is_linear_preimage section LinearOrderedCancelAddCommMonoid variable [TopologicalSpace β] [LinearOrderedCancelAddCommMonoid β] [OrderTopology β] [Module 𝕜 β] [OrderedSMul 𝕜 β] protected theorem Set.OrdConnected.strictConvex {s : Set β} (hs : OrdConnected s) : StrictConvex 𝕜 s := by refine' strictConvex_iff_openSegment_subset.2 fun x hx y hy hxy => _ cases' hxy.lt_or_lt with hlt hlt <;> [skip, rw [openSegment_symm]] <;> exact (openSegment_subset_Ioo hlt).trans (isOpen_Ioo.subset_interior_iff.2 <| Ioo_subset_Icc_self.trans <| hs.out ‹_› ‹_›) #align set.ord_connected.strict_convex Set.OrdConnected.strictConvex theorem strictConvex_Iic (r : β) : StrictConvex 𝕜 (Iic r) := ordConnected_Iic.strictConvex #align strict_convex_Iic strictConvex_Iic theorem strictConvex_Ici (r : β) : StrictConvex 𝕜 (Ici r) := ordConnected_Ici.strictConvex #align strict_convex_Ici strictConvex_Ici theorem strictConvex_Iio (r : β) : StrictConvex 𝕜 (Iio r) := ordConnected_Iio.strictConvex #align strict_convex_Iio strictConvex_Iio theorem strictConvex_Ioi (r : β) : StrictConvex 𝕜 (Ioi r) := ordConnected_Ioi.strictConvex #align strict_convex_Ioi strictConvex_Ioi theorem strictConvex_Icc (r s : β) : StrictConvex 𝕜 (Icc r s) := ordConnected_Icc.strictConvex #align strict_convex_Icc strictConvex_Icc theorem strictConvex_Ioo (r s : β) : StrictConvex 𝕜 (Ioo r s) := ordConnected_Ioo.strictConvex #align strict_convex_Ioo strictConvex_Ioo theorem strictConvex_Ico (r s : β) : StrictConvex 𝕜 (Ico r s) := ordConnected_Ico.strictConvex #align strict_convex_Ico strictConvex_Ico theorem strictConvex_Ioc (r s : β) : StrictConvex 𝕜 (Ioc r s) := ordConnected_Ioc.strictConvex #align strict_convex_Ioc strictConvex_Ioc theorem strictConvex_uIcc (r s : β) : StrictConvex 𝕜 (uIcc r s) := strictConvex_Icc _ _ #align strict_convex_uIcc strictConvex_uIcc theorem strictConvex_uIoc (r s : β) : StrictConvex 𝕜 (uIoc r s) := strictConvex_Ioc _ _ #align strict_convex_uIoc strictConvex_uIoc end LinearOrderedCancelAddCommMonoid end Module end AddCommMonoid section AddCancelCommMonoid variable [AddCancelCommMonoid E] [ContinuousAdd E] [Module 𝕜 E] {s : Set E} /-- The translation of a strictly convex set is also strictly convex. -/ theorem StrictConvex.preimage_add_right (hs : StrictConvex 𝕜 s) (z : E) : StrictConvex 𝕜 ((fun x => z + x) ⁻¹' s) := by intro x hx y hy hxy a b ha hb hab refine' preimage_interior_subset_interior_preimage (continuous_add_left _) _ have h := hs hx hy ((add_right_injective _).ne hxy) ha hb hab rwa [smul_add, smul_add, add_add_add_comm, ← _root_.add_smul, hab, one_smul] at h #align strict_convex.preimage_add_right StrictConvex.preimage_add_right /-- The translation of a strictly convex set is also strictly convex. -/ theorem StrictConvex.preimage_add_left (hs : StrictConvex 𝕜 s) (z : E) : StrictConvex 𝕜 ((fun x => x + z) ⁻¹' s) := by simpa only [add_comm] using hs.preimage_add_right z #align strict_convex.preimage_add_left StrictConvex.preimage_add_left end AddCancelCommMonoid section AddCommGroup variable [AddCommGroup E] [AddCommGroup F] [Module 𝕜 E] [Module 𝕜 F] section continuous_add variable [ContinuousAdd E] {s t : Set E} theorem StrictConvex.add (hs : StrictConvex 𝕜 s) (ht : StrictConvex 𝕜 t) : StrictConvex 𝕜 (s + t) := by rintro _ ⟨v, w, hv, hw, rfl⟩ _ ⟨x, y, hx, hy, rfl⟩ h a b ha hb hab rw [smul_add, smul_add, add_add_add_comm] obtain rfl | hvx := eq_or_ne v x · refine' interior_mono (add_subset_add (singleton_subset_iff.2 hv) Subset.rfl) _ rw [Convex.combo_self hab, singleton_add] exact (isOpenMap_add_left _).image_interior_subset _ (mem_image_of_mem _ <| ht hw hy (ne_of_apply_ne _ h) ha hb hab) exact subset_interior_add_left (add_mem_add (hs hv hx hvx ha hb hab) <| ht.convex hw hy ha.le hb.le hab) #align strict_convex.add StrictConvex.add theorem StrictConvex.add_left (hs : StrictConvex 𝕜 s) (z : E) : StrictConvex 𝕜 ((fun x => z + x) '' s) := by simpa only [singleton_add] using (strictConvex_singleton z).add hs #align strict_convex.add_left StrictConvex.add_left theorem StrictConvex.add_right (hs : StrictConvex 𝕜 s) (z : E) : StrictConvex 𝕜 ((fun x => x + z) '' s) := by simpa only [add_comm] using hs.add_left z #align strict_convex.add_right StrictConvex.add_right /-- The translation of a strictly convex set is also strictly convex. -/ theorem StrictConvex.vadd (hs : StrictConvex 𝕜 s) (x : E) : StrictConvex 𝕜 (x +ᵥ s) := hs.add_left x #align strict_convex.vadd StrictConvex.vadd end continuous_add section ContinuousSmul variable [LinearOrderedField 𝕝] [Module 𝕝 E] [ContinuousConstSMul 𝕝 E] [LinearMap.CompatibleSMul E E 𝕜 𝕝] {s : Set E} {x : E} theorem StrictConvex.smul (hs : StrictConvex 𝕜 s) (c : 𝕝) : StrictConvex 𝕜 (c • s) := by obtain rfl | hc := eq_or_ne c 0 · exact (subsingleton_zero_smul_set _).strictConvex · exact hs.linear_image (LinearMap.lsmul _ _ c) (isOpenMap_smul₀ hc) #align strict_convex.smul StrictConvex.smul theorem StrictConvex.affinity [ContinuousAdd E] (hs : StrictConvex 𝕜 s) (z : E) (c : 𝕝) : StrictConvex 𝕜 (z +ᵥ c • s) := (hs.smul c).vadd z #align strict_convex.affinity StrictConvex.affinity end ContinuousSmul end AddCommGroup end OrderedSemiring section OrderedCommSemiring variable [OrderedCommSemiring 𝕜] [TopologicalSpace E] section AddCommGroup variable [AddCommGroup E] [Module 𝕜 E] [NoZeroSMulDivisors 𝕜 E] [ContinuousConstSMul 𝕜 E] {s : Set E} theorem StrictConvex.preimage_smul (hs : StrictConvex 𝕜 s) (c : 𝕜) : StrictConvex 𝕜 ((fun z => c • z) ⁻¹' s) := by classical obtain rfl | hc := eq_or_ne c 0 · simp_rw [zero_smul, preimage_const] split_ifs · exact strictConvex_univ · exact strictConvex_empty refine' hs.linear_preimage (LinearMap.lsmul _ _ c) _ (smul_right_injective E hc) unfold LinearMap.lsmul LinearMap.mk₂ LinearMap.mk₂' LinearMap.mk₂'ₛₗ exact continuous_const_smul _ #align strict_convex.preimage_smul StrictConvex.preimage_smul end AddCommGroup end OrderedCommSemiring section OrderedRing variable [OrderedRing 𝕜] [TopologicalSpace E] [TopologicalSpace F] section AddCommGroup variable [AddCommGroup E] [AddCommGroup F] [Module 𝕜 E] [Module 𝕜 F] {s t : Set E} {x y : E} theorem StrictConvex.eq_of_openSegment_subset_frontier [Nontrivial 𝕜] [DenselyOrdered 𝕜] (hs : StrictConvex 𝕜 s) (hx : x ∈ s) (hy : y ∈ s) (h : openSegment 𝕜 x y ⊆ frontier s) : x = y := by obtain ⟨a, ha₀, ha₁⟩ := DenselyOrdered.dense (0 : 𝕜) 1 zero_lt_one classical by_contra hxy exact (h ⟨a, 1 - a, ha₀, sub_pos_of_lt ha₁, add_sub_cancel'_right _ _, rfl⟩).2 (hs hx hy hxy ha₀ (sub_pos_of_lt ha₁) <| add_sub_cancel'_right _ _) #align strict_convex.eq_of_open_segment_subset_frontier StrictConvex.eq_of_openSegment_subset_frontier theorem StrictConvex.add_smul_mem (hs : StrictConvex 𝕜 s) (hx : x ∈ s) (hxy : x + y ∈ s) (hy : y ≠ 0) {t : 𝕜} (ht₀ : 0 < t) (ht₁ : t < 1) : x + t • y ∈ interior s := by have h : x + t • y = (1 - t) • x + t • (x + y) := by rw [smul_add, ← add_assoc, ← _root_.add_smul, sub_add_cancel, one_smul] rw [h] refine' hs hx hxy (fun h => hy <| add_left_cancel _) (sub_pos_of_lt ht₁) ht₀ (sub_add_cancel _ _) rw [← h, add_zero] #align strict_convex.add_smul_mem StrictConvex.add_smul_mem theorem StrictConvex.smul_mem_of_zero_mem (hs : StrictConvex 𝕜 s) (zero_mem : (0 : E) ∈ s) (hx : x ∈ s) (hx₀ : x ≠ 0) {t : 𝕜} (ht₀ : 0 < t) (ht₁ : t < 1) : t • x ∈ interior s := by simpa using hs.add_smul_mem zero_mem (by simpa using hx) hx₀ ht₀ ht₁ #align strict_convex.smul_mem_of_zero_mem StrictConvex.smul_mem_of_zero_mem theorem StrictConvex.add_smul_sub_mem (h : StrictConvex 𝕜 s) (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y) {t : 𝕜} (ht₀ : 0 < t) (ht₁ : t < 1) : x + t • (y - x) ∈ interior s := by apply h.openSegment_subset hx hy hxy rw [openSegment_eq_image'] exact mem_image_of_mem _ ⟨ht₀, ht₁⟩ #align strict_convex.add_smul_sub_mem StrictConvex.add_smul_sub_mem /-- The preimage of a strictly convex set under an affine map is strictly convex. -/ theorem StrictConvex.affine_preimage {s : Set F} (hs : StrictConvex 𝕜 s) {f : E →ᵃ[𝕜] F} (hf : Continuous f) (hfinj : Injective f) : StrictConvex 𝕜 (f ⁻¹' s) := by intro x hx y hy hxy a b ha hb hab refine' preimage_interior_subset_interior_preimage hf _ rw [mem_preimage, Convex.combo_affine_apply hab] exact hs hx hy (hfinj.ne hxy) ha hb hab #align strict_convex.affine_preimage StrictConvex.affine_preimage /-- The image of a strictly convex set under an affine map is strictly convex. -/ theorem StrictConvex.affine_image (hs : StrictConvex 𝕜 s) {f : E →ᵃ[𝕜] F} (hf : IsOpenMap f) : StrictConvex 𝕜 (f '' s) := by rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ hxy a b ha hb hab exact hf.image_interior_subset _ ⟨a • x + b • y, ⟨hs hx hy (ne_of_apply_ne _ hxy) ha hb hab, Convex.combo_affine_apply hab⟩⟩ #align strict_convex.affine_image StrictConvex.affine_image variable [TopologicalAddGroup E] theorem StrictConvex.neg (hs : StrictConvex 𝕜 s) : StrictConvex 𝕜 (-s) := hs.is_linear_preimage IsLinearMap.isLinearMap_neg continuous_id.neg neg_injective #align strict_convex.neg StrictConvex.neg theorem StrictConvex.sub (hs : StrictConvex 𝕜 s) (ht : StrictConvex 𝕜 t) : StrictConvex 𝕜 (s - t) := (sub_eq_add_neg s t).symm ▸ hs.add ht.neg #align strict_convex.sub StrictConvex.sub end AddCommGroup end OrderedRing section LinearOrderedField variable [LinearOrderedField 𝕜] [TopologicalSpace E] section AddCommGroup variable [AddCommGroup E] [AddCommGroup F] [Module 𝕜 E] [Module 𝕜 F] {s : Set E} {x : E} /-- Alternative definition of set strict convexity, using division. -/ theorem strictConvex_iff_div : StrictConvex 𝕜 s ↔ s.Pairwise fun x y => ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → (a / (a + b)) • x + (b / (a + b)) • y ∈ interior s := ⟨fun h x hx y hy hxy a b ha hb => by apply h hx hy hxy (div_pos ha <| add_pos ha hb) (div_pos hb <| add_pos ha hb) rw [← add_div] exact div_self (add_pos ha hb).ne', fun h x hx y hy hxy a b ha hb hab => by convert h hx hy hxy ha hb <;> rw [hab, div_one]⟩ #align strict_convex_iff_div strictConvex_iff_div theorem StrictConvex.mem_smul_of_zero_mem (hs : StrictConvex 𝕜 s) (zero_mem : (0 : E) ∈ s) (hx : x ∈ s) (hx₀ : x ≠ 0) {t : 𝕜} (ht : 1 < t) : x ∈ t • interior s := by rw [mem_smul_set_iff_inv_smul_mem₀ (zero_lt_one.trans ht).ne'] exact hs.smul_mem_of_zero_mem zero_mem hx hx₀ (inv_pos.2 <| zero_lt_one.trans ht) (inv_lt_one ht) #align strict_convex.mem_smul_of_zero_mem StrictConvex.mem_smul_of_zero_mem end AddCommGroup end LinearOrderedField /-! #### Convex sets in an ordered space Relates `Convex` and `Set.OrdConnected`. -/ section variable [LinearOrderedField 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] {s : Set 𝕜} /-- A set in a linear ordered field is strictly convex if and only if it is convex. -/ @[simp] theorem strictConvex_iff_convex : StrictConvex 𝕜 s ↔ Convex 𝕜 s := ⟨StrictConvex.convex, fun hs => hs.ordConnected.strictConvex⟩ #align strict_convex_iff_convex strictConvex_iff_convex theorem strictConvex_iff_ordConnected : StrictConvex 𝕜 s ↔ s.OrdConnected := strictConvex_iff_convex.trans convex_iff_ordConnected #align strict_convex_iff_ord_connected strictConvex_iff_ordConnected alias strictConvex_iff_ordConnected ↔ StrictConvex.ordConnected _ #align strict_convex.ord_connected StrictConvex.ordConnected end
## Author: Sergio García Prado ## Title: Statistical Inference - Goodness of Fit - Exercise 14 rm(list = ls()) observed <- c(9, 11, 4, 6) (k <- length(observed)) # 4 (n <- sum(observed)) # 30 ## test F(x) is poisson(lambda) LogLikelihood <- function(lambda, y, k) { (sum(y[1:(k - 1)] * dpois(0:(k - 2), lambda = lambda, log = TRUE)) + y[k] * ppois(k - 2, lambda = lambda, lower.tail = FALSE, log = TRUE)) } NegativeLogLikelihood <- function(...) { - LogLikelihood(...) } opt <- optim(1, NegativeLogLikelihood, y = observed, k = k, lower = 10e-4, method = 'L-BFGS-B') (lambda.hat <- opt$par) # 1.31334181246836 (expected1 <- n * c(dpois(0:(k-2), lambda = lambda.hat), 1 - ppois(k - 2, lambda = lambda.hat))) # 8.06759619945891 10.5955114148602 6.9577640828109 4.37912830286995 (Q1 <- sum((observed - expected1) ^ 2 / expected1)) # 1.98049899014501 1 - pchisq(Q1, df = (k - 1) - 1) # 0.371483996032531 ## test F(x) is poisson(1.2) (expected2 <- n * c(dpois(0:(k-2), lambda = 1.2), 1 - ppois(k - 2, lambda = 1.2))) # 9.03582635736606 10.8429916288393 6.50579497730357 3.61538703649109 (Q2 <- sum((observed - expected2) ^ 2 / expected2)) # 2.54038357961436 1 - pchisq(Q2, df = (k - 1)) # 0.468037053437737 ## power: (null <- n * c(dpois(0:(k-2), lambda = 1.2), 1 - ppois(k - 2, lambda = 1.2))) # 9.03582635736606 10.8429916288393 6.50579497730357 3.61538703649109 (alternative <- n * c(dnbinom(0:(k-2),size = 2, prob = 2 / 3), 1 - pnbinom(k - 2,size = 2, prob = 2 / 3))) # 13.3333333333333 8.88888888888889 4.44444444444445 3.33333333333333 (Q <- sum((alternative - null) ^ 2 / alternative)) # 2.79465432822941 (power <- 1 - pchisq(qchisq(0.95, df = k - 1), df = k - 1, Q)) # 0.257468163480735 ## sample size power >= 0.8 fn <- function(n) { null <- n * c(dpois(0:(k-2), lambda = 1.2), 1 - ppois(k - 2, lambda = 1.2)) alternative <- n * c(dnbinom(0:(k-2),size = 2, prob = 2 / 3), 1 - pnbinom(k - 2,size = 2, prob = 2 / 3)) Q <- sum((alternative - null) ^ 2 / alternative) power <- 1 - pchisq(qchisq(0.95, df = k - 1), df = k - 1, Q) } (n.exact <- uniroot(function(n) {fn(n) - 0.8}, c(1, 500))$root) # 117.036620884611 ceiling(n.exact) # 118
module PrintNat where import PreludeShow open PreludeShow mainS = showNat 42