{"text": "import for_mathlib.category_theory.localization.opposite\nimport for_mathlib.category_theory.functor_misc\nimport for_mathlib.category_theory.localization.products\n\nnoncomputable theory\n\nnamespace category_theory\n\nopen category\n\nvariables {C : Type*} [category C] {W : morphism_property C}\n\nstructure left_calculus_of_fractions.to_sq {X' X Y : C} (s : X ⟶ X') (hs : W s) (f : X ⟶ Y) :=\n(obj : C)\n(g : X' ⟶ obj)\n(s' : Y ⟶ obj)\n(hs' : W s')\n(fac : f ≫ s' = s ≫ g)\n\nvariable (W)\n\nclass left_calculus_of_fractions : Prop :=\n(id : W.contains_identities)\n(comp [] : W.stable_under_composition)\n(ex : ∀ ⦃X' X Y : C⦄ (s : X ⟶ X') (hs : W s) (u : X ⟶ Y),\n nonempty (left_calculus_of_fractions.to_sq s hs u))\n(ext : ∀ ⦃X' X Y : C⦄ (f₁ f₂ : X ⟶ Y) (s : X' ⟶ X) (hs : W s) (eq : s ≫ f₁ = s ≫ f₂),\n ∃ (Y' : C) (t : Y ⟶ Y') (ht : W t), f₁ ≫ t = f₂ ≫ t)\n\ninstance left_calculus_of_fractions.contains_identities\n [h : left_calculus_of_fractions W] : W.contains_identities := h.id\n\nnamespace left_calculus_of_fractions\n\nvariables (W)\n\nstructure roof (X Y : C) :=\n(Z : C) (f : X ⟶ Z) (s : Y ⟶ Z) (hs : W s)\n\nvariable {W}\ndef roof_rel ⦃X Y : C⦄ (z₁ z₂ : roof W X Y) : Prop :=\n∃ (Z₃ : C) (t₁ : z₁.Z ⟶ Z₃) (t₂ : z₂.Z ⟶ Z₃) (hst : z₁.s ≫ t₁ = z₂.s ≫ t₂)\n (hft : z₁.f ≫ t₁ = z₂.f ≫ t₂), W (z₁.s ≫ t₁)\n\nvariables [left_calculus_of_fractions W] (W)\n\n@[simps]\ndef roof.of_hom {X Y : C} (f : X ⟶ Y) : roof W X Y :=\n⟨Y, f, 𝟙 Y, morphism_property.contains_identities.id W Y⟩\n\n@[simps]\ndef roof.id (X : C) := roof.of_hom W (𝟙 X)\n\nnamespace roof_rel\n\nvariables {W}\n\nlemma refl {X Y : C} (z : roof W X Y) : roof_rel z z :=\n⟨z.Z, 𝟙 _, 𝟙 _, rfl, rfl, by simpa only [comp_id] using z.hs⟩\n\nlemma symm {X Y : C} {z₁ z₂ : roof W X Y} (h : roof_rel z₁ z₂) : roof_rel z₂ z₁ :=\nbegin\n rcases h with ⟨Z₃, t₁, t₂, hst, hft, ht⟩,\n refine ⟨Z₃, t₂, t₁, hst.symm, hft.symm, by simpa only [← hst] using ht⟩,\nend\n\nlemma trans {X Y : C} {z₁ z₂ z₃ : roof W X Y} (h₁₂ : roof_rel z₁ z₂)\n (h₂₃ : roof_rel z₂ z₃) : roof_rel z₁ z₃ :=\nbegin\n rcases h₁₂ with ⟨Z₄, t₁, t₂, hst, hft, ht⟩,\n rcases h₂₃ with ⟨Z₅, u₂, u₃, hsu, hfu, hu⟩,\n rcases left_calculus_of_fractions.ex (z₁.s ≫ t₁) ht (z₃.s ≫ u₃) with ⟨Z₆, v₄, v₅, hv₅, fac⟩,\n simp only [assoc] at fac,\n have eq : z₂.s ≫ u₂ ≫ v₅ = z₂.s ≫ t₂ ≫ v₄,\n { simpa only [← reassoc_of hsu, reassoc_of hst] using fac, },\n rcases left_calculus_of_fractions.ext _ _ _ z₂.hs eq with ⟨Z₇, w, hw, fac'⟩,\n simp only [assoc] at fac',\n refine ⟨Z₇, t₁ ≫ v₄ ≫ w, u₃ ≫ v₅ ≫ w, _, _, _⟩,\n { rw reassoc_of fac, },\n { rw [reassoc_of hft, ← fac', reassoc_of hfu], },\n { rw [← reassoc_of fac, ← reassoc_of hsu, ← assoc],\n exact left_calculus_of_fractions.comp _ _ _ hu\n (left_calculus_of_fractions.comp _ _ _ hv₅ hw), },\nend\n\nend roof_rel\n\ninstance is_equiv_roof_rel (X Y : C) :\n is_equiv (roof W X Y) (λ z₁ z₂, roof_rel z₁ z₂) :=\n{ refl := roof_rel.refl,\n symm := λ z₁ z₂, roof_rel.symm,\n trans := λ z₁ z₂ z₃, roof_rel.trans, }\n\nvariable {W}\n\ndef roof.comp₀ {X₁ X₂ X₃ : C} (z₁₂ : roof W X₁ X₂) (z₂₃ : roof W X₂ X₃)\n (sq : to_sq z₁₂.s z₁₂.hs z₂₃.f) :\n roof W X₁ X₃ :=\n⟨sq.obj, z₁₂.f ≫ sq.g , z₂₃.s ≫ sq.s', left_calculus_of_fractions.comp _ _ _ z₂₃.hs sq.hs'⟩\n\nlemma roof.comp₀_rel {X₁ X₂ X₃ : C} (z₁₂ : roof W X₁ X₂) (z₂₃ : roof W X₂ X₃)\n (sq sq' : to_sq z₁₂.s z₁₂.hs z₂₃.f) :\n roof_rel (roof.comp₀ z₁₂ z₂₃ sq) (roof.comp₀ z₁₂ z₂₃ sq') :=\nbegin\n let H := (left_calculus_of_fractions.ex sq.s' sq.hs' sq'.s').some,\n have eq : z₁₂.s ≫ sq.g ≫ H.g = z₁₂.s ≫ sq'.g ≫ H.s',\n { rw [← reassoc_of sq.fac, ← reassoc_of sq'.fac, H.fac], },\n rcases left_calculus_of_fractions.ext _ _ _ (z₁₂.hs) eq with ⟨Y, t, ht, fac⟩,\n refine ⟨Y, H.g ≫ t, H.s' ≫ t, _, _, _⟩,\n { dsimp [roof.comp₀],\n simp only [assoc, reassoc_of H.fac], },\n { dsimp [roof.comp₀],\n simp only [assoc] at ⊢ fac,\n rw ← fac, },\n { dsimp [roof.comp₀],\n simp only [assoc, ← reassoc_of H.fac],\n refine left_calculus_of_fractions.comp _ _ _ z₂₃.hs\n (left_calculus_of_fractions.comp _ _ _ sq'.hs'\n (left_calculus_of_fractions.comp _ _ _ H.hs' ht)), }\nend\n\nvariable (W)\n\ndef hom (X Y : C) := quot ((λ (z₁ z₂ : roof W X Y), roof_rel z₁ z₂))\n\nvariable {W}\n\ndef roof.comp {X₁ X₂ X₃ : C} (z₁₂ : roof W X₁ X₂) (z₂₃ : roof W X₂ X₃) :\n hom W X₁ X₃ :=\nquot.mk _ (roof.comp₀ z₁₂ z₂₃ (left_calculus_of_fractions.ex z₁₂.s z₁₂.hs z₂₃.f).some)\n\nlemma roof.comp_eq {X₁ X₂ X₃ : C} (z₁₂ : roof W X₁ X₂) (z₂₃ : roof W X₂ X₃)\n (sq : to_sq z₁₂.s z₁₂.hs z₂₃.f) :\n roof.comp z₁₂ z₂₃ = quot.mk _ (roof.comp₀ z₁₂ z₂₃ sq) :=\nquot.sound (roof.comp₀_rel z₁₂ z₂₃ _ _)\n\ndef hom.comp {X₁ X₂ X₃ : C} : hom W X₁ X₂ → hom W X₂ X₃ → hom W X₁ X₃ :=\nbegin\n refine quot.lift₂ (λ z₁₂ z₂₃, roof.comp z₁₂ z₂₃) (λ z₁₂ z₂₃ z₂₃' h₂₃, _)\n (λ z₁₂ z₁₂' z₂₃ h₁₂, _),\n { dsimp,\n let sq := (left_calculus_of_fractions.ex z₁₂.s z₁₂.hs z₂₃.f).some,\n let sq' := (left_calculus_of_fractions.ex z₁₂.s z₁₂.hs z₂₃'.f).some,\n rw [roof.comp_eq _ _ sq, roof.comp_eq _ _ sq'],\n apply quot.sound,\n rcases h₂₃ with ⟨Y, t, t', hst, hft, ht⟩,\n let H₀ := (left_calculus_of_fractions.ex sq.s' sq.hs' t).some,\n let H₀' := (left_calculus_of_fractions.ex sq'.s' sq'.hs' t').some,\n have h : W (z₂₃.s ≫ sq.s' ≫ H₀.g),\n { rw [← H₀.fac, ← assoc],\n exact left_calculus_of_fractions.comp _ _ _ ht H₀.hs', },\n let H₁ := (left_calculus_of_fractions.ex H₀.s' H₀.hs' H₀'.s').some,\n have eq : z₁₂.s ≫ sq.g ≫ H₀.g ≫ H₁.g = z₁₂.s ≫ sq'.g ≫ H₀'.g ≫ H₁.s',\n { simp only [← reassoc_of sq.fac, ← reassoc_of sq'.fac,← reassoc_of H₀.fac,\n ← reassoc_of H₀'.fac, reassoc_of hft, H₁.fac], },\n rcases left_calculus_of_fractions.ext _ _ _ z₁₂.hs eq with ⟨Z, u, hu, fac⟩,\n simp only [assoc] at fac,\n refine ⟨Z, H₀.g ≫ H₁.g ≫ u, H₀'.g ≫ H₁.s' ≫ u, _, _, _⟩; dsimp [roof.comp₀],\n { simp only [assoc, ← reassoc_of H₀.fac, ← reassoc_of H₀'.fac,\n reassoc_of hst, reassoc_of H₁.fac], },\n { simp only [assoc, fac], },\n { simp only [assoc],\n rw [← reassoc_of H₀.fac, ← reassoc_of H₁.fac, ← assoc],\n refine left_calculus_of_fractions.comp _ _ _ ht\n (left_calculus_of_fractions.comp _ _ _ H₀'.hs'\n (left_calculus_of_fractions.comp _ _ _ H₁.hs' hu)), }, },\n { dsimp,\n let sq := (left_calculus_of_fractions.ex z₁₂.s z₁₂.hs z₂₃.f).some,\n let sq' := (left_calculus_of_fractions.ex z₁₂'.s z₁₂'.hs z₂₃.f).some,\n rw [roof.comp_eq _ _ sq, roof.comp_eq _ _ sq'],\n apply quot.sound,\n rcases h₁₂ with ⟨Y, t, t', hst, hft, ht⟩,\n let H := (left_calculus_of_fractions.ex (z₁₂.s ≫ t) ht (z₂₃.f ≫ sq.s')).some,\n let H' := (left_calculus_of_fractions.ex (z₁₂'.s ≫ t') (by { rw ← hst, exact ht, })\n (z₂₃.f ≫ sq'.s')).some,\n let z : roof W X₁ X₃ := ⟨H.obj, z₁₂.f ≫ t ≫ H.g, z₂₃.s ≫ sq.s' ≫ H.s',\n left_calculus_of_fractions.comp _ _ _ z₂₃.hs\n (left_calculus_of_fractions.comp _ _ _ sq.hs' H.hs')⟩,\n let z' : roof W X₁ X₃ := ⟨H'.obj, z₁₂'.f ≫ t' ≫ H'.g, z₂₃.s ≫ sq'.s' ≫ H'.s',\n left_calculus_of_fractions.comp _ _ _ z₂₃.hs\n (left_calculus_of_fractions.comp _ _ _ sq'.hs' H'.hs')⟩,\n refine trans _ (trans (_ : roof_rel z z') (symm _)),\n { have eq : z₁₂.s ≫ sq.g ≫ H.s' = z₁₂.s ≫ t ≫ H.g,\n { have h := H.fac,\n simp only [assoc] at h,\n rw [← h, reassoc_of sq.fac], },\n rcases left_calculus_of_fractions.ext _ _ _ z₁₂.hs eq with ⟨Z, u, hu, fac⟩,\n simp only [assoc] at fac,\n refine ⟨Z, H.s' ≫ u, u, _,_, _⟩; dsimp [roof.comp₀],\n { simp only [assoc, comp_id], },\n { simp only [assoc, comp_id, fac], },\n { simp only [assoc],\n refine left_calculus_of_fractions.comp _ _ _ z₂₃.hs\n (left_calculus_of_fractions.comp _ _ _ sq.hs'\n (left_calculus_of_fractions.comp _ _ _ H.hs' hu)), }, },\n { let T := (left_calculus_of_fractions.ex (sq.s' ≫ H.s')\n (left_calculus_of_fractions.comp _ _ _ sq.hs' H.hs') (sq'.s' ≫ H'.s')).some,\n have Tfac := T.fac,\n have fac := H.fac,\n have fac' := H'.fac,\n simp only [assoc] at Tfac fac fac',\n have eq : z₁₂.s ≫ t ≫ H.g ≫ T.g = z₁₂.s ≫ t ≫ H'.g ≫ T.s',\n { simp only [reassoc_of hst, ← reassoc_of fac', Tfac, reassoc_of fac], },\n rcases left_calculus_of_fractions.ext _ _ _ z₁₂.hs eq with ⟨Z, u, hu, fac''⟩,\n simp only [assoc] at fac'',\n refine ⟨Z, T.g ≫ u, T.s' ≫ u, _, _, _⟩; dsimp [z, z'],\n { simp only [assoc, reassoc_of Tfac], },\n { rw [assoc, assoc, assoc, assoc, fac'', reassoc_of hft], },\n { simp only [assoc, ← reassoc_of Tfac],\n exact left_calculus_of_fractions.comp _ _ _ z₂₃.hs\n (left_calculus_of_fractions.comp _ _ _ sq'.hs'\n (left_calculus_of_fractions.comp _ _ _ H'.hs'\n (left_calculus_of_fractions.comp _ _ _ T.hs' hu))), }, },\n { have eq : z₁₂'.s ≫ sq'.g ≫ H'.s' = z₁₂'.s ≫ t' ≫ H'.g,\n { have h := H'.fac,\n simp only [assoc] at h,\n rw [← h, reassoc_of sq'.fac], },\n rcases left_calculus_of_fractions.ext _ _ _ z₁₂'.hs eq with ⟨Z, u, hu, fac⟩,\n simp only [assoc] at fac,\n refine ⟨Z, H'.s' ≫ u, u, _,_, _⟩; dsimp [roof.comp₀],\n { simp only [assoc, comp_id], },\n { simp only [assoc, comp_id, fac], },\n { simp only [assoc],\n refine left_calculus_of_fractions.comp _ _ _ z₂₃.hs\n (left_calculus_of_fractions.comp _ _ _ sq'.hs'\n (left_calculus_of_fractions.comp _ _ _ H'.hs' hu)), }, }, },\nend\n\nlemma hom.comp_eq {X₁ X₂ X₃ : C} (z₁₂ : roof W X₁ X₂) (z₂₃ : roof W X₂ X₃)\n (sq : to_sq z₁₂.s z₁₂.hs z₂₃.f) : hom.comp (quot.mk _ z₁₂) (quot.mk _ z₂₃) =\n quot.mk _ (roof.comp₀ z₁₂ z₂₃ sq) :=\nbegin\n let sq' := (left_calculus_of_fractions.ex z₁₂.s z₁₂.hs z₂₃.f).some,\n have eq : (quot.mk _ (z₁₂.comp₀ z₂₃ sq) : hom W _ _) = quot.mk _ (z₁₂.comp₀ z₂₃ sq'),\n { rw [← roof.comp_eq, ← roof.comp_eq], },\n simpa only [eq],\nend\n\ninclude W\n\nvariable (W)\n\nstructure localization :=\n(obj : C)\n\ninstance : category (localization W) :=\n{ hom := λ X Y, hom W X.obj Y.obj,\n id := λ X, quot.mk _ (roof.id W X.obj),\n comp := λ X₁ X₂ X₃, hom.comp,\n id_comp' := λ X Y f, begin\n cases surjective_quot_mk _ f with g hg,\n subst hg,\n dsimp [hom.comp],\n let sq : to_sq (𝟙 X.obj) (morphism_property.contains_identities.id W X.obj) g.f :=\n ⟨g.Z, g.f, 𝟙 g.Z, morphism_property.contains_identities.id W g.Z, by rw [id_comp, comp_id]⟩,\n rw roof.comp_eq (roof.id W X.obj) g sq,\n congr' 1,\n dsimp [roof.comp₀],\n cases g,\n tidy,\n end,\n comp_id' := λ X Y f, begin\n cases surjective_quot_mk _ f with g hg,\n subst hg,\n dsimp [hom.comp],\n let sq : to_sq g.s g.hs (𝟙 Y.obj) := ⟨g.Z, 𝟙 g.Z, g.s, g.hs, by rw [id_comp, comp_id]⟩,\n rw roof.comp_eq g (roof.id W Y.obj) sq,\n congr' 1,\n dsimp [roof.comp₀],\n cases g,\n tidy,\n end,\n assoc' := λ X₁ X₂ X₃ X₄ f₁₂ f₂₃ f₃₄, begin\n cases surjective_quot_mk _ f₁₂ with z₁₂ h₁₂,\n cases surjective_quot_mk _ f₂₃ with z₂₃ h₂₃,\n cases surjective_quot_mk _ f₃₄ with z₃₄ h₃₄,\n let sq₁₃ := (left_calculus_of_fractions.ex z₁₂.s z₁₂.hs z₂₃.f).some,\n let sq₂₄ := (left_calculus_of_fractions.ex z₂₃.s z₂₃.hs z₃₄.f).some,\n dsimp,\n let H := (left_calculus_of_fractions.ex sq₁₃.s' sq₁₃.hs' sq₂₄.g).some,\n let sq : to_sq (z₁₂.comp₀ z₂₃ sq₁₃).s (z₁₂.comp₀ z₂₃ sq₁₃).hs z₃₄.f := begin\n refine ⟨H.obj, H.g, sq₂₄.s' ≫ H.s', left_calculus_of_fractions.comp _ _ _ sq₂₄.hs' H.hs', _⟩,\n dsimp [roof.comp₀],\n rw [assoc, ← H.fac, reassoc_of sq₂₄.fac],\n end,\n let sq' : to_sq z₁₂.s z₁₂.hs (z₂₃.comp₀ z₃₄ sq₂₄).f := begin\n refine ⟨H.obj, sq₁₃.g ≫ H.g, H.s', H.hs', _⟩,\n dsimp [roof.comp₀],\n rw [assoc, H.fac, reassoc_of sq₁₃.fac],\n end,\n simp only [← h₁₂, ← h₂₃, ← h₃₄],\n rw [hom.comp_eq z₁₂ z₂₃ sq₁₃, hom.comp_eq z₂₃ z₃₄ sq₂₄,\n hom.comp_eq (z₁₂.comp₀ z₂₃ sq₁₃) z₃₄ sq, hom.comp_eq z₁₂ (z₂₃.comp₀ z₃₄ sq₂₄) sq'],\n congr' 1,\n dsimp [roof.comp₀],\n tidy,\n end, }\n\nvariable {W}\n\ndef roof.hom {X Y : localization W} (z : roof W X.obj Y.obj) : X ⟶ Y := quot.mk _ z\n\ndef map_roof {D : Type*} [category D] (F : C ⥤ D) (hF : W.is_inverted_by F)\n {X Y : C} (z : roof W X Y) : F.obj X ⟶ F.obj Y :=\nF.map z.f ≫ by { haveI := hF z.s z.hs, exact inv (F.map z.s), }\n\nnamespace localization\n\nlemma comp_eq {X₁ X₂ X₃ : localization W} (z₁₂ : roof W X₁.obj X₂.obj) (z₂₃ : roof W X₂.obj X₃.obj)\n (sq : to_sq z₁₂.s z₁₂.hs z₂₃.f) : z₁₂.hom ≫ z₂₃.hom = (roof.comp₀ z₁₂ z₂₃ sq).hom :=\nhom.comp_eq z₁₂ z₂₃ sq\n\nvariable (W)\n\ndef hom_obj {X Y : C} (f : X ⟶ Y) :\n (⟨X⟩ : localization W).obj ⟶ (⟨Y⟩ : localization W).obj := f\n\n@[simps]\ndef Q : C ⥤ localization W :=\n{ obj := λ X, ⟨X⟩,\n map := λ X Y f, (roof.of_hom W (hom_obj W f)).hom,\n map_comp' := λ X₁ X₂ X₃ f g, begin\n dsimp,\n rw localization.comp_eq (roof.of_hom W (hom_obj W f)) (roof.of_hom W (hom_obj W g))\n ⟨X₃, g, 𝟙 X₃, morphism_property.contains_identities.id W X₃, by tidy⟩,\n dsimp [roof.of_hom, roof.comp₀],\n congr' 1,\n tidy,\n end, }\n\nvariable {W}\n\n@[simps]\ndef roof.inv {X Y : C} (s : X ⟶ Y) (hs : W s) :\n roof W (⟨Y⟩ : localization W).obj (⟨X⟩ : localization W).obj := ⟨Y, 𝟙 Y, s, hs⟩\n\ndef inv_Q_map {X Y : C} (s : X ⟶ Y) (hs : W s) : (Q W).obj Y ⟶ (Q W).obj X :=\nroof.hom (roof.inv s hs)\n\nlemma comp_inv_Q_map {X Y : C} (s : X ⟶ Y) (hs : W s) :\n (Q W).map s ≫ inv_Q_map s hs = 𝟙 _ :=\nbegin\n dsimp only [Q, inv_Q_map],\n rw localization.comp_eq (roof.of_hom W (hom_obj W s)) (roof.inv s hs)\n ⟨Y, 𝟙 Y, 𝟙 Y, morphism_property.contains_identities.id W Y, rfl⟩,\n dsimp [roof.comp₀],\n exact quot.sound ⟨Y, 𝟙 Y, s, by tidy, by tidy, by tidy⟩,\nend\n\nlemma inv_Q_map_comp {X Y : C} (s : X ⟶ Y) (hs : W s) :\n inv_Q_map s hs ≫ (Q W).map s = 𝟙 _ :=\nbegin\n dsimp [Q, inv_Q_map],\n rw localization.comp_eq (roof.inv s hs) (roof.of_hom W (hom_obj W s))\n ⟨Y, 𝟙 Y, 𝟙 Y, morphism_property.contains_identities.id W Y, rfl⟩,\n dsimp [roof.comp₀],\n exact quot.sound ⟨Y, 𝟙 Y, 𝟙 Y, by tidy, by tidy,\n by { dsimp, simp only [comp_id], exact morphism_property.contains_identities.id W _, }⟩,\nend\n\nvariable (W)\n\nlemma Q_inverts_W : W.is_inverted_by (Q W) :=\nλ X Y s hs, ⟨⟨inv_Q_map s hs, comp_inv_Q_map s hs, inv_Q_map_comp s hs⟩⟩\n\nlemma inv_Q_map_eq {X Y : C} (s : X ⟶ Y) (hs : W s) :\n inv_Q_map s hs = (by { haveI := Q_inverts_W W s hs, exact inv ((Q W).map s), }) :=\nbegin\n haveI := Q_inverts_W W s hs,\n simp only [← cancel_mono ((Q W).map s), is_iso.inv_hom_id, inv_Q_map_comp],\nend\n\ninstance {X Y : C} (s : X ⟶ Y) (hs : W s) : is_iso (inv_Q_map s hs) :=\nby { rw inv_Q_map_eq, apply_instance, }\n\nvariables {W}\n\n@[simp]\nlemma id_eq (X : localization W) : 𝟙 X = quot.mk _ (roof.id W X.obj) := rfl\n\ninstance {X Y : C} (z : roof W X Y) : is_iso ((Q W).map z.s) :=\nQ_inverts_W W z.s z.hs\n\n\nlemma map_roof_eq {X Y : C} (z : roof W X Y) :\n map_roof (localization.Q W) (Q_inverts_W W) z = quot.mk _ z :=\nbegin\n dsimp only [map_roof],\n rw ← inv_Q_map_eq W z.s z.hs,\n dsimp only [Q, inv_Q_map],\n rw comp_eq (roof.of_hom W (hom_obj W z.f)) (roof.inv z.s z.hs)\n ⟨z.Z, 𝟙 _, 𝟙 _, morphism_property.contains_identities.id W _, rfl⟩,\n dsimp [roof.of_hom, roof.comp₀, hom_obj, roof.hom],\n simp only [comp_id],\n cases z,\n refl,\nend\n\nvariable (W)\nlemma hom_fac {X Y : C} (f : (Q W).obj X ⟶ (Q W).obj Y) :\n ∃ (z : roof W X Y), f = map_roof (Q W) (Q_inverts_W W) z :=\nbegin\n cases surjective_quot_mk _ f with z hz,\n subst hz,\n exact ⟨z, (map_roof_eq z).symm⟩,\nend\n\nvariable {W}\n\ndef lift {D : Type*} [category D] (F : C ⥤ D) (hF : W.is_inverted_by F) :\n localization W ⥤ D :=\n{ obj := λ X, F.obj X.obj,\n map := λ X Y, quot.lift (λ (f : roof W X.obj Y.obj),\n by { haveI := hF f.s f.hs, exact F.map f.f ≫ inv (F.map f.s)})\n (λ z z' (h : roof_rel z z'), begin\n dsimp,\n rcases h with ⟨Y, t₁, t₂, hst, hft, ht⟩,\n haveI := hF _ ht,\n rw [← cancel_mono (F.map (z.s ≫ t₁)), assoc, assoc],\n nth_rewrite 0 F.map_comp,\n rw [is_iso.inv_hom_id_assoc, hst, F.map_comp, is_iso.inv_hom_id_assoc,\n ← F.map_comp z'.f, ← hft, F.map_comp],\n end),\n map_comp' := λ X₁ X₂ X₃ f₁ f₂, begin\n dsimp,\n cases surjective_quot_mk _ f₁ with g₁ h₁,\n cases surjective_quot_mk _ f₂ with g₂ h₂,\n substs h₁ h₂,\n let sq := (left_calculus_of_fractions.ex g₁.s g₁.hs g₂.f).some,\n erw comp_eq g₁ g₂ sq,\n dsimp [roof.comp₀, roof.hom],\n simp only [functor.map_comp, assoc],\n haveI := hF g₁.s g₁.hs,\n haveI := hF g₂.s g₂.hs,\n haveI := hF sq.s' sq.hs',\n rw is_iso.inv_comp,\n congr' 1,\n simp only [← cancel_mono (F.map g₂.s), ← cancel_mono (F.map sq.s'), ← cancel_epi (F.map g₁.s),\n assoc, is_iso.inv_hom_id, comp_id, is_iso.hom_inv_id_assoc, ← F.map_comp, sq.fac],\n end, }\n\nlemma fac {D : Type*} [category D] (F : C ⥤ D) (hF : W.is_inverted_by F) :\n Q W ⋙ lift F hF = F :=\nfunctor.ext (λ X, rfl) (λ X Y f, begin\n dsimp [lift, roof.hom, hom_obj],\n simp only [functor.map_id, is_iso.inv_id, id_comp],\nend)\n\nlemma uniq {D : Type*} [category D] (F₁ F₂ : localization W ⥤ D) (h : Q W ⋙ F₁ = Q W ⋙ F₂) :\n F₁ = F₂ :=\nbegin\n have eq : ∀ (X : localization W), F₁.obj X = F₂.obj X,\n { intro X,\n cases X,\n apply functor.congr_obj h X, },\n apply functor.ext eq,\n intros X Y f,\n cases X,\n cases Y,\n rcases hom_fac W f with ⟨φ, hφ⟩,\n subst f,\n have eq₁ := functor.congr_map_conjugate h φ.f,\n have eq₂ := functor.congr_map_conjugate h φ.s,\n dsimp only [functor.comp_map] at eq₁ eq₂,\n dsimp only [map_roof],\n simpa only [functor.map_comp, functor.map_inv, eq₁, eq₂, assoc, is_iso.inv_comp,\n inv_eq_to_hom, eq_to_hom_trans_assoc, eq_to_hom_refl, id_comp],\nend\n\ndef universal_property (D : Type*) [category D] :\n localization.strict_universal_property_fixed_target (Q W) W D :=\n{ inverts := Q_inverts_W W,\n lift := lift,\n fac := fac,\n uniq := uniq, }\n\ninstance Q_is_localization : (Q W).is_localization W :=\nfunctor.is_localization.mk' (Q W) W (universal_property _) (universal_property _)\n\nend localization\n\nlemma map_roof_compatibility {D E : Type*} [category D] [category E]\n (L₁ : C ⥤ D) (hL₁ : W.is_inverted_by L₁) (L₂ : C ⥤ E) (hL₂ : W.is_inverted_by L₂)\n (M : D ⥤ E) (e : L₁ ⋙ M ≅ L₂) {X Y : C} (z : roof W X Y) :\n map_roof L₂ hL₂ z = e.inv.app X ≫ M.map (map_roof L₁ hL₁ z) ≫ e.hom.app Y :=\nbegin\n dsimp [map_roof],\n simp only [M.map_comp, assoc],\n erw ← e.inv.naturality_assoc,\n congr' 1,\n haveI := hL₂ z.s z.hs,\n simp only [← cancel_mono (L₂.map z.s), is_iso.inv_hom_id, functor.map_inv, assoc,\n ← cancel_epi (e.hom.app z.Z), comp_id, iso.hom_inv_id_app_assoc, is_iso.eq_inv_comp],\n apply e.hom.naturality,\nend\n\nlemma map_roof_compatibility_imp {D E : Type*} [category D] [category E]\n (L₁ : C ⥤ D) (hL₁ : W.is_inverted_by L₁) (L₂ : C ⥤ E) (hL₂ : W.is_inverted_by L₂)\n (M : D ⥤ E) (e : L₁ ⋙ M ≅ L₂) {X Y : C} (z z' : roof W X Y)\n (eq : map_roof L₁ hL₁ z = map_roof L₁ hL₁ z') :\n map_roof L₂ hL₂ z = map_roof L₂ hL₂ z' :=\nby simp only [map_roof_compatibility L₁ hL₁ L₂ hL₂ M e, eq]\n\nlemma L_map_fac {D : Type*} [category D] (L : C ⥤ D) (W : morphism_property C)\n [left_calculus_of_fractions W] [L.is_localization W] {X Y : C} (f : L.obj X ⟶ L.obj Y) :\n ∃ (z : roof W X Y), f = map_roof L (localization.inverts L W) z :=\nbegin\n let E := (localization.uniq_equivalence W (localization.Q W) L),\n let e : localization.Q W ⋙ E.functor ≅ L :=\n localization.comp_uniq_equivalence_functor_iso W (localization.Q W) L,\n let f' := e.hom.app X ≫ f ≫ e.inv.app Y,\n cases localization.hom_fac W (E.functor.preimage f') with z hz,\n change E.functor.preimage f' =\n map_roof (localization.Q W) (localization.inverts _ W) z at hz,\n replace hz := congr_arg E.functor.map hz,\n refine ⟨z, _⟩,\n simp only [map_roof_compatibility (localization.Q W) (localization.inverts _ W)\n L (localization.inverts _ W) E.functor e, ← hz, functor.image_preimage, assoc,\n iso.inv_hom_id_app, comp_id, iso.inv_hom_id_app_assoc],\nend\n\nlemma L_map_roof_eq_iff {D : Type*} [category D] (L : C ⥤ D) {W : morphism_property C}\n [left_calculus_of_fractions W] [L.is_localization W] {X Y : C} (z₁ z₂ : roof W X Y) :\n map_roof L (localization.inverts L W) z₁ =\n map_roof L (localization.inverts L W) z₂ ↔ roof_rel z₁ z₂ :=\nbegin\n have eq : map_roof L (localization.inverts _ W) z₁ =\n map_roof L (localization.inverts _ W) z₂ ↔\n map_roof (localization.Q W) (localization.inverts _ W) z₁ =\n map_roof (localization.Q W) (localization.inverts _ W) z₂,\n { split,\n all_goals { exact map_roof_compatibility_imp _ _ _ _ _\n (localization.comp_uniq_equivalence_functor_iso W _ _) _ _, }, },\n simp only [eq, localization.map_roof_eq],\n split,\n { rw quot.eq,\n clear eq,\n intro h,\n induction h with s₁ s₂ h s s₁ s₂ h' h s₁ s₂ s₃ h'₁ h'₂ h₁ h₂,\n exacts [h, roof_rel.refl _, h.symm, h₁.trans h₂], },\n { exact quot.sound, },\nend\n\nlemma L_map_eq_iff {D : Type*} [category D] (L : C ⥤ D) (W : morphism_property C)\n [left_calculus_of_fractions W] [L.is_localization W] {X Y : C} (f₁ f₂ : X ⟶ Y) :\n L.map f₁ = L.map f₂ ↔ ∃ (Z : C) (s : Y ⟶ Z) (hs : W s), f₁ ≫ s = f₂ ≫ s :=\nbegin\n split,\n { intro h,\n rcases (L_map_roof_eq_iff L\n (roof.mk Y f₁ (𝟙 Y) (morphism_property.contains_identities.id W Y))\n (roof.mk Y f₂ (𝟙 Y) (morphism_property.contains_identities.id W Y))).mp\n (by { dsimp [map_roof], rw h, }) with ⟨Z, t₁, t₂, hst, hft, ht⟩,\n dsimp at t₁ t₂ ht hst hft,\n simp only [id_comp] at ht hst,\n refine ⟨Z, t₁, ht, by rw [hft, hst]⟩, },\n { rintro ⟨Z, s, hs, eq⟩,\n haveI := localization.inverts L W s hs,\n simp only [← cancel_mono (L.map s), ← L.map_comp, eq], },\nend\n\nsection\n\nvariables {D : Type*} [category D] (L : C ⥤ D) (W' : morphism_property C)\n [left_calculus_of_fractions W'] [L.is_localization W']\nomit W\ninclude L W'\n\nlemma exists_lift_arrow (f : arrow D) :\n ∃ (g : arrow C), nonempty (f ≅ L.map_arrow.obj g) :=\nbegin\n haveI : ess_surj L := localization.ess_surj L W',\n let e₁ := L.obj_obj_preimage_iso _,\n let e₂ := L.obj_obj_preimage_iso _,\n let f' := e₁.hom ≫ f.hom ≫ e₂.inv,\n rcases L_map_fac L W' f' with ⟨z, hz⟩,\n refine ⟨arrow.mk z.f, nonempty.intro _⟩,\n haveI := localization.inverts L W' z.s z.hs,\n refine arrow.iso_mk e₁.symm (e₂.symm ≪≫ as_iso (L.map z.s)) _,\n dsimp [map_roof] at hz ⊢,\n simp only [← cancel_mono (inv (L.map z.s)), assoc, ← hz, is_iso.hom_inv_id, comp_id,\n ← cancel_epi e₁.hom, e₁.hom_inv_id_assoc],\nend\n\ndef lift_map₁ {X Y : D} (f : X ⟶ Y) : C := (exists_lift_arrow L W' (arrow.mk f)).some.left\ndef lift_map₂ {X Y : D} (f : X ⟶ Y) : C := (exists_lift_arrow L W' (arrow.mk f)).some.right\ndef lift_map {X Y : D} (f : X ⟶ Y) : lift_map₁ L W' f ⟶ lift_map₂ L W' f :=\n(exists_lift_arrow L W' (arrow.mk f)).some.hom\ndef map_lift_map_iso {X Y : D} (f : X ⟶ Y) :\n arrow.mk f ≅ arrow.mk (L.map (lift_map L W' f)) :=\n(exists_lift_arrow L W' (arrow.mk f)).some_spec.some\ndef lift_map_iso₁ {X Y : D} (f : X ⟶ Y) : X ≅ L.obj (lift_map₁ L W' f) :=\narrow.left_func.map_iso (map_lift_map_iso L W' f)\ndef lift_map_iso₂ {X Y : D} (f : X ⟶ Y) : Y ≅ L.obj (lift_map₂ L W' f) :=\narrow.right_func.map_iso (map_lift_map_iso L W' f)\n\nlemma lift_map_fac {X Y : D} (f : X ⟶ Y) : f ≫ (lift_map_iso₂ L W' f).hom =\n (lift_map_iso₁ L W' f).hom ≫ L.map (lift_map L W' f) :=\n(map_lift_map_iso L W' f).hom.w.symm\n\nend\n\nend left_calculus_of_fractions\n\nvariable {W}\n\nstructure right_calculus_of_fractions.to_sq {X Y Y' : C} (s : Y' ⟶ Y) (hs : W s) (f : X ⟶ Y) :=\n(obj : C)\n(g : obj ⟶ Y')\n(s' : obj ⟶ X)\n(hs' : W s')\n(fac : s' ≫ f = g ≫ s)\n\nvariable (W)\n\nclass right_calculus_of_fractions : Prop :=\n(id : W.contains_identities)\n(comp : W.stable_under_composition)\n(ex : ∀ ⦃X Y Y' : C⦄ (s : Y' ⟶ Y) (hs : W s) (u : X ⟶ Y),\n nonempty (right_calculus_of_fractions.to_sq s hs u))\n(ext : ∀ ⦃X Y Y' : C⦄ (f₁ f₂ : X ⟶ Y) (s : Y ⟶ Y') (hs : W s) (eq : f₁ ≫ s = f₂ ≫ s),\n ∃ (X' : C) (t : X' ⟶ X) (ht : W t), t ≫ f₁ = t ≫ f₂)\n\ninstance right_calculus_of_fractions.contains_identities\n [h : right_calculus_of_fractions W] : W.contains_identities := h.id\n\nvariable {W}\n\ndef left_calculus_of_fractions.op\n (h : left_calculus_of_fractions W) : right_calculus_of_fractions W.op :=\n{ id := h.id.op,\n comp := h.comp.op,\n ex := λ X Y Y' s hs u, begin\n let sq := (h.ex s.unop hs u.unop).some,\n exact nonempty.intro ⟨opposite.op sq.obj, sq.g.op, sq.s'.op, sq.hs',\n quiver.hom.unop_inj sq.fac⟩,\n end,\n ext := λ X Y Y' f₁ f₂ s hs eq, begin\n rcases h.ext f₁.unop f₂.unop s.unop hs (by simp only [← unop_comp, eq])\n with ⟨X', t, ht, fac⟩,\n exact ⟨opposite.op X', t.op, ht, quiver.hom.unop_inj fac⟩,\n end, }\n\ndef left_calculus_of_fractions.unop {W : morphism_property Cᵒᵖ}\n (h : left_calculus_of_fractions W) :\n right_calculus_of_fractions W.unop :=\n{ id := h.id.unop,\n comp := h.comp.unop,\n ex := λ X Y Y' s hs u, begin\n let sq := (h.ex s.op hs u.op).some,\n exact nonempty.intro ⟨opposite.unop sq.obj, sq.g.unop, sq.s'.unop, sq.hs',\n quiver.hom.op_inj sq.fac⟩,\n end,\n ext := λ X Y Y' f₁ f₂ s hs eq, begin\n rcases h.ext f₁.op f₂.op s.op hs (by simp only [← op_comp, eq])\n with ⟨X', t, ht, fac⟩,\n exact ⟨opposite.unop X', t.unop, ht, quiver.hom.op_inj fac⟩,\n end, }\n\ndef right_calculus_of_fractions.op\n (h : right_calculus_of_fractions W) : left_calculus_of_fractions W.op :=\n{ id := h.id.op,\n comp := h.comp.op,\n ex := λ X' X Y s hs u, begin\n let sq := (h.ex s.unop hs u.unop).some,\n exact nonempty.intro ⟨opposite.op sq.obj, sq.g.op, sq.s'.op, sq.hs',\n quiver.hom.unop_inj sq.fac⟩,\n end,\n ext := λ X' X Y f₁ f₂ s hs eq, begin\n have pif := h.ext f₁.unop f₂.unop s.unop hs (by simp only [← unop_comp, eq]),\n rcases h.ext f₁.unop f₂.unop s.unop hs (by simp only [← unop_comp, eq])\n with ⟨Y', t, ht, fac⟩,\n exact ⟨opposite.op Y', t.op, ht, quiver.hom.unop_inj fac⟩,\n end, }\n\ndef right_calculus_of_fractions.unop {W : morphism_property Cᵒᵖ}\n (h : right_calculus_of_fractions W) :\n left_calculus_of_fractions W.unop :=\n{ id := h.id.unop,\n comp := h.comp.unop,\n ex := λ X' X Y s hs u, begin\n let sq := (h.ex s.op hs u.op).some,\n exact nonempty.intro ⟨opposite.unop sq.obj, sq.g.unop, sq.s'.unop, sq.hs',\n quiver.hom.op_inj sq.fac⟩,\n end,\n ext := λ X' X Y f₁ f₂ s hs eq, begin\n have pif := h.ext f₁.op f₂.op s.op hs (by simp only [← op_comp, eq]),\n rcases h.ext f₁.op f₂.op s.op hs (by simp only [← op_comp, eq])\n with ⟨Y', t, ht, fac⟩,\n exact ⟨opposite.unop Y', t.unop, ht, quiver.hom.op_inj fac⟩,\n end, }\n\ninstance [h : right_calculus_of_fractions W] :\n left_calculus_of_fractions W.op := right_calculus_of_fractions.op h\n\ninstance [h : left_calculus_of_fractions W] :\n right_calculus_of_fractions W.op := left_calculus_of_fractions.op h\n\nnamespace right_calculus_of_fractions\n\nvariables (W)\n\nstructure roof (X Y : C) :=\n(Z : C) (s : Z ⟶ X) (f : Z ⟶ Y) (hs : W s)\n\nvariable {W}\n\ndef roof.op {X Y : C} (z : roof W X Y) :\n left_calculus_of_fractions.roof W.op (opposite.op Y) (opposite.op X) :=\n⟨opposite.op z.Z, z.f.op, z.s.op, z.hs⟩\n\ndef roof_rel ⦃X Y : C⦄ (z₁ z₂ : roof W X Y) : Prop :=\n∃ (Z₃ : C) (t₁ : Z₃ ⟶ z₁.Z) (t₂ : Z₃ ⟶ z₂.Z) (hts : t₁ ≫ z₁.s = t₂ ≫ z₂.s)\n (htf : t₁ ≫ z₁.f = t₂ ≫ z₂.f), W (t₁ ≫ z₁.s)\n\nlemma roof_rel.iff_op {X Y : C} (z₁ z₂ : roof W X Y) :\n roof_rel z₁ z₂ ↔ left_calculus_of_fractions.roof_rel z₁.op z₂.op :=\nbegin\n split,\n { intro h,\n rcases h with ⟨Z₃, t₁, t₂, hts, htf, ht⟩,\n exact ⟨opposite.op Z₃, t₁.op, t₂.op, quiver.hom.unop_inj hts, quiver.hom.unop_inj htf, ht⟩, },\n { intro h,\n rcases h with ⟨Z₃, t₁, t₂, hst, hft, ht⟩,\n refine ⟨opposite.unop Z₃, t₁.unop, t₂.unop, quiver.hom.op_inj hst, quiver.hom.op_inj hft, ht⟩, },\nend\n\nvariables (W) [right_calculus_of_fractions W]\n\n@[simps]\ndef roof.of_hom {X Y : C} (f : X ⟶ Y) : roof W X Y :=\n⟨X, 𝟙 X, f, morphism_property.contains_identities.id W X⟩\n\n@[simps]\ndef roof.id (X : C) := roof.of_hom W (𝟙 X)\n\nnamespace roof_rel\n\nvariables {W}\n\nlemma refl {X Y : C} (z : roof W X Y) : roof_rel z z :=\nby { rw roof_rel.iff_op, apply left_calculus_of_fractions.roof_rel.refl, }\n\nlemma symm {X Y : C} {z₁ z₂ : roof W X Y} (h : roof_rel z₁ z₂) : roof_rel z₂ z₁ :=\nby { rw roof_rel.iff_op at h ⊢, exact h.symm, }\n\nlemma trans {X Y : C} {z₁ z₂ z₃ : roof W X Y} (h₁₂ : roof_rel z₁ z₂)\n (h₂₃ : roof_rel z₂ z₃) : roof_rel z₁ z₃ :=\nby { rw roof_rel.iff_op at h₁₂ h₂₃ ⊢, exact h₁₂.trans h₂₃, }\n\nend roof_rel\n\ninstance is_equiv_roof_rel (X Y : C) :\n is_equiv (roof W X Y) (λ z₁ z₂, roof_rel z₁ z₂) :=\n{ refl := roof_rel.refl,\n symm := λ z₁ z₂, roof_rel.symm,\n trans := λ z₁ z₂ z₃, roof_rel.trans, }\n\nend right_calculus_of_fractions\n\nnamespace left_calculus_of_fractions\n\nvariables {W} [morphism_property.contains_identities W] [right_calculus_of_fractions W]\n\ndef roof.unop {X Y : C} (z : roof W.op (opposite.op X) (opposite.op Y)) :\n right_calculus_of_fractions.roof W Y X :=\n⟨opposite.unop z.Z, z.s.unop, z.f.unop, z.hs⟩\n\nend left_calculus_of_fractions\n\nnamespace right_calculus_of_fractions\n\nvariables {W} [morphism_property.contains_identities W] [right_calculus_of_fractions W]\n\ndef map_roof {D : Type*} [category D] (F : C ⥤ D) (hF : W.is_inverted_by F)\n {X Y : C} (z : roof W X Y) : F.obj X ⟶ F.obj Y :=\nby { haveI := hF z.s z.hs, exact inv (F.map z.s), } ≫ F.map z.f\n\nlemma map_roof_eq_unop_map_roof_op {D : Type*} [category D] (F : C ⥤ D)\n (hF : W.is_inverted_by F) {X Y : C} (z : roof W X Y) :\n map_roof F hF z = (left_calculus_of_fractions.map_roof F.op hF.op z.op).unop :=\nbegin\n dsimp [left_calculus_of_fractions.map_roof, map_roof, roof.op],\n simp only [quiver.hom.unop_op, unop_inv],\nend\n\nlemma L_map_fac {D : Type*} [category D] (L : C ⥤ D) (W : morphism_property C)\n [right_calculus_of_fractions W]\n [L.is_localization W] {X Y : C} (f : L.obj X ⟶ L.obj Y) :\n ∃ (z : roof W X Y), f = map_roof L (localization.inverts L W) z :=\nbegin\n let f' : L.op.obj (opposite.op Y) ⟶ L.op.obj (opposite.op X) := f.op,\n rcases left_calculus_of_fractions.L_map_fac L.op W.op f' with ⟨z, hz⟩,\n refine ⟨z.unop, _⟩,\n change f'.unop = _,\n simpa only [hz, map_roof_eq_unop_map_roof_op],\nend\n\nlemma L_map_roof_eq_iff {D : Type*} [category D] (L : C ⥤ D) {W : morphism_property C}\n [right_calculus_of_fractions W] [L.is_localization W]\n {X Y : C} (z₁ z₂ : roof W X Y) :\n map_roof L (localization.inverts L W) z₁ =\n map_roof L (localization.inverts L W) z₂ ↔ roof_rel z₁ z₂ :=\nbegin\n simp only [roof_rel.iff_op, ← left_calculus_of_fractions.L_map_roof_eq_iff L.op z₁.op,\n map_roof_eq_unop_map_roof_op],\n exact ⟨λ h, quiver.hom.unop_inj h, λ h, quiver.hom.op_inj h⟩,\nend\n\nlemma L_map_eq_iff {D : Type*} [category D] (L : C ⥤ D) (W : morphism_property C)\n [right_calculus_of_fractions W] [L.is_localization W] {Y Z : C} (f₁ f₂ : Y ⟶ Z) :\n L.map f₁ = L.map f₂ ↔ ∃ (X : C) (s : X ⟶ Y) (hs : W s), s ≫ f₁ = s ≫ f₂ :=\nbegin\n split,\n { intro h,\n rcases (L_map_roof_eq_iff L\n (roof.mk Y (𝟙 Y) f₁ (morphism_property.contains_identities.id W Y))\n (roof.mk Y (𝟙 Y) f₂ (morphism_property.contains_identities.id W Y))).mp\n (by { dsimp [map_roof], rw h, }) with ⟨Z, t₁, t₂, hts, htf, ht⟩,\n dsimp at t₁ t₂ ht hts htf,\n simp only [comp_id] at ht hts,\n exact ⟨Z, t₁, ht, by rw [htf, hts]⟩, },\n { rintro ⟨Z, s, hs, eq⟩,\n haveI := localization.inverts L W s hs,\n simp only [← cancel_epi (L.map s), ← L.map_comp, eq], },\nend\n\nend right_calculus_of_fractions\n\nvariable (W)\n\nclass morphism_property.is_saturated : Prop :=\n(condition' : ∀ ⦃X Y Z T : C⦄ (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ T) (hfg : W (f ≫ g))\n (hgh : W (g ≫ h)), W g)\n\nlemma morphism_property.is_saturated.condition [W.is_saturated] {X Y Z T : C}\n (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ T) (hfg : W (f ≫ g))\n (hgh : W (g ≫ h)) : W g :=\nmorphism_property.is_saturated.condition' f g h hfg hgh\n\nnamespace localization\n\nlemma is_iso_map_iff_of_calculus_of_fractions {D : Type*} [category D] (L : C ⥤ D)\n (W : morphism_property C) [L.is_localization W] [W.is_saturated]\n [left_calculus_of_fractions W] [right_calculus_of_fractions W] {X Y : C} (f : X ⟶ Y) :\n is_iso (L.map f) ↔ W f :=\nbegin\n refine ⟨_ ,λ hf, localization.inverts L W f hf⟩,\n introI,\n rcases left_calculus_of_fractions.L_map_fac L W (inv (L.map f)) with ⟨z₁, h₁⟩,\n rcases right_calculus_of_fractions.L_map_fac L W (inv (L.map f)) with ⟨z₂, h₂⟩,\n dsimp [left_calculus_of_fractions.map_roof] at h₁,\n dsimp [right_calculus_of_fractions.map_roof] at h₂,\n rcases (left_calculus_of_fractions.L_map_roof_eq_iff L\n (left_calculus_of_fractions.roof.mk _ (f ≫ z₁.f) z₁.s z₁.hs)\n (left_calculus_of_fractions.roof.id W X)).mp begin\n dsimp [left_calculus_of_fractions.map_roof],\n simp only [L.map_comp, assoc, ← h₁, is_iso.hom_inv_id],\n end with ⟨Z, t₁, t₁', hst, hft, H₁⟩,\n rcases (right_calculus_of_fractions.L_map_roof_eq_iff L\n (right_calculus_of_fractions.roof.mk _ z₂.s (z₂.f ≫ f) z₂.hs)\n (right_calculus_of_fractions.roof.id W Y)).mp begin\n dsimp [right_calculus_of_fractions.map_roof],\n simp only [L.map_comp, assoc, ← reassoc_of h₂, is_iso.inv_hom_id],\n end with ⟨Z', t₂, t₂', hts, htf, H₂⟩,\n dsimp at t₁ t₁' hst hft H₁ t₂ t₂' hts htf H₂,\n simp only [assoc, id_comp, comp_id] at hst hft hts htf,\n rw ← hft at hst,\n rw ← htf at hts,\n exact morphism_property.is_saturated.condition W (t₂ ≫ z₂.f)\n f (z₁.f ≫ t₁) (by simpa only [assoc, ← hts] using H₂)\n (by simpa only [← hst] using H₁),\nend\n\nend localization\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/localization/calculus_of_fractions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5660185498374789, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.24999511416865197}} {"text": "/-\nimport condensed.adjunctions\nimport category_theory.adjunction.evaluation\n\nopen category_theory\nopen category_theory.grothendieck_topology\nopen opposite\n\nuniverse u\n\nsection for_mathlib\n\nlemma AddCommGroup.mono_iff_injective {X Y : AddCommGroup} (f : X ⟶ Y) :\n mono f ↔ function.injective f := sorry\n\ninstance {α : Type u} : limits.has_coproducts_of_shape α Ab.{u+1} := sorry\n\nvariables {C : Type (u+1)} [category.{u} C] (J : grothendieck_topology C)\n (F : Cᵒᵖ ⥤ Ab.{u+1}) (G : Sheaf J Ab.{u+1}) (η : F ⟶ G.val)\n\n-- TODO: This theorem may need additional assumptions on `J`.\ntheorem sheafify_lift_mono_iff :\n mono (sheafify_lift J η G.cond) ↔\n ∀ (B : C) (t : F.obj (op B)), η.app (op B) t = 0 →\n (∃ W : (J.cover B), ∀ f : W.arrow, F.map f.f.op t = 0) :=\nbegin\n rw nat_trans.mono_iff_app_mono,\n split,\n { intros h B t ht,\n replace h : ∀ B : C, ((J.sheafify_lift η G.cond).app (op B)).ker = ⊥, sorry,\n specialize h B,\n let t' := (J.to_sheafify F).app (op B) t,\n have : t' ∈ add_monoid_hom.ker ((J.sheafify_lift η _).app (op B)), sorry,\n rw h at this, simp only [add_subgroup.mem_bot] at this,\n sorry },\n { intros h B, tactic.op_induction',\n -- Is this missing?\n suffices : function.injective ((J.sheafify_lift η G.cond).app (op B)), sorry,\n rw add_monoid_hom.injective_iff, intros t ht,\n specialize h B, sorry },\nend\n\nend for_mathlib\n\nvariables (F : Profinite.{u}ᵒᵖ ⥤ Ab.{u+1}) (G : Condensed.{u} Ab.{u+1})\nvariables (η : F ⟶ G.val)\n\ntheorem Condensed_Ab_sheafify_lift_mono_iff :\n mono (sheafify_lift _ η G.cond) ↔\n ∀ (B : Profinite.{u}) (t : F.obj (op B)), η.app (op B) t = 0 →\n (∃ (α : Type u) [fintype α] (X : α → Profinite.{u}) (π : Π a : α, X a ⟶ B)\n (surj : ∀ b : B, ∃ (a : α) (x : X a), π a x = b),\n ∀ a : α, F.map (π a).op t = 0) :=\nbegin\n rw sheafify_lift_mono_iff proetale_topology.{u},\n split,\n { intros h B t ht,\n specialize h B t ht,\n obtain ⟨W,hw⟩ := h,\n rcases W with ⟨W,hW⟩,\n have HW : W ∈ proetale_topology B := hW,\n rcases hW with ⟨W, ⟨α, hα, X, π, surj, rfl⟩, h⟩,\n use [α, hα, X, π, surj], intros a,\n let W' : proetale_topology.cover B := ⟨W,HW⟩,\n let ff : W'.arrow := _,\n swap, { constructor, apply h, use a },\n specialize hw ff, exact hw },\n { rintros h B t ht, specialize h B t ht,\n obtain ⟨α, hα, X, π, surj, hh⟩ := h,\n refine ⟨⟨sieve.generate (presieve.of_arrows X π),_⟩,_⟩,\n constructor, use [α, hα, X, π, surj], exact sieve.le_generate (presieve.of_arrows X π),\n rintros ⟨X,f,⟨W,e1,e2,hhh,rfl⟩⟩,\n dsimp, simp only [F.map_comp, comp_apply],\n obtain ⟨a⟩ := hhh, rw hh,\n rw add_monoid_hom.map_zero }\nend\n-/\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/backup/sheafification_mono.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.7025300573952052, "lm_q2_score": 0.35577489351363034, "lm_q1q2_score": 0.24994255635990376}} {"text": "import data.matrix.notation\nimport o_minimal.sheaf.yoneda\n\nnamespace o_minimal\n\nuniverse u\n\nvariables {R : Type*} (S : struc R)\n\nstructure map_to (X : Type*) [has_coordinates R X] [definable_rep S X] :=\n(obj : Type*)\n[has_coordinates : has_coordinates R obj]\n[definable_rep : definable_rep S obj]\n(to_fun : obj → X)\n(is_definable : definable S to_fun)\n\nattribute [instance] map_to.has_coordinates map_to.definable_rep\n\n/-- General (finite) cover of a representable by representables. -/\nstructure cover (X : Type*) [has_coordinates R X] [definable_rep S X] :=\n(n : ℕ)\n(map : fin n → map_to S X)\n(jointly_surjective : ∀ x, ∃ i l, (map i).to_fun l = x)\n\nvariables {S}\n\n-- TODO: Can we avoid the messy pullback construction in `o_minimal.Def` using these?\n\nnoncomputable def Def.cover_of_general {K : Def S} (𝓛 : cover S K) : K.cover :=\n{ n := 𝓛.n,\n obj := λ i, as_Def S (𝓛.map i).obj,\n map := λ i,\n ⟨(𝓛.map i).to_fun ∘ (equiv_Def S (𝓛.map i).obj).symm,\n (definable_iff_def_fun.mp (𝓛.map i).is_definable).comp def_fun_equiv_Def_symm⟩,\n jointly_surjective := λ k,\n let ⟨i, l, h⟩ := 𝓛.jointly_surjective k in\n ⟨i, (equiv_Def S (𝓛.map i).obj) l, show (𝓛.map i).to_fun _ = k, by simp [h]⟩ }\n\ndef cover.pullback {X' X : Type*} [has_coordinates R X'] [definable_rep S X']\n [has_coordinates R X] [definable_rep S X] (𝓛 : cover S X) (f : X' → X) (df : definable S f) :\n cover S X' :=\n{ n := 𝓛.n,\n map := λ i,\n { obj := {p : X' × (𝓛.map i).obj | f p.1 = (𝓛.map i).to_fun p.2},\n definable_rep := subtype.definable_rep $ definable_iff_def_set.mpr $ def_set_eq\n ((definable_iff_def_fun.mp df).comp def_fun.fst)\n ((definable_iff_def_fun.mp (𝓛.map i).is_definable).comp def_fun.snd),\n to_fun := prod.fst ∘ subtype.val,\n is_definable := definable.fst.comp definable.subtype.val },\n jointly_surjective := λ x',\n let ⟨i, l, h⟩ := 𝓛.jointly_surjective (f x') in\n ⟨i, ⟨⟨x', l⟩, h.symm⟩, rfl⟩ }\n\ndef cover_of_Def {K : Def S} (𝓛 : K.cover) : cover S K :=\n{ n := 𝓛.n,\n map := λ i,\n { obj := 𝓛.obj i,\n to_fun := 𝓛.map i,\n is_definable := definable_iff_def_fun.mpr (𝓛.map i).is_definable },\n jointly_surjective := 𝓛.jointly_surjective }\n\nvariables {X : Type*} [has_coordinates R X] [definable_rep S X]\nvariables {Y : Type*} [definable_sheaf S Y]\n\nlemma definable_cover_of_Def {K : Def S} (f : K → Y) (𝓛 : cover S K)\n (h : ∀ i, definable S (f ∘ (𝓛.map i).to_fun)) : definable S f :=\nbegin\n rw definable_yoneda,\n let 𝓛' := Def.cover_of_general 𝓛,\n apply definable_sheaf.definable_cover _ 𝓛',\n intro i,\n rw ←definable_yoneda,\n refine (h i).comp _,\n rw definable_iff_def_fun,\n apply def_fun_equiv_Def_symm\nend\n\nlemma definable_cover (f : X → Y) (𝓛 : cover S X)\n (h : ∀ i, definable S (f ∘ (𝓛.map i).to_fun)) : definable S f :=\nbegin\n rw definable_fun,\n intros K φ hφ,\n let 𝓛' := 𝓛.pullback φ (definable_yoneda.mpr hφ),\n rw ←definable_yoneda at ⊢ hφ,\n apply definable_cover_of_Def _ 𝓛',\n intro i,\n change definable S (f ∘ (φ ∘ (𝓛'.map i).to_fun)),\n let ψ : (𝓛'.map i).obj → (𝓛.map i).obj := λ z, z.val.snd,\n have dψ : definable S ψ := definable.snd.comp definable.subtype.val,\n have : φ ∘ (𝓛'.map i).to_fun = (𝓛.map i).to_fun ∘ ψ,\n { ext x,\n exact x.property },\n rw this,\n refine (h i).comp dψ\nend\n\n-- Building covers.\n\ndef sep_cover (s : set X) (ds : definable S s) : cover S X :=\n{ n := 2,\n map :=\n ![{ obj := s,\n definable_rep := subtype.definable_rep ds,\n to_fun := subtype.val,\n is_definable := begin\n -- TODO: lemma\n rw definable_iff_def_fun,\n exact @def_fun_subtype_val R S X _ _ s (definable_iff_def_set.mp ds)\n end },\n { obj := ↥(sᶜ),\n definable_rep := subtype.definable_rep (definable.app definable.compl ds),\n to_fun := subtype.val,\n is_definable := begin\n -- TODO: lemma\n rw definable_iff_def_fun,\n exact @def_fun_subtype_val R S X _ _ _ (def_set.compl $ definable_iff_def_set.mp ds)\n end } ],\n jointly_surjective := begin\n intro x,\n by_cases hx : x ∈ s,\n { refine ⟨0, by exact ⟨x, hx⟩, by exact rfl⟩ },\n { refine ⟨1, by exact ⟨x, hx⟩, by exact rfl⟩ }\n end }\n\n-- TODO: is this true for any sheaf X?\nlemma definable_if (f : X → Y) (s : set X) (ds : definable S s)\n (hpos : definable S (f ∘ (subtype.val : s → X)))\n (hneg : definable S (f ∘ (subtype.val : sᶜ → X))) :\n definable S f :=\nbegin\n apply definable_cover f (sep_cover s ds),\n intro i,\n fin_cases i,\n { exact hpos },\n { exact hneg }\nend\n\nend o_minimal\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/src/o_minimal/sheaf/covers.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.24956931203338628}} {"text": "-- Copyright (c) Microsoft Corporation. All rights reserved.\n-- Licensed under the MIT license.\n\nimport ..smtexpr\nimport ..bitvector\nimport ..irsem\nimport .spec\nimport .lemmas\nimport .irstate\nimport smt2.syntax\nimport system.io\nimport init.meta.tactic\nimport init.meta.interactive\n\nnamespace spec\n\nopen irsem\n\ndef env.added2 (η:freevar.env) (n1 n2:string) (η':freevar.env):=\n (∀ n, n ∉ η → n ≠ n1 ∧ n ≠ n2 → n ∉ η') ∧\n (∀ n, n ∈ η ∨ n = n1 ∨ n = n2 → n ∈ η')\n\ndef env.has_only (η:freevar.env) (names:list string) :=\n ∀ name, name ∈ names ↔ name ∈ η\n\nuniverses u v\n@[reducible]\ndef apply {α:Type u} (f:α → α) : option α → option α\n| (some x) := some (f x)\n| none := none\n\nlemma apply_none: ∀ {α:Type u} (f:α → α) o,\n apply f o = none ↔ o = none\n:= begin\n intros,\n split,\n { intros H, cases o, refl, unfold apply at H, cases H },\n { intros H, rw H }\nend\n\nlemma apply_some: ∀ {α:Type u} {f:α → α} {o} {v}\n (H:apply f o = some v), ∃ v', o = some v'\n:= begin\n intros,\n cases o with v0,\n { unfold apply at H, cases H },\n { unfold apply at H, apply exists.intro v0, refl }\nend\n\nnotation η `⟦` s `⟧'` := apply (freevar.env.replace η) s\nnotation η `⟦` s `⟧'` := apply (freevar.env.replace_valty η) s\nnotation η `⟦` s `⟧'` := apply (freevar.env.replace_sbv η) s\nnotation η `⟦` s `⟧'` := apply (freevar.env.replace_sb η) s\n\n\n-- Induction principles for sbool & sbitvec which are mutually defined\nsection\n@[reducible]\nparameters (P:sbool → Prop) (P':Π {sz:size}, sbitvec sz → Prop)\n (Hbtt: P sbool.tt) (Hbff: P sbool.ff) (Hbvar: ∀ s, P (sbool.var s))\n (Hband: ∀ b1 b2, P b1 → P b2 → P (sbool.and b1 b2))\n (Hbor: ∀ b1 b2, P b1 → P b2 → P (sbool.or b1 b2))\n (Hbxor: ∀ b1 b2, P b1 → P b2 → P (sbool.xor b1 b2))\n (Hbeqb: ∀ b1 b2, P b1 → P b2 → P (sbool.eqb b1 b2))\n (Hbneb: ∀ b1 b2, P b1 → P b2 → P (sbool.neb b1 b2))\n (Hbite: ∀ b1 b2 b3, P b1 → P b2 → P b3 → P (sbool.ite b1 b2 b3))\n (Hbnot: ∀ b, P b → P (sbool.not b))\n (Hbeqbv: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P (sbool.eqbv v1 v2))\n (Hbnebv: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P (sbool.nebv v1 v2))\n (Hbsle: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P (sbool.sle v1 v2))\n (Hbslt: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P (sbool.slt v1 v2))\n (Hbule: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P (sbool.ule v1 v2))\n (Hbult: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P (sbool.ult v1 v2))\n (Hvconst: ∀ sz n, P' (sbitvec.const sz n))\n (Hvvar: ∀ sz n, P' (sbitvec.var sz n))\n (Hvadd: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.add v1 v2))\n (Hvsub: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.sub v1 v2))\n (Hvmul: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.mul v1 v2))\n (Hvudiv: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.udiv v1 v2))\n (Hvurem: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.urem v1 v2))\n (Hvsdiv: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.sdiv v1 v2))\n (Hvsrem: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.srem v1 v2))\n (Hvand: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.and v1 v2))\n (Hvor: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.or v1 v2))\n (Hvxor: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.xor v1 v2))\n (Hvshl: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.shl v1 v2))\n (Hvlshr: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.lshr v1 v2))\n (Hvashr: ∀ {sz} (v1 v2:sbitvec sz), P' v1 → P' v2 → P' (sbitvec.ashr v1 v2))\n (Hvzext: ∀ {sz} (v:sbitvec sz) sz', P' v → P' (sbitvec.zext sz' v))\n (Hvsext:∀ {sz} (v:sbitvec sz) sz', P' v → P' (sbitvec.sext sz' v))\n (Hvtrunc: ∀ {sz} (v:sbitvec sz) sz', P' v → P' (sbitvec.trunc sz' v))\n (Hvextract: ∀ {sz sz':size} (v:sbitvec sz) highbit lowbit\n (H:sz'.val = highbit - lowbit + 1),\n P' v → P' (sbitvec.extract highbit lowbit H v))\n (Hvite: ∀ {sz} (b:sbool) (v1 v2:sbitvec sz), P b → P' v1 → P' v2 →\n P' (sbitvec.ite b v1 v2))\n\n@[reducible]\nmutual def sbool.induction, sbitvec.induction\nwith sbool.induction : ∀ b, P b\n| sbool.tt := Hbtt\n| sbool.ff := Hbff\n| (sbool.var b) := Hbvar b\n| (sbool.and b1 b2) := Hband b1 b2 (sbool.induction b1) (sbool.induction b2)\n| (sbool.or b1 b2) := Hbor b1 b2 (sbool.induction b1) (sbool.induction b2)\n| (sbool.xor b1 b2) := Hbxor b1 b2 (sbool.induction b1) (sbool.induction b2)\n| (sbool.eqb b1 b2) := Hbeqb b1 b2 (sbool.induction b1) (sbool.induction b2)\n| (sbool.neb b1 b2) := Hbneb b1 b2 (sbool.induction b1) (sbool.induction b2)\n| (sbool.ite b1 b2 b3) := Hbite b1 b2 b3 (sbool.induction b1) (sbool.induction b2) (sbool.induction b3)\n| (sbool.not b) := Hbnot b (sbool.induction b)\n| (@sbool.eqbv sz v1 v2) :=\n have 0 < sbitvec.sizeof sz v1, by apply sbitvec.decr_sbitvec,\n have 0 < sbitvec.sizeof sz v2, by apply sbitvec.decr_sbitvec,\n Hbeqbv v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| (@sbool.nebv sz v1 v2) :=\n have 0 < sbitvec.sizeof sz v1, by apply sbitvec.decr_sbitvec,\n have 0 < sbitvec.sizeof sz v2, by apply sbitvec.decr_sbitvec,\n Hbnebv v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| (@sbool.sle sz v1 v2) := \n have 0 < sbitvec.sizeof sz v1, by apply sbitvec.decr_sbitvec,\n have 0 < sbitvec.sizeof sz v2, by apply sbitvec.decr_sbitvec,\n Hbsle v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| (@sbool.slt sz v1 v2) := \n have 0 < sbitvec.sizeof sz v1, by apply sbitvec.decr_sbitvec,\n have 0 < sbitvec.sizeof sz v2, by apply sbitvec.decr_sbitvec,\n Hbslt v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| (@sbool.ule sz v1 v2) := \n have 0 < sbitvec.sizeof sz v1, by apply sbitvec.decr_sbitvec,\n have 0 < sbitvec.sizeof sz v2, by apply sbitvec.decr_sbitvec,\n Hbule v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| (@sbool.ult sz v1 v2) := \n have 0 < sbitvec.sizeof sz v1, by apply sbitvec.decr_sbitvec,\n have 0 < sbitvec.sizeof sz v2, by apply sbitvec.decr_sbitvec,\n Hbult v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\nwith sbitvec.induction: ∀ {sz:size} (v:sbitvec sz), P' v\n| _ (sbitvec.const sz n) := Hvconst sz n\n| _ (sbitvec.var sz n) := Hvvar sz n\n| _ (sbitvec.add v1 v2) := Hvadd v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.sub v1 v2) := Hvsub v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.mul v1 v2) := Hvmul v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.udiv v1 v2) := Hvudiv v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.urem v1 v2) := Hvurem v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.sdiv v1 v2) := Hvsdiv v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.srem v1 v2) := Hvsrem v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.and v1 v2) := Hvand v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.or v1 v2) := Hvor v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.xor v1 v2) := Hvxor v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.shl v1 v2) := Hvshl v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.lshr v1 v2) := Hvlshr v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.ashr v1 v2) := Hvashr v1 v2 (sbitvec.induction v1) (sbitvec.induction v2)\n| _ (sbitvec.zext sz' v) := Hvzext v sz' (sbitvec.induction v)\n| _ (sbitvec.sext sz' v) := Hvsext v sz' (sbitvec.induction v)\n| _ (sbitvec.trunc sz' v) := Hvtrunc v sz' (sbitvec.induction v)\n| _ (sbitvec.extract h l H v) := Hvextract v h l H (sbitvec.induction v)\n| _ (sbitvec.ite b v1 v2) := Hvite b v1 v2 (sbool.induction b)\n (sbitvec.induction v1) (sbitvec.induction v2)\n\nend\n\n\nlemma env.replace_sb_and0: ∀ (b1 b2:sbool) (η:freevar.env),\n η⟦sbool.and b1 b2⟧ = sbool.and (η⟦b1⟧) (η⟦b2⟧)\n:= begin intros, unfold freevar.env.replace_sb end\nlemma env.replace_sb_and: ∀ (b1 b2:sbool) (η:freevar.env),\n η⟦b1 & b2⟧ = η⟦b1⟧ & η⟦b2⟧\n:= begin intros, apply env.replace_sb_and0 end\n\nlemma env.replace_sb_or0: ∀ (b1 b2:sbool) (η:freevar.env),\n η⟦sbool.or b1 b2⟧ = sbool.or (η⟦b1⟧) (η⟦b2⟧)\n:= begin intros, unfold freevar.env.replace_sb end\nlemma env.replace_sb_or: ∀ (b1 b2:sbool) (η:freevar.env),\n η⟦b1 |b b2⟧ = η⟦b1⟧ |b η⟦b2⟧\n:= begin intros, apply env.replace_sb_or0 end\n\nlemma env.replace_sb_not0: ∀ (b:sbool) (η:freevar.env),\n η⟦sbool.not b⟧ = sbool.not (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sb end\nlemma env.replace_sb_not: ∀ (b:sbool) (η:freevar.env),\n η⟦~ b⟧ = ~ η⟦b⟧\n:= begin intros, apply env.replace_sb_not0 end\n\nlemma env.replace_sb_eqbv: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbool.eqbv a b⟧ = sbool.eqbv (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_nebv: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbool.nebv a b⟧ = sbool.nebv (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_sle: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbool.sle a b⟧ = sbool.sle (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_slt: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbool.slt a b⟧ = sbool.slt (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_ule: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbool.ule a b⟧ = sbool.ule (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_ult: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbool.ult a b⟧ = sbool.ult (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_ite: ∀ (c:sbool) (a b:sbool) (η:freevar.env),\n η⟦sbool.ite c a b⟧ = sbool.ite (η⟦c⟧) (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_b2p: ∀ (b:sbool) (η:freevar.env),\n η⟦b2p irsem_smt b⟧ = b2p irsem_smt (η⟦b⟧)\n:= begin\n intros,\n unfold b2p,\n unfold has_ite.ite,\n unfold freevar.env.replace_sb,\n refl\nend\n\nlemma env.replace_sb_of_bool: ∀ (a:bool) (η:freevar.env),\n η⟦sbool.of_bool a⟧ = sbool.of_bool a\n:= begin\n intros, cases a; refl\nend\n\nlemma env.replace_eq2p: ∀ {sz:size} (v1:sbitvec sz) (v2:sbitvec sz) (η:freevar.env),\n η⟦irsem.eq2p irsem_smt v1 v2⟧ = (irsem.eq2p irsem_smt (η⟦v1⟧) (η⟦v2⟧))\n:= begin\n intros,\n unfold eq2p,\n unfold has_ne.ne,\n unfold has_comp.ne,\n have HNE: sbool.nebv (η⟦v1⟧) (η⟦v2⟧) = η⟦sbool.nebv v1 v2⟧,\n {\n unfold freevar.env.replace_sb\n },\n rw HNE,\n apply env.replace_b2p,\nend\n\nlemma env.replace_neq2p: ∀ {sz:size} (v1:sbitvec sz) (v2:sbitvec sz) (η:freevar.env),\n η⟦irsem.neq2p irsem_smt v1 v2⟧ = (irsem.neq2p irsem_smt (η⟦v1⟧) (η⟦v2⟧))\n:= begin\n intros,\n unfold neq2p,\n unfold has_eq.eq,\n unfold has_comp.eq,\n have HNE: sbool.eqbv (η⟦v1⟧) (η⟦v2⟧) = η⟦sbool.eqbv v1 v2⟧,\n {\n unfold freevar.env.replace_sb\n },\n rw HNE,\n apply env.replace_b2p,\nend\n\nlemma env.replace_eq2p': ∀ {sz:size} (v1:sbitvec sz) (v2:sbitvec sz) (η:freevar.env)\n (H:v2 = η⟦v2⟧),\n (irsem.eq2p irsem_smt (η⟦v1⟧) v2) = η⟦irsem.eq2p irsem_smt v1 v2⟧\n:= begin\n intros,\n have H0: irsem.eq2p irsem_smt (η⟦v1⟧) v2 = irsem.eq2p irsem_smt (η⟦v1⟧) (η⟦v2⟧),\n { rw ← H },\n rw H0,\n rw ← env.replace_eq2p\nend\n\n-- replace_sbv\n\nlemma env.replace_sbv_add: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.add a b⟧ = sbitvec.add (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_sub: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.sub a b⟧ = sbitvec.sub (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_mul: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.mul a b⟧ = sbitvec.mul (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_udiv: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.udiv a b⟧ = sbitvec.udiv (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_urem: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.urem a b⟧ = sbitvec.urem (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_sdiv: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.sdiv a b⟧ = sbitvec.sdiv (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_srem: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.srem a b⟧ = sbitvec.srem (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_shl: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.shl a b⟧ = sbitvec.shl (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_lshr: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.lshr a b⟧ = sbitvec.lshr (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_ashr: ∀ {sz:size} (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.ashr a b⟧ = sbitvec.ashr (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_mk_zext: ∀ {sz sz2:size} (a:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.mk_zext sz2 a⟧ = sbitvec.mk_zext sz2 (η⟦a⟧)\n:= begin intros, unfold sbitvec.mk_zext, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_mk_sext: ∀ {sz sz2:size} (a:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.mk_sext sz2 a⟧ = sbitvec.mk_sext sz2 (η⟦a⟧)\n:= begin intros, unfold sbitvec.mk_sext, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_trunc: ∀ {sz sz':size} (b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.trunc sz' b⟧ = sbitvec.trunc sz' (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_zext: ∀ {sz sz':size} (b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.zext sz' b⟧ = sbitvec.zext sz' (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_sext: ∀ {sz sz':size} (b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.sext sz' b⟧ = sbitvec.sext sz' (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_extract: ∀ {sz sz':size} (b:sbitvec sz) (η:freevar.env) h l \n (H:sz'.val = h - l + 1),\n η⟦sbitvec.extract h l H b⟧ = sbitvec.extract h l H (η⟦b⟧)\n:= begin\n intros,\n unfold freevar.env.replace_sbv\nend\n\nlemma env.replace_sbv_ite: ∀ {sz:size} (c:sbool) (a b:sbitvec sz) (η:freevar.env),\n η⟦sbitvec.ite c a b⟧ = sbitvec.ite (η⟦c⟧) (η⟦a⟧) (η⟦b⟧)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_of_int: ∀ sz z (η:freevar.env),\n η⟦sbitvec.of_int sz z⟧ = sbitvec.of_int sz z\n:= begin\n intros,\n cases sz,\n cases z;\n {\n unfold sbitvec.of_int,\n unfold freevar.env.replace_sbv\n }\nend\n\nlemma env.replace_sbv_of_bool: ∀ (a:sbool) (η:freevar.env),\n η⟦sbitvec.of_bool a⟧ = sbitvec.of_bool (η⟦a⟧)\n:= begin\n intros, unfold sbitvec.of_bool, rw env.replace_sbv_ite,\n unfold sbitvec.zero, unfold sbitvec.one,\n rw env.replace_sbv_of_int, rw env.replace_sbv_of_int\nend\n\n\n\nlemma env.replace_idemp :\n (∀ (η:freevar.env) (b:sbool), η⟦η⟦b⟧⟧ = η⟦b⟧) ∧\n (∀ {sz:size} (η:freevar.env) (b:sbitvec sz), η⟦η⟦b⟧⟧ = η⟦b⟧) \n:= begin\n split; intros; revert b,\n apply (sbool.induction (λ b, η⟦η⟦b⟧⟧ = η⟦b⟧)\n (λ {sz:size} (v:sbitvec sz), η⟦η⟦v⟧⟧ = η⟦v⟧)),\n any_goals {\n apply (sbitvec.induction (λ b, η⟦η⟦b⟧⟧ = η⟦b⟧)\n (λ {sz:size} (v:sbitvec sz), η⟦η⟦v⟧⟧ = η⟦v⟧))\n },\n any_goals\n { refl },\n -- sbool\n any_goals {\n intros b1 b2 H1 H2,\n unfold freevar.env.replace_sb, rw [H1, H2], done\n },\n any_goals {\n intros,\n unfold freevar.env.replace_sb,\n generalize Hb': η.b s = b',\n cases b',\n { unfold freevar.env.replace_sb._match_1,\n unfold freevar.env.replace_sb,\n rw Hb', refl\n },\n { unfold freevar.env.replace_sb._match_1,\n cases b'; refl\n }\n },\n any_goals { intros b1 b2 b3 H1 H2 H3,\n unfold freevar.env.replace_sb, rw [H1, H2, H3], done\n },\n any_goals { intros b H,\n unfold freevar.env.replace_sb, rw H, done\n },\n any_goals { intros sz v1 v2 H1 H2,\n unfold freevar.env.replace_sb, rw H1, rw H2, done\n },\n -- sbitvec\n any_goals\n { intros, unfold freevar.env.replace_sbv, done },\n any_goals {\n intros sz v1 v2 H1 H2,\n unfold freevar.env.replace_sbv, rw [H1, H2], done\n },\n any_goals {\n intros,\n unfold freevar.env.replace_sbv,\n generalize Hb': η.bv n = b',\n cases b'; unfold freevar.env.replace_sbv._match_1,\n { unfold freevar.env.replace_sbv,\n rw Hb', refl\n },\n { rw env.replace_sbv_of_int }, done\n },\n any_goals {\n intros sz v' sz' H,\n unfold freevar.env.replace_sbv, rw H, done\n },\n any_goals {\n intros sz sz' v highbit lowbit H H',\n unfold freevar.env.replace_sbv,\n rw H', done\n },\n any_goals {\n intros sz b v1 v2 H H1 H2,\n unfold freevar.env.replace_sbv,\n rw [H, H1, H2]\n }\nend\n\nlemma env.replace_sb_idemp: ∀ (η:freevar.env) (b:sbool), η⟦η⟦b⟧⟧ = η⟦b⟧\n:= begin\n apply (and.elim_left env.replace_idemp)\nend\n\nlemma env.replace_sbv_idemp: ∀ {sz} (η:freevar.env) (b:sbitvec sz), η⟦η⟦b⟧⟧ = η⟦b⟧\n:= begin\n intros,\n apply (and.elim_right env.replace_idemp)\nend\n\nlemma env.empty_replace: (∀ (b:sbool), freevar.env.empty⟦b⟧ = b) ∧\n (∀ {sz} (b:sbitvec sz), freevar.env.empty⟦b⟧ = b)\n:= begin\n intros,\n split; intros; revert b,\n apply (sbool.induction (λ b, freevar.env.empty⟦b⟧ = b)\n (λ {sz:size} (v:sbitvec sz), freevar.env.empty⟦v⟧ = v)),\n any_goals {\n apply (sbitvec.induction (λ b, freevar.env.empty⟦b⟧ = b)\n (λ {sz:size} (v:sbitvec sz), freevar.env.empty⟦v⟧ = v)),\n },\n any_goals { refl },\n any_goals {\n intros,\n unfold freevar.env.replace_sb,\n unfold freevar.env.empty,\n simp, done\n },\n any_goals {\n intros b H, unfold freevar.env.replace_sb, rw H\n },\n any_goals {\n intros b1 b2 H1 H2, unfold freevar.env.replace_sb, rw [H1, H2], done\n },\n any_goals {\n intros b b1 b2 H H1 H2, unfold freevar.env.replace_sb, rw [H, H1, H2], done\n },\n any_goals {\n intros sz b1 b2 H1 H2, unfold freevar.env.replace_sb, rw [H1, H2], done\n },\n -- sbitvec\n any_goals\n { intros, unfold freevar.env.replace_sbv, done },\n any_goals {\n intros sz v1 v2 H1 H2,\n unfold freevar.env.replace_sbv, rw [H1, H2], done\n },\n any_goals {\n intros,\n unfold freevar.env.replace_sbv,\n unfold freevar.env.empty,\n simp, done\n },\n any_goals {\n intros sz v' sz' H,\n unfold freevar.env.replace_sbv, rw H, done\n },\n any_goals {\n intros sz sz' v highbit lowbit H H',\n unfold freevar.env.replace_sbv,\n rw H', done\n },\n any_goals {\n intros sz b v1 v2 H H1 H2,\n unfold freevar.env.replace_sbv,\n rw [H, H1, H2]\n }\nend\n\n\nlemma env.empty_replace_sb: ∀ (b:sbool), freevar.env.empty⟦b⟧ = b\n:= begin\n apply (and.elim_left env.empty_replace)\nend\n\nlemma env.empty_replace_sbv {sz:size} : ∀ (b:sbitvec sz), freevar.env.empty⟦b⟧ = b\n:= begin\n apply (and.elim_right env.empty_replace)\nend\n\nlemma env.replace_sbv_cast: ∀ {sz sz':size} {H:sz = sz'} {H':sbitvec sz = sbitvec sz'}\n (b:sbitvec sz) (η:freevar.env),\n η⟦cast H' b⟧ = cast H' (η⟦b⟧)\n:= begin\n intros,\n induction H,\n unfold cast\nend\n\nlemma env.replace_sb_overflowchk_add: ∀\n {sz1:size} (sz2:size) (v1 v2:sbitvec sz1) nsw (η:freevar.env),\n η⟦sbitvec.overflow_chk @sbitvec.add sz2 nsw v1 v2⟧ =\n sbitvec.overflow_chk @sbitvec.add sz2 nsw (η⟦v1⟧) (η⟦v2⟧)\n:= begin\n intros, unfold sbitvec.overflow_chk,\n cases nsw; simp, rw env.replace_sbv_of_int\nend\n\nlemma env.replace_sb_overflowchk_sub: ∀\n {sz1:size} (sz2:size) (v1 v2:sbitvec sz1) nsw (η:freevar.env),\n η⟦sbitvec.overflow_chk @sbitvec.sub sz2 nsw v1 v2⟧ =\n sbitvec.overflow_chk @sbitvec.sub sz2 nsw (η⟦v1⟧) (η⟦v2⟧)\n:= begin\n intros, unfold sbitvec.overflow_chk,\n cases nsw; simp, rw env.replace_sbv_of_int\nend\n\nlemma env.replace_sb_overflowchk_mul: ∀\n {sz1:size} (sz2:size) (v1 v2:sbitvec sz1) nsw (η:freevar.env),\n η⟦sbitvec.overflow_chk @sbitvec.mul sz2 nsw v1 v2⟧ =\n sbitvec.overflow_chk @sbitvec.mul sz2 nsw (η⟦v1⟧) (η⟦v2⟧)\n:= begin\n intros, unfold sbitvec.overflow_chk,\n cases nsw; simp, rw env.replace_sbv_of_int\nend\n\nlemma env.replace_sb_overflowchk_shl: ∀\n {sz1:size} (sz2:size) (v1 v2:sbitvec sz1) nsw (η:freevar.env),\n η⟦sbitvec.shl_overflow_chk sz2 nsw v1 v2⟧ =\n sbitvec.shl_overflow_chk sz2 nsw (η⟦v1⟧) (η⟦v2⟧)\n:= begin\n intros, unfold sbitvec.shl_overflow_chk,\n unfold sbitvec.overflow_chk,\n cases nsw; simp,\n { repeat { rw env.replace_sbv_of_int }, tauto },\n { rw env.replace_sbv_of_int, tauto }\nend\n\n-- irstate\n\nlemma getreg_replace_none: ∀ ss ss' (η:freevar.env) (name name':string)\n (H:irstate.getreg irsem_smt ss name = none)\n (H':ss' = η⟦ss⟧),\n irstate.getreg irsem_smt ss' name = none\n:= begin\n intros,\n unfold freevar.env.replace at H',\n rw H',\n rw ← irstate.getreg_apply_none_smt,\n assumption\nend\n\nlemma getreg_replace_none_inv: ∀ ss ss' (η:freevar.env) (name name':string)\n (H:irstate.getreg irsem_smt ss' name = none)\n (H':ss' = η⟦ss⟧),\n irstate.getreg irsem_smt ss name = none\n:= begin\n intros,\n unfold freevar.env.replace at H',\n rw H' at H,\n rw irstate.getreg_apply_none_smt,\n assumption\nend\n\nlemma getreg_replace: ∀ {ss:irstate_smt} {name:string} {η:freevar.env} {ov}\n (HV:irstate.getreg irsem_smt ss name = ov),\n irstate.getreg irsem_smt (η⟦ss⟧) name = η⟦ov⟧'\n:= begin\n intros,\n revert ov,\n unfold irstate.getreg at *,\n unfold freevar.env.replace at *,\n unfold irstate.apply_to_values at *,\n cases ss with ss_ub ss_rf,\n apply regfile.induction ss_rf,\n {\n intros ov H,\n unfold irstate.setub, simp at *,\n rw regfile.empty_apply_empty,\n rw regfile.empty_get_none at *, rw ← H\n },\n {\n intros rf Hind n v ov H,\n unfold irstate.setub, simp at *,\n rw regfile.apply_update_comm,\n have HNAME: decidable (n = name), apply_instance,\n cases HNAME,\n {\n rw regfile.update_get_nomatch,\n apply Hind,\n { rw regfile.update_get_nomatch at H, apply H,\n apply neq_symm, assumption },\n { apply neq_symm, assumption }\n },\n {\n rw regfile.update_get_match,\n rw regfile.update_get_match at H,\n rw ← H, rw HNAME, rw HNAME\n }\n }\nend\n\nlemma replace_updatereg: ∀ (ss:irstate_smt) (name:string)\n (η:freevar.env) v,\n η⟦irstate.updatereg irsem_smt ss name v⟧ =\n irstate.updatereg irsem_smt (η⟦ss⟧) name (η⟦v⟧)\n:= begin\n intros,\n unfold irstate.updatereg,\n unfold freevar.env.replace,\n unfold irstate.apply_to_values,\n congr\nend\n\nlemma replace_updateub: ∀ (ss:irstate_smt) (η:freevar.env) ub,\n η⟦irstate.updateub irsem_smt ss ub⟧ =\n irstate.updateub irsem_smt (η⟦ss⟧) (η⟦ub⟧)\n:= begin\n intros,\n unfold irstate.updateub,\n unfold freevar.env.replace,\n unfold irstate.apply_to_values,\n unfold irstate.setub,\n unfold irstate.getub,\n simp,\n congr, rw env.replace_sb_and\nend\n\nlemma replace_getub: ∀ (ss:irstate_smt) (η:freevar.env),\n η⟦irstate.getub irsem_smt ss⟧ =\n irstate.getub irsem_smt (η⟦ss⟧)\n:= begin\n intros,\n unfold irstate.getub,\n cases ss, refl\nend\n\nlemma empty_replace_st: ∀ (ss:irstate_smt),\n freevar.env.empty⟦ss⟧ = ss\n:= begin\n intros,\n unfold freevar.env.replace,\n cases ss,\n unfold irstate.apply_to_values,\n unfold irstate.setub,\n unfold irstate.getub,\n simp,\n rw prod_inj,\n split,\n { rw env.empty_replace_sb },\n {\n simp,\n revert ss_snd,\n apply regfile.induction,\n { rw regfile.empty_apply_empty },\n {\n intros rf H,\n intros,\n rw regfile.apply_update_comm,\n congr, assumption, cases v,\n unfold freevar.env.replace_valty,\n congr, rw env.empty_replace_sbv, rw env.empty_replace_sb\n }\n }\nend\n\n-- ∉\n\nlemma env.not_in_split: ∀ (η:freevar.env) n,\n n ∉ η ↔ η.b n = none ∧ η.bv n = none\n:= begin\n intros,\n split; intros H,\n {\n unfold has_mem.mem at H,\n rw decidable.not_or_iff_and_not at H,\n cases H,\n rw ne.def at H_left,\n rw ne.def at H_right,\n rw decidable.not_not_iff at H_left,\n rw decidable.not_not_iff at H_right,\n split; assumption\n },\n {\n unfold has_mem.mem,\n rw decidable.not_or_iff_and_not,\n cases H,\n rw ne.def,\n rw ne.def,\n rw decidable.not_not_iff,\n rw decidable.not_not_iff,\n split; assumption\n }\nend\n\nlemma env.in_not_in: ∀ n (η:freevar.env), n ∉ η ∨ n ∈ η\n:= begin\n intros,\n rw env.not_in_split,\n unfold has_mem.mem,\n generalize Hb: η.b n = b',\n generalize Hb: η.bv n = bv',\n cases b'; cases bv',\n {\n left, split; refl \n },\n { right, right, intros H, cases H },\n { right, left, intros H, cases H },\n { right, left, intros H, cases H },\nend\n\nlemma env.not_in_add_bv: ∀ (η:freevar.env) n1 n2 z\n (HNEQ:n1 ≠ n2)\n (HNOTIN:n1 ∉ η),\n n1 ∉ (η.add_bv n2 z)\n:= begin\n intros,\n rw env.not_in_split at *,\n cases HNOTIN,\n unfold freevar.env.add_bv,\n split,\n { simp, assumption },\n { simp, rw if_neg; assumption }\nend\n\nlemma env.not_in_add_b: ∀ (η:freevar.env) n1 n2 z\n (HNEQ:n1 ≠ n2)\n (HNOTIN:n1 ∉ η),\n n1 ∉ (η.add_b n2 z)\n:= begin\n intros,\n rw env.not_in_split at *,\n cases HNOTIN,\n unfold freevar.env.add_b,\n split,\n { simp, rw if_neg; assumption },\n { simp, assumption }\nend\n\nlemma env.not_in_empty: ∀ n, n ∉ freevar.env.empty\n:= begin\n intros, rw env.not_in_split,\n split; refl\nend\n\n-- replace_sb, repalce_sbv\n\nlemma env.not_in_replace_sb: ∀ (η:freevar.env) n\n (HNOTIN:n ∉ η),\n η⟦sbool.var n⟧ = sbool.var n\n:= begin\n intros,\n rw env.not_in_split at *,\n cases HNOTIN,\n unfold freevar.env.replace_sb,\n generalize H:η.b n = g,\n cases g,\n { refl },\n { rw HNOTIN_left at H, cases H }\nend\n\nlemma env.not_in_replace_sbv: ∀ (η:freevar.env) n sz\n (HNOTIN:n ∉ η),\n η⟦sbitvec.var sz n⟧ = sbitvec.var sz n\n:= begin\n intros,\n rw env.not_in_split at *,\n cases HNOTIN,\n unfold freevar.env.replace_sbv,\n generalize H:η.bv n = g,\n cases g,\n { refl },\n { rw HNOTIN_right at H, cases H }\nend\n\nlemma env.in_replace_sbv: ∀ (η:freevar.env) n sz\n (HIN:∃ z, η.bv n = some z),\n ∃ z, η⟦sbitvec.var sz n⟧ = sbitvec.const sz z\n:= begin\n intros,\n cases HIN with z HIN,\n unfold freevar.env.replace_sbv,\n rw HIN,\n unfold freevar.env.replace_sbv._match_1,\n cases z; unfold sbitvec.of_int,\n apply exists.intro, refl,\n apply exists.intro, refl\nend\n\nlemma env.sbv_var_or_const: ∀ (η:freevar.env) sz n,\n η⟦sbitvec.var sz n⟧ = sbitvec.var sz n ∨\n ∃ z, η⟦sbitvec.var sz n⟧ = sbitvec.const sz z\n:= begin\n intros,\n unfold freevar.env.replace_sbv,\n generalize H: (η.bv n) = b,\n cases b,\n {\n unfold freevar.env.replace_sbv._match_1,\n left, refl\n },\n {\n unfold freevar.env.replace_sbv._match_1,\n right, cases b; unfold sbitvec.of_int,\n apply exists.intro, refl,\n apply exists.intro, refl\n }\nend\n\nlemma env.sb_var_or_const: ∀ (η:freevar.env) n,\n η⟦sbool.var n⟧ = sbool.var n ∨\n η⟦sbool.var n⟧ = sbool.tt ∨\n η⟦sbool.var n⟧ = sbool.ff\n:= begin\n intros,\n unfold freevar.env.replace_sb,\n generalize H: (η.b n) = b,\n cases b,\n {\n unfold freevar.env.replace_sb._match_1,\n left, refl\n },\n {\n unfold freevar.env.replace_sb._match_1,\n right, cases b, right, refl, left, refl\n }\nend\n\nlemma env.not_in_add_bv_replace: ∀ (η:freevar.env) n n2 sz z\n (HNEQ:n ≠ n2),\n (η.add_bv n2 z)⟦sbitvec.var sz n⟧ = η⟦sbitvec.var sz n⟧\n:= begin\n intros,\n unfold freevar.env.replace_sbv,\n unfold freevar.env.add_bv,\n simp,\n rw if_neg, assumption\nend\n\nlemma env.not_in_add_b_replace: ∀ (η:freevar.env) n n2 z\n (HNEQ:n ≠ n2),\n (η.add_b n2 z)⟦sbool.var n⟧ = η⟦sbool.var n⟧\n:= begin\n intros,\n unfold freevar.env.replace_sb,\n unfold freevar.env.add_b,\n simp,\n rw if_neg, assumption\nend\n\nlemma env.add_b_replace_match: ∀ (η:freevar.env) n b,\n (freevar.env.add_b η n b)⟦sbool.var n⟧ = sbool.of_bool b\n:= begin\n intros,\n unfold freevar.env.replace_sb,\n unfold freevar.env.add_b,\n simp\nend\n\nlemma env.add_bv_replace_match: ∀ (η:freevar.env) n z sz,\n (freevar.env.add_bv η n z)⟦sbitvec.var sz n⟧ = sbitvec.of_int sz z\n:= begin\n intros,\n unfold freevar.env.replace_sbv,\n unfold freevar.env.add_bv,\n simp\nend\n\nlemma env.add_bv_replace_sb: ∀ (η:freevar.env) n n' z,\n (freevar.env.add_bv η n z)⟦sbool.var n'⟧ = η⟦sbool.var n'⟧\n:= begin\n intros,\n unfold freevar.env.replace_sb,\n unfold freevar.env.add_bv\nend\n\nlemma env.add_b_replace_sbv: ∀ (η:freevar.env) n n' b sz,\n (freevar.env.add_b η n b)⟦sbitvec.var sz n'⟧ = η⟦sbitvec.var sz n'⟧\n:= begin\n intros,\n unfold freevar.env.replace_sbv,\n unfold freevar.env.add_b\nend\n\nlemma env.replace_sb_cases: ∀ s (η:freevar.env), \n η⟦sbool.var s⟧ = sbool.var s ∨ η⟦sbool.var s⟧ = sbool.tt ∨ η⟦sbool.var s⟧ = sbool.ff\n:= begin\n intros,\n unfold freevar.env.replace_sb,\n generalize Hb: η.b s = b',\n rw Hb at *, cases b'; unfold freevar.env.replace_sb._match_1,\n { left, refl },\n {\n right,\n cases b'; unfold sbool.of_bool; simp\n }\nend\n\nlemma env.replace_sbv_cases: ∀ sz s (η:freevar.env),\n η⟦sbitvec.var sz s⟧ = sbitvec.var sz s\n ∨ ∃ n, η⟦sbitvec.var sz s⟧ = sbitvec.const sz n\n:= begin\n intros,\n unfold freevar.env.replace_sbv,\n generalize Hb: η.bv s = b',\n rw Hb at *, cases b'; unfold freevar.env.replace_sbv._match_1,\n { left, refl },\n {\n right,\n cases b'; unfold sbitvec.of_int,\n apply exists.intro, refl, apply exists.intro, refl\n }\nend\n\n\nlemma env.not_in_add_b_bv_bv_comm: ∀ (η:freevar.env) z,\n (∀ (v:sbool) n, n ∉ η → (η.add_bv n z)⟦v⟧ =\n (freevar.env.empty.add_bv n z)⟦η⟦v⟧⟧) ∧\n (∀ {sz} (v:sbitvec sz) n, n ∉ η → \n (η.add_bv n z)⟦v⟧ = (freevar.env.empty.add_bv n z)⟦η⟦v⟧⟧)\n:= begin\n intros,\n split,\n apply sbool.induction\n (λ v, ∀ n, n ∉ η → (η.add_bv n z)⟦v⟧ = (freevar.env.empty.add_bv n z)⟦η⟦v⟧⟧)\n (λ {sz} (v:sbitvec sz), ∀ n, n ∉ η → \n (η.add_bv n z)⟦v⟧ = (freevar.env.empty.add_bv n z)⟦η⟦v⟧⟧),\n any_goals {\n apply sbitvec.induction\n (λ v, ∀ n, n ∉ η → (η.add_bv n z)⟦v⟧ = (freevar.env.empty.add_bv n z)⟦η⟦v⟧⟧)\n (λ {sz} (v:sbitvec sz), ∀ n, n ∉ η → \n (η.add_bv n z)⟦v⟧ = (freevar.env.empty.add_bv n z)⟦η⟦v⟧⟧),\n },\n any_goals { intros, refl },\n any_goals {\n intros,\n unfold freevar.env.add_bv,\n unfold freevar.env.replace_sb,\n simp,\n unfold freevar.env.empty,\n generalize HG: η.b s = b',\n cases b',\n {\n unfold freevar.env.replace_sb._match_1,\n unfold freevar.env.replace_sb,\n },\n {\n unfold freevar.env.replace_sb._match_1,\n rw env.replace_sb_of_bool, done\n }\n },\n any_goals {\n intros b1 b2 H1 H2 n' HNOTIN',\n unfold freevar.env.replace_sb at *,\n rw [H1, H2]; assumption\n },\n any_goals {\n intros b1 b2 b3 H1 H2 H3 n' HNOTIN',\n unfold freevar.env.replace_sb at *,\n rw [H1, H2, H3]; assumption\n },\n any_goals {\n intros b H n' HNOTIN',\n unfold freevar.env.replace_sb at *,\n rw [H], assumption\n },\n any_goals {\n intros sz b1 b2 H1 H2 n' HNOTIN',\n unfold freevar.env.replace_sb at *,\n rw [H1, H2]; assumption\n },\n any_goals {\n intros,\n unfold freevar.env.replace_sbv at *, done\n },\n any_goals {\n intros sz n',\n intros n'' HNOTIN',\n have HEQ:decidable (n' = n''), apply_instance,\n cases HEQ,\n {\n have H:= env.sbv_var_or_const η sz n',\n cases H,\n {\n rw env.not_in_add_bv_replace,\n rw H,\n rw env.not_in_add_bv_replace,\n rw env.empty_replace_sbv,\n assumption, assumption\n },\n {\n cases H with z' H,\n rw env.not_in_add_bv_replace,\n rw H,\n unfold freevar.env.replace_sbv,\n assumption\n }\n },\n {\n rw HEQ,\n rw env.add_bv_replace_match,\n rw env.not_in_replace_sbv,\n rw env.add_bv_replace_match,\n assumption\n }\n },\n any_goals {\n intros sz v1 v2 H1 H2 n' HNOTIN',\n unfold freevar.env.replace_sbv at *,\n rw [H1, H2]; assumption\n },\n any_goals {\n intros sz v sz' H n' HNOTIN',\n unfold freevar.env.replace_sbv at *,\n rw H, assumption\n },\n any_goals {\n intros sz sz' v highbit lowbit HH H n' HNOTIN',\n unfold freevar.env.replace_sbv at *,\n rw H, assumption\n },\n any_goals {\n intros sz v1 v2 v3 H1 H2 H3 n' HNOTIN',\n unfold freevar.env.replace_sbv at *,\n rw [H1, H2, H3]; assumption\n }\nend\n\nlemma env.not_in_add_bv_b_comm: ∀ (η:freevar.env) z (v:sbool) n,\n n ∉ η → (η.add_bv n z)⟦v⟧ = (freevar.env.empty.add_bv n z)⟦η⟦v⟧⟧\n:= begin\n intros, apply (and.elim_left (env.not_in_add_b_bv_bv_comm η z)),\n assumption\nend\n\nlemma env.not_in_add_bv_bv_comm: ∀ (η:freevar.env) z {sz} (v:sbitvec sz) n,\n n ∉ η → (η.add_bv n z)⟦v⟧ = (freevar.env.empty.add_bv n z)⟦η⟦v⟧⟧\n:= begin\n intros, apply (and.elim_right (env.not_in_add_b_bv_bv_comm η z)),\n assumption\nend\n\n\n\n\nlemma env.not_in_add_b_bv_b_comm: ∀ (η:freevar.env) z,\n (∀ (v:sbool) n, n ∉ η → (η.add_b n z)⟦v⟧ =\n (freevar.env.empty.add_b n z)⟦η⟦v⟧⟧) ∧\n (∀ {sz} (v:sbitvec sz) n, n ∉ η → \n (η.add_b n z)⟦v⟧ = (freevar.env.empty.add_b n z)⟦η⟦v⟧⟧)\n:= begin\n intros,\n split,\n apply sbool.induction\n (λ v, ∀ n, n ∉ η → (η.add_b n z)⟦v⟧ = (freevar.env.empty.add_b n z)⟦η⟦v⟧⟧)\n (λ {sz} (v:sbitvec sz), ∀ n, n ∉ η → \n (η.add_b n z)⟦v⟧ = (freevar.env.empty.add_b n z)⟦η⟦v⟧⟧),\n any_goals {\n apply sbitvec.induction\n (λ v, ∀ n, n ∉ η → (η.add_b n z)⟦v⟧ = (freevar.env.empty.add_b n z)⟦η⟦v⟧⟧)\n (λ {sz} (v:sbitvec sz), ∀ n, n ∉ η → \n (η.add_b n z)⟦v⟧ = (freevar.env.empty.add_b n z)⟦η⟦v⟧⟧),\n },\n any_goals { intros, refl },\n any_goals {\n intros n',\n intros n'' HNOTIN',\n have HEQ:decidable (n' = n''), apply_instance,\n cases HEQ,\n {\n have H:= env.sb_var_or_const η n',\n cases H,\n {\n rw env.not_in_add_b_replace,\n rw H,\n rw env.not_in_add_b_replace,\n rw env.empty_replace_sb,\n assumption, assumption\n },\n {\n cases H,\n any_goals {rw env.not_in_add_b_replace,\n rw H,\n unfold freevar.env.replace_sb,\n assumption }\n }\n },\n {\n rw HEQ,\n rw env.add_b_replace_match,\n rw env.not_in_replace_sb,\n rw env.add_b_replace_match,\n assumption\n }\n },\n any_goals {\n intros b1 b2 H1 H2 n' HNOTIN',\n unfold freevar.env.replace_sb at *,\n rw [H1, H2]; assumption\n },\n any_goals {\n intros b1 b2 b3 H1 H2 H3 n' HNOTIN',\n unfold freevar.env.replace_sb at *,\n rw [H1, H2, H3]; assumption\n },\n any_goals {\n intros b H n' HNOTIN',\n unfold freevar.env.replace_sb at *,\n rw [H], assumption\n },\n any_goals {\n intros sz b1 b2 H1 H2 n' HNOTIN',\n unfold freevar.env.replace_sb at *,\n rw [H1, H2]; assumption\n },\n any_goals {\n intros,\n unfold freevar.env.replace_sbv at *, done\n },\n any_goals {\n intros,\n unfold freevar.env.add_b,\n unfold freevar.env.replace_sbv,\n simp,\n unfold freevar.env.empty,\n generalize HG: η.bv n = b',\n cases b',\n {\n unfold freevar.env.replace_sbv._match_1,\n unfold freevar.env.replace_sbv,\n },\n {\n unfold freevar.env.replace_sbv._match_1,\n simp,\n rw env.replace_sbv_of_int, done\n }\n },\n any_goals {\n intros sz v1 v2 H1 H2 n' HNOTIN',\n unfold freevar.env.replace_sbv at *,\n rw [H1, H2]; assumption\n },\n any_goals {\n intros sz v sz' H n' HNOTIN',\n unfold freevar.env.replace_sbv at *,\n rw H, assumption\n },\n any_goals {\n intros sz sz' v highbit lowbit HH H n' HNOTIN',\n unfold freevar.env.replace_sbv at *,\n rw H, assumption\n },\n any_goals {\n intros sz v1 v2 v3 H1 H2 H3 n' HNOTIN',\n unfold freevar.env.replace_sbv at *,\n rw [H1, H2, H3]; assumption\n }\nend\n\nlemma env.not_in_add_b_b_comm: ∀ (η:freevar.env) z (v:sbool) n,\n n ∉ η → (η.add_b n z)⟦v⟧ = (freevar.env.empty.add_b n z)⟦η⟦v⟧⟧\n:= begin\n intros, apply (and.elim_left (env.not_in_add_b_bv_b_comm η z)),\n assumption\nend\n\nlemma env.not_in_add_b_bv_comm: ∀ (η:freevar.env) z {sz} (v:sbitvec sz) n,\n n ∉ η → (η.add_b n z)⟦v⟧ = (freevar.env.empty.add_b n z)⟦η⟦v⟧⟧\n:= begin\n intros, apply (and.elim_right (env.not_in_add_b_bv_b_comm η z)),\n assumption\nend\n\nlemma env.not_in_add_bv_valty_comm: ∀ (η:freevar.env) (vv:valty_smt) n z,\n n ∉ η → (η.add_bv n z)⟦vv⟧ = (freevar.env.empty.add_bv n z)⟦η⟦vv⟧⟧\n:= begin\n intros,\n cases vv with sz iv pv,\n unfold freevar.env.replace_valty,\n simp,\n rw env.not_in_add_bv_bv_comm,\n rw env.not_in_add_bv_b_comm,\n split, refl, refl,\n assumption, assumption\nend\n\nlemma env.not_in_add_b_valty_comm: ∀ (η:freevar.env) (vv:valty_smt) n z,\n n ∉ η → (η.add_b n z)⟦vv⟧ = (freevar.env.empty.add_b n z)⟦η⟦vv⟧⟧\n:= begin\n intros,\n cases vv with sz iv pv,\n unfold freevar.env.replace_valty,\n simp,\n rw env.not_in_add_b_bv_comm,\n rw env.not_in_add_b_b_comm,\n split, refl, refl,\n assumption, assumption\nend\n\nlemma env.not_in_add_bv_irstate_comm: ∀ (η:freevar.env) (ss:irstate irsem_smt) n z,\n n ∉ η → (η.add_bv n z)⟦ss⟧ = (freevar.env.empty.add_bv n z)⟦η⟦ss⟧⟧\n:= begin\n intros,\n cases ss,\n unfold freevar.env.replace,\n rw ← irstate.setub_apply_to_values,\n rw ← irstate.setub_apply_to_values,\n rw ← irstate.setub_apply_to_values,\n rw ← irstate.setub_apply_to_values,\n unfold irstate.getub,\n unfold irstate.setub,\n unfold irstate.apply_to_values,\n unfold regfile.apply_to_values,\n simp,\n rw prod_inj,\n simp,\n split,\n {\n rw env.not_in_add_bv_b_comm, assumption\n },\n {\n induction ss_snd,\n { refl },\n {\n simp,\n rw ss_snd_ih,\n cases ss_snd_hd with rn v,\n cases v with sz iv pv,\n simp,\n rw env.not_in_add_bv_bv_comm,\n rw env.not_in_add_bv_b_comm,\n assumption, assumption\n }\n }\nend\n\nlemma env.not_in_add_b_irstate_comm: ∀ (η:freevar.env) (ss:irstate irsem_smt) n z,\n n ∉ η → (η.add_b n z)⟦ss⟧ = (freevar.env.empty.add_b n z)⟦η⟦ss⟧⟧\n:= begin\n intros,\n cases ss,\n unfold freevar.env.replace,\n rw ← irstate.setub_apply_to_values,\n rw ← irstate.setub_apply_to_values,\n rw ← irstate.setub_apply_to_values,\n rw ← irstate.setub_apply_to_values,\n unfold irstate.getub,\n unfold irstate.setub,\n unfold irstate.apply_to_values,\n unfold regfile.apply_to_values,\n simp,\n rw prod_inj,\n simp,\n split,\n {\n rw env.not_in_add_b_b_comm, assumption\n },\n {\n induction ss_snd,\n { refl },\n {\n simp,\n rw ss_snd_ih,\n cases ss_snd_hd with rn v,\n cases v with sz iv pv,\n simp,\n rw env.not_in_add_b_bv_comm,\n rw env.not_in_add_b_b_comm,\n assumption, assumption\n }\n }\nend\n\nlemma env.has_only_shuffle: ∀ {η:freevar.env} (s:string) (l1 l2:list string),\n env.has_only η (s::(l1 ++ l2)) ↔ env.has_only η (l1 ++ s::l2)\n:= begin\n intros, rw ← list.cons_append,\n unfold env.has_only,\n split,\n {\n intros, simp, simp at a,\n rw or.comm, rw or.assoc,\n rw @or.comm (name ∈ l2) (name ∈ l1), apply a\n },\n {\n intros, simp, simp at a,\n rw or.comm, rw or.assoc,\n rw @or.comm (name ∈ l2) (name = s), apply a\n }\nend\n\nlemma env.has_only_shuffle2: ∀ {η:freevar.env} (s1 s2:string) (l:list string),\n env.has_only η (s1::s2::l) ↔ env.has_only η (s2::s1::l)\n:= begin\n intros,\n unfold env.has_only,\n split,\n {\n intros, simp, simp at a,\n rw or.comm, rw or.assoc,\n rw @or.comm (name ∈ l) (name = s2), apply a\n },\n {\n intros, simp, simp at a,\n rw or.comm, rw or.assoc,\n rw @or.comm (name ∈ l) (name = s1), apply a\n }\nend\n\nlemma env.has_only_added2: ∀ {η η':freevar.env} {n1 n2:string}\n {l:list string}\n (H1: env.has_only η l)\n (H2: env.added2 η n1 n2 η'),\n env.has_only η' (n1::n2::l)\n:= begin\n intros,\n unfold env.added2 at H2,\n cases H2,\n unfold env.has_only at *,\n intros,\n simp,\n rw H1,\n split,\n { intros, apply H2_right, rw or.comm, rw or.assoc, assumption },\n {\n intros,\n rw ← decidable.not_not_iff (name ∈ η') at a,\n rw ← decidable.not_not_iff (name = n1 ∨ name = n2 ∨ name ∈ η),\n intros H0,\n rw decidable.not_or_iff_and_not at H0,\n rw decidable.not_or_iff_and_not at H0,\n cases H0, cases H0_right,\n apply a,\n apply H2_left, assumption, split; assumption\n }\nend\n\nlemma env.has_only_not_in: ∀ {η:freevar.env} {l n}\n (H:env.has_only η l) (HNOTIN:n ∉ l), n ∉ η\n:= begin\n intros,\n unfold env.has_only at H,\n intros H0,\n apply HNOTIN, rw H, assumption\nend\n\n-- get_value\n\nlemma get_value_replace: ∀ (ss:irstate_smt) (op:operand)\n (η:freevar.env) (t:ty),\n get_value irsem_smt (η⟦ss⟧) op t = η⟦get_value irsem_smt ss op t⟧'\n:= begin\n intros,\n cases op,\n { -- operand.reg\n cases op,\n unfold get_value,\n apply getreg_replace, refl\n },\n {\n cases op,\n cases t,\n {\n unfold get_value,\n have H0: decidable (0 < t), apply_instance,\n cases H0,\n { rw dif_neg, assumption },\n {\n rw dif_pos,\n simp,\n have H1: decidable (within_signed_range ⟨t, H0⟩ op), apply_instance,\n cases H1,\n {\n rw if_neg,\n {\n have H2: decidable (↑(int_min_nat ⟨t, H0⟩) ≤ op ∧ op ≤ ↑(all_one_nat ⟨t, H0⟩)),\n apply_instance,\n cases H2,\n { rw if_neg, apply H2 },\n { rw if_pos,\n unfold uint_like.from_z,\n unfold apply,\n unfold freevar.env.replace_valty,\n generalize HCONST: op + -↑(2^t) = c,\n cases c,\n { unfold sbitvec.of_int, unfold freevar.env.replace_sbv, refl },\n { unfold sbitvec.of_int, unfold freevar.env.replace_sbv, refl },\n assumption\n }\n },\n { assumption }\n },\n { rw if_pos,\n unfold uint_like.from_z,\n unfold apply,\n unfold freevar.env.replace_valty,\n cases op,\n { unfold sbitvec.of_int, unfold freevar.env.replace_sbv, refl },\n { unfold sbitvec.of_int, unfold freevar.env.replace_sbv, refl },\n assumption\n }\n }\n },\n { unfold get_value }\n }\nend\n\nend spec", "meta": {"author": "microsoft", "repo": "AliveInLean", "sha": "34370c2c15aa69f010d97b8d38e9e1955e9e387d", "save_path": "github-repos/lean/microsoft-AliveInLean", "path": "github-repos/lean/microsoft-AliveInLean/AliveInLean-34370c2c15aa69f010d97b8d38e9e1955e9e387d/src/spec/freevar.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5698526368038304, "lm_q2_score": 0.43782349911420193, "lm_q1q2_score": 0.24949487542490745}} {"text": "import category_theory.limits.shapes.kernels\n\nopen category_theory\n\nuniverses v\nnamespace category_theory.limits\n\nvariables {C D : Type*} [category.{v} C] [category.{v} D]\n [has_zero_morphisms C] [has_zero_morphisms D]\n\n/- These two lemmas are no longer used. -/\n\n@[simp, reassoc]\nlemma lift_map_inv_kernel_comparison {X Y Z : C} (f : Y ⟶ Z) [has_kernel f] (G : C ⥤ D)\n [G.preserves_zero_morphisms] [has_kernel (G.map f)] [is_iso (kernel_comparison f G)]\n {g : X ⟶ Y} (w : g ≫ f = 0) :\n kernel.lift (G.map f) (G.map g) (by simp only [← G.map_comp, w, functor.map_zero]) ≫\n category_theory.inv (kernel_comparison f G) = G.map (kernel.lift f g w) :=\nby simp [← cancel_mono (kernel_comparison f G)]\n\n@[simp, reassoc]\nlemma inv_cokernel_comparison_desc_map {X Y Z : C} (f : X ⟶ Y) [has_cokernel f] (G : C ⥤ D)\n [G.preserves_zero_morphisms] [has_cokernel (G.map f)] [is_iso (cokernel_comparison f G)]\n {g : Y ⟶ Z} (w : f ≫ g = 0) :\n category_theory.inv (cokernel_comparison f G) ≫\n cokernel.desc (G.map f) (G.map g) (by simp only [← G.map_comp, w, functor.map_zero]) =\n G.map (cokernel.desc f g w) :=\nby simp [← cancel_epi (cokernel_comparison f G)]\n\nend category_theory.limits\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/kernel_comparison.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6297746074044135, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.24943367392062057}} {"text": "import category_theory.sites.sheafification\n\nopen category_theory\nopen category_theory.limits\nopen opposite\n\nnamespace category_theory.Sheaf\n\nuniverses w v u\n\n-- All the classes we need for sheafification\nvariables\n {C : Type u} [category.{v} C]\n (J : grothendieck_topology C)\n {D : Type w} [category.{max v u} D] [concrete_category.{max v u} D]\n [preserves_limits (forget D)]\n [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.cover X), has_multiequalizer (S.index P)]\n [∀ (X : C), has_colimits_of_shape (J.cover X)ᵒᵖ D]\n [∀ (X : C), preserves_colimits_of_shape (J.cover X)ᵒᵖ (forget D)]\n [reflects_isomorphisms (forget D)]\n\nlemma is_iso_of_eval {F : Sheaf J D} {G : Cᵒᵖ ⥤ D}\n (γ : F ⟶ (presheaf_to_Sheaf _ _).obj G)\n (η : F.val ⟶ G)\n [∀ X : C, is_iso (η.app (op X))]\n (h : γ.val = η ≫ J.to_sheafify _) :\n is_iso γ :=\nbegin\n haveI : is_iso (J.to_sheafify F.val) :=\n grothendieck_topology.is_iso_to_sheafify J F.2,\n have : γ.val = (J.to_sheafify F.val) ≫ (J.sheafify_map η),\n { rw ← is_iso.inv_comp_eq,\n apply J.sheafify_hom_ext, apply Sheaf.cond,\n rw [← grothendieck_topology.to_sheafify_naturality, ← h],\n simp },\n suffices : is_iso ((Sheaf_to_presheaf _ _).map γ),\n { resetI, apply is_iso_of_fully_faithful (Sheaf_to_presheaf J D) },\n dsimp, rw this,\n suffices : is_iso (J.sheafify_map η),\n { resetI, apply is_iso.comp_is_iso },\n change is_iso ((Sheaf_to_presheaf _ _).map ((presheaf_to_Sheaf _ _).map η)),\n haveI : is_iso η,\n { apply_with nat_iso.is_iso_of_is_iso_app { instances := ff },\n intros X, tactic.op_induction', apply_instance },\n apply_instance,\n apply_instance,\nend\n\nend category_theory.Sheaf\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/map_to_sheaf_is_iso.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6297746074044134, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.24943367392062052}} {"text": "import .definitions3 .logic\n\nlemma strengthen_impl_with_dominating_instantiations {σ: env} {P P' Q: prop}:\n (σ ⊨ vc.implies P'.to_vc P.to_vc) → (σ ⊨ (prop.implies P Q).to_vc) → (σ ⊨ (prop.implies P' Q).to_vc) :=\n begin\n assume h1,\n assume h2,\n apply valid_env.to_vc_implies.mpr,\n apply valid_env.mpr,\n assume h3,\n have h4, from valid_env.mp h1 h3,\n have h5, from valid_env.to_vc_implies.mp h2,\n from valid_env.mp h5 h4\n end\n\nlemma strengthen_vc {P P' Q: prop} {σ: env}:\n (σ ⊨ vc.implies P'.to_vc P.to_vc) → (FV P ⊆ FV P') →\n (closed_subst σ (prop.implies P Q) → σ ⊨ (prop.implies P Q).to_vc) →\n (closed_subst σ (prop.implies P' Q) → σ ⊨ (prop.implies P' Q).to_vc) :=\n begin\n assume h1,\n assume h2,\n assume h3,\n assume h4,\n apply @strengthen_impl_with_dominating_instantiations σ P P' Q,\n from h1,\n\n have h5: closed_subst σ (prop.implies P Q), by begin\n assume x,\n assume h6,\n cases free_in_prop.implies.inv h6 with h7 h8,\n have h9: x ∈ FV P, from h7,\n have h10, from set.mem_of_mem_of_subset h9 h2,\n have h12: free_in_prop x (prop.implies P' Q), from free_in_prop.implies₁ h10,\n from h4 h12,\n\n have h12: free_in_prop x (prop.implies P' Q), from free_in_prop.implies₂ h8,\n from h4 h12\n end,\n from h3 h5\n end\n\nlemma strengthen_vc_with_q {P P' Q S: prop} {σ: env}:\n (σ ⊨ vc.implies P'.to_vc P.to_vc) → (FV P ⊆ FV P') →\n (closed_subst σ (prop.implies (P ⋀ Q) S) → σ ⊨ (prop.implies (P ⋀ Q) S).to_vc) →\n (closed_subst σ (prop.implies (P' ⋀ Q) S) → σ ⊨ (prop.implies (P' ⋀ Q) S).to_vc) :=\n begin\n assume h1,\n assume h2,\n assume h3,\n assume h4,\n apply @strengthen_impl_with_dominating_instantiations σ (P ⋀ Q) (P' ⋀ Q) S,\n from vc.implies.same_right (λ_, h1),\n have h5: closed_subst σ (prop.implies (P⋀Q) S), by begin\n assume x,\n assume h6,\n cases free_in_prop.implies.inv h6 with h7 h8,\n cases free_in_prop.and.inv h7 with h8 h9,\n have h9: x ∈ FV P, from h8,\n have h10, from set.mem_of_mem_of_subset h9 h2,\n have h11: free_in_prop x (P' ⋀ Q), from free_in_prop.and₁ h10,\n have h12: free_in_prop x (prop.implies (P' ⋀ Q) S), from free_in_prop.implies₁ h11,\n from h4 h12,\n\n\n have h11: free_in_prop x (P' ⋀ Q), from free_in_prop.and₂ h9,\n have h12: free_in_prop x (prop.implies (P' ⋀ Q) S), from free_in_prop.implies₁ h11,\n from h4 h12,\n\n have h12: free_in_prop x (prop.implies (P' ⋀ Q) S), from free_in_prop.implies₂ h8,\n from h4 h12\n end,\n from h3 h5\n end\n\nlemma strengthen_exp {P: prop} {Q: propctx} {e: exp}:\n (P ⊩ e : Q) → ∀P': prop, (FV P' = FV P) → (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc) → (P' ⊩ e: Q) :=\n assume e_verified: (P ⊩ e : Q),\n begin\n induction e_verified,\n case exp.dvcgen.tru x P e' Q x_not_free_in_P e'_verified ih { from (\n assume P': prop,\n assume free_P'_P: FV P' = FV P,\n assume P'_dominates_p_P: (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc),\n\n have h1: FV (P' ⋀ x ≡ value.true) = FV (P ⋀ x ≡ value.true),\n from free_in_prop.same_right free_P'_P,\n have h2: (∀σ, σ ⊨ vc.implies (P' ⋀ x ≡ value.true).to_vc (P ⋀ x ≡ value.true).to_vc),\n from λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ),\n have e'_verified': P' ⋀ x ≡ value.true ⊩ e': Q, from ih (P' ⋀ x ≡ value.true) h1 h2,\n have x_not_free_in_P': x ∉ FV P', from free_P'_P.symm ▸ x_not_free_in_P,\n show P' ⊩ lett x = true in e' : propctx.exis x (x ≡ value.true ⋀ Q),\n from exp.dvcgen.tru x_not_free_in_P' e'_verified'\n )},\n case exp.dvcgen.fals x P e' Q x_not_free_in_P e'_verified ih { from\n assume P': prop,\n assume free_P'_P: FV P' = FV P,\n assume P'_dominates_p_P: (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc),\n\n have h1: FV (P' ⋀ (x ≡ value.false)) = FV (P ⋀ x ≡ value.false),\n from free_in_prop.same_right free_P'_P,\n have h2: (∀σ, σ ⊨ vc.implies (P' ⋀ x ≡ value.false).to_vc (P ⋀ x ≡ value.false).to_vc),\n from λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ),\n have e'_verified': P' ⋀ x ≡ value.false ⊩ e': Q, from ih (P' ⋀ x ≡ value.false) h1 h2,\n have x_not_free_in_P': x ∉ FV P', from free_P'_P.symm ▸ x_not_free_in_P,\n show P' ⊩ letf x = false in e' : propctx.exis x ((x ≡ value.false) ⋀ Q),\n from exp.dvcgen.fals x_not_free_in_P' e'_verified'\n },\n case exp.dvcgen.num x n P e' Q x_not_free_in_P e'_verified ih { from\n assume P': prop,\n assume free_P'_P: FV P' = FV P,\n assume P'_dominates_p_P: (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc),\n\n have h1: FV (P' ⋀ x ≡ value.num n) = FV (P ⋀ x ≡ value.num n),\n from free_in_prop.same_right free_P'_P,\n have h2: (∀σ, σ ⊨ vc.implies (P' ⋀ x ≡ value.num n).to_vc (P ⋀ x ≡ value.num n).to_vc),\n from λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ),\n have e'_verified': P' ⋀ (x ≡ value.num n) ⊩ e': Q, from ih (P' ⋀ (x ≡ value.num n)) h1 h2,\n have x_not_free_in_P': x ∉ FV P', from free_P'_P.symm ▸ x_not_free_in_P,\n show P' ⊩ letn x = n in e' : propctx.exis x ((x ≡ value.num n) ⋀ Q),\n from exp.dvcgen.num x_not_free_in_P' e'_verified'\n },\n case exp.dvcgen.func f x R S e₁ e₂ P Q₁ Q₂ f_not_free_in_P x_not_free_in_P f_neq_x x_free_in_R fv_R fv_S\n e₁_verified e₂_verified func_vc ih₁ ih₂ { from\n assume P': prop,\n assume free_P'_P: FV P' = FV P,\n assume P'_dominates_p_P: (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc),\n\n have f_not_free_in_P': f ∉ FV P', from free_P'_P.symm ▸ f_not_free_in_P,\n have x_not_free_in_P': x ∉ FV P', from free_P'_P.symm ▸ x_not_free_in_P,\n have fv_R': FV R.to_prop ⊆ FV P' ∪ { f, x }, from free_P'_P.symm ▸ fv_R,\n have fv_S': FV S.to_prop ⊆ FV P' ∪ { f, x }, from free_P'_P.symm ▸ fv_S,\n\n have h1: FV (P' ⋀ ((spec.func f x R S) ⋀ R)) = FV (P ⋀ ((spec.func f x R S) ⋀ R)),\n from free_in_prop.same_right free_P'_P,\n have h2: (∀σ, σ ⊨ vc.implies (P' ⋀ (spec.func f x R S) ⋀ R).to_vc (P ⋀ (spec.func f x R S) ⋀ R).to_vc),\n from λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ),\n have e₁_verified': P' ⋀ (spec.func f x R S) ⋀ R ⊩ e₁ : Q₁,\n from ih₁ (P' ⋀ (spec.func f x R S) ⋀ R) h1 h2,\n\n have h3: FV (P' ⋀ (prop.func f x R (Q₁ (term.app ↑f ↑x) ⋀ ↑S)))\n = FV (P ⋀ (prop.func f x R (Q₁ (term.app ↑f ↑x) ⋀ ↑S))),\n from free_in_prop.same_right free_P'_P,\n\n have h5: (∀σ, σ ⊨ vc.implies (P' ⋀ (prop.func f x R (Q₁ (term.app ↑f ↑x) ⋀ ↑S))).to_vc\n (P ⋀ (prop.func f x R (Q₁ (term.app ↑f ↑x) ⋀ ↑S))).to_vc),\n from (λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ)),\n\n have e₂_verified': P' ⋀ (prop.func f x R (Q₁ (term.app ↑f ↑x) ⋀ ↑S)) ⊩ e₂ : Q₂,\n from ih₂ (P' ⋀ (prop.func f x R (Q₁ (term.app ↑f ↑x) ⋀ ↑S))) h3 h5,\n\n have func_vc': ∀ (σ : env),\n closed_subst σ (prop.implies (P'⋀↑(spec.func ↑f x R S) ⋀ R ⋀ Q₁ (term.app ↑f ↑x)) ↑S) →\n σ ⊨ (prop.implies (P' ⋀ ↑(spec.func ↑f x R S) ⋀ R ⋀ Q₁ (term.app ↑f ↑x)) ↑S).to_vc,\n from (λσ, strengthen_vc_with_q (P'_dominates_p_P σ) (set.subset_of_eq free_P'_P.symm) (func_vc σ)),\n\n show P' ⊩ letf f[x] req R ens S {e₁} in e₂ : propctx.exis f (prop.func f x R (Q₁ (term.app ↑f ↑x) ⋀ ↑S) ⋀ Q₂),\n from exp.dvcgen.func f_not_free_in_P' x_not_free_in_P' f_neq_x x_free_in_R fv_R' fv_S' e₁_verified'\n e₂_verified' func_vc'\n },\n case exp.dvcgen.unop op x y P e' Q' x_free_in_P y_not_free_in_P e'_verified vc_valid ih { from\n assume P': prop,\n assume free_P'_P: FV P' = FV P,\n assume P'_dominates_p_P: (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc),\n\n have x_free_in_P': x ∈ FV P', from free_P'_P.symm ▸ x_free_in_P,\n have y_not_free_in_P': y ∉ FV P', from free_P'_P.symm ▸ y_not_free_in_P,\n\n have h1: FV (P' ⋀ y ≡ term.unop op x) = FV (P ⋀ y ≡ term.unop op x),\n from free_in_prop.same_right free_P'_P,\n have h2: (∀σ, σ ⊨ vc.implies (P' ⋀ y ≡ term.unop op x).to_vc (P ⋀ y ≡ term.unop op x).to_vc),\n from (λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ)),\n have e'_verified': P' ⋀ y ≡ term.unop op x ⊩ e' : Q',\n from ih (P' ⋀ y ≡ term.unop op x) h1 h2,\n\n have FV P ⊆ FV P', from set.subset_of_eq free_P'_P.symm,\n have vc_valid': ∀ (σ : env),\n closed_subst σ (prop.implies P' (prop.pre₁ op x)) → σ ⊨ (prop.implies P' (prop.pre₁ op x)).to_vc,\n from (λσ, strengthen_vc (P'_dominates_p_P σ) this (vc_valid σ)),\n\n show P' ⊩ letop y = op [x] in e' : propctx.exis y (y ≡ term.unop op x ⋀ Q'),\n from exp.dvcgen.unop x_free_in_P' y_not_free_in_P' e'_verified' vc_valid'\n },\n case exp.dvcgen.binop op x y z e' P Q' x_free_in_P y_free_in_P z_not_free_in_P e'_verified vc_valid ih { from\n assume P': prop,\n assume free_P'_P: FV P' = FV P,\n assume P'_dominates_p_P: (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc),\n\n have x_free_in_P': x ∈ FV P', from free_P'_P.symm ▸ x_free_in_P,\n have y_free_in_P': y ∈ FV P', from free_P'_P.symm ▸ y_free_in_P,\n have z_not_free_in_P': z ∉ FV P', from free_P'_P.symm ▸ z_not_free_in_P,\n\n have h1: FV (P' ⋀ z ≡ term.binop op x y) = FV (P ⋀ z ≡ term.binop op x y),\n from free_in_prop.same_right free_P'_P,\n have h2: (∀σ, σ ⊨ vc.implies (P' ⋀ z ≡ term.binop op x y).to_vc (P ⋀ z ≡ term.binop op x y).to_vc),\n from (λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ)),\n have e'_verified': P' ⋀ z ≡ term.binop op x y ⊩ e' : Q',\n from ih (P' ⋀ z ≡ term.binop op x y) h1 h2,\n\n have FV P ⊆ FV P', from set.subset_of_eq free_P'_P.symm,\n have vc_valid': ∀ (σ : env),\n closed_subst σ (prop.implies P' (prop.pre₂ op x y)) →\n σ ⊨ (prop.implies P' (prop.pre₂ op x y)).to_vc,\n from (λσ, strengthen_vc (P'_dominates_p_P σ) this (vc_valid σ)),\n\n show P' ⊩ letop2 z = op [x, y] in e' : propctx.exis z (z ≡ term.binop op x y ⋀ Q'),\n from exp.dvcgen.binop x_free_in_P' y_free_in_P' z_not_free_in_P' e'_verified' vc_valid'\n },\n case exp.dvcgen.app y f x e' P Q' f_free_in_P x_free_in_P y_not_free_in_P e'_verified vc_valid ih { from\n assume P': prop,\n assume free_P'_P: FV P' = FV P,\n assume P'_dominates_p_P: (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc),\n\n have f_free_in_P': f ∈ FV P', from free_P'_P.symm ▸ f_free_in_P,\n have x_free_in_P': x ∈ FV P', from free_P'_P.symm ▸ x_free_in_P,\n have y_not_free_in_P': y ∉ FV P', from free_P'_P.symm ▸ y_not_free_in_P,\n\n have h1: FV (P' ⋀ prop.call x ⋀ prop.post f x ⋀ y ≡ term.app f x)\n = FV (P ⋀ prop.call x ⋀ prop.post f x ⋀ y ≡ term.app f x),\n from free_in_prop.same_right free_P'_P,\n\n have h2: (∀σ, σ ⊨ vc.implies (P' ⋀ prop.call x ⋀ prop.post f x ⋀ y ≡ term.app f x).to_vc\n (P ⋀ prop.call x ⋀ prop.post f x ⋀ y ≡ term.app f x).to_vc),\n from (λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ)),\n\n have e'_verified': P' ⋀ prop.call x ⋀ prop.post f x ⋀ y ≡ term.app f x ⊩ e' : Q',\n from ih (P' ⋀ prop.call x ⋀ prop.post f x ⋀ y ≡ term.app f x) h1 h2,\n\n have vc_valid': ∀ (σ : env),\n closed_subst σ (prop.implies (P' ⋀ prop.call x) (term.unop unop.isFunc f ⋀ prop.pre f x)) →\n σ ⊨ (prop.implies (P' ⋀ prop.call x) (term.unop unop.isFunc f ⋀ prop.pre f x)).to_vc,\n from (λσ, strengthen_vc_with_q (P'_dominates_p_P σ) (set.subset_of_eq free_P'_P.symm) (vc_valid σ)),\n\n show P' ⊩ letapp y = f [x] in e' : propctx.exis y (prop.call x ⋀ prop.post f x ⋀ y ≡ term.app f x ⋀ Q'),\n from exp.dvcgen.app f_free_in_P' x_free_in_P' y_not_free_in_P' e'_verified' vc_valid'\n },\n case exp.dvcgen.ite x e₂ e₁ P Q₁ Q₂ x_free_in_P e₁_verified e₂_verified vc_valid ih₁ ih₂ { from\n assume P': prop,\n assume free_P'_P: FV P' = FV P,\n assume P'_dominates_p_P: (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc),\n\n have x_free_in_P': x ∈ FV P', from free_P'_P.symm ▸ x_free_in_P,\n\n have h1: FV (P' ⋀ x) = FV (P ⋀ x), from free_in_prop.same_right free_P'_P,\n have h2: (∀σ, σ ⊨ vc.implies (P' ⋀ x).to_vc (P ⋀ x).to_vc),\n from (λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ)),\n have e₁_verified': P' ⋀ x ⊩ e₁ : Q₁, from ih₁ (P' ⋀ x) h1 h2,\n\n have h1: FV (P' ⋀ prop.not x) = FV (P ⋀ prop.not x), from free_in_prop.same_right free_P'_P,\n have h2: (∀σ, σ ⊨ vc.implies (P' ⋀ prop.not x).to_vc (P ⋀ prop.not x).to_vc),\n from (λσ, vc.implies.same_right (λ_, P'_dominates_p_P σ)),\n have e₂_verified': P' ⋀ prop.not x ⊩ e₂ : Q₂, from ih₂ (P' ⋀ prop.not x) h1 h2,\n\n have FV P ⊆ FV P', from set.subset_of_eq free_P'_P.symm,\n have vc_valid': ∀ (σ : env),\n closed_subst σ (prop.implies P' (term.unop unop.isBool x)) →\n σ ⊨ (prop.implies P' (term.unop unop.isBool x)).to_vc,\n from (λσ, strengthen_vc (P'_dominates_p_P σ) this (vc_valid σ)),\n\n show P' ⊩ exp.ite x e₁ e₂ : propctx.implies x Q₁ ⋀ propctx.implies (prop.not x) Q₂,\n from exp.dvcgen.ite x_free_in_P' e₁_verified' e₂_verified' vc_valid'\n },\n case exp.dvcgen.return x P x_free_in_P { from\n assume P': prop,\n assume free_P'_P: FV P' = FV P,\n assume P'_dominates_p_P: (∀σ, σ ⊨ vc.implies P'.to_vc P.to_vc),\n\n have x_free_in_P': x ∈ FV P', from free_P'_P.symm ▸ x_free_in_P,\n\n show P' ⊩ exp.return x : (x ≣ •), from exp.dvcgen.return x_free_in_P'\n }\n end\n", "meta": {"author": "levjj", "repo": "esverify-theory", "sha": "8565b123c87b0113f83553d7732cd6696c9b5807", "save_path": "github-repos/lean/levjj-esverify-theory", "path": "github-repos/lean/levjj-esverify-theory/esverify-theory-8565b123c87b0113f83553d7732cd6696c9b5807/src/strengthening.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5544704796847396, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.24917494959846412}} {"text": "import ReactorModel.Objects.Reactor.Updatable\nimport Mathlib.Tactic.Set\n\nnoncomputable section\nopen Classical\nopen Reactor (Component)\n\nnamespace ReactorType\n\ndef UniqueIDs [ReactorType α] (rtr : α) : Prop :=\n ∀ {cpt i}, Subsingleton (Member cpt i rtr)\n\nclass Indexable (α) extends LawfulUpdatable α where\n unique_ids : ∀ {rtr : α}, UniqueIDs rtr\n\nstructure Container (α) where\n id : WithTop ID \n rtr : α \n\ninstance [Coe α β] : Coe (Container α) (Container β) where\n coe i := { id := i.id, rtr := i.rtr }\n\nnamespace Member\n\nvariable [LawfulUpdatable α] \n\ndef container {rtr : α} : (Member cpt i rtr) → Container α\n | .nest _ (.nest h l) => container (.nest h l)\n | .nest (rtr₂ := con) (j := j) .. => { id := j, rtr := con }\n | .final _ => { id := ⊤, rtr := rtr }\n\ntheorem nest_container {rtr₁ rtr₂ : α} \n (h : ReactorType.nest rtr₁ i = some rtr₂) (m : Member cpt j rtr₂) : \n ∃ (k : ID) (con : α), (Member.nest h m).container = ⟨k, con⟩ := by\n induction m generalizing i rtr₁\n case final => simp [container]\n case nest hn _ hi => simp [container, hi hn]\n\ntheorem container_eq_root {rtr : α} {m : Member cpt i rtr} (h : m.container = ⟨⊤, con⟩) : \n rtr = con := by\n induction m generalizing con\n case final => \n simp [container] at h\n assumption\n case nest hn m _ =>\n have ⟨_, _, _⟩ := nest_container hn m\n simp_all\n\nend Member\n\nnamespace Indexable\n\nvariable [a : Indexable α]\n\ndef con? (rtr : α) (cpt : Component) : ID ⇀ Container α := \n fun i => if m : Nonempty (Member cpt i rtr) then m.some.container else none\n\nnotation rtr \"[\" cpt \"]&\" => ReactorType.Indexable.con? rtr cpt\nnotation rtr \"[\" cpt \"][\" i \"]&\" => ReactorType.Indexable.con? rtr cpt i\n\ndef obj? (rtr : α) : (cpt : Component) → cpt.idType ⇀ a.cptType cpt\n | .val cpt, i => rtr[.val cpt][i]& >>= fun con => cpt? (.val cpt) con.rtr i\n | .rcn, i => rtr[.rcn][i]& >>= fun con => cpt? .rcn con.rtr i\n | .rtr, (i : ID) => rtr[.rtr][i]& >>= fun con => cpt? .rtr con.rtr i\n | .rtr, ⊤ => rtr\n\nnotation (priority := 1001) rtr \"[\" cpt \"]\" => ReactorType.Indexable.obj? rtr cpt\nnotation rtr \"[\" cpt \"][\" i \"]\" => ReactorType.Indexable.obj? rtr cpt i\n\nvariable {rtr rtr₁ rtr₂ : α}\n\nend Indexable\nend ReactorType", "meta": {"author": "marcusrossel", "repo": "reactor-model", "sha": "f82fffb489b4352a0cc6bee964d44a142fee18ce", "save_path": "github-repos/lean/marcusrossel-reactor-model", "path": "github-repos/lean/marcusrossel-reactor-model/reactor-model-f82fffb489b4352a0cc6bee964d44a142fee18ce/src/ReactorModel/Objects/Reactor/Indexable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.43398146480389854, "lm_q1q2_score": 0.24896579559260787}} {"text": "import category_theory.adjunction.basic\nimport category_theory.limits.has_limits\nimport data.pfun\n\nopen category_theory category_theory.functor category_theory.limits\nuniverses u v\nvariables (𝒞 : Type) [category.{0} 𝒞]\n\ninductive bicompletion_aux : bool → Type 1\n| of_cat_obj : 𝒞 → bicompletion_aux ff\n| limit_obj {D : Type} (F : D → bicompletion_aux tt) : bicompletion_aux ff\n| colimit_obj {D : Type} (F : D → bicompletion_aux tt) : bicompletion_aux ff\n| of_cat_hom : Π {X Y : 𝒞}, (X ⟶ Y) → bicompletion_aux tt -- of_cat_obj X ⟶ of_cat_obj Y\n| limit_cone_comp {D : Type} (F : D → bicompletion_aux tt) \n (X : D) (Y : bicompletion_aux ff) (f : bicompletion_aux tt) : -- F_obj X ⟶ Y\n bicompletion_aux tt -- limit_obj F ⟶ Y\n| colimit_cocone_comp {D : Type} (F : D → bicompletion_aux tt) \n (X : D) (Y : bicompletion_aux ff) (f : bicompletion_aux tt) : -- Y ⟶ F_obj X\n bicompletion_aux tt -- Y ⟶ colimit_obj F\n| is_limit {D : Type} (F : D → bicompletion_aux tt) \n (cone_obj : bicompletion_aux ff)\n (cone : Π (X : D), bicompletion_aux tt) : -- cone_obj ⟶ F_obj X\n bicompletion_aux tt -- cone_obj → limit_obj F\n| is_colimit {D : Type} (F : D → bicompletion_aux tt) \n (cocone_obj : bicompletion_aux ff)\n (cocone : Π (X : D), bicompletion_aux tt) : -- F_obj X ⟶ cocone_obj\n bicompletion_aux tt -- colimit_obj F ⟶ cocone_obj\n| id (X : bicompletion_aux ff) : bicompletion_aux tt -- X ⟶ X\n\nnamespace bicompletion_aux\n\nvariable {𝒞}\n\n@[simp] def dom : Π (X : bicompletion_aux 𝒞 tt), bicompletion_aux 𝒞 ff\n| (@of_cat_hom _ _ X Y f) := of_cat_obj X \n| (@limit_cone_comp _ _ _ F _ _ _) := by exactI limit_obj F\n| (@is_limit _ _ _ _ cone_obj _) := cone_obj\n| (@colimit_cocone_comp _ _ _ _ X Y f) := Y\n| (@is_colimit _ _ _ F cocone_obj cocone) := by exactI colimit_obj F\n| (id X) := X\n\n@[simp] def cod : Π (X : bicompletion_aux 𝒞 tt), bicompletion_aux 𝒞 ff\n| (@of_cat_hom _ _ X Y f) := of_cat_obj Y \n| (@colimit_cocone_comp _ _ 𝒟 F X _ _) := by exactI colimit_obj F\n| (@is_colimit _ _ 𝒟 F cocone_obj cocone) := cocone_obj\n| (@limit_cone_comp _ _ 𝒟 F X Y f) := Y\n| (@is_limit _ _ 𝒟 F cone_obj cone) := by exactI limit_obj F\n| (id X) := X\n\nopen sum\n\ninductive valid : bicompletion_aux 𝒞 ff ⊕ bicompletion_aux 𝒞 tt → Type 1\n| of_cat_obj : Π (X : 𝒞), valid (inl (of_cat_obj X))\n| limit_obj {D : Type} (F : D → bicompletion_aux 𝒞 tt) (hF : Π (X : D), valid (inr (F X))) :\n valid (inl (limit_obj F))\n| colimit_obj {D : Type} (F : D → bicompletion_aux 𝒞 tt) (hF : Π (X : D), valid (inr (F X))) :\n valid (inl (colimit_obj F))\n| limit_cone_comp {D : Type} (F : D → bicompletion_aux 𝒞 tt)\n (hF : Π (X : D), valid (inr (F X))) \n (X : D) (Y : bicompletion_aux 𝒞 ff) \n (hY : valid (inl Y))\n (f : bicompletion_aux 𝒞 tt) \n (hf : valid (inr f))\n (hfd : f.dom = (F X).dom)\n (hfc : f.cod = Y)\n\n : -- F_obj X ⟶ Y\n bicompletion_aux tt -- limit_obj F ⟶ Y\n\nvariable (𝒞)\n\ndef obj₁ : Type 1 := bicompletion_aux 𝒞 ff\n\nvariable {𝒞}\nvariables {D : Type} [category.{0} 𝒟]\n\ndef hom₁ (X Y : obj₁ 𝒞) : Type 1 :=\n{ f : bicompletion_aux 𝒞 tt // f.dom = X ∧ f.cod = Y }\n\n@[simp] lemma coe_dom {X Y : obj₁ 𝒞} (f : hom₁ X Y) :\n (@coe { f : bicompletion_aux 𝒞 tt // f.dom = X ∧ f.cod = Y } \n (bicompletion_aux 𝒞 tt) _ f).dom = X := f.2.1\n\n@[simp] lemma coe_cod {X Y : obj₁ 𝒞} (f : hom₁ X Y) :\n (@coe { f : bicompletion_aux 𝒞 tt // f.dom = X ∧ f.cod = Y } \n (bicompletion_aux 𝒞 tt) _ f).cod = Y := f.2.2\n\ndef of_cat_obj₁ (X : 𝒞) : obj₁ 𝒞 := of_cat_obj X\n\ndef limit_obj₁ (F_obj : 𝒟 → obj₁ 𝒞) \n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y)) : obj₁ 𝒞 :=\nlimit_obj _\n\ndef colimit_obj₁ (F_obj : 𝒟 → obj₁ 𝒞) \n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y)) : obj₁ 𝒞 :=\ncolimit_obj F_obj (λ X Y f, (F_hom f).1)\n\ndef of_cat_hom₁ {X Y : 𝒞} (f : X ⟶ Y) : hom₁ (of_cat_obj X) (of_cat_obj Y) :=\n⟨of_cat_hom f, by simp⟩\n\ndef limit_cone_comp₁ (F_obj : 𝒟 → obj₁ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y)) (X : 𝒟) \n {Y : obj₁ 𝒞} (f : hom₁ (F_obj X) Y) :\n hom₁ (limit_obj₁ F_obj @F_hom) Y :=\n⟨limit_cone_comp F_obj (λ X Y f, (F_hom f).1) X Y f.1, by simp [limit_obj₁]⟩\n\ndef colimit_cocone_comp₁ (F_obj : 𝒟 → obj₁ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y)) (X : 𝒟) \n {Y : obj₁ 𝒞} (f : hom₁ Y (F_obj X)) :\n hom₁ Y (colimit_obj₁ F_obj @F_hom) :=\n⟨colimit_cocone_comp F_obj (λ X Y f, (F_hom f).1) X Y f.1, by simp [colimit_obj₁]⟩\n\ndef is_limit₁ (F_obj : 𝒟 → obj₁ 𝒞) \n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y))\n (cone_obj : obj₁ 𝒞)\n (cone : Π (X : 𝒟), hom₁ cone_obj (F_obj X)) :\n hom₁ cone_obj (limit_obj₁ F_obj @F_hom) :=\n⟨is_limit F_obj (λ X Y f, (F_hom f).1) cone_obj (λ X, (cone X).1), by simp [limit_obj₁]⟩\n\ndef is_colimit₁ (F_obj : 𝒟 → obj₁ 𝒞) \n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y))\n (cocone_obj : obj₁ 𝒞)\n (cocone : Π (X : 𝒟), hom₁ (F_obj X) cocone_obj) :\n hom₁ (colimit_obj₁ F_obj @F_hom) cocone_obj :=\n⟨is_colimit F_obj (λ X Y f, (F_hom f).1) cocone_obj (λ X, (cocone X).1), by simp [colimit_obj₁]⟩\n\ndef id₁ (X : obj₁ 𝒞) : hom₁ X X := ⟨id X, rfl, rfl⟩\n\n@[elab_as_eliminator] def bicompletion_tt_rec_on \n {motive : bicompletion_aux 𝒞 tt → Sort u} \n (f : bicompletion_aux 𝒞 tt)\n (of_cat_hom : Π {X Y : 𝒞} (f : X ⟶ Y), motive (of_cat_hom f))\n (limit_cone_comp : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → bicompletion_aux 𝒞 ff)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → bicompletion_aux 𝒞 tt) (X : 𝒟) (Y : bicompletion_aux 𝒞 ff)\n (f : bicompletion_aux 𝒞 tt)\n (ih : Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f)),\n motive f → by exactI motive (limit_cone_comp F_obj @F_hom X Y f))\n (colimit_cone_comp : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → bicompletion_aux 𝒞 ff)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → bicompletion_aux 𝒞 tt) (X : 𝒟) (Y : bicompletion_aux 𝒞 ff)\n (f : bicompletion_aux 𝒞 tt)\n (ih : Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f)),\n motive f → by exactI motive (colimit_cocone_comp F_obj @F_hom X Y f))\n (is_limit : Π {𝒟 : Type} [_inst_2 : category 𝒟] (F_obj : 𝒟 → bicompletion_aux 𝒞 ff)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → bicompletion_aux 𝒞 tt) (cone_obj : bicompletion_aux 𝒞 ff)\n (cone : 𝒟 → bicompletion_aux 𝒞 tt)\n (ih_F_hom : Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f))\n (ih_cone : Π (X : 𝒟), motive (cone X)), \n by exactI motive (is_limit F_obj @F_hom cone_obj cone))\n (is_colimit : Π {𝒟 : Type} [_inst_2 : category 𝒟] (F_obj : 𝒟 → bicompletion_aux 𝒞 ff)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → bicompletion_aux 𝒞 tt) (cone_obj : bicompletion_aux 𝒞 ff)\n (cone : 𝒟 → bicompletion_aux 𝒞 tt)\n (ih_F_hom : Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f))\n (ih_cone : Π (X : 𝒟), motive (cone X)), \n by exactI motive (is_colimit F_obj @F_hom cone_obj cone))\n (id : Π (X : bicompletion_aux 𝒞 ff), motive X.id) :\n motive f := sorry\n\ndef comp₁ (f : bicompletion_aux 𝒞 tt) : bicompletion_aux 𝒞 tt → part (bicompletion_aux 𝒞 tt) :=\nbicompletion_tt_rec_on f \n begin\n intros X Y f g,\n refine bicompletion_tt_rec_on g _ _ _ _ _ _,\n { intros B C g,\n exact ⟨Y = B, λ h, by subst h; exact of_cat_hom (f ≫ g)⟩ },\n { intros, exact part.none },\n { introsI 𝒟 _ F_obj F_hom A B g ih₁ ih₂,\n exact ih₂ >>= λ ih₂, return (colimit_cocone_comp F_obj @F_hom A B ih₂) },\n { introsI 𝒟 _ F_obj F_hom A cone ih₁ ih₂, \n exact ⟨∀ (X : 𝒟), (ih₂ X).dom, λ h, is_limit F_obj @F_hom (of_cat_obj X) (λ X, (ih₂ X).get (h X))⟩ },\n { intros, exact part.none },\n { intros, exact return (of_cat_hom f) }\n end \n begin\n introsI 𝒟 _ F_obj F_hom A B f _ ih₂ g,\n exact ih₂ g >>= λ ih₂, return (limit_cone_comp F_obj @F_hom A B ih₂)\n end\n begin\n introsI 𝒟 _ F_obj F_hom A B f ih₁ ih₂ g,\n revert ih₂ A,\n refine bicompletion_tt_rec_on g _ _ _ _ _ _,\n { intros, exact part.none },\n { intros, exact part.none },\n { introsI ℰ _ G_obj G_hom C Y g ih₃ ih₄ ih₂ A,\n exact ih₄ ih₂ A >>= λ ih₄, return (colimit_cocone_comp G_obj @G_hom C Y ih₄) },\n { introsI ℰ _ G_obj G_hom _ g ih₃ ih₄ ih₂ A,\n exact ⟨Π (X : ℰ), (ih₄ X ih₂ A).dom, \n λ h, is_limit G_obj @G_hom B (λ X, (ih₄ X ih₂ A).get (h X))⟩ },\n { introsI ℰ _ G_obj G_hom cocone_obj cocone _ g ih₂ A,\n exact ih₂ (cocone A) },\n { intros A f _,\n exact colimit_cocone_comp₂ F_obj @F_hom A f }\n end\n _ _ (λ _, return)\n -- begin\n -- introsI 𝒟 _ F_obj F_hom ih₁ cone_obj cone ih₂ Z g,\n -- revert ih₂,\n -- refine hom₂_limit_obj_rec_on g _ _ _ _,\n -- { introsI ℰ _ G_obj G_hom A B g ih₂,\n -- exact ih₂ A g },\n -- { introsI ℰ _ F_obj F_hom A ℱ _ G_obj G_hom g ih₃ ih₂,\n -- exact colimit_cocone_comp₂ F_obj @F_hom A (ih₃ @ih₂) },\n -- { introsI ℰ _ F_obj F_hom ℱ _ G_obj G_hom ih₃ ih₄ ih₂,\n -- exact is_limit₂ F_obj @F_hom cone_obj (λ X, ih₄ _ @ih₂) },\n -- { introsI ih,\n -- exact is_limit₂ F_obj @F_hom cone_obj cone }\n -- end\n -- begin\n -- introsI 𝒟 _ F_obj F_hom ih₁ cocone_obj cocone ih₂ Z g,\n -- exact is_colimit₂ F_obj @F_hom Z (λ A, ih₂ A g)\n -- end\n -- (λ _ _ g, g)\n\ninductive valid_obj₁ : Π (X : obj₁ 𝒞), Prop\n| of_cat_obj (X : 𝒞) : valid_obj₁ (of_cat_obj X)\n| limit_obj {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → obj₁ 𝒞) \n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y)) \n (h : Π X : 𝒟, valid_obj₁ (F_obj X)) : \n valid_obj₁ (limit_obj₁ F_obj @F_hom)\n| colimit_obj {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → obj₁ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y))\n (h : Π X : 𝒟, valid_obj₁ (F_obj X)) :\n valid_obj₁ (colimit_obj₁ F_obj @F_hom)\n\ndef valid_obj₁_limit_obj \n {𝒟 : Type} [category.{0} 𝒟] {F_obj : 𝒟 → obj₁ 𝒞}\n {F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → bicompletion_aux 𝒞 tt}\n (h : valid_obj₁ (limit_obj F_obj @F_hom)) :\n Π (X : 𝒟), valid_obj₁ (F_obj X) :=\nbegin\n generalize hX : limit_obj F_obj @F_hom = X,\n rw hX at h,\n induction h,\n { simp * at * },\n { simp [limit_obj₁] at hX,\n rcases hX with ⟨hX₁, hX₂, hX₂, hX₄⟩,\n subst hX₁,\n simp at *,\n subst hX₂,\n assumption },\n { simp [*, colimit_obj₁] at * }\nend\n\ndef valid_obj₁_colimit_obj \n {𝒟 : Type} [category.{0} 𝒟] {F_obj : 𝒟 → obj₁ 𝒞}\n {F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → bicompletion_aux 𝒞 tt}\n (h : valid_obj₁ (colimit_obj F_obj @F_hom)) :\n Π (X : 𝒟), valid_obj₁ (F_obj X) :=\nbegin\n generalize hX : colimit_obj F_obj @F_hom = X,\n rw hX at h,\n induction h,\n { simp * at * },\n { simp [*, limit_obj₁] at * },\n { simp [colimit_obj₁] at hX,\n rcases hX with ⟨hX₁, hX₂, hX₂, hX₄⟩,\n subst hX₁,\n simp at *,\n subst hX₂,\n assumption }\nend\n\n@[elab_as_eliminator] def hom_rec_on {motive : bicompletion_aux 𝒞 tt → Sort u}\n (f : bicompletion_aux 𝒞 tt)\n (of_cat_hom : Π {X Y : 𝒞} (f : X ⟶ Y), motive (of_cat_hom f))\n (limit_cone_comp : Π {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → bicompletion_aux 𝒞 ff)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → bicompletion_aux 𝒞 tt) (X : 𝒟) (Y : bicompletion_aux 𝒞 ff)\n (f : bicompletion_aux 𝒞 tt),\n (Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f)) →\n motive f → motive (by exactI limit_cone_comp F_obj @F_hom X Y f))\n (is_limit : Π {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → bicompletion_aux 𝒞 ff)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → bicompletion_aux 𝒞 tt) (cone_obj : bicompletion_aux 𝒞 ff)\n (cone : 𝒟 → bicompletion_aux 𝒞 tt),\n (Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f)) →\n (Π (X : 𝒟), motive (cone X)) → motive (by exactI is_limit F_obj @F_hom cone_obj cone))\n (colimit_cocone_comp : Π {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → bicompletion_aux 𝒞 ff)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → bicompletion_aux 𝒞 tt) (X : 𝒟) (Y : bicompletion_aux 𝒞 ff)\n (f : bicompletion_aux 𝒞 tt),\n (Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f)) →\n motive f → motive (by exactI colimit_cocone_comp F_obj @F_hom X Y f))\n (is_colimit : Π {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → bicompletion_aux 𝒞 ff)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → bicompletion_aux 𝒞 tt) (cocone_obj : bicompletion_aux 𝒞 ff)\n (cocone : 𝒟 → bicompletion_aux 𝒞 tt),\n (Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f)) →\n (Π (X : 𝒟), motive (cocone X)) → motive (by exactI is_colimit F_obj @F_hom cocone_obj cocone))\n (id : Π (X : obj₁ 𝒞), motive (id X)) :\n motive f :=\nhave ∀ b (f : bicompletion_aux 𝒞 b) (h : b = tt), motive (eq.rec_on h f) :=\n begin\n intros b f,\n refine bicompletion_aux.rec_on f _ _ _ _ _ _ _ _ _,\n { intros, simp at *, contradiction },\n { intros, simp at *, contradiction },\n { intros, simp at *, contradiction },\n { intros X Y f _,\n exact of_cat_hom f },\n { introsI 𝒟 _ F_obj F_hom X Y f ih₁ ih₂ ih₃ ih₄ _,\n exact limit_cone_comp F_obj @F_hom X Y f (λ X Y f, ih₂ f rfl) (ih₄ rfl) },\n { introsI 𝒟 _ F_obj F_hom X Y f ih₁ ih₂ ih₃ ih₄ _,\n exact colimit_cocone_comp F_obj @F_hom X Y f (λ X Y f, ih₂ f rfl) (ih₄ rfl) },\n { introsI 𝒟 _ F_obj F_hom cone_obj cone ih₁ ih₂ ih₃ ih₄ _,\n exact is_limit F_obj @F_hom cone_obj cone (λ X Y f, ih₂ f rfl) (λ X, ih₄ X rfl) },\n { introsI 𝒟 _ F_obj F_hom cone_obj cone ih₁ ih₂ ih₃ ih₄ _,\n exact is_colimit F_obj @F_hom cone_obj cone (λ X Y f, ih₂ f rfl) (λ X, ih₄ X rfl) },\n { intros X _ _, exact id X }\n end,\nthis tt f rfl\n\ninductive valid_hom₁ : Π {X Y : obj₁ 𝒞}, hom₁ X Y → Prop\n| of_cat_hom {X Y : 𝒞} (f : X ⟶ Y) : valid_hom₁ (of_cat_hom₁ f)\n| id (X : obj₁ 𝒞) : valid_hom₁ (id₁ X)\n| limit_cone_comp {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → obj₁ 𝒞)\n (obj_valid : ∀ X, valid_obj₁ (F_obj X))\n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y)) \n (X : 𝒟) {Y : obj₁ 𝒞} (f : hom₁ (F_obj X) Y) \n (F_hom_valid : Π {X Y : 𝒟} (f : X ⟶ Y), valid_hom₁ (F_hom f))\n (f_valid : valid_hom₁ f) :\n valid_hom₁ (limit_cone_comp₁ F_obj @F_hom X f)\n| colimit_cocone_comp {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → obj₁ 𝒞)\n (obj_valid : ∀ X, valid_obj₁ (F_obj X))\n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y)) \n (X : 𝒟) {Y : obj₁ 𝒞} (f : hom₁ Y (F_obj X)) \n (F_hom_valid : Π {X Y : 𝒟} (f : X ⟶ Y), valid_hom₁ (F_hom f))\n (f_valid : valid_hom₁ f) :\n valid_hom₁ (colimit_cocone_comp₁ F_obj @F_hom X f)\n| is_limit {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → obj₁ 𝒞)\n (obj_valid : ∀ X, valid_obj₁ (F_obj X))\n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y))\n (cone_obj : obj₁ 𝒞)\n (cone : Π (X : 𝒟), hom₁ cone_obj (F_obj X)) \n (F_hom_valid : Π {X Y : 𝒟} (f : X ⟶ Y), valid_hom₁ (F_hom f))\n (cone_valid : Π (X : 𝒟), valid_hom₁ (cone X)) :\n valid_hom₁ (is_limit₁ F_obj @F_hom cone_obj cone)\n| is_colimit {𝒟 : Type} [category.{0} 𝒟] (F_obj : 𝒟 → obj₁ 𝒞)\n (obj_valid : ∀ X, valid_obj₁ (F_obj X))\n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₁ (F_obj X) (F_obj Y))\n (cocone_obj : obj₁ 𝒞)\n (cocone : Π (X : 𝒟), hom₁ (F_obj X) cocone_obj) \n (F_hom_valid : Π {X Y : 𝒟} (f : X ⟶ Y), valid_hom₁ (F_hom f))\n (cocone_valid : Π (X : 𝒟), valid_hom₁ (cocone X)) :\n valid_hom₁ (is_colimit₁ F_obj @F_hom cocone_obj cocone)\n\nvariable (𝒞)\n\ndef obj₂ : Type 1 := { X : obj₁ 𝒞 // valid_obj₁ X } \n\nvariable {𝒞}\n\ndef hom₂ (X Y : obj₂ 𝒞) : Type 1 := { f : hom₁ X.1 Y.1 // valid_hom₁ f }\n\nopen valid_hom₁\n\ndef of_cat_obj₂ (X : 𝒞) : obj₂ 𝒞 :=\n⟨of_cat_obj X, valid_obj₁.of_cat_obj _⟩ \n\nlemma of_cat_obj₂_injective : function.injective (@of_cat_obj₂ 𝒞 _) :=\nbegin\n intros X Y hXY,\n simp [of_cat_obj₂] at hXY,\n injection hXY,\nend\n\ndef limit_obj₂ (F_obj : 𝒟 → obj₂ 𝒞) \n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)) : obj₂ 𝒞 :=\n⟨limit_obj₁ (λ X, (F_obj X).1) (λ X Y f, (F_hom f).1), valid_obj₁.limit_obj _ _ (λ X, (F_obj X).2)⟩\n\nlemma limit_obj₂_injective {𝒟₁ 𝒟₂ : Type} [i₁ : category 𝒟₁] [i₂ : category 𝒟₂] \n {F_obj₁ : 𝒟₁ → obj₂ 𝒞} {F_obj₂ : 𝒟₂ → obj₂ 𝒞} \n {F_hom₁ : Π {X Y : 𝒟₁}, (X ⟶ Y) → hom₂ (F_obj₁ X) (F_obj₁ Y)}\n {F_hom₂ : Π {X Y : 𝒟₂}, (X ⟶ Y) → hom₂ (F_obj₂ X) (F_obj₂ Y)}\n (h : limit_obj₂ F_obj₁ @F_hom₁ = limit_obj₂ F_obj₂ @F_hom₂) : \n 𝒟₁ = 𝒟₂ ∧ i₁ == i₂ ∧ F_obj₁ == F_obj₂ ∧ @F_hom₁ == @F_hom₂ :=\nbegin\n simp [limit_obj₂, limit_obj₁] at h,\n injection h with h₁ h₂ h₃ h₄,\n unfreezingI { subst h₁ },\n rw heq_iff_eq at h₂,\n unfreezingI { subst h₂ },\n simp [heq_iff_eq, function.funext_iff, subtype.coe_injective.eq_iff] at h₃,\n rw [← function.funext_iff] at h₃,\n dsimp at h₃,\n subst h₃,\n simp [heq_iff_eq, function.funext_iff, subtype.coe_injective.eq_iff] at h₄,\n simp,\n ext,\n simp *\nend\n\ndef colimit_obj₂ (F_obj : 𝒟 → obj₂ 𝒞) \n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)) : obj₂ 𝒞 :=\n⟨colimit_obj₁ (λ X, (F_obj X).1) (λ X Y f, (F_hom f).1), valid_obj₁.colimit_obj _ _ (λ X, (F_obj X).2)⟩\n\nlemma colimit_obj₂_injective {𝒟₁ 𝒟₂ : Type} [i₁ : category 𝒟₁] [i₂ : category 𝒟₂] \n {F_obj₁ : 𝒟₁ → obj₂ 𝒞} {F_obj₂ : 𝒟₂ → obj₂ 𝒞} \n {F_hom₁ : Π {X Y : 𝒟₁}, (X ⟶ Y) → hom₂ (F_obj₁ X) (F_obj₁ Y)}\n {F_hom₂ : Π {X Y : 𝒟₂}, (X ⟶ Y) → hom₂ (F_obj₂ X) (F_obj₂ Y)}\n (h : colimit_obj₂ F_obj₁ @F_hom₁ = colimit_obj₂ F_obj₂ @F_hom₂) : \n 𝒟₁ = 𝒟₂ ∧ i₁ == i₂ ∧ F_obj₁ == F_obj₂ ∧ @F_hom₁ == @F_hom₂ :=\nbegin\n simp [colimit_obj₂, colimit_obj₁] at h,\n injection h with h₁ h₂ h₃ h₄,\n unfreezingI { subst h₁ },\n rw heq_iff_eq at h₂,\n unfreezingI { subst h₂ },\n simp [heq_iff_eq, function.funext_iff, subtype.coe_injective.eq_iff] at h₃,\n rw [← function.funext_iff] at h₃,\n dsimp at h₃,\n subst h₃,\n simp [heq_iff_eq, function.funext_iff, subtype.coe_injective.eq_iff] at h₄,\n simp,\n ext,\n simp *\nend\n\ndef of_cat_hom₂ {X Y : 𝒞} (f : X ⟶ Y) : hom₂ (of_cat_obj₂ X) (of_cat_obj₂ Y) :=\n⟨of_cat_hom₁ f, valid_hom₁.of_cat_hom _⟩ \n\ndef limit_cone_comp₂ (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)) (X : 𝒟) \n {Y : obj₂ 𝒞} (f : hom₂ (F_obj X) Y) :\n hom₂ (limit_obj₂ F_obj @F_hom) Y :=\n⟨limit_cone_comp₁ (λ X, (F_obj X).1) (λ X Y f, (F_hom f).1) X f.1, \n valid_hom₁.limit_cone_comp _ (λ X, (F_obj X).2) _ _ _ (λ X Y f, (F_hom f).2) f.2⟩\n\ndef colimit_cocone_comp₂ (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)) (X : 𝒟) \n {Y : obj₂ 𝒞} (f : hom₂ Y (F_obj X)):\n hom₂ Y (colimit_obj₂ F_obj @F_hom) :=\n⟨colimit_cocone_comp₁ (λ X, (F_obj X).1) (λ X Y f, (F_hom f).1) X f.1, \n valid_hom₁.colimit_cocone_comp _ (λ X, (F_obj X).2) _ _ _ (λ X Y f, (F_hom f).2) f.2⟩\n\ndef is_limit₂ (F_obj : 𝒟 → obj₂ 𝒞) \n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n (cone_obj : obj₂ 𝒞)\n (cone : Π (X : 𝒟), hom₂ cone_obj (F_obj X)) :\n hom₂ cone_obj (limit_obj₂ F_obj @F_hom) :=\n⟨is_limit₁ (λ X, (F_obj X).1) (λ X Y f, (F_hom f).1) cone_obj.1 (λ X, (cone X).1), \n valid_hom₁.is_limit _ (λ X, (F_obj X).2) _ _ _ (λ X Y f, (F_hom f).2) (λ X, (cone X).2)⟩\n\ndef is_colimit₂ (F_obj : 𝒟 → obj₂ 𝒞) \n (F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n (cocone_obj : obj₂ 𝒞)\n (cocone : Π (X : 𝒟), hom₂ (F_obj X) cocone_obj) :\n hom₂ (colimit_obj₂ F_obj @F_hom) cocone_obj :=\n⟨is_colimit₁ (λ X, (F_obj X).1) (λ X Y f, (F_hom f).1) cocone_obj.1 (λ X, (cocone X).1), \n valid_hom₁.is_colimit _ (λ X, (F_obj X).2) _ _ _ (λ X Y f, (F_hom f).2) (λ X, (cocone X).2)⟩\n\ndef id₂ (X : obj₂ 𝒞) : hom₂ X X := ⟨id₁ X.1, valid_hom₁.id _⟩ \n\n@[elab_as_eliminator] protected def hom₂.rec_on \n {motive : Π {X Y : obj₂ 𝒞} (f : hom₂ X Y), Sort*} {X Y : obj₂ 𝒞} (f : hom₂ X Y)\n (of_cat_hom : Π {X Y : 𝒞} (f : X ⟶ Y), motive (of_cat_hom₂ f))\n (limit_cone_comp : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n (ih_F_hom : Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f))\n (X : 𝒟) {Y : obj₂ 𝒞} (f : hom₂ (F_obj X) Y)\n (ih_f : motive f),\n motive (by exactI limit_cone_comp₂ F_obj @F_hom X f))\n (colimit_cocone_comp : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)) \n (ih_F_hom : Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f))\n (X : 𝒟) {Y : obj₂ 𝒞} (f : hom₂ Y (F_obj X))\n (ih_f : motive f),\n motive (by exactI colimit_cocone_comp₂ F_obj @F_hom X f))\n (is_limit : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n (ih_F_hom : Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f)) \n (cone_obj : obj₂ 𝒞) (cone : Π (X : 𝒟), hom₂ cone_obj (F_obj X))\n (ih_cone : Π (X : 𝒟), motive (cone X)),\n motive (by exactI is_limit₂ F_obj @F_hom cone_obj cone))\n (is_colimit : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)) \n (ih_F_hom : Π {X Y : 𝒟} (f : by exactI X ⟶ Y), motive (F_hom f))\n (cocone_obj : obj₂ 𝒞) (cocone : Π (X : 𝒟), hom₂ (F_obj X) cocone_obj)\n (ih_cone : Π (X : 𝒟), motive (cocone X)),\n motive (by exactI is_colimit₂ F_obj @F_hom cocone_obj cocone))\n (id : Π (X : obj₂ 𝒞), motive (id₂ X)):\n motive f :=\nbegin\n cases X with X hX, cases Y with Y hY,\n cases f with f hf,\n rcases f with ⟨f, hfd, hfc⟩,\n revert X Y hX hY,\n refine hom_rec_on f _ _ _ _ _ _,\n { intros A B f X Y hX hY hfd hfc hf,\n dsimp at hfd hfc, substs hfc hfd,\n exact of_cat_hom f },\n { introsI 𝒟 _ F_obj F_hom A B g ih₁ ih₂ X Y hX hY hfd hfc hf,\n dsimp at hfd hfc, substs hfc hfd,\n have valid_F_obj : ∀ X, valid_obj₁ (F_obj X),\n { cases hf, assumption },\n let F_obj' : 𝒟 → obj₂ 𝒞 := λ X, ⟨F_obj X, valid_F_obj X⟩,\n have valid_F_hom : ∀ X Y f, \n ∃ (h₁ : (@F_hom X Y f).dom = F_obj X) \n (h₂ : (@F_hom X Y f).cod = F_obj Y),\n valid_hom₁ ⟨@F_hom X Y f, h₁, h₂⟩,\n { cases hf, simpa },\n let F_hom' : Π (X Y : 𝒟) (f : X ⟶ Y), hom₂ (F_obj' X) (F_obj' Y) :=\n λ X Y f, ⟨⟨@F_hom X Y f, (valid_F_hom X Y f).fst, (valid_F_hom X Y f).snd.fst⟩,\n (valid_F_hom X Y f).snd.snd⟩,\n have valid_g : \n ∃ (h₁ : g.dom = F_obj A) (h₂ : g.cod = B),\n valid_hom₁ ⟨g, h₁, h₂⟩,\n { cases hf, simpa },\n let g' : hom₂ (F_obj' A) ⟨B, hY⟩ :=\n ⟨⟨g, valid_g.fst, valid_g.snd.fst⟩, valid_g.snd.snd⟩,\n exact limit_cone_comp F_obj' F_hom'\n (λ X Y f, ih₁ f (F_obj X) (F_obj Y) (valid_F_obj _) (valid_F_obj _)\n (valid_F_hom _ _ f).fst (valid_F_hom _ _ f).snd.fst\n (valid_F_hom _ _ f).snd.snd) A g'\n (ih₂ (F_obj' A).1 B (F_obj' A).2 hY g'.1.2.1 g'.1.2.2 g'.2) },\n { introsI 𝒟 _ F_obj F_hom cone_obj cone ih₁ ih₂ X Y hX hY hfd hfc hf,\n dsimp at hfd hfc,\n substs hfc hfd,\n have valid_F_obj : ∀ X, valid_obj₁ (F_obj X),\n { cases hf, assumption },\n let F_obj' : 𝒟 → obj₂ 𝒞 := λ X, ⟨F_obj X, valid_F_obj X⟩,\n have valid_F_hom : ∀ X Y f, \n ∃ (h₁ : (@F_hom X Y f).dom = F_obj X) \n (h₂ : (@F_hom X Y f).cod = F_obj Y),\n valid_hom₁ ⟨@F_hom X Y f, h₁, h₂⟩,\n { cases hf, simpa },\n let F_hom' : Π (X Y : 𝒟) (f : X ⟶ Y), hom₂ (F_obj' X) (F_obj' Y) :=\n λ X Y f, ⟨⟨@F_hom X Y f, (valid_F_hom X Y f).fst, (valid_F_hom X Y f).snd.fst⟩,\n (valid_F_hom X Y f).snd.snd⟩,\n let cone_obj' : obj₂ 𝒞 := ⟨cone_obj, hX⟩,\n have valid_cone : ∀ (X : 𝒟), ∃ (h₁ : (cone X).dom = cone_obj'.1)\n (h₂ : (cone X).cod = (F_obj' X).1),\n valid_hom₁ ⟨cone X, h₁, h₂⟩,\n { cases hf, simpa },\n let cone' : Π (X : 𝒟), hom₂ cone_obj' (F_obj' X) :=\n λ X, ⟨⟨cone X, (valid_cone X).fst, (valid_cone X).snd.fst⟩, (valid_cone X).snd.snd⟩,\n exact is_limit F_obj' F_hom'\n (λ A B f, ih₁ f (F_obj A) (F_obj B) (F_obj' A).2 (F_obj' B).2\n (valid_F_hom _ _ f).fst (valid_F_hom _ _ f).snd.fst\n (valid_F_hom _ _ f).snd.snd)\n cone_obj' cone'\n (λ X, ih₂ X cone_obj'.1 (F_obj' X).1 cone_obj'.2 (F_obj' X).2\n (cone' X).1.2.1 (cone' X).1.2.2 (cone' X).2) },\n { introsI 𝒟 _ F_obj F_hom A B g ih₁ ih₂ X Y hX hY hfd hfc hf,\n dsimp at hfd hfc, substs hfc hfd,\n have valid_F_obj : ∀ X, valid_obj₁ (F_obj X),\n { cases hf, assumption },\n let F_obj' : 𝒟 → obj₂ 𝒞 := λ X, ⟨F_obj X, valid_F_obj X⟩,\n have valid_F_hom : ∀ X Y f, \n ∃ (h₁ : (@F_hom X Y f).dom = F_obj X) \n (h₂ : (@F_hom X Y f).cod = F_obj Y),\n valid_hom₁ ⟨@F_hom X Y f, h₁, h₂⟩,\n { cases hf, simpa },\n have valid_g : \n ∃ (h₁ : g.dom = B) (h₂ : g.cod = F_obj A),\n valid_hom₁ ⟨g, h₁, h₂⟩,\n { cases hf, simpa },\n let g' : hom₂ ⟨B, hX⟩ (F_obj' A) :=\n ⟨⟨g, valid_g.fst, valid_g.snd.fst⟩, valid_g.snd.snd⟩,\n let F_hom' : Π (X Y : 𝒟) (f : X ⟶ Y), hom₂ (F_obj' X) (F_obj' Y) :=\n λ X Y f, ⟨⟨@F_hom X Y f, (valid_F_hom X Y f).fst, (valid_F_hom X Y f).snd.fst⟩,\n (valid_F_hom X Y f).snd.snd⟩,\n exact colimit_cocone_comp F_obj' F_hom'\n (λ X Y f, ih₁ f (F_obj X) (F_obj Y) (valid_F_obj _) (valid_F_obj _)\n (valid_F_hom _ _ f).fst (valid_F_hom _ _ f).snd.fst\n (valid_F_hom _ _ f).snd.snd) A g'\n (ih₂ B (F_obj' A).1 hX (F_obj' A).2 g'.1.2.1 g'.1.2.2 g'.2) },\n { introsI 𝒟 _ F_obj F_hom cocone_obj cocone ih₁ ih₂ X Y hX hY hfd hfc hf,\n dsimp at hfd hfc,\n substs hfc hfd,\n have valid_F_obj : ∀ X, valid_obj₁ (F_obj X),\n { cases hf, assumption },\n let F_obj' : 𝒟 → obj₂ 𝒞 := λ X, ⟨F_obj X, valid_F_obj X⟩,\n have valid_F_hom : ∀ X Y f, \n ∃ (h₁ : (@F_hom X Y f).dom = F_obj X) \n (h₂ : (@F_hom X Y f).cod = F_obj Y),\n valid_hom₁ ⟨@F_hom X Y f, h₁, h₂⟩,\n { cases hf, simpa },\n let F_hom' : Π (X Y : 𝒟) (f : X ⟶ Y), hom₂ (F_obj' X) (F_obj' Y) :=\n λ X Y f, ⟨⟨@F_hom X Y f, (valid_F_hom X Y f).fst, (valid_F_hom X Y f).snd.fst⟩,\n (valid_F_hom X Y f).snd.snd⟩,\n let cocone_obj' : obj₂ 𝒞 := ⟨cocone_obj, hY⟩,\n have valid_cocone : ∀ (X : 𝒟), ∃ (h₁ : (cocone X).dom = (F_obj' X).1)\n (h₂ : (cocone X).cod = cocone_obj'.1),\n valid_hom₁ ⟨cocone X, h₁, h₂⟩,\n { cases hf, simpa },\n let cocone' : Π (X : 𝒟), hom₂ (F_obj' X) cocone_obj' :=\n λ X, ⟨⟨cocone X, (valid_cocone X).fst, (valid_cocone X).snd.fst⟩, (valid_cocone X).snd.snd⟩,\n exact is_colimit F_obj' F_hom'\n (λ A B f, ih₁ f (F_obj A) (F_obj B) (F_obj' A).2 (F_obj' B).2\n (valid_F_hom _ _ f).fst (valid_F_hom _ _ f).snd.fst\n (valid_F_hom _ _ f).snd.snd)\n cocone_obj' cocone'\n (λ X, ih₂ X (F_obj' X).1 cocone_obj'.1 (F_obj' X).2 cocone_obj'.2 \n (cocone' X).1.2.1 (cocone' X).1.2.2 (cocone' X).2) },\n { intros A B C hB _ hAB hBC _,\n dsimp at hAB hBC, subst A, subst C, \n exact id ⟨B, hB⟩ }\nend\n\ndef hom₂_of_cat_obj_rec_on\n {motive : Π {X : 𝒞} {Y : obj₂ 𝒞} (f : hom₂ (of_cat_obj₂ X) Y), Sort*} \n {X : 𝒞} {Y : obj₂ 𝒞} (f : hom₂ (of_cat_obj₂ X) Y)\n (of_cat_hom : Π {Y : 𝒞} (f : X ⟶ Y), motive (of_cat_hom₂ f))\n (colimit_cocone_comp : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)) \n (X : 𝒟) {Y : 𝒞} (f : hom₂ (of_cat_obj₂ Y) (F_obj X))\n (ih_f : motive f),\n motive (by exactI colimit_cocone_comp₂ F_obj @F_hom X f))\n (is_limit : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n (cone_obj : 𝒞) (cone : Π (X : 𝒟), hom₂ (of_cat_obj₂ cone_obj) (F_obj X))\n (ih_cone : Π (X : 𝒟), motive (cone X)),\n motive (by exactI is_limit₂ F_obj @F_hom (of_cat_obj₂ cone_obj) cone)) \n (id : motive (id₂ (of_cat_obj₂ X))):\n motive f := \n@hom₂.rec_on 𝒞 _ (λ A B f, ∀ (h : A = of_cat_obj₂ X),\n motive (show hom₂ (of_cat_obj₂ X) B, from eq.rec_on h f))\n (of_cat_obj₂ X) Y f \n (λ A B g h, begin\n have := of_cat_obj₂_injective h,\n subst this,\n dsimp,\n exact of_cat_hom g\n end) \n begin \n intros,\n simp [limit_obj₂, of_cat_obj₂, limit_obj₁] at h,\n contradiction\n end \n begin\n introsI 𝒟 _ F_obj F_hom ih₁ A B g ih₂ h,\n subst h,\n exact colimit_cocone_comp _ _ _ _ (ih₂ rfl)\n end \n begin\n introsI 𝒟 _ F_obj F_hom ih₁ cone_obj cone ih₂ h,\n subst h,\n exact is_limit _ _ _ _ (λ A, ih₂ A rfl),\n end \n begin \n intros,\n simp [colimit_obj₂, of_cat_obj₂] at h,\n contradiction\n end\n begin\n intros X h,\n subst h,\n exact id\n end\n rfl\n\ndef hom₂_limit_obj_rec_on\n {motive : Π {𝒟 : Type} [category 𝒟] {F_obj : 𝒟 → obj₂ 𝒞}\n {F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)} {Y : obj₂ 𝒞}, \n hom₂ (by exactI limit_obj₂ F_obj @F_hom) Y → Sort*}\n {𝒟 : Type} [category 𝒟] {F_obj : 𝒟 → obj₂ 𝒞}\n {F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)} {Y : obj₂ 𝒞}\n (f : hom₂ (limit_obj₂ F_obj @F_hom) Y)\n (limit_cone_comp : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n (X : 𝒟) {Y : obj₂ 𝒞} (f : hom₂ (F_obj X) Y),\n by exactI motive (limit_cone_comp₂ F_obj @F_hom X f))\n (colimit_cocone_comp : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n (X : 𝒟)\n {ℰ : Type} [category ℰ] (G_obj : ℰ → obj₂ 𝒞)\n (G_hom : Π {X Y : ℰ}, (by exactI X ⟶ Y) → hom₂ (G_obj X) (G_obj Y))\n (f : hom₂ (by exactI limit_obj₂ G_obj @G_hom) (F_obj X))\n (ih_f : by exactI motive f),\n by exactI motive (colimit_cocone_comp₂ F_obj @F_hom X f))\n (is_limit : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n {ℰ : Type} [category ℰ] (G_obj : ℰ → obj₂ 𝒞)\n (G_hom : Π {X Y : ℰ}, (by exactI X ⟶ Y) → hom₂ (G_obj X) (G_obj Y))\n (cone : Π (X : 𝒟), hom₂ (by exactI limit_obj₂ G_obj @G_hom) (F_obj X))\n (ih_cone : Π (X : 𝒟), by exactI motive (cone X)),\n by exactI motive (is_limit₂ F_obj @F_hom (limit_obj₂ G_obj @G_hom) cone))\n (id : by exactI motive (id₂ (limit_obj₂ F_obj @F_hom))) :\n motive f :=\n@hom₂.rec_on 𝒞 _ (λ A B f, ∀ (h : A = limit_obj₂ F_obj @F_hom),\n motive (show hom₂ (limit_obj₂ F_obj @F_hom) B, from eq.rec_on h f))\n (limit_obj₂ F_obj @F_hom) Y f \n begin \n intros,\n simp [limit_obj₂, of_cat_obj₂, limit_obj₁] at h,\n contradiction\n end \n begin \n introsI ℰ _ G_obj G_hom ih₁ A B g ih₂ h,\n unfreezingI { rcases (limit_obj₂_injective h) with ⟨rfl, h₁, h₂, h₃⟩ },\n unfreezingI { subst h₁, subst h₂, subst h₃ },\n exact limit_cone_comp _ _ _ _\n end \n begin\n introsI 𝒟 _ F_obj F_hom ih₁ A B g ih₂ h,\n subst h,\n exact colimit_cocone_comp _ _ _ _ _ _ (ih₂ rfl)\n end \n begin\n introsI 𝒟 _ F_obj F_hom ih₁ cone_obj cone ih₂ h,\n subst h,\n exact is_limit _ _ _ _ _ (λ A, ih₂ A rfl),\n end \n begin \n intros,\n simp [colimit_obj₂, of_cat_obj₂, limit_obj₂] at h,\n contradiction\n end\n begin\n introsI X h,\n subst h,\n exact id\n end\n rfl\n\n@[elab_as_eliminator] def hom₂_colimit_obj_rec_on\n {motive : Π {𝒟 : Type} [category 𝒟] {F_obj : 𝒟 → obj₂ 𝒞}\n {F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)} {Y : obj₂ 𝒞}, \n hom₂ (by exactI colimit_obj₂ F_obj @F_hom) Y → Sort*}\n {𝒟 : Type} [category 𝒟] {F_obj : 𝒟 → obj₂ 𝒞}\n {F_hom : Π {X Y : 𝒟}, (X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)} {Y : obj₂ 𝒞}\n (f : hom₂ (colimit_obj₂ F_obj @F_hom) Y)\n (colimit_cocone_comp : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n (X : 𝒟) \n {ℰ : Type} [category ℰ] {G_obj : ℰ → obj₂ 𝒞}\n {G_hom : Π {X Y : ℰ}, (by exactI X ⟶ Y) → hom₂ (G_obj X) (G_obj Y)} \n (f : hom₂ (by exactI colimit_obj₂ G_obj @G_hom) (F_obj X))\n (ih_f : by exactI motive f),\n by exactI motive (by exactI colimit_cocone_comp₂ F_obj @F_hom X f))\n (is_limit : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y))\n {ℰ : Type} [category ℰ] {G_obj : ℰ → obj₂ 𝒞}\n {G_hom : Π {X Y : ℰ}, (by exactI X ⟶ Y) → hom₂ (G_obj X) (G_obj Y)}\n (cone : Π (X : 𝒟), hom₂ (by exactI colimit_obj₂ G_obj @G_hom) (F_obj X))\n (ih_cone : Π (X : 𝒟), by exactI motive (cone X)),\n by exactI motive (by exactI is_limit₂ F_obj @F_hom _ cone))\n (is_colimit : Π {𝒟 : Type} [category 𝒟] (F_obj : 𝒟 → obj₂ 𝒞)\n (F_hom : Π {X Y : 𝒟}, (by exactI X ⟶ Y) → hom₂ (F_obj X) (F_obj Y)) \n (cocone_obj : obj₂ 𝒞) (cocone : Π (X : 𝒟), hom₂ (F_obj X) cocone_obj),\n by exactI motive (is_colimit₂ F_obj @F_hom cocone_obj cocone)) \n (id : by exactI motive (id₂ (colimit_obj₂ F_obj @F_hom))):\n motive f :=\n@hom₂.rec_on 𝒞 _ (λ A B f, ∀ (h : A = colimit_obj₂ F_obj @F_hom),\n motive (show hom₂ (colimit_obj₂ F_obj @F_hom) B, from eq.rec_on h f))\n (colimit_obj₂ F_obj @F_hom) Y f \n begin \n intros,\n simp [colimit_obj₂, of_cat_obj₂, colimit_obj₁] at h,\n contradiction\n end \n begin \n intros,\n simp [colimit_obj₂, of_cat_obj₂, colimit_obj₁, limit_obj₁, limit_obj₂] at h,\n contradiction\n end\n begin\n introsI 𝒟 _ F_obj F_hom ih₁ A B f ih₂ h,\n subst h,\n exact colimit_cocone_comp _ _ _ _ (ih₂ rfl)\n end\n begin\n introsI 𝒟 _ F_obj F_hom ih₁ cone_obj cone ih₂ h,\n subst h,\n exact is_limit _ _ _ (λ X, ih₂ X rfl)\n end\n begin\n introsI ℰ _ G_obj G_hom ih₁ cocone_obj cocone ih₂ h,\n unfreezingI { rcases (colimit_obj₂_injective h) with ⟨rfl, h₁, h₂, h₃⟩ },\n unfreezingI { subst h₁, subst h₂, subst h₃ },\n exact is_colimit _ _ _ _\n end\n begin\n introsI X h,\n subst h,\n exact id\n end\n rfl\n\ndef comp₂ {X Y : obj₂ 𝒞} (f : hom₂ X Y) : Π {Z : obj₂ 𝒞}, hom₂ Y Z → hom₂ X Z :=\nhom₂.rec_on f \n begin\n intros X Y f Z g,\n refine hom₂_of_cat_obj_rec_on g _ _ _ _,\n { intros B g,\n exact of_cat_hom₂ (f ≫ g) },\n { introsI 𝒟 _ F_obj F_hom A B g ih,\n exact colimit_cocone_comp₂ F_obj @F_hom A ih },\n { introsI 𝒟 _ F_obj F_hom A cone ih,\n exact is_limit₂ F_obj @F_hom (of_cat_obj₂ X) (λ X, ih _) },\n { exact of_cat_hom₂ f }\n end\n begin\n introsI 𝒟 _ F_obj F_hom ih₁ A B f ih₂ Z g,\n refine limit_cone_comp₂ F_obj @F_hom A (ih₂ g),\n end\n begin\n introsI 𝒟 _ F_obj F_hom ih₁ A B f ih₂ Z g,\n revert ih₂ A,\n refine hom₂_colimit_obj_rec_on g _ _ _ _,\n { introsI ℰ _ G_obj G_hom C ℱ _ H_obj H_hom ih₃ ih₄ A g ih₂,\n refine colimit_cocone_comp₂ G_obj @G_hom C (ih₄ A g @ih₂) },\n { introsI ℰ _ G_obj G_hom ℱ _ H_obj H_hom ih₃ ih₄ A g ih₂,\n exact is_limit₂ G_obj @G_hom B (λ X, ih₄ X A g @ih₂) },\n { introsI ℰ _ G_obj G_hom cocone_obj cocone A g ih₂,\n exact ih₂ (cocone A) },\n { intros A f _,\n exact colimit_cocone_comp₂ F_obj @F_hom A f }\n end \n begin\n introsI 𝒟 _ F_obj F_hom ih₁ cone_obj cone ih₂ Z g,\n revert ih₂,\n refine hom₂_limit_obj_rec_on g _ _ _ _,\n { introsI ℰ _ G_obj G_hom A B g ih₂,\n exact ih₂ A g },\n { introsI ℰ _ F_obj F_hom A ℱ _ G_obj G_hom g ih₃ ih₂,\n exact colimit_cocone_comp₂ F_obj @F_hom A (ih₃ @ih₂) },\n { introsI ℰ _ F_obj F_hom ℱ _ G_obj G_hom ih₃ ih₄ ih₂,\n exact is_limit₂ F_obj @F_hom cone_obj (λ X, ih₄ _ @ih₂) },\n { introsI ih,\n exact is_limit₂ F_obj @F_hom cone_obj cone }\n end\n begin\n introsI 𝒟 _ F_obj F_hom ih₁ cocone_obj cocone ih₂ Z g,\n exact is_colimit₂ F_obj @F_hom Z (λ A, ih₂ A g)\n end\n (λ _ _ g, g)\n#print has_limits_of_size\nvariables {ℰ : Type u} [category ℰ] [has_limits_of_size.{0} ℰ] [has_colimits_of_size.{0} ℰ] (F : 𝒞 ⥤ ℰ)\n\ndef UMP_obj {X Y : obj₂ 𝒞} (f : hom₂ X Y) : Σ A B : ℰ, A ⟶ B :=\nhom₂.rec_on f \n (λ X Y f, ⟨F.obj X, F.obj Y, F.map f⟩) \n begin\n introsI 𝒟 _ F_obj F_hom ih₁ A B g ih₂,\n\n end\n _ \n _ \n _ \n _\n\n\nend bicompletion_aux\n", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/bicompletion/inductive5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.4649015713733885, "lm_q1q2_score": 0.24876810030794272}} {"text": "\nimport category_theory.functor_category\n--import field_theory.splitting_field\n--import field_theory.subfield\nimport algebra.field\nimport algebra.ring\n--import ring_theory.algebra\n--import ring_theory.algebraic\nimport category_theory.isomorphism\nimport algebra.group.hom\nimport data.set.basic\n\nopen category_theory\nuniverses v u\n--variables (k : Type u) [𝕜 :field k] (L : Type u) [𝕃 :field L] (F : Type u) [𝔽 :field F]\nstructure fields : Type (u+1) :=\n(k : Type u)\n(fStruct : field k)\n\n\ninstance fields_to_sort : has_coe_to_sort fields :=\n{S := Type u, coe := λ F, F.k} \ninstance fieldIsField (a : fields) : field a := a.fStruct\n\ninstance fields_has_hom : has_hom fields :=\n{ hom:= λ a b, ring_hom a b }\ninstance fields_has_cat_struct : category_struct fields :=\n{to_has_hom:= fields_has_hom, id:=λ X, ring_hom.id X, comp := λ a b c fab fbc,ring_hom.comp fbc fab }\n\n\nstructure fieldsOver (L : fields.{u}) : Type (u+1) :=\n(k : fields.{u})\n(L2k : L →+* k )\n\ninstance ext_fields_coe (L : fields.{u}) : has_coe (fieldsOver L) fields.{u}:=\n⟨fieldsOver.k⟩\n\n@[ext] structure kLinearMor {L : fields.{u}} (k₁ k₂ : fieldsOver L) : Type u :=\n(mor : k₁ →+* k₂ )\n(coincide : ring_hom.comp mor k₁.L2k = k₂.L2k )\n\n\ninstance morphism_to_fun {L : fields.{u}} (k₁ k₂ : fieldsOver L) :\n has_coe_to_fun ( kLinearMor k₁ k₂) :=\n{ F := λ _, k₁ → k₂,\n coe := λ m, m.mor }\n\ninstance ext_fields_has_hom (L : fields.{u}) : has_hom (fieldsOver L) :=\n{hom := kLinearMor }\n\ninstance ext_fields_has_cat_struct (L : fields.{u}) : category_struct (fieldsOver L) :=\n{to_has_hom:= ext_fields_has_hom L, id:=λ X, {mor := ring_hom.id X, coincide:= ring_hom.id_comp _ },\n comp := λ a b c fab fbc,⟨ring_hom.comp fbc.mor fab.mor, by rw [ring_hom.comp_assoc,fab.coincide,fbc.coincide] ⟩ }\n\n/- variables (L : fields.{u})(X Y Z :fieldsOver L)\n#check (ext_fields_has_cat_struct L).comp\n#check kLinearMor.mor (𝟙X)\n -/\ninstance ext_fields_cat (L : fields.{u}): category (fieldsOver L):=\n{\n to_category_struct := ext_fields_has_cat_struct L,\n\n id_comp' :=begin intros X Y fXY ,ext,\n dsimp [kLinearMor.mor],\n refl, end , \n \n comp_id':=begin intros X Y fXY ,ext,\n dsimp [kLinearMor.mor],\n refl, end ,\n \n assoc' := begin intros W X Y Z f g h ,ext,\n dsimp [kLinearMor.mor],\n refl, end \n }\n\n\n/- structure subFields (F : Type u) [𝔽 :field F] : Type (u+1):=\n(k : Type u)\n(𝕜 :field k)\n(k2F : k →+* F ) -/\n\n\n\n\n\n\n def AutGrp (L : fields.{u})(F : fieldsOver L):Type u :=\n --F ≃ₐ[L] F\n F ≅ F\n\n\n--notation `Aut(`:30 F `/` L := AutGrp L F\n\n\n\n\ninstance aut_grp_struct (L : fields.{u})(F : fieldsOver L) : group (AutGrp L F) :=\n{ mul:= λ a b, iso.trans b a,\n mul_assoc := begin intros a b c, ext, simp, end,\n one := iso.refl F,\n one_mul := begin intro a, ext,simp,refl, end,\n mul_one := begin intro a, ext,simp, refl, end,\n inv := iso.symm,\n mul_left_inv := category_theory.iso.self_symm_id\n} \n/- { mul:= alg_equiv.trans,\n mul_assoc := begin intros a b c, ext, simp, refl, end,\n one := alg_equiv.refl,\n one_mul := begin intro a, ext,simp, refl, end,\n mul_one := begin intro a, ext,simp, refl, end,\n inv := alg_equiv.symm,\n mul_left_inv := begin intro a,ext,simp,rw a.left_inv, end\n\n} -/\n\nstructure fieldsBetween (L : fields.{u})(F : fieldsOver L) :Type (u+1) :=\n(k:fieldsOver L)\n(k2F : k ⟶ F)\ninstance bet_fields_coe (L : fields.{u})(F : fieldsOver L) : has_coe (fieldsBetween L F) (fieldsOver L) :=\n⟨fieldsBetween.k⟩\n\nvariables (L : fields.{u})(F : fieldsOver L)(E : fieldsOver F.k)\n\n\ninstance inbeding_coe : has_coe (fieldsOver F.k) (fieldsOver L ):=\n⟨ λ E, {k:= E.k, L2k:= ring_hom.comp E.L2k F.L2k }⟩\n\nlemma induce1 : (↑E: fieldsOver L).L2k = ring_hom.comp E.L2k F.L2k :=\nbegin ext,refl, end\n\ndef base_change_functor : functor (fieldsOver F.k) (fieldsOver L) :=\n{\n obj := λ E , ↑E,\n map := λ A B f , ⟨f.mor, begin cases f,dsimp,rw [induce1,induce1, ←ring_hom.comp_assoc ,f_coincide], end ⟩,\n map_id':= begin intro X, ext, refl, end,\n map_comp':= begin intros X Y Z f g, ext,refl, end\n}\n\n\ninstance AutSubGrp_lift : has_lift (AutGrp F.k E) (AutGrp L ↑E) :=\n⟨functor.map_iso (base_change_functor L F)⟩\n\nlemma lift_inj(g: AutGrp F.k E) : ⇑(g.hom.mor)=(↑ g : (AutGrp L ↑E)).hom.mor :=\nbegin ext, refl, end\n\ndef AutSubGrp : monoid_hom (AutGrp F.k E) (AutGrp L ↑E) :=\n{ to_fun :=λ g, ↑g,\n map_one' := by refl,\n map_mul' := begin intros x y, ext, refl, end,\n}\n\nlemma AutSub_inj : function.injective ⇑(AutSubGrp L F E) :=\nbegin \nrw monoid_hom.injective_iff,\nintros a h,\napply iso.ext,\nhave h0 : ⇑(AutSubGrp L F E) = λa, ↑a := by refl,\nrw h0 at h, dsimp at h,\nhave h1:= (lift_inj _ _ _ a),\nrw h at h1, symmetry,\next, rw h1,refl,\nend\n\n\n\ndef normal_ext(F: fieldsOver L) : Prop :=\n∀ (K : fieldsOver L) (f g : F ⟶ K) , set.range f = set.range g", "meta": {"author": "iamcxds", "repo": "Galois", "sha": "8ad1c22b5efcf332bc77901e1f1c64c2667ec11f", "save_path": "github-repos/lean/iamcxds-Galois", "path": "github-repos/lean/iamcxds-Galois/Galois-8ad1c22b5efcf332bc77901e1f1c64c2667ec11f/src/basic_cat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.24875116618628154}} {"text": "import for_mathlib.short_complex_functor_category\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n\nnamespace category_theory\n\nnamespace functor\n\nvariables {C₁ C₂ C₃ : Type*} [category C₁] [category C₂] [category C₃] [has_zero_morphisms C₃]\n [has_zero_object C₃]\n\nlemma is_zero_of_comp (F : C₁ ⥤ C₂) (G : C₂ ⥤ C₃) (h : limits.is_zero G) :\n limits.is_zero (F ⋙ G) :=\nbegin\n rw limits.is_zero.iff_id_eq_zero,\n ext,\n apply limits.is_zero.eq_zero_of_src,\n dsimp,\n apply limits.is_zero.obj,\n exact h,\nend\n\nend functor\n\nend category_theory\n\nnamespace homological_complex\n\nvariables (C : Type*) [category C] [has_zero_morphisms C]\n {M : Type*} (c : complex_shape M)\n\n@[simps]\ndef prev_functor (i : M) : homological_complex C c ⥤ C :=\nhomological_complex.eval _ c (c.prev i)\n\n@[simps]\ndef next_functor (i : M) : homological_complex C c ⥤ C :=\nhomological_complex.eval _ c (c.next i)\n\ndef prev_functor_iso_eval (i j : M) (hij : c.rel j i) :\n prev_functor C c i ≅ homological_complex.eval C c j :=\nnat_iso.of_components\n (λ X, X.X_prev_iso hij)\n (λ X Y f, by { dsimp, rw [← iso.eq_comp_inv, assoc, ← hom.prev_eq f hij], })\n\ndef next_functor_iso_eval (i j : M) (hij : c.rel i j) :\n next_functor C c i ≅ homological_complex.eval C c j :=\nnat_iso.of_components\n (λ X, X.X_next_iso hij)\n (λ X Y f, by { dsimp, rw [← iso.eq_comp_inv, assoc, ← hom.next_eq f hij], })\n\nend homological_complex\n\nnamespace short_complex\n\nvariables (C : Type*) [category C] [has_zero_morphisms C] {M : Type*} (c : complex_shape M)\n\ndef functor_homological_complex_π₁_iso_prev_functor (i : M) :\n functor_homological_complex C c i ⋙ π₁ ≅ homological_complex.prev_functor C c i := by refl\n\ndef functor_homological_complex_π₂_iso_eval (i : M) :\n functor_homological_complex C c i ⋙ π₂ ≅ homological_complex.eval C c i := by refl\n\ndef functor_homological_complex_π₃_iso_next_functor (i : M) :\n functor_homological_complex C c i ⋙ π₃ ≅ homological_complex.next_functor C c i := by refl\n\nend short_complex\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/short_complex_homological_complex.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6334102775181399, "lm_q2_score": 0.3923368301671084, "lm_q1q2_score": 0.24851018047673548}} {"text": "/-\nCopyright (c) 2017 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Sébastien Gouëzel, Patrick Massot\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.uniform_space.cauchy\nimport Mathlib.topology.uniform_space.separation\nimport Mathlib.topology.dense_embedding\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 l u_3 u_4 \n\nnamespace Mathlib\n\n/-!\n# Uniform embeddings of uniform spaces.\n\nExtension of uniform continuous functions.\n-/\n\nstructure uniform_inducing {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n (f : α → β)\n where\n comap_uniformity :\n filter.comap (fun (x : α × α) => (f (prod.fst x), f (prod.snd x))) (uniformity β) = uniformity α\n\ntheorem uniform_inducing.mk' {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {f : α → β}\n (h :\n ∀ (s : set (α × α)),\n s ∈ uniformity α ↔\n ∃ (t : set (β × β)), ∃ (H : t ∈ uniformity β), ∀ (x y : α), (f x, f y) ∈ t → (x, y) ∈ s) :\n uniform_inducing f :=\n sorry\n\ntheorem uniform_inducing.comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n [uniform_space β] [uniform_space γ] {g : β → γ} (hg : uniform_inducing g) {f : α → β}\n (hf : uniform_inducing f) : uniform_inducing (g ∘ f) :=\n sorry\n\nstructure uniform_embedding {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n (f : α → β)\n extends uniform_inducing f where\n inj : function.injective f\n\ntheorem uniform_embedding_subtype_val {α : Type u_1} [uniform_space α] {p : α → Prop} :\n uniform_embedding subtype.val :=\n uniform_embedding.mk (uniform_inducing.mk rfl) subtype.val_injective\n\ntheorem uniform_embedding_subtype_coe {α : Type u_1} [uniform_space α] {p : α → Prop} :\n uniform_embedding coe :=\n uniform_embedding_subtype_val\n\ntheorem uniform_embedding_set_inclusion {α : Type u_1} [uniform_space α] {s : set α} {t : set α}\n (hst : s ⊆ t) : uniform_embedding (set.inclusion hst) :=\n sorry\n\ntheorem uniform_embedding.comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n [uniform_space β] [uniform_space γ] {g : β → γ} (hg : uniform_embedding g) {f : α → β}\n (hf : uniform_embedding f) : uniform_embedding (g ∘ f) :=\n sorry\n\ntheorem uniform_embedding_def {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {f : α → β} :\n uniform_embedding f ↔\n function.injective f ∧\n ∀ (s : set (α × α)),\n s ∈ uniformity α ↔\n ∃ (t : set (β × β)),\n ∃ (H : t ∈ uniformity β), ∀ (x y : α), (f x, f y) ∈ t → (x, y) ∈ s :=\n sorry\n\ntheorem uniform_embedding_def' {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {f : α → β} :\n uniform_embedding f ↔\n function.injective f ∧\n uniform_continuous f ∧\n ∀ (s : set (α × α)),\n s ∈ uniformity α →\n ∃ (t : set (β × β)),\n ∃ (H : t ∈ uniformity β), ∀ (x y : α), (f x, f y) ∈ t → (x, y) ∈ s :=\n sorry\n\ntheorem uniform_inducing.uniform_continuous {α : Type u_1} {β : Type u_2} [uniform_space α]\n [uniform_space β] {f : α → β} (hf : uniform_inducing f) : uniform_continuous f :=\n sorry\n\ntheorem uniform_inducing.uniform_continuous_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3}\n [uniform_space α] [uniform_space β] [uniform_space γ] {f : α → β} {g : β → γ}\n (hg : uniform_inducing g) : uniform_continuous f ↔ uniform_continuous (g ∘ f) :=\n sorry\n\ntheorem uniform_inducing.inducing {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {f : α → β} (h : uniform_inducing f) : inducing f :=\n sorry\n\ntheorem uniform_inducing.prod {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {α' : Type u_3} {β' : Type u_4} [uniform_space α'] [uniform_space β'] {e₁ : α → α'}\n {e₂ : β → β'} (h₁ : uniform_inducing e₁) (h₂ : uniform_inducing e₂) :\n uniform_inducing fun (p : α × β) => (e₁ (prod.fst p), e₂ (prod.snd p)) :=\n sorry\n\ntheorem uniform_inducing.dense_inducing {α : Type u_1} {β : Type u_2} [uniform_space α]\n [uniform_space β] {f : α → β} (h : uniform_inducing f) (hd : dense_range f) :\n dense_inducing f :=\n dense_inducing.mk (inducing.mk (inducing.induced (uniform_inducing.inducing h))) hd\n\ntheorem uniform_embedding.embedding {α : Type u_1} {β : Type u_2} [uniform_space α]\n [uniform_space β] {f : α → β} (h : uniform_embedding f) : embedding f :=\n embedding.mk\n (inducing.mk\n (inducing.induced (uniform_inducing.inducing (uniform_embedding.to_uniform_inducing h))))\n (uniform_embedding.inj h)\n\ntheorem uniform_embedding.dense_embedding {α : Type u_1} {β : Type u_2} [uniform_space α]\n [uniform_space β] {f : α → β} (h : uniform_embedding f) (hd : dense_range f) :\n dense_embedding f :=\n dense_embedding.mk\n (dense_inducing.mk\n (inducing.mk (inducing.induced (embedding.to_inducing (uniform_embedding.embedding h)))) hd)\n (uniform_embedding.inj h)\n\ntheorem closure_image_mem_nhds_of_uniform_inducing {α : Type u_1} {β : Type u_2} [uniform_space α]\n [uniform_space β] {s : set (α × α)} {e : α → β} (b : β) (he₁ : uniform_inducing e)\n (he₂ : dense_inducing e) (hs : s ∈ uniformity α) :\n ∃ (a : α), closure (e '' set_of fun (a' : α) => (a, a') ∈ s) ∈ nhds b :=\n sorry\n\ntheorem uniform_embedding_subtype_emb {α : Type u_1} {β : Type u_2} [uniform_space α]\n [uniform_space β] (p : α → Prop) {e : α → β} (ue : uniform_embedding e)\n (de : dense_embedding e) : uniform_embedding (dense_embedding.subtype_emb p e) :=\n sorry\n\ntheorem uniform_embedding.prod {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {α' : Type u_3} {β' : Type u_4} [uniform_space α'] [uniform_space β'] {e₁ : α → α'}\n {e₂ : β → β'} (h₁ : uniform_embedding e₁) (h₂ : uniform_embedding e₂) :\n uniform_embedding fun (p : α × β) => (e₁ (prod.fst p), e₂ (prod.snd p)) :=\n sorry\n\ntheorem is_complete_of_complete_image {α : Type u_1} {β : Type u_2} [uniform_space α]\n [uniform_space β] {m : α → β} {s : set α} (hm : uniform_inducing m)\n (hs : is_complete (m '' s)) : is_complete s :=\n sorry\n\n/-- A set is complete iff its image under a uniform embedding is complete. -/\ntheorem is_complete_image_iff {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {m : α → β} {s : set α} (hm : uniform_embedding m) : is_complete (m '' s) ↔ is_complete s :=\n sorry\n\ntheorem complete_space_iff_is_complete_range {α : Type u_1} {β : Type u_2} [uniform_space α]\n [uniform_space β] {f : α → β} (hf : uniform_embedding f) :\n complete_space α ↔ is_complete (set.range f) :=\n sorry\n\ntheorem complete_space_congr {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {e : α ≃ β} (he : uniform_embedding ⇑e) : complete_space α ↔ complete_space β :=\n sorry\n\ntheorem complete_space_coe_iff_is_complete {α : Type u_1} [uniform_space α] {s : set α} :\n complete_space ↥s ↔ is_complete s :=\n iff.trans (complete_space_iff_is_complete_range uniform_embedding_subtype_coe)\n (eq.mpr\n (id (Eq._oldrec (Eq.refl (is_complete (set.range coe) ↔ is_complete s)) subtype.range_coe))\n (iff.refl (is_complete s)))\n\ntheorem is_complete.complete_space_coe {α : Type u_1} [uniform_space α] {s : set α}\n (hs : is_complete s) : complete_space ↥s :=\n iff.mpr complete_space_coe_iff_is_complete hs\n\ntheorem is_closed.complete_space_coe {α : Type u_1} [uniform_space α] [complete_space α] {s : set α}\n (hs : is_closed s) : complete_space ↥s :=\n is_complete.complete_space_coe (is_closed.is_complete hs)\n\ntheorem complete_space_extension {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {m : β → α} (hm : uniform_inducing m) (dense : dense_range m)\n (h : ∀ (f : filter β), cauchy f → ∃ (x : α), filter.map m f ≤ nhds x) : complete_space α :=\n sorry\n\ntheorem totally_bounded_preimage {α : Type u_1} {β : Type u_2} [uniform_space α] [uniform_space β]\n {f : α → β} {s : set β} (hf : uniform_embedding f) (hs : totally_bounded s) :\n totally_bounded (f ⁻¹' s) :=\n sorry\n\ntheorem uniform_embedding_comap {α : Type u_1} {β : Type u_2} {f : α → β} [u : uniform_space β]\n (hf : function.injective f) : uniform_embedding f :=\n uniform_embedding.mk (uniform_inducing.mk rfl) hf\n\ntheorem uniformly_extend_exists {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n [uniform_space β] [uniform_space γ] {e : β → α} (h_e : uniform_inducing e)\n (h_dense : dense_range e) {f : β → γ} (h_f : uniform_continuous f) [complete_space γ] (a : α) :\n ∃ (c : γ), filter.tendsto f (filter.comap e (nhds a)) (nhds c) :=\n sorry\n\ntheorem uniform_extend_subtype {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n [uniform_space β] [uniform_space γ] [complete_space γ] {p : α → Prop} {e : α → β} {f : α → γ}\n {b : β} {s : set α} (hf : uniform_continuous fun (x : Subtype p) => f (subtype.val x))\n (he : uniform_embedding e) (hd : ∀ (x : β), x ∈ closure (set.range e))\n (hb : closure (e '' s) ∈ nhds b) (hs : is_closed s) (hp : ∀ (x : α), x ∈ s → p x) :\n ∃ (c : γ), filter.tendsto f (filter.comap e (nhds b)) (nhds c) :=\n sorry\n\ntheorem uniformly_extend_of_ind {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n [uniform_space β] [uniform_space γ] {e : β → α} (h_e : uniform_inducing e)\n (h_dense : dense_range e) {f : β → γ} (h_f : uniform_continuous f) [separated_space γ] (b : β) :\n dense_inducing.extend (uniform_inducing.dense_inducing h_e h_dense) f (e b) = f b :=\n dense_inducing.extend_eq_at (uniform_inducing.dense_inducing h_e h_dense) b\n (continuous.continuous_at (uniform_continuous.continuous h_f))\n\ntheorem uniformly_extend_unique {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n [uniform_space β] [uniform_space γ] {e : β → α} (h_e : uniform_inducing e)\n (h_dense : dense_range e) {f : β → γ} [separated_space γ] {g : α → γ}\n (hg : ∀ (b : β), g (e b) = f b) (hc : continuous g) :\n dense_inducing.extend (uniform_inducing.dense_inducing h_e h_dense) f = g :=\n dense_inducing.extend_unique (uniform_inducing.dense_inducing h_e h_dense) hg hc\n\ntheorem uniformly_extend_spec {α : Type u_1} {β : Type u_2} {γ : Type u_3} [uniform_space α]\n [uniform_space β] [uniform_space γ] {e : β → α} (h_e : uniform_inducing e)\n (h_dense : dense_range e) {f : β → γ} (h_f : uniform_continuous f) [separated_space γ]\n [complete_space γ] (a : α) :\n filter.tendsto f (filter.comap e (nhds a))\n (nhds (dense_inducing.extend (uniform_inducing.dense_inducing h_e h_dense) f a)) :=\n sorry\n\ntheorem uniform_continuous_uniformly_extend {α : Type u_1} {β : Type u_2} {γ : Type u_3}\n [uniform_space α] [uniform_space β] [uniform_space γ] {e : β → α} (h_e : uniform_inducing e)\n (h_dense : dense_range e) {f : β → γ} (h_f : uniform_continuous f) [separated_space γ]\n [cγ : complete_space γ] :\n uniform_continuous (dense_inducing.extend (uniform_inducing.dense_inducing h_e h_dense) f) :=\n sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/uniform_space/uniform_embedding_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.538983220687684, "lm_q2_score": 0.46101677931231594, "lm_q1q2_score": 0.24848030850481528}} {"text": "/-\nCopyright (c) 2021 OpenAI. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor(s): Stanislas Polu, Jesse Michael Han\n\nHelper functions to work with the tactic monad.\n-/\nimport tactic\nimport tactic.core\nimport utils.io\nimport system.io\nimport basic.control\n\nnamespace expr\n\nmeta def app_symbol_is (e : expr) (nm : name) : bool :=\nmatch e.get_app_fn with\n| (expr.const n _) := n = nm\n| _ := ff\nend\n\n\nmeta def contains_undefined (e : expr) : bool :=\ne.fold ff $ λ e' _ b, if e'.app_symbol_is `undefined then tt else b\n\nend expr\n\n\nnamespace tactic\n\nmeta def set_goal_to (goal : expr) : tactic unit :=\nmk_meta_var goal >>= set_goals ∘ pure\n\nmeta def guard_sorry (e : expr) : tactic unit := guard $ bnot e.contains_sorry\n\nmeta def guard_undefined (e : expr) : tactic unit := guard $ bnot e.contains_undefined\n\nend tactic\n\nsection validate\n\nmeta def kernel_type_check (pf : expr) : tactic unit := do {\n tp ← tactic.infer_type pf,\n env ← tactic.get_env,\n let decl := (declaration.defn `_ (expr.collect_univ_params pf) tp pf reducibility_hints.opaque ff),\n res ← tactic.capture' (env.add decl $> ()),\n match res with\n | (interaction_monad.result.success _ _) := pure ()\n | (interaction_monad.result.exception msg _ _) := let msg := msg.get_or_else (λ _, (\"\" : format)) in\n tactic.fail format! \"kernel type check failed:\\n---\\n{msg ()}\\n---\\n\"\n end\n}\n\nmeta def validate_proof (tgt: expr) (pf: expr) : tactic unit := do {\n env ← tactic.get_env,\n pf ← pure $ env.unfold_untrusted_macros pf,\n pft ← tactic.infer_type pf,\n tactic.type_check pf tactic.transparency.all,\n guard (bnot pf.has_meta_var) <|> do {\n tactic.fail format! \"proof contains metavariables\"\n },\n tactic.guard_sorry pf <|> do {\n tactic.fail format! \"proof contains `sorry`\"\n },\n tactic.guard_undefined pf <|> do {\n tactic.fail format! \"proof contains `undefined`\"\n },\n tactic.is_def_eq tgt pft <|> do {\n tgt_fmt ← tactic.pp tgt,\n pft_fmt ← tactic.pp pft,\n tactic.fail format! \"proof type mismatch: {tgt_fmt} != {pft_fmt}\"\n },\n kernel_type_check pf\n}\n\nmeta def validate_decl (nm : name) : tactic unit := do {\n env ← tactic.get_env,\n d ← env.get nm,\n validate_proof d.type d.value\n}\n\nend validate\n\nsection add_open_namespace\n\nmeta def add_open_namespace : name → tactic unit := λ nm, do\nenv ← tactic.get_env, tactic.set_env (env.execute_open nm)\n\nmeta def add_open_namespaces (nms : list name) : tactic unit :=\nnms.mmap' add_open_namespace\n\nend add_open_namespace\n\n\nsection hashing\n\nmeta def tactic_hash : tactic ℕ := do {\n gs ← tactic.get_goals,\n hs ← gs.mmap $ λ g, do {\n tactic.set_goals [g],\n es ← (::) <$> tactic.target <*> tactic.local_context,\n es.mfoldl (λ acc e, (+) acc <$> expr.hash <$> tactic.head_zeta e) 0\n },\n pure $ hs.sum\n}\n\nend hashing\n\n\nsection misc\n\nmeta def tactic.is_theorem (nm : name) : tactic bool := do {\n env ← tactic.get_env,\n declaration.is_theorem <$> env.get nm\n}\n\nend misc\n\nmeta def run_with_input' {α} : lean.parser α → string → tactic α := λ p s,\ndo\n (p, \"\") ← lean.parser.run (lean.parser.with_input p s),\n pure p\n\nmeta def parse_texpr_with_univs (univs : list string): lean.parser pexpr := do\n -- add all universe names in the list as universe levels\n univs.mmap $ (λ s, lean.parser.add_local_level s),\n -- parse the buffer as a pexpr\n interactive.types.texpr\n\nmeta def parse_and_typecheck (proof : string) : tactic expr := do\n let univs := [\"u_1001\", \"u_1002\", \"u_1003\", \"u_1004\", \"u_1005\", \"u_1006\"],\n pexpr_proof_term <- run_with_input' (parse_texpr_with_univs univs) proof,\n proof_term <- tactic.to_expr pexpr_proof_term,\n kernel_type_check proof_term, \n thm <- tactic.infer_type proof_term,\n isproof <- tactic.is_proof proof_term,\n if isproof then return thm else failure", "meta": {"author": "joepalermo", "repo": "synthetic-proof-term-data-augmentation", "sha": "c82d77478d26d196e561c7df6ee08bd31ef813a3", "save_path": "github-repos/lean/joepalermo-synthetic-proof-term-data-augmentation", "path": "github-repos/lean/joepalermo-synthetic-proof-term-data-augmentation/synthetic-proof-term-data-augmentation-c82d77478d26d196e561c7df6ee08bd31ef813a3/src/utils/tactic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5117166047041652, "lm_q2_score": 0.48438008427698437, "lm_q1q2_score": 0.24786533211253586}} {"text": "import Aesop\n\naxiom Ring : Type\naxiom Scheme : Type\naxiom affine (X : Scheme) : Prop\naxiom quasi_compact (X : Scheme) : Prop\n\n@[aesop 99%] axiom Spec : Ring → Scheme\n@[aesop 99%] axiom qc_of_af {X : Scheme} (h : affine X) : quasi_compact X\n@[aesop 99%] axiom ZZ : Ring\n@[aesop 99%] axiom spec_affine (R : Ring) : affine (Spec R)\n\ntheorem thm : ∃ (X : Scheme) (h₁ : affine X) (h₂ : quasi_compact X), True := by {\n aesop;\n}\n\n#print thm\n\n-- example : ∃ (X : Scheme) (h₁ : P X) (h₂ : Q X), True := by {\n-- apply Exists.intro (Spec ZZ);\n-- apply Exists.intro (spec_affine ZZ);\n-- apply Exists.intro (qc_of_af (spec_affine ZZ));\n-- apply True.intro;\n-- }\n", "meta": {"author": "jessetvogel", "repo": "duck", "sha": "4ab46eb4099ef5a827112d5ac217f9e649946796", "save_path": "github-repos/lean/jessetvogel-duck", "path": "github-repos/lean/jessetvogel-duck/duck-4ab46eb4099ef5a827112d5ac217f9e649946796/EdgeCase.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5660185351961015, "lm_q2_score": 0.43782349911420193, "lm_q1q2_score": 0.2478162156430522}} {"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.int.basic\nimport Mathlib.data.nat.cast\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 \n\nnamespace Mathlib\n\nnamespace int\n\n\n/- cast (injection into groups with one) -/\n\n@[simp] theorem nat_cast_eq_coe_nat (n : ℕ) : ↑n = ↑n := sorry\n\n/-- Coercion `ℕ → ℤ` as a `ring_hom`. -/\ndef of_nat_hom : ℕ →+* ℤ := ring_hom.mk coe sorry of_nat_mul sorry of_nat_add\n\n/-- Canonical homomorphism from the integers to any ring(-like) structure `α` -/\nprotected def cast {α : Type u_1} [HasZero α] [HasOne α] [Add α] [Neg α] : ℤ → α := sorry\n\n-- see Note [coercion into rings]\n\nprotected instance cast_coe {α : Type u_1} [HasZero α] [HasOne α] [Add α] [Neg α] : has_coe_t ℤ α :=\n has_coe_t.mk int.cast\n\n@[simp] theorem cast_zero {α : Type u_1} [HasZero α] [HasOne α] [Add α] [Neg α] : ↑0 = 0 := rfl\n\ntheorem cast_of_nat {α : Type u_1} [HasZero α] [HasOne α] [Add α] [Neg α] (n : ℕ) :\n ↑(Int.ofNat n) = ↑n :=\n rfl\n\n@[simp] theorem cast_coe_nat {α : Type u_1} [HasZero α] [HasOne α] [Add α] [Neg α] (n : ℕ) :\n ↑↑n = ↑n :=\n rfl\n\ntheorem cast_coe_nat' {α : Type u_1} [HasZero α] [HasOne α] [Add α] [Neg α] (n : ℕ) : ↑↑n = ↑n :=\n sorry\n\n@[simp] theorem cast_neg_succ_of_nat {α : Type u_1} [HasZero α] [HasOne α] [Add α] [Neg α] (n : ℕ) :\n ↑(Int.negSucc n) = -(↑n + 1) :=\n rfl\n\n@[simp] theorem cast_one {α : Type u_1} [add_monoid α] [HasOne α] [Neg α] : ↑1 = 1 := nat.cast_one\n\n@[simp] theorem cast_sub_nat_nat {α : Type u_1} [add_group α] [HasOne α] (m : ℕ) (n : ℕ) :\n ↑(sub_nat_nat m n) = ↑m - ↑n :=\n sorry\n\n@[simp] theorem cast_neg_of_nat {α : Type u_1} [add_group α] [HasOne α] (n : ℕ) :\n ↑(neg_of_nat n) = -↑n :=\n nat.cases_on n (idRhs (0 = -0) (Eq.symm neg_zero))\n fun (n : ℕ) => idRhs (↑(neg_of_nat (n + 1)) = ↑(neg_of_nat (n + 1))) rfl\n\n@[simp] theorem cast_add {α : Type u_1} [add_group α] [HasOne α] (m : ℤ) (n : ℤ) :\n ↑(m + n) = ↑m + ↑n :=\n sorry\n\n@[simp] theorem cast_neg {α : Type u_1} [add_group α] [HasOne α] (n : ℤ) : ↑(-n) = -↑n :=\n int.cases_on n (fun (n : ℕ) => idRhs (↑(neg_of_nat n) = -↑n) (cast_neg_of_nat n))\n fun (n : ℕ) =>\n idRhs (↑(-Int.negSucc n) = --↑(-Int.negSucc n)) (Eq.symm (neg_neg ↑(-Int.negSucc n)))\n\n@[simp] theorem cast_sub {α : Type u_1} [add_group α] [HasOne α] (m : ℤ) (n : ℤ) :\n ↑(m - n) = ↑m - ↑n :=\n sorry\n\n@[simp] theorem cast_mul {α : Type u_1} [ring α] (m : ℤ) (n : ℤ) : ↑(m * n) = ↑m * ↑n := sorry\n\n/-- `coe : ℤ → α` as an `add_monoid_hom`. -/\ndef cast_add_hom (α : Type u_1) [add_group α] [HasOne α] : ℤ →+ α :=\n add_monoid_hom.mk coe sorry cast_add\n\n@[simp] theorem coe_cast_add_hom {α : Type u_1} [add_group α] [HasOne α] :\n ⇑(cast_add_hom α) = coe :=\n rfl\n\n/-- `coe : ℤ → α` as a `ring_hom`. -/\ndef cast_ring_hom (α : Type u_1) [ring α] : ℤ →+* α := ring_hom.mk coe sorry cast_mul sorry sorry\n\n@[simp] theorem coe_cast_ring_hom {α : Type u_1} [ring α] : ⇑(cast_ring_hom α) = coe := rfl\n\ntheorem cast_commute {α : Type u_1} [ring α] (m : ℤ) (x : α) : commute (↑m) x :=\n int.cases_on m (fun (n : ℕ) => nat.cast_commute n x)\n fun (n : ℕ) => commute.neg_left (nat.cast_commute (n + 1) x)\n\ntheorem commute_cast {α : Type u_1} [ring α] (x : α) (m : ℤ) : commute x ↑m :=\n commute.symm (cast_commute m x)\n\n@[simp] theorem coe_nat_bit0 (n : ℕ) : ↑(bit0 n) = bit0 ↑n := sorry\n\n@[simp] theorem coe_nat_bit1 (n : ℕ) : ↑(bit1 n) = bit1 ↑n := sorry\n\n@[simp] theorem cast_bit0 {α : Type u_1} [ring α] (n : ℤ) : ↑(bit0 n) = bit0 ↑n := cast_add n n\n\n@[simp] theorem cast_bit1 {α : Type u_1} [ring α] (n : ℤ) : ↑(bit1 n) = bit1 ↑n := sorry\n\ntheorem cast_two {α : Type u_1} [ring α] : ↑(bit0 1) = bit0 1 := sorry\n\ntheorem cast_mono {α : Type u_1} [ordered_ring α] : monotone coe := sorry\n\n@[simp] theorem cast_nonneg {α : Type u_1} [ordered_ring α] [nontrivial α] {n : ℤ} :\n 0 ≤ ↑n ↔ 0 ≤ n :=\n sorry\n\n@[simp] theorem cast_le {α : Type u_1} [ordered_ring α] [nontrivial α] {m : ℤ} {n : ℤ} :\n ↑m ≤ ↑n ↔ m ≤ n :=\n sorry\n\ntheorem cast_strict_mono {α : Type u_1} [ordered_ring α] [nontrivial α] : strict_mono coe :=\n strict_mono_of_le_iff_le fun (m n : ℤ) => iff.symm cast_le\n\n@[simp] theorem cast_lt {α : Type u_1} [ordered_ring α] [nontrivial α] {m : ℤ} {n : ℤ} :\n ↑m < ↑n ↔ m < n :=\n strict_mono.lt_iff_lt cast_strict_mono\n\n@[simp] theorem cast_nonpos {α : Type u_1} [ordered_ring α] [nontrivial α] {n : ℤ} :\n ↑n ≤ 0 ↔ n ≤ 0 :=\n eq.mpr (id (Eq._oldrec (Eq.refl (↑n ≤ 0 ↔ n ≤ 0)) (Eq.symm cast_zero)))\n (eq.mpr (id (Eq._oldrec (Eq.refl (↑n ≤ ↑0 ↔ n ≤ 0)) (propext cast_le))) (iff.refl (n ≤ 0)))\n\n@[simp] theorem cast_pos {α : Type u_1} [ordered_ring α] [nontrivial α] {n : ℤ} : 0 < ↑n ↔ 0 < n :=\n eq.mpr (id (Eq._oldrec (Eq.refl (0 < ↑n ↔ 0 < n)) (Eq.symm cast_zero)))\n (eq.mpr (id (Eq._oldrec (Eq.refl (↑0 < ↑n ↔ 0 < n)) (propext cast_lt))) (iff.refl (0 < n)))\n\n@[simp] theorem cast_lt_zero {α : Type u_1} [ordered_ring α] [nontrivial α] {n : ℤ} :\n ↑n < 0 ↔ n < 0 :=\n eq.mpr (id (Eq._oldrec (Eq.refl (↑n < 0 ↔ n < 0)) (Eq.symm cast_zero)))\n (eq.mpr (id (Eq._oldrec (Eq.refl (↑n < ↑0 ↔ n < 0)) (propext cast_lt))) (iff.refl (n < 0)))\n\n@[simp] theorem cast_min {α : Type u_1} [linear_ordered_ring α] {a : ℤ} {b : ℤ} :\n ↑(min a b) = min ↑a ↑b :=\n monotone.map_min cast_mono\n\n@[simp] theorem cast_max {α : Type u_1} [linear_ordered_ring α] {a : ℤ} {b : ℤ} :\n ↑(max a b) = max ↑a ↑b :=\n monotone.map_max cast_mono\n\n@[simp] theorem cast_abs {α : Type u_1} [linear_ordered_ring α] {q : ℤ} : ↑(abs q) = abs ↑q := sorry\n\ntheorem coe_int_dvd {α : Type u_1} [comm_ring α] (m : ℤ) (n : ℤ) (h : m ∣ n) : ↑m ∣ ↑n :=\n ring_hom.map_dvd (cast_ring_hom α) h\n\nend int\n\n\nnamespace add_monoid_hom\n\n\n/-- Two additive monoid homomorphisms `f`, `g` from `ℤ` to an additive monoid are equal\nif `f 1 = g 1`. -/\ntheorem ext_int {A : Type u_1} [add_monoid A] {f : ℤ →+ A} {g : ℤ →+ A}\n (h1 : coe_fn f 1 = coe_fn g 1) : f = g :=\n sorry\n\ntheorem eq_int_cast_hom {A : Type u_1} [add_group A] [HasOne A] (f : ℤ →+ A) (h1 : coe_fn f 1 = 1) :\n f = int.cast_add_hom A :=\n sorry\n\ntheorem eq_int_cast {A : Type u_1} [add_group A] [HasOne A] (f : ℤ →+ A) (h1 : coe_fn f 1 = 1)\n (n : ℤ) : coe_fn f n = ↑n :=\n iff.mp ext_iff (eq_int_cast_hom f h1)\n\nend add_monoid_hom\n\n\nnamespace monoid_hom\n\n\ntheorem ext_int {M : Type u_1} [monoid M] {f : multiplicative ℤ →* M} {g : multiplicative ℤ →* M}\n (h1 : coe_fn f (coe_fn multiplicative.of_add 1) = coe_fn g (coe_fn multiplicative.of_add 1)) :\n f = g :=\n ext fun (x : multiplicative ℤ) => iff.mp add_monoid_hom.ext_iff (add_monoid_hom.ext_int h1) x\n\nend monoid_hom\n\n\nnamespace ring_hom\n\n\n@[simp] theorem eq_int_cast {α : Type u_1} [ring α] (f : ℤ →+* α) (n : ℤ) : coe_fn f n = ↑n :=\n add_monoid_hom.eq_int_cast (to_add_monoid_hom f) (map_one f) n\n\ntheorem eq_int_cast' {α : Type u_1} [ring α] (f : ℤ →+* α) : f = int.cast_ring_hom α :=\n ext (eq_int_cast f)\n\n@[simp] theorem map_int_cast {α : Type u_1} {β : Type u_2} [ring α] [ring β] (f : α →+* β) (n : ℤ) :\n coe_fn f ↑n = ↑n :=\n eq_int_cast (comp f (int.cast_ring_hom α)) n\n\ntheorem ext_int {R : Type u_1} [semiring R] (f : ℤ →+* R) (g : ℤ →+* R) : f = g :=\n coe_add_monoid_hom_injective (add_monoid_hom.ext_int (Eq.trans (map_one f) (Eq.symm (map_one g))))\n\nprotected instance int.subsingleton_ring_hom {R : Type u_1} [semiring R] : subsingleton (ℤ →+* R) :=\n subsingleton.intro ext_int\n\nend ring_hom\n\n\n@[simp] theorem int.cast_id (n : ℤ) : ↑n = n := Eq.symm (ring_hom.eq_int_cast (ring_hom.id ℤ) n)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/int/cast_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.47657965106367595, "lm_q1q2_score": 0.24759329033606814}} {"text": "import breen_deligne.main\nimport breen_deligne.eg\nimport condensed.tensor_short_exact\nimport condensed.evaluation_homology\nimport condensed.sheafification_homology\nimport pseudo_normed_group.QprimeFP\nimport for_mathlib.AddCommGroup\nimport for_mathlib.map_to_sheaf_is_iso\nimport condensed.is_iso_iff_extrdisc\nimport Lbar.torsion_free_condensed\nimport condensed.ab5\nimport condensed.ab4\nimport for_mathlib.endomorphisms.ab4\nimport for_mathlib.homology_exact\nimport condensed.Qprime_isoms2\nimport for_mathlib.free_abelian_exact\nimport for_mathlib.unflip\nimport breen_deligne.eval_Pow_functor_nat_trans_compatibility\n\n.\n\nnoncomputable theory\n\nuniverses u\n\nopen category_theory category_theory.limits breen_deligne opposite\nopen_locale big_operators\n\nsection\nopen category_theory.preadditive\n\nattribute [simps map] AddCommGroup.free\n\nlemma oof (A B : AddCommGroup.{u}) : (A →+ B) = (A ⟶ B) := rfl\n\nlemma reorder {M : Type*} [add_comm_monoid M] (a b c d : M) :\n (a + b) + (c + d) = (a + c) + (b + d) :=\nby { simp only [add_assoc, add_left_comm b c d], }\n\ndef eval_free_π (A : AddCommGroup.{u}) (i : fin 2) : (preadditive.Pow 2).obj A ⟶ (preadditive.Pow 1).obj A :=\nbiproduct.π _ (ulift.up i) ≫ biproduct.ι (λ _, A) (ulift.up 0)\n\nlemma eval_free_π_eq (A : AddCommGroup.{u}) (k : fin 2) :\n eval_free_π A k = biproduct.matrix\n (λ (i : ulift (fin 2)) (j : ulift (fin 1)), basic_universal_map.proj 1 k j.down i.down • 𝟙 A) :=\nbegin\n apply biproduct.hom_ext, rintro ⟨j⟩, fin_cases j,\n rw [biproduct.matrix_π, eval_free_π, category.assoc, biproduct.ι_π, dif_pos rfl, eq_to_hom_refl,\n category.comp_id],\n apply biproduct.hom_ext', rintro ⟨i⟩, rw [biproduct.ι_desc],\n suffices : basic_universal_map.proj 1 k 0 i = if i = k then 1 else 0,\n { rw [this, biproduct.ι_π], dsimp, obtain (rfl|hik) := eq_or_ne i k,\n { rw [if_pos rfl, if_pos rfl, one_smul], },\n { rw [if_neg, if_neg hik, zero_smul], intro H, apply hik, apply equiv.ulift.symm.injective, exact H } },\n { dsimp [basic_universal_map.proj, basic_universal_map.proj_aux], dec_trivial! },\nend\n\ndef eval_free_σ (A : AddCommGroup.{u}) : (preadditive.Pow 2).obj A ⟶ (preadditive.Pow 1).obj A :=\neval_free_π A 0 + eval_free_π A 1\n\nlemma eval_free_d10 (A : AddCommGroup.{u}) :\n (((data.eval_functor (forget _ ⋙ AddCommGroup.free)).obj breen_deligne.eg.data).obj A).d 1 0 =\n ((forget _ ⋙ AddCommGroup.free).map $ eval_free_π A 0) +\n ((forget _ ⋙ AddCommGroup.free).map $ eval_free_π A 1) -\n ((forget _ ⋙ AddCommGroup.free).map $ eval_free_σ A) :=\nbegin\n dsimp only [eg, eg.BD, data.eval_functor_obj_obj_d], rw [dif_pos rfl],\n dsimp only [universal_map.eval_Pow], rw [lift_app],\n dsimp only [whisker_right_app, eg.map, eg.σπ, universal_map.proj, universal_map.sum],\n simp only [add_monoid_hom.map_sub, free_abelian_group.lift.of,\n basic_universal_map.eval_Pow_app, functor.comp_map, forget_map_eq_coe, sub_comp, add_comp,\n preadditive.Pow_obj, forget_obj_eq_coe, fin.sum_univ_two, add_monoid_hom.map_add],\n refine congr_arg2 _ (congr_arg2 _ _ _) _; congr' 2,\n { rw eval_free_π_eq, refl, },\n { rw eval_free_π_eq, refl, },\n { rw [eval_free_σ, eval_free_π_eq, eval_free_π_eq],\n apply biproduct.hom_ext, rintro ⟨j⟩, fin_cases j, simp only [add_comp, biproduct.matrix_π],\n erw [biproduct.matrix_π, biproduct.matrix_π],\n apply biproduct.hom_ext', rintro ⟨i⟩, simp only [comp_add, biproduct.ι_desc, ← add_smul],\n refl }\nend\n\ndef Pow_1_iso (A : AddCommGroup.{u}) : (preadditive.Pow 1).obj A ≅ A :=\n{ hom := biproduct.π (λ _, A) (ulift.up 0),\n inv := biproduct.ι (λ _, A) (ulift.up 0),\n hom_inv_id' := begin\n erw [← biproduct.total, ← equiv.ulift.symm.sum_comp, fin.sum_univ_one], refl,\n end,\n inv_hom_id' := by simp only [biproduct.ι_π, dif_pos rfl, eq_to_hom_refl] }\n\ndef Pow_2_iso (A : AddCommGroup.{u}) : (preadditive.Pow 2).obj A ≅ AddCommGroup.of (A × A) :=\n{ hom := add_monoid_hom.prod (biproduct.π (λ _, A) (ulift.up 0)) (biproduct.π (λ _, A) (ulift.up 1)),\n inv := add_monoid_hom.coprod (biproduct.ι (λ _, A) (ulift.up 0)) (biproduct.ι (λ _, A) (ulift.up 1)),\n hom_inv_id' := begin\n ext x, erw [← biproduct.total, ← equiv.ulift.symm.sum_comp, comp_apply],\n swap, apply_instance,\n dsimp only [add_monoid_hom.coprod_apply, add_monoid_hom.prod_apply],\n simp only [← comp_apply, fin.sum_univ_two], refl,\n end,\n inv_hom_id' := begin\n ext1 x, rw [comp_apply, id_apply],\n dsimp only [add_monoid_hom.coprod_apply, add_monoid_hom.prod_apply],\n simp only [add_monoid_hom.map_add, ← comp_apply, biproduct.ι_π, dif_pos rfl, eq_to_hom_refl, id_apply],\n rw [dif_neg], swap, dec_trivial,\n rw [dif_neg], swap, dec_trivial,\n erw [add_zero, zero_add], cases x, refl,\n end }\n.\n\nlemma eval_free_π_eq_fst (A : AddCommGroup.{u}) :\n (Pow_2_iso A).inv ≫ eval_free_π A 0 ≫ (Pow_1_iso A).hom =\n AddCommGroup.of_hom (add_monoid_hom.fst A A) :=\nbegin\n ext x, simp only [comp_apply],\n dsimp only [Pow_2_iso, Pow_1_iso, eval_free_π, add_monoid_hom.coprod_apply],\n simp only [← comp_apply, category.assoc, biproduct.ι_π, dif_pos rfl, eq_to_hom_refl,\n category.comp_id, add_monoid_hom.map_add, id_apply],\n erw [dif_neg, add_zero], refl, dec_trivial,\nend\n\nlemma eval_free_π_eq_snd (A : AddCommGroup.{u}) :\n (Pow_2_iso A).inv ≫ eval_free_π A 1 ≫ (Pow_1_iso A).hom =\n AddCommGroup.of_hom (add_monoid_hom.snd A A) :=\nbegin\n ext x, simp only [comp_apply],\n dsimp only [Pow_2_iso, Pow_1_iso, eval_free_π, add_monoid_hom.coprod_apply],\n simp only [← comp_apply, category.assoc, biproduct.ι_π, dif_pos rfl, eq_to_hom_refl,\n category.comp_id, add_monoid_hom.map_add, id_apply],\n erw [dif_neg, zero_add], refl, dec_trivial,\nend\n\nlemma eval_free_σ_eq_add (A : AddCommGroup.{u}) :\n (Pow_2_iso A).inv ≫ eval_free_σ A ≫ (Pow_1_iso A).hom =\n AddCommGroup.of_hom (add_monoid_hom.coprod (add_monoid_hom.id _) (add_monoid_hom.id _)) :=\nby { simp only [eval_free_σ, add_comp, comp_add, eval_free_π_eq_fst, eval_free_π_eq_snd], refl, }\n\nlemma eval_free_homology_zero_exact (A : AddCommGroup.{u}) :\n exact\n ((((data.eval_functor (forget _ ⋙ AddCommGroup.free)).obj breen_deligne.eg.data).obj A).d 1 0)\n ((forget _ ⋙ AddCommGroup.free).map (Pow_1_iso A).hom ≫ AddCommGroup.of_hom (free_abelian_group.lift id)) :=\nbegin\n let F := forget _ ⋙ AddCommGroup.free,\n refine exact_of_iso_of_exact' _ _ _ _\n (F.map_iso (Pow_2_iso A).symm) (F.map_iso (Pow_1_iso A).symm) (iso.refl _) _ _\n (free_abelian_group.exact_σπ A),\n swap,\n { dsimp only [functor.map_iso_hom, iso.symm_hom, iso.refl_hom, F],\n rw [category.comp_id, ← functor.map_iso_inv, ← functor.map_iso_hom, iso.inv_hom_id_assoc], },\n rw [← iso.comp_inv_eq, category.assoc, eval_free_d10],\n simp only [comp_add, add_comp, comp_sub, sub_comp],\n refine congr_arg2 _ (congr_arg2 _ _ _) _,\n { simp only [functor.map_iso_hom, functor.map_iso_inv, iso.symm_hom, iso.symm_inv,\n ← functor.map_comp, eval_free_π_eq_fst], refl },\n { simp only [functor.map_iso_hom, functor.map_iso_inv, iso.symm_hom, iso.symm_inv,\n ← functor.map_comp, eval_free_π_eq_snd], refl },\n { simp only [functor.map_iso_hom, functor.map_iso_inv, iso.symm_hom, iso.symm_inv,\n ← functor.map_comp, eval_free_σ_eq_add], refl },\nend\n\ninstance eval_free_homology_zero_epi (A : AddCommGroup.{u}) :\n epi ((forget _ ⋙ AddCommGroup.free).map (Pow_1_iso A).hom ≫ AddCommGroup.of_hom (free_abelian_group.lift id)) :=\nbegin\n apply_with epi_comp {instances:=ff}, apply_instance,\n rw [AddCommGroup.epi_iff_surjective], intro a,\n exact ⟨free_abelian_group.of a, free_abelian_group.lift.of _ _⟩\nend\n\nopen_locale zero_object\n\nsection\n\nvariables {𝓐 : Type*} [category 𝓐] [abelian 𝓐]\nvariables {A B C X : 𝓐} (f : A ⟶ B) (g : B ⟶ C) (γ : B ⟶ X)\n\ndef of_epi_g (hfg : exact f g) (hg : epi g) (hγ : γ = 0) :\n homology_iso_datum f γ C :=\n{ w := by rw [hγ, comp_zero],\n K := B,\n ι := 𝟙 B,\n f' := f,\n fac' := category.comp_id _,\n zero₁' := by rw [hγ, comp_zero],\n π := g,\n zero₂' := hfg.w,\n fork_is_limit := is_limit_aux _ (λ s, s.ι) (λ s, by apply category.comp_id)\n (λ s m hm, begin rw [← hm], symmetry, apply category.comp_id, end),\n cofork_is_colimit := @abelian.is_colimit_of_exact_of_epi _ _ _ _ _ _ _ _ hg hfg }\n\n@[simp] lemma of_epi_g.to_homology_iso_predatum_π\n (hfg : exact f g) (hg : epi g) (hγ : γ = 0) :\n (of_epi_g f g γ hfg hg hγ).to_homology_iso_predatum.π = g := rfl\n\nend\n\ndef nat_trans_eval_free :\n ((data.eval_functor (forget _ ⋙ AddCommGroup.free.{u})).obj breen_deligne.eg.data) ⋙\n homological_complex.eval _ _ 0 ⟶ 𝟭 AddCommGroup :=\n{ app := λ A, (forget _ ⋙ AddCommGroup.free).map (Pow_1_iso A).hom ≫\n AddCommGroup.of_hom (free_abelian_group.lift id),\n naturality' := λ A₁ A₂ f, begin\n simp only [functor.comp_map, homological_complex.eval_map, data.eval_functor_obj_map_f,\n forget_map_eq_coe, AddCommGroup.free_map, functor.id_map, category.assoc],\n ext x,\n dsimp [eg, eg.BD, eg.rank] at x,\n have h : ∃ y, x = (Pow_1_iso A₁).inv y,\n { use (Pow_1_iso A₁).hom x,\n rw [← comp_apply, iso.hom_inv_id, id_apply], },\n cases h with y hy,\n subst hy,\n simp only [comp_apply, free_abelian_group.map_of_apply, AddCommGroup.of_hom_apply,\n free_abelian_group.lift.of, id.def, iso.inv_hom_id_apply, biproduct.map_eq],\n let z : fin (eg.data.X 0) := ⟨0, begin\n dsimp [eg, eg.BD, eg.rank],\n linarith,\n end⟩,\n rw finset.sum_eq_single (ulift.up z), rotate,\n { intros b hb₁ hb₂,\n exfalso,\n apply hb₂,\n cases b,\n simp only [ulift.up_inj],\n rw fin.eq_mk_iff_coe_eq,\n have hb₃ := b.is_lt,\n dsimp [eg, eg.BD, eg.rank] at hb₃,\n linarith, },\n { intro h,\n exfalso,\n apply h,\n simp only [finset.mem_univ], },\n simp only [← comp_apply, category.assoc],\n congr' 1,\n dsimp,\n change _ ≫ (Pow_1_iso A₁).hom ≫ _ ≫ (Pow_1_iso A₂).inv ≫ _ = _,\n rw [iso.inv_hom_id, iso.inv_hom_id_assoc, category.comp_id],\n end, }\n\ndef short_complex_nat_trans_eval_free :\n ((data.eval_functor (forget _ ⋙ AddCommGroup.free)).obj breen_deligne.eg.data)\n ⋙ short_complex.functor_homological_complex _ _ 0 ⟶ short_complex.ι_middle :=\nbegin\n refine short_complex.nat_trans_hom_mk 0 nat_trans_eval_free 0 _\n (begin apply is_zero.eq_of_tgt, apply short_complex.ι_middle_π₃_is_zero, end),\n ext1, ext1 A,\n simp only [zero_comp, nat_trans.app_zero, nat_trans.hcomp_app, nat_trans.comp_app,\n nat_trans.id_app, short_complex.π₂.map_id, category.comp_id],\n dsimp only [short_complex.φ₁₂, short_complex.functor_homological_complex, functor.comp_obj,\n short_complex.mk],\n simp only [@homological_complex.d_to_eq _ _ _ _ (complex_shape.down ℕ) _ _ 1 0 (zero_add 1),\n category.assoc],\n erw [(eval_free_homology_zero_exact A).w, comp_zero],\nend\n\nlemma short_complex_nat_trans_eval_free_app_τ₂ (A : AddCommGroup) :\n (short_complex_nat_trans_eval_free.app A).τ₂ = nat_trans_eval_free.app A := rfl\n\ndef eval_free_homology_zero_nat_trans :=\nshort_complex_nat_trans_eval_free ◫ (𝟙 short_complex.homology_functor)\n\nlemma _root_.short_complex.homology_map_is_iso_of_exact_and_epi\n {A : Type*} [category A] [abelian A]\n {S₁ S₂ : short_complex A} (φ : S₁ ⟶ S₂) (hg₁ : S₁.1.g = 0) (hf₂ : S₂.1.f = 0) (hg₂ : S₂.1.g = 0)\n (ex : exact S₁.1.f φ.τ₂) (epi_τ₂ : epi φ.τ₂) :\n is_iso (short_complex.homology_functor.map φ) :=\nbegin\n let h₁ := homology_iso_datum.of_g_is_zero S₁.1.f S₁.1.g hg₁,\n let h₂ := homology_iso_datum.of_both_zeros S₂.1.f S₂.1.g hf₂ hg₂,\n let ψ := cokernel.desc _ φ.τ₂ ex.w,\n let μ : homology_map_datum φ h₁ h₂ ψ :=\n { κ := φ.τ₂,\n fac₁' := by { erw [φ.comm₁₂], simp only [hf₂], refl, },\n fac₂' := by { erw [category.id_comp, category.comp_id], },\n fac₃' := by { erw [category.comp_id], apply cokernel.π_desc, }, },\n rw μ.homology_map_eq,\n suffices : is_iso ψ,\n { haveI := this, apply_instance, },\n exact abelian.category_theory.limits.cokernel.desc.category_theory.is_iso _ _ ex,\nend\n\ninstance : is_iso eval_free_homology_zero_nat_trans.{u} :=\nbegin\n suffices : ∀ A, is_iso ((short_complex_nat_trans_eval_free ◫\n (𝟙 short_complex.homology_functor)).app A),\n { apply_with nat_iso.is_iso_of_is_iso_app { instances := ff }, exact this, },\n intro A,\n simp only [nat_trans.hcomp_id_app],\n refine short_complex.homology_map_is_iso_of_exact_and_epi _ _ rfl rfl _ _,\n { apply is_zero.eq_of_tgt,\n refine is_zero.of_iso (is_zero_zero _) _,\n apply homological_complex.X_next_iso_zero,\n rcases h : (complex_shape.down ℕ).next 0 with _ | ⟨i, hi⟩,\n { refl, },\n { exfalso,\n change i+1=0 at hi,\n simpa only using hi, }, },\n { refine exact_of_iso_of_exact' _ _ _ _ _ _ _ _ _ (eval_free_homology_zero_exact A),\n { symmetry,\n exact (homological_complex.X_prev_iso _ (zero_add 1)), },\n { refl, },\n { apply eq_to_iso, cases A, refl, },\n { dsimp only [short_complex.functor_homological_complex, functor.comp_obj,\n short_complex.mk],\n rw homological_complex.d_to_eq, swap 3, exact 1, swap, dsimp, refl,\n simp only [iso.symm_hom, iso.refl_hom, category.comp_id],\n apply iso.inv_hom_id_assoc, },\n { apply category.id_comp, }, },\n { rw short_complex_nat_trans_eval_free_app_τ₂,\n dsimp [nat_trans_eval_free],\n convert eval_free_homology_zero_epi.{u} A,\n cases A,\n refl, },\nend\n\ndef eval_free_homology_zero :\n ((data.eval_functor (forget _ ⋙ AddCommGroup.free)).obj breen_deligne.eg.data) ⋙\n homology_functor _ _ 0 ≅ 𝟭 _ :=\n iso_whisker_left _ (short_complex.homology_functor_iso _ _ _) ≪≫\n (functor.associator _ _ _).symm ≪≫ as_iso eval_free_homology_zero_nat_trans ≪≫\n short_complex.ι_middle_homology_nat_iso.symm\n\nend\n\nopen bounded_homotopy_category\n\nnamespace Condensed\n\ndef HQ'Z (n : ℤ) : Ab :=\n((eg.eval $ category_theory.forget AddCommGroup ⋙ AddCommGroup.free).obj\n (AddCommGroup.free.obj punit)).val.as.homology n\n\nvariables (BD : package)\n\n-- `by apply_instance` takes for ever, so we provide this shortcut\ninstance : abelian (endomorphisms $ Condensed.{u} Ab.{u+1}) :=\nendomorphisms.category_theory.abelian\n\n-- `by apply_instance` takes for ever, so we provide this shortcut\ninstance : has_finite_biproducts (endomorphisms $ Condensed.{u} Ab.{u+1}) :=\nabelian.has_finite_biproducts\n\n-- `by apply_instance` takes for ever, so we provide this shortcut\ninstance : enough_projectives (endomorphisms $ Condensed.{u} Ab.{u+1}) :=\nendomorphisms.category_theory.enough_projectives\n\n-- `by apply_instance` takes for ever, so we provide this shortcut\ninstance : has_coproducts_of_shape (ulift.{u+1} ℕ) (endomorphisms $ Condensed.{u} Ab.{u+1}) :=\nendomorphisms.has_colimits_of_shape\n\n-- `by apply_instance` takes for ever, so we provide this shortcut\ninstance : has_products_of_shape (ulift ℕ) (endomorphisms $ Condensed.{u} Ab.{u+1}) :=\nendomorphisms.has_limits_of_shape\n\n-- `by apply_instance` takes for ever, so we provide this shortcut\ninstance : has_coproducts (endomorphisms $ Condensed.{u} Ab.{u+1}) :=\nλ (J : Type (u+1)), endomorphisms.has_colimits_of_shape\n\n-- `by apply_instance` takes for ever, so we provide this shortcut\ninstance : AB4 (endomorphisms $ Condensed.{u} Ab.{u+1}) :=\nendomorphisms.category_theory.AB4 _\n\n-- `by apply_instance` takes for ever, so we provide this shortcut\ninstance : has_finite_limits (endomorphisms $ Condensed.{u} Ab.{u+1}) :=\nabelian.has_finite_limits\n\n-- `by apply_instance` takes for ever, so we provide this shortcut\ninstance : has_finite_colimits (endomorphisms $ Condensed.{u} Ab.{u+1}) :=\nabelian.has_finite_colimits\n.\n\n-- move this\nattribute [reassoc] homology_bd_eval_natural\n\ndef exists_tensor_iso (A : endomorphisms (Condensed.{u} Ab.{u+1}))\n [∀ S : ExtrDisc.{u}, no_zero_smul_divisors ℤ (A.X.val.obj (op S.val))]\n (n : ℕ) :\n ((package.endo_T tensor_functor).obj A).obj (HQ'Z (-n)) ≅\n ((eg.eval freeCond'.map_endomorphisms).obj A).val.as.homology (-n) :=\nbegin\n refine endomorphisms.mk_iso _ _,\n { refine _ ≪≫ ((package.hH_endo₁ eg freeCond' n).app A).symm,\n refine (homology_bd_eval eg A.X (-n)).symm ≪≫ _,\n exact (package.eval'_homology eg freeCond' n).app A.X, },\n { dsimp only [iso.trans_hom, iso.symm_hom, package.endo_T_obj_obj_e, tensor_functor, HQ'Z],\n simp only [category.assoc, ← homology_bd_eval_natural_assoc],\n refine congr_arg2 _ rfl _,\n dsimp only [iso.app_hom, iso.app_inv],\n rw [← functor.comp_map, nat_trans.naturality_assoc],\n refine congr_arg2 _ rfl _,\n dsimp only [← iso.app_inv],\n rw [iso.comp_inv_eq, category.assoc, iso.eq_inv_comp],\n exact (eg.hH_endo₁_natural freeCond' A n).symm, }\nend\n.\n\n-- move this\nlemma is_tensor_unit_of_iso (A B : Ab) (e : A ≅ B) (ha : AddCommGroup.is_tensor_unit A) :\n AddCommGroup.is_tensor_unit B :=\nbegin\n obtain ⟨a, ha⟩ := ha,\n refine ⟨e.hom a, _⟩,\n intro C, specialize ha C,\n let φ := iso.AddCommGroup_iso_to_add_equiv ((preadditive_yoneda.obj C).map_iso e.op),\n exact ha.comp φ.bijective,\nend\n\nlemma bd_lemma (A : Condensed.{u} Ab.{u+1}) (B : Condensed.{u} Ab.{u+1})\n [∀ S : ExtrDisc.{u}, no_zero_smul_divisors ℤ (A.val.obj (op S.val))]\n (f : A ⟶ A) (g : B ⟶ B) :\n (∀ i, is_iso $ ((Ext' i).map f.op).app B - ((Ext' i).obj (op A)).map g) ↔\n (∀ i, is_iso $\n ((Ext i).map ((breen_deligne.eg.eval freeCond').map f).op).app ((single _ 0).obj B) -\n ((Ext i).obj (op $ (breen_deligne.eg.eval freeCond').obj A)).map ((single _ 0).map g)) :=\nbegin\n apply eg.main_lemma_general' _ A B f g tensor_functor tensor_punit (λ n, HQ'Z (-n)),\n { apply tensor_tunit,\n apply is_tensor_unit_of_iso\n (AddCommGroup.free.obj punit) (HQ'Z 0),\n { let e := (eval_free_homology_zero.app (AddCommGroup.free.obj punit)).symm,\n refine e ≪≫ _, clear e,\n let e := (package.eval'_homology eg (forget AddCommGroup ⋙ AddCommGroup.free) 0).symm,\n exact e.app (AddCommGroup.free.obj punit), },\n { refine ⟨free_abelian_group.of punit.star, _⟩,\n intro B, split,\n { intros f g h, ext ⟨⟩, exact h },\n { intros b, refine ⟨free_abelian_group.lift (λ _, b), _⟩,\n apply free_abelian_group.lift.of } } },\n { apply exists_tensor_iso }\nend\n\nend Condensed\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/condensed/bd_lemma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5506073802837477, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.24743890118145312}} {"text": "import Mt.Thread.Traced\nimport Mt.System.Basic\nimport Mt.System.BasicAux\nimport Mt.Utils.List\n\nnamespace Mt.Traced\n\nstructure TracedSystem (spec : Spec) where\n state : spec.State\n threads : List (TracedThread spec)\n\nnamespace TracedSystem\n\nvariable {spec : Spec}\n\nlocal instance : IsReservation spec.Reservation :=spec.is_reservation\n\ndef ThreadIndex (s : TracedSystem spec) : Type :=Fin s.threads.length\ndef done (s : TracedSystem spec) : Bool :=s.threads.length = 0\n\ndef iterate (s : TracedSystem spec) (idx : s.ThreadIndex) : Thread.IterationResult spec :=\n (s.threads.get idx).iterate s.state\n\ndef update_thread (s : TracedSystem spec) (idx : Nat) (state : spec.State)\n (r : spec.Reservation) (cont : Thread spec) : TracedSystem spec :={\n state\n threads :=s.threads.set idx ⟨cont, r⟩\n}\n\ndef remove_thread (s : TracedSystem spec) (idx : Nat) (state : spec.State)\n : TracedSystem spec :={\n state\n threads :=s.threads.eraseIdx idx\n}\n\ndef reservations (s : TracedSystem spec) : spec.Reservation :=\n s.threads.foldl (λ env_r thread => env_r + thread.reservation) spec.is_reservation.empty\n\ndef other_reservations (s : TracedSystem spec) (idx : Nat) : spec.Reservation :=\n (s.threads.eraseIdx idx).foldl (λ env_r thread => env_r + thread.reservation) spec.is_reservation.empty\n\ntheorem decompose_reservations (s : TracedSystem spec) (idx : s.ThreadIndex) :\n s.reservations = s.other_reservations idx.val + (s.threads.get idx).reservation :=\n System.Traced.decompose_reservation s.threads idx _ rfl\n\nstructure valid (s : TracedSystem spec) : Prop where\n currently_valid : spec.validate s.reservations s.state\n threads_valid : ∀ t, t ∈ s.threads → t.valid \n\ndef to_system (s : TracedSystem spec) : System spec :={\n state := s.state\n threads := s.threads.map λ ⟨t, _⟩ => t\n panics := 0\n}\n\ndef mk_initial (s : System spec) : TracedSystem spec :={\n state := s.state\n threads := s.threads.map λ t => ⟨t, IsReservation.empty⟩\n}\n\ntheorem mk_initial.valid (s : System spec)\n (initial_valid : spec.validate IsReservation.empty s.state)\n (threads_valid : ∀ t, t ∈ s.threads → t.valid)\n : (mk_initial s).valid :=by\n constructor\n . simp only [mk_initial]\n induction s.threads\n . exact initial_valid\n . rename_i head tail IH\n simp only [List.map, Traced.TracedSystem.reservations, List.foldl, IsReservation.empty_add]\n exact IH\n . intro t t_hyp\n simp only [mk_initial] at t_hyp\n cases Utils.List.eq_of_in_map t_hyp\n rename_i t_orig t_orig_hyp\n rw [t_orig_hyp.right]\n exact threads_valid t_orig t_orig_hyp.left\n\ntheorem mk_initial.cancels_to_system {s : System spec}\n (no_panics_yet : s.panics = 0)\n :\n (mk_initial s).to_system = s :=by\n simp only [mk_initial, to_system]\n rw [System.mk.injEq]\n constructor\n . rfl\n constructor\n . induction s.threads\n . rfl\n . rename_i head tail IH\n simp only [List.map]\n rw [IH]\n . exact no_panics_yet.symm\n\ntheorem valid_by_iteration (s s' : System spec)\n {idx : s.ThreadIndex}\n {ts : TracedSystem spec}\n (has_traced_system : s = ts.to_system)\n (ts_valid : ts.valid)\n (iteration : s.iterate idx = s')\n : ∃ ts' : TracedSystem spec,\n ts'.to_system = s' ∧ ts'.valid :=by\n \n simp only [System.iterate] at iteration\n cases blocked_until : (s.threads.get idx).block_until s.state\n <;> simp only [blocked_until, ite_true, ite_false] at iteration\n . exists ts\n simp only [<- iteration, has_traced_system, ts_valid]\n \n have ts_state_eq : ts.state = s.state :=by rw [has_traced_system] ; rfl\n\n let idx' : ts.ThreadIndex :=Utils.Fin.cast idx (by\n rw [has_traced_system]\n exact List.length_map ..)\n have get_idx' : (ts.threads.get idx').thread = s.threads.get idx :=by\n have :=congrArg System.threads has_traced_system\n rw [Utils.List.get_congr idx this]\n simp only [to_system, Utils.List.get_of_map]\n rfl\n \n let env_r :=ts.other_reservations idx.val\n have decompose : ts.reservations = env_r + _ :=ts.decompose_reservations idx'\n\n have t_valid :=TracedThread.valid_elim\n (ts_valid.threads_valid (ts.threads.get idx') (Utils.List.get_in ..))\n env_r s.state\n (by\n simp only [TracedThread.block_until, get_idx']\n exact blocked_until)\n (by\n rw [<- decompose, <- ts_state_eq]\n exact ts_valid.currently_valid)\n cases t_valid\n rename_i r' t_valid\n rw [TracedThread.iterate, get_idx'] at t_valid\n\n cases h : (s.threads.get idx).iterate s.state\n <;> simp only [h] at iteration\n <;> simp only [h] at t_valid\n\n . rename_i state\n exists ts.remove_thread idx.val state\n rw [<- iteration] ; clear iteration s'\n simp only [remove_thread]\n constructor\n . simp only [to_system, has_traced_system, System.mk.injEq, and_true, true_and]\n exact Utils.List.erase_map_commutes ..\n . rw [t_valid.right, IsReservation.toIsCommutative.comm, IsReservation.empty_add] at t_valid\n constructor\n . exact t_valid.left\n . intro t (t_hyp : t ∈ ts.threads.eraseIdx idx.val)\n exact ts_valid.threads_valid t <| Utils.List.erase_subset _ _ t_hyp\n . rename_i state cont\n exists ts.update_thread idx.val state r' cont\n rw [<- iteration] ; clear iteration s'\n simp only [update_thread]\n constructor\n . simp only [to_system, System.mk.injEq, true_and, has_traced_system, and_true]\n exact Utils.List.set_map_commutes ..\n . constructor\n . let ts' :=ts.update_thread idx.val state r' cont\n show spec.validate ts'.reservations ts'.state\n \n let idx'' : ts'.ThreadIndex :=⟨idx.val, by calc\n idx.val < ts.threads.length :=idx'.isLt\n _ = ts'.threads.length :=Eq.symm <| List.length_set ..⟩\n have decompose' :=ts'.decompose_reservations idx''\n\n conv at decompose' =>\n rhs\n conv =>\n arg 1\n simp only [other_reservations, update_thread, Utils.List.erase_set]\n conv =>\n arg 2\n simp only [update_thread, Utils.List.get_of_set]\n arg 1\n change env_r\n \n rw [decompose']\n exact t_valid.left\n . intro t (t_hyp : t ∈ ts.threads.set idx.val ⟨cont, r'⟩)\n cases Utils.List.set_subset _ _ _ t_hyp <;> rename_i t_hyp\n . rw [t_hyp]\n exact t_valid.right\n . exact ts_valid.threads_valid t t_hyp\n\nend TracedSystem\n\nend Mt.Traced", "meta": {"author": "mirkootter", "repo": "lean-mt", "sha": "027a16555d487e46a0a00611b8039655378dfdd5", "save_path": "github-repos/lean/mirkootter-lean-mt", "path": "github-repos/lean/mirkootter-lean-mt/lean-mt-027a16555d487e46a0a00611b8039655378dfdd5/Mt/System/Traced.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.4225046348141882, "lm_q1q2_score": 0.2472079433725687}} {"text": "import Radon.setup\n\nopen_locale nnreal big_operators classical\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\nopen topological_space\n\nlocal attribute [instance]\n locally_constant.seminormed_add_comm_group\n locally_constant.pseudo_metric_space\n\nnamespace Profinite\n\n/--\nThe space of signed `p`-Radon measures on `X`, bounded by `c`.\n-/\n@[derive topological_space]\ndef Radon (X : Profinite.{0}) (p c : ℝ≥0) :\n Top.{0} :=\nTop.of { μ : weak_dual ℝ C(X,ℝ) // μ.bdd p c }\n\n/--\nThe space of signed `p`-Radon measures on `X`, bounded by `c`.\nThis is a variant of `Radon` which uses the dual of locally constant functions\nas opposed to continuous functions, to be used an an auxiliary declaration in the\nconstructions below.\n-/\n@[derive topological_space]\ndef Radon_LC (X : Profinite.{0}) (p c : ℝ≥0) :\n Top.{0} :=\nTop.of { μ : weak_dual ℝ (locally_constant X ℝ) // μ.bdd_LC p c }\n\n/--\nA continuous map `X → Y` induces a map between spaces of `p`-Radon measures\nwith a given bound.\n-/\ndef map_Radon {X Y : Profinite.{0}} (f : X ⟶ Y)\n (p c : ℝ≥0) [fact (0 < p)] :\n X.Radon p c ⟶ Y.Radon p c :=\n{ to_fun := λ μ, ⟨weak_dual.comap f.comap μ.1,\n weak_dual.bdd_comap _ μ.2 _⟩,\n continuous_to_fun := begin\n apply continuous.subtype_mk,\n refine continuous.comp _ continuous_subtype_coe,\n exact continuous_linear_map.continuous _,\n end }\n\n/--\nA continuous map `X → Y` induces a map between spaces of `p`-Radon measures\nwith a given bound. (This is the locally constant variant.)\n-/\ndef map_Radon_LC {X Y : Profinite.{0}} (f : X ⟶ Y)\n (p c : ℝ≥0) [fact (0 < p)] :\n X.Radon_LC p c ⟶ Y.Radon_LC p c :=\n{ to_fun := λ μ, ⟨weak_dual.comap f.comap_LC μ.1,\n weak_dual.bdd_LC_comap _ μ.2 _⟩,\n continuous_to_fun := begin\n apply continuous.subtype_mk,\n refine continuous.comp _ continuous_subtype_coe,\n exact continuous_linear_map.continuous _,\n end }\n\n/--\nThe functor sending a topological space to the space of `p`-Radon\nmeasures bounded by `c`.\n-/\ndef Radon_functor (p c : ℝ≥0) [fact (0 < p)] :\n Profinite.{0} ⥤ Top.{0} :=\n{ obj := λ X, X.Radon p c,\n map := λ X Y f, map_Radon f _ _,\n map_id' := λ X, by { ext, dsimp [map_Radon, weak_dual.comap], congr' 1,\n ext, refl },\n map_comp' := λ X Y Z f g, by { ext, refl } }\n\n/--\nThe functor sending a topological space to the space of `p`-Radon\nmeasures bounded by `c`. This is the locally constant variant.\n-/\ndef Radon_LC_functor (p c : ℝ≥0) [fact (0 < p)] :\n Profinite.{0} ⥤ Top.{0} :=\n{ obj := λ X, X.Radon_LC p c,\n map := λ X Y f, map_Radon_LC f _ _,\n map_id' := λ X,\n by { ext, dsimp [map_Radon_LC, weak_dual.comap], congr' 1, ext, refl },\n map_comp' := λ X Y Z f g, by { ext, refl } }\n\n\n/--\nAn auxiliary definition to be used in the constructions below.\n-/\ndef weak_dual_C_to_LC (X : Profinite.{0}) :\n weak_dual ℝ C(X,ℝ) →L[ℝ] weak_dual ℝ (locally_constant X ℝ) :=\nweak_dual.comap $ lc_to_c _\n\nlemma dense_range_coe₂ (X : Profinite.{0}) :\n dense_range (λ p : locally_constant X ℝ × locally_constant X ℝ,\n (lc_to_c X p.1, lc_to_c X p.2)) :=\nbegin\n letI : uniform_space (locally_constant.pkg X ℝ).space :=\n (locally_constant.pkg X ℝ).uniform_struct,\n exact (locally_constant.pkg X ℝ).dense.prod_map (locally_constant.pkg X ℝ).dense\nend\n\n/--\nAn auxiliary definition to be used in the constructions below.\n-/\ndef weak_dual_LC_to_C (X : Profinite.{0}) :\n weak_dual ℝ (locally_constant X ℝ) →ₗ[ℝ] weak_dual ℝ C(X,ℝ) :=\n{ to_fun := λ f,\n { to_fun := (locally_constant.pkg X ℝ).extend f,\n map_add' := begin\n letI : uniform_space (locally_constant.pkg X ℝ).space :=\n (locally_constant.pkg X ℝ).uniform_struct,\n letI : add_group (locally_constant.pkg X ℝ).space :=\n continuous_map.add_group,\n letI : topological_add_group (locally_constant.pkg X ℝ).space :=\n continuous_map.topological_add_group,\n rw ← prod.forall',\n refine is_closed_property (dense_range_coe₂ X) _ _,\n { apply is_closed_eq,\n { refine (locally_constant.pkg X ℝ).continuous_extend.comp continuous_add },\n { refine continuous.add _ _;\n refine (locally_constant.pkg X ℝ).continuous_extend.comp _,\n exact continuous_fst,\n exact continuous_snd } },\n { rintro ⟨φ, ψ⟩, dsimp only,\n have hf := continuous_linear_map.uniform_continuous f,\n rw [← (lc_to_c X).map_add],\n erw [(locally_constant.pkg X ℝ).extend_coe hf, (locally_constant.pkg X ℝ).extend_coe hf,\n (locally_constant.pkg X ℝ).extend_coe hf, map_add], }\n end,\n map_smul' := begin\n letI : uniform_space (locally_constant.pkg X ℝ).space :=\n (locally_constant.pkg X ℝ).uniform_struct,\n letI : add_group (locally_constant.pkg X ℝ).space :=\n continuous_map.add_group,\n letI : topological_add_group (locally_constant.pkg X ℝ).space :=\n continuous_map.topological_add_group,\n letI : has_smul ℝ (locally_constant.pkg X ℝ).space :=\n continuous_map.has_smul,\n letI : has_continuous_smul ℝ (locally_constant.pkg X ℝ).space :=\n continuous_map.has_continuous_smul,\n intros r φ,\n apply (locally_constant.pkg X ℝ).induction_on φ; clear φ,\n { apply is_closed_eq,\n { refine (locally_constant.pkg X ℝ).continuous_extend.comp\n (continuous_const.smul continuous_id), },\n { refine continuous_const.smul (locally_constant.pkg X ℝ).continuous_extend } },\n { intro φ,\n have hf := continuous_linear_map.uniform_continuous f,\n erw [← (lc_to_c X).map_smul, (locally_constant.pkg X ℝ).extend_coe hf,\n (locally_constant.pkg X ℝ).extend_coe hf, map_smul],\n refl }\n end,\n cont := (locally_constant.pkg X ℝ).continuous_extend },\n map_add' := begin\n letI : uniform_space (locally_constant.pkg X ℝ).space :=\n (locally_constant.pkg X ℝ).uniform_struct,\n intros f g, ext ff, dsimp,\n apply (locally_constant.pkg X ℝ).induction_on ff,\n { apply is_closed_eq,\n apply (locally_constant.pkg X ℝ).continuous_extend, apply_instance,\n let G : C(X,ℝ) → ℝ × ℝ := λ ff,\n ((locally_constant.pkg X ℝ).extend f ff, (locally_constant.pkg X ℝ).extend g ff),\n change continuous ((λ a : ℝ × ℝ, a.1 + a.2) ∘ G),\n refine continuous.comp continuous_add _,\n apply continuous.prod_mk,\n apply (locally_constant.pkg X ℝ).continuous_extend, apply_instance,\n apply (locally_constant.pkg X ℝ).continuous_extend, apply_instance },\n { intros a,\n rw [(locally_constant.pkg X ℝ).extend_coe],\n rw [(locally_constant.pkg X ℝ).extend_coe],\n rw [(locally_constant.pkg X ℝ).extend_coe],\n refl,\n any_goals { apply continuous_linear_map.uniform_continuous },\n any_goals { apply_instance } },\n end,\n map_smul' := begin\n letI : uniform_space (locally_constant.pkg X ℝ).space :=\n (locally_constant.pkg X ℝ).uniform_struct,\n intros r f, ext ff, dsimp,\n apply (locally_constant.pkg X ℝ).induction_on ff,\n { apply is_closed_eq,\n apply (locally_constant.pkg X ℝ).continuous_extend, apply_instance,\n refine continuous.comp (continuous_mul_left r) _,\n apply (locally_constant.pkg X ℝ).continuous_extend, apply_instance },\n { intros a,\n rw [(locally_constant.pkg X ℝ).extend_coe],\n rw [(locally_constant.pkg X ℝ).extend_coe],\n refl,\n any_goals { apply_instance },\n exact f.uniform_continuous,\n exact (r • f).uniform_continuous },\n end }\n\nend Profinite\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/Radon/defs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6297746213017459, "lm_q2_score": 0.3923368301671084, "lm_q1q2_score": 0.24708377864121808}} {"text": "/-\nThis file translates the autogenerated data and constraints to the form used in the formalization.\n-/\nimport starkware.cairo.lean.semantics.air_encoding.constraints_autogen\nimport starkware.cairo.lean.semantics.air_encoding.constraints\nimport starkware.cairo.lean.semantics.air_encoding.memory\nimport starkware.cairo.lean.semantics.air_encoding.range_check\n\nopen_locale classical big_operators\n\nnoncomputable theory\n\nvariables {F : Type*} [field F] [fintype F]\n\n/- interpreting instruction constraints -/\n\ndef cpu__decode.to_instruction_constraints {c : columns F} (cd : cpu__decode c)\n (j : nat) :\n instruction_constraints\n (c.cpu__decode__instruction (j * 16)) -- inst\n (c.cpu__decode__off1 (j * 16)) -- off_op0_tilde\n (c.cpu__decode__off2 (j * 16)) -- off_op1_tilde\n (c.cpu__decode__off0 (j * 16)) -- off_dst_tilde\n (λ k : fin 16, c.cpu__decode__opcode_rc__column (j * 16 + k)) -- f_tilde\n :=\n{ h_instruction :=\n begin\n dsimp,\n have := cd.opcode_rc_input (j * 16) (by simp),\n rw [eq_of_sub_eq_zero this, add_zero],\n ring\n end,\n h_bit :=\n begin\n intro k, dsimp [tilde_type.to_f, column.off],\n have : ↑(k.succ) = ↑k + 1, by simp,\n rw [this, mul_sub, add_zero, add_zero, ←add_assoc, mul_one],\n have : ¬(j * 16 + ↑k) % 16 = 15,\n { rw [add_comm, nat.add_mul_mod_self_right], apply ne_of_lt,\n rw [nat.mod_eq_of_lt (lt_trans k.prop (nat.lt_succ_self _))],\n apply k.prop },\n have h := cd.opcode_rc__bit (j * 16 + k) this,\n rw [←two_mul, column.off] at h,\n exact h,\n end,\n h_last_value :=\n begin\n dsimp,\n have : (j * 16 + 15) % 16 = 15,\n { rw [add_comm, nat.add_mul_mod_self_right, nat.mod_eq_of_lt (nat.lt_succ_self _)] },\n exact cd.opcode_rc__zero (j * 16 + 15) this\n end }\n\n /- interpreting execution step constraints -/\n\ndef cpu__operands.to_step_constraints {c : columns F} {inp : input_data F} (ops : cpu__operands c)\n (upd : cpu__update_registers inp c) (opcodes : cpu__opcodes c)\n (j : ℕ) (hj : j ≠ inp.trace_length / 16 - 1) :\n step_constraints\n (c.cpu__decode__off1 (j * 16)) -- off_op0_tilde\n (c.cpu__decode__off2 (j * 16)) -- off_op1_tilde\n (c.cpu__decode__off0 (j * 16)) -- off_dst_tilde\n (λ k : fin 16, c.cpu__decode__opcode_rc__column (j * 16 + k)) -- f_tilde\n (c.cpu__registers__fp (j * 16)) -- fp\n (c.cpu__registers__ap (j * 16)) -- ap\n (c.cpu__decode__pc (j * 16)) -- pc\n (c.cpu__registers__fp ((j + 1) * 16)) -- next fp\n (c.cpu__registers__ap ((j + 1) * 16)) -- next ap\n (c.cpu__decode__pc ((j + 1) * 16)) -- next pc\n (c.cpu__operands__mem_dst__addr (j * 16)) -- dst_addr\n (c.cpu__operands__mem_op0__addr (j * 16)) -- op0_addr\n (c.cpu__operands__mem_op1__addr (j * 16)) -- op1_addr\n (c.cpu__operands__mem_dst__value (j * 16)) -- dst\n (c.cpu__operands__mem_op0__value (j * 16)) -- op0\n (c.cpu__operands__mem_op1__value (j * 16)) -- op1\n :=\nhave h0 : (j * 16 % 16 = 0), by simp,\nhave h1 : ¬ (j * 16 = 16 * (inp.trace_length / 16 - 1)),\n by { rwa [mul_comm, mul_right_inj' _], norm_num },\n{ mul := c.cpu__operands__ops_mul (j * 16),\n res := c.cpu__operands__res (j * 16),\n t0 := c.cpu__update_registers__update_pc__tmp0 (j * 16),\n t1 := c.cpu__update_registers__update_pc__tmp1 (j * 16),\n h_dst_addr :=\n begin\n simp [tilde_type.f_dst_reg, tilde_type.to_f, column.off, two_mul],\n have h := ops.mem_dst_addr _ h0,\n simp [column.off] at h,\n rw [sub_eq_zero] at h,\n rw ←sub_eq_iff_eq_add.mpr h.symm,\n ring\n end,\n h_op0_addr :=\n begin\n simp [tilde_type.f_op0_reg, tilde_type.to_f, column.off, two_mul],\n have h := ops.mem0_addr _ h0,\n simp [column.off] at h,\n rw [sub_eq_zero] at h,\n rw ←sub_eq_iff_eq_add.mpr h.symm,\n ring\n end,\n h_op1_addr :=\n begin\n have coe3 : ↑(3 : fin 15) = 3 := fin.coe_eq_val _,\n have coe4 : ↑(4 : fin 15) = 4 := fin.coe_eq_val _,\n simp [tilde_type.f_op1_imm, tilde_type.f_op1_ap, tilde_type.f_op1_fp,\n tilde_type.to_f, column.off, two_mul, coe3, coe4],\n have h := ops.mem1_addr _ h0,\n simp [column.off] at h,\n rw [sub_eq_zero] at h,\n rw ←sub_eq_iff_eq_add.mpr h.symm,\n ring,\n end,\n h_mul := eq_of_sub_eq_zero (ops.ops_mul _ h0),\n h_res :=\n begin\n have coe5 : ↑(5 : fin 15) = 5 := fin.coe_eq_val _,\n have coe6 : ↑(6 : fin 15) = 6 := fin.coe_eq_val _,\n have coe9 : ↑(9 : fin 15) = 9 := fin.coe_eq_val _,\n simp [tilde_type.f_pc_jnz, tilde_type.f_res_add, tilde_type.f_res_mul,\n tilde_type.to_f, column.off, coe5, coe6, coe9, two_mul],\n have h := ops.res _ h0,\n rw [sub_eq_zero] at h,\n transitivity,\n apply h,\n norm_num, ring,\n end,\n h_t0_eq :=\n begin\n simp [tilde_type.f_pc_jnz, tilde_type.to_f, column.off, two_mul],\n exact eq_of_sub_eq_zero (upd.update_pc__tmp0 _ ⟨h0, h1⟩)\n end,\n h_t1_eq := eq_of_sub_eq_zero (upd.update_pc__tmp1 _ ⟨h0, h1⟩),\n h_next_pc_eq :=\n begin\n have coe9 : ↑(9 : fin 15) = 9 := fin.coe_eq_val _,\n dsimp,\n simp only [tilde_type.f_pc_jnz, tilde_type.f_op1_imm, tilde_type.to_f, column.off, coe9,\n two_mul, add_zero, fin.coe_two, fin.coe_succ, fin.coe_cast_succ, add_mul],\n have h := upd.update_pc__pc_cond_positive _ ⟨h0, h1⟩,\n convert h using 2,\n simp [column.off], ring\n end,\n h_next_pc_eq' :=\n begin\n dsimp,\n have coe7 : ↑(7 : fin 15) = 7 := fin.coe_eq_val _,\n have coe8 : ↑(8 : fin 15) = 8 := fin.coe_eq_val _,\n have coe9 : ↑(9 : fin 15) = 9 := fin.coe_eq_val _,\n rw ←upd.update_pc__pc_cond_negative _ ⟨h0, h1⟩,\n simp [tilde_type.f_pc_jnz, tilde_type.f_pc_jump_abs, tilde_type.f_pc_jump_rel,\n tilde_type.f_op1_imm, tilde_type.to_f, column.off, coe7, coe8, coe9,\n two_mul, add_zero, add_mul, fin.coe_two, fin.coe_succ, fin.coe_cast_succ],\n ring\n end,\n h_opcode_call :=\n begin\n rw ←opcodes.call__push_fp _ h0,\n dsimp,\n simp only [tilde_type.f_opcode_call, tilde_type.to_f, column.off, add_zero, fin.coe_succ,\n fin.coe_cast_succ, ←two_mul],\n refl\n end,\n h_opcode_call' :=\n begin\n have coe12 : ↑(12 : fin 15) = 12 := fin.coe_eq_val _,\n rw ←opcodes.call__push_pc _ h0,\n dsimp,\n simp only [tilde_type.f_opcode_call, tilde_type.f_op1_imm, tilde_type.to_f, column.off,\n add_zero, fin.coe_succ, fin.coe_cast_succ, ←two_mul, coe12],\n ring\n end,\n h_opcode_assert_eq :=\n begin\n have coe14 : ↑(14 : fin 15) = 14 := fin.coe_eq_val _,\n rw ←opcodes.assert_eq__assert_eq _ h0,\n dsimp,\n simp only [tilde_type.f_opcode_assert_eq, tilde_type.to_f, column.off, add_zero, fin.coe_succ,\n fin.coe_cast_succ, ←two_mul, coe14]\n end,\n h_next_ap :=\n begin\n have coe10 : ↑(10 : fin 15) = 10 := fin.coe_eq_val _,\n have coe11 : ↑(11 : fin 15) = 11 := fin.coe_eq_val _,\n have coe12 : ↑(12 : fin 15) = 12 := fin.coe_eq_val _,\n dsimp,\n simp only [add_mul, one_mul, column.off, add_zero],\n transitivity,\n { exact eq_of_sub_eq_zero (upd.update_ap__ap_update _ ⟨h0, h1⟩) },\n simp only [tilde_type.f_opcode_call, tilde_type.f_ap_add, tilde_type.f_ap_add1,\n tilde_type.to_f, column.off, fin.coe_succ, fin.coe_cast_succ, coe10, coe11, coe12,\n ←two_mul],\n norm_num, ring\n end,\n h_next_fp :=\n begin\n have coe12 : ↑(12 : fin 15) = 12 := fin.coe_eq_val _,\n have coe13 : ↑(13 : fin 15) = 13 := fin.coe_eq_val _,\n dsimp,\n simp only [add_mul, one_mul, column.off, add_zero],\n transitivity,\n { exact eq_of_sub_eq_zero (upd.update_fp__fp_update _ ⟨h0, h1⟩) },\n simp only [tilde_type.f_opcode_call, tilde_type.f_opcode_ret,\n tilde_type.to_f, column.off, fin.coe_succ, fin.coe_cast_succ,\n coe12, coe13, ←two_mul],\n norm_num, ring\n end }\n\n/-\ninterpreting range check constraints\n\nNote: there are inp.trace_length / 16 - 1 steps (so the execution trace, including\nthe last step, has length inp.trace_length / 16), but there are inp.trace_length / 16\nmany 16-bit range-checked elements.\n-/\n\ndef rc16.to_range_check_constraints\n {c : columns F}\n {ci : columns_inter F}\n {inp : input_data F}\n {pd : public_data F}\n (rc16 : rc16 inp pd c ci)\n (trace_length_pos : inp.trace_length > 0)\n (public_memory_prod_eq_one : pd.rc16__perm__public_memory_prod = 1)\n (trace_length_le_char : inp.trace_length ≤ ring_char F) :\n range_check_constraints\n (inp.trace_length / 16 - 1) -- T\n (inp.trace_length / 16) -- rc16_len\n (λ j, c.cpu__decode__off1 (j * 16)) -- off_op0_tilde : fin T → F\n (λ j, c.cpu__decode__off2 (j * 16)) -- off_op1_tilde : fin T → F\n (λ j, c.cpu__decode__off0 (j * 16)) -- off_dst_tilde : fin T → F\n (λ j, c.rc_builtin__inner_rc (j * 16)) -- rc16_val : fin rc16_len → F\n pd.rc_min\n pd.rc_max :=\nhave h : ∀ j : ℕ, ∀ i : fin (inp.trace_length / 16 - 1),\n j < 16 → (↑i * 16 + j) < inp.trace_length - 1 + 1,\n begin\n rintros j ⟨i, ilt⟩ jlt,\n rw nat.sub_add_cancel trace_length_pos,\n apply lt_of_lt_of_le (add_lt_add_left jlt _),\n suffices : (i + 1) * 16 ≤ inp.trace_length, by rwa [add_mul] at this,\n apply le_trans (nat.mul_le_mul_right _ _) (nat.div_mul_le_self _ 16),\n exact lt_of_lt_of_le ilt (nat.pred_le _)\n end,\nhave h' : ∀ j : ℕ, ∀ i : fin (inp.trace_length / 16),\n j < 16 → (↑i * 16 + j) < inp.trace_length - 1 + 1,\n begin\n rintros j ⟨i, ilt⟩ jlt,\n rw nat.sub_add_cancel trace_length_pos,\n apply lt_of_lt_of_le (add_lt_add_left jlt _),\n suffices : (i + 1) * 16 ≤ inp.trace_length, by rwa [add_mul] at this,\n apply le_trans (nat.mul_le_mul_right _ _) (nat.div_mul_le_self _ 16),\n exact nat.succ_le_of_lt ilt\n end,\n{ n := inp.trace_length - 1,\n a := λ i, c.rc16_pool i,\n a' := λ i, c.rc16__sorted i,\n p := λ i, ci.rc16__perm__cum_prod0 i,\n z := pd.rc16__perm__interaction_elm,\n embed_off_op0 := λ i, ⟨↑i * 16 + 8, h 8 i (by norm_num)⟩,\n embed_off_op1 := λ i, ⟨↑i * 16 + 4, h 4 i (by norm_num)⟩,\n embed_off_dst := λ i, ⟨↑i * 16, h 0 i (by norm_num)⟩,\n embed_rc16_vals := λ i, ⟨↑i * 16 + 12, h' 12 i (by norm_num)⟩,\n h_embed_op0 := λ i, rfl,\n h_embed_op1 := λ i, rfl,\n h_embed_dst := λ i, rfl,\n h_embed_rc16 := λ i, rfl,\n h_continuity :=\n begin\n intro i,\n rw [←rc16.diff_is_bit _ (ne_of_lt i.is_lt), mul_sub, mul_one],\n simp, refl\n end,\n h_initial :=\n begin\n rw [←sub_eq_zero, ←rc16.perm__init0 _ rfl],\n simp [column.off], abel\n end,\n h_cumulative :=\n begin\n intro i,\n rw [←sub_eq_zero, ←rc16.perm__step0 _ (ne_of_lt i.is_lt)],\n simp [column.off]\n end,\n h_final := (eq_of_sub_eq_zero (rc16.perm__last _ rfl)).trans public_memory_prod_eq_one,\n h_rc_min := eq_of_sub_eq_zero $ rc16.minimum _ rfl,\n h_rc_max := eq_of_sub_eq_zero $ rc16.maximum _ rfl,\n h_n_lt :=\n begin\n apply nat.lt_of_succ_le,\n rw [nat.succ_eq_add_one, nat.sub_add_cancel trace_length_pos],\n exact trace_length_le_char\n end }\n\n/- interpreting memory constraints -/\n\ndef memory.to_memory_block_constraints\n {inp : input_data F} {pd : public_data F} {c : columns F} {ci : columns_inter F}\n (h_mem_star :\n let z := pd.memory__multi_column_perm__perm__interaction_elm,\n alpha := pd.memory__multi_column_perm__hash_interaction_elm0,\n p := pd.memory__multi_column_perm__perm__public_memory_prod,\n dom_m_star := { x // option.is_some (inp.m_star x) } in\n p * ∏ a : dom_m_star, (z - (a.val + alpha * mem_val a)) = z^(fintype.card dom_m_star))\n (m : memory inp pd c ci) :\n memory_block_constraints\n (inp.trace_length / 2 - 1) -- n\n (λ i, c.mem_pool__addr (2 * i)) -- a\n (λ i, c.mem_pool__value (2 * i)) -- v\n inp.m_star\n :=\nhave h0 : ∀ j : fin (inp.trace_length / 2 - 1), ↑j * 2 % 2 = 0, by intro j; simp,\nhave h1 : ∀ j : fin (inp.trace_length / 2 - 1), ¬ (↑j * 2 = 2 * (inp.trace_length / 2 - 1)),\n begin\n rintros ⟨j, jlt⟩,\n have hj : j ≠ inp.trace_length / 2 - 1 := ne_of_lt jlt,\n rwa [mul_comm, mul_right_inj' _], norm_num\n end,\n{ a' := (λ j, c.column20 (2 * j)),\n v' := (λ j, c.column20 (2 * j + 1)),\n p := (λ j, ci.column24_inter1 (2 * j)),\n alpha := pd.memory__multi_column_perm__hash_interaction_elm0,\n z := pd.memory__multi_column_perm__perm__interaction_elm,\n h_continuity :=\n begin\n intro j,\n rw [←m.diff_is_bit (↑j * 2) ⟨h0 j, h1 j⟩, mul_comm 2],\n simp [column.off, add_mul, mul_comm 2], ring\n end,\n h_single_valued :=\n begin\n intro j,\n apply neg_inj.mp,\n rw [neg_zero, ←m.is_func (↑j * 2) ⟨h0 j, h1 j⟩],\n simp [column.off, add_mul, mul_add, mul_comm 2, add_assoc], norm_num,\n ring\n end,\n h_initial :=\n begin\n rw [←sub_eq_zero, ←m.multi_column_perm__perm__init0 _ rfl],\n simp [column.off], ring\n end,\n h_cumulative :=\n begin\n intro j,\n rw [←sub_eq_zero, ←m.multi_column_perm__perm__step0 (↑j * 2) ⟨h0 j, h1 j⟩],\n simp [column.off, add_mul, mul_add, mul_comm 2, add_assoc]\n end,\n h_final :=\n begin\n apply eq.trans _ h_mem_star,\n rw [←eq_of_sub_eq_zero (m.multi_column_perm__perm__last _ rfl)],\n refl\n end }\n\n/- interpreting range check builtin constraints -/\n\n/-- Use 8 16-bit range-checked elements for each 128-bit range-checked element -/\ndef rc_to_rc16 {inp : input_data F} :\n fin (inp.trace_length / 128) → fin 8 → fin (inp.trace_length / 16) :=\nλ i j, ⟨i * 8 + j,\n begin\n cases i with i hi,\n cases j with j hj,\n calc\n ↑i * 8 + ↑j < (i + 1) * 8 :\n by { rw [add_mul, one_mul], apply add_lt_add_left hj }\n ... = ((i + 1) * 8 * 16) / 16 :\n by { rw nat.mul_div_cancel, norm_num }\n ... ≤ inp.trace_length / 16 :\n by { apply nat.div_le_div_right, rw mul_assoc, norm_num,\n rw ← nat.le_div_iff_mul_le, exact nat.succ_le_of_lt hi, norm_num }\n end⟩\n\ndef rc_builtin.to_rc_builtin_constraints\n {inp : input_data F} {pd : public_data F} {c : columns F}\n (rcb : rc_builtin inp pd c) :\n rc_builtin_constraints\n (inp.trace_length / 16)\n (pd.initial_rc_addr)\n (inp.trace_length / 128)\n (λ j, c.rc_builtin__inner_rc (j * 16))\n (λ j, c.rc_builtin__mem__addr (j * 128))\n (λ j, c.rc_builtin__mem__value (j * 128))\n rc_to_rc16 :=\n{ h_rc_init_addr := λ h, eq_of_sub_eq_zero (rcb.init_addr _ rfl),\n h_rc_addr_step :=\n begin\n intros i hi,\n have := rcb.addr_step (i * 128),\n simp [column.off, nat.succ_eq_add_one, add_mul, one_mul, add_assoc],\n norm_num,\n convert eq_of_sub_eq_zero (this _), simp,\n rw [mul_comm _ 128, nat.mul_right_inj (show 0 < 128, by norm_num)],\n contrapose! hi,\n rw [hi, nat.succ_eq_add_one],\n apply le_tsub_add\n end,\n h_rc_value :=\n begin\n intro i,\n have := rcb.value (i * 128),\n simp at this,\n rw [columns.rc_builtin__mem__value, ←eq_of_sub_eq_zero this],\n simp only [rc_to_rc16, column.off, columns.rc_builtin__inner_rc],\n iterate 14 { congr' 1 };\n { simp [column.off, add_mul, mul_assoc], congr' 1, try { norm_num } }\n end }\n\ntheorem card_dom_aux {inp : input_data F}\n (h_card : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length) :\n 4 * fintype.card { x // option.is_some (inp.m_star x) } ≤ inp.trace_length / 2 - 1 :=\nbegin\n apply nat.le_pred_of_lt,\n apply nat.lt_of_succ_le,\n rw [nat.le_div_iff_mul_le' (show 0 < 2, by norm_num), nat.succ_mul, mul_comm, ←mul_assoc],\n norm_num,\n exact h_card\nend\n\ndef embed_mem {inp : input_data F}\n (h_card : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length)\n (a : mem_dom inp.m_star) :\n fin (inp.trace_length / 2 - 1 + 1) :=\nlet i := (fintype.equiv_fin { x // option.is_some (inp.m_star x) }).to_fun a in\n ⟨4 * i.val + 1,\n nat.succ_lt_succ (lt_of_lt_of_le (nat.mul_lt_mul_of_pos_left i.is_lt (by norm_num))\n (card_dom_aux h_card))⟩\n\ndef public_memory.to_memory_embedding_constraints\n {c : columns F} {inp : input_data F}\n (pm : public_memory c)\n (h_card : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length) :\n memory_embedding_constraints\n (inp.trace_length / 16 - 1) -- T\n (inp.trace_length / 128) -- rc_len\n (λ j, c.cpu__decode__pc (j * 16)) -- pc\n (λ j, c.cpu__decode__instruction (j * 16)) -- inst\n (λ j, c.cpu__operands__mem_dst__addr (j * 16)) -- dst_addr\n (λ j, c.cpu__operands__mem_dst__value (j * 16)) -- dst\n (λ j, c.cpu__operands__mem_op0__addr (j * 16)) -- op0_addr\n (λ j, c.cpu__operands__mem_op0__value (j * 16)) -- op0\n (λ j, c.cpu__operands__mem_op1__addr (j * 16)) -- op1_addr\n (λ j, c.cpu__operands__mem_op1__value (j * 16)) -- op1\n (λ j, c.rc_builtin__mem__addr (j * 128)) -- rc_addr\n (λ j, c.rc_builtin__mem__value (j * 128)) -- rc\n inp.m_star -- mem_star\n (inp.trace_length / 2 - 1) -- n\n (λ i, c.mem_pool__addr (2 * i)) -- a\n (λ i, c.mem_pool__value (2 * i)) -- v\n :=\nhave h : ∀ j : ℕ, ∀ i : fin (inp.trace_length / 16 - 1), j < 8 →\n (↑i * 8 + j) < inp.trace_length / 2 - 1 + 1,\n begin\n rintros j ⟨i, ilt⟩ jlt,\n apply nat.lt_succ_of_le,\n apply nat.le_pred_of_lt,\n have : i * 8 + j < (i + 1) * 8,\n { rw [add_mul, one_mul], exact add_lt_add_left jlt _ },\n apply lt_of_lt_of_le this,\n rw [nat.le_div_iff_mul_le' (show 0 < 2, by norm_num), mul_assoc],\n norm_num,\n rw [←nat.le_div_iff_mul_le' (show 0 < 16, by norm_num)],\n apply nat.succ_le_of_lt,\n exact lt_of_lt_of_le ilt (nat.pred_le _)\n end,\nhave h1 : ∀ i : fin (inp.trace_length / 128),\n (↑i * 64 + 51) < inp.trace_length / 2 - 1 + 1,\n begin\n rintros ⟨i, ilt⟩,\n apply nat.lt_succ_of_le,\n apply nat.le_pred_of_lt,\n have : i * 64 + 51 < (i + 1) * 64,\n { rw add_mul, apply add_lt_add_left, norm_num },\n apply lt_of_lt_of_le this,\n apply le_trans (nat.mul_le_mul_right _ (nat.succ_le_of_lt ilt)),\n rw [nat.le_div_iff_mul_le' (show 0 < 2, by norm_num), mul_assoc],\n norm_num,\n apply nat.div_mul_le_self\n end,\nhave jaux : ∀ j : fin (inp.trace_length / 16 - 1), (j : ℕ) * 8 = 4 * (2 * j),\n by { intro j, rw [←mul_assoc, mul_comm (4 * 2)], refl },\n{ embed_inst := λ i, ⟨↑i * 8 + 0, h 0 i (by norm_num)⟩,\n embed_dst := λ i, ⟨↑i * 8 + 4, h 4 i (by norm_num)⟩,\n embed_op0 := λ i, ⟨↑i * 8 + 2, h 2 i (by norm_num)⟩,\n embed_op1 := λ i, ⟨↑i * 8 + 6, h 6 i (by norm_num)⟩,\n embed_rc := λ i, ⟨↑i * 64 + 51, h1 i⟩,\n embed_mem := embed_mem h_card,\n h_embed_pc := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_inst := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_dst_addr := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_dst := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_op0_addr := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_op0 := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_op1_addr := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_op1 := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_rc_addr := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_rc := by { intro i, dsimp [column.off], congr' 1, ring },\n h_embed_dom :=\n begin\n intro a, simp [column.off],\n apply pm.addr_zero, simp, rw [←mul_assoc],\n exact nat.mul_mod_right _ _\n end,\n h_embed_val :=\n begin\n intro a, simp [column.off],\n apply pm.value_zero, simp, rw [←mul_assoc],\n exact nat.mul_mod_right _ _\n end,\n h_embed_mem_inj :=\n begin\n intros a1 a2, dsimp [embed_mem],\n rw [fin.eq_iff_veq, add_left_inj 1, mul_right_inj' (show 4 ≠ 0, by norm_num), ←fin.ext_iff],\n apply equiv.injective\n end,\n h_embed_mem_disj_inst :=\n begin\n intros a j h',\n rw [fin.eq_iff_veq] at h', dsimp at h',\n have := congr_arg (λ n, n % 4) h', dsimp [embed_mem] at this,\n rw [add_comm, add_comm _ 0, jaux, nat.add_mul_mod_self_left,\n nat.add_mul_mod_self_left] at this,\n norm_num at this\n end,\n h_embed_mem_disj_dst :=\n begin\n intros a j h',\n rw [fin.eq_iff_veq] at h', dsimp [embed_mem] at h',\n have := congr_arg (λ n, n % 4) h', dsimp at this,\n rw [add_comm, add_comm _ 4, jaux, nat.add_mul_mod_self_left,\n nat.add_mul_mod_self_left] at this,\n norm_num at this\n end,\n h_embed_mem_disj_op0 :=\n begin\n intros a j h',\n rw [fin.eq_iff_veq] at h', dsimp [embed_mem] at h',\n have := congr_arg (λ n, n % 4) h', dsimp at this,\n rw [add_comm, add_comm _ 2, jaux, nat.add_mul_mod_self_left,\n nat.add_mul_mod_self_left] at this,\n norm_num at this\n end,\n h_embed_mem_disj_op1 :=\n begin\n intros a j h',\n rw [fin.eq_iff_veq] at h', dsimp [embed_mem] at h',\n have := congr_arg (λ n, n % 4) h', dsimp at this,\n rw [add_comm, add_comm _ 6, jaux, nat.add_mul_mod_self_left,\n nat.add_mul_mod_self_left] at this,\n norm_num at this\n end,\n h_embed_mem_disj_rc :=\n begin\n intros a j h',\n rw [fin.eq_iff_veq] at h', dsimp [embed_mem] at h',\n have jaux' : 64 = 16 * 4, by norm_num,\n have := congr_arg (λ n, n % 4) h', dsimp at this,\n rw [add_comm, add_comm _ 51, nat.add_mul_mod_self_left] at this,\n simp only [jaux', ←mul_assoc] at this,\n norm_num at this\n end }\n\n/- putting it all together -/\n\ndef input_data.to_input_data_aux (inp : input_data F) (pd : public_data F)\n (rc_max_lt : pd.rc_max < 2^16)\n (rc_min_le : pd.rc_min ≤ pd.rc_max) : input_data_aux F :=\n{ T := inp.trace_length / 16 - 1,\n rc16_len := inp.trace_length / 16,\n rc_len := inp.trace_length / 128,\n pc_I := inp.initial_pc,\n pc_F := inp.final_pc,\n ap_I := inp.initial_ap,\n ap_F := inp.final_ap,\n mem_star := inp.m_star,\n rc_min := pd.rc_min,\n rc_max := pd.rc_max,\n initial_rc_addr := pd.initial_rc_addr,\n rc_to_rc16 := rc_to_rc16,\n h_rc_lt := rc_max_lt,\n h_rc_le := rc_min_le }\n\ndef to_constraints {inp : input_data F} {pd : public_data F} {c : columns F} {ci : columns_inter F}\n /- autogenerated constraints -/\n (cd : cpu__decode c)\n (ops : cpu__operands c)\n (upd : cpu__update_registers inp c)\n (opcodes : cpu__opcodes c)\n (m : memory inp pd c ci)\n (rc : rc16 inp pd c ci)\n (pm : public_memory c)\n (rcb : rc_builtin inp pd c)\n (iandf : toplevel_constraints inp c)\n /- extra assumptions -/\n (h_mem_star :\n let z := pd.memory__multi_column_perm__perm__interaction_elm,\n alpha := pd.memory__multi_column_perm__hash_interaction_elm0,\n p := pd.memory__multi_column_perm__perm__public_memory_prod,\n dom_m_star := { x // option.is_some (inp.m_star x) } in\n p * ∏ a : dom_m_star, (z - (a.val + alpha * mem_val a)) = z^(fintype.card dom_m_star))\n (h_card_dom : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length)\n (public_memory_prod_eq_one : pd.rc16__perm__public_memory_prod = 1)\n (rc_max_lt : pd.rc_max < 2^16)\n (rc_min_le : pd.rc_min ≤ pd.rc_max)\n (trace_length_le_char : inp.trace_length ≤ ring_char F) :\n constraints (inp.to_input_data_aux pd rc_max_lt rc_min_le) :=\nhave trace_length_pos : inp.trace_length > 0,\n from lt_of_lt_of_le (nat.zero_lt_succ _) h_card_dom,\n{ fp := λ j, c.cpu__registers__fp (j * 16),\n ap := λ j, c.cpu__registers__ap (j * 16),\n pc := λ j, c.cpu__decode__pc (j * 16),\n inst := λ j, c.cpu__decode__instruction (j * 16),\n off_op0_tilde := λ j, c.cpu__decode__off1 (j * 16),\n off_op1_tilde := λ j, c.cpu__decode__off2 (j * 16),\n off_dst_tilde := λ j, c.cpu__decode__off0 (j * 16),\n rc16_val := λ j, c.rc_builtin__inner_rc (j * 16),\n f_tilde := λ j k, c.cpu__decode__opcode_rc__column (j * 16 + k),\n dst_addr := λ j, c.cpu__operands__mem_dst__addr (j * 16),\n dst := λ j, c.cpu__operands__mem_dst__value (j * 16),\n op0_addr := λ j, c.cpu__operands__mem_op0__addr (j * 16),\n op0 := λ j, c.cpu__operands__mem_op0__value (j * 16),\n op1_addr := λ j, c.cpu__operands__mem_op1__addr (j * 16),\n op1 := λ j, c.cpu__operands__mem_op1__value (j * 16),\n rc_addr := λj, c.rc_builtin__mem__addr (j * 128),\n rc_val := λj, c.rc_builtin__mem__value (j * 128),\n h_pc_I := eq_of_sub_eq_zero (iandf.initial_pc _ rfl),\n h_ap_I := eq_of_sub_eq_zero (iandf.initial_ap _ rfl),\n h_fp_I := eq_of_sub_eq_zero (iandf.initial_fp _ rfl),\n h_pc_F := by { rw mul_comm _ 16, exact eq_of_sub_eq_zero (iandf.final_pc _ rfl) },\n h_ap_F := by { rw mul_comm _ 16, exact eq_of_sub_eq_zero (iandf.final_ap _ rfl) },\n mc := { n := inp.trace_length / 2 - 1,\n a := λ i, c.mem_pool__addr (2 * i),\n v := λ i, c.mem_pool__value (2 * i),\n em := pm.to_memory_embedding_constraints h_card_dom,\n mb := m.to_memory_block_constraints h_mem_star,\n h_n_lt :=\n begin\n apply lt_of_lt_of_le _ trace_length_le_char,\n apply nat.lt_of_succ_le,\n rw [nat.sub_one, nat.succ_pred_eq_of_pos],\n { apply nat.div_le_self },\n apply nat.div_pos _ (show 0 < 2, by norm_num),\n apply le_trans _ h_card_dom,\n apply le_add_left (le_refl _),\n end},\n rc := rc.to_range_check_constraints trace_length_pos public_memory_prod_eq_one\n trace_length_le_char,\n ic := λ i, cd.to_instruction_constraints i,\n sc := λ i, by { rw fin.coe_succ, exact ops.to_step_constraints upd opcodes i (ne_of_lt i.is_lt) },\n rcb := rcb.to_rc_builtin_constraints\n}\n\n/- probabilistic constraints -/\n\ndef bad1 {inp : input_data F}\n (h_card : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length)\n (c19 c20 : column F) : finset F :=\nbad_set_1\n (real_a inp.m_star (λ i, c19 (2 * i)) (embed_mem h_card))\n (real_v inp.m_star (λ i, c19 (2 * i + 1)) (embed_mem h_card))\n (λ j, c20 (2 * ↑j))\n (λ j, c20 (2 * ↑j + 1))\n\ndef bad2 {inp : input_data F} (pd : public_data F)\n (h_card : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length)\n (c19 c20 : column F) : finset F :=\nbad_set_2\n (real_a inp.m_star (λ i, c19 (2 * i)) (embed_mem h_card))\n (real_v inp.m_star (λ i, c19 (2 * i + 1)) (embed_mem h_card))\n (λ j, c20 (2 * ↑j))\n (λ j, c20 (2 * ↑j + 1))\n pd.memory__multi_column_perm__hash_interaction_elm0\n\ndef bad3 (inp : input_data F) (c0 c2 : column F) : finset F :=\nbad_set_3\n (λ (i : fin (inp.trace_length - 1 + 1)), c0 i)\n (λ (i : fin (inp.trace_length - 1 + 1)), c2 i)\n\nlemma trace_length_div_two_pos {inp : input_data F}\n (h_card : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length) :\n inp.trace_length / 2 > 0 :=\nbegin\n apply nat.div_pos _ (show 0 < 2, by norm_num),\n apply le_trans _ h_card,\n apply le_add_left (le_refl _)\nend\n\ntheorem bad1_bound {inp : input_data F}\n (h_card : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length)\n (c19 c20 : column F) :\n (bad1 h_card c19 c20).card ≤ (inp.trace_length / 2)^2 :=\nbegin\n transitivity,\n apply card_bad_set_1_le,\n rw [nat.sub_add_cancel, pow_two],\n apply trace_length_div_two_pos h_card\nend\n\ntheorem bad2_bound {inp : input_data F} (pd : public_data F)\n (h_card : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length)\n (c19 c20 : column F) :\n (bad2 pd h_card c19 c20).card ≤ inp.trace_length / 2 :=\nbegin\n transitivity,\n apply card_bad_set_2_le,\n rw nat.sub_add_cancel,\n apply trace_length_div_two_pos h_card\nend\n\ntheorem bad3_bound {inp : input_data F}\n (h_card : 8 * fintype.card { x // option.is_some (inp.m_star x) } + 2 ≤ inp.trace_length)\n (c0 c2 : column F) :\n (bad3 inp c0 c2).card ≤ inp.trace_length :=\nbegin\n transitivity,\n apply card_bad_set_3_le,\n rw nat.sub_add_cancel,\n exact lt_of_lt_of_le (nat.zero_lt_succ _) h_card\nend", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/lean/semantics/air_encoding/glue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.43014734858584286, "lm_q1q2_score": 0.24676624590664586}} {"text": "/-\nCopyright (c) 2019 Johan Commelin. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johan Commelin, Simon Hudon, Scott Morrison\n-/\n\nimport Mathlib.Control.Basic\nimport Mathlib.Logic.Equiv.Defs\n\n/-!\n\n# Functors can be applied to `Equiv`s.\n\n```\ndef functor.map_equiv (f : Type u → Type v) [functor f] [LawfulFunctor f] :\n α ≃ β → f α ≃ f β\n```\n\n-/\n\nopen Equiv\n\nnamespace Functor\n\nvariable (f : Type u → Type v) [Functor f] [LawfulFunctor f]\n\n/-- Apply a functor to an `Equiv`. -/\ndef map_equiv (h : α ≃ β) : f α ≃ f β where\n toFun := map h\n invFun := map h.symm\n left_inv x := by simp [map_map]\n right_inv x := by simp [map_map]\n\n@[simp]\nlemma map_equiv_apply (h : α ≃ β) (x : f α) :\n (map_equiv f h : f α ≃ f β) x = map h x := rfl\n\n@[simp]\nlemma map_equiv_symm_apply (h : α ≃ β) (y : f β) :\n (map_equiv f h : f α ≃ f β).symm y = map h.symm y := rfl\n\nend Functor\n", "meta": {"author": "leanprover-community", "repo": "mathlib4", "sha": "b9a0a30342ca06e9817e22dbe46e75fc7f435500", "save_path": "github-repos/lean/leanprover-community-mathlib4", "path": "github-repos/lean/leanprover-community-mathlib4/mathlib4-b9a0a30342ca06e9817e22dbe46e75fc7f435500/Mathlib/Data/Equiv/Functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.461016779312316, "lm_q1q2_score": 0.24668935418052163}} {"text": "import category_theory.isomorphism\n\nimport .colimits\n\n/-\n\n* Notation and lemmas for categories with `has_coproducts`.\n\n* Construction of pushouts in terms of coproducts and coequalizers.\n\n-/\n\nopen set\n\nopen category_theory.category\nlocal notation f ` ∘ `:80 g:80 := g ≫ f\n\nnamespace category_theory\n\nuniverses v u\n\nsection initial\nvariables {C : Type u} [category.{v} C]\nvariable [has_initial_object.{v} C]\n\ndef initial : C := has_initial_object.initial_object.{v}.ob\n\ninstance : has_emptyc C := ⟨initial⟩\n\ndef initial.induced (a : C) : ∅ ⟶ a :=\nhas_initial_object.initial_object.is_initial_object.induced\n\nnotation `!` a := initial.induced a\n\ndef initial.uniqueness {a : C} (k k' : ∅ ⟶ a) : k = k' :=\nhas_initial_object.initial_object.is_initial_object.uniqueness k k'\n\n-- This instance tends not to be very useful because `congr` generates\n-- a congruence lemma which is too general, and does not \"know\" that\n-- the domain is ∅.\ninstance initial_hom.subsingleton (a : C) : subsingleton (∅ ⟶ a) := ⟨initial.uniqueness⟩\n\nend initial\n\nsection coproduct\nvariables {C : Type u} [category.{v} C]\nvariable [has_coproducts.{v} C]\n\n-- The (chosen) coproduct of two objects.\ndef coprod (a₀ a₁ : C) :=\n(has_coproducts.coproduct.{v} a₀ a₁).ob\n\ninfix ` ⊔ ` := coprod\n\n-- The \"left\" inclusion.\ndef i₀ {a₀ a₁ : C} : a₀ ⟶ a₀ ⊔ a₁ :=\n(has_coproducts.coproduct.{v} a₀ a₁).map₀\n\n-- The \"right\" inclusion.\ndef i₁ {a₀ a₁ : C} : a₁ ⟶ a₀ ⊔ a₁ :=\n(has_coproducts.coproduct.{v} a₀ a₁).map₁\n\n-- The map out of a coproduct induced by a map on each summand.\ndef coprod.induced {a₀ a₁ b : C} (f₀ : a₀ ⟶ b) (f₁ : a₁ ⟶ b) : a₀ ⊔ a₁ ⟶ b :=\n(has_coproducts.coproduct.{v} a₀ a₁).is_coproduct.induced f₀ f₁\n\ndef coprod.induced_Is_equiv {a₀ a₁ b : C} :\n Is_equiv (λ p : (a₀ ⟶ b) × (a₁ ⟶ b), coprod.induced p.1 p.2) :=\n{ e := ((has_coproducts.coproduct a₀ a₁).is_coproduct.universal b).e.symm,\n h := by funext p; cases p; refl }\n\n@[simp] lemma coprod.induced_commutes₀ {a₀ a₁ b : C} (f₀ : a₀ ⟶ b) (f₁ : a₁ ⟶ b) :\n coprod.induced f₀ f₁ ∘ i₀ = f₀ :=\n(has_coproducts.coproduct.{v} a₀ a₁).is_coproduct.induced_commutes₀ f₀ f₁\n\n@[simp] lemma coprod.induced_commutes₁ {a₀ a₁ b : C} (f₀ : a₀ ⟶ b) (f₁ : a₁ ⟶ b) :\n coprod.induced f₀ f₁ ∘ i₁ = f₁ :=\n(has_coproducts.coproduct.{v} a₀ a₁).is_coproduct.induced_commutes₁ f₀ f₁\n\ndef coprod.fold (a : C) : a ⊔ a ⟶ a :=\ncoprod.induced (𝟙 a) (𝟙 a)\n\n@[simp] lemma coprod.fold_i₀ {a : C} : coprod.fold a ∘ i₀ = 𝟙 a :=\ncoprod.induced_commutes₀ _ _\n\n@[simp] lemma coprod.fold_i₁ {a : C} : coprod.fold a ∘ i₁ = 𝟙 a :=\ncoprod.induced_commutes₁ _ _\n\n-- This is a kind of \"co-extensionality\" lemma; does that count?\n@[ext] lemma coprod.uniqueness {a₀ a₁ b : C} {k k' : a₀ ⊔ a₁ ⟶ b}\n (e₀ : k ∘ i₀ = k' ∘ i₀) (e₁ : k ∘ i₁ = k' ∘ i₁) : k = k' :=\n(has_coproducts.coproduct.{v} a₀ a₁).is_coproduct.uniqueness e₀ e₁\n\nlemma coprod.ext {a₀ a₁ b : C} {k k' : a₀ ⊔ a₁ ⟶ b} :\n k = k' ↔ k ∘ i₀ = k' ∘ i₀ ∧ k ∘ i₁ = k' ∘ i₁ :=\niff.intro (assume h, by rw h; simp) (assume ⟨h₀, h₁⟩, coprod.uniqueness h₀ h₁)\n\n-- Similarly, this is a \"co-eta reduction\".\n@[simp] lemma coprod.eta {a₀ a₁ b : C} {k : a₀ ⊔ a₁ ⟶ b} :\n coprod.induced (k ∘ i₀) (k ∘ i₁) = k :=\ncoprod.uniqueness (by simp) (by simp)\n\ndef coprod_of_maps {a₀ a₁ b₀ b₁ : C} (f₀ : a₀ ⟶ b₀) (f₁ : a₁ ⟶ b₁) : a₀ ⊔ a₁ ⟶ b₀ ⊔ b₁ :=\ncoprod.induced (i₀ ∘ f₀) (i₁ ∘ f₁)\n\n@[simp] lemma coprod_of_maps_commutes₀ {a₀ a₁ b₀ b₁ : C} {f₀ : a₀ ⟶ b₀} {f₁ : a₁ ⟶ b₁} :\n coprod_of_maps f₀ f₁ ∘ i₀ = i₀ ∘ f₀ :=\ncoprod.induced_commutes₀ _ _\n\n@[simp] lemma coprod_of_maps_commutes₁ {a₀ a₁ b₀ b₁ : C} {f₀ : a₀ ⟶ b₀} {f₁ : a₁ ⟶ b₁} :\n coprod_of_maps f₀ f₁ ∘ i₁ = i₁ ∘ f₁ :=\ncoprod.induced_commutes₁ _ _\n\ndef isomorphic_coprod_of_Is_coproduct {a₀ a₁ b : C} {f₀ : a₀ ⟶ b} {f₁ : a₁ ⟶ b}\n (h : Is_coproduct f₀ f₁) : iso (a₀ ⊔ a₁) b :=\n{ hom := coprod.induced f₀ f₁,\n inv := h.induced i₀ i₁,\n hom_inv_id' := by apply coprod.uniqueness; { rw ←assoc, simp },\n inv_hom_id' := by apply h.uniqueness; { rw ←assoc, simp } }\n\ndef coprod_of_isomorphisms {a₀ a₁ b₀ b₁ : C} (j₀ : iso a₀ b₀) (j₁ : iso a₁ b₁) :\n iso (a₀ ⊔ a₁) (b₀ ⊔ b₁) :=\n{ hom := coprod_of_maps j₀.hom j₁.hom,\n inv := coprod_of_maps j₀.inv j₁.inv,\n hom_inv_id' := by apply coprod.uniqueness; rw ←assoc; simp,\n inv_hom_id' := by apply coprod.uniqueness; rw ←assoc; simp }\n\nvariables [has_initial_object.{v} C]\n\ndef coprod_initial_right (a : C) : a ≅ a ⊔ ∅ :=\n{ hom := i₀,\n inv := coprod.induced (𝟙 a) (! a),\n hom_inv_id' := by simp,\n inv_hom_id' :=\n by apply coprod.uniqueness; try { apply initial.uniqueness };\n rw ←assoc; simp }\n\n@[simp] lemma coprod_initial_right_hom {a : C} : (coprod_initial_right a).hom = i₀ :=\nrfl\n\ndef coprod_initial_left (a : C) : a ≅ ∅ ⊔ a :=\n{ hom := i₁,\n inv := coprod.induced (! a) (𝟙 a),\n hom_inv_id' := by simp,\n inv_hom_id' :=\n by apply coprod.uniqueness; try { apply initial.uniqueness };\n rw ←assoc; simp }\n\n@[simp] lemma coprod_initial_left_hom {a : C} : (coprod_initial_left a).hom = i₁ :=\nrfl\n\nend coproduct\n\n\nsection pushout_induced_eq\nparameters {C : Type u} [category.{v} C]\nparameters {a b₀ b₁ c c' : C} {f₀ : a ⟶ b₀} {f₁ : a ⟶ b₁}\nparameters {g₀ : b₀ ⟶ c} {g₁ : b₁ ⟶ c} (po : Is_pushout f₀ f₁ g₀ g₁)\n\nlemma pushout_induced_eq_iff {x : C} {h₀ : b₀ ⟶ x} {h₁ : b₁ ⟶ x} {k : c ⟶ x} {e}\n (H₀ : h₀ = g₀ ≫ k) (H₁ : h₁ = g₁ ≫ k) : po.induced h₀ h₁ e = k :=\nby apply po.uniqueness; simp [H₀, H₁]\n\nend pushout_induced_eq\n\n\nsection pushout_induced_comp\nparameters {C : Type u} [category.{v} C]\nparameters {a b₀ b₁ c c' : C} {f₀ : a ⟶ b₀} {f₁ : a ⟶ b₁}\nparameters {g₀ : b₀ ⟶ c} {g₁ : b₁ ⟶ c} (po : Is_pushout f₀ f₁ g₀ g₁)\n\nlemma pushout_induced_comp {x y : C} {h₀ : b₀ ⟶ x} {h₁ : b₁ ⟶ x} {k : x ⟶ y} {e} :\n k ∘ po.induced h₀ h₁ e = po.induced (k ∘ h₀) (k ∘ h₁)\n (by rw [←assoc, ←assoc, e]) :=\nby apply po.uniqueness; rw ←assoc; simp\n\nend pushout_induced_comp\n\nsection pushouts_from_coequalizers\nparameters {C : Type u} [category.{v} C] [has_coproducts.{v} C]\n\nsection construction\nparameters {a b₀ b₁ b c : C} {f₀ : a ⟶ b₀} {f₁ : a ⟶ b₁} {g₀ : b₀ ⟶ c} {g₁ : b₁ ⟶ c}\n\ndef Is_pushout_of_Is_coequalizer\n (H : Is_coequalizer (i₀ ∘ f₀) (i₁ ∘ f₁) (coprod.induced g₀ g₁)) :\n Is_pushout f₀ f₁ g₀ g₁ :=\nIs_pushout.mk'\n (begin convert H.commutes using 1; rw assoc; simp end)\n (λ x h₀ h₁ e, H.induced (coprod.induced h₀ h₁)\n (begin rw [assoc, assoc], simpa using e end))\n (assume x h₀ h₁ e,\n -- Weird trick to avoid repeating the proof argument\n (λ p, let K := H.induced (coprod.induced h₀ h₁) p in calc\n K ∘ g₀ = K ∘ (coprod.induced g₀ g₁ ∘ i₀) : by simp\n ... = (K ∘ coprod.induced g₀ g₁) ∘ i₀ : by rw assoc\n ... = h₀ : by simp) _)\n (assume x h₀ h₁ e,\n (λ p, let K := H.induced (coprod.induced h₀ h₁) p in calc\n K ∘ g₁ = K ∘ (coprod.induced g₀ g₁ ∘ i₁) : by simp\n ... = (K ∘ coprod.induced g₀ g₁) ∘ i₁ : by rw assoc\n ... = h₁ : by simp) _)\n (assume x k k' e₀ e₁, H.uniqueness $ coprod.uniqueness\n (by rw [←assoc, ←assoc]; simpa using e₀)\n (by rw [←assoc, ←assoc]; simpa using e₁))\n\ndef pushout_of_coequalizer (E : coequalizer (i₀ ∘ f₀) (i₁ ∘ f₁)) : pushout f₀ f₁ :=\n{ ob := E.ob,\n map₀ := E.map ∘ i₀,\n map₁ := E.map ∘ i₁,\n is_pushout := by\n apply Is_pushout_of_Is_coequalizer; convert E.is_coequalizer; simp }\n\nend construction\n\ndef has_pushouts_of_has_coequalizers_and_coproducts [has_coequalizers.{v} C] :\n has_pushouts.{v} C :=\n{ pushout := λ a b₀ b₁ f₀ f₁,\n pushout_of_coequalizer $ has_coequalizers.coequalizer (i₀ ∘ f₀) (i₁ ∘ f₁) }\n\nend pushouts_from_coequalizers\n\n\nsection uniqueness_of_initial_objects\nparameters {C : Type u} [category.{v} C]\nparameters {a : C} (init : Is_initial_object.{v} a)\nparameters {a' : C} (init' : Is_initial_object.{v} a')\n\ndef initial_object.unique : iso a a' :=\n{ hom := init.induced,\n inv := init'.induced,\n hom_inv_id' := init.uniqueness _ _,\n inv_hom_id' := init'.uniqueness _ _ }\n\nend uniqueness_of_initial_objects\n\nsection uniqueness_of_pushouts\n\nparameters {C : Type u} [category.{v} C]\nparameters {a b₀ b₁ c c' : C} {f₀ : a ⟶ b₀} {f₁ : a ⟶ b₁}\nparameters {g₀ : b₀ ⟶ c} {g₁ : b₁ ⟶ c} (po : Is_pushout f₀ f₁ g₀ g₁)\nparameters {g'₀ : b₀ ⟶ c'} {g'₁ : b₁ ⟶ c'} (po' : Is_pushout f₀ f₁ g'₀ g'₁)\n\n@[reducible] private def h : c ⟶ c' := po.induced g'₀ g'₁ po'.commutes\n@[reducible] private def h' : c' ⟶ c := po'.induced g₀ g₁ po.commutes\n\ndef pushout.unique : iso c c' :=\n{ hom := h,\n inv := h',\n hom_inv_id' := by apply po.uniqueness; {rw ←category.assoc, simp},\n inv_hom_id' := by apply po'.uniqueness; {rw ←category.assoc, simp} }\n\n@[simp] lemma pushout.unique_commutes₀ : pushout.unique.hom ∘ g₀ = g'₀ :=\nby apply po.induced_commutes₀\n\n@[simp] lemma pushout.unique_commutes₁ : pushout.unique.hom ∘ g₁ = g'₁ :=\nby apply po.induced_commutes₁\n\nend uniqueness_of_pushouts\n\n\nlocal notation [parsing_only] a ` ~~ ` b := Bij_on _ a b\n\nsection refl\nparameters {C : Type u} [category.{v} C]\nparameters {a b : C} (f : a ⟶ b)\n\ndef Is_pushout.refl : Is_pushout f (𝟙 a) (𝟙 b) f :=\nIs_pushout.mk $ λ x,\n Bij_on.mk\n { to_fun := λ h, ⟨(h ∘ 𝟙 b, h ∘ f), by simp⟩,\n inv_fun := λ p, ⟨p.val.1, trivial⟩,\n left_inv := assume h, by simp,\n right_inv := assume ⟨⟨pv1, pv2⟩, pp⟩, by simpa using pp }\n (assume h, rfl)\n\nend refl\n\nsection isomorphic\n\nparameters {C : Type u} [category.{v} C]\n\n-- TODO: Move this somewhere?\ndef precomposition_bij {a' a x : C} (i : iso a' a) :\n Bij_on (λ (k : a ⟶ x), (k ∘ i.hom : a' ⟶ x)) univ univ :=\nBij_on.of_equiv $ show (a ⟶ x) ≃ (a' ⟶ x), from\n{ to_fun := λ k, k ∘ i.hom,\n inv_fun := λ k', k' ∘ i.inv,\n left_inv := λ k, by simp,\n right_inv := λ k', by simp }\n\nparameters {a b₀ b₁ c : C} {f₀ : a ⟶ b₀} {f₁ : a ⟶ b₁}\nparameters {g₀ : b₀ ⟶ c} {g₁ : b₁ ⟶ c} (po : Is_pushout f₀ f₁ g₀ g₁)\nparameters {a' b'₀ b'₁ : C} (f'₀ : a' ⟶ b'₀) (f'₁ : a' ⟶ b'₁)\nparameters (i : iso a' a) (j₀ : iso b'₀ b₀) (j₁ : iso b'₁ b₁)\nparameters (e₀ : f₀ ∘ i.hom = j₀.hom ∘ f'₀) (e₁ : f₁ ∘ i.hom = j₁.hom ∘ f'₁)\n\ninclude e₀ e₁\ndef Is_pushout_of_isomorphic : Is_pushout f'₀ f'₁ (g₀ ∘ j₀.hom) (g₁ ∘ j₁.hom) :=\nIs_pushout.mk $ λ x,\n have _ := calc\n univ ~~ {p : (b₀ ⟶ x) × (b₁ ⟶ x) | p.1 ∘ f₀ = p.2 ∘ f₁}\n : po.universal x\n ... ~~ {p : (b₀ ⟶ x) × (b₁ ⟶ x) | (p.1 ∘ j₀.hom) ∘ f'₀ = (p.2 ∘ j₁.hom) ∘ f'₁}\n : begin\n convert Bij_on.refl _, funext p, apply propext,\n rw [←assoc, ←assoc, ←e₀, ←e₁], simp [cancel_epi],\n end\n ... ~~ {p : (b'₀ ⟶ x) × (b'₁ ⟶ x) | p.1 ∘ f'₀ = p.2 ∘ f'₁}\n : Bij_on.restrict''\n (Bij_on.prod' (precomposition_bij j₀) (precomposition_bij j₁))\n {p | p.1 ∘ f'₀ = p.2 ∘ f'₁},\n by convert this; funext; simp\nomit e₀ e₁\n\nparameters {c' : C} (k : iso c c')\n\ndef Is_pushout_of_isomorphic' : Is_pushout f₀ f₁ (k.hom ∘ g₀) (k.hom ∘ g₁) :=\nIs_pushout.mk $ λ x,\n have _ := calc\n univ ~~ univ\n : precomposition_bij k\n ... ~~ {p : (b₀ ⟶ x) × (b₁ ⟶ x) | p.1 ∘ f₀ = p.2 ∘ f₁ }\n : po.universal x,\n by convert this; funext; simp\n\nend isomorphic\n\nsection pushout_tranpose\n\nparameters {C : Type u} [category.{v} C]\nparameters {a b₀ b₁ c : C} {f₀ : a ⟶ b₀} {f₁ : a ⟶ b₁}\nparameters {g₀ : b₀ ⟶ c} {g₁ : b₁ ⟶ c} (po : Is_pushout f₀ f₁ g₀ g₁)\n\ndef Is_pushout.transpose : Is_pushout f₁ f₀ g₁ g₀ :=\nIs_pushout.mk $ λ x, calc\n univ ~~ {p : (b₀ ⟶ x) × (b₁ ⟶ x) | p.1 ∘ f₀ = p.2 ∘ f₁}\n : po.universal x\n ... ~~ {p : (b₀ ⟶ x) × (b₁ ⟶ x) | p.2 ∘ f₁ = p.1 ∘ f₀}\n : begin convert Bij_on.refl _; ext p; split; exact eq.symm, end\n ... ~~ {p' : (b₁ ⟶ x) × (b₀ ⟶ x) | p'.1 ∘ f₁ = p'.2 ∘ f₀}\n : Bij_on.restrict_equiv (equiv.prod_comm _ _)\n {p' | p'.1 ∘ f₁ = p'.2 ∘ f₀}\n\nparameters {c' : C} {g₀' : b₀ ⟶ c'} {g₁' : b₁ ⟶ c'}\nparameters (po' : Is_pushout f₁ f₀ g₁' g₀')\ndef Is_pushout.iso_transpose : c ≅ c' :=\npushout.unique po.transpose po'\n\n@[simp] lemma Is_pushout.iso_transpose_map₀ : g₀ ≫ (po.iso_transpose po').hom = g₀' :=\nby apply pushout.unique_commutes₁\n\n@[simp] lemma Is_pushout.iso_transpose_map₁ : g₁ ≫ (po.iso_transpose po').hom = g₁' :=\nby apply pushout.unique_commutes₀\n\nlemma Is_pushout.transpose_induced {x : C} {h₀ : b₀ ⟶ x} {h₁ : b₁ ⟶ x} {e : f₀ ≫ h₀ = f₁ ≫ h₁} :\n (po.iso_transpose po').hom ≫ po'.induced h₁ h₀ e.symm = po.induced h₀ h₁ e :=\nbegin\n symmetry,\n apply pushout_induced_eq_iff; rw ←assoc; simp\nend\n\nend pushout_tranpose\n\nsection pushout_initial\nparameters {C : Type u} [category.{v} C]\nparameters {a b₀ b₁ c : C} {f₀ : a ⟶ b₀} {f₁ : a ⟶ b₁}\nparameters {g₀ : b₀ ⟶ c} {g₁ : b₁ ⟶ c}\n\n-- TODO: Somehow prove these two simultaneously?\ndef Is_pushout_of_Is_coproduct_of_Is_initial (copr : Is_coproduct g₀ g₁)\n (h : Is_initial_object.{v} a) : Is_pushout f₀ f₁ g₀ g₁ :=\nIs_pushout.mk $ λ x, calc\n univ ~~ {p : (b₀ ⟶ x) × (b₁ ⟶ x) | true}\n : Bij_on.of_Is_equiv (copr.universal x)\n ... ~~ {p : (b₀ ⟶ x) × (b₁ ⟶ x) | p.1 ∘ f₀ = p.2 ∘ f₁}\n : by convert Bij_on.refl _; ext p; change (_ = _) ↔ true;\n simp; apply h.uniqueness\n\ndef Is_coproduct_of_Is_pushout_of_Is_initial (po : Is_pushout f₀ f₁ g₀ g₁)\n (h : Is_initial_object.{v} a) : Is_coproduct g₀ g₁ :=\nhave _ := λ x, calc\n univ ~~ {p : (b₀ ⟶ x) × (b₁ ⟶ x) | p.1 ∘ f₀ = p.2 ∘ f₁}\n : po.universal x\n ... ~~ (univ : set ((b₀ ⟶ x) × (b₁ ⟶ x)))\n : begin\n convert Bij_on.refl _, symmetry, rw ←univ_subset_iff,\n intros p _, apply h.uniqueness\n end,\nIs_coproduct.mk $ λ x, (this x).Is_equiv\n\nend pushout_initial\n\nsection coprod_of_pushouts\n\nparameters {C : Type u} [category.{v} C] [has_coproducts.{v} C]\nparameters {a b₀ b₁ c : C} {f₀ : a ⟶ b₀} {f₁ : a ⟶ b₁}\nparameters {g₀ : b₀ ⟶ c} {g₁ : b₁ ⟶ c} (po : Is_pushout f₀ f₁ g₀ g₁)\nparameters {a' b₀' b₁' c' : C} {f₀' : a' ⟶ b₀'} {f₁' : a' ⟶ b₁'}\nparameters {g₀' : b₀' ⟶ c'} {g₁' : b₁' ⟶ c'} (po' : Is_pushout f₀' f₁' g₀' g₁')\ninclude po po'\n\ndef Is_pushout_coprod :\n Is_pushout\n (coprod_of_maps f₀ f₀') (coprod_of_maps f₁ f₁')\n (coprod_of_maps g₀ g₀') (coprod_of_maps g₁ g₁') :=\nIs_pushout.mk $ λ x,\n have _ := calc\n univ ~~ (univ : set ((c ⟶ x) × (c' ⟶ x)))\n : Bij_on.of_Is_equiv ((has_coproducts.coproduct c c').is_coproduct.universal x)\n ... ~~ {pp : ((b₀ ⟶ x) × (b₁ ⟶ x)) × ((b₀' ⟶ x) × (b₁' ⟶ x))\n | pp.1.1 ∘ f₀ = pp.1.2 ∘ f₁ ∧ pp.2.1 ∘ f₀' = pp.2.2 ∘ f₁'}\n :\n begin\n convert Bij_on.prod (po.universal x) (po'.universal x),\n ext p, simp\n end\n ... ~~ {qq : ((b₀ ⟶ x) × (b₀' ⟶ x)) × ((b₁ ⟶ x) × (b₁' ⟶ x))\n | qq.1.1 ∘ f₀ = qq.2.1 ∘ f₁ ∧ qq.1.2 ∘ f₀' = qq.2.2 ∘ f₁'}\n : Bij_on.restrict_equiv\n { to_fun := λ (pp : ((b₀ ⟶ x) × (b₁ ⟶ x)) × ((b₀' ⟶ x) × (b₁' ⟶ x))), ((pp.1.1, pp.2.1), (pp.1.2, pp.2.2)),\n inv_fun := λ qq, ⟨⟨qq.1.1, qq.2.1⟩, ⟨qq.1.2, qq.2.2⟩⟩,\n left_inv := assume ⟨⟨_,_⟩,⟨_,_⟩⟩, rfl,\n right_inv := assume ⟨⟨_,_⟩,⟨_,_⟩⟩, rfl }\n {qq : ((b₀ ⟶ x) × (b₀' ⟶ x)) × ((b₁ ⟶ x) × (b₁' ⟶ x))\n | qq.1.1 ∘ f₀ = qq.2.1 ∘ f₁ ∧ qq.1.2 ∘ f₀' = qq.2.2 ∘ f₁'}\n ... ~~ {qq : ((b₀ ⟶ x) × (b₀' ⟶ x)) × ((b₁ ⟶ x) × (b₁' ⟶ x))\n | coprod.induced qq.1.1 qq.1.2 ∘ coprod_of_maps f₀ f₀' =\n coprod.induced qq.2.1 qq.2.2 ∘ coprod_of_maps f₁ f₁' }\n :\n begin\n convert Bij_on.refl _,\n ext qq, change _ = _ ↔ _ = _ ∧ _ = _,\n rw [coprod.ext, ←assoc, ←assoc, ←assoc, ←assoc],\n simp\n end\n ... ~~ {qq : (b₀ ⊔ b₀' ⟶ x) × (b₁ ⊔ b₁' ⟶ x)\n | qq.1 ∘ coprod_of_maps f₀ f₀' = qq.2 ∘ coprod_of_maps f₁ f₁'}\n : Bij_on.restrict''\n (Bij_on.prod'\n (Bij_on.of_Is_equiv coprod.induced_Is_equiv)\n (Bij_on.of_Is_equiv coprod.induced_Is_equiv))\n {qq : (b₀ ⊔ b₀' ⟶ x) × (b₁ ⊔ b₁' ⟶ x)\n | qq.1 ∘ coprod_of_maps f₀ f₀' = qq.2 ∘ coprod_of_maps f₁ f₁'},\n begin\n convert this,\n funext k, apply prod.ext; apply coprod.uniqueness;\n { change _ ∘ _ ∘ _ = _ ∘ _, simp [coproduct_comparison],\n rw ←assoc, simp, refl },\n end\n\nend coprod_of_pushouts\n\nsection pushout_i\n\nparameters {C : Type u} [category.{v} C] [has_coproducts.{v} C]\n-- Obviously we shouldn't really need C to have an initial object here, but oh well\nparameters [has_initial_object.{v} C]\nparameters {a b c : C} (f : a ⟶ b)\n\n/-\n a → a ⊔ c\n ↓ ↓\n b → b ⊔ c\n-/\n\ndef Is_pushout_i₀ : Is_pushout f i₀ i₀ (coprod_of_maps f (𝟙 c)) :=\nlet po := Is_pushout_coprod (Is_pushout.refl f) (Is_pushout.refl (! c)).transpose in\nby convert Is_pushout_of_isomorphic po f i₀\n (coprod_initial_right a) (coprod_initial_right b) (iso.refl _) _ _; simp\n\n/-\n a → c ⊔ a\n ↓ ↓\n b → c ⊔ b\n-/\n\ndef Is_pushout_i₁ : Is_pushout f i₁ i₁ (coprod_of_maps (𝟙 c) f) :=\nlet po := Is_pushout_coprod (Is_pushout.refl (! c)).transpose (Is_pushout.refl f) in\nby convert Is_pushout_of_isomorphic po f i₁\n (coprod_initial_left a) (coprod_initial_left b) (iso.refl _) _ _; simp\n\nend pushout_i\n\nsection pushout_swap\nparameters {C : Type u} [category.{v} C]\nparameters {a b c : C} {f : a ⟶ b} {g₀ g₁ : b ⟶ c} (po : Is_pushout f f g₀ g₁)\n\ndef Is_pushout.swap : c ⟶ c := po.induced g₁ g₀ po.commutes.symm\n\ndef Is_pushout.swap_iso : c ≅ c :=\n{ hom := po.swap,\n inv := po.swap,\n hom_inv_id' := by apply po.uniqueness; unfold Is_pushout.swap; rw ←assoc; simp,\n inv_hom_id' := by apply po.uniqueness; unfold Is_pushout.swap; rw ←assoc; simp }\n\n@[simp] def Is_pushout.induced_swap {x} {h₀ h₁ : b ⟶ x} {p p'} :\n po.induced h₀ h₁ p ∘ po.swap = po.induced h₁ h₀ p' :=\nby apply po.uniqueness; unfold Is_pushout.swap; rw ←assoc; simp\n\nend pushout_swap\n\nsection pushout_of_maps\nparameters {C : Type u} [category.{v} C]\nvariables {a b₀ b₁ c : C} {f₀ : a ⟶ b₀} {f₁ : a ⟶ b₁}\nvariables {g₀ : b₀ ⟶ c} {g₁ : b₁ ⟶ c} (po : Is_pushout f₀ f₁ g₀ g₁)\nvariables {a' b₀' b₁' c' : C} {f₀' : a' ⟶ b₀'} {f₁' : a' ⟶ b₁'}\nvariables {g₀' : b₀' ⟶ c'} {g₁' : b₁' ⟶ c'} (po' : Is_pushout f₀' f₁' g₀' g₁')\nvariables {a'' b₀'' b₁'' c'' : C} {f₀'' : a'' ⟶ b₀''} {f₁'' : a'' ⟶ b₁''}\nvariables {g₀'' : b₀'' ⟶ c''} {g₁'' : b₁'' ⟶ c''} (po'' : Is_pushout f₀'' f₁'' g₀'' g₁'')\nvariables (ha : a ⟶ a') (hb₀ : b₀ ⟶ b₀') (hb₁ : b₁ ⟶ b₁')\nvariables (h₀ : hb₀ ∘ f₀ = f₀' ∘ ha) (h₁ : hb₁ ∘ f₁ = f₁' ∘ ha)\nvariables (ka : a' ⟶ a'') (kb₀ : b₀' ⟶ b₀'') (kb₁ : b₁' ⟶ b₁'')\nvariables (k₀ : kb₀ ∘ f₀' = f₀'' ∘ ka) (k₁ : kb₁ ∘ f₁' = f₁'' ∘ ka)\n\ninclude po po' h₀ h₁\n\ndef pushout_of_maps : c ⟶ c' :=\npo.induced (g₀' ∘ hb₀) (g₁' ∘ hb₁)\n (by rw [←assoc, ←assoc, h₀, h₁]; simp [po'.commutes])\n\nomit po po' h₀ h₁\n\nlemma induced_pushout_of_maps {x : C} {k₀ : b₀' ⟶ x} {k₁ : b₁' ⟶ x} {e} :\n po'.induced k₀ k₁ e ∘ pushout_of_maps po po' ha hb₀ hb₁ h₀ h₁ = po.induced (k₀ ∘ hb₀) (k₁ ∘ hb₁)\n (by rw [←assoc, ←assoc, h₀, h₁]; simp [e]) :=\nbegin\n unfold pushout_of_maps,\n apply po.uniqueness; { rw ←assoc, simp }\nend\n\n@[simp] lemma pushout_of_maps_commutes₀ : pushout_of_maps po po' ha hb₀ hb₁ h₀ h₁ ∘ g₀ = g₀' ∘ hb₀ :=\nby simp [pushout_of_maps]\n\n@[simp] lemma pushout_of_maps_commutes₁ : pushout_of_maps po po' ha hb₀ hb₁ h₀ h₁ ∘ g₁ = g₁' ∘ hb₁ :=\nby simp [pushout_of_maps]\n\nlemma pushout_of_maps_id : pushout_of_maps po po (𝟙 a) (𝟙 b₀) (𝟙 b₁) (by simp) (by simp) = 𝟙 _ :=\nby apply pushout_induced_eq_iff; simp\n\nlemma pushout_of_maps_comp :\n pushout_of_maps po po'' (ha ≫ ka) (hb₀ ≫ kb₀) (hb₁ ≫ kb₁)\n (by rw [←assoc, h₀, assoc, k₀, ←assoc]) (by rw [←assoc, h₁, assoc, k₁, ←assoc]) =\n pushout_of_maps po po' ha hb₀ hb₁ h₀ h₁ ≫ pushout_of_maps po' po'' ka kb₀ kb₁ k₀ k₁ :=\nby apply pushout_induced_eq_iff; rw ←assoc; simp\n\nend pushout_of_maps\n\nend category_theory\n", "meta": {"author": "rwbarton", "repo": "lean-homotopy-theory", "sha": "39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee", "save_path": "github-repos/lean/rwbarton-lean-homotopy-theory", "path": "github-repos/lean/rwbarton-lean-homotopy-theory/lean-homotopy-theory-39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee/src/category_theory/colimit_lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.4610167793123159, "lm_q1q2_score": 0.24668935418052157}} {"text": "import tactic\nimport category_theory.functor\nimport data.W.basic\nimport category_theory.closed.types\nimport algebra.category.CommRing.basic\nimport algebra.category.Module.basic\n\nuniverses u v w x\n\nopen category_theory\n--W\n\nvariables {𝒞 : Type u} [category.{v} 𝒞]\n\n@[protect_proj] class struc (F : 𝒞 → Type w) :=\n( hom : Π {A B : 𝒞} (f : A ⟶ B) (a : F A) (b : F B), Type x )\n( id : Π {A : 𝒞} (a : F A), hom (𝟙 A) a a )\n( comp : Π {A B C : 𝒞} {a : F A} {b : F B} {c : F C}\n {f : A ⟶ B} {g : B ⟶ C} (f' : hom f a b) (g' : hom g b c) \n {h : A ⟶ C} (H : f ≫ g = h), hom h a c )\n( id_comp : Π {A B : 𝒞} {f : A ⟶ B} {a : F A} {b : F B}\n (f' : hom f a b), comp (id a) f' (category.id_comp f) = f' )\n( comp_id : Π {A B : 𝒞} {f : A ⟶ B} {a : F A} {b : F B}\n (f' : hom f a b), comp f' (id b) (category.comp_id f) = f' )\n( assoc : Π {A B C D : 𝒞} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D}\n {a : F A} {b : F B} {c : F C} {d : F D}\n (f' : hom f a b) (g' : hom g b c) (h' : hom h c d),\n comp (comp f' g' rfl) h' rfl = comp f' (comp g' h' rfl) \n (category.assoc _ _ _).symm )\n\n-- @[protect_proj] class GS (F : 𝒞 → Type w) :=\n-- ( hom : Π {A B : 𝒞} (f : A ⟶ B) (a : F A) (b : F B), Type x )\n-- ( id : Π {A : 𝒞} (a b : F A) (h : a = b) (f : A ⟶ A) (hf : f = 𝟙 A), hom f a b )\n\nattribute [simp] struc.id_comp struc.comp_id\n\nnamespace struc\n\nvariables (F : 𝒞 → Type w) [struc F]\n\nlemma assoc_left {A B C D : 𝒞} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D}\n {a : F A} {b : F B} {c : F C} {d : F D}\n (f' : struc.hom f a b) (g' : struc.hom g b c) (h' : struc.hom h c d)\n (i : A ⟶ C) (k : A ⟶ D)\n (hi : f ≫ g = i) (hk : i ≫ h = k) :\n struc.comp (struc.comp f' g' hi) h' hk = struc.comp f'\n (struc.comp g' h' rfl) (by rw [← hk, ← hi, category.assoc]) :=\nbegin\n substs i k,\n rw struc.assoc,\nend\n\nlemma comp_eq_cast {A B C : 𝒞} {f : A ⟶ B} {g : B ⟶ C} \n {a : F A} {b : F B} {c : F C} (f' : struc.hom f a b) (g' : struc.hom g b c)\n (i : A ⟶ C) (hi : f ≫ g = i)\n (j : A ⟶ C) (hj : f ≫ g = j) :\n struc.comp f' g' hi = cast (by substs i j) (struc.comp f' g' hj) :=\nbegin\n substs i j, refl\nend\n\nlemma assoc_left' {A B C D : 𝒞} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D}\n {a : F A} {b : F B} {c : F C} {d : F D}\n (f' : struc.hom f a b) (g' : struc.hom g b c) (h' : struc.hom h c d)\n (i : A ⟶ C) (k : A ⟶ D)\n (hi : f ≫ g = i) (hk : i ≫ h = k) :\n struc.comp (struc.comp f' g' hi) h' hk = cast (by rw [← hk, ← hi, category.assoc]) \n (struc.comp f' (struc.comp g' h' rfl) rfl) :=\nbegin\n rw struc.assoc_left,\n substs i k,\n rw [comp_eq_cast]\nend\n\nlemma id_comp' {A B : 𝒞} {f : A ⟶ B} (g : A ⟶ B) {a : F A} {b : F B}\n (h : 𝟙 A ≫ f = g) (f' : struc.hom f a b) : \n struc.comp (struc.id a) f' h = cast (by rw [← h, category.id_comp]) f' :=\nbegin\n rw [category.id_comp] at h,\n subst h,\n simp\nend\n\nlemma comp_id' {A B : 𝒞} {f : A ⟶ B} (g : A ⟶ B) {a : F A} {b : F B}\n (h : f ≫ 𝟙 B = g) (f' : struc.hom f a b) : \n struc.comp f' (struc.id b) h = cast (by rw [← h, category.comp_id]) f' :=\nbegin\n rw [category.comp_id] at h,\n subst h,\n simp\nend \n\ninstance : category_struct (sigma F) :=\n{ hom := λ A B, Σ (f : A.1 ⟶ B.1), struc.hom f A.2 B.2,\n id := λ A, ⟨𝟙 A.1, struc.id A.2⟩,\n comp := λ A B C f g, ⟨f.1 ≫ g.1, struc.comp f.2 g.2 rfl⟩ }\n\n@[simp] lemma comp_fst {A B C : sigma F} (f : A ⟶ B) (g : B ⟶ C) :\n (f ≫ g).fst = f.1 ≫ g.1 := rfl\n\n@[simp] lemma comp_snd {A B C : sigma F} (f : A ⟶ B) (g : B ⟶ C) :\n (f ≫ g).snd = struc.comp f.2 g.2 rfl := rfl\n\n@[simp] lemma id_fst {A : sigma F} : sigma.fst (𝟙 A) = 𝟙 A.1 := rfl\n\n@[simp] lemma id_snd {A : sigma F} : sigma.snd (𝟙 A) = struc.id A.2 := rfl\n\ninstance sigma.category : category (sigma F) :=\n{ id_comp' := λ A B f, sigma.ext (category.id_comp _) $\n by simp [struc.id_comp'],\n comp_id' := λ A B f, sigma.ext (category.comp_id _) $\n by simp [struc.comp_id'],\n assoc' := λ A B C D f g h, sigma.ext (category.assoc _ _ _) $\n by simp [assoc_left'] }\n\ninstance (X : 𝒞) : category_struct (F X) :=\n{ hom := λ A B, struc.hom (𝟙 X) A B,\n id := λ A, struc.id A,\n comp := λ A B C f g, (struc.comp f g (category.id_comp _)) }\n\n\ninstance (X : 𝒞) : category (F X) :=\n{ id_comp' := λ A B f, struc.id_comp _,\n comp_id' := λ A B f, struc.comp_id _,\n assoc' := λ A B C D f g h,\n show (f ≫ g) ≫ h = f ≫ g ≫ h,\n begin\n dsimp [category_struct.comp],\n rw [struc.assoc_left],\n congr' 2; simp\n end }\n\ndef forget : sigma F ⥤ 𝒞 :=\n{ obj := sigma.fst,\n map := λ _ _, sigma.fst }\n\ndef thing (X : 𝒞) : F X ⥤ sigma F :=\n{ obj := λ A, ⟨X, A⟩,\n map := λ A B f, ⟨𝟙 X, f⟩,\n map_id' := λ A, rfl,\n map_comp' := λ A B C f g, sigma.ext \n (by simp) begin simp only [comp_snd],\n rw [struc.comp_eq_cast F f g (𝟙 X ≫ 𝟙 X) rfl (𝟙 X)\n (category.comp_id _)],\n symmetry,\n rw [← cast_eq_iff_heq],\n simp, refl,\n simp,\n end }\n\ninstance inst1 (F : 𝒞 ⥤ Type) : struc F.obj :=\n{ hom := λ A B f a b, plift (F.map f a = b),\n id := λ A a, ⟨by simp⟩,\n comp := λ A B C a b c f g h₁ h₂ _ h, ⟨by simp [← h, F.map_comp, h₁.down, h₂.down]⟩,\n assoc := λ _ _ _ _ _ _ _ _ _ _ _ h₁ h₂ h₃, \n begin simp [h₁.down, h₂.down, h₃.down] end,\n id_comp := λ _ _ _ _ _ h, \n begin simp [h.down] end,\n comp_id := λ _ _ _ _ _ h, \n begin simp [h.down] end }\n\n-- instance inst2 (F : 𝒞 ⥤ Typeᵒᵖ) : struc (λ x, (F.obj x).unop) :=\n-- { hom := λ A B f a b, plift ((F.map f).unop b = a),\n-- id := λ A a, ⟨by simp⟩,\n-- comp := λ A B C a b c f g h₁ h₂, ⟨by simp [F.map_comp, h₁.down, h₂.down]⟩,\n-- assoc := λ _ _ _ _ _ _ _ _ _ _ _ h₁ h₂ h₃, \n-- begin refine heq_of_cast_eq _ _;\n-- simp [h₁.down, h₂.down, h₃.down] end,\n-- id_comp := λ _ _ _ _ _ h, \n-- begin refine heq_of_cast_eq _ _; simp [h.down] end,\n-- comp_id := λ _ _ _ _ _ h, \n-- begin refine heq_of_cast_eq _ _; simp [h.down] end } \n\nexample : struc (λ R : Ring, Module R) :=\n{ hom := λ R S f M₁ M₂, M₁ →ₛₗ[f] M₂,\n id := λ R M, linear_map.id,\n comp := λ R S T M₁ M₂ M₃ f g f' g' _ h, \n @linear_map.comp _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ⟨h⟩ g' f',\n id_comp := λ R S f M₁ M₂ f', begin\n cases f', cases f, refl\n end,\n comp_id := λ R S f M₁ M₂ f', begin\n cases f', cases f, refl,\n end,\n assoc := λ R S T U f g h M₁ M₂ M₃ M₄ f' g' h', \n begin\n cases f, cases g, cases h, cases f', cases g', cases h',\n refl\n end }\n\nexample (F : 𝒞 ⥤ Type) (G : 𝒞 → Type) [struc G] : struc (λ A : 𝒞, F.obj A → G A) :=\n{ hom := λ X Y f x y, Π (a : F.obj X) (b : F.obj Y), struc.hom f (x a) (y (F.map f a)),\n id := λ X x a, cast (by simp) (struc.id (x a)),\n comp := λ X Y Z x y z f g f' g' _ h a, struc.comp (f' a) \n (g' (F.map f a)) _,\n id_comp := λ X Y f x y f', begin\n apply function.hfunext,\n { refl },\n { intros a a' h,\n rw [heq_iff_eq] at h,\n subst a',\n refine cast_eq_iff_heq.1 _,\n simp,\n simp, admit } \n end,\n comp_id := sorry,\n assoc := λ W X Y Z f g h w x y z f' g' h', \n begin\n apply function.hfunext,\n { refl },\n { intros a a' h,\n rw [heq_iff_eq] at h,\n subst a',\n dsimp,\n admit }\n \n end }\n\ndef pi.struc (F : 𝒞 ⥤ Type) (G : (Σ A : 𝒞, F.obj A) → Type) [struc G] : \n struc (λ A : 𝒞, Π a : F.obj A, G ⟨A, a⟩) :=\n{ hom := λ X Y f x y, Π (a : F.obj X),\n @struc.hom _ _ G _ ⟨X, a⟩ ⟨Y, F.map f a⟩ ⟨f, ⟨rfl⟩⟩ (x a) (y (F.map f a)),\n id := λ X x a, by convert @struc.id _ _ G _ ⟨X, a⟩ (x a); simp,\n comp := sorry,\n id_comp := sorry,\n comp_id := sorry,\n assoc := sorry }\n\n-- Maybe think about W.\n\nend struc", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/parametricity/sigma_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.538983220687684, "lm_q2_score": 0.4571367168274948, "lm_q1q2_score": 0.24638901993027693}} {"text": "import data.cpi.species\n\nnamespace cpi\n\n/-- A concretion represents the potential for a species to interact with another.\n -/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive concretion (ℍ : Type) (ω : context) : context → ℕ → ℕ → Type\n| apply {Γ} {b} (bs : vector (name Γ) b) (y : ℕ)\n : species ℍ ω (context.extend y Γ)\n → concretion Γ b y\n| parallel₁ {Γ} {b y} : concretion Γ b y → species ℍ ω Γ → concretion Γ b y\n| parallel₂ {Γ} {b y} : species ℍ ω Γ → concretion Γ b y → concretion Γ b y\n| restriction {Γ} {b y} (M : affinity ℍ)\n : concretion (context.extend M.arity Γ) b y\n → concretion Γ b y\n\nnotation `#(` b ` ; ` y `)` A := concretion.apply b y A\n\nreserve infixr ` |₁ ` :50\nreserve infixr ` |₂ ` :50\n\ninfixr ` |₁ ` := concretion.parallel₁\ninfixr ` |₂ ` := concretion.parallel₂\n\nnotation `ν'(` M `) ` A := concretion.restriction M A\n\nvariables {ℍ : Type} {ω : context}\n\nnamespace concretion\n\n/-- Convert a concretion to a string. Can use `repr` normally. -/\nprotected def to_string [has_repr ℍ]: ∀ {Γ} {b y} , concretion ℍ ω Γ b y → string\n| ._ ._ ._ (concretion.apply bs y A') := \"(\" ++ repr bs.val ++ \";\" ++ repr y ++ \")\" ++ repr A'\n| ._ ._ ._ (F |₁ A') := \"(\" ++ to_string F ++ \" | \" ++ repr A' ++ \")\"\n| ._ ._ ._ (A' |₂ F) := \"(\" ++ repr A' ++ \" | \" ++ to_string F ++ \")\"\n| ._ ._ ._ (ν'(M) A') := \"(ν ?)(\" ++ to_string A' ++ \")\"\n\ninstance [has_repr ℍ] {b y} {Γ} : has_repr (concretion ℍ ω b y Γ) := ⟨ concretion.to_string ⟩\n\nsection free\n /-- Determine whether a level occurs within a concretion. -/\n def free_in : ∀ {Γ} {b y} (l : level Γ) (F : concretion ℍ ω Γ b y), Prop\n | Γ b y l (#(bs; _) A) := (∃ b ∈ bs.val, l ∈ b) ∨ level.extend l ∈ A\n | Γ b y l (F |₁ A) := free_in l F ∨ l ∈ A\n | Γ b y l (A |₂ F) := l ∈ A ∨ free_in l F\n | Γ b y l (ν'(M) F) := free_in (level.extend l) F\n\n instance {Γ} {b y} : has_mem (level Γ) (concretion ℍ ω Γ b y) := ⟨ free_in ⟩\n\n private def free_in_decide : ∀ {Γ} {b y} (l : level Γ) (F : concretion ℍ ω Γ b y), decidable (free_in l F)\n | Γ b y l (#(bs; _) A) := by { unfold free_in, apply_instance }\n | Γ b y l (F |₁ A) := @or.decidable _ _ (free_in_decide l F) _\n | Γ b y l (A |₂ F) := @or.decidable _ _ _ (free_in_decide l F)\n | Γ b y l (ν'(M) F) := free_in_decide (level.extend l) F\n\n instance free_in.decidable {Γ} {b y} {l} {F : concretion ℍ ω Γ b y} : decidable (l ∈ F)\n := free_in_decide l F\nend free\n\nsection rename\n /-- Rename a concretion. -/\n def rename : ∀ {Γ Δ} {b y} (ρ : name Γ → name Δ), concretion ℍ ω Γ b y → concretion ℍ ω Δ b y\n | Γ Δ b y ρ (#(bs; _) A) := #( vector.map ρ bs; y) species.rename (name.ext ρ) A\n | Γ Δ b y ρ (F |₁ A) := rename ρ F |₁ species.rename ρ A\n | Γ Δ b y ρ (A |₂ F) := species.rename ρ A |₂ rename ρ F\n | Γ Δ b y ρ (ν'(M) A) := ν'(M) (rename (name.ext ρ) A)\n\n lemma rename_id\n : ∀ {Γ} {b y} (F : concretion ℍ ω Γ b y)\n , rename id F = F\n | Γ b ._ (#(⟨ list, n ⟩; y) A) := begin\n simp only [rename, vector.map, list.map_id, subtype.mk_eq_mk],\n rw name.ext_id,\n from ⟨ rfl, species.rename_id A ⟩\n end\n | Γ b y (F |₁ A) := begin\n simp only [rename],\n from ⟨ rename_id F, species.rename_id A ⟩\n end\n | Γ b y (A |₂ F) := begin\n simp only [rename],\n from ⟨ species.rename_id A, rename_id F ⟩\n end\n | Γ b y (ν'(M) F) := begin\n simp only [rename], rw name.ext_id,\n from ⟨ rfl, heq_of_eq (rename_id F) ⟩,\n end\n\n lemma rename_compose :\n ∀ {Γ Δ η} {b y} (ρ : name Γ → name Δ) (σ : name Δ → name η) (A : concretion ℍ ω Γ b y)\n , rename σ (rename ρ A) = rename (σ ∘ ρ) A\n | Γ Δ η b ._ ρ σ (#(⟨ elem, n ⟩; y) A) := begin\n unfold rename vector.map,\n rw [species.rename_compose _ _ A, name.ext_comp],\n simp\n end\n | Γ Δ η b y ρ σ (F |₁ A) := begin\n unfold rename,\n rw [rename_compose ρ σ F, species.rename_compose ρ σ A]\n end\n | Γ Δ η b y ρ σ (A |₂ F) := begin\n unfold rename,\n rw [rename_compose ρ σ F, species.rename_compose ρ σ A]\n end\n | Γ Δ η b y ρ σ (ν'(M) A) := begin\n unfold rename,\n rw [rename_compose (name.ext ρ) (name.ext σ) A, name.ext_comp]\n end\n\nend rename\n\nend concretion\n\n/-- A quotient of all equivalent concretions. -/\n@[nolint has_inhabited_instance]\ndef concretion' (ℍ : Type) (ω Γ : context) (b y : ℕ) [r : setoid (concretion ℍ ω Γ b y)]\n := quotient r\n\nend cpi\n\n#lint-\n", "meta": {"author": "continuouspi", "repo": "lean-cpi", "sha": "443bf2cb236feadc45a01387099c236ab2b78237", "save_path": "github-repos/lean/continuouspi-lean-cpi", "path": "github-repos/lean/continuouspi-lean-cpi/lean-cpi-443bf2cb236feadc45a01387099c236ab2b78237/src/data/cpi/concretion/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.577495350642608, "lm_q2_score": 0.4263215925474903, "lm_q1q2_score": 0.246198737574728}} {"text": "\n/- Observable events, execution traces, and semantics of external calls. -/\n\nimport .globalenvs .memory\n\nnamespace events\nopen integers word floats ast globalenvs values memory\n ast.typ memory.perm_kind\n\n/- * Events and traces -/\n\n/- The observable behaviour of programs is stated in terms of\n input/output events, which represent the actions of the program\n that the external world can observe. CompCert leaves much flexibility as to\n the exact content of events: the only requirement is that they\n do not expose memory states nor pointer values\n (other than pointers to global variables), because these\n are not preserved literally during compilation. For concreteness,\n we use the following type for events. Each event represents either:\n\n- A system call (e.g. an input/output operation), recording the\n name of the system call, its parameters, and its result.\n\n- A volatile load from a global memory location, recording the chunk\n and address being read and the value just read.\n\n- A volatile store to a global memory location, recording the chunk\n and address being written and the value stored there.\n\n- An annotation, recording the text of the annotation and the values\n of the arguments.\n\n The values attached to these events are of the following form.\n As mentioned above, we do not expose pointer values directly.\n Pointers relative to a global variable are shown with the name\n of the variable instead of the block identifier.\n-/\n\ninductive eventval : Type\n| EVint : int32 → eventval\n| EVlong : int64 → eventval\n| EVfloat : float → eventval\n| EVsingle : float32 → eventval\n| EVptr_global : ident → ptrofs → eventval\nopen eventval\n\ninductive event : Type\n| syscall : string → list eventval → eventval → event\n| vload : memory_chunk → ident → ptrofs → eventval → event\n| vstore : memory_chunk → ident → ptrofs → eventval → event\n| annot : string → list eventval → event\n\n/- * Relating values and event values -/\n\nnamespace eventval\n\ndef type : eventval → typ\n| (EVint _) := Tint\n| (EVlong _) := Tlong\n| (EVfloat _) := Tfloat\n| (EVsingle _) := Tsingle\n| (EVptr_global _ _) := Tptr\n\n/- Symbol environment used to translate between global variable names and their block identifiers. -/\n\nsection\nvariable (ge : Senv)\n\n/- Translation between values and event values. -/\n\ndef to_val : eventval → option val\n| (EVint i) := some (Vint i)\n| (EVlong i) := some (Vlong i)\n| (EVfloat f) := some (Vfloat f)\n| (EVsingle f) := some (Vsingle f)\n| (EVptr_global id ofs) :=\n do guard (Senv.public_symbol ge id),\n b ← Senv.find_symbol ge id,\n return (Vptr b ofs)\n\ndef matchv (ev : eventval) (t : typ) (v : val) : Prop :=\nev.type = t ∧ ev.to_val ge = some v\n\ndef list_match (evl : list eventval) (tl : list typ) (vl : list val) : Prop :=\nevl.map type = tl ∧ mmap (to_val ge) evl = some vl\n\n/- Some properties of these translation predicates. -/\n\nlemma match_type {ev ty v} : matchv ge ev ty v → val.has_type v ty := sorry'\n\nlemma match_lessdef {ev ty v1 v2} :\n matchv ge ev ty v1 → val.lessdef v1 v2 → matchv ge ev ty v2 := sorry'\n\nlemma list_match_lessdef {evl tyl vl1} :\n list_match ge evl tyl vl1 →\n ∀ vl2, list.forall2 val.lessdef vl1 vl2 → list_match ge evl tyl vl2 := sorry'\n\n/- Determinism -/\n\nlemma match_determ_1 {ev ty v1 v2} :\n matchv ge ev ty v1 → matchv ge ev ty v2 → v1 = v2 := sorry'\n\nlemma match_determ_2 {ev1 ev2 ty v} :\n matchv ge ev1 ty v → matchv ge ev2 ty v → ev1 = ev2 := sorry'\n\nlemma list_match_determ_2 {evl1 tyl vl} :\n list_match ge evl1 tyl vl →\n ∀ evl2, list_match ge evl2 tyl vl → evl1 = evl2 := sorry'\n\n/- Validity -/\n\ndef valid : eventval → bool\n| (EVptr_global id ofs) := Senv.public_symbol ge id\n| _ := tt\n\nlemma match_receptive {ev1 ty v1 ev2} :\n matchv ge ev1 ty v1 →\n valid ge ev1 → valid ge ev2 → type ev1 = type ev2 →\n ∃ v2, matchv ge ev2 ty v2 := sorry'\n\nlemma match_valid {ev ty v} :\n matchv ge ev ty v → valid ge ev := sorry'\n\nlemma match_same_type {ev1 ty v1 ev2 v2} :\n matchv ge ev1 ty v1 → matchv ge ev2 ty v2 → type ev1 = type ev2 := sorry'\n\nend\nend eventval\n\n/- Invariance under changes to the global environment -/\n\nsection eventval_inv\n\nparameters {ge1 ge2 : Senv}\nparameter (public_preserved : ∀ id,\n Senv.public_symbol ge2 id = Senv.public_symbol ge1 id)\n\nlemma eventval_valid_preserved {ev} :\n eventval.valid ge1 ev → eventval.valid ge2 ev := sorry'\n\nparameter (symbols_preserved : ∀ id,\n Senv.find_symbol ge2 id = Senv.find_symbol ge1 id)\n\nlemma eventval_match_preserved {ev ty v} :\n eventval.matchv ge1 ev ty v → eventval.matchv ge2 ev ty v := sorry'\n\nlemma eventval_list_match_preserved :\n ∀ evl tyl vl,\n eventval.list_match ge1 evl tyl vl → eventval.list_match ge2 evl tyl vl := sorry'\n\nend eventval_inv\n\n/- Compatibility with memory injections -/\n\nsection eventval_inject\n\nparameter (f : block → option (block × ℤ))\nparameters (ge1 ge2 : Senv)\n\ndef symbols_inject : Prop :=\n (∀ id, Senv.public_symbol ge2 id = Senv.public_symbol ge1 id)\n∧ (∀ id b1 b2 delta,\n f b1 = some (b2, delta) → Senv.find_symbol ge1 id = some b1 →\n delta = 0 ∧ Senv.find_symbol ge2 id = some b2)\n∧ (∀ id b1,\n Senv.public_symbol ge1 id = tt → Senv.find_symbol ge1 id = some b1 →\n ∃ b2, f b1 = some (b2, 0) ∧ Senv.find_symbol ge2 id = some b2)\n∧ (∀ b1 b2 delta,\n f b1 = some (b2, delta) →\n Senv.block_is_volatile ge2 b2 = Senv.block_is_volatile ge1 b1)\n\nparameter symb_inj : symbols_inject\n\nlemma eventval_match_inject {ev ty v1 v2} :\n eventval.matchv ge1 ev ty v1 → val.inject f v1 v2 → eventval.matchv ge2 ev ty v2 := sorry'\n\nlemma eventval_match_inject_2 :\n ∀ ev ty v1,\n eventval.matchv ge1 ev ty v1 →\n ∃ v2, eventval.matchv ge2 ev ty v2 ∧ val.inject f v1 v2 := sorry'\n\nlemma eventval_list_match_inject {evl tyl vl1} :\n eventval.list_match ge1 evl tyl vl1 →\n ∀ vl2, list.forall2 (val.inject f) vl1 vl2 → eventval.list_match ge2 evl tyl vl2 := sorry'\n\nend eventval_inject\n\n/- * Matching traces. -/\n\nsection match_traces\n\nparameter ge : Senv\n\n/- Matching between traces corresponding to single transitions.\n Arguments (provided by the program) must be equal.\n Results (provided by the outside world) can vary as long as they\n can be converted safely to values. -/\n\ndef match_events : event → event → Prop\n| (event.syscall id args res1) (event.syscall id' args' res2) :=\n id = id' ∧ args = args' ∧ res1.valid ge ∧ res2.valid ge ∧ res1.type = res2.type\n| (event.vload chunk id ofs res1) (event.vload chunk' id' ofs' res2) :=\n chunk = chunk' ∧ id = id' ∧ ofs = ofs' ∧ res1.valid ge ∧ res2.valid ge ∧ res1.type = res2.type\n| (event.vstore chunk id ofs arg) (event.vstore chunk' id' ofs' arg') :=\n chunk = chunk' ∧ id = id' ∧ ofs = ofs' ∧ arg = arg'\n| (event.annot id args) (event.annot id' args') :=\n id = id' ∧ args = args'\n| _ _ := false\n\ninductive match_traces : list event → list event → Prop\n| nil : match_traces [] []\n| evt (e1 e2) : match_events e1 e2 → match_traces [e1] [e2]\n\nend match_traces\n\n/- Invariance by change of global environment -/\n\nlemma match_traces_preserved {ge1 ge2}\n (public_preserved : ∀ id, Senv.public_symbol ge2 id = Senv.public_symbol ge1 id)\n {t1 t2} : match_traces ge1 t1 t2 → match_traces ge2 t1 t2 := sorry'\n\n/- An output trace is a trace composed only of output events,\n that is, events that do not take any result from the outside world. -/\n\ndef output_event : event → bool\n| (event.vstore _ _ _ _) := tt\n| (event.annot _ _) := tt\n| _ := ff\n\ndef output_trace (t : list event) : bool := t.all output_event\n\n/- * Semantics of external functions -/\n\n/- For each external function, its behavior is defined by a predicate relating:\n- the global symbol environment\n- the values of the arguments passed to this function\n- the memory state before the call\n- the result value of the call\n- the memory state after the call\n- the trace generated by the call (can be empty).\n-/\n\ndef extcall_sem : Type := Senv → list val → mem → list event → val → mem → Prop\n\n/- We now specify the expected properties of this predicate. -/\n\ndef loc_out_of_bounds (m : mem) (b : block) (ofs : ℕ) : Prop :=\n ¬ perm m b ofs Max Nonempty\n\ndef loc_not_writable (m : mem) (b : block) (ofs : ℕ) : Prop :=\n ¬ perm m b ofs Max Writable\n\ndef loc_unmapped (f : meminj) (b : block) (ofs : ℕ) : Prop :=\n f b = none\n\ndef loc_out_of_reach (f : meminj) (m : mem) (b : block) (ofs : ℕ) : Prop :=\n ∀ b0 delta,\n f b0 = some (b, delta) → ¬ perm_Z m b0 (ofs - delta) Max Nonempty\n\ndef inject_separated (f f' : meminj) (m1 m2 : mem) : Prop :=\n ∀ b1 b2 delta,\n f b1 = none → f' b1 = some (b2, delta) →\n ¬ valid_block m1 b1 ∧ ¬ valid_block m2 b2\n\nstructure extcall_properties (sem : extcall_sem) (sg : signature) : Prop :=\n/- The return value of an external call must agree with its signature. -/\n(well_typed :\n ∀ ge vargs m1 t vres m2,\n sem ge vargs m1 t vres m2 →\n vres.has_type (proj_sig_res sg))\n\n/- The semantics is invariant under change of global environment that preserves symbols. -/\n(symbols_preserved :\n ∀ ge1 ge2 vargs m1 t vres m2,\n Senv.equiv ge1 ge2 →\n sem ge1 vargs m1 t vres m2 →\n sem ge2 vargs m1 t vres m2)\n\n/- External calls cannot invalidate memory blocks. (Remember that\n freeing a block does not invalidate its block identifier.) -/\n(valid_block :\n ∀ ge vargs m1 t vres m2 b,\n sem ge vargs m1 t vres m2 →\n valid_block m1 b → valid_block m2 b)\n\n/- External calls cannot increase the max permissions of a valid block.\n They can decrease the max permissions, e.g. by freeing. -/\n(max_perm :\n ∀ ge vargs m1 t vres m2 b ofs p,\n sem ge vargs m1 t vres m2 →\n memory.valid_block m1 b → perm m2 b ofs Max p → perm m1 b ofs Max p)\n\n/- External call cannot modify memory unless they have [Max, Writable]\n permissions. -/\n(readonly :\n ∀ ge vargs m1 t vres m2,\n sem ge vargs m1 t vres m2 →\n unchanged_on (loc_not_writable m1) m1 m2)\n\n/- External calls must commute with memory extensions, in the\n following sense. -/\n(mem_extends :\n ∀ ge vargs m1 t vres m2 m1' vargs',\n sem ge vargs m1 t vres m2 →\n extends' m1 m1' →\n list.forall2 lessdef vargs vargs' →\n ∃ vres', ∃ m2',\n sem ge vargs' m1' t vres' m2'\n ∧ lessdef vres vres'\n ∧ extends' m2 m2'\n ∧ unchanged_on (loc_out_of_bounds m1) m1' m2')\n\n/- External calls must commute with memory injections,\n in the following sense. -/\n(mem_inject :\n ∀ ge1 ge2 vargs m1 t vres m2 f m1' vargs',\n symbols_inject f ge1 ge2 →\n sem ge1 vargs m1 t vres m2 →\n inject f m1 m1' →\n list.forall2 (val.inject f) vargs vargs' →\n ∃ f', ∃ vres', ∃ m2',\n sem ge2 vargs' m1' t vres' m2'\n ∧ inject f' vres vres'\n ∧ inject f' m2 m2'\n ∧ unchanged_on (loc_unmapped f) m1 m2\n ∧ unchanged_on (loc_out_of_reach f m1) m1' m2'\n ∧ inject_incr f f'\n ∧ inject_separated f f' m1 m1')\n\n/- External calls produce at most one event. -/\n(trace_length :\n ∀ ge vargs m t vres m',\n sem ge vargs m t vres m' → t.length ≤ 1)\n\n/- External calls must be receptive to changes of traces by another, matching trace. -/\n(receptive :\n ∀ ge vargs m t1 vres1 m1 t2,\n sem ge vargs m t1 vres1 m1 → match_traces ge t1 t2 →\n ∃ vres2 m2, sem ge vargs m t2 vres2 m2)\n\n/- External calls must be deterministic up to matching between traces. -/\n(determ :\n ∀ ge vargs m t1 vres1 m1 t2 vres2 m2,\n sem ge vargs m t1 vres1 m1 → sem ge vargs m t2 vres2 m2 →\n match_traces ge t1 t2 ∧ (t1 = t2 → vres1 = vres2 ∧ m1 = m2))\n\n/- * Semantics of volatile memory accesses -/\n\ninductive volatile_load (ge) (chunk : memory_chunk) (m b ofs) :\n list event → val → Prop\n| volatile_load_vol (id ev v) :\n Senv.block_is_volatile ge b = tt →\n Senv.find_symbol ge id = some b →\n eventval.matchv ge ev chunk.type v →\n volatile_load [event.vload chunk id ofs ev] (load_result chunk v)\n| volatile_load_nonvol (v) :\n Senv.block_is_volatile ge b = ff →\n load chunk m b (unsigned ofs) = some v →\n volatile_load [] v\n\ninductive volatile_store (ge) (chunk : memory_chunk) (m b ofs v) :\n list event → mem → Prop\n| volatile_store_vol (id ev) :\n Senv.block_is_volatile ge b = tt →\n Senv.find_symbol ge id = some b →\n eventval.matchv ge ev chunk.type (load_result chunk v) →\n volatile_store [event.vstore chunk id ofs ev] m\n| volatile_store_nonvol (m') :\n Senv.block_is_volatile ge b = ff →\n store chunk m b (unsigned ofs) v = some m' →\n volatile_store [] m'\n\n/- ** Semantics of volatile loads -/\n\ninductive volatile_load_sem (chunk : memory_chunk) (ge : Senv) :\n list val → mem → list event → val → mem → Prop\n| mk (b ofs m t v) :\n volatile_load ge chunk m b ofs t v →\n volatile_load_sem [Vptr b ofs] m t v m.\n\nlemma volatile_load_preserved {ge1 ge2 chunk m b ofs t v} :\n Senv.equiv ge1 ge2 →\n volatile_load ge1 chunk m b ofs t v →\n volatile_load ge2 chunk m b ofs t v := sorry'\n\nlemma volatile_load_extends {ge chunk m b ofs t v m'} :\n volatile_load ge chunk m b ofs t v →\n extends' m m' →\n ∃ v', volatile_load ge chunk m' b ofs t v' ∧ lessdef v v' := sorry'\n\nlemma volatile_load_inject {ge1 ge2 f chunk m b ofs t v b' ofs' m'} :\n symbols_inject f ge1 ge2 →\n volatile_load ge1 chunk m b ofs t v →\n inject f (Vptr b ofs) (Vptr b' ofs') →\n inject f m m' →\n ∃ v', volatile_load ge2 chunk m' b' ofs' t v' ∧ inject f v v' := sorry'\n\nlemma volatile_load_receptive {ge chunk m b ofs t1 t2 v1} :\n volatile_load ge chunk m b ofs t1 v1 → match_traces ge t1 t2 →\n ∃ v2, volatile_load ge chunk m b ofs t2 v2 := sorry'\n\nlemma volatile_load_ok {chunk} :\n extcall_properties (volatile_load_sem chunk)\n ⟨[Tptr], some chunk.type, cc_default⟩ :=\n{ well_typed := sorry',\n symbols_preserved := sorry',\n valid_block := sorry',\n max_perm := sorry',\n readonly := sorry',\n mem_extends := sorry',\n mem_inject := sorry',\n trace_length := sorry',\n receptive := sorry',\n determ := sorry' }\n\n/- ** Semantics of volatile stores -/\n\ninductive volatile_store_sem (chunk : memory_chunk) (ge : Senv) :\n list val → mem → list event → val → mem → Prop\n| mk (b ofs m1 v t m2) :\n volatile_store ge chunk m1 b ofs v t m2 →\n volatile_store_sem [Vptr b ofs, v] m1 t Vundef m2.\n\nlemma volatile_store_preserved {ge1 ge2 chunk m1 b ofs v t m2} :\n Senv.equiv ge1 ge2 →\n volatile_store ge1 chunk m1 b ofs v t m2 →\n volatile_store ge2 chunk m1 b ofs v t m2 := sorry'\n\nlemma volatile_store_readonly {ge chunk1 m1 b1 ofs1 v t m2} :\n volatile_store ge chunk1 m1 b1 ofs1 v t m2 →\n unchanged_on (loc_not_writable m1) m1 m2 := sorry'\n\nlemma volatile_store_extends {ge chunk m1 b ofs v t m2 m1' v'} :\n volatile_store ge chunk m1 b ofs v t m2 →\n extends' m1 m1' →\n lessdef v v' →\n ∃ m2',\n volatile_store ge chunk m1' b ofs v' t m2'\n ∧ extends' m2 m2'\n ∧ unchanged_on (loc_out_of_bounds m1) m1' m2' := sorry'\n\nlemma volatile_store_inject {ge1 ge2 f chunk m1 b ofs v t m2 m1' b' ofs' v'} :\n symbols_inject f ge1 ge2 →\n volatile_store ge1 chunk m1 b ofs v t m2 →\n inject f (Vptr b ofs) (Vptr b' ofs') →\n inject f v v' →\n inject f m1 m1' →\n ∃ m2',\n volatile_store ge2 chunk m1' b' ofs' v' t m2'\n ∧ inject f m2 m2'\n ∧ unchanged_on (loc_unmapped f) m1 m2\n ∧ unchanged_on (loc_out_of_reach f m1) m1' m2' := sorry'\n\nlemma volatile_store_receptive {ge chunk m b ofs v t1 m1 t2} :\n volatile_store ge chunk m b ofs v t1 m1 → match_traces ge t1 t2 → t1 = t2 := sorry'\n\nlemma volatile_store_ok {chunk} :\n extcall_properties (volatile_store_sem chunk) ⟨[Tptr, chunk.type], none, cc_default⟩ :=\n{ well_typed := sorry',\n symbols_preserved := sorry',\n valid_block := sorry',\n max_perm := sorry',\n readonly := sorry',\n mem_extends := sorry',\n mem_inject := sorry',\n trace_length := sorry',\n receptive := sorry',\n determ := sorry' }\n\n/- ** Semantics of dynamic memory allocation (malloc) -/\n\ninductive extcall_malloc_sem (ge : Senv) :\n list val → mem → list event → val → mem → Prop\n| mk (sz : ptrofs) (m m' : mem) :\n store Mptr (m.alloc 0 (unsigned sz + Mptr.size)) m.nextblock 0 (Vptrofs sz) = some m' →\n extcall_malloc_sem [Vptrofs sz] m [] (Vptr m.nextblock Mptr.size) m'\n\nlemma extcall_malloc_ok :\n extcall_properties extcall_malloc_sem ⟨[Tptr], some Tptr, cc_default⟩ :=\n{ well_typed := sorry',\n symbols_preserved := sorry',\n valid_block := sorry',\n max_perm := sorry',\n readonly := sorry',\n mem_extends := sorry',\n mem_inject := sorry',\n trace_length := sorry',\n receptive := sorry',\n determ := sorry' }\n\n/- ** Semantics of dynamic memory deallocation (free) -/\n\ninductive extcall_free_sem (ge : Senv) :\n list val → mem → list event → val → mem → Prop\n| mk (b) (lo : ptrofs) (sz m m') :\n load Mptr m b (unsigned lo - Mptr.size) = some (Vptrofs sz) →\n unsigned sz > 0 →\n free m b (unsigned lo - Mptr.size) (unsigned lo + unsigned sz) = some m' →\n extcall_free_sem [Vptr b lo] m [] Vundef m'\n\nlemma extcall_free_ok :\n extcall_properties extcall_free_sem ⟨[Tptr], none, cc_default⟩ :=\n{ well_typed := sorry',\n symbols_preserved := sorry',\n valid_block := sorry',\n max_perm := sorry',\n readonly := sorry',\n mem_extends := sorry',\n mem_inject := sorry',\n trace_length := sorry',\n receptive := sorry',\n determ := sorry' }\n\n/- ** Semantics of [memcpy] operations. -/\n\ninductive extcall_memcpy_sem (sz al : ℕ) (ge : Senv) :\n list val → mem → list event → val → mem → Prop\n| mk (bdst bsrc) (odst osrc : ptrofs) (m bytes m') :\n al = 1 ∨ al = 2 ∨ al = 4 ∨ al = 8 → al ∣ sz →\n (sz > 0 → al ∣ unsigned osrc ∧ al ∣ unsigned odst) →\n bsrc ≠ bdst ∨ unsigned osrc = unsigned odst\n ∨ unsigned osrc + sz ≤ unsigned odst\n ∨ unsigned odst + sz ≤ unsigned osrc →\n load_bytes m bsrc (unsigned osrc) sz = some bytes →\n store_bytes m bdst (unsigned odst) bytes = some m' →\n extcall_memcpy_sem [Vptr bdst odst, Vptr bsrc osrc] m [] Vundef m'\n\nlemma extcall_memcpy_ok (sz al) :\n extcall_properties (extcall_memcpy_sem sz al) ⟨[Tptr, Tptr], none, cc_default⟩ :=\n{ well_typed := sorry',\n symbols_preserved := sorry',\n valid_block := sorry',\n max_perm := sorry',\n readonly := sorry',\n mem_extends := sorry',\n mem_inject := sorry',\n trace_length := sorry',\n receptive := sorry',\n determ := sorry' }\n\n/- ** Semantics of annotations. -/\n\ninductive extcall_annot_sem (text : string) (targs : list typ) (ge : Senv) :\n list val → mem → list event → val → mem → Prop\n| mk (vargs m args) : eventval.list_match ge args targs vargs →\n extcall_annot_sem vargs m [event.annot text args] Vundef m\n\nlemma extcall_annot_ok (text targs) :\n extcall_properties (extcall_annot_sem text targs) ⟨targs, none, cc_default⟩ :=\n{ well_typed := sorry',\n symbols_preserved := sorry',\n valid_block := sorry',\n max_perm := sorry',\n readonly := sorry',\n mem_extends := sorry',\n mem_inject := sorry',\n trace_length := sorry',\n receptive := sorry',\n determ := sorry' }\n\ninductive extcall_annot_val_sem (text : string) (targ : typ) (ge : Senv) :\n list val → mem → list event → val → mem → Prop\n| mk (varg m arg) :\n eventval.matchv ge arg targ varg →\n extcall_annot_val_sem [varg] m [event.annot text [arg]] varg m\n\nlemma extcall_annot_val_ok (text targ) :\n extcall_properties (extcall_annot_val_sem text targ) ⟨[targ], some targ, cc_default⟩ :=\n{ well_typed := sorry',\n symbols_preserved := sorry',\n valid_block := sorry',\n max_perm := sorry',\n readonly := sorry',\n mem_extends := sorry',\n mem_inject := sorry',\n trace_length := sorry',\n receptive := sorry',\n determ := sorry' }\n\ninductive extcall_debug_sem (ge : Senv) :\n list val → mem → list event → val → mem → Prop\n| mk (vargs m) : extcall_debug_sem vargs m [] Vundef m\n\nlemma extcall_debug_ok (targs) :\n extcall_properties extcall_debug_sem ⟨targs, none, cc_default⟩ :=\n{ well_typed := sorry',\n symbols_preserved := sorry',\n valid_block := sorry',\n max_perm := sorry',\n readonly := sorry',\n mem_extends := sorry',\n mem_inject := sorry',\n trace_length := sorry',\n receptive := sorry',\n determ := sorry' }\n\n/- ** Semantics of external functions. -/\n\n/- For functions defined outside the program ([EF_external],\n [EF_builtin] and [EF_runtime]), we do not define their\n semantics, but only assume that it satisfies\n [extcall_properties]. -/\n\nconstant external_functions_sem : string → signature → extcall_sem\n\nconstant external_functions_properties {id sg} :\n extcall_properties (external_functions_sem id sg) sg\n\n/- We treat inline assembly similarly. -/\n\nconstant inline_assembly_sem : string → signature → extcall_sem\n\nconstant inline_assembly_properties {id sg} :\n extcall_properties (inline_assembly_sem id sg) sg\n\n/- ** Combined semantics of external calls -/\n\n/- Combining the semantics given above for the various kinds of external calls,\n we define the predicate [external_call] that relates:\n- the external function being invoked\n- the values of the arguments passed to this function\n- the memory state before the call\n- the result value of the call\n- the memory state after the call\n- the trace generated by the call (can be empty).\n\nThis predicate is used in the semantics of all CompCert languages. -/\n\nnoncomputable def external_call : external_function → extcall_sem\n| (EF_external name sg) := external_functions_sem name sg\n| (EF_builtin name sg) := external_functions_sem name sg\n| (EF_runtime name sg) := external_functions_sem name sg\n| (EF_vload chunk) := volatile_load_sem chunk\n| (EF_vstore chunk) := volatile_store_sem chunk\n| EF_malloc := extcall_malloc_sem\n| EF_free := extcall_free_sem\n| (EF_memcpy sz al) := extcall_memcpy_sem sz al\n| (EF_annot txt targs) := extcall_annot_sem txt targs\n| (EF_annot_val txt targ) := extcall_annot_val_sem txt targ\n| (EF_inline_asm txt sg clb) := inline_assembly_sem txt sg\n| (EF_debug kind txt targs) := extcall_debug_sem\n\ntheorem external_call_spec (ef) :\n extcall_properties (external_call ef) (ef_sig ef) := sorry'\n\ndef external_call_well_typed (ef) := (external_call_spec ef).well_typed\ndef external_call_symbols_preserved (ef) := (external_call_spec ef).symbols_preserved\ndef external_call_valid_block (ef) := (external_call_spec ef).valid_block\ndef external_call_max_perm (ef) := (external_call_spec ef).max_perm\ndef external_call_readonly (ef) := (external_call_spec ef).readonly\ndef external_call_mem_extends (ef) := (external_call_spec ef).mem_extends\ndef external_call_mem_inject_gen (ef) := (external_call_spec ef).mem_inject\ndef external_call_trace_length (ef) := (external_call_spec ef).trace_length\ndef external_call_receptive (ef) := (external_call_spec ef).receptive\ndef external_call_determ (ef) := (external_call_spec ef).determ\n\n/- Corollary of [external_call_valid_block]. -/\n\nlemma external_call_nextblock (ef ge vargs m1 t vres m2) :\n external_call ef ge vargs m1 t vres m2 →\n m1.nextblock ≤ m2.nextblock := sorry'\n\n/- Special case of [external_call_mem_inject_gen] (for backward compatibility) -/\n\ndef meminj_preserves_globals {F V} (ge : Genv F V) (f : block → option (block × ℤ)) : Prop :=\n (∀ id b, Genv.find_symbol ge id = some b → f b = some (b, 0))\n ∧ (∀ b gv, Genv.find_var_info ge b = some gv → f b = some (b, 0))\n ∧ (∀ b1 b2 delta gv, Genv.find_var_info ge b2 = some gv → f b1 = some (b2, delta) → b2 = b1)\n\nlemma external_call_mem_inject {ef F V} {ge : Genv F V} {vargs m1 t vres m2 f m1' vargs'} :\n meminj_preserves_globals ge f →\n external_call ef ge vargs m1 t vres m2 →\n inject f m1 m1' →\n list.forall2 (val.inject f) vargs vargs' →\n ∃ f' vres' m2',\n external_call ef ge vargs' m1' t vres' m2'\n ∧ inject f' vres vres'\n ∧ inject f' m2 m2'\n ∧ unchanged_on (loc_unmapped f) m1 m2\n ∧ unchanged_on (loc_out_of_reach f m1) m1' m2'\n ∧ inject_incr f f'\n ∧ inject_separated f f' m1 m1' := sorry'\n\n/- Corollaries of [external_call_determ]. -/\n\nlemma external_call_match_traces {ef ge vargs m t1 vres1 m1 t2 vres2 m2} :\n external_call ef ge vargs m t1 vres1 m1 →\n external_call ef ge vargs m t2 vres2 m2 →\n match_traces ge t1 t2 := sorry'\n\nlemma external_call_deterministic {ef ge vargs m t vres1 m1 vres2 m2} :\n external_call ef ge vargs m t vres1 m1 →\n external_call ef ge vargs m t vres2 m2 →\n vres1 = vres2 ∧ m1 = m2 := sorry'\n\n/- * Evaluation of builtin arguments -/\n\nsection eval_builtin_arg\n\nparameters {A : Type} (ge : Senv) (e : A → val) (sp : val) (m : mem)\n\ndef eval_builtin_arg : builtin_arg A → option val\n| (BA x) := some (e x)\n| (BA_int n) := some (Vint n)\n| (BA_long n) := some (Vlong n)\n| (BA_float n) := some (Vfloat n)\n| (BA_single n) := some (Vsingle n)\n| (BA_loadstack chunk ofs) := loadv chunk m (offset_ptr sp ofs)\n| (BA_addrstack ofs) := some (offset_ptr sp ofs)\n| (BA_loadglobal chunk id ofs) := loadv chunk m (Senv.symbol_address ge id ofs)\n| (BA_addrglobal id ofs) := some (Senv.symbol_address ge id ofs)\n| (BA_splitlong hi lo) :=\n do vhi ← eval_builtin_arg hi,\n vlo ← eval_builtin_arg lo,\n return (long_of_words vhi vlo)\n\ndef eval_builtin_args (al : list (builtin_arg A)) : option (list val) :=\nmmap eval_builtin_arg al\n\nend eval_builtin_arg\n\n/- Invariance by change of global environment. -/\n\nsection eval_builtin_arg_preserved\n\nparameters {A F1 V1 F2 V2 : Type} {ge1 : Genv F1 V1} {ge2 : Genv F2 V2}\n (e : A → val) (sp : val) (m : mem)\n\nparameter (symbols_preserved : ∀ id, Genv.find_symbol ge2 id = Genv.find_symbol ge1 id)\n\nlemma eval_builtin_arg_preserved {a v} :\n eval_builtin_arg ge1 e sp m a = some v → eval_builtin_arg ge2 e sp m a = some v := sorry'\n\nlemma eval_builtin_args_preserved {al vl} :\n eval_builtin_args ge1 e sp m al = some vl → eval_builtin_args ge2 e sp m al = some vl := sorry'\n\nend eval_builtin_arg_preserved\n\n/- Compatibility with the \"is less defined than\" relation. -/\n\nsection eval_builtin_arg_lessdef\n\nparameters {A : Type} (ge : Senv) {e1 e2 : A → val} (sp : val) {m1 m2 : mem}\n\nparameter env_lessdef : ∀ x, val.lessdef (e1 x) (e2 x)\nparameter mem_extends : extends' m1 m2\n\nlemma eval_builtin_arg_lessdef {a v1} :\n eval_builtin_arg ge e1 sp m1 a = some v1 →\n ∃ v2, eval_builtin_arg ge e2 sp m2 a = some v2 ∧ lessdef v1 v2 := sorry'\n\nlemma eval_builtin_args_lessdef {al vl1} :\n eval_builtin_args ge e1 sp m1 al = some vl1 →\n ∃ vl2, eval_builtin_args ge e2 sp m2 al = some vl2 ∧ list.forall2 lessdef vl1 vl2 := sorry'\n\nend eval_builtin_arg_lessdef\n\nend events", "meta": {"author": "digama0", "repo": "kremlin", "sha": "d4665929ce9012e93a0b05fc7063b96256bab86f", "save_path": "github-repos/lean/digama0-kremlin", "path": "github-repos/lean/digama0-kremlin/kremlin-d4665929ce9012e93a0b05fc7063b96256bab86f/events.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.48828339529583464, "lm_q1q2_score": 0.24604901585646127}} {"text": "import grid utils data.vector\n\nopen utils\n\nnamespace grid\n\nattribute [simp, reducible]\ndef Q (α : Type*) [grid α] := relative_grid.carrier α\n\nend grid\n\nopen grid\n\nsection cautomatons\n\nstructure cautomaton (α : Type) [decidable_eq α] :=\n (g : vec_grid₀ α)\n (empty : α)\n (neigh : point → list point)\n (bound : (bounding_box → bounding_box) ⊕ (α → vec_grid₀ α → point → α))\n (f : α → list α → α)\n\nend cautomatons\n\nsection cautomaton_instances\n\nvariables {α : Type} [decidable_eq α] [has_to_string α] (a : cautomaton α)\n\nopen grid\n\ndef cautomaton_to_str := grid_str a.g\n\ninstance : has_to_string (cautomaton α) := ⟨cautomaton_to_str⟩\n\ninstance : has_repr (cautomaton α) := ⟨cautomaton_to_str⟩\n\nend cautomaton_instances\n\nsection cautomaton_quot_setoid_eq \n\nvariables {α : Type} [decidable_eq α] (a a₁ a₂ a₃ : cautomaton α)\n\nend cautomaton_quot_setoid_eq\n\nnamespace cautomaton\n\nend cautomaton\n\nnamespace cautomatons\n\nopen cautomaton grid\n\ndef neumann : point → list point\n | ⟨x, y⟩ := \n [ ⟨x, y - 1⟩,\n ⟨x - 1, y⟩, ⟨x + 1, y⟩,\n ⟨x, y + 1⟩ ]\n\ndef moore : point → list point\n | ⟨x, y⟩ :=\n [ ⟨x - 1, y - 1⟩, ⟨x, y - 1⟩, ⟨x + 1, y - 1⟩,\n ⟨x - 1, y ⟩, ⟨x + 1, y ⟩,\n ⟨x - 1, y + 1⟩, ⟨x, y + 1⟩, ⟨x + 1, y + 1⟩ ]\n\n\ndef bounded_neigh {α} [grid α] (g : α)\n (f : point → list point) (p : grid_point g) : list point := f p\n\ninstance neigh_gridpoint_coe {α} [grid α] (g : α) :\n has_coe (point → list point)\n (grid_point g → list point) := ⟨bounded_neigh g⟩\n\ndef ext_id : bounding_box → bounding_box := id\n\ndef ext_one (bb : bounding_box) : bounding_box :=\n ⟨⟨bb.1.1 - 1, bb.1.2 - 1⟩, ⟨bb.2.1 + 1, bb.2.2 + 1⟩,\n ⟨\n (add_lt_add (grid_bounded_iff.1 bb.h).1 dec_trivial),\n (add_lt_add (grid_bounded_iff.1 bb.h).2 dec_trivial)⟩\n ⟩\n\nlemma rows_of_box_ext_one {bb} :\n rows_of_box (ext_one bb) = rows_of_box bb + 2 :=\nbegin\n cases bb with p₁ p₂ h,\n simp [ext_one, rows_of_box],\n rw ← int.coe_nat_eq_coe_nat_iff,\n rw int.coe_nat_add, simp,\n rw grid_bounded_iff at h, cases h,\n repeat { rw int.nat_abs_of_nonneg }; linarith\nend\n\nlemma cols_of_box_ext_one {bb} :\n cols_of_box (ext_one bb) = cols_of_box bb + 2 :=\nbegin\n cases bb with p₁ p₂ h,\n simp [ext_one, cols_of_box],\n rw ← int.coe_nat_eq_coe_nat_iff,\n rw int.coe_nat_add, simp,\n rw grid_bounded_iff at h, cases h,\n repeat { rw int.nat_abs_of_nonneg }; linarith\nend\n\nlemma bl_ext_one {bb} : (ext_one bb).p₁ = ⟨bb.p₁.x - 1, bb.p₁.y - 1⟩ := rfl\n\nlemma tr_ext_one {bb} : (ext_one bb).p₂ = ⟨bb.p₂.x + 1, bb.p₂.y + 1⟩ := rfl\n\nend cautomatons\n\nsection cautomaton_props\n\nvariables {α : Type} [decidable_eq α] (a : cautomaton α)\n\nend cautomaton_props\n\nsection cautomaton_ops\n\nopen function list prod relative_grid\n\nvariables variables {α : Type} [decidable_eq α] (a : cautomaton α)\n\ndef asize := size a.g\n\ndef bbox_of_caut := grid_bounds a.g\n\ntheorem caut_eq_iff {a₁ a₂ : cautomaton α}\n (hempty : a₁.empty = a₂.empty)\n (hneigh : a₁.neigh = a₂.neigh)\n (hbound : a₁.bound = a₂.bound)\n (hf : a₁.f = a₂.f)\n (hext : a₁.bound = a₂.bound) : a₁ = a₂ ↔ a₁.g = a₂.g :=\n ⟨λh, by simp [h], λh, by cases a₁; cases a₂; congr; cc⟩\n\nprivate lemma pres_nonempty {α β : Type} {f} {filtered : list (α × β)}\n {l : list ℤ}\n (h : ¬empty_list filtered) (h₁ : l = map f ((fst ∘ unzip) filtered)) : \n ¬empty_list l :=\n by simp [h₁, map_empty_iff_l_empty, unzip_fst_empty_iff_l_empty, h]\n\ndef compute_bounds : bounding_box :=\n let bounded := gip_g a.g in\n let mapped := ℘ a.g in\n let zipped := zip bounded mapped in\n let filtered := filter (λx, snd x ≠ a.empty) zipped in\n if h : empty_list filtered\n then ⟨gbl a.g, gtr a.g, grid_is_bounding_box⟩ else\n let unzipped := fst ∘ unzip $ filtered in\n let xs := map point.x unzipped in\n let ys := map point.y unzipped in\n let min_x := min_element xs (pres_nonempty h $ by simp) in\n let max_x := max_element xs (pres_nonempty h $ by simp) in\n let min_y := min_element ys (pres_nonempty h $ by simp) in \n let max_y := max_element ys (pres_nonempty h $ by simp) in\n ⟨⟨min_x, min_y⟩, ⟨max_x + 1, max_y + 1⟩,\n begin\n simp [(↗), min_x, max_x, min_y, max_y];\n split; rw add_comm; exact int.lt_add_one_of_le (min_elem_le_max_elem _ _)\n end⟩\n\nlemma compute_bounds_pres_overlaid\n : overlaid_by (compute_bounds a) ⟨gbl a.g, gtr a.g, grid_is_bounding_box⟩\n :=\nbegin\n simp [overlaid_by, compute_bounds],\n generalize h₂ : gip_g a.g = indices,\n by_cases h : empty_list (filter (λ (x : point × α), x.snd ≠ a.empty)\n (zip indices ℘ (a.g))); simp [h₂, h],\n {exact ⟨⟨le_refl _, le_refl _⟩, ⟨le_refl _, le_refl _⟩⟩},\n {\n split; split,\n {\n apply le_min_elem_of_all _ _ _ (λx, λh₁, _),\n simp at h₁, rcases h₁ with ⟨y₁, rest, h₃⟩, subst h₃,\n apply (zunzip_filter_first_irrel rest),\n rw ← h₂, intros y h₄,\n have h₅ := gip_g_in_grid h₄,\n simp [flip, is_in_grid, grid_bounds] at h₅,\n exact h₅.2.1\n }, \n { \n rw [add_comm, ← sub_le_sub_iff_right (1 : ℤ), add_sub_assoc],\n have : 1 - 1 = (0 : ℤ), from dec_trivial, rw this, rw add_zero,\n apply max_le_elem_of_all _ _ _ (λx, λh₁, _),\n simp at h₁, rcases h₁ with ⟨y₁, rest, h₃⟩, subst h₃,\n apply (zunzip_filter_first_irrel rest), rw ← h₂, intros y h₄,\n have h₅ := gip_g_in_grid h₄,\n simp [flip, is_in_grid, grid_bounds] at h₅,\n simp [gtr],\n rw [add_comm (-1 : ℤ), ← sub_eq_add_neg, int.le_sub_one_iff],\n exact h₅.2.2\n },\n {\n rw [add_comm, ← sub_le_sub_iff_right (1 : ℤ), add_sub_assoc],\n have : 1 - 1 = (0 : ℤ), from dec_trivial, rw [this, add_zero],\n apply max_le_elem_of_all _ _ _ (λx, λh₁, _),\n simp at h₁, rcases h₁ with ⟨y₁, rest, h₃⟩, subst h₃,\n apply (zunzip_filter_first_irrel rest),\n rw ← h₂, intros y h₄,\n have h₅ := gip_g_in_grid h₄,\n simp [flip, is_in_grid, grid_bounds] at h₅,\n rw int.le_sub_one_iff,\n exact h₅.1.2\n }, \n {\n apply le_min_elem_of_all _ _ _ (λx, λh₁, _),\n simp at h₁, rcases h₁ with ⟨y₁, rest, h₃⟩, subst h₃,\n simp [expand_gtr, point.x, point.y],\n apply (zunzip_filter_first_irrel rest),\n rw ← h₂, intros y h₄,\n have h₅ := gip_g_in_grid h₄,\n simp [flip, is_in_grid, grid_bounds, expand_gtr, point.x] at h₅,\n rcases h₅ with ⟨⟨h₅, h₆⟩, ⟨h₇, h₈⟩⟩,\n linarith\n }\n }\nend\n\nlemma compute_bounds_pres_grid :\n uncurry (↗) (points_of_box $ compute_bounds a) :=\nbegin\n generalize h : compute_bounds a = bounds,\n simp [points_of_box, uncurry, bounds.h]\nend\n\nlemma in_nth_of_zip {e₁ : point} {e₂} :\n (e₁, e₂) ∈ zip (gip_g a.g) ℘(a.g) →\n (∀{H₁} {H₂}, e₂ = abs_data a.g ⟨⟨e₁.y, H₁⟩, ⟨e₁.x, H₂⟩⟩) :=\nbegin\n intros H₀ H₁ H₂,\n rw mem_iff_nth_le at H₀,\n cases H₀ with i H₀r, cases H₀r with H₀r₁ H₀r₂,\n symmetry' at H₀r₂,\n have leneq : length (gip_g a.g) = length ℘(a.g),\n by simp [length_gip_g, length_generate_eq_size],\n have len₁ : i < length ℘(a.g),\n { rw [length_zip, leneq, min_self] at H₀r₁, exact H₀r₁ },\n have len₂ : i < length (gip_g a.g),\n { rw [length_zip, ← leneq, min_self] at H₀r₁, exact H₀r₁ }, \n have eq : nth_le (gip_g (a.g)) i len₂ = e₁ ∧\n nth_le ℘(a.g) i len₁ = e₂, from nth_le_zip' H₀r₂,\n cases eq with eq₁ eq₂, rw ← eq₂,\n rw nth_generate, rw nth_le_gip_g at eq₁,\n congr, rw ← eq₁, rw ← eq₁\nend\n\nlemma in_zip_dep {p} {e} {i} {hi}\n (h : (p, e) = nth_le (zip (gip_g a.g) ℘(a.g)) i hi) :\n nth_le (gip_g (a.g)) i \n begin\n have leneq : length (gip_g a.g) = length (℘(a.g)),\n by simp [length_gip_g, length_generate_eq_size],\n rw [length_zip, leneq, min_self] at hi,\n simpa [leneq]\n end = p ∧ nth_le ℘(a.g) i\n begin\n have leneq : length (gip_g a.g) = length (℘(a.g)),\n by simp [length_gip_g, length_generate_eq_size],\n rw [length_zip, leneq, min_self] at hi,\n simpa [leneq]\n end = e ∧\n i = |p.y - a.g.o.y| * a.g.c + |p.x - a.g.o.x| :=\nbegin\n have : nth_le (gip_g (a.g)) i\n begin\n have leneq : length (gip_g a.g) = length (℘(a.g)),\n by simp [length_gip_g, length_generate_eq_size],\n rw [length_zip, leneq, min_self] at hi,\n simpa [leneq]\n end = p ∧ nth_le ℘(a.g) i \n begin\n have leneq : length (gip_g a.g) = length (℘(a.g)),\n by simp [length_gip_g, length_generate_eq_size],\n rw [length_zip, leneq, min_self] at hi,\n simpa [leneq]\n end = e,\n from nth_le_zip' h,\n have ieq : i = |p.y - a.g.o.y| * a.g.c + |p.x - a.g.o.x|,\n {\n have leneq : length (gip_g a.g) = length (℘(a.g)),\n by simp [length_gip_g, length_generate_eq_size],\n cases this with h₁ h₂, clear h₂, clear h,\n rw [length_zip, leneq, min_self] at hi, rw ← leneq at hi, clear leneq,\n rw nth_le_gip_g at h₁, rw length_gip_g at hi,\n rw ← h₁,\n simp [bl, cols], rw mod_add_div_coe\n },\n exact ⟨this.1, this.2, ieq⟩\nend\n\nlemma nth_le_gen_iff_abs_data_gip {i} {H} {H₁} {e} :\n nth_le ℘(a.g) i H = e ↔\n abs_data a.g ⟨\n ⟨(nth_le (gip_g a.g) i H₁).y,\n begin\n simp [nth_le_gip_g], split,\n {norm_cast, linarith},\n {\n apply add_lt_of_lt_sub_left,\n simp [expand_gtr, bl],\n rw length_generate_eq_size at H, unfold size at H,\n norm_cast,\n rw nat.div_lt_iff_lt_mul _ _,\n exact H,\n have := a.g.h, simp [cols],\n apply pos_of_mul_pos_left this,\n apply zero_le _\n }\n end⟩,\n ⟨(nth_le (gip_g a.g) i H₁).x,\n begin\n simp [nth_le_gip_g], split,\n {norm_cast},\n {\n apply add_lt_of_lt_sub_left,\n simp [expand_gtr, bl],\n apply int.mod_lt_of_pos,\n have := a.g.h, simp [cols],\n apply pos_of_mul_pos_left this,\n apply zero_le _\n }\n end⟩\n ⟩ = e :=\nbegin\n split; intros h,\n {rw nth_generate at h, rw ← h, simp [nth_le_gip_g]},\n {rw nth_generate, rw ← h, simp [nth_le_gip_g]}\nend\n\nlemma mem_zip_gip_gen {p} {elem} \n (h : p ∈ a.g)\n (h₁ : elem = abs_data (a.g) {x := ⟨p.x, h.2⟩, y := ⟨p.y, h.1⟩}) :\n (p, elem) ∈ zip (gip_g (a.g)) ℘(a.g) :=\nbegin\n rw mem_iff_nth_le,\n let i := |p.x - ((a.g).o).x| + |p.y - ((a.g).o).y| * ((a.g).to_vec_grid).c,\n have H : i < size a.g,\n {\n simp [i, size, rows, cols, -sub_eq_add_neg], rw add_comm,\n apply linearize_array,\n {\n rcases h with ⟨⟨a₁, a₂⟩, ⟨a₃, a₄⟩⟩, \n simp [expand_gtr, gbl, bl, rows, cols] at a₁ a₂ a₃ a₄,\n rw ← int.coe_nat_lt_coe_nat_iff,\n rw int.nat_abs_of_nonneg; try { assumption },\n linarith, linarith\n },\n {\n rcases h with ⟨⟨a₁, a₂⟩, ⟨a₃, a₄⟩⟩, \n simp [expand_gtr, gbl, bl, rows, cols] at a₁ a₂ a₃ a₄,\n rw ← int.coe_nat_lt_coe_nat_iff,\n rw int.nat_abs_of_nonneg; try { assumption },\n linarith, linarith\n }\n },\n have leneq : length (gip_g a.g) = length ℘(a.g),\n by simp [length_gip_g, length_generate_eq_size],\n have H₀ : i < length (gip_g a.g),\n by rw length_gip_g; exact H,\n have H₁ : i < length (zip (gip_g a.g) ℘(a.g)),\n by rwa [length_zip, leneq, min_self, length_generate_eq_size],\n use i, use H₁, symmetry,\n rcases h with ⟨⟨a₁, a₂⟩, ⟨a₃, a₄⟩⟩, \n simp [expand_gtr, gbl, bl, rows, cols] at a₁ a₂ a₃ a₄,\n apply nth_le_zip,\n rw nth_le_gip_g, cases p, simp, split, ring,\n apply add_eq_of_eq_sub', simp [expand_gtr, bl, cols],\n repeat { rw int.nat_abs_of_nonneg; try { linarith } },\n apply int.mod_eq_of_lt; try { linarith },\n apply add_eq_of_eq_sub', simp [cols, bl], rw ← add_assoc, \n rw int.add_mul_div_right,\n rw int.div_eq_zero_of_lt; linarith,\n simp, intros contra, let falso := a.g.h,\n rw contra at falso, linarith,\n rw h₁, rw nth_generate, congr,\n simp [i],\n apply add_eq_of_eq_sub', simp [expand_gtr, bl, cols],\n rw int.add_mul_div_right,\n rw int.div_eq_zero_of_lt, rw int.nat_abs_of_nonneg; linarith,\n rw int.nat_abs_of_nonneg; linarith,\n rw int.nat_abs_of_nonneg; linarith,\n intros contra, let falso := a.g.h, simp at contra,\n rw contra at falso, linarith,\n simp [i],\n apply add_eq_of_eq_sub', simp [expand_gtr, bl, cols],\n repeat { rw int.nat_abs_of_nonneg; try { linarith } },\n apply int.mod_eq_of_lt; try { linarith }, exact H₀,\n rw ← leneq, exact H₀\nend\n\nlemma y_notin_elem_empty {x} {y} {H₁} {H₂}\n (notin : x ∉ map point.x\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst)) :\n abs_data (a.g) {x := ⟨x, H₁⟩, y := ⟨y, H₂⟩} = a.empty :=\nbegin\n let p : point := ⟨x, y⟩,\n have eqp : p = ⟨x, y⟩, from rfl,\n have eq₁ : p ∈ gip_g a.g,\n {apply in_gip_g_of_in_g, exact ⟨H₂, H₁⟩},\n rw [mem_map, not_exists] at notin,\n let elem := abs_data a.g ⟨⟨p.y, H₂⟩, ⟨p.x, H₁⟩⟩,\n have eqelem : elem = abs_data a.g ⟨⟨p.y, H₂⟩, ⟨p.x, H₁⟩⟩, from rfl,\n specialize notin p, simp at notin,\n by_contradiction contra,\n have eq₂ : (p, elem) ∈\n filter (λ (x : point × α), ¬x.snd = a.empty) (zip (gip_g a.g) ℘(a.g)),\n {\n rw @mem_filter _ (λ (x : point × α), ¬x.snd = a.empty),\n simp, split, swap 2, rw eqelem, refine contra, \n apply mem_zip_gip_gen _ (in_grid_iff_in_gip_g.2 eq₁) eqelem\n },\n have eq₃ : p ∈ (unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst,\n {rw in_unzip_iff, use elem, exact eq₂},\n contradiction\nend\n\nlemma x_notin_elem_empty {y} {x} {H₁} {H₂}\n (notin : y ∉ map point.y\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst)) :\n abs_data (a.g) {x := ⟨x, H₁⟩, y := ⟨y, H₂⟩} = a.empty :=\nbegin\n let p : point := ⟨x, y⟩,\n have eqp : p = ⟨x, y⟩, from rfl,\n have eq₁ : p ∈ gip_g a.g,\n {apply in_gip_g_of_in_g, exact ⟨H₂, H₁⟩},\n rw [mem_map, not_exists] at notin,\n let elem := abs_data a.g ⟨⟨p.y, H₂⟩, ⟨p.x, H₁⟩⟩,\n have eqelem : elem = abs_data a.g ⟨⟨p.y, H₂⟩, ⟨p.x, H₁⟩⟩, from rfl,\n specialize notin p, simp at notin,\n by_contradiction contra,\n have eq₂ : (p, elem) ∈\n filter (λ (x : point × α), ¬x.snd = a.empty) (zip (gip_g a.g) ℘(a.g)),\n {\n rw @mem_filter _ (λ (x : point × α), ¬x.snd = a.empty),\n simp, split, swap 2, rw eqelem, refine contra, \n apply mem_zip_gip_gen _ (in_grid_iff_in_gip_g.2 eq₁) eqelem\n },\n have eq₃ : p ∈ (unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst,\n {rw in_unzip_iff, use elem, exact eq₂},\n contradiction\nend\n\nlemma y_lt_min_elem_empty {x} {H₁} {H₂}\n (h : x < min_element (map point.x\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst)) H₁) :\n ∀y {H₃}, abs_data (a.g) {x := ⟨x, H₂⟩, y := ⟨y, H₃⟩} = a.empty :=\nbegin\n intros,\n have notin : x ∉ map point.x\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst),\n from not_mem_of_lt_min_element H₁ h,\n apply y_notin_elem_empty _ notin\nend\n\nlemma add_one_y_gt_max_elem_empty {x} {H₁} {H₂}\n (h : 1 + max_element (map point.x\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst)) H₁ ≤ x) :\n ∀y {H₃}, abs_data (a.g) {x := ⟨x, H₂⟩, y := ⟨y, H₃⟩} = a.empty :=\nbegin\n intros,\n have notin : x ∉ (map point.x\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst)),\n from not_mem_of_add_one_max_elem_gt _ h,\n apply y_notin_elem_empty _ notin\nend\n\nlemma x_lt_min_elem_empty {y} {H₁} {H₂}\n (h : y < min_element (map point.y\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst)) H₁) :\n ∀x {H₃}, abs_data (a.g) {x := ⟨x, H₃⟩, y := ⟨y, H₂⟩} = a.empty :=\nbegin\n intros,\n have notin : y ∉ map point.y\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst),\n from not_mem_of_lt_min_element _ h,\n apply x_notin_elem_empty _ notin\nend\n\nlemma add_one_x_lt_max_elem_empty {y} {H₁} {H₂}\n (h : 1 + max_element (map point.y\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst)) H₁ ≤ y) :\n ∀x {H₃}, abs_data (a.g) {x := ⟨x, H₃⟩, y := ⟨y, H₂⟩} = a.empty :=\nbegin\n intros,\n have notin : y ∉ map point.y\n ((unzip (filter (λ (x : point × α), ¬x.snd = a.empty)\n (zip (gip_g (a.g)) ℘(a.g)))).fst),\n from not_mem_of_add_one_max_elem_gt _ h,\n apply x_notin_elem_empty _ notin\nend\n\nlemma empty_of_mem_gip_nmem_compute {p : point}\n (h : p ∈ a.g)\n (h₁ : p ∉ compute_bounds a) :\n abs_data (a.g) {x := ⟨p.x, h.2⟩, y := ⟨p.y, h.1⟩} = a.empty :=\nbegin\n unfold compute_bounds at h₁,\n simp [flip, is_in_grid, is_in_grid', is_bounded] at h,\n rcases h with ⟨⟨B₁, B₂⟩, ⟨B₃, B₄⟩⟩,\n simp [expand_gtr, bl, cols, rows] at B₁ B₂ B₃ B₄,\n let i := |p.y - a.g.o.y| * a.g.c + |p.x - a.g.o.x|,\n have A₁ : p.y - a.g.o.y ≥ 0, by linarith,\n have A₂ : p.x - a.g.o.x ≥ 0, by linarith,\n have A₃ : i < size a.g,\n {\n simp [i, size, rows, cols, -sub_eq_add_neg, -add_comm],\n apply linearize_array,\n {\n rw ← int.coe_nat_lt_coe_nat_iff,\n rw int.nat_abs_of_nonneg; try { assumption },\n linarith\n },\n {\n rw ← int.coe_nat_lt_coe_nat_iff,\n rw int.nat_abs_of_nonneg; try { assumption },\n linarith\n }\n },\n have A₄ : 0 ≤ i, by linarith,\n cases p with x y,\n have eq₁ : (bl (a.g)).x + ↑|↑i| % ↑(cols (a.g)) = x,\n {\n simp, norm_cast, simp [-sub_eq_add_neg, bl],\n simp only [cols],\n repeat { rw int.nat_abs_of_nonneg; try { assumption } },\n ring, simp [-sub_eq_add_neg] at *,\n rw add_eq_of_eq_neg_add, simp, \n rw ← sub_eq_add_neg,\n rw int.mod_eq_of_lt,\n linarith,\n linarith\n },\n have eq₂ : (bl (a.g)).y + ↑|↑i| / ↑(cols (a.g)) = y,\n {\n simp, norm_cast, simp [-sub_eq_add_neg, bl],\n simp only [cols],\n repeat { rw int.nat_abs_of_nonneg; try { assumption } },\n ring, simp [-sub_eq_add_neg] at *,\n rw add_eq_of_eq_neg_add, simp, \n rw ← sub_eq_add_neg,\n rw ← add_assoc, ring,\n rw int.add_mul_div_right,\n rw int.div_eq_zero_of_lt,\n simp,\n linarith,\n linarith,\n linarith\n },\n by_cases eq :\n empty_list (filter (λ (x : point × α), x.snd ≠ a.empty)\n (zip (gip_g (a.g)) ℘(a.g))),\n {\n unfold empty_list at eq, symmetry' at eq,\n rw filter_eq_nil at eq, simp at eq,\n apply eq ⟨x, y⟩,\n simp [flip, is_in_grid, is_in_grid', is_bounded] at h,\n refine @nth_le_in_grid _ (int.nat_abs i) _ _ _ _,\n rw length_zip,\n rw length_gip_g, rw length_generate_eq_size, unfold size,\n rw min_eq_right, exact A₃, exact le_refl _,\n rw nth_le_zip, rw nth_le_gip_g,\n {congr, exact eq₁, exact eq₂},\n {\n rw nth_generate, congr, \n exact eq₂, exact eq₁\n },\n rw length_gip_g, exact A₃,\n rw length_generate_eq_size, exact A₃\n },\n {\n simp [eq, flip, is_in_grid, is_bounded, -not_and] at h₁,\n rw not_and_distrib at h₁, cases h₁, rw not_and_distrib at h₁,\n cases h₁,\n {\n simp only [point.x, point.y] at *,\n rw not_le at h₁,\n apply x_lt_min_elem_empty _ h₁\n }, \n {\n rw not_lt at h₁,\n apply add_one_x_lt_max_elem_empty _ h₁\n },\n rw not_and_distrib at h₁, cases h₁,\n {\n rw not_le at h₁,\n apply y_lt_min_elem_empty _ h₁\n },\n {\n rw not_lt at h₁,\n apply add_one_y_gt_max_elem_empty _ h₁\n }\n }\nend\n\nlemma exists_p_of_in_generate {x} (h : x ∈ ℘(a.g)) :\n ∃(p : point) (H : p ∈ gip_g a.g),\n abs_data a.g ⟨\n ⟨p.y, begin rw ← in_grid_iff_in_gip_g at H, exact H.1 end⟩,\n ⟨p.x, begin rw ← in_grid_iff_in_gip_g at H, exact H.2 end⟩\n ⟩ = x :=\nbegin\n rw mem_iff_nth_le at h,\n rcases h with ⟨i, ⟨h₁, h₂⟩⟩, \n have : i < length (gip_g (a.g)),\n {rw length_gip_g, rw length_generate_eq_size at h₁, exact h₁},\n let p := nth_le (gip_g a.g) i this,\n have eqp : p = nth_le (gip_g (a.g)) i this, from rfl, \n use p, intros,\n rw ← h₂,\n rw nth_generate, simp [nth_le_gip_g, bl, cols, eqp],\n have : p ∈ gip_g (a.g), { rw eqp, apply nth_le_mem },\n use this, congr\nend\n\ndef canonical_grid :=\n compute_bounds a = ⟨gbl a.g, gtr a.g, grid_is_bounding_box⟩\n\ndef make_canonical : cautomaton α :=\n {a with g := ↑(subgrid a.g (compute_bounds a) (compute_bounds_pres_overlaid _))}\n\ndef is_canonical := make_canonical a = a\n\ndef aut_eq (a₁ a₂ : cautomaton α) : Prop :=\n (band : bool → bool → bool) (℘(make_canonical a₁).g = ℘(make_canonical a₂).g)\n $ (band : bool → bool → bool)\n ((make_canonical a₁).g.r = (make_canonical a₂).g.r)\n ((make_canonical a₁).g.c = (make_canonical a₂).g.c)\n\ninfix ` ~ₐ `:100 := aut_eq\n\ninstance decidable_aut_eq {α} [decidable_eq α] {a₁ a₂} :\n decidable (@aut_eq α _ a₁ a₂) := by simp [(~ₐ)]; apply_instance\n\ndef ext_aut (a : cautomaton α) : cautomaton α :=\n match a.bound with\n | (sum.inr _) := a\n | (sum.inl ext) :=\n let new_bb := ext (grid_bounds a.g) in\n let new_grid :=\n fgrid₀.mk\n (rows_of_box new_bb)\n (cols_of_box new_bb)\n (mul_pos rows_of_box_pos cols_of_box_pos)\n new_bb.p₁\n (λx y, if h : (⟨y, x⟩ : point) ∈ a.g\n then abs_data a.g $ grid_point_of_prod'\n ((make_bounded h.1), (make_bounded h.2))\n else a.empty) in\n ⟨new_grid, a.empty, a.neigh, a.bound, a.f⟩\n end\n\ndef default_if_nex {α : Type*} [grid α] (empty : carrier α)\n (g : α) (p : point) : carrier α :=\n if h : p ∈ g\n then abs_data g (grid_point_of_prod' (in_grid_bounded g p h))\n else empty\n\nsection boundary\n\nprivate lemma bound_periodic_modulo'\n {a} {b : ℤ} {c} (h : a > 0) :\n b ≤ (b + a) - 1 - (b - c - 1) % a :=\nbegin\n simp, repeat { rw ← sub_eq_add_neg },\n rw [\n ← add_sub_assoc, ← sub_eq_add_neg,\n ← le_add_iff_nonneg_left (1 : ℤ)\n ],\n change (1 : ℤ) with (0 + 1),\n rw int.add_one_le_iff, simp [-sub_eq_add_neg],\n rw ← add_sub_assoc, simp,\n apply lt_add_of_neg_add_lt, simp,\n apply int.mod_lt_of_pos,\n simpa [h]\nend\n\nprivate lemma bound_periodic_modulo''\n {a} {b : ℤ} {c} (h : a > 0) :\n (b + a) - 1 - (b - c - 1) % a < b + a :=\nbegin\n simp, rw ← add_assoc, repeat { rw ← sub_eq_add_neg },\n rw neg_lt,\n apply int.lt_of_add_one_le, simp [-sub_eq_add_neg],\n apply int.mod_nonneg,\n simp, linarith\nend\n\ndef bound_periodic {α : Type*} [grid α] (empty : carrier α)\n (g : α) (p : point) : carrier α :=\n if h : p ∈ g\n then abs_data g (grid_point_of_prod' (in_grid_bounded g p h))\n else\n if b₁ : is_bounded (gbl g).y (gtr g).y p.y \n then\n if p₁ : p.x ≥ (gtr g).x\n then abs_data g ⟨\n make_bounded b₁,\n ⟨(gbl g).x + (p.x - (gbl g).x) % cols g,\n begin\n split,\n {\n have : cols g > 0, from cols_pos,\n apply le_add_of_nonneg_right (int.mod_nonneg _ _),\n linarith\n },\n {simp [expand_gtr, int.mod_lt_of_pos, cols_pos]}\n end\n ⟩\n ⟩\n else abs_data g ⟨\n make_bounded b₁,\n ⟨(gtr g).x - 1 - ((gbl g).x - p.x - 1) % cols g,\n have h₂ : p.x < (gbl g).x,\n {\n by_cases p₃ : (gbl g).x ≤ p.x,\n {\n have contra : is_bounded (gbl g).x (gtr g).x p.x,\n from ⟨p₃, lt_of_not_ge p₁⟩,\n simp only [(∉), flip, is_in_grid'] at h,\n finish\n },\n {linarith}\n },\n ⟨\n bound_periodic_modulo' cols_pos,\n bound_periodic_modulo'' cols_pos\n ⟩\n ⟩\n ⟩\n else\n if b₂ : is_bounded (gbl g).x (gtr g).x p.x\n then\n if p₂ : p.y ≥ (gtr g).y\n then abs_data g ⟨\n ⟨(gbl g).y + (p.y - (gbl g).y) % rows g,\n ⟨\n begin\n simp only [gbl, le_add_iff_nonneg_right, sub_eq_add_neg],\n rw ← sub_eq_add_neg,\n apply int.mod_nonneg, simp,\n have : 0 < rows g, from rows_pos,\n linarith\n end,\n by simp [expand_gtr, int.mod_lt_of_pos, rows_pos]\n ⟩\n ⟩,\n make_bounded b₂\n ⟩\n else abs_data g ⟨\n ⟨(gtr g).y - 1 - ((gbl g).y - p.y - 1) % rows g,\n have h₂ : p.y < (gbl g).y,\n {\n replace p₂ := lt_of_not_ge p₂,\n by_cases p₃ : (gbl g).y ≤ p.y,\n {\n have contra : is_bounded (gbl g).y (gtr g).y p.y,\n from ⟨p₃, p₂⟩,\n contradiction\n },\n {linarith}\n },\n ⟨\n bound_periodic_modulo' rows_pos,\n bound_periodic_modulo'' rows_pos\n ⟩\n ⟩,\n make_bounded b₂\n ⟩\n else empty\n\ndef bound_const {α : Type*} [grid α]\n (const : carrier α) (g : α) (p : point) : carrier α := default_if_nex const g p\n\nend boundary\n\ndef next_gen (a : cautomaton α) : cautomaton α :=\n let new_grid := (ext_aut a).g in\n let cells := ℘ new_grid in\n let neighs := map a.neigh (gip_g new_grid) in\n let defaulted := \n match a.bound with\n | (sum.inr boundf) := boundf a.empty new_grid\n | _ := @bound_const (vec_grid₀ α) _ a.empty new_grid\n end in\n let neigh_cells := map (list.map defaulted) neighs in\n let new_cells := zip_with a.f cells neigh_cells in\n let grid :=\n @vec_grid₀.mk _\n ⟨grid_rows new_grid, grid_cols new_grid,\n mul_pos rows_pos cols_pos,\n ⟨new_cells, by simp [\n zip_with_len_l,\n length_generate_eq_size,\n size,\n rows_eq_try_sub_bly,\n cols_eq_trx_sub_blx,\n length_gip_g,\n length_gip,\n grid_is_bounding_box\n ]\n ⟩⟩ new_grid.o in\n let next_config := (⟨grid, a.empty, a.neigh, a.bound, a.f⟩ : cautomaton α) in\n match a.bound with\n | (sum.inl _) := make_canonical next_config\n | _ := next_config\n end\n\nattribute [simp]\nlemma next_gen_empty : (next_gen a).empty = a.empty :=\n by cases a with _ _ _ bound _; cases bound; refl\n\nattribute [simp]\nlemma next_gen_neigh : (next_gen a).neigh = a.neigh :=\n by cases a with _ _ _ bound _; cases bound; refl\n\nattribute [simp]\nlemma next_gen_f : (next_gen a).f = a.f :=\n by cases a with _ _ _ bound _; cases bound; refl\n\nattribute [simp]\nlemma next_gen_ext : (next_gen a).bound = a.bound :=\n by cases a with _ _ _ bound _; cases bound; refl\n\nattribute [simp]\nlemma iterate_next_gen_empty {n} : (iterate next_gen a n).empty = a.empty :=\n by induction n with n ih; simp [iterate_zero, *, iterate_one]\n\nattribute [simp]\nlemma iterate_next_gen_neigh {n} : (iterate next_gen a n).neigh = a.neigh :=\n by induction n with n ih; simp [iterate_zero, *, iterate_one]\n\nattribute [simp]\nlemma iterate_next_gen_f {n} : (iterate next_gen a n).f = a.f :=\n by induction n with n ih; simp [iterate_zero, *, iterate_one]\n\nattribute [simp]\nlemma iterate_next_gen_ext {n} : (iterate next_gen a n).bound = a.bound :=\n by induction n with n ih; simp [iterate_zero, *, iterate_one]\n\ndef step_n (n : ℕ) := iterate next_gen a n\n\ndef periodic := {n // n ≠ 0 ∧ step_n a n = a}\n\ndef count_at_single {α : Type} [decidable_eq α] (neigh : list α) (valid : α) :=\n list.sum ∘ map (λc, if c = valid then 1 else 0) $ neigh\n\ndef yield_at_if_in_neigh {α : Type} [decidable_eq α]\n (a : cautomaton α) (p : point) :=\n if p ∈ a.neigh p\n then some $ @default_if_nex (vec_grid₀ α) _ a.empty a.g p\n else none\n\nlemma step_n_zero : step_n a 0 = a := rfl\n\nlemma step_n_succ {n} : step_n a (nat.succ n) = next_gen (step_n a n) := rfl\n\ndef yield_at (p : point) : α := @default_if_nex (vec_grid₀ α) _ a.empty a.g p\n\ndef mod_at (p : point) (x : α) (a : cautomaton α) : cautomaton α :=\n ⟨modify_at p x a.g, a.empty, a.neigh, a.bound, a.f⟩\n\ndef mod_many (l : list (point × α)) (a : cautomaton α) : cautomaton α :=\n ⟨modify_many l a.g, a.empty, a.neigh, a.bound, a.f⟩\n\nend cautomaton_ops\n\nsection counting\n\nvariables {α : Type} [decidable_eq α] (a : cautomaton α)\n\ndef count (c : α) : ℕ := count_grid a.g c\n\nlemma count_grid_eq_count {x} : count a x = count_grid a.g x := rfl\n\nlemma count_cast_foa (a : vec_grid₀ α) {x} : count_grid ↑a x = count_grid a x :=\n by unfold_coes; simp [count_grid, gen_aof_eq_gen, gen_foa_eq_gen]\n\nlemma count_cast_aof (a : fgrid₀ α) {x} : count_grid ↑a x = count_grid a x :=\n by unfold_coes; simp [count_grid, gen_aof_eq_gen, gen_foa_eq_gen]\n\nlemma yield_at_nonempty {p} {a : cautomaton α}\n (h : yield_at a p ≠ a.empty) : p ∈ a.g :=\nbegin\n by_contradiction contra,\n unfold yield_at default_if_nex at h,\n rw dif_neg contra at h,\n contradiction\nend\n\nlemma count_uneq_in_subgrid' {a : cautomaton α} {x} (h : x ≠ a.empty) :\n list.count x (subgrid' (a.g) (compute_bounds a) (compute_bounds_pres_overlaid _)) =\n 0 :=\nbegin\n unfold subgrid' list.count,\n rw list.countp_eq_length_filter,\n unfold list.attach,\n rw list.map_pmap,\n rw list.length_eq_zero,\n rw list.filter_eq_nil,\n intros cell H,\n rw list.mem_pmap at H,\n cases H with p rest, cases rest with h₁ h₂,\n have : (abs_data (a.g) ∘ inject_filter_bounded (a.g)) ⟨p, h₁⟩ = a.empty,\n {\n rw list.mem_filter at h₁,\n cases h₁ with h₂ h₃,\n simp [(∘), inject_filter_bounded, grid_point_of_mem, make_bounded],\n apply empty_of_mem_gip_nmem_compute,\n rw in_grid_iff_in_gip_g, exact h₂,\n exact h₃\n },\n cc\nend\n\nlemma count_nonempty_compute_bounds {a : cautomaton α} {x} (h : x ≠ a.empty) :\n list.count x (℘ a.g) =\n list.count x ℘(subgrid a.g (compute_bounds a) (compute_bounds_pres_overlaid _)) :=\nbegin\n rw @count_split _ _ _ a.g (compute_bounds a) (compute_bounds_pres_overlaid _),\n rw count_uneq_in_subgrid' h,\n refl\nend\n\nlemma count_nonempty_make_canonical {a : cautomaton α} {x} (h : x ≠ a.empty) :\n count a x = count (make_canonical a) x :=\nbegin\n unfold make_canonical count count_grid,\n simp only [cautomaton.g],\n unfold_coes, rw gen_aof_eq_gen,\n exact count_nonempty_compute_bounds h\nend\n\nend counting\n\nnamespace cardinals\n\nsection cardinals\n\nvariables {α : Type} [decidable_eq α] (a : cautomaton α) (p : point)\n (neigh : point → list point)\n\ndef neigh_with_NW := ∀p : point, point.mk (p.x - 1) (p.y - 1) ∈ neigh p\n\ndef neigh_with_N := ∀p : point, point.mk p.x (p.y - 1) ∈ neigh p\n\ndef neigh_with_NE := ∀p : point, point.mk (p.x + 1) (p.y - 1) ∈ neigh p\n\ndef neigh_with_W := ∀p : point, point.mk (p.x - 1) p.y ∈ neigh p\n\ndef neigh_with_E := ∀p : point, point.mk (p.x + 1) p.y ∈ neigh p\n\ndef neigh_with_SW := ∀p : point, point.mk (p.x - 1) (p.y + 1) ∈ neigh p\n\ndef neigh_with_S := ∀p : point, point.mk p.x (p.y + 1) ∈ neigh p\n\ndef neigh_with_SE := ∀p : point, point.mk (p.x + 1) (p.y + 1) ∈ neigh p\n\nopen cautomatons\n\nlemma neumann_N : neigh_with_N neumann :=\n λ⟨x, y⟩, by simp [neumann]\n\nlemma neumann_W : neigh_with_W neumann :=\n λ⟨x, y⟩, by simp [neumann]\n\nlemma neumann_E : neigh_with_E neumann :=\n λ⟨x, y⟩, by simp [neumann]\n\nlemma neumann_S : neigh_with_S neumann :=\n λ⟨x, y⟩, by simp [neumann]\n\nlemma moore_NW : neigh_with_NW moore :=\n λ⟨x, y⟩, by simp [moore]\n\nlemma moore_N : neigh_with_N moore :=\n λ⟨x, y⟩, by simp [moore]\n\nlemma moore_NE : neigh_with_NE moore :=\n λ⟨x, y⟩, by simp [moore]\n\nlemma moore_W : neigh_with_W moore :=\n λ⟨x, y⟩, by simp [moore]\n\nlemma moore_E : neigh_with_E moore :=\n λ⟨x, y⟩, by simp [moore]\n\nlemma moore_SW : neigh_with_SW moore :=\n λ⟨x, y⟩, by simp [moore]\n\nlemma moore_S : neigh_with_S moore :=\n λ⟨x, y⟩, by simp [moore]\n\nlemma moore_SE : neigh_with_SE moore :=\n λ⟨x, y⟩, by simp [moore]\n\ndef NW (h : neigh_with_NW a.neigh) := yield_at a ⟨p.x - 1, p.y - 1⟩\n\ndef N (h : neigh_with_N a.neigh) := yield_at a ⟨p.x, p.y - 1⟩\n\ndef NE (h : neigh_with_NE a.neigh) := yield_at a ⟨p.x + 1, p.y - 1⟩\n\ndef W (h : neigh_with_W a.neigh) := yield_at a ⟨p.x - 1, p.y⟩\n\ndef E (h : neigh_with_E a.neigh) := yield_at a ⟨p.x + 1, p.y⟩\n\ndef SW (h : neigh_with_SW a.neigh) := yield_at a ⟨p.x - 1, p.y + 1⟩\n\ndef S (h : neigh_with_S a.neigh) := yield_at a ⟨p.x, p.y + 1⟩\n\ndef SE (h : neigh_with_SE a.neigh) := yield_at a ⟨p.x + 1, p.y + 1⟩\n\nend cardinals\n\nend cardinals", "meta": {"author": "frankSil", "repo": "CAExtensions", "sha": "f5c74fd9a806696c73497d9abd45b7315f45379f", "save_path": "github-repos/lean/frankSil-CAExtensions", "path": "github-repos/lean/frankSil-CAExtensions/CAExtensions-f5c74fd9a806696c73497d9abd45b7315f45379f/src/cautomaton.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6039318194686359, "lm_q2_score": 0.40733340004593027, "lm_q1q2_score": 0.24600160142008443}} {"text": "/- Copyright 2019 (c) Hans-Dieter Hiep. All rights reserved. Released under MIT license as described in the file LICENSE. -/\n\nimport syntax\n\nuniverse u\n\nopen signature list\n\n/- Fix a signature. We consider an interpretation of reference types and data types. Reference types are interpreted as object identities. Each object identity is associated to a single class name. Equality is decidable for objects. Each record name is uniquely associated to a data type. A data type comprises an inhabited Lean type with decidable equality. The built-in boolean is associated to Lean's bool with false as default. -/\nstructure datatype :=\n (host : Type)\n (inhabited_host: inhabited host)\n (decidable_host: decidable_eq host)\ninstance datatype.decidable_eq (d : datatype) :\n decidable_eq d.host := d.decidable_host\ninstance datatype.inhabited_eq (d : datatype) :\n inhabited d.host := d.inhabited_host\ndef datatype.default (d : datatype) : d.host :=\n default d.host\n\nclass objects (α β : Type) extends signature α :=\n(class_of: β → class_name α)\n(encodable_object: encodable β)\n(decidable_object: decidable_eq β) -- redundant\n(data_type: record_name α → datatype)\n(data_type_boolean:\n (data_type (boolean_name α)).host = bool)\n(data_type_boolean_inhabited:\n (cast data_type_boolean (data_type (boolean_name α))\n .inhabited_host.default) = ff)\nopen objects\n\nlemma data_type_booleanr {α β : Type} [objects α β] :\n bool = (data_type (boolean_name α)).host :=\nbegin symmetry, apply data_type_boolean end\ninstance objects.decidable_eq {α β : Type} [objects α β] :\n decidable_eq β := decidable_object α β\ninstance objects.encodable {α β : Type} [objects α β] :\n encodable β := encodable_object α β\n\n/- We treat values as being of a type. A value of a reference type is an object of the same class, or null. A value of a data type is a term of the associated type in Lean. -/\n@[derive decidable_eq]\ninductive value {α β : Type} [objects α β] : type α → Type\n| object {c : class_name α} :\n {o : β // c = class_of α o} → value (type.ref c)\n| null (c : class_name α) :\n value (type.ref c)\n| term {r : record_name α} :\n (data_type r).host → value (type.data r)\n/- The default value of a reference type is null, and the default value of a data type is the default in Lean. -/\ninstance value.inhabited {α β : Type} [objects α β] :\n Π{ty : type α}, inhabited (value ty)\n| (type.ref c) := ⟨value.null c⟩\n| (type.data r) := ⟨value.term (data_type r).default⟩\n-- Projection of value to term\ndef value.unterm {α β : Type} [objects α β]\n {r : record_name α} : Π (x : value (type.data r)),\n (data_type r).host\n| (value.term t) := t\n-- Projection of boolean value to bool\ndef value.unbool {α β : Type} [objects α β] :\n Π (x : value (boolean α)), bool\n| (value.term t) := cast (data_type_boolean α β) t\n-- Projection of value to potential object\ndef value.unobject {α β : Type} [objects α β]\n {c : class_name α} : Π (x : value (type.ref c)), option β\n| (value.object o) := o\n| (value.null _) := none\ndef value.not_null {α β : Type} [objects α β]\n {c : class_name α} (x : value (type.ref c)) : Prop :=\n x ≠ value.null c\n-- Projection of not-null value to object identity\ndef value.the_object {α β : Type} [objects α β]\n {c : class_name α} : Π {x : value (type.ref c)},\n value.not_null x → β\n| (value.object o) _ := o\n| (value.null .(c)) G := begin exfalso, apply G, refl end\nlemma value.class_of_the_object {α β : Type} [objects α β]\n {c : class_name α} {x : value (type.ref c)}\n (G : value.not_null x) :\n class_of α (value.the_object G) = c :=\nbegin\n cases x,\n {unfold value.the_object, apply eq.symm,\n simp [coe,lift_t,has_lift_t.lift],\n simp [coe_t,has_coe_t.coe,coe_b,has_coe.coe],\n exact x_a.property},\n {exfalso, apply G, refl}\nend\n\n/- Given a list of types, we have a value list of values with matching types. -/\n@[derive decidable_eq]\ninductive vallist {α β : Type} [objects α β] :\n list (type α) → Type\n| nil : vallist []\n| cons {ty : type α} {l : list (type α)} :\n value ty → vallist l → vallist (ty::l)\ndef vallist.default {α β : Type} [objects α β] :\n Π(l : list (type α)), vallist l\n| [] := vallist.nil\n| (t :: l) := vallist.cons (default (value t))\n (vallist.default l)\ninstance vallist.inhabited {α β : Type} [objects α β]\n (l : list (type α)) : inhabited (vallist l) :=\n ⟨vallist.default l⟩\n/- A value list of a single type is just a value. -/\ndef vallist.single {α β : Type} [objects α β] {ty : type α}\n (v : value ty) : vallist [ty] :=\n vallist.cons v vallist.nil\n/- There is a unique value of a single value list. -/\ndef vallist.the {α β : Type} [objects α β] {ty : type α} :\n vallist [ty] → value ty\n| (vallist.cons h vallist.nil) := h\n/- A value list of a single type can be appended at the front to form a new value list. -/\ndef vallist.consl {α β : Type} [objects α β]\n {ty : type α} {l : list (type α)}\n (h : vallist [ty]) (t : vallist l) : vallist (ty :: l) :=\n vallist.cons (h.the) t\n/- Given a value list and an index in the list of types, we obtain a value. -/\ndef vallist.lookup {α β : Type} [objects α β] {ty : type α} :\n Π {l : context α}, vallist l → list_at ty l → value ty\n| (x :: xs) (vallist.cons v _) (list_at.here .(x) .(xs)) := v\n| (x :: xs) (vallist.cons _ ys) (list_at.tail .(x) zs) :=\n vallist.lookup ys zs\n/- Given a value list and an index and a new value, we obtain a new value list which updates the given index. -/\ndef vallist.update {α β : Type} [objects α β] {ty : type α} :\n Π {l : context α}, vallist l → list_at ty l →\n value ty → vallist l\n| (x :: xs) (vallist.cons _ tl) (list_at.here .(x) .(xs)) v :=\n vallist.cons v tl\n| (x :: xs) (vallist.cons v ys) (list_at.tail .(x) zs) w :=\n vallist.cons v (vallist.update ys zs w)\n\n/- An interpretation consists of a mapping from constant symbols to values, and from function symbols to functions over value lists to values. -/\nclass interpret (α β : Type) extends objects α β :=\n (interp {args : list (type α)} {result : type α}\n {s : symbol_name α} (sym : symbol args result s):\n vallist args → value result)\n", "meta": {"author": "praalhans", "repo": "lean-abs", "sha": "5d23eec7234c880f5ebc0d7b831caf55119edef8", "save_path": "github-repos/lean/praalhans-lean-abs", "path": "github-repos/lean/praalhans-lean-abs/lean-abs-5d23eec7234c880f5ebc0d7b831caf55119edef8/src/objects.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5926665999540697, "lm_q2_score": 0.41489884579676883, "lm_q1q2_score": 0.24589668826323885}} {"text": "/-\nCopyright (c) 2020 Adam Topaz. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Adam Topaz\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.category_theory.monad.basic\nimport Mathlib.category_theory.eq_to_hom\nimport Mathlib.PostPort\n\nuniverses v u l \n\nnamespace Mathlib\n\n/-!\n# Bundled Monads\n\nWe define bundled (co)monads as a structure consisting of a functor `func : C ⥤ C` endowed with\na term of type `(co)monad func`. See `category_theory.monad.basic` for the definition.\nThe type of bundled (co)monads on a category `C` is denoted `(Co)Monad C`.\n\nWe also define morphisms of bundled (co)monads as morphisms of their underlying (co)monads\nin the sense of `category_theory.(co)monad_hom`. We construct a category instance on `(Co)Monad C`.\n-/\n\nnamespace category_theory\n\n\n/-- Bundled monads. -/\nstructure Monad (C : Type u) [category C] where\n func : C ⥤ C\n str :\n autoParam (monad func)\n (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.tactic.apply_instance\")\n (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"tactic\")\n \"apply_instance\")\n [])\n\n/-- Bundled comonads -/\nstructure Comonad (C : Type u) [category C] where\n func : C ⥤ C\n str :\n autoParam (comonad func)\n (Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring \"Mathlib.tactic.apply_instance\")\n (Lean.Name.mkStr (Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous \"Mathlib\") \"tactic\")\n \"apply_instance\")\n [])\n\nnamespace Monad\n\n\n/-- The initial monad. TODO: Prove it's initial. -/\ndef initial (C : Type u) [category C] : Monad C := mk 𝟭\n\nprotected instance inhabited {C : Type u} [category C] : Inhabited (Monad C) :=\n { default := initial C }\n\nprotected instance func.category_theory.monad {C : Type u} [category C] {M : Monad C} :\n monad (func M) :=\n str M\n\n/-- Morphisms of bundled monads. -/\ndef hom {C : Type u} [category C] (M : Monad C) (N : Monad C) := monad_hom (func M) (func N)\n\nnamespace hom\n\n\nend hom\n\n\nprotected instance hom.inhabited {C : Type u} [category C] {M : Monad C} : Inhabited (hom M M) :=\n { default := monad_hom.id (func M) }\n\nprotected instance category_theory.category {C : Type u} [category C] : category (Monad C) :=\n category.mk\n\n/-- The forgetful functor from `Monad C` to `C ⥤ C`. -/\ndef forget (C : Type u) [category C] : Monad C ⥤ C ⥤ C :=\n functor.mk func fun (_x _x_1 : Monad C) (f : _x ⟶ _x_1) => monad_hom.to_nat_trans f\n\n@[simp] theorem comp_to_nat_trans {C : Type u} [category C] {M : Monad C} {N : Monad C}\n {L : Monad C} (f : M ⟶ N) (g : N ⟶ L) :\n monad_hom.to_nat_trans (f ≫ g) =\n nat_trans.vcomp (monad_hom.to_nat_trans f) (monad_hom.to_nat_trans g) :=\n rfl\n\n@[simp] theorem assoc_func_app {C : Type u} [category C] {M : Monad C} {X : C} :\n functor.map (func M) (nat_trans.app μ_ X) ≫ nat_trans.app μ_ X =\n nat_trans.app μ_ (functor.obj (func M) X) ≫ nat_trans.app μ_ X :=\n monad.assoc X\n\nend Monad\n\n\nnamespace Comonad\n\n\n/-- The terminal comonad. TODO: Prove it's terminal. -/\ndef terminal (C : Type u) [category C] : Comonad C := mk 𝟭\n\nprotected instance inhabited {C : Type u} [category C] : Inhabited (Comonad C) :=\n { default := terminal C }\n\nprotected instance func.category_theory.comonad {C : Type u} [category C] {M : Comonad C} :\n comonad (func M) :=\n str M\n\n/-- Morphisms of bundled comonads. -/\ndef hom {C : Type u} [category C] (M : Comonad C) (N : Comonad C) := comonad_hom (func M) (func N)\n\nnamespace hom\n\n\nend hom\n\n\nprotected instance hom.inhabited {C : Type u} [category C] {M : Comonad C} : Inhabited (hom M M) :=\n { default := comonad_hom.id (func M) }\n\nprotected instance category_theory.category {C : Type u} [category C] : category (Comonad C) :=\n category.mk\n\n/-- The forgetful functor from `CoMonad C` to `C ⥤ C`. -/\ndef forget (C : Type u) [category C] : Comonad C ⥤ C ⥤ C :=\n functor.mk func fun (_x _x_1 : Comonad C) (f : _x ⟶ _x_1) => comonad_hom.to_nat_trans f\n\n@[simp] theorem comp_to_nat_trans {C : Type u} [category C] {M : Comonad C} {N : Comonad C}\n {L : Comonad C} (f : M ⟶ N) (g : N ⟶ L) :\n comonad_hom.to_nat_trans (f ≫ g) =\n nat_trans.vcomp (comonad_hom.to_nat_trans f) (comonad_hom.to_nat_trans g) :=\n rfl\n\n@[simp] theorem coassoc_func_app {C : Type u} [category C] {M : Comonad C} {X : C} :\n nat_trans.app δ_ X ≫ functor.map (func M) (nat_trans.app δ_ X) =\n nat_trans.app δ_ X ≫ nat_trans.app δ_ (functor.obj (func M) X) :=\n comonad.coassoc X\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/category_theory/monad/bundled_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5117165898111866, "lm_q2_score": 0.480478678047907, "lm_q1q2_score": 0.24586891060766203}} {"text": "\nimport tactic\n\nuniverses u v w\n\nclass is_lawful_monad_lift (m : Type u → Type v) (n : Type u → Type w) [has_monad_lift m n] [monad m] [monad n] :=\n(monad_lift_pure : ∀ {α} (x : α),\n has_monad_lift.monad_lift (pure x : m α) = (pure x : n α))\n(monad_lift_bind : ∀ {α β} (x : m α) (f : α → m β),\n (has_monad_lift.monad_lift $ x >>= f : n β) =\n has_monad_lift.monad_lift x >>= has_monad_lift.monad_lift ∘ f )\n\nclass is_lawful_monad_lift_t (m : Type u → Type v) (n : Type u → Type w) [has_monad_lift_t m n] [monad m] [monad n] :=\n(monad_lift_pure : ∀ {α} (x : α),\n has_monad_lift_t.monad_lift (pure x : m α) = (pure x : n α))\n(monad_lift_bind : ∀ {α β} (x : m α) (f : α → m β),\n (has_monad_lift_t.monad_lift $ x >>= f : n β) =\n has_monad_lift_t.monad_lift x >>= has_monad_lift_t.monad_lift ∘ f )\n\nlemma is_lawful_monad_lift_t.monad_lift_and_then (m : Type u → Type v) (n : Type u → Type w)\n [has_monad_lift_t m n] [monad m] [monad n] [is_lawful_monad_lift_t m n]\n {α β} (x : m α) (f : m β) :\n (has_monad_lift_t.monad_lift $ x >> f : n β) =\n has_monad_lift_t.monad_lift x >> has_monad_lift_t.monad_lift f :=\nby { simp [(>>),is_lawful_monad_lift_t.monad_lift_bind n] }\n\nexport is_lawful_monad_lift_t (monad_lift_pure monad_lift_bind monad_lift_and_then)\n\ninstance has_lawful_monad_lift_t_trans (m n o) [monad m] [monad n] [monad o]\n [has_monad_lift n o] [has_monad_lift_t m n]\n [is_lawful_monad_lift n o] [is_lawful_monad_lift_t m n] : is_lawful_monad_lift_t m o :=\nby constructor; intros; simp [monad_lift];\n [ simp [monad_lift_pure m n,is_lawful_monad_lift.monad_lift_pure n o],\n simp [monad_lift_bind n,is_lawful_monad_lift.monad_lift_bind o] ]\n\ninstance has_lawful_monad_lift_t_refl (m) [monad m] : is_lawful_monad_lift_t m m :=\nby constructor; intros; simp [monad_lift]\n\nclass is_lawful_monad_state (σ : out_param (Type u)) (m : Type u → Type v) [monad m] [monad_state σ m] :=\n(lift_pure : ∀ {α} (x : α),\n monad_state.lift (pure x : state σ α) = (pure x : m α))\n(lift_bind : ∀ {α β} (x : state σ α) (f : α → state σ β),\n (monad_state.lift $ x >>= f : m β) =\n monad_state.lift x >>= monad_state.lift ∘ f )\n(lift_put : ∀ (x : σ),\n monad_state.lift (put x : state σ punit) = (put x : m punit))\n(lift_get :\n monad_state.lift (get : state σ σ) = (get : m σ))\nopen is_lawful_monad_state\n\nlemma is_lawful_monad_state.lift_and_then {m} [monad m] {α β σ} [monad_state σ m] [is_lawful_monad_state σ m] (x : state σ α) (f : state σ β) :\n (monad_state.lift $ x >> f : m β) =\n monad_state.lift x >> monad_state.lift f :=\nby { simp [(>>),lift_bind m] }\n\ninstance (σ : (Type u)) (m : Type u → Type v) [monad m] [is_lawful_monad m] : is_lawful_monad_state σ (state_t σ m) :=\nby { constructor; intros; try { refl },\n { simp [(>>=),state_t.bind,monad_state.lift,id_bind],\n congr, ext z, cases x.run z, refl }, }\n\ninstance (σ σ' : (Type u)) (m : Type u → Type v) [monad m] [is_lawful_monad m] [monad_state σ m] [is_lawful_monad_state σ m] :\n is_lawful_monad_state σ (reader_t σ' m) :=\nby { constructor; intros; simp [monad_state.lift,lift_pure m,lift_bind m]; refl }\n\ninstance (σ : (Type u)) (m : Type u → Type v) [monad m] [is_lawful_monad m] : is_lawful_monad_lift m (state_t σ m) :=\nby { constructor; intros; try { refl },\n all_goals\n { simp [(>>=),state_t.bind,state_t.lift,has_monad_lift.monad_lift,id_bind,bind_assoc]; refl }, }\n\ninstance (σ : (Type u)) (m : Type u → Type v) [monad m] : is_lawful_monad_lift m (reader_t σ m) :=\nby { constructor; intros; refl }\n\n-- class is_lawful_monad_reader (σ : out_param (Type u)) (m : Type u → Type v) [monad m] [monad_reader σ m] :=\n-- (lift_pure {} : ∀ {α} (x : α),\n-- monad_reader.lift (pure x : reader σ α) = (pure x : m α))\n-- (lift_bind {} : ∀ {α β} (x : state σ α) (f : α → state σ β),\n-- (monad_state.lift $ x >>= f : m β) =\n-- monad_state.lift x >>= monad_state.lift ∘ f )\n\n-- instance (σ : (Type u)) (m : Type u → Type v) [monad m] [is_lawful_monad m] : is_lawful_monad_state σ (state_t σ m) :=\n-- by { constructor; intros,\n-- { refl },\n-- { simp [(>>=),state_t.bind,monad_state.lift,id_bind],\n-- congr, ext z, cases x.run z, refl } }\n\n-- class is_lawful_monad_state\n", "meta": {"author": "leanprover-community", "repo": "mathlib-nursery", "sha": "0479b31fa5b4d39f41e89b8584c9f5bf5271e8ec", "save_path": "github-repos/lean/leanprover-community-mathlib-nursery", "path": "github-repos/lean/leanprover-community-mathlib-nursery/mathlib-nursery-0479b31fa5b4d39f41e89b8584c9f5bf5271e8ec/src/category/monad_trans.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4726834766204328, "lm_q1q2_score": 0.2455691446387585}} {"text": "/- Provides simplification lemmas for applicative laws. -/\n\nuniverse variables u\n\n@[simp]\nlemma fmap_pure {m : Type u → Type u} [hm : applicative m] {α β : Type u} (f : α → β) (v : α) :\n f <$> (pure v : m α) = pure (f v) := applicative.map_pure m f v\n", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/category/applicative.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.46879062662624377, "lm_q1q2_score": 0.2453745533667865}} {"text": "import for_mathlib.category_theory.localization.derived_functor\n\nnoncomputable theory\n\nopen category_theory category_theory.category\n\nnamespace category_theory\n\nnamespace structured_arrow\n\nvariables {C₁ C₂ C₃ D₁ D₂ D₃ : Type*} [category C₁] [category C₂]\n [category C₃] [category D₁] [category D₂] [category D₃]\n {P₁ : C₁ ⥤ D₁} {P₂ : C₂ ⥤ D₂} {P₃ : C₃ ⥤ D₃}\n {A : C₁ ⥤ C₂} {B : D₁ ⥤ D₂} {A' : C₂ ⥤ C₃} {B' : D₂ ⥤ D₃}\n (τ : P₁ ⋙ B ⟶ A ⋙ P₂) (τ' : P₂ ⋙ B' ⟶ A' ⋙ P₃) (Y : D₁)\n\n@[simps]\ndef whisker :\n structured_arrow Y P₁ ⥤ structured_arrow (B.obj Y) P₂ :=\n{ obj := λ X, structured_arrow.mk (B.map X.hom ≫ τ.app X.right),\n map := λ X X' f, structured_arrow.hom_mk (A.map f.right) begin\n dsimp,\n simp only [← structured_arrow.w f, category.assoc, B.map_comp],\n erw τ.naturality,\n refl,\n end, }\n\n-- unnecessary\n@[simps]\ndef whisker_comp_iso\n (τ'' : P₁ ⋙ (B ⋙ B') ⟶ (A ⋙ A') ⋙ P₃)\n (hτ : τ'' = (functor.associator P₁ B B').inv ≫ whisker_right τ B' ≫\n (functor.associator A P₂ B').hom ≫ whisker_left A τ' ≫ (functor.associator A A' P₃).inv) :\n whisker τ Y ⋙ whisker τ' (B.obj Y) ≅\n whisker τ'' Y :=\nnat_iso.of_components (λ X, structured_arrow.iso_mk (iso.refl _) begin\n dsimp,\n simp only [hτ, functor.map_comp, assoc, functor.map_id, comp_id, nat_trans.comp_app, functor.associator_inv_app,\n whisker_right_app, functor.associator_hom_app, whisker_left_app, id_comp],\nend) (by tidy)\n\ninstance full_whisker [full A] [faithful B] [is_iso τ] : full (whisker τ Y) :=\nfunctor.full_of_surjective _ (λ X₁ X₂ f, begin\n refine ⟨structured_arrow.hom_mk (A.preimage f.right) (B.map_injective _), _⟩,\n { have eq := structured_arrow.w f,\n dsimp at eq,\n erw [B.map_comp, ← cancel_mono (τ.app X₂.right), ← eq, assoc, assoc, τ.naturality],\n dsimp,\n simp only [functor.image_preimage], },\n { ext,\n dsimp,\n simp, },\nend)\n\ninstance faithful_whisker [faithful A] : faithful (whisker τ Y) :=\n⟨λ X₁ X₂ f₁ f₂ hf, begin\n ext,\n exact A.map_injective ((structured_arrow.proj _ _).congr_map hf),\nend⟩\n\ninstance ess_surj [ess_surj A] [full B] [is_iso τ] : ess_surj (whisker τ Y) :=\n⟨λ X, ⟨structured_arrow.mk (B.preimage (X.hom ≫\n P₂.map (A.obj_obj_preimage_iso X.right).inv ≫ (inv τ).app _)),\n ⟨structured_arrow.iso_mk (A.obj_obj_preimage_iso X.right) begin\n dsimp,\n simp only [nat_iso.is_iso_inv_app, functor.image_preimage, assoc, is_iso.inv_hom_id, comp_id,\n ← P₂.map_comp, iso.inv_hom_id, P₂.map_id],\n end⟩⟩⟩\n\ninstance is_equivalence_whisker\n [is_iso τ] [is_equivalence A] [full B] [faithful B] : is_equivalence (whisker τ Y) :=\nbegin\n haveI : ess_surj A := -- `ess_surj_of_is_equivalence` should be an instance\n ⟨λ X, ⟨(is_equivalence.inverse A).obj X, ⟨is_equivalence.counit_iso.app X⟩⟩⟩,\n apply equivalence.of_fully_faithfully_ess_surj,\nend\n\nend structured_arrow\n\nnamespace functor\n\nnamespace is_right_derived_functor\n\nsection\n\nvariables {C D D' H : Type*} [category C] [category D] [category D'] [category H]\n {F : C ⥤ D} (RF : H ⥤ D) {L : C ⥤ H} (α : F ⟶ L ⋙ RF) (e : D ≌ D')\n (W : morphism_property C) [L.is_localization W]\n\nlemma of_equivalence_comp_right [RF.is_right_derived_functor α]\n (β : F ⋙ e.functor ⟶ L ⋙ RF ⋙ e.functor)\n (hβ : β = whisker_right α e.functor ≫ (functor.associator _ _ _).hom) :\n (RF ⋙ e.functor).is_right_derived_functor β :=\nbegin\n let e' : (whiskering_left C H D).obj L ⋙ (whiskering_right C D D').obj e.functor ≅\n (whiskering_right H D D').obj e.functor ⋙ (whiskering_left C H D').obj L :=\n nat_iso.of_components (λ X, iso.refl _) (by tidy),\n exact ⟨⟨limits.is_initial.of_iso (limits.is_initial.is_initial_obj (structured_arrow.whisker e'.hom F) (structured_arrow.mk α)\n (is_right_derived_functor.is_initial α).some)\n (structured_arrow.iso_mk (iso.refl _) (by { rw hβ, tidy, }))⟩⟩,\nend\n\ninstance of_equivalence_comp_right' [RF.is_right_derived_functor α] (G : D ⥤ D')\n [is_equivalence G] :\n (RF ⋙ G).is_right_derived_functor (whisker_right α G ≫ (functor.associator _ _ _).hom) :=\nof_equivalence_comp_right RF α (as_equivalence G) _ rfl\n\ninstance has_right_derived_functor_equivalence_comp_right (G : D ⥤ D')\n [is_equivalence G] [F.has_right_derived_functor W] :\n (F ⋙ G).has_right_derived_functor W :=\nis_right_derived_functor.has_right_derived_functor (F ⋙ G)\n (F.right_derived_functor W.Q W ⋙ G) W.Q\n (whisker_right (F.right_derived_functor_α W.Q W) G ≫ (functor.associator _ _ _).hom) W\n\nend\n\nsection\n\nvariables {C C' D H H' : Type*} [category C] [category C'] [category D] [category H] [category H']\n {F' : C' ⥤ D} (RF' : H' ⥤ D) {L' : C' ⥤ H'} (α' : F' ⟶ L' ⋙ RF') {L : C ⥤ H}\n {G : C ⥤ C'} {G' : H ⥤ H'} (e : G ⋙ L' ≅ L ⋙ G')\n [is_equivalence G] [is_equivalence G']\n (W : morphism_property C) [L.is_localization W]\n (W' : morphism_property C') [L'.is_localization W']\n\nlemma of_equivalence_comp_left [RF'.is_right_derived_functor α']\n (α : G ⋙ F' ⟶ L ⋙ (G' ⋙ RF'))\n (hα : α = whisker_left G α' ≫ (functor.associator _ _ _).inv ≫\n whisker_right e.hom RF' ≫ (functor.associator _ _ _).hom) :\n (G' ⋙ RF').is_right_derived_functor α :=\nbegin\n let e' : (whiskering_left C' H' D).obj L' ⋙ (whiskering_left C C' D).obj G ≅\n (whiskering_left H H' D).obj G' ⋙ (whiskering_left C H D).obj L :=\n nat_iso.of_components (λ X, iso_whisker_right e X) (by tidy),\n exact ⟨⟨limits.is_initial.of_iso (limits.is_initial.is_initial_obj\n (structured_arrow.whisker e'.hom F') (structured_arrow.mk α')\n (is_right_derived_functor.is_initial α').some) (structured_arrow.iso_mk (iso.refl _)\n (by { rw hα, tidy, }))⟩⟩,\nend\n\ninstance of_equivalence_comp_left' [RF'.is_right_derived_functor α'] :\n (G' ⋙ RF').is_right_derived_functor (whisker_left G α' ≫ (functor.associator _ _ _).inv ≫\n whisker_right e.hom RF' ≫ (functor.associator _ _ _).hom) :=\nof_equivalence_comp_left RF' α' e _ rfl\n\nlemma _root_.category_theory.functor.has_right_derived_functor_equivalence_comp_right\n [F'.has_right_derived_functor W'] :\n (G ⋙ F').has_right_derived_functor W :=\nis_right_derived_functor.has_right_derived_functor (G ⋙ F') _ _\n ((whisker_left G (F'.right_derived_functor_α L' W') ≫ (functor.associator _ _ _).inv ≫\n whisker_right e.hom _ ≫ (functor.associator _ _ _).hom)) W\n\nend\n\nend is_right_derived_functor\n\nend functor\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/localization/derived_functor_functoriality.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6187804478040616, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.24507923728798503}} {"text": "import reducibility friedberg_muchnik\nopen encodable denumerable part\n\n-- Degrees of Unsolvability\n\nattribute [instance, priority 0] classical.prop_decidable\n\n@[notation_class] class has_jump (α : Type*) := (jump : α → α)\n\npostfix `⁺`:(max+1) := has_jump.jump\n\ntheorem equivalence_of_t_reducible_equiv (α) [primcodable α] :\n equivalence (@t_reducible_equiv α α _ _) :=\n⟨λ x, t_reducible_equiv.refl x,\n λ _ _, t_reducible_equiv.symm,\n λ _ _ _, t_reducible_equiv.trans⟩\n\ndef turing_degree : Type :=\nquotient (⟨t_reducible_equiv, equivalence_of_t_reducible_equiv ℕ⟩ : setoid (set ℕ))\n\nnotation `𝐃` := turing_degree\n\nnamespace turing_degree\n\ndef deg (A : set ℕ) : 𝐃 := quotient.mk' A\n\n@[elab_as_eliminator]\nprotected lemma ind_on {C : 𝐃 → Prop} (d : 𝐃)\n (h : ∀ p : set ℕ, C (deg p)) : C d :=\nquotient.induction_on' d h\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on {φ} (d : 𝐃) (f : set ℕ → φ)\n (h : ∀ p q, p ≡ₜ q → f p = f q) : φ :=\nquotient.lift_on' d f h\n\n@[simp]\nprotected lemma lift_on_eq {φ} (p : set ℕ) (f : set ℕ → φ)\n (h : ∀ p q, t_reducible_equiv p q → f p = f q) : (deg p).lift_on f h = f p :=\nrfl\n\n@[elab_as_eliminator, reducible, simp]\nprotected def lift_on₂ {φ} (d₁ d₂ : 𝐃) (f : set ℕ → set ℕ → φ)\n (h : ∀ p₁ p₂ q₁ q₂, p₁ ≡ₜ q₁ → p₂ ≡ₜ q₂ → f p₁ p₂ = f q₁ q₂) : φ :=\nquotient.lift_on₂' d₁ d₂ f h\n\n@[simp]\nprotected lemma lift_on₂_eq {φ} (p q : set ℕ) (f : set ℕ → set ℕ → φ)\n (h : ∀ p₁ p₂ q₁ q₂, p₁ ≡ₜ q₁ → p₂ ≡ₜ q₂ → f p₁ p₂ = f q₁ q₂) :\n (deg p).lift_on₂ (deg q) f h = f p q := rfl\n\n@[simp] lemma of_eq_of {p q} : deg p = deg q ↔ p ≡ₜ q :=\nby simp [deg, quotient.eq']\n\ninstance : has_le 𝐃 :=\n⟨λ d₁ d₂, turing_degree.lift_on₂ d₁ d₂ (≤ₜ) $\n λ p₁ p₂ q₁ q₂ hp hq, propext \n ⟨λ hpq, (hp.2.trans hpq).trans hq.1, λ hpq, (hp.1.trans hpq).trans hq.2⟩⟩\n\n@[simp] lemma of_le_of {A B} : deg A ≤ deg B ↔ A ≤ₜ B := by refl\n\ninstance : semilattice_sup_bot 𝐃 :=\n{ le := (≤),\n sup := λ a b, turing_degree.lift_on₂ a b (λ A B, deg (Join₂ A B)) (λ A₁ B₁ A₂ B₂ hA hB,\n by { simp, split,\n { have lmm₁ : A₁ ≤ₜ Join₂ A₂ B₂, from hA.1.trans (le_Join₂_left _ _).to_turing,\n have lmm₂ : B₁ ≤ₜ Join₂ A₂ B₂, from hB.1.trans (le_Join₂_right _ _).to_turing,\n refine Join₂_le A₁ B₁ _ lmm₁ lmm₂ },\n { have lmm₁ : A₂ ≤ₜ Join₂ A₁ B₁, from hA.2.trans (le_Join₂_left _ _).to_turing,\n have lmm₂ : B₂ ≤ₜ Join₂ A₁ B₁, from hB.2.trans (le_Join₂_right _ _).to_turing,\n refine Join₂_le A₂ B₂ _ lmm₁ lmm₂ } }),\n bot := deg ∅,\n le_refl := λ d, by induction d using turing_degree.ind_on; simp,\n le_trans := λ a b c,\n by { induction a using turing_degree.ind_on,\n induction b using turing_degree.ind_on,\n induction c using turing_degree.ind_on,\n exact t_reducible.trans },\n le_antisymm := λ a b,\n by { induction a using turing_degree.ind_on,\n induction b using turing_degree.ind_on,\n intros hp hq,\n simp only [*, t_reducible_equiv, of_le_of, of_eq_of, true_and] at * },\n le_sup_left := λ a b,\n by { induction a using turing_degree.ind_on,\n induction b using turing_degree.ind_on,\n simp[has_sup.sup], exact (le_Join₂_left _ _).to_turing },\n le_sup_right := λ a b,\n by { induction a using turing_degree.ind_on,\n induction b using turing_degree.ind_on,\n simp[has_sup.sup], exact (le_Join₂_right _ _).to_turing },\n sup_le := λ a b c,\n by { induction a using turing_degree.ind_on,\n induction b using turing_degree.ind_on,\n induction c using turing_degree.ind_on,\n simp[has_sup.sup], exact Join₂_le a b c },\n bot_le := λ a, by { induction a using turing_degree.ind_on, simp, exact computable_le _ computable_0 } }\n\nlemma of_sup_of {A B} : deg A ⊔ deg B = deg (Join₂ A B) := rfl\n\ninstance : inhabited 𝐃 := ⟨⊥⟩\n\ndef djump : 𝐃 → 𝐃 :=\nλ d, turing_degree.lift_on d (λ d, deg d′)\n(λ A B ⟨ab, ba⟩, by { simp, exact \n ⟨(le_le_Jump ab).to_many_one.to_turing, (le_le_Jump ba).to_many_one.to_turing⟩ })\n\ninstance : has_jump 𝐃 := ⟨djump⟩\n\ndef djump_itr (d : 𝐃) : ℕ → 𝐃\n| 0 := d\n| (n+1) := (djump_itr n)⁺\n\n@[simp] lemma of_jump {A} : (deg A)⁺ = deg A′ := rfl\n\ndef re_degree := {d // ∃ R : set ℕ, r.e. R ∧ d = deg R}\n\nnotation `𝐑` := re_degree\n\ninstance : has_coe 𝐑 𝐃 := ⟨subtype.val⟩\n\ninstance : semilattice_sup_bot 𝐑 :=\n { le := λ a b, (a : 𝐃) ≤ (b : 𝐃),\n sup := λ a b, ⟨(a : 𝐃) ⊔ (b : 𝐃),\n by { rcases a with ⟨a, A, reA, rfl⟩, rcases b with ⟨b, B, reB, rfl⟩,\n refine ⟨Join₂ A B, re_Join_of_re_re reA reB, by simp[of_sup_of]⟩ }⟩,\n bot := ⟨⊥, ∅, re_pred_0, rfl⟩,\n le_refl := by simp,\n le_trans := λ ⟨a, _⟩ ⟨b, _⟩ ⟨c, _⟩, by {simp, exact le_trans },\n le_antisymm := λ ⟨a, _⟩ ⟨b, _⟩, by { simp, exact le_antisymm },\n bot_le := λ ⟨a, _⟩, by simp,\n le_sup_left := λ ⟨a, _⟩ ⟨b, _⟩, by simp,\n le_sup_right := λ ⟨a, _⟩ ⟨b, _⟩, by simp,\n sup_le := λ ⟨a, _⟩ ⟨b, _⟩ ⟨c, _⟩, by { simp[-sup_le_iff], exact sup_le } }\n\ninstance : semilattice_sup_top 𝐑 :=\n { top := ⟨⊥⁺, (∅ : set ℕ)′, re_pred_Jump_0, rfl⟩,\n le_top := λ ⟨a, R, reR, rfl⟩, by { simp[has_top.top, show ⊥⁺ = deg ∅′, by refl],\n exact (re_many_one_reducible_to_0'.mp reR).to_turing },\n ..re_degree.semilattice_sup_bot }\n\ndef High := {d : 𝐑 | (d : 𝐃)⁺ = ⊥⁺⁺}\n\ndef Low := {d : 𝐑 | (d : 𝐃)⁺ = ⊥⁺}\n\n@[simp] lemma of_lt_of {A B} : deg A < deg B ↔ A <ₜ B := by refl\n\ntheorem lt_djump (d : 𝐃) : d < d⁺ :=\nby { induction d using turing_degree.ind_on, simp,\n exact lt_Jump _ } \n\ntheorem djump_neq (d : 𝐃) : d ≠ d⁺ := λ h,\nby { have : d⁺ ≤ d, rw ←h,\n exact (lt_djump d).2 this }\n\ninstance : nontrivial 𝐃 := ⟨⟨⊥, ⊥⁺, djump_neq ⊥⟩⟩\n\nlemma jump_order_preserving (a b : 𝐃) (le : a ≤ b) : a⁺ ≤ b⁺ :=\nby { induction a using turing_degree.ind_on,\n induction b using turing_degree.ind_on,\n simp at le ⊢, exact (le_le_Jump le).to_turing }\n\ntheorem friedberg_muchnik : ∃ a b : 𝐑, ¬a ≤ b ∧ ¬b ≤ a :=\nby rcases friedberg_muchnik.incomparable_re_sets with ⟨I₀, I₁, re₀, re₁, nle₀, nle₁⟩;\n refine ⟨⟨deg I₀, I₀, re₀, rfl⟩, ⟨deg I₁, I₁, re₁, rfl⟩, nle₁, nle₀⟩\n\nend turing_degree", "meta": {"author": "iehality", "repo": "lean-reducibility", "sha": "82a7e3ec0fcedfb0d69c25e77bcd24c9b29626b7", "save_path": "github-repos/lean/iehality-lean-reducibility", "path": "github-repos/lean/iehality-lean-reducibility/lean-reducibility-82a7e3ec0fcedfb0d69c25e77bcd24c9b29626b7/src/degree.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.41869690935568665, "lm_q1q2_score": 0.24498004492533793}} {"text": "structure PFunctor : Type 1 :=\n( α : Type )\n( β : α → Type )\n\nvariable (P : PFunctor)\n\nnamespace PFunctor\n\ndef obj (X : Type) : Type :=\nΣ (a : P.α), P.β a → X\n\ndef map {X Y : Type} (f : X → Y) (x : P.obj X) : P.obj Y :=\n⟨x.1, λ a => f (x.2 a)⟩\n\ninductive Z (P : PFunctor) : Type\n| bud : Z P\n| some (a : P.α) (f : P.β a → Z P) : Z P\n\nvariable {P}\n\ndef of_α (a : P.α) : Z P :=\nZ.some a (λ _ => Z.bud)\n\ninductive bud : Z P → Type\n| bud : bud (@Z.bud P)\n| some {a : P.α} {f : P.β a → Z P} {p : P.β a} (b : bud (f p)) : \n bud (Z.some a f)\n\ninductive is_extension : Z P → Z P → Prop\n| bud (z : Z P) : is_extension Z.bud z\n| some {a : P.α} {f₁ f₂ : P.β a → Z P} (h : ∀ p : P.β a, is_extension (f₁ p) (f₂ p)) :\n is_extension (Z.some a f₁) (Z.some a f₂)\n\ntheorem is_extension.refl : (z : Z P) → is_extension z z\n| Z.bud => is_extension.bud _\n| Z.some _ _ => is_extension.some (λ _ => is_extension.refl _)\n\ninductive extends_at {P : PFunctor}: (z₁ : Z P) → (b : bud z) → Z P → Type\n| bud {a : P.α} {f : P.β a → Z P} : extends_at (@Z.bud P) (@bud.bud P) (Z.some a f)\n| some {a : P.α} {f₁ f₂ : P.β a → Z P} {p : P.β a} (b : bud (f₁ p)) \n (h : extends_at (f₁ p) b (f₂ p)) : \n extends_at (Z.some a f₁) (bud.some b) (Z.some a f₂)\n\nstructure M' (P : PFunctor) : Type :=\n( s : Z P → Prop )\n( bud_mem : s Z.bud )\n( extension_pair {z₁ z₂ : Z P} : s z₁ → s z₂ → \n ∃ z₃ : Z P, s z₃ ∧ is_extension z₁ z₃ ∧ is_extension z₂ z₃ )\n( extend {z : Z P} : s z → bud z → Z P )\n( extend_extends {z : Z P} (h : s z) (b : bud z) : \n extends_at z b (extend h b) )\n\ndef M'.constructor (m : M' P) : P.α :=\nlet z := m.extend m.bud_mem bud.bud\nhave hz : extends_at Z.bud bud.bud z := m.extend_extends m.bud_mem bud.bud\nmatch z, hz with\n| Z.some a _, _ => a\n\ndef M.branch (m : M' P) (a : P.β m.constructor) : M' P :=\n\ndef M'_coalg (m : M' P) : P.obj (M' P) :=\nlet z := m.extend m.bud_mem bud.bud\nhave hz : extends_at Z.bud bud.bud z := m.extend_extends m.bud_mem bud.bud\nmatch z, hz with\n| Z.some a f, _ => ⟨a, λ p => \n { s := λ z => z = Z.bud ∨ ∃ f : P.β a → Z P, m.s (Z.some a f) ∧ z = f p,\n bud_mem := Or.inl rfl,\n extension_pair := @λ z₁ z₂ hz₁ hz₂ => \n match z₁, z₂, hz₁, hz₂ with \n | _, z₂, Or.inl rfl, hz₂ => \n ⟨z₂, hz₂, is_extension.bud _, is_extension.refl _⟩\n | z₁, _, hz₁, Or.inl rfl => \n ⟨z₁, hz₁, is_extension.refl _, is_extension.bud _⟩\n | _, _, Or.inr ⟨f₁, hf₁, rfl⟩, Or.inr ⟨f₂, hf₂, rfl⟩ => \n match m.extension_pair hf₁ hf₂ with\n | ⟨Z.some _ f, h₁, is_extension.some h₂, is_extension.some h₃⟩ => \n ⟨f p, Or.inr ⟨f, h₁, rfl⟩, h₂ p, h₃ p⟩,\n extend := @λ z hz b => \n match z, hz, b with\n | Z.bud, _, bud.bud => f p\n | Z.some a' f', h, @bud.some _ _ _ p' h' => \n _\n extend_extends := sorry\n }⟩\n\n-- def M'.rel (m₁ m₂ : M' P) : Prop :=\n-- ∃ m₃ : M' P, (∀ z, m₁.s z → m₃.s z) ∧ (∀ z, m₂.s z → m₃.s z)\n\n-- def M'.rel.refl (m : M' P) : M'.rel m m :=\n-- ⟨m, λ _ => id, λ _ => id⟩\n\n-- def M'.rel.symm {m₁ m₂ : M' P} : M'.rel m₁ m₂ → M'.rel m₂ m₁ \n-- | ⟨m₃, h₁, h₂⟩ => ⟨m₃, h₂, h₁⟩\n\n-- def M'.rel.trans {m₁ m₂ m₃ : M' P} : M'.rel m₁ m₂ → M'.rel m₂ m₃ → M'.rel m₁ m₃\n-- | ⟨n, hn₁, hn₂⟩, ⟨o, ho₁, ho₂⟩ => \n-- ⟨{ s := λ z => n.s z ∨ o.s z,\n-- bud_mem := Or.inl n.s.bud_mem,\n-- extension_pair := _ } \n", "meta": {"author": "ChrisHughes24", "repo": "lean4stuff", "sha": "2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346", "save_path": "github-repos/lean/ChrisHughes24-lean4stuff", "path": "github-repos/lean/ChrisHughes24-lean4stuff/lean4stuff-2b5f6589cfd0113853d2dd0a5ce3fdf91fae7346/Stuff/Coind/try2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.4610167793123159, "lm_q1q2_score": 0.2448964344532826}} {"text": "import Aesop\n\naxiom Scheme : Type\naxiom P : Scheme → Prop\naxiom Q : Scheme → Prop\naxiom R : Scheme → Prop\naxiom S : Scheme → Prop\n\n@[aesop 99%] axiom Q_of_P (X : Scheme) (h : P X) : Q X\n@[aesop 99%] axiom R_of_Q (X : Scheme) (h : Q X) : R X\n\n@[aesop 99%] axiom S_of__R_of_P (X : Scheme) (h : P X → R X) : S X\n\ntheorem thm : S X := by {\n aesop;\n}\n\n#print thm\n", "meta": {"author": "jessetvogel", "repo": "duck", "sha": "4ab46eb4099ef5a827112d5ac217f9e649946796", "save_path": "github-repos/lean/jessetvogel-duck", "path": "github-repos/lean/jessetvogel-duck/duck-4ab46eb4099ef5a827112d5ac217f9e649946796/EdgeCase2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.4571367168274948, "lm_q1q2_score": 0.24461313884192074}} {"text": "import data.list.alist\nimport .presheaf2\n\nnamespace o_minimal\n\nvariables {R : Type*} {S : struc R}\n\nstructure sect (Γ : Def S) (X : Type*) [definable_psh S X] :=\n(to_fun : Γ → X)\n(definable : definable_psh.definable to_fun)\n\ninfixr ` ⊢ `:10 := sect\n\ndef sect.precomp {Γ' Γ : Def S} {X : Type*} [definable_psh S X]\n (σ : Γ ⊢ X) (φ : Hom Γ' Γ) : Γ' ⊢ X :=\n{ to_fun := σ.to_fun ∘ φ.to_fun,\n definable := definable_psh.definable_precomp φ σ.definable }\n\nlemma begin_lem {X : Type*} [definable_psh S X] {x : X} :\n definable S x ↔ ∀ (Γ : Def S), definable_psh.definable (λ (γ : Γ), x) :=\nbegin\n unfold definable,\n split; intro H,\n { intro Γ,\n let u : Hom Γ pt := ⟨λ _, default _, by exact pt.definable⟩,\n exact definable_psh.definable_precomp u H },\n { apply H }\nend\n\nlemma intro_lem₁ {X Y : Type*} [definable_psh S X] [definable_psh S Y]\n (f : X → Y) :\n (∀ (Γ : Def S), definable S (λ (γ : Γ), f)) ↔\n (∀ (Γ : Def S) (x : Γ → X), definable S x → definable S (λ (γ : Γ), f (x γ))) :=\nsorry\n\nlemma definable_fun' {Γ : Def S} {X Y : Type*} [definable_psh S X] [definable_psh S Y]\n {f : Γ → X → Y} : definable_psh.definable f ↔\n (∀ (Γ' : Def S) (π : Hom Γ' Γ) (g : Γ' ⊢ X),\n definable_psh.definable (λ γ_1, f (π.to_fun γ_1) (g.to_fun γ_1))) :=\nbegin\n split; intro H,\n { intros Γ' π g,\n have : definable_psh.definable (λ γ', (π.to_fun γ', g.to_fun γ')) :=\n ⟨π.is_definable, g.definable⟩,\n exact H Γ' this },\n { intros M g hg,\n exact H M ⟨_, hg.1⟩ ⟨_, hg.2⟩ }\nend\n\nlemma definable.app_ctx' {Γ : Def S} {X Y : Type*} [definable_psh S X] [definable_psh S Y]\n (f : Γ → X → Y) {hf : definable_psh.definable f} (x : Γ → X) {hx : definable_psh.definable x} :\n definable_psh.definable (λ γ, f γ (x γ)) :=\nbegin\n have : definable_psh.definable (λ γ, (γ, x γ)) :=\n ⟨(Def.id _).is_definable, hx⟩,\n exact hf Γ this\nend\n\nlemma definable_const {Γ : Def S} {X : Type*} [definable_psh S X] {x : X} :\n definable S x → definable_psh.definable (λ (_ : Γ), x) :=\nλ H, begin_lem.mp H Γ\n\nend o_minimal\n\nnamespace tactic.interactive\n\nopen tactic\nopen interactive interactive.types\n\nmeta def defin_start : tactic unit :=\n`[rw o_minimal.begin_lem, intro Γ]\n\n/-- Return the variable representing the definable context. -/\nmeta def guess_ctx_var : tactic expr :=\ndo `(o_minimal.definable_psh.definable (λ (_ : ↥%%var), _)) ← target,\n -- trace var,\n return var\n\n/-- Return a list of \"definable\" variables along with their processed types. -/\nmeta def guess_defin_vars (ctx_var : expr) : tactic (list (expr × expr)) :=\ndo l ← local_context,\n -- some kind of moption_map?\n l ← l.mmap (λ var,\n (do `(o_minimal.sect %%ctx_var %%ty) ← infer_type var,\n return $ some (var, ty)) <|> return none),\n let l' := l.filter_map id,\n -- trace l',\n return l'\n\nmeta def guess_defin_vars' : tactic (list (expr × expr)) :=\nguess_ctx_var >>= guess_defin_vars\n\n/-- Goal should look like\n ⊢ definable_psh.definable (λ γ, λ x, e)\nWe want to \"intro\" `x` as a definable variable, and leave\n ⊢ definable_psh.definable (λ γ, e)\nas the new goal.\n\nStrategy:\nBy `definable_fun'` it's enough to check the new goal\nfor an arbitrary context extension π : Γ' → Γ and section x : Γ' ⊢ α.\nHowever, we also have to move any existing definable variables from Γ to Γ'.\nSo, we proceed as follows:\n* Identify the variables `γ` (`i_var`) and `Γ` (`ctx_var`) in the goal\n `definable_psh.definable (λ (γ : Γ), body)`.\n Here `body` is expected to be a function whose argument `x`\n we want to intro.\n* Use `definable_fun'` but then intro only `Γ'` and `π`.\n* For each existing definable variable `p`, we add a let binding\n `p' := p.precomp π`.\n* Now intro the new variable `x` (`new_var`) as well, and build a new function\n (λ (γ' : Γ'), body' (x.to_fun γ')), by making the following replacements:\n - each old `p` becomes `p'`;\n - `i` becomes `i'`;\n - `Γ` becomes `Γ'`.\n The claim is that the new expression is well-typed and definitionally equal\n (in the context of the let-bound variables `p'`, ...) to the current goal.\n Moreover, it only mentions the new `Γ'` and `p'`.\n* Now we cover our tracks:\n - clear the bodies of the let bindings `p'`, so that we can:\n - clear the old definable variables, `π`, and the old `Γ`.\n\nThe tactic reuses the same user-visible names for the new `Γ` and `γ`.\nThis is nice for interactive use, but not so nice for debugging the tactic.\nIn the latter case, add `name.append_after _ 1` when generating names.\n-/\nmeta def defin_intro (var : parse ident_) : tactic unit :=\nlet trace : Π {α : Type} [has_to_tactic_format α] (a : α), tactic unit :=\n λ _ _ _, tactic.skip in -- comment this for debugging\ndo `(o_minimal.definable_psh.definable %%f) ← target,\n ([i_var], body) ← open_n_lambdas f 1,\n ctx_var ← guess_ctx_var,\n trace i_var,\n trace body,\n `[rw definable_fun'],\n new_ctx_var ← tactic.intro ctx_var.local_pp_name,\n proj_var ← tactic.intro `π,\n defin_vars ← guess_defin_vars ctx_var,\n -- do something to them:\n -- * for each old variable `p`, create a new variable `p'`\n -- which is let-bound to `p.precomp π`\n defin_var_list ← defin_vars.mmap (λ ⟨dvar, dvar_ty⟩, do\n -- \"let p' := p.precomp π,\"\n new_body ← to_expr ``((%%dvar).precomp %%proj_var),\n new_dvar ← tactic.pose dvar.local_pp_name none new_body,\n return (sigma.mk dvar new_dvar)),\n new_i_type ← to_expr ``(↥%%new_ctx_var),\n new_i_var ← mk_local' i_var.local_pp_name f.binding_info new_i_type,\n -- * replace variables `p` → `p'` in `body`, and also the γ and Γ vars\n let var_map :=\n (defin_var_list.to_alist.insert i_var new_i_var).insert ctx_var new_ctx_var,\n let body' := body.replace (λ e _, do\n -- for \"efficiency\", first check whether we have a variable at all\n guard (e.is_local_constant),\n -- then, look up the whole expression in our map\n var_map.lookup e),\n -- do the actual intro\n new_var ← tactic.intro var,\n new_var' ← to_expr ``((%%new_var).to_fun %%new_i_var),\n new_f ← tactic.lambdas [new_i_var] (body'.subst new_var'),\n trace new_f,\n new_target ← to_expr\n ``(o_minimal.definable_psh.definable %%new_f),\n tactic.change new_target,\n -- for each defin var:\n -- * forget its let binding (so that we can do the `clear`s below)\n -- (using `clear_value` from mathlib's `tactic.core`)\n -- * clear the original variable\n tactic.clear_value (defin_var_list.map sigma.snd),\n defin_var_list.mmap (λ ⟨dvar, new_dvar⟩, do tactic.clear dvar),\n tactic.clear proj_var,\n tactic.clear ctx_var,\n return ()\n\n/-- Goal should look like\n ⊢ definable_psh.definable (λ γ, f x)\nand we want to produce\n ⊢ definable_psh.definable (λ γ, f)\n ⊢ definable_psh.definable (λ γ, x)\nThis is just `apply definable.app_ctx'`,\nbut Lean needs help with the unification problem.\n-/\nmeta def defin_app : tactic unit :=\ndo `(o_minimal.definable_psh.definable %%e) ← target,\n ([i_var], body) ← open_n_lambdas e 1,\n (expr.app f x) ← pure body,\n f' ← tactic.lambdas [i_var] f,\n x' ← tactic.lambdas [i_var] x,\n `[apply o_minimal.definable.app_ctx' %%f' %%x'],\n return ()\n\n/-- Goal should look like\n ⊢ definable_psh.definable (λ γ, p.to_fun γ)\nwhere p : Γ ⊢ α. Just apply `sect.definable`.\n-/\nmeta def defin_var : tactic unit :=\n`[refine o_minimal.sect.definable _]\n\nend tactic.interactive\n\n-- Now dress it up\n\nmeta def defin := tactic\n\nmeta instance : monad defin :=\nshow monad tactic, by apply_instance\n\nmeta instance : interactive.executor defin :=\n{ config_type := unit,\n inhabited := by apply_instance,\n execute_with := λ _ tac, tactic.interactive.defin_start >> tac }\n\nnamespace defin\n\nmeta def execute (tac : defin unit) : tactic unit :=\ntactic.interactive.defin_start >> tac\n\nmeta def step := @tactic.step -- what does this even do\nmeta def istep := @tactic.istep -- ditto\nmeta def solve1 : defin unit → defin unit := tactic.solve1\n\nopen tactic\n\n-- Tactic state display borrows liberally from\n-- https://github.com/unitb/temporal-logic\n-- file temporal_logic.tactic\n\n/-- Replace any occurrences of `p.to_fun γ` with simply `p`.\nThis is rather crude, but these aren't expected to appear\noutside the execution of a defin tactic. (More sophisticated\nwould be to process only those variables which are sections\nover the context variable that appears in the goal.)\nThe resulting expression is intended to be used for display purposes. -/\nmeta def shorten (E : expr) : expr :=\nE.replace $ λ e _, match e with\n | `(o_minimal.sect.to_fun %%p _) := some p\n | _ := none\nend\n\nmeta structure hyp_data : Type :=\n(crisp : bool)\n(var : expr)\n(ty : expr)\n(val : option expr)\n\n/-- Return information about a local hypothesis `l`. -/\nmeta def get_hyp_data (l : expr) : defin hyp_data :=\ndo ty ← infer_type l,\n val ← try_core (shorten <$> local_def_value l),\n match ty with\n | `(o_minimal.sect %%Γ %%ty') := return ⟨ff, l, shorten ty', val⟩\n | _ := return ⟨tt, l, shorten ty, val⟩\n end\n\nmeta def decl_to_fmt (s : tactic_state) (crisp : bool) (vs : list expr)\n (ty : expr) (val : option expr) : format :=\nlet vs' := format.join $ (vs.map s.format_expr).intersperse \" \",\n t := s.format_expr ty,\n sep := if crisp then \"::\" else \":\" in\nmatch val with\n| (some val) := format! \"{vs'} {sep} {t} := {s.format_expr val}\"\n| none := format! \"{vs'} {sep} {t}\"\nend\n\nmeta def goal_to_fmt (g : expr) : defin (thunk format) :=\ndo set_goals [g],\n s ← read,\n `(o_minimal.definable_psh.definable (λ (_ : ↥%%Γ), %%body)) ← target\n | pure (λ _, to_fmt s),\n lc ← local_context,\n ctx_var ← tactic.interactive.guess_ctx_var,\n dat ← (lc.filter (λ l, l ≠ ctx_var)).mmap get_hyp_data,\n return $ λ _, format.intercalate format.line\n [format.intercalate (\",\" ++ format.line) $ dat.map $ λ d,\n decl_to_fmt s d.crisp [d.var] d.ty d.val,\n format! \"⊢ {s.format_expr (shorten body)} def\"]\n\nmeta def save_info (p : pos) : defin unit :=\ndo gs ← get_goals,\n fmt ← gs.mmap goal_to_fmt,\n set_goals gs,\n tactic.save_info_thunk p (λ _,\n let header := if fmt.length > 1 then format! \"{fmt.length} goals\\n\" else \"\",\n eval : thunk format → format := λ f, f () in\n if fmt.empty\n then \"no goals\"\n else format.join ((fmt.map eval).intersperse (format.line ++ format.line)))\n\nnamespace interactive\n\nmeta def swap := tactic.interactive.swap\nmeta def exact := tactic.interactive.exact\nmeta def solve1 : defin unit → defin unit := tactic.interactive.solve1\n\nmeta def intro := tactic.interactive.defin_intro\nmeta def app := tactic.interactive.defin_app\nmeta def var := tactic.interactive.defin_var\n\nmeta def trace_state : defin unit :=\ndo s ← read,\n trace s.to_format\n\nend interactive\n\nend defin\n\nnamespace o_minimal\n\nvariables {R : Type*} {S : struc R}\n\nlocal infixr ` ⊢ `:10 := sect\n\nexample : definable S (λ p q, (q ∧ p) ∧ q) :=\nbegin\n defin_start,\n defin_intro p,\n defin_intro q,\n defin_app,\n swap,\n { defin_var },\n defin_app,\n { exact definable_const definable_and },\n defin_app,\n { defin_app,\n { exact definable_const definable_and },\n defin_var },\n { defin_var },\nend\n\nexample : definable S (λ p q, (q ∧ p) ∧ q) :=\nbegin [defin]\n intro p,\n intro q,\n app,\n swap,\n { var },\n app,\n { exact definable_const definable_and },\n app,\n { app,\n { exact definable_const definable_and },\n var },\n { var },\nend\n\nexample : definable S and :=\nbegin [defin]\n intro p,\n intro q,\n exact struc.def_coords.inter p.definable q.definable\nend\n\nexample {X Y Z : Type*} [definable_psh S X] [definable_psh S Y] [definable_psh S Z] : definable S (@function.curry X Y Z) :=\nbegin\n unfold function.curry,\n begin [defin]\n intro f,\n intro x,\n intro y,\n app, { var },\n exact ⟨x.definable, y.definable⟩\n /-\n app,\n app,\n exact definable_const definable_prod_mk,\n var,\n var, -/\n end\nend\n\n#exit\n\n-- stuff after this uses pi type instances, which we don't need yet\n\nvariables {Y : Type*} [definable_psh S Y] (y : Y)\n\n--set_option trace.class_instances true\nexample : definable S (λ (X : set Y) (h : nonempty X), true) :=\nbegin\n defin_start, rw ←definable_yoneda, -- TODO: combine these\n\n -- \"intro X\",\n rw definable_fun', intros Γ' π p,\n -- now we need to pull back any variables mentioning Γ\n -- to use Γ' -- there aren't any yet ✓\n -- since that's done, we can dispose of the old context\n clear π Γ,\n rename Γ' → Γ,\n\n -- \"intro x\",\n rw definable_fun', intros Γ' π, -- don't intro q just yet\n -- this time we need to deal with p\n have : ∀ d, p.to_fun (π.to_fun d) = (p.precomp π).to_fun d := λ d, rfl,\n simp only [this],\n generalize H : (p.precomp π) = p', clear this H p, rename p' → p,\n -- okay, now it's safe to intro q\n intro q,\n -- dispose of old context again\n clear π Γ,\n rename Γ' → Γ,\n\n -- we're done with intros!\nend\n\nend o_minimal\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/omin/tactic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5583269796369904, "lm_q2_score": 0.43782349911420193, "lm_q1q2_score": 0.2444486718745309}} {"text": "import tactic\nimport category_theory.functor\nimport data.W.basic\nimport category_theory.closed.types\nimport algebra.category.CommRing.basic\nimport algebra.category.Module.basic\n\nuniverses w x u v \n\nopen category_theory\n\nvariables (𝒞 : Type u) [category.{v} 𝒞]\n\n@[protect_proj] structure struc : Type (max u v (w+1) (x+1)) :=\n( F : 𝒞 → Type w )\n( hom : Π (A B : sigma F) (f : A.1 ⟶ B.1), Type x )\n( id : Π (A : sigma F), Σ f : A.1 ⟶ A.1, hom A A f )\n( id_fst' : Π (A : sigma F), (id A).fst = 𝟙 A.1 )\n( comp : Π {A B C : sigma F}\n (f : Σ f : A.1 ⟶ B.1, hom A B f)\n (g : Σ g : B.1 ⟶ C.1, hom B C g),\n Σ h : A.1 ⟶ C.1, hom A C h )\n( comp_fst' : Π {A B C : sigma F}\n (f : Σ f : A.1 ⟶ B.1, hom A B f)\n (g : Σ g : B.1 ⟶ C.1, hom B C g),\n (comp f g).fst = f.1 ≫ g.1)\n( id_comp' : Π {A B : sigma F} (f : Σ f : A.1 ⟶ B.1, hom A B f), \n comp (id A) f = f )\n( comp_id' : Π {A B : sigma F} (f : Σ f : A.1 ⟶ B.1, hom A B f), \n comp f (id B) = f )\n( assoc' : Π {A B C D : sigma F} \n (f : Σ f : A.1 ⟶ B.1, hom A B f)\n (g : Σ g : B.1 ⟶ C.1, hom B C g)\n (h : Σ h : C.1 ⟶ D.1, hom C D h), \n comp (comp f g) h = comp f (comp g h) )\n\nnamespace struc\n\ninstance : has_coe_to_fun (struc 𝒞) (λ _, 𝒞 → Type w) :=\n{ coe := struc.F }\n\nvariables {𝒞} {F : struc 𝒞}\n\n@[simp] lemma id_comp {A B : sigma F} (f : Σ (f : A.fst ⟶ B.fst), F.hom A B f) : \n F.comp (F.id A) f = f := F.id_comp' _\n\n@[simp] lemma comp_id {A B : sigma F} (f : Σ (f : A.fst ⟶ B.fst), F.hom A B f) : \n F.comp f (F.id B) = f := F.comp_id' _\n\n@[simp] lemma assoc {A B C D : sigma F}\n (f : Σ f : A.1 ⟶ B.1, F.hom A B f)\n (g : Σ g : B.1 ⟶ C.1, F.hom B C g)\n (h : Σ h : C.1 ⟶ D.1, F.hom C D h): \n F.comp (F.comp f g) h = F.comp f (F.comp g h) :=\nF.assoc' _ _ _\n\n@[simp] lemma id_fst₁ (A : sigma F) : (F.id A).fst = 𝟙 A.1 := F.id_fst' _\n\n@[simp] lemma comp_fst₁ {A B C : sigma F}\n (f : Σ f : A.1 ⟶ B.1, F.hom A B f)\n (g : Σ g : B.1 ⟶ C.1, F.hom B C g) :\n (F.comp f g).fst = f.1 ≫ g.1 := F.comp_fst' _ _\n\ninstance : category_struct (sigma F) :=\n{ hom := λ A B, Σ (f : A.1 ⟶ B.1), F.hom A B f,\n id := F.id,\n comp := F.comp }\n\nvariable {F}\n\ndef sigma_category : category (sigma F) :=\n{ id_comp' := F.id_comp',\n comp_id' := F.comp_id',\n assoc' := F.assoc' }\n\n@[simp] lemma comp_fst {A B C : sigma F} (f : A ⟶ B) (g : B ⟶ C) :\n (f ≫ g).fst = f.1 ≫ g.1 := struc.comp_fst₁ f g\n\n@[simp] lemma id_fst {A : sigma F} : sigma.fst (𝟙 A) = 𝟙 A.1 := struc.id_fst₁ _\n\ninstance (X : 𝒞) : category_struct (F X) :=\n{ hom := λ A B, F.hom ⟨X, A⟩ ⟨X, B⟩ (𝟙 X),\n id := λ A, (F.id ⟨X, A⟩).snd,\n comp := λ A B C f g, begin\n have := (F.comp ⟨(F.id ⟨X, B⟩).fst, f⟩ _).snd,\n end }\n\nlemma id_def {X : 𝒞} (x : F X) : 𝟙 x = F.id x := rfl \n\nlemma comp_def (X : 𝒞) (A B C : F X) (f : A ⟶ B) (g : B ⟶ C) :\n f ≫ g = F.hom_iso (𝟙 X ≫ 𝟙 X) A C (𝟙 X) A C (iso.refl X) (iso.refl X) \n (by simp) (by simp) (by simp) (F.comp f g) := rfl\n\ninstance (X : 𝒞) : category (F X) :=\n{ id_comp' := λ A B f, begin \n simp [id_def, comp_def],\n rw [← equiv.trans_apply, F.hom_iso_trans],\n simp\n end,\n comp_id' := λ A B f, begin \n simp [id_def, comp_def],\n rw [← equiv.trans_apply, F.hom_iso_trans],\n simp\n end,\n assoc' := λ A B C D f g h,\n begin\n simp only [comp_def, ← F.hom_iso_comp],\n erw F.hom_iso_comp,\n end }\n\ndef forget : sigma₂ F ⥤ 𝒞 :=\n{ obj := sigma.fst,\n map := λ _ _, sigma.fst }\n\ndef thing (X : 𝒞) : F X ⥤ sigma₂ F :=\n{ obj := λ A, ⟨X, A⟩,\n map := λ A B f, ⟨𝟙 X, f⟩,\n map_id' := λ A, rfl,\n map_comp' := λ A B C f g, sigma.ext \n (by simp) begin \n simp only [comp_snd],\n rw [struc.comp_eq_cast F f g (𝟙 X ≫ 𝟙 X) rfl (𝟙 X)\n (category.comp_id _)],\n symmetry,\n rw [← cast_eq_iff_heq],\n simp, refl,\n simp,\n end }\n\nopen opposite\n\nprotected def op (F : struc 𝒞) : struc 𝒞ᵒᵖ :=\n{ F := λ A, F.F (unop A),\n hom := λ A B f a b, F.hom f.unop b a,\n id := λ A a, F.id a,\n comp := λ A B C a b c f g f' g' h hH, \n F.comp g' f' (by simp [← hH]),\n id_comp := λ A B f a b f', F.comp_id _,\n comp_id := λ A B f a b f', F.id_comp _,\n assoc := λ A B C D f g h a b c d f' g' h', \n by rw F.assoc_left; refl }\n\ndef unop (F : struc 𝒞ᵒᵖ) : struc 𝒞 :=\n{ F := λ A, F.F (op A),\n hom := λ A B f a b, F.hom f.op b a,\n id := λ A a, F.id a,\n comp := λ A B C a b c f g f' g' h hH, \n F.comp g' f' (by simp [← hH]),\n id_comp := λ A B f a b f', F.comp_id _,\n comp_id := λ A B f a b f', F.id_comp _,\n assoc := λ A B C D f g h a b c d f' g' h', \n by rw F.assoc_left; refl }\n\ndef of_functor (F : 𝒞 ⥤ Type w) : struc 𝒞 :=\n{ F := F.obj,\n hom := λ A B f a b, plift (F.map f a = b),\n id := λ A a, ⟨by simp⟩,\n comp := λ A B C a b c f g h₁ h₂ _ h, ⟨by simp [← h, F.map_comp, h₁.down, h₂.down]⟩,\n assoc := λ _ _ _ _ _ _ _ _ _ _ _ h₁ h₂ h₃, \n begin simp [h₁.down, h₂.down, h₃.down] end,\n id_comp := λ _ _ _ _ _ h, \n begin simp [h.down] end,\n comp_id := λ _ _ _ _ _ h, \n begin simp [h.down] end }\n\ndef Module₂ : struc Ring :=\n{ F := λ R, Module R,\n hom := λ R S f M₁ M₂, M₁ →ₛₗ[f] M₂,\n id := λ R M, linear_map.id,\n comp := λ R S T M₁ M₂ M₃ f g f' g' _ h, \n @linear_map.comp _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ⟨h⟩ g' f',\n id_comp := λ R S f M₁ M₂ f', begin\n cases f', cases f, refl\n end,\n comp_id := λ R S f M₁ M₂ f', begin\n cases f', cases f, refl,\n end,\n assoc := λ R S T U f g h M₁ M₂ M₃ M₄ f' g' h', \n begin\n cases f, cases g, cases h, cases f', cases g', cases h',\n refl\n end }\n\ndef pi.struc (F : 𝒞 ⥤ Type) (G : struc (sigma₂ (of_functor F))) : struc 𝒞 :=\n{ F := λ X, Π a : F.obj X, G.F ⟨X, a⟩,\n hom := λ X Y f x y, Π (a : F.obj X), \n @struc.hom _ _ G ⟨X, a⟩ ⟨Y, F.map f a⟩ ⟨f, ⟨rfl⟩⟩ (x a) (y (F.map f a)),\n id := λ X x a, by convert (G.id (x a)); simp,\n comp := λ X Y Z x y z f g f' g' h H a, \n by convert struc.comp G (f' a) (g' (F.map f a)) rfl; subst H; simp,\n id_comp := λ X a, begin\n intros,\n ext,\n simp,\n \n end }\n\n-- Maybe think about W.\n\nend struc", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/parametricity/sigma_category/struc2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5389832354982645, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.24430053737125548}} {"text": "/-\nCopyright (c) 2018 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.equiv.basic\nimport Mathlib.PostPort\n\nuniverses u u_1 u_2 \n\nnamespace Mathlib\n\n/-!\n# A type for VM-erased data\n\nThis file defines a type `erased α` which is classically isomorphic to `α`,\nbut erased in the VM. That is, at runtime every value of `erased α` is\nrepresented as `0`, just like types and proofs.\n-/\n\n/-- `erased α` is the same as `α`, except that the elements\n of `erased α` are erased in the VM in the same way as types\n and proofs. This can be used to track data without storing it\n literally. -/\ndef erased (α : Sort u) := psigma fun (s : α → Prop) => ∃ (a : α), (fun (b : α) => a = b) = s\n\nnamespace erased\n\n\n/-- Erase a value. -/\ndef mk {α : Sort u_1} (a : α) : erased α := psigma.mk (fun (b : α) => a = b) sorry\n\n/-- Extracts the erased value, noncomputably. -/\ndef out {α : Sort u_1} : erased α → α := sorry\n\n/--\nExtracts the erased value, if it is a type.\n\nNote: `(mk a).out_type` is not definitionally equal to `a`.\n-/\ndef out_type (a : erased (Sort u)) := out a\n\n/-- Extracts the erased value, if it is a proof. -/\ntheorem out_proof {p : Prop} (a : erased p) : p := out a\n\n@[simp] theorem out_mk {α : Sort u_1} (a : α) : out (mk a) = a :=\n let h : ∃ (x : α), (fun (b : α) => x = b) = fun (b : α) => a = b := mk._proof_1 a;\n id (cast (Eq.symm (congr_fun (classical.some_spec h) a)) rfl)\n\n@[simp] theorem mk_out {α : Sort u_1} (a : erased α) : mk (out a) = a := sorry\n\ntheorem out_inj {α : Sort u_1} (a : erased α) (b : erased α) (h : out a = out b) : a = b := sorry\n\n/-- Equivalence between `erased α` and `α`. -/\ndef equiv (α : Sort u_1) : erased α ≃ α := equiv.mk out mk mk_out out_mk\n\nprotected instance has_repr (α : Type u) : has_repr (erased α) :=\n has_repr.mk\n fun (_x : erased α) =>\n string.str\n (string.str\n (string.str\n (string.str\n (string.str\n (string.str string.empty (char.of_nat (bit1 (bit0 (bit1 (bit0 (bit0 (bit1 1))))))))\n (char.of_nat (bit0 (bit1 (bit0 (bit0 (bit1 (bit1 1))))))))\n (char.of_nat (bit1 (bit0 (bit0 (bit0 (bit0 (bit1 1))))))))\n (char.of_nat (bit1 (bit1 (bit0 (bit0 (bit1 (bit1 1))))))))\n (char.of_nat (bit1 (bit0 (bit1 (bit0 (bit0 (bit1 1))))))))\n (char.of_nat (bit0 (bit0 (bit1 (bit0 (bit0 (bit1 1)))))))\n\nprotected instance has_to_string (α : Type u) : has_to_string (erased α) :=\n has_to_string.mk\n fun (_x : erased α) =>\n string.str\n (string.str\n (string.str\n (string.str\n (string.str\n (string.str string.empty (char.of_nat (bit1 (bit0 (bit1 (bit0 (bit0 (bit1 1))))))))\n (char.of_nat (bit0 (bit1 (bit0 (bit0 (bit1 (bit1 1))))))))\n (char.of_nat (bit1 (bit0 (bit0 (bit0 (bit0 (bit1 1))))))))\n (char.of_nat (bit1 (bit1 (bit0 (bit0 (bit1 (bit1 1))))))))\n (char.of_nat (bit1 (bit0 (bit1 (bit0 (bit0 (bit1 1))))))))\n (char.of_nat (bit0 (bit0 (bit1 (bit0 (bit0 (bit1 1)))))))\n\n/-- Computably produce an erased value from a proof of nonemptiness. -/\ndef choice {α : Sort u_1} (h : Nonempty α) : erased α := mk (Classical.choice h)\n\n@[simp] theorem nonempty_iff {α : Sort u_1} : Nonempty (erased α) ↔ Nonempty α := sorry\n\nprotected instance inhabited {α : Sort u_1} [h : Nonempty α] : Inhabited (erased α) :=\n { default := choice h }\n\n/--\n`(>>=)` operation on `erased`.\n\nThis is a separate definition because `α` and `β` can live in different\nuniverses (the universe is fixed in `monad`).\n-/\ndef bind {α : Sort u_1} {β : Sort u_2} (a : erased α) (f : α → erased β) : erased β :=\n psigma.mk (fun (b : β) => psigma.fst (f (out a)) b) sorry\n\n@[simp] theorem bind_eq_out {α : Sort u_1} {β : Sort u_2} (a : erased α) (f : α → erased β) :\n bind a f = f (out a) :=\n sorry\n\n/--\nCollapses two levels of erasure.\n-/\ndef join {α : Sort u_1} (a : erased (erased α)) : erased α := bind a id\n\n@[simp] theorem join_eq_out {α : Sort u_1} (a : erased (erased α)) : join a = out a :=\n bind_eq_out a id\n\n/--\n`(<$>)` operation on `erased`.\n\nThis is a separate definition because `α` and `β` can live in different\nuniverses (the universe is fixed in `functor`).\n-/\ndef map {α : Sort u_1} {β : Sort u_2} (f : α → β) (a : erased α) : erased β := bind a (mk ∘ f)\n\n@[simp] theorem map_out {α : Sort u_1} {β : Sort u_2} {f : α → β} (a : erased α) :\n out (map f a) = f (out a) :=\n sorry\n\nprotected instance monad : Monad erased :=\n { toApplicative :=\n { toFunctor := { map := map, mapConst := fun (α β : Type u_1) => map ∘ function.const β },\n toPure := { pure := mk },\n toSeq :=\n { seq :=\n fun (α β : Type u_1) (f : erased (α → β)) (x : erased α) =>\n bind f fun (_x : α → β) => map _x x },\n toSeqLeft :=\n { seqLeft :=\n fun (α β : Type u_1) (a : erased α) (b : erased β) =>\n (fun (α β : Type u_1) (f : erased (α → β)) (x : erased α) =>\n bind f fun (_x : α → β) => map _x x)\n β α (map (function.const β) a) b },\n toSeqRight :=\n { seqRight :=\n fun (α β : Type u_1) (a : erased α) (b : erased β) =>\n (fun (α β : Type u_1) (f : erased (α → β)) (x : erased α) =>\n bind f fun (_x : α → β) => map _x x)\n β β (map (function.const α id) a) b } },\n toBind := { bind := bind } }\n\n@[simp] theorem pure_def {α : Type u_1} : pure = mk := rfl\n\n@[simp] theorem bind_def {α : Type u_1} {β : Type u_1} : bind = bind := rfl\n\n@[simp] theorem map_def {α : Type u_1} {β : Type u_1} : Functor.map = map := rfl\n\nprotected instance is_lawful_monad : is_lawful_monad erased := sorry\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/erased_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.4843800842769844, "lm_q1q2_score": 0.2440821133485685}} {"text": "import Architectural.ArchWithContracts\n\nvariables {Φ Var : Type} [fintype Var] [decidable_eq Var] [AssertionLang Φ Var]\n\ndef isCorrectDecompositionImpl \n{S : Component Var} \n(A : ArchitectureWithContracts Φ S)\n(Is : Implementations A.to_Architecture)\n : Prop := \n(∀ (S' : Component Var) (h : S' ∈ A.subs), (Is S' h).satisfiesContract (A.contracts.find_val S').iget)\n → (@CompositeImplementation Var _ _ _ _ S {..A} Is).satisfiesContract A.parent\n\ndef isCorrectDecompositionEnv \n{S : Component Var}\n(A : ArchitectureWithContracts Φ S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : Prop := \n∀ (S'' : Component Var) (h'': S'' ∈ A.subs) , \n(E.satisfiesContract A.parent ∧ \n(∀ (S' : Component Var) {S' ∈ A.subs.erase S''}, (Is S' (list.mem_of_mem_erase H)).satisfiesContract (A.contracts.find_val S').iget) → \n(CompositeEnvironment A.to_Architecture S'' Is E).satisfiesContract (A.contracts.find_val S'').iget)\n\n\ndef isCorrectDecomposition \n{S : Component Var}\n(A : ArchitectureWithContracts Φ S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) := \nisCorrectDecompositionImpl A Is ∧ \nisCorrectDecompositionEnv A Is E \n\nnamespace Claim \n\n\ndef correctDecompositionImpl \n{S : Component Var} \n(A : ArchitectureWithContracts Φ S)\n(Is :Implementations A.to_Architecture)\n(σ : Trace Var) : Prop := \n(∀ (S' : Component Var) {S' ∈ A.subs}, ∀ σ',(σ' ∈ (Is S' H) ∧ \n(σ' ∈ (@AssertionLang.sem Φ Var _ _ _ (A.contracts.find_val S').iget.A))) → \n(σ' ∈ (@AssertionLang.sem Φ Var _ _ _ (A.contracts.find_val S').iget.G))) → ( (σ ∈ (@CompositeImplementation Var _ _ _ _ S ↑A Is) ∧ (σ ∈ (@AssertionLang.sem Φ Var _ _ _ A.parent.A))) → (σ ∈ (@AssertionLang.sem Φ Var _ _ _ A.parent.G)))\n\n\n-- example {C : Contract Φ Var} {σ : Trace Var} :\n-- (σ ∈ (@AssertionLang.sem Φ Var _ _ _ C.A)) → (σ ∈ (@AssertionLang.sem Φ Var _ _ _ C.G))\n-- ↔ (σ ∈ (@AssertionLang.sem Φ Var _ _ _ C.nf)) := \n-- begin\n-- split,\n-- intro H,\n-- rw AssertionLang.disj_def,\n-- rw AssertionLang.compl_def,\n-- simp,\n-- rw ← imp_iff_not_or, exact H, \n-- intro H,\n-- rw AssertionLang.disj_def at H,\n-- rw AssertionLang.compl_def at H,\n-- simp at H,\n-- rw ← imp_iff_not_or at H, exact H,\n-- end \n\ndef correctDecompositionImpl' \n{S : Component Var} \n(A : ArchitectureWithContracts Φ S)\n(Is :Implementations A.to_Architecture)\n(σ : Trace Var) : Prop := \n(∀ (S' : Component Var) {S' ∈ A.subs}, ∀ σ',(σ' ∈ (Is S' H) ∧ \n(σ' ∈ (@AssertionLang.sem Φ Var _ _ _ (A.contracts.find_val S').iget.A))) → \n(σ' ∈ (@AssertionLang.sem Φ Var _ _ _ (A.contracts.find_val S').iget.G))) → \n( (σ ∈ (@CompositeImplementation Var _ _ _ _ S ↑A Is) ∧ (σ ∈ (@AssertionLang.sem Φ Var _ _ _ A.parent.A))) → (σ ∈ (@AssertionLang.sem Φ Var _ _ _ A.parent.G)))\n\ndef correctDecompositionEnv \n{S : Component Var}\n(A : ArchitectureWithContracts Φ S)\n(Is :Implementations A.to_Architecture)\n(E : Env Var) (σ : Trace Var) : Prop := \n∀ (S'' : Component Var) {S'' ∈ A.subs},\nE.satisfiesContract A.parent → \n(∀ (S' : Component Var) {S' ∈ A.subs.erase S''}, (Is S' (list.mem_of_mem_erase H)).satisfiesContract (A.contracts.find_val S').iget) → \n(σ ∈ (CompositeEnvironment A.to_Architecture S'' Is E)) → σ ∈ (@AssertionLang.sem Φ Var _ _ _ ((A.contracts.find_val S'').iget).A)\n\n\ndef correctDecomposition \n{S : Component Var}\n(A : ArchitectureWithContracts Φ S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : Claim (Trace Var) := \n{\n X := set.univ, \n P := \n λ σ, correctDecompositionImpl A Is σ ∧ correctDecompositionEnv A Is E σ \n}\n\nend Claim \n-- def correctDecompositionImplProperty\n-- (A : ArchWithContracts S)\n-- (Is : Implementations A) : Property (Trace Var) := λ σ,\n-- (∀ (S' : Component Var) {S' ∈ A.subs}, \n-- (∀ σ', σ' ∈ (Is S' H) ∧ σ' ∈ $\\llparenthesis$(A.contracts.get S').A$\\rrparenthesis$ \n-- → (σ' ∈ $\\llparenthesis$(A.contracts.get S').G$\\rrparenthesis$)) \n-- → ((σ ∈ CompositeImplementation A Is ∧ σ ∈ $\\llparenthesis$S.C.A$\\rrparenthesis$) \n-- → σ ∈ $\\llparenthesis$S.C.G$\\rrparenthesis$)\n\n-- def correctDecompositionEnvProperty\n-- {S : ComponentWithContract Φ Var}\n-- (A : ArchWithContracts S)\n-- (Is :Implementations A) \n-- (E : Env Var) : Property (Trace Var) :=λ σ, \n-- ∀ (S'' : Component Var),\n-- E.satisfiesContract S.C → \n-- (∀ (S' : Component Var) {S' ∈ A.subs}, \n-- (Is S' H).satisfies (A.contracts.get S')) → \n-- (σ ∈ CompositeEnvironment A S'' Is E) → \n-- σ ∈ {{((A.contracts.get S'')).A}}\ntheorem \nclaim_imp_correctDecomp\n{S : Component Var}\n(A : ArchitectureWithContracts Φ S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : \n⟦Claim.correctDecomposition A Is E⟧ → isCorrectDecomposition A Is E := \nbegin\n intro clm, \n rw meaning at clm, split, {\n intro h,\n intro s,\n replace clm := clm s, \n rw [Claim.correctDecomposition] at clm,\n simp at clm, replace clm := clm.1,\n intro h',\n cases h' with h₂ h₃,\n rw Claim.correctDecompositionImpl at clm,\n apply clm,\n intros S' S'' hMem, \n replace h := h S'',\n rw Impl.satisfiesContract at h,\n rw CompositeImplementation at h₂, simp at h₂, \n intro h'', apply h,split, exact h₂,\n exact h₃,\n }, \n {\n rintros S'' h₄ ⟨h₅, h₆⟩ s,\n replace clm := clm s, rw [Claim.correctDecomposition] at clm, \n simp at clm, replace clm := clm.2 S'' h₅ h₆, exact clm,\n rw Claim.correctDecompositionEnv at clm, assumption,\n}\nend \n\n\n\ntheorem decompCorrectImpClaim \n{S : Component Var}\n(A : ArchitectureWithContracts Φ S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : \nisCorrectDecomposition A Is E → \n⟦Claim.correctDecomposition A Is E⟧ := \nbegin \n intro h,\n rw Claim.correctDecomposition, rw meaning, simp,\n rw forall_and_distrib,\n split, \n { \n intro s, \n rw Claim.correctDecompositionImpl,\n revert s,simp,\n replace h := h.1,\n rw isCorrectDecompositionImpl at h,\n intros σ' h₂ h₃,\n rw CompositeImplementation at h₃,\n intros h₄,\n rw Impl.satisfiesContract at h,\n simp at h,\n apply h,\n intros S' h',\n replace h₂ := h₂ S' h',\n intros σ h₅, cases h₅ with L R,\n replace h₂ := h₂ σ L R, simp, \n apply h₂,split, rw CompositeImplementation, apply h₃, assumption,\n },\n {\n intros σ, intros _, intros S'' mem, \n replace h := h.2,\n rw isCorrectDecompositionEnv at h,\n simp at h,\n replace h := h S'' mem, \n intros s smem, rw Env.satisfiesContract at h, \n simp at h,\n apply h,\n intros h₂, apply s, exact smem, \n }\n\nend\n\ntheorem decompositionCorrectAsClaim \n{S : Component Var}\n(A : ArchitectureWithContracts Φ S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : \nisCorrectDecomposition A Is E ↔ ⟦Claim.correctDecomposition A Is E⟧ := \niff.intro (decompCorrectImpClaim A Is E) (claim_imp_correctDecomp A Is E)\n\n", "meta": {"author": "loganrjmurphy", "repo": "ForeMoSt", "sha": "c7affc7c8971562520d2775ac48fe4f188f84b02", "save_path": "github-repos/lean/loganrjmurphy-ForeMoSt", "path": "github-repos/lean/loganrjmurphy-ForeMoSt/ForeMoSt-c7affc7c8971562520d2775ac48fe4f188f84b02/src/Architectural/ArchitectureDecomp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5926665855647395, "lm_q2_score": 0.411110869232168, "lm_q1q2_score": 0.24365167515638111}} {"text": "import for_mathlib.category_theory.localization.predicate\n\nnoncomputable theory\n\nopen category_theory category_theory.category\n\nnamespace category_theory\n\nnamespace morphism_property\n\nnamespace is_inverted_by\n\n/-\nlemma op {C D : Type*} [category C] [category D]\n {W : morphism_property C} {L : C ⥤ D} (h : W.is_inverted_by L) :\n W.op.is_inverted_by L.op := λ X Y f hf,\nby { haveI := h f.unop hf, dsimp, apply_instance, }\n\nlemma right_op {C D : Type*} [category C] [category D]\n {W : morphism_property C} {L : Cᵒᵖ ⥤ D} (h : W.op.is_inverted_by L):\n W.is_inverted_by L.right_op := λ X Y f hf,\nby { haveI := h f.op hf, dsimp, apply_instance, }-/\n\nend is_inverted_by\n\nend morphism_property\n\nvariables {C D : Type*} [category C] [category D] {L : C ⥤ D}\n {W : morphism_property C}\n\nnamespace localization\n\ndef strict_universal_property_fixed_target.op {E : Type*} [category E]\n (h : strict_universal_property_fixed_target L W Eᵒᵖ):\n strict_universal_property_fixed_target L.op W.op E :=\n{ inverts := h.inverts.op,\n lift := λ F hF, (h.lift F.right_op hF.right_op).left_op,\n fac := λ F hF, begin\n convert congr_arg functor.left_op (h.fac F.right_op hF.right_op),\n exact F.right_op_left_op_eq.symm,\n end,\n uniq := λ F₁ F₂ eq, begin\n suffices : F₁.right_op = F₂.right_op,\n { rw [← F₁.right_op_left_op_eq, ← F₂.right_op_left_op_eq, this], },\n have eq' := congr_arg functor.right_op eq,\n exact h.uniq _ _ eq',\n end, }\n\ninstance is_localization_op : W.Q.op.is_localization W.op :=\nfunctor.is_localization.mk' W.Q.op W.op\n (strict_universal_property_fixed_target_Q W _).op\n (strict_universal_property_fixed_target_Q W _).op\n\nend localization\n\nnamespace functor\n\nvariables (L W)\n\ninstance is_localization.op [h : L.is_localization W] : L.op.is_localization W.op :=\nis_localization.of_equivalence_target W.Q.op W.op L.op (localization.equivalence_from_model L W).op\n (nat_iso.op (localization.Q_comp_equivalence_from_model_functor_iso L W).symm)\n\nend functor\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/localization/opposite.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6187804337438502, "lm_q2_score": 0.39233683016710835, "lm_q1q2_score": 0.2427703539444906}} {"text": "/-\nFile: signature_recover_public_key_validate_reduced_field_element_soundness.lean\n\nAutogenerated file.\n-/\nimport starkware.cairo.lean.semantics.soundness.hoare\nimport .signature_recover_public_key_code\nimport ..signature_recover_public_key_spec\nimport .signature_recover_public_key_assert_nn_le_soundness\nopen tactic\n\nopen starkware.cairo.common.cairo_secp.field\nopen starkware.cairo.common.cairo_secp.bigint\nopen starkware.cairo.common.math\nopen starkware.cairo.common.cairo_secp.constants\n\nvariables {F : Type} [field F] [decidable_eq F] [prelude_hyps F]\nvariable mem : F → F\nvariable σ : register_state F\n\n/- starkware.cairo.common.cairo_secp.field.validate_reduced_field_element autogenerated soundness theorem -/\n\ntheorem auto_sound_validate_reduced_field_element\n -- arguments\n (range_check_ptr : F) (val : BigInt3 F)\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_validate_reduced_field_element σ.pc)\n -- all dependencies are in memory\n (h_mem_0 : mem_at mem code_assert_nn (σ.pc - 152))\n (h_mem_1 : mem_at mem code_assert_le (σ.pc - 148))\n (h_mem_2 : mem_at mem code_assert_nn_le (σ.pc - 143))\n -- input arguments on the stack\n (hin_range_check_ptr : range_check_ptr = mem (σ.fp - 6))\n (hin_val : val = cast_BigInt3 mem (σ.fp - 5))\n -- conclusion\n : ensures_ret mem σ (λ κ τ,\n ∃ μ ≤ κ, rc_ensures mem (rc_bound F) μ (mem (σ.fp - 6)) (mem $ τ.ap - 1)\n (spec_validate_reduced_field_element mem κ range_check_ptr val (mem (τ.ap - 1)))) :=\nbegin\n apply ensures_of_ensuresb, intro νbound,\n have h_mem_rec := h_mem,\n unpack_memory code_validate_reduced_field_element at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15, hpc16, hpc17, hpc18, hpc19, hpc20, hpc21, hpc22, hpc23, hpc24, hpc25, hpc26, hpc27, hpc28, hpc29, hpc30, hpc31, hpc32, hpc33, hpc34, hpc35, hpc36, hpc37, hpc38, hpc39⟩,\n -- function call\n step_assert_eq hpc0 with arg0,\n step_assert_eq hpc1 with arg1,\n step_assert_eq hpc2 hpc3 with arg2,\n step_sub hpc4 (auto_sound_assert_nn_le mem _ range_check_ptr val.d2 P2 _ _ _ _ _ _),\n { rw hpc5, norm_num2, exact h_mem_2 },\n { rw hpc5, norm_num2, exact h_mem_0 },\n { rw hpc5, norm_num2, exact h_mem_1 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call6 ap6 h_call6,\n rcases h_call6 with ⟨h_call6_ap_offset, h_call6⟩,\n rcases h_call6 with ⟨rc_m6, rc_mle6, hl_range_check_ptr₁, h_call6⟩,\n generalize' hr_rev_range_check_ptr₁: mem (ap6 - 1) = range_check_ptr₁,\n have htv_range_check_ptr₁ := hr_rev_range_check_ptr₁.symm, clear hr_rev_range_check_ptr₁,\n try { simp only [arg0 ,arg1 ,arg2] at hl_range_check_ptr₁ },\n rw [←htv_range_check_ptr₁, ←hin_range_check_ptr] at hl_range_check_ptr₁,\n try { simp only [arg0 ,arg1 ,arg2] at h_call6 },\n rw [hin_range_check_ptr] at h_call6,\n clear arg0 arg1 arg2,\n -- function call\n step_assert_eq hpc6 with arg0,\n step_assert_eq hpc7 hpc8 with arg1,\n step_sub hpc9 (auto_sound_assert_nn_le mem _ range_check_ptr₁ val.d1 (BASE - 1) _ _ _ _ _ _),\n { rw hpc10, norm_num2, exact h_mem_2 },\n { rw hpc10, norm_num2, exact h_mem_0 },\n { rw hpc10, norm_num2, exact h_mem_1 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1] },\n try { simp only [h_call6_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1] },\n try { simp only [h_call6_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1] },\n try { simp only [h_call6_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call11 ap11 h_call11,\n rcases h_call11 with ⟨h_call11_ap_offset, h_call11⟩,\n rcases h_call11 with ⟨rc_m11, rc_mle11, hl_range_check_ptr₂, h_call11⟩,\n generalize' hr_rev_range_check_ptr₂: mem (ap11 - 1) = range_check_ptr₂,\n have htv_range_check_ptr₂ := hr_rev_range_check_ptr₂.symm, clear hr_rev_range_check_ptr₂,\n try { simp only [arg0 ,arg1] at hl_range_check_ptr₂ },\n rw [←htv_range_check_ptr₂, ←htv_range_check_ptr₁] at hl_range_check_ptr₂,\n try { simp only [arg0 ,arg1] at h_call11 },\n rw [←htv_range_check_ptr₁, hl_range_check_ptr₁, hin_range_check_ptr] at h_call11,\n clear arg0 arg1,\n -- function call\n step_assert_eq hpc11 with arg0,\n step_assert_eq hpc12 hpc13 with arg1,\n step_sub hpc14 (auto_sound_assert_nn_le mem _ range_check_ptr₂ val.d0 (BASE - 1) _ _ _ _ _ _),\n { rw hpc15, norm_num2, exact h_mem_2 },\n { rw hpc15, norm_num2, exact h_mem_0 },\n { rw hpc15, norm_num2, exact h_mem_1 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call16 ap16 h_call16,\n rcases h_call16 with ⟨h_call16_ap_offset, h_call16⟩,\n rcases h_call16 with ⟨rc_m16, rc_mle16, hl_range_check_ptr₃, h_call16⟩,\n generalize' hr_rev_range_check_ptr₃: mem (ap16 - 1) = range_check_ptr₃,\n have htv_range_check_ptr₃ := hr_rev_range_check_ptr₃.symm, clear hr_rev_range_check_ptr₃,\n try { simp only [arg0 ,arg1] at hl_range_check_ptr₃ },\n rw [←htv_range_check_ptr₃, ←htv_range_check_ptr₂] at hl_range_check_ptr₃,\n try { simp only [arg0 ,arg1] at h_call16 },\n rw [←htv_range_check_ptr₂, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call16,\n clear arg0 arg1,\n -- if statement\n step_assert_eq hpc16 hpc17 with temp0,\n have htest: _ = val.d2 - P2, {\n apply eq.trans temp0,\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃] },\n try { dsimp [cast_BigInt3] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n clear temp0,\n step_jnz hpc18 hpc19 with hcond hcond,\n {\n -- if: positive branch\n have a16 := cond_aux1 htest hcond,\n try { arith_simps at a16 },\n clear htest hcond,\n -- if statement\n step_assert_eq hpc20 hpc21 with temp0,\n have htest: _ = val.d1 - P1, {\n apply eq.trans temp0,\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃] },\n try { dsimp [cast_BigInt3] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n clear temp0,\n step_jnz hpc22 hpc23 with hcond hcond,\n {\n -- if: positive branch\n have a20 := cond_aux1 htest hcond,\n try { arith_simps at a20 },\n clear htest hcond,\n -- function call\n step_assert_eq hpc24 with arg0,\n step_assert_eq hpc25 with arg1,\n step_assert_eq hpc26 hpc27 with arg2,\n step_sub hpc28 (auto_sound_assert_nn_le mem _ range_check_ptr₃ val.d0 (P0 - 1) _ _ _ _ _ _),\n { rw hpc29, norm_num2, exact h_mem_2 },\n { rw hpc29, norm_num2, exact h_mem_0 },\n { rw hpc29, norm_num2, exact h_mem_1 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call30 ap30 h_call30,\n rcases h_call30 with ⟨h_call30_ap_offset, h_call30⟩,\n rcases h_call30 with ⟨rc_m30, rc_mle30, hl_range_check_ptr₄, h_call30⟩,\n generalize' hr_rev_range_check_ptr₄: mem (ap30 - 1) = range_check_ptr₄,\n have htv_range_check_ptr₄ := hr_rev_range_check_ptr₄.symm, clear hr_rev_range_check_ptr₄,\n try { simp only [arg0 ,arg1 ,arg2] at hl_range_check_ptr₄ },\n rw [←htv_range_check_ptr₄, ←htv_range_check_ptr₃] at hl_range_check_ptr₄,\n try { simp only [arg0 ,arg1 ,arg2] at h_call30 },\n rw [←htv_range_check_ptr₃, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call30,\n clear arg0 arg1 arg2,\n -- return\n step_ret hpc30,\n -- finish\n step_done, use_only [rfl, rfl],\n -- range check condition\n use_only (rc_m6+rc_m11+rc_m16+rc_m30+0+0), split,\n linarith [rc_mle6, rc_mle11, rc_mle16, rc_mle30],\n split,\n { arith_simps,\n rw [←htv_range_check_ptr₄, hl_range_check_ptr₄, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr],\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_validate_reduced_field_element mem _ range_check_ptr val _,\n { apply sound_validate_reduced_field_element, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_validate_reduced_field_element],\n try { norm_num1 }, try { arith_simps },\n use_only [κ_call6],\n use_only [range_check_ptr₁],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have spec6 := h_call6 rc_h_range_check_ptr',\n rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec6,\n try { dsimp at spec6, arith_simps at spec6 },\n use_only [spec6],\n use_only [κ_call11],\n use_only [range_check_ptr₂],\n have rc_h_range_check_ptr₂ := range_checked_offset' rc_h_range_check_ptr₁,\n have rc_h_range_check_ptr₂' := range_checked_add_right rc_h_range_check_ptr₂, try { norm_cast at rc_h_range_check_ptr₂' },\n have spec11 := h_call11 rc_h_range_check_ptr₁',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←htv_range_check_ptr₂] at spec11,\n try { dsimp at spec11, arith_simps at spec11 },\n use_only [spec11],\n use_only [κ_call16],\n use_only [range_check_ptr₃],\n have rc_h_range_check_ptr₃ := range_checked_offset' rc_h_range_check_ptr₂,\n have rc_h_range_check_ptr₃' := range_checked_add_right rc_h_range_check_ptr₃, try { norm_cast at rc_h_range_check_ptr₃' },\n have spec16 := h_call16 rc_h_range_check_ptr₂',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←htv_range_check_ptr₃] at spec16,\n try { dsimp at spec16, arith_simps at spec16 },\n use_only [spec16],\n left,\n use_only [a16],\n left,\n use_only [a20],\n use_only [κ_call30],\n use_only [range_check_ptr₄],\n have rc_h_range_check_ptr₄ := range_checked_offset' rc_h_range_check_ptr₃,\n have rc_h_range_check_ptr₄' := range_checked_add_right rc_h_range_check_ptr₄, try { norm_cast at rc_h_range_check_ptr₄' },\n have spec30 := h_call30 rc_h_range_check_ptr₃',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←hl_range_check_ptr₃, ←htv_range_check_ptr₄] at spec30,\n try { dsimp at spec30, arith_simps at spec30 },\n use_only [spec30],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃, htv_range_check_ptr₄] }, },\n try { dsimp [cast_BigInt3] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset, h_call30_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n {\n -- if: negative branch\n have a20 := cond_aux2 htest hcond,\n try { arith_simps at a20 },\n clear htest hcond,\n -- function call\n step_assert_eq hpc31 with arg0,\n step_assert_eq hpc32 with arg1,\n step_assert_eq hpc33 hpc34 with arg2,\n step_sub hpc35 (auto_sound_assert_nn_le mem _ range_check_ptr₃ val.d1 (P1 - 1) _ _ _ _ _ _),\n { rw hpc36, norm_num2, exact h_mem_2 },\n { rw hpc36, norm_num2, exact h_mem_0 },\n { rw hpc36, norm_num2, exact h_mem_1 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call37 ap37 h_call37,\n rcases h_call37 with ⟨h_call37_ap_offset, h_call37⟩,\n rcases h_call37 with ⟨rc_m37, rc_mle37, hl_range_check_ptr₄, h_call37⟩,\n generalize' hr_rev_range_check_ptr₄: mem (ap37 - 1) = range_check_ptr₄,\n have htv_range_check_ptr₄ := hr_rev_range_check_ptr₄.symm, clear hr_rev_range_check_ptr₄,\n try { simp only [arg0 ,arg1 ,arg2] at hl_range_check_ptr₄ },\n rw [←htv_range_check_ptr₄, ←htv_range_check_ptr₃] at hl_range_check_ptr₄,\n try { simp only [arg0 ,arg1 ,arg2] at h_call37 },\n rw [←htv_range_check_ptr₃, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call37,\n clear arg0 arg1 arg2,\n -- return\n step_ret hpc37,\n -- finish\n step_done, use_only [rfl, rfl],\n -- range check condition\n use_only (rc_m6+rc_m11+rc_m16+rc_m37+0+0), split,\n linarith [rc_mle6, rc_mle11, rc_mle16, rc_mle37],\n split,\n { arith_simps,\n rw [←htv_range_check_ptr₄, hl_range_check_ptr₄, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr],\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_validate_reduced_field_element mem _ range_check_ptr val _,\n { apply sound_validate_reduced_field_element, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_validate_reduced_field_element],\n try { norm_num1 }, try { arith_simps },\n use_only [κ_call6],\n use_only [range_check_ptr₁],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have spec6 := h_call6 rc_h_range_check_ptr',\n rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec6,\n try { dsimp at spec6, arith_simps at spec6 },\n use_only [spec6],\n use_only [κ_call11],\n use_only [range_check_ptr₂],\n have rc_h_range_check_ptr₂ := range_checked_offset' rc_h_range_check_ptr₁,\n have rc_h_range_check_ptr₂' := range_checked_add_right rc_h_range_check_ptr₂, try { norm_cast at rc_h_range_check_ptr₂' },\n have spec11 := h_call11 rc_h_range_check_ptr₁',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←htv_range_check_ptr₂] at spec11,\n try { dsimp at spec11, arith_simps at spec11 },\n use_only [spec11],\n use_only [κ_call16],\n use_only [range_check_ptr₃],\n have rc_h_range_check_ptr₃ := range_checked_offset' rc_h_range_check_ptr₂,\n have rc_h_range_check_ptr₃' := range_checked_add_right rc_h_range_check_ptr₃, try { norm_cast at rc_h_range_check_ptr₃' },\n have spec16 := h_call16 rc_h_range_check_ptr₂',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←htv_range_check_ptr₃] at spec16,\n try { dsimp at spec16, arith_simps at spec16 },\n use_only [spec16],\n left,\n use_only [a16],\n right,\n use_only [a20],\n use_only [κ_call37],\n use_only [range_check_ptr₄],\n have rc_h_range_check_ptr₄ := range_checked_offset' rc_h_range_check_ptr₃,\n have rc_h_range_check_ptr₄' := range_checked_add_right rc_h_range_check_ptr₄, try { norm_cast at rc_h_range_check_ptr₄' },\n have spec37 := h_call37 rc_h_range_check_ptr₃',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←hl_range_check_ptr₃, ←htv_range_check_ptr₄] at spec37,\n try { dsimp at spec37, arith_simps at spec37 },\n use_only [spec37],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃, htv_range_check_ptr₄] }, },\n try { dsimp [cast_BigInt3] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset, h_call37_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n }\n },\n {\n -- if: negative branch\n have a16 := cond_aux2 htest hcond,\n try { arith_simps at a16 },\n clear htest hcond,\n -- return\n step_assert_eq hpc38 with hret0,\n step_ret hpc39,\n -- finish\n step_done, use_only [rfl, rfl],\n -- range check condition\n use_only (rc_m6+rc_m11+rc_m16+0+0), split,\n linarith [rc_mle6, rc_mle11, rc_mle16],\n split,\n { arith_simps, try { simp only [hret0] },\n rw [←htv_range_check_ptr₃, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr],\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_validate_reduced_field_element mem _ range_check_ptr val _,\n { apply sound_validate_reduced_field_element, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_validate_reduced_field_element],\n try { norm_num1 }, try { arith_simps },\n use_only [κ_call6],\n use_only [range_check_ptr₁],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have spec6 := h_call6 rc_h_range_check_ptr',\n rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec6,\n try { dsimp at spec6, arith_simps at spec6 },\n use_only [spec6],\n use_only [κ_call11],\n use_only [range_check_ptr₂],\n have rc_h_range_check_ptr₂ := range_checked_offset' rc_h_range_check_ptr₁,\n have rc_h_range_check_ptr₂' := range_checked_add_right rc_h_range_check_ptr₂, try { norm_cast at rc_h_range_check_ptr₂' },\n have spec11 := h_call11 rc_h_range_check_ptr₁',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←htv_range_check_ptr₂] at spec11,\n try { dsimp at spec11, arith_simps at spec11 },\n use_only [spec11],\n use_only [κ_call16],\n use_only [range_check_ptr₃],\n have rc_h_range_check_ptr₃ := range_checked_offset' rc_h_range_check_ptr₂,\n have rc_h_range_check_ptr₃' := range_checked_add_right rc_h_range_check_ptr₃, try { norm_cast at rc_h_range_check_ptr₃' },\n have spec16 := h_call16 rc_h_range_check_ptr₂',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←htv_range_check_ptr₃] at spec16,\n try { dsimp at spec16, arith_simps at spec16 },\n use_only [spec16],\n right,\n use_only [a16],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, htv_range_check_ptr₁, htv_range_check_ptr₂, htv_range_check_ptr₃] }, },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [hret0] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call16_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n }\nend\n\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/common/cairo_secp/verification/verification/signature_recover_public_key_validate_reduced_field_element_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5544704796847395, "lm_q2_score": 0.4378234991142019, "lm_q1q2_score": 0.24276020557110264}} {"text": "import category_theory.limits.shapes.images\nimport algebraic_topology.simplex_category\nimport tactic.equiv_rw\nimport category_theory.limits.shapes.regular_mono\n\nnoncomputable theory\n/-\nuniverses u\n\nnamespace category_theory\n\nlemma concrete_category.bijective_of_is_iso {C : Type*} [category C]\n [concrete_category C] {X Y : C} (f : X ⟶ Y) [is_iso f] :\n function.bijective ((forget _).map f) :=\nby { rw ← is_iso_iff_bijective, apply_instance, }\n\nlemma strong_epi_of_is_split_epi\n {C : Type*} [category C] {A B : C} (f : A ⟶ B) [is_split_epi f] : strong_epi f :=\nstrong_epi.mk' begin\n introsI X Y z hz u v sq,\n exact comm_sq.has_lift.mk'\n { l := section_ f ≫ u,\n fac_left' := by simp only [← cancel_mono z, sq.w, category.assoc, is_split_epi.id_assoc],\n fac_right' := by simp only [sq.w, category.assoc, is_split_epi.id_assoc], }\nend\n\nvariables {C D : Type*} [category C] [category D] (F : C ⥤ D) {A B : C} (f : A ⟶ B)\n\nnamespace functor\n\ndef is_split_epi_iff [full F] [faithful F] : is_split_epi f ↔ is_split_epi (F.map f) :=\nbegin\n split,\n { intro h, refine is_split_epi.mk' ((split_epi_equiv F f).to_fun h.exists_split_epi.some), },\n { intro h, refine is_split_epi.mk' ((split_epi_equiv F f).inv_fun h.exists_split_epi.some), },\nend\n\nvariable {F}\nlemma strong_epi_imp_strong_epi_map_of_adjunction {F' : D ⥤ C} (adj : F ⊣ F') (f : A ⟶ B)\n [h₁ : preserves_monomorphisms F']\n [h₂ : preserves_epimorphisms F] :\n strong_epi f → strong_epi (F.map f) :=\nbegin\n introI hf,\n refine ⟨infer_instance, _⟩,\n intros X Y z,\n introI,\n rw has_lifting_property.iff_of_adjunction adj,\n apply_instance,\nend\n\ninstance strong_epi_map_of_is_equivalence [is_equivalence F]\n [h : strong_epi f] : strong_epi (F.map f) :=\nstrong_epi_imp_strong_epi_map_of_adjunction ((as_equivalence F).to_adjunction) f h\n\nlemma strong_epi.of_arrow_iso {A B A' B' : C} {f : A ⟶ B} {g : A' ⟶ B'}\n (e : arrow.mk f ≅ arrow.mk g) [h : strong_epi f] : strong_epi g :=\n{ epi := begin\n haveI : epi (f ≫ (arrow.right_func.map_iso e).hom) := epi_comp _ _,\n have eq : g = (arrow.left_func.map_iso e).inv ≫ f ≫\n (arrow.right_func.map_iso e).hom,\n { have eq' := arrow.hom.congr_right e.inv_hom_id,\n dsimp at eq',\n simp only [map_iso_inv, arrow.left_func_map, map_iso_hom,\n arrow.right_func_map, arrow.w_mk_right_assoc, arrow.mk_hom, eq'],\n dsimp,\n simp only [category.comp_id], },\n rw eq,\n apply epi_comp,\n end,\n llp := λ X Y z, begin\n introI,\n apply has_lifting_property.of_arrow_iso_left e z,\n end }\n\nlemma strong_epi_iff_of_arrow_iso {A B A' B' : C} {f : A ⟶ B} {g : A' ⟶ B'}\n (e : arrow.mk f ≅ arrow.mk g) : strong_epi f ↔ strong_epi g :=\nby { split; introI, exacts [strong_epi.of_arrow_iso e, strong_epi.of_arrow_iso e.symm], }\n\ndef arrow.iso_of_nat_iso {C D : Type*} [category C] [category D]\n {F G : C ⥤ D} (e : F ≅ G) (f : arrow C) :\n F.map_arrow.obj f ≅ G.map_arrow.obj f :=\narrow.iso_mk (e.app f.left) (e.app f.right) (by simp)\n\nvariable (F)\nlemma strong_epi_iff_strong_epi_map_of_is_equivalence [is_equivalence F] :\n strong_epi f ↔ strong_epi (F.map f) :=\nbegin\n split,\n { introI,\n apply_instance, },\n { introI,\n have e : arrow.mk f ≅ arrow.mk (F.inv.map (F.map f)) :=\n arrow.iso_of_nat_iso (F.as_equivalence.unit_iso) (arrow.mk f),\n rw strong_epi_iff_of_arrow_iso e,\n apply_instance, }\nend\n\nopen limits\n\ndef preimage_strong_epi_mono_factorisation (s : strong_epi_mono_factorisation (F.map f))\n [is_equivalence F] :\n strong_epi_mono_factorisation f :=\nbegin\n haveI : mono (F.preimage (F.as_equivalence.counit_iso.hom.app _ ≫ s.m)),\n { simp only [← F.mono_map_iff_mono, as_equivalence_counit, image_preimage],\n apply mono_comp, },\n haveI : strong_epi (F.preimage (s.e ≫ F.as_equivalence.counit_iso.inv.app _)),\n { simp only [← @strong_epi_map_iff_strong_epi_of_is_equivalence _ _ _ _ F,\n image_preimage, as_equivalence_counit],\n apply strong_epi_comp, },\n exact\n { I := F.inv.obj s.I,\n m := F.preimage (F.as_equivalence.counit_iso.hom.app _ ≫ s.m),\n e := F.preimage (s.e ≫ F.as_equivalence.counit_iso.inv.app _),\n m_mono := infer_instance,\n fac' := begin\n apply F.map_injective,\n simp only [map_comp, image_preimage, category.assoc, iso.inv_hom_id_app_assoc,\n mono_factorisation.fac],\n end, }\nend\n\nlemma has_strong_epi_mono_factorisations_imp [is_equivalence F]\n [h : has_strong_epi_mono_factorisations D] :\n has_strong_epi_mono_factorisations C :=\n⟨λ X Y f, begin\n apply nonempty.intro,\n apply F.preimage_strong_epi_mono_factorisation,\n let H := h.has_fac,\n exact (H (F.map f)).some,\nend⟩\n\nend functor\n\nend category_theory\n\nopen category_theory\n\nnamespace simplex_category\n\nlemma skeletal_equivalence.functor.map_eq\n {Δ₁ Δ₂ : simplex_category} (f : Δ₁ ⟶ Δ₂) :\n coe_fn (simplex_category.skeletal_equivalence.{u}.functor.map f) =\n ulift.up ∘ f.to_order_hom ∘ ulift.down := rfl\n\nlemma skeletal_equivalence.functor.surjective_iff_map\n {Δ₁ Δ₂ : simplex_category} (f : Δ₁ ⟶ Δ₂) :\n function.surjective f.to_order_hom ↔\n function.surjective\n (simplex_category.skeletal_equivalence.{u}.functor.map f) :=\nby rw [skeletal_equivalence.functor.map_eq,\n function.surjective.of_comp_iff' ulift.up_bijective, function.surjective.of_comp_iff _ ulift.down_surjective]\n\nlemma skeletal_equivalence.functor.injective_iff_map\n {Δ₁ Δ₂ : simplex_category} (f : Δ₁ ⟶ Δ₂) :\n function.injective f.to_order_hom ↔\n function.injective\n (simplex_category.skeletal_equivalence.{u}.functor.map f) :=\nby rw [skeletal_equivalence.functor.map_eq, function.injective.of_comp_iff ulift.up_injective,\n function.injective.of_comp_iff' _ ulift.down_bijective]\n\nend simplex_category\n\nnamespace NonemptyFinLinOrd\n\nlemma epi_iff_surjective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) :\n epi f ↔ function.surjective f :=\nbegin\n have eq := simplex_category.skeletal_equivalence.counit_iso.hom.naturality f,\n simp only [← cancel_mono (simplex_category.skeletal_equivalence.counit_iso.inv.app B),\n category.assoc, iso.hom_inv_id_app, category.comp_id, functor.id_map] at eq,\n rw [← simplex_category.skeletal_equivalence.inverse.epi_map_iff_epi,\n simplex_category.epi_iff_surjective,\n simplex_category.skeletal_equivalence.functor.surjective_iff_map,\n ← functor.comp_map, eq, coe_comp, coe_comp,\n function.surjective.of_comp_iff, function.surjective.of_comp_iff'],\n { apply concrete_category.bijective_of_is_iso, },\n { apply function.bijective.surjective,\n apply concrete_category.bijective_of_is_iso, },\nend\n\ninstance : split_epi_category NonemptyFinLinOrd.{u} :=\n⟨λ X Y f hf, begin\n have H : ∀ (y : Y), nonempty (f⁻¹' { y }),\n { rw epi_iff_surjective at hf,\n intro y,\n exact nonempty.intro ⟨(hf y).some, (hf y).some_spec⟩, },\n let φ : Y → X := λ y, (H y).some.1,\n have hφ : ∀ (y : Y), f (φ y) = y := λ y, (H y).some.2,\n refine is_split_epi.mk' ⟨⟨φ, _⟩, _⟩, swap,\n { ext b,\n apply hφ, },\n { intros a b,\n contrapose,\n intro h,\n simp only [not_le] at h ⊢,\n suffices : b ≤ a,\n { cases this.lt_or_eq with h₁ h₂,\n { assumption, },\n { exfalso,\n simpa only [h₂, lt_self_iff_false] using h, }, },\n simpa only [hφ] using f.monotone (le_of_lt h), },\nend⟩\n\nlemma mono_iff_injective {A B : NonemptyFinLinOrd.{u}} {f : A ⟶ B} :\n mono f ↔ function.injective f :=\nbegin\n have eq := simplex_category.skeletal_equivalence.counit_iso.hom.naturality f,\n simp only [← cancel_mono (simplex_category.skeletal_equivalence.counit_iso.inv.app B),\n category.assoc, iso.hom_inv_id_app, category.comp_id, functor.id_map] at eq,\n rw [← simplex_category.skeletal_equivalence.inverse.mono_map_iff_mono,\n simplex_category.mono_iff_injective,\n simplex_category.skeletal_equivalence.functor.injective_iff_map,\n ← functor.comp_map, eq, coe_comp, coe_comp,\n function.injective.of_comp_iff', function.injective.of_comp_iff],\n { apply function.bijective.injective,\n apply concrete_category.bijective_of_is_iso, },\n { apply concrete_category.bijective_of_is_iso, },\nend\n\n@[protected, simps]\ndef strong_epi_mono_factorisation {X Y : NonemptyFinLinOrd.{u}} (f : X ⟶ Y) :\n limits.strong_epi_mono_factorisation f :=\nbegin\n let I : NonemptyFinLinOrd.{u} := ⟨set.image (coe_fn f) ⊤, ⟨⟩⟩,\n let e : X ⟶ I := ⟨λ x, ⟨f x, ⟨x, by tidy⟩⟩, λ x₁ x₂ h, f.monotone h⟩,\n let m : I ⟶ Y := ⟨λ y, y, by tidy⟩,\n haveI : epi e,\n { rw epi_iff_surjective, tidy, },\n haveI : strong_epi e := strong_epi_of_epi e,\n haveI : mono m,\n { rw mono_iff_injective, tidy, },\n exact\n { I := I,\n m := m,\n e := e, },\nend\n\ninstance : limits.has_strong_epi_mono_factorisations NonemptyFinLinOrd.{u} :=\n⟨λ X Y f, nonempty.intro (NonemptyFinLinOrd.strong_epi_mono_factorisation f)⟩\n\nend NonemptyFinLinOrd\n\nnamespace simplex_category\n\nopen category_theory.limits\n\ninstance : split_epi_category simplex_category :=\n⟨λ X Y f, begin\n introI,\n rw ← simplex_category.skeletal_equivalence.{0}.functor.is_split_epi_iff,\n apply is_split_epi_of_epi,\nend⟩\n\n@[protected]\nlemma has_strong_epi_mono_factorisations : has_strong_epi_mono_factorisations simplex_category :=\nsimplex_category.skeletal_functor.has_strong_epi_mono_factorisations_imp.{0}\n\nattribute [instance] has_strong_epi_mono_factorisations\n\nlemma image_eq {Δ Δ' Δ'' : simplex_category } {φ : Δ ⟶ Δ''}\n {e : Δ ⟶ Δ'} [epi e] {i : Δ' ⟶ Δ''} [mono i] (fac : e ≫ i = φ) :\n image φ = Δ' :=\nbegin\n haveI := strong_epi_of_epi e,\n let eq := image.iso_strong_epi_mono e i fac,\n ext,\n apply le_antisymm,\n { exact @len_le_of_epi _ _ eq.hom infer_instance, },\n { exact @len_le_of_mono _ _ eq.hom infer_instance, },\nend\n\nlemma image_ι_eq {Δ Δ'' : simplex_category } {φ : Δ ⟶ Δ''}\n {e : Δ ⟶ image φ} [epi e] {i : image φ ⟶ Δ''} [mono i] (fac : e ≫ i = φ) :\n image.ι φ = i :=\nbegin\n haveI := strong_epi_of_epi e,\n rw ← image.iso_strong_epi_mono_hom_comp_ι e i fac,\n conv_lhs { rw ← category.id_comp (image.ι φ), },\n congr,\n symmetry,\n apply simplex_category.eq_id_of_is_iso,\n apply_instance,\nend\n\nlemma factor_thru_image_eq {Δ Δ'' : simplex_category } {φ : Δ ⟶ Δ''}\n {e : Δ ⟶ image φ} [epi e] {i : image φ ⟶ Δ''} [mono i] (fac : e ≫ i = φ) :\n factor_thru_image φ = e :=\nby rw [← cancel_mono i, fac, ← image_ι_eq fac, image.fac]\n\nend simplex_category\n-/\n", "meta": {"author": "joelriou", "repo": "dold-kan", "sha": "a083fe264275774ac49ac520caf25f2ee29debb1", "save_path": "github-repos/lean/joelriou-dold-kan", "path": "github-repos/lean/joelriou-dold-kan/dold-kan-a083fe264275774ac49ac520caf25f2ee29debb1/src/for_mathlib/simplex_category/factorisations.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.43398146480389854, "lm_q1q2_score": 0.24230356684122378}} {"text": "\nimport .refinement.one_to_one\n\nuniverse variables u u₀ u₁ u₂\n\nnamespace temporal\nnamespace feasibility\nopen fairness predicate nat\nlocal infix ` ≃ `:75 := v_eq\nsection feasibility\n\nparameters {α : Type u}\nparameters {evt : Type u₂}\nparameters {p : pred' α}\nparameters (A : evt → act α)\nparameters {cs₀ fs₀ : evt → pred' α}\nparameters (J : pred' α)\nparameters [inhabited evt] [inhabited α]\n\nparameter init_FIS : ∃ s, s ⊨ p\nparameter init_INV : ∀ s, s ⊨ p → s ⊨ J\nparameter DLF : ∀ s, s ⊨ J → ∃ e, s ⊨ cs₀ e ∧ s ⊨ fs₀ e\nparameter evt_FIS : ∀ e s, s ⊨ J → s ⊨ cs₀ e → s ⊨ fs₀ e → ∃ s', A e s s'\nparameter evt_INV : ∀ e s s', A e s s' → s ⊨ J → s' ⊨ J\n\ndef SPEC₀ (v : tvar α) : cpred :=\nspec p cs₀ fs₀ A v\n\ndef p' : pred' (unit × α) :=\np ! pair.snd\n\ndef q' : pred' (unit × unit) :=\nTrue\n\nopen prod\ndef A' (e : evt) : act (unit × α) :=\nλ σ σ',\n (A e on snd) σ σ'\n\ndef C (e : evt) : act (unit × unit) :=\nλ _ _, true\n\ndef C' (e : evt) : act (evt × unit × unit) :=\nλ ⟨sch,_⟩ _, sch = e\n\nabbreviation J' : pred' (unit × α × unit) :=\nJ ! pair.fst ! pair.snd\n\nabbreviation cs₀' (e : evt) : pred' (unit × α) :=\ncs₀ e ! pair.snd\n\nabbreviation fs₀' (e : evt) : pred' (unit × α) :=\nfs₀ e ! pair.snd\n\nabbreviation cs₁ (e : evt) : pred' (unit × unit) :=\nTrue\n\nabbreviation fs₁ (e : evt) : pred' (unit × unit) :=\nTrue\nsection\ninclude init_FIS init_INV DLF\nlemma SIM₀' (v o : unit)\n (h : (o, v) ⊨ q')\n: (∃ (w : α), (o, w) ⊨ p' ∧ (o, w, v) ⊨ J') :=\nby { simp [q',p'] at *,\n apply exists_imp_exists _ init_FIS,\n intros, split, assumption, apply init_INV, assumption }\nend\nopen function\nsection\ninclude evt_FIS evt_INV DLF\nlemma SIM' (w : α) (v o v' o' : unit) (e : evt)\n (hJ : (o, w, v) ⊨ J')\n (_ : true)\n (_ : true)\n (_ : true)\n (hC : C e (o, v) (o', v'))\n: (∃ (w' : α),\n (o,w) ⊨ cs₀' e ∧\n (o,w) ⊨ fs₀' e ∧\n A' e (o, w) (o', w') ∧\n (o', w', v') ⊨ J') :=\nbegin\n -- simp [comp,A',on_fun] at *,\n -- casesm* [_ ∧ _, Exists _, unit],\n -- constructor_matching* [_ ∧ _],\n -- apply exists_imp_exists _ (evt_FIS e w _),\n -- intros, split, admit, assumption,\n -- tauto,\n admit,\nend\n\nend\n\ndef o : tvar unit := ↑()\n\n-- parameter Hpo\n-- : ∀ c a e, one_to_one_po' (SPEC₀.saf a o ⋀ ◻(J ! ⦃o,a,c⦄))\n-- ⟨cs₁ e,fs₁ e,C' e⟩\n-- ⟨cs₀ e,fs₀ e,A' e⟩ ⦃o,c⦄ ⦃o,a⦄)\n\ndef SPEC₀.saf' (v : tvar α) (sch : tvar evt) : cpred :=\nspec_saf_spec p' cs₀' fs₀' A' ⦃o,v⦄ sch\n\ndef SPEC₁ (v : tvar unit) : cpred :=\nspec q' cs₁ fs₁ C ⦃o,v⦄\n\nlemma Hpo'\n : ∀ c a e sch, one_to_one_po' (SPEC₁ c ⋀ SPEC₀.saf' a sch ⋀ ◻(J' ! ⦃o,a,c⦄))\n ⟨cs₁ e!pair.snd,fs₁ e!pair.snd,one_to_one.C' C e⟩\n ⟨cs₀' e,fs₀' e,A' e⟩ ⦃sch,o,c⦄ ⦃o,a⦄ :=\nbegin\n intros,\n constructor,\n { simp [tl_leads_to], },\n { simp [tl_leads_to], },\n { simp [tl_leads_to], },\n begin [temporal]\n simp [SPEC₁,q',sched,SPEC₀.saf'],\n intros _ _ _ h _, henceforth! at *,\n intros, cases h with x h,\n explicit' [C,one_to_one.C',A']\n with h a_3\n { cc },\n end,\nend\n\ninclude J init_INV init_FIS evt_INV evt_FIS Hpo' DLF\nlemma feasibility [schedulable evt]\n: ⊩ (∃∃ v, SPEC₀ v) :=\nbegin [temporal]\n have := temporal.feasibility.SIM',\n have := @one_to_one.refinement α unit unit evt\n temporal.feasibility.p' temporal.feasibility.q'\n temporal.feasibility.A'\n temporal.feasibility.C\n temporal.feasibility.cs₀'\n temporal.feasibility.fs₀'\n temporal.feasibility.cs₁\n temporal.feasibility.fs₁\n temporal.feasibility.J' True _ _\n _ _\n temporal.feasibility.SIM₀'\n temporal.feasibility.SIM'\n o _ _ Γ _,\n { simp [one_to_one.SPEC₀,SPEC₀] at this ⊢,\n casesm* [p_exists _, _ ⋀ _],\n existsi _, solve_by_elim,\n split,\n { simp [A',p',action_on' _ _ prod.snd] at *,\n tauto, },\n { simp [A',action_on' _ _ prod.snd] at *,\n assumption, }, },\n { intros, simp, },\n { intros, simp, },\n apply temporal.feasibility.Hpo' ,\n { existsi o,\n simp [one_to_one.SPEC₁,q',C,C',sched], }\nend\n\nend feasibility\nend feasibility\nend temporal\n", "meta": {"author": "unitb", "repo": "temporal-logic", "sha": "accec04d1b09ca841be065511c9e206b725b16e9", "save_path": "github-repos/lean/unitb-temporal-logic", "path": "github-repos/lean/unitb-temporal-logic/temporal-logic-accec04d1b09ca841be065511c9e206b725b16e9/src/temporal_logic/feasibility.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.40356685373537454, "lm_q1q2_score": 0.24221612779523757}} {"text": "import tactic\nimport data.finsupp.basic\nimport control.bifunctor\nimport verification.misc\nimport verification.semantics.stream_props\nimport verification.semantics.finsuppeval\n\nopen_locale classical\nnoncomputable theory\n\nvariables {ι : Type} {α : Type*}\n[linear_order ι]\n\n@[mk_iff]\nstructure Stream.mul.ready {ι : Type} (a : Stream ι α) (b : Stream ι α) (s : a.σ × b.σ) : Prop :=\n(v₁ : a.valid s.1)\n(v₂ : b.valid s.2)\n(r₁ : a.ready s.1)\n(r₂ : b.ready s.2)\n(index : a.index s.1 v₁ = b.index s.2 v₂)\n\nsection defs\nvariables [has_mul α]\n\n@[simps]\ninstance : has_mul (Stream ι α) := ⟨λ (a b : Stream ι α),\n{ σ := a.σ × b.σ,\n valid := λ p, a.valid p.1 ∧ b.valid p.2,\n ready := λ p, Stream.mul.ready a b p,\n next := λ p hv,\n if a.to_order p.1 ≤ b.to_order p.2 then\n (a.next p.1 hv.1, p.2)\n else (p.1, b.next p.2 hv.2),\n index := λ p hv, max (a.index p.1 hv.1) (b.index p.2 hv.2),\n value := λ p hr, a.value p.1 hr.r₁ * b.value p.2 hr.r₂ }⟩\n\nend defs\n\n\nsection index_lemmas\nvariables [has_mul α]\n\nlemma Stream.mul.ready.index' {a : Stream ι α} {b : Stream ι α} {x y} (h : (a * b).ready (x, y)) :\n a.index' x = b.index' y :=\nby simp [Stream.index'_val h.v₁, Stream.index'_val h.v₂, h.index]\n\nlemma Stream.mul.ready.order_eq {a : Stream ι α} {b : Stream ι α} {x y} (h : (a * b).ready (x, y)) :\n a.to_order x = b.to_order y :=\nby ext : 1; simp [h.r₁, h.r₂, h.index']\n\nlemma Stream.mul_index' (a : Stream ι α) (b : Stream ι α) (xy : a.σ × b.σ) :\n (a * b).index' xy = max (a.index' xy.1) (b.index' xy.2) :=\nbegin\n cases xy with x y,\n rw [Stream.index'], simp, split_ifs with h,\n { simp [Stream.index'_val h.1, Stream.index'_val h.2], },\n rw not_and_distrib at h, cases h; simp [Stream.index'_invalid h],\nend\n\nend index_lemmas\n\nsection value_lemmas\n\nvariables [non_unital_non_assoc_semiring α]\n\nlemma Stream.mul_eval₀_of_neq {a : Stream ι α} {b : Stream ι α} {x y} (h : a.to_order x ≠ b.to_order y) (H) :\n (a * b).eval₀ (x, y) H = 0 :=\nby { contrapose! h, apply Stream.mul.ready.order_eq, simp [Stream.eval₀] at h, exact h.fst, }\n\nlemma Stream.mul_eval₀ (a : Stream ι α) (b : Stream ι α) (x : a.σ) (y : b.σ) (H) :\n (a * b).eval₀ (x, y) H = (a.eval₀ x H.1) * (b.eval₀ y H.2) :=\nbegin\n rw [Stream.eval₀], split_ifs with hr,\n { simp [Stream.eval₀, hr.r₁, hr.r₂, hr.index], },\n simp [Stream.mul.ready_iff, H.1, H.2] at hr,\n simp [Stream.eval₀], split_ifs with h₁ h₂; try { simp },\n rw finsupp.mul_single_eq_zero _ _ (hr h₁ h₂),\nend\n\n/-- This lemma states that if `a.to_order x ≤ b.to_order y`, \n then the support of `a.eval₀ x h₁` (which is at most `{a.index x}`) \n is disjoint from `b.eval_steps n (b.next y)`, assuming `b` is simple. -/\nlemma Stream.mul_eq_zero_aux {a : Stream ι α} {b : Stream ι α} (hb : b.simple) {x : a.σ} {y : b.σ}\n (h₁ : a.valid x) (h₂ : b.valid y) (H : a.to_order x ≤ b.to_order y) (n : ℕ) :\n disjoint (a.eval₀ x h₁).support (b.eval_steps n (b.next y h₂)).support :=\nbegin\n -- Assume `a` is ready, or else `a.eval₀ x h₁ = 0` has trivial support.\n by_cases hr : a.ready x, swap, { simp [Stream.eval₀, hr], },\n rw finset.disjoint_iff_ne,\n intros i₁ hi₁ i₂ hi₂,\n cases finset.mem_singleton.mp (a.eval₀_support _ _ hi₁),\n rw le_iff_eq_or_lt at H,\n refine ne_of_lt (with_top.coe_lt_coe.mp _), rw ← Stream.index'_val h₁,\n cases H,\n { -- `a.to_order x = b.to_order y`\n simp [prod.ext_iff, hr] at H,\n rw H.1,\n exact hb.index_lt_support h₂ H.2 _ hi₂, },\n -- Case `a < b`\n refine lt_of_lt_of_le (prod.lex.fst_lt_of_lt_of_le H (by simp [hr])) _,\n exact (hb.monotonic h₂).trans (hb.monotonic.index_le_support _ hi₂),\nend\n\nlemma Stream.mul_eq_zero {a : Stream ι α} {b : Stream ι α} (hb : b.simple) {x : a.σ} {y : b.σ}\n (h₁ : a.valid x) (h₂ : b.valid y) (H : a.to_order x ≤ b.to_order y) (n : ℕ) :\n a.eval₀ x h₁ * b.eval_steps n (b.next y h₂) = 0 :=\nby { rw [finsupp.mul_eq_zero_of_disjoint_support], exact Stream.mul_eq_zero_aux hb h₁ h₂ H n, }\n\nlemma Stream.mul_eq_zero' {a : Stream ι α} {b : Stream ι α} (ha : a.simple) {x : a.σ} {y : b.σ}\n (h₁ : a.valid x) (h₂ : b.valid y) (H : b.to_order y ≤ a.to_order x) (n : ℕ) :\n a.eval_steps n (a.next x h₁) * b.eval₀ y h₂ = 0 :=\nby { rw [finsupp.mul_eq_zero_of_disjoint_support], exact (Stream.mul_eq_zero_aux ha h₂ h₁ H n).symm, }\n\nend value_lemmas\n\n\n@[elab_as_eliminator]\ntheorem Stream.mul_induction [has_mul α] {a : Stream ι α} {b : Stream ι α} {x : a.σ} {y : b.σ}\n {B₁ B₂ : ℕ} (ha : a.bound_valid B₁ x) (hb : b.bound_valid B₂ y)\n (P : ∀ (x : a.σ) (y : b.σ) (k₁ : ℕ) (k₂ : ℕ) (N : ℕ), Prop)\n (hP_base : ∀ (x y), P x y 0 0 0)\n (hP_invalid : ∀ (x y B₁ B₂ N) (H : ¬(a * b).valid (x, y)) (hvx : ¬a.valid x ∨ ¬b.valid y), a.bound_valid B₁ x → b.bound_valid B₂ y → P x y B₁ B₂ N)\n (hP_advance_a : ∀ (x y k₁ k₂ N) (H : (a * b).valid (x, y)), a.to_order x ≤ b.to_order y → P (a.next x H.1) y k₁ (k₂ + 1) N → P x y (k₁ + 1) (k₂ + 1) (N + 1))\n (hP_advance_b : ∀ (x y k₁ k₂ N) (H : (a * b).valid (x, y)), b.to_order y < a.to_order x → P x (b.next y H.2) (k₁ + 1) k₂ N → P x y (k₁ + 1) (k₂ + 1) (N + 1)) :\n P x y B₁ B₂ (B₁ + B₂) :=\nbegin\n suffices : ∀ n, n = B₁ + B₂ → ∃ (k₁ k₂ : ℕ), k₁ ≤ B₁ ∧ k₂ ≤ B₂ ∧ n = k₁ + k₂ ∧ P x y k₁ k₂ n,\n { obtain ⟨k₁, k₂, hk₁, hk₂, hn, he⟩ := this (B₁ + B₂) rfl,\n obtain ⟨rfl, rfl⟩ : k₁ = B₁ ∧ k₂ = B₂ := by split; linarith only [hk₁, hk₂, hn],\n exact he, },\n intros n hn,\n induction n with n ih generalizing B₁ B₂ x y,\n { use [0, 0], simpa using hP_base x y, },\n by_cases H : (a * b).valid (x, y), swap,\n { refine ⟨B₁, B₂, rfl.le, rfl.le, hn, hP_invalid _ _ _ _ _ H _ ha hb⟩, \n simpa [not_and_distrib] using H, },\n cases B₁, { cases H.1.bound_pos ha, },\n cases B₂, { cases H.2.bound_pos hb, },\n simp [nat.succ_eq_add_one, ← add_assoc] at hn,\n by_cases h : a.to_order x ≤ b.to_order y,\n { -- Advance `a` (i.e. `a` ≤ `b`)\n rw [Stream.bound_valid_succ] at ha,\n obtain ⟨k₁, k₂, hk₁, hk₂, rfl, he⟩ := ih (ha H.1) hb (hn.trans (add_right_comm _ _ _)),\n refine ⟨k₁ + 1, k₂, nat.succ_le_succ hk₁, hk₂, (add_right_comm k₁ k₂ 1), _⟩,\n cases k₂, { exfalso, linarith only [hn, hk₁], },\n apply hP_advance_a _ _ _ _ _ H h he, },\n { -- Advance `b` (i.e. `b < a`)\n rw [Stream.bound_valid_succ] at hb,\n obtain ⟨k₁, k₂, hk₁, hk₂, rfl, he⟩ := ih ha (hb H.2) hn,\n refine ⟨k₁, k₂ + 1, hk₁, nat.succ_le_succ hk₂, rfl, _⟩,\n cases k₁, { exfalso, linarith only [hn, hk₂], },\n apply hP_advance_b _ _ _ _ _ H (lt_of_not_le h) he, }\nend\n\ntheorem Stream.mul_spec_value [non_unital_non_assoc_semiring α] {a : Stream ι α} {b : Stream ι α} (hsa : a.simple) (hsb : b.simple)\n {x y B₁ B₂} (ha : a.bound_valid B₁ x) (hb : b.bound_valid B₂ y) :\n (a * b).eval_steps (B₁ + B₂) (x, y) = (a.eval_steps B₁ x) * (b.eval_steps B₂ y) :=\nbegin\n apply Stream.mul_induction ha hb (λ x y k₁ k₂ N, (a * b).eval_steps N (x, y) = (a.eval_steps k₁ x) * (b.eval_steps k₂ y)); clear_except hsa hsb,\n { intros, simp, },\n { intros x y B₁ B₂ N H h ha hb,\n cases h; simp [H, Stream.eval_invalid h, Stream.eval_invalid H], },\n { intros x y k₁ k₂ n H h he,\n simp [H, H.1, h, he, add_mul], congr,\n simp [H.2, mul_add, Stream.mul_eq_zero hsb H.1 H.2 h, Stream.mul_eval₀], },\n { intros x y k₁ k₂ n H h he,\n simp [H, H.2, h.not_le, he, mul_add], congr,\n simp [H.1, add_mul, Stream.mul_eval₀, Stream.mul_eq_zero' hsa H.1 H.2 h.le], },\nend\n\ntheorem Stream.mul_spec_index [has_mul α] {a : Stream ι α} {b : Stream ι α}\n {x y B₁ B₂} (ha : a.bound_valid B₁ x) (hb : b.bound_valid B₂ y) :\n ((a * b).valid ((a * b).next'^[B₁ + B₂] (x, y)) → ((a * b).next'^[B₁ + B₂] (x, y)) = (a.next'^[B₁] x, b.next'^[B₂] y)) :=\nbegin\n apply Stream.mul_induction ha hb (λ x y k₁ k₂ N, (a * b).valid ((a * b).next'^[N] (x, y)) → ((a * b).next'^[N] (x, y)) = (a.next'^[k₁] x, b.next'^[k₂] y)); clear_except hsa hsb,\n { intros, simp, },\n { intros x y B₁ B₂ N H h ha hb, simp only [Stream.next'_val_invalid' H], exact false.elim ∘ H, },\n { intros x y k₁ k₂ n H h hiter,\n simp only [Stream.next'_val H, function.iterate_succ_apply, Stream.has_mul_mul_next, h, if_true, Stream.next'_val H.1],\n exact hiter, },\n { intros x y k₁ k₂ n H h hiter,\n simp only [Stream.next'_val H, function.iterate_succ_apply, Stream.has_mul_mul_next, h.not_le, if_false, Stream.next'_val H.2],\n exact hiter, },\nend\n\n@[simps]\ninstance {ι : Type} {α : Type*} [linear_order ι] [has_mul α] : has_mul (StreamExec ι α) := ⟨λ a b,\n{ stream := a.stream * b.stream,\n state := (a.state, b.state),\n bound := a.bound + b.bound,\n bound_valid := begin\n rw [bound_valid_iff_next'_iterate],\n intro H,\n have := Stream.mul_spec_index a.bound_valid b.bound_valid H,\n dsimp at H, simp [this] at H,\n -- In fact, either `a` or `b` having a valid bound makes `a * b` have a valid bound\n -- We make an arbitrary choice here to use `a`\n refine absurd H.1 _,\n rw [← bound_valid_iff_next'_iterate],\n exact a.bound_valid,\n end }⟩\n\nlemma StreamExec.mul_spec [non_unital_non_assoc_semiring α] (a : StreamExec ι α) (b : StreamExec ι α) (ha : a.stream.simple) (hb : b.stream.simple) :\n (a * b).eval = a.eval * b.eval := Stream.mul_spec_value ha hb a.bound_valid b.bound_valid\n\nlemma Stream.mul_is_monotonic [has_mul α] {a : Stream ι α} {b : Stream ι α} (hsa : a.monotonic) (hsb : b.monotonic) :\n (a * b).monotonic :=\nbegin\n rintros ⟨x, y⟩ H,\n simp only [Stream.mul_index'],\n refine max_le_max _ _; simp; split_ifs,\n any_goals { exact rfl.le, },\n exacts [hsa _, hsb _],\nend\n\nlemma Stream.mul_is_simple [has_mul α] {a : Stream ι α} {b : Stream ι α} (hsa : a.simple) (hsb : b.simple) :\n (a * b).simple :=\nbegin\n refine ⟨Stream.mul_is_monotonic hsa.monotonic hsb.monotonic, _⟩,\n rintros ⟨x, y⟩ hv hr,\n simp only [Stream.mul_index', hr.index', max_self, Stream.has_mul_mul_next],\n split_ifs with H,\n { simp only [← hr.index', ne, max_ne_self_iff'], exact hsa.index_lt_next _ hr.r₁, },\n { simp only [hr.index', ne, max_ne_self_iff], exact hsb.index_lt_next _ hr.r₂, },\nend\n\n@[simps]\ninstance {ι : Type} {α : Type*} [linear_order ι] [has_mul α] : has_mul (SimpleStream ι α) := ⟨λ a b,\n{ simple := Stream.mul_is_simple a.simple b.simple,\n ..(@has_mul.mul (StreamExec ι α) _ a b) }⟩\n\nlemma SimpleStream.coe_mul {ι : Type} {α : Type*} [linear_order ι] [has_mul α] (a b : SimpleStream ι α) :\n (↑(a * b) : StreamExec ι α) = (↑a) * (↑b) := rfl\n\ninstance SimpleStream.MulEval [non_unital_non_assoc_semiring α] : MulEval (SimpleStream ι α) ι α :=\n{ hmul := λ a b, StreamExec.mul_spec a b a.simple b.simple }\n\nsection\n\nlemma mul_value_eval {ι α ι' α' : Type*} [linear_order ι] [non_unital_non_assoc_semiring α'] [MulEval α ι' α'] \n (a b : StreamExec ι α) :\n (Eval.eval <$₂> (a * b)) = (Eval.eval <$₂> a) * (Eval.eval <$₂> b) :=\nbegin\n ext; solve_refl,\n { simp only [Stream.mul.ready_iff], refl, },\n { simp, refl, },\nend\n\n-- huh??\ninstance {ι α ι' α' : Type*} [linear_order ι] [non_unital_non_assoc_semiring α'] [MulEval α ι' α'] :\n Eval (SimpleStream ι α) ι (ι' →₀ α') := SimpleStream.Eval_ind\n\ninstance {ι α ι' α' : Type*} [linear_order ι] [non_unital_non_assoc_semiring α'] [MulEval α ι' α'] :\n MulEval (SimpleStream ι α) ι (ι' →₀ α') :=\n{ hmul := λ x y, by { simp [Eval.eval, mul_value_eval, SimpleStream.coe_mul], rw StreamExec.mul_spec, exacts [⟨x.monotonic, x.reduced⟩, ⟨y.monotonic, y.reduced⟩], } }\n\nend\n", "meta": {"author": "kovach", "repo": "etch", "sha": "26ef67eb83cf7c5cfd1667059e16c3873b9098ca", "save_path": "github-repos/lean/kovach-etch", "path": "github-repos/lean/kovach-etch/etch-26ef67eb83cf7c5cfd1667059e16c3873b9098ca/src/verification/semantics/stream_multiply.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.24214893705561955}} {"text": "import for_mathlib.category_theory.triangulated.yoneda\nimport for_mathlib.category_theory.triangulated.triangles\nimport category_theory.triangulated.triangulated\n\nnoncomputable theory\n\nnamespace category_theory\n\nopen limits category preadditive triangulated\nopen_locale zero_object\n\nvariables {C : Type*} [category C] [preadditive C] [has_zero_object C] [has_shift C ℤ]\n [∀ (n : ℤ), functor.additive (shift_functor C n)] [pretriangulated C]\n\nnamespace triangulated\n\nopen pretriangulated\n\nvariables {X₁ X₂ X₃ Z₁₂ Z₂₃ Z₁₃ : C} (u₁₂ : X₁ ⟶ X₂) (u₂₃ : X₂ ⟶ X₃) (u₁₃ : X₁ ⟶ X₃)\n (comm : u₁₂ ≫ u₂₃ = u₁₃)\n {v₁₂ : X₂ ⟶ Z₁₂} {w₁₂ : Z₁₂ ⟶ X₁⟦(1 : ℤ)⟧} (h₁₂ : triangle.mk u₁₂ v₁₂ w₁₂ ∈ dist_triang C)\n {v₂₃ : X₃ ⟶ Z₂₃} {w₂₃ : Z₂₃ ⟶ X₂⟦(1 : ℤ)⟧} (h₂₃ : triangle.mk u₂₃ v₂₃ w₂₃ ∈ dist_triang C)\n {v₁₃ : X₃ ⟶ Z₁₃} {w₁₃ : Z₁₃ ⟶ X₁⟦(1 : ℤ)⟧} (h₁₃ : triangle.mk u₁₃ v₁₃ w₁₃ ∈ dist_triang C)\n\nlemma octahedron.of_iso {X₁' X₂' X₃' Z₁₂' Z₂₃' Z₁₃' : C} (u₁₂' : X₁' ⟶ X₂') (u₂₃' : X₂' ⟶ X₃')\n (e₁ : X₁ ≅ X₁') (e₂ : X₂ ≅ X₂')(e₃ : X₃ ≅ X₃')\n (comm₁₂ : u₁₂ ≫ e₂.hom = e₁.hom ≫ u₁₂') (comm₂₃ : u₂₃ ≫ e₃.hom = e₂.hom ≫ u₂₃')\n (v₁₂' : X₂' ⟶ Z₁₂') (w₁₂' : Z₁₂' ⟶ X₁'⟦(1 : ℤ)⟧)\n (h₁₂' : triangle.mk u₁₂' v₁₂' w₁₂' ∈ dist_triang C)\n (v₂₃' : X₃' ⟶ Z₂₃') (w₂₃' : Z₂₃' ⟶ X₂'⟦(1 : ℤ)⟧)\n (h₂₃' : triangle.mk u₂₃' v₂₃' w₂₃' ∈ dist_triang C)\n (v₁₃' : X₃' ⟶ Z₁₃') (w₁₃' : Z₁₃' ⟶ X₁'⟦(1 : ℤ)⟧)\n (h₁₃' : triangle.mk (u₁₂' ≫ u₂₃') v₁₃' w₁₃' ∈ dist_triang C)\n (H : octahedron rfl h₁₂' h₂₃' h₁₃') : octahedron comm h₁₂ h₂₃ h₁₃ :=\nbegin\n let iso₁₂ := iso_triangle_of_distinguished_of_is_iso₁₂ _ _ h₁₂ h₁₂' e₁ e₂ comm₁₂,\n let iso₂₃ := iso_triangle_of_distinguished_of_is_iso₁₂ _ _ h₂₃ h₂₃' e₂ e₃ comm₂₃,\n let iso₁₃ := iso_triangle_of_distinguished_of_is_iso₁₂ _ _ h₁₃ h₁₃' e₁ e₃\n (by { dsimp, simp only [← comm, assoc, comm₂₃, reassoc_of comm₁₂], }),\n have eq₁₂ := iso₁₂.hom.comm₂,\n have eq₁₂' := iso₁₂.hom.comm₃,\n have eq₁₃ := iso₁₃.hom.comm₂,\n have eq₁₃' := iso₁₃.hom.comm₃,\n have eq₂₃ := iso₂₃.hom.comm₂,\n have eq₂₃' := iso₂₃.hom.comm₃,\n have rel₁₂ := H.triangle_morphism₁.comm₂,\n have rel₁₃ := H.triangle_morphism₁.comm₃,\n have rel₂₂ := H.triangle_morphism₂.comm₂,\n have rel₂₃ := H.triangle_morphism₂.comm₃,\n dsimp at eq₁₂ eq₁₂' eq₁₃ eq₁₃' eq₂₃ eq₂₃' rel₁₂ rel₁₃ rel₂₂ rel₂₃,\n rw [functor.map_id, comp_id] at rel₁₃,\n rw id_comp at rel₂₂,\n refine ⟨iso₁₂.hom.hom₃ ≫ H.m₁ ≫ iso₁₃.inv.hom₃,\n iso₁₃.hom.hom₃ ≫ H.m₃ ≫ iso₂₃.inv.hom₃, _, _, _, _, _⟩,\n { simp only [reassoc_of eq₁₂, ← cancel_mono iso₁₃.hom.hom₃, assoc,\n iso₁₃.triangle_inv_hom_id₃, eq₁₃, reassoc_of comm₂₃, ← rel₁₂],\n dsimp,\n rw comp_id, },\n { rw [← cancel_mono ((shift_functor C (1 : ℤ)).map e₁.hom), eq₁₂', assoc, assoc, assoc, eq₁₃',\n iso₁₃.triangle_inv_hom_id₃_assoc, ← rel₁₃], },\n { rw [reassoc_of eq₁₃, reassoc_of rel₂₂, ← cancel_mono iso₂₃.hom.hom₃, assoc, assoc,\n iso₂₃.triangle_inv_hom_id₃, eq₂₃],\n dsimp,\n rw comp_id, },\n { rw [← cancel_mono ((shift_functor C (1 : ℤ)).map e₂.hom), assoc, assoc, assoc, assoc, eq₂₃',\n iso₂₃.triangle_inv_hom_id₃_assoc, ← rel₂₃, ← functor.map_comp, comm₁₂, functor.map_comp,\n reassoc_of eq₁₃'], },\n { refine pretriangulated.isomorphic_distinguished _ H.mem _ _,\n refine triangle.mk_iso _ _ iso₁₂.triangle_eval₃ iso₁₃.triangle_eval₃ iso₂₃.triangle_eval₃\n _ _ _ ,\n { dsimp, erw [assoc, assoc, iso.triangle_inv_hom_id₃, comp_id], },\n { dsimp, erw [assoc, assoc, iso.triangle_inv_hom_id₃, comp_id], },\n { dsimp, erw [assoc, ← functor.map_comp, eq₁₂, functor.map_comp, reassoc_of eq₂₃'], }, },\nend\n\n\nend triangulated\n\nopen pretriangulated triangulated\n\nlemma is_triangulated.mk' (h : ∀ ⦃X₁' X₂' X₃' : C⦄ (u₁₂' : X₁' ⟶ X₂') (u₂₃' : X₂' ⟶ X₃'),\n ∃ (X₁ X₂ X₃ Z₁₂ Z₂₃ Z₁₃ : C) (u₁₂ : X₁ ⟶ X₂) (u₂₃ : X₂ ⟶ X₃) (e₁ : X₁' ≅ X₁) (e₂ : X₂' ≅ X₂)\n (e₃ : X₃' ≅ X₃) (comm₁₂ : u₁₂' ≫ e₂.hom = e₁.hom ≫ u₁₂)\n (comm₂₃ : u₂₃' ≫ e₃.hom = e₂.hom ≫ u₂₃)\n (v₁₂ : X₂ ⟶ Z₁₂) (w₁₂ : Z₁₂ ⟶ X₁⟦1⟧) (h₁₂ : triangle.mk u₁₂ v₁₂ w₁₂ ∈ dist_triang C)\n (v₂₃ : X₃ ⟶ Z₂₃) (w₂₃ : Z₂₃ ⟶ X₂⟦1⟧) (h₂₃ : triangle.mk u₂₃ v₂₃ w₂₃ ∈ dist_triang C)\n (v₁₃ : X₃ ⟶ Z₁₃) (w₁₃ : Z₁₃ ⟶ X₁⟦1⟧)\n (h₁₃ : triangle.mk (u₁₂ ≫ u₂₃) v₁₃ w₁₃ ∈ dist_triang C),\n nonempty (octahedron rfl h₁₂ h₂₃ h₁₃)) : is_triangulated C :=\n⟨λ X₁' X₂' X₃' Z₁₂' Z₂₃' Z₁₃' u₁₂' u₂₃' u₁₃' comm' v₁₂' w₁₂' h₁₂' v₂₃' w₂₃' h₂₃'\n v₁₃' w₁₃' h₁₃', begin\n obtain ⟨X₁, X₂, X₃, Z₁₂, Z₂₃, Z₁₃, u₁₂, u₂₃, e₁, e₂, e₃, comm₁₂, comm₂₃,\n v₁₂, w₁₂, h₁₂, v₂₃, w₂₃, h₂₃, v₁₃, w₁₃, h₁₃, H⟩ := h u₁₂' u₂₃',\n exact ⟨octahedron.of_iso _ _ _ _ _ _ _ u₁₂ u₂₃ e₁ e₂ e₃ comm₁₂ comm₂₃ v₁₂ w₁₂ h₁₂\n v₂₃ w₂₃ h₂₃ v₁₃ w₁₃ h₁₃ H.some⟩\nend⟩\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/triangulated/triangulated.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.38861802670584894, "lm_q1q2_score": 0.2418989169963072}} {"text": "/-\nCopyright (c) 2020 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\n\nimport tactic.norm_num\nimport tactic.linarith\nimport tactic.omega\nimport control.lawful_fix\nimport order.category.omega_complete_partial_order\nimport data.nat.basic\n\nuniverses u_1 u_2\n\nnamespace part.examples\nopen function has_fix omega_complete_partial_order\n\n/-! `easy` is a trivial, non-recursive example -/\n\ndef easy.intl (easy : ℕ → ℕ → part ℕ) : ℕ → ℕ → part ℕ\n| x y := pure x\n\ndef easy :=\nfix easy.intl\n\n-- automation coming soon\ntheorem easy.cont : continuous' easy.intl :=\npi.omega_complete_partial_order.flip₂_continuous' easy.intl\n (λ x, pi.omega_complete_partial_order.flip₂_continuous' _ (λ x_1, const_continuous' (pure x)))\n\n-- automation coming soon\ntheorem easy.equations.eqn_1 (x y : ℕ) : easy x y = pure x :=\nby rw [easy, lawful_fix.fix_eq' easy.cont]; refl\n\n/-! division on natural numbers -/\n\ndef div.intl (div : ℕ → ℕ → part ℕ) : ℕ → ℕ → part ℕ\n| x y :=\nif y ≤ x ∧ y > 0\n then div (x - y) y\n else pure x\n\ndef div : ℕ → ℕ → part ℕ :=\nfix div.intl\n\n-- automation coming soon\ntheorem div.cont : continuous' div.intl :=\npi.omega_complete_partial_order.flip₂_continuous' div.intl\n (λ (x : ℕ),\n pi.omega_complete_partial_order.flip₂_continuous' (λ (g : ℕ → ℕ → part ℕ), div.intl g x)\n (λ (x_1 : ℕ),\n (continuous_hom.ite_continuous' (λ (x_2 : ℕ → ℕ → part ℕ), x_2 (x - x_1) x_1)\n (λ (x_1 : ℕ → ℕ → part ℕ), pure x)\n (pi.omega_complete_partial_order.flip₁_continuous'\n (λ (v_1 : ℕ) (x_2 : ℕ → ℕ → part ℕ), x_2 (x - x_1) v_1) _ $\n pi.omega_complete_partial_order.flip₁_continuous'\n (λ (v : ℕ) (g : ℕ → ℕ → part ℕ) (x : ℕ), g v x) _ id_continuous')\n (const_continuous' (pure x)))))\n\n-- automation coming soon\ntheorem div.equations.eqn_1 (x y : ℕ) : div x y = if y ≤ x ∧ y > 0 then div (x - y) y else pure x :=\nby conv_lhs { rw [div, lawful_fix.fix_eq' div.cont] }; refl\n\ninductive tree (α : Type*)\n| nil {} : tree\n| node (x : α) : tree → tree → tree\n\nopen part.examples.tree\n\n/-! `map` on a `tree` using monadic notation -/\ndef tree_map.intl {α β : Type*} (f : α → β) (tree_map : tree α → part (tree β)) :\n tree α → part (tree β)\n| nil := pure nil\n| (node x t₀ t₁) :=\ndo tt₀ ← tree_map t₀,\n tt₁ ← tree_map t₁,\n pure $ node (f x) tt₀ tt₁\n\n-- automation coming soon\ndef tree_map {α : Type u_1} {β : Type u_2} (f : α → β) : tree α → part (tree β) :=\nfix (tree_map.intl f)\n\n-- automation coming soon\ntheorem tree_map.cont :\n ∀ {α : Type u_1} {β : Type u_2} (f : α → β), continuous' (tree_map.intl f) :=\nλ {α : Type u_1} {β : Type u_2} (f : α → β),\n pi.omega_complete_partial_order.flip₂_continuous' (tree_map.intl f)\n (λ (x : tree α),\n tree.cases_on x (id (const_continuous' (pure nil)))\n (λ (x_x : α) (x_a x_a_1 : tree α),\n (continuous_hom.bind_continuous' (λ (x : tree α → part (tree β)), x x_a)\n (λ (x : tree α → part (tree β)) (tt₀ : tree β),\n x x_a_1 >>= λ (tt₁ : tree β), pure (node (f x_x) tt₀ tt₁))\n (pi.omega_complete_partial_order.flip₁_continuous' (λ (v : tree α) (x : tree α → part (tree β)), x v) x_a id_continuous')\n (pi.omega_complete_partial_order.flip₂_continuous'\n (λ (x : tree α → part (tree β)) (tt₀ : tree β),\n x x_a_1 >>= λ (tt₁ : tree β), pure (node (f x_x) tt₀ tt₁))\n (λ (x : tree β),\n continuous_hom.bind_continuous' (λ (x : tree α → part (tree β)), x x_a_1)\n (λ (x_1 : tree α → part (tree β)) (tt₁ : tree β), pure (node (f x_x) x tt₁))\n (pi.omega_complete_partial_order.flip₁_continuous' (λ (v : tree α) (x : tree α → part (tree β)), x v) x_a_1\n id_continuous')\n (pi.omega_complete_partial_order.flip₂_continuous'\n (λ (x_1 : tree α → part (tree β)) (tt₁ : tree β), pure (node (f x_x) x tt₁))\n (λ (x_1 : tree β), const_continuous' (pure (node (f x_x) x x_1)))))))))\n\n-- automation coming soon\ntheorem tree_map.equations.eqn_1 {α : Type u_1} {β : Type u_2} (f : α → β) :\n tree_map f nil = pure nil :=\nby rw [tree_map,lawful_fix.fix_eq' (tree_map.cont f)]; refl\n\n-- automation coming soon\ntheorem tree_map.equations.eqn_2 {α : Type u_1} {β : Type u_2} (f : α → β) (x : α)\n (t₀ t₁ : tree α) :\n tree_map f (node x t₀ t₁) = tree_map f t₀ >>= λ (tt₀ : tree β), tree_map f t₁ >>=\n λ (tt₁ : tree β), pure (node (f x) tt₀ tt₁) :=\nby conv_lhs { rw [tree_map,lawful_fix.fix_eq' (tree_map.cont f)] }; refl\n\n/-! `map` on a `tree` using applicative notation -/\n\ndef tree_map'.intl {α β} (f : α → β) (tree_map : tree α → part (tree β)) :\n tree α → part (tree β)\n| nil := pure nil\n| (node x t₀ t₁) :=\nnode (f x) <$> tree_map t₀ <*> tree_map t₁\n\n-- automation coming soon\ndef tree_map' {α : Type u_1} {β : Type u_2} (f : α → β) : tree α → part (tree β) :=\nfix (tree_map'.intl f)\n\n-- automation coming soon\ntheorem tree_map'.cont :\n ∀ {α : Type u_1} {β : Type u_2} (f : α → β), continuous' (tree_map'.intl f) :=\nλ {α : Type u_1} {β : Type u_2} (f : α → β),\n pi.omega_complete_partial_order.flip₂_continuous' (tree_map'.intl f)\n (λ (x : tree α),\n tree.cases_on x (id (const_continuous' (pure nil)))\n (λ (x_x : α) (x_a x_a_1 : tree α),\n (continuous_hom.seq_continuous' (λ (x : tree α → part (tree β)), node (f x_x) <$> x x_a)\n (λ (x : tree α → part (tree β)), x x_a_1)\n (continuous_hom.map_continuous' (node (f x_x)) (λ (x : tree α → part (tree β)), x x_a)\n (pi.omega_complete_partial_order.flip₁_continuous' (λ (v : tree α) (x : tree α → part (tree β)), x v) x_a id_continuous'))\n (pi.omega_complete_partial_order.flip₁_continuous' (λ (v : tree α) (x : tree α → part (tree β)), x v) x_a_1 id_continuous'))))\n\n-- automation coming soon\ntheorem tree_map'.equations.eqn_1 {α : Type u_1} {β : Type u_2} (f : α → β) :\n tree_map' f nil = pure nil :=\nby rw [tree_map',lawful_fix.fix_eq' (tree_map'.cont f)]; refl\n\n-- automation coming soon\ntheorem tree_map'.equations.eqn_2 {α : Type u_1} {β : Type u_2} (f : α → β) (x : α) (t₀ t₁ : tree α) :\n tree_map' f (node x t₀ t₁) = node (f x) <$> tree_map' f t₀ <*> tree_map' f t₁ :=\nby conv_lhs { rw [tree_map',lawful_fix.fix_eq' (tree_map'.cont f)] }; refl\n\n/-! f91 is a function whose proof of termination cannot rely on the structural\nordering of its arguments and does not use the usual well-founded order\non natural numbers. It is an interesting candidate to show that `fix` lets us disentangle\nthe issue of termination from the definition of the function. -/\n\ndef f91.intl (f91 : ℕ → part ℕ) (n : ℕ) : part ℕ :=\nif n > 100\n then pure $ n - 10\n else f91 (n + 11) >>= f91\n\n-- automation coming soon\ndef f91 : ℕ → part ℕ := fix f91.intl\n\n-- automation coming soon\nlemma f91.cont : continuous' f91.intl :=\npi.omega_complete_partial_order.flip₂_continuous' f91.intl\n (λ (x : ℕ),\n id\n (continuous_hom.ite_continuous' (λ (x_1 : ℕ → part ℕ), pure (x - 10)) (λ (x_1 : ℕ → part ℕ), x_1 (x + 11) >>= x_1)\n (const_continuous' (pure (x - 10)))\n (continuous_hom.bind_continuous' (λ (x_1 : ℕ → part ℕ), x_1 (x + 11)) (λ (x : ℕ → part ℕ), x)\n (pi.omega_complete_partial_order.flip₁_continuous' (λ (v : ℕ) (x : ℕ → part ℕ), x v) (x + 11) id_continuous')\n (pi.omega_complete_partial_order.flip₂_continuous' (λ (x : ℕ → part ℕ), x)\n (λ (x_1 : ℕ), pi.omega_complete_partial_order.flip₁_continuous' (λ (v : ℕ) (g : ℕ → part ℕ), g v) x_1 id_continuous')))))\n.\n-- automation coming soon\ntheorem f91.equations.eqn_1 (n : ℕ) : f91 n = ite (n > 100) (pure (n - 10)) (f91 (n + 11) >>= f91) :=\nby conv_lhs { rw [f91, lawful_fix.fix_eq' f91.cont] }; refl\n\nlemma f91_spec (n : ℕ) : (∃ n', n < n' + 11 ∧ n' ∈ f91 n) :=\nbegin\n apply well_founded.induction (measure_wf $ λ n, 101 - n) n,\n clear n, dsimp [measure,inv_image], intros n ih,\n by_cases h' : n > 100,\n { rw [part.examples.f91.equations.eqn_1,if_pos h'],\n existsi n - 10, rw tsub_add_eq_add_tsub, norm_num [pure],\n apply le_of_lt, transitivity 100, norm_num, exact h' },\n { rw [part.examples.f91.equations.eqn_1,if_neg h'],\n simp, rcases ih (n + 11) _ with ⟨n',hn₀,hn₁⟩,\n rcases ih (n') _ with ⟨n'',hn'₀,hn'₁⟩,\n refine ⟨n'',_,_,hn₁,hn'₁⟩,\n { clear ih hn₁ hn'₁, omega },\n { clear ih hn₁, omega },\n { clear ih, omega } },\nend\n\nlemma f91_dom (n : ℕ) : (f91 n).dom :=\nby rw part.dom_iff_mem; apply exists_imp_exists _ (f91_spec n); simp\n\ndef f91' (n : ℕ) : ℕ := (f91 n).get (f91_dom n)\n\nrun_cmd guard (f91' 109 = 99)\n\nlemma f91_spec' (n : ℕ) : f91' n = if n > 100 then n - 10 else 91 :=\nbegin\n suffices : (∃ n', n' ∈ f91 n ∧ n' = if n > 100 then n - 10 else 91),\n { dsimp [f91'], rw part.get_eq_of_mem,\n rcases this with ⟨n,_,_⟩, subst n, assumption },\n apply well_founded.induction (measure_wf $ λ n, 101 - n) n,\n clear n, dsimp [measure,inv_image], intros n ih,\n by_cases h' : n > 100,\n { rw [part.examples.f91.equations.eqn_1,if_pos h',if_pos h'],\n simp [pure] },\n { rw [part.examples.f91.equations.eqn_1,if_neg h',if_neg h'],\n simp, rcases ih (n + 11) _ with ⟨n',hn'₀,hn'₁⟩,\n split_ifs at hn'₁,\n { subst hn'₁, norm_num at hn'₀, refine ⟨_,hn'₀,_⟩,\n rcases ih (n+1) _ with ⟨n',hn'₀,hn'₁⟩,\n split_ifs at hn'₁,\n { subst n', convert hn'₀, clear hn'₀ hn'₀ ih, omega },\n { subst n', exact hn'₀ },\n { clear ih hn'₀, omega } },\n { refine ⟨_,hn'₀,_⟩, subst n',\n rcases ih 91 _ with ⟨n',hn'₀,hn'₁⟩,\n rw if_neg at hn'₁, subst n', exact hn'₀,\n { clear ih hn'₀ hn'₀, omega, },\n { clear ih hn'₀, omega, } },\n { clear ih, omega } }\nend\n\nend part.examples\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/test/general_recursion.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166195971441, "lm_q2_score": 0.47268347662043286, "lm_q1q2_score": 0.2418799907956336}} {"text": "import for_mathlib.algebra.homology.k_projective\nimport category_theory.abelian.injective\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n\nnamespace category_theory\n\nnamespace short_complex\n\nvariables {C : Type*} [category C] [has_zero_morphisms C]\n (S : short_complex C) [has_homology S]\n\ndef homology_op_iso : S.op.homology ≅ opposite.op S.homology :=\nbegin\n let h := S.some_homology_data,\n exact h.op.homology_iso ≪≫ h.iso.op ≪≫ h.homology_iso.op,\nend\n\nend short_complex\n\nend category_theory\n\nopen category_theory\n\nnamespace cochain_complex\n\nvariables {C : Type*} [category C] [abelian C]\n\nnamespace op_equivalence\n\n@[simps]\ndef op_obj (K : cochain_complex C ℤ) :\n cochain_complex Cᵒᵖ ℤ :=\n{ X := λ n, opposite.op (K.X (-n)),\n d := λ n m, (K.d _ _).op,\n shape' := λ i j hij, begin\n rw K.shape,\n { refl, },\n { simp only [complex_shape.up_rel] at ⊢ hij,\n intro h,\n apply hij,\n linarith, },\n end,\n d_comp_d' := λ i j k hij hjk,\n by simpa only [← op_comp, homological_complex.d_comp_d], }\n\n@[simps]\ndef unop_obj (K : cochain_complex Cᵒᵖ ℤ) :\n cochain_complex C ℤ :=\n{ X := λ n, opposite.unop (K.X (-n)),\n d := λ n m, (K.d _ _).unop,\n shape' := λ i j hij, begin\n rw K.shape,\n { refl, },\n { simp only [complex_shape.up_rel] at ⊢ hij,\n intro h,\n apply hij,\n linarith, },\n end,\n d_comp_d' := λ i j k hij hjk,\n by simpa only [← unop_comp, homological_complex.d_comp_d], }\n\n@[simps]\ndef unop_op_obj (K : cochain_complex C ℤ) :\n unop_obj (op_obj K) ≅ K :=\nhomological_complex.hom.iso_of_components\n (λ n, homological_complex.X_iso_of_eq K (by linarith)) (by tidy)\n\n@[simps]\ndef op_unop_obj (K : cochain_complex Cᵒᵖ ℤ) :\n op_obj (unop_obj K) ≅ K :=\nhomological_complex.hom.iso_of_components\n (λ n, homological_complex.X_iso_of_eq K (by linarith)) (by tidy)\n\nvariable (C)\n\n@[simps]\ndef functor : (cochain_complex C ℤ)ᵒᵖ ⥤ cochain_complex Cᵒᵖ ℤ :=\n{ obj := λ K, op_obj (opposite.unop K) ,\n map := λ K L φ,\n { f := λ n, (φ.unop.f (-n)).op,\n comm' := λ i j hij, begin\n dsimp,\n simp only [← op_comp, homological_complex.hom.comm],\n end, }, }\n\n@[simps]\ndef inverse : cochain_complex Cᵒᵖ ℤ ⥤ (cochain_complex C ℤ)ᵒᵖ :=\n{ obj := λ K, opposite.op (unop_obj K),\n map := λ K L φ, quiver.hom.op\n { f := λ n, (φ.f (-n)).unop,\n comm' := λ i j hij, begin\n dsimp,\n simp only [← unop_comp, homological_complex.hom.comm],\n end, }, }\n\n@[simps]\ndef unit_iso :\n 𝟭 (cochain_complex C ℤ)ᵒᵖ ≅ op_equivalence.functor C ⋙ op_equivalence.inverse C :=\nnat_iso.of_components (λ K, (unop_op_obj (opposite.unop K)).op)\n (λ K L f, quiver.hom.unop_inj begin\n ext n,\n dsimp,\n symmetry,\n apply homological_complex.X_iso_of_eq_hom_naturality f.unop,\n end)\n\n@[simps]\ndef counit_iso :\n op_equivalence.inverse C ⋙ op_equivalence.functor C ≅ 𝟭 (cochain_complex Cᵒᵖ ℤ) :=\nnat_iso.of_components (λ K, (op_unop_obj K))\n (λ K L f, begin\n ext n,\n dsimp,\n apply homological_complex.X_iso_of_eq_hom_naturality f,\n end)\n\nend op_equivalence\n\nvariable (C)\n\n@[simps]\ndef op_equivalence : (cochain_complex C ℤ)ᵒᵖ ≌ cochain_complex Cᵒᵖ ℤ :=\n{ functor := op_equivalence.functor C,\n inverse := op_equivalence.inverse C,\n unit_iso := op_equivalence.unit_iso C,\n counit_iso := op_equivalence.counit_iso C,\n functor_unit_iso_comp' := λ K, begin\n ext n,\n dsimp [homological_complex.X_iso_of_eq],\n simp only [eq_to_hom_op, eq_to_hom_trans, eq_to_hom_refl],\n end, }\n\nvariable {C}\n\nlemma op_obj_is_strictly_le (K : cochain_complex C ℤ) (n : ℤ) [K.is_strictly_ge (-n)] :\n (op_equivalence.op_obj K).is_strictly_le n :=\n⟨λ i hi, (cochain_complex.is_strictly_ge.is_zero K (-n) (-i) (by linarith)).op⟩\n\nlemma op_obj_is_strictly_ge (K : cochain_complex C ℤ) (n : ℤ) [K.is_strictly_le (-n)] :\n (op_equivalence.op_obj K).is_strictly_ge n :=\n⟨λ i hi, (cochain_complex.is_strictly_le.is_zero K (-n) (-i) (by linarith)).op⟩\n\nlemma unop_obj_is_strictly_le (K : cochain_complex Cᵒᵖ ℤ) (n : ℤ) [K.is_strictly_ge (-n)] :\n (op_equivalence.unop_obj K).is_strictly_le n :=\n⟨λ i hi, (cochain_complex.is_strictly_ge.is_zero K (-n) (-i) (by linarith)).unop⟩\n\nlemma unop_obj_is_strictly_ge (K : cochain_complex Cᵒᵖ ℤ) (n : ℤ) [K.is_strictly_le (-n)] :\n (op_equivalence.unop_obj K).is_strictly_ge n :=\n⟨λ i hi, (cochain_complex.is_strictly_le.is_zero K (-n) (-i) (by linarith)).unop⟩\n\ndef unop_homotopy {K L : cochain_complex C ℤ} {f₁ f₂ : K ⟶ L}\n (h : homotopy ((op_equivalence.functor C).map f₁.op) ((op_equivalence.functor C).map f₂.op)) :\n homotopy f₁ f₂ :=\n{ hom := λ i j, (K.X_iso_of_eq (by simp)).hom ≫ (h.hom (-j) (-i)).unop ≫\n (L.X_iso_of_eq (by simp)).hom,\n zero' := λ i j hij, begin\n rw [h.zero, unop_zero, zero_comp, comp_zero],\n simp only [complex_shape.up_rel] at hij ⊢,\n intro h,\n apply hij,\n linarith,\n end,\n comm := λ n, quiver.hom.op_inj begin\n obtain ⟨m, rfl⟩ : ∃ (m : ℤ), n = -m := ⟨-n, by rw neg_neg n⟩,\n have eq := h.comm m,\n have eq₁ : (complex_shape.up ℤ).rel m (m+1) := rfl,\n have eq₂ : (complex_shape.up ℤ).rel (m-1) m := by simp,\n have eq₃ : (complex_shape.up ℤ).rel (-m) (-(m-1)),\n { simp only [neg_sub, complex_shape.up_rel], linarith, },\n have eq₄ : (complex_shape.up ℤ).rel (-(m+1)) (-m) := by simp,\n rw [d_next_eq _ eq₁, prev_d_eq _ eq₂] at eq,\n rw [d_next_eq _ eq₃, prev_d_eq _ eq₄],\n dsimp at eq ⊢,\n rw eq,\n have eq₅ : ∀ (a a' b b' : ℤ) (ha : a = a') (hb : b = b'),\n h.hom a b = eq_to_hom (by rw ha) ≫ h.hom a' b' ≫ eq_to_hom (by rw hb),\n { intros a a' b b' ha hb,\n substs ha hb,\n simp only [eq_to_hom_refl, id_comp, comp_id], },\n conv_lhs { congr, rw add_comm, },\n congr' 3;\n { dsimp [homological_complex.X_iso_of_eq],\n simp only [assoc, eq_to_hom_op],\n exact eq₅ _ _ _ _ (neg_neg _).symm (neg_neg _).symm, },\n end, }\n\ndef homology_op_iso (K : cochain_complex C ℤ) (n : ℤ) :\n (op_equivalence.op_obj K).homology n ≅ opposite.op (K.homology (-n)) :=\nbegin\n have r₁ : (complex_shape.up ℤ).rel (-(n+1)) (-n) := by simp,\n have r₂ : (complex_shape.up ℤ).rel (-n) (-(n-1)) := by { rw complex_shape.up_rel, linarith, },\n have r₃ : (complex_shape.up ℤ).rel (n-1) n := by simp,\n have r₄ : (complex_shape.up ℤ).rel n (n+1) := by simp,\n refine _ ≪≫ short_complex.homology_op_iso _ ≪≫\n (short_complex.homology_map_iso\n ((homological_complex.short_complex_functor_nat_iso C _ r₁ r₂).app K)).op,\n exact short_complex.homology_map_iso\n ((homological_complex.short_complex_functor_nat_iso Cᵒᵖ _ r₃ r₄).app ((op_equivalence.op_obj K))),\nend\n\nlemma acyclic_op {K : cochain_complex C ℤ} (hK : homological_complex.acyclic K) :\n homological_complex.acyclic (op_equivalence.op_obj K) :=\nλ n, is_zero.of_iso (hK (-n)).op (homology_op_iso K n)\n\nend cochain_complex\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebra/homology/cochain_complex_opposites.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.24186162614190215}} {"text": "import o_minimal.sheaf.yoneda\n\nnamespace o_minimal\n\nvariables {R : Type*} (S : struc R)\n\nclass is_good_uncurry' (α β γ : Type*) [function.has_uncurry α β γ]\n [definable_sheaf S α] [definable_sheaf S β] [definable_sheaf S γ] :=\n(definable_iff : ∀ (K : Def S) (f : K → α),\n definable S f ↔ definable S (λ k, ↿(f k)))\n\ninstance base.is_good_uncurry' {α β : Type*}\n [definable_sheaf S α] [definable_sheaf S β] : is_good_uncurry' S (α → β) α β :=\n⟨λ K f, iff.rfl⟩\n\ninstance induction.is_good_uncurry' {α β γ δ : Type*} [function.has_uncurry β γ δ]\n [definable_sheaf S α] [definable_sheaf S β] [definable_sheaf S γ] [definable_sheaf S δ] :\n is_good_uncurry' S (α → β) (α × γ) δ :=\nbegin\n refine ⟨λ K f, _⟩,\n change _ ↔ definable S (λ k, function.uncurry (λ a c, ↿(f k a) c)),\n split; intro H,\n { begin [defin]\n intro k,\n app, exact definable.uncurry.definable _,\n intro a,\n intro c,\n app,\n exact sorry,\n var,\n end\n},\n { let g := λ k, function.uncurry (λ a c, ↿(f k a) c),\n change definable S g at H,\n sorry }\nend\n\nclass is_good_uncurry (α β γ : Type*) [function.has_uncurry α β γ]\n [definable_sheaf S α]\n [has_coordinates R β] [is_definable S β]\n [has_coordinates R γ] [is_definable S γ] :=\n(x : @is_good_uncurry' R S α β γ _ _ definable_sheaf.rep definable_sheaf.rep)\n\nvariables {S}\n\nlemma definable_iff_uncurry' {α β γ : Type*} [function.has_uncurry α β γ]\n [definable_sheaf S α]\n [has_coordinates R β] [is_definable S β]\n [has_coordinates R γ] [is_definable S γ]\n [i : is_good_uncurry S α β γ]\n {f : α} :\n definable S f ↔ def_fun S ↿f :=\nbegin\n letI : definable_sheaf S β := definable_sheaf.rep,\n letI : definable_sheaf S γ := definable_sheaf.rep,\n letI : definable_rep S β := ⟨λ _ _, iff.rfl⟩,\n letI : definable_rep S γ := ⟨λ _ _, iff.rfl⟩,\n letI := i.x,\n sorry -- exact (is_good_uncurry'.definable_iff f).trans definable_iff_def_fun\nend\n\nend o_minimal\n", "meta": {"author": "rwbarton", "repo": "lean-omin", "sha": "fd733c6d95ef6f4743aae97de5e15df79877c00e", "save_path": "github-repos/lean/rwbarton-lean-omin", "path": "github-repos/lean/rwbarton-lean-omin/lean-omin-fd733c6d95ef6f4743aae97de5e15df79877c00e/omin/uncurry.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.4301473485858429, "lm_q1q2_score": 0.24181873129329282}} {"text": "/-\nCopyright (c) 2018 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.isomorphism\nimport category_theory.functor.category\nimport category_theory.functor.fully_faithful\n\n/-!\n# Whiskering\n\n> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.\n> Any changes to this file require a corresponding PR to mathlib4.\n\nGiven a functor `F : C ⥤ D` and functors `G H : D ⥤ E` and a natural transformation `α : G ⟶ H`,\nwe can construct a new natural transformation `F ⋙ G ⟶ F ⋙ H`,\ncalled `whisker_left F α`. This is the same as the horizontal composition of `𝟙 F` with `α`.\n\nThis operation is functorial in `F`, and we package this as `whiskering_left`. Here\n`(whiskering_left.obj F).obj G` is `F ⋙ G`, and\n`(whiskering_left.obj F).map α` is `whisker_left F α`.\n(That is, we might have alternatively named this as the \"left composition functor\".)\n\nWe also provide analogues for composition on the right, and for these operations on isomorphisms.\n\nAt the end of the file, we provide the left and right unitors, and the associator,\nfor functor composition.\n(In fact functor composition is definitionally associative, but very often relying on this causes\nextremely slow elaboration, so it is better to insert it explicitly.)\nWe also show these natural isomorphisms satisfy the triangle and pentagon identities.\n-/\n\nnamespace category_theory\n\nuniverses u₁ v₁ u₂ v₂ u₃ v₃ u₄ v₄\n\nsection\nvariables {C : Type u₁} [category.{v₁} C]\n {D : Type u₂} [category.{v₂} D]\n {E : Type u₃} [category.{v₃} E]\n\n/--\nIf `α : G ⟶ H` then\n`whisker_left F α : (F ⋙ G) ⟶ (F ⋙ H)` has components `α.app (F.obj X)`.\n-/\n@[simps] def whisker_left (F : C ⥤ D) {G H : D ⥤ E} (α : G ⟶ H) : (F ⋙ G) ⟶ (F ⋙ H) :=\n{ app := λ X, α.app (F.obj X),\n naturality' := λ X Y f, by rw [functor.comp_map, functor.comp_map, α.naturality] }\n\n/--\nIf `α : G ⟶ H` then\n`whisker_right α F : (G ⋙ F) ⟶ (G ⋙ F)` has components `F.map (α.app X)`.\n-/\n@[simps] def whisker_right {G H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) : (G ⋙ F) ⟶ (H ⋙ F) :=\n{ app := λ X, F.map (α.app X),\n naturality' := λ X Y f,\n by rw [functor.comp_map, functor.comp_map, ←F.map_comp, ←F.map_comp, α.naturality] }\n\nvariables (C D E)\n\n/--\nLeft-composition gives a functor `(C ⥤ D) ⥤ ((D ⥤ E) ⥤ (C ⥤ E))`.\n\n`(whiskering_left.obj F).obj G` is `F ⋙ G`, and\n`(whiskering_left.obj F).map α` is `whisker_left F α`.\n-/\n@[simps] def whiskering_left : (C ⥤ D) ⥤ ((D ⥤ E) ⥤ (C ⥤ E)) :=\n{ obj := λ F,\n { obj := λ G, F ⋙ G,\n map := λ G H α, whisker_left F α },\n map := λ F G τ,\n { app := λ H,\n { app := λ c, H.map (τ.app c),\n naturality' := λ X Y f, begin dsimp, rw [←H.map_comp, ←H.map_comp, ←τ.naturality] end },\n naturality' := λ X Y f, begin ext, dsimp, rw [f.naturality] end } }\n\n/--\nRight-composition gives a functor `(D ⥤ E) ⥤ ((C ⥤ D) ⥤ (C ⥤ E))`.\n\n`(whiskering_right.obj H).obj F` is `F ⋙ H`, and\n`(whiskering_right.obj H).map α` is `whisker_right α H`.\n-/\n@[simps] def whiskering_right : (D ⥤ E) ⥤ ((C ⥤ D) ⥤ (C ⥤ E)) :=\n{ obj := λ H,\n { obj := λ F, F ⋙ H,\n map := λ _ _ α, whisker_right α H },\n map := λ G H τ,\n { app := λ F,\n { app := λ c, τ.app (F.obj c),\n naturality' := λ X Y f, begin dsimp, rw [τ.naturality] end },\n naturality' := λ X Y f, begin ext, dsimp, rw [←nat_trans.naturality] end } }\n\nvariables {C} {D} {E}\n\ninstance faithful_whiskering_right_obj {F : D ⥤ E} [faithful F] :\n faithful ((whiskering_right C D E).obj F) :=\n{ map_injective' := λ G H α β hαβ, nat_trans.ext _ _ $ funext $ λ X,\n functor.map_injective _ $ congr_fun (congr_arg nat_trans.app hαβ) X }\n\n@[simp] lemma whisker_left_id (F : C ⥤ D) {G : D ⥤ E} :\n whisker_left F (nat_trans.id G) = nat_trans.id (F.comp G) :=\nrfl\n@[simp] lemma whisker_left_id' (F : C ⥤ D) {G : D ⥤ E} :\n whisker_left F (𝟙 G) = 𝟙 (F.comp G) :=\nrfl\n\n@[simp] lemma whisker_right_id {G : C ⥤ D} (F : D ⥤ E) :\n whisker_right (nat_trans.id G) F = nat_trans.id (G.comp F) :=\n((whiskering_right C D E).obj F).map_id _\n@[simp] lemma whisker_right_id' {G : C ⥤ D} (F : D ⥤ E) :\n whisker_right (𝟙 G) F = 𝟙 (G.comp F) :=\n((whiskering_right C D E).obj F).map_id _\n\n@[simp] lemma whisker_left_comp (F : C ⥤ D) {G H K : D ⥤ E} (α : G ⟶ H) (β : H ⟶ K) :\n whisker_left F (α ≫ β) = (whisker_left F α) ≫ (whisker_left F β) :=\nrfl\n\n@[simp] lemma whisker_right_comp {G H K : C ⥤ D} (α : G ⟶ H) (β : H ⟶ K) (F : D ⥤ E) :\n whisker_right (α ≫ β) F = (whisker_right α F) ≫ (whisker_right β F) :=\n((whiskering_right C D E).obj F).map_comp α β\n\n/--\nIf `α : G ≅ H` is a natural isomorphism then\n`iso_whisker_left F α : (F ⋙ G) ≅ (F ⋙ H)` has components `α.app (F.obj X)`.\n-/\ndef iso_whisker_left (F : C ⥤ D) {G H : D ⥤ E} (α : G ≅ H) : (F ⋙ G) ≅ (F ⋙ H) :=\n((whiskering_left C D E).obj F).map_iso α\n@[simp] lemma iso_whisker_left_hom (F : C ⥤ D) {G H : D ⥤ E} (α : G ≅ H) :\n (iso_whisker_left F α).hom = whisker_left F α.hom :=\nrfl\n@[simp] lemma iso_whisker_left_inv (F : C ⥤ D) {G H : D ⥤ E} (α : G ≅ H) :\n (iso_whisker_left F α).inv = whisker_left F α.inv :=\nrfl\n\n/--\nIf `α : G ≅ H` then\n`iso_whisker_right α F : (G ⋙ F) ≅ (H ⋙ F)` has components `F.map_iso (α.app X)`.\n-/\ndef iso_whisker_right {G H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) : (G ⋙ F) ≅ (H ⋙ F) :=\n((whiskering_right C D E).obj F).map_iso α\n@[simp] lemma iso_whisker_right_hom {G H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) :\n (iso_whisker_right α F).hom = whisker_right α.hom F :=\nrfl\n@[simp] lemma iso_whisker_right_inv {G H : C ⥤ D} (α : G ≅ H) (F : D ⥤ E) :\n (iso_whisker_right α F).inv = whisker_right α.inv F :=\nrfl\n\ninstance is_iso_whisker_left (F : C ⥤ D) {G H : D ⥤ E} (α : G ⟶ H) [is_iso α] :\n is_iso (whisker_left F α) :=\nis_iso.of_iso (iso_whisker_left F (as_iso α))\ninstance is_iso_whisker_right {G H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) [is_iso α] :\n is_iso (whisker_right α F) :=\nis_iso.of_iso (iso_whisker_right (as_iso α) F)\n\nvariables {B : Type u₄} [category.{v₄} B]\n\nlocal attribute [elab_simple] whisker_left whisker_right\n\n@[simp] lemma whisker_left_twice (F : B ⥤ C) (G : C ⥤ D) {H K : D ⥤ E} (α : H ⟶ K) :\n whisker_left F (whisker_left G α) = whisker_left (F ⋙ G) α :=\nrfl\n\n@[simp] lemma whisker_right_twice {H K : B ⥤ C} (F : C ⥤ D) (G : D ⥤ E) (α : H ⟶ K) :\n whisker_right (whisker_right α F) G = whisker_right α (F ⋙ G) :=\nrfl\n\nlemma whisker_right_left (F : B ⥤ C) {G H : C ⥤ D} (α : G ⟶ H) (K : D ⥤ E) :\n whisker_right (whisker_left F α) K = whisker_left F (whisker_right α K) :=\nrfl\nend\n\nnamespace functor\n\nuniverses u₅ v₅\n\nvariables {A : Type u₁} [category.{v₁} A]\nvariables {B : Type u₂} [category.{v₂} B]\n\n/--\nThe left unitor, a natural isomorphism `((𝟭 _) ⋙ F) ≅ F`.\n-/\n@[simps] def left_unitor (F : A ⥤ B) : ((𝟭 A) ⋙ F) ≅ F :=\n{ hom := { app := λ X, 𝟙 (F.obj X) },\n inv := { app := λ X, 𝟙 (F.obj X) } }\n\n/--\nThe right unitor, a natural isomorphism `(F ⋙ (𝟭 B)) ≅ F`.\n-/\n@[simps] def right_unitor (F : A ⥤ B) : (F ⋙ (𝟭 B)) ≅ F :=\n{ hom := { app := λ X, 𝟙 (F.obj X) },\n inv := { app := λ X, 𝟙 (F.obj X) } }\n\nvariables {C : Type u₃} [category.{v₃} C]\nvariables {D : Type u₄} [category.{v₄} D]\n\n/--\nThe associator for functors, a natural isomorphism `((F ⋙ G) ⋙ H) ≅ (F ⋙ (G ⋙ H))`.\n\n(In fact, `iso.refl _` will work here, but it tends to make Lean slow later,\nand it's usually best to insert explicit associators.)\n-/\n@[simps] def associator (F : A ⥤ B) (G : B ⥤ C) (H : C ⥤ D) : ((F ⋙ G) ⋙ H) ≅ (F ⋙ (G ⋙ H)) :=\n{ hom := { app := λ _, 𝟙 _ },\n inv := { app := λ _, 𝟙 _ } }\n\n@[protected]\nlemma assoc (F : A ⥤ B) (G : B ⥤ C) (H : C ⥤ D) : ((F ⋙ G) ⋙ H) = (F ⋙ (G ⋙ H)) := rfl\n\nlemma triangle (F : A ⥤ B) (G : B ⥤ C) :\n (associator F (𝟭 B) G).hom ≫ (whisker_left F (left_unitor G).hom) =\n (whisker_right (right_unitor F).hom G) :=\nby { ext, dsimp, simp } -- See note [dsimp, simp].\n\nvariables {E : Type u₅} [category.{v₅} E]\n\nvariables (F : A ⥤ B) (G : B ⥤ C) (H : C ⥤ D) (K : D ⥤ E)\n\nlemma pentagon :\n (whisker_right (associator F G H).hom K) ≫\n (associator F (G ⋙ H) K).hom ≫\n (whisker_left F (associator G H K).hom) =\n ((associator (F ⋙ G) H K).hom ≫ (associator F G (H ⋙ K)).hom) :=\nby { ext, dsimp, simp }\n\nend functor\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/category_theory/whiskering.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.4687906266262437, "lm_q1q2_score": 0.24171778339276345}} {"text": "import pseudo_normed_group.category.strictProFiltPseuNormGrpWithTinv\nimport laurent_measures.functor\nimport condensed.ab\nimport condensed.rescale\nimport condensed.exact\nimport for_mathlib.split_exact\n.\n\nnoncomputable theory\n\nuniverse u\n\nopen_locale nnreal\nopen category_theory\n\nvariables {C D : Type*} [category C] [category D] (r' : ℝ≥0) [fact (0 < r')]\n\nabbreviation category_theory.nat_trans.conj_by {F G : C ⥤ D} (α : F ≅ G) (β : G ⟶ G) :\n F ⟶ F := α.hom ≫ β ≫ α.inv\n\nopen category_theory\n\nopen ProFiltPseuNormGrpWithTinv₁ CompHausFiltPseuNormGrp₁ CompHausFiltPseuNormGrp\n\nvariables {r'}\n\n/--\nGiven a functor `F` from `Fintype` to `CompHausFiltPseuNormGrp₁`, we can obtain\na functor `Profinite ⥤ CompHausFiltPseuNormGrp₁` by expressing any profinite\nset as a limit of finite sets and taking a limit in the target category.\nWe then compose with the functor to condensed abelian groups, and the result is\ncalled `condensify F`.\n-/\ndef condensify (F : Fintype.{u} ⥤ CompHausFiltPseuNormGrp₁.{u}) :\n Profinite.{u} ⥤ Condensed.{u} Ab.{u+1} :=\n(Profinite.extend.{u} F ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u}) ⋙ to_Condensed.{u}\n\nvariables {F G H : Fintype.{u} ⥤ CompHausFiltPseuNormGrp₁.{u}}\nvariables (α β : F ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u} ⟶ G ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u})\nvariables (c cα cβ cαβ : ℝ≥0) [fact (0 < c)] [fact (0 < cα)] [fact (0 < cβ)] [fact (0 < cαβ)]\n\n/--\nGiven functors `F G : Fintype ⥤ CompHausFiltPseuNormGrp₁` and a\nnatural transformation `η` between the induced functors `Fintype ⥤ CompHausFiltPseuNormGrp`\n(obtained by composing with `CHFPNG₁_to_CHFPNGₑₗ`), such that the components of `η` are bounded\nby a *single* `c : ℝ≥0`, this is the morphism between the associated condensed abelian groups.\n-/\ndef condensify_nonstrict\n (α : F ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u} ⟶ G ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u}) (c : ℝ≥0) [fact (0 < c)]\n (h : ∀ X, (α.app X).bound_by c) :\n condensify F ⟶ condensify G :=\nwhisker_right (nonstrict_extend.{u} α c h) to_Condensed\n\nlemma condensify_nonstrict_id (c : ℝ≥0) [fact (0 < c)]\n (h : ∀ X, (nat_trans.app (𝟙 (F ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u})) X).bound_by c) :\n condensify_nonstrict (𝟙 _) c h = 𝟙 _ :=\nby { simp only [condensify_nonstrict, nonstrict_extend_id, whisker_right_id'], refl }\n\nlemma condensify_nonstrict_comp\n (α : F ⋙ CHFPNG₁_to_CHFPNGₑₗ ⟶ G ⋙ CHFPNG₁_to_CHFPNGₑₗ)\n (β : G ⋙ CHFPNG₁_to_CHFPNGₑₗ ⟶ H ⋙ CHFPNG₁_to_CHFPNGₑₗ)\n (hα : ∀ X, (α.app X).bound_by cα) (hβ : ∀ X, (β.app X).bound_by cβ)\n (hαβ : ∀ X, ((α ≫ β).app X).bound_by cαβ) :\n condensify_nonstrict (α ≫ β) cαβ hαβ =\n condensify_nonstrict α cα hα ≫ condensify_nonstrict β cβ hβ :=\nbegin\n simp only [condensify_nonstrict, whisker_right_comp],\n rw [nonstrict_extend_comp cα cβ cαβ _ _ _ _, whisker_right_comp],\nend\n\ndef condensify_map (α : F ⟶ G) : condensify F ⟶ condensify G :=\ncondensify_nonstrict (whisker_right α _) 1\n (λ X, (comphaus_filtered_pseudo_normed_group_hom.mk_of_strict_strict _ _).bound_by_one)\n\nlemma condensify_map_id (F : Fintype.{u} ⥤ CompHausFiltPseuNormGrp₁.{u}) :\n condensify_map (𝟙 F) = 𝟙 (condensify F) :=\ncondensify_nonstrict_id _ _\n\nlemma condensify_map_comp (α : F ⟶ G) (β : G ⟶ H) :\n condensify_map (α ≫ β) = condensify_map α ≫ condensify_map β :=\nbegin\n dsimp only [condensify_map],\n simp only [whisker_right_comp],\n apply condensify_nonstrict_comp,\nend\n\ndef condensify_def (F : Fintype.{u} ⥤ CompHausFiltPseuNormGrp₁.{u}) :\n condensify F ≅ Profinite.extend.{u} F ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u} ⋙ to_Condensed.{u} :=\niso.refl _\n\n/-- Given a family `F` of profinitely filtered normed groups with `T⁻¹`,\n indexed by a category (and such that all the morphisms in the family are strict),\n `Tinv_nat_trans` is the associated (possibly non-strict) morphism from the\n corresponding family of `CompHaus`ly filtered pseudo-normed groups coming from `T⁻¹`.\n -/\ndef Tinv_nat_trans (F : C ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') :\n (F ⋙ PFPNGT₁_to_CHFPNG₁ₑₗ.{u} r') ⋙ CHFPNG₁_to_CHFPNGₑₗ ⟶\n (F ⋙ PFPNGT₁_to_CHFPNG₁ₑₗ.{u} r') ⋙ CHFPNG₁_to_CHFPNGₑₗ :=\n{ app := λ X, profinitely_filtered_pseudo_normed_group_with_Tinv.Tinv,\n naturality' := λ X Y f, by { ext x, exact ((F.map f).map_Tinv x).symm } }\n\n/-- The endomorphism `T⁻¹ - 2` of a strict family of profinitely-filtered\npseudo-normed groups with `T⁻¹`, considered as a possibly non-strict\nendomorphism of the associated `CompHaus`ly filtered pseudo-normed groups. -/\ndef Tinv2_nat_trans (F : C ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') :\n (F ⋙ PFPNGT₁_to_CHFPNG₁ₑₗ.{u} r') ⋙ CHFPNG₁_to_CHFPNGₑₗ ⟶\n (F ⋙ PFPNGT₁_to_CHFPNG₁ₑₗ.{u} r') ⋙ CHFPNG₁_to_CHFPNGₑₗ :=\nTinv_nat_trans F - 2 • 𝟙 _\n\nlemma Tinv_bound_by (F : C ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') (X : C) :\n ((Tinv_nat_trans F).app X).bound_by r'⁻¹ :=\nprofinitely_filtered_pseudo_normed_group_with_Tinv.Tinv_bound_by\n\nlemma twoid_bound_by (F : C ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') (X : C) :\n comphaus_filtered_pseudo_normed_group_hom.bound_by\n ((2 • 𝟙 ((F ⋙ PFPNGT₁_to_CHFPNG₁ₑₗ r') ⋙ CHFPNG₁_to_CHFPNGₑₗ)).app X) 2 :=\nbegin\n simp only [nat_trans.app_nsmul, nat_trans.id_app],\n refine ((comphaus_filtered_pseudo_normed_group_hom.mk_of_bound_bound_by _ 1 _).nsmul 2).mono _ _,\n norm_num,\nend\n\nlemma Tinv2_bound_by (F : C ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') (X : C) :\n ((Tinv2_nat_trans F).app X).bound_by (r'⁻¹ + 2) :=\n(Tinv_bound_by F X).sub (twoid_bound_by F X)\n\n@[reassoc]\nlemma Tinv_nat_trans_comp {F G : C ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r'} (α : F ⟶ G) :\n Tinv_nat_trans F ≫ @whisker_right _ _ _ _ _ _ F G α (PFPNGT₁_to_CHFPNG₁ₑₗ r' ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u}) =\n @whisker_right _ _ _ _ _ _ F G α (PFPNGT₁_to_CHFPNG₁ₑₗ r' ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u}) ≫ Tinv_nat_trans G :=\nby { ext X x, exact (α.app X).map_Tinv x }\n\n-- move me\ninstance fact_inv_pos : fact (0 < r'⁻¹) := ⟨nnreal.inv_pos.2 $ fact.out _⟩\n\n--set_option pp.universes true\n\n/--\nGiven a functor from `Fintype` to `ProFiltPseuNormGrpWithTinv₁`, the `T⁻¹` action\nis a nonstrict morphism which is natural (see `Tinv_nat_trans`) and thus\ninduces a morphism on the associated condensed abelian groups.\n-/\ndef condensify_Tinv (F : Fintype.{u} ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') :\n condensify.{u} (F ⋙ PFPNGT₁_to_CHFPNG₁ₑₗ r') ⟶ condensify.{u} (F ⋙ PFPNGT₁_to_CHFPNG₁ₑₗ r') :=\ncondensify_nonstrict (Tinv_nat_trans _) r'⁻¹ (Tinv_bound_by _)\n\n/--\nA variant of `condensify_Tinv` with a different bound, given by `r'⁻¹ + 2`.\n-/\ndef condensify_Tinv2 (F : Fintype.{u} ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') :\n condensify.{u} (F ⋙ PFPNGT₁_to_CHFPNG₁ₑₗ r') ⟶ condensify.{u} (F ⋙ PFPNGT₁_to_CHFPNG₁ₑₗ r') :=\ncondensify_nonstrict (Tinv2_nat_trans _) (r'⁻¹ + 2) (Tinv2_bound_by _)\n\nlemma condensify_map_comp_Tinv {F G : Fintype.{u} ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r'}\n (α : F ⟶ G) :\n condensify_map (whisker_right α (PFPNGT₁_to_CHFPNG₁ₑₗ r')) ≫ condensify_Tinv G =\n condensify_Tinv F ≫ condensify_map (whisker_right α (PFPNGT₁_to_CHFPNG₁ₑₗ r')) :=\nbegin\n delta condensify_map condensify_Tinv,\n rw [← condensify_nonstrict_comp 1 r'⁻¹ r'⁻¹, ← condensify_nonstrict_comp r'⁻¹ 1 r'⁻¹],\n swap, {\n intro X,\n rw nat_trans.comp_app,\n rw ← one_mul r'⁻¹,\n apply comphaus_filtered_pseudo_normed_group_hom.bound_by.comp (Tinv_bound_by F X),\n simp only [whisker_right_twice, whisker_right_app, functor.comp_map, CHFPNG₁_to_CHFPNGₑₗ_map],\n apply strict_comphaus_filtered_pseudo_normed_group_hom.to_chfpsng_hom.bound_by_one\n },\n swap, {\n intro X,\n rw nat_trans.comp_app,\n rw ← mul_one r'⁻¹,\n refine comphaus_filtered_pseudo_normed_group_hom.bound_by.comp _ (Tinv_bound_by G X),\n simp only [whisker_right_twice, whisker_right_app, functor.comp_map, CHFPNG₁_to_CHFPNGₑₗ_map],\n apply strict_comphaus_filtered_pseudo_normed_group_hom.to_chfpsng_hom.bound_by_one, },\n { simp only [whisker_right_twice, Tinv_nat_trans_comp], },\nend\n.\n\nsection\n\n\nlemma condensify_nonstrict_map_add\n (hα : ∀ X, (α.app X).bound_by cα) (hβ : ∀ X, (β.app X).bound_by cβ)\n (hαβ : ∀ X, ((α + β).app X).bound_by cαβ) :\n condensify_nonstrict (α + β) cαβ hαβ =\n condensify_nonstrict α cα hα + condensify_nonstrict β cβ hβ :=\nbegin\n delta condensify_nonstrict,\n rw [nonstrict_extend_map_add _ _ cα cβ cαβ hα hβ],\n refl,\nend\n\nlemma condensify_nonstrict_map_neg\n (hα : ∀ X, (α.app X).bound_by cα) (hβ : ∀ X, ((-α).app X).bound_by cβ) :\n condensify_nonstrict (-α) cβ hβ = -condensify_nonstrict α cα hα :=\nbegin\n delta condensify_nonstrict,\n rw [nonstrict_extend_map_neg _ _ cβ hα],\n refl,\nend\n\nlemma condensify_nonstrict_map_sub\n (hα : ∀ X, (α.app X).bound_by cα) (hβ : ∀ X, (β.app X).bound_by cβ)\n (hαβ : ∀ X, ((α - β).app X).bound_by cαβ) :\n condensify_nonstrict (α - β) cαβ hαβ =\n condensify_nonstrict α cα hα - condensify_nonstrict β cβ hβ :=\nbegin\n delta condensify_nonstrict,\n rw [nonstrict_extend_map_sub _ _ cα cβ cαβ hα hβ],\n refl,\nend\n\nlemma condensify_nonstrict_map_nsmul (n : ℕ)\n (hα : ∀ X, (α.app X).bound_by cα) (hβ : ∀ X, ((n • α).app X).bound_by cβ) :\n condensify_nonstrict (n • α) cβ hβ = n • condensify_nonstrict α cα hα :=\nbegin\n delta condensify_nonstrict,\n rw [nonstrict_extend_map_nsmul _ _ cβ n hα],\n clear hβ,\n induction n with n ih,\n { rw [zero_smul, zero_smul], refl },\n { rw [succ_nsmul, succ_nsmul, ← ih], refl, }\nend\n\n-- lemma nonstrict_extend_Tinv (F : Fintype.{u} ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') :\n-- nonstrict_extend (Tinv_nat_trans F) r'⁻¹ (Tinv_bound_by _) =\n-- nat_trans.conj_by (iso_whisker_right\n-- (Profinite.extend_commutes F (PFPNG₁_to_CHFPNG₁ₑₗ.{u} r')).symm enlarging_functor.{u})\n-- (Tinv_nat_trans (Profinite.extend F)) :=\n-- begin\n-- refine nonstrict_extend_ext' _ _ r'⁻¹ (nonstrict_extend_bound_by _ _ _) _ _,\n-- { admit },\n-- { rw [nonstrict_extend_whisker_left],\n-- simp only [whisker_left_comp, ← iso_whisker_left_hom, ← iso_whisker_left_inv,\n-- ← iso.inv_comp_eq, iso.eq_comp_inv, category.assoc],\n-- admit }\n-- end\n\nlemma condensify_nonstrict_Tinv (F : Fintype.{u} ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') :\n condensify_nonstrict (Tinv_nat_trans F) r'⁻¹ (Tinv_bound_by _) = condensify_Tinv F :=\nrfl\n\nlemma condensify_nonstrict_whisker_right_enlarging (α : F ⟶ G) :\n condensify_nonstrict (whisker_right α _) 1\n (λ X, (comphaus_filtered_pseudo_normed_group_hom.mk_of_strict_strict _ _).bound_by_one) =\n condensify_map α :=\nrfl\n\nend\n\nopen pseudo_normed_group (filtration)\n\nlemma exact_of_iso_comp_exact {V : Type u} [category V] [limits.has_images V]\n [limits.has_zero_morphisms V] [limits.has_equalizers V]\n {A B C D : V} (f : A ⟶ B) {g : B ⟶ C} {h : C ⟶ D} (hf : is_iso f) (hgh : exact g h) :\n exact (f ≫ g) h :=\nby rwa exact_iso_comp\n\nlemma condensify_nonstrict_exact\n (α : F ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u} ⟶ G ⋙ CHFPNG₁_to_CHFPNGₑₗ.{u}) (β : G ⟶ H)\n (c : ℝ≥0) [fact (0 < c)]\n (h : ∀ X, (α.app X).bound_by c)\n (cα cβ : ℝ≥0 → ℝ≥0) (hcα : id ≤ cα) (hcβ : id ≤ cβ)\n (H1 : ∀ S, function.injective (α.app S))\n (H2a : ∀ S, (α.app S) ≫ ((whisker_right β _).app S) = 0)\n (H2b : ∀ S c', (β.app S) ⁻¹' {0} ∩ filtration (G.obj S) c' ⊆\n (α.app S) '' filtration (F.obj S) (cα c' * c⁻¹))\n (H3b : ∀ S c', filtration (H.obj S) c' ⊆ (β.app S) '' filtration (G.obj S) (cβ c'))\n (X : Profinite.{u}) :\n short_exact ((condensify_nonstrict α c h).app X) ((condensify_map β).app X) :=\nbegin\n apply_with short_exact.mk { instances := ff },\n { simp only [condensify_nonstrict, nonstrict_extend, whisker_right_comp],\n repeat { apply_with mono_comp { instances := ff }; try { apply_instance } },\n apply Condensed.mono_to_Condensed_map,\n apply exact_with_constant_extend_zero_left,\n intro S,\n apply_with exact_with_constant_of_mono { instances := ff },\n rw AddCommGroup.mono_iff_injective,\n exact H1 S, },\n { dsimp only [condensify_map, condensify_nonstrict],\n rw nonstrict_extend_whisker_right_enlarging,\n apply Condensed.epi_to_Condensed_map _ cβ,\n apply exact_with_constant_extend_zero_right,\n intro S,\n apply exact_with_constant_of_epi _ _ _ hcβ (H3b S), },\n { dsimp only [condensify_map, condensify_nonstrict],\n rw nonstrict_extend_whisker_right_enlarging,\n simp only [nonstrict_extend, whisker_right_comp, nat_trans.comp_app, category.assoc],\n repeat { apply exact_of_iso_comp_exact; [apply_instance, skip] },\n apply Condensed.exact_of_exact_with_constant _ _ cα,\n apply exact_with_constant.extend,\n intro S,\n refine ⟨_, _, hcα⟩,\n { ext x, specialize H2a S, apply_fun (λ φ, φ.to_fun) at H2a, exact congr_fun H2a x },\n { intros c' y hy,\n obtain ⟨x, hx, rfl⟩ := H2b S c' hy,\n refine ⟨@rescale.of c _ x, hx, rfl⟩, } }\nend\n.\n\nlemma condensify_exact (α : F ⟶ G) (β : G ⟶ H)\n (cα cβ : ℝ≥0 → ℝ≥0) (hcα : id ≤ cα) (hcβ : id ≤ cβ)\n (H1 : ∀ S, function.injective (α.app S))\n (H2a : ∀ S, α.app S ≫ β.app S = 0)\n (H2b : ∀ S c, (β.app S) ⁻¹' {0} ∩ filtration (G.obj S) c ⊆\n (α.app S) '' filtration (F.obj S) (cα c))\n (H3b : ∀ S c, filtration (H.obj S) c ⊆ (β.app S) '' filtration (G.obj S) (cβ c))\n (X : Profinite.{u}) :\n short_exact ((condensify_map α).app X) ((condensify_map β).app X) :=\nbegin\n refine condensify_nonstrict_exact _ _ 1 _ cα cβ hcα hcβ H1 _ _ H3b _,\n { intro S, simp only [whisker_right_app, ← functor.map_comp, H2a], refl, },\n { intros S c' x H, obtain ⟨x, hx, rfl⟩ := H2b S c' H,\n refine ⟨x, pseudo_normed_group.filtration_mono _ hx, rfl⟩,\n simp only [inv_one, mul_one], },\nend\n\n-- move me\nattribute [simps] Ab.ulift\n\nlemma condensify_Tinv2_eq (F : Fintype.{u} ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r') :\n condensify_Tinv2 F = condensify_Tinv F - 2 • 𝟙 _ :=\nbegin\n delta condensify_Tinv2 Tinv2_nat_trans,\n rw [condensify_nonstrict_map_sub _ _ r'⁻¹ 2 (r'⁻¹ + 2) (Tinv_bound_by _) (twoid_bound_by _),\n condensify_nonstrict_map_nsmul _ 1 2, condensify_nonstrict_Tinv],\n swap,\n { intro, exact comphaus_filtered_pseudo_normed_group_hom.mk_of_bound_bound_by _ 1 _ },\n rw [← condensify_map_id, ← condensify_nonstrict_whisker_right_enlarging],\n refl\nend\n\nopen category_theory.preadditive\n\nlemma condensify_map_comp_Tinv2 {F G : Fintype.{u} ⥤ ProFiltPseuNormGrpWithTinv₁.{u} r'}\n (α : F ⟶ G) :\n condensify_map (whisker_right α (PFPNGT₁_to_CHFPNG₁ₑₗ r')) ≫ condensify_Tinv2 G =\n condensify_Tinv2 F ≫ condensify_map (whisker_right α (PFPNGT₁_to_CHFPNG₁ₑₗ r')) :=\nby simp only [condensify_Tinv2_eq, comp_sub, sub_comp, comp_nsmul, nsmul_comp,\n condensify_map_comp_Tinv, category.id_comp, category.comp_id]\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/condensify.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.24147948289856727}} {"text": "/-\nCopyright (c) 2022 Devon Tuma. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Devon Tuma\n-/\nimport computational_monads.simulation_semantics.constructions.logging.logging_oracle\nimport computational_monads.simulation_semantics.constructions.logging.query_log.lookup\nimport computational_monads.simulation_semantics.constructions.logging.query_log.fork\n\n/-!\n# Seeded Simulation Oracle\n\nThis file constructs a simulation oracle that allows for a set of predetermined query responses.\nThe oracle takes a `query_log` as an initial state, and uses the internal values\n to respond to queries, and then forwards any additional queries back to the original oracle.\nNote that if any query fails to find a seed value, the entire `query_log` is discarded,\n regardless of if further values exist for oracles of different indices.\n\nThis can more generally be thought of as a form of small-step semantics for `oracle_comp`,\n evaluating the computation using the provided value, eventually reducing to a single value,\n unless it runs out of \"gas\", leading to only a partial evaluation.\n\n-/\n\nopen oracle_comp oracle_spec\n\nvariables {spec spec' spec'' : oracle_spec} {α β γ : Type}\n \n/-- Use the first element of the `seed` as the query result if inputs match.\n If the query values don't match then throw away the seed as computation has diverged.\n Using this with a log from a previous computation ensures they behave identically. -/\ndef seeded_oracle (spec : oracle_spec) :\n sim_oracle spec spec (query_log spec) :=\n{ default_state := query_log.init spec,\n o := λ i ⟨t, seed⟩, match seed.lookup_fst i t with\n -- Once the seed is empty, just keep it empty going forward\n | none := (λ u, (u, query_log.init spec)) <$> query i t\n | (some u) := return (u, seed.remove_head i)\n end }\n\nnamespace seeded_oracle\n\nvariables (log : query_log spec) (log' : query_log spec')\n\nsection simulate\n\n\nend simulate\n\nsection eval_dist\n\n-- Log and run, run from seed, return original output -> looks like just logging\nlemma eval_dist_seeded_oracle_fst (oa : oracle_comp spec α) (i : spec.ι)\n (choose_fork : α → query_log spec → option ℕ) :\n⁅do{ ⟨a, log⟩ ← simulate (logging_oracle spec) oa (query_log.init spec),\n seed ← return (log.fork_cache i $ choose_fork a log).to_seed,\n ⟨a', log'⟩ ← simulate (seeded_oracle spec) oa seed,\n return (a, log) }⁆ =\n ⁅(simulate (logging_oracle spec) oa (query_log.init spec))⁆ :=\nsorry\n\n-- Log and run, run from seed, return new output -> looks like just logging\nlemma eval_dist_seeded_oracle_snd (oa : oracle_comp spec α) (i : spec.ι)\n (choose_fork : α → query_log spec → option ℕ) :\n⁅do{ ⟨a, log⟩ ← simulate (logging_oracle spec) oa (query_log.init spec),\n seed ← return (log.fork_cache i $ choose_fork a log).to_seed,\n ⟨a', log'⟩ ← simulate (seeded_oracle spec) oa (seed),\n return (a', log') }⁆ = \n ⁅(simulate (logging_oracle spec) oa (query_log.init spec))⁆ :=\nsorry\n\n-- The log values match up until the point where the log was forked\nlemma seeded_oracle_log_eq_log (oa : oracle_comp spec α) (i : spec.ι)\n (choose_fork : α → query_log spec → option ℕ) :\ndo{ ⟨a, log⟩ ← simulate (logging_oracle spec) oa (query_log.init spec),\n seed ← return (log.fork_cache i $ choose_fork a log).to_seed,\n ⟨a', log'⟩ ← simulate (seeded_oracle spec) oa (seed),\n return (a, log, log') }.support\n ⊆ λ ⟨a, log, log'⟩, log.fork_cache i (choose_fork a log) =\n log'.fork_cache i (choose_fork a log) :=\nsorry\n\nend eval_dist\n\nend seeded_oracle", "meta": {"author": "dtumad", "repo": "lean-crypto-formalization", "sha": "f975a9a9882120b509553a7ced9aa05b745ff154", "save_path": "github-repos/lean/dtumad-lean-crypto-formalization", "path": "github-repos/lean/dtumad-lean-crypto-formalization/lean-crypto-formalization-f975a9a9882120b509553a7ced9aa05b745ff154/src/computational_monads/simulation_semantics/constructions/logging/seeded_oracle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.46101677931231594, "lm_q1q2_score": 0.2413055634931527}} {"text": "/-\nFile: signature_recover_public_key_assert_nn_soundness.lean\n\nAutogenerated file.\n-/\nimport starkware.cairo.lean.semantics.soundness.hoare\nimport .signature_recover_public_key_code\nimport ..signature_recover_public_key_spec\nopen tactic\n\nopen starkware.cairo.common.math\n\nvariables {F : Type} [field F] [decidable_eq F] [prelude_hyps F]\nvariable mem : F → F\nvariable σ : register_state F\n\n/- starkware.cairo.common.math.assert_nn autogenerated soundness theorem -/\n\ntheorem auto_sound_assert_nn\n -- arguments\n (range_check_ptr a : F)\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_assert_nn σ.pc)\n -- input arguments on the stack\n (hin_range_check_ptr : range_check_ptr = mem (σ.fp - 4))\n (hin_a : a = mem (σ.fp - 3))\n -- conclusion\n : ensures_ret mem σ (λ κ τ,\n τ.ap = σ.ap + 1 ∧\n ∃ μ ≤ κ, rc_ensures mem (rc_bound F) μ (mem (σ.fp - 4)) (mem $ τ.ap - 1)\n (spec_assert_nn mem κ range_check_ptr a (mem (τ.ap - 1)))) :=\nbegin\n apply ensures_of_ensuresb, intro νbound,\n have h_mem_rec := h_mem,\n unpack_memory code_assert_nn at h_mem with ⟨hpc0, hpc1, hpc2, hpc3⟩,\n -- assert eq\n step_assert_eq hpc0 with temp0,\n have a0: a = mem (range_check_ptr), {\n apply assert_eq_reduction temp0,\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_a] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a0 }, try { arith_simps at a0 },\n clear temp0,\n -- let\n generalize' hl_rev_range_check_ptr₁: (range_check_ptr + 1 : F) = range_check_ptr₁,\n have hl_range_check_ptr₁ := hl_rev_range_check_ptr₁.symm, clear hl_rev_range_check_ptr₁,\n try { dsimp at hl_range_check_ptr₁ }, try { arith_simps at hl_range_check_ptr₁ },\n -- return\n step_assert_eq hpc1 hpc2 with hret0,\n step_ret hpc3,\n -- finish\n step_done, use_only [rfl, rfl],\n split, refl,\n -- range check condition\n use_only (1+0+0), split,\n linarith [],\n split,\n { arith_simps, try { simp only [hret0] },\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_assert_nn mem _ range_check_ptr a _,\n { apply sound_assert_nn, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_assert_nn],\n try { norm_num1 }, try { arith_simps },\n use_only [a0],\n cases rc_h_range_check_ptr' (0) (by norm_num1) with n hn, arith_simps at hn,\n use_only [n], { simp only [a0, hin_range_check_ptr], arith_simps, exact hn },\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁,try { norm_cast at rc_h_range_check_ptr₁' },\n use_only [range_check_ptr₁, hl_range_check_ptr₁],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_a, hl_range_check_ptr₁] }, },\n try { arith_simps }, try { simp only [hret0] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\nend\n\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/common/cairo_secp/verification/verification/signature_recover_public_key_assert_nn_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6261241772283034, "lm_q2_score": 0.3849121444839335, "lm_q1q2_score": 0.2410027997701847}} {"text": "/-\nCopyright (c) 2020 Yury G. Kudryashov. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Yury G. Kudryashov\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.linear_algebra.affine_space.affine_map\nimport Mathlib.algebra.invertible\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 u_4 u_5 l u_6 u_7 u_8 u_9 u_10 \n\nnamespace Mathlib\n\n/-!\n# Affine equivalences\n\nIn this file we define `affine_equiv k P₁ P₂` (notation: `P₁ ≃ᵃ[k] P₂`) to be the type of affine\nequivalences between `P₁` and `P₂, i.e., equivalences such that both forward and inverse maps are\naffine maps.\n\nWe define the following equivalences:\n\n* `affine_equiv.refl k P`: the identity map as an `affine_equiv`;\n\n* `e.symm`: the inverse map of an `affine_equiv` as an `affine_equiv`;\n\n* `e.trans e'`: composition of two `affine_equiv`s; note that the order follows `mathlib`'s\n `category_theory` convention (apply `e`, then `e'`), not the convention used in function\n composition and compositions of bundled morphisms.\n\n## Tags\n\naffine space, affine equivalence\n-/\n\n/-- An affine equivalence is an equivalence between affine spaces such that both forward\nand inverse maps are affine.\n\nWe define it using an `equiv` for the map and a `linear_equiv` for the linear part in order\nto allow affine equivalences with good definitional equalities. -/\nstructure affine_equiv (k : Type u_1) (P₁ : Type u_2) (P₂ : Type u_3) {V₁ : Type u_4} {V₂ : Type u_5} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] \nextends P₁ ≃ P₂\nwhere\n linear : linear_equiv k V₁ V₂\n map_vadd' : ∀ (p : P₁) (v : V₁), coe_fn _to_equiv (v +ᵥ p) = coe_fn linear v +ᵥ coe_fn _to_equiv p\n\nprotected instance affine_equiv.has_coe_to_fun (k : Type u_1) {V1 : Type u_2} (P1 : Type u_3) {V2 : Type u_4} (P2 : Type u_5) [ring k] [add_comm_group V1] [module k V1] [add_torsor V1 P1] [add_comm_group V2] [module k V2] [add_torsor V2 P2] : has_coe_to_fun (affine_equiv k P1 P2) :=\n has_coe_to_fun.mk (fun (e : affine_equiv k P1 P2) => P1 → P2)\n fun (e : affine_equiv k P1 P2) => equiv.to_fun (affine_equiv.to_equiv e)\n\nnamespace linear_equiv\n\n\n/-- Interpret a linear equivalence between modules as an affine equivalence. -/\ndef to_affine_equiv {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_comm_group V₂] [semimodule k V₂] (e : linear_equiv k V₁ V₂) : affine_equiv k V₁ V₂ :=\n affine_equiv.mk (to_equiv e) e sorry\n\n@[simp] theorem coe_to_affine_equiv {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_comm_group V₂] [semimodule k V₂] (e : linear_equiv k V₁ V₂) : ⇑(to_affine_equiv e) = ⇑e :=\n rfl\n\nend linear_equiv\n\n\nnamespace affine_equiv\n\n\n/-- Identity map as an `affine_equiv`. -/\ndef refl (k : Type u_1) {V₁ : Type u_2} (P₁ : Type u_6) [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] : affine_equiv k P₁ P₁ :=\n mk (equiv.refl P₁) (linear_equiv.refl k V₁) sorry\n\n@[simp] theorem coe_refl (k : Type u_1) {V₁ : Type u_2} (P₁ : Type u_6) [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] : ⇑(refl k P₁) = id :=\n rfl\n\ntheorem refl_apply (k : Type u_1) {V₁ : Type u_2} (P₁ : Type u_6) [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (x : P₁) : coe_fn (refl k P₁) x = x :=\n rfl\n\n@[simp] theorem to_equiv_refl (k : Type u_1) {V₁ : Type u_2} (P₁ : Type u_6) [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] : to_equiv (refl k P₁) = equiv.refl P₁ :=\n rfl\n\n@[simp] theorem linear_refl (k : Type u_1) {V₁ : Type u_2} (P₁ : Type u_6) [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] : linear (refl k P₁) = linear_equiv.refl k V₁ :=\n rfl\n\n@[simp] theorem map_vadd {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) (p : P₁) (v : V₁) : coe_fn e (v +ᵥ p) = coe_fn (linear e) v +ᵥ coe_fn e p :=\n map_vadd' e p v\n\n@[simp] theorem coe_to_equiv {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : ⇑(to_equiv e) = ⇑e :=\n rfl\n\n/-- Reinterpret an `affine_equiv` as an `affine_map`. -/\ndef to_affine_map {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : affine_map k P₁ P₂ :=\n affine_map.mk (⇑e) (↑(linear e)) (map_vadd' e)\n\n@[simp] theorem coe_to_affine_map {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : ⇑(to_affine_map e) = ⇑e :=\n rfl\n\n@[simp] theorem to_affine_map_mk {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (f : P₁ ≃ P₂) (f' : linear_equiv k V₁ V₂) (h : ∀ (p : P₁) (v : V₁), coe_fn f (v +ᵥ p) = coe_fn f' v +ᵥ coe_fn f p) : to_affine_map (mk f f' h) = affine_map.mk (⇑f) (↑f') h :=\n rfl\n\n@[simp] theorem linear_to_affine_map {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : affine_map.linear (to_affine_map e) = ↑(linear e) :=\n rfl\n\ntheorem injective_to_affine_map {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] : function.injective to_affine_map := sorry\n\n@[simp] theorem to_affine_map_inj {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] {e : affine_equiv k P₁ P₂} {e' : affine_equiv k P₁ P₂} : to_affine_map e = to_affine_map e' ↔ e = e' :=\n function.injective.eq_iff injective_to_affine_map\n\ntheorem ext {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] {e : affine_equiv k P₁ P₂} {e' : affine_equiv k P₁ P₂} (h : ∀ (x : P₁), coe_fn e x = coe_fn e' x) : e = e' :=\n injective_to_affine_map (affine_map.ext h)\n\ntheorem injective_coe_fn {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] : function.injective fun (e : affine_equiv k P₁ P₂) (x : P₁) => coe_fn e x := sorry\n\n@[simp] theorem coe_fn_inj {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] {e : affine_equiv k P₁ P₂} {e' : affine_equiv k P₁ P₂} : ⇑e = ⇑e' ↔ e = e' :=\n function.injective.eq_iff injective_coe_fn\n\ntheorem injective_to_equiv {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] : function.injective to_equiv :=\n fun (e e' : affine_equiv k P₁ P₂) (H : to_equiv e = to_equiv e') => ext (iff.mp equiv.ext_iff H)\n\n@[simp] theorem to_equiv_inj {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] {e : affine_equiv k P₁ P₂} {e' : affine_equiv k P₁ P₂} : to_equiv e = to_equiv e' ↔ e = e' :=\n function.injective.eq_iff injective_to_equiv\n\n/-- Construct an affine equivalence by verifying the relation between the map and its linear part at\none base point. Namely, this function takes an equivalence `e : P₁ ≃ P₂`, a linear equivalece\n`e' : V₁ ≃ₗ[k] V₂`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -ᵥ p) +ᵥ e p`. -/\ndef mk' {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : P₁ ≃ P₂) (e' : linear_equiv k V₁ V₂) (p : P₁) (h : ∀ (p' : P₁), coe_fn e p' = coe_fn e' (p' -ᵥ p) +ᵥ coe_fn e p) : affine_equiv k P₁ P₂ :=\n mk e e' sorry\n\n@[simp] theorem coe_mk' {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : P₁ ≃ P₂) (e' : linear_equiv k V₁ V₂) (p : P₁) (h : ∀ (p' : P₁), coe_fn e p' = coe_fn e' (p' -ᵥ p) +ᵥ coe_fn e p) : ⇑(mk' e e' p h) = ⇑e :=\n rfl\n\n@[simp] theorem to_equiv_mk' {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : P₁ ≃ P₂) (e' : linear_equiv k V₁ V₂) (p : P₁) (h : ∀ (p' : P₁), coe_fn e p' = coe_fn e' (p' -ᵥ p) +ᵥ coe_fn e p) : to_equiv (mk' e e' p h) = e :=\n rfl\n\n@[simp] theorem linear_mk' {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : P₁ ≃ P₂) (e' : linear_equiv k V₁ V₂) (p : P₁) (h : ∀ (p' : P₁), coe_fn e p' = coe_fn e' (p' -ᵥ p) +ᵥ coe_fn e p) : linear (mk' e e' p h) = e' :=\n rfl\n\n/-- Inverse of an affine equivalence as an affine equivalence. -/\ndef symm {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : affine_equiv k P₂ P₁ :=\n mk (equiv.symm (to_equiv e)) (linear_equiv.symm (linear e)) sorry\n\n@[simp] theorem symm_to_equiv {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : equiv.symm (to_equiv e) = to_equiv (symm e) :=\n rfl\n\n@[simp] theorem symm_linear {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : linear_equiv.symm (linear e) = linear (symm e) :=\n rfl\n\nprotected theorem bijective {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : function.bijective ⇑e :=\n equiv.bijective (to_equiv e)\n\nprotected theorem surjective {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : function.surjective ⇑e :=\n equiv.surjective (to_equiv e)\n\nprotected theorem injective {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : function.injective ⇑e :=\n equiv.injective (to_equiv e)\n\n@[simp] theorem range_eq {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : set.range ⇑e = set.univ :=\n function.surjective.range_eq (affine_equiv.surjective e)\n\n@[simp] theorem apply_symm_apply {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) (p : P₂) : coe_fn e (coe_fn (symm e) p) = p :=\n equiv.apply_symm_apply (to_equiv e) p\n\n@[simp] theorem symm_apply_apply {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) (p : P₁) : coe_fn (symm e) (coe_fn e p) = p :=\n equiv.symm_apply_apply (to_equiv e) p\n\ntheorem apply_eq_iff_eq_symm_apply {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) {p₁ : P₁} {p₂ : P₂} : coe_fn e p₁ = p₂ ↔ p₁ = coe_fn (symm e) p₂ :=\n equiv.apply_eq_iff_eq_symm_apply (to_equiv e)\n\n@[simp] theorem apply_eq_iff_eq {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) {p₁ : P₁} {p₂ : P₁} : coe_fn e p₁ = coe_fn e p₂ ↔ p₁ = p₂ :=\n equiv.apply_eq_iff_eq (to_equiv e)\n\n@[simp] theorem symm_refl {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] : symm (refl k P₁) = refl k P₁ :=\n rfl\n\n/-- Composition of two `affine_equiv`alences, applied left to right. -/\ndef trans {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {V₃ : Type u_4} {P₁ : Type u_6} {P₂ : Type u_7} {P₃ : Type u_8} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] [add_comm_group V₃] [semimodule k V₃] [add_torsor V₃ P₃] (e : affine_equiv k P₁ P₂) (e' : affine_equiv k P₂ P₃) : affine_equiv k P₁ P₃ :=\n mk (equiv.trans (to_equiv e) (to_equiv e')) (linear_equiv.trans (linear e) (linear e')) sorry\n\n@[simp] theorem coe_trans {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {V₃ : Type u_4} {P₁ : Type u_6} {P₂ : Type u_7} {P₃ : Type u_8} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] [add_comm_group V₃] [semimodule k V₃] [add_torsor V₃ P₃] (e : affine_equiv k P₁ P₂) (e' : affine_equiv k P₂ P₃) : ⇑(trans e e') = ⇑e' ∘ ⇑e :=\n rfl\n\ntheorem trans_apply {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {V₃ : Type u_4} {P₁ : Type u_6} {P₂ : Type u_7} {P₃ : Type u_8} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] [add_comm_group V₃] [semimodule k V₃] [add_torsor V₃ P₃] (e : affine_equiv k P₁ P₂) (e' : affine_equiv k P₂ P₃) (p : P₁) : coe_fn (trans e e') p = coe_fn e' (coe_fn e p) :=\n rfl\n\ntheorem trans_assoc {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {V₃ : Type u_4} {V₄ : Type u_5} {P₁ : Type u_6} {P₂ : Type u_7} {P₃ : Type u_8} {P₄ : Type u_9} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] [add_comm_group V₃] [semimodule k V₃] [add_torsor V₃ P₃] [add_comm_group V₄] [semimodule k V₄] [add_torsor V₄ P₄] (e₁ : affine_equiv k P₁ P₂) (e₂ : affine_equiv k P₂ P₃) (e₃ : affine_equiv k P₃ P₄) : trans (trans e₁ e₂) e₃ = trans e₁ (trans e₂ e₃) :=\n ext fun (_x : P₁) => rfl\n\n@[simp] theorem trans_refl {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : trans e (refl k P₂) = e :=\n ext fun (_x : P₁) => rfl\n\n@[simp] theorem refl_trans {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : trans (refl k P₁) e = e :=\n ext fun (_x : P₁) => rfl\n\n@[simp] theorem trans_symm {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : trans e (symm e) = refl k P₁ :=\n ext (symm_apply_apply e)\n\n@[simp] theorem symm_trans {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) : trans (symm e) e = refl k P₂ :=\n ext (apply_symm_apply e)\n\n@[simp] theorem apply_line_map {k : Type u_1} {V₁ : Type u_2} {V₂ : Type u_3} {P₁ : Type u_6} {P₂ : Type u_7} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [add_comm_group V₂] [semimodule k V₂] [add_torsor V₂ P₂] (e : affine_equiv k P₁ P₂) (a : P₁) (b : P₁) (c : k) : coe_fn e (coe_fn (affine_map.line_map a b) c) = coe_fn (affine_map.line_map (coe_fn e a) (coe_fn e b)) c :=\n affine_map.apply_line_map (to_affine_map e) a b c\n\nprotected instance group {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] : group (affine_equiv k P₁ P₁) :=\n group.mk (fun (e e' : affine_equiv k P₁ P₁) => trans e' e) sorry (refl k P₁) trans_refl refl_trans symm\n (div_inv_monoid.div._default (fun (e e' : affine_equiv k P₁ P₁) => trans e' e) sorry (refl k P₁) trans_refl refl_trans\n symm)\n trans_symm\n\ntheorem one_def {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] : 1 = refl k P₁ :=\n rfl\n\n@[simp] theorem coe_one {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] : ⇑1 = id :=\n rfl\n\ntheorem mul_def {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (e : affine_equiv k P₁ P₁) (e' : affine_equiv k P₁ P₁) : e * e' = trans e' e :=\n rfl\n\n@[simp] theorem coe_mul {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (e : affine_equiv k P₁ P₁) (e' : affine_equiv k P₁ P₁) : ⇑(e * e') = ⇑e ∘ ⇑e' :=\n rfl\n\ntheorem inv_def {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (e : affine_equiv k P₁ P₁) : e⁻¹ = symm e :=\n rfl\n\n/-- The map `v ↦ v +ᵥ b` as an affine equivalence between a module `V` and an affine space `P` with\ntangent space `V`. -/\ndef vadd_const (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (b : P₁) : affine_equiv k V₁ P₁ :=\n mk (equiv.vadd_const b) (linear_equiv.refl k V₁) sorry\n\n@[simp] theorem linear_vadd_const (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (b : P₁) : linear (vadd_const k b) = linear_equiv.refl k V₁ :=\n rfl\n\n@[simp] theorem vadd_const_apply (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (b : P₁) (v : V₁) : coe_fn (vadd_const k b) v = v +ᵥ b :=\n rfl\n\n@[simp] theorem vadd_const_symm_apply (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (b : P₁) (p : P₁) : coe_fn (symm (vadd_const k b)) p = p -ᵥ b :=\n rfl\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef const_vsub (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (p : P₁) : affine_equiv k P₁ V₁ :=\n mk (equiv.const_vsub p) (linear_equiv.neg k) sorry\n\n@[simp] theorem coe_const_vsub (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (p : P₁) : ⇑(const_vsub k p) = has_vsub.vsub p :=\n rfl\n\n@[simp] theorem coe_const_vsub_symm (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (p : P₁) : ⇑(symm (const_vsub k p)) = fun (v : V₁) => -v +ᵥ p :=\n rfl\n\n/-- The map `p ↦ v +ᵥ p` as an affine automorphism of an affine space. -/\ndef const_vadd (k : Type u_1) {V₁ : Type u_2} (P₁ : Type u_6) [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (v : V₁) : affine_equiv k P₁ P₁ :=\n mk (equiv.const_vadd P₁ v) (linear_equiv.refl k V₁) sorry\n\n@[simp] theorem linear_const_vadd (k : Type u_1) {V₁ : Type u_2} (P₁ : Type u_6) [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (v : V₁) : linear (const_vadd k P₁ v) = linear_equiv.refl k V₁ :=\n rfl\n\n@[simp] theorem const_vadd_apply (k : Type u_1) {V₁ : Type u_2} (P₁ : Type u_6) [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (v : V₁) (p : P₁) : coe_fn (const_vadd k P₁ v) p = v +ᵥ p :=\n rfl\n\n@[simp] theorem const_vadd_symm_apply (k : Type u_1) {V₁ : Type u_2} (P₁ : Type u_6) [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (v : V₁) (p : P₁) : coe_fn (symm (const_vadd k P₁ v)) p = -v +ᵥ p :=\n rfl\n\n/-- Point reflection in `x` as a permutation. -/\ndef point_reflection (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (x : P₁) : affine_equiv k P₁ P₁ :=\n trans (const_vsub k x) (vadd_const k x)\n\ntheorem point_reflection_apply (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (x : P₁) (y : P₁) : coe_fn (point_reflection k x) y = x -ᵥ y +ᵥ x :=\n rfl\n\n@[simp] theorem point_reflection_symm (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (x : P₁) : symm (point_reflection k x) = point_reflection k x :=\n injective_to_equiv (equiv.point_reflection_symm x)\n\n@[simp] theorem to_equiv_point_reflection (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (x : P₁) : to_equiv (point_reflection k x) = equiv.point_reflection x :=\n rfl\n\n@[simp] theorem point_reflection_self (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (x : P₁) : coe_fn (point_reflection k x) x = x :=\n vsub_vadd x x\n\ntheorem point_reflection_involutive (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (x : P₁) : function.involutive ⇑(point_reflection k x) :=\n equiv.point_reflection_involutive x\n\n/-- `x` is the only fixed point of `point_reflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem point_reflection_fixed_iff_of_injective_bit0 (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] {x : P₁} {y : P₁} (h : function.injective bit0) : coe_fn (point_reflection k x) y = y ↔ y = x :=\n equiv.point_reflection_fixed_iff_of_injective_bit0 h\n\ntheorem injective_point_reflection_left_of_injective_bit0 (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (h : function.injective bit0) (y : P₁) : function.injective fun (x : P₁) => coe_fn (point_reflection k x) y :=\n equiv.injective_point_reflection_left_of_injective_bit0 h y\n\ntheorem injective_point_reflection_left_of_module (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [invertible (bit0 1)] (y : P₁) : function.injective fun (x : P₁) => coe_fn (point_reflection k x) y := sorry\n\ntheorem point_reflection_fixed_iff_of_module (k : Type u_1) {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] [invertible (bit0 1)] {x : P₁} {y : P₁} : coe_fn (point_reflection k x) y = y ↔ y = x :=\n iff.trans (function.injective.eq_iff' (injective_point_reflection_left_of_module k y) (point_reflection_self k y))\n eq_comm\n\nend affine_equiv\n\n\nnamespace affine_map\n\n\ntheorem line_map_vadd {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (v : V₁) (v' : V₁) (p : P₁) (c : k) : coe_fn (line_map v v') c +ᵥ p = coe_fn (line_map (v +ᵥ p) (v' +ᵥ p)) c :=\n affine_equiv.apply_line_map (affine_equiv.vadd_const k p) v v' c\n\ntheorem line_map_vsub {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (p₁ : P₁) (p₂ : P₁) (p₃ : P₁) (c : k) : coe_fn (line_map p₁ p₂) c -ᵥ p₃ = coe_fn (line_map (p₁ -ᵥ p₃) (p₂ -ᵥ p₃)) c :=\n affine_equiv.apply_line_map (affine_equiv.symm (affine_equiv.vadd_const k p₃)) p₁ p₂ c\n\ntheorem vsub_line_map {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (p₁ : P₁) (p₂ : P₁) (p₃ : P₁) (c : k) : p₁ -ᵥ coe_fn (line_map p₂ p₃) c = coe_fn (line_map (p₁ -ᵥ p₂) (p₁ -ᵥ p₃)) c :=\n affine_equiv.apply_line_map (affine_equiv.const_vsub k p₁) p₂ p₃ c\n\ntheorem vadd_line_map {k : Type u_1} {V₁ : Type u_2} {P₁ : Type u_6} [ring k] [add_comm_group V₁] [semimodule k V₁] [add_torsor V₁ P₁] (v : V₁) (p₁ : P₁) (p₂ : P₁) (c : k) : v +ᵥ coe_fn (line_map p₁ p₂) c = coe_fn (line_map (v +ᵥ p₁) (v +ᵥ p₂)) c :=\n affine_equiv.apply_line_map (affine_equiv.const_vadd k P₁ v) p₁ p₂ c\n\ntheorem homothety_neg_one_apply {V₁ : Type u_2} {P₁ : Type u_6} [add_comm_group V₁] [add_torsor V₁ P₁] {R' : Type u_10} [comm_ring R'] [semimodule R' V₁] (c : P₁) (p : P₁) : coe_fn (homothety c (-1)) p = coe_fn (affine_equiv.point_reflection R' c) p := sorry\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/linear_algebra/affine_space/affine_equiv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.47657965106367595, "lm_q1q2_score": 0.24015142691958236}} {"text": "import tactic.interactive\n\nexample : ¬ ∀ (α : Type) (r : Prop), r → (∃ x : α, r) :=\nbegin\n intro h,\n cases h empty _ true.intro with w,\n cases w\nend\n\nexample (α : Type) [inhabited α] (r : Prop) : r → (∃ x : α, r) :=\nλ h, ⟨inhabited.default α, h⟩\n\n#print foo\n", "meta": {"author": "AtnNn", "repo": "lean-sandbox", "sha": "8c68afbdc09213173aef1be195da7a9a86060a97", "save_path": "github-repos/lean/AtnNn-lean-sandbox", "path": "github-repos/lean/AtnNn-lean-sandbox/lean-sandbox-8c68afbdc09213173aef1be195da7a9a86060a97/src/stackoverflow/exists_of_prop.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5428632831725051, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.2397680579437671}} {"text": "import new.ordered.C_o\nimport algebra.homology.homological_complex\nimport algebra.category.Group.abelian\nimport algebra.homology.homology\nimport topology.sheaves.sheaf_condition.unique_gluing\n-- import new.refinement\n\nnoncomputable theory\n\nsection\n\nopen topological_space Top Top.sheaf\nopen category_theory\nopen category_theory.limits\nopen opposite\nopen nat\n\nopen_locale big_operators\n\nuniverse u\nvariables {X : Top.{u}} (𝓕 : sheaf Ab X) (U V : X.oc)\n\nsection\n\nvariables {U}\n\ndef vec_o.single (i : U.ι) : vec_o U 1 :=\n{ to_fun := λ _, i,\n is_strict_mono := λ ⟨i, hi⟩ ⟨j, hj⟩ (h : i < j), by linarith }\n\ndef vec_o.double {i j : U.ι} (h : i < j) :\n vec_o U 2 :=\n{ to_fun := ![i, j],\n is_strict_mono := begin\n intros m n ineq,\n fin_cases m;\n fin_cases n,\n { exfalso, exact lt_irrefl _ ineq, },\n { exact h },\n { have triv : ¬ 1 < 0,\n { rw not_lt,\n linarith, },\n exfalso, exact triv ineq, },\n { exfalso, exact lt_irrefl _ ineq, },\n end }\n\nlemma vec_o.double_apply0 {i j : U.ι} (h : i < j) :\n vec_o.double h 0 = i :=\nbegin\n change ![i, j] 0 = i,\n simp only [matrix.cons_val_zero],\nend\n\nlemma vec_o.double_apply1 {i j : U.ι} (h : i < j) :\n vec_o.double h 1 = j :=\nbegin\n change ![i, j] 1 = j,\n simp only [matrix.cons_val_one, matrix.head_cons],\nend\n\nlemma vec_o.double_ignore0 {i j : U.ι} (h : i < j) :\n ignore_o (vec_o.double h) 0 = vec_o.single j :=\nsorry\n\nlemma vec_o.double_ignore1 {i j : U.ι} (h : i < j) :\n ignore_o (vec_o.double h) 1 = vec_o.single i :=\nsorry\n\nlemma face.vec_o_single (i : U.ι) :\n face_o (vec_o.single i) = U.cover i :=\nbegin\n change face (vec_o.single i) = _,\n ext,\n split;\n intros hx;\n rw opens.mem_coe at hx ⊢,\n { erw opens.fintype_infi at hx,\n specialize hx 0,\n convert hx, },\n { erw opens.fintype_infi,\n rintros ⟨i, hi⟩,\n interval_cases i,\n convert hx, },\nend\n\nlemma face.double_le_single1 {i j : U.ι} (h : i < j) :\n face_o (vec_o.double h) ≤ face_o (vec_o.single i) := sorry\n\nlemma face.double_le_single2 {i j : U.ι} (h : i < j) :\n face_o (vec_o.double h) ≤ face_o (vec_o.single j) := sorry\n\n\nend\n\ndef d_o_from_to (i j : ℕ) : C_o 𝓕 U i ⟶ C_o 𝓕 U j :=\ndite (j = i + 1)\n(λ h, d_o 𝓕 U i ≫ eq_to_hom (by rw h))\n(λ h, 0)\n\nlemma d_o_to_succ {i : ℕ} (f α) :\n d_o_from_to 𝓕 U i (i + 1) f α = d_o 𝓕 U i f α :=\nbegin\n rw [d_o_from_to],\n rw dif_pos rfl,\n rw comp_apply,\n refl,\nend\n\nlemma d_o_to_succ' (i : ℕ) :\n d_o_from_to 𝓕 U i (i + 1) = d_o 𝓕 U i :=\nbegin\n ext f α,\n rw d_o_from_to,\n rw dif_pos rfl,\n refl,\nend\n\nlemma d_o_not_to_succ {i j : ℕ} (h : j ≠ i + 1) (f α) :\n d_o_from_to 𝓕 U i j f α = 0 :=\nbegin\n rw [d_o_from_to, dif_neg h],\n refl,\nend\n\ndef Cech_complex_wrt_cover_ordered : cochain_complex Ab.{u} ℕ :=\n{ X := λ n, C_o 𝓕 U (n + 1),\n d := λ i j, d_o_from_to 𝓕 U _ _,\n shape' := λ i j h, begin\n ext f α,\n rw d_o_not_to_succ,\n rw [add_monoid_hom.zero_apply, pi.zero_apply],\n simp only [complex_shape.up_rel] at h,\n contrapose! h,\n symmetry,\n simpa [add_left_inj] using h,\n end,\n d_comp_d' := λ i j k h1 h2, begin\n simp only [complex_shape.up_rel] at h1 h2,\n subst' h2,\n subst' h1,\n ext f α,\n rw comp_apply,\n rw d_o_to_succ,\n rw d_o_to_succ',\n simp only [AddCommGroup.zero_apply, pi.zero_apply],\n rw dd_o_eq_zero,\n end }\n\nlemma Cech_complex_wrt_cover_ordered.d_to_rel\n (n : ℕ) (m) (h : (complex_shape.up ℕ).prev n = some m) :\n (Cech_complex_wrt_cover_ordered 𝓕 U).d m.1 n =\n d_o 𝓕 U (m.1 + 1) ≫ eq_to_hom begin\n have := m.2,\n simp only [complex_shape.up_rel] at this,\n rw this,\n refl,\n end :=\nbegin\n change d_o_from_to 𝓕 U _ _ = _,\n rw [d_o_from_to, dif_pos],\n refl,\n rw add_left_inj,\n exact m.2.symm,\nend\n\ndef Cech_Cohomology_Group_wrt_cover_ordered_nth (n : ℕ) : Ab :=\n@homological_complex.homology ℕ Ab _ _ (complex_shape.up ℕ) (abelian.has_zero_object) _ _ _\n (Cech_complex_wrt_cover_ordered 𝓕 U) n\n\nsection zeroth\n\ndef ex1 :\n Cech_Cohomology_Group_wrt_cover_ordered_nth 𝓕 U 0 ≅\n kernel ((Cech_complex_wrt_cover_ordered 𝓕 U).d 0 1) :=\nbegin\n refine homology_iso_cokernel_image_to_kernel' _ _ _ ≪≫ _,\n change cokernel (kernel.lift _ _ _) ≅ _,\n\n simp only [image.ι_zero', homological_complex.d_to_eq_zero, cochain_complex.prev_nat_zero, eq_self_iff_true, kernel.lift_zero],\n refine cokernel_zero_iso_target ≪≫ _,\n refine AddCommGroup.kernel_iso_ker _ ≪≫ _,\n refine _ ≪≫ (AddCommGroup.kernel_iso_ker (d_o 𝓕 U _)).symm,\n refine { hom := _, inv := _, hom_inv_id' := _, inv_hom_id' := _ },\n { refine { to_fun := _, map_zero' := _, map_add' := _ },\n { intros x,\n refine ⟨x.1, _⟩,\n rw add_monoid_hom.mem_ker,\n have := x.2,\n rw add_monoid_hom.mem_ker at this,\n have eq1 := homological_complex.d_from_eq (Cech_complex_wrt_cover_ordered 𝓕 U) (show 1 = 0 + 1, from rfl),\n generalize_proofs h1 h2 at eq1,\n change _ = d_o _ _ _ ≫ _ at eq1,\n have eq2 : homological_complex.d_from (Cech_complex_wrt_cover_ordered 𝓕 U) 0 x.1 = (d_o 𝓕 _ _ ≫ (homological_complex.X_next_iso (Cech_complex_wrt_cover_ordered 𝓕 U) h1).inv) x.1,\n { apply congr_fun,\n simpa only [fun_like.coe_fn_eq] using eq1, },\n apply_fun (homological_complex.X_next_iso (Cech_complex_wrt_cover_ordered 𝓕 U) h1).hom at eq2,\n rw comp_apply at eq2,\n rw this at eq2,\n simp only [map_zero, coe_inv_hom_id] at eq2,\n rw ←eq2, \n },\n { rw subtype.ext_iff_val,\n refl, },\n { intros x1 x2, \n rw subtype.ext_iff_val,\n refl, } },\n { refine { to_fun := _, map_zero' := _, map_add' := _ },\n { intros x,\n refine ⟨x.1, _⟩,\n have := x.2,\n rw add_monoid_hom.mem_ker at this ⊢,\n have eq1 := homological_complex.d_from_eq (Cech_complex_wrt_cover_ordered 𝓕 U) (show 1 = 0 + 1, from rfl),\n erw eq1,\n rw comp_apply,\n generalize_proofs h1 h2,\n apply_fun (homological_complex.X_next_iso (Cech_complex_wrt_cover_ordered 𝓕 U) h1).hom,\n simp only [coe_inv_hom_id, map_zero],\n convert this,\n apply function.bijective.injective,\n rw function.bijective_iff_has_inverse,\n use (homological_complex.X_next_iso (Cech_complex_wrt_cover_ordered 𝓕 U) h1).inv,\n refine ⟨_, _⟩,\n intros x,\n rw coe_hom_inv_id,\n intros x,\n rw coe_inv_hom_id, },\n { rw subtype.ext_iff_val,\n refl },\n { intros x y,\n rw subtype.ext_iff_val,\n refl, } },\n { ext1 σ,\n simp only [comp_apply, subtype.val_eq_coe, add_subgroup.coe_mk, add_monoid_hom.coe_mk, set_like.eta, id_apply] },\n { ext1 σ,\n simp only [comp_apply, subtype.val_eq_coe, add_subgroup.coe_mk, add_monoid_hom.coe_mk, set_like.eta, id_apply] },\nend\n\ndef ex2 :\n kernel ((Cech_complex_wrt_cover_ordered 𝓕 U).d 0 1) ≅\n kernel (d_o 𝓕 U 1) :=\neq_to_iso rfl\n\ndef ex3 :\n kernel (d_o 𝓕 U 1) ≅\n AddCommGroup.of (add_monoid_hom.ker (d_o 𝓕 U 1)) :=\nAddCommGroup.kernel_iso_ker _\n\nlemma ex41.forward.aux1 {i j : U.ι} {f : C_o 𝓕 U 1} \n (h : d_o _ _ _ f = 0) :\n 𝓕.1.map ((U.cover i).inf_le_left (U.cover j) ≫ eq_to_hom begin\n rw ← face.vec_o_single,\n refl,\n end).op (f (vec_o.single i)) = \n 𝓕.1.map (hom_of_le begin\n convert inf_le_left,\n rw ← face.vec_o_single,\n refl,\n end).op (f (vec_o.single i)) :=\nbegin\n congr,\nend\n\nlemma ex41.forward.aux1' {i j : U.ι} {f : C_o 𝓕 U 1} \n (h : d_o _ _ _ f = 0) :\n 𝓕.1.map ((U.cover i).inf_le_right (U.cover j) ≫ eq_to_hom begin\n rw ← face.vec_o_single,\n refl,\n end).op (f (vec_o.single j)) = \n 𝓕.1.map (hom_of_le begin\n convert inf_le_right,\n rw ← face.vec_o_single,\n refl,\n end).op (f (vec_o.single j)) :=\nbegin\n congr,\nend\n\nlemma ex41.forward.aux2 {i j : U.ι} {f : C_o 𝓕 U 1} \n (h : d_o _ _ _ f = 0) :\n 𝓕.1.map ((U.cover i).inf_le_right (U.cover j) ≫ eq_to_hom begin\n rw ← face.vec_o_single,\n refl,\n end).op (f (vec_o.single j)) = \n 𝓕.1.map (hom_of_le begin\n convert inf_le_right,\n rw ← face.vec_o_single,\n refl,\n end).op (f (vec_o.single j)) :=\nbegin\n congr,\nend\n\nlemma ex41.forward.aux2' {i j : U.ι} {f : C_o 𝓕 U 1} \n (h : d_o _ _ _ f = 0) :\n 𝓕.1.map ((U.cover i).inf_le_left (U.cover j) ≫ eq_to_hom begin\n rw ← face.vec_o_single,\n refl,\n end).op (f (vec_o.single i)) = \n 𝓕.1.map (hom_of_le begin\n convert inf_le_left,\n rw ← face.vec_o_single,\n refl,\n end).op (f (vec_o.single i)) :=\nbegin\n congr,\nend\n\nlemma ex41.forward.aux3 {i j : U.ι} (ineq : i < j) (f : C_o 𝓕 U 1) :\n 𝓕.1.map (hom_of_le (face.le_ignore_o _ _)).op (f (ignore_o (vec_o.double ineq) 0)) =\n 𝓕.1.map ((hom_of_le (face.double_le_single2 ineq))).op (f (vec_o.single j)) :=\nbegin\n generalize_proofs _ h1 h2,\n rw map_congr.vec_o_eq f (vec_o.double_ignore0 ineq),\n rw [← comp_apply, ← 𝓕.1.map_comp],\n congr,\nend\n\nlemma ex41.forward.aux3' {i j : U.ι} (ineq : j < i) (f : C_o 𝓕 U 1) :\n 𝓕.1.map (hom_of_le (face.le_ignore_o _ _)).op \n (f (ignore_o (vec_o.double ineq) 0)) =\n 𝓕.1.map \n (hom_of_le (face.double_le_single2 ineq)).op \n (f (vec_o.single i)) \n :=\nbegin\n generalize_proofs _ h1 h2 h3 h4 h5,\n rw map_congr.vec_o_eq f (vec_o.double_ignore0 ineq),\n rw [← comp_apply, ← 𝓕.1.map_comp],\n congr,\nend\n\nlemma ex41.forward.aux4 {i j : U.ι} (ineq : i < j) (f : C_o 𝓕 U 1) :\n 𝓕.1.map (hom_of_le (face.le_ignore_o _ _)).op (f (ignore_o (vec_o.double ineq) 1)) =\n 𝓕.1.map (hom_of_le (face.double_le_single1 ineq)).op (f (vec_o.single i)) \n :=\nbegin\n generalize_proofs _ h1 h2,\n rw map_congr.vec_o_eq f (vec_o.double_ignore1 ineq),\n rw [← comp_apply, ← 𝓕.1.map_comp],\n congr,\nend\n\nlemma ex41.forward.aux4' {i j : U.ι} (ineq : j < i) (f : C_o 𝓕 U 1) :\n 𝓕.1.map (hom_of_le (face.le_ignore_o _ _)).op \n (f (ignore_o (vec_o.double ineq) 1)) =\n 𝓕.1.map \n (hom_of_le (face.double_le_single1 ineq)).op \n (f (vec_o.single j)) \n :=\nbegin\n generalize_proofs _ h1 h2,\n rw map_congr.vec_o_eq f (vec_o.double_ignore1 ineq),\n rw [← comp_apply, ← 𝓕.1.map_comp],\n congr,\nend\n\nlemma ex41.forward.aux5 (f : C_o 𝓕 U 1) \n (o1 o2 o3 o4 : opens X)\n (oop2 : 𝓕.val.obj (op o2))\n (oop3 : 𝓕.val.obj (op o3))\n-- o1 : face ij\n-- o2 : face i\n-- o3 : face j\n-- o4 : cover i ⊓ cover j\n (h12 : o1 ≤ o2)\n (h13 : o1 ≤ o3)\n (h42 : o4 ≤ o2)\n (h43 : o4 ≤ o3)\n (h14 : o4 ≤ o1)\n (eq1 : 𝓕.1.map (hom_of_le h12).op oop2 = 𝓕.1.map (hom_of_le h13).op oop3) : \n 𝓕.1.map (hom_of_le h42).op oop2 = 𝓕.1.map (hom_of_le h43).op oop3 :=\nbegin\n have : hom_of_le h42 = hom_of_le h14 ≫ hom_of_le h12,\n { ext, },\n rw this,\n have : hom_of_le h43 = hom_of_le h14 ≫ hom_of_le h13,\n { ext },\n rw this,\n rw [op_comp, category_theory.functor.map_comp, op_comp, category_theory.functor.map_comp],\n rw [comp_apply, comp_apply, eq1],\nend\n\nlemma ker_compatible (f : add_monoid_hom.ker (d_o 𝓕 U 1)) : \n presheaf.is_compatible 𝓕.1 U.cover \n (λ i, begin\n refine 𝓕.1.map (eq_to_hom _).op (f.1 (vec_o.single i)),\n rw ← face.vec_o_single,\n refl,\n end) :=\nbegin\n intros i j,\n have := f.2,\n rw add_monoid_hom.mem_ker at this,\n \n rcases @trichotomous U.ι (<) _ i j with ineq|ineq|ineq,\n { dsimp only,\n change (𝓕.1.map _ ≫ _) _ = (𝓕.1.map _ ≫ _) _,\n rw [← category_theory.functor.map_comp, ← category_theory.functor.map_comp, ← op_comp, ← op_comp],\n rw ex41.forward.aux1 _ _ this,\n rw ex41.forward.aux2 _ _ this,\n\n have eq1 : d_o _ _ _ f.1 (vec_o.double ineq) = 0,\n { rw this, simp, },\n simp only [d_o_small.d_o.one_apply] at eq1,\n rw sub_eq_zero at eq1,\n rw ex41.forward.aux3 at eq1,\n have eq2 := eq.trans eq1 (ex41.forward.aux4 𝓕 U ineq f.1),\n \n refine ex41.forward.aux5 𝓕 U f.1 (face_o (vec_o.double ineq)) \n (face_o (vec_o.single i))\n (face_o (vec_o.single j))\n (U.cover i ⊓ U.cover j)\n (f.val (vec_o.single i))\n (f.val (vec_o.single j))\n _ _ _ _ _ _,\n { apply face.double_le_single1, },\n { apply face.double_le_single2, },\n { intros p hp,\n rcases hp with ⟨hp1, hp2⟩,\n rw opens.mem_coe at hp1 hp2 ⊢,\n erw opens.fintype_infi,\n intros k,\n fin_cases k,\n { rwa vec_o.double_apply0, },\n { rwa vec_o.double_apply1, }, },\n { exact eq2.symm, }, },\n { subst ineq, refl, },\n { dsimp only,\n change (𝓕.1.map _ ≫ _) _ = (𝓕.1.map _ ≫ _) _,\n rw [← category_theory.functor.map_comp, ← category_theory.functor.map_comp, ← op_comp, ← op_comp],\n rw ex41.forward.aux1' _ _ this,\n rw ex41.forward.aux2' _ _ this,\n\n have eq1 : d_o _ _ _ f.1 (vec_o.double ineq) = 0,\n { rw this, simp, },\n simp only [d_o_small.d_o.one_apply] at eq1,\n change _ - _ = _ at eq1,\n rw sub_eq_zero at eq1,\n dsimp only at eq1,\n rw ex41.forward.aux3' at eq1,\n have eq2 := eq.trans eq1 (ex41.forward.aux4' 𝓕 U ineq f.1),\n\n refine ex41.forward.aux5 𝓕 U f.1 \n (face_o (vec_o.double ineq)) \n (face_o (vec_o.single i))\n (face_o (vec_o.single j))\n (U.cover i ⊓ U.cover j)\n (f.val (vec_o.single i))\n (f.val (vec_o.single j))\n _ _ _ _ _ _,\n { apply face.double_le_single2, },\n { apply face.double_le_single1, },\n { intros p hp,\n rcases hp with ⟨hp1, hp2⟩,\n rw opens.mem_coe at hp1 hp2 ⊢,\n erw opens.fintype_infi,\n intros k,\n fin_cases k,\n { rwa vec_o.double_apply0, },\n { rwa vec_o.double_apply1, }, },\n { convert eq2, }, },\nend\n\nlemma unique_gluing_prop \n (f : add_monoid_hom.ker (d_o 𝓕 U 1)) :\n ∃! (s : 𝓕.val.obj (op ⊤)),\n ∀ (i : U.ι),\n (𝓕.val.map (hom_of_le le_top).op) s =\n (𝓕.val.map (eq_to_hom (by rw ← face.vec_o_single : U.cover i = (face_o (vec_o.single i)))).op)\n (f.val (vec_o.single i)) :=\nsheaf.exists_unique_gluing' \n 𝓕 U.cover ⊤ \n (λ i, hom_of_le le_top) \n begin\n rw U.is_cover,\n exact le_refl _,\n end \n (λ i, begin\n refine 𝓕.1.map (eq_to_hom _).op (f.1 (vec_o.single i)),\n rw ← face.vec_o_single,\n refl,\n end) \n (ker_compatible 𝓕 U f)\n\ndef unique_gluing (f : add_monoid_hom.ker (d_o 𝓕 U 1)) :\n 𝓕.1.obj (op ⊤) :=\nclassical.some (unique_gluing_prop _ _ f)\n\nlemma unique_gluing_is_glueing \n (f : add_monoid_hom.ker (d_o 𝓕 U 1)) \n (i : U.ι) :\n 𝓕.1.map (hom_of_le le_top).op (unique_gluing _ _ f) = \n 𝓕.1.map (eq_to_hom (begin\n rw ← face.vec_o_single,\n refl,\n end : U.cover i = _)).op (f.1 (vec_o.single i)) := \nbegin\n have := classical.some_spec (unique_gluing_prop _ _ f),\n dsimp only at this,\n rcases this with ⟨h1, h2⟩,\n exact h1 i,\nend\n\nlemma unique_gluing_is_unique \n (f : add_monoid_hom.ker (d_o 𝓕 U 1)) \n (s : 𝓕.1.obj (op ⊤))\n (is_glue : ∀ (i : U.ι), \n 𝓕.1.map (hom_of_le le_top).op s = \n 𝓕.1.map (eq_to_hom (begin\n rw ← face.vec_o_single,\n refl,\n end : U.cover i = _)).op (f.1 (vec_o.single i))) :\n (unique_gluing _ _ f) = s :=\nbegin\n have := classical.some_spec (unique_gluing_prop _ _ f),\n dsimp only at this,\n rcases this with ⟨h1, h2⟩,\n symmetry,\n apply h2,\n assumption,\nend\n\ndef ex41.forward :\n (AddCommGroup.of $ add_monoid_hom.ker (d_o 𝓕 U 1)) ⟶ 𝓕.1.obj (op ⊤) :=\n{ to_fun := λ f, unique_gluing _ _ f,\n map_zero' := begin\n apply unique_gluing_is_unique,\n intros i,\n simp,\n end,\n map_add' := λ f g, begin\n apply unique_gluing_is_unique,\n intros i,\n rw map_add,\n erw map_add,\n congr;\n apply unique_gluing_is_glueing,\n end }\n\nlemma inj :\n function.injective (ex41.forward 𝓕 U) :=\nbegin\n intros f g h,\n change unique_gluing _ _ f = unique_gluing _ _ g at h,\n have h1 := unique_gluing_is_glueing _ _ f,\n rw subtype.ext_iff_val,\n ext σ,\n -- have eq1 : ∃ i, σ.to_finset = {i},\n -- { have := σ.card_eq,\n -- simp only [nat.pred_succ] at this,\n -- rwa finset.card_eq_one at this, },\n -- rcases eq1 with ⟨i, hi⟩,\n specialize h1 (σ 0),\n \n have h2 := unique_gluing_is_glueing _ _ g,\n specialize h2 (σ 0),\n\n rw [eq_to_hom_op, eq_to_hom_map] at h1 h2,\n rw h at h1,\n rw h1 at h2,\n\n have eq2 : σ = vec_o.single (σ 0),\n { ext, rcases x with ⟨x, hx⟩, interval_cases x, refl, },\n rw eq2,\n generalize_proofs _ h3 at h2,\n suffices : function.injective (eq_to_hom h3),\n apply this,\n exact h2,\n\n intros x y h,\n apply_fun (eq_to_hom h3.symm) at h,\n change (eq_to_hom h3 ≫ eq_to_hom h3.symm) x = (eq_to_hom h3 ≫ eq_to_hom h3.symm) y at h,\n rw [eq_to_hom_trans, eq_to_hom_refl] at h_1,\n simpa only using h_1,\nend\n\nlemma surj :\n function.surjective (ex41.forward 𝓕 U) :=\nbegin\n rw function.surjective_iff_has_right_inverse,\n fconstructor,\n { intros s,\n refine ⟨λ σ, _, _⟩,\n exact 𝓕.1.map (hom_of_le le_top).op s,\n rw add_monoid_hom.mem_ker,\n ext σ,\n rw pi.zero_apply,\n rw d_o_small.d_o.one_apply,\n rw sub_eq_zero,\n dsimp only,\n change (𝓕.1.map _ ≫ 𝓕.1.map _) _ = (𝓕.1.map _ ≫ 𝓕.1.map _) _,\n rw [← 𝓕.1.map_comp, ← 𝓕.1.map_comp, ← op_comp],\n refl, },\n { intros s,\n apply unique_gluing_is_unique,\n intros i,\n dsimp only,\n change _ = (𝓕.1.map _ ≫ 𝓕.1.map _) _,\n congr' 1,\n rw ← 𝓕.1.map_comp,\n rw ← op_comp,\n congr' 1,\n },\nend\n\ndef ex41 :\n (AddCommGroup.of $ add_monoid_hom.ker (d_o 𝓕 U 1)) ≃+\n 𝓕.1.obj (op ⊤) :=\nadd_equiv.of_bijective (ex41.forward _ _) ⟨inj _ _, surj _ _⟩\n\n\ndef zeroth_Cech_Cohomology :\n (Cech_Cohomology_Group_wrt_cover_ordered_nth 𝓕 U 0) ≅\n 𝓕.1.obj (op ⊤) :=\nex1 𝓕 U ≪≫ ex2 𝓕 U ≪≫ ex3 𝓕 U ≪≫ \n{ hom := (ex41 _ _).to_add_monoid_hom,\n inv := (ex41 _ _).symm.to_add_monoid_hom,\n hom_inv_id' := begin\n ext f σ,\n simp only [comp_apply, add_equiv.coe_to_add_monoid_hom, add_equiv.symm_apply_apply, id_apply],\n end,\n inv_hom_id' := begin\n ext f σ,\n simp only [comp_apply, add_equiv.coe_to_add_monoid_hom, add_equiv.apply_symm_apply, id_apply],\n end }\n\n\nend zeroth\n\nend", "meta": {"author": "jjaassoonn", "repo": "cc", "sha": "6d3dc6885fa012e8c18fd38ab2949d73777fb442", "save_path": "github-repos/lean/jjaassoonn-cc", "path": "github-repos/lean/jjaassoonn-cc/cc-6d3dc6885fa012e8c18fd38ab2949d73777fb442/src/new/ordered/chain_o.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5428632683808533, "lm_q2_score": 0.44167300566462553, "lm_q1q2_score": 0.23976805141069374}} {"text": "theorem eq_of_isEqvAux [DecidableEq α] (a b : Array α) (hsz : a.size = b.size) (i : Nat) (hi : i ≤ a.size) (heqv : Array.isEqvAux a b hsz (fun x y => x = y) i) : ∀ (j : Nat) (hl : i ≤ j) (hj : j < a.size), a.get ⟨j, hj⟩ = b.get ⟨j, hsz ▸ hj⟩ := by\n intro j low high\n by_cases h : i < a.size\n · unfold Array.isEqvAux at heqv\n simp [h] at heqv\n have hind := eq_of_isEqvAux a b hsz (i+1) (Nat.succ_le_of_lt h) heqv.2\n by_cases heq : i = j\n · subst heq; exact heqv.1\n · exact hind j (Nat.succ_le_of_lt (Nat.lt_of_le_of_ne low heq)) high\n · have heq : i = a.size := Nat.le_antisymm hi (Nat.ge_of_not_lt h)\n subst heq\n exact absurd (Nat.lt_of_lt_of_le high low) (Nat.lt_irrefl j)\ntermination_by _ => a.size - i\n\n@[simp] def f (x y : Nat) : Nat → Nat :=\n if h : x > 0 then\n fun z => f (x - 1) (y + 1) z + 1\n else\n (· + y)\ntermination_by\n f x y => x\n\n#check f._eq_1\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/overAndPartialAppsAtWF.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.46490157137338844, "lm_q1q2_score": 0.23971250905104405}} {"text": "import for_mathlib.derived.K_projective\nimport for_mathlib.homological_complex_op\nimport for_mathlib.homology_iso_Ab\n\nnoncomputable theory\n\nuniverses v u\n\nopen category_theory category_theory.limits category_theory.preadditive\n\nvariables {C : Type u} {ι : Type*} [category.{v} C] [abelian C] {c : complex_shape ι}\n\ndef homotopy_category.quotient_map_hom (A B : homological_complex C c) :\n (A ⟶ B) →+ ((homotopy_category.quotient C c).obj A ⟶ (homotopy_category.quotient C c).obj B) :=\nadd_monoid_hom.mk' (λ f, (homotopy_category.quotient C c).map f) $ λ f g, rfl\n\nlemma quot.mk_surjective {X : Type*} (r : X → X → Prop) :\n function.surjective (quot.mk r) :=\nλ x, quot.induction_on x $ λ x, ⟨x, rfl⟩\n\nnoncomputable\ndef homotopy.to_single [decidable_eq ι] [decidable_rel c.rel] {X : homological_complex C c} {B : C}\n {i j : ι} (r : c.rel i j)\n (f g : X ⟶ (homological_complex.single C c i).obj B) (h : X.X j ⟶ B)\n (H : f.f i = X.d i j ≫ h ≫ eq_to_hom (if_pos rfl).symm + g.f i) :\n homotopy f g :=\n{ hom := λ i₁ i₂, if r' : c.rel i₂ i₁ then if e : i₂ = i then\n (X.X_eq_to_iso (c.next_eq (e ▸ r' : c.rel i i₁) r)).hom ≫ h ≫ eq_to_hom (if_pos e).symm\n else 0 else 0,\n zero' := λ _ _ e, dif_neg e,\n comm := λ k, begin\n dsimp,\n by_cases hki : k = i,\n swap, { apply is_zero.eq_of_tgt, dsimp, rw if_neg hki, exact is_zero_zero _ },\n subst hki,\n rw [← d_next_eq_d_from_from_next, ← prev_d_eq_to_prev_d_to,\n d_next_eq _ r, dif_pos r, dif_pos rfl, X.X_eq_to_iso_refl, category.id_comp, H],\n nth_rewrite_lhs 0 ← add_monoid.add_zero (X.d k j ≫ h ≫ eq_to_hom _),\n congr,\n by_cases aux : c.rel (c.prev k) k,\n { rw [prev_d_eq _ aux, dif_pos aux],\n by_cases hk : c.prev k = k,\n { rw [dif_pos hk, eq_comm], apply comp_zero },\n { rw [dif_neg hk, zero_comp], refl, } },\n { delta prev_d, dsimp only [add_monoid_hom.mk'_apply],\n rw [dif_neg aux, zero_comp], refl }\n end }\n\nlemma homotopic_to_single_iff [decidable_eq ι] {X : homological_complex C c}\n {B : C} {i j : ι} (r : c.rel i j)\n (f g : X ⟶ (homological_complex.single C c i).obj B) :\n homotopic _ _ f g ↔\n ∃ (h : X.X j ⟶ B), f.f i = X.d i j ≫ h ≫ eq_to_hom (if_pos rfl).symm + g.f i :=\nbegin\n haveI : decidable_rel c.rel := λ _ _, classical.dec _,\n refine ⟨_, λ ⟨h, H⟩, ⟨homotopy.to_single r f g h H⟩⟩,\n rintro ⟨h⟩,\n use h.hom j i ≫ eq_to_hom (if_pos rfl),\n rw [category.assoc, eq_to_hom_trans, eq_to_hom_refl, category.comp_id, ← add_zero (_ ≫ _)],\n have := h.comm i,\n rw [d_next_eq _ r] at this,\n convert this,\n delta prev_d, dsimp only [add_monoid_hom.mk'_apply],\n rw eq_comm, apply comp_zero,\nend\n\ninstance : decidable_rel (complex_shape.up ℤ).rel :=\nλ i j, show decidable (i + 1 = j), by apply_instance\n\n@[simps] noncomputable\ndef homological_complex.hom_single_iso\n (P : cochain_complex C ℤ) (B : C) (i : ℤ) :\n (P ⟶ (homological_complex.single C (complex_shape.up ℤ) i).obj B) ≃+\n (add_monoid_hom.ker ((((preadditive_yoneda.obj B).map_homological_complex\n (complex_shape.up ℤ).symm).obj P.op).d i (i - 1))) :=\n{ to_fun := λ f, begin\n refine ⟨f.f i ≫ eq_to_hom (if_pos rfl), _⟩,\n change P.d (i - 1) i ≫ f.f i ≫ eq_to_hom _ = 0,\n rw ← f.comm_assoc,\n dsimp,\n rw [zero_comp, comp_zero],\n end,\n inv_fun := λ f, begin\n refine ⟨λ j, if e : j = i then\n (P.X_eq_to_iso $ e).hom ≫ f.1 ≫ eq_to_hom (if_pos e).symm else 0, _⟩,\n rintros j k (rfl : j + 1 = k),\n dsimp,\n rw comp_zero,\n split_ifs,\n { have := eq_sub_iff_add_eq.mpr h, subst this,\n rw [P.X_d_eq_to_iso_assoc, ← category.assoc, ← subtype.val_eq_coe,\n show P.d (i - 1) i ≫ f.1 = 0, from f.2, zero_comp] },\n { exact comp_zero.symm }\n end,\n left_inv := begin\n intro f,\n ext j,\n dsimp,\n split_ifs,\n { subst h, simp },\n { apply is_zero.eq_of_tgt, rw if_neg h, exact is_zero_zero _ }\n end,\n right_inv := λ f, by { ext, dsimp, simp },\n map_add' := λ f g, subtype.ext (preadditive.add_comp _ _ _ _ _ _) }\n\nnamespace bounded_homotopy_category\n\nnamespace hom_single_iso_setup\n\ndef hom_complex\n (P : bounded_homotopy_category C) (B : C) :=\n((preadditive_yoneda.obj B).map_homological_complex _).obj P.val.as.op\n\ndef map_hom_complex\n {P₁ P₂ : bounded_homotopy_category C} (f : P₁ ⟶ P₂) (B : C) :\n hom_complex P₂ B ⟶ hom_complex P₁ B :=\n(((preadditive_yoneda.obj B).map_homological_complex _).map\n (homological_complex.op_functor.map f.out.op))\n\ndef map_hom_complex'\n (P : bounded_homotopy_category C) {B₁ B₂ : C} (f : B₁ ⟶ B₂) :\n hom_complex P B₁ ⟶ hom_complex P B₂ :=\n(nat_trans.map_homological_complex (preadditive_yoneda.map f) _).app _\n\ndef aux₁\n (P : bounded_homotopy_category C) (B : C) (i : ℤ) :\n homology\n ((hom_complex P B).d (i+1) i)\n ((hom_complex P B).d i (i-1))\n ((hom_complex P B).d_comp_d _ _ _) ≅\n (hom_complex P B).homology i :=\n(homology_iso' (hom_complex P B) (i+1) i (i-1) (by simp) (by simp)).symm\n\ndef map_homology\n {P₁ P₂ : bounded_homotopy_category C} (f : P₁ ⟶ P₂) (B : C) (i : ℤ) :\n homology ((hom_complex P₂ B).d (i + 1) i) ((hom_complex P₂ B).d i (i - 1))\n ((hom_complex _ B).d_comp_d _ _ _) ⟶\n homology ((hom_complex P₁ B).d (i + 1) i) ((hom_complex P₁ B).d i (i - 1))\n ((hom_complex _ B).d_comp_d _ _ _) :=\nhomology.map _ _\n(arrow.hom_mk $ (map_hom_complex f B).comm _ _)\n(arrow.hom_mk $ (map_hom_complex f B).comm _ _)\nrfl\n\nlemma aux₁_naturality\n (P₁ P₂ : bounded_homotopy_category C) (f : P₁ ⟶ P₂) (B : C) (i : ℤ) :\n (aux₁ P₂ B i).hom ≫ (homology_functor _ _ _).map (map_hom_complex f B) =\n (map_homology f _ _) ≫ (aux₁ P₁ B i).hom :=\nbegin\n dsimp only [map_homology, aux₁, homology_iso', iso.symm_hom, homology.map_iso,\n homology_functor_map],\n rw homology.map_eq_desc'_lift_left,\n rw homology.map_eq_lift_desc'_left,\n rw homology.map_eq_desc'_lift_left,\n rw homology.map_eq_lift_desc'_left,\n apply homology.hom_from_ext, apply homology.hom_to_ext,\n simp only [homology.π'_desc', category.assoc, homology.π'_desc'_assoc,\n homology.lift_ι, homology.lift_ι_assoc],\n let t := _, change t ≫ _ = _,\n have ht : t = kernel.lift _ (kernel.ι _) _ ≫ homology.π' _ _ _,\n rotate 2,\n { rw homological_complex.d_from_eq,\n rw [kernel.condition_assoc, zero_comp],\n simp, },\n { apply homology.hom_to_ext,\n simp, dsimp, simp },\n rw ht, clear ht, clear t,\n simp only [kernel.lift_ι_assoc, category.assoc, arrow.hom_mk_left, arrow.iso_mk_inv_left,\n iso.refl_inv, homological_complex.hom.sq_from_left, homology.π'_desc'],\n let t := _, change _ = _ ≫ t,\n have ht : t = homology.ι _ _ _ ≫ cokernel.desc _ (cokernel.π _) _,\n rotate 2,\n { have := (hom_complex P₁ B).d_to_eq (by simp : (complex_shape.up ℤ).symm.rel (i+1) i),\n rw ← iso.inv_comp_eq at this,\n rw [← this, category.assoc, cokernel.condition, comp_zero] },\n { apply homology.hom_from_ext,\n simp, dsimp, simp },\n rw ht, clear ht, clear t,\n simp only [category.assoc, cokernel.π_desc, homology.lift_ι_assoc],\nend\n\ndef aux₂\n (P : bounded_homotopy_category C) (B : C) (i : ℤ) :\n homology\n ((hom_complex P B).d (i+1) i)\n ((hom_complex P B).d i (i-1))\n (homological_complex.d_comp_d _ _ _ _) ≅\n AddCommGroup.homology ((hom_complex P B).d (i+1) i) ((hom_complex P B).d i (i-1)) :=\n(AddCommGroup.homology_iso _ _ _)\n\ndef ker_hom\n {P₁ P₂ : bounded_homotopy_category C} (f : P₁ ⟶ P₂) (B : C) (i : ℤ) :\n ((hom_complex P₂ B).d i (i - 1)).ker →+\n ((hom_complex P₁ B).d i (i - 1)).ker :=\n{ to_fun := λ x, ⟨(map_hom_complex f B).f _ ↑x, begin\n change _ = _,\n have : _ = _ := x.2,\n dsimp [hom_complex, map_hom_complex] at *,\n rw [← category.assoc, ← f.out.comm, category.assoc, this, comp_zero],\n end⟩,\n map_zero' := by { ext, simp },\n map_add' := begin\n intros x y, ext, dsimp [map_hom_complex], simp,\n end }\n\ndef map_explicit_homology\n {P₁ P₂ : bounded_homotopy_category C} (f : P₁ ⟶ P₂) (B : C) (i : ℤ) :\n AddCommGroup.homology ((hom_complex P₂ B).d (i+1) i) ((hom_complex P₂ B).d i (i-1)) ⟶\n AddCommGroup.homology ((hom_complex P₁ B).d (i+1) i) ((hom_complex P₁ B).d i (i-1)) :=\nquotient_add_group.lift _\n(add_monoid_hom.comp (quotient_add_group.mk' _) $ ker_hom f _ _)\nbegin\n rintros ⟨x,(hx : _ = _)⟩ hh,\n dsimp [ker_hom, map_hom_complex],\n rw quotient_add_group.eq_zero_iff,\n rw add_subgroup.mem_comap at *, dsimp at *,\n change ∃ e, _,\n obtain ⟨e,he⟩ := hh,\n dsimp [hom_complex] at *,\n use f.out.f _ ≫ e,\n rw [← category.assoc, ← f.out.comm, category.assoc, he],\nend\n\n--TODO: This relates the above construction to AddcommGroup.homology_map\n-- the above def has more convenient defeq properties for some of the proofs below, but\n-- the `AddCommGroup.homology_map` is better suited for `aux₂_naturality`.\nlemma map_explicit_homology_eq\n {P₁ P₂ : bounded_homotopy_category C} (f : P₁ ⟶ P₂) (B : C) (i : ℤ) :\n map_explicit_homology f B i =\n AddCommGroup.homology_map\n ((hom_complex P₂ B).d_comp_d _ _ _)\n ((hom_complex P₁ B).d_comp_d _ _ _)\n (commsq.of_eq $ ((map_hom_complex f B).comm (i+1) i).symm)\n (commsq.of_eq $ ((map_hom_complex f B).comm i (i-1)).symm) :=\nbegin\n ext ⟨t⟩,\n symmetry, apply AddCommGroup.homology_map_apply_mk,\nend\n\nlemma aux₂_naturality\n (P₁ P₂ : bounded_homotopy_category C) (f : P₁ ⟶ P₂) (B : C) (i : ℤ) :\n (aux₂ P₂ B i).hom ≫ map_explicit_homology f _ _ =\n map_homology f _ _ ≫ (aux₂ P₁ B i).hom :=\nbegin\n rw map_explicit_homology_eq,\n dsimp [aux₂],\n dsimp [AddCommGroup.homology_iso, AddCommGroup.homology_map, map_homology],\n generalize_proofs _ _ w _ w',\n apply (homology.has _ _ w).ext_π,\n apply (AddCommGroup.has_homology _ _ w').ext_ι,\n rw has_homology.homology_map_eq,\n simp only [has_homology.π_map, category.assoc, has_homology.π_map_assoc,\n has_homology.map_ι, has_homology.map_ι_assoc],\n let t := _, change t ≫ _ = _,\n have ht : t = kernel.lift _ (kernel.ι _) _ ≫ (AddCommGroup.has_homology _ _ w).π,\n rotate 2,\n { apply kernel.condition },\n { apply (AddCommGroup.has_homology _ _ w).ext_ι,\n simp [has_homology.π_ι] },\n rw ht, clear ht, clear t,\n let t := _, change _ = _ ≫ t,\n have ht : t = (homology.has _ _ w').ι ≫ cokernel.desc _ (cokernel.π _) _,\n rotate 2,\n { apply cokernel.condition },\n { apply (homology.has _ _ w').ext_π,\n rw [← category.assoc, has_homology.π_ι],\n simp },\n rw ht, clear ht, clear t,\n simp,\nend\n\nlemma aux₂_naturality_inv\n (P₁ P₂ : bounded_homotopy_category C) (f : P₁ ⟶ P₂) (B : C) (i : ℤ) :\n map_explicit_homology f _ _ ≫ (aux₂ P₁ B i).inv =\n (aux₂ P₂ B i).inv ≫ map_homology f _ _ :=\nby rw [iso.comp_inv_eq, category.assoc, iso.eq_inv_comp, aux₂_naturality]\n\ndef aux₃\n (P : bounded_homotopy_category C) (B : C) (i : ℤ) :\n (P ⟶ (single C i).obj B) ≃+\n AddCommGroup.homology ((hom_complex P B).d (i+1) i) ((hom_complex P B).d i (i-1)) :=\nbegin\n refine add_equiv.surjective_congr (homological_complex.hom_single_iso P.val.as B i)\n (homotopy_category.quotient_map_hom _ _)\n (quotient_add_group.mk' _) (quot.mk_surjective _) (quot.mk_surjective _) _,\n ext f,\n dsimp,\n simp only [homotopy_category.quotient_map_hom, quotient_add_group.ker_mk,\n add_equiv.coe_to_add_monoid_hom, add_monoid_hom.mem_ker, add_subgroup.mem_comap,\n add_subgroup.coe_subtype, add_monoid_hom.mk'_apply, add_subgroup.coe_mk,\n add_equiv.coe_mk, add_monoid_hom.mem_range],\n rw ← (homotopy_category.quotient _ _).map_zero,\n any_goals { apply_instance },\n erw quotient.functor_map_eq_iff,\n rw homotopic_to_single_iff (show (complex_shape.up ℤ).rel i (i+1), from rfl),\n apply exists_congr,\n intro g,\n simp only [add_zero, quiver.hom.unop_op, linear_map.to_add_monoid_hom_coe,\n preadditive_yoneda_obj_map_apply, homological_complex.zero_f_apply,\n homological_complex.hom_single_iso_apply_coe],\n rw [← is_iso.comp_inv_eq, eq_comm],\n split,\n { intro h,\n rw [h, is_iso.comp_inv_eq, category.assoc, category.assoc, eq_to_hom_trans,\n eq_to_hom_refl, category.comp_id],\n refl },\n { intro h,\n rw [h, is_iso.eq_comp_inv, category.assoc, category.assoc, eq_to_hom_trans,\n eq_to_hom_refl, category.comp_id],\n refl }\nend\n\nlemma aux₃_apply\n (P : bounded_homotopy_category C) (B : C) (i : ℤ)\n (f : P ⟶ (single C i).obj B) :\n aux₃ P B i f = quotient_add_group.mk ⟨f.out.f i ≫ eq_to_hom (if_pos rfl), begin\n change _ = _, dsimp [hom_complex],\n rw [← category.assoc, ← f.out.comm, category.assoc],\n convert zero_comp,\n apply is_zero.eq_of_tgt, convert is_zero_zero _,\n dsimp [single], rw if_neg, simp,\n end⟩ := rfl\n\nlemma aux₃_naturality\n (P₁ P₂ : bounded_homotopy_category C) (f : P₁ ⟶ P₂) (B : C) (i : ℤ) :\n (map_explicit_homology f B i).comp (aux₃ P₂ B i).to_add_monoid_hom =\n add_monoid_hom.comp (aux₃ P₁ B i).to_add_monoid_hom ((preadditive_yoneda.obj _).map f.op) :=\nbegin\n ext ⟨x⟩,\n dsimp, simp_rw aux₃_apply,\n dsimp [map_explicit_homology, ker_hom, map_hom_complex],\n rw ← sub_eq_zero,\n erw quotient_add_group.eq_zero_iff,\n rw [add_subgroup.mem_comap],\n dsimp [hom_complex],\n -- now we need to use a homotopy...\n simp_rw [← category.assoc, ← homological_complex.comp_f],\n let t := _, let s := _,\n change ∃ _, _ = homological_complex.hom.f t i ≫ _ - homological_complex.hom.f s i ≫ _,\n let hh : homotopy t s := begin\n apply homotopy_category.homotopy_of_eq,\n simpa,\n end,\n let e := hh.hom (i+1) i,\n use e ≫ eq_to_hom (if_pos rfl),\n rw [← preadditive.sub_comp _ _ (eq_to_hom _), ← category.assoc],\n congr' 1,\n erw hh.comm i,\n simp only [homological_complex.cochain_complex_d_next,\n homological_complex.cochain_complex_prev_d, add_sub_cancel,\n self_eq_add_right],\n exact comp_zero,\nend\n\nlemma comp_add_equiv_iso_AddcommGroup_iso_eq_comp\n (X X' B : AddCommGroup.{u}) (e' : X' ≃+ B) (f : X ⟶ X') :\n f ≫ (add_equiv_iso_AddCommGroup_iso.hom e').hom =\n e'.to_add_monoid_hom.comp f := rfl\n\ndef hom_mk {A B : Type u} [add_comm_group A] [add_comm_group B] (f : A →+ B) :\n (AddCommGroup.of A) ⟶ (AddCommGroup.of B) := f\n\nend hom_single_iso_setup\n\nopen hom_single_iso_setup\n\nnoncomputable\ndef hom_single_iso\n (P : bounded_homotopy_category C) (B : C) (i : ℤ) :\n AddCommGroup.of (P ⟶ (bounded_homotopy_category.single C i).obj B) ≅\n (((preadditive_yoneda.obj B).map_homological_complex _).obj P.val.as.op).homology i :=\nbegin\n refine _ ≪≫ aux₁ P B i,\n refine add_equiv_iso_AddCommGroup_iso.hom _ ≪≫ (aux₂ P B i).symm,\n exact aux₃ P B i,\nend\n\n.\n\nopen opposite\n\nvariables {X Y Z : cochain_complex C ℤ} (f : X ⟶ Y) (g : Y ⟶ Z)\n\ndef of' (X : cochain_complex C ℤ)\n [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)] :\n bounded_homotopy_category C :=\nof $ (homotopy_category.quotient _ _).obj X\n\ndef of_hom (f : X ⟶ Y)\n [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)]\n [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y)] :\n of' X ⟶ of' Y :=\n(homotopy_category.quotient _ _).map f\n\ninstance val_as_bdd_above (P : bounded_homotopy_category C) :\n ((homotopy_category.quotient C (complex_shape.up ℤ)).obj P.val.as).is_bounded_above :=\nby { rcases P with ⟨P, ⟨a, ha⟩⟩, use a, intros i hi, exact ha i hi }\n\nlemma hom_single_iso_naturality\n (P₁ P₂ : bounded_homotopy_category C) (B : C) (i : ℤ)\n (f : P₁ ⟶ P₂) :\n (preadditive_yoneda.obj _).map f.op ≫ (hom_single_iso P₁ B i).hom =\n (hom_single_iso P₂ B i).hom ≫\n (((preadditive_yoneda.obj B).right_op.map_homological_complex _ ⋙\n homological_complex.unop_functor.right_op ⋙\n (_root_.homology_functor _ _ _).op).map f.out).unop :=\nbegin\n dsimp only [hom_single_iso, iso.trans_hom, iso.symm_hom, functor.comp_map, functor.op_map,\n functor.right_op_map, quiver.hom.unop_op],\n simp_rw [← category.assoc, comp_add_equiv_iso_AddcommGroup_iso_eq_comp],\n rw ← aux₃_naturality,\n rw [category.assoc],\n\n let t := hom_mk (aux₃ P₂ B i).to_add_monoid_hom,\n change (t ≫ (map_explicit_homology f B i)) ≫ _ ≫ _ = _,\n slice_lhs 2 3\n { rw aux₂_naturality_inv },\n simp_rw category.assoc,\n rw ← aux₁_naturality,\n refl,\nend\n\nlemma hom_single_iso_naturality'\n (P₁ P₂ : bounded_homotopy_category C) (B : C) (i : ℤ)\n (f : P₁.val.as ⟶ P₂.val.as) :\n (preadditive_yoneda.obj ((single C i).obj B)).map (of_hom f).op ≫ (hom_single_iso P₁ B i).hom =\n (hom_single_iso P₂ B i).hom ≫\n (((preadditive_yoneda.obj B).right_op.map_homological_complex _ ⋙\n homological_complex.unop_functor.right_op ⋙\n (_root_.homology_functor _ _ _).op).map f).unop :=\nbegin\n erw hom_single_iso_naturality P₁ P₂ B i (of_hom f),\n refine congr_arg2 _ rfl _,\n apply homology_map_eq_of_homotopy,\n let h := (preadditive_yoneda.obj B).right_op.map_homotopy (homotopy_category.homotopy_out_map f),\n refine ⟨λ i j, (h.hom j i).unop, _, _⟩,\n { intros i j hij, rw [h.zero, unop_zero], exact hij },\n { intros i,\n conv_rhs { congr, rw add_comm, },\n exact congr_arg quiver.hom.unop (h.comm i), },\nend\n\ndef map_hom_complex_homology\n (P : bounded_homotopy_category C) {B₁ B₂ : C} (i : ℤ) (f : B₁ ⟶ B₂) (w₁ w₂) :\n homology ((hom_complex P B₁).d (i + 1) i) ((hom_complex P B₁).d i (i - 1)) w₁ ⟶\n homology ((hom_complex P B₂).d (i + 1) i) ((hom_complex P B₂).d i (i - 1)) w₂ :=\nhomology.map _ _\n (arrow.hom_mk ((map_hom_complex' _ f).comm _ _))\n (arrow.hom_mk ((map_hom_complex' _ f).comm _ _)) rfl\n\nend bounded_homotopy_category\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/hom_single_iso.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.23919817393835974}} {"text": "\nimport unitb.models.nondet\nimport unitb.refinement.basic\n\nnamespace superposition\n\nopen stream\nopen temporal\nopen predicate\nopen unitb nondet\n\nuniverse variable u\n\nsection defs\n\nparameters {α α' β : Type}\nparameters abs : α' → α\n\nstructure evt_ref (lbl : Type) (mc : program α') (ea : event α) (ecs : lbl → event α') : Type :=\n (witness : lbl → α' → Prop)\n (witness_fis : ⦃ ∃∃ e, witness e ⦄)\n (sim : ∀ ec, ⟦ (ecs ec).step_of ⟧ ⟹ ⟦ ea.step_of on abs ⟧)\n (delay : ∀ ec, witness ec ⋀ (ea.coarse_sch ⋀ ea.fine_sch) ∘ abs ↦ witness ec ⋀ (ecs ec).coarse_sch in mc)\n (stable : ∀ ec, unless_except mc (witness ec ⋀ (ecs ec).coarse_sch) (-(ea.coarse_sch ∘ abs))\n { e | ∃ l, ecs l = e })\n (resched : ∀ ec, (ea.coarse_sch ⋀ ea.fine_sch) ∘ abs ⋀ witness ec ↦ (ecs ec).fine_sch in mc)\n\nstructure evt_ref_wk (lbl : Type) (mc : program α') (ea : event α) (ecs : lbl → event α')\n: Type :=\n (witness : lbl → α' → Prop)\n (sim : ∀ ec, ⟦ (ecs ec).step_of ⟧ ⟹ ⟦ ea.step_of on abs ⟧)\n (delay : (ea.coarse_sch ⋀ ea.fine_sch) ∘ abs\n >~>\n -(ea.coarse_sch ∘ abs)\n ⋁ ∃∃ ec, witness ec ⋀ (ecs ec).coarse_sch in mc)\n (stable : ∀ ec, unless_except mc (witness ec ⋀ (ecs ec).coarse_sch) (-(ea.coarse_sch ∘ abs))\n { e | ∃ l, ecs l = e })\n (resched : ∀ ec, (ea.coarse_sch ⋀ ea.fine_sch) ∘ abs ⋀ witness ec ⋀ (ecs ec).coarse_sch\n >~>\n (ecs ec).fine_sch in mc)\n\nlemma evt_ref_wk_of_evt_ref\n (lbl : Type) (mc : program α')\n (ea : event α)\n (ecs : lbl → event α')\n (H : evt_ref lbl mc ea ecs)\n: evt_ref_wk lbl mc ea ecs :=\nbegin\n apply evt_ref_wk.mk H.witness,\n { apply H.sim },\n { have Hsch : ∀ ec, H.witness ec ⋀ (ea.coarse_sch ⋀ ea.fine_sch) ∘ abs\n ↦\n -(ea.coarse_sch ∘ abs)\n ⋁ H.witness ec ⋀ (ecs ec).coarse_sch in mc,\n { intro ec,\n have H' := H.delay ec, revert H',\n apply leads_to.mono_right,\n apply p_or_intro_right },\n have Hsch' := leads_to.gen_disj' Hsch,\n have H₀ : (∃∃ (ec : lbl), H.witness ec ⋀ (ea.coarse_sch ∘ abs ⋀ ea.fine_sch ∘ abs))\n = (ea.coarse_sch ⋀ ea.fine_sch) ∘ abs,\n { rw [← p_and_over_p_exists_right,ew_eq_true H.witness_fis],\n simp },\n simp [H₀] at Hsch',\n simp [p_or_over_p_exists_left _ _ H.witness_fis],\n apply often_imp_often.basis,\n apply Hsch', },\n { apply H.stable },\n { intro ce,\n have P₀ := H.resched ce,\n apply often_imp_often.basis,\n revert P₀,\n apply leads_to.antimono_left,\n apply p_and_elim_left }\nend\n\nparameters (ma : program α) (mc : program α')\n\nstructure refined : Type :=\n (sim_init : mc^.first ⟹ ma^.first∘abs)\n (ref : option mc.lbl → option ma.lbl → Prop)\n (evt_sim : ∀ ec, ⟦ mc.step_of ec ⟧\n ⟹ ∃∃ ea : { ea // ref ec ea }, ⟦ ma.step_of ea.val on abs ⟧)\n (events : ∀ ae, evt_ref_wk { ec // ref ec ae } mc (ma.event ae) (λ ec, mc.event ec.val) )\n\nparameters {ma mc}\n\nlemma refined.sim\n (R : refined)\n: ⟦ is_step mc ⟧ ⟹ ⟦ is_step ma on abs ⟧ :=\nbegin\n simp [is_step_exists_event'],\n intro τ,\n simp,\n intros ce H,\n apply exists_imp_exists' subtype.val _ (R.evt_sim ce τ H),\n intro, apply id,\nend\n\nend defs\n\nsection soundness\n\nparameters {α α' β : Type}\nparameters {abs : α' → α}\nparameter {ma : program α}\nparameter {mc : program α'}\n\nopen temporal\n\nparameter R : refined abs ma mc\nparameter {τ : stream α'}\nparameter M₁ : system_sem.ex mc τ\n\nsection schedules\n\nparameter e : option ma.lbl\n@[reducible]\ndef imp_lbl := { ec : option mc.lbl // R.ref ec e }\n\ndef AC := (program.event ma e).coarse_sch ∘ abs\ndef AF := (program.event ma e).fine_sch ∘ abs\ndef W (e' : imp_lbl) := (R.events e).witness e'\ndef CC (e' : option mc.lbl) := mc.coarse_sch_of e'\ndef CF (e' : option mc.lbl) := mc.fine_sch_of e'\n\nparameter abs_coarse : (◇◻(•AC ⋀ -⟦ ma.step_of e on abs ⟧)) τ\n\nparameter abs_fine : (◻◇•AF) τ\n\ninclude M₁\ninclude abs_coarse\ninclude abs_fine\n\nlemma abs_coarse_and_fine\n: (◻◇(•AC ⋀ •AF)) τ :=\nbegin\n apply coincidence,\n { apply stable_entails_stable _ _ abs_coarse,\n apply λ _, and.left },\n { apply abs_fine },\nend\n\ninclude R\n\nlemma evt_ref_wk.delay_sem\n: ◻◇(∃∃ ce, •W ce ⋀ •CC ce.val) $ τ :=\nbegin\n have Hdelay := (R.events e).delay,\n have H := system_sem.often_imp_often_sem' _ M₁ Hdelay\n (abs_coarse_and_fine M₁ e abs_coarse abs_fine),\n clear Hdelay,\n rw [init_p_or,inf_often_p_or,← p_not_p_imp,not_henceforth,not_eventually] at H,\n rw [not_init,p_not_p_not_iff_self] at H,\n have Hc := stable_entails_stable (λ _, and.left) τ abs_coarse,\n apply H Hc,\nend\n-- lemma conc_coarse : ∃ e', (◇◻(• W e' ⋀ • CC e'.val) ) τ :=\n\nlemma conc_event : ∃ e' : imp_lbl, (◇◻• CC e'.val ⋀ ◻◇•CF e'.val ) τ :=\nbegin\n have H : ((∃∃ e', ◇◻(• W R e e' ⋀ • CC e'.val))\n ⋁ ◻◇((-•AC e) ⋁ ∃∃ e' : imp_lbl R e, ⟦ mc.step_of e'.val ⟧)) τ,\n { rw exists_action,\n apply p_or_p_imp_p_or_right _ (unless_sem_exists' M₁.safety (R.events e).stable _),\n { apply inf_often_entails_inf_often,\n apply p_or_p_imp_p_or_right' _,\n apply action_entails_action,\n intros σ σ',\n simp [mem_set_of,imp_lbl],\n intros ec H x H' H₂,\n existsi x,\n cases H with H₀ H,\n cases H with H₁ STEP,\n unfold program.step_of,\n simp [H',event.step_of,STEP,H₀,H₁,H₂], },\n have H' := (R.events e).delay,\n have H'' := system_sem.often_imp_often_sem' _ M₁ H' , clear H',\n rw [init_p_or, inf_often_p_or,shunting,init_exists] at H'',\n apply evt_ref_wk.delay_sem R M₁ e abs_coarse abs_fine },\n cases H with H H,\n { apply exists_imp_exists _ H,\n intros ce Hcc,\n simp, split,\n { revert Hcc,\n apply stable_entails_stable,\n apply p_and_elim_right },\n have Hc := stable_and_of_stable_of_stable Hcc abs_coarse,\n have Ha := coincidence Hc abs_fine,\n apply system_sem.often_imp_often_sem' _ M₁ ((R.events e).resched ce),\n revert Ha,\n apply inf_often_entails_inf_often,\n intro, simp [init_p_and,W,CC,AC,AF,W,program.coarse_sch_of],\n generalize : ((•(program.event ma e).coarse_sch ∘ abs) i) = X₀,\n generalize : ((•(program.event ma e).fine_sch ∘ abs) i) = X₁,\n generalize : ((•(program.event mc (ce.val)).coarse_sch) i) = X₂,\n generalize : ((•(R.events e).witness ce) i) = X₃,\n begin [smt] by_cases X₀ end, },\n { exfalso,\n revert abs_coarse,\n change ¬ _,\n rw [p_not_eq_not,not_eventually,not_henceforth,p_not_p_and,p_not_p_not_iff_self],\n revert H,\n apply inf_often_entails_inf_often,\n apply p_or_p_imp_p_or_right',\n rw p_exists_entails_eq_p_forall_entails,\n intros ec,\n apply (R.events e).sim _ , },\nend\n\n\nend schedules\n\ninclude M₁\ninclude R\n\ntheorem soundness : system_sem.ex ma (map abs τ) :=\nbegin\n apply nondet.program.ex.mk,\n { apply R.sim_init,\n apply M₁.init },\n { intro i,\n rw [drop_map],\n rw [comp_map_app_eq_map ⟦ step ma ⟧, ← action_trading ],\n apply R.sim abs,\n apply M₁.safety },\n { intros e COARSE₀ FINE₀,\n apply assume_neg _, intro ACT,\n have COARSE₁ : (◇◻(•AC e ⋀ -⟦program.step_of ma e on abs⟧)) τ,\n { rw [← inf_often_trace_action_trading] at ACT,\n rw [← stable_trace_init_trading] at COARSE₀,\n rw [p_not_eq_not,not_henceforth,not_eventually] at ACT,\n apply stable_and_of_stable_of_stable COARSE₀ ACT },\n clear COARSE₀ ACT,\n cases conc_event R M₁ _ COARSE₁ FINE₀ with e' C_EVT,\n cases C_EVT with C_COARSE C_FINE,\n rw [← inf_often_trace_trading,← action_trading],\n apply inf_often_entails_inf_often _ _ (M₁.liveness _ C_COARSE C_FINE),\n have H := (R.events e).sim e',\n apply H, },\nend\n\nend soundness\n\nend superposition\n", "meta": {"author": "unitb", "repo": "unitb-semantics", "sha": "07607ddb2ced4044af121f1fd989e058e19c3c9c", "save_path": "github-repos/lean/unitb-unitb-semantics", "path": "github-repos/lean/unitb-unitb-semantics/unitb-semantics-07607ddb2ced4044af121f1fd989e058e19c3c9c/src/unitb/refinement/superposition.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.38861802670584894, "lm_q1q2_score": 0.23903422866138607}} {"text": "/-\nFile: signature_recover_public_key_assert_le_soundness.lean\n\nAutogenerated file.\n-/\nimport starkware.cairo.lean.semantics.soundness.hoare\nimport .signature_recover_public_key_code\nimport ..signature_recover_public_key_spec\nimport .signature_recover_public_key_assert_nn_soundness\nopen tactic\n\nopen starkware.cairo.common.math\n\nvariables {F : Type} [field F] [decidable_eq F] [prelude_hyps F]\nvariable mem : F → F\nvariable σ : register_state F\n\n/- starkware.cairo.common.math.assert_le autogenerated soundness theorem -/\n\ntheorem auto_sound_assert_le\n -- arguments\n (range_check_ptr a b : F)\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_assert_le σ.pc)\n -- all dependencies are in memory\n (h_mem_0 : mem_at mem code_assert_nn (σ.pc - 4))\n -- input arguments on the stack\n (hin_range_check_ptr : range_check_ptr = mem (σ.fp - 5))\n (hin_a : a = mem (σ.fp - 4))\n (hin_b : b = mem (σ.fp - 3))\n -- conclusion\n : ensures_ret mem σ (λ κ τ,\n τ.ap = σ.ap + 5 ∧\n ∃ μ ≤ κ, rc_ensures mem (rc_bound F) μ (mem (σ.fp - 5)) (mem $ τ.ap - 1)\n (spec_assert_le mem κ range_check_ptr a b (mem (τ.ap - 1)))) :=\nbegin\n apply ensures_of_ensuresb, intro νbound,\n have h_mem_rec := h_mem,\n unpack_memory code_assert_le at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4⟩,\n -- function call\n step_assert_eq hpc0 with arg0,\n step_assert_eq hpc1 with arg1,\n step_sub hpc2 (auto_sound_assert_nn mem _ range_check_ptr (b - a) _ _ _),\n { rw hpc3, norm_num2, exact h_mem_0 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_a, hin_b] },\n try { arith_simps }, try { simp only [arg0, (eq_sub_of_eq_add arg1)] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_a, hin_b] },\n try { arith_simps }, try { simp only [arg0, (eq_sub_of_eq_add arg1)] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call4 ap4 h_call4,\n rcases h_call4 with ⟨h_call4_ap_offset, h_call4⟩,\n rcases h_call4 with ⟨rc_m4, rc_mle4, hl_range_check_ptr₁, h_call4⟩,\n generalize' hr_rev_range_check_ptr₁: mem (ap4 - 1) = range_check_ptr₁,\n have htv_range_check_ptr₁ := hr_rev_range_check_ptr₁.symm, clear hr_rev_range_check_ptr₁,\n try { simp only [arg0 ,arg1] at hl_range_check_ptr₁ },\n rw [←htv_range_check_ptr₁, ←hin_range_check_ptr] at hl_range_check_ptr₁,\n try { simp only [arg0 ,arg1] at h_call4 },\n rw [hin_range_check_ptr] at h_call4,\n clear arg0 arg1,\n -- return\n step_ret hpc4,\n -- finish\n step_done, use_only [rfl, rfl],\n split,\n { try { simp only [h_call4_ap_offset] },\n try { arith_simps }, try { refl } },\n -- range check condition\n use_only (rc_m4+0+0), split,\n linarith [rc_mle4],\n split,\n { arith_simps,\n rw [←htv_range_check_ptr₁, hl_range_check_ptr₁, hin_range_check_ptr],\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_assert_le mem _ range_check_ptr a b _,\n { apply sound_assert_le, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_assert_le],\n try { norm_num1 }, try { arith_simps },\n use_only [κ_call4],\n use_only [range_check_ptr₁],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have spec4 := h_call4 rc_h_range_check_ptr',\n rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec4,\n try { dsimp at spec4, arith_simps at spec4 },\n use_only [spec4],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_a, hin_b, htv_range_check_ptr₁] }, },\n try { simp only [h_call4_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\nend\n\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/common/cairo_secp/verification/verification/signature_recover_public_key_assert_le_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.3886180267058489, "lm_q1q2_score": 0.23903422866138604}} {"text": "import DijkstraMonad.Basic\nopen EffectObservation\nopen OrderedMonad\n\nuniverse u v w\n#print ExceptT\n\ninstance\n {ε : Type u}\n {W:Type u → Type v}\n [Monad W] [OrderedMonad W]\n : OrderedMonad (ExceptT ε W) where\n\n leW := by\n simp [ExceptT]\n intro α e1 e2\n apply leW e1 e2\n\n trans := by\n intro α a b c h1 h2\n simp [ExceptT] at a b c\n apply trans a b c h1 h2\n\n refl := by\n intro α a\n simp [ExceptT] at a\n apply refl a\n\n bindW := by\n intro α β w w' f f' h1 h2\n simp [ExceptT] at w w' f f'\n simp at h1 h2\n apply bindW <;> try assumption\n simp [ExceptT.bindCont]\n intro x\n cases x <;> simp\n . case a.error x =>\n apply refl\n . case a.ok x =>\n apply h2\n\n#check θ\n#check bindθ\n\ntheorem fun_apply_same_args {α:Type u} {β:Type v} : (f:α→β) → (x y:α) → x = y → f x = f y := by\n intro f x y h\n induction h\n rfl\n\ninstance\n {ε:Type u}\n {M:Type u → Type v}\n {W:Type u → Type w}\n [Monad M] [Monad W]\n [OrderedMonad W]\n [EffectObservation M W]\n : EffectObservation (ExceptT ε M) (ExceptT ε W) where\n\n θ {α:Type u} (x:ExceptT ε M α) : ExceptT ε W α :=\n @θ M _ _ _ _ _ (Except ε α) x\n\n bindθ := by\n intro α β m f\n simp [ExceptT] at m f\n simp [bind, ExceptT.bind, ExceptT.bindCont, ExceptT.mk]\n simp [bindθ]\n apply fun_apply_same_args\n simp [Function.comp]\n apply funext\n intro x\n cases x\n . simp [pureθ]\n . simp\n\n pureθ := by\n intro α x\n simp\n apply pureθ\n\n\n", "meta": {"author": "RemyCiterin", "repo": "DijkstraMonad", "sha": "2e6499a79a72f275a8875da01df88ee6b9ad4e18", "save_path": "github-repos/lean/RemyCiterin-DijkstraMonad", "path": "github-repos/lean/RemyCiterin-DijkstraMonad/DijkstraMonad-2e6499a79a72f275a8875da01df88ee6b9ad4e18/DijkstraMonad/Except.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061556288288, "lm_q2_score": 0.47268347662043286, "lm_q1q2_score": 0.2381881135330717}} {"text": "import for_mathlib.category_theory.lifting_properties.continuous_functor\n\nnoncomputable theory\n\nuniverses w v u\n\nopen category_theory category_theory.category category_theory.limits\n\nsection\n\nvariables {α : Type w} [partial_order α] {a b : α}\n\nlemma is_bot.unique (ha : is_bot a) (hb : is_bot b) :\n a = b :=\nle_antisymm (ha _) (hb _)\n\nlemma is_bot.of_le (ha : is_bot b) (a : α) (h : a ≤ b) : is_bot a :=\nλ c, h.trans (ha c)\n\nlemma is_top.unique (ha : is_top a) (hb : is_top b) :\n a = b :=\nle_antisymm (hb _) (ha _)\n\nvariables (a b)\n\ndef order.are_succ : Prop := (a < b) ∧\n ∀ (c : α) (hc₁ : a ≤ c) (hc₂ : c < b), c = a\n\ndef order.is_succ : Prop :=\n ∃ (a : α), order.are_succ a b\n\ndef order.is_limit : Prop :=\n (¬is_bot a) ∧ (¬order.is_succ a)\n\nvariables {a b}\n\ndef order.are_succ.lt (h : order.are_succ a b) : a < b := h.1\n\ndef order.are_succ.le (h : order.are_succ a b) : a ≤ b := h.1.le\n\ndef order.are_succ.hom (h : order.are_succ a b) :\n a ⟶ b := hom_of_le h.1.le\n\nlemma order.are_succ.of_le_iff {m : α} (a b : { x : α // x ≤ m}) :\n order.are_succ a b ↔ order.are_succ a.1 b.1 :=\nbegin\n split,\n { intro h,\n exact ⟨h.1, λ c hc₁ hc₂, subtype.ext_iff.1 (h.2 ⟨c, hc₂.le.trans b.2⟩ hc₁ hc₂)⟩, },\n { intro h,\n exact ⟨h.1, λ c hc₁ hc₂, by { ext, exact h.2 c.1 hc₁ hc₂}⟩, },\nend\n\nlemma order.is_succ.of_le_iff {m : α} (b : { x : α // x ≤ m}) :\n order.is_succ b ↔ order.is_succ b.1 :=\nbegin\n split,\n { rintro ⟨a, ha⟩,\n rw order.are_succ.of_le_iff at ha,\n exact ⟨_, ha⟩, },\n { rintro ⟨a, ha⟩,\n let a' : { x // x ≤ m} := ⟨a, ha.1.le.trans b.2⟩,\n exact ⟨_, (order.are_succ.of_le_iff a' b).2 ha⟩, },\nend\n\n@[simps, nolint unused_arguments]\ndef order.lt_inclusion_functor (m : α) :\n { a : α // a < m } ⥤ α :=\nmonotone.functor (subtype.mono_coe _)\n\n@[simps]\ndef order.lt_cocone (m : α) {C : Type*} [category C] (F : α ⥤ C) :\n cocone (order.lt_inclusion_functor m ⋙ F) :=\n{ X := F.obj m,\n ι :=\n { app := λ a, F.map (hom_of_le a.2.le),\n naturality' := λ a b f, begin\n dsimp,\n simp only [comp_id, ← F.map_comp],\n congr,\n end, }, }\n\n@[simps]\ndef order.le_inclusion_functor_of_le (m₁ m₂ : α) (h : m₁ ≤ m₂) :\n { a : α // a ≤ m₁ } ⥤ { a : α // a ≤ m₂ } :=\nbegin\n let φ : { a : α // a ≤ m₁ } → { a : α // a ≤ m₂ } := λ a, ⟨a.1, a.2.trans h⟩,\n have hφ : monotone φ := λ a b hab, hab,\n exact monotone.functor hφ,\nend\n\n@[simps]\ndef order.order_iso_lt_le (m₁ m₂ : α) (h : m₁ ≤ m₂) (b : { x // x ≤ m₁}) :\n order_iso { y : { x // x ≤ m₁ } // y < b } { y : { x // x ≤ m₂ } // y < ⟨b.1, b.2.trans h⟩ } :=\n{ to_fun := λ y, ⟨⟨y.1.1, y.1.2.trans h⟩, y.2⟩,\n inv_fun := λ y, ⟨⟨y.1, (show y.1.1 ≤ b.1, by exact y.2.le).trans (b.2 : b.1 ≤ m₁)⟩, y.2⟩,\n left_inv := λ y, by { ext, refl, },\n right_inv := λ y, by { ext, refl, },\n map_rel_iff' := λ x y, ⟨λ h, h, λ h, h⟩, }\n\n@[simps]\ndef order_iso.to_equivalence {α : Type u } {β : Type v} [preorder α] [preorder β]\n (e : order_iso α β) : α ≌ β :=\n{ functor := monotone.functor e.monotone,\n inverse := monotone.functor e.symm.monotone,\n unit_iso := eq_to_iso (category_theory.functor.ext (λ a, (e.left_inv a).symm)\n (λ a₁ a₂ f, subsingleton.elim _ _)),\n counit_iso := eq_to_iso (category_theory.functor.ext (λ b, (e.right_inv b))\n (λ b₁ b₂ f, subsingleton.elim _ _)),\n functor_unit_iso_comp' := λ X, subsingleton.elim _ _, }\n\n@[simps]\ndef order.lt_inclusion_functor_iso_of_le (m₁ m₂ : α) (h : m₁ ≤ m₂) (b : { x // x ≤ m₁}) :\n order.lt_inclusion_functor b ⋙ order.le_inclusion_functor_of_le m₁ m₂ h ≅\n (order.order_iso_lt_le m₁ m₂ h b).to_equivalence.functor ⋙\n order.lt_inclusion_functor (⟨b, b.2.trans h⟩ : { x // x ≤ m₂ }) := iso.refl _\n\n@[simps]\ndef order.lt_inclusion_functor_iso_of_le' (m₁ m₂ : α) (h : m₁ ≤ m₂) (b : { x // x ≤ m₁}) :\n (order.order_iso_lt_le m₁ m₂ h b).to_equivalence.inverse ⋙\n order.lt_inclusion_functor b ⋙ order.le_inclusion_functor_of_le m₁ m₂ h ≅\n order.lt_inclusion_functor (⟨b, b.2.trans h⟩ : { x // x ≤ m₂ }) :=\niso_whisker_left (order.order_iso_lt_le m₁ m₂ h b).to_equivalence.inverse\n (order.lt_inclusion_functor_iso_of_le m₁ m₂ h b) ≪≫ (functor.associator _ _ _).symm ≪≫\n iso_whisker_right (order.order_iso_lt_le m₁ m₂ h b).to_equivalence.counit_iso _ ≪≫\n functor.left_unitor _\n\nlemma is_bot.subsingleton_le {m : α} (hm : is_bot m) :\n subsingleton {a // a ≤ m} :=\n⟨λ x₁ x₂, begin\n have eq : ∀ (x : {x // x ≤ m}), x = ⟨m, hm m⟩ := λ x, le_antisymm x.2 (hm _),\n rw [eq x₁, eq x₂],\nend⟩\n\nend\n\nsection\n\nvariables {α : Type*} [linear_order α]\n\n@[simp]\nlemma is_bot.of_le_iff {m : α} (a : { x : α // x ≤ m}) :\n is_bot a ↔ is_bot a.1 :=\nbegin\n split,\n { intros h b,\n by_cases hb : b ≤ m,\n { exact h ⟨b, hb⟩, },\n { exact a.2.trans (not_le.1 hb).le, }, },\n { intros h b,\n exact h b.1, },\nend\n\nlemma order.is_limit.of_le_iff {m : α} (a : { x : α // x ≤ m}) :\n order.is_limit a ↔ order.is_limit a.1 :=\nbegin\n dsimp only [order.is_limit],\n rw [is_bot.of_le_iff, order.is_succ.of_le_iff],\nend\n\nlemma order.are_succ.lt_iff_le {a b : α} (h : order.are_succ a b) (c : α) : c < b ↔ c ≤ a :=\nbegin\n split,\n { intro hc,\n by_contra',\n simpa only [h.2 c this.le hc, lt_self_iff_false] using this, },\n { intro hc,\n exact lt_of_le_of_lt hc h.lt, },\nend\n\nlemma order.are_succ.pred_uniq {a a' b : α} (h₁ : order.are_succ a b) (h₂ : order.are_succ a' b) :\n a = a' :=\nle_antisymm (by simpa only [← h₂.lt_iff_le] using h₁.lt)\n (by simpa only [← h₁.lt_iff_le] using h₂.lt)\n\nsection\n\nvariables {C : Type*} [category C] {m : α} (hm : is_top m)\n (F G : α ⥤ C) (φ : order.lt_inclusion_functor m ⋙ F ⟶ order.lt_inclusion_functor m ⋙ G)\n (φm : F.obj m ⟶ G.obj m)\n (comm : ∀ (a : { x // x < m }), F.map (hom_of_le (hm a.1)) ≫ φm =\n φ.app a ≫ G.map (hom_of_le (hm a.1)))\n\ninclude comm\n\ndef is_top.mk_nat_trans : F ⟶ G :=\n{ app := λ a, begin\n by_cases a < m,\n { exact φ.app ⟨a, h⟩, },\n { refine eq_to_hom _ ≫ φm ≫ eq_to_hom _,\n all_goals\n { rw le_antisymm (hm _) (not_lt.1 h), }, },\n end,\n naturality' := λ a₁ a₂ ψ, begin\n by_cases h₂ : a₂ < m,\n { have h₁ := lt_of_le_of_lt (le_of_hom ψ) h₂,\n rw [dif_pos h₁, dif_pos h₂],\n let b₁ : { x // x < m} := ⟨a₁, h₁⟩,\n let b₂ : { x // x < m} := ⟨a₂, h₂⟩,\n have ψ' : b₁ ≤ b₂ := le_of_hom ψ,\n convert φ.naturality (hom_of_le ψ'), },\n { have h₂' := le_antisymm (not_lt.1 h₂) (hm a₂),\n subst h₂',\n rw dif_neg (lt_irrefl m),\n by_cases h₁ : a₁ < m,\n { simp only [dif_pos h₁, eq_to_hom_refl, id_comp, comp_id],\n convert comm ⟨a₁ ,h₁⟩, },\n { have h₁' := le_antisymm (not_lt.1 h₁) (hm a₁),\n subst h₁',\n simp only [dif_neg (lt_irrefl m), subsingleton.elim ψ (𝟙 _),\n category_theory.functor.map_id, comp_id, id_comp], }, },\n end, }\n\nlemma is_top.mk_nat_trans_eq (a : α) (ha : a < m) :\n (is_top.mk_nat_trans hm F G φ φm comm).app a = φ.app ⟨a, ha⟩ :=\nbegin\n dsimp only [is_top.mk_nat_trans],\n rw dif_pos ha,\nend\n\n@[simp]\nlemma is_top.mk_nat_trans_eq' :\n (is_top.mk_nat_trans hm F G φ φm comm).app m = φm :=\nbegin\n dsimp only [is_top.mk_nat_trans],\n simp only [dif_neg (lt_irrefl m), eq_to_hom_refl, comp_id, id_comp],\nend\n\nend\n\nsection\n\nvariables {C : Type*} [category C] {m₁ m₂ : α} (hm₁₂ : order.are_succ m₁ m₂)\n (hm₂ : is_top m₂)\n (F G : α ⥤ C) (φ : order.lt_inclusion_functor m₂ ⋙ F ⟶ order.lt_inclusion_functor m₂ ⋙ G)\n (φm : F.obj m₂ ⟶ G.obj m₂)\n (comm : F.map hm₁₂.hom ≫ φm = φ.app ⟨m₁, hm₁₂.lt⟩ ≫ G.map hm₁₂.hom)\n\ninclude comm\n\ndef order.are_succ.mk_nat_trans : F ⟶ G :=\nhm₂.mk_nat_trans F G φ φm (λ a, begin\n have r : a.1 ≤ m₁ := (hm₁₂.lt_iff_le _).1 a.2,\n have r' : a ≤ ⟨m₁, hm₁₂.lt⟩ := r,\n simp only [subsingleton.elim (hom_of_le (r.trans hm₁₂.le)) (hom_of_le r ≫ hom_of_le hm₁₂.le),\n functor.map_comp, assoc],\n erw comm,\n apply φ.naturality_assoc (hom_of_le r'),\nend)\n\nlemma order.are_succ.mk_nat_trans_eq (a : α) (ha : a < m₂) :\n (order.are_succ.mk_nat_trans hm₁₂ hm₂ F G φ φm comm).app a = φ.app ⟨a, ha⟩ :=\nbegin\n dsimp only [order.are_succ.mk_nat_trans],\n apply is_top.mk_nat_trans_eq,\nend\n\n@[simp]\nlemma order.are_succ.mk_nat_trans_eq' :\n (order.are_succ.mk_nat_trans hm₁₂ hm₂ F G φ φm comm).app m₂ = φm :=\nbegin\n dsimp only [order.are_succ.mk_nat_trans],\n apply is_top.mk_nat_trans_eq',\nend\n\nend\n\nend\n\nlemma is_well_order.three_cases {α : Type*} [linear_order α] [is_well_order α (<)]\n (a : α) : is_bot a ∨ order.is_succ a ∨ order.is_limit a :=\nbegin\n by_cases h₁ : is_bot a,\n { exact or.inl h₁, },\n { by_cases h₂ : order.is_succ a,\n { exact or.inr (or.inl h₂), },\n { exact or.inr (or.inr ⟨h₁, h₂⟩), }, },\nend\n\nlemma is_well_order.two_cases {α : Type*} [linear_order α] [is_well_order α (<)]\n (a : α) (ha : ¬is_bot a) : order.is_succ a ∨ order.is_limit a :=\nbegin\n by_cases order.is_succ a,\n { exact or.inl h, },\n { exact or.inr ⟨ha, h⟩, },\nend\n\ninstance is_well_order_subtype {α : Type*} [linear_order α] [is_well_order α (<)]\n (P : α → Prop) : is_well_order { a : α // P a } (<) :=\nbegin\n haveI : is_trichotomous { a : α // P a } (<) := ⟨λ a b, begin\n rcases @is_trichotomous.trichotomous α (<) _ a.1 b.1 with h₁ | (h₂ | h₃),\n { exact or.inl h₁, },\n { exact or.inr (or.inl (by { ext, exact h₂, })), },\n { exact or.inr (or.inr h₃), },\n end⟩,\n haveI : is_trans { a : α // P a } (<) := ⟨λ a b c hab hbc, hab.trans hbc⟩,\n haveI : is_well_founded { a : α // P a } (<) := ⟨⟨begin\n rintro ⟨a, ha⟩,\n apply @well_founded.induction α (<) is_well_founded.wf (λ (a : α),\n ∀ (ha : P a), acc (<) (⟨a, ha⟩ : { b : α // P b})),\n refine λ b H hb, acc.intro _ _,\n rintro ⟨a, ha⟩ hab,\n exact H a hab ha,\n end⟩⟩,\n constructor,\nend\n\nnamespace category_theory\n\nnamespace functor\n\nvariables {C : Type u} [category.{v} C] {α : Type*}\n {Φ : C ⥤ C} (τ : 𝟭 C ⟶ Φ)\n\nstructure transfinite_iteration [partial_order α] (m : α) :=\n(F : { a : α // a ≤ m } ⥤ C)\n(hF : ∀ (b : { a : α // a ≤ m }) (hb : order.is_limit b),\n is_colimit (order.lt_cocone b F))\n(iso : Π (a b : { a : α // a ≤ m }) (hab : order.are_succ a b),\n under.mk (F.map hab.hom) ≅ under.mk (τ.app (F.obj a)))\n\nnamespace transfinite_iteration\n\nvariables {τ} {α}\n\nsection\n\nvariables [partial_order α] {m : α}\n\n@[ext]\nstructure hom (I₁ I₂ : transfinite_iteration τ m) :=\n(f : I₁.F ⟶ I₂.F)\n(commτ : Π (a b : { a : α // a ≤ m}) (hab : order.are_succ a b),\n (I₁.iso a b hab).hom.right ≫ Φ.map (f.app a) =\n f.app b ≫ (I₂.iso a b hab).hom.right)\n\n@[simps]\ndef hom.id (I : transfinite_iteration τ m) :\n hom I I :=\n{ f := 𝟙 _,\n commτ := by tidy, }\n\n@[simps]\ndef hom.comp {I₁ I₂ I₃ : transfinite_iteration τ m} (f : hom I₁ I₂) (g : hom I₂ I₃) :\n hom I₁ I₃ :=\n{ f := f.f ≫ g.f,\n commτ := λ a b hab, by simp only [nat_trans.comp_app, map_comp, assoc,\n reassoc_of (f.commτ a b hab), g.commτ a b hab], }\n\ninstance : category (transfinite_iteration τ m) :=\n{ hom := hom,\n id := hom.id,\n comp := λ I₁ I₂ I₃, hom.comp, }\n\nvariables (τ m)\n\n@[simps]\ndef eval (a : { b : α // b ≤ m}) : transfinite_iteration τ m ⥤ C :=\n{ obj := λ I, I.F.obj a,\n map := λ I₁ I₂ f, f.f.app a, }\n\nend\n\nsection\n\nvariables [linear_order α] {m : α}\n\ndef restriction (m₁ m₂ : α) (h : m₁ ≤ m₂) :\n transfinite_iteration τ m₂ ⥤ transfinite_iteration τ m₁ :=\n{ obj := λ I,\n { F := order.le_inclusion_functor_of_le _ _ h ⋙ I.F,\n hF := begin\n rintro ⟨b, hb⟩ hb',\n have hc := I.hF ⟨b, hb.trans h⟩ (by simpa only [order.is_limit.of_le_iff] using hb'),\n apply limits.is_colimit.of_whisker_equivalence\n (order.order_iso_lt_le m₁ m₂ h ⟨b, hb⟩).to_equivalence.symm,\n let e := order.lt_inclusion_functor_iso_of_le' m₁ m₂ h ⟨b, hb⟩,\n let e' := iso_whisker_right e I.F,\n let e'' : (order.order_iso_lt_le m₁ m₂ h ⟨b, hb⟩).to_equivalence.inverse ⋙\n order.lt_inclusion_functor ⟨b, hb⟩ ⋙ order.le_inclusion_functor_of_le m₁ m₂ h ⋙\n I.F ≅ _ := e',\n equiv_rw (limits.is_colimit.precompose_hom_equiv e''.symm _).symm,\n refine is_colimit.of_iso_colimit hc (cocones.ext (iso.refl _) (λ a, _)),\n dsimp,\n simpa only [comp_id, ← I.F.map_comp],\n end,\n iso := λ a b hab, I.iso ⟨a.1, a.2.trans h⟩ ⟨b.1, b.2.trans h⟩\n (by simpa only [order.are_succ.of_le_iff] using hab), },\n map := λ I₁ I₂ f,\n { f := whisker_left (order.le_inclusion_functor_of_le _ _ h) f.f,\n commτ := λ a b hab, f.commτ ⟨a.1, a.2.trans h⟩ ⟨b.1, b.2.trans h⟩\n (by simpa only [order.are_succ.of_le_iff] using hab), }, }\n\nend\n\nvariables (τ) [linear_order α] [is_well_order α (<)] (m : α) (a₀ : { b : α // b ≤ m})\n (ha₀ : is_bot a₀)\n\ninclude ha₀\n\nlemma faithful_eval_zero : faithful (eval τ m a₀) :=\n⟨λ I₁ I₂ f g h, begin\n ext b,\n apply @well_founded.induction { b : α // b ≤ m } (<) is_well_founded.wf\n (λ b, f.f.app b = g.f.app b),\n intros b H,\n rcases is_well_order.three_cases b with h₁ | (h₂ | h₃),\n { have eq := is_bot.unique ha₀ h₁,\n subst eq,\n exact h, },\n { obtain ⟨a, hab⟩ := h₂,\n simp only [← cancel_mono ((under.forget _).map (I₂.iso a b hab).hom),\n under.forget_map, ← f.commτ a b hab, H a hab.lt, g.commτ a b hab], },\n { apply (I₁.hF b h₃).hom_ext,\n intro a,\n simp only [order.lt_cocone_ι_app, nat_trans.naturality],\n congr' 1,\n exact H a a.2, },\nend⟩\n\nvariable {m}\n\nlemma eval_injective (I₁ I₂ : transfinite_iteration τ m) (m₁ m₂ : { x // x ≤ m})\n (f₁ : (restriction m₁.1 m m₁.2).obj I₁ ⟶ (restriction m₁.1 m m₁.2).obj I₂)\n (f₂ : (restriction m₂.1 m m₂.2).obj I₁ ⟶ (restriction m₂.1 m m₂.2).obj I₂)\n (eq : f₁.f.app ⟨a₀.1, ha₀ _⟩ = f₂.f.app ⟨a₀.1, ha₀ _⟩)\n (a : { x // x ≤ m}) (ha₁ : a ≤ m₁) (ha₂ : a ≤ m₂) :\n f₁.f.app ⟨a.1, ha₁⟩ = f₂.f.app ⟨a.1, ha₂⟩ :=\nbegin\n suffices : (restriction a.1 m₁.1 ha₁).map f₁ = (restriction a.1 m₂.1 ha₂).map f₂,\n { exact congr_app (congr_arg transfinite_iteration.hom.f this) ⟨a.1, le_refl _⟩, },\n haveI := faithful_eval_zero τ a.1 ⟨a₀, ha₀ _⟩\n (by simpa only [is_bot.of_le_iff] using ha₀),\n exact (eval τ a.1 ⟨a₀, ha₀ _⟩).map_injective eq,\nend\n\nvariable (m)\n\nlemma full_eval_zero : full (eval τ m a₀) :=\nnonempty.some begin\n rcases a₀ with ⟨a₀, ha₁⟩,\n rw is_bot.of_le_iff at ha₀,\n dsimp at ha₀,\n apply @well_founded.induction α (<) is_well_founded.wf (λ (m' : α), nonempty\n (full (eval τ m' ⟨a₀, ha₀ _⟩))),\n clear ha₁ m,\n intros m H,\n refine ⟨full_of_surjective _ (λ I₁ I₂ f, _)⟩,\n dsimp at f,\n by_cases hm : is_bot m,\n { haveI : subsingleton { x // x ≤ m},\n { have hm : ∀ (a : { x // x ≤ m}), a = ⟨a₀, ha₀ _⟩ :=\n λ a, le_antisymm (a.2.trans (hm _)) (ha₀ _),\n exact ⟨λ x y, by rw [hm x, hm y]⟩, },\n refine\n ⟨{ f :=\n { app := λ a, eq_to_hom (by congr) ≫ f ≫ eq_to_hom (by congr),\n naturality' := λ a₁ a₂ φ, begin\n have h₁₂ := subsingleton.elim a₁ a₂,\n subst h₁₂,\n simp only [subsingleton.elim φ (𝟙 _), map_id, id_comp, comp_id],\n end, },\n commτ := λ a b hab, begin\n exfalso,\n rw subsingleton.elim a b at hab,\n simpa only [lt_self_iff_false] using hab.1,\n end, }, _⟩,\n dsimp,\n simp only [comp_id, id_comp], },\n { let X := { x // x < m},\n let R₁ := λ (a : X), (restriction a.1 m a.2.le).obj I₁,\n let R₂ := λ (a : X), (restriction a.1 m a.2.le).obj I₂,\n have h : ∀ (a : X), ∃ (Φ : R₁ a ⟶ R₂ a),\n (eval τ a.1 ⟨a₀, ha₀ _⟩).map Φ = f,\n { intros a,\n haveI := (H a.1 a.2).some,\n apply (eval τ a.1 ⟨a₀, ha₀ _⟩).map_surjective, },\n let Ψ := λ (a : X), (h a).some,\n have hΨ : ∀ (a : X), (Ψ a).f.app ⟨a₀, ha₀ _⟩ = f := λ a, (h a).some_spec,\n have hΨ' : ∀ (a₁ a₂ : X) (ha₁₂ : a₁ ≤ a₂) (b : α) (hb : b ≤ a₁.1),\n (Ψ a₁).f.app ⟨b, hb⟩ = (Ψ a₂).f.app ⟨b, hb.trans ha₁₂⟩,\n { intros a₁ a₂ ha₁₂ b hb,\n exact eval_injective τ ⟨a₀, ha₀ _⟩ (by simpa only [is_bot.of_le_iff] using ha₀)\n I₁ I₂ ⟨a₁.1, a₁.2.le⟩ ⟨a₂.1, a₂.2.le⟩ (Ψ a₁) (Ψ a₂) (by erw [hΨ a₁, hΨ a₂])\n ⟨b, hb.trans a₁.2.le⟩ hb (hb.trans ha₁₂), },\n let m' : { x // x ≤ m} := ⟨m, le_refl m⟩,\n have hm' : is_top m' := λ a, a.2,\n let φ' : order.lt_inclusion_functor m' ⋙ I₁.F ⟶ order.lt_inclusion_functor m' ⋙ I₂.F :=\n { app := by { rintro ⟨⟨a, ha⟩, ha'⟩, exact (Ψ ⟨a, ha'⟩).f.app ⟨a, le_refl _⟩, },\n naturality' := begin\n rintro ⟨⟨a₁, ha₁⟩, ha₁'⟩ ⟨⟨a₂, ha₂⟩, ha₂'⟩ g,\n dsimp,\n rw hΨ' ⟨a₁, ha₁'⟩ ⟨a₂, ha₂'⟩ (le_of_hom g),\n let a₁' : {x // x ≤ a₂} := ⟨a₁, le_of_hom g⟩,\n let a₂' : {x // x ≤ a₂} := ⟨a₂, le_refl _⟩,\n let g' : a₁' ⟶ a₂' := hom_of_le (le_of_hom g),\n exact (Ψ ⟨a₂, ha₂'⟩).f.naturality g',\n end },\n cases is_well_order.two_cases _ hm with hm'' hm'',\n { obtain ⟨m₁, hm₁⟩ := hm'',\n have hm₁' := (order.are_succ.of_le_iff ⟨m₁, hm₁.le⟩ m').2 hm₁,\n let m₁' : { x // x < m'} := ⟨⟨m₁, hm₁.le⟩, hm₁.lt⟩,\n let φm : I₁.F.obj m' ⟶ I₂.F.obj m' := (under.forget _).map (I₁.iso _ _ hm₁').hom ≫\n Φ.map (φ'.app m₁') ≫ (under.forget _).map (I₂.iso _ _ hm₁').inv,\n refine ⟨{ f := hm₁'.mk_nat_trans hm' _ _ φ' φm _, commτ := _, }, _⟩,\n { have eq := τ.naturality (φ'.app m₁'),\n have eq₁ := under.w (I₁.iso _ _ hm₁').hom,\n have eq₂ := under.w (I₂.iso _ _ hm₁').hom,\n have eq₃ := ((under.forget _).map_iso (I₂.iso _ _ hm₁')).hom_inv_id,\n dsimp [φm] at ⊢ eq eq₁ eq₂ eq₃,\n rw [← eq₁, ← eq₂, assoc] at eq,\n slice_lhs 1 3 { rw ← eq, },\n simp only [assoc, eq₃, comp_id], },\n { rintro ⟨a, ha⟩ ⟨b, hb⟩ hab,\n by_cases hb' : b < m,\n { have ha' : a < m := lt_of_le_of_lt hab.le hb',\n rw [hm₁'.mk_nat_trans_eq hm' _ _ _ _ _ ⟨b, hb⟩ hb',\n hm₁'.mk_nat_trans_eq hm' _ _ _ _ _ ⟨a, ha⟩ ha'],\n dsimp [φ'],\n rw [hΨ' ⟨a, ha'⟩ ⟨b, hb'⟩ hab.le a (le_refl _)],\n exact (Ψ ⟨b, hb'⟩).commτ ⟨a, hab.le⟩ ⟨b, le_refl _⟩\n (by simpa only [order.are_succ.of_le_iff] using hab), },\n { have hb'' : m = b := le_antisymm (not_lt.1 hb') hb,\n subst hb'',\n have ha' : m₁ = a := order.are_succ.pred_uniq hm₁ ((order.are_succ.of_le_iff _ _).1 hab),\n subst ha',\n rw [hm₁'.mk_nat_trans_eq' hm', hm₁'.mk_nat_trans_eq hm' _ _ _ _ _ ⟨m₁, ha⟩ hm₁.lt],\n dsimp [φm],\n have eq := ((under.forget _).map_iso (I₂.iso ⟨m₁, ha⟩ ⟨m, hb⟩ hab)).inv_hom_id,\n dsimp at eq,\n simp only [assoc, eq, comp_id], }, },\n { dsimp,\n let a₀' : { x // x ≤ m} := ⟨a₀, ha₀ _⟩,\n have ha₀' : a₀' < m',\n { rw hm₁'.lt_iff_le,\n apply ha₀, },\n rw hm₁'.mk_nat_trans_eq hm' _ _ _ _ _ a₀' ha₀',\n dsimp [φ'],\n rw hΨ, }, },\n { let φm : I₁.F.obj m' ⟶ I₂.F.obj m' := (I₁.hF m'\n ((order.is_limit.of_le_iff m').2 hm'')).desc (cocone.mk (I₂.F.obj m')\n { app := begin\n rintro ⟨⟨a, ha⟩, ha'⟩,\n exact (Ψ ⟨a, ha'⟩).f.app ⟨a, le_refl _⟩ ≫ I₂.F.map (hom_of_le ha),\n end,\n naturality' := begin\n rintro ⟨⟨a, ha⟩, ha'⟩ ⟨⟨b, hb⟩, hb'⟩ hab,\n dsimp,\n rw [comp_id, hΨ' ⟨a, ha'⟩ ⟨b, hb'⟩ (le_of_hom hab) a (le_refl _)],\n let a' : { x // x ≤ b} := ⟨a, le_of_hom hab⟩,\n let b' : { x // x ≤ b} := ⟨b, le_refl _⟩,\n let hab' : a' ⟶ b' := hom_of_le a'.2,\n let a'' : {x // x ≤ m} := ⟨a, ha⟩,\n let b'' : {x // x ≤ m} := ⟨b, hb⟩,\n let g : b'' ⟶ m' := hom_of_le hb,\n let hab'' : a'' ⟶ b'' := hab,\n have eq' := subsingleton.elim (hom_of_le ha : a'' ⟶ m') (hab'' ≫ hom_of_le hb),\n rw [eq', I₂.F.map_comp],\n have eq := (Ψ ⟨b, hb'⟩).f.naturality hab' =≫ I₂.F.map g,\n simp only [assoc] at eq,\n convert eq,\n end }),\n refine ⟨{ f := hm'.mk_nat_trans _ _ φ' φm _, commτ := _, }, _⟩,\n { rintro ⟨⟨a, ha⟩, ha'⟩,\n apply (I₁.hF m' ((order.is_limit.of_le_iff m').2 hm'')).fac, },\n { rintro ⟨a, ha⟩ ⟨b, hb⟩ hab,\n have hb' : b < m,\n { by_contra',\n have hb'' := le_antisymm this hb,\n subst hb'',\n simp only [order.are_succ.of_le_iff] at hab,\n exact hm''.2 ⟨_, hab⟩, },\n have ha' : a < m := lt_of_lt_of_le hab.lt hb,\n rw [hm'.mk_nat_trans_eq _ _ _ _ _ ⟨a, ha⟩ ha',\n hm'.mk_nat_trans_eq _ _ _ _ _ ⟨b, hb⟩ hb'],\n dsimp [φ'],\n rw hΨ' ⟨a, ha'⟩ ⟨b, hb'⟩ hab.le a (le_refl _),\n exact (Ψ ⟨b, hb'⟩).commτ ⟨a, _⟩ ⟨b, _⟩\n (by simpa only [order.are_succ.of_le_iff] using hab), },\n { dsimp,\n let a₀' : { x // x ≤ m} := ⟨a₀, ha₀ _⟩,\n have ha₀' : a₀' < m',\n { by_contra',\n apply hm''.1,\n rw ← le_antisymm a₀'.2 this,\n exact ha₀, },\n rw hm'.mk_nat_trans_eq _ _ _ _ _ a₀' ha₀',\n apply hΨ, }, }, },\nend\n\nend transfinite_iteration\n\nsection\n\ndef to_sections_lt_inclusion_functor [partial_order α] (F : αᵒᵖ ⥤ Type v) (a : α) (x : F.obj (opposite.op a)) :\n ((order.lt_inclusion_functor a).op ⋙ F).sections :=\n⟨λ b, F.map (hom_of_le b.unop.2.le).op x, begin\n rintro b c f,\n dsimp,\n simpa only [← functor_to_types.map_comp_apply F],\nend⟩\n\nvariables [linear_order α] [is_well_order α (<)]\n (F : αᵒᵖ ⥤ Type v)\n (hF₁ : ∀ (a b : α) (hab : order.are_succ a b), function.surjective (F.map (hom_of_le hab.le).op))\n (hF₂ : ∀ (a : α) (ha : order.is_limit a), function.surjective (F.to_sections_lt_inclusion_functor a))\n\nnamespace surjective_of_is_well_order_of_surjective\n\nstructure X :=\n(β : set α)\n(hβ : ∀ (x y : α) (hxy : x ≤ y) (hy : y ∈ β), x ∈ β)\n(s : Π (b : β), F.obj (opposite.op b.1))\n(hs : ∀ (b c : β) (h : b ≤ c), s b = F.map (hom_of_le h : b.1 ⟶ c.1).op (s c))\n\ninstance : partial_order (X F) :=\n{ le := λ σ₁ σ₂, (σ₁.β ⊆ σ₂.β) ∧\n ∀ (b : α) (hb₁ : b ∈ σ₁.β) (hb₂ : b ∈ σ₂.β), σ₁.s ⟨b, hb₁⟩ = σ₂.s ⟨b, hb₂⟩,\n le_refl := by tauto,\n le_trans := λ σ₁ σ₂ σ₃ h₁₂ h₂₃,\n ⟨h₁₂.1.trans h₂₃.1, λ b hb₁ hb₃, (h₁₂.2 b hb₁ (h₁₂.1 hb₁)).trans (h₂₃.2 b (h₁₂.1 hb₁) hb₃)⟩,\n le_antisymm := λ σ₁ σ₂ h₁₂ h₂₁, begin\n rcases σ₁ with ⟨β, hβ, s, hs⟩,\n rcases σ₂ with ⟨β', hβ', s', hs'⟩,\n have eqβ : β = β',\n { ext,\n exact ⟨λ h, h₁₂.1 h, λ h, h₂₁.1 h⟩, },\n subst eqβ,\n simp only [eq_self_iff_true, heq_iff_eq, true_and],\n ext ⟨b, hb⟩,\n exact h₁₂.2 b hb hb,\n end, }\n\n@[simps]\ndef X.of_is_bot (a₀ : α) (ha₀ : is_bot a₀) (x : F.obj (opposite.op a₀)) :\n X F :=\n{ β := { a₀ },\n hβ := λ x y hxy hy, begin\n simp only [set.mem_singleton_iff] at hy ⊢,\n exact le_antisymm (hxy.trans (by rw hy)) (ha₀ _),\n end,\n s := begin\n rintro ⟨b, hb⟩,\n simp only [set.mem_singleton_iff] at hb,\n subst hb,\n exact x,\n end,\n hs := begin\n rintro ⟨b, hb⟩ ⟨c, hc⟩ hbc,\n simp only [set.mem_singleton_iff] at hb hc,\n substs hb hc,\n dsimp,\n erw [subsingleton.elim (hom_of_le hbc) (𝟙 _), op_id, F.map_id, types_id_apply],\n end, }\n\n@[simp]\nlemma X.of_is_bot_s₀ (a₀ : α) (ha₀ : is_bot a₀) (x : F.obj (opposite.op a₀)) :\n (X.of_is_bot F a₀ ha₀ x).s ⟨a₀, rfl⟩ = x := rfl\n\ndef X_set (a₀ : α) (ha₀ : is_bot a₀) (x₀ : F.obj (opposite.op a₀)) :=\n { σ : X F | X.of_is_bot F a₀ ha₀ x₀ ≤ σ }\n\nvariable {F}\n\nlemma X_set_chain_condition {a₀ : α} {ha₀ : is_bot a₀} {x₀ : F.obj (opposite.op a₀)}\n (C : set (X F)) (hC₁ : C ⊆ X_set F a₀ ha₀ x₀) (hC₂ : is_chain (≤) C) :\n ∃ (m : X F) (hm : m ∈ X_set F a₀ ha₀ x₀), ∀ (z : X F) (hz : z ∈ C), z ≤ m :=\nbegin\n by_cases hC₀ : nonempty C,\n { let β : set α := λ b, ∃ (c : C), b ∈ c.1.β,\n let γ : β → C := λ b, b.2.some,\n have hγ : ∀ (b : β), b.1 ∈ (γ b).1.β := λ b, b.2.some_spec,\n let s : Π (b : β), F.obj (opposite.op b.val) := λ b, (γ b).1.s ⟨b.1, hγ b⟩,\n have hC₂' : ∀ (z₁ z₂ : C) (b : α) (hb₁ : b ∈ z₁.1.β) (hb₂ : b ∈ z₂.1.β),\n z₁.1.s ⟨b, hb₁⟩ = z₂.1.s ⟨b, hb₂⟩,\n { intros z₁ z₂ b hb₁ hb₂,\n by_cases hz₁₂ : z₁.1 = z₂.1,\n { have hz₁₂' : z₁ = z₂ := by { ext, exact hz₁₂, },\n subst hz₁₂', },\n { cases hC₂ z₁.2 z₂.2 hz₁₂,\n { apply h.2, },\n { symmetry, apply h.2, }, }, },\n have hs : ∀ (z : C) (b : α) (hb : b ∈ z.1.β), s ⟨b, ⟨z, hb⟩⟩ = z.1.s ⟨b, hb⟩,\n { intros s b hb,\n apply hC₂', },\n refine\n ⟨{ β := β,\n hβ := λ b₁ b₂ h₁₂ h₂, begin\n obtain ⟨c, hc⟩ := h₂,\n exact ⟨c, c.1.hβ b₁ _ h₁₂ hc⟩,\n end,\n s := s,\n hs := begin\n rintro ⟨b, hb⟩ ⟨c, hc⟩ hbc,\n let g := γ ⟨c, hc⟩,\n erw [hs g c (hγ _), hs g b (g.1.hβ _ _ hbc (hγ _))],\n exact g.1.hs ⟨b, _⟩ ⟨c, _⟩ hbc,\n end, }, _, _⟩,\n { split,\n { dsimp,\n simp only [set.singleton_subset_iff],\n exact ⟨_, (hC₁ hC₀.some.2).1 rfl⟩, },\n { intros b hb₁ hb₂,\n apply (hC₁ (γ ⟨b, hb₂⟩).2).2, }, },\n { intros z hz,\n split,\n { intros a ha,\n exact ⟨⟨z, hz⟩, ha⟩, },\n { intros b hb₁ hb₂,\n exact (hs ⟨z, hz⟩ b hb₁).symm, }, }, },\n { refine ⟨X.of_is_bot F a₀ ha₀ x₀, le_refl _, _⟩,\n intros z hz,\n exfalso,\n exact hC₀ ⟨⟨z, hz⟩⟩, },\nend\n\nsection\n\nvariables (x : X F) {m : α} (hx : x.β = {a | a < m}) (t : F.obj (opposite.op m))\n (ht : ∀ (b : α) (hb : b < m),\n x.s ⟨b, by simpa only [hx] using hb⟩ = (F.map (hom_of_le hb.le).op) t)\n\ninclude ht\n\n@[simps]\ndef X.extension : X F :=\n{ β := {a | a ≤ m},\n hβ := λ x y hxy hy, hxy.trans hy,\n s := begin\n rintro ⟨b, hb⟩,\n by_cases b < m,\n { exact x.s ⟨b, by simpa only [hx] using h⟩, },\n { have hb' := le_antisymm (not_lt.1 h) hb,\n subst hb',\n exact t, },\n end,\n hs := begin\n rintro ⟨b, hb⟩ ⟨c, hc⟩ (hbc : b ≤ c),\n dsimp,\n by_cases hc' : c < m,\n { have hb' : b < m := lt_of_le_of_lt hbc hc',\n rw [dif_pos hb', dif_pos hc'],\n exact x.hs ⟨b, by simpa only [hx] using hb'⟩ ⟨c, by simpa only [hx] using hc'⟩ hbc, },\n { replace hc' : m = c := le_antisymm (not_lt.1 hc') hc,\n subst hc',\n by_cases hb' : b < m,\n { dsimp,\n simp only [dif_pos hb', lt_self_iff_false, not_false_iff, dif_neg],\n apply ht, },\n { replace hb' : m = b := le_antisymm (not_lt.1 hb') hb,\n subst hb',\n dsimp,\n simp only [lt_self_iff_false, not_false_iff, dif_neg,\n subsingleton.elim (hom_of_le hbc) (𝟙 _), op_id, F.map_id, types_id_apply], }, },\n end, }\n\nlemma X.le_extension : x < X.extension x hx t ht :=\nbegin\n have hx' : x ≠ X.extension x hx t ht,\n { intro h,\n rw ← lt_self_iff_false m,\n change m ∈ { x | x < m},\n rw [← hx, h],\n apply le_refl, },\n suffices : x ≤ X.extension x hx t ht,\n { cases this.lt_or_eq,\n { exact h, },\n { exfalso,\n refine hx' h, }, },\n split,\n { dsimp,\n simp only [hx, set.set_of_subset_set_of],\n intros a ha,\n exact ha.le, },\n { intros b hb₁ hb₂,\n have hb₁' : b < m := by simpa only [hx] using hb₁,\n dsimp,\n rw dif_pos hb₁', },\nend\n\nend\n\nend surjective_of_is_well_order_of_surjective\n\ninclude hF₁ hF₂\n\nopen surjective_of_is_well_order_of_surjective\n\nlemma surjective_of_is_well_order_of_surjective' (a₀ : α) (ha₀ : is_bot a₀):\n function.surjective (λ (s : F.sections), s.1 (opposite.op a₀)) :=\nλ x₀, begin\n obtain ⟨m, hm₀ : X.of_is_bot F a₀ ha₀ x₀ ≤ m, hm⟩ :=\n zorn_partial_order₀ (X_set F a₀ ha₀ x₀) (by apply X_set_chain_condition),\n suffices : m.β = ⊤,\n { have hm' : ∀ (b : α), b ∈ m.β := λ b, by simp only [this, set.top_eq_univ],\n refine ⟨⟨λ b, m.s ⟨b.unop, hm' _⟩, _⟩, _⟩,\n { intros b c f,\n have eq := m.hs ⟨c.unop, hm' _⟩ ⟨b.unop, hm' _⟩ (le_of_hom f.unop),\n convert eq.symm, },\n { dsimp,\n simp only [← hm₀.2 a₀ (by simp) (hm' _), X.of_is_bot_s], }, },\n replace hm : ∀ (z : X F) (hz : m ≤ z), z = m := λ z hz, hm z (hm₀.trans hz) hz,\n by_contra' hm',\n replace hm' : (m.βᶜ : set α).nonempty,\n { simp only [set.nonempty_iff_ne_empty],\n intro h,\n apply hm',\n rw [← compl_compl m.β, h, set.compl_empty, set.top_eq_univ], },\n let b := @well_founded.min α (<) is_well_founded.wf _ hm',\n have hb : m.β = { x | x < b},\n { have hb' : b ∈ m.βᶜ := well_founded.min_mem _ _ _,\n ext a,\n split,\n { intro ha,\n dsimp,\n by_contra',\n exact hb' (m.hβ _ _ this ha), },\n { intro ha,\n dsimp at ha,\n by_contra ha',\n have ha'' : ¬ (a < b):= well_founded.not_lt_min _ _ _ ha',\n exact ha'' ha, }, },\n rcases is_well_order.three_cases b with h₁ | (h₂ | h₃),\n { rw is_bot.unique h₁ ha₀ at hb,\n have ha₀' : a₀ ∉ m.β,\n { simp only [hb, set.mem_set_of_eq, lt_self_iff_false, not_false_iff], },\n apply ha₀',\n apply hm₀.1,\n simp only [X.of_is_bot_β, set.mem_singleton], },\n { obtain ⟨a, hab⟩ := h₂,\n have ha' : a ∈ m.β := by simpa only [hb] using hab.lt,\n obtain ⟨t, ht⟩ := hF₁ _ _ hab (m.s ⟨a, ha'⟩),\n let M := X.extension m hb t (λ c hc, begin\n rw hab.lt_iff_le at hc,\n rw m.hs ⟨c, m.hβ _ _ hc ha'⟩ ⟨a, ha'⟩ hc,\n have eq := congr_arg (F.map (hom_of_le hc).op) ht,\n simp only [← functor_to_types.map_comp_apply] at eq,\n convert eq.symm,\n end),\n have hM : m < M := X.le_extension _ _ _ _,\n simpa only [hm M hM.le, lt_self_iff_false] using hM, },\n { obtain ⟨t, ht⟩ := hF₂ _ h₃ ⟨λ c, m.s ⟨c.unop.1, by simpa only [hb] using c.unop.2⟩,\n (λ c d hcd, (m.hs ⟨d.unop.1, _⟩ ⟨c.unop.1, _⟩ _).symm)⟩,\n let M := X.extension m hb t (λ c hc,\n congr_fun (congr_arg subtype.val ht.symm) (opposite.op ⟨c, hc⟩)),\n have hM : m < M := X.le_extension _ _ _ _,\n simpa only [hm M hM.le, lt_self_iff_false] using hM, },\nend\n\nlemma surjective_of_is_well_order_of_surjective [order_bot α] :\n function.surjective (λ (s : F.sections), s.1 (opposite.op ⊥)) :=\nsurjective_of_is_well_order_of_surjective' F hF₁ hF₂ ⊥ (order_bot.bot_le)\n\nend\n\nsection\n\nvariables {m : α} [linear_order α] (F : { x // x < m } ⥤ C) (X : C)\n (φ : F ⟶ (functor.const _).obj X)\n\nnamespace order_extension_from_lt_to_le\n\ninclude F X\n\ndef obj (a : { x // x ≤ m}) : C :=\nbegin\n by_cases a.1 < m,\n { exact F.obj ⟨a.1, h⟩, },\n { exact X, },\nend\n\ndef obj_iso_of_lt (a : { x // x ≤ m}) (ha : a.1 < m) :\n obj F X a ≅ F.obj ⟨a.1, ha⟩ :=\neq_to_iso begin\n dsimp [obj],\n classical,\n erw [dif_pos ha],\nend\n\ndef obj_iso_of_not_lt (a : { x // x ≤ m}) (ha : ¬ a.1 < m) :\n obj F X a ≅ X :=\neq_to_iso begin\n dsimp [obj],\n erw [dif_neg ha],\nend\n\nend order_extension_from_lt_to_le\n\nopen order_extension_from_lt_to_le\n\ninclude φ\n\ndef order_extension_from_lt_to_le : { x // x ≤ m } ⥤ C :=\n{ obj := order_extension_from_lt_to_le.obj F X,\n map := λ a b f, begin\n classical,\n by_cases ha : a.1 < m,\n { by_cases hb : b.1 < m,\n { exact (obj_iso_of_lt F X a ha).hom ≫ F.map (hom_of_le (by exact le_of_hom f)) ≫\n (obj_iso_of_lt F X b hb).inv, },\n { exact (obj_iso_of_lt F X a ha).hom ≫ φ.app ⟨a, ha⟩ ≫ (obj_iso_of_not_lt F X b hb).inv, }, },\n { exact (obj_iso_of_not_lt F X a ha).hom ≫ (obj_iso_of_not_lt F X b\n (by { simp only [not_lt] at ⊢ ha, exact ha.trans (le_of_hom f), })).inv, },\n end,\n map_id' := λ a, begin\n by_cases ha : a.1 < m,\n { simp only [dif_pos ha],\n have h := le_refl (⟨a.1, ha⟩ : { x // x < m}),\n rw [subsingleton.elim (hom_of_le h) (𝟙 _), functor.map_id, id_comp, iso.hom_inv_id], },\n { simp only [dif_neg ha, iso.hom_inv_id], },\n end,\n map_comp' := λ a b c f g, begin\n by_cases ha : a.1 < m,\n { by_cases hb : b.1 < m,\n { by_cases hc : c.1 < m,\n { simp only [dif_pos ha, dif_pos hb, dif_pos hc, assoc, iso.inv_hom_id_assoc,\n iso.cancel_iso_hom_left, ← F.map_comp_assoc],\n congr, },\n { simp only [dif_pos ha, dif_pos hb, dif_neg hc, assoc, iso.inv_hom_id_assoc,\n iso.cancel_iso_hom_left],\n let f' : (⟨a, ha⟩ : { x // x < m}) ⟶ ⟨b, hb⟩ := f,\n have eq := φ.naturality f',\n dsimp at eq,\n rw comp_id at eq,\n simp only [← eq, assoc],\n congr, }, },\n { have hc : ¬c.1 < m := λ h, hb (lt_of_le_of_lt (le_of_hom g) h),\n simp only [dif_pos ha, dif_neg hb, dif_neg hc, assoc, iso.inv_hom_id_assoc], } },\n { have hb : ¬b.1 < m := λ h, ha (lt_of_le_of_lt (le_of_hom f) h),\n have hc : ¬c.1 < m := λ h, hb (lt_of_le_of_lt (le_of_hom g) h),\n simp only [dif_neg ha, dif_neg hb, dif_neg hc, assoc, iso.inv_hom_id_assoc], },\n end, }\n\nend\n\n@[simps]\ndef nat_trans_to_functor_const [preorder α] (F : α ⥤ C) (m : α) (hm : is_top m) :\n F ⟶ (functor.const _).obj (F.obj m) :=\n{ app := λ a, F.map (hom_of_le (hm a)),\n naturality' := λ a b hab, begin\n dsimp,\n simpa only [comp_id, ← F.map_comp],\n end, }\n\nnamespace transfinite_iteration\n\nvariables (τ) [linear_order α] [is_well_order α (<)] {m : α} (a₀ : { b : α // b ≤ m})\n (ha₀ : is_bot a₀)\n\ndef mk_of_is_bot (hm : is_bot m) (X : C) : transfinite_iteration τ m :=\n{ F := (functor.const _).obj X,\n hF := λ b hb, begin\n exfalso,\n exact hb.1 (by simpa only [is_bot.of_le_iff] using (hm.of_le _ b.2)),\n end,\n iso := begin\n rintro ⟨a, ha⟩ ⟨b, hb⟩ hab,\n exfalso,\n rw order.are_succ.of_le_iff at hab,\n dsimp at hab,\n have ha' := is_bot.unique (hm.of_le _ ha) hm,\n have hb' := is_bot.unique (hm.of_le _ hb) hm,\n substs ha' hb',\n simpa only [lt_self_iff_false] using hab.lt,\n end, }\n\ndef mk_of_are_succ {a b : α} (hab : order.are_succ a b) (I : transfinite_iteration τ a) :\n transfinite_iteration τ b :=\nbegin\n let a' : { x // x < b} := ⟨a, hab.lt⟩,\n have ha' : is_top a' := λ c, (hab.lt_iff_le c.1).1 c.2,\n let i : { x // x < b } → { x // x ≤ a } := λ x, ⟨x.1, ha' _⟩,\n have hi : _root_.monotone i := λ x y hxy, hxy,\n exact\n { F := order_extension_from_lt_to_le (monotone.functor hi ⋙ I.F)\n (Φ.obj (I.F.obj ⟨a, le_refl a⟩))\n (functor.nat_trans_to_functor_const _ a' ha' ≫ (functor.const _).map (τ.app _)),\n hF := sorry,\n iso := sorry, }\nend\n\nvariable (m)\n\ninclude ha₀\n\nlemma ess_surj_eval_zero : ess_surj (eval τ m a₀) :=\nbegin\n rcases a₀ with ⟨a₀, ha₁⟩,\n rw is_bot.of_le_iff at ha₀,\n apply @well_founded.induction α (<) is_well_founded.wf\n (λ b, ess_surj (eval τ b ⟨a₀, ha₀ _⟩)) m,\n intros b H,\n rcases is_well_order.three_cases b with h₁ | (h₂ | h₃),\n { have hb := is_bot.unique h₁ ha₀,\n subst hb,\n exact ⟨λ X₀, ⟨mk_of_is_bot τ ha₀ X₀, ⟨iso.refl _⟩⟩⟩, },\n { obtain ⟨a, hab⟩ := h₂,\n haveI := H a hab.lt,\n exact ⟨λ X₀, ⟨mk_of_are_succ τ hab ((eval τ a ⟨a₀, ha₀ _⟩).obj_preimage X₀),\n ⟨order_extension_from_lt_to_le.obj_iso_of_lt _ _ _ (lt_of_le_of_lt (ha₀ _) hab.lt) ≪≫\n ((eval τ a ⟨a₀, ha₀ _⟩).obj_obj_preimage_iso _)⟩⟩⟩, },\n { sorry, },\nend\n\nend transfinite_iteration\n\nend functor\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebraic_topology/small_object/iteration.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.4649015713733885, "lm_q1q2_score": 0.23789785362482155}} {"text": "/-\nCopyright (c) 2020 Kenji Nakagawa. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenji Nakagawa, Anne Baanen, Filippo A. E. Nuccio\n-/\nimport ring_theory.discrete_valuation_ring\nimport ring_theory.fractional_ideal\nimport ring_theory.ideal.over\n\n/-!\n# Dedekind domains\n\nThis file defines the notion of a Dedekind domain (or Dedekind ring),\ngiving three equivalent definitions (TODO: and shows that they are equivalent).\n\n## Main definitions\n\n - `is_dedekind_domain` defines a Dedekind domain as a commutative ring that is not a field,\n Noetherian, integrally closed in its field of fractions and has Krull dimension exactly one.\n `is_dedekind_domain_iff` shows that this does not depend on the choice of field of fractions.\n - `is_dedekind_domain_dvr` alternatively defines a Dedekind domain as an integral domain that\n is not a field, Noetherian, and the localization at every nonzero prime ideal is a DVR.\n - `is_dedekind_domain_inv` alternatively defines a Dedekind domain as an integral domain that\n is not a field, and every nonzero fractional ideal is invertible.\n - `is_dedekind_domain_inv_iff` shows that this does note depend on the choice of field of\n fractions.\n\n## Implementation notes\n\nThe definitions that involve a field of fractions choose a canonical field of fractions,\nbut are independent of that choice. The `..._iff` lemmas express this independence.\n\n## References\n\n* [D. Marcus, *Number Fields*][marcus1977number]\n* [J.W.S. Cassels, A. Frölich, *Algebraic Number Theory*][cassels1967algebraic]\n\n## Tags\n\ndedekind domain, dedekind ring\n-/\n\nvariables (R A K : Type*) [comm_ring R] [integral_domain A] [field K]\n\n/-- A ring `R` has Krull dimension at most one if all nonzero prime ideals are maximal. -/\ndef ring.dimension_le_one : Prop :=\n∀ p ≠ (⊥ : ideal R), p.is_prime → p.is_maximal\n\nopen ideal ring\n\nnamespace ring\n\nlemma dimension_le_one.principal_ideal_ring\n [is_principal_ideal_ring A] : dimension_le_one A :=\nλ p nonzero prime, by { haveI := prime, exact is_prime.to_maximal_ideal nonzero }\n\nlemma dimension_le_one.integral_closure [nontrivial R] [algebra R A]\n (h : dimension_le_one R) : dimension_le_one (integral_closure R A) :=\nbegin\n intros p ne_bot prime,\n haveI := prime,\n refine integral_closure.is_maximal_of_is_maximal_comap p\n (h _ (integral_closure.comap_ne_bot ne_bot) _),\n apply is_prime.comap\nend\nend ring\n\n/--\nA Dedekind domain is an integral domain that is Noetherian, integrally closed, and\nhas Krull dimension exactly one (`not_is_field` and `dimension_le_one`).\n\nThe integral closure condition is independent of the choice of field of fractions:\nuse `is_dedekind_domain_iff` to prove `is_dedekind_domain` for a given `fraction_map`.\n\nThis is the default implementation, but there are equivalent definitions,\n`is_dedekind_domain_dvr` and `is_dedekind_domain_inv`.\nTODO: Prove that these are actually equivalent definitions.\n-/\nclass is_dedekind_domain : Prop :=\n(not_is_field : ¬ is_field A)\n(is_noetherian_ring : is_noetherian_ring A)\n(dimension_le_one : dimension_le_one A)\n(is_integrally_closed : integral_closure A (fraction_ring A) = ⊥)\n\n/-- An integral domain is a Dedekind domain iff and only if it is not a field, is\nNoetherian, has dimension ≤ 1, and is integrally closed in a given fraction field.\nIn particular, this definition does not depend on the choice of this fraction field. -/\nlemma is_dedekind_domain_iff (f : fraction_map A K) :\n is_dedekind_domain A ↔\n (¬ is_field A) ∧ is_noetherian_ring A ∧ dimension_le_one A ∧\n integral_closure A f.codomain = ⊥ :=\n⟨λ ⟨hf, hr, hd, hi⟩, ⟨hf, hr, hd,\n by rw [←integral_closure_map_alg_equiv (fraction_ring.alg_equiv_of_quotient f),\n hi, algebra.map_bot]⟩,\n λ ⟨hf, hr, hd, hi⟩, ⟨hf, hr, hd,\n by rw [←integral_closure_map_alg_equiv (fraction_ring.alg_equiv_of_quotient f).symm,\n hi, algebra.map_bot]⟩⟩\n\n/--\nA Dedekind domain is an integral domain that is not a field, is Noetherian, and the\nlocalization at every nonzero prime is a discrete valuation ring.\n\nThis is equivalent to `is_dedekind_domain`.\nTODO: prove the equivalence.\n-/\nstructure is_dedekind_domain_dvr : Prop :=\n(not_is_field : ¬ is_field A)\n(is_noetherian_ring : is_noetherian_ring A)\n(is_dvr_at_nonzero_prime : ∀ P ≠ (⊥ : ideal A), P.is_prime →\n discrete_valuation_ring (localization.at_prime P))\n\nsection inverse\n\nopen_locale classical\n\nvariables {R₁ : Type*} [integral_domain R₁] {g : fraction_map R₁ K}\nvariables {I J : fractional_ideal g}\n\nnoncomputable instance : has_inv (fractional_ideal g) := ⟨λ I, 1 / I⟩\n\nlemma inv_eq : I⁻¹ = 1 / I := rfl\n\nlemma inv_zero' : (0 : fractional_ideal g)⁻¹ = 0 := fractional_ideal.div_zero\n\nlemma inv_nonzero {J : fractional_ideal g} (h : J ≠ 0) :\nJ⁻¹ = ⟨(1 : fractional_ideal g) / J, fractional_ideal.fractional_div_of_nonzero h⟩ :=\nfractional_ideal.div_nonzero _\n\nlemma coe_inv_of_nonzero {J : fractional_ideal g} (h : J ≠ 0) :\n (↑J⁻¹ : submodule R₁ g.codomain) = g.coe_submodule 1 / J :=\nby { rwa inv_nonzero _, refl, assumption}\n\n/-- `I⁻¹` is the inverse of `I` if `I` has an inverse. -/\ntheorem right_inverse_eq (I J : fractional_ideal g) (h : I * J = 1) :\n J = I⁻¹ :=\nbegin\n have hI : I ≠ 0 := fractional_ideal.ne_zero_of_mul_eq_one I J h,\n suffices h' : I * (1 / I) = 1,\n { exact (congr_arg units.inv $\n @units.ext _ _ (units.mk_of_mul_eq_one _ _ h) (units.mk_of_mul_eq_one _ _ h') rfl) },\n apply le_antisymm,\n { apply fractional_ideal.mul_le.mpr _,\n intros x hx y hy,\n rw mul_comm,\n exact (fractional_ideal.mem_div_iff_of_nonzero hI).mp hy x hx },\n rw ← h,\n apply fractional_ideal.mul_left_mono I,\n apply (fractional_ideal.le_div_iff_of_nonzero hI).mpr _,\n intros y hy x hx,\n rw mul_comm,\n exact fractional_ideal.mul_mem_mul hx hy\nend\n\ntheorem mul_inv_cancel_iff {I : fractional_ideal g} :\n I * I⁻¹ = 1 ↔ ∃ J, I * J = 1 :=\n⟨λ h, ⟨I⁻¹, h⟩, λ ⟨J, hJ⟩, by rwa [← @right_inverse_eq _ _ _ _ _ I J hJ]⟩\n\nvariables {K' : Type*} [field K'] {g' : fraction_map R₁ K'}\n\n@[simp] lemma map_inv (I : fractional_ideal g) (h : g.codomain ≃ₐ[R₁] g'.codomain) :\n (I⁻¹).map (h : g.codomain →ₐ[R₁] g'.codomain) = (I.map h)⁻¹ :=\nby rw [inv_eq, fractional_ideal.map_div, fractional_ideal.map_one, inv_eq]\n\nopen_locale classical\n\nopen submodule submodule.is_principal\n\n@[simp] lemma span_singleton_inv (x : g.codomain) :\n (fractional_ideal.span_singleton x)⁻¹ = fractional_ideal.span_singleton (x⁻¹) :=\nfractional_ideal.one_div_span_singleton x\n\nlemma mul_generator_self_inv (I : fractional_ideal g)\n [submodule.is_principal (I : submodule R₁ g.codomain)] (h : I ≠ 0) :\n I * fractional_ideal.span_singleton (generator (I : submodule R₁ g.codomain))⁻¹ = 1 :=\nbegin\n -- Rewrite only the `I` that appears alone.\n conv_lhs { congr, rw fractional_ideal.eq_span_singleton_of_principal I },\n rw [fractional_ideal.span_singleton_mul_span_singleton, mul_inv_cancel,\n fractional_ideal.span_singleton_one],\n intro generator_I_eq_zero,\n apply h,\n rw [fractional_ideal.eq_span_singleton_of_principal I, generator_I_eq_zero,\n fractional_ideal.span_singleton_zero]\nend\n\nlemma invertible_of_principal (I : fractional_ideal g)\n [submodule.is_principal (I : submodule R₁ g.codomain)] (h : I ≠ 0) :\n I * I⁻¹ = 1 :=\n(fractional_ideal.mul_div_self_cancel_iff).mpr\n ⟨fractional_ideal.span_singleton (generator (I : submodule R₁ g.codomain))⁻¹,\n @mul_generator_self_inv _ _ _ _ _ I _ h⟩\n\nlemma invertible_iff_generator_nonzero (I : fractional_ideal g)\n [submodule.is_principal (I : submodule R₁ g.codomain)] :\n I * I⁻¹ = 1 ↔ generator (I : submodule R₁ g.codomain) ≠ 0 :=\nbegin\n split,\n { intros hI hg,\n apply fractional_ideal.ne_zero_of_mul_eq_one _ _ hI,\n rw [fractional_ideal.eq_span_singleton_of_principal I, hg,\n fractional_ideal.span_singleton_zero] },\n { intro hg,\n apply invertible_of_principal,\n rw [fractional_ideal.eq_span_singleton_of_principal I],\n intro hI,\n have := fractional_ideal.mem_span_singleton_self (generator (I : submodule R₁ g.codomain)),\n rw [hI, fractional_ideal.mem_zero_iff] at this,\n contradiction }\nend\n\nlemma is_principal_inv (I : fractional_ideal g)\n [submodule.is_principal (I : submodule R₁ g.codomain)] (h : I ≠ 0) :\n submodule.is_principal (I⁻¹).1 :=\nbegin\n rw [fractional_ideal.val_eq_coe, fractional_ideal.is_principal_iff],\n use (generator (I : submodule R₁ g.codomain))⁻¹,\n have hI : I * fractional_ideal.span_singleton ((generator (I : submodule R₁ g.codomain))⁻¹) = 1,\n apply @mul_generator_self_inv _ _ _ _ _ I _ h,\n apply (@right_inverse_eq _ _ _ _ _ I (fractional_ideal.span_singleton\n ( (generator (I : submodule R₁ g.codomain))⁻¹)) hI).symm,\nend\n\n/--\nA Dedekind domain is an integral domain that is not a field such that every fractional ideal\nhas an inverse.\n\nThis is equivalent to `is_dedekind_domain`.\nTODO: prove the equivalence.\n-/\nstructure is_dedekind_domain_inv : Prop :=\n(not_is_field : ¬ is_field A)\n(mul_inv_cancel : ∀ I ≠ (⊥ : fractional_ideal (fraction_ring.of A)), I * (1 / I) = 1)\n\nopen ring.fractional_ideal\n\nlemma is_dedekind_domain_inv_iff (f : fraction_map A K) :\n is_dedekind_domain_inv A ↔\n (¬ is_field A) ∧ (∀ I ≠ (⊥ : fractional_ideal f), I * I⁻¹ = 1) :=\nbegin\n set h : (fraction_ring.of A).codomain ≃ₐ[A] f.codomain := fraction_ring.alg_equiv_of_quotient f,\n split; rintros ⟨hf, hi⟩; use hf; intros I hI,\n { have := hi (map ↑h.symm I) (map_ne_zero _ hI),\n convert congr_arg (map (h : (fraction_ring.of A).codomain →ₐ[A] f.codomain)) this;\n simp only [map_symm_map, map_one, fractional_ideal.map_mul, fractional_ideal.map_div,\n inv_eq] },\n { have := hi (map ↑h I) (map_ne_zero _ hI),\n convert congr_arg (map (h.symm : f.codomain →ₐ[A] (fraction_ring.of A).codomain)) this;\n simp only [map_map_symm, map_one, fractional_ideal.map_mul, fractional_ideal.map_div,\n inv_eq] },\nend\n\nend inverse\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/ring_theory/dedekind_domain.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.46490157137338844, "lm_q1q2_score": 0.23789785362482152}} {"text": "import defs data.list.perm\nopen nnf\n\nnamespace list\nuniverses u v w\nvariables {α : Type u}\n\ntheorem length_sub_lt_of_nodup_subperm [decidable_eq α] {l₁ l₂ : list α} {a : α} \n(h₁ : l₁ <+~ l₂) (h₂ : a ∈ l₂) (h₃ : a ∉ l₁) (h₄ : nodup l₁):\nlength l₂ - length (a :: l₁) < length l₂ - length l₁\n:=\nbegin\n rw nat.sub_lt_sub_left_iff,\n { simp [zero_lt_one] }, \n { apply subperm.length_le, \n apply cons_subperm_of_mem; assumption }\nend\n\nend list\n\nstructure psig : Type :=\n(d : nnf)\n(b : list nnf)\n\ninstance : decidable_eq psig := by tactic.mk_dec_eq_instance\n\ndef sig : Type := option psig\n\ninstance : decidable_eq sig := by tactic.mk_dec_eq_instance\n\ndef dsig : Π (s : sig) (h : s ≠ none), nnf\n| none h := by contradiction\n| (some ⟨d, b⟩) h := d\n\ndef bsig : Π (s : sig) (h : s ≠ none), list nnf\n| none h := by contradiction\n| (some ⟨d, b⟩) h := b\n\ninstance (Γ) : decidable_eq (no_literals Γ) := by tactic.mk_dec_eq_instance\n\ninstance (Γ) : decidable_eq (saturated Γ) := by tactic.mk_dec_eq_instance\n\ninstance (Γ) : decidable_eq (box_only Γ) := by tactic.mk_dec_eq_instance\n\nstructure sseqt : Type :=\n(goal : list nnf)\n(s : sig) -- sig := option psig\n(a : list psig) -- psig is the signature, which is of the form (d, b)\n(h b m: list nnf)\n(ndh : list.nodup h) -- nodup says there is no duplicate elements\n(ndb : list.nodup b)\n(sph : h <+~ closure goal) -- <+~ denotes sublist permutation\n(spb : b <+~ closure goal)\n(sbm : m ⊆ closure goal)\n(ha : ∀ φ ∈ h, (⟨φ, b⟩ : psig) ∈ a)\n(hb : box_only b)\n-- dsig takes a signature (d, b) and a proof h, and returns d\n(ps₁ : Π (h : s ≠ none), dsig s h ∈ m)\n-- bsig takes a signature (d, b) and a proof h, and returns b\n(ps₂ : Π (h : s ≠ none), bsig s h ⊆ m)\n\ninstance : decidable_eq sseqt := by tactic.mk_dec_eq_instance\n\nclass val_constructible (Γ : sseqt) :=\n(satu : saturated Γ.m)\n(no_box_main : ∀ {φ}, box φ ∉ Γ.m)\n(no_contra_main : ∀ {n}, var n ∈ Γ.m → neg n ∉ Γ.m)\n\nclass modal_applicable (Γ : sseqt) extends val_constructible Γ :=\n(φ : nnf)\n(ex : dia φ ∈ Γ.m)\n\nclass model_constructible (Γ : sseqt) extends val_constructible Γ :=\n(no_dia : ∀ {φ}, nnf.dia φ ∉ Γ.m)\n\ndef and_child {φ ψ} (Γ : sseqt) (h : nnf.and φ ψ ∈ Γ.m) : sseqt :=\n{ goal := Γ.goal, \n s := none,\n m := φ :: ψ :: Γ.m.erase (and φ ψ),\n sbm := begin \n intros x hx, cases hx, \n {rw hx, apply (mem_closure_and _ (Γ.sbm h)).1}, \n {cases hx, \n {rw hx, apply (mem_closure_and _ (Γ.sbm h)).2},\n {apply Γ.sbm, apply list.erase_subset, exact hx}}\n end,\n ps₁ := by intro; contradiction,\n ps₂ := by intro; contradiction,\n .. Γ}\n\ninductive and_instance_seqt (Γ : sseqt) : sseqt → Type\n| cons : Π {φ ψ} (h : nnf.and φ ψ ∈ Γ.m), \n and_instance_seqt $ and_child Γ h\n\ndef or_child_left {φ ψ} (Γ : sseqt) (h : nnf.or φ ψ ∈ Γ.m) : sseqt :=\n{ goal := Γ.goal, \n s := none,\n m := φ :: Γ.m.erase (or φ ψ),\n sbm := begin \n intros x hx, cases hx, \n {rw hx, apply (mem_closure_or _ (Γ.sbm h)).1}, \n {apply Γ.sbm, apply list.erase_subset, exact hx}\n end,\n ps₁ := by intro; contradiction,\n ps₂ := by intro; contradiction,\n .. Γ}\n\ndef or_child_right {φ ψ} (Γ : sseqt) (h : nnf.or φ ψ ∈ Γ.m) : sseqt :=\n{ goal := Γ.goal, \n s := none,\n m := ψ :: Γ.m.erase (or φ ψ),\n sbm := begin \n intros x hx, cases hx, \n {rw hx, apply (mem_closure_or _ (Γ.sbm h)).2}, \n {apply Γ.sbm, apply list.erase_subset, exact hx}\n end,\n ps₁ := by intro; contradiction,\n ps₂ := by intro; contradiction,\n .. Γ}\n\ninductive or_instance_seqt (Γ : sseqt) : sseqt → sseqt → Type\n| cons : Π {φ ψ} (h : nnf.or φ ψ ∈ Γ.m),\n or_instance_seqt (or_child_left Γ h) (or_child_right Γ h)\n\ndef box_child_new {φ} (Γ : sseqt) (h₁ : nnf.box φ ∈ Γ.m) (h₂ : nnf.box φ ∉ Γ.b) : sseqt :=\n{ goal := Γ.goal, \n s := none,\n h := [], \n b := box φ :: Γ.b, \n m := φ :: Γ.m.erase (box φ),\n ndh := by simp,\n ndb := begin rw list.nodup_cons, split, exact h₂, exact Γ.ndb end,\n sph := begin apply list.nil_subperm end,\n spb := begin \n apply list.cons_subperm_of_mem Γ.ndb h₂, \n apply Γ.sbm h₁, apply Γ.spb\n end,\n sbm := begin \n intros x hx, cases hx, \n {rw hx, apply mem_closure_box _ (Γ.sbm h₁)}, \n {apply Γ.sbm, apply list.erase_subset, exact hx}\n end,\n ha := λ φ h, absurd h $ list.not_mem_nil _,\n hb := cons_box_only Γ.hb,\n ps₁ := by intro; contradiction,\n ps₂ := by intro; contradiction,\n .. Γ}\n\ninductive box_new_instance_seqt (Γ : sseqt) : sseqt → Type\n| cons : Π {φ} (h₁ : nnf.box φ ∈ Γ.m) (h₂ : nnf.box φ ∉ Γ.b), \n box_new_instance_seqt $ box_child_new Γ h₁ h₂\n\ndef box_child {φ} (Γ : sseqt) (h₁ : nnf.box φ ∈ Γ.m) : sseqt :=\n{ goal := Γ.goal, \n s := none,\n a := Γ.a, \n h := Γ.h, \n b := Γ.b, \n m := φ :: Γ.m.erase (box φ),\n ndh := Γ.ndh,\n ndb := Γ.ndb,\n sph := Γ.sph,\n spb := Γ.spb,\n sbm := begin \n intros x hx, cases hx, \n {rw hx, apply mem_closure_box _ (Γ.sbm h₁)}, \n {apply Γ.sbm, apply list.erase_subset, exact hx}\n end,\n ha := Γ.ha,\n hb := Γ.hb,\n ps₁ := by intro; contradiction,\n ps₂ := by intro; contradiction}\n\ninductive box_dup_instance_seqt (Γ : sseqt) : sseqt → Type\n| cons : Π {φ} (h₁ : nnf.box φ ∈ Γ.m) (h₂ : nnf.box φ ∈ Γ.b), \n box_dup_instance_seqt $ box_child Γ h₁\n\n\ntheorem hintikka_vc {Γ} (h : val_constructible Γ) : hintikka Γ.m :=\n{hno_contra := h.no_contra_main,\n hand_left := begin intros φ ψ h₁, exfalso, apply h.satu.no_and, exact h₁ end,\n hand_right := begin intros φ ψ h₁, exfalso, apply h.satu.no_and, exact h₁ end,\n hor := begin intros φ ψ h₁, exfalso, apply h.satu.no_or, exact h₁ end,\n hbox := begin intros φ h₁, exfalso, apply h.no_box_main, exact h₁ end}\n\ntheorem hintikka_ma {Γ} (h : modal_applicable Γ) : hintikka Γ.m :=\nhintikka_vc h.to_val_constructible\n\ntheorem hintikka_mc {Γ} (h : model_constructible Γ) : hintikka Γ.m :=\nhintikka_vc h.to_val_constructible\n\nstructure info : Type :=\n(id : sseqt)\n(htk : list nnf)\n(hhtk : hintikka htk)\n(mhtk : id.m ⊆ htk)\n\ninstance : decidable_eq info := by tactic.mk_dec_eq_instance\n\ninductive tmodel\n| cons : info → list tmodel → list psig → tmodel\n\ninstance : decidable_eq tmodel := by tactic.mk_dec_eq_instance\n", "meta": {"author": "minchaowu", "repo": "ModalTab", "sha": "9bb0bf17faf0554d907ef7bdd639648742889178", "save_path": "github-repos/lean/minchaowu-ModalTab", "path": "github-repos/lean/minchaowu-ModalTab/ModalTab-9bb0bf17faf0554d907ef7bdd639648742889178/src/S4/data.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5428632979641571, "lm_q2_score": 0.4378234991142019, "lm_q1q2_score": 0.23767830865534284}} {"text": "import data.cpi.species data.upair\n\nnamespace cpi\n\nvariables {ℍ : Type} {ω : context}\n\n/-- The kind of a production, either a species or concretion-/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive kind\n| species\n| concretion\n\n/-- A transition from a species to some production of a given kind. -/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive label (ℍ : Type) : context → kind → Type\n/- From a species to a concretion. Sends $b$ values on channel $a$ and evolves\n into whatever species the concretion applies, substituting $y$ variables\n with the values received. -/\n| apply {} {Γ} (a : name Γ) : label Γ kind.concretion\n\n/- Evolution from one species to another species without any other interaction,\n at a specific rate. -/\n| spontaneous {Γ} (rate : ℍ) : label Γ kind.species\n\n/- Evolution from one species to another, with a rate determined by an affinity\n network. This is converted into a spontaneous interaction when the names\n refer to a global affinity network. -/\n| of_affinity {} {Γ} (k : upair (name Γ)) : label Γ kind.species\n\nnotation `#`:max a:max := label.apply a\nnotation `τ@'`:max k:max := label.spontaneous k\nnotation `τ⟨ `:max a `, ` b ` ⟩`:max := label.of_affinity (upair.mk a b)\nnotation `τ⟨ `:max p ` ⟩`:max := label.of_affinity p\n\n/-- Convert a label to a string. Can use `repr` normally. -/\nprotected def label.to_string [has_repr ℍ] : ∀ {k}, label ℍ ω k → string\n| ._ (# a) := \"#\" ++ repr a\n| ._ (τ@' k) := \"τ@\" ++ repr k\n| ._ (τ⟨ p ⟩) := \"τ⟨ \" ++ repr p ++ \" ⟩\"\n\ninstance label.has_repr [has_repr ℍ] {k} : has_repr (label ℍ ω k) := ⟨ label.to_string ⟩\n\n/-- Rename all names within a label. -/\ndef label.rename {Γ Δ} (ρ : name Γ → name Δ) : ∀ {k}, label ℍ Γ k → label ℍ Δ k\n| ._ #a := # (ρ a)\n| ._ τ@'k := τ@'k\n| ._ τ⟨ ab ⟩ := τ⟨ upair.map ρ ab ⟩\n\nlemma label.rename.inj {Γ Δ} {ρ : name Γ → name Δ} (inj : function.injective ρ)\n : ∀ {k}, function.injective (@label.rename ℍ Γ Δ ρ k)\n | ._ #a #b eq := by { cases inj (label.apply.inj eq), from rfl }\n | ._ τ@'k τ@'j rfl := rfl\n | ._ τ⟨ a ⟩ τ⟨ b ⟩ eq := begin\n cases upair.map.inj inj (label.of_affinity.inj eq),\n from rfl\n end\n | ._ τ@'k τ⟨ _ ⟩ eq := by contradiction\n | ._ τ⟨ _ ⟩ τ@'k eq := by contradiction\n\nlemma label.rename_compose {Γ Δ η} (ρ : name Γ → name Δ) (σ : name Δ → name η)\n : ∀ {k} (l : label ℍ Γ k)\n , label.rename σ (label.rename ρ l) = label.rename (σ ∘ ρ) l\n| ._ #a := rfl\n| ._ τ@'k := rfl\n| ._ τ⟨ ab ⟩ := by simp only [label.rename, upair.map_compose]\n\nlemma label.rename_id {Γ} : ∀ {k} (l : label ℍ Γ k), label.rename id l = l\n| ._ #a := rfl\n| ._ τ@'k := rfl\n| ._ τ⟨ p ⟩ := congr_arg _ (upair.map_identity p)\n\nend cpi\n\n#lint-\n", "meta": {"author": "continuouspi", "repo": "lean-cpi", "sha": "443bf2cb236feadc45a01387099c236ab2b78237", "save_path": "github-repos/lean/continuouspi-lean-cpi", "path": "github-repos/lean/continuouspi-lean-cpi/lean-cpi-443bf2cb236feadc45a01387099c236ab2b78237/src/data/cpi/transition/label.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5888891163376235, "lm_q2_score": 0.40356685373537454, "lm_q1q2_score": 0.23765612787937967}} {"text": "import phase2.litter_completion\n\nopen set sum\nopen_locale pointwise\n\nuniverse u\n\nnamespace con_nf\n\nnamespace struct_approx\nvariables [params.{u}] {α : Λ} [position_data.{}] [phase_2_assumptions α]\n {β : Iic α} [freedom_of_action_hypothesis β]\n\ndef near_litter_hypothesis (N : near_litter) (A : extended_index β) (H : hypothesis ⟨inr N, A⟩) :\n hypothesis ⟨inr N.1.to_near_litter, A⟩ := {\n atom_image := λ a B h, H.atom_image a B (begin\n by_cases h' : litter_set N.fst = N.snd,\n suffices : N.fst.to_near_litter = N,\n { rwa this at h, },\n { ext : 1,\n refl,\n exact h', },\n exact relation.trans_gen.tail h (constrains.near_litter N h' A),\n end),\n near_litter_image := λ N' B h, H.near_litter_image N' B (begin\n by_cases h' : litter_set N.fst = N.snd,\n suffices : N.fst.to_near_litter = N,\n { rwa this at h, },\n { ext : 1,\n refl,\n exact h', },\n exact relation.trans_gen.tail h (constrains.near_litter N h' A),\n end),\n}\n\ndef near_litter_completion_map (π : struct_approx β) (hπ : π.free)\n (N : near_litter) (A : extended_index β) (H : hypothesis ⟨inr N, A⟩) : set atom :=\n(near_litter_approx.largest_sublitter (π A)\n (litter_completion π hπ N.1 A (near_litter_hypothesis N A H)) ∪\n π A • (N ∩ (π A).atom_perm.domain)) ∆\n ⋃ (a : atom) (ha : a ∈ (litter_set N.1 ∆ N) \\ (π A).atom_perm.domain),\n {H.atom_image a A (relation.trans_gen.single (constrains.symm_diff N a ha.1 A))}\n\n-- TODO: Move this lemma\nlemma near_litter_approx.near_litter_domain_small (π : near_litter_approx) (N : near_litter) :\n small ((N : set atom) ∩ π.atom_perm.domain) :=\nbegin\n rw [← symm_diff_symm_diff_cancel_left (litter_set N.fst) N, inter_symm_diff_distrib_right],\n exact small.symm_diff (π.domain_small N.fst) (small.mono (inter_subset_left _ _) N.2.prop),\nend\n\n/-\nlemma largest_sublitter_symm_diff_small (π : near_litter_approx) (N : near_litter) :\n small ((π.largest_sublitter N.fst : set atom) ∆ N) :=\nbegin\n refine is_near_litter.near _ _,\n exact N.fst,\n exact (near_litter.is_near_litter (π.largest_sublitter N.fst).to_near_litter _).mpr rfl,\n rw near_litter.is_near_litter,\nend\n\nlemma largest_sublitter_diff_small (π : near_litter_approx) (N : near_litter) :\n small ((π.largest_sublitter N.fst : set atom) \\ N) :=\nsmall.mono (subset_union_left _ _) (largest_sublitter_symm_diff_small π N)\n-/\n\nlemma near_litter_completion_map_is_near_litter (π : struct_approx β)\n (hπ : π.free) (N : near_litter) (A : extended_index β) (H : hypothesis ⟨inr N, A⟩) :\n is_near_litter (π.litter_completion hπ N.fst A (near_litter_hypothesis N A H))\n (π.near_litter_completion_map hπ N A H) :=\nbegin\n rw [near_litter_completion_map, is_near_litter, is_near, near_litter_approx.coe_largest_sublitter,\n ← symm_diff_assoc, symm_diff_comm, ← small.symm_diff_iff _],\n { rw [set.symm_diff_def, ← diff_diff, sdiff_sdiff_right_self, inf_eq_inter,\n union_diff_distrib, sdiff_sdiff_self, bot_eq_empty, empty_union],\n exact small.union (small.mono (diff_subset _ _) ((π A).domain_small _))\n (small.mono (diff_subset _ _) ((near_litter_approx.near_litter_domain_small _ _).image)), },\n { exact small.bUnion (small.mono (diff_subset _ _) N.2.prop) (λ _ _, small_singleton _), },\nend\n\nnoncomputable def near_litter_completion (π : struct_approx β) (hπ : π.free)\n (N : near_litter) (A : extended_index β) (H : hypothesis ⟨inr N, A⟩) : near_litter :=\n⟨litter_completion π hπ N.1 A (near_litter_hypothesis N A H),\n near_litter_completion_map π hπ N A H,\n near_litter_completion_map_is_near_litter π hπ N A H⟩\n\n@[simp] lemma near_litter_completion_fst_eq (π : struct_approx β) (hπ : π.free)\n (N : near_litter) (A : extended_index β) (H : hypothesis ⟨inr N, A⟩) :\n (π.near_litter_completion hπ N A H).1 =\n litter_completion π hπ N.1 A (near_litter_hypothesis N A H) := rfl\n\nend struct_approx\n\nend con_nf\n", "meta": {"author": "leanprover-community", "repo": "con-nf", "sha": "f0b66bd73ca5d3bd8b744985242c4c0b5464913f", "save_path": "github-repos/lean/leanprover-community-con-nf", "path": "github-repos/lean/leanprover-community-con-nf/con-nf-f0b66bd73ca5d3bd8b744985242c4c0b5464913f/src/phase2/near_litter_completion.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5774953797290152, "lm_q2_score": 0.41111086923216794, "lm_q1q2_score": 0.23741462753795634}} {"text": "import .presheaves\n\nopen category_theory opposite\n\nnoncomputable theory\n\nvariables (C : Type) [category.{0} C]\n\ninductive prod_coprod : Type\n| of_cat' : C → prod_coprod\n| prod : prod_coprod → prod_coprod → prod_coprod\n| coprod : prod_coprod → prod_coprod → prod_coprod\n\nvariable {C}\n\nnamespace prod_coprod\n\ninductive syntax : Π (X Y : prod_coprod C), Type\n| of_cat {X Y : C} : (X ⟶ Y) → syntax (of_cat' X) (of_cat' Y)\n| prod_mk {X Y Z : prod_coprod C} : syntax X Y → syntax X Z → syntax X (Y.prod Z)\n| fst {X Y : prod_coprod C} : syntax (X.prod Y) X\n| snd {X Y : prod_coprod C} : syntax (X.prod Y) Y\n| coprod_mk {X Y Z : prod_coprod C} : syntax X Z → syntax Y Z → syntax (X.coprod Y) Z\n| inl {X Y : prod_coprod C} : syntax X (X.coprod Y)\n| inr {X Y : prod_coprod C} : syntax Y (X.coprod Y)\n| id (X : prod_coprod C) : syntax X X\n| comp {X Y Z : prod_coprod C} : syntax X Y → syntax Y Z → syntax X Z\n\nnamespace syntax\n\ninductive rel : Π {X Y : prod_coprod C}, syntax X Y → syntax X Y → Prop\n| refl {X Y : prod_coprod C} (f : syntax X Y) : rel f f\n| symm {X Y : prod_coprod C} {f g : syntax X Y} : rel f g → rel g f\n| trans {X Y : prod_coprod C} {f g h : syntax X Y} : rel f g → rel g h → rel f h\n| comp_congr {X Y Z : prod_coprod C} {f₁ f₂ : syntax X Y} {g₁ g₂ : syntax Y Z} :\n rel f₁ f₂ → rel g₁ g₂ → rel (f₁.comp g₁) (f₂.comp g₂)\n| prod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : syntax X Y} {g₁ g₂ : syntax X Z} :\n rel f₁ f₂ → rel g₁ g₂ → rel (f₁.prod_mk g₁) (f₂.prod_mk g₂)\n| coprod_mk_congr {X Y Z : prod_coprod C} {f₁ f₂ : syntax X Z} {g₁ g₂ : syntax Y Z} :\n rel f₁ f₂ → rel g₁ g₂ → rel (f₁.coprod_mk g₁) (f₂.coprod_mk g₂)\n| id_comp {X Y : prod_coprod C} (f : syntax X Y) : rel ((syntax.id X).comp f) f\n| comp_id {X Y : prod_coprod C} (f : syntax X Y) : rel (f.comp (syntax.id Y)) f\n| assoc {W X Y Z : prod_coprod C} (f : syntax W X) (g : syntax X Y) (h : syntax Y Z) :\n rel ((f.comp g).comp h) (f.comp (g.comp h))\n| of_cat_id {X : C} : rel (syntax.of_cat (𝟙 X)) (syntax.id (of_cat' X))\n| of_cat_comp {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n rel (syntax.of_cat (f ≫ g)) (syntax.comp (syntax.of_cat f) (syntax.of_cat g))\n| mk_fst_comp {X Y Z : prod_coprod C} (f : syntax X Y) (g : syntax X Z) :\n rel (syntax.comp (syntax.prod_mk f g) syntax.fst) f\n| mk_snd_comp {X Y Z : prod_coprod C} (f : syntax X Y) (g : syntax X Z) :\n rel (syntax.comp (syntax.prod_mk f g) syntax.snd) g\n| prod_eta {X Y Z : prod_coprod C} (f : syntax X (Y.prod Z)) :\n rel (syntax.prod_mk (f.comp syntax.fst) (f.comp syntax.snd)) f\n| inl_comp_mk {X Y Z : prod_coprod C} (f : syntax X Z) (g : syntax Y Z) :\n rel (syntax.comp syntax.inl (syntax.coprod_mk f g)) f\n| inr_comp_mk {X Y Z : prod_coprod C} (f : syntax X Z) (g : syntax Y Z) :\n rel (syntax.comp syntax.inr (syntax.coprod_mk f g)) g\n| coprod_eta {X Y Z : prod_coprod C} (f : syntax (X.coprod Y) Z) :\n rel (syntax.coprod_mk (syntax.inl.comp f) (syntax.inr.comp f)) f\n\nattribute [refl] rel.refl\nattribute [symm] rel.symm\nattribute [trans] rel.trans\n\ninfixl ` ♥ `: 50 := rel\n\nlemma rel_prod {X Y Z : prod_coprod C} {f g : syntax X (Y.prod Z)}\n (h₁ : rel (f.comp syntax.fst) (g.comp syntax.fst))\n (h₂ : rel (f.comp syntax.snd) (g.comp syntax.snd)) :\n rel f g :=\ncalc f ♥ syntax.prod_mk (f.comp syntax.fst) (f.comp syntax.snd) : rel.symm (rel.prod_eta f)\n ... ♥ syntax.prod_mk (g.comp syntax.fst) (g.comp syntax.snd) : rel.prod_mk_congr h₁ h₂\n ... ♥ g : rel.prod_eta g\n\nlemma rel_coprod {X Y Z : prod_coprod C} {f g : syntax (X.coprod Y) Z}\n (h₁ : rel (syntax.inl.comp f) (syntax.inl.comp g))\n (h₂ : rel (syntax.inr.comp f) (syntax.inr.comp g)) :\n rel f g :=\ncalc f ♥ syntax.coprod_mk (syntax.inl.comp f) (syntax.inr.comp f) : rel.symm (rel.coprod_eta f)\n ... ♥ syntax.coprod_mk (syntax.inl.comp g) (syntax.inr.comp g) : rel.coprod_mk_congr h₁ h₂\n ... ♥ g : rel.coprod_eta g\n\ninstance rel_setoid (X Y : prod_coprod C) : setoid (syntax X Y) :=\n{ r := rel,\n iseqv := ⟨rel.refl, λ _ _, rel.symm, λ _ _ _, rel.trans⟩ }\n\nend syntax\n\nsection syntax\n\nopen syntax\n\ndef hom (X Y : prod_coprod C) : Type := quotient (syntax.rel_setoid X Y)\n\ninstance : category_struct (prod_coprod C) :=\n{ hom := hom,\n id := λ X, quotient.mk' (syntax.id X),\n comp := λ X Y Z f g, quotient.lift_on₂ f g (λ f g, quotient.mk' (syntax.comp f g))\n (λ f₁ g₁ f₂ g₂ hf hg, quotient.sound (rel.comp_congr hf hg)) }\n\ninstance : category (prod_coprod C) :=\n{ id_comp' := λ X Y f, quotient.induction_on f (λ f, quotient.sound (rel.id_comp f)),\n comp_id' := λ X Y f, quotient.induction_on f (λ f, quotient.sound (rel.comp_id f)),\n assoc' := λ W X Y Z f g h, quotient.induction_on₃ f g h\n (λ f g h, quotient.sound (rel.assoc f g h)) }\n\ndef of_syntax {X Y : prod_coprod C} : syntax X Y → (X ⟶ Y) := quotient.mk\n\ndef of_cat : C ⥤ prod_coprod C :=\n{ obj := λ X, of_cat' X,\n map := λ X Y f, of_syntax (syntax.of_cat f),\n map_id' := λ X, quotient.sound rel.of_cat_id,\n map_comp' := λ X Y Z f g, quotient.sound (rel.of_cat_comp f g) }\n\n@[simp] lemma of_cat_obj (X : C) : of_cat.obj X = of_cat' X := rfl\n\ndef prod_mk {X Y Z : prod_coprod C} (f : X ⟶ Y) (g : X ⟶ Z) : X ⟶ (Y.prod Z) :=\nquotient.lift_on₂ f g (λ f g, of_syntax (prod_mk f g)) begin\n intros,\n dsimp,\n refine quotient.sound _,\n refine rel.prod_mk_congr _ _; assumption\nend\n\ndef fst {X Y : prod_coprod C} : (X.prod Y) ⟶ X :=\nof_syntax fst\n\ndef snd {X Y : prod_coprod C} : (X.prod Y) ⟶ Y :=\nof_syntax snd\n\n@[simp] lemma prod_mk_fst_comp {X Y Z : prod_coprod C} (f : X ⟶ Y) (g : X ⟶ Z) :\n prod_mk f g ≫ fst = f :=\nquotient.induction_on₂ f g (λ f g, quotient.sound (syntax.rel.mk_fst_comp _ _))\n\n@[simp] lemma prod_mk_snd_comp {X Y Z : prod_coprod C} (f : X ⟶ Y) (g : X ⟶ Z) :\n prod_mk f g ≫ snd = g :=\nquotient.induction_on₂ f g (λ f g, quotient.sound (syntax.rel.mk_snd_comp _ _))\n\nlemma prod_mk_eta {X Y Z : prod_coprod C} (f : X ⟶ Y.prod Z) :\n prod_mk (f ≫ fst) (f ≫ snd) = f :=\nquotient.induction_on f (λ f, quotient.sound (syntax.rel.prod_eta _))\n\n@[ext] lemma prod_hom_ext {X Y Z : prod_coprod C} {f g : X ⟶ Y.prod Z}\n (h₁ : f ≫ fst = g ≫ fst) (h₂ : f ≫ snd = g ≫ snd) : f = g :=\nbegin\n conv_lhs { rw ← prod_mk_eta f },\n rw [h₁, h₂, prod_mk_eta]\nend\n\ndef coprod_mk {X Y Z : prod_coprod C} (f : X ⟶ Z) (g : Y ⟶ Z) : (X.coprod Y) ⟶ Z :=\nquotient.lift_on₂ f g (λ f g, of_syntax (coprod_mk f g)) begin\n intros,\n dsimp,\n refine quotient.sound _,\n refine rel.coprod_mk_congr _ _; assumption\nend\n\ndef inl {X Y : prod_coprod C} : X ⟶ (X.coprod Y) :=\nof_syntax inl\n\ndef inr {X Y : prod_coprod C} : Y ⟶ (X.coprod Y) :=\nof_syntax inr\n\n@[elab_as_eliminator] lemma hom_induction\n {motive : Π (X Y : prod_coprod C), (X ⟶ Y) → Prop}\n {X Y : prod_coprod C} (f : X ⟶ Y)\n (h₁ : Π {X Y : C} (f : X ⟶ Y), motive _ _ (of_cat.map f))\n (h₂ : Π {X Y Z : prod_coprod C} (f : X ⟶ Y) (g : X ⟶ Z),\n motive X Y f → motive X Z g → motive _ _ (prod_mk f g))\n (h₃ : Π {X Y : prod_coprod C}, motive (X.prod Y) X fst)\n (h₄ : Π {X Y : prod_coprod C}, motive (X.prod Y) Y snd)\n (h₅ : Π {X Y Z : prod_coprod C} (f : X ⟶ Z) (g : Y ⟶ Z),\n motive X Z f → motive Y Z g → motive _ _ (coprod_mk f g))\n (h₆ : Π {X Y : prod_coprod C}, motive X (X.coprod Y) inl)\n (h₇ : Π {X Y : prod_coprod C}, motive Y (X.coprod Y) inr)\n (h₈ : Π (X : prod_coprod C), motive X X (𝟙 X))\n (h₉ : Π {X Y Z : prod_coprod C} (f : X ⟶ Y) (g : Y ⟶ Z),\n motive X Y f → motive Y Z g → motive X Z (f ≫ g)) :\n motive X Y f :=\nquotient.induction_on f\n begin\n intro f,\n apply syntax.rec_on f; try { assumption },\n { intros _ _ _ f g,\n exact h₂ (of_syntax f) (of_syntax g) },\n { intros _ _ _ f g,\n exact h₅ (of_syntax f) (of_syntax g) },\n { intros _ _ _ f g,\n exact h₉ (of_syntax f) (of_syntax g) }\n end\n\n@[simp] lemma inl_comp_coprod_mk {X Y Z : prod_coprod C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n inl ≫ coprod_mk f g = f :=\nquotient.induction_on₂ f g (λ f g, quotient.sound (syntax.rel.inl_comp_mk _ _))\n\n@[simp] lemma inr_comp_coprod_mk {X Y Z : prod_coprod C} (f : X ⟶ Z) (g : Y ⟶ Z) :\n inr ≫ coprod_mk f g = g :=\nquotient.induction_on₂ f g (λ f g, quotient.sound (syntax.rel.inr_comp_mk _ _))\n\nlemma coprod_mk_eta {X Y Z : prod_coprod C} (f : X.coprod Y ⟶ Z) :\n coprod_mk (inl ≫ f) (inr ≫ f) = f :=\nquotient.induction_on f (λ f, quotient.sound (syntax.rel.coprod_eta _))\n\n@[ext] lemma coprod_hom_ext {X Y Z : prod_coprod C} {f g : X.coprod Y ⟶ Z}\n (h₁ : inl ≫ f = inl ≫ g ) (h₂ : inr ≫ f = inr ≫ g) : f = g :=\nbegin\n conv_lhs { rw ← coprod_mk_eta f },\n rw [h₁, h₂, coprod_mk_eta]\nend\n\n-- def wf_rel (x y : (prod_coprod C × prod_coprod C) ⊕\n-- (prod_coprod C × prod_coprod C × prod_coprod C)) :Prop :=\n-- sum.lex (measure sizeof) (measure sizeof) x y\n\n\n\n-- @[simp] def sizeof2 : prod_coprod C → ℕ\n-- | (of_cat' X) := 0\n-- | (prod X Y) := sizeof2 X + sizeof2 Y + 0\n-- | (coprod X Y) := sizeof2 X + sizeof2 Y + 1\n\n-- def hwf_rel_wf : has_well_founded ((prod_coprod C × prod_coprod C) ⊕\n-- (prod_coprod C × prod_coprod C × prod_coprod C)) :=\n-- ⟨_, measure_wf (λ x, sum.cases_on x\n-- (λ x, sizeof x.1 + sizeof x.2)\n-- (λ x, sizeof x.1 + sizeof x.2.1 + sizeof x.2.2))⟩\n\n-- @[simp] lemma hwf_rel_wf_simp :@has_well_founded.r _ (@hwf_rel_wf C _) =\n-- measure (λ x, sum.cases_on x\n-- (λ x, sizeof x.1 + sizeof x.2)\n-- (λ x, sizeof x.1 + sizeof x.2.1 + sizeof x.2.2)) := rfl\n\n-- meta def wf_dec_tac : tactic unit :=\n-- `[try { simp },\n-- well_founded_tactics.default_dec_tac]\n\n/-- Defining two maps by mutual induction. Morally we are defining the following.\n First - `norm_type (X Y : prod_coprod C) : Type`\n The type of normal form of maps `X ⟶ Y`.\n Second - `norm_type_not_proj (X Y Z : prod_coprod C) : Type`\n The type of normal forms of maps `(X.prod Y) ⟶ Z` that cannot be written\n `fst ≫ f` or `snd ≫ f` for any `f`\n-/\n\n-- @[simp] def norm_type :\n-- ((prod_coprod C × prod_coprod C) ⊕\n-- (prod_coprod C × prod_coprod C × prod_coprod C)) → Type\n-- | (sum.inl (coprod X Y, Z)) := norm_type (sum.inl (X, Z)) × norm_type (sum.inl (Y, Z))\n-- | (sum.inl (prod X Y, Z)) :=\n-- norm_type (sum.inl (X, Z)) ⊕ norm_type (sum.inl (Y, Z))\n-- ⊕ norm_type (sum.inr (X, Y, Z))\n-- | (sum.inl (of_cat' X, of_cat' Y)) := X ⟶ Y\n-- | (sum.inl (of_cat' X, prod Y Z)) :=\n-- norm_type (sum.inl (of_cat' X, Y)) × norm_type (sum.inl (of_cat' X, Z))\n-- | (sum.inl (of_cat' X, coprod Y Z)) :=\n-- norm_type (sum.inl (of_cat' X, Y)) ⊕ norm_type (sum.inl (of_cat' X, Z))\n-- | (sum.inr (W, X, coprod Y Z)) :=\n-- norm_type (sum.inr (W, X, Y)) ⊕ -- (f : prod W X ⟶ Y) ≫ inl\n-- norm_type (sum.inr (W, X, Z)) -- (f : prod W X ⟶ Z) ≫ inr\n-- | (sum.inr (W, X, prod Y Z)) :=\n-- (norm_type (sum.inr (W, X, Y)) × norm_type (sum.inr (W, X, Z))) ⊕ -- prod_mk _ _\n-- (norm_type (sum.inl (W, Y)) × norm_type (sum.inl (X, Z))) ⊕\n-- (norm_type (sum.inl (W, Z)) × norm_type (sum.inl (X, Y)))\n-- | (sum.inr (X, Y, of_cat' Z)) := empty\n-- using_well_founded {\n-- dec_tac := wf_dec_tac,\n-- rel_tac := λ _ _, `[exact hwf_rel_wf] }\n\ninductive norm_hom :\n ((prod_coprod C × prod_coprod C) ⊕\n (prod_coprod C × prod_coprod C × prod_coprod C)) → Type\n| coprod_mk {X Y Z : prod_coprod C} :\n norm_hom (sum.inl (X, Z)) → norm_hom (sum.inl (Y, Z)) →\n norm_hom (sum.inl (coprod X Y, Z))\n| fst_comp {X Y Z : prod_coprod C} : norm_hom (sum.inl (X, Z)) →\n norm_hom (sum.inl (prod X Y, Z))\n| snd_comp {X Y Z : prod_coprod C} : norm_hom (sum.inl (Y, Z)) →\n norm_hom (sum.inl (prod X Y, Z))\n| of_not_proj {X Y Z : prod_coprod C} : norm_hom (sum.inr (X, Y, Z)) →\n norm_hom (sum.inl (prod X Y, Z))\n| of_cat {X Y : C} : (X ⟶ Y) → norm_hom (sum.inl (of_cat' X, of_cat' Y))\n| comp_inl_of_cat {X : C} {Y Z : prod_coprod C} : norm_hom (sum.inl (of_cat' X, Y)) →\n norm_hom (sum.inl (of_cat' X, coprod Y Z))\n| comp_inr_of_cat {X : C} {Y Z : prod_coprod C} : norm_hom (sum.inl (of_cat' X, Z)) →\n norm_hom (sum.inl (of_cat' X, coprod Y Z))\n| prod_mk_of_cat {X : C} {Y Z : prod_coprod C} : norm_hom (sum.inl (of_cat' X, Y)) →\n norm_hom (sum.inl (of_cat' X, Z)) → norm_hom (sum.inl (of_cat' X, prod Y Z))\n| comp_inl_not_proj {W X Y Z : prod_coprod C} : norm_hom (sum.inr (W, X, Y)) →\n norm_hom (sum.inr (W, X, coprod Y Z))\n| comp_inr_not_proj {W X Y Z : prod_coprod C} : norm_hom (sum.inr (W, X, Z)) →\n norm_hom (sum.inr (W, X, coprod Y Z))\n| prod_mk_not_proj {W X Y Z : prod_coprod C} : norm_hom (sum.inr (W, X, Y)) →\n norm_hom (sum.inr (W, X, Z)) → norm_hom (sum.inr (W, X, prod Y Z))\n| prod_mk_not_proj_fst_comp {W X Y Z : prod_coprod C} : norm_hom (sum.inr (W, X, Y)) →\n norm_hom (sum.inl (W, Z)) → norm_hom (sum.inr (W, X, prod Y Z))\n| prod_mk_not_proj_snd_comp {W X Y Z : prod_coprod C} : norm_hom (sum.inr (W, X, Y)) →\n norm_hom (sum.inl (X, Z)) → norm_hom (sum.inr (W, X, prod Y Z))\n| prod_mk_fst_comp_not_proj {W X Y Z : prod_coprod C} : norm_hom (sum.inl (W, Y)) →\n norm_hom (sum.inr (W, X, Z)) → norm_hom (sum.inr (W, X, prod Y Z))\n| prod_mk_snd_comp_not_proj {W X Y Z : prod_coprod C} : norm_hom (sum.inl (X, Y)) →\n norm_hom (sum.inr (W, X, Z)) → norm_hom (sum.inr (W, X, prod Y Z))\n| prod_mk_fst_comp_snd_comp {W X Y Z : prod_coprod C} :\n norm_hom (sum.inl (W, Y)) → norm_hom (sum.inl (X, Z)) →\n norm_hom (sum.inr (W, X, prod Y Z))\n| prod_mk_snd_comp_fst_comp {W X Y Z : prod_coprod C} :\n norm_hom (sum.inl (X, Y)) → norm_hom (sum.inl (W, Z)) →\n norm_hom (sum.inr (W, X, prod Y Z))\n\nvariables {W X Y Z : prod_coprod C}\n\nopen norm_hom\n\ndef norm_hom.comp_inl : Π {X Y Z : prod_coprod C}, norm_hom (sum.inl (X, Y)) →\n norm_hom (sum.inl (X, coprod Y Z))\n| (of_cat' X) _ _ f := norm_hom.comp_inl_of_cat f\n| (coprod W X) Y Z (norm_hom.coprod_mk f g) := norm_hom.coprod_mk (norm_hom.comp_inl f) (norm_hom.comp_inl g)\n| (prod W X) Y Z (norm_hom.fst_comp f) := norm_hom.fst_comp (norm_hom.comp_inl f)\n| (prod W X) Y Z (norm_hom.snd_comp f) := norm_hom.snd_comp (norm_hom.comp_inl f)\n| (prod W X) Y Z (norm_hom.of_not_proj f) := norm_hom.of_not_proj (norm_hom.comp_inl_not_proj f)\n\ndef norm_hom.comp_inr : Π {X Y Z : prod_coprod C}, norm_hom (sum.inl (X, Z)) →\n norm_hom (sum.inl (X, coprod Y Z))\n| (of_cat' X) _ _ f := norm_hom.comp_inr_of_cat f\n| (coprod W X) Y Z (norm_hom.coprod_mk f g) := norm_hom.coprod_mk (norm_hom.comp_inr f) (norm_hom.comp_inr g)\n| (prod W X) Y Z (norm_hom.fst_comp f) := norm_hom.fst_comp (norm_hom.comp_inr f)\n| (prod W X) Y Z (norm_hom.snd_comp f) := norm_hom.snd_comp (norm_hom.comp_inr f)\n| (prod W X) Y Z (norm_hom.of_not_proj f) := norm_hom.of_not_proj (norm_hom.comp_inr_not_proj f)\n\ndef norm_hom.id : Π (X : prod_coprod C), norm_hom (sum.inl (X, X))\n| (of_cat' X) := norm_hom.of_cat (𝟙 X)\n| (prod X Y) := norm_hom.of_not_proj\n (norm_hom.prod_mk_fst_comp_snd_comp (norm_hom.id X) (norm_hom.id Y))\n| (coprod X Y) :=\n norm_hom.coprod_mk\n (norm_hom.comp_inl (norm_hom.id _))\n (norm_hom.comp_inr (norm_hom.id _))\n\ndef norm_hom.inl {X Y : prod_coprod C} : norm_hom (sum.inl (X, coprod X Y)) :=\nnorm_hom.comp_inl (norm_hom.id _)\n\ndef norm_hom.inr {X Y : prod_coprod C} : norm_hom (sum.inl (Y, coprod X Y)) :=\nnorm_hom.comp_inr (norm_hom.id _)\n\ndef norm_hom.fst {X Y : prod_coprod C} : norm_hom (sum.inl (prod X Y, X)) :=\nnorm_hom.fst_comp (norm_hom.id _)\n\ndef norm_hom.snd {X Y : prod_coprod C} : norm_hom (sum.inl (prod X Y, Y)) :=\nnorm_hom.snd_comp (norm_hom.id _)\n\ndef norm_hom.prod_mk : Π {X Y Z : prod_coprod C} (f : norm_hom (sum.inl (X, Y)))\n (g : norm_hom (sum.inl (X, Z))), norm_hom (sum.inl (X, prod Y Z))\n| (of_cat' X) Y Z f g := norm_hom.prod_mk_of_cat f g\n| (prod W X) Y Z (norm_hom.fst_comp f) (norm_hom.fst_comp g) :=\n norm_hom.fst_comp (norm_hom.prod_mk f g)\n| (prod W X) Y Z (norm_hom.snd_comp f) (norm_hom.snd_comp g) :=\n norm_hom.snd_comp (norm_hom.prod_mk f g)\n| (prod W X) Y Z (norm_hom.fst_comp f) (norm_hom.snd_comp g) :=\n norm_hom.of_not_proj (norm_hom.prod_mk_fst_comp_snd_comp f g)\n| (prod W X) Y Z (norm_hom.snd_comp f) (norm_hom.fst_comp g) :=\n norm_hom.of_not_proj (norm_hom.prod_mk_snd_comp_fst_comp f g)\n| (prod W X) Y Z (norm_hom.of_not_proj f) (norm_hom.fst_comp g) :=\n norm_hom.of_not_proj (norm_hom.prod_mk_not_proj_fst_comp f g)\n| (prod W X) Y Z (norm_hom.of_not_proj f) (norm_hom.snd_comp g) :=\n norm_hom.of_not_proj (norm_hom.prod_mk_not_proj_snd_comp f g)\n| (prod W X) Y Z (norm_hom.fst_comp f) (norm_hom.of_not_proj g) :=\n norm_hom.of_not_proj (norm_hom.prod_mk_fst_comp_not_proj f g)\n| (prod W X) Y Z (norm_hom.snd_comp f) (norm_hom.of_not_proj g) :=\n norm_hom.of_not_proj (norm_hom.prod_mk_snd_comp_not_proj f g)\n| (prod W X) Y Z (norm_hom.of_not_proj f) (norm_hom.of_not_proj g) :=\n norm_hom.of_not_proj (norm_hom.prod_mk_not_proj f g)\n| (coprod W X) Y Z (norm_hom.coprod_mk f g) (norm_hom.coprod_mk h i) :=\n norm_hom.coprod_mk (norm_hom.prod_mk f h) (norm_hom.prod_mk g i)\n--set_option timeout 400000\n\ninductive norm_hom2 : Π (X Y : prod_coprod C), Type\n| of_cat {X Y : C} (f : X ⟶ Y) : norm_hom2 (of_cat' X) (of_cat' Y)\n| coprod_mk {X Y Z : prod_coprod C} (f : norm_hom2 X Z) (g : norm_hom2 Y Z) :\n norm_hom2 (X.coprod Y) Z\n| comp_inl {X Y Z : prod_coprod C} (f : norm_hom2 X Y) :\n norm_hom2 X (coprod Y Z)\n| comp_inr {X Y Z : prod_coprod C} (f : norm_hom2 X Z) :\n norm_hom2 X (coprod Y Z)\n| prod_mk {X Y Z : prod_coprod C} (f : norm_hom2 X Y) (g : norm_hom2 X Z) :\n norm_hom2 X (prod Y Z)\n| fst_comp {X Y Z : prod_coprod C} (f : norm_hom2 X Z) :\n norm_hom2 (prod X Y) Z\n| snd_comp {X Y Z : prod_coprod C} (f : norm_hom2 Y Z) :\n norm_hom2 (prod X Y) Z\n\n@[simp] def norm_hom.to_norm_hom2 : Π {X Y : prod_coprod C} (f : norm_hom (sum.inl (X, Y))),\n norm_hom2 X Y\n| _ _ (norm_hom.of_cat f) := norm_hom2.of_cat f\n| _ _ (norm_hom.coprod_mk f g) := norm_hom2.coprod_mk (norm_hom.to_norm_hom2 f) (norm_hom.to_norm_hom2 g)\n| _ _ (norm_hom.fst_comp f) := norm_hom2.fst_comp (norm_hom.to_norm_hom2 f)\n| _ _ (norm_hom.snd_comp f) := norm_hom2.snd_comp (norm_hom.to_norm_hom2 f)\n| _ _ (norm_hom.comp_inl_of_cat f) := norm_hom2.comp_inl (norm_hom.to_norm_hom2 f)\n| _ _ (norm_hom.comp_inr_of_cat f) := norm_hom2.comp_inr (norm_hom.to_norm_hom2 f)\n| _ _ (norm_hom.prod_mk_of_cat f g) := norm_hom2.prod_mk (norm_hom.to_norm_hom2 f) (norm_hom.to_norm_hom2 g)\n| _ _ (norm_hom.of_not_proj (norm_hom.comp_inl_not_proj f)) :=\n norm_hom2.comp_inl (norm_hom.to_norm_hom2 (norm_hom.of_not_proj f))\n| _ _ (norm_hom.of_not_proj (norm_hom.comp_inr_not_proj f)) :=\n norm_hom2.comp_inr (norm_hom.to_norm_hom2 (norm_hom.of_not_proj f))\n| _ _ (norm_hom.of_not_proj (norm_hom.prod_mk_not_proj f g)) :=\n norm_hom2.prod_mk (norm_hom.to_norm_hom2 f.of_not_proj) (norm_hom.to_norm_hom2 g.of_not_proj)\n| _ _ (norm_hom.of_not_proj (norm_hom.prod_mk_not_proj_fst_comp f g)) :=\n norm_hom2.prod_mk (norm_hom.to_norm_hom2 f.of_not_proj) (norm_hom.to_norm_hom2 g.fst_comp)\n| _ _ (norm_hom.of_not_proj (norm_hom.prod_mk_not_proj_snd_comp f g)) :=\n norm_hom2.prod_mk (norm_hom.to_norm_hom2 f.of_not_proj) (norm_hom.to_norm_hom2 g.snd_comp)\n| _ _ (norm_hom.of_not_proj (norm_hom.prod_mk_fst_comp_not_proj f g)) :=\n norm_hom2.prod_mk (norm_hom.to_norm_hom2 f.fst_comp) (norm_hom.to_norm_hom2 g.of_not_proj)\n| _ _ (norm_hom.of_not_proj (norm_hom.prod_mk_snd_comp_not_proj f g)) :=\n norm_hom2.prod_mk (norm_hom.to_norm_hom2 f.snd_comp) (norm_hom.to_norm_hom2 g.of_not_proj)\n| _ _ (norm_hom.of_not_proj (norm_hom.prod_mk_fst_comp_snd_comp f g)) :=\n norm_hom2.prod_mk (norm_hom.to_norm_hom2 f.fst_comp) (norm_hom.to_norm_hom2 g.snd_comp)\n| _ _ (norm_hom.of_not_proj (norm_hom.prod_mk_snd_comp_fst_comp f g)) :=\n norm_hom2.prod_mk (norm_hom.to_norm_hom2 f.snd_comp) (norm_hom.to_norm_hom2 g.fst_comp)\n\n@[simp] def norm_hom2.comp : Π {X Y Z : prod_coprod C} (f : norm_hom2 X Y)\n (g : norm_hom2 Y Z), norm_hom2 X Z\n| _ _ _ (norm_hom2.coprod_mk f g) h :=\n norm_hom2.coprod_mk (norm_hom2.comp f h) (norm_hom2.comp g h)\n| _ _ _ (norm_hom2.fst_comp f) g :=\n norm_hom2.fst_comp (norm_hom2.comp f g)\n| _ _ _ (norm_hom2.snd_comp f) g :=\n norm_hom2.snd_comp (norm_hom2.comp f g)\n-- | _ _ _ f (norm_hom2.prod_mk g h) :=\n-- norm_hom2.prod_mk (norm_hom2.comp f g) (norm_hom2.comp f h)\n-- | _ _ _ f (norm_hom2.comp_inl g) :=\n-- norm_hom2.comp_inl (norm_hom2.comp f g)\n-- | _ _ _ f (norm_hom2.comp_inr g) :=\n-- norm_hom2.comp_inr (norm_hom2.comp f g)\n| _ _ _ (norm_hom2.of_cat f) (norm_hom2.of_cat g) :=\n norm_hom2.of_cat (f ≫ g)\n| _ _ _ (norm_hom2.comp_inl f) (norm_hom2.coprod_mk g h) :=\n norm_hom2.comp f g\n| _ _ _ (norm_hom2.comp_inr f) (norm_hom2.coprod_mk g h) :=\n norm_hom2.comp f h\n| _ _ _ (norm_hom2.prod_mk f g) (norm_hom2.fst_comp h) :=\n norm_hom2.comp f h\n| _ _ _ (norm_hom2.prod_mk f g) (norm_hom2.snd_comp h) :=\n norm_hom2.comp g h\n--repeated cases\n| _ _ _ (norm_hom2.of_cat f) (norm_hom2.comp_inl g) :=\n norm_hom2.comp_inl (norm_hom2.comp (norm_hom2.of_cat f) g)\n| _ _ _ (norm_hom2.of_cat f) (norm_hom2.comp_inr g) :=\n norm_hom2.comp_inr (norm_hom2.comp (norm_hom2.of_cat f) g)\n| _ _ _ (norm_hom2.of_cat f) (norm_hom2.prod_mk g h) :=\n norm_hom2.prod_mk (norm_hom2.comp (norm_hom2.of_cat f) g)\n (norm_hom2.comp (norm_hom2.of_cat f) h)\n| _ _ _ f'@(norm_hom2.comp_inl f) (norm_hom2.comp_inl g) :=\n norm_hom2.comp_inl (norm_hom2.comp f' g)\n| _ _ _ f'@(norm_hom2.comp_inr f) (norm_hom2.comp_inl g) :=\n norm_hom2.comp_inl (norm_hom2.comp f' g)\n| _ _ _ f'@(norm_hom2.comp_inr f) (norm_hom2.comp_inr g) :=\n norm_hom2.comp_inr (norm_hom2.comp f' g)\n| _ _ _ f'@(norm_hom2.comp_inl f) (norm_hom2.comp_inr g) :=\n norm_hom2.comp_inr (norm_hom2.comp f' g)\n| _ _ _ f'@(norm_hom2.comp_inl f) (norm_hom2.prod_mk g h) :=\n norm_hom2.prod_mk (norm_hom2.comp f' g) (norm_hom2.comp f' h)\n| _ _ _ f'@(norm_hom2.comp_inr f) (norm_hom2.prod_mk g h) :=\n norm_hom2.prod_mk (norm_hom2.comp f' g) (norm_hom2.comp f' h)\n| _ _ _ f@(norm_hom2.prod_mk _ _) (norm_hom2.comp_inl g) :=\n norm_hom2.comp_inl (norm_hom2.comp f g)\n| _ _ _ f@(norm_hom2.prod_mk _ _) (norm_hom2.comp_inr g) :=\n norm_hom2.comp_inr (norm_hom2.comp f g)\n| _ _ _ f@(norm_hom2.prod_mk _ _) (norm_hom2.prod_mk g h) :=\n norm_hom2.prod_mk (norm_hom2.comp f g) (norm_hom2.comp f h)\n\n@[simp] def norm_hom2.to_norm_hom : Π {X Y : prod_coprod C} (f : norm_hom2 X Y),\n norm_hom (sum.inl (X, Y))\n| _ _ (norm_hom2.of_cat f) := norm_hom.of_cat f\n| _ _ (norm_hom2.comp_inl f) := norm_hom.comp_inl (norm_hom2.to_norm_hom f)\n| _ _ (norm_hom2.comp_inr f) := norm_hom.comp_inr (norm_hom2.to_norm_hom f)\n| _ _ (norm_hom2.fst_comp f) := norm_hom.fst_comp (norm_hom2.to_norm_hom f)\n| _ _ (norm_hom2.snd_comp f) := norm_hom.snd_comp (norm_hom2.to_norm_hom f)\n| _ _ (norm_hom2.prod_mk f g) := norm_hom.prod_mk (norm_hom2.to_norm_hom f) (norm_hom2.to_norm_hom g)\n| _ _ (norm_hom2.coprod_mk f g) := norm_hom.coprod_mk (norm_hom2.to_norm_hom f) (norm_hom2.to_norm_hom g)\n\n@[simp] def norm_hom2.to_hom : Π {X Y : prod_coprod C} (f : norm_hom2 X Y), (X ⟶ Y)\n| _ _ (norm_hom2.of_cat f) := of_cat.map f\n| _ _ (norm_hom2.comp_inl f) := norm_hom2.to_hom f ≫ inl\n| _ _ (norm_hom2.comp_inr f) := norm_hom2.to_hom f ≫ inr\n| _ _ (norm_hom2.fst_comp f) := fst ≫ norm_hom2.to_hom f\n| _ _ (norm_hom2.snd_comp f) := snd ≫ norm_hom2.to_hom f\n| _ _ (norm_hom2.prod_mk f g) := prod_mk (norm_hom2.to_hom f) (norm_hom2.to_hom g)\n| _ _ (norm_hom2.coprod_mk f g) := coprod_mk (norm_hom2.to_hom f) (norm_hom2.to_hom g)\n\n@[simp] def norm_hom.comp {X Y Z : prod_coprod C} (f : norm_hom (sum.inl (X, Y)))\n (g : norm_hom (sum.inl (Y, Z))) : norm_hom (sum.inl (X, Z)) :=\n(f.to_norm_hom2.comp g.to_norm_hom2).to_norm_hom\n\nlemma comp_id {X Y Z : prod_coprod C}\n (f : norm_hom (sum.inl (X, Y))) :\n f.comp (norm_hom.id _) = f :=\nbegin\n\nend\n-- | (coprod W X) Y Z (norm_hom.coprod_mk f g) := norm_hom.coprod_mk (norm_hom.comp_inl f) (norm_hom.comp_inl g)\n-- | (prod W X) Y Z (norm_hom.fst_comp f) := norm_hom.fst_comp (norm_hom.comp_inl f)\n-- | (prod W X) Y Z (norm_hom.snd_comp f) := norm_hom.snd_comp (norm_hom.comp_inl f)\n-- | (prod W X) Y Z (norm_hom.of_not_proj f) := norm_hom.of_not_proj (norm_hom.comp_inl_not_proj f)\n\n@[simp] def norm_syntax : Π {X Y : prod_coprod C} (f : syntax X Y),\n norm_hom (sum.inl (X, Y))\n| _ _ (syntax.of_cat f) := norm_hom.of_cat f\n| _ _ (syntax.id _) := norm_hom.id _\n| _ _ (syntax.comp f g) := (norm_syntax f).comp (norm_syntax g)\n| _ _ syntax.fst := norm_hom.fst\n| _ _ syntax.snd := norm_hom.snd\n| _ _ (syntax.prod_mk f g) := norm_hom.prod_mk (norm_syntax f) (norm_syntax g)\n| _ _ syntax.inl := norm_hom.inl\n| _ _ syntax.inr := norm_hom.inr\n| _ _ (syntax.coprod_mk f g) := norm_hom.coprod_mk (norm_syntax f) (norm_syntax g)\n\nlemma norm_syntax_rel : Π {X Y : prod_coprod C} {f g : syntax X Y}, rel f g → norm_syntax f = norm_syntax g :=\nbegin\n intros X Y f g h,\n induction h; simp [*, norm_hom.to_norm_hom2, norm_hom.id] at *,\n\nend\n#exit\n@[simp] lemma to_hom_comp_inl : Π {X Y Z : prod_coprod C} (f : norm_hom (sum.inl (X, Y))),\n (@norm_hom.comp_inl _ _ _ _ Z f).to_norm_hom2.to_hom = f.to_norm_hom2.to_hom ≫ inl\n| (of_cat' X) _ _ f := by simp [norm_hom.comp_inl]\n| (coprod W X) Y Z (norm_hom.coprod_mk f g) :=\n by ext; simp [norm_hom.comp_inl, to_hom_comp_inl f, to_hom_comp_inl g,\n ← category.assoc]\n| (prod W X) Y Z (norm_hom.fst_comp f) := by simp [norm_hom.comp_inl, to_hom_comp_inl f]\n| (prod W X) Y Z (norm_hom.snd_comp f) := by simp [norm_hom.comp_inl, to_hom_comp_inl f]\n| (prod W X) Y Z (norm_hom.of_not_proj f) :=\n by simp [norm_hom.comp_inl, to_hom_comp_inl f.of_not_proj]\n\n@[simp] lemma to_hom_comp_inr : Π {X Y Z : prod_coprod C} (f : norm_hom (sum.inl (X, Z))),\n (@norm_hom.comp_inr _ _ X Y Z f).to_norm_hom2.to_hom = f.to_norm_hom2.to_hom ≫ inr\n| (of_cat' X) _ _ f := by simp [norm_hom.comp_inr]\n| (coprod W X) Y Z (norm_hom.coprod_mk f g) :=\n by ext; simp [norm_hom.comp_inr, to_hom_comp_inr f, to_hom_comp_inr g,\n ← category.assoc]\n| (prod W X) Y Z (norm_hom.fst_comp f) := by simp [norm_hom.comp_inr, to_hom_comp_inr f]\n| (prod W X) Y Z (norm_hom.snd_comp f) := by simp [norm_hom.comp_inr, to_hom_comp_inr f]\n| (prod W X) Y Z (norm_hom.of_not_proj f) :=\n by simp [norm_hom.comp_inr, to_hom_comp_inr f.of_not_proj]\n\n@[simp] lemma to_hom_prod_mk : Π {X Y Z : prod_coprod C} (f : norm_hom (sum.inl (X, Y)))\n (g : norm_hom (sum.inl (X, Z))),\n (f.prod_mk g).to_norm_hom2.to_hom = prod_mk f.to_norm_hom2.to_hom g.to_norm_hom2.to_hom\n| (of_cat' X) Y Z f g := by simp [norm_hom.prod_mk]\n| (prod W X) Y Z (norm_hom.fst_comp f) (norm_hom.fst_comp g) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f, to_hom_prod_mk g]\n| (prod W X) Y Z (norm_hom.snd_comp f) (norm_hom.snd_comp g) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f, to_hom_prod_mk g]\n| (prod W X) Y Z (norm_hom.fst_comp f) (norm_hom.snd_comp g) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f, to_hom_prod_mk g]\n| (prod W X) Y Z (norm_hom.snd_comp f) (norm_hom.fst_comp g) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f, to_hom_prod_mk g]\n| (prod W X) Y Z (norm_hom.of_not_proj f) (norm_hom.fst_comp g) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f.of_not_proj, to_hom_prod_mk g]\n| (prod W X) Y Z (norm_hom.of_not_proj f) (norm_hom.snd_comp g) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f.of_not_proj, to_hom_prod_mk g]\n| (prod W X) Y Z (norm_hom.fst_comp f) (norm_hom.of_not_proj g) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f, to_hom_prod_mk g.of_not_proj]\n| (prod W X) Y Z (norm_hom.snd_comp f) (norm_hom.of_not_proj g) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f, to_hom_prod_mk g.of_not_proj]\n| (prod W X) Y Z (norm_hom.of_not_proj f) (norm_hom.of_not_proj g) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f.of_not_proj, to_hom_prod_mk g.of_not_proj]\n| (coprod W X) Y Z (norm_hom.coprod_mk f g) (norm_hom.coprod_mk h i) :=\n by ext; simp [norm_hom.prod_mk, to_hom_prod_mk f, to_hom_prod_mk g]\n\n@[simp] lemma to_hom_comp : Π {X Y Z : prod_coprod C} (f : norm_hom2 X Y) (g : norm_hom2 Y Z),\n (f.comp g).to_hom = f.to_hom ≫ g.to_hom\n| _ _ _ (norm_hom2.coprod_mk f g) h :=\n by ext; simp [to_hom_comp f, to_hom_comp g, ← category.assoc]\n| _ _ _ (norm_hom2.fst_comp f) g :=\n by simp [to_hom_comp f]\n| _ _ _ (norm_hom2.snd_comp f) g :=\n by simp [to_hom_comp f]\n-- | _ _ _ f (norm_hom2.prod_mk g h) :=\n-- | _ _ _ f (norm_hom2.comp_inl g) := g)\n-- | _ _ _ f (norm_hom2.comp_inr g) :=\n| _ _ _ (norm_hom2.of_cat f) (norm_hom2.of_cat g) :=\n by simp\n| _ _ _ (norm_hom2.comp_inl f) (norm_hom2.coprod_mk g h) :=\n by simp [to_hom_comp f]\n| _ _ _ (norm_hom2.comp_inr f) (norm_hom2.coprod_mk g h) :=\n by simp [to_hom_comp f]\n| _ _ _ (norm_hom2.prod_mk f g) (norm_hom2.fst_comp h) :=\n by simp [to_hom_comp _ h, ← category.assoc]\n| _ _ _ (norm_hom2.prod_mk f g) (norm_hom2.snd_comp h) :=\n by simp [to_hom_comp _ h, ← category.assoc]\n--repeated cases\n| _ _ _ (norm_hom2.of_cat f) (norm_hom2.comp_inl g) :=\n by simp [to_hom_comp _ g]\n| _ _ _ (norm_hom2.of_cat f) (norm_hom2.comp_inr g) :=\n by simp [to_hom_comp _ g]\n| _ _ _ (norm_hom2.of_cat f) (norm_hom2.prod_mk g h) :=\n by ext; simp [to_hom_comp _ g, to_hom_comp _ h]\n| _ _ _ (norm_hom2.comp_inl f) (norm_hom2.comp_inl g) :=\n by simp [to_hom_comp _ g]\n| _ _ _ (norm_hom2.comp_inr f) (norm_hom2.comp_inl g) :=\n by simp [to_hom_comp _ g]\n| _ _ _ f'@(norm_hom2.comp_inr f) (norm_hom2.comp_inr g) :=\n by simp [to_hom_comp _ g]\n| _ _ _ f'@(norm_hom2.comp_inl f) (norm_hom2.comp_inr g) :=\n by simp [to_hom_comp _ g]\n| _ _ _ f'@(norm_hom2.comp_inl f) (norm_hom2.prod_mk g h) :=\n by ext; simp [to_hom_comp _ g, to_hom_comp _ h]\n| _ _ _ f'@(norm_hom2.comp_inr f) (norm_hom2.prod_mk g h) :=\n by ext; simp [to_hom_comp _ g, to_hom_comp _ h]\n| _ _ _ f@(norm_hom2.prod_mk _ _) (norm_hom2.comp_inl g) :=\n by simp [to_hom_comp _ g]\n| _ _ _ f@(norm_hom2.prod_mk _ _) (norm_hom2.comp_inr g) :=\n by simp [to_hom_comp _ g]\n| _ _ _ f@(norm_hom2.prod_mk _ _) (norm_hom2.prod_mk g h) :=\n by ext; simp [to_hom_comp _ g, to_hom_comp _ h]\n\n\n\n#exit\nlemma to_presheaf_syntax_comp {X Y Z : prod_coprod C} (f : syntax X Y) (g : syntax Y Z) :\n to_presheaf_syntax (f.comp g) = to_presheaf_syntax f ≫ to_presheaf_syntax g := rfl\n\nlemma to_presheaf_syntax_rel {X Y : prod_coprod C} (f g : syntax X Y) (h : rel f g) :\n to_presheaf_syntax f = to_presheaf_syntax g :=\nbegin\n induction h; try { simp * }; try { ext }; try { refl }; tidy,\nend\n\ndef to_presheaf : prod_coprod C ⥤ (Cᵒᵖ ⥤ Type) :=\n{ obj := to_presheaf_obj,\n map := λ X Y f, quotient.lift_on f (to_presheaf_syntax) to_presheaf_syntax_rel,\n map_id' := λ _, rfl,\n map_comp' := λ _ _ _ f g, quotient.induction_on₂ f g begin intros, simp,\n erw quotient.lift_on_mk,\n simp [to_presheaf_syntax_comp] end }\n\n@[simp] lemma to_presheaf_obj_of_cat (X : C) : to_presheaf.obj (of_cat' X) = yoneda.obj X := rfl\n\n@[simp] lemma to_presheaf_obj_prod (X Y : prod_coprod C) : to_presheaf.obj (prod X Y) =\n Pprod (to_presheaf_obj X) (to_presheaf_obj Y) := rfl\n\n@[simp] lemma to_presheaf_obj_coprod (X Y : prod_coprod C) : to_presheaf.obj (coprod X Y) =\n Pcoprod (to_presheaf_obj X) (to_presheaf_obj Y) := rfl\n\n@[simp] lemma to_presheaf_of_cat {X Y : C} (f : X ⟶ Y) :\n to_presheaf.map (of_cat.map f) = yoneda.map f := rfl\n\n@[simp] lemma to_presheaf_prod_mk {X Y Z : prod_coprod C}\n (f : X ⟶ Y) (g : X ⟶ Z) :\n to_presheaf.map (prod_mk f g) = Pprod_lift (to_presheaf.map f) (to_presheaf.map g) :=\nbegin\n refine quotient.induction_on₂ f g _,\n intros, refl\nend\n\n@[simp] lemma to_presheaf_coprod_mk {X Y Z : prod_coprod C}\n (f : X ⟶ Z) (g : Y ⟶ Z) :\n to_presheaf.map (coprod_mk f g) = Pcoprod_lift (to_presheaf.map f) (to_presheaf.map g) :=\nbegin\n refine quotient.induction_on₂ f g _,\n intros, refl\nend\n\n@[simp] lemma to_presheaf_fst {X Y : prod_coprod C} :\n to_presheaf.map (fst : X.prod Y ⟶ X) = Pprod_fst := rfl\n\n@[simp] lemma to_presheaf_snd {X Y : prod_coprod C} :\n to_presheaf.map (snd : X.prod Y ⟶ Y) = Pprod_snd := rfl\n\n@[simp] lemma to_presheaf_inl {X Y : prod_coprod C} :\n to_presheaf.map (inl : X ⟶ X.coprod Y) = Pcoprod_inl := rfl\n\n@[simp] lemma to_presheaf_inr {X Y : prod_coprod C} :\n to_presheaf.map (inr : Y ⟶ X.coprod Y) = Pcoprod_inr := rfl\n\nend syntax\n\ndef transformation_syntax : Π {X : C} {Y : prod_coprod C}, (to_presheaf.obj Y).obj (opposite.op X) →\n syntax (of_cat' X) Y\n| X (of_cat' Y) := λ f, syntax.of_cat f\n| X (prod Y Z) := λ f, syntax.prod_mk (transformation_syntax f.1) (transformation_syntax f.2)\n| X (coprod Y Z) := λ f, f.elim\n (λ f, (transformation_syntax f).comp syntax.inl)\n (λ f, (transformation_syntax f).comp syntax.inr)\n\n@[simp] def transformation : Π {X : C} {Y : prod_coprod C},\n (to_presheaf.obj Y).obj (opposite.op X) →\n ((of_cat' X) ⟶ Y)\n| X (of_cat' Y) := λ f, of_cat.map f\n| X (prod Y Z) := λ f, prod_mk (transformation f.1) (transformation f.2)\n| X (coprod Y Z) := λ f, f.elim\n (λ f, (transformation f) ≫ inl)\n (λ f, (transformation f) ≫ inr)\n\nlemma transformation_eq_of_syntax_transformation_syntax {X : C} {Y : prod_coprod C}\n (x : (to_presheaf.obj Y).obj (opposite.op X)) :\n transformation x = of_syntax (transformation_syntax x) :=\nby induction Y; simp [transformation, transformation_syntax, *]; tidy\n\nlemma transformation_left_naturality : Π {X Y : prod_coprod C}\n (f : X ⟶ Y) ⦃Z : C⦄ (z : (to_presheaf.obj X).obj (op Z)),\n transformation ((to_presheaf.map f).app (op Z) z) =\n transformation z ≫ f :=\nbegin\n intros X Y f Z z, revert Z z,\n refine hom_induction f _ _ _ _ _ _ _ _ _; intros; try { ext };\n try { dsimp at * }; try { simp * at * },\n cases z; simp *\nend\n\ndef transformation_inverse {X : C} {Y : prod_coprod C}\n (f : (of_cat' X) ⟶ Y) :\n (to_presheaf.obj Y).obj (opposite.op X) :=\nyoneda_equiv (to_presheaf.map f)\n\nlemma transformation_transformation_inverse {X : C} {Y : prod_coprod C}\n (f : (of_cat' X) ⟶ Y) : transformation (transformation_inverse f) = f :=\nbegin\n simp [yoneda_equiv, transformation_inverse, transformation_left_naturality],\n exact category.id_comp _,\nend\n\nlemma transformation_inverse_transformation {X : C} {Y : prod_coprod C}\n (f : (to_presheaf.obj Y).obj (opposite.op X)) :\n transformation_inverse (transformation f) = f :=\nbegin\n simp [yoneda_equiv, transformation_inverse, transformation_left_naturality],\n induction Y,\n { simp [transformation], exact category.id_comp _ },\n { simp [transformation, *] },\n { cases f;\n simp [transformation, *] }\nend\n\ninstance of_cat_full : full (@of_cat C _) :=\n{ preimage := λ X Y f, ((to_presheaf.map f).app (op X) (𝟙 X)),\n witness' := λ X Y f, begin\n have := transformation_left_naturality f (𝟙 X),\n simp at this,\n erw [category.id_comp] at this,\n simpa using this\n end }\n\ninstance of_cat_faithful : faithful (@of_cat C _) :=\n{ map_injective' := λ X Y f g h, begin\n have := congr_arg transformation_inverse h,\n simp [transformation_inverse] at this,\n erw [category.id_comp] at this,\n erw [category.id_comp] at this,\n assumption\nend }\n\ndef normalize {X : C} {Y : prod_coprod C}\n (f : (of_cat' X) ⟶ Y) : syntax (of_cat' X) Y :=\ntransformation_syntax (transformation_inverse f)\n\nlemma of_syntax_normalize {X : C} {Y : prod_coprod C}\n (f : (of_cat' X) ⟶ Y) : of_syntax (normalize f) = f :=\nby rw [normalize, ← transformation_eq_of_syntax_transformation_syntax,\n transformation_transformation_inverse]\n\nend prod_coprod", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/prodcoprod/full_normalization.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.411110869232168, "lm_q1q2_score": 0.23741462155908738}} {"text": "import tactic.slice\nimport category_theory.colimit_lemmas\nimport category_theory.pushout_fold\nimport homotopy_theory.formal.cofibrations.cofibration_category\nimport homotopy_theory.formal.cofibrations.cylinder\nimport homotopy_theory.formal.cofibrations.factorization_from_cylinder\nimport homotopy_theory.formal.cofibrations.homotopy\nimport homotopy_theory.formal.cofibrations.left_proper\nimport .cylinder_object\nimport .dold\n\nuniverses v u\n\nopen category_theory\nopen category_theory.category\nlocal notation f ` ∘ `:80 g:80 := g ≫ f\n\nnamespace homotopy_theory.cofibrations\nopen homotopy_theory.cylinder (renaming homotopic_rel → homotopic_rel_cylinder)\nopen homotopy_theory.weak_equivalences\nopen precofibration_category\n\n-- An I-category gives rise to a cofibration category with the same\n-- cofibrations in which the weak equivalences are the homotopy\n-- equivalences.\n\nvariables {C : Type u} [category.{v} C]\n [has_initial_object.{v} C] [has_coproducts.{v} C] [I_category.{v} C]\n\n-- Every object is fibrant.\nlemma all_objects_fibrant (x : C) : fibrant x :=\nassume y j ⟨jc, jw⟩,\nlet ⟨⟨r, h, H⟩⟩ := (heq_iff_sdr_inclusion jc).mp jw in ⟨r, h⟩\n\ninstance I_category.cofibration_category : cofibration_category.{v} C :=\ncofibration_category.mk_from_cylinder\n (assume a b a' b' f g f' g' po ⟨fc, fw⟩,\n ⟨precofibration_category.pushout_is_cof po fc, pushout_is_acof po fc fw⟩)\n (assume a, ⟨I.obj a, ii @> a, p @> a, cof_ii a, heq_p, pii⟩)\n (assume x, ⟨x, 𝟙 x, ⟨cof_id x, weq_id x⟩, all_objects_fibrant x⟩)\n\n-- The functor I produces cylinder objects in the general sense of\n-- cofibration categories.\ndef canonical_cylinder (b : C) :\n relative_cylinder (all_objects_cofibrant.cofibrant.{v} b) :=\n⟨I.obj b,\n (pushout_by_cof (!b) (!b) _).is_pushout.induced (i 0 @> b) (i 1 @> b)\n (category_theory.initial.uniqueness _ _),\n p @> b,\n -- We proved ii : b ⊔ b → Ib is a cofibration; need to massage this\n -- into a map from the pushout over the initial object.\n let po := pushout_by_cof (!b) (!b) (all_objects_cofibrant.cofibrant.{v} b),\n -- The map we need to show is a cofibration\n ii' := po.is_pushout.induced (i 0 @> b) (i 1 @> b)\n (category_theory.initial.uniqueness _ _),\n c : Is_coproduct po.map₀ po.map₁ :=\n Is_coproduct_of_Is_pushout_of_Is_initial po.is_pushout\n has_initial_object.initial_object.is_initial_object,\n j : iso (b ⊔ b) po.ob := isomorphic_coprod_of_Is_coproduct c in\n have ii' ∘ j.hom = ii @> b, begin\n dsimp [j, isomorphic_coprod_of_Is_coproduct];\n apply coprod.uniqueness; rw ←assoc; simp [ii]\n end,\n have ii' = ii @> b ∘ j.inv, by rw ←this; simp,\n show is_cof ii',\n by rw this; exact cof_comp (cof_iso j.symm) (cof_ii b),\n heq_p,\n begin\n apply (pushout_by_cof (!b) (!b) _).is_pushout.uniqueness;\n { rw ←assoc, simp }\n end⟩\n\n/-\n I a → a\n ↓ po ↓\n b ⊔ b → I b → c → b\n a\n-/\ndef canonical_relative_cylinder {a b : C} {j : a ⟶ b} (hj : is_cof j) :\n relative_cylinder hj :=\nlet po := pushout_by_cof (I.map j) (p.app a) (I_preserves_cofibrations hj) in\n⟨po.ob,\n (pushout_by_cof j j _).is_pushout.induced ((i 0).app b ≫ po.map₀) ((i 1).app b ≫ po.map₀)\n begin\n erw [←assoc, ←assoc, (i 0).naturality, (i 1).naturality],\n rw [assoc, assoc, po.is_pushout.commutes, ←assoc, ←assoc],\n simp\n end,\n po.is_pushout.induced (p.app b) j (p.naturality j),\n\n/-\n a ⊔ a → I a → a\n ↓ po₁ ↓ po₂ ↓\n b ⊔ b → ⬝ → b ⊔ b\n a\n ↓ po₃ ↓\n I b → c → b\n-/\n begin\n let po₀ := pushout_by_cof j j hj,\n let abb : a ⟶ po₀.ob := po₀.map₀ ∘ j,\n let po₁ := pushout_by_cof _ (ii.app a) (cof_coprod hj hj),\n let l := po₁.is_pushout.induced (coprod.induced po₀.map₀ po₀.map₁) (abb ∘ p.app a)\n begin\n apply coprod.uniqueness,\n { rw [←assoc, coprod_of_maps_commutes₀, assoc, coprod.induced_commutes₀],\n rw [iii₀_assoc, ←assoc, pi_components, id_comp] },\n { rw [←assoc, coprod_of_maps_commutes₁, assoc, coprod.induced_commutes₁],\n rw [iii₁_assoc, ←assoc, pi_components, id_comp, ←po₀.is_pushout.commutes] }\n end,\n have po₁₂ : Is_pushout (coprod_of_maps j j) (coprod.fold a) _ _ :=\n Is_pushout_fold po₀.is_pushout,\n have po₂ : Is_pushout po₁.map₁ (p.app a) l abb,\n { refine Is_pushout_of_Is_pushout_of_Is_pushout' po₁.is_pushout _ _,\n { convert po₁₂,\n { apply pii },\n { simp } },\n { simp } },\n have po₂₃ : Is_pushout (I.map j) (p.app a) _ _ := po.is_pushout,\n let m := _, -- naming part of the type of a hypothesis\n have : is_cof m := I_category.relative_cylinder j hj,\n let n := _, -- naming part of the type of the goal\n change is_cof n,\n have po₃ : Is_pushout m l po.map₀ n,\n { refine Is_pushout_of_Is_pushout_of_Is_pushout_vert' po₂ _ _,\n convert po₂₃,\n { simp, refl },\n { have : po.map₀ ∘ (i 0).app b ∘ j = po.map₁,\n { rw ←assoc,\n erw (i 0).naturality,\n rw [assoc, po.is_pushout.commutes, ←assoc, pi_components, id_comp] },\n simpa using this },\n { apply po₁.is_pushout.uniqueness; rw [←assoc, ←assoc],\n { simp only [Is_pushout.induced_commutes₀, Is_pushout.induced_commutes₁],\n apply coprod.uniqueness; rw [←assoc, ←assoc]; simp },\n { simp only [assoc, Is_pushout.induced_commutes₀, Is_pushout.induced_commutes₁],\n slice_rhs 2 3 { change (i 0).app b ∘ ((functor.id _).map j), rw (i 0).naturality },\n simp only [assoc],\n erw [po.is_pushout.commutes],\n slice_rhs 2 3 { rw pi_components },\n dsimp, simp } } },\n exact pushout_is_cof po₃ this\n end,\n begin\n have : is_weq po.map₀ :=\n left_proper.pushout_weq_by_cof po.is_pushout (I_preserves_cofibrations hj) heq_p,\n refine category_with_weak_equivalences.weq_of_comp_weq_left this _,\n simpa using heq_p,\n end,\n begin\n symmetry,\n apply pushout_induced_eq_iff; rw ←assoc; simp\n end⟩\n\nsection homotopy\nvariables {a b x : C} {j : a ⟶ b} (hj : is_cof j) (f₀ f₁ : b ⟶ x)\n\nlemma homotopic_rel_iff_cylinder :\n homotopic_rel hj f₀ f₁ ↔ homotopic_rel_cylinder j f₀ f₁ :=\nlet po := pushout_by_cof (I.map j) (p.app a) (I_preserves_cofibrations hj) in\nbegin\n split; intro H,\n { rcases homotopic_rel' (canonical_relative_cylinder hj) (all_objects_fibrant x) f₀ f₁ H\n with ⟨H, Hi₀, Hi₁⟩,\n dsimp [canonical_relative_cylinder, relative_cylinder.i₀, relative_cylinder.i₁] at Hi₀ Hi₁,\n simp at Hi₀ Hi₁,\n refine ⟨⟨po.map₀ ≫ H, _, _⟩, _⟩,\n { rw [←Hi₀, ←assoc, ←assoc], refl },\n { rw [←Hi₁, ←assoc, ←assoc], refl },\n { dsimp [homotopy.is_rel],\n rw [←Hi₀],\n slice_rhs 2 3 { change (functor.id _).map j ≫ (i 0).app b, rw (i 0).naturality },\n slice_lhs 1 2 { rw po.is_pushout.commutes },\n slice_rhs 3 4 { change I.map j ≫ po.map₀, rw po.is_pushout.commutes },\n slice_rhs 2 3 { rw pi_components },\n simp } },\n { rcases H with ⟨⟨H, Hi₀, Hi₁⟩, r⟩,\n refine ⟨canonical_relative_cylinder hj, ⟨⟨_, _, _⟩⟩⟩,\n refine po.is_pushout.induced H (j ≫ f₀) r,\n { convert Hi₀ using 1,\n dsimp [relative_cylinder.i₀, canonical_relative_cylinder], simp },\n { convert Hi₁ using 1,\n dsimp [relative_cylinder.i₁, canonical_relative_cylinder], simp } }\nend\n\nend homotopy\n\nend homotopy_theory.cofibrations\n", "meta": {"author": "rwbarton", "repo": "lean-homotopy-theory", "sha": "39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee", "save_path": "github-repos/lean/rwbarton-lean-homotopy-theory", "path": "github-repos/lean/rwbarton-lean-homotopy-theory/lean-homotopy-theory-39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee/src/homotopy_theory/formal/i_category/cofibration_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5234203340678567, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.23724646790842752}} {"text": "import for_mathlib.category_theory.localization.equivalence\nimport category_theory.products.basic\nimport for_mathlib.category_theory.functor_misc\nimport for_mathlib.category_theory.finite_products\n\nnoncomputable theory\n\nuniverses v v' u u'\n\nnamespace category_theory\n\nopen category\n\n@[simp]\nlemma prod.eq_to_hom_fst {C₁ C₂ : Type*} [category C₁] [category C₂]\n {X Y : C₁ × C₂} (eq : X = Y) : (eq_to_hom eq : X ⟶ Y).fst = eq_to_hom (by rw eq) :=\nby { subst eq, refl, }\n\n@[simp]\nlemma prod.eq_to_hom_snd {C₁ C₂ : Type*} [category C₁] [category C₂]\n {X Y : C₁ × C₂} (eq : X = Y) : (eq_to_hom eq : X ⟶ Y).snd = eq_to_hom (by rw eq) :=\nby { subst eq, refl, }\n\nlemma functor.prod.ext {C₁ C₂ E : Type*} [category C₁] [category C₂] [category E]\n {F₁ F₂ : E ⥤ C₁ × C₂} (h₁ : F₁ ⋙ prod.fst _ _ = F₂ ⋙ prod.fst _ _)\n (h₂ : F₁ ⋙ prod.snd _ _ = F₂ ⋙ prod.snd _ _) : F₁ = F₂ :=\nbegin\n refine functor.ext (λ X, _) (λ X Y f, _),\n { ext,\n exacts [functor.congr_obj h₁ X, functor.congr_obj h₂ X], },\n { ext,\n { simpa only [prod_comp_fst, prod.eq_to_hom_fst] using functor.congr_map_conjugate h₁ f, },\n { simpa only [prod_comp_snd, prod.eq_to_hom_snd] using functor.congr_map_conjugate h₂ f, }, },\nend\n\nlemma functor.is_localization.of_is_equivalence {C D : Type*} [category C] [category D]\n (F : C ⥤ D) [is_equivalence F] (W : morphism_property C)\n (hF : W ⊆ morphism_property.isomorphisms C) : F.is_localization W :=\nbegin\n haveI := localization.id_is_localization W hF,\n exact functor.is_localization.of_equivalence (𝟭 C) W F F.as_equivalence F.left_unitor,\nend\n\nlemma morphism_property.of_arrow_eq {C : Type*} [category C] (W : morphism_property C)\n (f₁ f₂ : arrow C) (hf₂ : W f₂.hom) (eq : f₁ = f₂) : W f₁.hom := by { subst eq, exact hf₂, }\n\nlemma morphism_property.of_arrow_mk_eq {C : Type*} [category C] (W : morphism_property C)\n {X₁ Y₁ X₂ Y₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (hf₂ : W f₂) (eq : arrow.mk f₁ = arrow.mk f₂) :\n W f₁ :=\nW.of_arrow_eq (arrow.mk f₁) (arrow.mk f₂) hf₂ eq\n\nlemma functor.congr_map_arrow_obj_arrow_mk {C D : Type*} [category C] [category D]\n {F₁ F₂ : C ⥤ D} (eq : F₁ = F₂) {X Y : C} (f : X ⟶ Y) :\n F₁.map_arrow.obj (arrow.mk f) = F₂.map_arrow.obj (arrow.mk f) := by subst eq\n\nsection\n\nvariables {C₁ D₁ C₂ D₂ : Type*} [category C₁] [category C₂] [category D₁] [category D₂]\n (W₁ : morphism_property C₁) (W₂ : morphism_property C₂) {E : Type*} [category E]\n\n@[simps]\ndef nat_iso.prod {F F' : C₁ ⥤ D₁} {G G' : C₂ ⥤ D₂} (α : F ≅ F') (β : G ≅ G') :\n F.prod G ≅ F'.prod G' :=\n{ hom := α.hom.prod β.hom,\n inv := α.inv.prod β.inv, }\n\nnamespace equivalence\n\ndef prod (E₁ : C₁ ≌ D₁) (E₂ : C₂ ≌ D₂) : C₁ × C₂ ≌ D₁ × D₂ :=\n{ functor := E₁.functor.prod E₂.functor,\n inverse := E₁.inverse.prod E₂.inverse,\n unit_iso := ((functor_prod_functor_equiv (C₁ × C₂) C₁ C₂).counit_iso.app (𝟭 _)).symm\n ≪≫ nat_iso.prod E₁.unit_iso E₂.unit_iso,\n counit_iso := nat_iso.prod E₁.counit_iso E₂.counit_iso ≪≫\n ((functor_prod_functor_equiv (D₁ × D₂) D₁ D₂).counit_iso.app (𝟭 _)), }\n\nend equivalence\n\nnamespace functor\n\n@[simps]\ndef prod_functor : (C₁ ⥤ D₁) × (C₂ ⥤ D₂) ⥤ (C₁ × C₂) ⥤ (D₁ × D₂) :=\n{ obj := λ F, F.1.prod F.2,\n map := λ F G φ, φ.1.prod φ.2, }\n\nlemma flip_flip (H : D₁ ⥤ D₂ ⥤ E) : H.flip.flip = H :=\nfunctor.ext (λ X₁, (functor.ext (λ X₂, rfl) (by tidy))) (by tidy)\n\nlemma comp_comp_curry_flip_flip_eq_curry (H : D₁ × D₂ ⥤ E) (F₁ : C₁ ⥤ D₁) (F₂ : C₂ ⥤ D₂) :\n F₁ ⋙ (F₂ ⋙ (curry.obj H).flip).flip = curry.obj (F₁.prod F₂ ⋙ H) :=\nfunctor.ext (λ X₁, (functor.ext (λ Y₁, rfl) (by tidy))) (by tidy)\n\nlemma uncurry_curry (H : D₁ × D₂ ⥤ E) : uncurry.obj (curry.obj H) = H :=\nfunctor.ext (λ X, by { cases X, refl, }) (by tidy)\n\nend functor\n\nnamespace morphism_property\n\nclass contains_identities {C : Type*} [category C] (W : morphism_property C) : Prop :=\n(id [] : ∀ (X : C), W (𝟙 X))\n\nnamespace contains_identities\n\nlemma op {C : Type*} [category C] {W : morphism_property C}\n (h : W.contains_identities) : W.op.contains_identities :=\n⟨λ X, h.id X.unop⟩\n\nlemma unop {C : Type*} [category C] {W : morphism_property Cᵒᵖ}\n (h : W.contains_identities) : W.unop.contains_identities :=\n⟨λ X, h.id (opposite.op X)⟩\n\ninstance op' {C : Type*} [category C] {W : morphism_property C} [h : W.contains_identities] :\n W.op.contains_identities := h.op\n\nend contains_identities\n\ndef prod : morphism_property (C₁ × C₂) := λ X Y f, W₁ f.fst ∧ W₂ f.snd\n\nvariables {W₁ W₂}\n\nlemma is_inverted_by.prod {F₁ : C₁ ⥤ D₁} {F₂ : C₂ ⥤ D₂} (h₁ : W₁.is_inverted_by F₁)\n (h₂ : W₂.is_inverted_by F₂) : (W₁.prod W₂).is_inverted_by (F₁.prod F₂) :=\nλ X Y f hf, by { rw is_iso_prod_iff, exact ⟨h₁ f.1 hf.1,h₂ f.2 hf.2⟩, }\n\nend morphism_property\n\nnamespace localization\n\nvariables [hW₁ : W₁.contains_identities] [hW₂ : W₂.contains_identities]\n\nnamespace strict_universal_property_fixed_target\n\nvariables (F : C₁ × C₂ ⥤ E) (hF : (W₁.prod W₂).is_inverted_by F)\n\n@[simps]\ndef prod.hom_mk {X₁ Y₁ : C₁} {X₂ Y₂ : C₂} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) :\n (⟨X₁, X₂⟩ : C₁ × C₂) ⟶ ⟨Y₁, Y₂⟩ := ⟨f₁, f₂⟩\n\nnamespace prod\n\ninclude hF hW₂\ndef lift₁ : W₁.localization ⥤ C₂ ⥤ E :=\nlocalization.construction.lift (curry.obj F) (λ X₁ Y₁ f₁ hf₁, begin\n haveI : Π (Z₂ : C₂), is_iso (((curry.obj F).map f₁).app Z₂),\n { intro Z₂,\n apply hF,\n exact ⟨hf₁, morphism_property.contains_identities.id _ _⟩, },\n apply nat_iso.is_iso_of_is_iso_app,\nend)\n\nlemma fac₁ : W₁.Q ⋙ (lift₁ W₁ W₂ F hF) = curry.obj F := localization.construction.fac _ _\n\nlemma lift₁_obj_map (X₁ : C₁) {X₂ Y₂ : C₂} (f₂ : X₂ ⟶ Y₂) :\n ((lift₁ W₁ W₂ F hF).obj (W₁.Q.obj X₁)).map f₂ =\n F.map (prod.hom_mk (𝟙 X₁) f₂) := rfl\n\nlemma lift₁_map_app {X₁ Y₁ : C₁} (f₁ : X₁ ⟶ Y₁) (X₂ : C₂) :\n ((lift₁ W₁ W₂ F hF).map (W₁.Q.map f₁)).app X₂ =\n F.map (prod.hom_mk f₁ (𝟙 X₂)) :=\nby simpa only [functor.comp_map, eq_to_hom_refl, category.comp_id, category.id_comp,\n curry_obj_map_app] using congr_app (functor.congr_map_conjugate (fac₁ W₁ W₂ F hF) f₁) X₂\n\ninclude hW₁\n\ndef lift₂ : W₂.localization ⥤ W₁.localization ⥤ E :=\nlocalization.construction.lift (lift₁ W₁ W₂ F hF).flip (λ X₂ Y₂ f₂ hf₂, begin\n haveI : ∀ (X₁ : W₁.localization), is_iso (((lift₁ W₁ W₂ F hF).flip.map f₂).app X₁),\n { intro X₁,\n have hF₁ : ∃ (A₁ : C₁), W₁.Q.obj A₁ = X₁ := (construction.obj_equiv W₁).surjective X₁,\n cases hF₁ with A₁ hA₁,\n subst hA₁,\n simp only [functor.flip_map_app, lift₁_obj_map],\n haveI := hF (prod.hom_mk (𝟙 A₁) f₂) ⟨morphism_property.contains_identities.id _ _, hf₂⟩,\n apply_instance, },\n apply nat_iso.is_iso_of_is_iso_app,\nend)\n\nlemma fac₂ : W₂.Q ⋙ (lift₂ W₁ W₂ F hF) = (lift₁ W₁ W₂ F hF).flip :=\nlocalization.construction.fac _ _\n\nlemma lift₂_obj_map {X₁ Y₁ : C₁} (f₁ : X₁ ⟶ Y₁) (X₂ : C₂) :\n ((lift₂ W₁ W₂ F hF).obj (W₂.Q.obj X₂)).map (W₁.Q.map f₁) = F.map (prod.hom_mk f₁ (𝟙 X₂)) :=\nby simpa only [eq_to_hom_refl, functor.flip_obj_map, category.comp_id,\n category.id_comp, lift₁_map_app] using functor.congr_map_conjugate\n (functor.congr_obj (fac₂ W₁ W₂ F hF) X₂) (W₁.Q.map f₁)\n\nlemma lift₂_map_app (X₁ : C₁) {X₂ Y₂ : C₂} (f₂ : X₂ ⟶ Y₂) :\n ((lift₂ W₁ W₂ F hF).map (W₂.Q.map f₂)).app (W₁.Q.obj X₁) = F.map (prod.hom_mk (𝟙 X₁) f₂) :=\nby simpa only [eq_to_hom_refl, category.comp_id, category.id_comp]\n using congr_app (functor.congr_map_conjugate (fac₂ W₁ W₂ F hF) f₂) (W₁.Q.obj X₁)\n\ndef lift₃ : W₁.localization × W₂.localization ⥤ E := uncurry.obj (lift₂ W₁ W₂ F hF).flip\n\nlemma fac : W₁.Q.prod W₂.Q ⋙ prod.lift₃ W₁ W₂ F hF = F :=\nbegin\n refine functor.ext (λ X, by { cases X, refl, }) (λ X Y f, _),\n { rcases X with ⟨X₁, X₂⟩,\n rcases Y with ⟨Y₁, Y₂⟩,\n have eq : f = prod.hom_mk (𝟙 X₁) f.2 ≫ prod.hom_mk f.1 (𝟙 Y₂) :=\n by simp only [prod_comp, hom_mk_fst, category.id_comp, hom_mk_snd, category.comp_id,\n prod.mk.eta],\n nth_rewrite 0 eq,\n dsimp [functor.comp, lift₃],\n simp only [category.id_comp, category.comp_id, nat_trans.naturality,\n lift₂_obj_map, lift₂_map_app, ← F.map_comp],\n congr' 1,\n ext,\n { apply category.comp_id, },\n { apply category.id_comp, }, },\nend\n\nomit hF hW₁ hW₂\n\nlemma uniq (H H' : W₁.localization × W₂.localization ⥤ E)\n (eq : W₁.Q.prod W₂.Q ⋙ H = W₁.Q.prod W₂.Q ⋙ H') : H = H' :=\nbegin\n let G := (curry.obj H).flip,\n let G' := (curry.obj H').flip,\n suffices : G = G',\n { rw [← functor.uncurry_curry H, ← functor.uncurry_curry H'],\n congr' 1,\n rw [← functor.flip_flip (curry.obj H), ← functor.flip_flip (curry.obj H')],\n congr', },\n apply construction.uniq,\n suffices : (W₂.Q ⋙ G).flip = (W₂.Q ⋙ G').flip,\n { rw [← functor.flip_flip (W₂.Q ⋙ G), ← functor.flip_flip (W₂.Q ⋙ G'), this], },\n apply construction.uniq,\n convert congr_arg curry.obj eq,\n all_goals { apply functor.comp_comp_curry_flip_flip_eq_curry, },\nend\n\nend prod\n\ninclude hW₁ hW₂\n\nvariable (E)\n\ndef prod : strict_universal_property_fixed_target (W₁.Q.prod W₂.Q) (W₁.prod W₂) E :=\n{ inverts := (localization.inverts _ _).prod (localization.inverts _ _),\n lift := λ F hF, prod.lift₃ W₁ W₂ F hF,\n fac := λ F hF, prod.fac W₁ W₂ F hF,\n uniq := λ H H' eq, begin\n let G := (curry.obj H).flip,\n let G' := (curry.obj H').flip,\n suffices : G = G',\n { rw [← functor.uncurry_curry H, ← functor.uncurry_curry H'],\n congr' 1,\n rw [← functor.flip_flip (curry.obj H), ← functor.flip_flip (curry.obj H')],\n congr', },\n apply construction.uniq,\n suffices : (W₂.Q ⋙ G).flip = (W₂.Q ⋙ G').flip,\n { rw [← functor.flip_flip (W₂.Q ⋙ G), ← functor.flip_flip (W₂.Q ⋙ G'), this], },\n apply construction.uniq,\n convert congr_arg curry.obj eq,\n all_goals { apply functor.comp_comp_curry_flip_flip_eq_curry, },\n end, }\n\nend strict_universal_property_fixed_target\n\ninclude hW₁ hW₂\n\ninstance prod_construction_is_localization : (W₁.Q.prod W₂.Q).is_localization (W₁.prod W₂) :=\nfunctor.is_localization.mk' _ _\n (strict_universal_property_fixed_target.prod W₁ W₂ _)\n (strict_universal_property_fixed_target.prod W₁ W₂ _)\n\ninstance prod_is_localization (L₁ : C₁ ⥤ D₁) (L₂ : C₂ ⥤ D₂)\n [L₁.is_localization W₁] [L₂.is_localization W₂] :\n (L₁.prod L₂).is_localization (W₁.prod W₂) :=\nbegin\n let E₁ := equivalence_from_model L₁ W₁,\n let E₂ := equivalence_from_model L₂ W₂,\n let e₁ : W₁.Q ⋙ E₁.functor ≅ L₁ := Q_comp_equivalence_from_model_functor_iso _ _,\n let e₂ : W₂.Q ⋙ E₂.functor ≅ L₂ := Q_comp_equivalence_from_model_functor_iso _ _,\n exact functor.is_localization.of_equivalence (W₁.Q.prod W₂.Q) (W₁.prod W₂) (L₁.prod L₂)\n (E₁.prod E₂) (functor.prod_functor.map_iso (e₁.prod e₂)),\nend\n\nend localization\n\nvariables {J : Type*} (C : J → Type u) [Π j, category (C j)]\n\ndef equivalence.pi' {J' : Type*} (α : J' ≃ J) :\n (Π j, C (α j)) ≌ (Π j', C j'):=\n{ functor := functor.pi'_ (λ j, functor.pi_.eval _ (α.symm j) ⋙\n (pi.equivalence_of_eq C (show α (α.symm j) = j, by simp)).functor),\n inverse := functor.pi'_ (λ j', functor.pi_.eval _ (α j')),\n unit_iso := functor.pi_.mk_nat_iso (λ j', begin\n calc 𝟭 (Π (j : J'), C (α j)) ⋙ functor.pi_.eval (λ (j : J'), C (α j)) j' ≅ _ :\n functor.left_unitor _\n ... ≅ _ : (functor.pi_.eval_iso_of_eq (λ j, C (α j)) (show α.symm (α j') = j', by simp)).symm\n ... ≅ _ : _\n ... ≅ _ ⋙ functor.pi_.eval _ _ : (functor.pi'__eval_iso _ _).symm\n ... ≅ _ ⋙ _ ⋙ _ : iso_whisker_left _ ((functor.pi'__eval_iso _ _).symm)\n ... ≅ (_ ⋙ _) ⋙ _ : (functor.associator _ _ _).symm,\n { exact iso_whisker_left _ (pi.equivalence_of_eq_functor_iso C α (by simp)), },\n end),\n counit_iso := functor.pi_.mk_nat_iso\n (λ j, functor.associator _ _ _ ≪≫ iso_whisker_left _ (functor.pi'__eval_iso _ _) ≪≫\n (functor.associator _ _ _).symm ≪≫ iso_whisker_right (functor.pi'__eval_iso _ _) _ ≪≫\n functor.pi_.eval_iso_of_eq _ _ ≪≫ (functor.left_unitor _).symm),\n functor_unit_iso_comp' := λ X, begin\n ext j,\n dsimp [iso.refl],\n simp only [assoc, id_comp],\n erw nat_trans.id_app,\n dsimp,\n simp only [id_comp, comp_id, functor.map_id, eq_to_hom_app, functor.map_comp, assoc,\n pi.equivalence_of_eq_functor_iso_hom_app, eq_to_hom_map, eq_to_hom_trans, eq_to_hom_refl],\n end, }\n\nlemma equivalence.pi'_inverse_comp_eval {J' : Type*} (α : J' ≃ J) (j' : J') :\n (equivalence.pi' C α).inverse ⋙ functor.pi_.eval _ j' = functor.pi_.eval _ (α j') := rfl\n\nlemma equivalence.pi'_functor_comp_eval {J' : Type*} (α : J' ≃ J) (j' : J') :\n (equivalence.pi' C α).functor ⋙ functor.pi_.eval _ (α j') = functor.pi_.eval _ j' :=\nbegin\n dsimp only [equivalence.pi'],\n rw functor.pi'__eval,\n rw ← functor.pi_.eval_eq_of_eq (λ j', C (α j')) (show α.symm (α j') = j', by simp),\n rw pi.equivalence_of_eq_functor_eq C α,\nend\n\nvariable {C}\n\n@[simps]\ndef equivalence.pi'' {J' : Type*} (α : J ≃ J') {D : J' → Type*}\n [Π j', category (D j')] (e : Π j, C j ≌ D (α j)) :\n (Π j, C j) ≌ (Π j', D j') :=\n(equivalence.pi e).trans (equivalence.pi' D α)\n\nlemma equivalence.pi''_inverse_comp_eval {J' : Type*} (α : J ≃ J') {D : J' → Type*}\n [Π j', category (D j')] (e : Π j, C j ≌ D (α j)) (j : J) :\n (equivalence.pi'' α e).inverse ⋙ functor.pi_.eval _ j =\n functor.pi_.eval _ (α j) ⋙ (e j).inverse := rfl\n\nlemma equivalence.pi''_functor_comp_eval {J' : Type*} (α : J ≃ J') {D : J' → Type*}\n [Π j', category (D j')] (e : Π j, C j ≌ D (α j)) (j : J) :\n (equivalence.pi'' α e).functor ⋙ functor.pi_.eval _ (α j) =\n functor.pi_.eval _ j ⋙ (e j).functor :=\nbegin\n dsimp only [equivalence.pi'', equivalence.trans],\n rw [functor.assoc, equivalence.pi'_functor_comp_eval],\n refl,\nend\n\nlemma is_iso_pi_iff {X Y : Π j, C j} (f : X ⟶ Y) :\n is_iso f ↔ ∀ j, is_iso (f j) :=\nbegin\n split,\n { introI,\n intro j,\n change is_iso ((functor.pi_.eval C j).map f),\n apply_instance, },\n { introI,\n exact ⟨⟨λ j, inv (f j), by tidy⟩⟩, },\nend\n\ndef morphism_property.pi (W : Π j, morphism_property (C j)) :\n morphism_property (Π j, C j) := λ X Y f, ∀ j, (W j) (f j)\n\nend\n\nsection\n\nvariables {J₁ J₂ : Type*} (C₁ : J₁ → Type u) (C₂ : J₂ → Type u)\n\n@[simp]\ndef sum.desc : sum J₁ J₂ → Type u\n|(sum.inl j₁) := C₁ j₁\n|(sum.inr j₂) := C₂ j₂\n\nvariables [Π j₁, category.{v} (C₁ j₁)] [Π j₂, category.{v} (C₂ j₂)]\n\ninstance : Π j, category.{v} (sum.desc C₁ C₂ j) :=\nλ j, by { cases j; dsimp only [sum.desc]; apply_instance, }\n\ndef equivalence_pi_prod :\n (Π j₁, C₁ j₁) × (Π j₂, C₂ j₂) ≌ (Π j, sum.desc C₁ C₂ j) :=\n{ functor := functor.pi'_ (λ j, match j with\n | sum.inl j₁ := category_theory.prod.fst _ _ ⋙ functor.pi_.eval _ j₁\n | sum.inr j₂ := category_theory.prod.snd _ _ ⋙ functor.pi_.eval _ j₂\n end),\n inverse := functor.prod'\n (functor.pi'_ (λ j₁, functor.pi_.eval _ (sum.inl j₁)))\n (functor.pi'_ (λ j₂, functor.pi_.eval _ (sum.inr j₂))),\n unit_iso := eq_to_iso (functor.ext (by tidy) (by tidy)),\n counit_iso := eq_to_iso (functor.ext (by tidy) (by tidy)), }\n\nend\n\nsection\n\nvariables {J : Type*} {T : Type*} (C : J → T) (C₀ : T)\n\n@[simp]\ndef option.desc : option J → T\n| none := C₀\n| (some j) := C j\n\nlemma option.is_desc (f : option J → T) : ∃ (C : J → T) (C₀ : T), f = option.desc C C₀ :=\n⟨λ j, f (some j), f none, by { ext j, cases j; refl, }⟩\n\ndef option.desc' {C : J → Type u} {C₀ : Type u}\n (f : Π j, C j) (f₀ : C₀) : Π (j : option J), option.desc C C₀ j\n| none := f₀\n| (some j) := f j\n\nlemma option.is_desc'\n {C : J → Type u} {C₀ : Type u} (g : Π (j : option J), option.desc C C₀ j) :\n ∃ (f : Π j, C j) (f₀ : C₀), g = option.desc' f f₀ :=\n⟨λ j, g (some j), g none, by { ext j, cases j; refl,}⟩\n\nend\n\nsection\n\nvariables {J : Type*} (j : J) [subsingleton J] (C : J → Type*) [Π t, category (C t)]\n\ndef equivalence_pi_single :\n (Π t, C t) ≌ C j :=\n{ functor := functor.pi_.eval _ j,\n inverse := functor.pi'_ (λ t, begin\n have eq := subsingleton.elim j t,\n subst eq,\n exact 𝟭 _,\n end),\n unit_iso := eq_to_iso begin\n refine functor.ext _ _,\n { intro X,\n ext t,\n have eq := subsingleton.elim j t,\n subst eq,\n refl, },\n { intros X Y f,\n ext t,\n have eq := subsingleton.elim j t,\n subst eq,\n simp, },\n end,\n counit_iso := eq_to_iso rfl, }\n\nend\n\nsection\n\nvariables {J : Type} (C : option J → Type u) [Π j', category.{v} (C j')]\n\ndef equivalence_pi_option : (Π j', C j') ≌ (Π j, C (some j)) × C none :=\n{ functor := functor.prod' (functor.pi'_ (λ j, functor.pi_.eval _ (some j))) (functor.pi_.eval _ none),\n inverse := functor.pi'_ (λ j, match j with\n | none := prod.snd _ _\n | (some j) := prod.fst _ _ ⋙ functor.pi_.eval _ j\n end),\n unit_iso := eq_to_iso (functor.pi_.ext (λ j, by { cases j; refl, })),\n counit_iso := eq_to_iso (functor.prod.ext rfl rfl), }\n\nend\n\nsection\n\nvariables {J : Type*} {C : J → Type*} {D : J → Type*}\n [Π j, category (C j)] [Π j, category (D j)]\n (W : Π j, morphism_property (C j))\n (L : Π j, C j ⥤ D j)\n\nlemma morphism_property.is_inverted_by.pi (h : ∀ j, (W j).is_inverted_by (L j)):\n (morphism_property.pi W).is_inverted_by (functor.pi_ (λ j, L j)) :=\nλ X Y f hf, by { rw is_iso_pi_iff, exact λ j, h _ _ (hf j), }\n\ninstance [Π j, (W j).contains_identities] :\n morphism_property.contains_identities (morphism_property.pi W) :=\n⟨λ X j, morphism_property.contains_identities.id (W j) (X j)⟩\n\nend\n\nnamespace localization\n\nvariables (J : Type) [finite J] {C : J → Type*} {D : J → Type*}\n [Π j, category (C j)] [Π j, category (D j)]\n (W : Π j, morphism_property (C j))\n [hW : ∀ j, (W j).contains_identities]\n (L : Π j, C j ⥤ D j) [Π j, (L j).is_localization (W j)]\n\ninclude hW\n\ninstance pi_is_localization : ((functor.pi_ L).is_localization (morphism_property.pi W)) :=\nbegin\n unfreezingI { revert C D, },\n refine finite.induction_empty_option _ _ _ J,\n { intros J₁ J₂ e h₁ C₂ D₂, introI, introI, intros W₂, introI, intro L₂, introI,\n let C₁ := λ j₁, C₂ (e j₁),\n let D₁ := λ j₁, D₂ (e j₁),\n let L₁ : Π j₁, C₁ j₁ ⥤ D₁ j₁ := λ j₁, L₂ (e j₁),\n let W₁ : Π j₁, morphism_property (C₁ j₁) := λ j₁, W₂ (e j₁),\n haveI := h₁ W₁ L₁,\n let E : (Π j₁, C₁ j₁) ≌ (Π j₂, C₂ j₂) := equivalence.pi'' e (λ j₁, by refl),\n let E' : (Π j₁, D₁ j₁) ≌ (Π j₂, D₂ j₂) := equivalence.pi'' e (λ j₁, by refl),\n let Sq : Comm_sq E.symm.functor (functor.pi_ L₂) (functor.pi_ L₁) E'.symm.functor :=\n ⟨eq_to_iso (functor.pi_.ext (λ j₁, begin\n simp only [functor.assoc, functor.pi_eval],\n erw equivalence.pi''_inverse_comp_eval,\n simp only [← functor.assoc],\n erw equivalence.pi''_inverse_comp_eval,\n refl,\n end))⟩,\n have hW₁ : morphism_property.pi W₁ ⊆ (morphism_property.pi W₂).inverse_image' E.symm.inverse,\n { intros X₁ Y₁ f hf,\n refine ⟨X₁, Y₁, iso.refl _, iso.refl _, f, λ j₂, _, by tidy⟩,\n rcases e.surjective j₂ with ⟨j₁, hj₁⟩,\n subst hj₁,\n refine (W₂ (e j₁)).of_arrow_mk_eq _ _ (hf j₁) _,\n exact functor.congr_map_arrow_obj_arrow_mk (equivalence.pi''_functor_comp_eval e _ _) f, },\n exact (functor.is_localization.of_equivalence'' E.symm E'.symm Sq\n (morphism_property.pi W₂) (morphism_property.pi W₁)\n (morphism_property.is_inverted_by.pi W₂ L₂ (λ j₂, localization.inverts _ _)) hW₁), },\n { intros C D, introI, introI, intros W, introI, intro L, introI,\n haveI : is_equivalence (functor.pi_ L) :=\n { inverse :=\n { obj := λ Y j, by induction j,\n map := λ X Y f j, by induction j, },\n unit_iso := eq_to_iso (functor.ext (by tidy) (by tidy)),\n counit_iso := eq_to_iso (functor.ext (by tidy) (by tidy)), },\n apply functor.is_localization.of_is_equivalence (functor.pi_ L) (morphism_property.pi W),\n intros X Y f hf,\n rw morphism_property.isomorphisms.iff,\n rw is_iso_pi_iff,\n intro j,\n induction j, },\n { intro J, introI, intros hJ C' D', introI, introI, intros W' hW' L' hL',\n let W := λ j, W' (some j),\n let W₀ := W' none,\n let L := λ j, L' (some j),\n let L₀ := L' none,\n let E := equivalence_pi_option C',\n let E' := equivalence_pi_option D',\n haveI : L₀.is_localization W₀ := hL' none,\n let H : Comm_sq (equivalence_pi_option C').functor (functor.pi_ L') (functor.prod (functor.pi_ L) L₀) (equivalence_pi_option D').functor := ⟨eq_to_iso rfl⟩,\n have hW₁ := morphism_property.is_inverted_by.pi W' L' (λ j, localization.inverts _ _),\n have hW₂ : (morphism_property.pi W).prod W₀ ⊆ (morphism_property.pi W').inverse_image' E.inverse,\n { intros X Y f hf,\n refine ⟨X, Y, iso.refl X, iso.refl Y, f, _, comm_sq.mk (by simp)⟩,\n rintro (_|j),\n { exact hf.2, },\n { exact hf.1 j, }, },\n exact functor.is_localization.of_equivalence'' E E' H (morphism_property.pi W')\n (morphism_property.prod (morphism_property.pi W) W₀) hW₁ hW₂, },\nend\n\nend localization\n\ndef morphism_property.functor_category {C : Type*} [category C]\n (W : morphism_property C) (J : Type*) [category J] :\n morphism_property (J ⥤ C) := λ X Y f, ∀ j, W (f.app j)\n\nnamespace localization\n\nvariables (J : Type) [finite J] {C D : Type*} [category C] [category D]\n (W : morphism_property C)\n [morphism_property.contains_identities W]\n (L : C ⥤ D) [L.is_localization W]\n\ninstance whiskering_right_discrete_is_localization :\n ((whiskering_right (discrete J) C D).obj L).is_localization (W.functor_category _) :=\nbegin\n let E := pi_equivalence_functors_from_discrete C J,\n let E' := pi_equivalence_functors_from_discrete D J,\n let L₁ := (whiskering_right (discrete J) C D).obj L,\n let L₂ := functor.pi_ (λ (j : J), L),\n let H : Comm_sq E.symm.functor L₁ L₂ E'.symm.functor := ⟨iso.refl _⟩,\n refine functor.is_localization.of_equivalence'' E.symm E'.symm H (W.functor_category _)\n (morphism_property.pi (λ j, W)) _ _,\n { intros X Y f hf,\n haveI : ∀ (j : discrete J), is_iso ((((whiskering_right\n (discrete J) C D).obj L).map f).app j),\n { rintro ⟨j⟩,\n dsimp,\n exact localization.inverts L W _ (hf (discrete.mk j)), },\n apply nat_iso.is_iso_of_is_iso_app, },\n { refine has_subset.subset.trans _ (morphism_property.inverse_image_subset_inverse_image' _ _),\n rintros X Y f hf ⟨j⟩,\n exact hf j, },\nend\n\nend localization\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/localization/products.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.44552953503957277, "lm_q1q2_score": 0.23666946512787246}} {"text": "/-\nCopyright (c) 2022 Joël Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joël Riou\n-/\n\nimport for_mathlib.algebra.homology.hom_complex\nimport for_mathlib.algebra.homology.bounded_above\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits category_theory.preadditive\n\nnamespace cochain_complex\n\nnamespace hom_complex\n\nvariables {C : Type*} [category C] [preadditive C]\n\nvariables {F G K : cochain_complex C ℤ} {n : ℤ} (z : cocycle F G n) {m : ℤ} [∀ p, has_binary_biproduct (F.X (p+1-n)) (G.X p)]\ninclude z\n\nnamespace twist\n\n@[protected, simp]\ndef δ (p q : ℤ) :\n biprod (F.X (p+1-n)) (G.X p) ⟶ biprod (F.X (q+1-n)) (G.X q) :=\nbegin\n refine biprod.desc (biprod.lift (ε (n+1) • F.d (p+1-n) (q+1-n)) _) (biprod.lift 0 (G.d p q)),\n by_cases p+1 = q,\n { exact (z : cochain F G n).v (p+1-n) q (show q=(p+1-n)+n, by linarith), },\n { exact 0, },\nend\n\nend twist\n\n@[simps]\ndef twist : cochain_complex C ℤ :=\n{ X := λ p, biprod (F.X (p+1-n)) (G.X p),\n d := λ p q, twist.δ z p q,\n shape' := λ p q hpq, begin\n dsimp [twist.δ],\n ext,\n { simp only [biprod.inl_desc, biprod.lift_fst, comp_zero, zero_comp],\n rw [F.shape, smul_zero],\n intro h,\n apply hpq,\n change p+1-n+1=q+1-n at h,\n change p+1=q,\n linarith, },\n { simp only [biprod.inl_desc, biprod.lift_snd, comp_zero, zero_comp],\n split_ifs,\n { exfalso, exact hpq h, },\n { refl, }, },\n { simp only [biprod.inr_desc, biprod.lift_fst, comp_zero, zero_comp], },\n { simp only [biprod.inr_desc, biprod.lift_snd, comp_zero, zero_comp, G.shape p q hpq], },\n end,\n d_comp_d' := λ i j k hij hjk, begin\n change i+1=j at hij,\n subst hij,\n change i+1+1=k at hjk,\n have hjk' : i+2 = k := by linarith,\n subst hjk',\n simp only [twist.δ, dif_pos rfl, dif_pos (show i+1+1 = i+2, by linarith)],\n ext,\n { simp only [add_zero, biprod.inl_desc_assoc, biprod.lift_desc, linear.smul_comp,\n add_comp, assoc, biprod.lift_fst,\n linear.comp_smul, homological_complex.d_comp_d, smul_zero, comp_zero, zero_comp], },\n { simp only [biprod.inl_desc_assoc, biprod.lift_desc, linear.smul_comp,\n add_comp, assoc, biprod.lift_snd, comp_zero, zero_comp],\n have hz₁ := z.2,\n rw cocycle.mem_iff n (n+1) rfl at hz₁,\n have hz₂ := cochain.congr_v hz₁ (i+1-n) (i+2) (by linarith),\n simp only [δ_v n (n+1) rfl _ (i+1-n) (i+2) (by linarith) (i+1) (i+1+1-n)\n (by linarith) (by linarith), cochain.zero_v] at hz₂,\n rw ← hz₂,\n abel, },\n { simp only [zero_add, biprod.inr_desc_assoc, biprod.lift_desc, zero_comp, assoc, biprod.lift_fst, comp_zero], },\n { simp only [zero_add, biprod.inr_desc_assoc, biprod.lift_desc, zero_comp, assoc, biprod.lift_snd, homological_complex.d_comp_d,\n comp_zero], },\n end }\n\nnamespace twist\n\nomit z\n\nlemma is_bounded_above (z : cocycle F G n) (hF : F.is_bounded_above) (hG : G.is_bounded_above) :\n (twist z).is_bounded_above :=\nbegin\n cases hF with r hr,\n cases hG with s hs,\n use max (r+n-1) s,\n intros i hi,\n dsimp only [twist],\n rw is_zero.iff_of_biprod,\n split,\n { apply hr,\n have h := lt_of_le_of_lt (le_max_left _ _) hi,\n linarith, },\n { apply hs,\n exact lt_of_le_of_lt (le_max_right _ _) hi, },\nend\n\ninclude z\ndef inl {n₀ : ℤ} (hn₀ : n₀+1=n) : cochain F (twist z) n₀ :=\ncochain.mk (λ p q hpq, (cochain.of_hom (𝟙 F)).v p (q+1-n) (by linarith) ≫ biprod.inl)\n\ndef inr : G ⟶ twist z := { f := λ p, biprod.inr, }\n\ndef fst {n₁ : ℤ} (hn₁ : n+n₁=1) : cocycle (twist z) F n₁ :=\ncocycle.mk (cochain.mk (λ p q hpq, biprod.fst ≫\n (cochain.of_hom (𝟙 F)).v (p+1-n) q (show q=p+1-n+0, by linarith))) (n₁+1) rfl\nbegin\n have hn₁' : n₁ = 1-n := by linarith,\n subst hn₁',\n ext1,\n simp only [δ_v (1-n) (1-n+1) rfl _ p q hpq (p+1-n) (p+1) (by linarith) rfl,\n cochain.mk_v, cochain.of_hom_v, homological_complex.id_f, comp_id, twist_d, twist.δ, dif_pos,\n cochain.zero_v],\n ext,\n { have hq : q = p+1+1-n := by linarith,\n subst hq,\n have eq : ε (1-n+1) * ε (n+1) = ε ((1 : ℤ) + 1 + 1) := by { rw ← ε_add, congr' 1, linarith, },\n have eq' : ε ((1 : ℤ)+1+1) = -1 := by { simp only [ε_succ, ε_1, neg_neg], },\n simp only [biprod.inl_fst_assoc, biprod.inl_desc_assoc, biprod.lift_fst, comp_add,\n cochain.of_hom_v, homological_complex.id_f, comp_zsmul, comp_id, comp_zero, smul_smul,\n eq, eq', neg_smul, one_zsmul, add_right_neg], },\n { simp only [zero_add, neg_eq_zero, comp_add, biprod.inr_fst_assoc, zero_comp,\n linear.comp_smul, biprod.inr_desc_assoc, biprod.lift_fst_assoc, smul_zero, comp_zero], },\nend\n\ndef snd : cochain (twist z) G 0 :=\ncochain.mk (λ p q hpq, biprod.snd ≫ (cochain.of_hom (𝟙 G)).v p q hpq)\n\n@[simp]\nlemma inl_comp_fst {n₀ n₁ : ℤ} (hn₀ : n₀+1=n) (hn₁ : n+n₁=1) :\n (inl z hn₀).comp ↑(fst z hn₁) (show 0=n₀+n₁, by linarith) = cochain.of_hom (𝟙 F) :=\nbegin\n ext,\n dsimp [cochain.comp, cochain.mk, cochain.v, cochain.of_hom, cochain.of_homs, inl, fst],\n simp only [id_comp, assoc, biprod.inl_fst_assoc, eq_to_hom_trans, eq_to_hom_refl],\nend\n\n@[simp]\nlemma inl_comp_snd {n₀ : ℤ} (hn₀ : n₀+1=n) :\n (inl z hn₀).comp (snd z) (add_zero n₀).symm = 0 :=\nbegin\n ext,\n simp only [inl, snd, cochain.comp, cochain.mk, cochain.v, cochain.of_hom, cochain.of_homs,\n assoc, biprod.inl_snd_assoc, zero_comp, comp_zero, cochain.zero_v],\nend\n\n@[simp]\nlemma inr_comp_fst {n₁ : ℤ} (hn₁ : n+n₁=1) :\n (cochain.of_hom (inr z)).comp (fst z hn₁ : cochain (twist z) F n₁) (zero_add n₁).symm = 0 :=\nbegin\n ext,\n simp only [inr, fst, cochain.zero_cochain_comp, cochain.of_hom_v, cocycle.mk_coe,\n cochain.mk_v, biprod.inr_fst_assoc, zero_comp, cochain.zero_v],\nend\n\n@[simp]\nlemma inr_comp_snd :\n (cochain.of_hom (inr z)).comp (snd z) (add_zero 0).symm = cochain.of_hom (𝟙 G) :=\nbegin\n ext,\n simp only [inr, snd, cochain.comp_zero_cochain, cochain.mk_v, cochain.of_hom_v,\n homological_complex.id_f, comp_id, biprod.inr_snd],\nend\n\n@[simp]\nlemma δ_inl {n₀ : ℤ} (hn₀ : n₀+1=n) :\n δ n₀ n (inl z hn₀) = cochain.comp ↑z (cochain.of_hom (inr z)) (add_zero n).symm :=\nbegin\n ext1,\n simp only [δ_v n₀ n hn₀ (inl z hn₀) p q hpq _ _ rfl rfl, twist_d, twist.δ],\n ext,\n { simp only [← hn₀, inl, cochain.mk_v, ε_succ, neg_neg, assoc, biprod.inl_desc, neg_smul,\n add_comp, biprod.lift_fst, comp_zsmul, cochain.of_hom_v_comp_d,\n homological_complex.id_f, id_comp, neg_comp, zsmul_comp, biprod.inl_fst, comp_id,\n cochain.d_comp_of_hom_v, add_right_neg, cochain.comp_zero_cochain, cochain.of_hom_v,\n inr, biprod.inr_fst, comp_zero], },\n { simp only [inl, inr, add_zero, sub_add_cancel, eq_self_iff_true, cochain.mk_v,\n dif_pos, assoc, biprod.inl_desc, add_comp, biprod.lift_snd,\n linear.smul_comp, biprod.inl_snd, comp_zero, smul_zero, cochain.comp_zero_cochain,\n cochain.of_hom_v, biprod.inr_snd, comp_id, id_comp,\n cochain.zero_cochain_comp' _ _ p (q-1+1-n) q, homological_complex.id_f], },\nend\n\n@[simp]\nlemma δ_snd {n₁ : ℤ} (hn₁ : n+n₁=1) :\n δ 0 1 (snd z) = -cochain.comp (fst z hn₁ : cochain (twist z) F n₁) (↑z) (show 1 = n₁+n, by rw [← hn₁, add_comm]) :=\nbegin\n ext1,\n simp only [δ_v 0 1 (zero_add 1) _ p q hpq p q (by linarith) hpq, fst, snd, zero_add, ε_1,\n cochain.mk_v, cochain.of_hom_v, homological_complex.id_f, comp_id, neg_zsmul, one_zsmul,\n cochain.neg_v, cocycle.mk_coe, twist_d, twist.δ,\n cochain.comp_v _ _ (show 1=n₁+n, by linarith) p (p+1-n) q (by linarith) (by linarith)],\n ext,\n { simp only [dif_pos hpq.symm, zero_add, comp_add, biprod.inl_snd_assoc, zero_comp,\n comp_neg, biprod.inl_desc_assoc, biprod.lift_snd, biprod.inl_fst_assoc], },\n { simp only [neg_zero, comp_add, biprod.inr_snd_assoc, comp_neg, biprod.inr_desc_assoc,\n biprod.lift_snd, add_right_neg, biprod.inr_fst_assoc, zero_comp], },\nend\n\nlemma id_eq {n₀ n₁ : ℤ} (hn₀ : n₀+1=n) (hn₁ : n+n₁=1) : cochain.of_hom (𝟙 (twist z)) =\ncochain.comp ↑(fst z hn₁) (inl z hn₀) (show 0=n₁+n₀, by linarith) +\ncochain.comp (snd z) (cochain.of_hom (inr z)) (zero_add 0).symm :=\nbegin\n ext1,\n simpa only [fst, inl, snd, inr, cochain.add_v,\n cochain.comp_v _ _ (show 0 = n₁+n₀, by linarith) p (p+1-n) p (by linarith) (by linarith),\n cochain.of_hom_v, homological_complex.id_f, cocycle.mk_coe, cochain.mk_v,\n comp_id, id_comp, cochain.comp_zero_cochain, biprod.total],\nend\n\nlemma cochain_ext (y₁ y₂ : cochain (twist z) K m) {n₀ n₁ : ℤ} (hn₀ : n₀+1=n)\n (hn₁ : n₁ = n₀+m) :\n y₁ = y₂ ↔ cochain.comp (inl z hn₀) y₁ hn₁ = cochain.comp (inl z hn₀) y₂ hn₁ ∧\n cochain.comp (cochain.of_hom (inr z)) y₁ (zero_add m).symm =\n cochain.comp (cochain.of_hom (inr z)) y₂ (zero_add m).symm :=\nbegin\n split,\n { intro h, rw h, tauto, },\n { rintro ⟨hl, hr⟩,\n suffices : cochain.comp (cochain.of_hom (𝟙 _)) y₁ (zero_add m).symm =\n cochain.comp (cochain.of_hom (𝟙 _)) y₂ (zero_add m).symm,\n { ext1,\n simpa only [cochain.id_comp] using cochain.congr_v this p q hpq, },\n simp only [id_eq z hn₀ (show n+(-n₀)=1, by linarith), cochain.add_comp,\n cochain.comp_assoc_of_second_is_zero_cochain,\n cochain.comp_assoc _ _ _ (show 0=-n₀+n₀, by linarith) (show n₁=n₀+m, by linarith)\n (show m=-n₀+n₀+m, by linarith), hl, hr], }\nend\n\ndef desc_cochain {m m₁ : ℤ} (y₁ : cochain F K m₁) (y₂ : cochain G K m)\n (hm₁ : m₁+1=n+m) : cochain (twist z) K m :=\ncochain.comp ↑(fst z (show n+(m-m₁) = 1, by linarith)) y₁ (eq_add_of_sub_eq rfl : m=(m-m₁)+m₁) +\n cochain.comp (snd z) y₂ (zero_add m).symm\n\nlemma desc_cochain_eq {m m₁ n₁ : ℤ} (y₁ : cochain F K m₁) (y₂ : cochain G K m)\n (hm₁ : m₁+1=n+m) (hn₁ : n+n₁=1) : desc_cochain z y₁ y₂ hm₁ =\ncochain.comp ↑(fst z hn₁) y₁ (show m = n₁+m₁, begin\n suffices : m+1=n₁+m₁+1,\n { simpa only [add_left_inj] using this, },\n rw [add_assoc, hm₁, ← hn₁, add_comm n₁, add_comm n m, add_assoc],\nend) + cochain.comp (snd z) y₂ (zero_add m).symm :=\nbegin\n have h : n₁ = m-m₁ := by linarith,\n subst h,\n refl,\nend\n\nlemma inl_comp_desc_cochain {m m₁ n₀ : ℤ} (y₁ : cochain F K m₁)\n (y₂ : cochain G K m) (hm₁ : m₁+1=n+m) (hn₀ : n₀+1=n) :\n cochain.comp (inl z hn₀) (desc_cochain z y₁ y₂ hm₁) begin\n suffices : m₁+1 = n₀+m+1,\n { simpa only [add_left_inj] using this, },\n rw [add_assoc, hm₁, ← hn₀, add_assoc, add_comm 1 m],\n end = y₁ :=\nbegin\n simp only [desc_cochain_eq z y₁ y₂ hm₁ (show n+(-n₀)=1, by linarith), cochain.comp_add,\n ← cochain.comp_assoc (inl z hn₀) _ y₁ (show 0=n₀+(-n₀), by linarith)\n (show m= _, by linarith) (show m₁=_, by linarith),\n ← cochain.comp_assoc_of_second_is_zero_cochain, add_zero,\n inl_comp_fst, inl_comp_snd, cochain.id_comp, cochain.zero_comp],\nend\n\nlemma inr_comp_desc_cochain {m m₁ : ℤ} (y₁ : cochain F K m₁)\n (y₂ : cochain G K m) (hm₁ : m₁+1=n+m) :\n cochain.comp (cochain.of_hom (inr z)) (desc_cochain z y₁ y₂ hm₁) (zero_add m).symm = y₂ :=\nbegin\n simp only [desc_cochain_eq z y₁ y₂ hm₁ (show n+(1-n)=1, by linarith), cochain.comp_add,\n ← cochain.comp_assoc_of_second_is_zero_cochain, inr_comp_snd, cochain.id_comp,\n ← cochain.comp_assoc_of_first_is_zero_cochain, inr_comp_fst, cochain.zero_comp, zero_add],\nend\n\nlemma δ_desc_cochain {m m₁ m₂ n₁ : ℤ} (y₁ : cochain F K m₁) (y₂ : cochain G K m)\n (hm₁ : m₁+1=n+m) (hn₁ : n+n₁=1) (hm₂ : m₁+1=m₂)\n (m' : ℤ) (hm' : m+1=m') :\n δ m m' (desc_cochain z y₁ y₂ hm₁) =\n cochain.comp (fst z hn₁ : cochain (twist z) F n₁) (δ m₁ m₂ y₁ +\n ε (m+1) • cochain.comp ↑z y₂ (show m₂ = n+m, by linarith)) (show m' = n₁+m₂, by linarith) +\n cochain.comp (snd z) (δ m m' y₂) (zero_add m').symm :=\nbegin\n simp only [desc_cochain_eq z y₁ y₂ hm₁ hn₁, δ_add, cochain.comp_add,\n δ_comp_of_first_is_zero_cochain _ _ _ hm', δ_snd z hn₁,\n δ_comp ↑(fst z hn₁) y₁ (show m = n₁+m₁, by linarith) _ m₂ m' hm' rfl hm₂,\n cochain.comp_zsmul, cochain.neg_comp, zsmul_neg, ε_add, ε_1, mul_neg, mul_one,\n neg_zsmul, cochain.comp_neg, cocycle.δ_eq_zero, cochain.zero_comp, zsmul_zero, add_zero,\n add_assoc],\n rw cochain.comp_assoc _ _ _ (show 1=n₁+n, by linarith) (show m₂=n+m, by linarith)\n (show m' = n₁+n+m, by linarith),\n conv_rhs { congr, skip, rw add_comm, },\nend\n\n@[simps]\ndef desc_cocycle {m m₁ n₂ : ℤ} (y₁ : cochain F K m₁) (y₂ : cocycle G K m)\n (hm₁ : m₁+1=n+m) (hn₂ : n₂ = n+m)\n (hy : δ m₁ n₂ y₁ = ε m • cochain.comp (z : cochain F G n) (y₂ : cochain G K m) hn₂) :\n cocycle (twist z) K m :=\ncocycle.mk (desc_cochain z y₁ ↑y₂ hm₁) _ rfl\nbegin\n simp only [δ_desc_cochain z y₁ ↑y₂ hm₁ (show n+(1-n)=1, by linarith) (show m₁+1=n₂, by linarith) _ rfl,\n cocycle.δ_eq_zero, cochain.comp_zero, add_zero, hy, ε_add, ε_1, mul_neg, mul_one, neg_zsmul,\n add_right_neg, cochain.comp_zero],\nend\n\nlemma inr_comp_desc_cocycle {m m₁ n₂ : ℤ} (y₁ : cochain F K m₁) (y₂ : cocycle G K m)\n (hm₁ : m₁+1=n+m) (hn₂ : n₂ = n+m)\n (hy : δ m₁ n₂ y₁ = ε m • cochain.comp (z : cochain F G n) (y₂ : cochain G K m) hn₂) :\n cochain.comp (cochain.of_hom (inr z)) (desc_cocycle z y₁ y₂ hm₁ hn₂ hy : cochain (twist z) K m)\n (zero_add m).symm = y₂ :=\nby simp only [desc_cocycle, cocycle.mk_coe, inr_comp_desc_cochain]\n\n@[simps]\ndef desc_hom_as_cocycle {m₁ : ℤ} (y₁ : cochain F K m₁) (y₂ : G ⟶ K)(hm₁ : m₁+1=n)\n (hy : δ m₁ n y₁ = cochain.comp (z : cochain F G n) (cochain.of_hom y₂) (add_zero n).symm) :\n cocycle (twist z) K 0 :=\nbegin\n apply desc_cocycle z y₁ (cocycle.of_hom y₂) (by linarith) (add_zero n).symm,\n simpa only [hy, ε_0, one_zsmul],\nend\n\n@[simps]\ndef desc {m₁ : ℤ} (y₁ : cochain F K m₁) (y₂ : G ⟶ K)\n (hm₁ : m₁+1=n)\n (hy : δ m₁ n y₁ = cochain.comp (z : cochain F G n) (cochain.of_hom y₂) (add_zero n).symm) :\n twist z ⟶ K :=\ncocycle.hom_of (desc_hom_as_cocycle z y₁ y₂ hm₁ hy)\n\n@[simp]\nlemma inr_comp_desc {m₁ : ℤ} (y₁ : cochain F K m₁) (y₂ : G ⟶ K)\n (hm₁ : m₁+1=n)\n (hy : δ m₁ n y₁ = cochain.comp (z : cochain F G n) (cochain.of_hom y₂) (add_zero n).symm) :\n inr z ≫ desc z y₁ y₂ hm₁ hy = y₂ :=\nbegin\n apply (cocycle.equiv_hom G K).to_equiv.injective,\n ext1,\n dsimp [cocycle.equiv_hom],\n simp only [cocycle.of_hom, cocycle.mk_coe, cochain.of_hom_comp, desc,\n cocycle.cochain_of_hom_hom_of_eq_coe, desc_hom_as_cocycle_coe, inr_comp_desc_cochain],\nend\n\n\n\ndef lift_cochain {m₁ : ℤ} (y₁ : cochain K F m₁) (y₂ : cochain K G m)\n (hm : m+1=m₁+n) : cochain K (twist z) m :=\ncochain.comp y₁ (inl z (show (n-1)+1=n, by linarith)) (show m=m₁+(n-1), by linarith) +\n cochain.comp y₂ (cochain.of_hom (inr z)) (add_zero m).symm\n\nlemma lift_cochain_eq {m₁ n₀ : ℤ} (y₁ : cochain K F m₁) (y₂ : cochain K G m) (hm : m+1=m₁+n)\n (hn₀ : n₀+1=n) : lift_cochain z y₁ y₂ hm =\ncochain.comp y₁ (inl z hn₀) (begin\n suffices : m+1=m₁+n₀+1,\n { simpa only [add_left_inj] using this, },\n rw [hm, ← hn₀, add_assoc],\nend) + cochain.comp y₂ (cochain.of_hom (inr z)) (add_zero m).symm :=\nbegin\n have eq : n₀ = n-1 := by linarith,\n subst eq,\n refl,\nend\n\nlemma lift_cochain_v {m₁ n₀ : ℤ} (y₁ : cochain K F m₁) (y₂ : cochain K G m)\n (hm : m+1=m₁+n) (hn₀ : n₀+1 = n) (p q : ℤ) (hpq : q = p + m) (p' : ℤ) (hp' : p' = p + m₁):\n (lift_cochain z y₁ y₂ hm).v p q hpq =\n y₁.v p p' hp' ≫ (inl z hn₀).v p' q (by rw [hpq, hp', add_assoc, add_right_inj,\n ← add_left_inj (1 : ℤ), hm, ← hn₀, add_assoc]) +\n y₂.v p q hpq ≫ (inr z).f q :=\nbegin\n have hn₀' : n₀ = n-1 := by linarith,\n substs hn₀' hp' hpq,\n dsimp [lift_cochain, cochain.comp],\n simp only [cochain.of_hom_v],\nend\n\n@[simp]\nlemma lift_cochain_comp_fst {m₁ n₁ : ℤ} (y₁ : cochain K F m₁) (y₂ : cochain K G m) (hm : m+1=m₁+n)\n (hn₁ : n+n₁=1) : cochain.comp (lift_cochain z y₁ y₂ hm) ↑(fst z hn₁)\n (show m₁=m+n₁, by { suffices : m₁+n = m+n₁+n,\n { simpa only [add_left_inj] using this,},\n rw [← hm, ← hn₁, add_comm n, add_assoc]}) = y₁ :=\nbegin\n simp only [lift_cochain, cochain.add_comp,\n cochain.comp_assoc _ _ _ (show m=m₁+(n-1), by linarith) (show 0=n-1+n₁, by linarith)\n (show m₁=_, by linarith), inl_comp_fst, cochain.comp_id, add_zero,\n cochain.comp_assoc_of_second_is_zero_cochain, inr_comp_fst, cochain.comp_zero],\nend\n\n@[simp]\nlemma lift_cochain_comp_snd {m₁ : ℤ} (y₁ : cochain K F m₁) (y₂ : cochain K G m) (hm : m+1=m₁+n) :\n cochain.comp (lift_cochain z y₁ y₂ hm) (snd z) (add_zero m).symm = y₂ :=\nby simp only [lift_cochain, cochain.add_comp, cochain.comp_assoc_of_third_is_zero_cochain,\n inl_comp_snd, cochain.comp_zero, zero_add, inr_comp_snd, cochain.comp_id]\n\nlemma δ_lift_cochain {m₁ n₀ m₂ : ℤ} (y₁ : cochain K F m₁) (y₂ : cochain K G m) (hm : m+1=m₁+n)\n (hn₀ : n₀+1=n) (hm₂ : m₁+1=m₂) (m' : ℤ) (hm' : m+1=m') :\n δ m m' (lift_cochain z y₁ y₂ hm) =\n ε n₀ • cochain.comp (δ m₁ m₂ y₁) (inl z hn₀)\n (by rw [← hm', ← hm₂, hm, ← hn₀, add_comm n₀ 1, add_assoc]) +\n cochain.comp (δ m m' y₂ + cochain.comp y₁ ↑z (by rw [← hm', hm]))\n (cochain.of_hom (inr z)) (add_zero m').symm :=\nbegin\n simp only [lift_cochain_eq z y₁ y₂ hm hn₀, δ_add,\n δ_comp y₁ (inl z hn₀) (show m = m₁+n₀, by linarith) m₂ n m' hm' hm₂ hn₀,\n δ_comp_of_second_is_zero_cochain _ _ _ hm', δ_inl, cocycle.δ_cochain_of_hom,\n cochain.comp_zero, zero_add, cochain.comp_assoc_of_third_is_zero_cochain,\n cochain.add_comp],\n conv_lhs { rw [add_assoc, add_comm, add_assoc], },\nend\n\ndef lift_cocycle {m₁ n₀ : ℤ} (y₁ : cocycle K F m₁) (y₂ : cochain K G m) (hm : m+1=m₁+n)\n (hn₀ : n₀+1=n) (m' : ℤ) (hm' : m+1=m')\n (hy : δ m m' y₂ + cochain.comp (y₁ : cochain K F m₁) ↑z (show m'=m₁+n, by rw [← hm', hm]) = 0) :\n cocycle K (twist z) m := cocycle.mk (lift_cochain z ↑y₁ y₂ hm) m' hm'\n(by simp only [δ_lift_cochain z ↑y₁ y₂ hm hn₀ rfl m' hm', cocycle.δ_eq_zero, cochain.zero_comp,\n zsmul_zero, zero_add, hy])\n\n@[simps]\ndef lift_hom_as_cocycle {m₁ n₀ : ℤ} (y₁ : cocycle K F m₁) (y₂ : cochain K G 0) (hm : m₁+n=1)\n (hn₀ : n₀+1=n)\n (hy : δ 0 1 y₂ + cochain.comp (y₁ : cochain K F m₁) ↑z hm.symm = 0) : cocycle K (twist z) 0 :=\nlift_cocycle z y₁ y₂ (show 0+1 = m₁+n, by linarith) hn₀ 1 (zero_add 1) hy\n\n@[simps]\ndef lift {m₁ n₀ : ℤ} (y₁ : cocycle K F m₁) (y₂ : cochain K G 0) (hm : m₁+n=1)\n (hn₀ : n₀+1=n)\n (hy : δ 0 1 y₂ + cochain.comp (y₁ : cochain K F m₁) ↑z hm.symm = 0) :\n K ⟶ twist z :=\ncocycle.hom_of (lift_hom_as_cocycle z y₁ y₂ hm hn₀ hy)\n\nlemma cochain_ext' (y₁ y₂ : cochain K (twist z) m) {n₁ m₁ : ℤ} (hn₁ : n+n₁=1) (hm₁ : m₁ = m+n₁) :\n y₁ = y₂ ↔ cochain.comp y₁ (fst z hn₁ : cochain (twist z) F n₁) hm₁\n = cochain.comp y₂ (fst z hn₁ : cochain (twist z) F n₁) hm₁ ∧\n cochain.comp y₁ (snd z) (add_zero m).symm =\n cochain.comp y₂ (snd z) (add_zero m).symm :=\nbegin\n split,\n { intro h, rw h, tauto, },\n { rintro ⟨hl, hr⟩,\n suffices : cochain.comp y₁ (cochain.of_hom (𝟙 _)) (add_zero m).symm =\n cochain.comp y₂ (cochain.of_hom (𝟙 _)) (add_zero m).symm,\n { ext1,\n simpa only [cochain.comp_id] using cochain.congr_v this p q hpq, },\n simp only [id_eq z (show n-1+1=n, by linarith) hn₁, cochain.add_comp,\n cochain.comp_add],\n simp only [← cochain.comp_assoc_of_second_is_zero_cochain,\n ← cochain.comp_assoc _ _ _ hm₁ (show 0=n₁+(n-1), by linarith)\n (show m=m+n₁+(n-1), by linarith), hl, hr], },\nend\n\nlemma of_d_eq (n₁ n₂ n₃ : ℤ) (hn₁ : n + n₁ = 1) (hn₂ : n₂ = n₁+1) (hn₃ : n₃+1=n) : cochain.of_d (twist z) =\n ε (n+1) • ((fst z hn₁ : cochain (twist z) F n₁).comp (cochain.of_d F) hn₂).comp (inl z hn₃)\n (by rw [← hn₁, hn₂, ← hn₃, add_comm n₃, add_assoc, add_comm n₃, ← add_assoc, add_comm n₁]) +\n ((fst z hn₁ : cochain (twist z) F n₁).comp (z : cochain F G n) (show 1 = n₁ + n, by rw [← hn₁, add_comm])).comp\n (cochain.of_hom (inr z)) (add_zero 1).symm +\n ((snd z).comp (cochain.of_d G) (zero_add 1).symm).comp (cochain.of_hom (inr z)) (add_zero 1).symm :=\nbegin\n rw cochain_ext z (cochain.of_d (twist z)) _ hn₃ hn₃.symm,\n split,\n { simp only [cochain.comp_add, cochain.comp_zsmul],\n simp only [← cochain.comp_assoc_of_third_is_zero_cochain,\n ← cochain.comp_assoc_of_second_is_zero_cochain, inl_comp_snd, inl_comp_fst, cochain.id_comp,\n ← cochain.comp_assoc (inl z hn₃) _ _ (show 1 = n₃+n₂, by linarith) _ (show n = n₃+n₂+n₃, by linarith),\n ← cochain.comp_assoc (inl z hn₃) _ _ (show 0 = n₃ + n₁, by linarith) _ (show 1 = n₃ + n₁ + 1, by linarith),\n ← cochain.comp_assoc (inl z hn₃) _ _ (show 0 = n₃ + n₁, by linarith) (show 1 = n₁ + n, by linarith)\n (show n = n₃+n₁+n, by linarith), cochain.zero_comp, add_zero,\n cochain_ext' z _ _ hn₁ (show 1 = n+n₁, by linarith)],\n split,\n { simp only [cochain.add_comp, cochain.zsmul_comp,\n cochain.comp_assoc_of_second_is_zero_cochain, inr_comp_fst, cochain.comp_zero, inl_comp_fst,\n cochain.comp_assoc _ (inl z hn₃) _ (show n = 1+n₃, by linarith) (show 0 = n₃ + n₁, by linarith)\n (show 1 = 1 + n₃ + n₁, by linarith), add_zero, cochain.comp_id],\n ext p q hpq,\n dsimp [inl, fst, cochain.comp],\n simp only [twist.δ, cochain.of_d_v, twist_d, assoc, biprod.inl_desc, biprod.lift_fst_assoc,\n linear.smul_comp, cochain.d_comp_of_hom_v, homological_complex.id_f, comp_id,\n linear.comp_smul, cochain.of_hom_v_comp_d, id_comp], },\n { simp only [cochain.comp_assoc_of_third_is_zero_cochain, cochain.add_comp, cochain.zsmul_comp,\n inl_comp_snd, inr_comp_snd, cochain.comp_zero, zsmul_zero, zero_add, cochain.comp_id],\n ext p q hpq,\n have hp : ∃ (p' : ℤ), p = p' + 1 -n := ⟨p+n-1, by linarith⟩,\n obtain ⟨p', hp'⟩ := hp,\n subst hp',\n rw cochain.comp_v _ _ hn₃.symm (p'+1-n) p' q (by linarith) (by linarith),\n dsimp [inl, snd],\n simp only [cochain.of_hom_v, homological_complex.id_f, id_comp, cochain.comp_zero_cochain,\n twist.δ, cochain.of_d_v, twist_d, cochain.mk_v, comp_id, biprod.inl_desc_assoc,\n biprod.lift_snd, dif_pos (show p'+1 = q, by linarith)], }, },\n { simp only [ε_succ, neg_smul,\n cochain.comp_add, cochain.comp_neg, cochain.comp_zsmul,\n ← cochain.comp_assoc_of_first_is_zero_cochain, inr_comp_fst, cochain.zero_comp, zsmul_zero,\n zero_add, neg_zero, inr_comp_snd, cochain.id_comp,\n cochain_ext' z _ _ hn₁ (show n₂ = 1 + n₁, by linarith)],\n split,\n { rw [cochain.comp_assoc_of_second_is_zero_cochain, inr_comp_fst, cochain.comp_zero],\n ext p q hpq,\n simp only [cochain.comp_assoc_of_first_is_zero_cochain, cochain.zero_cochain_comp,\n cochain.of_hom_v, cochain.zero_v,\n cochain.comp_v _ _ (show n₂ = 1 + n₁, by linarith) p (p+1) q rfl (by linarith)],\n dsimp [inr, fst],\n simp only [twist.δ, cochain.of_d_v, twist_d, biprod.inr_desc_assoc,\n biprod.lift_fst_assoc, zero_comp], },\n { rw [cochain.comp_assoc_of_second_is_zero_cochain, inr_comp_snd, cochain.comp_id],\n ext p q hpq,\n dsimp [inr, snd],\n simp only [cochain.comp_assoc_of_third_is_zero_cochain, cochain.zero_cochain_comp,\n cochain.of_hom_v, cochain.comp_zero_cochain, twist.δ, cochain.of_d_v, twist_d,\n cochain.mk_v, homological_complex.id_f, comp_id, biprod.inr_desc_assoc,\n biprod.lift_snd], }, },\nend\n\nend twist\n\nend hom_complex\n\nend cochain_complex\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebra/homology/twist_cocycle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.44167300566462553, "lm_q1q2_score": 0.2363385312979336}} {"text": "import for_mathlib.derived.bounded_homotopy_category\nimport for_mathlib.is_quasi_iso_sigma\nimport for_mathlib.coprod_op\nimport for_mathlib.derived.example\n\nopen category_theory\nopen category_theory.limits\n\nuniverses v u\nvariables {A : Type u} [category.{v} A] [abelian A] [has_coproducts.{v} A]\n\nopen_locale zero_object\n\nnamespace bounded_homotopy_category\n\nnoncomputable\ndef cofan {α : Type v} (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] : cofan X := cofan.mk\n{ val := (homotopy_category.colimit_cofan $ λ a : α, (X a).val).X,\n bdd := begin\n obtain ⟨n,hn⟩ := homotopy_category.is_uniformly_bounded_above.cond (val ∘ X),\n use n, intros i hi,\n dsimp [homotopy_category.colimit_cofan],\n let e : (∐ λ (a : α), (X a).val.as).X i ≅\n (∐ λ (a : α), (X a).val.as.X i) := homotopy_category.coproduct_iso _ _,\n refine is_zero_of_iso_of_zero _ e.symm,\n apply category_theory.is_zero_colimit,\n intros j,\n refine hn j.as _ hi,\n end }\n(λ a, (homotopy_category.colimit_cofan (λ a : α, (X a).val)).ι.app ⟨a⟩)\n\nnoncomputable\ndef is_colimit_cofan {α : Type v} (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] : is_colimit (cofan X) :=\n{ desc := λ S, (homotopy_category.is_colimit_cofan\n (λ a : α, (X a).val)).desc ((forget A).map_cocone S),\n fac' := begin\n intros S j,\n erw (homotopy_category.is_colimit_cofan (λ a : α, (X a).val)).fac\n ((forget A).map_cocone S) j, refl,\n end,\n uniq' := begin\n intros S m hm,\n apply (homotopy_category.is_colimit_cofan (λ a : α, (X a).val)).hom_ext,\n intros j,\n specialize hm j,\n erw hm,\n erw (homotopy_category.is_colimit_cofan (λ a : α, (X a).val)).fac,\n refl,\n end }\n\ninstance has_coproduct_of_uniform_bound {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] :\n has_coproduct X :=\nbegin\n constructor, apply nonempty.intro,\n refine ⟨cofan X, is_colimit_cofan X⟩,\nend\n\ninstance is_K_projective_sigma {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n [∀ a, homotopy_category.is_K_projective (X a).val] :\n homotopy_category.is_K_projective (sigma_obj X).val :=\nbegin\n let e : (sigma_obj X) ≅ (cofan X).X :=\n (colimit.is_colimit _).cocone_point_unique_up_to_iso (is_colimit_cofan X),\n let ee := (forget A).map_iso e,\n suffices : homotopy_category.is_K_projective ((forget A).obj (cofan X).X),\n { resetI, apply homotopy_category.is_K_projective_of_iso _ _ ee.symm },\n dsimp [forget, cofan],\n apply_instance,\nend\n\nnoncomputable\ninstance forget_preserves_coproduct {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] :\n preserves_colimit (discrete.functor X) (forget A) :=\nbegin\n apply preserves_colimit_of_preserves_colimit_cocone (is_colimit_cofan X),\n let E : (forget A).map_cocone (cofan X) ≅\n homotopy_category.colimit_cofan (val ∘ X) :=\n cocones.ext (iso.refl _) _,\n rotate,\n { intros a, dsimp [forget, cofan], simpa only [category.comp_id] },\n apply is_colimit.of_iso_colimit _ E.symm,\n apply homotopy_category.is_colimit_cofan,\nend\n\nlemma is_quasi_iso_sigma\n [AB4 A]\n {α : Type v}\n (X P : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n [uniformly_bounded P]\n (π : Π a, P a ⟶ X a)\n [∀ a, homotopy_category.is_quasi_iso (π a)] :\n homotopy_category.is_quasi_iso\n (sigma.desc $ λ a : α, π a ≫ sigma.ι X a : sigma_obj P ⟶ sigma_obj X) :=\nbegin\n let t := sigma.desc (λ (a : α), π a ≫ sigma.ι X a),\n change homotopy_category.is_quasi_iso ((forget A).map t),\n let eP : (forget A).obj (∐ P) ≅ ∐ (λ a, (forget A).obj (P a)) :=\n preserves_colimit_iso (forget A) _,\n let eX : (forget A).obj (∐ X) ≅ ∐ (λ a, (forget A).obj (X a)) :=\n preserves_colimit_iso (forget A) _,\n let s : ∐ (λ a, (forget A).obj (P a)) ⟶ ∐ (λ a, (forget A).obj (X a)) :=\n sigma.desc (λ (a : α), π a ≫ sigma.ι (val ∘ X) a),\n suffices : (forget A).map t = eP.hom ≫ s ≫ eX.inv,\n { rw this,\n apply homotopy_category.is_quasi_iso_comp },\n apply (is_colimit_of_preserves (forget A) (colimit.is_colimit _)).hom_ext,\n swap, apply_instance,\n intros a,\n dsimp [t, s, eP, eX, preserves_colimit_iso, is_colimit.cocone_point_unique_up_to_iso],\n rw [← (forget A).map_comp, colimit.ι_desc],\n slice_rhs 0 1\n { erw (is_colimit_of_preserves (forget A) (colimit.is_colimit (discrete.functor P))).fac },\n erw colimit.ι_desc,\n dsimp, simp only [category.assoc], erw colimit.ι_desc,\n dsimp, simp only [functor.map_comp], refl,\nend\n\nvariables [enough_projectives A]\n\nnoncomputable\ndef uniform_π {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] : sigma_obj (replace_uniformly X) ⟶ sigma_obj X :=\nsigma.desc $ λ a, π_uniformly _ _ ≫ sigma.ι _ a\n\ninstance is_quasi_iso_sigma_map_π_uniformly\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] :\n homotopy_category.is_quasi_iso (uniform_π X) :=\nis_quasi_iso_sigma _ _ _\n\nopen opposite\n\nnoncomputable\ndef Ext_coproduct_iso\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n (i : ℤ) (Y) :\n ((Ext i).obj (op (sigma_obj X))).obj Y ≅\n pi_obj (λ a : α, ((Ext i).obj (op (X a))).obj Y) :=\nExt_iso i _ _ _ (uniform_π X) ≪≫\ncategory_theory.preadditive_yoneda_coproduct_iso (replace_uniformly X) (Y⟦i⟧) ≪≫\ncategory_theory.pi_iso _ _ (λ a, (Ext_iso i _ _ _ (π_uniformly X a)).symm)\n\nlemma ι_Ext_coprodut_iso\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n (i : ℤ) (Y) (j) :\n (Ext_coproduct_iso X i Y).inv ≫\n ((Ext i).map (sigma.ι X j : X j ⟶ ∐ X).op).app Y =\n pi.π _ _ :=\nbegin\n rw iso.inv_comp_eq,\n dsimp [Ext_coproduct_iso, pi_iso],\n simp only [category.assoc, limit.lift_π, fan.mk_π_app],\n simp only [← category.assoc], rw iso.eq_comp_inv,\n dsimp [Ext, Ext_iso], --ext t, simp only [comp_apply],\n dsimp [preadditive_yoneda_coproduct_iso, preadditive_yoneda_coproduct_to_product],\n simp only [category.assoc, limit.lift_π],\n ext t, simp only [comp_apply], dsimp,\n simp only [← category.assoc], congr' 1,\n apply lift_ext (∐ X).π, swap, apply_instance,\n dsimp [uniform_π],\n simp,\nend\n\nlemma ι_Ext_coproduct_iso'\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n (i : ℤ) (Y) (j) :\n (Ext_coproduct_iso X i Y).hom ≫ pi.π _ _ =\n ((Ext i).map (sigma.ι X j : X j ⟶ ∐ X).op).app Y :=\nbegin\n rw [← iso.eq_inv_comp, ι_Ext_coprodut_iso],\nend\n\nlemma Ext_coproduct_iso_naturality\n [AB4 A]\n {α : Type v}\n (X₁ X₂ : α → bounded_homotopy_category A)\n [uniformly_bounded X₁]\n [uniformly_bounded X₂]\n (g : X₁ ⟶ X₂)\n (i : ℤ) (Y) :\n ((Ext i).map (sigma.desc (λ b, g b ≫ sigma.ι X₂ b) : ∐ X₁ ⟶ ∐ X₂).op).app Y ≫\n (Ext_coproduct_iso _ _ _).hom =\n (Ext_coproduct_iso _ _ _).hom ≫\n pi.lift (λ b, pi.π _ b ≫ ((Ext i).map (g b).op).app Y) :=\nbegin\n dsimp only [Ext_coproduct_iso, Ext, Ext0, Ext_iso, functor.comp_map, whiskering_left,\n whisker_left, iso.trans_hom, functor.map_iso, preadditive_yoneda_coproduct_iso,\n functor.flip, pi_iso, as_iso, preadditive_yoneda_coproduct_to_product],\n simp only [category.assoc],\n simp only [quiver.hom.unop_op, iso.op_hom, replacement_iso_hom, iso.op_inv,\n replacement_iso_inv, iso.symm_mk],\n apply limit.hom_ext,\n intros j,\n simp only [category.assoc, limit.lift_π, fan.mk_π_app, limit.lift_π_assoc],\n simp only [← functor.map_comp, ← op_comp],\n congr' 2,\n simp only [category.assoc],\n apply lift_ext (∐ X₂).π, swap, apply_instance,\n dsimp [quiver.hom.unop_op],\n simp only [category.assoc, lift_lifts, lift_lifts_assoc],\n dsimp [uniform_π],\n simp only [colimit.ι_desc_assoc, cofan.mk_ι_app, category.assoc, colimit.ι_desc,\n lift_lifts_assoc],\nend\n\nlemma Ext_coproduct_iso_naturality'\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n (i : ℤ) (Y₁ Y₂) (f : Y₁ ⟶ Y₂) :\n ((Ext i).obj (op (sigma_obj X))).map f ≫\n (Ext_coproduct_iso _ _ _).hom =\n (Ext_coproduct_iso _ _ _).hom ≫\n pi.lift (λ a, pi.π _ a ≫ ((Ext i).obj _).map f) :=\nbegin\n dsimp only [Ext_coproduct_iso, Ext, Ext0, Ext_iso, functor.comp_map, whiskering_left,\n whisker_left, iso.trans_hom, functor.map_iso, preadditive_yoneda_coproduct_iso,\n functor.flip, pi_iso, as_iso, preadditive_yoneda_coproduct_to_product,\n functor.comp_map, functor.comp_obj],\n simp only [category.assoc],\n simp only [quiver.hom.unop_op, iso.op_hom, replacement_iso_hom, iso.op_inv,\n replacement_iso_inv, iso.symm_mk],\n apply limit.hom_ext,\n intros j,\n simp only [category.assoc, limit.lift_π, fan.mk_π_app, limit.lift_π_assoc],\n erw nat_trans.naturality,\n erw nat_trans.naturality_assoc,\n erw nat_trans.naturality_assoc,\n refl,\nend\n\nend bounded_homotopy_category\n\n-- TODO: find better names... And move this stuff!\n\ninstance chain_complex_embed_cofan_uniformly_bounded\n {α : Type v}\n (X : α → chain_complex A ℕ) :\n bounded_homotopy_category.uniformly_bounded\n (λ a, chain_complex.to_bounded_homotopy_category.obj (X a)) :=\nbegin\n constructor, use 1, intros a i hi,\n rcases i with (_|i)|_,\n { exfalso, revert hi, dec_trivial },\n { exact is_zero_zero _, },\n { exfalso, revert hi, dec_trivial }\nend\n\nuniverse u'\n\ndef whisker_discrete_functor {α : Type v}\n {C : Type u} {D : Type u'} [category.{v} C] [category.{v} D] (F : C ⥤ D)\n (X : α → C) : discrete.functor X ⋙ F ≅ discrete.functor (F.obj ∘ X) :=\n discrete.nat_iso (λ i, iso.refl _)\n\nnoncomputable\nlemma preserves_coproducts_aux\n {α : Type v} {C : Type u} {D : Type u'}\n [category.{v} C] [category.{v} D]\n (F : C ⥤ D)\n [has_coproducts_of_shape α C]\n [∀ (X : α → C), has_coproduct (λ a, F.obj (X a))]\n (e : Π (X : α → C), F.obj (∐ X) ≅ ∐ (λ a, F.obj (X a)))\n (he : ∀ (X : α → C) (a : α), F.map (sigma.ι X a) ≫ (e X).hom = sigma.ι _ a) :\n preserves_colimits_of_shape (discrete α) F :=\nbegin\n constructor, intros K,\n let E : K ≅ discrete.functor (K.obj ∘ discrete.mk) := discrete.nat_iso (λ ⟨a⟩, iso.refl _),\n apply preserves_colimit_of_iso_diagram _ E.symm,\n apply preserves_colimit_of_preserves_colimit_cocone (colimit.is_colimit _),\n swap, apply_instance,\n let P := _, change is_colimit P,\n let P' := (cocones.precompose (whisker_discrete_functor F _).inv).obj P,\n suffices : is_colimit P',\n { exact is_colimit.precompose_inv_equiv _ _ this },\n apply is_colimit.of_iso_colimit (colimit.is_colimit _), swap,\n change has_colimit (discrete.functor (λ a : α, F.obj (K.obj ⟨a⟩))),\n apply_instance,\n symmetry,\n fapply cocones.ext,\n apply e,\n rintro ⟨a⟩,\n convert (he (λ b, (K.obj ⟨b⟩))) a,\n dsimp [P', whisker_discrete_functor],\n rw category.id_comp,\nend\n\nnoncomputable\ninstance homological_complex_embed_preserves_coproducts {α : Type v}\n {M N : Type} (c₁ : complex_shape M) (c₂ : complex_shape N) (e : c₁.embedding c₂) :\n preserves_colimits_of_shape (discrete α)\n (homological_complex.embed e : homological_complex A _ ⥤ _) :=\npreserves_coproducts_aux\n(homological_complex.embed e : homological_complex A _ ⥤ _)\n(λ (X : α → homological_complex A c₁), homological_complex.hom.iso_of_components\n(λ i,\nbegin\n rcases h : e.r i with _ | j,\n { refine homological_complex.embed.X_iso_of_none _ h ≪≫ _,\n refine _ ≪≫ (preserves_colimit_iso (homological_complex.eval A c₂ i) _).symm,\n refine (is_zero.iso_zero _).symm,\n apply is_zero_colimit,\n intros a,\n dsimp,\n exact homological_complex.embed.X_is_zero_of_none _ h },\n { refine homological_complex.embed.X_iso_of_some _ h ≪≫ _,\n refine (preserves_colimit_iso (homological_complex.eval _ _ _) _) ≪≫ _,\n refine _ ≪≫ (preserves_colimit_iso (homological_complex.eval _ _ _) _).symm,\n refine has_colimit.iso_of_nat_iso _,\n refine discrete.nat_iso _,\n intros b,\n dsimp,\n refine (homological_complex.embed.X_iso_of_some _ h).symm }\nend) begin\n intros i j h,\n rcases h₁ : e.r i with _ | i';\n rcases h₂ : e.r j with _ | j',\n { apply is_zero.eq_of_src,\n apply homological_complex.embed.X_is_zero_of_none,\n assumption },\n { apply is_zero.eq_of_src,\n apply homological_complex.embed.X_is_zero_of_none,\n assumption },\n { apply is_zero.eq_of_tgt,\n refine is_zero.of_iso _\n (preserves_colimit_iso (homological_complex.eval _ _ _) _),\n apply is_zero_colimit, intros b,\n apply homological_complex.embed.X_is_zero_of_none,\n assumption },\n { simp_rw [h₁, h₂], dsimp,\n simp only [category.assoc],\n rw ← iso.eq_inv_comp,\n dsimp [homological_complex.embed, homological_complex.embed.obj],\n rw homological_complex.embed.d_of_some_of_some (∐ X) h₁ h₂,\n simp only [category.assoc, iso.inv_hom_id_assoc],\n apply (is_colimit_of_preserves (homological_complex.eval A c₁ i') _).hom_ext,\n rintro ⟨a⟩,\n simp only [functor.map_cocone_ι_app, colimit.cocone_ι, homological_complex.eval_map],\n slice_lhs 1 2 {\n erw (is_colimit_of_preserves (homological_complex.eval A c₁ i') _).fac },\n dsimp,\n simp only [has_colimit.iso_of_nat_iso_ι_hom, discrete.nat_iso_hom_app, iso.symm_hom,\n category.assoc, ι_preserves_colimits_iso_inv, homological_complex.eval_map,\n homological_complex.hom.comm, homological_complex.hom.comm_assoc],\n dsimp,\n rw iso.inv_comp_eq,\n slice_rhs 3 4\n { erw (is_colimit_of_preserves (homological_complex.eval A c₁ j') _).fac },\n dsimp,\n simp only [has_colimit.iso_of_nat_iso_ι_hom, discrete.nat_iso_hom_app, iso.symm_hom,\n category.assoc, ι_preserves_colimits_iso_inv, homological_complex.eval_map],\n slice_rhs 1 3\n { erw ← homological_complex.embed.d_of_some_of_some (X a) h₁ h₂ },\n apply colimit.is_colimit,\n apply_instance, }\n -- still annoying\n end)\nbegin\n intros X a, ext i,\n rcases h : e.r i with _ | i',\n { apply is_zero.eq_of_tgt,\n refine is_zero.of_iso _\n (preserves_colimit_iso (homological_complex.eval _ _ _) _),\n apply is_zero_colimit, intros b,\n apply homological_complex.embed.X_is_zero_of_none,\n exact h },\n dsimp [homological_complex.hom.iso_of_components],\n simp_rw [h], dsimp,\n simp only [← category.assoc, iso.comp_inv_eq],\n simp_rw [← iso.eq_comp_inv, category.assoc],\n slice_rhs 1 2\n { erw (is_colimit_of_preserves (homological_complex.eval A c₂ i) _).fac },\n dsimp,\n simp only [has_colimit.iso_of_nat_iso_ι_inv, discrete.nat_iso_inv_app, iso.symm_inv,\n category.assoc, ι_preserves_colimits_iso_inv, homological_complex.eval_map],\n apply homological_complex.embed.f_of_some,\nend\n\nnoncomputable\ndef embed_coproduct_iso\n {α : Type v}\n (X : α → chain_complex A ℕ) :\n (homological_complex.embed complex_shape.embedding.nat_down_int_up).obj (∐ X) ≅\n (∐ λ (a : α), (homological_complex.embed complex_shape.embedding.nat_down_int_up).obj (X a)) :=\npreserves_colimit_iso (homological_complex.embed complex_shape.embedding.nat_down_int_up) _ ≪≫\nhas_colimit.iso_of_nat_iso (whisker_discrete_functor _ _)\n\nnoncomputable\ndef chain_complex_embed_cofan_iso\n {α : Type v}\n (X : α → chain_complex A ℕ) :\n (bounded_homotopy_category.cofan\n (λ a, chain_complex.to_bounded_homotopy_category.obj (X a))) ≅\n ((cocones.precompose (whisker_discrete_functor _ X).inv).obj\n (chain_complex.to_bounded_homotopy_category.map_cocone\n (colimit.cocone (discrete.functor X)))) :=\ncocones.ext\n(bounded_homotopy_category.mk_iso $\n (homotopy_category.quotient _ _).map_iso $ (embed_coproduct_iso X).symm)\nbegin\n rintro ⟨a⟩,\n dsimp [bounded_homotopy_category.cofan,\n homotopy_category.colimit_cofan, whisker_discrete_functor],\n erw [category.id_comp, ← functor.map_comp],\n congr' 1,\n dsimp [embed_coproduct_iso],\n simp only [category.assoc],\n erw colimit.ι_desc_assoc,\n rw iso.comp_inv_eq,\n erw (is_colimit_of_preserves\n (homological_complex.embed complex_shape.embedding.nat_down_int_up) _).fac,\n dsimp [whisker_discrete_functor],\n rw category.id_comp,\nend\n\nnoncomputable\ninstance chain_complex_to_bounded_homotopy_category_preserves_coproducts\n {α : Type v} :\n preserves_colimits_of_shape (discrete α)\n (chain_complex.to_bounded_homotopy_category : chain_complex A _ ⥤ _) :=\nbegin\n constructor, intros K,\n let E : K ≅ discrete.functor (K.obj ∘ discrete.mk) := discrete.nat_iso (λ ⟨a⟩, iso.refl _),\n apply preserves_colimit_of_iso_diagram _ E.symm,\n apply preserves_colimit_of_preserves_colimit_cocone (colimit.is_colimit _),\n let Q : α → bounded_homotopy_category A := λ a,\n chain_complex.to_bounded_homotopy_category.obj (K.obj ⟨a⟩),\n let P := _, change is_colimit P,\n let T : discrete.functor (K.obj ∘ discrete.mk) ⋙ chain_complex.to_bounded_homotopy_category ≅\n discrete.functor Q := discrete.nat_iso (λ _, iso.refl _),\n let P' := (cocones.precompose T.inv).obj P,\n suffices : is_colimit P',\n { exact is_colimit.precompose_inv_equiv _ _ this },\n apply is_colimit.of_iso_colimit (bounded_homotopy_category.is_colimit_cofan Q),\n swap, apply_instance,\n apply chain_complex_embed_cofan_iso,\nend\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/derived/ext_coproducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.46879062662624377, "lm_q1q2_score": 0.2362264894431585}} {"text": "import Logic.Predicate.FirstOrder.Semantics\n\nuniverse u v\n\nsection\n\nvariable {L : Language.{u}} {μ : Type v}\n {I : Type u} (A : I → Type u) [(ι : I) → Inhabited (A ι)] [s : (ι : I) → FirstOrder.Structure L (A ι)] (𝓤 : Ultrafilter I)\n\nnamespace FirstOrder\n\nnamespace Structure\n\nstructure Uprod (𝓤 : Ultrafilter I) where\n val : (i : I) → A i\n\ninstance UprodStruc : Structure.{u,u} L (Uprod A 𝓤) where\n func := fun f v => ⟨fun ι => (s ι).func f (fun i => (v i).val ι)⟩\n rel := fun r v => {ι | (s ι).rel r (fun i => (v i).val ι)} ∈ 𝓤\n\ninstance [Inhabited I] [(ι : I) → Inhabited (A ι)] : Inhabited (Uprod A 𝓤) := ⟨⟨default⟩⟩\n\n@[simp] lemma func_Uprod {k} (f : L.func k) (v : Fin k → Uprod A 𝓤) :\n func f v = ⟨fun ι => (s ι).func f (fun i => (v i).val ι)⟩ := rfl\n\n@[simp] lemma rel_Uprod {k} (r : L.rel k) (v : Fin k → Uprod A 𝓤) :\n rel r v ↔ {ι | (s ι).rel r (fun i => (v i).val ι)} ∈ 𝓤 := of_eq rfl\n\nend Structure\n\nend FirstOrder\n\nnamespace SubTerm\n\nopen FirstOrder Structure\n\nvariable (e : Fin n → Uprod A 𝓤) (ε : μ → Uprod A 𝓤)\n\nlemma val_Uprod (t : SubTerm L μ n) :\n t.val! (Uprod A 𝓤) e ε = ⟨fun ι => t.val (s ι) (fun i => (e i).val ι) (fun i => (ε i).val ι)⟩ :=\n by induction t <;> simp[*, val_func]\n\nend SubTerm\n\nnamespace FirstOrder\n\nopen Structure\n\nvariable {A} {𝓤}\n\nnamespace SubFormula\nvariable {e : Fin n → Uprod A 𝓤} {ε : μ → Uprod A 𝓤}\n\nlemma val_vecCons_val_eq {z : Uprod A 𝓤} {ι : I} :\n (z.val ι :> fun i => (e i).val ι) = (fun i => ((z :> e) i).val ι) :=\n by simp[Matrix.comp_vecCons (Uprod.val · ι), Function.comp]\n\nlemma eval_Uprod {p : SubFormula L μ n} :\n Eval! (Uprod A 𝓤) e ε p ↔ {ι | Eval (s ι) (fun i => (e i).val ι) (fun i => (ε i).val ι) p} ∈ 𝓤 := by\n induction p using rec' <;>\n simp[*, Prop.top_eq_true, Prop.bot_eq_false, eval_rel, eval_nrel, SubTerm.val_Uprod]\n case hverum => exact Filter.univ_mem\n case hnrel k r v =>\n exact Ultrafilter.compl_mem_iff_not_mem.symm\n case hand =>\n exact Filter.inter_mem_iff.symm\n case hor p q ihp ihq =>\n exact Ultrafilter.union_mem_iff.symm\n case hall p _ =>\n constructor\n · intro h\n let z : Uprod A 𝓤 := ⟨fun ι =>\n Classical.epsilon (fun z => ¬Eval (s ι) (z :> fun i => (e i).val ι) (fun i => (ε i).val ι) p)⟩\n exact Filter.mem_of_superset (h z) (by \n intro ι hι a\n have : Eval (s ι) (z.val ι :> fun i => (e i).val ι) (fun i => (ε i).val ι) p :=\n by rw [val_vecCons_val_eq]; exact hι\n by_contra hc\n have : ¬Eval! (A ι) (z.val ι :> fun i => (e i).val ι) (fun i => (ε i).val ι) p :=\n Classical.epsilon_spec (p := fun z => ¬(Eval (s ι) (z :> fun i => (e i).val ι) _ p)) ⟨a, hc⟩\n contradiction)\n · intro h x\n exact Filter.mem_of_superset h (by intro ι h; simpa [val_vecCons_val_eq] using h (x.val ι))\n case hex p _ =>\n constructor\n · rintro ⟨x, hx⟩\n exact Filter.mem_of_superset hx (by intro ι h; use x.val ι; simpa[val_vecCons_val_eq] using h)\n · intro h\n let z : Uprod A 𝓤 := ⟨fun ι =>\n Classical.epsilon (fun z => Eval (s ι) (z :> fun i => (e i).val ι) (fun i => (ε i).val ι) p)⟩\n use z\n exact Filter.mem_of_superset h (by\n intro ι; rintro ⟨x, hx⟩\n have : Eval (s ι) (z.val ι :> fun i => (e i).val ι) (fun i => (ε i).val ι) p :=\n Classical.epsilon_spec (p := fun z => Eval (s ι) (z :> fun i => (e i).val ι) _ p) ⟨x, hx⟩\n rw[val_vecCons_val_eq] at this; exact this)\n\nlemma val_Uprod {p : Formula L μ} :\n Val! (Uprod A 𝓤) ε p ↔ {ι | Val (s ι) (fun i => (ε i).val ι) p} ∈ 𝓤 :=\n by simp[Val, eval_Uprod, Matrix.empty_eq]\n\nend SubFormula\n\nlemma realize_Uprod {σ : Sentence L} :\n (Uprod A 𝓤) ⊧₁ σ ↔ {ι | Semantics.realize (self := semantics) (s ι) σ} ∈ 𝓤 :=\n by simp[realize_def, SubFormula.val_Uprod, Empty.eq_elim]\n\nvariable (A)\n\ndef SubFormula.domain (σ : Sentence L) := {ι | (A ι) ⊧₁ σ}\n\nend FirstOrder\n\nend\n\nsection\n\nnamespace FirstOrder\n\nvariable {L : Language.{u}} {T : CTheory L}\n\nabbrev FinSubTheory (T : CTheory L) := {t : Finset (Sentence L) // ↑t ⊆ T}\n\nvariable (A : FinSubTheory T → Type u) [s : (ι : FinSubTheory T) → Structure L (A ι)]\n\ninstance : Inhabited (FinSubTheory T) := ⟨∅, by simp⟩\n\nattribute [instance] Classical.propDecidable in\nlemma ultrafilter_exists (H : ∀ (ι : FinSubTheory T), (A ι) ⊧₁* (ι.val : CTheory L)) :\n ∃ 𝓤 : Ultrafilter (FinSubTheory T), Set.image (SubFormula.domain A) T ⊆ 𝓤.sets :=\n Ultrafilter.exists_ultrafilter_of_finite_inter_nonempty _ (by\n simp[Finset.subset_image_iff, SubFormula.domain]\n intro t ht\n use t; use ht\n intro σ hσ\n exact H ⟨t, ht⟩ hσ)\n\ntheorem compactness :\n Semantics.Satisfiableₛ T ↔ ∀ ι : FinSubTheory T, Semantics.Satisfiableₛ (ι.val : CTheory L) := by\n constructor\n · rintro h ⟨t, ht⟩; exact Semantics.satisfiableₛ_of_subset h ht\n · intro h\n have : ∀ ι : FinSubTheory T, ∃ (M : Type u) (_ : Inhabited M) (_ : Structure L M), M ⊧₁* (ι.val : CTheory L) := \n by intro ι; exact satisfiableₛ_iff.mp (h ι)\n choose A si s hA using this\n have : ∃ 𝓤 : Ultrafilter (FinSubTheory T), Set.image (SubFormula.domain A) T ⊆ 𝓤.sets := ultrafilter_exists A hA\n rcases this with ⟨𝓤, h𝓤⟩\n have : Structure.Uprod A 𝓤 ⊧₁* T := by intro σ hσ; exact realize_Uprod.mpr (h𝓤 $ Set.mem_image_of_mem (SubFormula.domain A) hσ)\n exact satisfiableₛ_intro (Structure.Uprod A 𝓤) this\n\nend FirstOrder\n\nend\n\n", "meta": {"author": "iehality", "repo": "lean4-logic", "sha": "ef518051931fb1ecd0b89e94240b2900cd54d95c", "save_path": "github-repos/lean/iehality-lean4-logic", "path": "github-repos/lean/iehality-lean4-logic/lean4-logic-ef518051931fb1ecd0b89e94240b2900cd54d95c/Logic/Predicate/FirstOrder/Ultraproduct.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6076631840431539, "lm_q2_score": 0.3886180267058489, "lm_q1q2_score": 0.23614886748464353}} {"text": "-- Copyright (c) 2017 Scott Morrison. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n-- Authors: Patrick Massot, Scott Morrison, Mario Carneiro\n\nimport category_theory.full_subcategory\nimport category_theory.functor_category\nimport category_theory.natural_isomorphism\nimport analysis.topology.topological_space\nimport analysis.topology.continuity\n\nopen category_theory\nopen category_theory.nat_iso\n\nuniverse u\n\nnamespace category_theory.examples\n\n/-- The category of topological spaces and continuous maps. -/\n@[reducible] def Top : Type (u+1) := bundled topological_space\n\ninstance (x : Top) : topological_space x := x.str\n\nnamespace Top\ninstance : concrete_category @continuous := ⟨@continuous_id, @continuous.comp⟩\n\n-- local attribute [class] continuous\n-- instance {R S : Top} (f : R ⟶ S) : continuous (f : R → S) := f.2\nend Top\n\nstructure open_set (X : Top.{u}) : Type u :=\n(s : set X.α)\n(is_open : topological_space.is_open X.str s)\n\nvariables {X : Top.{u}}\n\nnamespace open_set\ninstance : has_coe (open_set X) (set X.α) := { coe := λ U, U.s }\n\ninstance : has_subset (open_set X) :=\n{ subset := λ U V, U.s ⊆ V.s }\n\ninstance : preorder (open_set X) := by refine { le := (⊇), .. } ; tidy\n\ninstance open_sets : small_category (open_set X) := by apply_instance\n\ninstance : has_mem X.α (open_set X) :=\n{ mem := λ a V, a ∈ V.s }\n\ndef nbhd (x : X.α) := { U : open_set X // x ∈ U }\ndef nbhds (x : X.α) : small_category (nbhd x) := begin unfold nbhd, apply_instance end\n\n/-- `open_set.map f` gives the functor from open sets in Y to open set in X, \n given by taking preimages under f. -/\ndef map\n {X Y : Top.{u}} (f : X ⟶ Y) : open_set Y ⥤ open_set X :=\n{ obj := λ U, ⟨ f.val ⁻¹' U.s, f.property _ U.is_open ⟩,\n map' := λ U V i, ⟨ ⟨ λ a b, i.down.down b ⟩ ⟩ }.\n\n@[simp] lemma map_id_obj (X : Top.{u}) (U : open_set X) : map (𝟙 X) U = U :=\nbegin\n cases U, tidy\nend\n\n@[simp] def map_id (X : Top.{u}) : map (𝟙 X) ≅ functor.id (open_set X) := \n{ hom := { app := λ U, 𝟙 U },\n inv := { app := λ U, 𝟙 U } }\n\n-- We could make f g implicit here, but it's nice to be able to see when they are the identity (often!)\ndef map_iso {X Y : Top.{u}} (f g : X ⟶ Y) (h : f = g) : map f ≅ map g := \nnat_iso.of_components (λ U, eq_to_iso (congr_fun (congr_arg _ (congr_arg _ h)) _) ) (by obviously)\n\n@[simp] def map_iso_id {X : Top.{u}} (h) : map_iso (𝟙 X) (𝟙 X) h = iso.refl (map _) := rfl\n\nend open_set\n\nend category_theory.examples\n", "meta": {"author": "khoek", "repo": "mathlib-tidy", "sha": "866afa6ab597c47f1b72e8fe2b82b97fff5b980f", "save_path": "github-repos/lean/khoek-mathlib-tidy", "path": "github-repos/lean/khoek-mathlib-tidy/mathlib-tidy-866afa6ab597c47f1b72e8fe2b82b97fff5b980f/category_theory/examples/topological_spaces.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.45713671682749485, "lm_q1q2_score": 0.23570879540448894}} {"text": "-- Copyright (c) 2017 Scott Morrison. All rights reserved.\n-- Released under Apache 2.0 license as described in the file LICENSE.\n-- Authors: Stephen Morgan and Scott Morrison\n\nimport category_theory.graphs.category\n\n-- FIXME why do we need this here?\n@[obviously] meta def obviously_4 := tactic.tidy { tactics := extended_tidy_tactics }\n\nopen category_theory\nopen category_theory.graphs\n\nuniverses v₁ v₂ u₁ u₂\n\nnamespace category_theory.graphs\n\ndef paths (C : Type u₂) := C\n\ninstance paths_category (C : Type u₁) [graph.{v₁} C] : category.{(max u₁ v₁)+1} (paths C) :=\n{ hom := λ x y : C, path x y,\n id := λ x, path.nil x,\n comp := λ _ _ _ f g, concatenate_paths f g,\n comp_id' := begin\n tidy,\n induction f, -- PROJECT think about how to automate an inductive step. When can you be sure it's a good idea?\n obviously,\n end,\n assoc' := begin\n tidy,\n induction f,\n obviously,\n end }.\n\ninstance paths_small_category (C : Type u₁) [graph.{u₁ u₁} C] : small_category (paths C) := graphs.paths_category C\n\nvariables {C : Type u₂} [𝒞 : category.{v₂} C] {G : Type u₁} [𝒢 : graph.{v₁} G]\ninclude 𝒢 𝒞\n\n@[simp] def path_to_morphism\n (H : graph_hom G C)\n : Π {X Y : G}, path X Y → ((H.onVertices X) ⟶ (H.onVertices Y))\n| ._ ._ (path.nil Z) := 𝟙 (H.onVertices Z)\n| ._ ._ (@path.cons ._ _ _ _ _ e p) := (H.onEdges e) ≫ (path_to_morphism p)\n\n@[simp] lemma path_to_morphism.comp (H : graph_hom G C) {X Y Z : paths G} (f : X ⟶ Y) (g : Y ⟶ Z) : path_to_morphism H (f ≫ g) = path_to_morphism H f ≫ path_to_morphism H g :=\nbegin\n induction f,\n obviously,\nend\n\nend category_theory.graphs\n\nnamespace category_theory.functor\n\nopen category_theory.graphs\n\nvariables {C : Type u₂} [𝒞 : category.{v₂} C] {G : Type u₁} [𝒢 : graph.{v₁} G]\ninclude 𝒢 𝒞\n\n-- PROJECT obtain this as the left adjoint to the forgetful functor.\n@[simp] def of_graph_hom (H : graph_hom G C) : (paths G) ⥤ C :=\n{ obj := λ X, (H.onVertices X),\n map := λ _ _ f, (path_to_morphism H f) }\n\nend category_theory.functor", "meta": {"author": "semorrison", "repo": "lean-category-theory", "sha": "a27b4ae5eac978e9188d2e867c3d11d9a5b87a9e", "save_path": "github-repos/lean/semorrison-lean-category-theory", "path": "github-repos/lean/semorrison-lean-category-theory/lean-category-theory-a27b4ae5eac978e9188d2e867c3d11d9a5b87a9e/src/category_theory/path_category.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4532618480153861, "lm_q1q2_score": 0.23547919447140206}} {"text": "import Duper.MClause\nimport Duper.RuleM\nimport Duper.Simp\nimport Duper.Util.ProofReconstruction\n\n-- LoobHoist BoolHoist\n-- C\n-- -----------------------------\n-- C<⊤> ∨ u = ⊥ C<⊥> ∨ u = ⊤\n--\n-- where u is of type Prop, but neither ⊥ nor ⊤, and u is not at the top level of a positive literal.\n\nnamespace Duper\nopen Lean\nopen RuleM\nopen Meta\nopen SimpResult\n\ninitialize Lean.registerTraceClass `Rule.identBoolHoist\n\ntheorem loob_hoist_proof (f : Prop → Prop) (e : Prop) (H : f e) : f True ∨ e = False :=\n @Classical.byCases e _\n (fun p => have h : e = True := by simp [p];\n Or.inl (h ▸ H))\n (fun np => by simp [np])\n\ntheorem bool_hoist_proof (f : Prop → Prop) (e : Prop) (H : f e) : f False ∨ e = True :=\n @Classical.byCases e _\n (fun p => by simp [p])\n (fun np => have h : e = False := by simp [np];\n Or.inl (h ▸ H))\n\ndef mkBoolHoistProof (pos : ClausePos) (sgn : Bool) (premises : List Expr)\n (parents : List ProofParent) (transferExprs : Array Expr) (c : Clause) : MetaM Expr :=\n Meta.forallTelescope c.toForallExpr fun xs body => do\n let cLits := c.lits.map (fun l => l.map (fun e => e.instantiateRev xs))\n let (parentsLits, appliedPremises, transferExprs) ← instantiatePremises parents premises xs transferExprs\n let parentLits := parentsLits[0]!\n let appliedPremise := appliedPremises[0]!\n\n let i := pos.lit\n let ⟨s, p⟩ := pos.toLitPos\n\n let mut caseProofs := Array.mkEmpty parentLits.size\n for j in [:parentLits.size] do\n let lit := parentLits[j]!\n if j == i then\n let lp : LitPos := ⟨s, p⟩\n let f ← Meta.withLocalDeclD `h (.sort .zero) fun h => do\n let lit' ← lit.replaceAtPos! lp h\n let f := lit'.toExpr\n Meta.mkLambdaFVars #[h] f\n let e ← lit.getAtPos! lp\n let pr ← Meta.withLocalDeclD `h lit.toExpr fun h => do\n let mut pr := h\n if sgn then\n pr ← Meta.mkAppM ``loob_hoist_proof #[f, e, h]\n else\n pr ← Meta.mkAppM ``bool_hoist_proof #[f, e, h]\n Meta.mkLambdaFVars #[h] $ ← orSubclause (cLits.map Lit.toExpr) 2 pr\n caseProofs := caseProofs.push pr\n else\n -- need proof of `L_j → L_1 ∨ ... ∨ L_n`\n let pr ← Meta.withLocalDeclD `h lit.toExpr fun h => do\n let idx := if j ≥ i then j - 1 else j\n Meta.mkLambdaFVars #[h] $ ← orIntro (cLits.map Lit.toExpr) idx h\n caseProofs := caseProofs.push pr\n \n let r ← orCases (parentLits.map Lit.toExpr) caseProofs\n Meta.mkLambdaFVars xs $ mkApp r appliedPremise\n\ndef identBoolHoistAtExpr (e : Expr) (pos : ClausePos) (c : MClause) : RuleM (Option (Array (Clause × Proof))) :=\n withoutModifyingMCtx do\n let ty ← inferType e\n if ty == .sort .zero then\n let l := pos.lit\n let ⟨s, p⟩ := pos.toLitPos\n trace[Rule.identBoolHoist] m!\"Inspecting position {pos} in clause {c.lits.map Lit.toExpr}\"\n let is_true := e == (mkConst ``True)\n let is_false := e == (mkConst ``False)\n let is_top_positive := p.size == 0 ∧ c.lits[l]!.sign\n if is_true ∨ is_false ∨ is_top_positive then\n return none\n else\n trace[Rule.identBoolHoist] m!\"BoolHoist at literal {l}, side {s}, position {p} in clause {c.lits.map Lit.toExpr}\"\n let litl := c.lits[l]!\n let c_erased := c.eraseLit l\n let nc := c_erased.appendLits\n #[← litl.replaceAtPos! ⟨s, p⟩ (mkConst ``True), Lit.fromSingleExpr e false]\n trace[Rule.identBoolHoist] s!\"New Clause: {nc.lits.map Lit.toExpr}\"\n let cp1 ← yieldClause nc \"identity loobHoist\" (some (mkBoolHoistProof pos true))\n let nc := c_erased.appendLits\n #[← litl.replaceAtPos! ⟨s, p⟩ (mkConst ``False), Lit.fromSingleExpr e true]\n trace[Rule.identBoolHoist] s!\"New Clause: {nc.lits.map Lit.toExpr}\"\n let cp2 ← yieldClause nc \"identity boolHoist\" (some (mkBoolHoistProof pos false))\n return some #[cp1, cp2]\n else\n return none\n\ndef identBoolHoist : MSimpRule := fun c => do\n let c ← loadClause c\n let fold_fn := fun acc e pos => do\n match acc with\n | some res => return some res\n | none => identBoolHoistAtExpr e pos c\n c.foldGreenM fold_fn none", "meta": {"author": "leanprover-community", "repo": "duper", "sha": "96b8f8383363e800976b0fa99830c1b5e8c19b09", "save_path": "github-repos/lean/leanprover-community-duper", "path": "github-repos/lean/leanprover-community-duper/duper-96b8f8383363e800976b0fa99830c1b5e8c19b09/Duper/Rules/IdentBoolHoist.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5888891451980403, "lm_q2_score": 0.399811640739795, "lm_q1q2_score": 0.23544473535548385}} {"text": "import for_mathlib.derived_functor\nimport category_theory.abelian.left_derived\n\nuniverses w v u\n\nnoncomputable theory\n\nnamespace category_theory.abelian.functor\n\nopen category_theory category_theory.functor category_theory.limits\nopen category_theory.functor.left_derived\n\nvariables {C : Type u} {D : Type u} [category.{w} C] [category.{w} D] [enough_projectives C]\nvariables (F : C ⥤ D) {A₁ A₂ A₃ X : C} {f : A₁ ⟶ A₂} {g : A₂ ⟶ A₃}\nvariables [abelian C] [abelian D] [additive F] [preserves_finite_colimits F]\n\nsection les\n\ndef δ₀ (A : short_exact_sequence C) := δ F 0 A ≫ (left_derived_zero_iso_self F).hom.app A.1\n\nlemma seven_term_exact_seq (A : short_exact_sequence C) :\n exact_seq D [\n (F.left_derived 1).map A.f, (F.left_derived 1).map A.g,\n δ₀ F A,\n F.map A.f, F.map A.g, (0 : F.obj A.3 ⟶ F.obj A.3)] :=\nbegin\n refine exact_seq.cons _ _ (exact_of_short_exact _ _ _) _ (exact_seq.cons _ _ _ _ _),\n { refine preadditive.exact_of_iso_of_exact' ((F.left_derived 1).map A.g) (δ F 0 A) _ _\n (iso.refl _) (iso.refl _) ((left_derived_zero_iso_self F).app A.1) (by simp) _ _,\n { dsimp [δ₀], rw [category.id_comp] },\n { exact (exact_iff_exact_seq _ _).2 ((six_term_exact_seq F 0 A).extract 1 2) } },\n refine exact_seq.cons _ _ _ _ _,\n { refine preadditive.exact_of_iso_of_exact' (δ F 0 A) ((F.left_derived 0).map A.f) _ _\n (iso.refl _) ((left_derived_zero_iso_self F).app A.1) ((left_derived_zero_iso_self F).app A.2)\n _ (by simp) _,\n { dsimp [δ₀], rw [category.id_comp] },\n { exact (exact_iff_exact_seq _ _).2 ((six_term_exact_seq F 0 A).extract 2 2) } },\n apply exact_seq.cons,\n { exact preserves_exact_of_preserves_finite_colimits_of_epi _ A.exact' },\n { rw [← exact_iff_exact_seq],\n exact ((abelian.tfae_epi (F.obj A.3) (F.map A.g)).out 0 2).1 infer_instance, }\nend\n\nend les\n\nend category_theory.abelian.functor\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/derived_functor_zero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.611381973294151, "lm_q2_score": 0.3849121444839335, "lm_q1q2_score": 0.23532834643947062}} {"text": "/-\nCopyright (c) 2021 Andrew Yang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Andrew Yang\n-/\nimport algebraic_geometry.AffineScheme\nimport ring_theory.nilpotent\nimport topology.sheaves.sheaf_condition.sites\nimport category_theory.limits.constructions.binary_products\nimport algebra.category.CommRing.constructions\nimport ring_theory.integral_domain\nimport ring_theory.local_properties\n\n/-!\n# Basic properties of schemes\n\nWe provide some basic properties of schemes\n\n## Main definition\n* `algebraic_geometry.is_integral`: A scheme is integral if it is nontrivial and all nontrivial\n components of the structure sheaf are integral domains.\n* `algebraic_geometry.is_reduced`: A scheme is reduced if all the components of the structure sheaf\n is reduced.\n-/\n\nopen topological_space opposite category_theory category_theory.limits Top\n\nnamespace algebraic_geometry\n\nvariable (X : Scheme)\n\ninstance : t0_space X.carrier :=\nbegin\n rw t0_space_iff_distinguishable,\n intros x y h h',\n obtain ⟨U, R, ⟨e⟩⟩ := X.local_affine x,\n have hy := (h' _ U.1.2).mp U.2,\n erw ← subtype_indistinguishable_iff (⟨x, U.2⟩ : U.1.1) (⟨y, hy⟩ : U.1.1) at h',\n let e' : U.1 ≃ₜ prime_spectrum R :=\n homeo_of_iso ((LocallyRingedSpace.forget_to_SheafedSpace ⋙ SheafedSpace.forget _).map_iso e),\n have := t0_space_of_injective_of_continuous e'.injective e'.continuous,\n rw t0_space_iff_distinguishable at this,\n exact this ⟨x, U.2⟩ ⟨y, hy⟩ (by simpa using h) h'\nend\n\ninstance : quasi_sober X.carrier :=\nbegin\n apply_with (quasi_sober_of_open_cover\n (set.range (λ x, set.range $ (X.affine_cover.map x).1.base)))\n { instances := ff },\n { rintro ⟨_,i,rfl⟩, exact (X.affine_cover.is_open i).base_open.open_range },\n { rintro ⟨_,i,rfl⟩,\n exact @@open_embedding.quasi_sober _ _ _\n (homeomorph.of_embedding _ (X.affine_cover.is_open i).base_open.to_embedding)\n .symm.open_embedding prime_spectrum.quasi_sober },\n { rw [set.top_eq_univ, set.sUnion_range, set.eq_univ_iff_forall],\n intro x, exact ⟨_, ⟨_, rfl⟩, X.affine_cover.covers x⟩ }\nend\n\n/-- A scheme `X` is reduced if all `𝒪ₓ(U)` are reduced. -/\nclass is_reduced : Prop :=\n(component_reduced : ∀ U, _root_.is_reduced (X.presheaf.obj (op U)) . tactic.apply_instance)\n\nattribute [instance] is_reduced.component_reduced\n\nlemma is_reduced_of_stalk_is_reduced [∀ x : X.carrier, _root_.is_reduced (X.presheaf.stalk x)] :\n is_reduced X :=\nbegin\n refine ⟨λ U, ⟨λ s hs, _⟩⟩,\n apply presheaf.section_ext X.sheaf U s 0,\n intro x,\n rw ring_hom.map_zero,\n change X.presheaf.germ x s = 0,\n exact (hs.map _).eq_zero\nend\n\ninstance stalk_is_reduced_of_reduced [is_reduced X] (x : X.carrier) :\n _root_.is_reduced (X.presheaf.stalk x) :=\nbegin\n constructor,\n rintros g ⟨n, e⟩,\n obtain ⟨U, hxU, s, rfl⟩ := X.presheaf.germ_exist x g,\n rw [← map_pow, ← map_zero (X.presheaf.germ ⟨x, hxU⟩)] at e,\n obtain ⟨V, hxV, iU, iV, e'⟩ := X.presheaf.germ_eq x hxU hxU _ 0 e,\n rw [map_pow, map_zero] at e',\n replace e' := (is_nilpotent.mk _ _ e').eq_zero,\n erw ← concrete_category.congr_hom (X.presheaf.germ_res iU ⟨x, hxV⟩) s,\n rw [comp_apply, e', map_zero]\nend\n\nlemma is_reduced_of_open_immersion {X Y : Scheme} (f : X ⟶ Y) [H : is_open_immersion f]\n [is_reduced Y] : is_reduced X :=\nbegin\n constructor,\n intro U,\n have : U = (opens.map f.1.base).obj (H.base_open.is_open_map.functor.obj U),\n { ext1, exact (set.preimage_image_eq _ H.base_open.inj).symm },\n rw this,\n exact is_reduced_of_injective (inv $ f.1.c.app (op $ H.base_open.is_open_map.functor.obj U))\n (as_iso $ f.1.c.app (op $ H.base_open.is_open_map.functor.obj U) : Y.presheaf.obj _ ≅ _).symm\n .CommRing_iso_to_ring_equiv.injective\nend\n\ninstance {R : CommRing} [H : _root_.is_reduced R] : is_reduced (Scheme.Spec.obj $ op R) :=\nbegin\n apply_with is_reduced_of_stalk_is_reduced { instances := ff },\n intro x, dsimp,\n haveI : _root_.is_reduced (CommRing.of $ localization.at_prime (prime_spectrum.as_ideal x)),\n { dsimp, apply_instance },\n exact is_reduced_of_injective (structure_sheaf.stalk_iso R x).hom\n (structure_sheaf.stalk_iso R x).CommRing_iso_to_ring_equiv.injective,\nend\n\nlemma affine_is_reduced_iff (R : CommRing) :\n is_reduced (Scheme.Spec.obj $ op R) ↔ _root_.is_reduced R :=\nbegin\n refine ⟨_, λ h, by exactI infer_instance⟩,\n intro h,\n resetI,\n haveI : _root_.is_reduced (LocallyRingedSpace.Γ.obj (op $ Spec.to_LocallyRingedSpace.obj $ op R)),\n { change _root_.is_reduced ((Scheme.Spec.obj $ op R).presheaf.obj $ op ⊤), apply_instance },\n exact is_reduced_of_injective (to_Spec_Γ R)\n ((as_iso $ to_Spec_Γ R).CommRing_iso_to_ring_equiv.injective)\nend\n\nlemma is_reduced_of_is_affine_is_reduced [is_affine X]\n [h : _root_.is_reduced (X.presheaf.obj (op ⊤))] : is_reduced X :=\nbegin\n haveI : is_reduced (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))),\n { rw affine_is_reduced_iff, exact h },\n exact is_reduced_of_open_immersion X.iso_Spec.hom,\nend\n\n/-- To show that a statement `P` holds for all open subsets of all schemes, it suffices to show that\n1. In any scheme `X`, if `P` holds for an open cover of `U`, then `P` holds for `U`.\n2. For an open immerison `f : X ⟶ Y`, if `P` holds for the entire space of `X`, then `P` holds for\n the image of `f`.\n3. `P` holds for the entire space of an affine scheme.\n-/\nlemma reduce_to_affine_global (P : ∀ (X : Scheme) (U : opens X.carrier), Prop)\n (h₁ : ∀ (X : Scheme) (U : opens X.carrier),\n (∀ (x : U), ∃ {V} (h : x.1 ∈ V) (i : V ⟶ U), P X V) → P X U)\n (h₂ : ∀ {X Y} (f : X ⟶ Y) [hf : is_open_immersion f], ∃ {U : set X.carrier} {V : set Y.carrier}\n (hU : U = ⊤) (hV : V = set.range f.1.base), P X ⟨U, hU.symm ▸ is_open_univ⟩ →\n P Y ⟨V, hV.symm ▸ hf.base_open.open_range⟩)\n (h₃ : ∀ (R : CommRing), P (Scheme.Spec.obj $ op R) ⊤) :\n ∀ (X : Scheme) (U : opens X.carrier), P X U :=\nbegin\n intros X U,\n apply h₁,\n intro x,\n obtain ⟨_,⟨j,rfl⟩,hx,i⟩ := X.affine_basis_cover_is_basis.exists_subset_of_mem_open x.prop U.2,\n let U' : opens _ := ⟨_, (X.affine_basis_cover.is_open j).base_open.open_range⟩,\n let i' : U' ⟶ U :=\n hom_of_le i,\n refine ⟨U', hx, i', _⟩,\n obtain ⟨_,_,rfl,rfl,h₂'⟩ := h₂ (X.affine_basis_cover.map j),\n apply h₂',\n apply h₃\nend\n.\n\n\nlemma eq_zero_of_basic_open_empty {X : Scheme} [hX : is_reduced X] {U : opens X.carrier}\n (s : X.presheaf.obj (op U)) (hs : X.basic_open s = ∅) :\n s = 0 :=\nbegin\n apply Top.presheaf.section_ext X.sheaf U,\n simp_rw ring_hom.map_zero,\n unfreezingI { revert X U hX s },\n refine reduce_to_affine_global _ _ _ _,\n { intros X U hx hX s hs x,\n obtain ⟨V, hx, i, H⟩ := hx x,\n unfreezingI { specialize H (X.presheaf.map i.op s) },\n erw Scheme.basic_open_res at H,\n rw [hs, ← subtype.coe_injective.eq_iff, opens.empty_eq, opens.inter_eq, inf_bot_eq] at H,\n specialize H rfl ⟨x, hx⟩,\n erw Top.presheaf.germ_res_apply at H,\n exact H },\n { rintros X Y f hf,\n have e : (f.val.base) ⁻¹' set.range ⇑(f.val.base) = ⊤,\n { rw [← set.image_univ, set.preimage_image_eq _ hf.base_open.inj, set.top_eq_univ] },\n refine ⟨_, _, e, rfl, _⟩,\n rintros H hX s hs ⟨_, x, rfl⟩,\n unfreezingI { haveI := is_reduced_of_open_immersion f },\n specialize H (f.1.c.app _ s) _ ⟨x, by { change x ∈ (f.val.base) ⁻¹' _, rw e, trivial }⟩,\n { rw [← Scheme.preimage_basic_open, hs], ext1, simp [opens.map] },\n { erw ← PresheafedSpace.stalk_map_germ_apply f.1 ⟨_,_⟩ ⟨x,_⟩ at H,\n apply_fun (inv $ PresheafedSpace.stalk_map f.val x) at H,\n erw [category_theory.is_iso.hom_inv_id_apply, map_zero] at H,\n exact H } },\n { intros R hX s hs x,\n erw [basic_open_eq_of_affine', prime_spectrum.basic_open_eq_bot_iff] at hs,\n replace hs := (hs.map (Spec_Γ_identity.app R).inv),\n -- what the hell?!\n replace hs := @is_nilpotent.eq_zero _ _ _ _ (show _, from _) hs,\n rw coe_hom_inv_id at hs,\n rw [hs, map_zero],\n exact @@is_reduced.component_reduced hX ⊤ }\nend\n\n@[simp]\nlemma basic_open_eq_bot_iff {X : Scheme} [is_reduced X] {U : opens X.carrier}\n (s : X.presheaf.obj $ op U) :\n X.basic_open s = ⊥ ↔ s = 0 :=\nbegin\n refine ⟨eq_zero_of_basic_open_empty s, _⟩,\n rintro rfl,\n simp,\nend\n\n/-- A scheme `X` is integral if its carrier is nonempty,\nand `𝒪ₓ(U)` is an integral domain for each `U ≠ ∅`. -/\nclass is_integral : Prop :=\n(nonempty : nonempty X.carrier . tactic.apply_instance)\n(component_integral : ∀ (U : opens X.carrier) [_root_.nonempty U],\n is_domain (X.presheaf.obj (op U)) . tactic.apply_instance)\n\nattribute [instance] is_integral.component_integral is_integral.nonempty\n\ninstance [h : is_integral X] : is_domain (X.presheaf.obj (op ⊤)) :=\n@@is_integral.component_integral _ _ (by simp)\n\n@[priority 900]\ninstance is_reduced_of_is_integral [is_integral X] : is_reduced X :=\nbegin\n constructor,\n intro U,\n cases U.1.eq_empty_or_nonempty,\n { have : U = ∅ := subtype.eq h,\n haveI := CommRing.subsingleton_of_is_terminal (X.sheaf.is_terminal_of_eq_empty this),\n change _root_.is_reduced (X.sheaf.val.obj (op U)),\n apply_instance },\n { haveI : nonempty U := by simpa, apply_instance }\nend\n\ninstance is_irreducible_of_is_integral [is_integral X] : irreducible_space X.carrier :=\nbegin\n by_contradiction H,\n replace H : ¬ is_preirreducible (⊤ : set X.carrier) := λ h,\n H { to_preirreducible_space := ⟨h⟩, to_nonempty := infer_instance },\n simp_rw [is_preirreducible_iff_closed_union_closed, not_forall, not_or_distrib] at H,\n rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩,\n erw not_forall at h₂ h₃,\n simp_rw not_forall at h₂ h₃,\n haveI : nonempty (⟨Sᶜ, hS.1⟩ : opens X.carrier) := ⟨⟨_, h₂.some_spec.some_spec⟩⟩,\n haveI : nonempty (⟨Tᶜ, hT.1⟩ : opens X.carrier) := ⟨⟨_, h₃.some_spec.some_spec⟩⟩,\n haveI : nonempty (⟨Sᶜ, hS.1⟩ ⊔ ⟨Tᶜ, hT.1⟩ : opens X.carrier) :=\n ⟨⟨_, or.inl h₂.some_spec.some_spec⟩⟩,\n let e : X.presheaf.obj _ ≅ CommRing.of _ := (X.sheaf.is_product_of_disjoint ⟨_, hS.1⟩ ⟨_, hT.1⟩ _)\n .cone_point_unique_up_to_iso (CommRing.prod_fan_is_limit _ _),\n apply_with false_of_nontrivial_of_product_domain { instances := ff },\n { exact e.symm.CommRing_iso_to_ring_equiv.is_domain _ },\n { apply X.to_LocallyRingedSpace.component_nontrivial },\n { apply X.to_LocallyRingedSpace.component_nontrivial },\n { ext x,\n split,\n { rintros ⟨hS,hT⟩,\n cases h₁ (show x ∈ ⊤, by trivial),\n exacts [hS h, hT h] },\n { intro x, exact x.rec _ } }\nend\n\nlemma is_integral_of_is_irreducible_is_reduced [is_reduced X] [H : irreducible_space X.carrier] :\n is_integral X :=\nbegin\n split, refine λ U hU, ⟨λ a b e, _,\n (@@LocallyRingedSpace.component_nontrivial X.to_LocallyRingedSpace U hU).1⟩,\n simp_rw [← basic_open_eq_bot_iff, ← opens.not_nonempty_iff_eq_bot],\n by_contra' h,\n obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ := @@nonempty_preirreducible_inter _ H.1\n (X.basic_open a).2 (X.basic_open b).2\n h.1 h.2,\n replace e' := subtype.eq e',\n subst e',\n replace e := congr_arg (X.presheaf.germ x) e,\n rw [ring_hom.map_mul, ring_hom.map_zero] at e,\n refine @zero_ne_one (X.presheaf.stalk x.1) _ _ (is_unit_zero_iff.1 _),\n convert hx₁.mul hx₂,\n exact e.symm\nend\n\nlemma is_integral_iff_is_irreducible_and_is_reduced :\n is_integral X ↔ irreducible_space X.carrier ∧ is_reduced X :=\n⟨λ _, by exactI ⟨infer_instance, infer_instance⟩,\n λ ⟨_, _⟩, by exactI is_integral_of_is_irreducible_is_reduced X⟩\n\nlemma is_integral_of_open_immersion {X Y : Scheme} (f : X ⟶ Y) [H : is_open_immersion f]\n [is_integral Y] [nonempty X.carrier] : is_integral X :=\nbegin\n constructor,\n intros U hU,\n have : U = (opens.map f.1.base).obj (H.base_open.is_open_map.functor.obj U),\n { ext1, exact (set.preimage_image_eq _ H.base_open.inj).symm },\n rw this,\n haveI : is_domain (Y.presheaf.obj (op (H.base_open.is_open_map.functor.obj U))),\n { apply_with is_integral.component_integral { instances := ff },\n apply_instance,\n refine ⟨⟨_, _, hU.some.prop, rfl⟩⟩ },\n exact (as_iso $ f.1.c.app (op $ H.base_open.is_open_map.functor.obj U) :\n Y.presheaf.obj _ ≅ _).symm.CommRing_iso_to_ring_equiv.is_domain _\nend\n\ninstance {R : CommRing} [H : is_domain R] : is_integral (Scheme.Spec.obj $ op R) :=\nbegin\n apply_with is_integral_of_is_irreducible_is_reduced { instances := ff },\n { apply_instance },\n { dsimp [Spec.Top_obj],\n apply_instance },\nend\n\nlemma affine_is_integral_iff (R : CommRing) :\n is_integral (Scheme.Spec.obj $ op R) ↔ is_domain R :=\n⟨λ h, by exactI ring_equiv.is_domain ((Scheme.Spec.obj $ op R).presheaf.obj _)\n (as_iso $ to_Spec_Γ R).CommRing_iso_to_ring_equiv, λ h, by exactI infer_instance⟩\n\nlemma is_integral_of_is_affine_is_domain [is_affine X] [nonempty X.carrier]\n [h : is_domain (X.presheaf.obj (op ⊤))] : is_integral X :=\nbegin\n haveI : is_integral (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))),\n { rw affine_is_integral_iff, exact h },\n exact is_integral_of_open_immersion X.iso_Spec.hom,\nend\n\nlemma map_injective_of_is_integral [is_integral X] {U V : opens X.carrier} (i : U ⟶ V)\n [H : nonempty U] :\n function.injective (X.presheaf.map i.op) :=\nbegin\n rw ring_hom.injective_iff,\n intros x hx,\n rw ← basic_open_eq_bot_iff at ⊢ hx,\n rw Scheme.basic_open_res at hx,\n revert hx,\n contrapose!,\n simp_rw [← opens.not_nonempty_iff_eq_bot, not_not],\n apply nonempty_preirreducible_inter U.prop (RingedSpace.basic_open _ _).prop,\n simpa using H\nend\n\nend algebraic_geometry\n", "meta": {"author": "Mel-TunaRoll", "repo": "Lean-Mordell-Weil-Mel-Branch", "sha": "4db36f86423976aacd2c2968c4e45787fcd86b97", "save_path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch", "path": "github-repos/lean/Mel-TunaRoll-Lean-Mordell-Weil-Mel-Branch/Lean-Mordell-Weil-Mel-Branch-4db36f86423976aacd2c2968c4e45787fcd86b97/src/algebraic_geometry/properties.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.4493926344647597, "lm_q1q2_score": 0.23522124954095844}} {"text": "import analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n -- Let $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$.\n assume A : set (euclidean_space ℝ (fin n)),\n assume hA : is_open_cover A,\n -- We now construct a locally finite open refinement $\\mathcal{C}$ of $\\mathcal{A}$ that covers $\\mathbb{R}^n$.\n have h1 : ∃ C : set (euclidean_space ℝ (fin n)), is_open_cover C ∧ is_locally_finite C ∧ is_refinement A C, from by auto [euclidean_space.is_open_ball, euclidean_space.is_open_ball_iff, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_mem_nhds, euclidean_space.is_open_ball_iff_\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],\n -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],\n -- Hence $(A ∩ B) ∈ 𝒫 S$, by power set definition\n show (A ∩ B) ∈ 𝒫 S, from by auto [set.mem_powerset],\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n -- expand the power\n calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]\n -- distributive property of multiplication over addition gives:\n ... = x*(x+y) + y*(x+y) : by auto [add_mul]\n -- applying the above property further gives:\n ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]\n -- rearranging the terms using commutativity and adding gives:\n ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n -- Group has Latin Square Property\n have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],\n have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹], \n\n -- Setting $b = a$, this becomes:\n have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],\n have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],\n\n -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],\n have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],\n\n show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],\nend\n\n/--`theorem`\n\\mathbb{R}^n is paracompact\n$\\mathbb{R}^n$ is paracompact for all $n$.\n`proof`\nLet $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$. We now construct a locally finite open refinement $\\mathcal{C}$ of $\\mathcal{A}$ that covers $\\mathbb{R}^n$. First, we define a collection of pen balls. Let $B_0 = \\phi$, and for each $n \\in \\mathbb{N}$, let $B_m$ denote the ball of radius $m$\ncentered at 0. Given $m$, set $\\Bar{B_m}$ is compact in $\\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\\mathcal{A}$ that cover $\\Bar{B_m}$ and intersect each one with the open set $\\mathbb{R}^n \\setminus \\Bar{B_{m - 1}}$, and let $\\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\\mathcal{A}$). So $\\mathcal{C} = \\bigcup_{m = 0}^{\\infty} \\mathcal{C}_m$ is an open refinement of $\\mathcal{A}$. Note that $\\mathcal{C}$ covers $\\mathbb{R}^n$ since for any $x \\in \\mathbb{R}^n$, there is a smallest $m \\in \\mathbb{N}$ such that $x \\in \\Bar{B_{m}}$ (namely, some $m$ where $\\rVert x \\lVert \\leq m \\leq \\rVert x \\lVert + 1$), and so $x$ is an element of $\\mathcal{C}_m$. Now collection $\\mathcal{C}$ is locally finite since for given $x \\in \\mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\\mathcal{C}$, namely those elements in collection $\\mathcal{C}_1 \\cup \\mathcal{C}_2 \\cup \\cdots \\mathcal{C}_m$. So $\\mathcal{C}$ is a locally finite open refinement of $\\mathcal{A}$ that covers $\\mathbb{R}^n$, hence $\\mathbb{R}^n$ is paracompact.\n\nQED\n-/\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_auto_with_comments-Natural-Language-Proof-Translation/Correct_statement-lean_proof_auto_with_comments-3_few_shot_temperature_0_max_tokens_2000_n_1/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.3886180267058489, "lm_q1q2_score": 0.23469879748742672}} {"text": "\nimport unitb.code.syntax\nimport unitb.code.instances\nimport unitb.code.rules\nimport unitb.code.lemmas\nimport unitb.refinement.superposition\nimport unitb.category.transformer\n\nimport util.logic\nimport util.meta.tactic\nimport util.predicate\nimport util.data.subtype\n\nimport temporal_logic\n\nnamespace code.semantics\n\nsection\nopen code predicate temporal nondet\n\nparameters (σ : Type)\n@[reducible]\nprivate def pred := pred' σ\nparameters {p : nondet.program σ}\nparameters {term : pred}\nparameters {c : code p.lbl p.first term}\n\nparameter Hterm : ∀ ae : p.lbl, term ⟹ -p.coarse_sch_of ae\n\nstructure state :=\n (pc : option (current c))\n (intl : σ)\n (assertion : assert_of pc intl)\n\nparameter {σ}\nparameter Hcorr : ∀ pc, state_correctness p c pc\n\n-- include Hcorr\n\nsection event\n\nparameter (e : p.lbl)\nparameter (s : state)\nparameter (h₀ : selects s.pc e)\nparameter (h₁ : true)\n\nsection implicit\n\ninclude h₁\n\ntheorem evt_guard\n: p.guard e s.intl :=\n(Hcorr s.pc).enabled e h₀ s.intl s.assertion\n\ntheorem evt_coarse_sch\n: p.coarse_sch_of e s.intl :=\nevt_guard.left\n\ntheorem evt_fine_sch\n: p.fine_sch_of e s.intl :=\nevt_guard.right\n\nend implicit\n\ndef machine.run_event (s' : state) : Prop :=\n(p.event $ some e).step s.intl evt_coarse_sch evt_fine_sch s'.intl\n\nend event\n\ndef machine.step\n (e : current c)\n (s : state)\n (h : some e = s.pc)\n (s' : state) : Prop :=\n s'.pc = next s.intl s.pc\n∧ match action_of e with\n | (sum.inr ⟨l,hl⟩) :=\n have h : selects (s.pc) l,\n by { simp [h] at hl, apply hl },\n machine.run_event l s h trivial s'\n | (sum.inl _) := s'.intl = s.intl\n end\n\ndef machine.step_fis\n (e : current c)\n (s : state)\n (h : some e = s.pc)\n: ∃ (s' : state), machine.step e s h s' :=\nbegin\n destruct action_of e\n ; intros l Hl,\n { have Hss' : assert_of (next s.intl s.pc) s.intl,\n { rw assert_of_next,\n cases l with l H, cases H with P H,\n rw ← h,\n cases classical.em (condition (some e) P s.intl) with Hc Hnc,\n { apply (Hcorr $ some e).cond_true _ _ _ Hc,\n rw h,\n apply s.assertion, },\n { apply (Hcorr $ some e).cond_false _ _ _ Hnc,\n rw h,\n apply s.assertion } },\n let ss' := state.mk (next s.intl s.pc) s.intl Hss',\n existsi ss',\n unfold machine.step,\n split,\n { refl },\n { rw Hl, unfold machine.step._match_1 machine.run_event } },\n { cases l with l hl,\n rw h at hl,\n have CS := evt_coarse_sch Hcorr l s hl trivial,\n have FS := evt_fine_sch Hcorr l s hl trivial,\n cases (p.event l).fis s.intl CS FS with s' H,\n have Hss' : assert_of (next s.intl s.pc) s',\n { rw [assert_of_next],\n apply (Hcorr _).correct _ hl s.intl _ _ ⟨CS,FS,H⟩,\n apply s.assertion },\n let ss' := state.mk (next s.intl s.pc) s' Hss',\n existsi ss',\n unfold machine.step,\n split,\n { refl },\n { rw Hl, unfold machine.step._match_1 machine.run_event,\n apply H } }\nend\n\ndef machine.event (cur : current c) : nondet.event state :=\n { coarse_sch := λ s, some cur = s.pc\n , fine_sch := True\n , step := λ s hc _ s', machine.step cur s hc s'\n , fis := λ s hc _, machine.step_fis cur s hc }\n\ndef mch_of : nondet.program state :=\n { lbl := current c\n , lbl_is_sched := by apply_instance\n , first := λ ⟨s₀,s₁,_⟩, s₀ = first c ∧ p.first s₁\n , first_fis :=\n begin cases p.first_fis with s Hs,\n have Hss : assert_of (first c) s,\n { rw assert_of_first, apply Hs },\n let ss := state.mk (first c) s Hss,\n existsi ss,\n unfold mch_of._match_1,\n exact ⟨rfl,Hs⟩\n end\n , event' := machine.event }\n\n@[simp]\nlemma coarse_sch_of_mch_of_some (e : mch_of.lbl)\n: mch_of.coarse_sch_of (some e) = (λ s : state, some e = s.pc) :=\nby { cases e ; refl }\n\nlemma event_mch_of_some (e : mch_of.lbl)\n: mch_of.event (some e) = machine.event e :=\nby { cases e ; refl }\n\n@[simp]\nlemma fine_sch_of_mch_of (e : option mch_of.lbl)\n: mch_of.fine_sch_of e = True :=\nby { cases e ; refl }\n\n@[simp]\nlemma step_of_mch_of (e : mch_of.lbl) (s : state)\n: mch_of.step_of (some e) s = (λ s', ∃ Hc : some e = s.pc, machine.step e s Hc s') :=\nbegin\n apply funext, intro s',\n dunfold code.semantics.mch_of program.step_of program.event program.event',\n dunfold code.semantics.machine.event nondet.event.step_of,\n dunfold event.coarse_sch event.fine_sch event.step,\n apply iff.to_eq,\n apply exists_congr ,\n intro Hc ,\n dsimp [True_eq_true] ,\n rw exists_true,\nend\n\nlemma step_event'_mch_of_imp_pc_eq_next (e : mch_of.lbl) (s s' : state)\n (Hc : mch_of.coarse_sch_of (some e) s)\n (Hf : mch_of.fine_sch_of (some e) s)\n (H : (mch_of.event' e).step s Hc Hf s')\n: s'.pc = next s.intl s.pc :=\nH.left\n\nopen superposition\n\ndef rel (l : option mch_of.lbl) : option p.lbl → Prop\n | (some e) := selects l e\n | none := is_control l ∨ l = none\n\nlemma ref_sim (ec : option mch_of.lbl)\n: ⟦mch_of.step_of ec⟧ ⟹\n ∃∃ (ea : {ea // rel ec ea}), ⟦p.step_of (ea.val) on state.intl⟧ :=\nbegin\n rw exists_action,\n apply action_entails_action,\n intros s s' H,\n cases ec with pc,\n case none\n { let x : {ea // rel Hcorr none ea},\n { existsi none, unfold rel is_control, right, refl },\n existsi x, unfold function.on_fun,\n unfold mch_of nondet.program.step_of nondet.program.event\n nondet.skip nondet.event.step_of\n nondet.event.fine_sch nondet.event.coarse_sch\n nondet.event.step at H,\n unfold nondet.program.step_of nondet.program.event\n nondet.skip nondet.event.step_of\n nondet.event.fine_sch nondet.event.coarse_sch\n nondet.event.step,\n apply exists_imp_exists' (assume _, trivial) _ H, intro,\n apply exists_imp_exists' (assume _, trivial) _, intros _,\n simp, intro, subst s, },\n case some\n { destruct action_of pc,\n case sum.inl\n { intros c Hact,\n cases c with c Hc,\n cases Hc with P Hc,\n let x : {ea // rel Hcorr (some pc) ea},\n { existsi none, unfold rel is_control, left, apply P },\n existsi x,\n unfold function.on_fun nondet.program.step_of nondet.program.event\n nondet.event.step_of,\n unfold nondet.program.step_of nondet.program.event\n nondet.event.step_of at H,\n apply exists_imp_exists' (assume _, trivial) _ H, intro,\n apply exists_imp_exists' (assume _, trivial) _, intros _,\n intros H',\n change _ = _,\n dunfold code.semantics.mch_of nondet.program.event'\n code.semantics.machine.event\n nondet.event.step\n code.semantics.machine.step at H',\n rw Hact at H',\n symmetry, apply H'.right, },\n case sum.inr\n { intros e Hact,\n cases e with e He,\n let x : {ea // rel Hcorr (some pc) ea},\n { existsi (some e), apply He },\n existsi x, unfold function.on_fun,\n dunfold code.semantics.mch_of nondet.program.step_of nondet.program.event\n nondet.program.event' code.semantics.machine.event nondet.event.step_of\n nondet.event.coarse_sch nondet.event.fine_sch\n nondet.event.step at H,\n cases H with Hc H, cases H with Hf H,\n dunfold code.semantics.machine.step at H,\n rw Hact at H, unfold machine.step._match_1 machine.run_event at H,\n rw Hc at He,\n have Hen := (Hcorr s.pc).enabled e He _ s.assertion,\n exact ⟨Hen.left,Hen.right,H.right⟩, }, },\nend\n\nsection ref_resched\n\nparameter ea : option p.lbl\n\nvariable ec : { ec // rel ec ea }\n\nsection leads_to\n\nopen unitb\nparameter pc : current c\nparameters p' q' : pred\nparameter c' : code p.lbl p' q'\nparameter H : subtree c' c\nparameter e : p.lbl\n\n@[reducible]\ndef lt_sched := except (λ s : state, selects s.pc e) (leads_to mch_of)\n\n@[trans]\ndef lt_sched_trans\n {α} (β) {γ : pred' state}\n (h₀ : lt_sched α β)\n (h₁ : lt_sched β γ)\n: lt_sched α γ :=\nh₁ <<< h₀\n\nlocal infix ` ↦. `:60 := lt_sched\n\nlemma evt_leads_to_aux\n: (λ s : state, within H s.pc)\n ↦.\n (λ s : state, exits H s.pc) :=\nbegin\n induction c',\n case code.skip\n { apply lifted_pred.imp,\n intro s,\n apply not_within_skip },\n case code.action\n { apply except_lift,\n apply @ensure_rule _ (mch_of Hcorr) _ _ (some (counter H)),\n -- EN\n { rw coarse_sch_of_mch_of_some,\n intro s, simp [not_or_iff_not_and_not,and_shunting,exits],\n intros H₀ H₁,\n apply counter_action_of_within H₀ H₁, },\n -- FLW\n { simp [fine_sch_of_mch_of],\n apply leads_to.trivial },\n -- STEP\n { intros s s' Hp Hstep,\n rw step_of_mch_of at Hstep,\n cases Hstep with Hc Hstep,\n unfold machine.step at Hstep,\n cases Hstep with Hstep₀ Hstep₁,\n rw [Hstep₀,← Hc],\n rw next_counter_action,\n unfold exits, },\n -- STABLE\n { apply unless_rule,\n intros ec s Hc Hf s' Hstep Hp,\n-- rw [not_or_iff_not_and_not,and_shunting],\n intros Hnq₀,\n right,\n unfold exits,\n have Hp := counter_action_of_within Hp Hnq₀,\n rw [← next_counter_action s.intl H, Hp],\n symmetry,\n apply Hstep.left, }, },\n case code.seq p₀ q r c₀ c₁ ih_1 ih_2 H\n { have Pright : lt_sched Hcorr e\n (λ (s : state), within H.right (s.pc))\n (λ (s : state), exits H (s.pc)),\n { simp [exits_iff_exits_right],\n apply ih_2 H.right },\n have Pleft : lt_sched Hcorr e\n (λ (s : state), within H.left (s.pc))\n (λ (s : state), exits H (s.pc)),\n { apply lt_sched_trans Hcorr e (λ (s : state), exits H.left (s.pc)),\n { apply ih_1 },\n apply antimono_left,\n { intro, apply exits_left_imp_within_right H },\n { apply Pright } },\n simp [within_left_or_within_right_iff_within_seq],\n apply disj _ Pleft Pright, },\n case code.if_then_else\n { admit },\n case code.while\n { admit },\nend\n\nend leads_to\n\nopen unitb\ninclude Hterm\n\nlemma evt_leads_to\n: (p.coarse_sch_of ea ⋀ (p.event ea).fine_sch) ∘ state.intl\n ↦\n -(p.coarse_sch_of ea ∘ state.intl)\n ⋁ ∃∃ ec : { ec // rel ec ea }, mch_of.coarse_sch_of ec.val\n in mch_of :=\nbegin\n cases ea with ea,\n { apply unitb.leads_to.imp,\n apply entails_p_or_of_entails_right,\n intros s h, simp,\n let ec : {ec // rel Hcorr ec none},\n { existsi none, apply or.inr, refl },\n existsi [ec.val,ec.property], unfold_local ec,\n simp },\n have H := (evt_leads_to_aux Hcorr _ _ c subtree.rfl ea).run,\n revert H,\n apply unitb.leads_to.monotonicity,\n { intros s q,\n apply within_rfl },\n apply p_or_entails_p_or,\n { -- type_check (term ∘ state.intl),\n -- type_check entails_trans (term ∘ state.intl),\n refine entails_trans (term ∘ state.intl) _ _,\n { intro s, simp [exits],\n intro H,\n have Hasrt := s.assertion,\n rw ← H at Hasrt,\n apply Hasrt, },\n { rw p_not_comp,\n refine comp_entails_comp _ _,\n apply Hterm }, },\n { intros s h,\n let ec : {ec // rel Hcorr ec (some ea)},\n { existsi s.pc, apply h, },\n apply p_exists_intro ec,\n revert ec, simp,\n destruct s.pc,\n { intros h, simp [h], },\n { intros ec Hec, simp [Hec], }, },\nend\n\nomit Hterm\n\n\nlemma evt_resched\n: (p.coarse_sch_of ea ⋀ p.fine_sch_of ea) ∘ state.intl ⋀ True\n ⋀ mch_of.coarse_sch_of ec\n >~>\n mch_of.fine_sch_of ec in mch_of :=\nbegin\n simp,\n apply unitb.often_imp_often.basis,\n apply unitb.leads_to.trivial,\nend\n\ninclude Hterm\n\nlemma evt_delay\n: (p.coarse_sch_of ea ⋀ (p.event ea).fine_sch) ∘ state.intl\n >~>\n -(p.coarse_sch_of ea ∘ state.intl)\n ⋁ ∃∃ ec : { ec // rel ec ea }, True ⋀ mch_of.coarse_sch_of ec.val\n in mch_of :=\nbegin\n simp,\n apply often_imp_often.basis,\n apply evt_leads_to Hterm Hcorr ea,\nend\n\nomit Hterm\n\nlemma evt_stable\n: unless_except mch_of\n (True ⋀ mch_of.coarse_sch_of ec)\n (-(p.coarse_sch_of ea ∘ state.intl))\n { e | ∃ (l : {ec // rel ec ea}), mch_of.event l = e } :=\nbegin\n apply unless_except_rule,\n intros e s Hc Hf s' Hexcp H₀ H₁ H₂,\n simp [function.comp],\n simp [mem_set_of,not_exists_iff_forall_not] at Hexcp,\n simp [program.event,mch_of,machine.event,program.coarse_sch_of] at H₁ Hc,\n cases ec with ec Hec,\n specialize Hexcp ec Hec,\n cases ec with ec,\n { right, trivial, },\n simp at H₁,\n exfalso, apply Hexcp,\n dsimp [program.event,code.semantics.mch_of,program.event,machine.event] at H₁ Hc,\n rw ← Hc at H₁,\n rw H₁,\n refl\nend\n\nlemma evt_sim\n: ⟦mch_of.step_of (ec.val)⟧\n ⟹ ⟦p.step_of ea on state.intl⟧ :=\nbegin\n apply action_entails_action,\n intros s s',\n dunfold function.on_fun,\n cases ec with ec Hec,\n cases ea,\n case some ea\n { dunfold code.semantics.rel at Hec,\n cases ec with ec,\n { cases Hec },\n { unfold_projs,\n have Hgrd : (machine.event Hcorr ec).coarse_sch s\n → (p.event' ea).guard (s.intl),\n { unfold machine.event,\n unfold nondet.event.coarse_sch, intro H,\n rw H at Hec,\n apply (Hcorr s.pc).enabled _ Hec,\n apply s.assertion },\n have Hcs : (machine.event Hcorr ec).coarse_sch s\n → (p.event' ea).coarse_sch (s.intl),\n { apply and.left ∘ Hgrd },\n rw [step_of_mch_of],\n apply exists_imp_exists' Hcs,\n intros Hcs,\n have Hfs : (p.event' ea).fine_sch (s.intl),\n { apply (Hgrd Hcs).right },\n simp [machine.step],\n destruct action_of ec,\n case sum.inr\n { intros ea' Hea, cases ea' with ea' Hea',\n simp [Hea,machine.step._match_1,machine.run_event],\n intros ea'' Hea'',\n simp [nondet.program.event,mch_of,nondet.program.event'] at *,\n existsi Hfs,\n have H := selects_and_selects_imp_eq _ Hec Hea',\n subst ea', assumption, },\n case sum.inl\n { intros pc Hea, rw Hea,\n simp [machine.step._match_1],\n intros H₀ _, rw H₀,\n cases pc with pc P, cases P with P₀ P₁,\n cases not_selects_and_is_control Hec P₀, } } },\n case none\n { cases ec with ec ;\n simp [program.event],\n { have Hcs : nondet.skip.coarse_sch s → nondet.skip.coarse_sch s.intl,\n { apply id },\n intros Hcs', subst s, },\n { unfold rel at Hec,\n cases Hec,\n case or.inl Hec\n { intros Hc Hstep,\n destruct (action_of ec),\n case sum.inr\n { intros ea Hea₀,\n cases ea with ea Hea₁,\n cases not_selects_and_is_control Hea₁ Hec },\n case sum.inl\n { intros ea Hea,\n simp [Hea,machine.step,machine.step._match_1] at Hstep,\n rw Hstep.left } },\n case or.inr Hec\n { contradiction } } }\nend\n\nlemma ref_resched\n: evt_ref_wk state.intl {ec // rel ec ea} mch_of (p.event ea)\n (λ (ec : {ec // rel ec ea}), mch_of.event (ec.val)) :=\n{ witness := λ _, True\n, resched := evt_resched\n, stable := evt_stable\n, delay := evt_delay\n, sim := evt_sim }\n\nend ref_resched\n\nlemma code_refs_machine\n: refined state.intl p mch_of :=\n{ sim_init := by { intros i, cases i, apply and.right, }\n, ref := rel\n, evt_sim := ref_sim\n, events := ref_resched }\n\nend\n\nend code.semantics\n", "meta": {"author": "unitb", "repo": "unitb-semantics", "sha": "07607ddb2ced4044af121f1fd989e058e19c3c9c", "save_path": "github-repos/lean/unitb-unitb-semantics", "path": "github-repos/lean/unitb-unitb-semantics/unitb-semantics-07607ddb2ced4044af121f1fd989e058e19c3c9c/src/unitb/code/semantics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6334102636778401, "lm_q2_score": 0.3702254064929193, "lm_q1q2_score": 0.23450457234691557}} {"text": "import condensed.Qprime_isoms\n\n.\n\nnoncomputable theory\n\nuniverses v u u₁ u₂\n\nopen category_theory category_theory.limits breen_deligne opposite\nopen bounded_homotopy_category\n\nnamespace Condensed\n\nvariables (BD : package)\nvariables (M N : Condensed.{u} Ab.{u+1}) (f : M ⟶ N)\n\nlemma homology_functor_iso_natural'\n (C₁ C₂ : cochain_complex (Profinite.{u}ᵒᵖ ⥤ Ab.{u+1}) ℤ) (g : C₁ ⟶ C₂)\n (S : Profinite.{u}ᵒᵖ) (i : ℤ) :\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj S).homology_functor_iso (complex_shape.up ℤ) i).inv.app C₁ ≫\n ((homology_functor (Profinite.{u}ᵒᵖ ⥤ Ab.{u+1}) (complex_shape.up ℤ) i).map g).app S =\n category_theory.functor.map _ g ≫\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj S).homology_functor_iso (complex_shape.up ℤ) i).inv.app C₂ :=\n((((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj S).homology_functor_iso _ i).inv.naturality g).symm\n\nlemma homology_functor_iso_natural (S : ExtrDiscᵒᵖ) (i : ℤ) :\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj\n (op (unop S).val)).homology_functor_iso (complex_shape.up ℤ) i).inv.app\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M)) ≫\n ((homology_functor (Profiniteᵒᵖ ⥤ Ab) (complex_shape.up ℤ) i).map\n ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))).app\n (ExtrDisc_to_Profinite.op.obj S) =\n category_theory.functor.map _ (category_theory.functor.map _ (category_theory.functor.map _ f)) ≫\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj\n (op (unop S).val)).homology_functor_iso (complex_shape.up ℤ) i).inv.app\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj N)) :=\nhomology_functor_iso_natural' _ _ _ _ _\n.\n\nlemma eval_freeAb_iso_component_natural_zero (S : ExtrDiscᵒᵖ) :\n ((((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op (unop S).val)).map_homological_complex\n (complex_shape.up ℤ)).map\n ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))).f\n (int.of_nat 0) ≫\n (eval_freeAb_iso.component_zero BD N (unop S)).hom =\n (eval_freeAb_iso.component_zero BD M (unop S)).hom ≫\n ((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).map\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op (unop S).val)).map f.val)).f\n (int.of_nat 0) :=\nbegin\n dsimp only [eval_freeAb_iso.component_zero,\n functor.map_homological_complex_map_f, category_theory.evaluation_obj_map],\n erw [embed_f_0, embed_f_0],\n simp only [functor.map_biproduct, data.eval_functor_obj_map_f,\n whiskering_right_obj_map, whisker_right_app, functor.comp_map,\n functor.map_iso_hom, biproduct.unique_up_to_iso_hom,\n ← functor.map_comp], congr' 2,\n apply biproduct.hom_ext, intro j,\n simp only [category.assoc],\n erw [biproduct.lift_π, biproduct.map_π, biproduct.lift_π_assoc],\n simp only [functor.map_bicone_π, biproduct.bicone_π, evaluation_obj_map],\n simp only [← nat_trans.comp_app], congr' 1,\n rw [biproduct.map_π], refl,\nend\n\nlemma eval_freeAb_iso_component_natural_neg (S : ExtrDiscᵒᵖ) (n : ℕ) :\n((((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op (unop S).val)).map_homological_complex\n (complex_shape.up ℤ)).map\n ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))).f\n -[1+ n] ≫\n (eval_freeAb_iso.component_neg BD N (unop S) n).hom =\n (eval_freeAb_iso.component_neg BD M (unop S) n).hom ≫\n ((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).map\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op (unop S).val)).map f.val)).f\n -[1+ n] :=\nbegin\n dsimp only [eval_freeAb_iso.component_neg,\n functor.map_homological_complex_map_f, category_theory.evaluation_obj_map],\n erw [embed_f_neg, embed_f_neg],\n simp only [functor.map_biproduct, data.eval_functor_obj_map_f,\n whiskering_right_obj_map, whisker_right_app, functor.comp_map,\n functor.map_iso_hom, biproduct.unique_up_to_iso_hom,\n ← functor.map_comp], congr' 2,\n apply biproduct.hom_ext, intro j,\n simp only [category.assoc],\n erw [biproduct.lift_π, biproduct.map_π, biproduct.lift_π_assoc],\n simp only [functor.map_bicone_π, biproduct.bicone_π, evaluation_obj_map],\n simp only [← nat_trans.comp_app], congr' 1,\n rw [biproduct.map_π], refl,\nend\n\nlemma eval_freeAb_iso_component_natural (S : ExtrDiscᵒᵖ) :\n(eval_freeAb_iso_component BD M (unop S)).inv ≫\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op (unop S).val)).map_homological_complex\n (complex_shape.up ℤ)).map\n ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f)) =\n (BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).map\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op (unop S).val)).map f.val) ≫\n (eval_freeAb_iso_component BD N (unop S)).inv :=\nbegin\n rw [iso.inv_comp_eq, ← category.assoc, iso.eq_comp_inv],\n ext ((_|n)|n) : 2,\n { apply eval_freeAb_iso_component_natural_zero },\n { apply is_zero.eq_of_tgt, apply is_zero_zero, },\n { apply eval_freeAb_iso_component_natural_neg },\nend\n.\n\nlemma eval_freeAb_iso_component_natural_bis (S : ExtrDiscᵒᵖ) (i : ℤ) :\n (homology_functor AddCommGroup (complex_shape.up ℤ) i).map (eval_freeAb_iso_component BD M (unop S)).inv ≫\n (((category_theory.evaluation Profiniteᵒᵖ Ab).obj (op (unop S).val)).map_homological_complex\n (complex_shape.up ℤ) ⋙\n homology_functor Ab (complex_shape.up ℤ) i).map\n ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f)) =\n category_theory.functor.map _ (category_theory.functor.map _ (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj\n (op (unop S).val)).map f.val)) ≫\n (homology_functor AddCommGroup (complex_shape.up ℤ) i).map (eval_freeAb_iso_component BD N (unop S)).inv :=\nbegin\n rw [functor.comp_map, ← functor.map_comp, ← functor.map_comp], congr' 1,\n apply eval_freeAb_iso_component_natural,\nend\n\nlemma tensor_to_unsheafified_homology_natural'_aux (S : ExtrDiscᵒᵖ) (x) :\n ((AddCommGroup.adj.hom_equiv punit (N.val.obj (op (unop S).val))).symm)\n (point\n ((((ExtrSheaf_ExtrSheafProd_equiv Ab).functor.map ((Condensed_ExtrSheaf_equiv Ab).inverse.map f)).val.app S) x)) =\n ((AddCommGroup.adj.hom_equiv punit (M.val.obj (op (unop S).val))).symm) (point x) ≫\n ((category_theory.evaluation Profiniteᵒᵖ Ab).obj (op (unop S).val)).map f.val :=\nbegin\n dsimp [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv],\n apply free_abelian_group.lift.ext, rintro ⟨⟩,\n rw [free_abelian_group.lift.of, comp_apply, free_abelian_group.lift.of],\n refl\nend\n\nlemma aaaahrg (i : ℤ) {A B : Ab} (f : A ⟶ B) :\n (homotopy_category.homology_functor AddCommGroup (complex_shape.up ℤ) i).map\n ((BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).map f) =\n (homology_functor AddCommGroup (complex_shape.up ℤ) i).map\n ((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).map f) :=\nrfl\n\nlemma tensor_to_unsheafified_homology_natural' (i : ℤ) :\n tensor_to_unsheafified_homology BD M i ≫\n whisker_left ExtrDisc_to_Profinite.op\n ((homology_functor (Profiniteᵒᵖ ⥤ Ab) (complex_shape.up ℤ) i).map\n ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))) =\n (ExtrSheafProd.map_tensor\n ((ExtrSheaf_ExtrSheafProd_equiv Ab).functor.map ((Condensed_ExtrSheaf_equiv Ab).inverse.map f))\n (𝟙 (((BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).obj (AddCommGroup.free.obj punit)).val.as.homology i))).val ≫\n tensor_to_unsheafified_homology BD N i :=\nbegin\n ext S : 2,\n dsimp only [tensor_to_unsheafified_homology, nat_trans.comp_app, whisker_left_app,\n ExtrSheafProd.map_tensor_val_app],\n apply AddCommGroup.tensor_ext, intros x y,\n simp only [comp_apply, id_apply, AddCommGroup.map_tensor, tensor_product.map_tmul,\n AddCommGroup.tensor_uncurry, linear_map.to_add_monoid_hom_coe,\n tensor_product.lift.tmul, add_monoid_hom.coe_mk,\n linear_map.comp_apply, add_monoid_hom.coe_to_int_linear_map],\n dsimp only [tensor_to_unsheafified_homology_component, add_monoid_hom.mk'_apply,\n tensor_to_unsheafified_homology_component_applied],\n simp only [← comp_apply, category.assoc], congr' 1,\n rw homology_functor_iso_natural,\n simp only [← category.assoc], congr' 1, simp only [category.assoc],\n rw eval_freeAb_iso_component_natural_bis,\n simp only [← category.assoc], congr' 1,\n rw [tensor_to_unsheafified_homology_natural'_aux],\n rw [aaaahrg, aaaahrg, ← category_theory.functor.map_comp, ← category_theory.functor.map_comp],\nend\n\nlemma tensor_to_homology_natural (i : ℤ) :\n tensor_to_homology.{u} BD M i ≫ (homology_functor (Condensed.{u} Ab.{u+1}) _ i).map\n ((BD.eval' freeCond').map f) =\n map_tensor f (𝟙 _) ≫ tensor_to_homology.{u} BD N i :=\nbegin\n simp only [tensor_to_homology, category.assoc, ← functor.map_comp,\n eval_freeCond'_iso_component_natural],\n simp only [functor.map_comp],\n simp only [← category.assoc], refine congr_arg2 _ _ rfl, simp only [category.assoc],\n have := (homology_functor_sheafification_iso (complex_shape.up ℤ) i).hom.naturality\n ((Condensed_Ab_to_presheaf ⋙ BD.eval' freeFunc).map f),\n erw [← this], clear this,\n simp only [← category.assoc], refine congr_arg2 _ _ rfl, simp only [category.assoc],\n dsimp only [iso.app_hom],\n have := (Condensed_ExtrSheaf_equiv Ab.{u+1}).counit_iso.hom.naturality\n ((homology_functor (Profinite.{u}ᵒᵖ ⥤ Ab.{u+1}) _ i ⋙\n presheaf_to_Condensed_Ab).map ((Condensed_Ab_to_presheaf ⋙ BD.eval' freeFunc.{u u+1}).map f)),\n erw [← this], clear this,\n simp only [← category.assoc], refine congr_arg2 _ _ rfl, simp only [category.assoc],\n dsimp only [map_tensor, functor.comp_map],\n simp only [← functor.map_comp], congr' 1,\n have := ExtrDisc_sheafification_iso.hom.naturality\n ((homology_functor (Profinite.{u}ᵒᵖ ⥤ Ab.{u+1}) _ i).map\n ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))),\n erw [← this], clear this,\n simp only [← category.assoc], refine congr_arg2 _ _ rfl,\n ext1,\n dsimp only [tensor_to_homology_aux],\n simp only [functor.comp_map, whiskering_left_obj_map, Sheaf.category_theory.category_comp_val,\n presheaf_to_Sheaf_map_val, ExtrSheaf.map_tensor_val,\n grothendieck_topology.to_sheafify_naturality, category.assoc,\n grothendieck_topology.to_sheafify_naturality_assoc, ← grothendieck_topology.sheafify_map_comp],\n rw [tensor_to_unsheafified_homology_natural'],\nend\n\nlemma homology_bd_eval_natural\n [∀ S : ExtrDisc.{u}, no_zero_smul_divisors ℤ (M.val.obj (op S.val))]\n [∀ S : ExtrDisc.{u}, no_zero_smul_divisors ℤ (N.val.obj (op S.val))] (i : ℤ) :\n (homology_bd_eval BD M i).inv ≫ (homology_functor _ _ i).map ((BD.eval' freeCond').map f) =\n map_tensor f (𝟙 _) ≫ (homology_bd_eval BD N i).inv :=\ntensor_to_homology_natural BD M N f i\n\nend Condensed\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/Qprime_isoms2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.399811640739795, "lm_q1q2_score": 0.23393024667567028}} {"text": "import analysis.normed.group.SemiNormedGroup.kernels\nimport algebra.homology.additive\n\nnamespace SemiNormedGroup\n\nprotected class strict_iso {A B : SemiNormedGroup} (f : A ≅ B) :=\n(strict_hom' : ∀ a : A, ∥f.hom a∥₊ = ∥a∥₊)\n\n@[simp]\nlemma strict_iso_hom {A B : SemiNormedGroup} (f : A ≅ B) [strict_iso f] (a : A) :\n ∥f.hom a∥₊ = ∥a∥₊ := strict_iso.strict_hom' _\n\n@[simp]\nlemma strict_iso_inv {A B : SemiNormedGroup} (f : A ≅ B) [strict_iso f] (b : B) :\n ∥f.inv b∥₊ = ∥b∥₊ :=\nbegin\n have : b = f.hom (f.inv b),\n { change b = (f.inv ≫ f.hom) b, simp },\n conv_rhs {rw this},\n rw strict_iso_hom,\nend\n\nend SemiNormedGroup\n\nstructure strict_iso (C D : cochain_complex SemiNormedGroup ℕ) :=\n(iso : C ≅ D)\n[is_strict : ∀ i : ℕ, SemiNormedGroup.strict_iso $ (homological_complex.eval _ _ i).map_iso iso]\n\ninstance (C D : cochain_complex SemiNormedGroup ℕ) (f : strict_iso C D) (n : ℕ) :\n SemiNormedGroup.strict_iso ((homological_complex.eval _ _ n).map_iso f.iso) := f.is_strict _\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/prop819/strict_complex_iso.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6076631556226291, "lm_q2_score": 0.38491214448393346, "lm_q1q2_score": 0.23389692835458034}} {"text": "\nlemma eq_mp_heq :\n ∀ {α β : Sort*} {a : α} {a' : β} (h₂ : a == a'), (eq.mp (type_eq_of_heq h₂) a) = a'\n| α ._ a a' heq.rfl := rfl\n", "meta": {"author": "leanprover-community", "repo": "mathlib-nursery", "sha": "0479b31fa5b4d39f41e89b8584c9f5bf5271e8ec", "save_path": "github-repos/lean/leanprover-community-mathlib-nursery", "path": "github-repos/lean/leanprover-community-mathlib-nursery/mathlib-nursery-0479b31fa5b4d39f41e89b8584c9f5bf5271e8ec/src/logic/nursery.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.23346905553266564}} {"text": "/-\nFile: signature_recover_public_key_get_point_from_x_soundness.lean\n\nAutogenerated file.\n-/\nimport starkware.cairo.lean.semantics.soundness.hoare\nimport .signature_recover_public_key_code\nimport ..signature_recover_public_key_spec\nimport .signature_recover_public_key_validate_reduced_field_element_soundness\nimport .signature_recover_public_key_reduce_soundness\nimport .signature_recover_public_key_unreduced_sqr_soundness\nimport .signature_recover_public_key_unreduced_mul_soundness\nopen tactic\n\nopen starkware.cairo.common.cairo_secp.signature\nopen starkware.cairo.common.cairo_secp.constants\nopen starkware.cairo.common.math\nopen starkware.cairo.common.cairo_secp.field\nopen starkware.cairo.common.cairo_secp.ec\nopen starkware.cairo.common.cairo_secp.bigint\n\nvariables {F : Type} [field F] [decidable_eq F] [prelude_hyps F]\nvariable mem : F → F\nvariable σ : register_state F\n\n/- starkware.cairo.common.cairo_secp.signature.get_point_from_x autogenerated soundness theorem -/\n\ntheorem auto_sound_get_point_from_x\n -- arguments\n (range_check_ptr : F) (x : BigInt3 F) (v : F)\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_get_point_from_x σ.pc)\n -- all dependencies are in memory\n (h_mem_0 : mem_at mem code_assert_nn (σ.pc - 751))\n (h_mem_1 : mem_at mem code_assert_le (σ.pc - 747))\n (h_mem_2 : mem_at mem code_assert_nn_le (σ.pc - 742))\n (h_mem_4 : mem_at mem code_nondet_bigint3 (σ.pc - 719))\n (h_mem_5 : mem_at mem code_unreduced_mul (σ.pc - 707))\n (h_mem_6 : mem_at mem code_unreduced_sqr (σ.pc - 687))\n (h_mem_7 : mem_at mem code_verify_zero (σ.pc - 671))\n (h_mem_9 : mem_at mem code_reduce (σ.pc - 612))\n (h_mem_10 : mem_at mem code_validate_reduced_field_element (σ.pc - 599))\n -- input arguments on the stack\n (hin_range_check_ptr : range_check_ptr = mem (σ.fp - 7))\n (hin_x : x = cast_BigInt3 mem (σ.fp - 6))\n (hin_v : v = mem (σ.fp - 3))\n -- conclusion\n : ensures_ret mem σ (λ κ τ,\n ∃ μ ≤ κ, rc_ensures mem (rc_bound F) μ (mem (σ.fp - 7)) (mem $ τ.ap - 7)\n (spec_get_point_from_x mem κ range_check_ptr x v (mem (τ.ap - 7)) (cast_EcPoint mem (τ.ap - 6)))) :=\nbegin\n apply ensures_of_ensuresb, intro νbound,\n have h_mem_rec := h_mem,\n unpack_memory code_get_point_from_x at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15, hpc16, hpc17, hpc18, hpc19, hpc20, hpc21, hpc22, hpc23, hpc24, hpc25, hpc26, hpc27, hpc28, hpc29, hpc30, hpc31, hpc32, hpc33, hpc34, hpc35, hpc36, hpc37, hpc38, hpc39, hpc40, hpc41, hpc42, hpc43, hpc44, hpc45, hpc46, hpc47, hpc48, hpc49, hpc50, hpc51, hpc52, hpc53, hpc54, hpc55, hpc56, hpc57, hpc58, hpc59, hpc60, hpc61, hpc62, hpc63, hpc64, hpc65⟩,\n -- ap += 6\n step_advance_ap hpc0 hpc1,\n -- function call\n step_assert_eq hpc2 with arg0,\n step_assert_eq hpc3 with arg1,\n step_sub hpc4 (auto_sound_assert_nn mem _ range_check_ptr v _ _ _),\n { rw hpc5, norm_num2, exact h_mem_0 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call6 ap6 h_call6,\n rcases h_call6 with ⟨h_call6_ap_offset, h_call6⟩,\n rcases h_call6 with ⟨rc_m6, rc_mle6, hl_range_check_ptr₁, h_call6⟩,\n generalize' hr_rev_range_check_ptr₁: mem (ap6 - 1) = range_check_ptr₁,\n have htv_range_check_ptr₁ := hr_rev_range_check_ptr₁.symm, clear hr_rev_range_check_ptr₁,\n try { simp only [arg0 ,arg1] at hl_range_check_ptr₁ },\n rw [←htv_range_check_ptr₁, ←hin_range_check_ptr] at hl_range_check_ptr₁,\n try { simp only [arg0 ,arg1] at h_call6 },\n rw [hin_range_check_ptr] at h_call6,\n clear arg0 arg1,\n -- function call\n step_assert_eq hpc6 with arg0,\n step_assert_eq hpc7 with arg1,\n step_assert_eq hpc8 with arg2,\n step_sub hpc9 (auto_sound_unreduced_sqr mem _ x _ _),\n { rw hpc10, norm_num2, exact h_mem_6 },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call11 ap11 h_call11,\n rcases h_call11 with ⟨h_call11_ap_offset, h_call11⟩,\n generalize' hr_rev_x_square: cast_UnreducedBigInt3 mem (ap11 - 3) = x_square,\n simp only [hr_rev_x_square] at h_call11,\n have htv_x_square := hr_rev_x_square.symm, clear hr_rev_x_square,\n clear arg0 arg1 arg2,\n -- function call\n step_assert_eq hpc11 with arg0,\n step_assert_eq hpc12 with arg1,\n step_assert_eq hpc13 with arg2,\n step_assert_eq hpc14 with arg3,\n step_sub hpc15 (auto_sound_reduce mem _ range_check_ptr₁ x_square _ _ _ _ _),\n { rw hpc16, norm_num2, exact h_mem_9 },\n { rw hpc16, norm_num2, exact h_mem_4 },\n { rw hpc16, norm_num2, exact h_mem_7 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call17 ap17 h_call17,\n rcases h_call17 with ⟨h_call17_ap_offset, h_call17⟩,\n rcases h_call17 with ⟨rc_m17, rc_mle17, hl_range_check_ptr₂, h_call17⟩,\n generalize' hr_rev_range_check_ptr₂: mem (ap17 - 4) = range_check_ptr₂,\n have htv_range_check_ptr₂ := hr_rev_range_check_ptr₂.symm, clear hr_rev_range_check_ptr₂,\n generalize' hr_rev_x_square_reduced: cast_BigInt3 mem (ap17 - 3) = x_square_reduced,\n simp only [hr_rev_x_square_reduced] at h_call17,\n have htv_x_square_reduced := hr_rev_x_square_reduced.symm, clear hr_rev_x_square_reduced,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3] at hl_range_check_ptr₂ },\n try { rw [h_call11_ap_offset] at hl_range_check_ptr₂ }, try { arith_simps at hl_range_check_ptr₂ },\n rw [←htv_range_check_ptr₂, ←htv_range_check_ptr₁] at hl_range_check_ptr₂,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3] at h_call17 },\n try { rw [h_call11_ap_offset] at h_call17 }, try { arith_simps at h_call17 },\n rw [←htv_range_check_ptr₁, hl_range_check_ptr₁, hin_range_check_ptr] at h_call17,\n clear arg0 arg1 arg2 arg3,\n -- function call\n step_assert_eq hpc17 with arg0,\n step_assert_eq hpc18 with arg1,\n step_assert_eq hpc19 with arg2,\n step_assert_eq hpc20 with arg3,\n step_assert_eq hpc21 with arg4,\n step_assert_eq hpc22 with arg5,\n step_sub hpc23 (auto_sound_unreduced_mul mem _ x x_square_reduced _ _ _),\n { rw hpc24, norm_num2, exact h_mem_5 },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call25 ap25 h_call25,\n rcases h_call25 with ⟨h_call25_ap_offset, h_call25⟩,\n generalize' hr_rev_x_cube: cast_UnreducedBigInt3 mem (ap25 - 3) = x_cube,\n simp only [hr_rev_x_cube] at h_call25,\n have htv_x_cube := hr_rev_x_cube.symm, clear hr_rev_x_cube,\n clear arg0 arg1 arg2 arg3 arg4 arg5,\n -- local var\n step_assert_eq hpc25 with temp0,\n step_assert_eq hpc26 with temp1,\n step_assert_eq hpc27 with temp2,\n have lc_x_cube: x_cube = cast_UnreducedBigInt3 mem σ.fp, {\n try { ext } ; {\n try { simp only [htv_x_cube] },\n try { dsimp [cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [temp0, temp1, temp2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n clear temp0 temp1 temp2,\n -- function call\n step_assert_eq hpc28 with arg0,\n step_sub hpc29 (auto_sound_nondet_bigint3 mem _ range_check_ptr₂ _ _),\n { rw hpc30, norm_num2, exact h_mem_4 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced, htv_x_cube, lc_x_cube] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call31 ap31 h_call31,\n rcases h_call31 with ⟨h_call31_ap_offset, h_call31⟩,\n rcases h_call31 with ⟨rc_m31, rc_mle31, hl_range_check_ptr₃, h_call31⟩,\n generalize' hr_rev_range_check_ptr₃: mem (ap31 - 4) = range_check_ptr₃,\n have htv_range_check_ptr₃ := hr_rev_range_check_ptr₃.symm, clear hr_rev_range_check_ptr₃,\n generalize' hr_rev_y: cast_BigInt3 mem (ap31 - 3) = y,\n simp only [hr_rev_y] at h_call31,\n have htv_y := hr_rev_y.symm, clear hr_rev_y,\n try { simp only [arg0] at hl_range_check_ptr₃ },\n try { rw [h_call25_ap_offset] at hl_range_check_ptr₃ }, try { arith_simps at hl_range_check_ptr₃ },\n rw [←htv_range_check_ptr₃, ←htv_range_check_ptr₂] at hl_range_check_ptr₃,\n try { simp only [arg0] at h_call31 },\n try { rw [h_call25_ap_offset] at h_call31 }, try { arith_simps at h_call31 },\n rw [←htv_range_check_ptr₂, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call31,\n clear arg0,\n -- local var\n step_assert_eq hpc31 with temp0,\n step_assert_eq hpc32 with temp1,\n step_assert_eq hpc33 with temp2,\n have lc_y: y = cast_BigInt3 mem (σ.fp + 3), {\n try { ext } ; {\n try { simp only [htv_y] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps }, try { simp only [temp0, temp1, temp2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset, h_call31_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n clear temp0 temp1 temp2,\n -- function call\n step_assert_eq hpc34 with arg0,\n step_assert_eq hpc35 with arg1,\n step_assert_eq hpc36 with arg2,\n step_assert_eq hpc37 with arg3,\n step_sub hpc38 (auto_sound_validate_reduced_field_element mem _ range_check_ptr₃ y _ _ _ _ _ _),\n { rw hpc39, norm_num2, exact h_mem_10 },\n { rw hpc39, norm_num2, exact h_mem_0 },\n { rw hpc39, norm_num2, exact h_mem_1 },\n { rw hpc39, norm_num2, exact h_mem_2 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr₃, htv_y, lc_y] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset, h_call31_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr₃, htv_y, lc_y] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset, h_call31_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call40 ap40 h_call40,\n rcases h_call40 with ⟨rc_m40, rc_mle40, hl_range_check_ptr₄, h_call40⟩,\n generalize' hr_rev_range_check_ptr₄: mem (ap40 - 1) = range_check_ptr₄,\n have htv_range_check_ptr₄ := hr_rev_range_check_ptr₄.symm, clear hr_rev_range_check_ptr₄,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3] at hl_range_check_ptr₄ },\n rw [←htv_range_check_ptr₄, ←htv_range_check_ptr₃] at hl_range_check_ptr₄,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3] at h_call40 },\n rw [←htv_range_check_ptr₃, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call40,\n clear arg0 arg1 arg2 arg3,\n -- function call\n step_assert_eq hpc40 with arg0,\n step_assert_eq hpc41 with arg1,\n step_assert_eq hpc42 hpc43 with arg2,\n have h_δ40_c0 : ∀ x : F, x / (2 : ℤ) = x * (-1809251394333065606848661391547535052811553607665798349986546028067936010240 : ℤ),\n { intro x, apply div_eq_mul_inv', apply PRIME.int_cast_mul_eq_one, rw [PRIME], try { simp_int_casts }, norm_num1 },\n have h_δ40_c0_fz : ∀ x : F, x / 2 = x / (2 : ℤ), { intro x, norm_cast }, \n step_sub hpc44 (auto_sound_assert_nn mem _ range_check_ptr₄ ((y.d0 + v) / (2 : ℤ)) _ _ _),\n { rw hpc45, norm_num2, exact h_mem_0 },\n { try { simp only [h_δ40_c0_fz, h_δ40_c0] }, try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr₃, htv_y, lc_y, htv_range_check_ptr₄] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset, h_call31_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { simp only [h_δ40_c0_fz, h_δ40_c0] }, try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr₃, htv_y, lc_y, htv_range_check_ptr₄] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset, h_call31_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call46 ap46 h_call46,\n rcases h_call46 with ⟨h_call46_ap_offset, h_call46⟩,\n rcases h_call46 with ⟨rc_m46, rc_mle46, hl_range_check_ptr₅, h_call46⟩,\n generalize' hr_rev_range_check_ptr₅: mem (ap46 - 1) = range_check_ptr₅,\n have htv_range_check_ptr₅ := hr_rev_range_check_ptr₅.symm, clear hr_rev_range_check_ptr₅,\n try { simp only [arg0 ,arg1 ,arg2] at hl_range_check_ptr₅ },\n rw [←htv_range_check_ptr₅, ←htv_range_check_ptr₄] at hl_range_check_ptr₅,\n try { simp only [arg0 ,arg1 ,arg2] at h_call46 },\n rw [←htv_range_check_ptr₄, hl_range_check_ptr₄, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call46,\n clear arg0 arg1 arg2,\n -- function call\n step_assert_eq hpc46 with arg0,\n step_assert_eq hpc47 with arg1,\n step_assert_eq hpc48 with arg2,\n step_sub hpc49 (auto_sound_unreduced_sqr mem _ y _ _),\n { rw hpc50, norm_num2, exact h_mem_6 },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr₃, htv_y, lc_y, htv_range_check_ptr₄, htv_range_check_ptr₅] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset, h_call31_ap_offset, h_call46_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call51 ap51 h_call51,\n rcases h_call51 with ⟨h_call51_ap_offset, h_call51⟩,\n generalize' hr_rev_y_square: cast_UnreducedBigInt3 mem (ap51 - 3) = y_square,\n simp only [hr_rev_y_square] at h_call51,\n have htv_y_square := hr_rev_y_square.symm, clear hr_rev_y_square,\n clear arg0 arg1 arg2,\n -- function call\n step_assert_eq hpc51 hpc52 with arg0,\n step_assert_eq hpc53 with arg1,\n step_assert_eq hpc54 with arg2,\n step_assert_eq hpc55 with arg3,\n step_assert_eq hpc56 with arg4,\n step_sub hpc57 (auto_sound_verify_zero mem _ range_check_ptr₅ {\n d0 := x_cube.d0 + BETA - y_square.d0,\n d1 := x_cube.d1 - y_square.d1,\n d2 := x_cube.d2 - y_square.d2\n } _ _ _),\n { rw hpc58, norm_num2, exact h_mem_7 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr₃, htv_y, lc_y, htv_range_check_ptr₄, htv_range_check_ptr₅, htv_y_square] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, (eq_sub_of_eq_add arg2), (eq_sub_of_eq_add arg3), (eq_sub_of_eq_add arg4)] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset, h_call31_ap_offset, h_call46_ap_offset, h_call51_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr₃, htv_y, lc_y, htv_range_check_ptr₄, htv_range_check_ptr₅, htv_y_square] },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, (eq_sub_of_eq_add arg2), (eq_sub_of_eq_add arg3), (eq_sub_of_eq_add arg4)] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset, h_call31_ap_offset, h_call46_ap_offset, h_call51_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call59 ap59 h_call59,\n rcases h_call59 with ⟨h_call59_ap_offset, h_call59⟩,\n rcases h_call59 with ⟨rc_m59, rc_mle59, hl_range_check_ptr₆, h_call59⟩,\n generalize' hr_rev_range_check_ptr₆: mem (ap59 - 1) = range_check_ptr₆,\n have htv_range_check_ptr₆ := hr_rev_range_check_ptr₆.symm, clear hr_rev_range_check_ptr₆,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4] at hl_range_check_ptr₆ },\n try { rw [h_call51_ap_offset] at hl_range_check_ptr₆ }, try { arith_simps at hl_range_check_ptr₆ },\n rw [←htv_range_check_ptr₆, ←htv_range_check_ptr₅] at hl_range_check_ptr₆,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4] at h_call59 },\n try { rw [h_call51_ap_offset] at h_call59 }, try { arith_simps at h_call59 },\n rw [←htv_range_check_ptr₅, hl_range_check_ptr₅, hl_range_check_ptr₄, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call59,\n clear arg0 arg1 arg2 arg3 arg4,\n -- return\n step_assert_eq hpc59 with hret0,\n step_assert_eq hpc60 with hret1,\n step_assert_eq hpc61 with hret2,\n step_assert_eq hpc62 with hret3,\n step_assert_eq hpc63 with hret4,\n step_assert_eq hpc64 with hret5,\n step_ret hpc65,\n -- finish\n step_done, use_only [rfl, rfl],\n -- range check condition\n use_only (rc_m6+rc_m17+rc_m31+rc_m40+rc_m46+rc_m59+0+0), split,\n linarith [rc_mle6, rc_mle17, rc_mle31, rc_mle40, rc_mle46, rc_mle59],\n split,\n { arith_simps, try { simp only [hret0 ,hret1 ,hret2 ,hret3 ,hret4 ,hret5] },\n rw [←htv_range_check_ptr₆, hl_range_check_ptr₆, hl_range_check_ptr₅, hl_range_check_ptr₄, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr],\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_get_point_from_x mem _ range_check_ptr x v _ _,\n { apply sound_get_point_from_x, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_get_point_from_x],\n try { norm_num1 }, try { arith_simps },\n use_only [κ_call6],\n use_only [range_check_ptr₁],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have spec6 := h_call6 rc_h_range_check_ptr',\n rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec6,\n try { dsimp at spec6, arith_simps at spec6 },\n use_only [spec6],\n use_only [κ_call11],\n use_only [x_square],\n try { dsimp at h_call11, arith_simps at h_call11 },\n try { use_only [h_call11] },\n use_only [κ_call17],\n use_only [range_check_ptr₂],\n use_only [x_square_reduced],\n have rc_h_range_check_ptr₂ := range_checked_offset' rc_h_range_check_ptr₁,\n have rc_h_range_check_ptr₂' := range_checked_add_right rc_h_range_check_ptr₂, try { norm_cast at rc_h_range_check_ptr₂' },\n have spec17 := h_call17 rc_h_range_check_ptr₁',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←htv_range_check_ptr₂] at spec17,\n try { dsimp at spec17, arith_simps at spec17 },\n use_only [spec17],\n use_only [κ_call25],\n use_only [x_cube],\n try { dsimp at h_call25, arith_simps at h_call25 },\n try { use_only [h_call25] },\n use_only [κ_call31],\n use_only [range_check_ptr₃],\n use_only [y],\n have rc_h_range_check_ptr₃ := range_checked_offset' rc_h_range_check_ptr₂,\n have rc_h_range_check_ptr₃' := range_checked_add_right rc_h_range_check_ptr₃, try { norm_cast at rc_h_range_check_ptr₃' },\n have spec31 := h_call31 rc_h_range_check_ptr₂',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←htv_range_check_ptr₃] at spec31,\n try { dsimp at spec31, arith_simps at spec31 },\n use_only [spec31],\n use_only [κ_call40],\n use_only [range_check_ptr₄],\n have rc_h_range_check_ptr₄ := range_checked_offset' rc_h_range_check_ptr₃,\n have rc_h_range_check_ptr₄' := range_checked_add_right rc_h_range_check_ptr₄, try { norm_cast at rc_h_range_check_ptr₄' },\n have spec40 := h_call40 rc_h_range_check_ptr₃',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←hl_range_check_ptr₃, ←htv_range_check_ptr₄] at spec40,\n try { dsimp at spec40, arith_simps at spec40 },\n use_only [spec40],\n use_only [κ_call46],\n use_only [range_check_ptr₅],\n have rc_h_range_check_ptr₅ := range_checked_offset' rc_h_range_check_ptr₄,\n have rc_h_range_check_ptr₅' := range_checked_add_right rc_h_range_check_ptr₅, try { norm_cast at rc_h_range_check_ptr₅' },\n have spec46 := h_call46 rc_h_range_check_ptr₄',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←hl_range_check_ptr₃, ←hl_range_check_ptr₄, ←htv_range_check_ptr₅] at spec46,\n try { dsimp at spec46, arith_simps at spec46 },\n use_only [spec46],\n use_only [κ_call51],\n use_only [y_square],\n try { dsimp at h_call51, arith_simps at h_call51 },\n try { use_only [h_call51] },\n use_only [κ_call59],\n use_only [range_check_ptr₆],\n have rc_h_range_check_ptr₆ := range_checked_offset' rc_h_range_check_ptr₅,\n have rc_h_range_check_ptr₆' := range_checked_add_right rc_h_range_check_ptr₆, try { norm_cast at rc_h_range_check_ptr₆' },\n have spec59 := h_call59 rc_h_range_check_ptr₅',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←hl_range_check_ptr₃, ←hl_range_check_ptr₄, ←hl_range_check_ptr₅, ←htv_range_check_ptr₆] at spec59,\n try { dsimp at spec59, arith_simps at spec59 },\n use_only [spec59],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr₁, htv_x_square, htv_range_check_ptr₂, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr₃, htv_y, lc_y, htv_range_check_ptr₄, htv_range_check_ptr₅, htv_y_square, htv_range_check_ptr₆] }, },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3, cast_EcPoint] },\n try { arith_simps }, try { simp only [hret0, hret1, hret2, hret3, hret4, hret5] },\n try { simp only [h_call6_ap_offset, h_call11_ap_offset, h_call17_ap_offset, h_call25_ap_offset, h_call31_ap_offset, h_call46_ap_offset, h_call51_ap_offset, h_call59_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\nend\n\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/common/cairo_secp/verification/verification/signature_recover_public_key_get_point_from_x_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.41489884579676883, "lm_q1q2_score": 0.23324638135158385}} {"text": "import for_mathlib.derived_functor\nimport category_theory.abelian.left_derived\n\nuniverses w v u\n\nnoncomputable theory\n\nnamespace category_theory.abelian.functor\n\nopen category_theory category_theory.functor category_theory.limits\nopen category_theory.functor.left_derived\n\nvariables {C : Type u} {D : Type u} [category.{w} C] [category.{w} D] [enough_projectives C]\nvariables (F : C ⥤ D) {A₁ A₂ A₃ X : C} {f : A₁ ⟶ A₂} {g : A₂ ⟶ A₃}\nvariables [abelian C] [abelian D] [additive F] [preserves_finite_colimits F]\n\nsection les\n\ndef δ₀ (A : short_exact_sequence C) := δ F 0 A ≫ (left_derived_zero_iso_self F).hom.app A.1\n\nlemma seven_term_exact_seq (A : short_exact_sequence C) :\n exact_seq D [\n (F.left_derived 1).map A.f, (F.left_derived 1).map A.g,\n δ₀ F A,\n F.map A.f, F.map A.g, (0 : F.obj A.3 ⟶ F.obj A.3)] :=\nbegin\n refine exact_seq.cons _ _ (exact_of_short_exact _ _ _) _ (exact_seq.cons _ _ _ _ _),\n { refine preadditive.exact_of_iso_of_exact' ((F.left_derived 1).map A.g) (δ F 0 A) _ _\n (iso.refl _) (iso.refl _) ((left_derived_zero_iso_self F).app A.1) (by simp) _ _,\n { dsimp [δ₀], rw [category.id_comp] },\n { exact (exact_iff_exact_seq _ _).2 ((six_term_exact_seq F 0 A).extract 1 2) } },\n refine exact_seq.cons _ _ _ _ _,\n { refine preadditive.exact_of_iso_of_exact' (δ F 0 A) ((F.left_derived 0).map A.f) _ _\n (iso.refl _) ((left_derived_zero_iso_self F).app A.1) ((left_derived_zero_iso_self F).app A.2)\n _ (by simp) _,\n { dsimp [δ₀], rw [category.id_comp] },\n { exact (exact_iff_exact_seq _ _).2 ((six_term_exact_seq F 0 A).extract 2 2) } },\n apply exact_seq.cons,\n { exact preserves_exact_of_preserves_finite_colimits_of_epi _ A.exact' },\n { rw [← exact_iff_exact_seq],\n exact ((abelian.tfae_epi (F.obj A.3) (F.map A.g)).out 0 2).1\n (category_theory.preserves_epi _ _) }\nend\n\nend les\n\nend category_theory.abelian.functor\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/for_mathlib/derived_functor_zero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.38861802670584894, "lm_q1q2_score": 0.233244015827522}} {"text": "import data.real.basic\n\ntheorem exo:\n (forall (a b c: real), ((2*a + b + c)^2)/(2*a^2 + (b + c)^2) + ((2*b + c + a)^2)/(2*b^2 + (c + a)^2) + ((2*c + a + b)^2)/(2*c^2 + (a + b)^2) <= 8)\n:=\n sorry\n", "meta": {"author": "ahayat16", "repo": "lean_exos", "sha": "682f2552d5b04a8c8eb9e4ab15f875a91b03845c", "save_path": "github-repos/lean/ahayat16-lean_exos", "path": "github-repos/lean/ahayat16-lean_exos/lean_exos-682f2552d5b04a8c8eb9e4ab15f875a91b03845c/src_icannos_totilas/aops/2003-USAMO-Problem_5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6224593312018546, "lm_q2_score": 0.3738758227716967, "lm_q1q2_score": 0.23272249459501343}} {"text": "import feather_model.basic\n\nopen_locale classical\n\nopen feather_model\n\n@[reducible] def 𝕋 := mterm (finset V)\n\n/-- To establish a base case for the model, we create the \"empty\" model level. -/\ninstance : term_struct (finset V) := {\n var := λ v, {v},\n bound := id,\n subst := λ v e f, if v ∈ f then f.erase v ∪ e else f,\n is_type := λ _ _, true,\n runtime_ok := λ _, true,\n rir_ok := λ _, true,\n runtime_judgments := λ _, true,\n rir_judgments := λ _, true,\n defeq := λ _ _ _ _, true,\n sort := λ _, ∅,\n representable := λ s f, f,\n}\n\ninstance : type_data (finset V) := ⟨λ _ _, true, λ _, true⟩\n\ninstance : term (finset V) :=\nbegin\n refine_struct { .. };\n intros; try { trivial },\n { unfold subst,\n rw if_neg,\n assumption, },\n { unfold subst,\n rw if_pos,\n refl,\n assumption, },\nend\n\nexample : term_struct 𝕋 := infer_instance\n", "meta": {"author": "quill-lang", "repo": "feather-model", "sha": "64e760f426b4dde09065157c9f5121862681d9e3", "save_path": "github-repos/lean/quill-lang-feather-model", "path": "github-repos/lean/quill-lang-feather-model/feather-model-64e760f426b4dde09065157c9f5121862681d9e3/src/feather_model/model.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.44552953503957277, "lm_q1q2_score": 0.23146209301246018}} {"text": "-- author: Ben Sherman\nimport .action\n galois.tactic\n galois.option\n galois.temporal.temporal\n\nuniverses u v\n\nnamespace network\n\nstructure incoming_items :=\n (messages : list (socket × message_t))\n\ndef lookup_updatef {A : Type u} [decidable_eq A] {B : A → Type v}\n (a : A) (f : B a → B a) (m : ∀ a, B a) (x : A) : B x\n:= if H : a = x\n then eq.rec_on H (f (m a))\n else m x\n\ndef lookup_update {A : Type u} [decidable_eq A] {B : A → Type v}\n (a : A) (b : B a) : (∀ a, B a) → (∀ a, B a)\n:= lookup_updatef a (λ _, b)\n\nlemma lookup_update_refl {A : Type u} [decidable_eq A] {B : A → Type v}\n {a : A} {b : B a} {f : ∀ a, B a} :\n lookup_update a b f a = b\n:= begin\nunfold lookup_update lookup_updatef,\nrw (dif_pos (eq.refl a)),\nend\n\nlemma lookup_update_different {A : Type u} [decidable_eq A] {B : A → Type v}\n {a a' : A} {b : B a} {f : ∀ a, B a} (H : a ≠ a') :\n lookup_update a b f a' = f a'\n:= begin\nunfold lookup_update lookup_updatef,\nrw (dif_neg H),\nend\n\n@[reducible]\ndef global_state_t := ip → incoming_items\n\ndef initial_incoming_items : incoming_items\n := { messages := [] }\n\ndef poll_label.to_poll_result\n (ports : list port) (sockets : list socket) (bound : time)\n (incoming : incoming_items)\n : poll_label → option (poll_result ports sockets bound)\n| poll_label.timeout := some poll_result.timeout\n| (poll_label.receive elapsed rn mess) := do\n plift.up (and.intro H H') ← option.precondition (elapsed < bound ∧ 0 < elapsed),\n idx ← list.check_member_st (λ p : socket × message_t, p.snd = mess) incoming.messages,\n sockidx ← list.check_member idx.to_member.value.fst sockets, --any other checks necessary?\n some (poll_result.message ⟨ elapsed, H ⟩ sockidx mess H')\n\ndef agent_label.to_dlabel\n (incoming : incoming_items) {ag : agent}\n: ∀ (a_next : act ag.state_type), agent_label → option (dlabel a_next)\n| (act.poll ports sockets bound cont) (agent_label.mk plabel ms) := do\n r ← plabel.to_poll_result ports sockets bound incoming,\n guard ((cont r).fst = ms),\n some (dlabel.poll ports sockets bound cont r)\n\ndef add_message (rn : remote_name) (m : message_t) (a_ip : ip)\n : global_state_t → global_state_t :=\n lookup_updatef a_ip (λ i : incoming_items, {i with messages := (rn, m) :: i.messages })\n\ndef dlabel_to_label {A} : ∀ {a_next : act A}, dlabel a_next → agent_label\n| (act.poll ports sockets bound cont) (dlabel.poll ._ ._ ._ ._ r) :=\n agent_label.mk r.to_label ((cont r).fst)\n\nsection\nparameter {agents : map ip agent}\n\nstructure system_state : Type 1 :=\n (local_state : ∀ a : agents.member, a.value.state_type)\n (global_state : global_state_t)\n\nstructure sys_dlabel (st : system_state) :=\n (ag : agents.member)\n (label : dlabel (ag.value.loop (st.local_state ag)))\n\nsection\nparameters (a_ip : ip) (ag : agent) (incoming : incoming_items)\n\ndef apply_message_updates (ms : list (socket × message_t))\n (updatef : global_state_t → global_state_t)\n : global_state_t → global_state_t\n := let fs := (list.map (λ p : socket × message_t, let (sock, mess) := p in\n add_message (a_ip, sock.snd) mess sock.fst) ms) in\n list.foldr function.comp updatef fs\n\ndef next_agent_state_poll_dlabel {A : Type} {ports : list port} {sockets : list socket}\n {bound : time} (cont : poll_result ports sockets bound → A)\n : poll_result ports sockets bound\n → option (global_state_t → global_state_t)\n| poll_result.timeout := some id\n| (poll_result.message elapsed_fin sock mess H) := do\n midx ← incoming.messages.check_member (sock.value, mess),\n some (lookup_updatef a_ip (λ inc, {inc with messages := list.remove_member _ midx}))\n\ndef next_agent_state_from_dlabel\n : ∀ {a_next : act ag.state_type} (la : dlabel a_next)\n , option (ag.state_type × (global_state_t → global_state_t))\n| (act.poll ports sockets bound cont) (dlabel.poll ._ ._ ._ ._ r) := do\n updatef ← next_agent_state_poll_dlabel cont r,\n let (ms, new_state) := cont r,\n some (new_state, apply_message_updates ms updatef)\n\nend\n\ndef next_state_from_dlabel (system : system_state)\n : sys_dlabel system → option system_state\n| (sys_dlabel.mk ag aupdate) :=\n option.bind (next_agent_state_from_dlabel ag.key ag.value\n (system.global_state ag.key) aupdate)\n $ λ p, let (new_state, updatef) := p in\n some { local_state := lookup_update ag new_state system.local_state\n , global_state := updatef system.global_state }\n\nopen temporal\n\n-- Our labeled transition system\ndef LTSd (s : system_state) (l : sys_dlabel s) (s' : system_state) : Prop :=\n next_state_from_dlabel s l = some s'\n\ndef TR := trace (sigma sys_dlabel)\ndef TP := tProp (sigma sys_dlabel)\n\n/--\nApply a function (usually a predicate) to the label of a state-label pair\n-/\ndef inLabel {S} {L} {B} (f : L → B) (x : sigma (λ _ : S, L)) : B := f x.snd\n/--\nIf we apply a decidable prop to the label, that application is decidable\n-/\ninstance inLabel_decidable {S L} {P : L → Prop} [decP : decidable_pred P] :\n decidable_pred (@inLabel S L _ P) :=\nbegin\nintros x, apply decP,\nend\n\nlemma inLabel_mono {S} {L} : subset.monotone (@inLabel S L Prop)\n:= begin\nintros P Q PQ x Hx, apply PQ, apply Hx\nend\n\nend\n\nend network", "meta": {"author": "GaloisInc", "repo": "lean-protocol-support", "sha": "cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda", "save_path": "github-repos/lean/GaloisInc-lean-protocol-support", "path": "github-repos/lean/GaloisInc-lean-protocol-support/lean-protocol-support-cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda/galois/network/network_implementation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5428632831725053, "lm_q2_score": 0.42632159254749036, "lm_q1q2_score": 0.2314343394176617}} {"text": "import Structure.Generic.Axioms.Universes\nimport Structure.Generic.Axioms.AbstractFunctors\n\nimport mathlib4_experiments.Data.Equiv.Basic\n\n\n\nset_option autoBoundImplicitLocal false\n--set_option pp.universes true\n\nuniverses u v\n\n\n\nclass HasExternalEquivalences (U : Universe.{u}) (V : Universe.{v})\n [hUV : HasExternalFunctors U V] [hVU : HasExternalFunctors V U] : Type (max u v) where\n(IsEquiv {α : U} {β : V} : (α ⟶' β) → (β ⟶' α) → Sort (max u v))\n\nstructure BundledEquivalence {U : Universe.{u}} {V : Universe.{v}}\n [hUV : HasExternalFunctors U V] [hVU : HasExternalFunctors V U]\n [h : HasExternalEquivalences U V]\n (α : U) (β : V) : Sort (max 1 u v) where\n(toFun : α ⟶' β)\n(invFun : β ⟶' α)\n(isEquiv : h.IsEquiv toFun invFun)\n\nnamespace BundledEquivalence\n\n infix:20 \" ⟷' \" => BundledEquivalence\n\n variable {U V : Universe} [hUV : HasExternalFunctors U V] [hVU : HasExternalFunctors V U]\n [h : HasExternalEquivalences U V]\n\n def mkEquiv {α : U} {β : V} {to : α ⟶' β} {inv : β ⟶' α} (he : h.IsEquiv to inv) : α ⟷' β :=\n ⟨to, inv, he⟩\n\nend BundledEquivalence\n\nclass HasInternalEquivalences (U : Universe.{u}) [h : HasInternalFunctors U] extends HasExternalEquivalences U U : Type u where\n(Equiv : U → U → U)\n(equivEquiv (α β : U) : ⌈Equiv α β⌉ ≃ (α ⟷' β))\n(equivElimToFunIsFun (α β : U) : h.IsFun (λ E : Equiv α β => HasInternalFunctors.fromBundled ((equivEquiv α β).toFun E).toFun))\n(equivElimInvFunIsFun (α β : U) : h.IsFun (λ E : Equiv α β => HasInternalFunctors.fromBundled ((equivEquiv α β).toFun E).invFun))\n\nnamespace HasInternalEquivalences\n\n infix:20 \" ⟷ \" => HasInternalEquivalences.Equiv\n\n variable {U : Universe} [HasInternalFunctors U] [h : HasInternalEquivalences U]\n\n def toBundled {α β : U} (E : α ⟷ β) : α ⟷' β := (h.equivEquiv α β).toFun E\n def fromBundled {α β : U} (E : α ⟷' β) : α ⟷ β := (h.equivEquiv α β).invFun E\n\n @[simp] theorem fromToBundled {α β : U} (E : α ⟷ β) : fromBundled (toBundled E) = E :=\n (h.equivEquiv α β).leftInv E\n @[simp] theorem toFromBundled {α β : U} (E : α ⟷' β) : toBundled (fromBundled E) = E :=\n (h.equivEquiv α β).rightInv E\n\n def to {α β : U} (E : α ⟷ β) (a : α) : β := (toBundled E).toFun a\n def inv {α β : U} (E : α ⟷ β) (b : β) : α := (toBundled E).invFun b\n\n def toFun {α β : U} (E : α ⟷ β) : α ⟶ β := HasInternalFunctors.fromBundled (toBundled E).toFun\n def invFun {α β : U} (E : α ⟷ β) : β ⟶ α := HasInternalFunctors.fromBundled (toBundled E).invFun\n\n @[simp] theorem toFun.eff {α β : U} (E : α ⟷ β) (a : α) : (toFun E) a = to E a :=\n by apply HasInternalFunctors.fromBundled.eff\n @[simp] theorem invFun.eff {α β : U} (E : α ⟷ β) (b : β) : (invFun E) b = inv E b :=\n by apply HasInternalFunctors.fromBundled.eff\n\n def toFunFun' (α β : U) : (α ⟷ β) ⟶' (α ⟶ β) := BundledFunctor.mkFun (h.equivElimToFunIsFun α β)\n def invFunFun' (α β : U) : (α ⟷ β) ⟶' (β ⟶ α) := BundledFunctor.mkFun (h.equivElimInvFunIsFun α β)\n def toFunFun (α β : U) : (α ⟷ β) ⟶ (α ⟶ β) := HasInternalFunctors.fromBundled (toFunFun' α β)\n def invFunFun (α β : U) : (α ⟷ β) ⟶ (β ⟶ α) := HasInternalFunctors.fromBundled (invFunFun' α β)\n\n @[simp] theorem toFunFun.eff {α β : U} (E : α ⟷ β) : (toFunFun α β) E = toFun E :=\n by apply HasInternalFunctors.fromBundled.eff\n @[simp] theorem invFunFun.eff {α β : U} (E : α ⟷ β) : (invFunFun α β) E = invFun E :=\n by apply HasInternalFunctors.fromBundled.eff\n @[simp] theorem toFunFun.effEff {α β : U} (E : α ⟷ β) (a : α) : ((toFunFun α β) E) a = to E a :=\n by simp\n @[simp] theorem invFunFun.effEff {α β : U} (E : α ⟷ β) (b : β) : ((invFunFun α β) E) b = inv E b :=\n by simp\n\n @[simp] theorem toFun.bundledEq {α β : U} (E : α ⟷ β) : HasInternalFunctors.toBundled (toFun E) = (toBundled E).toFun :=\n HasInternalFunctors.toFromBundled (toBundled E).toFun\n @[simp] theorem invFun.bundledEq {α β : U} (E : α ⟷ β) : HasInternalFunctors.toBundled (invFun E) = (toBundled E).invFun :=\n HasInternalFunctors.toFromBundled (toBundled E).invFun\n\n def isEquiv {α β : U} (E : α ⟷ β) : h.IsEquiv (toBundled E).toFun (toBundled E).invFun :=\n (toBundled E).isEquiv\n\n def isEquiv' {α β : U} (E : α ⟷ β) :\n h.IsEquiv (HasInternalFunctors.toBundled (toFun E)) (HasInternalFunctors.toBundled (invFun E)) :=\n by simp; apply isEquiv\n\n @[simp] theorem fromBundled.to.coe' {α β : U} (E : α ⟷' β) : (toBundled (fromBundled E)).toFun = E.toFun :=\n congrArg BundledEquivalence.toFun (toFromBundled E)\n @[simp] theorem fromBundled.inv.coe' {α β : U} (E : α ⟷' β) : (toBundled (fromBundled E)).invFun = E.invFun :=\n congrArg BundledEquivalence.invFun (toFromBundled E)\n @[simp] theorem fromBundled.to.coe {α β : U} (E : α ⟷' β) : (toBundled (fromBundled E)).toFun.f = E.toFun.f :=\n congrArg BundledFunctor.f (fromBundled.to.coe' E)\n @[simp] theorem fromBundled.inv.coe {α β : U} (E : α ⟷' β) : (toBundled (fromBundled E)).invFun.f = E.invFun.f :=\n congrArg BundledFunctor.f (fromBundled.inv.coe' E)\n @[simp] theorem fromBundled.to.eff {α β : U} (E : α ⟷' β) (a : α) : to (fromBundled E) a = E.toFun a :=\n congrFun (fromBundled.to.coe E) a\n @[simp] theorem fromBundled.inv.eff {α β : U} (E : α ⟷' β) (b : β) : inv (fromBundled E) b = E.invFun b :=\n congrFun (fromBundled.inv.coe E) b\n\n def mkEquiv {α β : U} {to : α ⟶' β} {inv : β ⟶' α} (he : h.IsEquiv to inv) : α ⟷ β :=\n fromBundled (BundledEquivalence.mkEquiv he)\n\nend HasInternalEquivalences\n\nclass HasIdEquiv (U : Universe) [HasExternalFunctors U U] [HasIdFun U] [h : HasExternalEquivalences U U] where\n(idIsEquiv (α : U) : h.IsEquiv (HasIdFun.idFun' α) (HasIdFun.idFun' α))\n\nnamespace HasIdEquiv\n\n variable {U : Universe} [HasExternalFunctors U U] [HasIdFun U] [HasExternalEquivalences U U] [h : HasIdEquiv U]\n\n def idEquiv' (α : U) : α ⟷' α := BundledEquivalence.mkEquiv (h.idIsEquiv α)\n\nend HasIdEquiv\n\nclass HasCompEquiv (U V W : Universe)\n [HasExternalFunctors U V] [HasExternalFunctors V W] [HasExternalFunctors U W]\n [HasExternalFunctors V U] [HasExternalFunctors W V] [HasExternalFunctors W U]\n [HasCompFun U V W] [HasCompFun W V U]\n [HasExternalEquivalences U V] [HasExternalEquivalences V W] [h : HasExternalEquivalences U W] where\n(compIsEquiv {α : U} {β : V} {γ : W} (E : α ⟷' β) (F : β ⟷' γ) : h.IsEquiv (F.toFun ⊙' E.toFun) (E.invFun ⊙' F.invFun))\n\nnamespace HasCompEquiv\n\n variable {U V W : Universe} [HasExternalFunctors U V] [HasExternalFunctors V W] [HasExternalFunctors U W]\n [HasExternalFunctors V U] [HasExternalFunctors W V] [HasExternalFunctors W U]\n [HasCompFun U V W] [HasCompFun W V U]\n [HasExternalEquivalences U V] [HasExternalEquivalences V W] [HasExternalEquivalences U W]\n [h : HasCompEquiv U V W]\n\n def compEquiv' {α : U} {β : V} {γ : W} (E : α ⟷' β) (F : β ⟷' γ) : α ⟷' γ := BundledEquivalence.mkEquiv (h.compIsEquiv E F)\n\nend HasCompEquiv\n\nclass HasInvEquiv (U V : Universe) [HasExternalFunctors U V] [HasExternalFunctors V U]\n [HasExternalEquivalences U V] [h : HasExternalEquivalences V U] where\n(invIsEquiv {α : U} {β : V} (E : α ⟷' β) : h.IsEquiv E.invFun E.toFun)\n\nnamespace HasInvEquiv\n\n variable {U V : Universe} [HasExternalFunctors U V] [HasExternalFunctors V U]\n [HasExternalEquivalences U V] [HasExternalEquivalences V U] [h : HasInvEquiv U V]\n\n def invEquiv' {α : U} {β : V} (E : α ⟷' β) : β ⟷' α := BundledEquivalence.mkEquiv (h.invIsEquiv E)\n\nend HasInvEquiv\n\nclass HasEquivOp (U : Universe.{u}) [h : HasInternalFunctors U] [HasLinearFunOp U] extends\n HasInternalEquivalences U, HasIdEquiv U, HasCompEquiv U U U, HasInvEquiv U U : Type u where\n(compEquivIsFun {α β : U} (E : α ⟷' β) (γ : U) : h.IsFun (λ F : β ⟷ γ => HasInternalEquivalences.mkEquiv (compIsEquiv E (HasInternalEquivalences.toBundled F))))\n(compEquivFunIsFun (α β γ : U) : h.IsFun (λ E : α ⟷ β => HasInternalFunctors.mkFun (compEquivIsFun (HasInternalEquivalences.toBundled E) γ)))\n(invEquivIsFun (α β : U) : h.IsFun (λ E : α ⟷ β => HasInternalEquivalences.mkEquiv (invIsEquiv (HasInternalEquivalences.toBundled E))))\n(invEquivIsEquiv (α β : U) : IsEquiv (BundledFunctor.mkFun (invEquivIsFun α β)) (BundledFunctor.mkFun (invEquivIsFun β α)))\n\nnamespace HasEquivOp\n\n variable {U : Universe.{u}} [HasInternalFunctors U] [HasLinearFunOp U] [h : HasEquivOp U]\n\n def idEquiv' (α : U) : α ⟷' α := HasIdEquiv.idEquiv' α\n def idEquiv (α : U) : α ⟷ α := HasInternalEquivalences.fromBundled (idEquiv' α)\n\n @[simp] theorem idEquiv.to.eff (α : U) (a : α) : HasInternalEquivalences.to (idEquiv α) a = a :=\n by apply HasInternalEquivalences.fromBundled.to.eff\n @[simp] theorem idEquiv.inv.eff (α : U) (a : α) : HasInternalEquivalences.inv (idEquiv α) a = a :=\n by apply HasInternalEquivalences.fromBundled.inv.eff\n\n def compEquiv' {α β γ : U} (E : α ⟷' β) (F : β ⟷' γ) : α ⟷' γ := HasCompEquiv.compEquiv' E F\n def compEquiv {α β γ : U} (E : α ⟷ β) (F : β ⟷ γ) : α ⟷ γ :=\n HasInternalEquivalences.fromBundled (compEquiv' (HasInternalEquivalences.toBundled E) (HasInternalEquivalences.toBundled F))\n\n @[simp] theorem compEquiv.to.eff {α β γ : U} (E : α ⟷ β) (F : β ⟷ γ) (a : α) :\n HasInternalEquivalences.to (compEquiv E F) a = HasInternalEquivalences.to F (HasInternalEquivalences.to E a) :=\n by apply HasInternalEquivalences.fromBundled.to.eff\n @[simp] theorem compEquiv.inv.eff {α β γ : U} (E : α ⟷ β) (F : β ⟷ γ) (c : γ) :\n HasInternalEquivalences.inv (compEquiv E F) c = HasInternalEquivalences.inv E (HasInternalEquivalences.inv F c) :=\n by apply HasInternalEquivalences.fromBundled.inv.eff\n\n def compEquivFun' {α β : U} (E : α ⟷' β) (γ : U) : (β ⟷ γ) ⟶' (α ⟷ γ) := BundledFunctor.mkFun (h.compEquivIsFun E γ)\n def compEquivFun {α β : U} (E : α ⟷ β) (γ : U) : (β ⟷ γ) ⟶ (α ⟷ γ) :=\n HasInternalFunctors.fromBundled (compEquivFun' (HasInternalEquivalences.toBundled E) γ)\n\n @[simp] theorem compEquivFun.eff {α β : U} (E : α ⟷ β) (γ : U) (F : β ⟷ γ) : (compEquivFun E γ) F = compEquiv E F :=\n by apply HasInternalFunctors.fromBundled.eff\n @[simp] theorem compEquivFun.to.effEff {α β : U} (E : α ⟷ β) (γ : U) (F : β ⟷ γ) (a : α) :\n HasInternalEquivalences.to ((compEquivFun E γ) F) a = HasInternalEquivalences.to F (HasInternalEquivalences.to E a) :=\n by simp\n @[simp] theorem compEquivFun.inv.effEff {α β : U} (E : α ⟷ β) (γ : U) (F : β ⟷ γ) (c : γ) :\n HasInternalEquivalences.inv ((compEquivFun E γ) F) c = HasInternalEquivalences.inv E (HasInternalEquivalences.inv F c) :=\n by simp\n\n def compEquivFunFun' (α β γ : U) : (α ⟷ β) ⟶' (β ⟷ γ) ⟶ (α ⟷ γ) := BundledFunctor.mkFun (h.compEquivFunIsFun α β γ)\n def compEquivFunFun (α β γ : U) : (α ⟷ β) ⟶ (β ⟷ γ) ⟶ (α ⟷ γ) := HasInternalFunctors.fromBundled (compEquivFunFun' α β γ)\n \n @[simp] theorem compEquivFunFun.eff (α β γ : U) (E : α ⟷ β) : (compEquivFunFun α β γ) E = compEquivFun E γ :=\n by apply HasInternalFunctors.fromBundled.eff\n @[simp] theorem compEquivFunFun.effEff (α β γ : U) (E : α ⟷ β) (F : β ⟷ γ) : ((compEquivFunFun α β γ) E) F = compEquiv E F :=\n by simp\n @[simp] theorem compEquivFunFun.to.effEffEff (α β γ : U) (E : α ⟷ β) (F : β ⟷ γ) (a : α) :\n HasInternalEquivalences.to (((compEquivFunFun α β γ) E) F) a = HasInternalEquivalences.to F (HasInternalEquivalences.to E a) := by simp\n @[simp] theorem compEquivFunFun.inv.effEffEff (α β γ : U) (E : α ⟷ β) (F : β ⟷ γ) (c : γ) :\n HasInternalEquivalences.inv (((compEquivFunFun α β γ) E) F) c = HasInternalEquivalences.inv E (HasInternalEquivalences.inv F c) := by simp\n\n def invEquiv' {α β : U} (E : α ⟷' β) : β ⟷' α := HasInvEquiv.invEquiv' E\n def invEquiv {α β : U} (E : α ⟷ β) : β ⟷ α :=\n HasInternalEquivalences.fromBundled (invEquiv' (HasInternalEquivalences.toBundled E))\n\n @[simp] theorem invEquiv.to.eff {α β : U} (E : α ⟷ β) (b : β) : HasInternalEquivalences.to (invEquiv E) b = HasInternalEquivalences.inv E b :=\n by apply HasInternalEquivalences.fromBundled.to.eff\n @[simp] theorem invEquiv.inv.eff {α β : U} (E : α ⟷ β) (a : α) : HasInternalEquivalences.inv (invEquiv E) a = HasInternalEquivalences.to E a :=\n by apply HasInternalEquivalences.fromBundled.inv.eff\n\n def invEquivFun' (α β : U) : (α ⟷ β) ⟶' (β ⟷ α) := BundledFunctor.mkFun (h.invEquivIsFun α β)\n def invEquivFun (α β : U) : (α ⟷ β) ⟶ (β ⟷ α) := HasInternalFunctors.fromBundled (invEquivFun' α β)\n\n @[simp] theorem invEquivFun.eff (α β : U) (E : α ⟷ β) : (invEquivFun α β) E = invEquiv E :=\n by apply HasInternalFunctors.fromBundled.eff\n @[simp] theorem invEquivFun.to.effEff (α β : U) (E : α ⟷ β) (b : β) :\n HasInternalEquivalences.to ((invEquivFun α β) E) b = HasInternalEquivalences.inv E b := by simp\n @[simp] theorem invEquivFun.inv.effEff (α β : U) (E : α ⟷ β) (a : α) :\n HasInternalEquivalences.inv ((invEquivFun α β) E) a = HasInternalEquivalences.to E a := by simp\n\n def invEquivEquiv' (α β : U) : (α ⟷ β) ⟷' (β ⟷ α) := BundledEquivalence.mkEquiv (h.invEquivIsEquiv α β)\n def invEquivEquiv (α β : U) : (α ⟷ β) ⟷ (β ⟷ α) := HasInternalEquivalences.fromBundled (invEquivEquiv' α β)\n\n @[simp] theorem invEquivEquiv.to.eff (α β : U) (E : α ⟷ β) : HasInternalEquivalences.to (invEquivEquiv α β) E = invEquiv E :=\n by apply HasInternalEquivalences.fromBundled.to.eff\n @[simp] theorem invEquivEquiv.inv.eff (α β : U) (E : β ⟷ α) : HasInternalEquivalences.inv (invEquivEquiv α β) E = invEquiv E :=\n by apply HasInternalEquivalences.fromBundled.inv.eff\n @[simp] theorem invEquivEquiv.to.to.effEff (α β : U) (E : α ⟷ β) (b : β) :\n HasInternalEquivalences.to (HasInternalEquivalences.to (invEquivEquiv α β) E) b = HasInternalEquivalences.inv E b := by simp\n @[simp] theorem invEquivEquiv.to.inv.effEff (α β : U) (E : α ⟷ β) (a : α) :\n HasInternalEquivalences.inv (HasInternalEquivalences.to (invEquivEquiv α β) E) a = HasInternalEquivalences.to E a := by simp\n @[simp] theorem invEquivEquiv.inv.to.effEff (α β : U) (E : β ⟷ α) (a : α) :\n HasInternalEquivalences.to (HasInternalEquivalences.inv (invEquivEquiv α β) E) a = HasInternalEquivalences.inv E a := by simp\n @[simp] theorem invEquivEquiv.inv.inv.effEff (α β : U) (E : β ⟷ α) (b : β) :\n HasInternalEquivalences.inv (HasInternalEquivalences.inv (invEquivEquiv α β) E) b = HasInternalEquivalences.to E b := by simp\n\nend HasEquivOp\n", "meta": {"author": "SReichelt", "repo": "lean4-experiments", "sha": "ff55357a01a34a91bf670d712637480089085ee4", "save_path": "github-repos/lean/SReichelt-lean4-experiments", "path": "github-repos/lean/SReichelt-lean4-experiments/lean4-experiments-ff55357a01a34a91bf670d712637480089085ee4/Structure/Generic/Axioms/AbstractEquivalences.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.4186969093556867, "lm_q1q2_score": 0.230537602218082}} {"text": "\n@[simp] lemma to_bool_true_eq_tt (h : decidable true) : @to_bool true h = tt :=\ndecidable.cases_on h (λ h, false.elim (iff.mp not_true h)) (λ _, rfl)\n\n@[simp] lemma to_bool_false_eq_ff (h : decidable false) : @to_bool false h = ff :=\ndecidable.cases_on h (λ h, rfl) (λ h, false.elim h)\n", "meta": {"author": "ImperialCollegeLondon", "repo": "SF-solns-zak", "sha": "7edc4424938e01a6ef4bb518fa8ec1757a2226b1", "save_path": "github-repos/lean/ImperialCollegeLondon-SF-solns-zak", "path": "github-repos/lean/ImperialCollegeLondon-SF-solns-zak/SF-solns-zak-7edc4424938e01a6ef4bb518fa8ec1757a2226b1/logic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5813030906443133, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.2302356491609262}} {"text": "definition {u v} transport {A : Type u} { P : A → Type v} {x y : A} (p : x = y)\n(u : P x) : P y :=\nby induction p; exact u\n\ndefinition {u v w} apdt011 \n {A : Type u} {Z : Type w} \n {B : A → Type v} \n (f : Πa, B a → Z) \n {a a' : A} \n {b : B a} \n {b' : B a'} \n (Ha : a = a') \n (Hb : transport Ha b = b')\n : f a b = f a' b' :=\nby cases Ha; cases Hb; reflexivity\n\nset_option trace.check true\n\n\n\n\n-- set_option pp.implicit true\n\n-- @NaturalTransformation.components ?M_1 ?M_2 ?M_3 ?M_4 :\n-- @NaturalTransformation ?M_1 ?M_2 ?M_3 ?M_4 → Π (X : ?M_1.Obj), ?M_2.Hom (⇑?M_3 X) (⇑?M_4 X)\n\n-- α === Type (max u v)\n-- a === (@NaturalTransformation (C × C) C (@MonoidalStructure.tensor C m)\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C)\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))))\n-- T === (λ (_x : Type (max u v)), _x)\n-- t : T a == a\n-- t === (@vertical_composition_of_NaturalTransformations (C × C) C (@MonoidalStructure.tensor C m)\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C)\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m)))\n-- (@isomorphism.Isomorphism.morphism (FunctorCategory (C × C) C) (@MonoidalStructure.tensor C m)\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n-- (@braided_monoidal_category.Symmetry.braiding C m β))\n-- (@whisker_on_left (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m)\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n-- (@isomorphism.Isomorphism.morphism (FunctorCategory (C × C) C) (@MonoidalStructure.tensor C m)\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n-- (@braided_monoidal_category.Symmetry.braiding C m β)))) \n-- b === (@NaturalTransformation (C × C) C (@MonoidalStructure.tensor C m) (@MonoidalStructure.tensor C m))\n-- e : a = b\n\n-- @eq.rec α a T t b e : T b\n-- T b == b\n\n-- now we want to apply\n-- f === @NaturalTransformation.components (C × C) C (@MonoidalStructure.tensor C m) (@MonoidalStructure.tensor C m)\n-- to @eq.rec α a T b e.\n-- actually, we're going to need to think of this as applying \n-- f' === @NaturalTransformation.components (C × C) C (@MonoidalStructure.tensor C m)\n-- : Π (F : Functor (C × C) C), NaturalTransformation m.tensor F → Π (x : (C × C).Obj), C.Hom (m.tensor x) (F x)\n-- and here we may as well introduce S : Functor (C × C) C → Type as S F = Π (x : (C × C).Obj), C.Hom (m.tensor x) (F x),\n-- and then write f' : Π (F : Functor (C × C) C), NaturalTransformation m.tensor F → S F \n--\n-- Thus we want to start with f' (@MonoidalStructure.tensor C m) (@eq.rec α a T t b e) : S (@MonoidalStructure.tensor C m)\n-- and by application of the lemma we're designing obtain ...?\n-- f' (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C)\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m)))\n-- a \n-- Now this thing is of type S (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C)\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m)))\n-- which is no good, so we're going to have to transport it through the type family S. But where do we obtain our \n-- path/equation to transport along? Somehow we take e : a = b, and think of that actually as e : R a' = R b' ... nope.\n\n-------------\n\n-- 20170508\n--\n-- (@NaturalTransformation.components (C × C) C\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n-- (@MonoidalStructure.tensor C m)\n-- (@eq.rec (Functor (C × C) C)\n-- (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C)) (@MonoidalStructure.tensor C m))\n-- (@NaturalTransformation (C × C) C\n-- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m)))\n-- (t : NaturalTransformation (switch tensor) (id tensor))\n-- (@MonoidalStructure.tensor C m)\n-- (FunctorComposition.left_identity (C × C) C (@MonoidalStructure.tensor C m)))\n-- X)\n\n-- S = (@NaturalTransformation (C × C) C\n-- f = @NaturalTransformation.components (C × C) C\n-- f : Π a a' : A, Π t : S a a', Z a a'\n\n-- Z a a' = Π X : (C × C).Obj, C.Hom (a X) (a' X)\n\n-- a = (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n-- a' = (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C)) (@MonoidalStructure.tensor C m))\n\n-- A = (Functor (C × C) C)\n-- a a' : A \n\n-- b = (@MonoidalStructure.tensor C m)\n-- b : A\n\n-- p : a' = b\n\n-- t : S a a'\n\n-- (@eq.rec A a' (S a) t b p) : S a b\n-- f a b (@eq.rec A a' (S a) t b p) : Z a b\n-- f a a' t : Z a a'\n-- (@eq.rec A a' (Z a) (f a a' t) b p) : Z a b\n\n\n\n\n\nlemma {u1 u2 u3 u4} v2 { α : Type u1 } { β : Type u2 } { S : α → β → Type u3 } { Z : α → β → Type u4 } { a : α } { b : β } { t : S a b } { b' : β } { p : b = b' } ( f : Π ( c : α ) ( d : β ) , S c d → Z c d ): \n f a b' (@eq.rec β b (S a) t b' p) = (@eq.rec β b (Z a) (f a b t) b' p) :=\nbegin\ninduction p, reflexivity\nend\n\nlemma {u1 u2 u3} v1 { β : Type u1 } { S : β → Type u2 } { Z : β → Type u3 } { b : β } { t : S b } { b' : β } { p : b = b' } ( f : Π d : β, S d → Z d ) : \n f b' (@eq.rec β b S t b' p) = (@eq.rec β b Z (f b t) b' p) :=\nbegin\ninduction p, reflexivity\nend\n\n\n -- (@NaturalTransformation.components (C × C) C\n -- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n -- (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C)) (@MonoidalStructure.tensor C m))\n -- (@eq.rec (Functor (C × C) (C × C))\n -- (@FunctorComposition (C × C) (C × C) (C × C) (SwitchProductCategory C C) (SwitchProductCategory C C))\n -- (λ (a : Functor (C × C) (C × C)),\n -- @NaturalTransformation (C × C) C\n -- (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n -- (@FunctorComposition (C × C) (C × C) C a (@MonoidalStructure.tensor C m)))\n -- (t : NaturalTransformation (switch tensor) (switch switch tensor))\n -- (IdentityFunctor (C × C))\n -- (switch_twice_is_the_identity C C)))\n\n-- f = @NaturalTransformation.components (C × C) C\n-- α = Functor (C × C) C \n-- a : α\n-- a = (@FunctorComposition (C × C) (C × C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n-- β = Functor (C × C) C\n-- f : Π (a : α) (b : β), S a b → Z a b\n-- γ = (Functor (C × C) (C × C)\n-- g = switch switch\n-- g' = id\n-- p : g = g'\n-- R : γ → β\n-- = λ g, (g tensor)\n-- S = λ a b, NaturalTransformation a b\n--\n-- f a (R g') (@eq.rec γ g (S a) t g' p)\n\n\n-- c' = (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C)) (@MonoidalStructure.tensor C m))\n-- c'' = (@FunctorComposition (C × C) (C × C) C (@FunctorComposition (C × C) (C × C) (C × C) (SwitchProductCategory C C) (SwitchProductCategory C C)) (@MonoidalStructure.tensor C m))\n-- eq.rec ... : NaturalTransformation c c'\n-- γ = (Functor (C × C) (C × C)\n-- g = switch switch\n-- S = Π (a : α) (g : γ), NaturalTransformation a (R g)\n-- t : NaturalTransformation a (R g)\n-- t : S a g\n-- g' = Identity (C × C)\n-- p : g = g'\n\n-- c' = R g'\n-- c'' = R g\n-- R = Π g : γ, (g tensor)\n-- R : γ → β\n\n-- f a c' t' : Z a c'\n\n-- f a (R g') (@eq.rec γ g S t g' p)\n-- f a (@eq.rec γ g R c'' g' p) (@eq.rec γ g S t g' p)\n-- @eq.rec γ g (Z a (R g)) (f a (R g) t) g' p\n-- @eq.rec γ g (Z a ???) (f a (@eq.rec γ g' R c' g (eq.symm p)) t) g' p\n\n\n\nlemma {u1 u2 u3 u4 u5} w\n { α : Type u1 } { β : Type u2 } { γ : Type u3 }\n { S : α → β → Type u4 }\n { Z : α → β → Type u5 }\n { a : α } { g : γ } ( R : γ → β ) { t : S a (R g) } { g' : γ } { p : g = g' } ( f : Π (a : α) (b : β), S a b → Z a b ):\n f a (R g') (@eq.rec γ g (λ g, S a (R g)) t g' p) \n = \n @eq.rec γ g (λ g, Z a (R g)) (f a (R g) t) g' p\n := begin induction p, reflexivity end\n\n--\n-- (@eq.rec (Functor (C × C) C)\n-- (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C)) (@MonoidalStructure.tensor C m))\n-- (λ (G : Functor (C × C) C),\n-- Π (X : (C × C).Obj),\n-- C.Hom\n-- (@Functor.onObjects (C × C) C\n-- (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C))\n-- (@MonoidalStructure.tensor C m))\n-- X)\n-- (@Functor.onObjects (C × C) C G X))\n-- (λ (X : (C × C).Obj),\n-- C.identity\n-- (@Functor.onObjects (C × C) C\n-- (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C))\n-- (@MonoidalStructure.tensor C m))\n-- X))\n-- (@MonoidalStructure.tensor C m)\n-- (@squared_Braiding._proof_3 C m)\n-- X)\nlemma {u1 u2 u3} b { α : Type u1 } { a : α } { β : Type u2 } { Z : α → β → Type u3 } { t : Π (b : β), Z a b } { a' : α } { p : a = a' } \n : @eq.rec α a _ t a' p = λ b : β, @eq.rec α a (λ _a, Z _a b) (t b) a' p :=\nbegin\n induction p,\n reflexivity\nend\n\n-- (@eq.rec (Functor (C × C) C)\n-- (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C)) (@MonoidalStructure.tensor C m))\n-- (λ (_a : Functor (C × C) C),\n-- C.Hom\n-- (@Functor.onObjects (C × C) C\n-- (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C))\n-- (@MonoidalStructure.tensor C m))\n-- (X_1, X_2))\n-- (@Functor.onObjects (C × C) C _a (X_1, X_2)))\n-- (C.identity\n-- (@Functor.onObjects (C × C) C\n-- (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C))\n-- (@MonoidalStructure.tensor C m))\n-- (X_1, X_2)))\n-- (@MonoidalStructure.tensor C m)\n-- (@squared_Braiding._proof_3 C m))\n-- α = (Functor (C × C) C)\n-- a = (@FunctorComposition (C × C) (C × C) C (IdentityFunctor (C × C)) (@MonoidalStructure.tensor C m))\n-- f = C.identity\n-- : Π X : C.Obj, C.Hom X X\n-- r = @Functor.onObjects (C × C) C\n-- x : (C × C).Obj\n-- r a x : C.Obj\n-- t = f (r a x)\n-- : C.Hom (r a x) (r a x)\n\nlemma {u1 u2 u3 u4} pull_function_out\n { α : Type u1 } { a : α } { β : Type u2 } { Z : β → Type u3 } { γ : Type u4 } { r : Π a : α, γ → β } { x : γ } { a' : α } { p : a = a' } ( f : Π (b : β), Z b ) :\n @eq.rec α a _ (f (r a x)) a' p = f (r a' x) := \nbegin\ninduction p, reflexivity\nend\n\n-- This seems sensible, but applies too often.\nlemma {u} bar { α : Type u } { a : α } { b : α } ( p : a = b ) : @eq.rec α a (λ b: α, b = a) (eq.refl a) b p = eq.symm p :=\nbegin\n cases p,\n reflexivity\nend\n\nlemma {u} foo { α : Type u } { a b : α } { p : a = b } : eq.symm (eq.symm p) = p := by reflexivity\n\n@[simp] lemma {u v w} function_of_eq.rec { α : Type u } { a : α } { T : α → Type v } { S : α → Type w } ( t : T a ) { b : α } ( e : a = b ) ( f : Π { c : α }, T c → S c ) :\n @f b ( @eq.rec α a T t b e ) = @eq.rec α a S (@f a t) b e :=\nbegin\n cases e,\n reflexivity\nend\n@[simp] lemma {u v w} function_of_eq.drec { α : Type u } { a : α } { T : Π b : α, a = b → Type v } { S : Π b : α, a = b → Type v } ( t : T a (eq.refl a)) { b : α } ( e : a = b ) ( f : Π { c : α } { p : a = c }, T c p → S c p ) :\n f ( @eq.drec α a T t b e ) = @eq.drec α a S (f t) b e :=\nbegin\n cases e,\n reflexivity\nend\n\nlemma z {A : Type} { X : A } : (eq.mpr (propext (eq_self_iff_true X)) trivial) = rfl :=\nbegin\n -- unfold trivial,\n reflexivity\nend\n", "meta": {"author": "semorrison", "repo": "proof", "sha": "5ee398aa239a379a431190edbb6022b1a0aa2c70", "save_path": "github-repos/lean/semorrison-proof", "path": "github-repos/lean/semorrison-proof/proof-5ee398aa239a379a431190edbb6022b1a0aa2c70/lean/20170509-transport_lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6406358411176238, "lm_q2_score": 0.3593641588823761, "lm_q1q2_score": 0.23022156019313844}} {"text": "import cfr\n\nexample (a b : rat) : (¬ a < b) ∧ (¬ b < a) → a = b := by exact eq_of_incomp\n\ndef dice := list.to_buffer [1,2,3,4,5,6]\ndef claims := list.to_buffer [(1,2), (1,3), (1,4), (1,5), (1,6), (1,1), (2,2), (2,3), (2,4), (2,5), (2,6), (2,1)]\ndef AllowedClaim := {i // ∃ v, claims.read i = v}\ninstance : has_lt AllowedClaim := ⟨ fun a b, a.val < b.val ⟩ \ninstance AllowedClaim_decidable_rel : decidable_rel ((<) : AllowedClaim → AllowedClaim → Prop) := infer_instance\n\ninductive Action\n| Claim (claim : AllowedClaim) : Action\n| Dudo : Action\n\ndef Action.show : Action → string\n| (Action.Claim ⟨ i, _⟩ ) := \"Claim \" ++ has_repr.repr (claims.read i)\n| Action.Dudo := \"Dudo\"\n\ninstance : has_repr Action := ⟨ Action.show ⟩\n\ndef actions.begin := claims.attach_index\ndef actions.later := (actions.begin.iterate buffer.nil (fun i x s, s.push_back $ Action.Claim x)).push_back Action.Dudo\n\ndef Die := {die // die ∈ dice}\ninstance : has_lt Die := ⟨ fun a b, a.val < b.val ⟩\ninstance Die_decidable_rel : decidable_rel ((<) : Die → Die → Prop) := infer_instance\n\n@[derive has_lt] def History := Die × list AllowedClaim\ninstance History_decidable_rel : decidable_rel ((<) : History → History → Prop) := infer_instance\n\ndef ℍ𝔸 : History → Type*\n | (die, []) := AllowedClaim\n | (die, _) := Action\n\ndef ha : HistoryToActions History ℍ𝔸\n | (_, []) := ⟨ actions.begin.1, actions.begin.read ⟩\n | (_, x :: xs) := \n -- TODO: The way buffer.drop behaves on out of bounds is wonky. Replace it.\n let v := actions.later.drop (x.1 + 1) in ⟨ v.1, v.read ⟩\n\nstructure Particle (α : Type*) := mk ::\n (state : α)\n (probability : ℚ)\n (is_updateable : bool)\n\nnamespace game\ndef state := state (Infosets ha)\ndef read_dice (i : fin dice.1) : Die := ⟨ dice.read i, ⟨ i, rfl ⟩ ⟩\n\ndef chance (one : Particle unit) (next : Particle Die → state rat) : state rat := \n chance_uniform ha ⟨ dice.1, read_dice ⟩ one.probability \n (fun dice prob, next {state:=dice, probability:=prob*one.probability, ..one})\n\ndef response (one two : Particle Die) (h : list AllowedClaim)\n (next : ℍ𝔸 ⟨ one.state, h ⟩ → Particle Die → state rat) \n : state rat :=\n response ha one.is_updateable one.probability two.probability ⟨ one.state, h ⟩\n (fun action prob, next action {probability:=prob, ..one}) \n\ndef terminal := terminal ha\n\nmeta def dudo.main : Particle Die → Particle Die → list AllowedClaim → state rat\n | one two [] := response one two [] (fun action one, dudo.main two one [action])\n | one two h@(⟨i, _⟩ :: _) :=\n response one two h $ fun action one, \n match action with\n | Action.Dudo := \n let (number, rank) := claims.read i in\n let check_guess (s x : nat) := if x = 1 ∨ x = rank then s+1 else s in\n let dice_guessed := check_guess (check_guess 0 one.state.val) two.state.val in\n terminal $ if dice_guessed < number then 1.0 else -1.0 \n | Action.Claim claim := dudo.main two one (claim :: h)\n end\n\nmeta def dudo.initial (one : Particle unit) (two : Particle unit) : state rat :=\n chance one $ fun one, \n chance two $ fun two, \n dudo.main one two []\n\nmeta def train (num_iterations : nat): rat × Infosets ha :=\n let particle : Particle unit := {state:=(), probability:=1, is_updateable:=ff} in\n let particle_tt : Particle unit := {is_updateable:=tt, ..particle} in\n @nat.foldl.fin (fun i, rat × Infosets ha) \n num_iterations (0, buffer.nil) \n (fun i ⟨ util, infosets ⟩,\n let (util, infosets) := (dudo.initial {is_updateable:=tt, ..particle} particle).run infosets in\n let (util', infosets) := (dudo.initial particle {is_updateable:=tt, ..particle}).run infosets in\n ((util + util') / 2, infosets)\n )\n\nend game", "meta": {"author": "mrakgr", "repo": "CFR-in-Lean", "sha": "720a3260297bcc158e08833d38964450dcaad2eb", "save_path": "github-repos/lean/mrakgr-CFR-in-Lean", "path": "github-repos/lean/mrakgr-CFR-in-Lean/CFR-in-Lean-720a3260297bcc158e08833d38964450dcaad2eb/src/v0.1/dudo.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6334102775181399, "lm_q2_score": 0.36296921930155557, "lm_q1q2_score": 0.2299084339283409}} {"text": "import model_theory.substructures\nimport model_theory.bundled\n\n\n--OUTPUT 1\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n sorry,\nend\n\n--OUTPUT 2\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n let A := λ n : ℕ, ∃ (x1 : F.Model.sort 1) (x2 : F.Model.sort 1) (xs : fin n → F.Model.sort 1),\n ∀ (x : fin n), x1 ≠ x2 ∧ x1 ≠ xs x ∧ ∀ (x y : fin n), x ≠ y → xs x ≠ xs y,\n have hA : ∀ (n : ℕ), A n, from sorry,\n let Gamma := F.axioms ∪ { A n | n : ℕ},\n have hGamma : ∀ (n : ℕ), ∃ (m : F.Model), (F.Model.satisfies m) Gamma, from sorry,\n have h1 : F.Model.satisfies (F.Model.compact_closure Gamma), from sorry,\n have h2 : ∀ (n : ℕ), F.Model.satisfies (F.Model.compact_closure Gamma) (A n), from sorry,\n have h3 : infinite (F.Model.compact_closure Gamma), from sorry,\n show ∃ (M : F.Model), infinite M, from sorry,\nend\n\n--OUTPUT 3\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n assume L : first_order.language,\n assume F : L.Theory,\n assume h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin,\n\n let Γ : set L.formula := sorry,\n have h1 : ∀ s : set L.formula, finite s → (∃ (m : F.Model), s ⊆ m) → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h2 : ∀ s : set L.formula, finite s → (∃ (m : F.Model), s ⊆ m), from sorry,\n have h3 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h4 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h5 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h6 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h7 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h8 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h9 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h10 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h11 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h12 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h13 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h14 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h15 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h16 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h17 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h18 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h19 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h20 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h21 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h22 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h23 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h24 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h25 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h26 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h27 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h28 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h29 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h30 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h31 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h32 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h33 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h34 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h35 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h36 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h37 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h38 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h39 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h40 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h41 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h42 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h43 : ∀ s : set L.formula, finite s → s ⊆ Γ → ∃ (m : F.Model), s ⊆ m, from sorry,\n have h44 : ∀ s : set L.formula, finite s → s ⊆\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n have h1 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h2 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h3 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h4 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h5 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h6 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h7 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h8 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h9 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h10 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h11 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h12 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h13 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h14 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h15 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h16 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h17 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h18 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h19 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h20 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h21 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h22 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h23 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h24 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h25 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h26 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h27 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h28 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h29 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h30 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h31 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h32 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h33 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h34 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h35 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h36 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h37 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h38 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h39 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h40 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h41 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h42 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h43 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h44 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h45 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h46 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h47 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h48 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h49 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h50 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h51 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h52 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h53 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\n have h54 : ∀ n : ℕ, ∃ (m : F.Model), n ≤ @fintype.card m _, from sorry,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n have h1 : ∃ (x : ℕ) (m : F.Model) [mfin : fintype m], x = fintype.card m, from sorry,\n have h2 : ∃ (m : F.Model) [mfin : fintype m], 1 ≤ @fintype.card m mfin, from sorry,\n have h3 : ∃ (m : F.Model) [mfin : fintype m], 2 ≤ @fintype.card m mfin, from sorry,\n have h4 : ∃ (m : F.Model) [mfin : fintype m], 3 ≤ @fintype.card m mfin, from sorry,\n\n have h5 : ∃ (m : F.Model) [mfin : fintype m], 4 ≤ @fintype.card m mfin, from sorry,\n have h6 : ∃ (m : F.Model) [mfin : fintype m], 5 ≤ @fintype.card m mfin, from sorry,\n have h7 : ∃ (m : F.Model) [mfin : fintype m], 6 ≤ @fintype.card m mfin, from sorry,\n have h8 : ∃ (m : F.Model) [mfin : fintype m], 7 ≤ @fintype.card m mfin, from sorry,\n have h9 : ∃ (m : F.Model) [mfin : fintype m], 8 ≤ @fintype.card m mfin, from sorry,\n\n have h10 : ∃ (m : F.Model) [mfin : fintype m], 9 ≤ @fintype.card m mfin, from sorry,\n have h11 : ∃ (m : F.Model) [mfin : fintype m], 10 ≤ @fintype.card m mfin, from sorry,\n have h12 : ∃ (m : F.Model) [mfin : fintype m], 11 ≤ @fintype.card m mfin, from sorry,\n have h13 : ∃ (m : F.Model) [mfin : fintype m], 12 ≤ @fintype.card m mfin, from sorry,\n have h14 : ∃ (m : F.Model) [mfin : fintype m], 13 ≤ @fintype.card m mfin, from sorry,\n\n have h15 : ∃ (m : F.Model) [mfin : fintype m], 14 ≤ @fintype.card m mfin, from sorry,\n have h16 : ∃ (m : F.Model) [mfin : fintype m], 15 ≤ @fintype.card m mfin, from sorry,\n have h17 : ∃ (m : F.Model) [mfin : fintype m], 16 ≤ @fintype.card m mfin, from sorry,\n have h18 : ∃ (m : F.Model) [mfin : fintype m], 17 ≤ @fintype.card m mfin, from sorry,\n have h19 : ∃ (m : F.Model) [mfin : fintype m], 18 ≤ @fintype.card m mfin, from sorry,\n\n have h20 : ∃ (m : F.Model) [mfin : fintype m], 19 ≤ @fintype.card m mfin, from sorry,\n have h21 : ∃ (m : F.Model) [mfin : fintype m], 20 ≤ @fintype.card m mfin, from sorry,\n have h22 : ∃ (m : F.Model) [mfin : fintype m], 21 ≤ @fintype.card m mfin, from sorry,\n have h23 : ∃ (m : F.Model) [mfin : fintype m], 22 ≤ @fintype.card m mfin, from sorry,\n have h24 : ∃ (m : F.Model) [mfin : fintype m], 23 ≤ @fintype.card m mfin, from sorry,\n\n have h25 : ∃ (m : F.Model) [mfin : fintype m], 24 ≤ @fintype.card m mfin, from sorry,\n have h26 : ∃ (m : F.Model) [mfin : fintype m], 25 ≤ @fintype.card m mfin, from sorry,\n have h27 : ∃ (m : F.Model) [mfin : fintype m], 26 ≤ @fintype.card m mfin, from sorry,\n have h28 : ∃ (m : F.Model) [mfin : fintype m], 27 ≤ @fintype.card m mfin, from sorry,\n have h29 : ∃ (m : F.Model) [mfin : fintype m], 28 ≤ @fintype.card m mfin, from sorry,\n\n have h30 : ∃ (m : F.Model) [mfin : fintype m], 29 ≤ @fintype.card m mfin, from sorry,\n have h31 : ∃ (m : F.Model) [mfin : fintype m], 30 ≤ @fintype.card m mfin, from sorry,\n have h32 : ∃ (m : F.Model) [mfin : fintype m], 31 ≤ @fintype.card m mfin, from sorry,\n have h33 : ∃ (m : F.Model) [mfin : fintype m], 32 ≤ @fintype.card m mfin, from sorry,\n have h34 : ∃ (m : F.Model) [mfin : fintype m], 33 ≤ @fintype.card m mfin, from sorry,\n\n have h35 : ∃ (m : F.Model) [mfin : fintype m], 34 ≤ @fintype.card m mfin, from sorry,\n have h36 : ∃ (m : F.Model) [mfin : fintype m], 35 ≤ @fintype.card m mfin, from sorry,\n have h37 : ∃ (m : F.Model) [mfin : fintype m], 36 ≤ @fintype.card m mfin, from sorry,\n have h38 : ∃ (m : F.Model) [mfin : fintype m], 37 ≤ @fintype.card m mfin, from sorry,\n have h39 : ∃ (m : F.Model) [mfin : fintype m], 38 ≤ @fintype.card m mfin, from sorry,\n\n have h40 : ∃ (m : F.Model) [mfin : fintype m], 39 ≤ @fintype.card m mfin, from sorry,\n have h41 : ∃ (m : F.Model) [mfin : fintype m], 40 ≤ @fintype.card m mfin, from sorry,\n have h42 : ∃ (m : F.Model) [mfin : fintype m], 41 ≤ @fintype.card m mfin, from sorry,\n have h43 : ∃ (m : F.Model) [mfin : fintype m], 42 ≤ @fintype.card m mfin, from sorry,\n have h44 : ∃ (m : F.Model) [mfin : fintype m], 43 ≤ @fintype.card m mfin, from sorry,\n\n have h45 : ∃ (m : F.Model) [mfin : fintype m], 44 ≤ @fintype.card m mfin, from sorry,\n have h46 : ∃ (m : F.Model) [mfin : fintype m], 45 ≤ @fintype.card m mfin, from sorry,\n have h47 : ∃ (m : F.Model) [mfin : fintype m], 46 ≤ @fintype.card m mfin, from sorry,\n have h48 : ∃ (m : F.Model) [mfin : fintype m], 47 ≤ @fintype.card m mfin, from sorry,\n have h49 : ∃ (m : F.Model) [mfin : fintype m], 48 ≤ @fintype.card m mfin, from sorry,\n\n have h50 : ∃ (m : F.Model) [mfin : fintype m], 49 ≤ @fintype.card m mfin, from sorry,\n have h51 : ∃ (m : F.Model) [mfin : fintype m], 50 ≤ @fintype.card m mfin, from sorry,\n have h52\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n assume (n : ℕ),\n let A : L.Theory := F.union (L.Theory.of (L.model_of_nat n)),\n have h1 : ∀ (s : finset F.Model), (∀ (m : F.Model) (H : m ∈ s), m.satisfies A) → ∃ (M : F.Model), M.satisfies A, from sorry,\n have h2 : ∀ (s : finset F.Model), (∀ (m : F.Model) (H : m ∈ s), m.satisfies A) → ∃ (M : F.Model), M.satisfies A ∧ infinite M, from sorry,\n have h3 : ∃ (M : F.Model), M.satisfies A ∧ infinite M, from sorry,\n show ∃ (M : F.Model), infinite M, from sorry,\nend\n\n--OUTPUT 7\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n sorry,\nend\n\n--OUTPUT 8\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n have h1 : ∀ n : ℕ, ∃ (A : F.Model), n ≤ fintype.card A, from sorry,\n have h2 : ∀ n : ℕ, F.Formula.Existential n ∈ F.Theory.satisfiable, from sorry,\n have h3 : ∀ n : ℕ, F.Formula.ForAll n ∈ F.Theory.satisfiable, from sorry,\n have h4 : ∀ n : ℕ, ∃ (A : F.Model), F.Formula.ForAll n ∈ F.Model.satisfy A, from sorry,\n\n have h5 : ∀ n : ℕ, F.Formula.ForAll (n + 1), from sorry,\n have h6 : ∀ n : ℕ, F.Formula.ForAll (n + 2), from sorry,\n\n have h7 : ∀ n : ℕ, F.Formula.ForAll (n + 3), from sorry,\n\n have h8 : ∀ n : ℕ, F.Formula.ForAll (n + 4), from sorry,\n have h9 : ∀ n : ℕ, F.Formula.ForAll (n + 5), from sorry,\n\n have h10 : ∀ n : ℕ, F.Formula.ForAll (n + 6), from sorry,\n\n have h11 : ∀ n : ℕ, F.Formula.ForAll (n + 7), from sorry,\n have h12 : ∀ n : ℕ, F.Formula.ForAll (n + 8), from sorry,\n\n have h13 : ∀ n : ℕ, F.Formula.ForAll (n + 9), from sorry,\n have h14 : ∀ n : ℕ, F.Formula.ForAll (n + 10), from sorry,\n\n have h15 : ∀ n : ℕ, F.Formula.ForAll (n + 11), from sorry,\n have h16 : ∀ n : ℕ, F.Formula.ForAll (n + 12), from sorry,\n\n have h17 : ∀ n : ℕ, F.Formula.ForAll (n + 13), from sorry,\n have h18 : ∀ n : ℕ, F.Formula.ForAll (n + 14), from sorry,\n\n have h19 : ∀ n : ℕ, F.Formula.ForAll (n + 15), from sorry,\n have h20 : ∀ n : ℕ, F.Formula.ForAll (n + 16), from sorry,\n\n have h21 : ∀ n : ℕ, F.Formula.ForAll (n + 17), from sorry,\n have h22 : ∀ n : ℕ, F.Formula.ForAll (n + 18), from sorry,\n\n have h23 : ∀ n : ℕ, F.Formula.ForAll (n + 19), from sorry,\n have h24 : ∀ n : ℕ, F.Formula.ForAll (n + 20), from sorry,\n\n have h25 : ∀ n : ℕ, F.Formula.ForAll (n + 21), from sorry,\n have h26 : ∀ n : ℕ, F.Formula.ForAll (n + 22), from sorry,\n\n have h27 : ∀ n : ℕ, F.Formula.ForAll (n + 23), from sorry,\n have h28 : ∀ n : ℕ, F.Formula.ForAll (n + 24), from sorry,\n\n have h29 : ∀ n : ℕ, F.Formula.ForAll (n + 25), from sorry,\n have h30 : ∀ n : ℕ, F.Formula.ForAll (n + 26), from sorry,\n\n have h31 : ∀ n : ℕ, F.Formula.ForAll (n + 27), from sorry,\n have h32 : ∀ n : ℕ, F.Formula.ForAll (n + 28), from sorry,\n\n have h33 : ∀ n : ℕ, F.Formula.ForAll (n + 29), from sorry,\n have h34 : ∀ n : ℕ, F.Formula.ForAll (n + 30), from sorry,\n\n have h35 : ∀ n : ℕ, F.Formula.ForAll (n + 31), from sorry,\n have h36 : ∀ n : ℕ, F.Formula.ForAll (n + 32), from sorry,\n\n have h37 : ∀ n : ℕ, F.Formula.ForAll (n + 33), from sorry,\n have h38 : ∀ n : ℕ, F.Formula.ForAll (n + 34), from sorry,\n\n have h39 : ∀ n : ℕ, F.Formula.ForAll (n + 35), from sorry,\n have h40 : ∀ n : ℕ, F.Formula.ForAll (n + 36), from sorry,\n\n have h41 : ∀ n : ℕ, F.Formula.ForAll (n + 37), from sorry,\n have h42 : ∀ n : ℕ, F.Formula.ForAll (n + 38), from sorry,\n\n have h43 : ∀ n : ℕ, F.Formula.ForAll (n + 39), from sorry,\n have h44 : ∀ n : ℕ, F.Formula.ForAll (n + 40), from sorry,\n\n have h45 : ∀ n : ℕ, F.Formula.ForAll (n + 41), from sorry,\n have h46 : ∀ n : ℕ, F.Formula.ForAll (n + 42), from sorry,\n\n have h47 : ∀ n : ℕ, F.Formula.ForAll (n + 43), from sorry,\n have h48 : ∀ n : ℕ, F.Formula.ForAll (n + 44), from sorry,\n\n have h49 : ∀ n : ℕ, F.Formula.ForAll (n + 45), from sorry,\n have h50 : ∀ n : ℕ, F.Formula.ForAll (n + 46), from sorry,\n\n have h51 : ∀ n : ℕ, F.Formula.ForAll (n + 47), from sorry,\n have h52 : ∀ n : ℕ, F.Formula.ForAll (n + 48), from sorry,\n\n have h53 : ∀ n : ℕ, F.Formula.ForAll (n + 49), from sorry,\n have h54 : ∀ n : ℕ, F.Formula.ForAll (n + 50), from sorry,\n\n have h55 : ∀ n : ℕ, F.Formula.ForAll (n + 51), from sorry,\n have h56 : ∀ n : ℕ, F.Formula.ForAll (n + 52), from sorry,\n\n have h57 : ∀ n : ℕ, F.Formula.ForAll (n + 53), from sorry,\n have h58 : ∀ n : ℕ, F.Formula.ForAll (n + 54), from sorry,\n\n have h59 : ∀ n : ℕ, F.Formula.ForAll (n + 55), from sorry,\n have h60 : ∀ n : ℕ, F.Formula.ForAll (n + 56), from sorry,\n\n have h61 : ∀ n : ℕ, F.Formula.ForAll (n + 57), from sorry,\n have h62 : ∀ n : ℕ, F.Formula.ForAll (n + 58), from sorry,\n\n have h63 : ∀ n : ℕ, F.Formula.ForAll (n + 59), from sorry,\n have h64 : ∀ n : ℕ, F.Formula.ForAll (n + 60), from sorry,\n\n have h65 : ∀ n : ℕ, F.Formula.ForAll (n + 61), from sorry,\n have h66 : ∀ n : ℕ, \nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n have h2 : (A ∩ B) ⊆ A, from sorry,\n have h3 : (A ∩ B) ⊆ S, from sorry,\n show (A ∩ B) ∈ 𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n calc (x + y)^2 = (x+y)*(x+y) : by sorry\n ... = x*(x+y) + y*(x+y) : by sorry\n ... = x*x + x*y + y*x + y*y : by sorry\n ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n use (1 : G),\n have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n show e = (1 : G), from sorry, \n },\n sorry,\n }\nend\n\n/--`theorem`\nOverflow theorem\nLet $F$ be a set of first-order formulas which has finite models of arbitrarily large size. Then $F$ has an infinite model.\n`proof`\nFor each $n$, let $\\mathbf A_n$ be the formula:\n\n$\\exists x_1 \\exists x_2 \\ldots \\exists x_n: \\{x_1 \\ne x_2 \\land x_1 \\ne x_3 \\land \\ldots \\land x_{n - 1} \\ne x_n\\}$\n\nThen $\\mathbf A_i$ is true in a structure $\\AA$ iff $\\AA$ has at least $n$ elements.\n\nTake:\n$$ \\Gamma := F \\cup \\bigcup_{i \\mathop = 1}^\\infty A_i $$\n\nSince $F$ has models of arbitrarily large size, every finite subset of $\\Gamma$ is satisfiable.\n\nFrom the Compactness Theorem, $\\Gamma$ is satisfiable in some model $\\mathbf{M}$.\n\nBut since $\\mathbf{M} \\models A_i$ for each $i$, $\\mathbf{M}$ must be infinite.\n\nSo $F$ has an infinite model.\n\nQED\n-/\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline-Natural-Language-Proof-Translation/Correct_statement-lean_proof_outline-3_few_shot_temperature_0.6_max_tokens_2000_n_8/clean_files/Overflow theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.3451052709578724, "lm_q1q2_score": 0.22963669117454852}} {"text": "import for_mathlib.split_exact\nimport category_theory.limits.preserves.shapes.biproducts\nimport category_theory.limits.constructions.finite_products_of_binary_products\n\nnoncomputable theory\n\nuniverses v u₁ u₂\nopen_locale tensor_product\n\nopen category_theory category_theory.limits opposite\n\nsection\nvariables {𝓐 : Type u₁} {𝓑 : Type u₂} [category.{v} 𝓐] [category.{v} 𝓑] (F : 𝓐 ⥤ 𝓑)\nvariables [abelian 𝓐] [abelian 𝓑]\n\ndef preserves_limits_of_shape_pempty_of_preserves_terminal\n [preserves_limit (functor.empty.{v} 𝓐) F] : preserves_limits_of_shape (discrete pempty) F :=\n{ preserves_limit := λ K,\n preserves_limit_of_iso_diagram.{v v} F (functor.empty_ext (functor.empty 𝓐) _) }\n\ndef preserves_terminal_object_of_preserves_zero_morphisms\n [functor.preserves_zero_morphisms F] : preserves_limit (functor.empty 𝓐) F :=\npreserves_terminal_of_iso F $\n (F.map_iso has_zero_object.zero_iso_terminal.symm).trans $\n (functor.map_zero_object F).trans $\n has_zero_object.zero_iso_terminal\n\ndef iso_of_ι {X Y : 𝓐} (f g : X ⟶ Y) (c : cone (parallel_pair f g)) :\n c ≅ fork.of_ι (fork.ι c) (fork.condition c) :=\nfork.ext (iso.refl _) (by tidy)\n\ndef preserves_equalizer_of_preserves_kernels [F.additive]\n [∀ {X Y} (f : X ⟶ Y), preserves_limit (parallel_pair f 0) F] {X Y : 𝓐}\n (f g : X ⟶ Y) : preserves_limit (parallel_pair f g) F :=\nbegin\n constructor, intros c i,\n let c' := preadditive.is_limit_kernel_fork_of_fork (i.of_iso_limit (iso_of_ι _ _ c)),\n let iFc := is_limit_fork_map_of_is_limit' F (by simp) c',\n apply is_limit.of_iso_limit _ ((cones.functoriality _ F).map_iso (iso_of_ι _ _ c).symm),\n apply (is_limit_map_cone_fork_equiv F (fork.condition c)).inv_fun,\n let p : parallel_pair (F.map (f - g)) 0 ≅ parallel_pair (F.map f - F.map g) 0,\n { exact parallel_pair.ext (iso.refl _) (iso.refl _) (by simp) (by simp) },\n refine is_limit.of_iso_limit (preadditive.is_limit_fork_of_kernel_fork\n ((is_limit.postcompose_hom_equiv p _).symm iFc)) _,\n refine fork.ext (iso.refl _) _,\n dsimp only [p, preadditive.fork_of_kernel_fork, cones.postcompose, ← fork.app_zero_eq_ι],\n simp [- fork.app_zero_eq_ι]\nend\n\ndef preserves_equalizers_of_preserves_kernels [F.additive]\n [∀ {X Y} (f : X ⟶ Y), preserves_limit (parallel_pair f 0) F] :\n preserves_limits_of_shape walking_parallel_pair F :=\n{ preserves_limit := λ K,\n begin\n letI := preserves_equalizer_of_preserves_kernels F\n (K.map walking_parallel_pair_hom.left) (K.map walking_parallel_pair_hom.right),\n apply preserves_limit_of_iso_diagram F (diagram_iso_parallel_pair K).symm\n end }\n\n-- todo: unify with `exact_comp_mono_iff`\nlemma exact_comp_mono_iff' {X Y Z A : 𝓐} (f : X ⟶ Y) (g : Y ⟶ Z) (h : Z ⟶ A) [mono h]:\n exact f (g ≫ h) ↔ exact f g :=\nbegin\n refine ⟨λ hfg, ⟨zero_of_comp_mono h (by rw [category.assoc, hfg.1]), _⟩, λ h, exact_comp_mono h⟩,\n rw ← (iso.eq_comp_inv _).1 (image_to_kernel_comp_mono _ _ h hfg.1),\n haveI := hfg.2, apply epi_comp\nend\n\nend\n\nlemma preserves_finite_limits_of_preserves_mono_preserves_finite_colimits\n {𝓐 : Type u₁} {𝓑 : Type u₂} [category.{v} 𝓐] [category.{v} 𝓑] [abelian 𝓐] [abelian 𝓑]\n (F : 𝓐 ⥤ 𝓑) (h1 : ∀ ⦃X Y : 𝓐⦄ (f : X ⟶ Y), mono f → mono (F.map f))\n [preserves_finite_colimits F] :\n preserves_finite_limits F :=\nbegin\n haveI : preserves_binary_biproducts F,\n { apply preserves_binary_biproducts_of_preserves_binary_coproducts },\n haveI : preserves_limits_of_shape (discrete walking_pair) F,\n { apply preserves_binary_products_of_preserves_binary_biproducts },\n haveI : F.additive,\n { apply functor.additive_of_preserves_binary_biproducts },\n haveI : ∀ {X Y} (f : X ⟶ Y), preserves_limit (parallel_pair f 0) F,\n { intros X Y f,\n constructor,\n intros c hc,\n suffices hF : exact (F.map (fork.ι c)) (F.map f),\n { haveI : mono (F.map (fork.ι c)),\n { apply h1,\n exact limits.mono_of_is_limit_fork hc },\n let := abelian.is_limit_of_exact_of_mono _ _ hF,\n let α : parallel_pair f 0 ⋙ F ≅ parallel_pair (F.map f) 0,\n { refine diagram_iso_parallel_pair _ ≪≫ _,\n refine parallel_pair.ext (iso.refl _) (iso.refl _) (by simp) (by simp) },\n refine is_limit.postcompose_hom_equiv α _ _,\n refine this.of_iso_limit (cones.ext (iso.refl _) _),\n rintro (_|_),\n { simp, dsimp, simp },\n { simp } },\n let hc' := hc.of_iso_limit (iso_of_ι _ _ _),\n have := abelian.exact_of_is_kernel _ _ (kernel_fork.condition c) hc',\n simp_rw ← image.fac f at this,\n rw exact_comp_mono_iff' at this,\n let := abelian.is_colimit_of_exact_of_epi _ _ this,\n let q := is_colimit_cofork_map_of_is_colimit' F _ this,\n haveI : mono (F.map (image.ι f)),\n { apply h1, apply_instance },\n simp_rw ← image.fac f,\n rw [functor.map_comp, exact_comp_mono_iff'],\n exact abelian.exact_of_is_cokernel _ _ _ q },\n haveI : preserves_limits_of_shape walking_parallel_pair.{v} F,\n { apply preserves_equalizers_of_preserves_kernels },\n haveI : preserves_limit (functor.empty 𝓐) F,\n { apply preserves_terminal_object_of_preserves_zero_morphisms },\n haveI : preserves_limits_of_shape (discrete.{v} pempty) F,\n { apply preserves_limits_of_shape_pempty_of_preserves_terminal, },\n haveI p := preserves_finite_products_of_preserves_binary_and_terminal F,\n exact @preserves_finite_limits_of_preserves_equalizers_and_finite_products\n _ _ _ _ _ _ _ _ p,\nend\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/for_mathlib/preserves_finite_limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.39233683016710835, "lm_q1q2_score": 0.22955673216721217}} {"text": "import for_mathlib.derived.Ext_lemmas\nimport for_mathlib.Cech.homotopy\nimport for_mathlib.acyclic\nimport for_mathlib.exact_seq4\nimport for_mathlib.cech\nimport for_mathlib.chain_complex_exact\nimport for_mathlib.abelian_sheaves.exact\nimport for_mathlib.Cech.homotopy\nimport for_mathlib.wide_pullback_iso\nimport for_mathlib.equivalence_additive\nimport for_mathlib.op\n\nimport condensed.adjunctions2\nimport condensed.projective_resolution\nimport condensed.extr.equivalence\n.\n\nnoncomputable theory\n\nuniverses u\n\nopen category_theory category_theory.limits homotopy_category opposite\nopen function (surjective)\n\nnamespace condensed\n\nset_option pp.universes true\n\n-- ANNOYING!\ninstance presheaf_abelian : abelian (Profinite.{u}ᵒᵖ ⥤ Ab.{u+1}) :=\ncategory_theory.functor_category_is_abelian.{(u+2) u (u+1)}\n\n-- ANNOYING!\ninstance ExtrDisc_presheaf_abelian : abelian (ExtrDisc.{u}ᵒᵖ ⥤ Ab.{u+1}) :=\ncategory_theory.functor_category_is_abelian.{(u+2) u (u+1)}\n\ninstance ExtrSheaf_abelian' : abelian (Sheaf ExtrDisc.proetale_topology.{u} Ab.{u+1}) :=\ncategory_theory.Sheaf.abelian.{(u+2) u (u+1)}\n\ninstance ExtrSheaf_abelian : abelian (ExtrSheaf.{u} Ab.{u+1}) :=\ncategory_theory.Sheaf.abelian.{(u+2) u (u+1)}\n\ndef Profinite_to_presheaf_Ab : Profinite.{u} ⥤ Profinite.{u}ᵒᵖ ⥤ Ab.{u+1} :=\nyoneda ⋙ (whiskering_right _ _ _).obj (ulift_functor.{u+1} ⋙ AddCommGroup.free)\n\ndef Profinite_to_ExtrDisc_presheaf : Profinite.{u} ⥤ ExtrDisc.{u}ᵒᵖ ⥤ Type (u+1) :=\nyoneda ⋙ (whiskering_left _ _ _).obj ExtrDisc_to_Profinite.op ⋙\n (whiskering_right _ _ _).obj ulift_functor.{u+1}\n\ndef Profinite_to_ExtrDisc_presheaf_Ab : Profinite.{u} ⥤ ExtrDisc.{u}ᵒᵖ ⥤ Ab.{u+1} :=\nyoneda ⋙ (whiskering_left _ _ _).obj ExtrDisc_to_Profinite.op ⋙\n (whiskering_right _ _ _).obj (ulift_functor.{u+1} ⋙ AddCommGroup.free)\n\ndef unsheafified_free_Cech' (F : arrow Profinite.{u}) :\n chain_complex (Profinite.{u}ᵒᵖ ⥤ Ab.{u+1}) ℕ :=\nsimplicial_object.augmented.to_complex $\n(((simplicial_object.augmented.whiskering _ _).obj Profinite_to_presheaf_Ab).obj\n F.augmented_cech_nerve)\n\ndef unsheafified_free_ExtrDiscr_Cech (F : arrow Profinite.{u}) :\n chain_complex (ExtrDisc.{u}ᵒᵖ ⥤ Ab.{u+1}) ℕ :=\nsimplicial_object.augmented.to_complex $\n(((simplicial_object.augmented.whiskering _ _).obj Profinite_to_ExtrDisc_presheaf_Ab).obj\n F.augmented_cech_nerve)\n\ndef free_Cech' (F : arrow Profinite.{u}) :\n chain_complex (Condensed.{u} Ab.{u+1}) ℕ :=\n(((simplicial_object.augmented.whiskering _ _).obj\n (Profinite_to_Condensed ⋙ CondensedSet_to_Condensed_Ab)).obj\n F.augmented_cech_nerve).to_complex\n\ndef free_ExtrDisc_Cech' (F : arrow Profinite.{u}) :\n chain_complex (ExtrSheaf.{u} Ab.{u+1}) ℕ :=\n(((simplicial_object.augmented.whiskering _ _).obj\n (Profinite_to_ExtrDisc_presheaf_Ab ⋙ presheaf_to_Sheaf _ _)).obj\n F.augmented_cech_nerve).to_complex\n\ndef free_Cech (F : arrow Profinite.{u}) :\n chain_complex (Condensed.{u} Ab.{u+1}) ℤ :=\n(homological_complex.embed $ complex_shape.embedding.nat_down_int_down).obj (free_Cech' F)\n\ninstance Condensed_ExtrSheaf_equiv_additive :\n functor.additive (Condensed_ExtrSheaf_equiv Ab.{u+1}).inverse :=\nby constructor\n\ndef whiskering_Cech_comp_iso\n {C : Type*} [category C] {𝓐 : Type*} [category 𝓐] [abelian 𝓐] {𝓑 : Type*} [category 𝓑] [abelian 𝓑]\n (f : arrow C) [∀ (n : ℕ),\n has_wide_pullback f.right (λ (i : ulift (fin (n + 1))), f.left) (λ (i : ulift (fin (n + 1))), f.hom)]\n (F : C ⥤ 𝓐) (G : 𝓐 ⥤ 𝓑) (H : C ⥤ 𝓑) (E : F ⋙ G ≅ H) [G.additive] :\n (G.map_homological_complex _).obj ((((simplicial_object.augmented.whiskering _ _).obj F).obj\n f.augmented_cech_nerve).to_complex) ≅\n (((simplicial_object.augmented.whiskering _ _).obj H).obj f.augmented_cech_nerve).to_complex :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| 0 := E.app _\n| i+1 := E.app _\nend)\nbegin\n rintros i j (rfl : j + 1 = i),\n dsimp only [functor.map_homological_complex_obj_d,\n unsheafified_free_ExtrDiscr_Cech, free_ExtrDisc_Cech',\n simplicial_object.augmented.to_complex],\n rw [chain_complex.of_d, chain_complex.of_d],\n cases j,\n { dsimp only [whiskering_Cech_comp_iso._match_1],\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n nat_trans.comp_app, whisker_right_app, functor.const_comp_hom_app],\n rw [category.comp_id, category.comp_id, nat_iso.app_hom, ← E.hom.naturality],\n refl },\n {\n dsimp only [whiskering_Cech_comp_iso._match_1],\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.drop_obj,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n simplicial_object.whiskering_obj_obj_map,\n simplicial_object.boundary,\n nat_iso.app_hom],\n simp only [functor.map_sum, functor.map_zsmul, preadditive.comp_sum,\n preadditive.comp_zsmul, preadditive.sum_comp, preadditive.zsmul_comp],\n apply finset.sum_congr rfl, intros _ _,\n erw ← E.hom.naturality,\n refl, },\nend\n\n\ndef free_Cech'_iso_ExtrDisc (F : arrow Profinite.{u}) :\n ((Condensed_ExtrSheaf_equiv _).inverse.map_homological_complex _).obj (free_Cech' F) ≅\n free_ExtrDisc_Cech' F :=\nlet e := ExtrDisc_sheafification_iso in\nwhiskering_Cech_comp_iso F\n (Profinite_to_Condensed.{u} ⋙ CondensedSet_to_Condensed_Ab.{u})\n ((Condensed_ExtrSheaf_equiv.{u u+2} Ab.{u+1}).inverse)\n (Profinite_to_ExtrDisc_presheaf_Ab.{u} ⋙ presheaf_to_Sheaf.{u+2 u u+1} ExtrDisc.proetale_topology.{u} Ab.{u+1}) $\nnat_iso.of_components\n(λ S, e.symm.app _)\nbegin\n intros S T f,\n dsimp only [nat_iso.app_hom],\n erw e.symm.hom.naturality,\n refl,\nend\n\ninstance presheaf_to_Sheaf_additive :\n (presheaf_to_Sheaf.{u+2 u u+1} ExtrDisc.proetale_topology.{u} Ab.{u+1}).additive :=\ncategory_theory.Sheaf.presheaf_to_Sheaf_additive\n\ndef acyclic_of_exact.induction_step_ex₂_aux\n {C : Type*} [category C] {𝓐 : Type*} [category 𝓐] [abelian 𝓐] {𝓑 : Type*} [category 𝓑] [abelian 𝓑]\n (f : arrow C) [∀ (n : ℕ),\n has_wide_pullback f.right (λ (i : ulift (fin (n + 1))), f.left) (λ (i : ulift (fin (n + 1))), f.hom)]\n (F : C ⥤ 𝓐) (G : 𝓐ᵒᵖ ⥤ 𝓑) [G.additive] :\n (G.map_homological_complex _).obj ((((simplicial_object.augmented.whiskering _ _).obj F).obj\n f.augmented_cech_nerve).to_complex).op ≅\n (((cosimplicial_object.augmented.whiskering _ _).obj (F.op ⋙ G)).obj\n f.augmented_cech_nerve.right_op).to_cocomplex :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| 0 := iso.refl _\n| i+1 := iso.refl _\nend)\nbegin\n rintros i j (rfl : i + 1 = j),\n dsimp only [functor.map_homological_complex_obj_d,\n unsheafified_free_ExtrDiscr_Cech, free_ExtrDisc_Cech',\n cosimplicial_object.augmented.to_cocomplex,\n simplicial_object.augmented.to_complex, homological_complex.op_d],\n rw [cochain_complex.of_d, chain_complex.of_d],\n cases i,\n { refine (category.id_comp _).trans ((category.comp_id _).trans _).symm,\n dsimp only [simplicial_object.augmented.to_complex_d,\n cosimplicial_object.augmented.to_cocomplex_d,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n cosimplicial_object.augmented.whiskering_obj_2,\n cosimplicial_object.augmented.whiskering_obj,\n nat_trans.comp_app, whisker_right_app,\n functor.const_comp_hom_app, functor.const_comp_inv_app],\n rw [category.comp_id, category.id_comp],\n refl, },\n { refine (category.id_comp _).trans ((category.comp_id _).trans _).symm,\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.drop_obj,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n simplicial_object.whiskering_obj_obj_map,\n simplicial_object.boundary,\n cosimplicial_object.augmented.to_cocomplex_d,\n cosimplicial_object.augmented.drop_obj,\n cosimplicial_object.augmented.whiskering_obj_2,\n cosimplicial_object.augmented.whiskering_obj,\n cosimplicial_object.whiskering_obj_obj_map,\n cosimplicial_object.coboundary],\n simp only [G.map_sum, G.map_zsmul, op_sum, op_zsmul],\n refl, },\nend\n\ndef free_ExtrDisc_Cech'_iso (F : arrow Profinite.{u}) :\n free_ExtrDisc_Cech' F ≅\n ((presheaf_to_Sheaf _ _).map_homological_complex _).obj (unsheafified_free_ExtrDiscr_Cech F) :=\n(whiskering_Cech_comp_iso F _ _ _ $ iso.refl _).symm\n/-\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| 0 := iso.refl _\n| i+1 := iso.refl _\nend)\nbegin\n rintros i j (rfl : j + 1 = i),\n dsimp only [functor.map_homological_complex_obj_d,\n unsheafified_free_ExtrDiscr_Cech, free_ExtrDisc_Cech',\n simplicial_object.augmented.to_complex],\n rw [chain_complex.of_d, chain_complex.of_d],\n cases j,\n { refine (category.id_comp _).trans ((category.comp_id _).trans _).symm,\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n nat_trans.comp_app, whisker_right_app, functor.const_comp_hom_app],\n rw [category.comp_id, category.comp_id],\n refl, },\n { refine (category.id_comp _).trans ((category.comp_id _).trans _).symm,\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.drop_obj,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n simplicial_object.whiskering_obj_obj_map,\n simplicial_object.boundary],\n simp only [functor.map_sum, functor.map_zsmul],\n refl, },\nend\n-/\n\n/-\ndef free_Cech_iso (F : arrow Profinite.{u}) :\n free_Cech F ≅ (homological_complex.embed $ complex_shape.embedding.nat_down_int_down).obj\n ((presheaf_to_Condensed_Ab.map_homological_complex _).obj\n (unsheafified_free_Cech' F)) :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| int.of_nat 0 := iso.refl _\n| int.of_nat (n+1) := iso.refl _\n| -[1+i] := iso.refl _\nend)\n(by admit)\n-/\n\n-- SO ANNOYING\ninstance evaluation_additive (X : ExtrDisc.{u}) :\n functor.additive ((evaluation ExtrDisc.{u}ᵒᵖ Ab.{u+1}).obj (op X)) :=\ncategory_theory.evaluation_additive.{(u+2) u (u+1)} _\n\ndef evaluated_free_ExtrDisc_Cech (F : arrow Profinite.{u}) (X : ExtrDisc.{u}) :\n chain_complex Ab.{u+1} ℕ :=\n(((simplicial_object.augmented.whiskering _ _).obj\n AddCommGroup.free).obj $\n ((Profinite_to_ExtrDisc_presheaf.flip.obj (op X)).map_arrow.obj F).augmented_cech_nerve).to_complex\n\n.\n\ndef yet_another_iso (F : arrow Profinite.{u}) (X : ExtrDisc.{u}) :\n (((evaluation.{u u+1 u+1 u+2} ExtrDisc.{u}ᵒᵖ Ab.{u+1}).obj\n (op X)).map_homological_complex\n (complex_shape.down.{0} ℕ)).obj\n (unsheafified_free_ExtrDiscr_Cech.{u} F) ≅\n evaluated_free_ExtrDisc_Cech F X :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| 0 := iso.refl _\n| i+1 := begin apply AddCommGroup.free.map_iso, apply ulift_wide_pullback_iso, end\nend)\nbegin\n rintros (_|i) (_|j) ⟨rfl⟩,\n { dsimp [yet_another_iso._match_1, iso.refl_hom], rw category.comp_id,\n dsimp [evaluated_free_ExtrDisc_Cech, unsheafified_free_ExtrDiscr_Cech],\n rw if_pos (rfl : (1 : ℕ) = 0 + 1), erw category.id_comp,\n rw if_pos (rfl : (1 : ℕ) = 0 + 1), erw category.id_comp,\n apply free_abelian_group.lift.ext,\n rintro ⟨t⟩,\n dsimp [AddCommGroup.free, simplicial_object.augmented.to_complex_d],\n simp only [category.comp_id, comp_apply, free_abelian_group.map_of_apply],\n dsimp at t,\n dsimp [ulift_wide_pullback_iso, ulift_wide_pullback_iso_hom_aux,\n Profinite_to_ExtrDisc_presheaf_Ab], congr' 1,\n have := types_comp_apply\n (wide_pullback.lift.{u+1 u+2} (ulift_functor.{u+1 u}.map ((yoneda.{u u+1}.map\n (wide_pullback.base.{u u+1} (λ (_x : ulift.{u 0} (fin (0 + 0 + 1))), F.hom))).app\n (op.{u+2} X.val))) (λ (q : ulift.{u+1 0} (fin (0 + 0 + 1))), ulift_functor.{u+1 u}.map\n ((yoneda.{u u+1}.map (wide_pullback.π.{u u+1} (λ (_x : ulift.{u 0} (fin (0 + 0 + 1))),\n F.hom) {down := q.down})).app (op.{u+2} X.val))) _)\n (wide_pullback.base.{u+1 u+2} (λ (i : ulift.{u+1 0} (fin (0 + 0 + 1))),\n (Profinite_to_ExtrDisc_presheaf.{u}.map F.hom).app (op.{u+2} X)))\n (ulift.up t),\n rw ← this, clear this, rw wide_pullback.lift_base, refl },\n { dsimp [yet_another_iso._match_1,\n evaluated_free_ExtrDisc_Cech,\n unsheafified_free_ExtrDiscr_Cech],\n rw [if_pos, if_pos], swap, refl, swap, refl, rw [category.id_comp, category.id_comp],\n dsimp [simplicial_object.augmented.to_complex_d, simplicial_object.boundary],\n simp only [preadditive.sum_comp, preadditive.comp_sum, preadditive.zsmul_comp,\n preadditive.comp_zsmul, category_theory.nat_trans.app_sum,\n category_theory.nat_trans.app_zsmul],\n apply finset.sum_congr rfl, rintros i -, congr' 1,\n dsimp [simplicial_object.δ],\n\n apply free_abelian_group.lift.ext,\n rintro ⟨t⟩,\n simp only [comp_apply],\n dsimp [AddCommGroup.free, Profinite_to_ExtrDisc_presheaf_Ab], congr' 1,\n dsimp [ulift_wide_pullback_iso, ulift_wide_pullback_iso_hom_aux],\n\n let f1 := wide_pullback.lift.{u+1 u+2} (wide_pullback.base.{u+1 u+2} (λ (i : ulift.{u+1 0}\n (fin (j + 1 + 1))), (Profinite_to_ExtrDisc_presheaf.{u}.map F.hom).app (op.{u+2} X)))\n (λ (i_1 : ulift.{u+1 0} (fin (j + 1))), wide_pullback.π.{u+1 u+2} (λ (i : ulift.{u+1 0}\n (fin (j + 1 + 1))), (Profinite_to_ExtrDisc_presheaf.{u}.map F.hom).app (op.{u+2} X))\n {down := (simplex_category.hom.to_order_hom (simplex_category.δ i)) i_1.down}) _,\n\n let f2 := wide_pullback.lift.{u+1 u+2} (ulift_functor.{u+1 u}.map ((yoneda.{u u+1}.map\n (wide_pullback.base.{u u+1} (λ (_x : ulift.{u 0} (fin (j.succ + 0 + 1))), F.hom))).app\n (op.{u+2} X.val))) (λ (q : ulift.{u+1 0} (fin (j.succ + 0 + 1))), ulift_functor.{u+1 u}.map\n ((yoneda.{u u+1}.map (wide_pullback.π.{u u+1} (λ (_x : ulift.{u 0} (fin (j.succ + 0 + 1))),\n F.hom) {down := q.down})).app (op.{u+2} X.val))) _,\n\n let f3 := wide_pullback.lift.{u+1 u+2} (ulift_functor.{u+1 u}.map ((yoneda.{u u+1}.map\n (wide_pullback.base.{u u+1} (λ (_x : ulift.{u 0} (fin (j + 0 + 1))), F.hom))).app\n (op.{u+2} X.val))) (λ (q : ulift.{u+1 0} (fin (j + 0 + 1))), ulift_functor.{u+1 u}.map\n ((yoneda.{u u+1}.map (wide_pullback.π.{u u+1} (λ (_x : ulift.{u 0} (fin (j + 0 + 1))),\n F.hom) {down := q.down})).app (op.{u+2} X.val))) _,\n\n change (f2 ≫ f1) _ = f3 _,\n\n let f4 := wide_pullback.lift.{u u+1} (wide_pullback.base.{u u+1} (λ (i : ulift.{u 0}\n (fin (j + 1 + 1))), F.hom)) (λ (i_1 : ulift.{u 0} (fin (j + 1))), wide_pullback.π.{u u+1}\n (λ (i : ulift.{u 0} (fin (j + 1 + 1))), F.hom) {down := (simplex_category.hom.to_order_hom\n (simplex_category.δ i)) i_1.down}) _,\n\n suffices : f2 ≫ f1 = ((yoneda'.map f4).app (op X.val) ≫ f3),\n { rw this, refl },\n\n apply wide_pullback.hom_ext,\n\n { intros k,\n dsimp [f4,f3,f2,f1],\n simp only [category.assoc, wide_pullback.lift_π, wide_pullback.lift_π_assoc],\n erw [wide_pullback.lift_π],\n erw [← functor.map_comp, ← nat_trans.comp_app, ← functor.map_comp, wide_pullback.lift_π] },\n\n { dsimp [f4,f3,f2,f1],\n simp only [category.assoc, wide_pullback.lift_base, wide_pullback.lift_base_assoc],\n erw wide_pullback.lift_base,\n erw [← functor.map_comp, ← nat_trans.comp_app, ← functor.map_comp,\n wide_pullback.lift_base] } }\nend\n\nlemma free_Cech_exact (F : arrow Profinite.{u}) (hF : function.surjective F.hom) : ∀ (n : ℤ),\n is_zero $ (free_Cech F).homology n :=\nbegin\n dsimp only [free_Cech],\n rw chain_complex.homology_zero_iff_homology_zero,\n rw chain_complex.homology_zero_iff_map_homology_zero _\n (Condensed_ExtrSheaf_equiv Ab.{u+1}).symm,\n intros i,\n dsimp only [equivalence.symm_functor],\n let E := (_root_.homology_functor _ _ i).map_iso (free_Cech'_iso_ExtrDisc F),\n apply is_zero.of_iso _ E, clear E,\n let E := (_root_.homology_functor _ _ i).map_iso (free_ExtrDisc_Cech'_iso F),\n apply is_zero.of_iso _ E, clear E,\n dsimp only [_root_.homology_functor],\n revert i,\n apply category_theory.Sheaf.map_presheaf_to_Sheaf_homology_zero_of_homology_zero.{(u+2) u (u+1)},\n apply category_theory.homology_zero_of_eval.{(u+2) u (u+1)},\n any_goals { apply_instance },\n intros X, tactic.op_induction',\n intros i,\n let E := (_root_.homology_functor _ _ i).map_iso (yet_another_iso F X),\n apply is_zero.of_iso _ E,\n -- Now we can use the splitting similarly to arrow.conerve_to_cocomplex_homology_is_zero\n -- but we need a dual variant.\n let G := ((Profinite_to_ExtrDisc_presheaf.flip.obj (op X)).map_arrow.obj F),\n haveI : G.split,\n { suffices : function.surjective G.hom,\n { refine ⟨λ i, (this i).some, _⟩,\n ext1 i, exact (this i).some_spec },\n dsimp [G, functor.map_arrow, Profinite_to_ExtrDisc_presheaf, ulift_functor, yoneda],\n rintros ⟨e⟩,\n use ExtrDisc.lift _ hF e,\n ext1,\n dsimp,\n rw ExtrDisc.lift_lifts },\n apply arrow.nerve_to_complex_homology_is_zero AddCommGroup.free G,\n recover,\nend\n\nlemma free_Cech_kernel_SES (F : arrow Profinite.{u}) (hF : function.surjective F.hom) : ∀ n,\n short_exact (kernel.ι $ (free_Cech F).d (n+1+1) (n+1)) (delta_to_kernel _ (n+1+1) (n+1) n) :=\nbegin\n erw ← is_acyclic_iff_short_exact_to_cycles' (free_Cech F), exact free_Cech_exact F hF\nend\n\nvariable (M : Condensed.{u} Ab.{u+1})\n\nabbreviation HH (i : ℤ) (S : Profinite.{u}) (M : Condensed.{u} Ab.{u+1}) :=\n((Ext' i).obj (op $ (CondensedSet_to_Condensed_Ab).obj $ Profinite.to_Condensed S)).obj M\n\ndef acyclic_of_exact.IH (n : ℤ) : Prop := ∀ S, ∀ i > 0, i ≤ n → is_zero (HH i S M)\n\n/-- Consider the following commutative diagram\n```\n O₀\n ↓\nA₁ → B₁ → C₁ → O₁\n ↘ ↓\n B₂\n ↓ ↘\nO₃ → B₃ → C₃\n```\nwhere `O₀`, `O₁`, and `O₃` are zero objects, and all sequence are exact.\n\nThen `C₁` is also a zero object.\n-/\nlemma acyclic_of_exact.induction_step_aux {𝓐 : Type*} [category 𝓐] [abelian 𝓐]\n {O₀ O₁ O₃ A₁ B₁ C₁ B₂ B₃ C₃ : 𝓐}\n {α₁ : A₁ ⟶ B₁} {β₁ : B₁ ⟶ C₁} {γ₁ : C₁ ⟶ O₁} (ex₁ : exact_seq 𝓐 [α₁, β₁, γ₁])\n {d₁ : A₁ ⟶ B₂} {d₂ : B₂ ⟶ C₃} (exd : exact d₁ d₂)\n {b₀ : O₀ ⟶ B₁} {b₁ : B₁ ⟶ B₂} {b₂ : B₂ ⟶ B₃} (exb : exact_seq 𝓐 [b₀, b₁, b₂])\n {α₃ : O₃ ⟶ B₃} {β₃ : B₃ ⟶ C₃} (ex₃ : exact α₃ β₃)\n (hO₀ : is_zero O₀) (hO₁ : is_zero O₁) (hO₃ : is_zero O₃)\n (tr₁ : α₁ ≫ b₁ = d₁) (tr₂ : b₂ ≫ β₃ = d₂) :\n is_zero C₁ :=\nbegin\n refine (ex₁.drop 1).pair.is_zero_of_eq_zero_eq_zero\n (ex₁.pair.eq_zero_of_epi _) (hO₁.eq_of_tgt _ _),\n haveI : mono b₁ := exb.pair.mono_of_eq_zero (hO₀.eq_of_src _ _),\n haveI : mono β₃ := ex₃.mono_of_eq_zero (hO₃.eq_of_src _ _),\n let l' := abelian.is_limit_of_exact_of_mono _ _ (exb.drop 1).pair,\n let l := is_kernel_comp_mono l' β₃ tr₂.symm,\n obtain rfl :\n α₁ = kernel.lift _ _ exd.w ≫ (is_limit.cone_point_unique_up_to_iso (limit.is_limit _) l).hom,\n { erw [← cancel_mono b₁, category.assoc,\n is_limit.cone_point_unique_up_to_iso_hom_comp _ _ walking_parallel_pair.zero, is_limit.fac,\n fork.of_ι_π_app, tr₁] },\n apply epi_comp\nend\n\nlemma acyclic_of_exact.induction_step_ex₁\n (F : arrow Profinite.{u})\n (h : ∀ i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n F.augmented_cech_nerve.right_op).to_cocomplex).homology i)) :\n let C := (((cosimplicial_object.augmented.whiskering Profiniteᵒᵖ Ab).obj\n ((Profinite_to_Condensed ⋙ CondensedSet_to_Condensed_Ab).op ⋙ preadditive_yoneda.obj M)).obj\n F.augmented_cech_nerve.right_op).to_cocomplex\n in ∀ i, is_zero (C.homology i) :=\nbegin\n intros C i,\n apply is_zero.of_iso (h i),\n refine (_root_.homology_functor _ _ i).map_iso _,\n refine cosimplicial_object.augmented.cocomplex.map_iso _,\n refine iso.app (functor.map_iso _ (condensed.profinite_free_adj _)) _,\nend\n\nlemma acyclic_of_exact.induction_step_ex₂\n (F : arrow Profinite.{u})\n (h : let C := (((cosimplicial_object.augmented.whiskering Profiniteᵒᵖ Ab).obj\n ((Profinite_to_Condensed ⋙ CondensedSet_to_Condensed_Ab).op ⋙ preadditive_yoneda.obj M)).obj\n F.augmented_cech_nerve.right_op).to_cocomplex\n in ∀ i, is_zero (C.homology i)) :\n ∀ i, is_zero ((((preadditive_yoneda.obj M).map_homological_complex _).obj (free_Cech' F).op).homology i) :=\nbegin\n intro i, apply (h i).of_iso,\n refine (_root_.homology_functor _ _ _).map_iso _,\n apply acyclic_of_exact.induction_step_ex₂_aux,\nend\n\nlemma int.of_nat_add_one (i : ℕ) : int.of_nat i + 1 = int.of_nat (i+1) := rfl\n\nlemma complex_shape.embedding.nat_down_int_down.r_int_of_nat (i : ℕ) :\n complex_shape.embedding.nat_down_int_down.r (int.of_nat i) = option.some i := rfl\n\n-- move me\nlemma cochain_complex.mono_of_is_zero_homology_0\n {𝓐 : Type*} [category 𝓐] [abelian 𝓐]\n (C : cochain_complex 𝓐 ℕ) (h : is_zero $ C.homology 0) :\n mono (C.d 0 1) :=\nbegin\n delta homological_complex.homology at h,\n simp only [homological_complex.d_to_eq_zero, cochain_complex.prev_nat_zero, eq_self_iff_true] at h,\n have f := homology_iso_cokernel_lift (C.d_to 0) (C.d_from 0) (by simp),\n simp only [homological_complex.d_to_eq_zero, cochain_complex.prev_nat_zero, eq_self_iff_true,\n kernel.lift_zero] at f,\n replace f := f ≪≫ limits.cokernel_zero_iso_target,\n simp_rw [C.d_from_eq (show (complex_shape.up ℕ).rel 0 1, by simp)] at f h,\n exact preadditive.mono_of_kernel_zero (is_zero.eq_of_src (is_zero.of_iso h\n (f ≪≫ (kernel_comp_mono _ _)).symm) _ _)\nend\n\nlemma acyclic_of_exact.induction_step_ex₃\n (F : arrow Profinite.{u}) (i : ℤ)\n (h : ∀ i, is_zero ((((preadditive_yoneda.obj M).map_homological_complex _).obj (free_Cech' F).op).homology i)) :\n exact ((preadditive_yoneda.obj M).map $ ((free_Cech F).d (i+1) i).op)\n ((preadditive_yoneda.obj M).map $ ((free_Cech F).d (i+1+1) (i+1)).op) :=\nbegin\n rcases i with (i|i),\n { delta free_Cech,\n dsimp only [homological_complex.embed, homological_complex.embed.obj],\n rw [int.of_nat_add_one, int.of_nat_add_one],\n erw [complex_shape.embedding.nat_down_int_down.r_int_of_nat],\n erw [complex_shape.embedding.nat_down_int_down.r_int_of_nat],\n erw [complex_shape.embedding.nat_down_int_down.r_int_of_nat],\n dsimp only [homological_complex.embed.d],\n refine exact_of_homology_is_zero ((h (i+1)).of_iso $ _),\n { rw [← functor.map_comp, ← op_comp, homological_complex.d_comp_d, op_zero, functor.map_zero] },\n clear h,\n refine _ ≪≫ (homology_iso _ i (i+1) (i+1+1) _ _).symm,\n swap, { dsimp, refl }, swap, { dsimp, refl },\n refl, },\n { have aux : (preadditive_yoneda.obj M).map ((free_Cech F).d (-[1+ i] + 1) -[1+ i]).op = 0,\n { cases i; erw [op_zero, functor.map_zero], },\n rw [aux], clear aux, apply_with exact_zero_left_of_mono {instances:=ff}, { apply_instance },\n cases i,\n { exact cochain_complex.mono_of_is_zero_homology_0 _ (h 0), },\n { apply mono_of_is_zero_object,\n rw [is_zero_iff_id_eq_zero, ← category_theory.functor.map_id,\n is_zero_iff_id_eq_zero.mp, functor.map_zero],\n refine (is_zero_zero _).op, } },\nend\n\nlemma acyclic_of_exact.induction_step_ex₄\n (F : arrow Profinite.{u}) (i : ℤ)\n (h : exact ((preadditive_yoneda.obj M).map $ ((free_Cech F).d (i+1) i).op)\n ((preadditive_yoneda.obj M).map $ ((free_Cech F).d (i+1+1) (i+1)).op)) :\n exact (((Ext' 0).flip.obj M).map $ ((free_Cech F).d (i+1) i).op)\n (((Ext' 0).flip.obj M).map $ ((free_Cech F).d (i+1+1) (i+1)).op) :=\nbegin\n let e := (bounded_derived_category.Ext'_zero_flip_iso _ M).symm,\n apply preadditive.exact_of_iso_of_exact' _ _ _ _ (e.app _) (e.app _) (e.app _) _ _ h,\n { simp only [nat_iso.app_hom, nat_trans.naturality], },\n { simp only [nat_iso.app_hom, nat_trans.naturality], }\nend\n\nlemma acyclic_of_exact.induction_step_ex\n (F : arrow Profinite.{u}) (surj : function.surjective F.hom)\n (h : ∀ i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n (i : ℤ) :\n exact (((Ext' 0).flip.obj M).map $ ((free_Cech F).d (i+1) i).op)\n (((Ext' 0).flip.obj M).map $ ((free_Cech F).d (i+1+1) (i+1)).op) :=\nbegin\n apply acyclic_of_exact.induction_step_ex₄,\n apply acyclic_of_exact.induction_step_ex₃,\n apply acyclic_of_exact.induction_step_ex₂,\n apply acyclic_of_exact.induction_step_ex₁ _ F h,\nend\n\nlemma acyclic_of_exact.induction_step\n (h : ∀ (F : arrow Profinite.{u}) (surj : function.surjective F.hom),\n ∀ i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n (n : ℤ) (ih : acyclic_of_exact.IH M n) :\n acyclic_of_exact.IH M (n+1) :=\nbegin\n intros S i h1 h2,\n rw [le_iff_eq_or_lt, or_comm, int.lt_add_one_iff] at h2,\n cases h2 with h2 h2, { exact ih S i h1 h2 },\n subst i,\n let F := arrow.mk S.projective_presentation.f,\n have hF : function.surjective F.hom,\n { rw ← Profinite.epi_iff_surjective, apply projective_presentation.epi },\n let E := λ i, (Ext' i).flip.obj M,\n have ih' : ∀ (i j : ℤ) (h0i : 0 < i) (hin : i ≤ n),\n is_zero ((E i).obj (op ((free_Cech F).X j))),\n { intros i j h0i hin,\n cases j with j j,\n { cases j; exact ih _ _ h0i hin, },\n { apply bounded_derived_category.Ext'_zero_left_is_zero,\n exact (is_zero_zero _).op, } },\n let K := λ i, kernel ((free_Cech F).d (i + 1) i),\n have LES := λ i j, (free_Cech_kernel_SES F hF i).Ext'_five_term_exact_seq M j,\n have H1 : ∀ i > 0, is_zero ((E i).obj (op ((free_Cech F).X 1))),\n { intros i hi,\n apply bounded_derived_category.Ext'_is_zero_of_projective _ _ _ _ hi,\n apply_with Condensed_Ab.free.category_theory.projective {instances:=ff},\n rw [simplicial_object.augmented.drop_obj, arrow.augmented_cech_nerve_left],\n apply projective.of_iso (arrow.cech_nerve_obj_0 F).symm,\n apply projective_presentation.projective, },\n have aux0 : ∀ (i : ℤ) (h0i : 0 < i+1) (H : is_zero ((E i).obj (op $ K 0))),\n is_zero ((E (i+1)).obj (op $ K (-1))),\n { intros i h0i H,\n refine is_zero_of_exact_is_zero_is_zero _ _ ((LES (-1) i).drop 2).pair H (H1 _ h0i), },\n have aux : ∀ (i j : ℤ) (h0i : 0 < i+1) (hi : i+1 ≤ n) (H : is_zero ((E i).obj (op $ K (j+1)))),\n is_zero ((E (i+1)).obj (op $ K j)),\n { intros i j h0i hi H,\n refine is_zero_of_exact_is_zero_is_zero _ _ ((LES j i).drop 2).pair H _,\n refine ih' _ _ h0i hi },\n suffices : ∀ i j, 0 < i → -1 ≤ j → i + j = n → is_zero ((E i).obj (op $ K j)),\n { refine is_zero_of_exact_is_zero_is_zero _ _ (LES (-2) (n+1)).pair _ _; clear LES,\n { apply bounded_derived_category.Ext'_zero_left_is_zero,\n refine (is_zero_of_mono (kernel.ι _) _).op, refine is_zero_zero _, },\n { refine this (n+1) (-1) h1 le_rfl _, rw [← sub_eq_add_neg, add_sub_cancel] } },\n obtain ⟨n, rfl⟩ : ∃ k, k+1 = n := ⟨n-1, sub_add_cancel _ _⟩,\n suffices : is_zero ((E 1).obj (op $ K n)),\n { intro i,\n apply int.induction_on' i 1; clear i,\n { intros j h0i hj hijn, rw [add_comm (1:ℤ), add_left_inj] at hijn, subst j, exact this },\n { intros i hi IH j hi' hj hijn,\n rw le_iff_eq_or_lt at hj, cases hj with hj hj,\n { subst j, apply aux0 _ hi', apply IH; linarith only [hi, hijn] },\n { apply aux _ _ hi' _ (IH _ _ _ _); linarith only [hi, hijn, hj], } },\n { intros i hi IH j hi', exfalso, linarith only [hi, hi'] } },\n clear aux0 aux,\n have aux := λ i, ((LES i (-1)).drop 2).pair.cons (LES i 0),\n have exd := acyclic_of_exact.induction_step_ex M F hF (h F hF) (n+1+1),\n apply acyclic_of_exact.induction_step_aux\n ((LES n 0).drop 1) exd ((aux (n+1)).extract 0 3) (aux (n+1+1)).pair; clear LES aux exd,\n { apply Ext'_is_zero_of_neg, dec_trivial },\n { obtain (rfl|hn) : n = -1 ∨ 1 ≤ n + 1,\n { rw [or_iff_not_imp_right], intro h2, linarith only [h1, h2] },\n { exact H1 _ zero_lt_one },\n { exact ih' _ _ zero_lt_one hn } },\n { apply Ext'_is_zero_of_neg, dec_trivial },\n { conv_rhs { rw [← delta_to_kernel_ι _ _ _ (n+1), op_comp, functor.map_comp] }, refl },\n { conv_rhs { rw [← delta_to_kernel_ι _ _ _ (n+1+1), op_comp, functor.map_comp] }, refl },\nend\n\nlemma acyclic_of_exact\n (h : ∀ (F : arrow Profinite.{u}) (surj : function.surjective F.hom),\n ∀ i, is_zero\n (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n (S : Profinite.{u}) :\n ∀ i > 0, is_zero (HH i S M) :=\nbegin\n intros i hi,\n suffices : acyclic_of_exact.IH M i,\n { apply this S i hi le_rfl, },\n apply int.induction_on' i 0; clear hi i S,\n { intros S i h1 h2, exfalso, exact h2.not_lt h1 },\n { intros k hk, apply acyclic_of_exact.induction_step M h, },\n { rintros k hk aux S i h1 h2, exfalso, linarith only [hk, h1, h2] }\nend\n\nend condensed\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/condensed/acyclic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.35936413143782797, "lm_q1q2_score": 0.22892601815759242}} {"text": "/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Sébastien Gouëzel\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.uniform_space.cauchy\nimport Mathlib.topology.uniform_space.separation\nimport Mathlib.topology.dense_embedding\nimport Mathlib.PostPort\n\nuniverses u_1 u_2 u_3 \n\nnamespace Mathlib\n\n/-!\n# Theory of complete separated uniform spaces.\n\nThis file is for elementary lemmas that depend on both Cauchy filters and separation.\n-/\n\n/-In a separated space, a complete set is closed -/\n\ntheorem is_complete.is_closed {α : Type u_1} [uniform_space α] [separated_space α] {s : set α}\n (h : is_complete s) : is_closed s :=\n sorry\n\nnamespace dense_inducing\n\n\ntheorem continuous_extend_of_cauchy {α : Type u_1} [topological_space α] {β : Type u_2}\n [topological_space β] {γ : Type u_3} [uniform_space γ] [complete_space γ] [separated_space γ]\n {e : α → β} {f : α → γ} (de : dense_inducing e)\n (h : ∀ (b : β), cauchy (filter.map f (filter.comap e (nhds b)))) : continuous (extend de f) :=\n continuous_extend de fun (b : β) => complete_space.complete (h b)\n\nend Mathlib", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/topology/uniform_space/complete_separated_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6001883735630721, "lm_q2_score": 0.3812195662561499, "lm_q1q2_score": 0.2288035514416984}} {"text": "/-\nCopyright (c) 2018 Johannes Hölzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes Hölzl, Kenny Lau, Johan Commelin, Mario Carneiro, Kevin Buzzard\n-/\nimport group_theory.submonoid.basic\nimport algebra.big_operators.basic\nimport deprecated.group\n\n/-!\n# Unbundled submonoids (deprecated)\n\nThis file is deprecated, and is no longer imported by anything in mathlib other than other\ndeprecated files, and test files. You should not need to import it.\n\nThis file defines unbundled multiplicative and additive submonoids. Instead of using this file,\nplease use `submonoid G` and `add_submonoid A`, defined in `group_theory.submonoid.basic`.\n\n## Main definitions\n\n`is_add_submonoid (S : set M)` : the predicate that `S` is the underlying subset of an additive\nsubmonoid of `M`. The bundled variant `add_submonoid M` should be used in preference to this.\n\n`is_submonoid (S : set M)` : the predicate that `S` is the underlying subset of a submonoid\nof `M`. The bundled variant `submonoid M` should be used in preference to this.\n\n## Tags\nsubmonoid, submonoids, is_submonoid\n-/\n\nopen_locale big_operators\n\nvariables {M : Type*} [monoid M] {s : set M}\nvariables {A : Type*} [add_monoid A] {t : set A}\n\n/-- `s` is an additive submonoid: a set containing 0 and closed under addition.\nNote that this structure is deprecated, and the bundled variant `add_submonoid A` should be\npreferred. -/\nstructure is_add_submonoid (s : set A) : Prop :=\n(zero_mem : (0:A) ∈ s)\n(add_mem {a b} : a ∈ s → b ∈ s → a + b ∈ s)\n\n/-- `s` is a submonoid: a set containing 1 and closed under multiplication.\nNote that this structure is deprecated, and the bundled variant `submonoid M` should be\npreferred. -/\n@[to_additive]\nstructure is_submonoid (s : set M) : Prop :=\n(one_mem : (1:M) ∈ s)\n(mul_mem {a b} : a ∈ s → b ∈ s → a * b ∈ s)\n\nlemma additive.is_add_submonoid\n {s : set M} : ∀ (is : is_submonoid s), @is_add_submonoid (additive M) _ s\n| ⟨h₁, h₂⟩ := ⟨h₁, @h₂⟩\n\ntheorem additive.is_add_submonoid_iff\n {s : set M} : @is_add_submonoid (additive M) _ s ↔ is_submonoid s :=\n⟨λ ⟨h₁, h₂⟩, ⟨h₁, @h₂⟩, additive.is_add_submonoid⟩\n\nlemma multiplicative.is_submonoid\n {s : set A} : ∀ (is : is_add_submonoid s), @is_submonoid (multiplicative A) _ s\n| ⟨h₁, h₂⟩ := ⟨h₁, @h₂⟩\n\ntheorem multiplicative.is_submonoid_iff\n {s : set A} : @is_submonoid (multiplicative A) _ s ↔ is_add_submonoid s :=\n⟨λ ⟨h₁, h₂⟩, ⟨h₁, @h₂⟩, multiplicative.is_submonoid⟩\n\n/-- The intersection of two submonoids of a monoid `M` is a submonoid of `M`. -/\n@[to_additive \"The intersection of two `add_submonoid`s of an `add_monoid` `M` is\nan `add_submonoid` of M.\"]\nlemma is_submonoid.inter {s₁ s₂ : set M} (is₁ : is_submonoid s₁) (is₂ : is_submonoid s₂) :\n is_submonoid (s₁ ∩ s₂) :=\n{ one_mem := ⟨is₁.one_mem, is₂.one_mem⟩,\n mul_mem := λ x y hx hy,\n ⟨is₁.mul_mem hx.1 hy.1, is₂.mul_mem hx.2 hy.2⟩ }\n\n/-- The intersection of an indexed set of submonoids of a monoid `M` is a submonoid of `M`. -/\n@[to_additive \"The intersection of an indexed set of `add_submonoid`s of an `add_monoid` `M` is\nan `add_submonoid` of `M`.\"]\nlemma is_submonoid.Inter {ι : Sort*} {s : ι → set M} (h : ∀ y : ι, is_submonoid (s y)) :\n is_submonoid (set.Inter s) :=\n{ one_mem := set.mem_Inter.2 $ λ y, (h y).one_mem,\n mul_mem := λ x₁ x₂ h₁ h₂, set.mem_Inter.2 $\n λ y, (h y).mul_mem (set.mem_Inter.1 h₁ y) (set.mem_Inter.1 h₂ y) }\n\n/-- The union of an indexed, directed, nonempty set of submonoids of a monoid `M` is a submonoid\n of `M`. -/\n@[to_additive \"The union of an indexed, directed, nonempty set\nof `add_submonoid`s of an `add_monoid` `M` is an `add_submonoid` of `M`. \"]\nlemma is_submonoid_Union_of_directed {ι : Type*} [hι : nonempty ι]\n {s : ι → set M} (hs : ∀ i, is_submonoid (s i))\n (directed : ∀ i j, ∃ k, s i ⊆ s k ∧ s j ⊆ s k) :\n is_submonoid (⋃i, s i) :=\n{ one_mem := let ⟨i⟩ := hι in set.mem_Union.2 ⟨i, (hs i).one_mem⟩,\n mul_mem := λ a b ha hb,\n let ⟨i, hi⟩ := set.mem_Union.1 ha in\n let ⟨j, hj⟩ := set.mem_Union.1 hb in\n let ⟨k, hk⟩ := directed i j in\n set.mem_Union.2 ⟨k, (hs k).mul_mem (hk.1 hi) (hk.2 hj)⟩ }\n\nsection powers\n\n/-- The set of natural number powers `1, x, x², ...` of an element `x` of a monoid. -/\n@[to_additive multiples\n\"The set of natural number multiples `0, x, 2x, ...` of an element `x` of an `add_monoid`.\"]\ndef powers (x : M) : set M := {y | ∃ n:ℕ, x^n = y}\n\n/-- 1 is in the set of natural number powers of an element of a monoid. -/\n@[to_additive \"0 is in the set of natural number multiples of an element of an `add_monoid`.\"]\nlemma powers.one_mem {x : M} : (1 : M) ∈ powers x := ⟨0, pow_zero _⟩\n\n/-- An element of a monoid is in the set of that element's natural number powers. -/\n@[to_additive\n\"An element of an `add_monoid` is in the set of that element's natural number multiples.\"]\nlemma powers.self_mem {x : M} : x ∈ powers x := ⟨1, pow_one _⟩\n\n/-- The set of natural number powers of an element of a monoid is closed under multiplication. -/\n@[to_additive\n\"The set of natural number multiples of an element of an `add_monoid` is closed under addition.\"]\nlemma powers.mul_mem {x y z : M} : (y ∈ powers x) → (z ∈ powers x) → (y * z ∈ powers x) :=\nλ ⟨n₁, h₁⟩ ⟨n₂, h₂⟩, ⟨n₁ + n₂, by simp only [pow_add, *]⟩\n\n/-- The set of natural number powers of an element of a monoid `M` is a submonoid of `M`. -/\n@[to_additive \"The set of natural number multiples of an element of\nan `add_monoid` `M` is an `add_submonoid` of `M`.\"]\nlemma powers.is_submonoid (x : M) : is_submonoid (powers x) :=\n{ one_mem := powers.one_mem,\n mul_mem := λ y z, powers.mul_mem }\n\n/-- A monoid is a submonoid of itself. -/\n@[to_additive \"An `add_monoid` is an `add_submonoid` of itself.\"]\nlemma univ.is_submonoid : is_submonoid (@set.univ M) := by split; simp\n\n/-- The preimage of a submonoid under a monoid hom is a submonoid of the domain. -/\n@[to_additive \"The preimage of an `add_submonoid` under an `add_monoid` hom is\nan `add_submonoid` of the domain.\"]\nlemma is_submonoid.preimage {N : Type*} [monoid N] {f : M → N} (hf : is_monoid_hom f)\n {s : set N} (hs : is_submonoid s) : is_submonoid (f ⁻¹' s) :=\n{ one_mem := show f 1 ∈ s, by rw is_monoid_hom.map_one hf; exact hs.one_mem,\n mul_mem := λ a b (ha : f a ∈ s) (hb : f b ∈ s),\n show f (a * b) ∈ s, by rw is_monoid_hom.map_mul hf; exact hs.mul_mem ha hb }\n\n/-- The image of a submonoid under a monoid hom is a submonoid of the codomain. -/\n@[to_additive \"The image of an `add_submonoid` under an `add_monoid`\nhom is an `add_submonoid` of the codomain.\"]\nlemma is_submonoid.image {γ : Type*} [monoid γ] {f : M → γ} (hf : is_monoid_hom f)\n {s : set M} (hs : is_submonoid s) : is_submonoid (f '' s) :=\n{ one_mem := ⟨1, hs.one_mem, hf.map_one⟩,\n mul_mem := λ a b ⟨x, hx⟩ ⟨y, hy⟩, ⟨x * y, hs.mul_mem hx.1 hy.1,\n by rw [hf.map_mul, hx.2, hy.2]⟩ }\n\n/-- The image of a monoid hom is a submonoid of the codomain. -/\n@[to_additive \"The image of an `add_monoid` hom is an `add_submonoid`\nof the codomain.\"]\nlemma range.is_submonoid {γ : Type*} [monoid γ] {f : M → γ} (hf : is_monoid_hom f) :\n is_submonoid (set.range f) :=\nby { rw ← set.image_univ, exact univ.is_submonoid.image hf }\n\n/-- Submonoids are closed under natural powers. -/\n@[to_additive is_add_submonoid.smul_mem\n\"An `add_submonoid` is closed under multiplication by naturals.\"]\nlemma is_submonoid.pow_mem {a : M} (hs : is_submonoid s) (h : a ∈ s) : ∀ {n : ℕ}, a ^ n ∈ s\n| 0 := by { rw pow_zero, exact hs.one_mem }\n| (n + 1) := by { rw pow_succ, exact hs.mul_mem h is_submonoid.pow_mem }\n\n/-- The set of natural number powers of an element of a submonoid is a subset of the submonoid. -/\n@[to_additive is_add_submonoid.multiples_subset \"The set of natural number multiples of an element\nof an `add_submonoid` is a subset of the `add_submonoid`.\"]\nlemma is_submonoid.power_subset {a : M} (hs : is_submonoid s) (h : a ∈ s) : powers a ⊆ s :=\nassume x ⟨n, hx⟩, hx ▸ hs.pow_mem h\n\nend powers\n\nnamespace is_submonoid\n\n/-- The product of a list of elements of a submonoid is an element of the submonoid. -/\n@[to_additive \"The sum of a list of elements of an `add_submonoid` is an element of the\n`add_submonoid`.\"]\nlemma list_prod_mem (hs : is_submonoid s) : ∀{l : list M}, (∀x∈l, x ∈ s) → l.prod ∈ s\n| [] h := hs.one_mem\n| (a::l) h :=\n suffices a * l.prod ∈ s, by simpa,\n have a ∈ s ∧ (∀x∈l, x ∈ s), by simpa using h,\n hs.mul_mem this.1 (list_prod_mem this.2)\n\n/-- The product of a multiset of elements of a submonoid of a `comm_monoid` is an element of\nthe submonoid. -/\n@[to_additive \"The sum of a multiset of elements of an `add_submonoid` of an `add_comm_monoid`\nis an element of the `add_submonoid`. \"]\nlemma multiset_prod_mem {M} [comm_monoid M] {s : set M} (hs : is_submonoid s) (m : multiset M) :\n (∀a∈m, a ∈ s) → m.prod ∈ s :=\nbegin\n refine quotient.induction_on m (assume l hl, _),\n rw [multiset.quot_mk_to_coe, multiset.coe_prod],\n exact list_prod_mem hs hl\nend\n\n/-- The product of elements of a submonoid of a `comm_monoid` indexed by a `finset` is an element\nof the submonoid. -/\n@[to_additive \"The sum of elements of an `add_submonoid` of an `add_comm_monoid` indexed by\na `finset` is an element of the `add_submonoid`.\"]\nlemma finset_prod_mem {M A} [comm_monoid M] {s : set M} (hs : is_submonoid s) (f : A → M) :\n ∀(t : finset A), (∀b∈t, f b ∈ s) → ∏ b in t, f b ∈ s\n| ⟨m, hm⟩ _ := multiset_prod_mem hs _ (by simpa)\n\nend is_submonoid\n\nnamespace add_monoid\n\n/-- The inductively defined membership predicate for the submonoid generated by a subset of a\n monoid. -/\ninductive in_closure (s : set A) : A → Prop\n| basic {a : A} : a ∈ s → in_closure a\n| zero : in_closure 0\n| add {a b : A} : in_closure a → in_closure b → in_closure (a + b)\n\nend add_monoid\n\nnamespace monoid\n\n/-- The inductively defined membership predicate for the `submonoid` generated by a subset of an\n monoid. -/\n@[to_additive]\ninductive in_closure (s : set M) : M → Prop\n| basic {a : M} : a ∈ s → in_closure a\n| one : in_closure 1\n| mul {a b : M} : in_closure a → in_closure b → in_closure (a * b)\n\n/-- The inductively defined submonoid generated by a subset of a monoid. -/\n@[to_additive \"The inductively defined `add_submonoid` genrated by a subset of an `add_monoid`.\"]\ndef closure (s : set M) : set M := {a | in_closure s a }\n\n@[to_additive]\nlemma closure.is_submonoid (s : set M) : is_submonoid (closure s) :=\n{ one_mem := in_closure.one, mul_mem := assume a b, in_closure.mul }\n\n/-- A subset of a monoid is contained in the submonoid it generates. -/\n@[to_additive \"A subset of an `add_monoid` is contained in the `add_submonoid` it generates.\"]\ntheorem subset_closure {s : set M} : s ⊆ closure s :=\nassume a, in_closure.basic\n\n/-- The submonoid generated by a set is contained in any submonoid that contains the set. -/\n@[to_additive \"The `add_submonoid` generated by a set is contained in any `add_submonoid` that\ncontains the set.\"]\ntheorem closure_subset {s t : set M} (ht : is_submonoid t) (h : s ⊆ t) : closure s ⊆ t :=\nassume a ha, by induction ha; simp [h _, *, is_submonoid.one_mem, is_submonoid.mul_mem]\n\n/-- Given subsets `t` and `s` of a monoid `M`, if `s ⊆ t`, the submonoid of `M` generated by `s` is\n contained in the submonoid generated by `t`. -/\n@[to_additive \"Given subsets `t` and `s` of an `add_monoid M`, if `s ⊆ t`, the `add_submonoid`\nof `M` generated by `s` is contained in the `add_submonoid` generated by `t`.\"]\ntheorem closure_mono {s t : set M} (h : s ⊆ t) : closure s ⊆ closure t :=\nclosure_subset (closure.is_submonoid t) $ set.subset.trans h subset_closure\n\n/-- The submonoid generated by an element of a monoid equals the set of natural number powers of\n the element. -/\n@[to_additive \"The `add_submonoid` generated by an element of an `add_monoid` equals the set of\nnatural number multiples of the element.\"]\ntheorem closure_singleton {x : M} : closure ({x} : set M) = powers x :=\nset.eq_of_subset_of_subset (closure_subset (powers.is_submonoid x) $ set.singleton_subset_iff.2 $\n powers.self_mem) $ is_submonoid.power_subset (closure.is_submonoid _) $\n set.singleton_subset_iff.1 $ subset_closure\n\n/-- The image under a monoid hom of the submonoid generated by a set equals the submonoid generated\n by the image of the set under the monoid hom. -/\n@[to_additive \"The image under an `add_monoid` hom of the `add_submonoid` generated by a set equals\nthe `add_submonoid` generated by the image of the set under the `add_monoid` hom.\"]\nlemma image_closure {A : Type*} [monoid A] {f : M → A} (hf : is_monoid_hom f) (s : set M) :\n f '' closure s = closure (f '' s) :=\nle_antisymm\n begin\n rintros _ ⟨x, hx, rfl⟩,\n apply in_closure.rec_on hx; intros,\n { solve_by_elim [subset_closure, set.mem_image_of_mem] },\n { rw [hf.map_one], apply is_submonoid.one_mem (closure.is_submonoid (f '' s))},\n { rw [hf.map_mul], solve_by_elim [(closure.is_submonoid _).mul_mem] }\n end\n (closure_subset (is_submonoid.image hf (closure.is_submonoid _)) $\n set.image_subset _ subset_closure)\n\n/-- Given an element `a` of the submonoid of a monoid `M` generated by a set `s`, there exists\na list of elements of `s` whose product is `a`. -/\n@[to_additive \"Given an element `a` of the `add_submonoid` of an `add_monoid M` generated by\na set `s`, there exists a list of elements of `s` whose sum is `a`.\"]\ntheorem exists_list_of_mem_closure {s : set M} {a : M} (h : a ∈ closure s) :\n (∃l:list M, (∀x∈l, x ∈ s) ∧ l.prod = a) :=\nbegin\n induction h,\n case in_closure.basic : a ha { existsi ([a]), simp [ha] },\n case in_closure.one { existsi ([]), simp },\n case in_closure.mul : a b _ _ ha hb\n { rcases ha with ⟨la, ha, eqa⟩,\n rcases hb with ⟨lb, hb, eqb⟩,\n existsi (la ++ lb),\n simp [eqa.symm, eqb.symm, or_imp_distrib],\n exact assume a, ⟨ha a, hb a⟩ }\nend\n\n/-- Given sets `s, t` of a commutative monoid `M`, `x ∈ M` is in the submonoid of `M` generated by\n `s ∪ t` iff there exists an element of the submonoid generated by `s` and an element of the\n submonoid generated by `t` whose product is `x`. -/\n@[to_additive \"Given sets `s, t` of a commutative `add_monoid M`, `x ∈ M` is in the `add_submonoid`\nof `M` generated by `s ∪ t` iff there exists an element of the `add_submonoid` generated by `s`\nand an element of the `add_submonoid` generated by `t` whose sum is `x`.\"]\ntheorem mem_closure_union_iff {M : Type*} [comm_monoid M] {s t : set M} {x : M} :\n x ∈ closure (s ∪ t) ↔ ∃ y ∈ closure s, ∃ z ∈ closure t, y * z = x :=\n⟨λ hx, let ⟨L, HL1, HL2⟩ := exists_list_of_mem_closure hx in HL2 ▸\n list.rec_on L (λ _, ⟨1, (closure.is_submonoid _).one_mem, 1,\n (closure.is_submonoid _).one_mem, mul_one _⟩)\n (λ hd tl ih HL1, let ⟨y, hy, z, hz, hyzx⟩ := ih (list.forall_mem_of_forall_mem_cons HL1) in\n or.cases_on (HL1 hd $ list.mem_cons_self _ _)\n (λ hs, ⟨hd * y, (closure.is_submonoid _).mul_mem (subset_closure hs) hy, z, hz,\n by rw [mul_assoc, list.prod_cons, ← hyzx]; refl⟩)\n (λ ht, ⟨y, hy, z * hd, (closure.is_submonoid _).mul_mem hz (subset_closure ht),\n by rw [← mul_assoc, list.prod_cons, ← hyzx, mul_comm hd]; refl⟩)) HL1,\nλ ⟨y, hy, z, hz, hyzx⟩, hyzx ▸ (closure.is_submonoid _).mul_mem\n (closure_mono (set.subset_union_left _ _) hy)\n (closure_mono (set.subset_union_right _ _) hz)⟩\n\nend monoid\n\n/-- Create a bundled submonoid from a set `s` and `[is_submonoid s]`. -/\n@[to_additive \"Create a bundled additive submonoid from a set `s` and `[is_add_submonoid s]`.\"]\ndef submonoid.of {s : set M} (h : is_submonoid s) : submonoid M := ⟨s, h.2, h.1⟩\n\n@[to_additive]\nlemma submonoid.is_submonoid (S : submonoid M) : is_submonoid (S : set M) := ⟨S.3, S.2⟩\n", "meta": {"author": "nick-kuhn", "repo": "leantools", "sha": "567a98c031fffe3f270b7b8dea48389bc70d7abb", "save_path": "github-repos/lean/nick-kuhn-leantools", "path": "github-repos/lean/nick-kuhn-leantools/leantools-567a98c031fffe3f270b7b8dea48389bc70d7abb/src/deprecated/submonoid.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.3738758227716966, "lm_q1q2_score": 0.2285809382931342}} {"text": "import category_theory.sites.sheafification\n\nnamespace category_theory\n\nopen category_theory\n\nuniverses v u\nvariables {C : Type u} [category.{v} C] (J : grothendieck_topology C)\n\nnoncomputable theory\n\n@[simps]\ndef presheaf_to_SheafOfTypes : (Cᵒᵖ ⥤ Type (max v u)) ⥤ SheafOfTypes J :=\n{ obj := λ P,\n { val := J.sheafify P,\n cond := begin\n rw ← is_sheaf_iff_is_sheaf_of_type,\n exact grothendieck_topology.plus.is_sheaf_plus_plus J P,\n end },\n map := λ P Q η, ⟨J.sheafify_map η⟩,\n map_id' := λ P, SheafOfTypes.hom.ext _ _ $ J.sheafify_map_id _,\n map_comp' := λ P Q R η γ, SheafOfTypes.hom.ext _ _ $ J.sheafify_map_comp _ _ }\n\n-- Sanity check\ndef presheaf_to_SheafOfTypes_iso : presheaf_to_SheafOfTypes J ≅\n presheaf_to_Sheaf J _ ⋙ (Sheaf_equiv_SheafOfTypes J).functor := eq_to_iso rfl\n\n-- The adjunction for sheaves of types\ndef sheafification_adjunction_types :\n (presheaf_to_SheafOfTypes J) ⊣ SheafOfTypes_to_presheaf J :=\nshow presheaf_to_Sheaf J _ ⋙ (Sheaf_equiv_SheafOfTypes J).functor ⊣\n (Sheaf_equiv_SheafOfTypes J).inverse ⋙ Sheaf_to_presheaf J _,\nfrom adjunction.comp (sheafification_adjunction _ _) $\n (Sheaf_equiv_SheafOfTypes J).to_adjunction\n\n@[simp]\nlemma sheafification_adjunction_types_hom_equiv_apply (X : Cᵒᵖ ⥤ Type (max v u))\n (Y : SheafOfTypes J) (e : (presheaf_to_SheafOfTypes _).obj X ⟶ Y) :\n (sheafification_adjunction_types J).hom_equiv _ _ e =\n J.to_sheafify _ ≫ e.val := rfl\n\n@[simp]\nlemma sheafification_adjunction_types_hom_equiv_symm_apply (X : Cᵒᵖ ⥤ Type (max v u))\n (Y : SheafOfTypes J) (e : X ⟶ (SheafOfTypes_to_presheaf _).obj Y) :\n (((sheafification_adjunction_types J).hom_equiv _ _).symm e).val =\n J.sheafify_lift e (by { rw is_sheaf_iff_is_sheaf_of_type, exact Y.2 }) := rfl\n\n@[simp]\nlemma sheafification_adjunction_types_unit_app (X : Cᵒᵖ ⥤ Type (max v u)) :\n (sheafification_adjunction_types J).unit.app X = J.to_sheafify X := rfl\n\n@[simp]\nlemma sheafification_adjunction_types_counit_app (Y : SheafOfTypes J) :\n ((sheafification_adjunction_types J).counit.app Y).val =\n J.sheafify_lift (𝟙 _) (by { rw is_sheaf_iff_is_sheaf_of_type, exact Y.2 }) := rfl\n\ninstance is_iso_sheafification_types_adjunction_counit_app (X : SheafOfTypes J) :\n is_iso ((sheafification_adjunction_types J).counit.app X) :=\nbegin\n apply is_iso_of_reflects_iso _ (Sheaf_equiv_SheafOfTypes J).inverse,\n change is_iso ((sheafification_adjunction J (Type (max v u))).counit.app\n ((Sheaf_equiv_SheafOfTypes J).inverse.obj X)),\n apply_instance\nend\n\ninstance sheafification_types_reflective : is_iso (sheafification_adjunction_types J).counit :=\nnat_iso.is_iso_of_is_iso_app _\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/SheafOfTypes_sheafification.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5660185205547238, "lm_q2_score": 0.40356685373537454, "lm_q1q2_score": 0.2284263134962213}} {"text": "import tactic\nimport .direction\nimport .list2d\nimport .boolset2d\nimport .component2d\nimport .sokostate\n\nstructure boxint := \n(subboxes : bset2d)\n(supboxes : bset2d)\n(sk_comp : bset2d)\n\nstructure boxint.valid (avail : bset2d) (as : boxint) : Prop :=\n(sub_sup : as.subboxes ⊆ as.supboxes)\n(sup_avail : as.supboxes ⊆ avail)\n(sub_disj : as.subboxes.disjoint as.sk_comp)\n(sk_comp_avail : as.sk_comp ⊆ avail)\n(sk_comp_closed : ∀ xy ∈ as.sk_comp, ∀ d : direction,\n d.shift xy ∈ avail →\n (d.shift xy ∈ as.sk_comp ∨ d.shift xy ∈ as.subboxes))\n\ndef boxint.mem (s : sokostate) (as : boxint)\n := s.storekeeper ∈ as.sk_comp ∧\n as.subboxes ⊆ s.boxes ∧ s.boxes ⊆ as.supboxes\ninstance : has_mem sokostate boxint\n:= ⟨boxint.mem⟩\nlemma boxint.mem.unfold\n {s : sokostate} {as : boxint}\n : s ∈ as = (s.storekeeper ∈ as.sk_comp ∧\n as.subboxes ⊆ s.boxes ∧ s.boxes ⊆ as.supboxes)\n:= rfl\ninstance boxint.mem.decidable\n (s : sokostate) (as : boxint) : decidable (s ∈ as)\n:= begin\n unfold has_mem.mem, unfold boxint.mem, apply_instance,\nend\n\n\ndef boxint.disjoint\n (as1 : boxint) (as2 : boxes_only) : Prop\n := ¬ (as1.subboxes ⊆ as2.boxes ∧ as2.boxes ⊆ as1.supboxes)\nlemma boxint.disjoint_correct\n (as : boxint) (bs : boxes_only)\n (s : sokostate)\n : as.disjoint bs → s ∈ as → s ∈ bs → false :=\nbegin\n simp [boxint.mem.unfold, boxes_only.mem.unfold, boxint.disjoint],\n introv Hnsol Hsk Hsub Hsup Hsbs Hbss,\n exact Hnsol (bset2d.subset.trans Hsub Hsbs) (bset2d.subset.trans Hbss Hsup),\nend\ninstance boxint.disjoint.decidable\n (as : boxint) (bs : boxes_only) : decidable (as.disjoint bs)\n:= begin\n unfold boxint.disjoint, apply_instance,\nend\n\ndef boxint.subset (as1 as2 : boxint) : Prop\n := as1.sk_comp ⊆ as2.sk_comp ∧ as2.subboxes ⊆ as1.subboxes\n ∧ as1.supboxes ⊆ as2.supboxes\ninstance : has_subset boxint := ⟨boxint.subset⟩\n\nlemma boxint.subset_correct (as1 as2 : boxint)\n : as1 ⊆ as2 → ∀ s : sokostate, s ∈ as1 → s ∈ as2 :=\nbegin\n intros H12 s H1,\n rcases H12 with ⟨H12sk,H12sub,H12sup⟩,\n rcases H1 with ⟨H1sk,H1sub,H1sup⟩,\n split, exact H12sk _ H1sk,\n split, exact bset2d.subset.trans H12sub H1sub,\n exact bset2d.subset.trans H1sup H12sup,\nend\ninstance boxint.subset.decidable\n (as1 as2 : boxint) : decidable (as1 ⊆ as2)\n:= begin\n unfold has_subset.subset, unfold boxint.subset, apply_instance,\nend\n\ndef boxint.subset_g (as1 as2 : boxint) (goal : boxes_only) : Prop\n := as1.sk_comp ⊆ as2.sk_comp ∧ as2.subboxes ⊆ as1.subboxes\n ∧ ( as1.supboxes ⊆ as2.supboxes ∨\n goal.boxes.count ≤ as1.subboxes.count ∧ as1.subboxes ⊆ as2.supboxes )\nlemma boxint.subset_g_correct {avail : bset2d} {as1 as2 : boxint} {goal : boxes_only}\n: as1.subset_g as2 goal → ∀ s sg : sokostate,\ns ∈ as1 → sg ∈ goal → sg.reachable avail s → s ∈ as2\n:=\nbegin\n intros H12 s sg H1 Hg Hr,\n rcases H12 with ⟨H12sk, H12sub, H12sup_cnt⟩,\n rcases H1 with ⟨H1sk,H1sub, H1sup⟩,\n split, exact H12sk _ H1sk,\n split, exact bset2d.subset.trans H12sub H1sub,\n cases H12sup_cnt with H12sup H12sup_cnt,\n exact bset2d.subset.trans H1sup H12sup,\n { cases H12sup_cnt with H_cnt H12sup,\n have : sg.boxes.count = s.boxes.count := sokostate.reachable_keep_box_count Hr,\n have : as1.subboxes.count ≤ s.boxes.count := bset2d.count_le_of_subset _ _ H1sub,\n have : sg.boxes.count ≤ goal.boxes.count := bset2d.count_le_of_subset _ _ Hg.1,\n have : as1.subboxes.count = s.boxes.count, by omega,\n have : s.boxes ⊆ as1.subboxes := bset2d.subset_eq_of_count_eq _ _ H1sub this,\n exact bset2d.subset.trans this H12sup,\n }\nend\ninstance boxint.subset_g.decidable\n (as1 as2 : boxint) (goal : boxes_only) : decidable (as1.subset_g as2 goal)\n:= begin\n unfold boxint.subset_g, apply_instance,\nend\n\ndef boxint.generate (avail : bset2d) (subboxes supboxes : bset2d) (sk : ℕ × ℕ) : boxint\n := {\n subboxes := subboxes,\n supboxes := supboxes,\n sk_comp := component2d (avail \\ subboxes) (bset2d.from_index sk),\n }\n\ntheorem boxint.generate_valid {avail subboxes supboxes : bset2d} {sk : ℕ × ℕ}\n : subboxes ⊆ supboxes → supboxes ⊆ avail →\n (boxint.generate avail subboxes supboxes sk).valid avail :=\nbegin\n intros sub_sup sup_avail, split, exact sub_sup, exact sup_avail, {\n intros xy Hsub Hcomp,\n exact bset2d.nmem_of_mem_sdiff (component2d_subset_avail xy Hcomp) Hsub,\n }, {\n intros xy Hcomp,\n exact bset2d.mem_of_mem_sdiff (component2d_subset_avail xy Hcomp),\n }, {\n introv Hcomp Ha2, by_cases C : d.shift xy ∈ subboxes,\n { right, exact C, }, left,\n have Ha2 : d.shift xy ∈ avail \\ subboxes\n := bset2d.mem_sdiff_of_mem_nmem Ha2 C,\n exact component2d_closed Hcomp Ha2,\n },\nend\n\ndef boxint.get_pushes (avail : bset2d) (s : boxint)\n : list (direction × (ℕ × ℕ))\n := do\n box ← s.subboxes.to_indexes,\n d ← direction.luniv,\n if d.shift box ∈ avail ∧ d.shift box ∉ s.subboxes\n ∧ d.opposite.shift box ∈ s.sk_comp\n then return (d, box)\n else list.nil\n\ndef boxint.get_appearances (avail : bset2d) (s : boxint)\n : list (direction × (ℕ × ℕ))\n := do\n box ← (avail \\ s.supboxes).to_indexes,\n d ← direction.luniv,\n if d.shift box ∈ s.supboxes ∧ d.shift box ∉ s.subboxes\n ∧ d.shift (d.shift box) ∈ s.sk_comp\n ∧ d.shift (d.shift box) ≠ d.shift box\n then return (d.opposite, d.shift box)\n else list.nil\n\ndef boxint.get_moves (avail : bset2d) (as : boxint)\n : list (direction × (ℕ × ℕ))\n := boxint.get_pushes avail as ++ boxint.get_appearances avail as\n\nlemma boxint.in_get_moves_iff (avail : bset2d) (s : boxint) (Hv : s.valid avail)\n : ∀ (d : direction) (box : ℕ×ℕ),\n (d,box) ∈ boxint.get_moves avail s ↔ (\n d.opposite.shift box ∈ s.sk_comp ∧\n d.opposite.shift box ≠ box ∧\n d.shift box ∈ avail ∧ d.shift box ∉ s.subboxes ∧\n box ∈ s.supboxes ∧ (d.shift box ∈ s.supboxes → box ∈ s.subboxes)\n ) :=\nbegin\n intros, unfold boxint.get_moves, rw list.mem_append,\n split, {\n rename box box', rename d d',\n intro H, cases H, {\n unfold boxint.get_pushes at H, simp [-prod.exists] at H,\n rcases H with ⟨box,Hbox,d,Huniv,H⟩, clear Huniv,\n have Hbox := (bset2d.to_indexes_iff _ _).mp Hbox,\n by_cases C : d.shift box ∈ avail ∧ d.shift box ∉ s.subboxes\n ∧ d.opposite.shift box ∈ s.sk_comp, {\n simp [C] at H, rw [H.1, H.2], clear H,\n rcases C with ⟨Ha2, Hnb2, Hsk⟩,\n split, exact Hsk,\n split, { -- disproving border case\n assume Heq, rw Heq at Hsk,\n exact Hv.sub_disj box Hbox Hsk,\n },\n split, exact Ha2, split, exact Hnb2,\n split, exact Hv.sub_sup box Hbox,\n intro, exact Hbox,\n }, { simp [C] at H, exact false.elim H, },\n }, {\n unfold boxint.get_appearances at H, simp [-prod.exists] at H,\n rcases H with ⟨box,Hbox,d,Huniv,H⟩, clear Huniv,\n have Hbox := (bset2d.to_indexes_iff _ box).mp Hbox,\n have Hba: box ∈ avail, from bset2d.mem_of_mem_sdiff Hbox,\n have Hbnsup: box ∉ s.supboxes, from bset2d.nmem_of_mem_sdiff Hbox,\n by_cases C : d.shift box ∈ s.supboxes ∧ d.shift box ∉ s.subboxes\n ∧ d.shift (d.shift box) ∈ s.sk_comp ∧ d.shift (d.shift box) ≠ d.shift box, {\n simp [C] at H, rw [H.1, H.2], clear H,\n rcases C with ⟨Hsup2, Hfree, Hcomp, Hnngen⟩,\n cases direction.opposite_shift d box with Heq Hop_simp, {\n -- border case d.shift box = box\n simp [Heq] at Hnngen, exact false.elim Hnngen,\n }, {\n rw [Hop_simp, direction.opposite_opposite],\n split, exact Hcomp,\n split, exact Hnngen,\n split, exact Hba,\n split, exact mt (Hv.sub_sup box) Hbnsup,\n split, exact Hsup2,\n assume Hbsup, exact false.elim (Hbnsup Hbsup),\n }\n },\n { simp [C] at H, exact false.elim H, }\n }\n }, {\n rintros ⟨Hcomp, Hnngen, Hav, Hfree, Hsup, H⟩,\n by_cases C : box ∈ s.subboxes, { left,\n unfold boxint.get_pushes, simp [-prod.exists], existsi box,\n split, exact (bset2d.to_indexes_iff s.subboxes box).mpr C,\n existsi d, split, exact direction.luniv_complete,\n simp [Hfree, Hcomp, Hav],\n }, { right,\n unfold boxint.get_appearances, simp [-prod.exists], existsi d.shift box,\n split, { show d.shift box ∈ (avail \\ s.supboxes).to_indexes,\n apply (bset2d.to_indexes_iff _ _).mpr,\n apply bset2d.mem_sdiff_of_mem_nmem,\n exact Hav, assume H2, exact C (H H2),\n },\n existsi d.opposite,\n split, exact direction.luniv_complete,\n simp [direction.opposite_opposite],\n cases direction.opposite_shift d box with Heq Hop_simp, {\n -- border case, d.shift box = box\n rw Heq at H Hfree, exact false.elim (C (H Hsup)),\n },\n { rw Hop_simp, simp! [Hsup, C, Hcomp, Hnngen], }\n },\n }\nend\n\ndef boxint.move (avail : bset2d)\n (s : boxint) (d : direction) (box : ℕ×ℕ)\n := boxint.generate avail\n ((s.subboxes.remove box).add (d.shift box))\n ((s.supboxes.remove box).add (d.shift box))\n box\n\ndef boxint.next_states (avail : bset2d) (s : boxint) : list boxint\n := list.map (function.uncurry (boxint.move avail s)) (boxint.get_moves avail s)\n\ntheorem boxint.next_valid (avail : bset2d) (as1 : boxint)\n : as1.valid avail →\n ∀ as2 : boxint, as2 ∈ as1.next_states avail → as2.valid avail\n:=\nbegin\n introv Hv H, simp [boxint.next_states, -prod.exists] at H,\n rcases H with ⟨⟨d, box⟩, H, Heq⟩,\n simp at Heq, rw ←Heq, clear Heq as2,\n rw (boxint.in_get_moves_iff avail as1 Hv) at H,\n rcases H with ⟨Hcomp, Hnng, Hav, Hnb, Hsp, Hextra⟩,\n apply boxint.generate_valid, {\n apply bset2d.subset_add_same,\n apply bset2d.subset_remove_same,\n exact Hv.sub_sup,\n }, {\n assume xy, assume H,\n cases bset2d.of_mem_add H with H H,\n rw H, exact Hav,\n have := bset2d.mem_of_mem_remove H,\n exact Hv.sup_avail xy this,\n }\nend\n\ntheorem boxint.next_of_real_move (avail : bset2d) (as1 : boxint) :\n as1.valid avail →\n ∀ (s : sokostate) (d : direction), s ∈ as1 → s.move avail d ∈ as1 ∨\n (∃ as2 : boxint, as2 ∈ as1.next_states avail ∧ s.move avail d ∈ as2)\n:=\nbegin\n intros Hv s d Hin,\n have := Hin,\n rcases this with ⟨Hsk,Hsub,Hsup⟩,\n let box := d.shift s.storekeeper,\n let box2 := d.shift box,\n by_cases C : box ∈ s.boxes ∧ box2 ∈ avail ∧ box2 ∉ s.boxes\n ∧ (box ∈ as1.subboxes ∨ box2 ∉ as1.supboxes), {\n\n right, -- we move to another abstract state\n\n existsi as1.move avail d box,\n rcases C with ⟨Hbb, Hb2a, Hb2nb, Has⟩,\n split, { -- in next_states\n simp [boxint.next_states, -prod.exists],\n existsi (d,box), split, {\n apply (boxint.in_get_moves_iff avail as1 Hv d box).mpr,\n have Hngen : box ≠ s.storekeeper, {\n assume Heq, simp [box] at Heq,\n simp only [box,box2,Heq] at Hbb Hb2nb,\n exact false.elim (Hb2nb Hbb),\n },\n have : d.opposite.shift box = s.storekeeper\n := or.resolve_left (direction.opposite_shift d s.storekeeper) Hngen,\n rw this,\n split, exact Hsk,\n split, exact ne_comm.mp Hngen,\n split, exact Hb2a,\n split, exact mt (Hsub box2) Hb2nb,\n split, exact Hsup box Hbb,\n exact or.neg_resolve_right Has,\n }, refl,\n }, { -- emulates real move\n have Hba : box ∈ avail := Hv.sup_avail box (Hsup box Hbb),\n simp [boxint.move, boxint.generate],\n simp [sokostate.move, Hba, Hbb, Hb2a, Hb2nb],\n split, simp, {\n apply component2d_supset, {\n intros xy H,\n rw (bset2d.from_index_iff box xy).1 H, clear H xy,\n apply bset2d.mem_sdiff_of_mem_nmem Hba,\n apply bset2d.nmem_add_of_neq_nmem, {\n intro contra, rw contra at Hbb, exact Hb2nb Hbb,\n }, exact bset2d.nmem_remove,\n },\n exact (bset2d.from_index_iff box box).2 rfl,\n },\n simp, split, {\n apply bset2d.subset_add_same,\n apply bset2d.subset_remove_same,\n exact Hsub,\n },\n apply bset2d.subset_add_same,\n apply bset2d.subset_remove_same,\n exact Hsup,\n }\n },\n\n left, -- the abstract state remains the same\n\n simp at C,\n simp [sokostate.move],\n by_cases Cba : box ∈ avail, {\n simp [Cba], by_cases Cbb : box ∈ s.boxes, {\n simp [Cbb], by_cases Cb2a : box2 ∈ avail, {\n simp [Cb2a], by_cases Cb2b : box2 ∈ s.boxes,\n { simp [Cb2b], exact Hin, }, {\n simp [Cb2b],\n have C := C Cbb Cb2a Cb2b,\n cases not_or_distrib.mp C with C1 C2,\n have C2 := not_not.mp C2,\n rw boxint.mem.unfold, split,\n exact or.resolve_right (Hv.sk_comp_closed s.storekeeper Hsk d Cba) C1,\n split, {\n intros xy Hin, apply bset2d.mem_add_of_mem,\n apply bset2d.mem_remove_of_neq_mem,\n { intro contra, rw contra at Hin, exact C1 Hin, },\n { exact Hsub xy Hin },\n }, {\n intros xy Hin, cases bset2d.of_mem_add Hin with Heq Hin,\n { rw Heq, exact C2, },\n { exact Hsup xy (bset2d.mem_of_mem_remove Hin), },\n },\n },\n },\n { simp [Cb2a], exact Hin, },\n },\n { simp [Cbb], split,\n exact or.resolve_right\n (Hv.sk_comp_closed s.storekeeper Hsk d Cba)\n (mt (Hsub box) Cbb),\n exact and.intro Hsub Hsup,\n },\n },\n { simp [Cba], exact Hin, },\nend\n", "meta": {"author": "mirefek", "repo": "sokoban.lean", "sha": "451c92308afb4d3f8e566594b9751286f93b899b", "save_path": "github-repos/lean/mirefek-sokoban.lean", "path": "github-repos/lean/mirefek-sokoban.lean/sokoban.lean-451c92308afb4d3f8e566594b9751286f93b899b/src/boxint.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.22840144208036733}} {"text": "import model_theory.substructures\nimport model_theory.bundled\n\n\n--OUTPUT 1\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M := sorry\n\nend\n\n--OUTPUT 2\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n let φ : set L.Formula,\n let φ := F.sentences,\n\n let φ1 : set L.Formula,\n let φ1 := (λ x : L.Formula, ∃ (a b : x.carrier), a ≠ b),\n\n let φ2 : set L.Formula,\n let φ2 := (λ x : L.Formula, ∃ (a b c : x.carrier), a ≠ b ∧ b ≠ c ∧ a ≠ c),\n\n let φ3 : set L.Formula,\n let φ3 := (λ x : L.Formula, ∃ (a b c d : x.carrier), a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ a ≠ c ∧ a ≠ d ∧ b ≠ d),\n\n let φ4 : set L.Formula,\n let φ4 := (λ x : L.Formula, ∃ (a b c d e : x.carrier), a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ d ≠ e ∧ a ≠ c ∧ a ≠ d ∧ a ≠ e ∧ b ≠ d ∧ b ≠ e ∧ c ≠ e),\n\n let φ5 : set L.Formula,\n let φ5 := (λ x : L.Formula, ∃ (a b c d e f : x.carrier), a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ d ≠ e ∧ e ≠ f ∧ a ≠ c ∧ a ≠ d ∧ a ≠ e ∧ a ≠ f ∧ b ≠ d ∧ b ≠ e ∧ b ≠ f ∧ c ≠ e ∧ c ≠ f ∧ d ≠ f),\n\n let φ6 : set L.Formula,\n let φ6 := (λ x : L.Formula, ∃ (a b c d e f g : x.carrier), a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ d ≠ e ∧ e ≠ f ∧ f ≠ g ∧ a ≠ c ∧ a ≠ d ∧ a ≠ e ∧ a ≠ f ∧ a ≠ g ∧ b ≠ d ∧ b ≠ e ∧ b ≠ f ∧ b ≠ g ∧ c ≠ e ∧ c ≠ f ∧ c ≠ g ∧ d ≠ f ∧ d ≠ g ∧ e ≠ g),\n\n let φ7 : set L.Formula,\n let φ7 := (λ x : L.Formula, ∃ (a b c d e f g h : x.carrier), a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ d ≠ e ∧ e ≠ f ∧ f ≠ g ∧ g ≠ h ∧ a ≠ c ∧ a ≠ d ∧ a ≠ e ∧ a ≠ f ∧ a ≠ g ∧ a ≠ h ∧ b ≠ d ∧ b ≠ e ∧ b ≠ f ∧ b ≠ g ∧ b ≠ h ∧ c ≠ e ∧ c ≠ f ∧ c ≠ g ∧ c ≠ h ∧ d ≠ f ∧ d ≠ g ∧ d ≠ h ∧ e ≠ g ∧ e ≠ h ∧ f ≠ h),\n\n let φ8 : set L.Formula,\n let φ8 := (λ x : L.Formula, ∃ (a b c d e f g h i : x.carrier), a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ d ≠ e ∧ e ≠ f ∧ f ≠ g ∧ g ≠ h ∧ h ≠ i ∧ a ≠ c ∧ a ≠ d ∧ a ≠ e ∧ a ≠ f ∧ a ≠ g ∧ a ≠ h ∧ a ≠ i ∧ b ≠ d ∧ b ≠ e ∧ b ≠ f ∧ b ≠ g ∧ b ≠ h ∧ b ≠ i ∧ c ≠ e ∧ c ≠ f ∧ c ≠ g ∧ c ≠ h ∧ c ≠ i ∧ d ≠ f ∧ d ≠ g ∧ d ≠ h ∧ d ≠ i ∧ e ≠ g ∧ e ≠ h ∧ e ≠ i ∧ f ≠ h ∧ f ≠ i ∧ g ≠ i),\n\n let φ9 : set L.Formula,\n let φ9 := (λ x : L.Formula, ∃ (a b c d e f g h i j : x.carrier), a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ d ≠ e ∧ e ≠ f ∧ f ≠ g ∧ g ≠ h ∧ h ≠ i ∧ i ≠ j ∧ a ≠ c ∧ a ≠ d ∧ a ≠ e ∧ a ≠ f ∧ a ≠ g ∧ a ≠ h ∧ a ≠ i ∧ a ≠ j ∧ b ≠ d ∧ b ≠ e ∧ b ≠ f ∧ b ≠ g ∧ b ≠ h ∧ b ≠ i ∧ b ≠ j ∧ c ≠ e ∧ c ≠ f ∧ c ≠ g ∧ c ≠ h ∧ c ≠ i ∧ c ≠ j ∧ d ≠ f ∧ d ≠ g ∧ d ≠ h ∧ d ≠ i ∧ d ≠ j ∧ e ≠ g ∧ e ≠ h ∧ e ≠ i ∧ e ≠ j ∧ f ≠ h ∧ f ≠ i ∧ f ≠ j ∧ g ≠ i ∧ g ≠ j ∧ h ≠ j),\n\n let φ10 : set L.Formula,\n let φ10 := (λ x : L.Formula, ∃ (a b c d e f g h i j k : x.carrier), a ≠ b ∧ b ≠ c ∧ c ≠ d ∧ d ≠ e ∧ e ≠ f ∧ f ≠ g ∧ g ≠ h ∧ h ≠ i ∧ i ≠ j ∧ j ≠ k ∧ a ≠ c ∧ a ≠ d ∧ a ≠ e ∧ a ≠ f ∧ a ≠ g ∧ a ≠ h ∧ a ≠ i ∧ a ≠ j ∧ a ≠ k ∧ b ≠ d ∧ b ≠ e ∧ b ≠ f ∧ b ≠ g ∧ b ≠ h ∧ b ≠ i ∧ b ≠ j ∧ b ≠ k ∧ c ≠ e ∧ c ≠ f ∧ c ≠ g ∧ c ≠ h ∧ c ≠ i ∧ c ≠ j ∧ c ≠ k ∧ d ≠ f ∧ d ≠ g ∧ d ≠ h ∧ d ≠ i ∧ d ≠ j ∧ d ≠ k ∧ e ≠ g ∧ e ≠ h ∧ e ≠ i ∧ e ≠ j ∧ e ≠ k ∧ f ≠ h ∧ f ≠ i ∧ f ≠ j ∧ f ≠ k ∧ g ≠ i ∧ g ≠ j ∧ g ≠ k ∧ h ≠ j ∧ h ≠ k ∧ i ≠ k),\n\n let ψ : set L.Formula,\n let ψ := (φ ∪ φ1 ∪ φ2 ∪ φ3 ∪ φ4 ∪ φ5 ∪ φ6 ∪ φ7 ∪ φ8 ∪ φ9 ∪ φ10),\n\n have h1 : ∀ Γ : set L.Formula, finite Γ → ∃ m : F.Model, Γ ⊆ m.sentences, from by auto [F.sentences_finite_model],\n\n have h2 : ∀𝔹 Γ : set L.Formula, finite Γ → ∃ m : F.Model, Γ ⊆ m.sentences ∧ finite m.carrier ∧ 𝔹.size ≤ m.size, from by intros 𝔹 Γ hΓ,\n let h3 : ∀𝔹 Γ : set L.Formula,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n have h1 : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin, from h,\n have h2 : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin, from h,\n have h3 : ∃ (m : F.Model) [mfin : fintype m], 1 ≤ @fintype.card m mfin, from h,\n have h4 : ∃ (m : F.Model) [mfin : fintype m], 2 ≤ @fintype.card m mfin, from h,\n have h5 : ∃ (m : F.Model) [mfin : fintype m], 3 ≤ @fintype.card m mfin, from h,\n have h6 : ∃ (m : F.Model) [mfin : fintype m], 4 ≤ @fintype.card m mfin, from h,\n have h7 : ∃ (m : F.Model) [mfin : fintype m], 5 ≤ @fintype.card m mfin, from h,\n have h8 : ∃ (m : F.Model) [mfin : fintype m], 6 ≤ @fintype.card m mfin, from h,\n have h9 : ∃ (m : F.Model) [mfin : fintype m], 7 ≤ @fintype.card m mfin, from h,\n have h10 : ∃ (m : F.Model) [mfin : fintype m], 8 ≤ @fintype.card m mfin, from h,\n\n have h11 : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin, from h,\n have h12 : ∃ (m : F.Model) [mfin : fintype m], 1 ≤ @fintype.card m mfin, from h3,\n have h13 : ∃ (m : F.Model) [mfin : fintype m], 2 ≤ @fintype.card m mfin, from h4,\n have h14 : ∃ (m : F.Model) [mfin : fintype m], 3 ≤ @fintype.card m mfin, from h5,\n have h15 : ∃ (m : F.Model) [mfin : fintype m], 4 ≤ @fintype.card m mfin, from h6,\n have h16 : ∃ (m : F.Model) [mfin : fintype m], 5 ≤ @fintype.card m mfin, from h7,\n have h17 : ∃ (m : F.Model) [mfin : fintype m], 6 ≤ @fintype.card m mfin, from h8,\n have h18 : ∃ (m : F.Model) [mfin : fintype m], 7 ≤ @fintype.card m mfin, from h9,\n have h19 : ∃ (m : F.Model) [mfin : fintype m], 8 ≤ @fintype.card m mfin, from h10,\n have h20 : ∃ (m : F.Model) [mfin : fintype m], 9 ≤ @fintype.card m mfin, from h,\n\n show ∃ (M : F.Model), infinite M, from sorry\nend\n\n--OUTPUT 4\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n let F' : L.Theory := F.copy,\n let F' := F'.add_finset_of_types 3,\n let F' := F'.add_fun_of_types 2 1,\n let F' := F'.add_binop_of_types (+) (2 : ℕ),\n let F' := F'.add_binop_of_types (<) (2 : ℕ),\n let F' := F'.add_binop_of_types (-) (2 : ℕ),\n let F' := F'.add_binop_of_types (*) (2 : ℕ),\n let F' := F'.add_binop_of_types (^) (2 : ℕ),\n let F' := F'.add_const_of_types 0,\n\n let F' := F'.add_const_of_types 0,\n let F' := F'.add_const_of_types 1,\n let F' := F'.add_const_of_types 2,\n let F' := F'.add_const_of_types 3,\n let F' := F'.add_const_of_types 4,\n let F' := F'.add_const_of_types 5,\n let F' := F'.add_const_of_types 6,\n let F' := F'.add_const_of_types 7,\n let F' := F'.add_const_of_types 8,\n let F' := F'.add_const_of_types 9,\n let F' := F'.add_const_of_types 10,\n\n let A : F'.Formula (ℕ) := ∃ ↑x ∃ ↑y ∃ ↑z, ∀ ↑f ∀ ↑g ∀ ↑h ∀ ↑i ∀ ↑j ∀ ↑k ∀ ↑l ∀ ↑m ∀ ↑n ∀ ↑o, x ≠ f ∧ x ≠ g ∧ x ≠ h ∧ x ≠ i ∧ x ≠ j ∧ x ≠ k ∧ x ≠ l ∧ x ≠ m ∧ x ≠ n ∧ x ≠ o ∧ y ≠ f ∧ y ≠ g ∧ y ≠ h ∧ y ≠ i ∧ y ≠ j ∧ y ≠ k ∧ y ≠ l ∧ y ≠ m ∧ y ≠ n ∧ y ≠ o ∧ z ≠ f ∧ z ≠ g ∧ z ≠ h ∧ z ≠ i ∧ z ≠ j ∧ z ≠ k ∧ z ≠ l ∧ z ≠ m ∧ z ≠ n ∧ z ≠ o,\n\n\n let add1 := (λ n : ℕ, n + 1),\n let add2 := (λ n : ℕ, n + 2),\n let add3 := (λ n : ℕ, n + 3),\n let add4 := (λ n : ℕ, n + 4),\n let add5 := (λ n : ℕ, n + 5),\n let add6 := (λ n : ℕ, n + 6),\n let add7 := (λ n : ℕ, n + 7),\n let add8 := (λ n : ℕ, n + 8),\n let add9 := (λ n : ℕ, n + 9),\n\n let sub0 := (λ n : ℕ, 10 - n),\n let sub1 := (λ n : ℕ, 9 - n),\n let sub2 := (λ n : ℕ, 8 - n),\n let sub3 := (λ n : ℕ, 7 - n),\n let sub4 := (λ n : ℕ, 6 - n),\n let sub5 := (λ n : ℕ, 5 - n),\n let sub6 := (λ n : ℕ, 4 - n),\n let sub7 := (λ n : ℕ, 3 - n),\n let sub8 := (λ n : ℕ, 2 - n),\n let sub9 := (λ n : ℕ, 1 - n),\n\n let A2 := (∀ ↑f ∀ ↑g ∀ ↑h ∀ ↑i ∀ ↑j ∀ ↑k ∀ ↑l ∀ ↑m ∀ ↑n ∀ ↑o, f = 0 ∨ f = 1 ∨ f = 2 ∨ f = 3 ∨ f = 4 ∨ f = 5 ∨ f = 6 ∨ f = 7 ∨ f = 8 ∨ f = 9 → g ≠ f ∧ g ≠ h ∧ g ≠ i ∧ g ≠ j ∧ g ≠ k ∧ g ≠ l ∧ g ≠ m ∧ g ≠ n ∧ g ≠ o ∧ h ≠ g ∧ h ≠ i ∧ h ≠ j ∧ h ≠ k ∧ h ≠ l ∧ h ≠ m ∧ h ≠ n ∧ h ≠ o ∧ i ≠ g ∧ i ≠ h ∧ i ≠ j ∧ i ≠ k ∧ i ≠ l ∧ i ≠ m ∧ i ≠ n ∧ i ≠ o ∧ j ≠ f ∧ j ≠ h ∧ j ≠ i ∧ j ≠ k ∧ j ≠ l ∧ j ≠ m ∧ j ≠ n ∧ j ≠ o ∧ k ≠ f ∧ k ≠ g ∧ k ≠ i ∧ k ≠ j ∧ k ≠ l ∧ k ≠ m ∧ k ≠ n ∧ k ≠ o ∧ l ≠ f ∧ l ≠ g ∧ l ≠ h ∧ l ≠ j ∧ l ≠ k ∧ l ≠ m ∧ l ≠ n ∧ l ≠ o ∧ m ≠ f ∧ m ≠ g ∧ m ≠ h ∧ m ≠ i ∧ m ≠ k ∧ m ≠ l ∧ m ≠ n ∧ m ≠ o ∧ n ≠ f ∧ n ≠ g ∧ n ≠ h ∧ n ≠ i ∧ n ≠ j ∧ n ≠ l ∧ n ≠ m ∧ n ≠ o ∧ o ≠ f ∧ o ≠ g ∧ o ≠ h ∧ o ≠ i ∧ o ≠ j ∧ o ≠ k ∧ o ≠ m ∧ o ≠ n),\n\n let Γ_0 := ∀ ↑f ∀ ↑g ∀ ↑h ∀ ↑i ∀ ↑j ∀ ↑k ∀ ↑l ∀ ↑m ∀ ↑n ∀ ↑o, f = 0 ∨ f = 1 ∨ f = 2 ∨ f = 3 ∨ f = 4 ∨ f = 5 ∨ f = 6 ∨ f = 7 ∨ f = 8 ∨ f = 9 → g ≠ f ∧ g ≠ h ∧ g ≠ i ∧ g ≠ j ∧ g ≠ k ∧ g ≠ l ∧ g ≠ m ∧ g ≠ n \n ∧ g ≠ o ∧ h ≠ g ∧ h ≠ i ∧ h ≠ j ∧ h ≠ k ∧ h ≠ l ∧ h ≠ m ∧ h ≠ n ∧ h ≠ o ∧ i ≠ g ∧ i ≠ h ∧ i ≠ j ∧ i ≠ k ∧ i ≠ l ∧ i ≠ m ∧ i ≠ n ∧ i ≠ o ∧ j ≠ f ∧ j ≠ h ∧ j ≠ i ∧ j ≠ k ∧ j ≠ l ∧ j ≠ m ∧ j ≠ n ∧ j ≠ o ∧ k ≠ f ∧ k ≠ g ∧ k ≠ i ∧ k ≠ j ∧ k ≠ l ∧ k ≠ m ∧ k ≠ n ∧ k ≠ o ∧ l ≠ f ∧ l ≠ g ∧ l ≠ h ∧ l ≠ j ∧ l ≠ k ∧ l ≠ m ∧ l ≠ n ∧ l ≠ o ∧ m ≠ f ∧ m ≠ g ∧ m ≠ h ∧ m ≠ i ∧ m ≠ k ∧ m ≠ l ∧ m ≠ n ∧ m ≠ o ∧ n ≠ f ∧ n ≠ g ∧ n ≠ h ∧ n ≠ i ∧ n ≠ j ∧ n ≠ l ∧ n ≠ m ∧ n ≠ o ∧\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n -- The negation is used to avoid a contradiction when n = 0\n have h1 : ¬(∀ n : ℕ, n ≤ 0 → ∀ (m : F.Model) [fintype m], n > @fintype.card m fintype), from by auto [lt_irrefl, zero_lt_one, not_zero_nat, zero_le],\n\n have h2 : ¬(∀ n : ℕ, ∀ (m : F.Model) [fintype m], n > @fintype.card m fintype), from by auto [lt_irrefl, zero_lt_one, not_zero_nat] using [h, h1],\n \n have h3 : ∃ (M : F.Model), infinite M, from ccw (h2),\n exact h3,\nend\n\n--OUTPUT 6\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n let A n := ∃ (l : fin n → L.Model.Atom), ∀ (a : fin n → L.Model.Atom), ∃! (m : fin n), l m = a m,\n have h1 : ∃ (M : F.Model) [mfin : fintype M], ∀ (n : ℕ), ¬ A n, from sorry,\n\n obtain ⟨M, mfin, h2⟩ := h1,\n\n exact M,\nend\n\n--OUTPUT 7\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n let Γ := \n begin\n exact (F ∪ (set.Union ℕ (λ n, {∃ (x₁ x₂ … xₙ : F.Var), ¬ (x₁ = x₂ ∧ … ∧ xₙ₋₁ = xₙ)})))\n end,\n\n have h1 : ∀ (n : ℕ), F.sat (set.to_finset Γ.val.val.val) (list.repeat F.true n), from by auto,\n have h2 : ∀ (n : ℕ), F.sat (set.to_finset Γ.val.val.val) (↑(Γ.val.val.val.val.val.val) :: list.repeat F.true n), from by auto,\n\n have h3 : F.T.sat Γ.val.val.val ∨ ¬F.T.sat Γ.val.val.val, from by blast,\n\n let M := Σ (M : F.Model), F.sat M Γ.val.val.val,\n have h4 : ∃ (M : F.Model), finite M, from by auto [finite.of_fintype, h],\n have h5 : ∃ (M : F.Model), infinite M, from by auto [h4],\n exact h5\nend\n\n--OUTPUT 8\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M := \nbegin\n have A1 : ∀ n : ℕ, fintype.card (@fintype.card F.Model (fintype.of_univ) n) = n, from by auto [fintype.card_univ],\n have A2 : ∀ n : ℕ, ∃ ( N : F.Model ) [mN : fintype N], ∀ i : ⋆, i.val < n → N.elems.val i ∈ N.elems.val (fintype.ord_max (n)), from begin\n assume n : ℕ,\n have B1 : ∀ i : ⋆, i.val < n → ∃ (m : F.Model) [mfin : fintype m], fintype.card m = n, from begin\n assume i₀ : ⋆,\n assume h : i₀.val < n,\n have h1 := (hgfp (@fintype.card F.Model (fintype.of_univ) n) (n+1)).val h,\n have h2 := nat.lt_succ_self n,\n have h3 : (n+1) ≤ fintype.card (hgfp (@fintype.card F.Model (fintype.of_univ) n) (n+1)).val, from h1 (λ a b, @nat.le_iff_lt_or_eq.2 b),\n have h4 : (n+1) ≤ (n+1), from by simp,\n have h5 : fintype.card (hgfp (@fintype.card F.Model (fintype.of_univ) n) (n+1)).val = n, from nat.eq_of_le_of_eq_of_le h2 h3 h4,\n have h6 : fintype (hgfp (@fintype.card F.Model (fintype.of_univ) n) (n+1)).val, from by auto [hgfp],\n show ∃ (m : F.Model) [mfin : fintype m], fintype.card m = n, from exists.intro (hgfp (@fintype.card F.Model (fintype.of_univ) n) (n+1)).val (exists.intro h6 h5),\n end,\n have B2 : ∀ i : ⋆, i.val < n → ∃ (m : F.Model), fintype.card m = n, from begin\n assume i₀ : ⋆,\n assume h : i₀.val < n,\n have h1 : ∃ (m : F.Model) [mfin : fintype m], fintype.card m = n, from B1 i₀ h,\n show ∃ (m : F.Model), fintype.card m = n, from exists.elim h1 (λ a b, a),\n end,\n have B3 : ∀ i : ⋆, i.val < n → ∃ (m : F.Model) [mfin : fintype m], fintype.card m = n, from by auto using B2,\n have B4 : ∀ i : ⋆, i.val < n → ∃ (m : F.Model), fintype.card m = n, from by auto using B3,\n have C1 : ∃ (m : F.Model) [mfin : fintype m], fintype.card m = n, from by auto [h, B4],\n have C2 : ∃ (m : F.Model), fintype.card m = n, from exists.elim C1 (λ a b, a),\n have C3 : ∃ (N : F.Model) [mN : fintype N], fintype.card N = n, from C2,\n have C4 : ∃ (N : F.Model) [mN : fintype N], ∀ i : ⋆, i.val < n → N.elems.val i ∈ N.elems.val (fintype.ord_max (n)), from exists.elim C3 (begin\n assume (N : F.Model) [mN : fintype N],\n assume hN : fintype.card N = n,\n have D1 : ∀ i : ⋆, i.val < n → N.elems.val i ∈ N.elems.val (fintype.ord_max (n)), from begin\n assume i₀ : ⋆,\n assume h : i₀.val < n,\n have h1 : ∃ (m : F.Model) [mfin : fintype m], fintype.card m = n, from B1 i₀ h,\n have h2 : fintype.card N = n, from hN,\n have h3 : ∀ i : ⋆, i.val < n → ∃ (m : F.Model), fintype.card m = n, from B4,\n have h4 : ∃ (N : F.Model) [mN : fintype N], fintype.card N = n, from h3 i₀ h,\n have h5 : ∃ (N : F.Model), fintype.card N = n, from exists.elim h4 (λ a b, a),\n have h6 : fintype.card N = fintype.card N, from h2,\n have h7 : fintype.card m = fintype.card N, from eq.trans (h2) (eq.symm (hN)),\n have h8 : ∃ (m : F.Model), fintype.card m = n, from h1,\n have h9 : ∃ (m : F.Model), fintype.card m = n, from h8,\n have h10 : ∃ (m : F.Model), fintype.card m = n, from h1,\n have h11 : ∃ (m : F.Model), fintype.card m = fintype.card N, from eq.trans (h10) (eq.symm h6),\n have h12 : fintype.card m = fintype.card N, from eq.trans (h10) (eq.symm h6),\n have h13 : ∃ (m : F.Model), fintype.card m = fintype.card N, from h11,\n have h14 : fintype.card m = fintype.card N, from eq.trans (h10) (eq.symm h6),\n have h15 : ∃ (m : F.Model), fintype.card m = n, from h1,\n have h16 : fintype.card m = n, from eq.trans (h1) (eq.symm h2),\n have h17 : n = n, from rfl,\n have h18 : ∃ (m : F.Model), fintype.card m = n, from exists.intro (N : F.Model) (exists.intro hN h6),\n have h19 : ∃ (m : F.Model), fintype.card m = fintype.card N, from exists.intro (N : F.Model) (exists.intro hN h6),\n have h20 : fintype.card m = fintype.card N, from h16,\n have h21 : fintype.card m = n, from h16,\n have h22 : (N : F.Model) ∈ N.elems, from by auto [fintype.subtype_val_range],\n have h23 : (N : F.Model) ∈ (N.elems), from h22,\n show N.elems.val i₀ ∈ N.elems.val (fintype.ord_max (n)), from h23,\n end,\n show ∃ (N : F.Model) [mN : fintype N], ∀ i : ⋆, i.val < n → N.elems.val i ∈ N.elems.val (fintype.ord_max (n)), from exists.intro (N : F.Model) (exists.intro mN D1),\n end),\n have C5 : ∃ (N\nend --Needs more than 2000 tokens!\n\n--OUTPUT 9\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n let Γ := F.add_axiom_of_infinite_models,\n have h1 : F.has_finite_models, from by auto [h],\n have h2 : ∀ (n : ℕ), n < Γ.card → ∃ (m : F.Model), n ≤ m.card, from by auto using [h1],\n have h3 : ∃ (M : F.Model), Γ.card ≤ M.card, from by auto using [compactness.compactness, h2],\n have h4 : ∃ (M : F.Model), infinite M, from by auto [h3],\n show ∃ (M : F.Model), infinite M, from h4,\nend\n\n--OUTPUT 10\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n\n have h1 : ∀ (n : ℕ), ∃ (m : F.Model), n ≤ fintype.card m, from by auto,\n\n have h3 : ∀ (n : ℕ), fintype.card ℕ ≥ n, from by linarith [fintype.card_nat],\n\n have h4 : ∀ (n : ℕ) (m : F.Model) [mfin : fintype m], n ≤ fintype.card m, from by {assume n m mfin, assume h, cases h, exact h},\n\n have h5 : ∀ (n : ℕ), ∃ (m : F.Model) [mfin : fintype m], fintype.card m ≥ n, from by auto [h1, h3, h4, exists.intro],\n\n have h6 : ∀ (A : set (L.Formula ℕ)), @fintype.card (set (L.Formula ℕ)) (fintype.fintype_set (L.Formula ℕ)) (F.Theory.SAT_set A) ≥ (fintype.card A), from by auto [fintype.card_SAT_set],\n\n have h7 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ fintype.card B = fintype.card A, from by auto [fintype.exists_set_of_card_eq, exists.intro],\n \n have h8 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ F.Theory.SAT_rel B, from by auto [h6, h7],\n\n have h9 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], fintype.card A < fintype.card (F.Theory.SAT_set A), from by auto,\n\n have h10 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ F.Theory.SAT_rel B ∧ fintype.card B ≤ fintype.card A, from by auto [h8, h9],\n\n have h11 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto,\n\n have h12 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n\n have h13 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n \n have h14 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n\n have h15 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n\n have h16 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n\n have h17 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n\n have h18 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n\n have h19 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n\n have h20 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n\n have h21 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT_set B ∧ fintype.card B < fintype.card A, from by auto [h8, h9],\n\n have h22 : ∀ (A : set (L.Formula ℕ)) [Afin : fintype A], ∃ (m : F.Model) [mfin : fintype m], ∃ (B : set (L.Formula ℕ)) [Bfin : fintype B], B ⊆ A ∧ m = F.Theory.SAT\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],\n have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],\n show (A ∩ B) ∈ 𝒫 S, from by auto [set.mem_powerset],\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]\n ... = x*(x+y) + y*(x+y) : by auto [add_mul]\n ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]\n ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],\n have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹], \n\n have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],\n have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],\n\n have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],\n have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],\n\n show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],\nend\n\n/--`theorem`\nOverflow theorem\nLet $F$ be a set of first-order formulas which has finite models of arbitrarily large size. Then $F$ has an infinite model.\n`proof`\nFor each $n$, let $\\mathbf A_n$ be the formula:\n\n$\\exists x_1 \\exists x_2 \\ldots \\exists x_n: \\{x_1 \\ne x_2 \\land x_1 \\ne x_3 \\land \\ldots \\land x_{n - 1} \\ne x_n\\}$\n\nThen $\\mathbf A_i$ is true in a structure $\\AA$ iff $\\AA$ has at least $n$ elements.\n\nTake:\n$$ \\Gamma := F \\cup \\bigcup_{i \\mathop = 1}^\\infty A_i $$\n\nSince $F$ has models of arbitrarily large size, every finite subset of $\\Gamma$ is satisfiable.\n\nFrom the Compactness Theorem, $\\Gamma$ is satisfiable in some model $\\mathbf{M}$.\n\nBut since $\\mathbf{M} \\models A_i$ for each $i$, $\\mathbf{M}$ must be infinite.\n\nSo $F$ has an infinite model.\n\nQED\n-/\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_auto-Natural-Language-Proof-Translation/Correct_statement-lean_proof_auto-3_few_shot_temperature_0.8_max_tokens_2000_n_10/clean_files/Overflow theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.36658973632215985, "lm_q1q2_score": 0.22818720723149288}} {"text": "import for_mathlib.derived.Ext_lemmas\nimport for_mathlib.Cech.homotopy\nimport for_mathlib.acyclic\nimport for_mathlib.exact_seq4\nimport for_mathlib.cech\nimport for_mathlib.chain_complex_exact\nimport for_mathlib.abelian_sheaves.exact\nimport for_mathlib.Cech.homotopy\nimport for_mathlib.wide_pullback_iso\nimport for_mathlib.equivalence_additive\n\nimport condensed.adjunctions2\nimport condensed.projective_resolution\nimport condensed.extr.equivalence\n.\n\nnoncomputable theory\n\nuniverses u\n\nopen category_theory category_theory.limits homotopy_category opposite\nopen function (surjective)\n\nnamespace condensed\n\nset_option pp.universes true\n\n-- ANNOYING!\ninstance presheaf_abelian : abelian (Profinite.{u}ᵒᵖ ⥤ Ab.{u+1}) :=\ncategory_theory.functor_category_is_abelian.{(u+2) u (u+1)}\n\n-- ANNOYING!\ninstance ExtrDisc_presheaf_abelian : abelian (ExtrDisc.{u}ᵒᵖ ⥤ Ab.{u+1}) :=\ncategory_theory.functor_category_is_abelian.{(u+2) u (u+1)}\n\ninstance ExtrSheaf_abelian' : abelian (Sheaf ExtrDisc.proetale_topology.{u} Ab.{u+1}) :=\ncategory_theory.Sheaf.abelian.{(u+2) u (u+1)}\n\ninstance ExtrSheaf_abelian : abelian (ExtrSheaf.{u} Ab.{u+1}) :=\ncategory_theory.Sheaf.abelian.{(u+2) u (u+1)}\n\ndef Profinite_to_presheaf_Ab : Profinite.{u} ⥤ Profinite.{u}ᵒᵖ ⥤ Ab.{u+1} :=\nyoneda ⋙ (whiskering_right _ _ _).obj (ulift_functor.{u+1} ⋙ AddCommGroup.free)\n\ndef Profinite_to_ExtrDisc_presheaf : Profinite.{u} ⥤ ExtrDisc.{u}ᵒᵖ ⥤ Type (u+1) :=\nyoneda ⋙ (whiskering_left _ _ _).obj ExtrDisc_to_Profinite.op ⋙\n (whiskering_right _ _ _).obj ulift_functor.{u+1}\n\ndef Profinite_to_ExtrDisc_presheaf_Ab : Profinite.{u} ⥤ ExtrDisc.{u}ᵒᵖ ⥤ Ab.{u+1} :=\nyoneda ⋙ (whiskering_left _ _ _).obj ExtrDisc_to_Profinite.op ⋙\n (whiskering_right _ _ _).obj (ulift_functor.{u+1} ⋙ AddCommGroup.free)\n\ndef unsheafified_free_Cech' (F : arrow Profinite.{u}) :\n chain_complex (Profinite.{u}ᵒᵖ ⥤ Ab.{u+1}) ℕ :=\nsimplicial_object.augmented.to_complex $\n(((simplicial_object.augmented.whiskering _ _).obj Profinite_to_presheaf_Ab).obj\n F.augmented_cech_nerve)\n\ndef unsheafified_free_ExtrDiscr_Cech (F : arrow Profinite.{u}) :\n chain_complex (ExtrDisc.{u}ᵒᵖ ⥤ Ab.{u+1}) ℕ :=\nsimplicial_object.augmented.to_complex $\n(((simplicial_object.augmented.whiskering _ _).obj Profinite_to_ExtrDisc_presheaf_Ab).obj\n F.augmented_cech_nerve)\n\ndef free_Cech' (F : arrow Profinite.{u}) :\n chain_complex (Condensed.{u} Ab.{u+1}) ℕ :=\n(((simplicial_object.augmented.whiskering _ _).obj\n (Profinite_to_Condensed ⋙ CondensedSet_to_Condensed_Ab)).obj\n F.augmented_cech_nerve).to_complex\n\ndef free_ExtrDisc_Cech' (F : arrow Profinite.{u}) :\n chain_complex (ExtrSheaf.{u} Ab.{u+1}) ℕ :=\n(((simplicial_object.augmented.whiskering _ _).obj\n (Profinite_to_ExtrDisc_presheaf_Ab ⋙ presheaf_to_Sheaf _ _)).obj\n F.augmented_cech_nerve).to_complex\n\ndef free_Cech (F : arrow Profinite.{u}) :\n chain_complex (Condensed.{u} Ab.{u+1}) ℤ :=\n(homological_complex.embed $ complex_shape.embedding.nat_down_int_down).obj (free_Cech' F)\n\ninstance Condensed_ExtrSheaf_equiv_additive :\n functor.additive (Condensed_ExtrSheaf_equiv Ab.{u+1}).inverse :=\nby constructor\n\ndef whiskering_Cech_comp_iso\n {C : Type*} [category C] {𝓐 : Type*} [category 𝓐] [abelian 𝓐] {𝓑 : Type*} [category 𝓑] [abelian 𝓑]\n (f : arrow C)\n [∀ (n : ℕ), has_wide_pullback f.right (λ (i : fin (n + 1)), f.left) (λ (i : fin (n + 1)), f.hom)]\n (F : C ⥤ 𝓐) (G : 𝓐 ⥤ 𝓑) (H : C ⥤ 𝓑) (E : F ⋙ G ≅ H) [G.additive] :\n (G.map_homological_complex _).obj ((((simplicial_object.augmented.whiskering _ _).obj F).obj\n f.augmented_cech_nerve).to_complex) ≅\n (((simplicial_object.augmented.whiskering _ _).obj H).obj f.augmented_cech_nerve).to_complex :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| 0 := E.app _\n| i+1 := E.app _\nend)\nbegin\n rintros i j (rfl : j + 1 = i),\n dsimp only [functor.map_homological_complex_obj_d,\n unsheafified_free_ExtrDiscr_Cech, free_ExtrDisc_Cech',\n simplicial_object.augmented.to_complex],\n rw [chain_complex.of_d, chain_complex.of_d],\n cases j,\n { dsimp only [whiskering_Cech_comp_iso._match_1],\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n nat_trans.comp_app, whisker_right_app, functor.const_comp_hom_app],\n rw [category.comp_id, category.comp_id, nat_iso.app_hom, ← E.hom.naturality],\n refl },\n {\n dsimp only [whiskering_Cech_comp_iso._match_1],\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.drop_obj,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n simplicial_object.whiskering_obj_obj_map,\n simplicial_object.boundary,\n nat_iso.app_hom],\n simp only [functor.map_sum, functor.map_zsmul, preadditive.comp_sum,\n preadditive.comp_zsmul, preadditive.sum_comp, preadditive.zsmul_comp],\n apply finset.sum_congr rfl, intros _ _,\n erw ← E.hom.naturality,\n refl, },\nend\n\n\ndef free_Cech'_iso_ExtrDisc (F : arrow Profinite.{u}) :\n ((Condensed_ExtrSheaf_equiv _).inverse.map_homological_complex _).obj (free_Cech' F) ≅\n free_ExtrDisc_Cech' F :=\nlet e := ExtrDisc_sheafification_iso in\nwhiskering_Cech_comp_iso F\n (Profinite_to_Condensed.{u} ⋙ CondensedSet_to_Condensed_Ab.{u})\n ((Condensed_ExtrSheaf_equiv.{u u+2} Ab.{u+1}).inverse)\n (Profinite_to_ExtrDisc_presheaf_Ab.{u} ⋙ presheaf_to_Sheaf.{u+2 u u+1} ExtrDisc.proetale_topology.{u} Ab.{u+1}) $\nnat_iso.of_components\n(λ S, e.symm.app _)\nbegin\n intros S T f,\n dsimp only [nat_iso.app_hom],\n erw e.symm.hom.naturality,\n refl,\nend\n\ninstance presheaf_to_Sheaf_additive :\n (presheaf_to_Sheaf.{u+2 u u+1} ExtrDisc.proetale_topology.{u} Ab.{u+1}).additive :=\ncategory_theory.Sheaf.presheaf_to_Sheaf_additive.{u+2 u u+1}\n\ndef acyclic_of_exact.induction_step_ex₂_aux\n {C : Type*} [category C] {𝓐 : Type*} [category 𝓐] [abelian 𝓐] {𝓑 : Type*} [category 𝓑] [abelian 𝓑]\n (f : arrow C)\n [∀ (n : ℕ), has_wide_pullback f.right (λ (i : fin (n + 1)), f.left) (λ (i : fin (n + 1)), f.hom)]\n (F : C ⥤ 𝓐) (G : 𝓐ᵒᵖ ⥤ 𝓑) [G.additive] :\n (G.map_homological_complex _).obj ((((simplicial_object.augmented.whiskering _ _).obj F).obj\n f.augmented_cech_nerve).to_complex).op ≅\n (((cosimplicial_object.augmented.whiskering _ _).obj (F.op ⋙ G)).obj\n f.augmented_cech_nerve.right_op).to_cocomplex :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| 0 := iso.refl _\n| i+1 := iso.refl _\nend)\nbegin\n rintros i j (rfl : i + 1 = j),\n dsimp only [functor.map_homological_complex_obj_d,\n unsheafified_free_ExtrDiscr_Cech, free_ExtrDisc_Cech',\n cosimplicial_object.augmented.to_cocomplex,\n simplicial_object.augmented.to_complex, homological_complex.op_d],\n rw [cochain_complex.of_d, chain_complex.of_d],\n cases i,\n { refine (category.id_comp _).trans ((category.comp_id _).trans _).symm,\n dsimp only [simplicial_object.augmented.to_complex_d,\n cosimplicial_object.augmented.to_cocomplex_d,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n cosimplicial_object.augmented.whiskering_obj_2,\n cosimplicial_object.augmented.whiskering_obj,\n nat_trans.comp_app, whisker_right_app,\n functor.const_comp_hom_app, functor.const_comp_inv_app],\n rw [category.comp_id, category.id_comp],\n refl, },\n { refine (category.id_comp _).trans ((category.comp_id _).trans _).symm,\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.drop_obj,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n simplicial_object.whiskering_obj_obj_map,\n simplicial_object.boundary,\n cosimplicial_object.augmented.to_cocomplex_d,\n cosimplicial_object.augmented.drop_obj,\n cosimplicial_object.augmented.whiskering_obj_2,\n cosimplicial_object.augmented.whiskering_obj,\n cosimplicial_object.whiskering_obj_obj_map,\n cosimplicial_object.coboundary],\n simp only [G.map_sum, G.map_zsmul, op_sum, op_zsmul],\n refl, },\nend\n\ndef free_ExtrDisc_Cech'_iso (F : arrow Profinite.{u}) :\n free_ExtrDisc_Cech' F ≅\n ((presheaf_to_Sheaf _ _).map_homological_complex _).obj (unsheafified_free_ExtrDiscr_Cech F) :=\n(whiskering_Cech_comp_iso F _ _ _ $ iso.refl _).symm\n/-\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| 0 := iso.refl _\n| i+1 := iso.refl _\nend)\nbegin\n rintros i j (rfl : j + 1 = i),\n dsimp only [functor.map_homological_complex_obj_d,\n unsheafified_free_ExtrDiscr_Cech, free_ExtrDisc_Cech',\n simplicial_object.augmented.to_complex],\n rw [chain_complex.of_d, chain_complex.of_d],\n cases j,\n { refine (category.id_comp _).trans ((category.comp_id _).trans _).symm,\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n nat_trans.comp_app, whisker_right_app, functor.const_comp_hom_app],\n rw [category.comp_id, category.comp_id],\n refl, },\n { refine (category.id_comp _).trans ((category.comp_id _).trans _).symm,\n dsimp only [simplicial_object.augmented.to_complex_d,\n simplicial_object.augmented.drop_obj,\n simplicial_object.augmented.whiskering_obj_2,\n simplicial_object.augmented.whiskering_obj,\n simplicial_object.whiskering_obj_obj_map,\n simplicial_object.boundary],\n simp only [functor.map_sum, functor.map_zsmul],\n refl, },\nend\n-/\n\n/-\ndef free_Cech_iso (F : arrow Profinite.{u}) :\n free_Cech F ≅ (homological_complex.embed $ complex_shape.embedding.nat_down_int_down).obj\n ((presheaf_to_Condensed_Ab.map_homological_complex _).obj\n (unsheafified_free_Cech' F)) :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| int.of_nat 0 := iso.refl _\n| int.of_nat (n+1) := iso.refl _\n| -[1+i] := iso.refl _\nend)\n(by admit)\n-/\n\n-- SO ANNOYING\ninstance evaluation_additive (X : ExtrDisc.{u}) :\n functor.additive ((evaluation ExtrDisc.{u}ᵒᵖ Ab.{u+1}).obj (op X)) :=\ncategory_theory.evaluation_additive.{(u+2) u (u+1)} _\n\ndef evaluated_free_ExtrDisc_Cech (F : arrow Profinite.{u}) (X : ExtrDisc.{u}) :\n chain_complex Ab.{u+1} ℕ :=\n(((simplicial_object.augmented.whiskering _ _).obj\n AddCommGroup.free).obj $\n ((Profinite_to_ExtrDisc_presheaf.flip.obj (op X)).map_arrow.obj F).augmented_cech_nerve).to_complex\n\n.\n\ndef yet_another_iso (F : arrow Profinite.{u}) (X : ExtrDisc.{u}) :\n (((evaluation.{u u+1 u+1 u+2} ExtrDisc.{u}ᵒᵖ Ab.{u+1}).obj\n (op X)).map_homological_complex\n (complex_shape.down.{0} ℕ)).obj\n (unsheafified_free_ExtrDiscr_Cech.{u} F) ≅\n evaluated_free_ExtrDisc_Cech F X :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| 0 := iso.refl _\n| i+1 := begin apply AddCommGroup.free.map_iso, apply ulift_wide_pullback_iso, end\nend)\nbegin\n rintros (_|i) (_|j) ⟨rfl⟩,\n { dsimp [yet_another_iso._match_1, iso.refl_hom], rw category.comp_id,\n dsimp [evaluated_free_ExtrDisc_Cech, unsheafified_free_ExtrDiscr_Cech],\n rw if_pos (rfl : (1 : ℕ) = 0 + 1), erw category.id_comp,\n rw if_pos (rfl : (1 : ℕ) = 0 + 1), erw category.id_comp,\n apply free_abelian_group.lift.ext,\n rintro ⟨t⟩,\n dsimp [AddCommGroup.free, simplicial_object.augmented.to_complex_d],\n simp only [category.comp_id, comp_apply, free_abelian_group.map_of_apply],\n dsimp at t,\n dsimp [ulift_wide_pullback_iso, ulift_wide_pullback_iso_hom_aux,\n Profinite_to_ExtrDisc_presheaf_Ab], congr' 1,\n have := types_comp_apply\n (wide_pullback.lift (ulift_functor.{u+1 u}.map ((yoneda.{u u+1}.map\n (wide_pullback.base (λ (_x : fin (0 + 0 + 1)), F.hom))).app\n (op.{u+2} X.val))) (λ (q : fin (0 + 0 + 1)), ulift_functor.{u+1 u}.map\n ((yoneda.{u u+1}.map (wide_pullback.π (λ (_x : fin (0 + 0 + 1)),\n F.hom) q)).app (op.{u+2} X.val))) _)\n (wide_pullback.base (λ (i : fin (0 + 0 + 1)),\n (Profinite_to_ExtrDisc_presheaf.{u}.map F.hom).app (op.{u+2} X)))\n (ulift.up t),\n rw ← this, clear this, rw wide_pullback.lift_base, refl },\n { dsimp [yet_another_iso._match_1,\n evaluated_free_ExtrDisc_Cech,\n unsheafified_free_ExtrDiscr_Cech],\n rw [if_pos, if_pos], swap, refl, swap, refl, rw [category.id_comp, category.id_comp],\n dsimp [simplicial_object.augmented.to_complex_d, simplicial_object.boundary],\n simp only [preadditive.sum_comp, preadditive.comp_sum, preadditive.zsmul_comp,\n preadditive.comp_zsmul, category_theory.nat_trans.app_sum,\n category_theory.nat_trans.app_zsmul],\n apply finset.sum_congr rfl, rintros i -, congr' 1,\n dsimp [simplicial_object.δ],\n\n apply free_abelian_group.lift.ext,\n rintro ⟨t⟩,\n simp only [comp_apply],\n dsimp [AddCommGroup.free, Profinite_to_ExtrDisc_presheaf_Ab], congr' 1,\n dsimp [ulift_wide_pullback_iso, ulift_wide_pullback_iso_hom_aux],\n\n let f1 := wide_pullback.lift (wide_pullback.base\n (λ (i : fin (j + 1 + 1)), (Profinite_to_ExtrDisc_presheaf.{u}.map F.hom).app (op.{u+2} X)))\n (λ (k : fin (j + 1)), wide_pullback.π\n (λ (i : fin (j + 1 + 1)), (Profinite_to_ExtrDisc_presheaf.{u}.map F.hom).app (op.{u+2} X))\n ((simplex_category.hom.to_order_hom (simplex_category.δ i)) k)) _,\n\n let f2 := wide_pullback.lift (ulift_functor.{u+1 u}.map ((yoneda.{u u+1}.map\n (wide_pullback.base (λ (_x : fin (j.succ + 0 + 1)), F.hom))).app (op.{u+2} X.val)))\n (λ (q : fin (j.succ + 0 + 1)), ulift_functor.{u+1 u}.map\n ((yoneda.{u u+1}.map (wide_pullback.π\n (λ (_x : fin (j.succ + 0 + 1)), F.hom) q)).app (op.{u+2} X.val))) _,\n\n let f3 := wide_pullback.lift (ulift_functor.{u+1 u}.map ((yoneda.{u u+1}.map\n (wide_pullback.base (λ (_x : fin (j + 0 + 1)), F.hom))).app (op.{u+2} X.val)))\n (λ (q : fin (j + 0 + 1)), ulift_functor.{u+1 u}.map\n ((yoneda.{u u+1}.map (wide_pullback.π\n (λ (_x : fin (j + 0 + 1)), F.hom) q)).app (op.{u+2} X.val))) _,\n\n change (f2 ≫ f1) _ = f3 _,\n\n let f4 := wide_pullback.lift (wide_pullback.base (λ (i : fin (j + 1 + 1)), F.hom))\n (λ (k : fin (j + 1)), wide_pullback.π\n (λ (i : fin (j + 1 + 1)), F.hom) ((simplex_category.hom.to_order_hom\n (simplex_category.δ i)) k)) _,\n\n suffices : f2 ≫ f1 = ((yoneda'.map f4).app (op X.val) ≫ f3),\n { rw this, refl },\n\n apply wide_pullback.hom_ext,\n\n { intros k,\n dsimp [f4,f3,f2,f1],\n simp only [category.assoc, wide_pullback.lift_π, wide_pullback.lift_π_assoc],\n erw [wide_pullback.lift_π],\n erw [← functor.map_comp, ← nat_trans.comp_app, ← functor.map_comp, wide_pullback.lift_π] },\n\n { dsimp [f4,f3,f2,f1],\n simp only [category.assoc, wide_pullback.lift_base, wide_pullback.lift_base_assoc],\n erw wide_pullback.lift_base,\n erw [← functor.map_comp, ← nat_trans.comp_app, ← functor.map_comp,\n wide_pullback.lift_base] } }\nend\n\nlemma free_Cech_exact (F : arrow Profinite.{u}) (hF : function.surjective F.hom) : ∀ (n : ℤ),\n is_zero $ (free_Cech F).homology n :=\nbegin\n dsimp only [free_Cech],\n rw chain_complex.homology_zero_iff_homology_zero,\n rw chain_complex.homology_zero_iff_map_homology_zero _\n (Condensed_ExtrSheaf_equiv Ab.{u+1}).symm,\n intros i,\n dsimp only [equivalence.symm_functor],\n let E := (_root_.homology_functor _ _ i).map_iso (free_Cech'_iso_ExtrDisc F),\n apply is_zero.of_iso _ E, clear E,\n let E := (_root_.homology_functor _ _ i).map_iso (free_ExtrDisc_Cech'_iso F),\n apply is_zero.of_iso _ E, clear E,\n dsimp only [_root_.homology_functor],\n revert i,\n apply category_theory.Sheaf.map_presheaf_to_Sheaf_homology_zero_of_homology_zero.{(u+2) u (u+1)},\n apply category_theory.homology_zero_of_eval.{(u+2) u (u+1)},\n any_goals { apply_instance },\n intros X, tactic.op_induction',\n intros i,\n let E := (_root_.homology_functor _ _ i).map_iso (yet_another_iso F X),\n apply is_zero.of_iso _ E,\n -- Now we can use the splitting similarly to arrow.conerve_to_cocomplex_homology_is_zero\n -- but we need a dual variant.\n let G := ((Profinite_to_ExtrDisc_presheaf.flip.obj (op X)).map_arrow.obj F),\n haveI : G.split,\n { suffices : function.surjective G.hom,\n { refine ⟨λ i, (this i).some, _⟩,\n ext1 i, exact (this i).some_spec },\n dsimp [G, functor.map_arrow, Profinite_to_ExtrDisc_presheaf, ulift_functor, yoneda],\n rintros ⟨e⟩,\n use ExtrDisc.lift _ hF e,\n ext1,\n dsimp,\n rw ExtrDisc.lift_lifts },\n apply arrow.nerve_to_complex_homology_is_zero AddCommGroup.free G,\n recover,\nend\n\nlemma free_Cech_kernel_SES (F : arrow Profinite.{u}) (hF : function.surjective F.hom) : ∀ n,\n short_exact (kernel.ι $ (free_Cech F).d (n+1+1) (n+1)) (delta_to_kernel _ (n+1+1) (n+1) n) :=\nbegin\n erw ← is_acyclic_iff_short_exact_to_cycles' (free_Cech F), exact free_Cech_exact F hF\nend\n\nvariable (M : Condensed.{u} Ab.{u+1})\n\nabbreviation HH (i : ℤ) (S : Profinite.{u}) (M : Condensed.{u} Ab.{u+1}) :=\n((Ext' i).obj (op $ (CondensedSet_to_Condensed_Ab).obj $ Profinite.to_Condensed S)).obj M\n\ndef acyclic_of_exact.IH (n : ℤ) : Prop := ∀ S, ∀ i > 0, i ≤ n → is_zero (HH i S M)\n\n/-- Consider the following commutative diagram\n```\n O₀\n ↓\nA₁ → B₁ → C₁ → O₁\n ↘ ↓\n B₂\n ↓ ↘\nO₃ → B₃ → C₃\n```\nwhere `O₀`, `O₁`, and `O₃` are zero objects, and all sequence are exact.\n\nThen `C₁` is also a zero object.\n-/\nlemma acyclic_of_exact.induction_step_aux {𝓐 : Type*} [category 𝓐] [abelian 𝓐]\n {O₀ O₁ O₃ A₁ B₁ C₁ B₂ B₃ C₃ : 𝓐}\n {α₁ : A₁ ⟶ B₁} {β₁ : B₁ ⟶ C₁} {γ₁ : C₁ ⟶ O₁} (ex₁ : exact_seq 𝓐 [α₁, β₁, γ₁])\n {d₁ : A₁ ⟶ B₂} {d₂ : B₂ ⟶ C₃} (exd : exact d₁ d₂)\n {b₀ : O₀ ⟶ B₁} {b₁ : B₁ ⟶ B₂} {b₂ : B₂ ⟶ B₃} (exb : exact_seq 𝓐 [b₀, b₁, b₂])\n {α₃ : O₃ ⟶ B₃} {β₃ : B₃ ⟶ C₃} (ex₃ : exact α₃ β₃)\n (hO₀ : is_zero O₀) (hO₁ : is_zero O₁) (hO₃ : is_zero O₃)\n (tr₁ : α₁ ≫ b₁ = d₁) (tr₂ : b₂ ≫ β₃ = d₂) :\n is_zero C₁ :=\nbegin\n refine (ex₁.drop 1).pair.is_zero_of_eq_zero_eq_zero\n (ex₁.pair.eq_zero_of_epi _) (hO₁.eq_of_tgt _ _),\n haveI : mono b₁ := exb.pair.mono_of_eq_zero (hO₀.eq_of_src _ _),\n haveI : mono β₃ := ex₃.mono_of_eq_zero (hO₃.eq_of_src _ _),\n let l' := abelian.is_limit_of_exact_of_mono _ _ (exb.drop 1).pair,\n let l := is_kernel_comp_mono l' β₃ tr₂.symm,\n obtain rfl :\n α₁ = kernel.lift _ _ exd.w ≫ (is_limit.cone_point_unique_up_to_iso (limit.is_limit _) l).hom,\n { erw [← cancel_mono b₁, category.assoc,\n is_limit.cone_point_unique_up_to_iso_hom_comp _ _ walking_parallel_pair.zero, is_limit.fac,\n fork.of_ι_π_app, tr₁] },\n apply epi_comp\nend\n\nlemma acyclic_of_exact.induction_step_ex₁\n (F : arrow Profinite.{u})\n (h : ∀ i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n F.augmented_cech_nerve.right_op).to_cocomplex).homology i)) :\n let C := (((cosimplicial_object.augmented.whiskering Profiniteᵒᵖ Ab).obj\n ((Profinite_to_Condensed ⋙ CondensedSet_to_Condensed_Ab).op ⋙ preadditive_yoneda.obj M)).obj\n F.augmented_cech_nerve.right_op).to_cocomplex\n in ∀ i, is_zero (C.homology i) :=\nbegin\n intros C i,\n apply is_zero.of_iso (h i),\n refine (_root_.homology_functor _ _ i).map_iso _,\n refine cosimplicial_object.augmented.cocomplex.map_iso _,\n refine iso.app (functor.map_iso _ (condensed.profinite_free_adj _)) _,\nend\n\nlemma acyclic_of_exact.induction_step_ex₂\n (F : arrow Profinite.{u})\n (h : let C := (((cosimplicial_object.augmented.whiskering Profiniteᵒᵖ Ab).obj\n ((Profinite_to_Condensed ⋙ CondensedSet_to_Condensed_Ab).op ⋙ preadditive_yoneda.obj M)).obj\n F.augmented_cech_nerve.right_op).to_cocomplex\n in ∀ i, is_zero (C.homology i)) :\n ∀ i, is_zero ((((preadditive_yoneda.obj M).map_homological_complex _).obj (free_Cech' F).op).homology i) :=\nbegin\n intro i, apply (h i).of_iso,\n refine (_root_.homology_functor _ _ _).map_iso _,\n apply acyclic_of_exact.induction_step_ex₂_aux,\nend\n\nlemma int.of_nat_add_one (i : ℕ) : int.of_nat i + 1 = int.of_nat (i+1) := rfl\n\nlemma complex_shape.embedding.nat_down_int_down.r_int_of_nat (i : ℕ) :\n complex_shape.embedding.nat_down_int_down.r (int.of_nat i) = option.some i := rfl\n\n-- move me\nlemma cochain_complex.mono_of_is_zero_homology_0\n {𝓐 : Type*} [category 𝓐] [abelian 𝓐]\n (C : cochain_complex 𝓐 ℕ) (h : is_zero $ C.homology 0) :\n mono (C.d 0 1) :=\nbegin\n replace h := exact_of_homology_is_zero h,\n rw [C.d_from_eq (show (complex_shape.up ℕ).rel 0 1, by simp), exact_comp_iso] at h,\n refine mono_of_exact_of_eq_zero _ _ _ _ _ h _,\n rw homological_complex.d_to_eq_zero,\n simp only [cochain_complex.prev_nat_zero, complex_shape.up_rel,\n nat.one_ne_zero, not_false_iff],\nend\n\nlemma acyclic_of_exact.induction_step_ex₃\n (F : arrow Profinite.{u}) (i : ℤ)\n (h : ∀ i, is_zero ((((preadditive_yoneda.obj M).map_homological_complex _).obj (free_Cech' F).op).homology i)) :\n exact ((preadditive_yoneda.obj M).map $ ((free_Cech F).d (i+1) i).op)\n ((preadditive_yoneda.obj M).map $ ((free_Cech F).d (i+1+1) (i+1)).op) :=\nbegin\n rcases i with (i|i),\n { delta free_Cech,\n dsimp only [homological_complex.embed, homological_complex.embed.obj],\n rw [int.of_nat_add_one, int.of_nat_add_one],\n erw [complex_shape.embedding.nat_down_int_down.r_int_of_nat],\n erw [complex_shape.embedding.nat_down_int_down.r_int_of_nat],\n erw [complex_shape.embedding.nat_down_int_down.r_int_of_nat],\n dsimp only [homological_complex.embed.d],\n refine exact_of_homology_is_zero ((h (i+1)).of_iso $ _),\n { rw [← functor.map_comp, ← op_comp, homological_complex.d_comp_d, op_zero, functor.map_zero] },\n clear h,\n refine _ ≪≫ (homology_iso _ i (i+1) (i+1+1) _ _).symm,\n swap, { dsimp, refl }, swap, { dsimp, refl },\n refl, },\n { have aux : (preadditive_yoneda.obj M).map ((free_Cech F).d (-[1+ i] + 1) -[1+ i]).op = 0,\n { cases i; erw [op_zero, functor.map_zero], },\n rw [aux], clear aux, apply_with exact_zero_left_of_mono {instances:=ff}, { apply_instance },\n cases i,\n { exact cochain_complex.mono_of_is_zero_homology_0 _ (h 0), },\n { apply mono_of_is_zero_object,\n rw [is_zero_iff_id_eq_zero, ← category_theory.functor.map_id,\n is_zero_iff_id_eq_zero.mp, functor.map_zero],\n refine (is_zero_zero _).op, } },\nend\n\nlemma acyclic_of_exact.induction_step_ex₄\n (F : arrow Profinite.{u}) (i : ℤ)\n (h : exact ((preadditive_yoneda.obj M).map $ ((free_Cech F).d (i+1) i).op)\n ((preadditive_yoneda.obj M).map $ ((free_Cech F).d (i+1+1) (i+1)).op)) :\n exact (((Ext' 0).flip.obj M).map $ ((free_Cech F).d (i+1) i).op)\n (((Ext' 0).flip.obj M).map $ ((free_Cech F).d (i+1+1) (i+1)).op) :=\nbegin\n let e := (bounded_derived_category.Ext'_zero_flip_iso _ M).symm,\n apply preadditive.exact_of_iso_of_exact' _ _ _ _ (e.app _) (e.app _) (e.app _) _ _ h,\n { simp only [nat_iso.app_hom, nat_trans.naturality], },\n { simp only [nat_iso.app_hom, nat_trans.naturality], }\nend\n\nlemma acyclic_of_exact.induction_step_ex\n (F : arrow Profinite.{u}) (surj : function.surjective F.hom)\n (h : ∀ i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n (i : ℤ) :\n exact (((Ext' 0).flip.obj M).map $ ((free_Cech F).d (i+1) i).op)\n (((Ext' 0).flip.obj M).map $ ((free_Cech F).d (i+1+1) (i+1)).op) :=\nbegin\n apply acyclic_of_exact.induction_step_ex₄,\n apply acyclic_of_exact.induction_step_ex₃,\n apply acyclic_of_exact.induction_step_ex₂,\n apply acyclic_of_exact.induction_step_ex₁ _ F h,\nend\n\nlemma acyclic_of_exact.induction_step\n (h : ∀ (F : arrow Profinite.{u}) (surj : function.surjective F.hom),\n ∀ i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n (n : ℤ) (ih : acyclic_of_exact.IH M n) :\n acyclic_of_exact.IH M (n+1) :=\nbegin\n intros S i h1 h2,\n rw [le_iff_eq_or_lt, or_comm, int.lt_add_one_iff] at h2,\n cases h2 with h2 h2, { exact ih S i h1 h2 },\n subst i,\n let F := arrow.mk S.projective_presentation.f,\n have hF : function.surjective F.hom,\n { rw ← Profinite.epi_iff_surjective, apply projective_presentation.epi },\n let E := λ i, (Ext' i).flip.obj M,\n have ih' : ∀ (i j : ℤ) (h0i : 0 < i) (hin : i ≤ n),\n is_zero ((E i).obj (op ((free_Cech F).X j))),\n { intros i j h0i hin,\n cases j with j j,\n { cases j; exact ih _ _ h0i hin, },\n { apply bounded_derived_category.Ext'_zero_left_is_zero,\n exact (is_zero_zero _).op, } },\n let K := λ i, kernel ((free_Cech F).d (i + 1) i),\n have LES := λ i j, (free_Cech_kernel_SES F hF i).Ext'_five_term_exact_seq M j,\n have H1 : ∀ i > 0, is_zero ((E i).obj (op ((free_Cech F).X 1))),\n { intros i hi,\n apply bounded_derived_category.Ext'_is_zero_of_projective _ _ _ _ hi,\n apply_with Condensed_Ab.free.category_theory.projective {instances:=ff},\n rw [simplicial_object.augmented.drop_obj, arrow.augmented_cech_nerve_left],\n apply projective.of_iso (arrow.cech_nerve_obj_0 F).symm,\n apply projective_presentation.projective, },\n have aux0 : ∀ (i : ℤ) (h0i : 0 < i+1) (H : is_zero ((E i).obj (op $ K 0))),\n is_zero ((E (i+1)).obj (op $ K (-1))),\n { intros i h0i H,\n refine is_zero_of_exact_is_zero_is_zero _ _ ((LES (-1) i).drop 2).pair H (H1 _ h0i), },\n have aux : ∀ (i j : ℤ) (h0i : 0 < i+1) (hi : i+1 ≤ n) (H : is_zero ((E i).obj (op $ K (j+1)))),\n is_zero ((E (i+1)).obj (op $ K j)),\n { intros i j h0i hi H,\n refine is_zero_of_exact_is_zero_is_zero _ _ ((LES j i).drop 2).pair H _,\n refine ih' _ _ h0i hi },\n suffices : ∀ i j, 0 < i → -1 ≤ j → i + j = n → is_zero ((E i).obj (op $ K j)),\n { refine is_zero_of_exact_is_zero_is_zero _ _ (LES (-2) (n+1)).pair _ _; clear LES,\n { apply bounded_derived_category.Ext'_zero_left_is_zero,\n refine (is_zero_of_mono (kernel.ι _) _).op, refine is_zero_zero _, },\n { refine this (n+1) (-1) h1 le_rfl _, rw [← sub_eq_add_neg, add_sub_cancel] } },\n obtain ⟨n, rfl⟩ : ∃ k, k+1 = n := ⟨n-1, sub_add_cancel _ _⟩,\n suffices : is_zero ((E 1).obj (op $ K n)),\n { intro i,\n apply int.induction_on' i 1; clear i,\n { intros j h0i hj hijn, rw [add_comm (1:ℤ), add_left_inj] at hijn, subst j, exact this },\n { intros i hi IH j hi' hj hijn,\n rw le_iff_eq_or_lt at hj, cases hj with hj hj,\n { subst j, apply aux0 _ hi', apply IH; linarith only [hi, hijn] },\n { apply aux _ _ hi' _ (IH _ _ _ _); linarith only [hi, hijn, hj], } },\n { intros i hi IH j hi', exfalso, linarith only [hi, hi'] } },\n clear aux0 aux,\n have aux := λ i, ((LES i (-1)).drop 2).pair.cons (LES i 0),\n have exd := acyclic_of_exact.induction_step_ex M F hF (h F hF) (n+1+1),\n apply acyclic_of_exact.induction_step_aux\n ((LES n 0).drop 1) exd ((aux (n+1)).extract 0 3) (aux (n+1+1)).pair; clear LES aux exd,\n { apply Ext'_is_zero_of_neg, dec_trivial },\n { obtain (rfl|hn) : n = -1 ∨ 1 ≤ n + 1,\n { rw [or_iff_not_imp_right], intro h2, linarith only [h1, h2] },\n { exact H1 _ zero_lt_one },\n { exact ih' _ _ zero_lt_one hn } },\n { apply Ext'_is_zero_of_neg, dec_trivial },\n { conv_rhs { rw [← delta_to_kernel_ι _ _ _ (n+1), op_comp, functor.map_comp] }, refl },\n { conv_rhs { rw [← delta_to_kernel_ι _ _ _ (n+1+1), op_comp, functor.map_comp] }, refl },\nend\n\nlemma acyclic_of_exact\n (h : ∀ (F : arrow Profinite.{u}) (surj : function.surjective F.hom),\n ∀ i, is_zero\n (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n (S : Profinite.{u}) :\n ∀ i > 0, is_zero (HH i S M) :=\nbegin\n intros i hi,\n suffices : acyclic_of_exact.IH M i,\n { apply this S i hi le_rfl, },\n apply int.induction_on' i 0; clear hi i S,\n { intros S i h1 h2, exfalso, exact h2.not_lt h1 },\n { intros k hk, apply acyclic_of_exact.induction_step M h, },\n { rintros k hk aux S i h1 h2, exfalso, linarith only [hk, h1, h2] }\nend\n\nend condensed\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/acyclic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5926665855647395, "lm_q2_score": 0.3849121444839335, "lm_q1q2_score": 0.22812456641369455}} {"text": "\n-- import data.array.lemmas\nimport tactic\nimport tactic.squeeze\nimport data.list.basic\n-- import tactic.linarith\n-- import data.finmap\n\nuniverses u v w\n\nstructure label (α : Type w) (m : Type u → Type v) (β : Type u) :=\n(apply : α → m β)\n\ndef goto {α β} {m : Type u → Type v} (f : label α m β) (x : α) := f.apply x\n\nclass monad_cont (m : Type u → Type v)\nextends monad m :=\n(call_cc : Π {α β}, ((label α m β) → m α) → m α)\n\nopen monad_cont\nclass is_lawful_monad_cont (m : Type u → Type v) [monad_cont m]\nextends is_lawful_monad m :=\n(call_cc_bind_right {α ω γ} (cmd : m α) (next : (label ω m γ) → α → m ω) :\n call_cc (λ f, cmd >>= next f) = cmd >>= λ x, call_cc (λ f, next f x))\n(call_cc_bind_left {α} (β) (x : α) (dead : label α m β → β → m α) :\n call_cc (λ f : label α m β, goto f x >>= dead f) = pure x)\n(call_cc_dummy {α β} (dummy : m α) :\n call_cc (λ f : label α m β, dummy) = dummy)\n\nexport is_lawful_monad_cont\n\ndef cont_t (r : Type u) (m : Type u → Type v) (α : Type w) := (α → m r) → m r\n\nnamespace cont_t\n\nvariables {r : Type u} {m : Type u → Type v} {α β γ ω : Type w}\n\ndef run : cont_t r m α → (α → m r) → m r := id\n\ndef map (f : m r → m r) (x : cont_t r m α) : cont_t r m α := f ∘ x\n\nlemma run_cont_t_map_cont_t (f : m r → m r) (x : cont_t r m α) :\n run (map f x) = f ∘ run x := rfl\n\ndef with_cont_t (f : (β → m r) → α → m r) (x : cont_t r m α) : cont_t r m β :=\nλ g, x $ f g\n\nlemma run_with_cont_t (f : (β → m r) → α → m r) (x : cont_t r m α) :\n run (with_cont_t f x) = run x ∘ f := rfl\n\n-- def call_cc (f : (α → cont_t r m β) → cont_t r m α) : cont_t r m α :=\n-- λ g, f (λ x h, g x) g\n\ninstance : monad (cont_t r m) :=\n{ pure := λ α x f, f x,\n bind := λ α β x f g, x $ λ i, f i g }\n\n-- variables [is_lawful_monad m]\n\ninstance : is_lawful_monad (cont_t r m) :=\n{ id_map := by { intros, refl },\n pure_bind := by { intros, ext, refl },\n bind_assoc := by { intros, ext, refl } }\n\ninstance [monad m] : has_monad_lift m (cont_t r m) :=\n{ monad_lift := λ a x f, x >>= f }\n\nlemma monad_lift_bind [monad m] [is_lawful_monad m] {α β} (x : m α) (f : α → m β) :\n (monad_lift (x >>= f) : cont_t r m β) = monad_lift x >>= monad_lift ∘ f :=\nby { ext, simp only [monad_lift,has_monad_lift.monad_lift,(∘),(>>=),bind_assoc,id.def] }\n\ninstance : monad_cont (cont_t r m) :=\n{ call_cc := λ α β f g, f ⟨λ x h, g x⟩ g }\n\ninstance : is_lawful_monad_cont (cont_t r m) :=\n{ call_cc_bind_right := by intros; ext; refl,\n call_cc_bind_left := by intros; ext; refl,\n call_cc_dummy := by intros; ext; refl }\n\nend cont_t\n\nsection take_while\nopen list (hiding take_while)\nvariables {r : Type u} {m : Type u → Type v} {α β γ ω : Type w}\n\ndef take_while' [monad_cont m] {α} (p : α → Prop) [decidable_pred p] (xs : list α) : m (list α) :=\ncall_cc $ λ leave,\ndo rs ← mfoldl (λ rs x,\n if p x then pure $ x :: rs\n else goto leave rs.reverse )\n [] xs,\n pure rs.reverse\n\ndef take_while (p : α → Prop) [decidable_pred p] (xs : list α) : list α :=\ncont_t.run (take_while' p xs) id\n\nmeta def assigned : tactic unit :=\ndo tactic.cleanup\n\nlemma take_while_eq' [monad_cont m] [is_lawful_monad_cont m] {α} (p : α → Prop) [decidable_pred p] (xs : list α) :\n take_while' p xs = (pure $ list.take_while p xs : m (list α)) :=\nbegin\n suffices : take_while' p xs = (pure $ [].reverse ++ list.take_while p xs : m (list α)),\n { revert this, simp only [imp_self, list.nil_append, list.reverse_nil] },\n dunfold take_while', generalize : list.nil = rs,\n induction xs with x xs generalizing rs,\n { simp only [list.take_while, call_cc_dummy, mfoldl, list.append_nil, pure_bind], },\n { simp [list.take_while, list.mfoldl_cons], split_ifs,\n { simp only [xs_ih,reverse_cons,cons_append,eq_self_iff_true,nil_append,pure_bind,append_assoc] },\n { simp only [bind_assoc, list.append_nil, call_cc_bind_left] } },\nend\n\nlemma take_while_eq (p : α → Prop) [decidable_pred p] (xs : list α) :\n take_while p xs = list.take_while p xs :=\nby rw [take_while,take_while_eq']; refl\n\nend take_while\n\nsection duff -- not the beer\n\nopen nat\nvariables {m : Type u → Type v} {α β γ ω : Type u}\nvariables (f : α → m α)\n\nsection iter\nvariables [monad m]\ndef iterate' : ℕ → α → m α\n| 0 := pure\n| (succ n) := λ x, f x >>= iterate' n\nopen list\n\nlemma iterate_eq_foldl (n : ℕ) (x : α) :\n iterate' f n x = mfoldl (λ i _, f i) x (iota n) :=\nbegin\n induction n with n generalizing x, refl,\n dsimp [iterate',mfoldl,iota],\n congr, ext, apply n_ih,\nend\n\nvariables [is_lawful_monad m]\n\nlemma iterate_succ' (n : ℕ) (x : α) :\n iterate' f (succ n) x = iterate' f n x >>= f :=\nbegin\n dsimp [iterate'],\n induction n with n generalizing x;\n simp only [iterate', *, bind_pure, nat.nat_zero_eq_zero, pure_bind],\n rw [← bind_assoc,n_ih],\nend\n\nlemma iterate_succ'' (n : ℕ) :\n iterate' f (succ n) = λ x, iterate' f n x >>= f :=\nby ext; rw _root_.iterate_succ'\n\nlemma iterate_bind_iterate (x : α) (n k : ℕ) :\n iterate' f k x >>= iterate' f n = iterate' f (k + n) x :=\nby induction k generalizing x; simp only [iterate',*,bind_assoc,pure_bind,zero_add,succ_add]\n\nlemma iterate_iterate (n k : ℕ) :\n iterate' (iterate' f n) k = iterate' f (n*k) :=\nby induction k; simp only [iterate',*,iterate_bind_iterate,mul_succ,mul_zero,eq_self_iff_true,add_comm]\n\nend iter\n\nvariables [monad_cont m]\n\ndef iterate_duff' : Π n, (array n (label α m α) → α → m α) → α → m α\n| 0 f x := f array.nil x\n| (succ n) g x :=\ncall_cc $ λ goto_n,\ndo y ← iterate_duff' n (λ a, g $ a.push_back goto_n) x,\n f y\n\ndef duff_idx {n} : fin n → fin n\n| ⟨i,hi⟩ :=\nhave h : n - (i + 1) < n,\n from nat.sub_lt_self (lt_of_le_of_lt (nat.zero_le _) hi) (zero_lt_succ _),\n⟨n - (i+1), h⟩\n\ndef iterate_duff {n} (i : fin n) : α → m α :=\niterate_duff' f n $ λ a,\ngoto (a.read (duff_idx i))\n\nvariables [is_lawful_monad_cont m]\n\n@[simp]\nlemma iterate_duff_dummy (n : ℕ) (goto_n : α → m α) (x : α) :\n iterate_duff' f n (λ (a : array n (label α m α)), goto_n) x = goto_n x >>= iterate' f n :=\nbegin\n induction n generalizing goto_n;\n simp only [iterate_duff',*,_root_.iterate_succ'',call_cc_dummy,bind_assoc],\n simp only [iterate', bind_pure],\nend\n\nlemma read_push_back {n} (a : array n α) (x : α) (i : fin $ n+1) :\n (a.push_back x).read (duff_idx i) =\n if h' : i = 0 then x\n else a.read (duff_idx $ i.pred h') :=\nby { cases i, dsimp [array.push_back,array.read,duff_idx,d_array.read],\n apply dif_ctx_congr, intros, refl,\n { intros, dsimp [duff_idx,fin.pred], congr' 2,\n cases i_val, contradiction,\n dsimp [pred], rw nat.add_sub_add_right, },\n { rw [nat.add_sub_add_right,nat.sub_eq_iff_eq_add],\n conv { to_lhs, to_lhs, rw ← add_zero n },\n rw add_left_inj, split; intro h;\n try { injection h }; subst i_val; refl,\n apply le_of_lt_succ i_is_lt, } }\n\nlemma coe_pred {n} (i : fin $ succ n) (h : i ≠ 0) :\n ↑(i.pred h) = nat.pred i :=\nby cases i; refl\n\nlemma iterate_duff_def {n} (i : fin n) (x : α) :\n iterate_duff f i x = iterate' f i x :=\nbegin\n dsimp [iterate_duff],\n induction n generalizing i,\n { cases not_lt_zero _ i.is_lt },\n { simp only [iterate_duff', read_push_back], split_ifs,\n { subst i,\n unfold_coes, unfold has_zero.zero,\n simp only [iterate',call_cc_bind_left,bind_assoc, iterate_duff_dummy] },\n { specialize n_ih (i.pred h), simp only [n_ih, call_cc_dummy, coe_pred],\n cases i with i, cases i, contradiction,\n unfold_coes, dsimp [fin.val],\n rw [_root_.iterate_succ'] } }\nend\n\ndef push_each : Π (l : list α) {n}, array n α → array (n + l.length) α\n| [] n a := a\n| (x :: xs) n a :=\nhave n + 1 + xs.length = (n + list.length (x :: xs)),\n by simp only [list.length, add_comm, add_left_comm],\ncast (by rw this) $ push_each xs $ a.push_back x\n\nlemma iterate_duff_def_4 (i : fin 4) (x : α) :\n iterate' f i x =\n call_cc (λ goto_n_0 : label α m α,\n call_cc (λ goto_n_1,\n call_cc (λ goto_n_2,\n call_cc (λ goto_n_3,\n let a := push_each [goto_n_3,goto_n_2,goto_n_1,goto_n_0] array.nil in\n goto (a.read (duff_idx i)) x >>=\n λ (y₄ : α), f y₄) >>=\n λ (y₃ : α), f y₃) >>=\n λ (y₂ : α), f y₂) >>=\n λ (y₁ : α), f y₁)\n :=\nbegin\n rw ← iterate_duff_def,\n dsimp [iterate_duff,iterate_duff'], refl,\nend\n\nlemma unroll_iterate_def (n c : ℕ) (h : n > 0) (x : α) :\n iterate' f c x =\n iterate_duff f ⟨c % n, mod_lt c h ⟩ x >>=\n iterate' (iterate' f n) (c / n) :=\nbegin\n rw iterate_duff_def, unfold_coes, dsimp [fin.val],\n simp only [iterate_iterate,iterate_bind_iterate,mod_add_div],\nend\n\nlemma unroll_iterate_def_4 (c : ℕ) (x : α) :\n iterate' f c x =\n call_cc (λ goto_n_0 : label α m α,\n call_cc (λ goto_n_1,\n call_cc (λ goto_n_2,\n call_cc (λ goto_n_3,\n let a := push_each [goto_n_3,goto_n_2,goto_n_1,goto_n_0] array.nil in\n goto (a.read $ duff_idx (⟨c % 4,mod_lt c dec_trivial⟩)) x >>=\n λ (y₄ : α), f y₄) >>=\n λ (y₃ : α), f y₃) >>=\n λ (y₂ : α), f y₂) >>=\n λ (y₁ : α), f y₁) >>=\n iterate' (λ x,\n f x >>= f >>=\n f >>= f)\n (c / 4) :=\nbegin\n rw unroll_iterate_def _ 4,\n dsimp [iterate_duff,iterate',iterate_duff'],\n congr, ext, simp only [bind_assoc,bind_pure], apply_instance\nend\n\nend duff\n", "meta": {"author": "cipher1024", "repo": "call-cc", "sha": "a287a0b1813279a76dc6ac9eeb1e0629b45e3e23", "save_path": "github-repos/lean/cipher1024-call-cc", "path": "github-repos/lean/cipher1024-call-cc/call-cc-a287a0b1813279a76dc6ac9eeb1e0629b45e3e23/src/call_cc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5117166047041652, "lm_q2_score": 0.44552953503957266, "lm_q1q2_score": 0.22798486096587553}} {"text": "/- Enumerable and the Decidable instance may already be in Mathlib -/\n\nclass Enumerable (α : Type u) where\n elems : List α\n complete : ∀ a : α, a ∈ elems\n\ndef List.allTrue (p : α → Prop) [(a : α) → Decidable (p a)] : List α → Bool\n | [] => true\n | a :: as => p a && allTrue p as\n\ntheorem List.of_allTrue [(a : α) → Decidable (p a)] (hc : allTrue p as) (hin : a ∈ as) : p a := by\n induction as with\n | nil => contradiction\n | cons b bs ih =>\n cases hin with simp [allTrue] at hc\n | head => simp [*]\n | tail _ h => exact ih hc.2 h\n\ntheorem List.allTrue_of_forall [(a : α) → Decidable (p a)] (h : ∀ a, p a) : allTrue p as := by\n induction as <;> simp [allTrue, *]\n\ninstance [Enumerable α] (p : α → Prop) [(a : α) → Decidable (p a)] : Decidable (∀ a, p a) :=\n have : List.allTrue p Enumerable.elems → (a : α) → p a :=\n fun h a => List.of_allTrue h (Enumerable.complete a)\n decidable_of_decidable_of_iff (Iff.intro this List.allTrue_of_forall)\n\ninductive States | s0 | s1 | s2 | s3 | s4 | s5 | s6 | s7 | s8 | s9 | s10 | s11 | s12 | s13 | s14 | s15 | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | s32 | s33 | s34\nderiving DecidableEq\n\n/- We can add a `deriving` for `Enumerable` in the future. -/\nopen States in\ninstance : Enumerable States where\n elems := [s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21, s22, s23, s24, s25, s26, s27, s28, s29, s30, s31, s32, s33, s34]\n complete a := by cases a <;> decide\n\nopen States\ndef f : States → States → States\n| s0, s0 => s0\n| s0, s1 => s0\n| s0, s2 => s0\n| s0, s3 => s0\n| s0, s4 => s0\n| s0, s5 => s0\n| s0, s6 => s0\n| s0, s7 => s0\n| s0, s8 => s0\n| s0, s9 => s0\n| s0, s10 => s0\n| s0, s11 => s0\n| s0, s12 => s0\n| s0, s13 => s0\n| s0, s14 => s0\n| s0, s15 => s0\n| s0, s16 => s0\n| s0, s17 => s0\n| s0, s18 => s0\n| s0, s19 => s0\n| s0, s20 => s0\n| s0, s21 => s0\n| s0, s22 => s0\n| s0, s23 => s0\n| s0, s24 => s0\n| s0, s25 => s0\n| s0, s26 => s0\n| s0, s27 => s0\n| s0, s28 => s0\n| s0, s29 => s0\n| s0, s30 => s0\n| s0, s31 => s0\n| s0, s32 => s0\n| s0, s33 => s0\n| s0, s34 => s0\n| s1, s0 => s0\n| s1, s1 => s0\n| s1, s2 => s0\n| s1, s3 => s0\n| s1, s4 => s0\n| s1, s5 => s0\n| s1, s6 => s0\n| s1, s7 => s0\n| s1, s8 => s0\n| s1, s9 => s0\n| s1, s10 => s0\n| s1, s11 => s0\n| s1, s12 => s0\n| s1, s13 => s0\n| s1, s14 => s0\n| s1, s15 => s0\n| s1, s16 => s0\n| s1, s17 => s0\n| s1, s18 => s0\n| s1, s19 => s0\n| s1, s20 => s0\n| s1, s21 => s0\n| s1, s22 => s0\n| s1, s23 => s0\n| s1, s24 => s0\n| s1, s25 => s0\n| s1, s26 => s0\n| s1, s27 => s0\n| s1, s28 => s0\n| s1, s29 => s0\n| s1, s30 => s0\n| s1, s31 => s0\n| s1, s32 => s0\n| s1, s33 => s0\n| s1, s34 => s0\n| s2, s0 => s0\n| s2, s1 => s0\n| s2, s2 => s0\n| s2, s3 => s0\n| s2, s4 => s0\n| s2, s5 => s0\n| s2, s6 => s0\n| s2, s7 => s0\n| s2, s8 => s0\n| s2, s9 => s0\n| s2, s10 => s0\n| s2, s11 => s0\n| s2, s12 => s0\n| s2, s13 => s0\n| s2, s14 => s0\n| s2, s15 => s0\n| s2, s16 => s0\n| s2, s17 => s0\n| s2, s18 => s0\n| s2, s19 => s0\n| s2, s20 => s0\n| s2, s21 => s0\n| s2, s22 => s0\n| s2, s23 => s0\n| s2, s24 => s0\n| s2, s25 => s0\n| s2, s26 => s0\n| s2, s27 => s0\n| s2, s28 => s0\n| s2, s29 => s0\n| s2, s30 => s0\n| s2, s31 => s0\n| s2, s32 => s0\n| s2, s33 => s0\n| s2, s34 => s0\n| s3, s0 => s0\n| s3, s1 => s0\n| s3, s2 => s0\n| s3, s3 => s0\n| s3, s4 => s0\n| s3, s5 => s0\n| s3, s6 => s0\n| s3, s7 => s0\n| s3, s8 => s0\n| s3, s9 => s0\n| s3, s10 => s0\n| s3, s11 => s0\n| s3, s12 => s0\n| s3, s13 => s0\n| s3, s14 => s0\n| s3, s15 => s0\n| s3, s16 => s0\n| s3, s17 => s0\n| s3, s18 => s0\n| s3, s19 => s0\n| s3, s20 => s0\n| s3, s21 => s0\n| s3, s22 => s0\n| s3, s23 => s0\n| s3, s24 => s0\n| s3, s25 => s0\n| s3, s26 => s0\n| s3, s27 => s0\n| s3, s28 => s0\n| s3, s29 => s0\n| s3, s30 => s0\n| s3, s31 => s0\n| s3, s32 => s0\n| s3, s33 => s0\n| s3, s34 => s0\n| s4, s0 => s0\n| s4, s1 => s0\n| s4, s2 => s0\n| s4, s3 => s0\n| s4, s4 => s0\n| s4, s5 => s0\n| s4, s6 => s0\n| s4, s7 => s0\n| s4, s8 => s0\n| s4, s9 => s0\n| s4, s10 => s0\n| s4, s11 => s0\n| s4, s12 => s0\n| s4, s13 => s0\n| s4, s14 => s0\n| s4, s15 => s0\n| s4, s16 => s0\n| s4, s17 => s0\n| s4, s18 => s0\n| s4, s19 => s0\n| s4, s20 => s0\n| s4, s21 => s0\n| s4, s22 => s0\n| s4, s23 => s0\n| s4, s24 => s0\n| s4, s25 => s0\n| s4, s26 => s0\n| s4, s27 => s0\n| s4, s28 => s0\n| s4, s29 => s0\n| s4, s30 => s0\n| s4, s31 => s0\n| s4, s32 => s0\n| s4, s33 => s0\n| s4, s34 => s0\n| s5, s0 => s0\n| s5, s1 => s0\n| s5, s2 => s0\n| s5, s3 => s0\n| s5, s4 => s0\n| s5, s5 => s0\n| s5, s6 => s0\n| s5, s7 => s0\n| s5, s8 => s0\n| s5, s9 => s0\n| s5, s10 => s0\n| s5, s11 => s0\n| s5, s12 => s0\n| s5, s13 => s0\n| s5, s14 => s0\n| s5, s15 => s0\n| s5, s16 => s0\n| s5, s17 => s0\n| s5, s18 => s0\n| s5, s19 => s0\n| s5, s20 => s0\n| s5, s21 => s0\n| s5, s22 => s0\n| s5, s23 => s0\n| s5, s24 => s0\n| s5, s25 => s0\n| s5, s26 => s0\n| s5, s27 => s0\n| s5, s28 => s0\n| s5, s29 => s0\n| s5, s30 => s0\n| s5, s31 => s0\n| s5, s32 => s0\n| s5, s33 => s0\n| s5, s34 => s0\n| s6, s0 => s0\n| s6, s1 => s0\n| s6, s2 => s0\n| s6, s3 => s0\n| s6, s4 => s0\n| s6, s5 => s0\n| s6, s6 => s0\n| s6, s7 => s0\n| s6, s8 => s0\n| s6, s9 => s0\n| s6, s10 => s0\n| s6, s11 => s0\n| s6, s12 => s0\n| s6, s13 => s0\n| s6, s14 => s0\n| s6, s15 => s0\n| s6, s16 => s0\n| s6, s17 => s0\n| s6, s18 => s0\n| s6, s19 => s0\n| s6, s20 => s0\n| s6, s21 => s0\n| s6, s22 => s0\n| s6, s23 => s0\n| s6, s24 => s0\n| s6, s25 => s0\n| s6, s26 => s0\n| s6, s27 => s0\n| s6, s28 => s0\n| s6, s29 => s0\n| s6, s30 => s0\n| s6, s31 => s0\n| s6, s32 => s0\n| s6, s33 => s0\n| s6, s34 => s0\n| s7, s0 => s0\n| s7, s1 => s0\n| s7, s2 => s0\n| s7, s3 => s0\n| s7, s4 => s0\n| s7, s5 => s0\n| s7, s6 => s0\n| s7, s7 => s0\n| s7, s8 => s0\n| s7, s9 => s0\n| s7, s10 => s0\n| s7, s11 => s0\n| s7, s12 => s0\n| s7, s13 => s0\n| s7, s14 => s0\n| s7, s15 => s0\n| s7, s16 => s0\n| s7, s17 => s0\n| s7, s18 => s0\n| s7, s19 => s0\n| s7, s20 => s0\n| s7, s21 => s0\n| s7, s22 => s0\n| s7, s23 => s0\n| s7, s24 => s0\n| s7, s25 => s0\n| s7, s26 => s0\n| s7, s27 => s0\n| s7, s28 => s0\n| s7, s29 => s0\n| s7, s30 => s0\n| s7, s31 => s0\n| s7, s32 => s0\n| s7, s33 => s0\n| s7, s34 => s0\n| s8, s0 => s0\n| s8, s1 => s0\n| s8, s2 => s0\n| s8, s3 => s0\n| s8, s4 => s0\n| s8, s5 => s0\n| s8, s6 => s0\n| s8, s7 => s0\n| s8, s8 => s0\n| s8, s9 => s0\n| s8, s10 => s0\n| s8, s11 => s0\n| s8, s12 => s0\n| s8, s13 => s0\n| s8, s14 => s0\n| s8, s15 => s0\n| s8, s16 => s0\n| s8, s17 => s0\n| s8, s18 => s0\n| s8, s19 => s0\n| s8, s20 => s0\n| s8, s21 => s0\n| s8, s22 => s0\n| s8, s23 => s0\n| s8, s24 => s0\n| s8, s25 => s0\n| s8, s26 => s0\n| s8, s27 => s0\n| s8, s28 => s0\n| s8, s29 => s0\n| s8, s30 => s0\n| s8, s31 => s0\n| s8, s32 => s0\n| s8, s33 => s0\n| s8, s34 => s0\n| s9, s0 => s0\n| s9, s1 => s0\n| s9, s2 => s0\n| s9, s3 => s0\n| s9, s4 => s0\n| s9, s5 => s0\n| s9, s6 => s0\n| s9, s7 => s0\n| s9, s8 => s0\n| s9, s9 => s0\n| s9, s10 => s0\n| s9, s11 => s0\n| s9, s12 => s0\n| s9, s13 => s0\n| s9, s14 => s0\n| s9, s15 => s0\n| s9, s16 => s0\n| s9, s17 => s0\n| s9, s18 => s0\n| s9, s19 => s0\n| s9, s20 => s0\n| s9, s21 => s0\n| s9, s22 => s0\n| s9, s23 => s0\n| s9, s24 => s0\n| s9, s25 => s0\n| s9, s26 => s0\n| s9, s27 => s0\n| s9, s28 => s0\n| s9, s29 => s0\n| s9, s30 => s0\n| s9, s31 => s0\n| s9, s32 => s0\n| s9, s33 => s0\n| s9, s34 => s0\n| s10, s0 => s0\n| s10, s1 => s0\n| s10, s2 => s0\n| s10, s3 => s0\n| s10, s4 => s0\n| s10, s5 => s0\n| s10, s6 => s0\n| s10, s7 => s0\n| s10, s8 => s0\n| s10, s9 => s0\n| s10, s10 => s0\n| s10, s11 => s0\n| s10, s12 => s0\n| s10, s13 => s0\n| s10, s14 => s0\n| s10, s15 => s0\n| s10, s16 => s0\n| s10, s17 => s0\n| s10, s18 => s0\n| s10, s19 => s0\n| s10, s20 => s0\n| s10, s21 => s0\n| s10, s22 => s0\n| s10, s23 => s0\n| s10, s24 => s0\n| s10, s25 => s0\n| s10, s26 => s0\n| s10, s27 => s0\n| s10, s28 => s0\n| s10, s29 => s0\n| s10, s30 => s0\n| s10, s31 => s0\n| s10, s32 => s0\n| s10, s33 => s0\n| s10, s34 => s0\n| s11, s0 => s0\n| s11, s1 => s0\n| s11, s2 => s0\n| s11, s3 => s0\n| s11, s4 => s0\n| s11, s5 => s0\n| s11, s6 => s0\n| s11, s7 => s0\n| s11, s8 => s0\n| s11, s9 => s0\n| s11, s10 => s0\n| s11, s11 => s0\n| s11, s12 => s0\n| s11, s13 => s0\n| s11, s14 => s0\n| s11, s15 => s0\n| s11, s16 => s0\n| s11, s17 => s0\n| s11, s18 => s0\n| s11, s19 => s0\n| s11, s20 => s0\n| s11, s21 => s0\n| s11, s22 => s0\n| s11, s23 => s0\n| s11, s24 => s0\n| s11, s25 => s0\n| s11, s26 => s0\n| s11, s27 => s0\n| s11, s28 => s0\n| s11, s29 => s0\n| s11, s30 => s0\n| s11, s31 => s0\n| s11, s32 => s0\n| s11, s33 => s0\n| s11, s34 => s0\n| s12, s0 => s0\n| s12, s1 => s0\n| s12, s2 => s0\n| s12, s3 => s0\n| s12, s4 => s0\n| s12, s5 => s0\n| s12, s6 => s0\n| s12, s7 => s0\n| s12, s8 => s0\n| s12, s9 => s0\n| s12, s10 => s0\n| s12, s11 => s0\n| s12, s12 => s0\n| s12, s13 => s0\n| s12, s14 => s0\n| s12, s15 => s0\n| s12, s16 => s0\n| s12, s17 => s0\n| s12, s18 => s0\n| s12, s19 => s0\n| s12, s20 => s0\n| s12, s21 => s0\n| s12, s22 => s0\n| s12, s23 => s0\n| s12, s24 => s0\n| s12, s25 => s0\n| s12, s26 => s0\n| s12, s27 => s0\n| s12, s28 => s0\n| s12, s29 => s0\n| s12, s30 => s0\n| s12, s31 => s0\n| s12, s32 => s0\n| s12, s33 => s0\n| s12, s34 => s0\n| s13, s0 => s0\n| s13, s1 => s0\n| s13, s2 => s0\n| s13, s3 => s0\n| s13, s4 => s0\n| s13, s5 => s0\n| s13, s6 => s0\n| s13, s7 => s0\n| s13, s8 => s0\n| s13, s9 => s0\n| s13, s10 => s0\n| s13, s11 => s0\n| s13, s12 => s0\n| s13, s13 => s0\n| s13, s14 => s0\n| s13, s15 => s0\n| s13, s16 => s0\n| s13, s17 => s0\n| s13, s18 => s0\n| s13, s19 => s0\n| s13, s20 => s0\n| s13, s21 => s0\n| s13, s22 => s0\n| s13, s23 => s0\n| s13, s24 => s0\n| s13, s25 => s0\n| s13, s26 => s0\n| s13, s27 => s0\n| s13, s28 => s0\n| s13, s29 => s0\n| s13, s30 => s0\n| s13, s31 => s0\n| s13, s32 => s0\n| s13, s33 => s0\n| s13, s34 => s0\n| s14, s0 => s0\n| s14, s1 => s0\n| s14, s2 => s0\n| s14, s3 => s0\n| s14, s4 => s0\n| s14, s5 => s0\n| s14, s6 => s0\n| s14, s7 => s0\n| s14, s8 => s0\n| s14, s9 => s0\n| s14, s10 => s0\n| s14, s11 => s0\n| s14, s12 => s0\n| s14, s13 => s0\n| s14, s14 => s0\n| s14, s15 => s0\n| s14, s16 => s0\n| s14, s17 => s0\n| s14, s18 => s0\n| s14, s19 => s0\n| s14, s20 => s0\n| s14, s21 => s0\n| s14, s22 => s0\n| s14, s23 => s0\n| s14, s24 => s0\n| s14, s25 => s0\n| s14, s26 => s0\n| s14, s27 => s0\n| s14, s28 => s0\n| s14, s29 => s0\n| s14, s30 => s0\n| s14, s31 => s0\n| s14, s32 => s0\n| s14, s33 => s0\n| s14, s34 => s0\n| s15, s0 => s0\n| s15, s1 => s0\n| s15, s2 => s0\n| s15, s3 => s0\n| s15, s4 => s0\n| s15, s5 => s0\n| s15, s6 => s0\n| s15, s7 => s0\n| s15, s8 => s0\n| s15, s9 => s0\n| s15, s10 => s0\n| s15, s11 => s0\n| s15, s12 => s0\n| s15, s13 => s0\n| s15, s14 => s0\n| s15, s15 => s0\n| s15, s16 => s0\n| s15, s17 => s0\n| s15, s18 => s0\n| s15, s19 => s0\n| s15, s20 => s0\n| s15, s21 => s0\n| s15, s22 => s0\n| s15, s23 => s0\n| s15, s24 => s0\n| s15, s25 => s0\n| s15, s26 => s0\n| s15, s27 => s0\n| s15, s28 => s0\n| s15, s29 => s0\n| s15, s30 => s0\n| s15, s31 => s0\n| s15, s32 => s0\n| s15, s33 => s0\n| s15, s34 => s0\n| s16, s0 => s0\n| s16, s1 => s0\n| s16, s2 => s0\n| s16, s3 => s0\n| s16, s4 => s0\n| s16, s5 => s0\n| s16, s6 => s0\n| s16, s7 => s0\n| s16, s8 => s0\n| s16, s9 => s0\n| s16, s10 => s0\n| s16, s11 => s0\n| s16, s12 => s0\n| s16, s13 => s0\n| s16, s14 => s0\n| s16, s15 => s0\n| s16, s16 => s0\n| s16, s17 => s0\n| s16, s18 => s0\n| s16, s19 => s0\n| s16, s20 => s0\n| s16, s21 => s0\n| s16, s22 => s0\n| s16, s23 => s0\n| s16, s24 => s0\n| s16, s25 => s0\n| s16, s26 => s0\n| s16, s27 => s0\n| s16, s28 => s0\n| s16, s29 => s0\n| s16, s30 => s0\n| s16, s31 => s0\n| s16, s32 => s0\n| s16, s33 => s0\n| s16, s34 => s0\n| s17, s0 => s0\n| s17, s1 => s0\n| s17, s2 => s0\n| s17, s3 => s0\n| s17, s4 => s0\n| s17, s5 => s0\n| s17, s6 => s0\n| s17, s7 => s0\n| s17, s8 => s0\n| s17, s9 => s0\n| s17, s10 => s0\n| s17, s11 => s0\n| s17, s12 => s0\n| s17, s13 => s0\n| s17, s14 => s0\n| s17, s15 => s0\n| s17, s16 => s0\n| s17, s17 => s0\n| s17, s18 => s0\n| s17, s19 => s0\n| s17, s20 => s0\n| s17, s21 => s0\n| s17, s22 => s0\n| s17, s23 => s0\n| s17, s24 => s0\n| s17, s25 => s0\n| s17, s26 => s0\n| s17, s27 => s0\n| s17, s28 => s0\n| s17, s29 => s0\n| s17, s30 => s0\n| s17, s31 => s0\n| s17, s32 => s0\n| s17, s33 => s0\n| s17, s34 => s0\n| s18, s0 => s0\n| s18, s1 => s0\n| s18, s2 => s0\n| s18, s3 => s0\n| s18, s4 => s0\n| s18, s5 => s0\n| s18, s6 => s0\n| s18, s7 => s0\n| s18, s8 => s0\n| s18, s9 => s0\n| s18, s10 => s0\n| s18, s11 => s0\n| s18, s12 => s0\n| s18, s13 => s0\n| s18, s14 => s0\n| s18, s15 => s0\n| s18, s16 => s0\n| s18, s17 => s0\n| s18, s18 => s0\n| s18, s19 => s0\n| s18, s20 => s0\n| s18, s21 => s0\n| s18, s22 => s0\n| s18, s23 => s0\n| s18, s24 => s0\n| s18, s25 => s0\n| s18, s26 => s0\n| s18, s27 => s0\n| s18, s28 => s0\n| s18, s29 => s0\n| s18, s30 => s0\n| s18, s31 => s0\n| s18, s32 => s0\n| s18, s33 => s0\n| s18, s34 => s0\n| s19, s0 => s0\n| s19, s1 => s0\n| s19, s2 => s0\n| s19, s3 => s0\n| s19, s4 => s0\n| s19, s5 => s0\n| s19, s6 => s0\n| s19, s7 => s0\n| s19, s8 => s0\n| s19, s9 => s0\n| s19, s10 => s0\n| s19, s11 => s0\n| s19, s12 => s0\n| s19, s13 => s0\n| s19, s14 => s0\n| s19, s15 => s0\n| s19, s16 => s0\n| s19, s17 => s0\n| s19, s18 => s0\n| s19, s19 => s0\n| s19, s20 => s0\n| s19, s21 => s0\n| s19, s22 => s0\n| s19, s23 => s0\n| s19, s24 => s0\n| s19, s25 => s0\n| s19, s26 => s0\n| s19, s27 => s0\n| s19, s28 => s0\n| s19, s29 => s0\n| s19, s30 => s0\n| s19, s31 => s0\n| s19, s32 => s0\n| s19, s33 => s0\n| s19, s34 => s0\n| s20, s0 => s0\n| s20, s1 => s0\n| s20, s2 => s0\n| s20, s3 => s0\n| s20, s4 => s0\n| s20, s5 => s0\n| s20, s6 => s0\n| s20, s7 => s0\n| s20, s8 => s0\n| s20, s9 => s0\n| s20, s10 => s0\n| s20, s11 => s0\n| s20, s12 => s0\n| s20, s13 => s0\n| s20, s14 => s0\n| s20, s15 => s0\n| s20, s16 => s0\n| s20, s17 => s0\n| s20, s18 => s0\n| s20, s19 => s0\n| s20, s20 => s0\n| s20, s21 => s0\n| s20, s22 => s0\n| s20, s23 => s0\n| s20, s24 => s0\n| s20, s25 => s0\n| s20, s26 => s0\n| s20, s27 => s0\n| s20, s28 => s0\n| s20, s29 => s0\n| s20, s30 => s0\n| s20, s31 => s0\n| s20, s32 => s0\n| s20, s33 => s0\n| s20, s34 => s0\n| s21, s0 => s0\n| s21, s1 => s0\n| s21, s2 => s0\n| s21, s3 => s0\n| s21, s4 => s0\n| s21, s5 => s0\n| s21, s6 => s0\n| s21, s7 => s0\n| s21, s8 => s0\n| s21, s9 => s0\n| s21, s10 => s0\n| s21, s11 => s0\n| s21, s12 => s0\n| s21, s13 => s0\n| s21, s14 => s0\n| s21, s15 => s0\n| s21, s16 => s0\n| s21, s17 => s0\n| s21, s18 => s0\n| s21, s19 => s0\n| s21, s20 => s0\n| s21, s21 => s0\n| s21, s22 => s0\n| s21, s23 => s0\n| s21, s24 => s0\n| s21, s25 => s0\n| s21, s26 => s0\n| s21, s27 => s0\n| s21, s28 => s0\n| s21, s29 => s0\n| s21, s30 => s0\n| s21, s31 => s0\n| s21, s32 => s0\n| s21, s33 => s0\n| s21, s34 => s0\n| s22, s0 => s0\n| s22, s1 => s0\n| s22, s2 => s0\n| s22, s3 => s0\n| s22, s4 => s0\n| s22, s5 => s0\n| s22, s6 => s0\n| s22, s7 => s0\n| s22, s8 => s0\n| s22, s9 => s0\n| s22, s10 => s0\n| s22, s11 => s0\n| s22, s12 => s0\n| s22, s13 => s0\n| s22, s14 => s0\n| s22, s15 => s0\n| s22, s16 => s0\n| s22, s17 => s0\n| s22, s18 => s0\n| s22, s19 => s0\n| s22, s20 => s0\n| s22, s21 => s0\n| s22, s22 => s0\n| s22, s23 => s0\n| s22, s24 => s0\n| s22, s25 => s0\n| s22, s26 => s0\n| s22, s27 => s0\n| s22, s28 => s0\n| s22, s29 => s0\n| s22, s30 => s0\n| s22, s31 => s0\n| s22, s32 => s0\n| s22, s33 => s0\n| s22, s34 => s0\n| s23, s0 => s0\n| s23, s1 => s0\n| s23, s2 => s0\n| s23, s3 => s0\n| s23, s4 => s0\n| s23, s5 => s0\n| s23, s6 => s0\n| s23, s7 => s0\n| s23, s8 => s0\n| s23, s9 => s0\n| s23, s10 => s0\n| s23, s11 => s0\n| s23, s12 => s0\n| s23, s13 => s0\n| s23, s14 => s0\n| s23, s15 => s0\n| s23, s16 => s0\n| s23, s17 => s0\n| s23, s18 => s0\n| s23, s19 => s0\n| s23, s20 => s0\n| s23, s21 => s0\n| s23, s22 => s0\n| s23, s23 => s0\n| s23, s24 => s0\n| s23, s25 => s0\n| s23, s26 => s0\n| s23, s27 => s0\n| s23, s28 => s0\n| s23, s29 => s0\n| s23, s30 => s0\n| s23, s31 => s0\n| s23, s32 => s0\n| s23, s33 => s0\n| s23, s34 => s0\n| s24, s0 => s0\n| s24, s1 => s0\n| s24, s2 => s0\n| s24, s3 => s0\n| s24, s4 => s0\n| s24, s5 => s0\n| s24, s6 => s0\n| s24, s7 => s0\n| s24, s8 => s0\n| s24, s9 => s0\n| s24, s10 => s0\n| s24, s11 => s0\n| s24, s12 => s0\n| s24, s13 => s0\n| s24, s14 => s0\n| s24, s15 => s0\n| s24, s16 => s0\n| s24, s17 => s0\n| s24, s18 => s0\n| s24, s19 => s0\n| s24, s20 => s0\n| s24, s21 => s0\n| s24, s22 => s0\n| s24, s23 => s0\n| s24, s24 => s0\n| s24, s25 => s0\n| s24, s26 => s0\n| s24, s27 => s0\n| s24, s28 => s0\n| s24, s29 => s0\n| s24, s30 => s0\n| s24, s31 => s0\n| s24, s32 => s0\n| s24, s33 => s0\n| s24, s34 => s0\n| s25, s0 => s0\n| s25, s1 => s0\n| s25, s2 => s0\n| s25, s3 => s0\n| s25, s4 => s0\n| s25, s5 => s0\n| s25, s6 => s0\n| s25, s7 => s0\n| s25, s8 => s0\n| s25, s9 => s0\n| s25, s10 => s0\n| s25, s11 => s0\n| s25, s12 => s0\n| s25, s13 => s0\n| s25, s14 => s0\n| s25, s15 => s0\n| s25, s16 => s0\n| s25, s17 => s0\n| s25, s18 => s0\n| s25, s19 => s0\n| s25, s20 => s0\n| s25, s21 => s0\n| s25, s22 => s0\n| s25, s23 => s0\n| s25, s24 => s0\n| s25, s25 => s0\n| s25, s26 => s0\n| s25, s27 => s0\n| s25, s28 => s0\n| s25, s29 => s0\n| s25, s30 => s0\n| s25, s31 => s0\n| s25, s32 => s0\n| s25, s33 => s0\n| s25, s34 => s0\n| s26, s0 => s0\n| s26, s1 => s0\n| s26, s2 => s0\n| s26, s3 => s0\n| s26, s4 => s0\n| s26, s5 => s0\n| s26, s6 => s0\n| s26, s7 => s0\n| s26, s8 => s0\n| s26, s9 => s0\n| s26, s10 => s0\n| s26, s11 => s0\n| s26, s12 => s0\n| s26, s13 => s0\n| s26, s14 => s0\n| s26, s15 => s0\n| s26, s16 => s0\n| s26, s17 => s0\n| s26, s18 => s0\n| s26, s19 => s0\n| s26, s20 => s0\n| s26, s21 => s0\n| s26, s22 => s0\n| s26, s23 => s0\n| s26, s24 => s0\n| s26, s25 => s0\n| s26, s26 => s0\n| s26, s27 => s0\n| s26, s28 => s0\n| s26, s29 => s0\n| s26, s30 => s0\n| s26, s31 => s0\n| s26, s32 => s0\n| s26, s33 => s0\n| s26, s34 => s0\n| s27, s0 => s0\n| s27, s1 => s0\n| s27, s2 => s0\n| s27, s3 => s0\n| s27, s4 => s0\n| s27, s5 => s0\n| s27, s6 => s0\n| s27, s7 => s0\n| s27, s8 => s0\n| s27, s9 => s0\n| s27, s10 => s0\n| s27, s11 => s0\n| s27, s12 => s0\n| s27, s13 => s0\n| s27, s14 => s0\n| s27, s15 => s0\n| s27, s16 => s0\n| s27, s17 => s0\n| s27, s18 => s0\n| s27, s19 => s0\n| s27, s20 => s0\n| s27, s21 => s0\n| s27, s22 => s0\n| s27, s23 => s0\n| s27, s24 => s0\n| s27, s25 => s0\n| s27, s26 => s0\n| s27, s27 => s0\n| s27, s28 => s0\n| s27, s29 => s0\n| s27, s30 => s0\n| s27, s31 => s0\n| s27, s32 => s0\n| s27, s33 => s0\n| s27, s34 => s0\n| s28, s0 => s0\n| s28, s1 => s0\n| s28, s2 => s0\n| s28, s3 => s0\n| s28, s4 => s0\n| s28, s5 => s0\n| s28, s6 => s0\n| s28, s7 => s0\n| s28, s8 => s0\n| s28, s9 => s0\n| s28, s10 => s0\n| s28, s11 => s0\n| s28, s12 => s0\n| s28, s13 => s0\n| s28, s14 => s0\n| s28, s15 => s0\n| s28, s16 => s0\n| s28, s17 => s0\n| s28, s18 => s0\n| s28, s19 => s0\n| s28, s20 => s0\n| s28, s21 => s0\n| s28, s22 => s0\n| s28, s23 => s0\n| s28, s24 => s0\n| s28, s25 => s0\n| s28, s26 => s0\n| s28, s27 => s0\n| s28, s28 => s0\n| s28, s29 => s0\n| s28, s30 => s0\n| s28, s31 => s0\n| s28, s32 => s0\n| s28, s33 => s0\n| s28, s34 => s0\n| s29, s0 => s0\n| s29, s1 => s0\n| s29, s2 => s0\n| s29, s3 => s0\n| s29, s4 => s0\n| s29, s5 => s0\n| s29, s6 => s0\n| s29, s7 => s0\n| s29, s8 => s0\n| s29, s9 => s0\n| s29, s10 => s0\n| s29, s11 => s0\n| s29, s12 => s0\n| s29, s13 => s0\n| s29, s14 => s0\n| s29, s15 => s0\n| s29, s16 => s0\n| s29, s17 => s0\n| s29, s18 => s0\n| s29, s19 => s0\n| s29, s20 => s0\n| s29, s21 => s0\n| s29, s22 => s0\n| s29, s23 => s0\n| s29, s24 => s0\n| s29, s25 => s0\n| s29, s26 => s0\n| s29, s27 => s0\n| s29, s28 => s0\n| s29, s29 => s0\n| s29, s30 => s0\n| s29, s31 => s0\n| s29, s32 => s0\n| s29, s33 => s0\n| s29, s34 => s0\n| s30, s0 => s0\n| s30, s1 => s0\n| s30, s2 => s0\n| s30, s3 => s0\n| s30, s4 => s0\n| s30, s5 => s0\n| s30, s6 => s0\n| s30, s7 => s0\n| s30, s8 => s0\n| s30, s9 => s0\n| s30, s10 => s0\n| s30, s11 => s0\n| s30, s12 => s0\n| s30, s13 => s0\n| s30, s14 => s0\n| s30, s15 => s0\n| s30, s16 => s0\n| s30, s17 => s0\n| s30, s18 => s0\n| s30, s19 => s0\n| s30, s20 => s0\n| s30, s21 => s0\n| s30, s22 => s0\n| s30, s23 => s0\n| s30, s24 => s0\n| s30, s25 => s0\n| s30, s26 => s0\n| s30, s27 => s0\n| s30, s28 => s0\n| s30, s29 => s0\n| s30, s30 => s0\n| s30, s31 => s0\n| s30, s32 => s0\n| s30, s33 => s0\n| s30, s34 => s0\n| s31, s0 => s0\n| s31, s1 => s0\n| s31, s2 => s0\n| s31, s3 => s0\n| s31, s4 => s0\n| s31, s5 => s0\n| s31, s6 => s0\n| s31, s7 => s0\n| s31, s8 => s0\n| s31, s9 => s0\n| s31, s10 => s0\n| s31, s11 => s0\n| s31, s12 => s0\n| s31, s13 => s0\n| s31, s14 => s0\n| s31, s15 => s0\n| s31, s16 => s0\n| s31, s17 => s0\n| s31, s18 => s0\n| s31, s19 => s0\n| s31, s20 => s0\n| s31, s21 => s0\n| s31, s22 => s0\n| s31, s23 => s0\n| s31, s24 => s0\n| s31, s25 => s0\n| s31, s26 => s0\n| s31, s27 => s0\n| s31, s28 => s0\n| s31, s29 => s0\n| s31, s30 => s0\n| s31, s31 => s0\n| s31, s32 => s0\n| s31, s33 => s0\n| s31, s34 => s0\n| s32, s0 => s0\n| s32, s1 => s0\n| s32, s2 => s0\n| s32, s3 => s0\n| s32, s4 => s0\n| s32, s5 => s0\n| s32, s6 => s0\n| s32, s7 => s0\n| s32, s8 => s0\n| s32, s9 => s0\n| s32, s10 => s0\n| s32, s11 => s0\n| s32, s12 => s0\n| s32, s13 => s0\n| s32, s14 => s0\n| s32, s15 => s0\n| s32, s16 => s0\n| s32, s17 => s0\n| s32, s18 => s0\n| s32, s19 => s0\n| s32, s20 => s0\n| s32, s21 => s0\n| s32, s22 => s0\n| s32, s23 => s0\n| s32, s24 => s0\n| s32, s25 => s0\n| s32, s26 => s0\n| s32, s27 => s0\n| s32, s28 => s0\n| s32, s29 => s0\n| s32, s30 => s0\n| s32, s31 => s0\n| s32, s32 => s0\n| s32, s33 => s0\n| s32, s34 => s0\n| s33, s0 => s0\n| s33, s1 => s0\n| s33, s2 => s0\n| s33, s3 => s0\n| s33, s4 => s0\n| s33, s5 => s0\n| s33, s6 => s0\n| s33, s7 => s0\n| s33, s8 => s0\n| s33, s9 => s0\n| s33, s10 => s0\n| s33, s11 => s0\n| s33, s12 => s0\n| s33, s13 => s0\n| s33, s14 => s0\n| s33, s15 => s0\n| s33, s16 => s0\n| s33, s17 => s0\n| s33, s18 => s0\n| s33, s19 => s0\n| s33, s20 => s0\n| s33, s21 => s0\n| s33, s22 => s0\n| s33, s23 => s0\n| s33, s24 => s0\n| s33, s25 => s0\n| s33, s26 => s0\n| s33, s27 => s0\n| s33, s28 => s0\n| s33, s29 => s0\n| s33, s30 => s0\n| s33, s31 => s0\n| s33, s32 => s0\n| s33, s33 => s0\n| s33, s34 => s0\n| s34, s0 => s0\n| s34, s1 => s0\n| s34, s2 => s0\n| s34, s3 => s0\n| s34, s4 => s0\n| s34, s5 => s0\n| s34, s6 => s0\n| s34, s7 => s0\n| s34, s8 => s0\n| s34, s9 => s0\n| s34, s10 => s0\n| s34, s11 => s0\n| s34, s12 => s0\n| s34, s13 => s0\n| s34, s14 => s0\n| s34, s15 => s0\n| s34, s16 => s0\n| s34, s17 => s0\n| s34, s18 => s0\n| s34, s19 => s0\n| s34, s20 => s0\n| s34, s21 => s0\n| s34, s22 => s0\n| s34, s23 => s0\n| s34, s24 => s0\n| s34, s25 => s0\n| s34, s26 => s0\n| s34, s27 => s0\n| s34, s28 => s0\n| s34, s29 => s0\n| s34, s30 => s0\n| s34, s31 => s0\n| s34, s32 => s0\n| s34, s33 => s0\n| s34, s34 => s0\nset_option maxHeartbeats 0\n\nexample : ∀ x y z, f (f (f s0 x) y) z = f (f x z) (f y z) := by\n native_decide\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/bench/states35.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5389832354982645, "lm_q2_score": 0.4225046348141882, "lm_q1q2_score": 0.22772291508516387}} {"text": "import Contractome.EVM\n\nopen EVM\n\n\nvariable {C : Cfg} [DecidableEq C.Tw] [∀ n, OfNat C.Tw n] [Element C.Tw] [DecidableEq C.Tb] [∀ n, OfNat C.Tb n] [Element C.Tb]\nvariable [TakeBytes C.BAI]\nvariable [instBA : SByteArray C.Tw C.Tb C.BA C.BAI]\nvariable [EVMStack C.Tw C.S] [EVMStack (C.Tw × C.BA) C.RS] [EVMMapDefault C.Tw C.Tw C.AM] [EVMMapSeq C.Tw C.Tb C.BA C.BAI C.M]\nvariable [EVMMapBasic C.Tw C.BA C.BAM]\nvariable [Zero C.M]\nvariable [EVMMapDefault C.Tw C.M C.STM]\nvariable [Repr C.Tw] [Repr C.Tb] [Repr C.M] [Repr C.S] [Repr C.BA] [Repr C.BAM] [Repr C.AM] [Repr C.BA] [Repr C.STM] [Repr C.RS]\n\n\nvariable {c : Context (C:=C)}\n\nset_option quotPrecheck false\nsyntax:67 term \" b:: \" term : term\n\nmacro_rules\n | `($a:term b:: $b:term) => `(EVMStack.push (S:=C.S) $b $a)\n\n\n-- syntax \"b[\" sepBy(term, \", \") \"]\" : term\n\n-- macro_rules\n-- | `(b[ $elems,* ]) => `(ByteArray.mk #[ $elems,* ])\n\n-- #print simp\n\n\ndef p (x y : Nat) := x = y\n\n-- example (x y : Nat) : p (x + y) (0 + y + x) := by\n-- conv =>\n-- whnf\n-- rhs\n-- rw [Nat.zero_add, Nat.add_comm]\n-- trace_state\n-- skip\n-- done\n\n-- abbrev optimistic_2stack_op {stackRest : C.S} {v1 v2 : C.Tw} (op : C.Tw -> C.Tw -> C.Tw) (opName : EVMM (C:=C) Unit) \n-- (hS : (c.stack = v1 b:: v2 b:: stackRest)) (post : EVMM (C:=C) α) :=\n-- EVMM.runWithC (C:=C) (do opName; post) c =\n-- EVMM.runWithC (C:=C) (post) {c with stack := (op v1 v2) b:: stackRest}\n\nabbrev optimistic_2stack_op_s {stackRest : C.S} {v1 v2 : C.Tw} \n {op : C.Tw -> C.Tw -> C.Tw} (opName : EVMM (C:=C) Unit) (hOp : opName = EVMM.mapStack2 op) \n (hS : (c.stack = v1 b:: v2 b:: stackRest)) (post : EVMM (C:=C) α) :=\n EVMM.runWithC (C:=C) (do opName; post) c =\n EVMM.runWithC (C:=C) (post) {c with stack := (op v1 v2) b:: stackRest}\n\ntheorem optimistic_2stack_op {stackRest : C.S} {v1 v2 : C.Tw} \n {op : C.Tw -> C.Tw -> C.Tw} (opName : EVMM (C:=C) Unit) (hOp : opName = EVMM.mapStack2 op) \n (hS : (c.stack = v1 b:: v2 b:: stackRest)) (post : EVMM (C:=C) α) :\n EVMM.runWithC (C:=C) (do opName; post) c =\n EVMM.runWithC (C:=C) (post) {c with stack := (op v1 v2) b:: stackRest} :=\n by\n cases c\n simp only at *\n subst hS\n subst hOp\n conv =>\n simp [EVMM.runWithC, EVMM.mapStack2, EVMM.popStack]\n\nabbrev optimistic_i01_add := optimistic_2stack_op (C:=C) (opName:=EVMM.i01_add) (op:=Element.add) (hOp := rfl)\n\n\n \n\ntheorem optimistic_add {stackRest : C.S} {v1 v2 : C.Tw} (hS : (c.stack = v1 b:: v2 b:: stackRest)) (post : EVMM (C:=C) α) :\n EVMM.runWithC (C:=C) (do EVMM.i01_add; post) c =\n EVMM.runWithC (C:=C) (post) {c with stack := (Element.add v1 v2) b:: stackRest}\n := by\n cases c\n simp only at *\n subst hS\n conv =>\n simp [EVMM.i01_add, EVMM.runWithC, EVMM.mapStack2, EVMM.popStack]\n \n\n\n-- set_option trace.Debug.Meta.Tactic.simp true\ntheorem test {stackRest : C.S} {v : C.Tw} (hS : (c.stack = v b:: stackRest)) :\n EVMM.runWithC (C:=C) (EVMM.popStack) c = Except.ok (v, {c with stack := stackRest}) := by\n simp [EVMM.runWithC, StateT.run, ExceptT.run]\n cases c\n simp at *\n subst hS\n -- simp [EVMM.popStack]\n unfold EVMM.popStack\n -- simp\n -- simp\n conv =>\n lhs\n whnf\n simp\n\n#eval 5\n\n -- simp (config := {zeta := false, beta := false, eta := false, etaStruct := false, iota := false, proj := false, decide := false, memoize := false})\n -- simp only [get]\n -- simp at *\n\n \n\n\n-- theorem test {stackRest : C.S} {v1 v2 : C.Tw} (hS : (c.stack = v1 b:: v2 b:: stackRest)) :\n-- EVMM.runWithC (C:=C) (EVMM.i01_add) tC cC c = Except.error EVMException.abstractValueError := by\n-- simp [EVMM.runWithC, StateT.run, ExceptT.run, EVMM.i01_add]\n-- unfold EVMM.mapStack2\n-- unfold EVMM.popStack\n -- simp \n \n", "meta": {"author": "zygi", "repo": "contractome", "sha": "d4d59ce817e47578d8764e26d77050ce72c18c18", "save_path": "github-repos/lean/zygi-contractome", "path": "github-repos/lean/zygi-contractome/contractome-d4d59ce817e47578d8764e26d77050ce72c18c18/Contractome/Theorems.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5851011542032312, "lm_q2_score": 0.38861802670584894, "lm_q1q2_score": 0.22738085596977434}} {"text": "import .rules\n\nopen psum nnf node\n\nset_option eqn_compiler.zeta true\n\ndef tableau : Π Γ : sseqt, node Γ\n| Γ := \n match get_contra_seqt Γ with \n | inl w := contra_rule_seqt w.2\n | inr no_contra :=\n match get_and_seqt Γ with\n | inl w := \n let inst := and_instance_seqt.cons w.2 in\n have h : prod.measure_lex' sseqt_size (and_child Γ w.2) Γ,\n begin apply split_lt_and_seqt end,\n let d_delta := tableau (and_child Γ w.2) in\n and_rule_seqt inst d_delta\n | inr no_and := \n match get_or_seqt Γ with\n | inl w := \n let inst := or_instance_seqt.cons w.2 in \n have h₁ : prod.measure_lex' sseqt_size (or_child_left Γ w.2) Γ,\n begin apply split_lt_or_seqt_left end,\n have h₂ : prod.measure_lex' sseqt_size (or_child_right Γ w.2) Γ,\n begin apply split_lt_or_seqt_right end,\n let Γ₁ := tableau (or_child_left Γ w.2) in\n match Γ₁ with\n | closed p := or_rule_seqt inst (closed p) (tableau (or_child_right Γ w.2))\n | open_ w := open_rule_seqt inst w.2\n end\n | inr no_or := \n match get_box_seqt Γ with\n | inl w := -- term mode here helps termination \n if hb : box w.1 ∈ Γ.b then\n let inst := box_dup_instance_seqt.cons w.2 hb in \n have h : prod.measure_lex' sseqt_size (box_child Γ w.2) Γ,\n from copy_lt_seqt _ _,\n let d_delta := tableau (box_child Γ w.2) in\n box_rule_seqt inst d_delta\n else \n let inst := box_new_instance_seqt.cons w.2 hb in \n have h : prod.measure_lex' sseqt_size (box_child_new Γ w.2 hb) Γ,\n from box_new_lt_seqt _ _ _,\n let d_delta := tableau (box_child_new Γ w.2 hb) in\n box_new_rule_seqt inst d_delta\n | inr no_box := \n match get_dia_seqt Γ with\n | inl w := \n let ma : modal_applicable Γ := \n {satu := {no_and := no_and, no_or := no_or},\n no_contra_main := no_contra, \n no_box_main := no_box,\n φ := w.1,\n ex := w.2} in \n let l := @dia_rule_seqt (λ Δ, prod.measure_lex' sseqt_size Δ Γ) \n (λ x h, tableau x) (unmodal_seqt Γ) \n (unmodal_seqt_size Γ) in\n match l with\n | inl w := begin left, exact unsat_of_unsat_unmodal w.1 w.2 end\n | inr w := \n begin \n right, split, swap,\n {let lm := models_to_tmodels w.1,\n let sgm := dia_rule_loop Γ.h Γ.b Γ.m,\n let mΓ : sseqt := Γ,\n let mhtk := Γ.m,\n have mhhtk : hintikka Γ.m, {apply hintikka_ma ma},\n have mmhtk : Γ.m ⊆ Γ.m, {simp},\n split, swap,\n {let minfo : info := ⟨mΓ, mhtk, mhhtk, mmhtk⟩,\n exact tmodel.cons minfo lm sgm },\n {split,\n {split,\n {simp, intros s hs, have := list.mem_map.1 hs, \n rcases this with ⟨i, hmem, hi⟩, intros φ hφ, rw ←hi,\n apply mem_be_box, exact w.2, exact hmem, exact hφ},\n {simp, intros s hs φ hφ, exfalso, apply no_box, exact hφ},\n {simp, intros φ hφ, \n by_cases hc : φ ∈ Γ.h,\n {left, have := mem_loop_left _ Γ.b _ _ hc hφ, split, split, exact this, simp},\n {right, have := mem_be_dia _ _ w.2 _ hφ hc, \n rcases this with ⟨i, hmem, hi⟩,\n have := list.mem_map_of_mem (λ x : model, x.val) hmem,\n split, split, exact this, exact hi} },\n {simp, intros s rq hdesc hmem, \n have := ex_desc' _ _ lm _ hdesc,\n cases this with hl hr,\n {have hc := list.mem_map.1 hl,\n rcases hc with ⟨ms, pmsl, pmsr⟩, \n have hci := be_ex _ _ w.2 _ pmsl,\n rcases hci with ⟨iw, imem, pi⟩,\n have ps := pt_of_m_to_tm _ _ hl,\n have hsub := ps.1.sreq,\n cases s with is ls sgs,\n simp at hmem, simp at hsub,\n have hin := hsub hmem,\n rw pmsr at pi, simp at pi, rw pi at hin,\n have := unmodal_sig _ _ imem _ hin,\n cases this,\n {right, split, swap, exact tmodel.cons is ls sgs, split, exact hdesc, simp, rw this, rw pi},\n {left, exact this}},\n {rcases hr with ⟨c, memc, pdc⟩, \n have pc := pt_of_m_to_tm _ _ memc,\n have := pc.1.bdia, \n cases c with ic lc sgc, simp at this,\n have hc := this _ _ pdc hmem,\n cases hc with hl hr,\n {have hcc := list.mem_map.1 memc,\n rcases hcc with ⟨ms, pmsl, pmsr⟩, \n have hci := be_ex _ _ w.2 _ pmsl,\n rcases hci with ⟨iw, imem, pi⟩,\n have ps := pt_of_m_to_tm _ _ memc,\n rw pmsr at pi, simp at pi, rw pi at hl,\n have hccc := unmodal_sig _ _ imem _ hl,\n cases hccc,\n {right, split, swap, exact tmodel.cons ic lc sgc, split, apply tc'.base, simp, exact memc, simp, rw hccc, rw pi},\n {left, exact hccc} },\n {right, \n rcases hr with ⟨d, ddesc, hd⟩,\n split, swap, exact d, split,\n {apply desc_ex, split, split, exact memc, exact ddesc},\n {exact hd}}}},\n {simp, intros rq hrq φ hφ, cases hφ, \n {exfalso, apply ma.no_box_main, exact hφ}, \n {have := mem_loop_box _ _ _ _ hrq, rw this, exact hφ}},\n {simp, intros s hs, have := mem_loop_dia _ _ _ _ hs, \n rcases this with ⟨w, hmem, hw⟩,\n have := Γ.ha _ hmem,\n have sb := mem_loop_box _ _ _ _ hs,\n cases s, rw ←hw at this, rw ←sb at this, simp at this, exact this}},\n {intros d hd, have := ex_desc' _ _ _ _ hd, \n cases this, \n {have pd := pt_of_m_to_tm _ _ this, exact pd.1}, \n {rcases this with ⟨m, memm, mdesc⟩, \n have pd := pt_of_m_to_tm _ _ memm,\n apply pd.2, exact mdesc}}}},\n {simp}\n end\n end\n | inr no_dia := \n let mc : model_constructible Γ := \n {satu := {no_and := no_and, no_or := no_or},\n no_box_main := no_box,\n no_contra_main := no_contra, \n no_dia := no_dia} in build_model mc\n end \n end\n end\n end\n end\nusing_well_founded {rel_tac := λ _ _, `[exact ⟨_, prod.measure_lex_wf' sseqt_size⟩], dec_tac := `[assumption]}\n\n@[simp] def mk_sseqt (Γ : list nnf) : sseqt :=\n{ goal := Γ,\n s := none,\n a := [],\n h := [],\n b := [],\n m := Γ,\n ndh := list.nodup_nil,\n ndb := list.nodup_nil,\n sph := list.nil_subperm,\n spb := list.nil_subperm,\n sbm := mem_closure_self _,\n ha := λ x hx, absurd hx $ list.not_mem_nil _,\n hb := box_only_nil,\n ps₁ := λ h, by contradiction,\n ps₂ := λ h, by contradiction }\n\ndef is_sat (Γ : list nnf) : bool :=\nmatch tableau (mk_sseqt Γ) with\n| closed _ := ff\n| open_ _ := tt\nend\n\ntheorem model_existence (m : model) (hrt : manc m.1 = []) \n(Γ : list nnf) (h : Γ ⊆ htk m.1) : ∃ (st : Type) (k : S4 st) s, sat k s Γ := \nbegin\nsplit, swap,\nexact {x : rmodel // x.1 = m.1 ∨ desc x.1 m.1},\nsplit, swap,\nexact builder m.1,\nsplit, swap,\nsplit,\nleft, swap, exact ⟨m.1, m.2.1⟩,\nsimp,\nintros φ hφ, apply good_model,\nexact hrt, apply h, exact hφ\nend\n\ntheorem correctness (Γ : list nnf) : is_sat Γ = tt ↔ ∃ (st : Type) (k : S4 st) s, sat k s Γ := \nbegin\n cases h : is_sat Γ,\n constructor,\n {intro, contradiction},\n {intro hsat, cases eq : tableau (mk_sseqt Γ), \n rcases hsat with ⟨w, k, s, hsat⟩,\n apply false.elim, apply a, simp, exact hsat,\n {dsimp [is_sat] at h, dsimp at eq, rw eq at h, contradiction}},\n {split, intro, dsimp [is_sat] at h, \n cases eq : tableau (mk_sseqt Γ),\n {dsimp at eq, rw eq at h, contradiction},\n {apply model_existence, swap 3, exact a_1.1,\n have := a_1.2, simp at this,\n cases a_1.val with tm ptm,\n cases tm with itm ltm sgtm,\n simp, simp at this, rw this,\n have := a_1.2, simp at this, \n cases a_1.val with tm ptm,\n cases tm with itm ltm sgtm,\n have hsub := itm.mhtk, simp, simp at this,\n rw this at hsub, dsimp at hsub, exact hsub},\n {simp}}\nend\n\n-- negation of K\ndef φ : nnf := \nand (box $ or (neg 1) (var 2)) (and (box $ var 1) (dia $ neg 2))\n\n#eval is_sat [φ] -- ff\n\n-- negation of S4\ndef ψ : nnf := and (box (var 1)) (dia (dia (neg 1)))\n\n#eval is_sat [ψ] -- ff\n\ndef γ : nnf := and (and (dia (var 1)) (dia (var 2))) (box (or (neg 1) (neg 2)))\n\n#eval is_sat [γ] -- tt\n", "meta": {"author": "minchaowu", "repo": "ModalTab", "sha": "9bb0bf17faf0554d907ef7bdd639648742889178", "save_path": "github-repos/lean/minchaowu-ModalTab", "path": "github-repos/lean/minchaowu-ModalTab/ModalTab-9bb0bf17faf0554d907ef7bdd639648742889178/src/S4/vanilla.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.35220177524832036, "lm_q1q2_score": 0.22689722616403762}} {"text": "import ..scheduling\nimport ..fairness\nimport ..spec\n\nimport util.predicate\n\nuniverse variables u u₀ u₁ u₂ u₃\nopen predicate nat\n\nlocal infix ` ≃ `:75 := v_eq\n\nnamespace temporal\n\nnamespace many_to_many\nsection\nopen fairness\nparameters {α : Type u} {β : Type u₀} {γ : Type u₁ }\nparameters {m₀ : mch (γ×α)} {m₁ : mch (γ×β)}\nlocal notation `p` := m₀.init\nlocal notation `q` := m₁.init\nlocal notation `aevt` := m₀.evt\nlocal notation `cevt` := m₁.evt\nlocal notation `cs₀` := m₀.cs\nlocal notation `fs₀` := m₀.fs\nlocal notation `cs₁` := m₁.cs\nlocal notation `fs₁` := m₁.fs\nlocal notation `A` := m₀.A\nlocal notation `C` := m₁.A\nlocal notation `ae` := m₀.event\nlocal notation `ce` := m₁.event\nlocal notation `ce'` := m₁.event' (option aevt)\n-- local notation `Next₀` := m₀.effect\n-- local notation `Next₁` := m₁.effect\n\n\nparameters (J : pred' (γ×α×β))\nparameter ref : option aevt → option cevt → Prop\nparameter wit : Π a : aevt, subtype (λ c : cevt, ref a c) → cpred\n\nopen prod\n\ndef C' (e : cevt) : act (cevt×γ×β) :=\nλ ⟨sch,s⟩ ⟨_,s'⟩, sch = e ∧ C e s s'\n\n\n-- #check (_ × _) × _\n-- abbreviation ae' (i : aevt) : event (γ×α×aevt) :=\n-- { p := cs₀ i!⟨prod.map_right fst⟩\n-- , q := fs₀ i!⟨prod.map_right fst⟩\n-- , A := λ s s', s.2.2 = i ∧ (A i on prod.map_right fst) s s' }\n-- abbreviation ce' (i : cevt) (j : aevt) : event (γ×β×(cevt×aevt)) :=\n-- { p := cs₁ i!⟨prod.map_right fst⟩\n-- , q := fs₁ i!⟨prod.map_right fst⟩\n-- , A := λ ⟨o,v,ce,_⟩ ⟨o',v',_,ae'⟩, ae' = j ∧ ce = i ∧ C i (o,v) (o',v') }\n\nsection specs\n\n-- parameters p q cs₀ fs₀ cs₁ fs₁\n\ndef SPEC₀.saf' (v : tvar α) (o : tvar γ) (sch : tvar (option aevt)) : cpred :=\nm₀.spec_saf_sch ⦃o,v⦄ (⊙sch)\n\ndef SPEC₀ (v : tvar α) (o : tvar γ) : cpred :=\nm₀.spec ⦃ o,v ⦄\n\ndef SPEC₁ (v : tvar β) (o : tvar γ) : cpred :=\nm₁.spec ⦃ o,v ⦄\n\ndef SPEC₂ (v : tvar β) (o : tvar γ) (s : tvar (option cevt)) : cpred :=\nm₁.spec_sch ⦃o,v⦄ s\n\nend specs\n\nparameters [inh_cevt : inhabited cevt]\n [inh_aevt : inhabited aevt]\n\n-- parameter Hc2a : ∀ ce : cevt, ∃ ae : aevt, ref ae ce\n\n-- parameter init_Jₐ : ∀ w o, (o,w) ⊨ p → (o,w) ⊨ Jₐ\n-- parameter evt_Jₐ : ∀ w o w' o' e,\n-- (o,w) ⊨ Jₐ →\n-- (o,w) ⊨ cs₀ e →\n-- (o,w) ⊨ fs₀ e →\n-- A e (o,w) (o',w') →\n-- (o',w') ⊨ Jₐ\n\nstructure refinement :=\n (SIM₀ : ∀ v o, (o,v) ⊨ q → ∃ w, (o,w) ⊨ p ∧ (o,w,v) ⊨ J)\n (SIM : ∀ cev w v o v' o',\n (o,w,v) ⊨ J →\n m₁.effect cev (o,v) (o',v') →\n ∃ aev w', ref aev cev ∧\n m₀.effect aev (o,w) (o',w') ∧\n (o',w',v') ⊨ J )\n (ANIM : ∀ (e : aevt) (sch : tvar (option aevt)) (o v w),\n many_to_many_po'\n (subtype _)\n (SPEC₁ v o ⋀ SPEC₀.saf' w o sch ⋀ ◻(J ! ⦃o,w,v⦄))\n (wit e)\n (λ e', ce e') (ae e)\n ⦃o,v⦄ ⦃o,w⦄)\n\nsection obligations\n\nparameters (v : tvar β) (o : tvar γ)\nparameters (Γ : cpred)\n\nparameter Href : refinement\n\nparameters β γ\nparameters {β γ}\n\nsection conc_sch\n\nparameters (sch_c : tvar (option cevt))\n\nvariable (sch_a : tvar (option aevt))\n\nsection SPEC₂\nvariable H : Γ ⊢ SPEC₂ v o sch_c\n\nopen prod temporal.prod\n\n-- def Next_a : act $ γ × aevt × α :=\n-- λ σ σ',\n-- ∃ e, σ.2.1 = e ∧\n-- map_right snd σ ⊨ cs₀ e ∧\n-- map_right snd σ ⊨ fs₀ e ∧\n-- (A e on map_right snd) σ σ'\n\n-- def Next_c : act $ γ × cevt × β :=\n-- λ σ σ',\n-- ∃ e, σ.2.1 = e ∧\n-- map_right snd σ ⊨ cs₁ e ∧\n-- map_right snd σ ⊨ fs₁ e ∧\n-- (C e on map_right snd) σ σ'\n\nsection J\ndef J' : pred' (γ × (aevt × α) × (cevt × β)) :=\nJ ! ⟨ prod.map_right $ prod.map prod.snd prod.snd ⟩ ⋀\n⟨ λ ⟨_, a, c⟩, ref a.1 c.1 ⟩\n\n-- def JJₐ : pred' (γ × aevt × α) :=\n-- Jₐ ! ⟨ prod.map_right snd ⟩\n\ndef p' : pred' (γ × aevt × α) :=\np ! ⟨prod.map_right prod.snd⟩\n\ndef q' : pred' (γ × cevt × β) :=\nq ! ⟨prod.map_right prod.snd⟩\n\nend J\nvariable w : tvar α\nopen function\ninclude inh_aevt\n-- def Wx₀_f : tvar (β → γ → aevt × α → Prop) :=\n-- λ v o (w : aevt × _), (o,w.2) ⊨ p ∧ (o,w.2,v) ⊨ J\n\n-- @[simp]\n-- def Wx₀ : tvar (option aevt × α → Prop) :=\n-- [| v o , λ (w : option aevt × _), (o,w.2) ⊨ p |]\n\n-- def Wf_f : tvar (option cevt → β → γ → γ → option aevt × α → option aevt × α → Prop) :=\n-- ⟪ℕ, λ ce v' o o' (w : _ × _) (w' : option aevt × α),\n-- (o',w'.2,v') ⊨ J ∧\n-- ref w'.1 ce ∧\n-- -- (o,w.2) ⊨ cs₀ w'.1 ∧\n-- -- (o,w.2) ⊨ fs₀ w'.1 ∧\n-- m₀.effect w'.1 (o,w.2) (o',w'.2) ⟫\n-- -- A w'.1 (o,w.2) (o',w'.2) ⟫\n\n-- @[simp]\n-- def Wf : tvar (option aevt × α → option aevt × α → Prop) :=\n-- ⟪ℕ, λ (cev : option cevt) o o' (w w' : option aevt × α),\n-- ref w'.1 cev ∧\n-- -- (o,w.2) ⊨ cs₀ w'.1 ∧\n-- -- (o,w.2) ⊨ fs₀ w'.1 ∧\n-- m₀.effect w'.1 (o,w.2) (o',w'.2) ⟫\n-- sch_c o (⊙o)\n\n-- lemma Wx₀_def' (σ : ℕ)\n-- : σ ⊨ Wx₀ =\n-- ε w : _ × α, (σ ⊨ o,w.2) ⊨ p ∧ (σ ⊨ o,w.2,σ ⊨ v) ⊨ J :=\n-- by repeat { unfold_coes <|> simp [Wx₀,Wx₀_f] }\n\n-- @[simp,predicate]\n-- lemma Wx₀_def (σ : ℕ) (a b)\n-- : (a,b) = σ ⊨ Wx₀ ↔\n-- a = (ε w : _ × α, (σ ⊨ o,w.2) ⊨ p ∧ (σ ⊨ o,w.2,σ ⊨ v) ⊨ J).fst ∧\n-- b = (ε w : aevt × α, (σ ⊨ o,w.2) ⊨ p ∧ (σ ⊨ o,w.2,σ ⊨ v) ⊨ J).snd :=\n-- by repeat { unfold_coes <|> simp [Wx₀,Wx₀_f,ext] }\n\n-- lemma Wf_def' (σ : ℕ) (w)\n-- : σ ⊨ Wf ⦃sch_a,w⦄ =\n-- ε w' : _ × α,\n-- (succ σ ⊨ o,w'.2,succ σ ⊨ v) ⊨ J ∧\n-- ref w'.1 (σ ⊨ sch_c) ∧\n-- (σ ⊨ o,σ ⊨ w) ⊨ cs₀ w'.1 ∧\n-- (σ ⊨ o,σ ⊨ w) ⊨ fs₀ w'.1 ∧\n-- A w'.1 (σ ⊨ o,σ ⊨ w) (succ σ ⊨ o,w'.2) :=\n-- by repeat { unfold_coes <|> simp [Wf,Wf_f] }\n\n\n-- @[simp,predicate]\n-- lemma Wf_def (σ : ℕ) (sch_a w) (a b)\n-- : (a,b) = (σ ⊨ Wf) (sch_a,w) ↔\n-- a = (ε w' : _ × α,\n-- (succ σ ⊨ o,w'.2,succ σ ⊨ v) ⊨ J ∧\n-- ref w'.1 (σ ⊨ sch_c) ∧\n-- (σ ⊨ o,w) ⊨ cs₀ w'.1 ∧\n-- (σ ⊨ o,w) ⊨ fs₀ w'.1 ∧\n-- A w'.1 (σ ⊨ o,w) (succ σ ⊨ o,w'.2)).1 ∧\n-- b = (ε w' : aevt × α,\n-- (succ σ ⊨ o,w'.2,succ σ ⊨ v) ⊨ J ∧\n-- ref w'.1 (σ ⊨ sch_c) ∧\n-- (σ ⊨ o,w) ⊨ cs₀ w'.1 ∧\n-- (σ ⊨ o,w) ⊨ fs₀ w'.1 ∧\n-- A w'.1 (σ ⊨ o,w) (succ σ ⊨ o,w'.2)).2 :=\n-- by repeat { unfold_coes <|> simp [Wf,Wf_f,ext] }\n\n-- variable valid_witness\n-- : Γ ⊢ Wtn ⦃sch_a,w⦄\n\n-- lemma abstract_sch (e : aevt)\n-- : Γ ⊢ sch_a ≃ e ⋀ cs₀ e ! ⦃o,w⦄ ⋀ fs₀ e ! ⦃o,w⦄ ⋀ ⟦ o,w | A e ⟧ ≡\n-- sch_a ≃ e ⋀ ⟦ o,sch_a,w | Next_a ⟧ :=\n-- begin\n-- lifted_pred [Next_a,on_fun],\n-- split ; intro h ; split\n-- ; casesm* _ ∧ _ ; subst e ; tauto,\n-- end\n\nsection Simulation_POs\n-- include SIM₀ Hc2a\n-- lemma SIM₀' (v : cevt × β) (o : γ)\n-- (h : (o, v) ⊨ q')\n-- : (∃ (w : aevt × α), (o, w) ⊨ p' ∧ (o, w, v) ⊨ J') :=\n-- begin\n-- simp [q',prod.map_left] at h,\n-- specialize SIM₀ v.2 o h,\n-- specialize Hc2a v.1,\n-- revert SIM₀, intros_mono,\n-- simp [J',p',map], intros,\n-- cases Hc2a,\n-- constructor_matching* [Exists _, _ ∧ _] ;\n-- tauto,\n-- end\n\n-- omit SIM₀\n-- include SIM\n-- lemma SIM' (w : aevt × α) (v : cevt × β) (o : γ) (v' : cevt × β) (o' : γ)\n-- (h₀ : (o, w, v) ⊨ J')\n-- (h₁ : Next_c (o, v) (o', v'))\n-- : (∃ w', Next_a (o,w) (o',w') ∧ (o', w', v') ⊨ J') :=\n-- begin\n-- simp [J',map] at h₀,\n-- simp [Next_c,on_fun] at h₁,\n-- cases h₀,\n-- specialize SIM w.2 v.2 o v'.2 o' v.1 w.1 h₀_right h₀_left h₁,\n-- cases SIM with w' SIM,\n-- cases Hc2a v'.1 with ae',\n-- existsi [(ae',w')],\n-- simp [Next_a, J',on_fun,map,h₀_right],\n-- tauto,\n-- end\n\n-- include H\n-- omit SIM\n-- lemma H'\n-- : Γ ⊢ simulation.SPEC₁ q' Next_c ⦃v,sch_c⦄ o :=\n-- begin [temporal]\n-- simp [SPEC₂,simulation.SPEC₁,q'] at H ⊢,\n-- split, tauto,\n-- casesm* _ ⋀ _,\n-- persistent,\n-- select h : ◻p_exists _,\n-- henceforth at h ⊢,\n-- cases h with e h,\n-- simp only [Next_c] at *,\n-- explicit'\n-- { cc },\n-- end\n\n-- omit H\nabbreviation ref' : tvar (option aevt → option cevt → Prop) :=\nref\n\n@[simp]\ndef Next₀ : act (γ × α × option aevt) :=\nλ ⟨o,w,sch_a⟩ ⟨o',w',_⟩, ∃ e, sch_a = e ∧ m₀.effect e (o,w) (o',w')\n\n-- include valid_witness -- init_Jₐ evt_Jₐ\ninclude H Href\n-- set_option pp.implicit true\n\nlemma J_inv_in_w'\n: Γ ⊢ ∃∃ w, ◻(J ! ⦃o,w,v⦄) ⋀ SPEC₀.saf' w o sch_a :=\nbegin [temporal]\n -- select_witness w : temporal.many_to_many.Wtn w\n -- with Hw using J ! ⦃o,w.snd,v⦄,\n unfold SPEC₂ mch.spec_sch at H, casesm* _ ⋀ _,\n\n select_witness w : m₀.init ! ⦃o,w⦄ ⋀ ◻ ⟦ o,w,sch_a | temporal.many_to_many.Next₀ ⟧\n -- with h₀ h₁\n using (J ! ⦃o,w,v⦄)\n { ext, admit, -- simp_coe [to_fun_var'],\n -- simp only with lifted_fn,\n -- congr, funext, transitivity, apply to_fun_var'_lift₂,\n -- -- congr,\n -- simp [to_fun_var'_coe] with lifted_fn,\n -- congr, rw to_fun_var'_id,\n -- refl,\n },\n explicit' with a\n { apply Href.SIM₀, assumption },\n -- simp [SPEC₂] at H,\n -- rw henceforth_next_intro,\n -- dsimp [SPEC₀.saf'],\n -- -- cases valid_witness with h₀ h₀,\n -- casesm* _ ⋀ _,\n -- intros,\n -- t_induction,\n -- { -- select Hw : _ ≃ temporal.many_to_many.Wx₀,\n -- select Hq : q ! _,\n -- have SIM₀ := Href.SIM₀,\n -- explicit' with SIM₀ Hq\n -- { { },\n -- simp, tauto, } },\n { select H₀ : p_exists _,\n -- henceforth! at h₀_1 H₀ ⊢,\n explicit' [Next₀] with H₀\n { intros h hJ,\n -- casesm* [_ ∧ _,Exists _],\n -- type_check cs₀,\n -- have : (o', h', v') ⊨ J ∧\n -- (o,w) ⊨ cs₀ sch_a' ∧ (o,w) ⊨ fs₀ sch_a' ∧\n -- A sch_a' (o, w) (o', w'),\n -- { subst H₀_w, subst w', subst sch_a',\n -- apply_epsilon_spec,\n -- simp,\n -- apply SIM ; solve_by_elim },\n -- split, tauto,\n -- casesm* _ ∧ _,\n -- apply evt_Jₐ ; apply hJₐ <|> solve_by_elim\n } },\nend\n\n-- lemma J_inv_in_w\n-- : Γ ⊢ ◻(J ! ⦃o,w,v⦄) :=\n-- begin [temporal]\n-- cases temporal.many_to_many.J_inv_in_w' _ H _ valid_witness,\n-- assumption\n-- end\n\n-- lemma abs_J_inv_in_w\n-- : Γ ⊢ ◻(Jₐ ! ⦃o,w⦄) :=\n-- begin [temporal]\n-- cases temporal.many_to_many.J_inv_in_w' _ H _ valid_witness,\n-- assumption\n-- end\n\nlemma witness_imp_SPEC₀_saf\n: Γ ⊢ SPEC₀.saf' w o sch_a :=\nbegin [temporal]\n simp [SPEC₀.saf',Wtn] at ⊢ valid_witness,\n cases valid_witness with H₀ H₁,\n split,\n explicit' with H₀\n { tauto, },\n henceforth!,\n explicit' with H₁\n { tauto, },\nend\n\nomit H\nparameters m₀ m₁\ninclude Href\nomit valid_witness\n\nlemma SPEC₂_imp_SPEC₁\n: (SPEC₂ v o sch_c) ⟹ (SPEC₁ v o) :=\nbegin [temporal]\n simp only [SPEC₁,SPEC₂,temporal.many_to_many.SPEC₁,temporal.many_to_many.SPEC₂],\n monotonicity, apply ctx_p_and_p_imp_p_and',\n { monotonicity, simp, intros x, intros,\n existsi x, tauto },\n { intros h i h₀ h₁,\n replace h := h _ h₀ h₁,\n revert h, monotonicity, simp, }\nend\n\nsection\nomit Href\ninclude valid_witness Γ H\n-- #check w\n-- noncomputable def sch_w : tvar aevt :=\n-- ⟪ ℕ, λ (w w' : α), ε ae, A ae w w' ⟫ w (⊙w)\n\n-- lemma sch_w_spec\n-- : Γ ⊢ ◻(ref' (⊙sch_a) sch_c) :=\n-- begin [temporal]\n-- have hJ := temporal.many_to_many.J_inv_in_w _ H _ valid_witness,\n-- have hJₐ := temporal.many_to_many.abs_J_inv_in_w _ H _ valid_witness,\n-- simp [Wtn,SPEC₂] at valid_witness H,\n-- cases valid_witness with Hw' Hw,\n-- cases H with H H₀,\n-- cases H with H₁ H₂,\n-- henceforth! at Hw ⊢ hJ hJₐ H₂,\n-- explicit' with Hw hJ hJₐ H₂\n-- { cases Hw, subst sch_a', casesm* [_∧_,Exists _],\n-- subst sch_c, apply_epsilon_spec,\n-- simp, solve_by_elim, },\n-- end\n\nend\n\ninclude H valid_witness\n\nlemma H_C_imp_A (e : option cevt) (e' : option aevt)\n (Hsim : ref e' e)\n: Γ ⊢ ◻(sch_c ≃ ↑e ⟶ ⊙sch_a ≃ ↑e' ⟶\n ⟦ o,v | Next₁ e ⟧ ⟶\n ⟦ o,w | Next₀ e' ⟧) :=\nbegin [temporal]\n have hJ := temporal.many_to_many.J_inv_in_w sch_a H w valid_witness,\n have hJₐ := temporal.many_to_many.abs_J_inv_in_w sch_a H w valid_witness,\n simp [Wtn] at valid_witness,\n cases valid_witness with h₀ h₁,\n cases H with H H₀,\n cases H with H₁ H₂,\n clear_except hJ hJₐ SIM h₁ H₂,\n henceforth! at *,\n explicit' with hJ hJₐ SIM h₁ H₂\n { intros, cases h₁, subst w', subst sch_c,\n subst sch_a', substs e',\n casesm* [_ ∧ _, Exists _], subst e,\n apply_epsilon_spec,\n simp, apply SIM ; solve_by_elim, },\nend\n\nomit valid_witness H\n\nlemma Hpo' (e : aevt)\n: many_to_many_po'\n _ (SPEC₂ v o sch_c ⋀ Wtn ⦃sch_a,w⦄ ⋀ ◻(J ! ⦃o,w,v⦄))\n (wit e)\n (λ i, ce' i e) (ae e)\n ⦃⦃o,v⦄,sch_c,sch_a⦄ ⦃o,w⦄\n:=\nbegin\n have\n : temporal.many_to_many.SPEC₂ v o sch_c ⋀ temporal.many_to_many.Wtn ⦃sch_a,w⦄ ⋀\n ◻(J ! ⦃o,w,v⦄) ⟹\n temporal.many_to_many.SPEC₁ v o ⋀ temporal.many_to_many.SPEC₀.saf' w o sch_a ⋀\n ◻(J ! ⦃o,w,v⦄),\n begin [temporal]\n simp, intros h₀ h₁ h₂, split*,\n { apply temporal.many_to_many.SPEC₂_imp_SPEC₁ _ _ ; try { solve_by_elim }, },\n { apply temporal.many_to_many.witness_imp_SPEC₀_saf _ h₀ _ h₁, },\n { solve_by_elim }\n end,\n constructor,\n iterate 3\n { cases (Href.ANIM e sch_a o v w),\n simp! [ce',mch.event'] at *,\n transitivity,\n { apply this },\n { assumption } },\n clear this,\n begin [temporal]\n intros,\n casesm* _ ⋀ _,\n select Hw : temporal.many_to_many.Wtn _,\n select hJ : ◻(J ! _),\n select H : temporal.many_to_many.SPEC₂ _ _ _,\n have := temporal.many_to_many.H_C_imp_A _ H w Hw _ e x.2,\n cases H with H H₀,\n cases H with H₁ H₂,\n clear_except this Href SIM₀ SIM Hw hJ H₂,\n simp [Wtn] at Hw, cases Hw with Hw' Hw,\n henceforth! at ⊢ Hw hJ H₂ this,\n explicit' [mch.event'] with this Hw hJ H₂\n { dsimp [ce',mch.event'], cases Hw,\n intros,\n casesm* [_ ∧ _, Exists _, sch_c = _],\n specialize this _ _ _ ; try { assumption },\n simp [and_assoc,*], exact this, },\n end\nend\n\nend Simulation_POs\n\ninclude H Href\n\nlemma sched_ref (i : aevt) -- (w : tvar (aevt × α))\n (hJ : Γ ⊢ ◻(J ! ⦃o,w,v⦄))\n (Hw : Γ ⊢ Wtn ⦃sch_a,w⦄)\n (h : Γ ⊢ ∀∀ j : cevt, ref ↑i ↑j ⟶ sched (cs₁ j ! ⦃o,v⦄) (fs₁ j ! ⦃o,v⦄) (sch_c ≃ some j ⋀ ⟦ o,v | C j ⟧))\n: Γ ⊢ sched (cs₀ i ! ⦃o,w⦄) (fs₀ i ! ⦃o,w⦄) ⟦ o,w | A i ⟧ :=\nbegin [temporal]\n -- have hJ : ◻(J ! ⦃o,w,v⦄),\n -- { apply temporal.many_to_many.J_inv_in_w ; solve_by_elim },\n apply splitting (Href.ANIM i sch_a o v w) _ _,\n { split*,\n apply temporal.many_to_many.SPEC₂_imp_SPEC₁ _ ; assumption,\n apply temporal.many_to_many.witness_imp_SPEC₀_saf ; assumption,\n assumption },\n intro cev, cases cev with cev Hce,\n simp only, intros H₀ H₁,\n replace h := h cev Hce H₀ H₁,\n revert h,\n monotonicity!,\n explicit'\n { intros, tauto },\nend\n\n/-\n This proof works as:\n Init₂ ⇒ Init₀\n Saf₂ ⇒ Saf₀\n Spec₂ ⇒ Live₀\n -/\nlemma many_to_many\n: Γ ⊢ ∃∃ w, SPEC₀ w o :=\nbegin [temporal]\n apply p_exists_partial_intro _ (proj $ @pair.snd (option aevt) α) _ _,\n -- replace H := H.left,\n cases H.left with H₀ H₁,\n select_witness w : temporal.many_to_many.Wtn w\n with Hw using J ! ⦃o,w.snd,v⦄,\n explicit' [Wx₀] with H₀\n { apply Href.SIM₀ _ _ H₀, },\n explicit' [Wf] with H₁\n { simp_intros b hJ [and_assoc],\n have := Href.SIM _ _ _ _ _ _ hJ H₁,\n tauto, }, -- a ∧ a ↔ a\n existsi w,\n { apply m₀.spec_of_spec_saf_sch _ (⊙w.fst),\n apply temporal.many_to_many.witness_imp_SPEC₀_saf _ H,\n revert Hw, simp,\n intro, apply temporal.many_to_many.sched_ref w.fst H w.snd x,\n assumption, simp *, introv H',\n apply H.right, },\nend\nend SPEC₂\nend conc_sch\n\nsection refinement_SPEC₂\ninclude Href wit inh_aevt\nparameters m₀ m₁\n\nlemma refinement_SPEC₂\n: Γ ⊢ (∃∃ sch_c, SPEC₂ v o sch_c) ⟶ (∃∃ a, SPEC₀ a o) :=\nbegin [temporal]\n simp, intros sch Hc,\n apply temporal.many_to_many.many_to_many ;\n solve_by_elim,\nend\n\nend refinement_SPEC₂\n\nopen nat function set scheduling\ninclude inh_cevt\n\nvariables [encodable cevt]\n\nlemma refinement_SPEC₁\n: SPEC₁ v o ⟹ (∃∃ sch, SPEC₂ v o sch) :=\nassume Γ,\nsch_intro _ _ _\n\nend obligations\nopen function\ninclude J wit inh_cevt inh_aevt\n\nlemma refinement' {o : tvar γ} [encodable cevt]\n (h : refinement)\n: (∃∃ c, SPEC₁ c o) ⟹ (∃∃ a, SPEC₀ a o) :=\nbegin [temporal]\n transitivity (∃∃ c (sch : tvar (option cevt)), SPEC₂ c o sch),\n { apply p_exists_p_imp_p_exists ,\n intro v,\n apply temporal.many_to_many.refinement_SPEC₁, },\n { simp, intros c sch Hspec,\n apply temporal.many_to_many.refinement_SPEC₂ c o Γ h,\n existsi sch, exact Hspec, },\nend\n\nend\nend many_to_many\n\nend temporal\n", "meta": {"author": "unitb", "repo": "temporal-logic", "sha": "accec04d1b09ca841be065511c9e206b725b16e9", "save_path": "github-repos/lean/unitb-temporal-logic", "path": "github-repos/lean/unitb-temporal-logic/temporal-logic-accec04d1b09ca841be065511c9e206b725b16e9/src/temporal_logic/refinement/many_to_many.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.40356685373537454, "lm_q1q2_score": 0.22687580170644356}} {"text": "namespace Monads\n /- Functors capture the notion of a regular computation being executed\n on values that are within another type.\n This type usually captures either the notion of a container, such\n as a list, or a context for a computation, such as receiving data\n from IO.-/\n class Functor (f : Type u → Type v) : Type (max (u+1) v) where\n fmap : (α → β) → f α → f β\n map_const : α → f β → f α := fmap ∘ (Function.const β)\n\n export Functor (fmap map_const)\n infixr:100 \" <$> \" => Monads.Functor.fmap\n infixr:90 \" <$ \" => Monads.Functor.map_const\n\n namespace Functor\n def const_map {α β : Type u} {f : Type u → Type v} [Functor f] : f β → α → f α := flip map_const\n infixr:90 \" $> \" => Monads.Functor.const_map\n def void {α : Type} {f : Type → Type} [Functor f] : f α → f Unit := map_const ()\n end Functor\n\n /- LawfulFunctor ensures the Functor is in fact only applying the function\n to the values and not performing additional computation or modification\n See Maybe.lean for an example why we need both laws to hold for a sensible\n functor. -/\n class LawfulFunctor (f : Type u → Type v) [Functor f] : Prop where\n /- If the function maps values to themselves the values in the functor\n shall remain unchanged -/\n fmap_id : ∀ (x : f α), id <$> x = x\n /- Applying two functions via fmap is the same as applying one composed function\n at once via fmap -/\n fmap_comp : ∀ (g : α → β) (h : β → γ) (x : f α), (h ∘ g) <$> x = h <$> g <$> x\n /- If there is a custom map_const implementation it has to behave like the\n default one. -/\n map_const_behaved: ∀ (x : α) (y : f β), x <$ y = (fmap ∘ (Function.const β)) x y\n\n namespace LawfulFunctor\n variable {f : Type u → Type v} [Functor f] [LawfulFunctor f]\n\n example {g : α → β} {x : f α} : g <$> (id <$> x) = g <$> x := by\n rw [fmap_id]\n\n example {g : α → β} {x : f α} : id <$> (g <$> x) = g <$> x := by\n rw [fmap_id]\n end LawfulFunctor\nend Monads\n", "meta": {"author": "hargoniX", "repo": "lean-monads", "sha": "2e87ca7ddf394641ea1b16bcbd8c384026d68e2f", "save_path": "github-repos/lean/hargoniX-lean-monads", "path": "github-repos/lean/hargoniX-lean-monads/lean-monads-2e87ca7ddf394641ea1b16bcbd8c384026d68e2f/Monads/Functor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.546738151984614, "lm_q2_score": 0.41489884579676883, "lm_q1q2_score": 0.2268410282114747}} {"text": "-- lemmas about evaluation\n\nimport .definitions3\n\n-- lemmas\n\nlemma binop.eq_of_equal_values {v: value}: binop.apply binop.eq v v = value.true :=\n have binop.apply binop.eq v v = (if v = v then value.true else value.false), by unfold binop.apply,\n show binop.apply binop.eq v v = value.true, by simp[this]\n\nlemma unop.isFunc.inv {v: value}: unop.apply unop.isFunc v = value.true → \n ∃ (f x: var) (R S: spec) (e: exp) (σ: env), v = value.func f x R S e σ :=\n assume isFunc_is_true: unop.apply unop.isFunc v = value.true,\n begin\n cases v with n f x R S e σ,\n\n show ∃ (f x: var) (R S: spec) (e: exp) (σ: env), value.true = value.func f x R S e σ, from (\n have h1: (unop.apply unop.isFunc value.true = value.true), from isFunc_is_true,\n have h2: (unop.apply unop.isFunc value.true = value.false), by unfold unop.apply,\n have some value.true = some value.false, from eq.trans h1.symm h2,\n have value.true = value.false, from option.some.inj this,\n false.elim (value._mut_.no_confusion this)\n ),\n\n show ∃ (f x: var) (R S: spec) (e: exp) (σ: env), value.false = value.func f x R S e σ, from (\n have h1: (unop.apply unop.isFunc value.false = value.true), from isFunc_is_true,\n have h2: (unop.apply unop.isFunc value.false = value.false), by unfold unop.apply,\n have some value.true = some value.false, from eq.trans h1.symm h2,\n have value.true = value.false, from option.some.inj this,\n false.elim (value._mut_.no_confusion this)\n ),\n\n show ∃ (f x: var) (R S: spec) (e: exp) (σ: env), value.num n = value.func f x R S e σ, from (\n have h1: (unop.apply unop.isFunc (value.num n) = value.true), from isFunc_is_true,\n have h2: (unop.apply unop.isFunc (value.num n) = value.false), by unfold unop.apply,\n have some value.true = some value.false, from eq.trans h1.symm h2,\n have value.true = value.false, from option.some.inj this,\n false.elim (value._mut_.no_confusion this)\n ),\n\n show ∃ (f_1 x_1: var) (R_1 S_1: spec) (e_1: exp) (σ_1: env),\n value.func f x R S e σ = value.func f_1 x_1 R_1 S_1 e_1 σ_1, from (\n exists.intro f (exists.intro x (exists.intro R (exists.intro S\n (exists.intro e (exists.intro σ rfl)))))\n )\n end\n\nlemma unop.isBool.inv {v: value}: unop.apply unop.isBool v = value.true → (v = value.true) ∨ (v = value.false) :=\n assume isBool_is_true: unop.apply unop.isBool v = value.true,\n begin\n cases v with n f x R S e σ,\n\n show ((value.true = value.true) ∨ (value.true = value.false)), from (\n or.inl rfl\n ),\n\n show ((value.false = value.true) ∨ (value.false = value.false)), from (\n or.inr rfl\n ),\n\n show (value.num n = value.true ∨ (value.num n = value.false)), from (\n have h1: unop.apply unop.isBool (value.num n) = ↑value.true, from isBool_is_true,\n have h2: (unop.apply unop.isBool (value.num n) = value.false), by unfold unop.apply,\n have some value.true = some value.false, from eq.trans h1.symm h2,\n have value.true = value.false, from option.some.inj this,\n false.elim (value._mut_.no_confusion this)\n ),\n\n show (value.func f x R S e σ = value.true ∨ (value.func f x R S e σ = value.false)), from (\n have h1: unop.apply unop.isBool (value.func f x R S e σ) = ↑value.true, from isBool_is_true,\n have h2: (unop.apply unop.isBool (value.func f x R S e σ) = value.false), by unfold unop.apply,\n have some value.true = some value.false, from eq.trans h1.symm h2,\n have value.true = value.false, from option.some.inj this,\n false.elim (value._mut_.no_confusion this)\n )\n end\n\nlemma binop.eq.inv {v₁ v₂: value}: binop.apply binop.eq v₁ v₂ = value.true → (v₁ = v₂) :=\n assume eq_is_true: binop.apply binop.eq v₁ v₂ = value.true,\n begin\n by_cases (v₁ = v₂),\n from h,\n unfold binop.apply at eq_is_true,\n simp[h] at eq_is_true,\n have h2, from option.some.inj eq_is_true,\n contradiction\n end\n\nlemma pre_preserved {s s': dstack}: s ⟹* s' → (s.pre = s'.pre) :=\n begin\n assume h1,\n induction h1,\n case trans_dstep.rfl {\n refl\n },\n case trans_dstep.trans s₁ s₂ s₃ h2 h3 ih {\n apply eq.trans ih,\n cases h3,\n repeat {refl}\n }\n end\n\nlemma unop_result_not_function {vx vy: value} {op: unop}:\n (unop.apply op vx = some vy) → (vy = value.true) ∨ (vy = value.false) :=\n begin\n assume h1,\n cases op,\n case unop.not {\n cases vx,\n\n unfold unop.apply at h1,\n have h2: (value.false = vy), from option.some.inj h1,\n right,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.true = vy), from option.some.inj h1,\n left,\n from h2.symm,\n\n unfold unop.apply at h1,\n contradiction,\n\n unfold unop.apply at h1,\n contradiction\n },\n case unop.isInt {\n cases vx,\n\n unfold unop.apply at h1,\n have h2: (value.false = vy), from option.some.inj h1,\n right,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.false = vy), from option.some.inj h1,\n right,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.true = vy), from option.some.inj h1,\n left,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.false = vy), from option.some.inj h1,\n right,\n from h2.symm\n },\n case unop.isBool {\n cases vx,\n\n unfold unop.apply at h1,\n have h2: (value.true = vy), from option.some.inj h1,\n left,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.true = vy), from option.some.inj h1,\n left,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.false = vy), from option.some.inj h1,\n right,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.false = vy), from option.some.inj h1,\n right,\n from h2.symm\n },\n case unop.isFunc {\n cases vx,\n\n unfold unop.apply at h1,\n have h2: (value.false = vy), from option.some.inj h1,\n right,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.false = vy), from option.some.inj h1,\n right,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.false = vy), from option.some.inj h1,\n right,\n from h2.symm,\n\n unfold unop.apply at h1,\n have h2: (value.true = vy), from option.some.inj h1,\n left,\n from h2.symm\n }\n end\n\nlemma binop_result_not_function {vx vy vz: value} {op: binop}:\n (binop.apply op vx vy = some vz) → ((vz = value.true) ∨ (vz = value.false) ∨ (∃n, vz = value.num n)) :=\n begin\n assume h1,\n cases op,\n case binop.plus {\n cases vx,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n cases vy,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n have h2: (value.num (a + a_1) = vz), from option.some.inj h1,\n right,\n right,\n existsi (a + a_1),\n from h2.symm,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction\n },\n case binop.minus {\n cases vx,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n cases vy,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n have h2: (value.num (a - a_1) = vz), from option.some.inj h1,\n right,\n right,\n existsi (a - a_1),\n from h2.symm,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction\n },\n case binop.times {\n cases vx,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n cases vy,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n have h2: (value.num (a * a_1) = vz), from option.some.inj h1,\n right,\n right,\n existsi (a * a_1),\n from h2.symm,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction\n },\n case binop.div {\n cases vx,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n cases vy,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n have h2: (value.num (a / a_1) = vz), from option.some.inj h1,\n right,\n right,\n existsi (a / a_1),\n from h2.symm,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction\n },\n case binop.and {\n cases vx,\n cases vy,\n\n unfold binop.apply at h1,\n have h2: (value.true = vz), from option.some.inj h1,\n left,\n from h2.symm,\n\n unfold binop.apply at h1,\n have h2: (value.false = vz), from option.some.inj h1,\n right,\n left,\n from h2.symm,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n cases vy,\n\n unfold binop.apply at h1,\n have h2: (value.false = vz), from option.some.inj h1,\n right,\n left,\n from h2.symm,\n\n unfold binop.apply at h1,\n have h2: (value.false = vz), from option.some.inj h1,\n right,\n left,\n from h2.symm,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction\n },\n case binop.or {\n cases vx,\n cases vy,\n\n unfold binop.apply at h1,\n have h2: (value.true = vz), from option.some.inj h1,\n left,\n from h2.symm,\n\n unfold binop.apply at h1,\n have h2: (value.true = vz), from option.some.inj h1,\n left,\n from h2.symm,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n cases vy,\n\n unfold binop.apply at h1,\n have h2: (value.true = vz), from option.some.inj h1,\n left,\n from h2.symm,\n\n unfold binop.apply at h1,\n have h2: (value.false = vz), from option.some.inj h1,\n right,\n left,\n from h2.symm,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction\n },\n case binop.eq {\n unfold binop.apply at h1,\n by_cases (vx = vy),\n simp[h] at h1,\n\n have h2: (value.true = vz), from option.some.inj h1,\n left,\n from h2.symm,\n\n simp[h] at h1,\n have h2: (value.false = vz), from option.some.inj h1,\n right,\n left,\n from h2.symm\n },\n case binop.lt {\n cases vx,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n cases vy,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n by_cases (a < a_1),\n\n simp[h] at h1,\n have h2: (value.true = vz), from option.some.inj h1,\n left,\n from h2.symm,\n\n simp[h] at h1,\n have h2: (value.false = vz), from option.some.inj h1,\n right,\n left,\n from h2.symm,\n\n unfold binop.apply at h1,\n contradiction,\n\n unfold binop.apply at h1,\n contradiction }\n end\n\nlemma step_dstep_progress {s s': stack}:\n (s ⟶ s') → ∀d, stack_equiv_dstack s d → ∃d', (d ⟹ d') :=\n begin\n assume h1,\n\n induction h1,\n\n case step.tru {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.top R (σ[x↦value.true]) e),\n apply dstep.tru\n },\n\n case step.fals {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.top R (σ[x↦value.false]) e),\n apply dstep.fals\n },\n\n case step.num {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.top R (σ[x↦value.num n]) e),\n apply dstep.num\n },\n\n case step.closure {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.top R_1 (σ[f↦value.func f x R S e₁ σ]) e₂),\n apply dstep.closure\n },\n\n case step.unop {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.top R (σ[y↦v]) e),\n apply dstep.unop a a_1\n },\n\n case step.binop {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.top R (σ[z↦v]) e),\n apply dstep.binop a a_1 a_2\n },\n\n case step.app {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.cons (R, (σ'[g↦value.func g z R S e σ'][z↦v]), e) R_1 σ y f x e'),\n apply dstep.app a a_1\n },\n\n case step.ite_true {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.top R σ e₁),\n apply dstep.ite_true a\n },\n\n case step.ite_false {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.top R σ e₂),\n apply dstep.ite_false a\n },\n\n case step.ctx s₁ s₂ σ₁ f x y e₁ steps ih {\n assume d,\n assume h2,\n cases h2,\n\n have h3, from ih d' a,\n cases h3 with d'' h4,\n\n existsi (dstack.cons d'' R σ₁ y f x e₁),\n apply dstep.ctx h4\n },\n\n case step.return {\n assume d,\n assume h2,\n cases h2,\n\n existsi (dstack.top R_1 (σ₂[y↦v]) e'),\n cases a_3,\n apply dstep.return a a_1 a_2\n }\n end\n\nlemma step_dstep_progress.inv {d d': dstack}:\n (d ⟹ d') → ∀s, stack_equiv_dstack s d → ∃s', (s ⟶ s') :=\n begin\n assume h1,\n\n induction h1,\n\n case dstep.tru {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.top (σ[x↦value.true]) e),\n apply step.tru\n },\n\n case dstep.fals {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.top (σ[x↦value.false]) e),\n apply step.fals\n },\n\n case dstep.num {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.top (σ[x↦value.num n]) e),\n apply step.num\n },\n\n case dstep.closure {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.top (σ[f↦value.func f x R S e₁ σ]) e₂),\n apply step.closure,\n from spec.term value.true\n },\n\n case dstep.unop {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.top (σ[y↦v]) e),\n apply step.unop a a_1\n },\n\n case dstep.binop {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.top (σ[z↦v]) e),\n apply step.binop a a_1 a_2\n },\n\n case dstep.app {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.cons ((σ'[g↦value.func g z R S e σ'][z↦v]), e) σ y f x e'),\n apply step.app a a_1\n },\n\n case dstep.ite_true {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.top σ e₁),\n apply step.ite_true a\n },\n\n case dstep.ite_false {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.top σ e₂),\n apply step.ite_false a\n },\n\n case dstep.ctx d₁ d₂ R σ₁ f x y e₁ steps ih {\n assume s,\n assume h2,\n cases h2,\n\n have h3, from ih s' a,\n cases h3 with s'' h4,\n\n existsi (stack.cons s'' σ₁ y f x e₁),\n apply step.ctx h4\n },\n\n case dstep.return {\n assume s,\n assume h2,\n cases h2,\n\n existsi (stack.top (σ₂[y↦v]) e'),\n cases a_3,\n apply step.return a a_1 a_2\n }\n end\n\nlemma step_dstep_preservation {s: stack}:\n ∀{s': stack} {d d': dstack},\n stack_equiv_dstack s d → (s ⟶ s') → (d ⟹ d') → stack_equiv_dstack s' d' :=\n begin\n induction s,\n\n case stack.top σ e {\n assume s' d d',\n assume h1,\n assume h2,\n assume h3,\n cases h1,\n have h4: (dstack.top R σ e ⟹ d'), from h3,\n cases h2,\n\n case step.tru {\n cases h4,\n simp,\n apply stack_equiv_dstack.top\n },\n\n case step.fals {\n cases h4,\n simp,\n apply stack_equiv_dstack.top\n },\n\n case step.num {\n cases h4,\n simp,\n apply stack_equiv_dstack.top\n },\n\n case step.closure {\n cases h4,\n simp,\n apply stack_equiv_dstack.top\n },\n\n case step.unop {\n cases h4,\n simp,\n have h5, from eq.trans a.symm a_2,\n have h6: (v₁ = v₁_1), from option.some.inj h5,\n rw[h6] at a_1,\n have h7, from eq.trans a_1.symm a_3,\n have h8: (v = v_1), from option.some.inj h7,\n rw[h8],\n apply stack_equiv_dstack.top\n },\n\n case step.binop {\n cases h4,\n simp,\n have h5, from eq.trans a.symm a_3,\n have h6: (v₁ = v₁_1), from option.some.inj h5,\n rw[h6] at a_2,\n have h7, from eq.trans a_1.symm a_4,\n have h8: (v₂ = v₂_1), from option.some.inj h7,\n rw[h8] at a_2,\n have h9, from eq.trans a_2.symm a_5,\n have h10: (v = v_1), from option.some.inj h9,\n rw[h10],\n\n apply stack_equiv_dstack.top\n },\n\n case step.app {\n cases h4,\n apply stack_equiv_dstack.cons,\n have h5, from eq.trans a.symm a_2,\n have h6: ((value.func g z R_1 S e_1 σ') = (value.func g_1 z_1 R_2 S_1 e σ'_1)),\n from option.some.inj h5,\n injection h6,\n rw[h_1],\n rw[h_2],\n rw[h_3],\n rw[h_4],\n rw[h_5],\n rw[h_6],\n have h7, from eq.trans a_1.symm a_3,\n have h8: (v = v_1), from option.some.inj h7,\n rw[h8],\n apply stack_equiv_dstack.top\n },\n\n case step.ite_true {\n cases h4,\n simp,\n apply stack_equiv_dstack.top,\n have h7, from eq.trans a.symm a_1,\n have h8: (value.true = value.false), from option.some.inj h7,\n contradiction\n },\n\n case step.ite_false {\n cases h4,\n simp,\n have h7, from eq.trans a.symm a_1,\n have h8: (value.false = value.true), from option.some.inj h7,\n contradiction,\n apply stack_equiv_dstack.top,\n },\n },\n\n case stack.cons s'' σ'' f x y e'' ih {\n assume s' d d',\n assume h1,\n assume h2,\n assume h3,\n cases h1,\n cases h2,\n\n case step.ctx {\n cases h3,\n\n apply stack_equiv_dstack.cons,\n from ih a a_1 a_2,\n\n simp at a,\n cases a,\n cases a_1\n },\n\n case step.return {\n cases h3,\n\n simp at a,\n cases a,\n cases a_4,\n\n simp,\n cases a,\n have h5, from eq.trans a_1.symm a_4,\n have h6: (v = v_1), from option.some.inj h5,\n rw[h6],\n apply stack_equiv_dstack.top,\n }\n }\n end\n\nlemma step_of_dstep_trans {d d': dstack}:\n (d ⟹* d') → ∀s, stack_equiv_dstack s d → ∃s', (s ⟶* s') ∧ stack_equiv_dstack s' d' :=\n begin\n assume h1,\n\n induction h1,\n\n assume s,\n assume h2,\n existsi s,\n split,\n from trans_step.rfl,\n from h2,\n\n assume s_1,\n assume h2,\n have h3, from ih_1 s_1 h2,\n cases h3 with s_2 h4,\n\n\n have h5, from step_dstep_progress.inv a_1 s_2 h4.right,\n cases h5 with s3 h6,\n\n existsi s3,\n split,\n apply trans_step.trans,\n from h4.left,\n from h6,\n\n apply step_dstep_preservation h4.right h6 a_1\n end\n\nlemma dstep_of_step_trans {s s': stack}:\n (s ⟶* s') → ∀d, stack_equiv_dstack s d → ∃d', (d ⟹* d') ∧ stack_equiv_dstack s' d' :=\n begin\n assume h1,\n\n induction h1,\n\n assume d,\n assume h2,\n existsi d,\n split,\n from trans_dstep.rfl,\n from h2,\n\n assume s_1,\n assume h2,\n have h3, from ih_1 s_1 h2,\n cases h3 with s_2 h4,\n\n\n have h5: ∃ (d' : dstack), s_2⟹d', from step_dstep_progress a_1 s_2 h4.right,\n cases h5 with s3 h6,\n\n existsi s3,\n split,\n apply trans_dstep.trans,\n from h4.left,\n from h6,\n\n apply step_dstep_preservation h4.right a_1 h6 \n end\n\nlemma step_of_dstep {R₁ R₂: spec} {σ₁ σ₂: env} {e₁ e₂: exp}: (R₁, σ₁, e₁) ⟹* (R₂, σ₂, e₂) → ((σ₁, e₁) ⟶* (σ₂, e₂)) :=\n begin\n assume h1,\n have h2: stack_equiv_dstack (σ₁, e₁) (R₁, σ₁, e₁), from stack_equiv_dstack.top,\n have h3, from step_of_dstep_trans h1 (σ₁, e₁) h2,\n cases h3 with s' h4,\n cases h4.right,\n from h4.left\n end\n\nlemma value_or_step_of_dvalue_or_dstep {s: stack} {d: dstack}:\n stack_equiv_dstack s d → (is_dvalue d ∨ ∃d', d ⟹ d') → (is_value s ∨ ∃s', s ⟶ s') :=\n begin\n assume h1,\n assume h2,\n cases h2 with h3 h3,\n unfold is_dvalue at h3,\n cases h3 with R h4,\n cases h4 with σ h5,\n cases h5 with x h6,\n cases h6 with v h7,\n left,\n unfold is_value,\n existsi σ,\n existsi x,\n existsi v,\n split,\n rw[h7.left] at h1,\n cases h1,\n congr,\n from h7.right,\n cases h3 with d' h4,\n have h5, from step_dstep_progress.inv h4 s h1,\n right,\n from h5\n end\n", "meta": {"author": "levjj", "repo": "esverify-theory", "sha": "8565b123c87b0113f83553d7732cd6696c9b5807", "save_path": "github-repos/lean/levjj-esverify-theory", "path": "github-repos/lean/levjj-esverify-theory/esverify-theory-8565b123c87b0113f83553d7732cd6696c9b5807/src/evaluation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.4301473485858429, "lm_q1q2_score": 0.22682380439722544}} {"text": "/-\nCopyright (c) 2019 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Daniel Selsam, Leonardo de Moura\n\nType class instance synthesizer using tabled resolution.\n-/\nimport Lean.Meta.Basic\nimport Lean.Meta.Instances\nimport Lean.Meta.AbstractMVars\nimport Lean.Meta.WHNF\nimport Lean.Meta.Check\nimport Lean.Util.Profile\n\nnamespace Lean.Meta\n\nregister_builtin_option synthInstance.maxHeartbeats : Nat := {\n defValue := 20000\n descr := \"maximum amount of heartbeats per typeclass resolution problem. A heartbeat is number of (small) memory allocations (in thousands), 0 means no limit\"\n}\n\nregister_builtin_option synthInstance.maxSize : Nat := {\n defValue := 128\n descr := \"maximum number of instances used to construct a solution in the type class instance synthesis procedure\"\n}\n\nregister_builtin_option synthInstance.etaExperiment : Bool := {\n defValue := false\n descr := \"[DO NOT USE EXCEPT FOR TESTING] enable structure eta for type-classes during type-class search\"\n}\n\nnamespace SynthInstance\n\ndef getMaxHeartbeats (opts : Options) : Nat :=\n synthInstance.maxHeartbeats.get opts * 1000\n\nbuiltin_initialize inferTCGoalsRLAttr : TagAttribute ←\n registerTagAttribute `infer_tc_goals_rl \"instruct type class resolution procedure to solve goals from right to left for this instance\"\n\ndef hasInferTCGoalsRLAttribute (env : Environment) (constName : Name) : Bool :=\n inferTCGoalsRLAttr.hasTag env constName\n\nstructure GeneratorNode where\n mvar : Expr\n key : Expr\n mctx : MetavarContext\n instances : Array Expr\n currInstanceIdx : Nat\n deriving Inhabited\n\nstructure ConsumerNode where\n mvar : Expr\n key : Expr\n mctx : MetavarContext\n subgoals : List Expr\n size : Nat -- instance size so far\n deriving Inhabited\n\ninductive Waiter where\n | consumerNode : ConsumerNode → Waiter\n | root : Waiter\n\ndef Waiter.isRoot : Waiter → Bool\n | Waiter.consumerNode _ => false\n | Waiter.root => true\n\n/-!\n In tabled resolution, we creating a mapping from goals (e.g., `Coe Nat ?x`) to\n answers and waiters. Waiters are consumer nodes that are waiting for answers for a\n particular node.\n\n We implement this mapping using a `HashMap` where the keys are\n normalized expressions. That is, we replace assignable metavariables\n with auxiliary free variables of the form `_tc.`. We do\n not declare these free variables in any local context, and we should\n view them as \"normalized names\" for metavariables. For example, the\n term `f ?m ?m ?n` is normalized as\n `f _tc.0 _tc.0 _tc.1`.\n\n This approach is structural, and we may visit the same goal more\n than once if the different occurrences are just definitionally\n equal, but not structurally equal.\n\n Remark: a metavariable is assignable only if its depth is equal to\n the metavar context depth.\n-/\nnamespace MkTableKey\n\nstructure State where\n nextIdx : Nat := 0\n lmap : HashMap LMVarId Level := {}\n emap : HashMap MVarId Expr := {}\n mctx : MetavarContext\n\nabbrev M := StateM State\n\n@[always_inline]\ninstance : MonadMCtx M where\n getMCtx := return (← get).mctx\n modifyMCtx f := modify fun s => { s with mctx := f s.mctx }\n\npartial def normLevel (u : Level) : M Level := do\n if !u.hasMVar then\n return u\n else match u with\n | Level.succ v => return u.updateSucc! (← normLevel v)\n | Level.max v w => return u.updateMax! (← normLevel v) (← normLevel w)\n | Level.imax v w => return u.updateIMax! (← normLevel v) (← normLevel w)\n | Level.mvar mvarId =>\n if (← getMCtx).getLevelDepth mvarId != (← getMCtx).depth then\n return u\n else\n let s ← get\n match (← get).lmap.find? mvarId with\n | some u' => pure u'\n | none =>\n let u' := mkLevelParam <| Name.mkNum `_tc s.nextIdx\n modify fun s => { s with nextIdx := s.nextIdx + 1, lmap := s.lmap.insert mvarId u' }\n return u'\n | u => return u\n\npartial def normExpr (e : Expr) : M Expr := do\n if !e.hasMVar then\n pure e\n else match e with\n | Expr.const _ us => return e.updateConst! (← us.mapM normLevel)\n | Expr.sort u => return e.updateSort! (← normLevel u)\n | Expr.app f a => return e.updateApp! (← normExpr f) (← normExpr a)\n | Expr.letE _ t v b _ => return e.updateLet! (← normExpr t) (← normExpr v) (← normExpr b)\n | Expr.forallE _ d b _ => return e.updateForallE! (← normExpr d) (← normExpr b)\n | Expr.lam _ d b _ => return e.updateLambdaE! (← normExpr d) (← normExpr b)\n | Expr.mdata _ b => return e.updateMData! (← normExpr b)\n | Expr.proj _ _ b => return e.updateProj! (← normExpr b)\n | Expr.mvar mvarId =>\n if !(← mvarId.isAssignable) then\n return e\n else\n let s ← get\n match s.emap.find? mvarId with\n | some e' => pure e'\n | none => do\n let e' := mkFVar { name := Name.mkNum `_tc s.nextIdx }\n modify fun s => { s with nextIdx := s.nextIdx + 1, emap := s.emap.insert mvarId e' }\n return e'\n | _ => return e\n\nend MkTableKey\n\n/-- Remark: `mkTableKey` assumes `e` does not contain assigned metavariables. -/\ndef mkTableKey [Monad m] [MonadMCtx m] (e : Expr) : m Expr := do\n let (r, s) := MkTableKey.normExpr e |>.run { mctx := (← getMCtx) }\n setMCtx s.mctx\n return r\n\nstructure Answer where\n result : AbstractMVarsResult\n resultType : Expr\n size : Nat\n deriving Inhabited\n\nstructure TableEntry where\n waiters : Array Waiter\n answers : Array Answer := #[]\n\nstructure Context where\n maxResultSize : Nat\n maxHeartbeats : Nat\n\n/--\n Remark: the SynthInstance.State is not really an extension of `Meta.State`.\n The field `postponed` is not needed, and the field `mctx` is misleading since\n `synthInstance` methods operate over different `MetavarContext`s simultaneously.\n That being said, we still use `extends` because it makes it simpler to move from\n `M` to `MetaM`.\n-/\nstructure State where\n result? : Option AbstractMVarsResult := none\n generatorStack : Array GeneratorNode := #[]\n resumeStack : Array (ConsumerNode × Answer) := #[]\n tableEntries : HashMap Expr TableEntry := {}\n\nabbrev SynthM := ReaderT Context $ StateRefT State MetaM\n\ndef checkMaxHeartbeats : SynthM Unit := do\n Core.checkMaxHeartbeatsCore \"typeclass\" `synthInstance.maxHeartbeats (← read).maxHeartbeats\n\n@[inline] def mapMetaM (f : forall {α}, MetaM α → MetaM α) {α} : SynthM α → SynthM α :=\n monadMap @f\n\ninstance : Inhabited (SynthM α) where\n default := fun _ _ => default\n\n/-- Return globals and locals instances that may unify with `type` -/\ndef getInstances (type : Expr) : MetaM (Array Expr) := do\n -- We must retrieve `localInstances` before we use `forallTelescopeReducing` because it will update the set of local instances\n let localInstances ← getLocalInstances\n forallTelescopeReducing type fun _ type => do\n let className? ← isClass? type\n match className? with\n | none => throwError \"type class instance expected{indentExpr type}\"\n | some className =>\n let globalInstances ← getGlobalInstancesIndex\n let result ← globalInstances.getUnify type\n -- Using insertion sort because it is stable and the array `result` should be mostly sorted.\n -- Most instances have default priority.\n let result := result.insertionSort fun e₁ e₂ => e₁.priority < e₂.priority\n let erasedInstances ← getErasedInstances\n let result ← result.filterMapM fun e => match e.val with\n | Expr.const constName us =>\n if erasedInstances.contains constName then\n return none\n else\n return some <| e.val.updateConst! (← us.mapM (fun _ => mkFreshLevelMVar))\n | _ => panic! \"global instance is not a constant\"\n let result := localInstances.foldl (init := result) fun (result : Array Expr) linst =>\n if linst.className == className then result.push linst.fvar else result\n trace[Meta.synthInstance.instances] result\n return result\n\ndef mkGeneratorNode? (key mvar : Expr) : MetaM (Option GeneratorNode) := do\n let mvarType ← inferType mvar\n let mvarType ← instantiateMVars mvarType\n let instances ← getInstances mvarType\n if instances.isEmpty then\n return none\n else\n let mctx ← getMCtx\n return some {\n mvar, key, mctx, instances\n currInstanceIdx := instances.size\n }\n\n/--\n Create a new generator node for `mvar` and add `waiter` as its waiter.\n `key` must be `mkTableKey mctx mvarType`. -/\ndef newSubgoal (mctx : MetavarContext) (key : Expr) (mvar : Expr) (waiter : Waiter) : SynthM Unit :=\n withMCtx mctx do withTraceNode' `Meta.synthInstance do\n match (← mkGeneratorNode? key mvar) with\n | none => pure ((), m!\"no instances for {key}\")\n | some node =>\n let entry : TableEntry := { waiters := #[waiter] }\n modify fun s =>\n { s with\n generatorStack := s.generatorStack.push node\n tableEntries := s.tableEntries.insert key entry }\n pure ((), m!\"new goal {key}\")\n\ndef findEntry? (key : Expr) : SynthM (Option TableEntry) := do\n return (← get).tableEntries.find? key\n\ndef getEntry (key : Expr) : SynthM TableEntry := do\n match (← findEntry? key) with\n | none => panic! \"invalid key at synthInstance\"\n | some entry => pure entry\n\n/--\n Create a `key` for the goal associated with the given metavariable.\n That is, we create a key for the type of the metavariable.\n\n We must instantiate assigned metavariables before we invoke `mkTableKey`. -/\ndef mkTableKeyFor (mctx : MetavarContext) (mvar : Expr) : SynthM Expr :=\n withMCtx mctx do\n let mvarType ← inferType mvar\n let mvarType ← instantiateMVars mvarType\n mkTableKey mvarType\n\n/-- See `getSubgoals` and `getSubgoalsAux`\n\n We use the parameter `j` to reduce the number of `instantiate*` invocations.\n It is the same approach we use at `forallTelescope` and `lambdaTelescope`.\n Given `getSubgoalsAux args j subgoals instVal type`,\n we have that `type.instantiateRevRange j args.size args` does not have loose bound variables. -/\nstructure SubgoalsResult where\n subgoals : List Expr\n instVal : Expr\n instTypeBody : Expr\n\nprivate partial def getSubgoalsAux (lctx : LocalContext) (localInsts : LocalInstances) (xs : Array Expr)\n : Array Expr → Nat → List Expr → Expr → Expr → MetaM SubgoalsResult\n | args, j, subgoals, instVal, Expr.forallE _ d b bi => do\n let d := d.instantiateRevRange j args.size args\n let mvarType ← mkForallFVars xs d\n let mvar ← mkFreshExprMVarAt lctx localInsts mvarType\n let arg := mkAppN mvar xs\n let instVal := mkApp instVal arg\n let subgoals := if bi.isInstImplicit then mvar::subgoals else subgoals\n let args := args.push (mkAppN mvar xs)\n getSubgoalsAux lctx localInsts xs args j subgoals instVal b\n | args, j, subgoals, instVal, type => do\n let type := type.instantiateRevRange j args.size args\n let type ← whnf type\n if type.isForall then\n getSubgoalsAux lctx localInsts xs args args.size subgoals instVal type\n else\n return ⟨subgoals, instVal, type⟩\n\n/--\n `getSubgoals lctx localInsts xs inst` creates the subgoals for the instance `inst`.\n The subgoals are in the context of the free variables `xs`, and\n `(lctx, localInsts)` is the local context and instances before we added the free variables to it.\n\n This extra complication is required because\n 1- We want all metavariables created by `synthInstance` to share the same local context.\n 2- We want to ensure that applications such as `mvar xs` are higher order patterns.\n\n The method `getGoals` create a new metavariable for each parameter of `inst`.\n For example, suppose the type of `inst` is `forall (x_1 : A_1) ... (x_n : A_n), B x_1 ... x_n`.\n Then, we create the metavariables `?m_i : forall xs, A_i`, and return the subset of these\n metavariables that are instance implicit arguments, and the expressions:\n - `inst (?m_1 xs) ... (?m_n xs)` (aka `instVal`)\n - `B (?m_1 xs) ... (?m_n xs)` -/\ndef getSubgoals (lctx : LocalContext) (localInsts : LocalInstances) (xs : Array Expr) (inst : Expr) : MetaM SubgoalsResult := do\n let instType ← inferType inst\n let result ← getSubgoalsAux lctx localInsts xs #[] 0 [] inst instType\n if let .const constName _ := inst.getAppFn then\n let env ← getEnv\n if hasInferTCGoalsRLAttribute env constName then\n return result\n return { result with subgoals := result.subgoals.reverse }\n\n/--\n Try to synthesize metavariable `mvar` using the instance `inst`.\n Remark: `mctx` is set using `withMCtx`.\n If it succeeds, the result is a new updated metavariable context and a new list of subgoals.\n A subgoal is created for each instance implicit parameter of `inst`. -/\ndef tryResolve (mvar : Expr) (inst : Expr) : MetaM (Option (MetavarContext × List Expr)) := do\n let mvarType ← inferType mvar\n let lctx ← getLCtx\n let localInsts ← getLocalInstances\n forallTelescopeReducing mvarType fun xs mvarTypeBody => do\n let ⟨subgoals, instVal, instTypeBody⟩ ← getSubgoals lctx localInsts xs inst\n withTraceNode `Meta.synthInstance.tryResolve (withMCtx (← getMCtx) do\n return m!\"{exceptOptionEmoji ·} {← instantiateMVars mvarTypeBody} ≟ {← instantiateMVars instTypeBody}\") do\n if (← isDefEq mvarTypeBody instTypeBody) then\n let instVal ← mkLambdaFVars xs instVal\n if (← isDefEq mvar instVal) then\n return some ((← getMCtx), subgoals)\n return none\n\n/--\n Assign a precomputed answer to `mvar`.\n If it succeeds, the result is a new updated metavariable context and a new list of subgoals. -/\ndef tryAnswer (mctx : MetavarContext) (mvar : Expr) (answer : Answer) : SynthM (Option MetavarContext) :=\n withMCtx mctx do\n let (_, _, val) ← openAbstractMVarsResult answer.result\n if (← isDefEq mvar val) then\n return some (← getMCtx)\n else\n return none\n\n/-- Move waiters that are waiting for the given answer to the resume stack. -/\ndef wakeUp (answer : Answer) : Waiter → SynthM Unit\n | Waiter.root => do\n /- Recall that we now use `ignoreLevelMVarDepth := true`. Thus, we should allow solutions\n containing universe metavariables, and not check `answer.result.paramNames.isEmpty`.\n We use `openAbstractMVarsResult` to construct the universe metavariables\n at the correct depth. -/\n if answer.result.numMVars == 0 then\n modify fun s => { s with result? := answer.result }\n else\n let (_, _, answerExpr) ← openAbstractMVarsResult answer.result\n trace[Meta.synthInstance] \"skip answer containing metavariables {answerExpr}\"\n | Waiter.consumerNode cNode =>\n modify fun s => { s with resumeStack := s.resumeStack.push (cNode, answer) }\n\ndef isNewAnswer (oldAnswers : Array Answer) (answer : Answer) : Bool :=\n oldAnswers.all fun oldAnswer =>\n -- Remark: isDefEq here is too expensive. TODO: if `==` is too imprecise, add some light normalization to `resultType` at `addAnswer`\n -- iseq ← isDefEq oldAnswer.resultType answer.resultType; pure (!iseq)\n oldAnswer.resultType != answer.resultType\n\nprivate def mkAnswer (cNode : ConsumerNode) : MetaM Answer :=\n withMCtx cNode.mctx do\n let val ← instantiateMVars cNode.mvar\n trace[Meta.synthInstance.newAnswer] \"size: {cNode.size}, val: {val}\"\n let result ← abstractMVars val -- assignable metavariables become parameters\n let resultType ← inferType result.expr\n return { result, resultType, size := cNode.size + 1 }\n\n/--\n Create a new answer after `cNode` resolved all subgoals.\n That is, `cNode.subgoals == []`.\n And then, store it in the tabled entries map, and wakeup waiters. -/\ndef addAnswer (cNode : ConsumerNode) : SynthM Unit := do\n withMCtx cNode.mctx do\n if cNode.size ≥ (← read).maxResultSize then\n trace[Meta.synthInstance.answer] \"{crossEmoji} {← instantiateMVars (← inferType cNode.mvar)}{Format.line}(size: {cNode.size} ≥ {(← read).maxResultSize})\"\n else\n withTraceNode `Meta.synthInstance.answer\n (fun _ => return m!\"{checkEmoji} {← instantiateMVars (← inferType cNode.mvar)}\") do\n let answer ← mkAnswer cNode\n -- Remark: `answer` does not contain assignable or assigned metavariables.\n let key := cNode.key\n let entry ← getEntry key\n if isNewAnswer entry.answers answer then\n let newEntry := { entry with answers := entry.answers.push answer }\n modify fun s => { s with tableEntries := s.tableEntries.insert key newEntry }\n entry.waiters.forM (wakeUp answer)\n\n/--\n Return `true` if a type of the form `(a_1 : A_1) → ... → (a_n : A_n) → B` has an unused argument `a_i`.\n\n Remark: This is syntactic check and no reduction is performed.\n-/\nprivate def hasUnusedArguments : Expr → Bool\n | Expr.forallE _ _ b _ => !b.hasLooseBVar 0 || hasUnusedArguments b\n | _ => false\n\n/--\n If the type of the metavariable `mvar` has unused argument, return a pair `(α, transformer)`\n where `α` is a new type without the unused arguments and the `transformer` is a function for coverting a\n solution with type `α` into a value that can be assigned to `mvar`.\n Example: suppose `mvar` has type `(a : A) → (b : B a) → (c : C a) → D a c`, the result is the pair\n ```\n ((a : A) → (c : C a) → D a c,\n fun (f : (a : A) → (c : C a) → D a c) (a : A) (b : B a) (c : C a) => f a c\n )\n ```\n\n This method is used to improve the effectiveness of the TC resolution procedure. It was suggested and prototyped by\n Tomas Skrivan. It improves the support for instances of type `a : A → C` where `a` does not appear in class `C`.\n When we look for such an instance it is enough to look for an instance `c : C` and then return `fun _ => c`.\n\n Tomas' approach makes sure that instance of a type like `a : A → C` never gets tabled/cached. More on that later.\n At the core is this method. it takes an expression E and does two things:\n\n The modification to TC resolution works this way: We are looking for an instance of `E`, if it is tabled\n just get it as normal, but if not first remove all unused arguments producing `E'`. Now we look up the table again but\n for `E'`. If it exists, use the transformer to create E. If it does not exists, create a new goal `E'`.\n-/\nprivate def removeUnusedArguments? (mctx : MetavarContext) (mvar : Expr) : MetaM (Option (Expr × Expr)) :=\n withMCtx mctx do\n let mvarType ← instantiateMVars (← inferType mvar)\n if !hasUnusedArguments mvarType then\n return none\n else\n forallTelescope mvarType fun xs body => do\n let ys ← xs.foldrM (init := []) fun x ys => do\n if body.containsFVar x.fvarId! then\n return x :: ys\n else if (← ys.anyM fun y => return (← inferType y).containsFVar x.fvarId!) then\n return x :: ys\n else\n return ys\n let ys := ys.toArray\n let mvarType' ← mkForallFVars ys body\n withLocalDeclD `redf mvarType' fun f => do\n let transformer ← mkLambdaFVars #[f] (← mkLambdaFVars xs (mkAppN f ys))\n trace[Meta.synthInstance.unusedArgs] \"{mvarType}\\nhas unused arguments, reduced type{indentExpr mvarType'}\\nTransformer{indentExpr transformer}\"\n return some (mvarType', transformer)\n\n/-- Process the next subgoal in the given consumer node. -/\ndef consume (cNode : ConsumerNode) : SynthM Unit := do\n /- Filter out subgoals that have already been assigned when solving typing constraints.\n This may happen when a local instance type depends on other local instances.\n For example, in Mathlib, we have\n ```\n @Submodule.setLike : {R : Type u_1} → {M : Type u_2} →\n [_inst_1 : Semiring R] →\n [_inst_2 : AddCommMonoid M] →\n [_inst_3 : @ModuleS R M _inst_1 _inst_2] →\n SetLike (@Submodule R M _inst_1 _inst_2 _inst_3) M\n ```\n -/\n let cNode := { cNode with\n subgoals := ← withMCtx cNode.mctx do\n cNode.subgoals.filterM (not <$> ·.mvarId!.isAssigned)\n }\n match cNode.subgoals with\n | [] => addAnswer cNode\n | mvar::_ =>\n let waiter := Waiter.consumerNode cNode\n let key ← mkTableKeyFor cNode.mctx mvar\n let entry? ← findEntry? key\n match entry? with\n | none =>\n -- Remove unused arguments and try again, see comment at `removeUnusedArguments?`\n match (← removeUnusedArguments? cNode.mctx mvar) with\n | none => newSubgoal cNode.mctx key mvar waiter\n | some (mvarType', transformer) =>\n let key' ← withMCtx cNode.mctx <| mkTableKey mvarType'\n match (← findEntry? key') with\n | none =>\n let (mctx', mvar') ← withMCtx cNode.mctx do\n let mvar' ← mkFreshExprMVar mvarType'\n return (← getMCtx, mvar')\n newSubgoal mctx' key' mvar' (Waiter.consumerNode { cNode with mctx := mctx', subgoals := mvar'::cNode.subgoals })\n | some entry' =>\n let answers' ← entry'.answers.mapM fun a => withMCtx cNode.mctx do\n let trAnswr := Expr.betaRev transformer #[← instantiateMVars a.result.expr]\n let trAnswrType ← inferType trAnswr\n pure { a with result.expr := trAnswr, resultType := trAnswrType }\n modify fun s =>\n { s with\n resumeStack := answers'.foldl (fun s answer => s.push (cNode, answer)) s.resumeStack,\n tableEntries := s.tableEntries.insert key' { entry' with waiters := entry'.waiters.push waiter } }\n | some entry => modify fun s =>\n { s with\n resumeStack := entry.answers.foldl (fun s answer => s.push (cNode, answer)) s.resumeStack,\n tableEntries := s.tableEntries.insert key { entry with waiters := entry.waiters.push waiter } }\n\ndef getTop : SynthM GeneratorNode :=\n return (← get).generatorStack.back\n\n@[inline] def modifyTop (f : GeneratorNode → GeneratorNode) : SynthM Unit :=\n modify fun s => { s with generatorStack := s.generatorStack.modify (s.generatorStack.size - 1) f }\n\n/-- Try the next instance in the node on the top of the generator stack. -/\ndef generate : SynthM Unit := do\n let gNode ← getTop\n if gNode.currInstanceIdx == 0 then\n modify fun s => { s with generatorStack := s.generatorStack.pop }\n else\n let key := gNode.key\n let idx := gNode.currInstanceIdx - 1\n let inst := gNode.instances.get! idx\n let mctx := gNode.mctx\n let mvar := gNode.mvar\n discard do withMCtx mctx do\n withTraceNode `Meta.synthInstance\n (return m!\"{exceptOptionEmoji ·} apply {inst} to {← instantiateMVars (← inferType mvar)}\") do\n modifyTop fun gNode => { gNode with currInstanceIdx := idx }\n if let some (mctx, subgoals) ← tryResolve mvar inst then\n consume { key, mvar, subgoals, mctx, size := 0 }\n return some ()\n return none\n\ndef getNextToResume : SynthM (ConsumerNode × Answer) := do\n let r := (← get).resumeStack.back\n modify fun s => { s with resumeStack := s.resumeStack.pop }\n return r\n\n/--\n Given `(cNode, answer)` on the top of the resume stack, continue execution by using `answer` to solve the\n next subgoal. -/\ndef resume : SynthM Unit := do\n let (cNode, answer) ← getNextToResume\n match cNode.subgoals with\n | [] => panic! \"resume found no remaining subgoals\"\n | mvar::rest =>\n match (← tryAnswer cNode.mctx mvar answer) with\n | none => return ()\n | some mctx =>\n withMCtx mctx do\n let goal ← inferType cNode.mvar\n let subgoal ← inferType mvar\n withTraceNode `Meta.synthInstance.resume\n (fun _ => withMCtx cNode.mctx do\n return m!\"propagating {← instantiateMVars answer.resultType} to subgoal {← instantiateMVars subgoal} of {← instantiateMVars goal}\") do\n trace[Meta.synthInstance.resume] \"size: {cNode.size + answer.size}\"\n consume { key := cNode.key, mvar := cNode.mvar, subgoals := rest, mctx, size := cNode.size + answer.size }\n\ndef step : SynthM Bool := do\n checkMaxHeartbeats\n let s ← get\n if !s.resumeStack.isEmpty then\n resume\n return true\n else if !s.generatorStack.isEmpty then\n generate\n return true\n else\n return false\n\ndef getResult : SynthM (Option AbstractMVarsResult) :=\n return (← get).result?\n\npartial def synth : SynthM (Option AbstractMVarsResult) := do\n if (← step) then\n match (← getResult) with\n | none => synth\n | some result => return result\n else\n return none\n\ndef main (type : Expr) (maxResultSize : Nat) : MetaM (Option AbstractMVarsResult) :=\n withCurrHeartbeats do\n let mvar ← mkFreshExprMVar type\n let key ← mkTableKey type\n let action : SynthM (Option AbstractMVarsResult) := do\n newSubgoal (← getMCtx) key mvar Waiter.root\n synth\n try\n action.run { maxResultSize := maxResultSize, maxHeartbeats := getMaxHeartbeats (← getOptions) } |>.run' {}\n catch ex =>\n if ex.isMaxHeartbeat then\n throwError \"failed to synthesize{indentExpr type}\\n{ex.toMessageData}\"\n else\n throw ex\n\nend SynthInstance\n\n/-!\nType class parameters can be annotated with `outParam` annotations.\n\nGiven `C a_1 ... a_n`, we replace `a_i` with a fresh metavariable `?m_i` IF\n`a_i` is an `outParam`.\nThe result is type correct because we reject type class declarations IF\nit contains a regular parameter X that depends on an `out` parameter Y.\n\nThen, we execute type class resolution as usual.\nIf it succeeds, and metavariables ?m_i have been assigned, we try to unify\nthe original type `C a_1 ... a_n` witht the normalized one.\n-/\n\nprivate def preprocess (type : Expr) : MetaM Expr :=\n forallTelescopeReducing type fun xs type => do\n let type ← whnf type\n mkForallFVars xs type\n\nprivate def preprocessLevels (us : List Level) : MetaM (List Level × Bool) := do\n let mut r := #[]\n let mut modified := false\n for u in us do\n let u ← instantiateLevelMVars u\n if u.hasMVar then\n r := r.push (← mkFreshLevelMVar)\n modified := true\n else\n r := r.push u\n return (r.toList, modified)\n\nprivate partial def preprocessArgs (type : Expr) (i : Nat) (args : Array Expr) (outParamsPos : Array Nat) : MetaM (Array Expr) := do\n if h : i < args.size then\n let type ← whnf type\n match type with\n | .forallE _ d b _ => do\n let arg := args.get ⟨i, h⟩\n /-\n We should not simply check `d.isOutParam`. See `checkOutParam` and issue #1852.\n If an instance implicit argument depends on an `outParam`, it is treated as an `outParam` too.\n -/\n let arg ← if outParamsPos.contains i then mkFreshExprMVar d else pure arg\n let args := args.set ⟨i, h⟩ arg\n preprocessArgs (b.instantiate1 arg) (i+1) args outParamsPos\n | _ =>\n throwError \"type class resolution failed, insufficient number of arguments\" -- TODO improve error message\n else\n return args\n\nprivate def preprocessOutParam (type : Expr) : MetaM Expr :=\n forallTelescope type fun xs typeBody => do\n match typeBody.getAppFn with\n | c@(Expr.const declName _) =>\n let env ← getEnv\n if let some outParamsPos := getOutParamPositions? env declName then\n unless outParamsPos.isEmpty do\n let args := typeBody.getAppArgs\n let cType ← inferType c\n let args ← preprocessArgs cType 0 args outParamsPos\n return (← mkForallFVars xs (mkAppN c args))\n return type\n | _ =>\n return type\n\n/-!\n Remark: when `maxResultSize? == none`, the configuration option `synthInstance.maxResultSize` is used.\n Remark: we use a different option for controlling the maximum result size for coercions.\n-/\n\ndef synthInstance? (type : Expr) (maxResultSize? : Option Nat := none) : MetaM (Option Expr) := do profileitM Exception \"typeclass inference\" (← getOptions) (decl := type.getAppFn.constName?.getD .anonymous) do\n let opts ← getOptions\n let maxResultSize := maxResultSize?.getD (synthInstance.maxSize.get opts)\n withTraceNode `Meta.synthInstance\n (return m!\"{exceptOptionEmoji ·} {← instantiateMVars type}\") do\n /-\n We disable eta for structures that are not classes during TC resolution because it allows us to find unintended solutions.\n See discussion at\n https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/.60constructor.60.20and.20.60Applicative.60/near/279984801\n -/\n let etaStruct := if synthInstance.etaExperiment.get (← getOptions) then .all else .notClasses\n withConfig (fun config => { config with isDefEqStuckEx := true, transparency := TransparencyMode.instances,\n foApprox := true, ctxApprox := true, constApprox := false,\n etaStruct }) do\n let localInsts ← getLocalInstances\n let type ← instantiateMVars type\n let type ← preprocess type\n let s ← get\n let rec assignOutParams (result : Expr) : MetaM Bool := do\n let resultType ← inferType result\n /- Output parameters of local instances may be marked as `syntheticOpaque` by the application-elaborator.\n We use `withAssignableSyntheticOpaque` to make sure this kind of parameter can be assigned by the following `isDefEq`.\n TODO: rewrite this check to avoid `withAssignableSyntheticOpaque`. -/\n let defEq ← withDefault <| withAssignableSyntheticOpaque <| isDefEq type resultType\n unless defEq do\n trace[Meta.synthInstance] \"{crossEmoji} result type{indentExpr resultType}\\nis not definitionally equal to{indentExpr type}\"\n return defEq\n match s.cache.synthInstance.find? (localInsts, type) with\n | some result =>\n trace[Meta.synthInstance] \"result {result} (cached)\"\n if let some inst := result then\n unless (← assignOutParams inst) do\n return none\n pure result\n | none =>\n let result? ← withNewMCtxDepth (allowLevelAssignments := true) do\n let normType ← preprocessOutParam type\n SynthInstance.main normType maxResultSize\n let result? ← match result? with\n | none => pure none\n | some result => do\n let (_, _, result) ← openAbstractMVarsResult result\n trace[Meta.synthInstance] \"result {result}\"\n if (← assignOutParams result) then\n let result ← instantiateMVars result\n /- We use `check` to propogate universe constraints implied by the `result`.\n Recall that we use `allowLevelAssignments := true` which allows universe metavariables in the current depth to be assigned,\n but these assignments are discarded by `withNewMCtxDepth`.\n\n TODO: If this `check` is a performance bottleneck, we can improve performance by tracking whether\n a universe metavariable from previous universe levels have been assigned or not during TC resolution.\n We only need to perform the `check` if this kind of assignment have been performed.\n\n The example in the issue #796 exposed this issue.\n ```\n structure A\n class B (a : outParam A) (α : Sort u)\n class C {a : A} (α : Sort u) [B a α]\n class D {a : A} (α : Sort u) [B a α] [c : C α]\n class E (a : A) where [c (α : Sort u) [B a α] : C α]\n instance c {a : A} [e : E a] (α : Sort u) [B a α] : C α := e.c α\n\n def d {a : A} [e : E a] (α : Sort u) [b : B a α] : D α := ⟨⟩\n ```\n The term `D α` has two instance implicit arguments. The second one has type `C α`, and TC\n resolution produces the result `@c.{u} a e α b`.\n Note that the `e` has type `E.{?v} a`, and `E` is universe polymorphic,\n but the universe does not occur in the parameter `a`. We have that `?v := u` is implied by `@c.{u} a e α b`,\n but this assignment is lost.\n -/\n check result\n pure (some result)\n else\n pure none\n modify fun s => { s with cache.synthInstance := s.cache.synthInstance.insert (localInsts, type) result? }\n pure result?\n\n/--\n Return `LOption.some r` if succeeded, `LOption.none` if it failed, and `LOption.undef` if\n instance cannot be synthesized right now because `type` contains metavariables. -/\ndef trySynthInstance (type : Expr) (maxResultSize? : Option Nat := none) : MetaM (LOption Expr) := do\n catchInternalId isDefEqStuckExceptionId\n (toLOptionM <| synthInstance? type maxResultSize?)\n (fun _ => pure LOption.undef)\n\ndef synthInstance (type : Expr) (maxResultSize? : Option Nat := none) : MetaM Expr :=\n catchInternalId isDefEqStuckExceptionId\n (do\n let result? ← synthInstance? type maxResultSize?\n match result? with\n | some result => pure result\n | none => throwError \"failed to synthesize{indentExpr type}\")\n (fun _ => throwError \"failed to synthesize{indentExpr type}\")\n\n@[export lean_synth_pending]\nprivate def synthPendingImp (mvarId : MVarId) : MetaM Bool := withIncRecDepth <| mvarId.withContext do\n let mvarDecl ← mvarId.getDecl\n match mvarDecl.kind with\n | MetavarKind.syntheticOpaque =>\n return false\n | _ =>\n /- Check whether the type of the given metavariable is a class or not. If yes, then try to synthesize\n it using type class resolution. We only do it for `synthetic` and `natural` metavariables. -/\n match (← isClass? mvarDecl.type) with\n | none =>\n return false\n | some _ =>\n /- TODO: use a configuration option instead of the hard-coded limit `1`. -/\n if (← read).synthPendingDepth > 1 then\n trace[Meta.synthPending] \"too many nested synthPending invocations\"\n return false\n else\n withReader (fun ctx => { ctx with synthPendingDepth := ctx.synthPendingDepth + 1 }) do\n trace[Meta.synthPending] \"synthPending {mkMVar mvarId}\"\n let val? ← catchInternalId isDefEqStuckExceptionId (synthInstance? mvarDecl.type (maxResultSize? := none)) (fun _ => pure none)\n match val? with\n | none =>\n return false\n | some val =>\n if (← mvarId.isAssigned) then\n return false\n else\n mvarId.assign val\n return true\n\nbuiltin_initialize\n registerTraceClass `Meta.synthPending\n registerTraceClass `Meta.synthInstance\n registerTraceClass `Meta.synthInstance.instances (inherited := true)\n registerTraceClass `Meta.synthInstance.tryResolve (inherited := true)\n registerTraceClass `Meta.synthInstance.resume (inherited := true)\n registerTraceClass `Meta.synthInstance.unusedArgs\n registerTraceClass `Meta.synthInstance.newAnswer\n\nend Lean.Meta\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/src/Lean/Meta/SynthInstance.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.22624518377989256}} {"text": "import category_theory.limits.fubini\n\nopen category_theory\n\nnamespace category_theory.limits\n\nuniverses v u\nvariables {C : Type u} [category.{v} C]\n\nnoncomputable\ndef limit_flip_comp_lim_iso_limit_comp_lim'\n {J : Type*} [category J]\n [has_limits_of_shape J C]\n {K : Type*} [category K]\n [has_limits_of_shape K C]\n (F : J ⥤ K ⥤ C) : limit (F.flip ⋙ lim) ≅ limit (F ⋙ lim) :=\n{ hom := limit.lift (F ⋙ lim) ⟨limit (F.flip ⋙ lim),\n { app := λ j, limit.lift (F.obj j) ⟨limit (F.flip ⋙ lim),\n { app := λ k, limit.π _ k ≫ limit.π _ j,\n naturality' := begin\n intros k1 k2 f,\n dsimp, simp only [category.id_comp, category.assoc],\n rw ← limit.w _ f,\n simp,\n end }⟩,\n naturality' := begin\n intros j1 j2 f,\n ext,\n dsimp,\n simp only [category.id_comp, category.assoc, limit.lift_π, limit.lift_map,\n cones.postcompose_obj_π, nat_trans.comp_app],\n rw ← limit.w _ f,\n refl,\n end }⟩,\n inv := limit.lift (F.flip ⋙ lim) ⟨limit (F ⋙ lim),\n { app := λ k, limit.lift (F.flip.obj k) ⟨limit (F ⋙ lim),\n { app := λ j, limit.π _ j ≫ limit.π _ k,\n naturality' := begin\n intros j1 j2 f,\n dsimp, simp only [category.id_comp, category.assoc],\n rw ← limit.w _ f,\n simp,\n end }⟩,\n naturality' := begin\n intros k1 k2 f,\n ext,\n dsimp,\n simp only [category.id_comp, category.assoc, limit.lift_π, limit.lift_map,\n cones.postcompose_obj_π, nat_trans.comp_app],\n rw ← limit.w _ f,\n refl,\n end }⟩,\n hom_inv_id' := begin\n ext, dsimp, simp,\n end,\n inv_hom_id' := begin\n ext, dsimp, simp,\n end }\n\n.\n\n@[simp, reassoc]\nlemma limit_flip_comp_lim_iso_limit_comp_lim'_hom_π_π {J : Type*} [category J]\n [has_limits_of_shape J C]\n {K : Type*} [category K]\n [has_limits_of_shape K C]\n (F : J ⥤ K ⥤ C) (j) (k) :\n (limit_flip_comp_lim_iso_limit_comp_lim' F).hom ≫ limit.π _ j ≫ limit.π _ k =\n limit.π _ k ≫ limit.π _ j :=\nbegin\n dsimp [limit_flip_comp_lim_iso_limit_comp_lim'],\n simp,\nend\n\n@[simp, reassoc]\nlemma limit_flip_comp_lim_iso_limit_comp_lim'_inv_π_π {J : Type*} [category J]\n [has_limits_of_shape J C]\n {K : Type*} [category K]\n [has_limits_of_shape K C]\n (F : J ⥤ K ⥤ C) (j) (k) :\n (limit_flip_comp_lim_iso_limit_comp_lim' F).inv ≫ limit.π _ j ≫ limit.π _ k =\n limit.π _ k ≫ limit.π _ j :=\nbegin\n dsimp [limit_flip_comp_lim_iso_limit_comp_lim'],\n simp,\nend\n\nend category_theory.limits\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/limit_flip_comp_iso.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.4225046348141882, "lm_q1q2_score": 0.2260815661765325}} {"text": "import category_theory.lifting_properties.basic\nimport category_theory.over\n\nnamespace category_theory\n\nopen category\n\nvariables {C : Type*} [category C] {M : C} {A B X Y : under M}\n {i : A ⟶ B} {p : X ⟶ Y} {f : A ⟶ X} {g : B ⟶ Y}\n (sq : comm_sq f i p g)\n\nnamespace comm_sq\n\ndef lift_struct.map {D : Type*} [category D] (F : C ⥤ D)\n {A B X Y : C} {i : A ⟶ B} {p : X ⟶ Y} {f : A ⟶ X} {g : B ⟶ Y}\n {sq : comm_sq f i p g} (l : sq.lift_struct) : (F.map_comm_sq sq).lift_struct :=\n{ l := F.map l.l,\n fac_left' := by { rw [← F.map_comp, l.fac_left], },\n fac_right' := by { rw [← F.map_comp, l.fac_right], }, }\n\nvariable (sq)\n\ndef under_forget_equiv_lift_struct :\n sq.lift_struct ≃ ((under.forget M).map_comm_sq sq).lift_struct :=\n{ to_fun := lift_struct.map (under.forget M),\n inv_fun := λ l,\n { l := structured_arrow.hom_mk l.l begin\n simp only [functor.id_map],\n have w₁ := f.w,\n have w₂ := i.w,\n dsimp at w₁ w₂,\n rw [id_comp] at w₁ w₂,\n have h := l.fac_left,\n dsimp at h,\n rw [w₂, assoc, h, w₁],\n end,\n fac_left' := by { ext, exact l.fac_left, },\n fac_right' := by { ext, exact l.fac_right, }, },\n left_inv := by tidy,\n right_inv := by tidy, }\n\nlemma under_sq_has_lift_iff :\n sq.has_lift ↔ ((under.forget M).map_comm_sq sq).has_lift :=\nby simpa only [comm_sq.has_lift.iff] using nonempty.congr\n (under_forget_equiv_lift_struct sq).to_fun (under_forget_equiv_lift_struct sq).inv_fun\n\nend comm_sq\n\nvariables (i p)\n\ninstance has_lifting_property_under\n [has_lifting_property ((under.forget M).map i) ((under.forget M).map p)] :\n has_lifting_property i p :=\n⟨λ f g sq, by { rw comm_sq.under_sq_has_lift_iff, apply_instance, }⟩\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/lifting_properties/over.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.44167300566462553, "lm_q1q2_score": 0.22601141084818577}} {"text": "import ReactorModel.Objects.Reactor.Updatable\n\nopen Classical\n\nnamespace Reactor\n\nprotected inductive Core \n | mk \n (ports : Kind → ID ⇀ Value)\n (acts : ID ⇀ Action)\n (state : ID ⇀ Value)\n (rcns : ID ⇀ Reaction)\n (nest : ID → Option Reactor.Core)\n\nnamespace Core\n\ninstance reactorType : ReactorType Reactor.Core where\n ports | mk p _ _ _ _ => p\n acts | mk _ a _ _ _ => a\n state | mk _ _ s _ _ => s \n rcns | mk _ _ _ r _ => r\n nest | mk _ _ _ _ n => n\n\ninstance : ReactorType.Extensional Reactor.Core where\n ext_iff := by intro (mk ..) (mk ..); open ReactorType in simp [ports, state, rcns, acts, nest]\n\ninstance : ReactorType.WellFounded Reactor.Core where\n wf := by\n constructor\n apply Reactor.Core.rec \n (motive_1 := fun rtr => Acc ReactorType.Nested rtr) \n (motive_2 := fun | none => True | some rtr => Acc ReactorType.Nested rtr)\n all_goals simp\n intro _ _ _ _ _ hi\n constructor\n intro n ⟨i, hn⟩\n simp [ReactorType.nest] at hn \n have := hn ▸ hi i\n simp_all\n \nnoncomputable section Update\nopen ReactorType\n\nabbrev «with» \n (rtr : Reactor.Core) (ports : Kind → ID ⇀ Value := ports rtr) (acts : ID ⇀ Action := acts rtr) \n (state : ID ⇀ Value := state rtr) (rcns : ID ⇀ Reaction := rcns rtr) \n (nest : ID ⇀ Reactor.Core := nest rtr) :=\n Reactor.Core.mk ports acts state rcns nest\n\ndef insert [inst : ReactorType Reactor.Core] \n (rtr : Reactor.Core) (cpt : Component) (i : ID) (v : inst.cptType cpt) :=\n match cpt with\n | .prt k => rtr.with (ports := Function.update (ports rtr) k $ ports rtr k |>.insert i v)\n | .act => rtr.with (acts := acts rtr |>.insert i v)\n | .stv => rtr.with (state := state rtr |>.insert i v)\n | .rcn => rtr.with (rcns := rcns rtr |>.insert i v)\n | .rtr => rtr.with (nest := nest rtr |>.insert i v)\n\ntheorem insert_cpt?_eq_self {rtr : Reactor.Core} (cpt) {i v} : \n cpt? cpt (rtr.insert cpt i v) i = v := by\n cases cpt <;> try cases ‹Component.Valued› \n all_goals\n simp [insert, cpt?, reactorType]\n apply Partial.insert_same\n\ntheorem insert_cpt?_ne_cpt_or_id {rtr : Reactor.Core} (h : c ≠ cpt ∨ j ≠ i) :\n cpt? c rtr j = cpt? c (rtr.insert cpt i v) j := by\n cases cpt <;> try cases ‹Component.Valued› <;> try cases ‹Kind›\n all_goals cases c <;> try cases ‹Component.Valued› <;> try cases ‹Kind›\n all_goals \n simp [cpt?, insert]\n try simp [reactorType]; done\n all_goals\n cases h\n case inl h => contradiction\n case inr h => exact Partial.insert_ne _ h |>.symm\n\ndef updateMem {rtr : Reactor.Core} {cpt : Component.Valued} (f : cpt.type → cpt.type) : \n Member cpt i rtr → Reactor.Core\n | .final h => rtr.insert cpt i $ f (Partial.mem_iff.mp h).choose\n | .nest (j := j) _ l => rtr.insert .rtr j (updateMem f l)\n\ntheorem updateMem_lawfulMemUpdate \n {cpt : Component.Valued} (l : Member cpt i rtr) \n (f : cpt.type → cpt.type) : LawfulMemUpdate cpt i f rtr (updateMem f l) := by\n induction l <;> simp [updateMem] \n case final h =>\n replace h := Partial.mem_iff.mp h\n exact .final insert_cpt?_ne_cpt_or_id h.choose_spec (insert_cpt?_eq_self cpt)\n case nest h l hi =>\n exact .nest insert_cpt?_ne_cpt_or_id h (insert_cpt?_eq_self .rtr) hi\n\ndef update (rtr : Reactor.Core) (cpt : Component.Valued) (i : ID) (f : cpt.type → cpt.type) :=\n if l : Nonempty (Member cpt i rtr) then updateMem f l.some else rtr\n\ninstance : ReactorType.LawfulUpdatable Reactor.Core where\n update := update\n lawful rtr cpt i f := \n if h : Nonempty (Member (Component.val cpt) i rtr) \n then .update $ by simp [update, h]; exact updateMem_lawfulMemUpdate h.some f\n else .notMem (not_nonempty_iff.mp h) $ by simp [update, h]\n\nend Update\nend Core\nend Reactor", "meta": {"author": "marcusrossel", "repo": "reactor-model", "sha": "f82fffb489b4352a0cc6bee964d44a142fee18ce", "save_path": "github-repos/lean/marcusrossel-reactor-model", "path": "github-repos/lean/marcusrossel-reactor-model/reactor-model-f82fffb489b4352a0cc6bee964d44a142fee18ce/src/ReactorModel/Objects/Reactor/Instances/Core.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.585101139733739, "lm_q2_score": 0.3849121444839335, "lm_q1q2_score": 0.22521253443490713}} {"text": "import vc0.basic\n\nnamespace c0\n\nopen ast ast.gdecl\n\ntheorem start_ok (Γ : ast) (ok : Γ.ok) : ∀ s, start Γ s → state.ok Γ s\n| _ (@start.mk _ s h) := begin\n rcases get_body_ok' ok.ind h with ⟨h₁, h₂|⟨⟨⟩⟩⟩,\n rcases ok.ok_init h with ⟨δ, h₃⟩,\n exact state.ok.stmt (some type.int) env.ok.empty vtype.of_ty.int h₁ h₃ (or.inl h₂)\nend\n\nnamespace value\n\ntheorem default.ok {Γ : ast} {ts v} (Γok : Γ.ok)\n (h : default Γ ts v) (E) : ok_type_or_sdef Γ E v ts :=\nbegin\n induction h,\n { exact ⟨_, vtype.of_ty.int, ok.int⟩ },\n { exact ⟨_, vtype.of_ty.bool, ok.bool⟩ },\n { exact ⟨_, vtype.of_ty.ref (vtype.of_ty_fn _).2, ok.null⟩ },\n { exact ⟨_, vtype.of_ty.arr (vtype.of_ty_fn _).2, ok.null_arr⟩ },\n { rcases h_ih with ⟨vs, vm, al'⟩,\n refine ⟨_, vtype.of_ty.struct, ok.struct\n (λ sd' τs hd al, value.of_map_ok.2 ⟨_, rfl, _⟩) vm⟩,\n cases get_sdef_determ Γok.ind h_a hd,\n refine list.forall₂.mp_trans _ al'.flip al,\n rintro _ _ _ ⟨i, v, t, τ, tτ, vok⟩ ⟨_, _, τ', tτ'⟩,\n cases vtype.of_ty_determ tτ tτ',\n exact ⟨vok⟩ },\n { exact ⟨∅, rfl, list.forall₂.nil⟩ },\n case c0.value.default.cons : Δ x τ h v vs h₁ h₂ IH₁ IH₂ {\n rcases IH₁ with ⟨τ', tτ₁, vok⟩,\n rcases IH₂ with ⟨τs', rfl, al⟩,\n exact ⟨_, (of_map_cons (mt al.mem_iff.2 h)).symm,\n alist.forall₂_cons.2 ⟨⟨_, tτ₁, vok⟩, al⟩⟩ },\nend\n\ntheorem default.ok' {Γ : ast} {t τ v} (ok : Γ.ok)\n (h : default Γ (sum.inl t) v) (E)\n (tτ : vtype.of_ty (exp.type.reg t) τ) : value.ok Γ E v τ :=\nlet ⟨τ', h₁, h₂⟩ := h.ok ok E in vtype.of_ty_determ h₁ tτ ▸ h₂\n\ntheorem ok.repeat {Γ E v τ} (h : value.ok Γ E v τ) :\n ∀ {n}, value.ok Γ E (value.repeat v n) (vtype.arr' τ n)\n| 0 := value.ok.nil\n| (n+1) := value.ok.cons h ok.repeat\n\nend value\n\nnamespace addr\n\ntheorem update.ok {Γ E Δ H σ η} (ok : ast.okind Γ)\n (σok : vars_ty.ok Δ σ)\n (Hok : heap.ok Γ H E) (ηok : vars.ok Γ E η σ)\n {R a H' η' τ} (aok : addr.ok Γ E σ a τ)\n (h : update H η R a H' η')\n (Rok : ∀ x, value.ok Γ E x τ → ∀ y, R x y → value.ok Γ E y τ) :\n heap.ok Γ H' E ∧ vars.ok Γ E η' σ :=\nbegin\n induction h generalizing τ,\n case c0.addr.update.ref : R n H' {\n rcases aok with ⟨_, _, m⟩,\n suffices : ∀ E', list.forall₂ (value.ok Γ E) H E' → τ ∈ list.nth E' n →\n list.forall₂ (value.ok Γ E) H' E', from ⟨this _ Hok m, ηok⟩,\n clear Hok m,\n induction h_a with v v' vs r n v' H H' h IH;\n intros E' Hok m; cases Hok with _ τ' _ E' v'ok vsok,\n { cases m,\n exact list.forall₂.cons (Rok _ v'ok _ r) vsok },\n { exact list.forall₂.cons v'ok (IH _ vsok m) } },\n case c0.addr.update.var : R i v v' e mη r {\n refine ⟨Hok, λ j τ' τσ, _⟩, subst e,\n rcases ηok _ _ τσ with ⟨x, xη, xok⟩,\n rcases aok with _|⟨_, _, mσ⟩,\n revert η, refine λ η, finmap.induction_on η (λ η, _), intros,\n have := alist.replace_forall₂ i v' η,\n rcases this.rel_of_lookup_right xη with ⟨v', m', h⟩,\n refine ⟨v', m', _⟩,\n cases h,\n { cases option.mem_unique mη xη,\n cases option.mem_unique mσ τσ,\n exact Rok _ xok _ r },\n { exact xok } },\n case c0.addr.update.head : R a H' η' h IH {\n rcases aok with _|_|⟨_, _, τs, aok⟩,\n exact IH aok (at_head.ok Rok) },\n case c0.addr.update.tail : R a H' η' h IH {\n rcases aok with _|_|_|⟨_, τ₁, _, aok⟩,\n exact IH aok (at_tail.ok Rok) },\n case c0.addr.update.nth : R a i H' η' h IH {\n rcases aok with _|_|_|_|⟨_, τ₁, _, aok⟩,\n exact IH aok_a_2 (at_nth.ok Rok aok_a_1) },\n case c0.addr.update.field : R a f H' η' h IH {\n rcases aok with _|_|_|_|⟨_, τ₁, _, aok⟩,\n exact IH aok_a_4 (at_field.ok ok Rok aok_a_1 aok_a_2 aok_a_3) },\nend\n\nend addr\n\ntheorem assign.ok {Γ E Δ σ η x v t τ}\n (σok : vars_ty.ok Δ σ) (ηok : vars.ok Γ E η σ)\n (xok : t ∈ Δ.lookup x)\n (tτ : vtype.of_ty (exp.type.reg t) τ)\n (vok : value.ok Γ E v τ) :\n∃ σ', vars_ty.ok Δ σ' ∧\n σ'.keys = insert x σ.keys ∧\n vars.ok Γ E (vars.assign η x v) σ' :=\nbegin\n by_cases xσ : x ∈ σ,\n { refine ⟨σ, σok, (finset.insert_eq_of_mem (finmap.mem_keys.2 xσ)).symm, _⟩,\n rw [vars.assign, if_pos (ηok.mem xσ)],\n intros y τ' hy,\n by_cases x = y,\n { subst y,\n rcases σok _ _ hy with ⟨t', h₁, h₂⟩,\n cases option.mem_unique xok h₁,\n cases vtype.of_ty_determ tτ h₂,\n exact ⟨v, finmap.lookup_replace_self (ηok.mem xσ), vok⟩ },\n { rcases ηok _ _ hy with ⟨v', h₁, h₂⟩,\n refine ⟨v', _, h₂⟩,\n convert h₁ using 1,\n exact finmap.lookup_replace_of_ne h } },\n { refine ⟨σ.insert x τ, λ y τ' hy, _, finmap.keys_insert _ _ _, λ y τ' hy, _⟩;\n rw finmap.lookup_insert_of_neg xσ at hy;\n rcases hy with ⟨⟨⟩⟩ | hy,\n { exact ⟨_, xok, tτ⟩ },\n { exact σok _ _ hy },\n { refine ⟨v, _, vok⟩,\n rw vars.assign, split_ifs,\n { exact finmap.lookup_replace_self h },\n { exact (finmap.lookup_insert_of_neg h).2 (or.inl rfl) } },\n { rcases ηok _ _ hy with ⟨v', h₁, h₂⟩,\n refine ⟨v', _, h₂⟩,\n rw vars.assign, split_ifs,\n { rwa finmap.lookup_replace_of_ne,\n rintro rfl,\n cases xσ (finmap.exists_mem_lookup_iff.1 ⟨_, hy⟩) },\n { exact (finmap.lookup_insert_of_neg h).2 (or.inr h₁) } } }\nend\n\ntheorem value.step_binop.ok {Γ E op t₁ t₂ τ₁ τ₂ v₁ v₂ v}\n (sok : value.step_binop op v₁ v₂ (sum.inl v))\n (opok : binop.ok op t₁ t₂)\n (tτ₁ : vtype.of_ty (exp.type.reg t₁) τ₁)\n (tτ₂ : vtype.of_ty (exp.type.reg t₂) τ₂)\n (vok₁ : value.ok Γ E v₁ τ₁) (vok₂ : value.ok Γ E v₂ τ₁) :\n value.ok Γ E v τ₂ :=\nbegin\n generalize_hyp e : sum.inl v = o at sok,\n generalize_hyp e' : op = o' at opok,\n induction sok; cases opok; cases e'; try {injection e, subst v};\n cases tτ₁; cases tτ₂; try {constructor},\n all_goals {\n rcases (⟨_, e⟩ : ∃ x, sum.inl v = value.to_err x) with ⟨_|_, ⟨⟩⟩,\n constructor }\nend\n\ntheorem value.step_unop.ok {Γ E op t₁ t₂ τ₁ τ₂ v v'}\n (sok : value.step_unop op v v')\n (opok : unop.ok op t₁ t₂)\n (tτ₁ : vtype.of_ty (exp.type.reg t₁) τ₁)\n (tτ₂ : vtype.of_ty (exp.type.reg t₂) τ₂)\n (vok₁ : value.ok Γ E v τ₁) : value.ok Γ E v' τ₂ :=\nby cases sok; cases opok; cases tτ₁; cases tτ₂; constructor\n\ntheorem stmt_list.ok.mono {Γ Δ δ₁ δ₂ ret K}\n (ss : δ₁ ⊆ δ₂) (Kok : stmt_list.ok Γ ret Δ δ₁ K) :\n stmt_list.ok Γ ret Δ δ₂ K :=\nbegin\n induction Kok generalizing δ₂,\n { exact stmt_list.ok.nil Kok_a },\n { rcases Kok_a_2.mono ss with ⟨δ', ss', i⟩,\n exact stmt_list.ok.one Kok_a Kok_a_1 i },\n { rcases Kok_a_1.mono ss with ⟨δ', ss', i⟩,\n exact stmt_list.ok.cons Kok_a i (Kok_ih ss') },\n { exact stmt_list.ok.weak (Kok_ih (finset.erase_subset_erase _ ss)) }\nend\n\ntheorem stmt_list.ok.cons_inv {Γ E Δ σ η ret s K}\n (σok : vars_ty.ok Δ σ)\n (ηok : vars.ok Γ E η σ) : stmt_list.ok Γ ret Δ σ.keys (s :: K) →\n ∃ Δ' σ' δ', vars_ty.ok Δ' σ' ∧ vars.ok Γ E η σ' ∧\n stmt.ok Γ ret Δ' s ∧\n stmt.init' Γ Δ'.keys.to_finset σ'.keys s δ' ∧\n (stmt.returns s ∨ stmt_list.ok Γ ret Δ' δ' K) :=\nbegin\n generalize e : (s :: K : list stmt) = K',\n generalize e' : σ.keys = δ,\n intro Kok, induction Kok generalizing σ; cases e; subst Kok_δ,\n { exact ⟨_, _, _, σok, ηok, Kok_a, Kok_a_2, or.inl Kok_a_1⟩ },\n { rcases Kok_a_1.subset Kok_a rfl σok.subset with ⟨ss₁', ss₂'⟩,\n exact ⟨_, _, _, σok, ηok, Kok_a, Kok_a_1, or.inr Kok_a_2⟩ },\n { exact Kok_ih rfl σok.erase ηok.erase (finmap.keys_erase _ _) }\nend\n\ntheorem step_deref.ok {Γ E σs Δ σ H S η ret a τ K s'}\n (σok : vars_ty.ok Δ σ) (Eok : heap.ok Γ H E)\n (ηok : vars.ok Γ E η σ) (Sok : stack.ok Γ E σs S ret)\n (aok : addr_opt.ok Γ E σ a τ)\n (Kok : cont.ok' Γ E σ Δ ret K τ)\n (h : step_deref ⟨H, S, η⟩ a K s') : state.ok Γ s' :=\nbegin\n cases h,\n { apply state.ok.err },\n { exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩\n (h_a_1.ok σok Eok ηok aok) Kok }\nend\n\ntheorem step_ret.ok {Γ E σs Δ σ H S η τ v s'}\n (σok : vars_ty.ok Δ σ) (Eok : heap.ok Γ H E)\n (ηok : vars.ok Γ E η σ) (Sok : stack.ok Γ E σs S τ)\n (vok : value.ok Γ E v τ)\n (h : step_ret ⟨H, S, η⟩ v s') : state.ok Γ s' :=\nbegin\n cases h,\n { cases Sok with Δ' η K' S' σ σs τ₁ τ' σok' ηok' Kok' Sok',\n exact state.ok.ret ⟨σok', Eok, ηok', Sok'⟩ vok Kok' },\n { apply state.ok.done }\nend\n\ntheorem step_call.ok {Γ : ast} {Δ : ctx} {E vs τs η}\n (τok : vtype.of_ty (exp.type.ls Δ.values) τs)\n (sc : step_call Δ vs η) (vok : value.ok Γ E vs τs) :\n ∃ σ, vars_ty.ok Δ σ ∧ vars.ok Γ E η σ ∧ Δ.keys.to_finset ⊆ σ.keys ∧ ∀ x ∈ η, x ∈ σ :=\nbegin\n induction sc with Δ x τ v vs η h a IH generalizing τs; cases τok; cases vok,\n { exact ⟨∅, by rintro _ _ ⟨⟩, by rintro _ _ ⟨⟩, λ _, id, by rintro _ ⟨_, ⟨⟩⟩⟩ },\n { rcases IH τok_a_1 vok_a_1 with ⟨σ, σok, ηok, ss, ησ⟩,\n have ηok' := ηok.insert (mt (σok.mem ∘ ησ _) h) vok_a,\n refine ⟨_, (σok.weak _).insert (mt σok.mem h) alist.lookup_cons_self τok_a,\n ηok', _, λ y h, _⟩,\n { rw [alist.cons_keys, list.cons_to_finset, finmap.keys_insert],\n exact finset.insert_subset_insert _ ss },\n { rw [← finmap.mem_keys, finmap.keys_insert, finset.mem_insert, finmap.mem_keys] at h ⊢,\n exact h.imp_right (ησ _) } }\nend\n\ntheorem step_alloc.ok {Γ E σs Δ σ H S ret η τ v K s}\n (σok : vars_ty.ok Δ σ) (Eok : heap.ok Γ H E)\n (ηok : vars.ok Γ E η σ) (Sok : stack.ok Γ E σs S ret)\n (vok : value.ok Γ E v τ) (Kok : cont.ok' Γ E σ Δ ret K (vtype.ref τ))\n (h : step_alloc ⟨H, S, η⟩ v K s) : state.ok Γ s :=\nbegin\n cases h,\n have EE : E ≤ E.add τ := E.le_add τ,\n refine state.ok.ret\n ⟨σok, Eok.add (vok.mono EE), ηok.mono EE, Sok.mono EE⟩\n (value.ok.ref _) (Kok.mono EE),\n rintro _ ⟨⟩,\n rw list.forall₂_length_eq Eok,\n apply list.nth_concat_length\nend\n\ntheorem step_alloc_arr.ok {Γ E σs Δ σ H S ret η τ n v K s}\n (σok : vars_ty.ok Δ σ) (Eok : heap.ok Γ H E)\n (ηok : vars.ok Γ E η σ) (Sok : stack.ok Γ E σs S ret)\n (vok : value.ok Γ E v (vtype.arr τ n))\n (Kok : cont.ok' Γ E σ Δ ret K (vtype.refarr τ))\n (h : step_alloc ⟨H, S, η⟩ v K s) : state.ok Γ s :=\nbegin\n cases h,\n have EE : E ≤ E.add (vtype.arr τ n) := E.le_add (vtype.arr τ n),\n refine state.ok.ret\n ⟨σok, Eok.add (vok.mono EE), ηok.mono EE, Sok.mono EE⟩\n (value.ok.refarr _) (Kok.mono EE),\n rintro _ ⟨⟩, existsi n,\n rw list.forall₂_length_eq Eok,\n apply list.nth_concat_length\nend\n\ntheorem preservation {Γ : ast} (ok : Γ.ok)\n {s} (sok : state.ok Γ s) {o} (iok : io.ok Γ o)\n {s'} (H : step Γ s o s') : state.ok Γ s' :=\nbegin\n cases H,\n case c0.step.decl : H S η v τ τ' s K H₁ {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, ⟨_, _, _, τ', _, hn, ττ', τsm, sok⟩, si, Kok⟩,\n cases si,\n refine state.ok.stmt t ⟨σok.weak _, Eok, ηok, Sok⟩ tτ sok\n (by simpa using si_a) _,\n rcases Kok with ⟨⟨_, _, _, r⟩⟩|Kok,\n { exact or.inl r },\n { exact or.inr Kok.weak } },\n case c0.step.decl_asgn : H S η v τ τ' e s K H₁ {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, Kok⟩, cases si, cases sok,\n refine state.ok.stmt t ⟨σok.weak sok_h, Eok, ηok, Sok⟩ tτ\n (stmt.ok.asgn (exp.ok.var alist.lookup_cons_self) sok_a_2.weak' sok_a_1)\n (ast.stmt.init.asgn ⟨⟩ si_a) (or.inr _),\n change stmt.init' Γ (insert v sok_Δ.keys.to_finset)\n (insert v sok_σ.keys) s si_δ' at si_a_1,\n rw [← list.cons_to_finset, ← alist.cons_keys] at si_a_1,\n rcases Kok with ⟨⟨⟩⟩|Kok,\n { exact stmt_list.ok.one sok_a_3 Kok_a si_a_1 },\n { exact Kok.weak.cons sok_a_3 si_a_1 } },\n case c0.step.If₁ : C c s₁ s₂ K {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, Kok⟩, cases si, cases sok,\n refine state.ok.exp ⟨σok, Eok, ηok, Sok⟩ si_a ⟨⟩\n ⟨_, sok_a_1, vtype.of_ty.bool⟩\n (cont.ok.If tτ sok_a_2 si_a_1 sok_a_3 si_a_2 _),\n rcases Kok with ⟨⟨⟩⟩|Kok,\n { exact or.inl ⟨Kok_a, Kok_a_1⟩ },\n { exact or.inr Kok } },\n case c0.step.If₂ : C b s₁ s₂ K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n _, _, _, _, δ₁, δ₂, _, t, tτ, s₁ok, i₁, s₂ok, i₂, Kok⟩,\n cases b,\n exact state.ok.stmt t ⟨σok, Eok, ηok, Sok⟩ tτ s₂ok i₂\n (Kok.imp and.right $ stmt_list.ok.mono (finset.inter_subset_right _ _)),\n exact state.ok.stmt t ⟨σok, Eok, ηok, Sok⟩ tτ s₁ok i₁\n (Kok.imp and.left $ stmt_list.ok.mono (finset.inter_subset_left _ _)) },\n case c0.step.while : C c s K {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, ⟨⟨⟩⟩|Kok⟩, cases si, cases id sok,\n have := si_a_1.subset a_1 rfl σok.subset,\n rcases si.mono this.1 with ⟨δ'', ss', i'⟩,\n exact (state.ok.exp ⟨σok, Eok, ηok, Sok⟩ si_a ⟨⟩ ⟨_, a, vtype.of_ty.bool⟩ $\n cont.ok.If tτ (a_1.seq sok) (si_a_1.seq i') stmt.ok.nop stmt.init.nop $\n or.inr $ Kok.mono $ finset.subset_inter ss' (finset.subset.refl _)) },\n case c0.step.asgn₁ : C lv e K eq {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, ⟨⟨⟩⟩|Kok⟩, cases si, cases sok,\n rcases vtype.of_ty_fn sok_τ with ⟨vτ, hv⟩,\n rw [lval.uses, eq] at si_a, rw eq at Kok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ si_a lv.ok ⟨_, sok_a_1, hv⟩\n (cont.ok.asgn₁ ⟨_, sok_a_2, hv⟩ si_a_1 ⟨t, tτ, Kok⟩) },\n case c0.step.asgn₂ : C a e K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n aok, _|⟨_, _, _, _, ⟨t, eok, tτ⟩, eu, t', tτ', Kok⟩⟩,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu ⟨⟩\n ⟨_, eok, tτ⟩ (cont.ok.asgn₂ aok ⟨_, tτ', Kok⟩) },\n case c0.step.asgn₃ : H H' S η η' a v K h {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, _|_|⟨_, _, _, _, aok, t, tτ, Kok⟩⟩,\n rcases h.ok ok.ind σok Eok ηok aok (addr.eq.ok vok) with ⟨Eok', ηok'⟩,\n exact state.ok.stmt t ⟨σok, Eok', ηok', Sok⟩ tτ\n stmt.ok.nop stmt.init.nop (or.inr Kok) },\n case c0.step.asgn_var₁ : C lv x e K eq {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, ⟨⟨⟩⟩|Kok⟩, cases si, cases sok,\n cases lv; cases eq,\n rcases vtype.of_ty_fn sok_τ with ⟨vτ, hv⟩,\n rcases sok_a_1 with _|_|_|⟨_, t', tΔ⟩,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ si_a_1 ⟨⟩\n ⟨_, sok_a_2, hv⟩ (cont.ok.asgn_var tΔ hv ⟨_, tτ, Kok⟩) },\n case c0.step.asgn_var₂ : H S η x v K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok, rcases Kok_a_2 with ⟨t, tτ, Kok⟩,\n rcases assign.ok σok ηok Kok_a Kok_a_1 vok with ⟨σ', σok', e, ηok'⟩,\n exact state.ok.stmt _ ⟨σok', Eok, ηok', Sok⟩ tτ\n stmt.ok.nop stmt.init.nop (or.inr (by rwa e)) },\n case c0.step.asgn_err : H S η v K { apply state.ok.err },\n case c0.step.asnop₁ : C lv op e K {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, ⟨⟨⟩⟩|Kok⟩, cases si, cases id sok,\n rcases vtype.of_ty_fn (exp.type.reg τ_1) with ⟨vτ, hv⟩,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ si_a lv.ok\n ⟨_, a, hv⟩ (cont.ok.asnop a_2 hv a_1 si_a_1 ⟨_, tτ, Kok⟩) },\n case c0.step.asnop₂ : _ C a op e K h {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n aok, Kok⟩, cases Kok, cases Kok_a with _ opok,\n exact step_deref.ok σok Eok ηok Sok aok\n (cont.ok.binop₁ opok Kok_a_1 Kok_a_1 Kok_a_2 Kok_a_3 $\n cont.ok.asgn₂ aok Kok_a_4) h },\n case c0.step.eval₁ : C e K {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, ⟨⟨⟩⟩|Kok⟩, cases si, cases id sok,\n rcases vtype.of_ty_fn τ_1 with ⟨vτ, hv⟩,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ si_a ⟨⟩\n ⟨_, a, hv⟩ (cont.ok.eval ⟨t, tτ, Kok⟩) },\n case c0.step.eval₂ : C e K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n aok, Kok⟩, cases Kok, rcases Kok_a with ⟨t, tτ, Kok⟩,\n exact state.ok.stmt t ⟨σok, Eok, ηok, Sok⟩ tτ\n stmt.ok.nop stmt.init.nop (or.inr Kok) },\n case c0.step.assert₁ : C e K {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, ⟨⟨⟩⟩|Kok⟩, cases si, cases id sok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ si_a ⟨⟩\n ⟨_, a, vtype.of_ty.bool⟩ (cont.ok.assert ⟨t, tτ, Kok⟩) },\n case c0.step.assert₂ : C b K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n aok, Kok⟩,\n cases b, {apply state.ok.err},\n cases Kok, rcases Kok_a with ⟨t, tτ, Kok⟩,\n exact state.ok.stmt t ⟨σok, Eok, ηok, Sok⟩ tτ\n stmt.ok.nop stmt.init.nop (or.inr Kok) },\n case c0.step.ret₁ : C e K {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, Kok⟩, cases si, cases id sok, cases a,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ (si_a _ rfl) ⟨⟩\n ⟨_, a_a_1, tτ⟩ cont.ok.ret },\n case c0.step.ret₂ : _ C v h {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, ⟨⟩⟩,\n exact h.ok σok Eok ηok Sok vok },\n case c0.step.ret_none : _ C v h {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, Kok⟩, cases id sok, cases a, cases tτ,\n exact h.ok σok Eok ηok Sok value.ok.nil },\n case c0.step.nop₁ : _ C h {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, _, si, ⟨⟨⟩⟩|Kok⟩, cases si, cases Kok.eq_none, cases tτ,\n exact h.ok σok Eok ηok Sok value.ok.nil },\n case c0.step.nop₂ : C s K {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, _, si, ⟨⟨⟩⟩|Kok⟩, cases si,\n rcases Kok.cons_inv σok ηok with ⟨Δ', σ', δ', σok', ηok', sok, si', Kok⟩,\n exact state.ok.stmt t ⟨σok', Eok, ηok', Sok⟩ tτ sok si' Kok },\n case c0.step.seq : C s₁ s₂ K {\n rcases sok with ⟨_, _, _, _, _, τ, _, _, _, t,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n tτ, sok, si, Kok⟩, cases si, cases id sok, rcases Kok with ⟨⟨⟩⟩|Kok,\n { exact state.ok.stmt t ⟨σok, Eok, ηok, Sok⟩ tτ a si_a (or.inl Kok_a) },\n { exact state.ok.stmt t ⟨σok, Eok, ηok, Sok⟩ tτ a si_a\n (or.inr $ stmt_list.ok.one a_1 Kok_a si_a_1) },\n { exact state.ok.stmt t ⟨σok, Eok, ηok, Sok⟩ tτ a si_a\n (or.inr $ Kok.cons a_1 si_a_1) } },\n case c0.step.int : C n K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, ⟨⟩, tτ⟩, Kok⟩, cases tτ,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩ value.ok.int Kok },\n case c0.step.bool : C b K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, ⟨⟩, tτ⟩, Kok⟩, cases tτ,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩ value.ok.bool Kok },\n case c0.step.null : C K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, ⟨⟩, tτ⟩, Kok⟩, cases tτ,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩ value.ok.null Kok },\n case c0.step.var : C i v K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨_, _|_|_|⟨_, t, iΔ⟩, tτ⟩, Kok⟩,\n rcases finmap.exists_mem_lookup_iff.2 (finmap.mem_keys.1 eu) with ⟨τ', iτ'⟩,\n cases vtype.of_ty_determ tτ (σok.ok_of_mem iτ' iΔ),\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩ (ηok.ok_of_mem iτ' H_a) Kok },\n case c0.step.binop₁ : C op e₁ e₂ K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n ⟨eu₁, eu₂⟩, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n rcases vtype.of_ty_fn (exp.type.reg eok_τ₁) with ⟨vτ₁, hv₁⟩,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu₁ ⟨⟩\n ⟨_, eok_a, hv₁⟩ (cont.ok.binop₁ eok_a_2 hv₁ tτ eok_a_1 eu₂ Kok) },\n case c0.step.binop₂ : C op v₁ e₂ K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ Kok_a_4 ⟨⟩ ⟨_, Kok_a_3, Kok_a_1⟩\n (cont.ok.binop₂ Kok_a Kok_a_1 Kok_a_2 vok Kok_a_5) },\n case c0.step.binop₃ : C op v₁ v₂ v K sb {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok₂, Kok⟩, cases Kok,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩\n (sb.ok Kok_a Kok_a_1 Kok_a_2 Kok_a_3 vok₂) Kok_a_4 },\n case c0.step.binop_err : C op v₁ v₂ err K sb { apply state.ok.err },\n case c0.step.unop₁ : C op e K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n rcases vtype.of_ty_fn (exp.type.reg eok_τ₁) with ⟨vτ₁, hv₁⟩,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu ⟨⟩\n ⟨_, eok_a, hv₁⟩ (cont.ok.unop eok_a_1 hv₁ tτ Kok) },\n case c0.step.unop₂ : C op v v' K su {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩\n (su.ok Kok_a Kok_a_1 Kok_a_2 vok) Kok_a_3 },\n case c0.step.cond₁ : C c e₁ e₂ K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n ⟨euc, eu₁, eu₂⟩, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ euc ⟨⟩ ⟨_, eok_a, vtype.of_ty.bool⟩\n (cont.ok.cond ⟨_, eok_a_1, tτ⟩ eu₁ ⟨_, eok_a_2, tτ⟩ eu₂ Kok) },\n case c0.step.cond₂ : C b e₁ e₂ K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok,\n cases b,\n { exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ Kok_a_3 ⟨⟩ Kok_a_2 Kok_a_4 },\n { exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ Kok_a_1 ⟨⟩ Kok_a Kok_a_4 } },\n case c0.step.nil : C K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, ⟨⟩, tτ⟩, Kok⟩, cases tτ,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩ value.ok.nil Kok },\n case c0.step.cons₁ : C e es K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n ⟨eu₁, eu₂⟩, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok, cases tτ,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu₁ ⟨⟩ ⟨_, eok_a, tτ_a⟩\n (cont.ok.cons₁ ⟨_, eok_a_1, tτ_a_1⟩ eu₂ Kok) },\n case c0.step.cons₂ : C v es K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ Kok_a_1 ⟨⟩ Kok_a\n (cont.ok.cons₂ vok Kok_a_2) },\n case c0.step.cons₃ : C v₁ v₂ K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok₂, Kok⟩, cases Kok,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩\n (value.ok.cons Kok_a vok₂) Kok_a_1 },\n case c0.step.call₁ : C op e K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n ⟨fok, eu⟩, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n rcases vtype.of_ty_fn (exp.type.ls eok_τs) with ⟨vτs, tτs⟩,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu ⟨⟩\n ⟨_, eok_a_1, tτs⟩ (cont.ok.call eok_a fok tτ tτs Kok) },\n case c0.step.call₂ : H S η η' f τ Δ' s vs K bok sc {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok,\n cases ok.fdef_uniq bok.get_fdef Kok_a,\n rcases sc.ok Kok_a_3 vok with ⟨σ', σok', ηok', ss, _⟩,\n rcases get_body_ok' ok.ind bok with ⟨sok, r⟩,\n rcases ok.ok_init bok with ⟨δ, si⟩,\n rcases si.mono ss with ⟨δ', ss', si'⟩,\n exact state.ok.stmt _ ⟨σok', Eok, ηok', Sok.cons σok ηok Kok_a_4⟩\n Kok_a_2 sok si' (r.imp_right stmt_list.ok.nil) },\n case c0.step.call_extern : H S η f vs H' v K ext {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok,\n rcases iok ext Kok_a Kok_a_2 Kok_a_3 Eok vok with ⟨E', EE, Eok', vok'⟩,\n exact state.ok.ret ⟨σok, Eok', ηok.mono EE, Sok.mono EE⟩\n vok' (Kok_a_4.mono EE) },\n case c0.step.deref : C e K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu ⟨⟩ ⟨_, eok_a, tτ.ref⟩\n (cont.ok.addr_deref $ cont.ok.deref Kok) },\n case c0.step.index : C e n K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n ⟨eu₁, eu₂⟩, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu₁ ⟨⟩ ⟨_, eok_a, tτ.arr⟩\n (cont.ok.addr_index₁ eok_a_1 eu₂ $ cont.ok.deref Kok) },\n case c0.step.field : C e n K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu\n (lv_ok_of_struct ok.ind eok_a) ⟨_, eok_a, vtype.of_ty.struct⟩\n (cont.ok.addr_field eok_a_1 eok_a_2 tτ $ cont.ok.deref Kok) },\n case c0.step.deref' : _ C a K sd {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n aok, Kok⟩, cases Kok,\n exact sd.ok σok Eok ηok Sok aok Kok_a },\n case c0.step.alloc_ref : _ C τ τ' v K ττ' v0 sa {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n cases ast.eval_ty.determ ok.ind ττ' eok_a, cases tτ,\n refine sa.ok σok Eok ηok Sok (v0.ok' ok _ tτ_a) Kok },\n case c0.step.alloc_arr₁ : C τ τ' e K ττ' {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n cases ast.eval_ty.determ ok.ind ττ' eok_a, cases tτ,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu ⟨⟩ ⟨_, eok_a_2, vtype.of_ty.int⟩\n (cont.ok.alloc_arr tτ eok_a_1 Kok) },\n case c0.step.alloc_arr₂ : _ C τ v K i n e v0 sa {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok, cases Kok_a,\n exact step_alloc_arr.ok σok Eok ηok Sok\n (v0.ok' ok _ Kok_a_a).repeat.arr Kok_a_2 sa },\n case c0.step.alloc_arr_err : C τ i K i0 { apply state.ok.err },\n case c0.step.addr_var : C v K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n rcases finmap.exists_mem_lookup_iff.2 (finmap.mem_keys.1 eu) with ⟨τ', vτ'⟩,\n cases vtype.of_ty_determ (σok.ok_of_mem vτ' eok_a) tτ,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩ (addr.ok.var vτ') Kok },\n case c0.step.addr_deref₁ : C e K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu ⟨⟩ ⟨_, eok_a, tτ.ref⟩\n (cont.ok.addr_deref Kok) },\n case c0.step.addr_deref₂ : C v K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok,\n refine state.ok.ret ⟨σok, Eok, ηok, Sok⟩ (addr.ok.ref_opt vok) Kok_a },\n case c0.step.addr_index₁ : C e n K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n ⟨eu₁, eu₂⟩, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu₁ ⟨⟩ ⟨_, eok_a, tτ.arr⟩\n (cont.ok.addr_index₁ eok_a_1 eu₂ Kok) },\n case c0.step.addr_index₂ : C a n K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n vok, Kok⟩, cases Kok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ Kok_a_1 ⟨⟩\n ⟨_, Kok_a, vtype.of_ty.int⟩\n (cont.ok.addr_index₂ (addr.ok.refarr_opt vok) Kok_a_2) },\n case c0.step.addr_index₃ : C a n K i j len e lt {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n _, Kok⟩, cases Kok,\n cases len with _ _ v aok,\n cases Kok_a _ rfl with n h,\n cases addr.get.ok σok Eok ηok h aok,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩ (h.nth lt) Kok_a_1 },\n case c0.step.addr_index_err₁ : C i K { apply state.ok.err },\n case c0.step.addr_index_err₂ : C a n K i { apply state.ok.err },\n case c0.step.addr_field₁ : C e f K {\n rcases sok with _|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n eu, _, ⟨t, eok, tτ⟩, Kok⟩, cases eok,\n exact state.ok.exp ⟨σok, Eok, ηok, Sok⟩ eu\n (lv_ok_of_struct ok.ind eok_a) ⟨_, eok_a, vtype.of_ty.struct⟩\n (cont.ok.addr_field eok_a_1 eok_a_2 tτ Kok) },\n case c0.step.addr_field₂ : C a f K {\n rcases sok with _|_|⟨E, σs, σ, H, η, S, Δ, ret, τ, α, v, K,\n ⟨E, σs, σ, H, η, S, Δ, _, σok, Eok, ηok, Sok⟩,\n aok, Kok⟩, cases Kok,\n exact state.ok.ret ⟨σok, Eok, ηok, Sok⟩\n (addr.ok.field Kok_a Kok_a_1 Kok_a_2 aok) Kok_a_3 },\n case c0.step.addr_field_err : C f K { apply state.ok.err }\nend\n\nend c0\n", "meta": {"author": "digama0", "repo": "vc0", "sha": "b8b192c8c139e0b5a25a7284b93ed53cdf7fd7a5", "save_path": "github-repos/lean/digama0-vc0", "path": "github-repos/lean/digama0-vc0/vc0-b8b192c8c139e0b5a25a7284b93ed53cdf7fd7a5/src/vc0/preservation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.38121956625615, "lm_q1q2_score": 0.2244960590042741}} {"text": "import code\nimport frespects_pfun\n\n/-! This code is adapted from Bolton Bailey's PR: https://github.com/leanprover-community/mathlib/pull/11046 -/\n\nopen boolcodeable (encode decode)\n\nlocal attribute [reducible] bitstring\n\ndef time {ι : Type} (impl : ι → bitstring → bitstring) : code ι → bitstring →. ℕ\n| (code.oracle i) := λ b, pure 1\n| (code.pair c₁ c₂) := λ v, (+1) <$> (time c₁ v) + (time c₂ v)\n| (code.comp c₁ c₂) := λ v, (+1) <$> (time c₂ v) + (c₂.eval impl v >>= time c₁)\n| (code.case c₁ c₂) := λ v, (+1) <$> (if v.head = ff then time c₁ v.tail else time c₂ v.tail)\n| (code.fix f) := λ v₀, (@pfun.fix (bitstring × ℕ) ℕ $ \n λ vt, (time f vt.1) >>= λ t',\n (f.eval impl vt.1).map (λ v' : bitstring,\n if v'.head = ff then sum.inl (vt.2+t')\n else sum.inr (v'.tail, vt.2+t'))\n ) (v₀, 0)\n\nvariables {ι : Type} (impl : ι → bitstring → bitstring)\n\nlemma time_dom_iff_eval_dom (c : code ι) (b : bitstring) : (time impl c b).dom ↔ (c.eval impl b).dom :=\nbegin\n induction c generalizing b,\n case code.oracle { simp [time], refl, },\n case code.pair : c₁ c₂ c₁ih c₂ih { simp only [time, code.eval, (+), (<*>)], simp [c₁ih, c₂ih], },\n case code.comp : c₁ c₂ c₁ih c₂ih { simp only [time, code.eval, (+), (<*>)], simp [c₁ih, c₂ih], tauto, },\n case code.case : c₁ c₂ c₁ih c₂ih { simp only [time, code.eval], split_ifs; simp [c₁ih, c₂ih], },\n case code.fix : f ih\n { simp only [time, code.eval], refine pfun.eq_dom_of_frespects_once prod.fst _ _,\n intro a, split,\n { simp [ih], }, split,\n { intro a',\n simp only [part.bind_eq_bind, part.mem_bind_iff, part.mem_map_iff, exists_prop, forall_exists_index, and_imp],\n intros n hn e he h, use e, refine ⟨he, _⟩,\n split_ifs at h, { contradiction, },\n rw ← h, split_ifs; refl, },\n simp only [part.bind_eq_bind, part.mem_bind_iff, part.mem_map_iff, exists_prop, forall_exists_index, and_imp],\n intros n₁ n₂ hn₂ b hb h,\n refine ⟨b.tail, b, hb, _⟩,\n split_ifs at h ⊢, { refl, }, { contradiction, }, }\nend\n\nvariables (c : code ι) (bound : ℕ → ℕ)\ndef time_bound : Prop :=\n∀ (b : bitstring) (l : ℕ), b.sizeof ≤ l → ∃ t ∈ time impl c b, t ≤ bound l\n\nvariables {impl c bound}\nlemma total_of_time_bound (H : time_bound impl c bound)\n (b : bitstring) : (c.eval impl b).dom :=\nbegin\n rw ← time_dom_iff_eval_dom,\n obtain ⟨n, t, _⟩ := H b b.sizeof (by refl),\n rw part.dom_iff_mem, use n, assumption,\nend\n\nlemma time_bound_oracle (i : ι) :\n time_bound impl (code.oracle i) 1 :=\nby { intros _ _ _, refine ⟨1, _, (by refl)⟩, simp [time], }\n\n\nlemma time_bound_pair (c₁ c₂ : code ι) {b₁ b₂ : ℕ → ℕ} (hb₁ : time_bound impl c₁ b₁) (hb₂ : time_bound impl c₂ b₂) :\n time_bound impl (code.pair c₁ c₂) (λ n, b₁ n + b₂ n + 1) :=\nbegin\n intros b l hb, simp only [time],\n obtain ⟨t₁, ht₁, t₁_le⟩ := hb₁ b l hb,\n obtain ⟨t₂, ht₂, t₂_le⟩ := hb₂ b l hb,\n use t₁ + t₂ + 1, split, swap, { linarith, },\n simp only [part.eq_some_iff.mpr ht₁, part.eq_some_iff.mpr ht₂, (+), (<*>)], simp, ring,\nend\n\n\n", "meta": {"author": "prakol16", "repo": "lean_complexity_theory_polytime_defs", "sha": "b4e5f5544e11cd5aca1a5a4b5b0231537af4962c", "save_path": "github-repos/lean/prakol16-lean_complexity_theory_polytime_defs", "path": "github-repos/lean/prakol16-lean_complexity_theory_polytime_defs/lean_complexity_theory_polytime_defs-b4e5f5544e11cd5aca1a5a4b5b0231537af4962c/src/old/time_bound.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.40356685373537454, "lm_q1q2_score": 0.22376590103326988}} {"text": "/-\nFile: signature_recover_public_key_ec_double_soundness.lean\n\nAutogenerated file.\n-/\nimport starkware.cairo.lean.semantics.soundness.hoare\nimport .signature_recover_public_key_code\nimport ..signature_recover_public_key_spec\nimport .signature_recover_public_key_compute_doubling_slope_soundness\nopen tactic\n\nopen starkware.cairo.common.cairo_secp.ec\nopen starkware.cairo.common.cairo_secp.bigint\nopen starkware.cairo.common.cairo_secp.field\n\nvariables {F : Type} [field F] [decidable_eq F] [prelude_hyps F]\nvariable mem : F → F\nvariable σ : register_state F\n\n/- starkware.cairo.common.cairo_secp.ec.ec_double autogenerated soundness theorem -/\n\ntheorem auto_sound_ec_double_block5\n -- An independent ap variable.\n (ap : F)\n -- arguments\n (range_check_ptr : F) (point : EcPoint F)\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_ec_double σ.pc)\n -- all dependencies are in memory\n (h_mem_4 : mem_at mem code_nondet_bigint3 (σ.pc - 244))\n (h_mem_5 : mem_at mem code_unreduced_mul (σ.pc - 232))\n (h_mem_6 : mem_at mem code_unreduced_sqr (σ.pc - 212))\n (h_mem_7 : mem_at mem code_verify_zero (σ.pc - 196))\n (h_mem_12 : mem_at mem code_compute_doubling_slope (σ.pc - 68))\n -- input arguments on the stack\n (hin_range_check_ptr : range_check_ptr = mem (σ.fp - 9))\n (hin_point : point = cast_EcPoint mem (σ.fp - 8))\n (νbound : ℕ)\n -- conclusion\n : ensuresb_ret νbound mem\n {pc := σ.pc + 14, ap := ap, fp := σ.fp}\n (λ κ τ,\n ∃ μ ≤ κ, rc_ensures mem (rc_bound F) μ (mem (σ.fp - 9)) (mem $ τ.ap - 7)\n (auto_spec_ec_double_block5 mem κ range_check_ptr point (mem (τ.ap - 7)) (cast_EcPoint mem (τ.ap - 6)))) :=\nbegin\n have h_mem_rec := h_mem,\n unpack_memory code_ec_double at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15, hpc16, hpc17, hpc18, hpc19, hpc20, hpc21, hpc22, hpc23, hpc24, hpc25, hpc26, hpc27, hpc28, hpc29, hpc30, hpc31, hpc32, hpc33, hpc34, hpc35, hpc36, hpc37, hpc38, hpc39, hpc40, hpc41, hpc42, hpc43, hpc44, hpc45, hpc46, hpc47, hpc48, hpc49, hpc50, hpc51, hpc52, hpc53, hpc54, hpc55, hpc56, hpc57, hpc58, hpc59, hpc60, hpc61, hpc62, hpc63, hpc64, hpc65, hpc66, hpc67, hpc68, hpc69, hpc70, hpc71, hpc72⟩,\n -- function call\n step_assert_eq hpc14 with arg0,\n step_assert_eq hpc15 with arg1,\n step_assert_eq hpc16 with arg2,\n step_assert_eq hpc17 with arg3,\n step_assert_eq hpc18 with arg4,\n step_assert_eq hpc19 with arg5,\n step_assert_eq hpc20 with arg6,\n step_sub hpc21 (auto_sound_compute_doubling_slope mem _ range_check_ptr point _ _ _ _ _ _ _),\n { rw hpc22, norm_num2, exact h_mem_12 },\n { rw hpc22, norm_num2, exact h_mem_4 },\n { rw hpc22, norm_num2, exact h_mem_5 },\n { rw hpc22, norm_num2, exact h_mem_6 },\n { rw hpc22, norm_num2, exact h_mem_7 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call23 ap23 h_call23,\n rcases h_call23 with ⟨h_call23_ap_offset, h_call23⟩,\n rcases h_call23 with ⟨rc_m23, rc_mle23, hl_range_check_ptr₁, h_call23⟩,\n generalize' hr_rev_range_check_ptr₁: mem (ap23 - 4) = range_check_ptr₁,\n have htv_range_check_ptr₁ := hr_rev_range_check_ptr₁.symm, clear hr_rev_range_check_ptr₁,\n generalize' hr_rev_slope: cast_BigInt3 mem (ap23 - 3) = slope,\n simp only [hr_rev_slope] at h_call23,\n have htv_slope := hr_rev_slope.symm, clear hr_rev_slope,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6] at hl_range_check_ptr₁ },\n rw [←htv_range_check_ptr₁, ←hin_range_check_ptr] at hl_range_check_ptr₁,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6] at h_call23 },\n rw [hin_range_check_ptr] at h_call23,\n clear arg0 arg1 arg2 arg3 arg4 arg5 arg6,\n -- function call\n step_sub hpc23 (auto_sound_unreduced_sqr mem _ slope _ _),\n { rw hpc24, norm_num2, exact h_mem_6 },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { simp only [h_call23_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call25 ap25 h_call25,\n rcases h_call25 with ⟨h_call25_ap_offset, h_call25⟩,\n generalize' hr_rev_slope_sqr: cast_UnreducedBigInt3 mem (ap25 - 3) = slope_sqr,\n simp only [hr_rev_slope_sqr] at h_call25,\n have htv_slope_sqr := hr_rev_slope_sqr.symm, clear hr_rev_slope_sqr,\n clear ,\n -- function call\n step_assert_eq hpc25 with arg0,\n step_sub hpc26 (auto_sound_nondet_bigint3 mem _ range_check_ptr₁ _ _),\n { rw hpc27, norm_num2, exact h_mem_4 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope, htv_slope_sqr] },\n try { dsimp [cast_EcPoint, cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0] },\n try { simp only [h_call23_ap_offset, h_call25_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call28 ap28 h_call28,\n rcases h_call28 with ⟨h_call28_ap_offset, h_call28⟩,\n rcases h_call28 with ⟨rc_m28, rc_mle28, hl_range_check_ptr₂, h_call28⟩,\n generalize' hr_rev_range_check_ptr₂: mem (ap28 - 4) = range_check_ptr₂,\n have htv_range_check_ptr₂ := hr_rev_range_check_ptr₂.symm, clear hr_rev_range_check_ptr₂,\n generalize' hr_rev_new_x: cast_BigInt3 mem (ap28 - 3) = new_x,\n simp only [hr_rev_new_x] at h_call28,\n have htv_new_x := hr_rev_new_x.symm, clear hr_rev_new_x,\n try { simp only [arg0] at hl_range_check_ptr₂ },\n try { rw [h_call25_ap_offset] at hl_range_check_ptr₂ }, try { arith_simps at hl_range_check_ptr₂ },\n rw [←htv_range_check_ptr₂, ←htv_range_check_ptr₁] at hl_range_check_ptr₂,\n try { simp only [arg0] at h_call28 },\n try { rw [h_call25_ap_offset] at h_call28 }, try { arith_simps at h_call28 },\n rw [←htv_range_check_ptr₁, hl_range_check_ptr₁, hin_range_check_ptr] at h_call28,\n clear arg0,\n -- function call\n step_assert_eq hpc28 with arg0,\n step_sub hpc29 (auto_sound_nondet_bigint3 mem _ range_check_ptr₂ _ _),\n { rw hpc30, norm_num2, exact h_mem_4 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope, htv_slope_sqr, htv_range_check_ptr₂, htv_new_x] },\n try { dsimp [cast_EcPoint, cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [arg0] },\n try { simp only [h_call23_ap_offset, h_call25_ap_offset, h_call28_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n intros κ_call31 ap31 h_call31,\n rcases h_call31 with ⟨h_call31_ap_offset, h_call31⟩,\n rcases h_call31 with ⟨rc_m31, rc_mle31, hl_range_check_ptr₃, h_call31⟩,\n generalize' hr_rev_range_check_ptr₃: mem (ap31 - 4) = range_check_ptr₃,\n have htv_range_check_ptr₃ := hr_rev_range_check_ptr₃.symm, clear hr_rev_range_check_ptr₃,\n generalize' hr_rev_new_y: cast_BigInt3 mem (ap31 - 3) = new_y,\n simp only [hr_rev_new_y] at h_call31,\n have htv_new_y := hr_rev_new_y.symm, clear hr_rev_new_y,\n try { simp only [arg0] at hl_range_check_ptr₃ },\n rw [←htv_range_check_ptr₃, ←htv_range_check_ptr₂] at hl_range_check_ptr₃,\n try { simp only [arg0] at h_call31 },\n rw [←htv_range_check_ptr₂, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call31,\n clear arg0,\n -- function call\n step_assert_eq hpc31 with arg0,\n step_assert_eq hpc32 hpc33 with arg1,\n step_assert_eq hpc34 with arg2,\n step_assert_eq hpc35 with arg3,\n step_assert_eq hpc36 hpc37 with arg4,\n step_assert_eq hpc38 with arg5,\n step_assert_eq hpc39 with arg6,\n step_assert_eq hpc40 hpc41 with arg7,\n step_assert_eq hpc42 with arg8,\n step_assert_eq hpc43 with arg9,\n step_assert_eq hpc44 with arg10,\n step_assert_eq hpc45 with arg11,\n step_assert_eq hpc46 with arg12,\n step_sub hpc47 (auto_sound_verify_zero mem _ range_check_ptr₃ {\n d0 := slope_sqr.d0 - new_x.d0 - 2 * point.x.d0,\n d1 := slope_sqr.d1 - new_x.d1 - 2 * point.x.d1,\n d2 := slope_sqr.d2 - new_x.d2 - 2 * point.x.d2\n } _ _ _),\n { rw hpc48, norm_num2, exact h_mem_7 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope, htv_slope_sqr, htv_range_check_ptr₂, htv_new_x, htv_range_check_ptr₃, htv_new_y] },\n try { dsimp [cast_EcPoint, cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [(eq_sub_of_eq_add arg0), arg1, arg2, (eq_sub_of_eq_add arg3), arg4, arg5, (eq_sub_of_eq_add arg6), arg7, arg8, arg9, (eq_sub_of_eq_add arg10), (eq_sub_of_eq_add arg11), (eq_sub_of_eq_add arg12)] },\n try { simp only [h_call23_ap_offset, h_call25_ap_offset, h_call28_ap_offset, h_call31_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope, htv_slope_sqr, htv_range_check_ptr₂, htv_new_x, htv_range_check_ptr₃, htv_new_y] },\n try { dsimp [cast_EcPoint, cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [(eq_sub_of_eq_add arg0), arg1, arg2, (eq_sub_of_eq_add arg3), arg4, arg5, (eq_sub_of_eq_add arg6), arg7, arg8, arg9, (eq_sub_of_eq_add arg10), (eq_sub_of_eq_add arg11), (eq_sub_of_eq_add arg12)] },\n try { simp only [h_call23_ap_offset, h_call25_ap_offset, h_call28_ap_offset, h_call31_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call49 ap49 h_call49,\n rcases h_call49 with ⟨h_call49_ap_offset, h_call49⟩,\n rcases h_call49 with ⟨rc_m49, rc_mle49, hl_range_check_ptr₄, h_call49⟩,\n generalize' hr_rev_range_check_ptr₄: mem (ap49 - 1) = range_check_ptr₄,\n have htv_range_check_ptr₄ := hr_rev_range_check_ptr₄.symm, clear hr_rev_range_check_ptr₄,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at hl_range_check_ptr₄ },\n rw [←htv_range_check_ptr₄, ←htv_range_check_ptr₃] at hl_range_check_ptr₄,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at h_call49 },\n rw [←htv_range_check_ptr₃, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call49,\n clear arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 arg10 arg11 arg12,\n -- function call\n step_assert_eq hpc49 with arg0,\n step_assert_eq hpc50 with arg1,\n step_assert_eq hpc51 with arg2,\n step_assert_eq hpc52 with arg3,\n step_assert_eq hpc53 with arg4,\n step_assert_eq hpc54 with arg5,\n step_sub hpc55 (auto_sound_unreduced_mul mem _ {\n d0 := point.x.d0 - new_x.d0,\n d1 := point.x.d1 - new_x.d1,\n d2 := point.x.d2 - new_x.d2\n } slope _ _ _),\n { rw hpc56, norm_num2, exact h_mem_5 },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope, htv_slope_sqr, htv_range_check_ptr₂, htv_new_x, htv_range_check_ptr₃, htv_new_y, htv_range_check_ptr₄] },\n try { dsimp [cast_EcPoint, cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [(eq_sub_of_eq_add arg0), (eq_sub_of_eq_add arg1), (eq_sub_of_eq_add arg2), arg3, arg4, arg5] },\n try { simp only [h_call23_ap_offset, h_call25_ap_offset, h_call28_ap_offset, h_call31_ap_offset, h_call49_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope, htv_slope_sqr, htv_range_check_ptr₂, htv_new_x, htv_range_check_ptr₃, htv_new_y, htv_range_check_ptr₄] },\n try { dsimp [cast_EcPoint, cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [(eq_sub_of_eq_add arg0), (eq_sub_of_eq_add arg1), (eq_sub_of_eq_add arg2), arg3, arg4, arg5] },\n try { simp only [h_call23_ap_offset, h_call25_ap_offset, h_call28_ap_offset, h_call31_ap_offset, h_call49_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call57 ap57 h_call57,\n rcases h_call57 with ⟨h_call57_ap_offset, h_call57⟩,\n generalize' hr_rev_x_diff_slope: cast_UnreducedBigInt3 mem (ap57 - 3) = x_diff_slope,\n simp only [hr_rev_x_diff_slope] at h_call57,\n have htv_x_diff_slope := hr_rev_x_diff_slope.symm, clear hr_rev_x_diff_slope,\n clear arg0 arg1 arg2 arg3 arg4 arg5,\n -- function call\n step_assert_eq hpc57 with arg0,\n step_assert_eq hpc58 with arg1,\n step_assert_eq hpc59 with arg2,\n step_assert_eq hpc60 with arg3,\n step_assert_eq hpc61 with arg4,\n step_assert_eq hpc62 with arg5,\n step_assert_eq hpc63 with arg6,\n step_sub hpc64 (auto_sound_verify_zero mem _ range_check_ptr₄ {\n d0 := x_diff_slope.d0 - point.y.d0 - new_y.d0,\n d1 := x_diff_slope.d1 - point.y.d1 - new_y.d1,\n d2 := x_diff_slope.d2 - point.y.d2 - new_y.d2\n } _ _ _),\n { rw hpc65, norm_num2, exact h_mem_7 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope, htv_slope_sqr, htv_range_check_ptr₂, htv_new_x, htv_range_check_ptr₃, htv_new_y, htv_range_check_ptr₄, htv_x_diff_slope] },\n try { dsimp [cast_EcPoint, cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [(eq_sub_of_eq_add arg0), (eq_sub_of_eq_add arg1), (eq_sub_of_eq_add arg2), arg3, (eq_sub_of_eq_add arg4), (eq_sub_of_eq_add arg5), (eq_sub_of_eq_add arg6)] },\n try { simp only [h_call23_ap_offset, h_call25_ap_offset, h_call28_ap_offset, h_call31_ap_offset, h_call49_ap_offset, h_call57_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope, htv_slope_sqr, htv_range_check_ptr₂, htv_new_x, htv_range_check_ptr₃, htv_new_y, htv_range_check_ptr₄, htv_x_diff_slope] },\n try { dsimp [cast_EcPoint, cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [(eq_sub_of_eq_add arg0), (eq_sub_of_eq_add arg1), (eq_sub_of_eq_add arg2), arg3, (eq_sub_of_eq_add arg4), (eq_sub_of_eq_add arg5), (eq_sub_of_eq_add arg6)] },\n try { simp only [h_call23_ap_offset, h_call25_ap_offset, h_call28_ap_offset, h_call31_ap_offset, h_call49_ap_offset, h_call57_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call66 ap66 h_call66,\n rcases h_call66 with ⟨h_call66_ap_offset, h_call66⟩,\n rcases h_call66 with ⟨rc_m66, rc_mle66, hl_range_check_ptr₅, h_call66⟩,\n generalize' hr_rev_range_check_ptr₅: mem (ap66 - 1) = range_check_ptr₅,\n have htv_range_check_ptr₅ := hr_rev_range_check_ptr₅.symm, clear hr_rev_range_check_ptr₅,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6] at hl_range_check_ptr₅ },\n try { rw [h_call57_ap_offset] at hl_range_check_ptr₅ }, try { arith_simps at hl_range_check_ptr₅ },\n rw [←htv_range_check_ptr₅, ←htv_range_check_ptr₄] at hl_range_check_ptr₅,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6] at h_call66 },\n try { rw [h_call57_ap_offset] at h_call66 }, try { arith_simps at h_call66 },\n rw [←htv_range_check_ptr₄, hl_range_check_ptr₄, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call66,\n clear arg0 arg1 arg2 arg3 arg4 arg5 arg6,\n -- return\n step_assert_eq hpc66 with hret0,\n step_assert_eq hpc67 with hret1,\n step_assert_eq hpc68 with hret2,\n step_assert_eq hpc69 with hret3,\n step_assert_eq hpc70 with hret4,\n step_assert_eq hpc71 with hret5,\n step_ret hpc72,\n -- finish\n step_done, use_only [rfl, rfl],\n -- range check condition\n use_only (rc_m23+rc_m28+rc_m31+rc_m49+rc_m66+0+0), split,\n linarith [rc_mle23, rc_mle28, rc_mle31, rc_mle49, rc_mle66],\n split,\n { arith_simps, try { simp only [hret0 ,hret1 ,hret2 ,hret3 ,hret4 ,hret5] },\n rw [←htv_range_check_ptr₅, hl_range_check_ptr₅, hl_range_check_ptr₄, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr],\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n dsimp [auto_spec_ec_double_block5],\n try { norm_num1 }, try { arith_simps },\n use_only [κ_call23],\n use_only [range_check_ptr₁],\n use_only [slope],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have spec23 := h_call23 rc_h_range_check_ptr',\n rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec23,\n try { dsimp at spec23, arith_simps at spec23 },\n use_only [spec23],\n use_only [κ_call25],\n use_only [slope_sqr],\n try { dsimp at h_call25, arith_simps at h_call25 },\n try { use_only [h_call25] },\n use_only [κ_call28],\n use_only [range_check_ptr₂],\n use_only [new_x],\n have rc_h_range_check_ptr₂ := range_checked_offset' rc_h_range_check_ptr₁,\n have rc_h_range_check_ptr₂' := range_checked_add_right rc_h_range_check_ptr₂, try { norm_cast at rc_h_range_check_ptr₂' },\n have spec28 := h_call28 rc_h_range_check_ptr₁',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←htv_range_check_ptr₂] at spec28,\n try { dsimp at spec28, arith_simps at spec28 },\n use_only [spec28],\n use_only [κ_call31],\n use_only [range_check_ptr₃],\n use_only [new_y],\n have rc_h_range_check_ptr₃ := range_checked_offset' rc_h_range_check_ptr₂,\n have rc_h_range_check_ptr₃' := range_checked_add_right rc_h_range_check_ptr₃, try { norm_cast at rc_h_range_check_ptr₃' },\n have spec31 := h_call31 rc_h_range_check_ptr₂',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←htv_range_check_ptr₃] at spec31,\n try { dsimp at spec31, arith_simps at spec31 },\n use_only [spec31],\n use_only [κ_call49],\n use_only [range_check_ptr₄],\n have rc_h_range_check_ptr₄ := range_checked_offset' rc_h_range_check_ptr₃,\n have rc_h_range_check_ptr₄' := range_checked_add_right rc_h_range_check_ptr₄, try { norm_cast at rc_h_range_check_ptr₄' },\n have spec49 := h_call49 rc_h_range_check_ptr₃',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←hl_range_check_ptr₃, ←htv_range_check_ptr₄] at spec49,\n try { dsimp at spec49, arith_simps at spec49 },\n use_only [spec49],\n use_only [κ_call57],\n use_only [x_diff_slope],\n try { dsimp at h_call57, arith_simps at h_call57 },\n try { use_only [h_call57] },\n use_only [κ_call66],\n use_only [range_check_ptr₅],\n have rc_h_range_check_ptr₅ := range_checked_offset' rc_h_range_check_ptr₄,\n have rc_h_range_check_ptr₅' := range_checked_add_right rc_h_range_check_ptr₅, try { norm_cast at rc_h_range_check_ptr₅' },\n have spec66 := h_call66 rc_h_range_check_ptr₄',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂, ←hl_range_check_ptr₃, ←hl_range_check_ptr₄, ←htv_range_check_ptr₅] at spec66,\n try { dsimp at spec66, arith_simps at spec66 },\n use_only [spec66],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point, htv_range_check_ptr₁, htv_slope, htv_slope_sqr, htv_range_check_ptr₂, htv_new_x, htv_range_check_ptr₃, htv_new_y, htv_range_check_ptr₄, htv_x_diff_slope, htv_range_check_ptr₅] }, },\n try { dsimp [cast_EcPoint, cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [hret0, hret1, hret2, hret3, hret4, hret5] },\n try { simp only [h_call23_ap_offset, h_call25_ap_offset, h_call28_ap_offset, h_call31_ap_offset, h_call49_ap_offset, h_call57_ap_offset, h_call66_ap_offset] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\nend\n\ntheorem auto_sound_ec_double\n -- arguments\n (range_check_ptr : F) (point : EcPoint F)\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_ec_double σ.pc)\n -- all dependencies are in memory\n (h_mem_4 : mem_at mem code_nondet_bigint3 (σ.pc - 244))\n (h_mem_5 : mem_at mem code_unreduced_mul (σ.pc - 232))\n (h_mem_6 : mem_at mem code_unreduced_sqr (σ.pc - 212))\n (h_mem_7 : mem_at mem code_verify_zero (σ.pc - 196))\n (h_mem_12 : mem_at mem code_compute_doubling_slope (σ.pc - 68))\n -- input arguments on the stack\n (hin_range_check_ptr : range_check_ptr = mem (σ.fp - 9))\n (hin_point : point = cast_EcPoint mem (σ.fp - 8))\n -- conclusion\n : ensures_ret mem σ (λ κ τ,\n ∃ μ ≤ κ, rc_ensures mem (rc_bound F) μ (mem (σ.fp - 9)) (mem $ τ.ap - 7)\n (spec_ec_double mem κ range_check_ptr point (mem (τ.ap - 7)) (cast_EcPoint mem (τ.ap - 6)))) :=\nbegin\n apply ensures_of_ensuresb, intro νbound,\n have h_mem_rec := h_mem,\n unpack_memory code_ec_double at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15, hpc16, hpc17, hpc18, hpc19, hpc20, hpc21, hpc22, hpc23, hpc24, hpc25, hpc26, hpc27, hpc28, hpc29, hpc30, hpc31, hpc32, hpc33, hpc34, hpc35, hpc36, hpc37, hpc38, hpc39, hpc40, hpc41, hpc42, hpc43, hpc44, hpc45, hpc46, hpc47, hpc48, hpc49, hpc50, hpc51, hpc52, hpc53, hpc54, hpc55, hpc56, hpc57, hpc58, hpc59, hpc60, hpc61, hpc62, hpc63, hpc64, hpc65, hpc66, hpc67, hpc68, hpc69, hpc70, hpc71, hpc72⟩,\n -- if statement\n step_jnz hpc0 hpc1 with hcond hcond,\n {\n -- if: positive branch\n have a0 : point.x.d0 = 0, {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a0 }, try { arith_simps at a0 },\n clear hcond,\n -- if statement\n step_jnz hpc2 hpc3 with hcond hcond,\n {\n -- if: positive branch\n have a2 : point.x.d1 = 0, {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a2 }, try { arith_simps at a2 },\n clear hcond,\n -- if statement\n step_jnz hpc4 hpc5 with hcond hcond,\n {\n -- if: positive branch\n have a4 : point.x.d2 = 0, {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a4 }, try { arith_simps at a4 },\n clear hcond,\n -- return\n step_assert_eq hpc6 with hret0,\n step_assert_eq hpc7 with hret1,\n step_assert_eq hpc8 with hret2,\n step_assert_eq hpc9 with hret3,\n step_assert_eq hpc10 with hret4,\n step_assert_eq hpc11 with hret5,\n step_assert_eq hpc12 with hret6,\n step_ret hpc13,\n -- finish\n step_done, use_only [rfl, rfl],\n -- range check condition\n use_only (0+0), split,\n linarith [],\n split,\n { arith_simps, try { simp only [hret0 ,hret1 ,hret2 ,hret3 ,hret4 ,hret5 ,hret6] },\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_ec_double mem _ range_check_ptr point _ _,\n { apply sound_ec_double, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_ec_double],\n try { norm_num1 }, try { arith_simps },\n left,\n use_only [a0],\n left,\n use_only [a2],\n left,\n use_only [a4],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point] }, },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hret0, hret1, hret2, hret3, hret4, hret5, hret6] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n {\n -- if: negative branch\n have a4 : point.x.d2 ≠ 0, {\n try { simp only [ne.def] },\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a4 }, try { arith_simps at a4 },\n clear hcond,\n -- Use the block soundness theorem.\n apply ensuresb_ret_trans (auto_sound_ec_double_block5 mem σ _ range_check_ptr point h_mem_rec h_mem_4 h_mem_5 h_mem_6 h_mem_7 h_mem_12 hin_range_check_ptr hin_point νbound),\n intros κ_block5 τ, try { arith_simps },\n intro h_block5,\n rcases h_block5 with ⟨rc_m_block5, rc_m_le_block5, hblk_range_check_ptr₁, h_block5⟩,\n -- range check condition\n use_only (rc_m_block5+0+0), split,\n linarith [rc_m_le_block5],\n split,\n { arith_simps, try { simp only [hblk_range_check_ptr₁] },\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_ec_double mem _ range_check_ptr point _ _,\n { apply sound_ec_double, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_ec_double],\n try { norm_num1 }, try { arith_simps },\n left,\n use_only [a0],\n left,\n use_only [a2],\n right,\n use_only [a4],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have h_block5' := h_block5 rc_h_range_check_ptr',\n try { rw [←hin_range_check_ptr] at h_block5' },\n try { dsimp at h_block5, arith_simps at h_block5' },\n have h_block5 := h_block5',\n use_only[κ_block5],\n use [h_block5],\n try { linarith }\n }\n },\n {\n -- if: negative branch\n have a2 : point.x.d1 ≠ 0, {\n try { simp only [ne.def] },\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a2 }, try { arith_simps at a2 },\n clear hcond,\n -- Use the block soundness theorem.\n apply ensuresb_ret_trans (auto_sound_ec_double_block5 mem σ _ range_check_ptr point h_mem_rec h_mem_4 h_mem_5 h_mem_6 h_mem_7 h_mem_12 hin_range_check_ptr hin_point νbound),\n intros κ_block5 τ, try { arith_simps },\n intro h_block5,\n rcases h_block5 with ⟨rc_m_block5, rc_m_le_block5, hblk_range_check_ptr₁, h_block5⟩,\n -- range check condition\n use_only (rc_m_block5+0+0), split,\n linarith [rc_m_le_block5],\n split,\n { arith_simps, try { simp only [hblk_range_check_ptr₁] },\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_ec_double mem _ range_check_ptr point _ _,\n { apply sound_ec_double, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_ec_double],\n try { norm_num1 }, try { arith_simps },\n left,\n use_only [a0],\n right,\n use_only [a2],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have h_block5' := h_block5 rc_h_range_check_ptr',\n try { rw [←hin_range_check_ptr] at h_block5' },\n try { dsimp at h_block5, arith_simps at h_block5' },\n have h_block5 := h_block5',\n use_only[κ_block5],\n use [h_block5],\n try { linarith }\n }\n },\n {\n -- if: negative branch\n have a0 : point.x.d0 ≠ 0, {\n try { simp only [ne.def] },\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a0 }, try { arith_simps at a0 },\n clear hcond,\n -- Use the block soundness theorem.\n apply ensuresb_ret_trans (auto_sound_ec_double_block5 mem σ _ range_check_ptr point h_mem_rec h_mem_4 h_mem_5 h_mem_6 h_mem_7 h_mem_12 hin_range_check_ptr hin_point νbound),\n intros κ_block5 τ, try { arith_simps },\n intro h_block5,\n rcases h_block5 with ⟨rc_m_block5, rc_m_le_block5, hblk_range_check_ptr₁, h_block5⟩,\n -- range check condition\n use_only (rc_m_block5+0+0), split,\n linarith [rc_m_le_block5],\n split,\n { arith_simps, try { simp only [hblk_range_check_ptr₁] },\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_ec_double mem _ range_check_ptr point _ _,\n { apply sound_ec_double, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_ec_double],\n try { norm_num1 }, try { arith_simps },\n right,\n use_only [a0],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have h_block5' := h_block5 rc_h_range_check_ptr',\n try { rw [←hin_range_check_ptr] at h_block5' },\n try { dsimp at h_block5, arith_simps at h_block5' },\n have h_block5 := h_block5',\n use_only[κ_block5],\n use [h_block5],\n try { linarith }\n }\nend\n\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/common/cairo_secp/verification/verification/signature_recover_public_key_ec_double_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5851011686727232, "lm_q2_score": 0.38121956625614994, "lm_q1q2_score": 0.22305201373738198}} {"text": "import condensed.top_comparison\nimport condensed.exact\nimport for_mathlib.exact_functor\n\n.\n\nopen category_theory\nopen category_theory.limits\nopen opposite\n\nnamespace Condensed\n\nuniverses u\n\nvariables {X Y Z : Condensed.{u} Ab.{u+1}} (f : X ⟶ Y) (g : Y ⟶ Z) (w : f ≫ g = 0)\n (S : Profinite.{u})\n\nnoncomputable theory\n\ninstance evaluation_additive (S : Profinite.{u}) :\n functor.additive (Condensed.evaluation _ S : Condensed.{u} Ab.{u+1} ⥤ _) :=\n⟨λ X Y f g, rfl⟩\n\nlemma evaluation_exact (S : ExtrDisc.{u}) :\n functor.exact (Condensed.evaluation _ S.val : Condensed.{u} Ab.{u+1} ⥤ _) :=\nbegin\n intros X Y Z f g h,\n rw Condensed.exact_iff_ExtrDisc at h,\n apply h\nend\n\nabbreviation homology_evaluation_iso (S : ExtrDisc.{u}) :\n (homology f g w).val.obj (op S.val) ≅\n homology (f.val.app (op S.val)) (g.val.app (op S.val))\n (by { rw [← f.val.comp_app, ← Sheaf.hom.comp_val, w], refl }) :=\n(Condensed.evaluation Ab.{u+1} _).homology_iso _ _ _ _\n\n.\n\nabbreviation homology_functor_evaluation_iso {M : Type*} (c : complex_shape M)\n (i : M) (S : ExtrDisc.{u}) :\n homology_functor (Condensed.{u} Ab.{u+1}) c i ⋙ Condensed.evaluation _ S.val ≅\n (Condensed.evaluation _ S.val).map_homological_complex _ ⋙ homology_functor Ab.{u+1} c i :=\n(Condensed.evaluation Ab.{u+1} _).homology_functor_iso _ _\n\nend Condensed\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/evaluation_homology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.4073334000459302, "lm_q1q2_score": 0.2227047103827213}} {"text": "/- Enumerable and the Decidable instance may already be in Mathlib -/\n\nclass Enumerable (α : Type u) where\n elems : List α\n complete : ∀ a : α, a ∈ elems\n\ndef List.allTrue (p : α → Prop) [(a : α) → Decidable (p a)] : List α → Bool\n | [] => true\n | a :: as => p a && allTrue p as\n\ntheorem List.of_allTrue [(a : α) → Decidable (p a)] (hc : allTrue p as) (hin : a ∈ as) : p a := by\n induction as with\n | nil => contradiction\n | cons b bs ih =>\n cases hin with simp [allTrue] at hc\n | head => simp [*]\n | tail _ h => exact ih hc.2 h\n\ntheorem List.allTrue_of_forall [(a : α) → Decidable (p a)] (h : ∀ a, p a) : allTrue p as := by\n induction as <;> simp [allTrue, *]\n\ninstance [Enumerable α] (p : α → Prop) [(a : α) → Decidable (p a)] : Decidable (∀ a, p a) :=\n have : List.allTrue p Enumerable.elems → (a : α) → p a :=\n fun h a => List.of_allTrue h (Enumerable.complete a)\n decidable_of_decidable_of_iff (Iff.intro this List.allTrue_of_forall)\n\ninductive States | s0 | s1 | s2 | s3 | s4 | s5 | s6 | s7 | s8 | s9 | s10 | s11\nderiving DecidableEq\n\n/- We can add a `deriving` for `Enumerable` in the future. -/\nopen States in\ninstance : Enumerable States where\n elems := [s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11]\n complete a := by cases a <;> decide\n\nopen States\ndef f : States → States → States\n| s0, s0 => s0\n| s0, s1 => s0\n| s0, s2 => s0\n| s0, s3 => s0\n| s0, s4 => s0\n| s0, s5 => s0\n| s0, s6 => s0\n| s0, s7 => s0\n| s0, s8 => s0\n| s0, s9 => s0\n| s0, s10 => s0\n| s0, s11 => s0\n| s1, s0 => s0\n| s1, s1 => s0\n| s1, s2 => s0\n| s1, s3 => s0\n| s1, s4 => s0\n| s1, s5 => s0\n| s1, s6 => s0\n| s1, s7 => s0\n| s1, s8 => s0\n| s1, s9 => s0\n| s1, s10 => s0\n| s1, s11 => s0\n| s2, s0 => s0\n| s2, s1 => s0\n| s2, s2 => s0\n| s2, s3 => s0\n| s2, s4 => s0\n| s2, s5 => s0\n| s2, s6 => s0\n| s2, s7 => s0\n| s2, s8 => s0\n| s2, s9 => s0\n| s2, s10 => s0\n| s2, s11 => s0\n| s3, s0 => s0\n| s3, s1 => s0\n| s3, s2 => s0\n| s3, s3 => s0\n| s3, s4 => s0\n| s3, s5 => s0\n| s3, s6 => s0\n| s3, s7 => s0\n| s3, s8 => s0\n| s3, s9 => s0\n| s3, s10 => s0\n| s3, s11 => s0\n| s4, s0 => s0\n| s4, s1 => s0\n| s4, s2 => s0\n| s4, s3 => s0\n| s4, s4 => s0\n| s4, s5 => s0\n| s4, s6 => s0\n| s4, s7 => s0\n| s4, s8 => s0\n| s4, s9 => s0\n| s4, s10 => s0\n| s4, s11 => s0\n| s5, s0 => s0\n| s5, s1 => s0\n| s5, s2 => s0\n| s5, s3 => s0\n| s5, s4 => s0\n| s5, s5 => s0\n| s5, s6 => s0\n| s5, s7 => s0\n| s5, s8 => s0\n| s5, s9 => s0\n| s5, s10 => s0\n| s5, s11 => s0\n| s6, s0 => s0\n| s6, s1 => s0\n| s6, s2 => s0\n| s6, s3 => s0\n| s6, s4 => s0\n| s6, s5 => s0\n| s6, s6 => s0\n| s6, s7 => s0\n| s6, s8 => s0\n| s6, s9 => s0\n| s6, s10 => s0\n| s6, s11 => s0\n| s7, s0 => s0\n| s7, s1 => s0\n| s7, s2 => s0\n| s7, s3 => s0\n| s7, s4 => s0\n| s7, s5 => s0\n| s7, s6 => s0\n| s7, s7 => s0\n| s7, s8 => s0\n| s7, s9 => s0\n| s7, s10 => s0\n| s7, s11 => s0\n| s8, s0 => s0\n| s8, s1 => s0\n| s8, s2 => s0\n| s8, s3 => s0\n| s8, s4 => s0\n| s8, s5 => s0\n| s8, s6 => s0\n| s8, s7 => s0\n| s8, s8 => s0\n| s8, s9 => s0\n| s8, s10 => s0\n| s8, s11 => s0\n| s9, s0 => s0\n| s9, s1 => s0\n| s9, s2 => s0\n| s9, s3 => s0\n| s9, s4 => s0\n| s9, s5 => s0\n| s9, s6 => s0\n| s9, s7 => s0\n| s9, s8 => s0\n| s9, s9 => s0\n| s9, s10 => s0\n| s9, s11 => s0\n| s10, s0 => s0\n| s10, s1 => s0\n| s10, s2 => s0\n| s10, s3 => s0\n| s10, s4 => s0\n| s10, s5 => s0\n| s10, s6 => s0\n| s10, s7 => s0\n| s10, s8 => s0\n| s10, s9 => s0\n| s10, s10 => s0\n| s10, s11 => s0\n| s11, s0 => s0\n| s11, s1 => s0\n| s11, s2 => s0\n| s11, s3 => s0\n| s11, s4 => s0\n| s11, s5 => s0\n| s11, s6 => s0\n| s11, s7 => s0\n| s11, s8 => s0\n| s11, s9 => s0\n| s11, s10 => s0\n| s11, s11 => s0\n\nset_option maxHeartbeats 0\nexample : ∀ x y z, f (f (f s0 x) y) z = f (f x z) (f y z) := by\n native_decide -- This is fast, but the TCB is much bigger\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/state12.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5621764862150636, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.2226602100175843}} {"text": "/-\nFile: signature_recover_public_key_unreduced_sqr_soundness.lean\n\nAutogenerated file.\n-/\nimport starkware.cairo.lean.semantics.soundness.hoare\nimport .signature_recover_public_key_code\nimport ..signature_recover_public_key_spec\nopen tactic\n\nopen starkware.cairo.common.cairo_secp.field\nopen starkware.cairo.common.cairo_secp.bigint\nopen starkware.cairo.common.cairo_secp.constants\n\nvariables {F : Type} [field F] [decidable_eq F] [prelude_hyps F]\nvariable mem : F → F\nvariable σ : register_state F\n\n/- starkware.cairo.common.cairo_secp.field.unreduced_sqr autogenerated soundness theorem -/\n\ntheorem auto_sound_unreduced_sqr\n -- arguments\n (a : BigInt3 F)\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_unreduced_sqr σ.pc)\n -- input arguments on the stack\n (hin_a : a = cast_BigInt3 mem (σ.fp - 5))\n -- conclusion\n : ensures_ret mem σ (λ κ τ, τ.ap = σ.ap + 12 ∧ spec_unreduced_sqr mem κ a (cast_UnreducedBigInt3 mem (τ.ap - 3))) :=\nbegin\n apply ensures_of_ensuresb, intro νbound,\n have h_mem_rec := h_mem,\n unpack_memory code_unreduced_sqr at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15⟩,\n -- tempvar\n step_assert_eq hpc0 hpc1 with tv_twice_d00,\n generalize' hl_rev_twice_d0: (a.d0 * 2 : F) = twice_d0,\n have hl_twice_d0 := hl_rev_twice_d0.symm, clear hl_rev_twice_d0,\n have htv_twice_d0: twice_d0 = _, {\n apply eq.symm, apply eq.trans tv_twice_d00,\n try { simp only [add_neg_eq_sub, hin_a, hl_twice_d0] },\n try { dsimp [cast_BigInt3] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n clear tv_twice_d00,\n try { dsimp at hl_twice_d0 }, try { arith_simps at hl_twice_d0 },\n -- return\n step_assert_eq hpc2 with hret0,\n step_assert_eq hpc3 hpc4 with hret1,\n step_assert_eq hpc5 with hret2,\n step_assert_eq hpc6 with hret3,\n step_assert_eq hpc7 hpc8 with hret4,\n step_assert_eq hpc9 with hret5,\n step_assert_eq hpc10 with hret6,\n step_assert_eq hpc11 with hret7,\n step_assert_eq hpc12 with hret8,\n step_assert_eq hpc13 with hret9,\n step_assert_eq hpc14 with hret10,\n step_ret hpc15,\n -- finish\n step_done, use_only [rfl, rfl],\n split, refl,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_unreduced_sqr mem _ a _,\n { apply sound_unreduced_sqr, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_unreduced_sqr],\n try { norm_num1 }, try { arith_simps },\n use_only [twice_d0, hl_twice_d0],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_a, hl_twice_d0, htv_twice_d0] }, },\n try { dsimp [cast_BigInt3, cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [hret0, hret1, hret2, hret3, hret4, hret5, hret6, hret7, hret8, hret9, hret10] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\nend\n\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/common/cairo_secp/verification/verification/signature_recover_public_key_unreduced_sqr_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.4186969093556867, "lm_q1q2_score": 0.22241572285236277}} {"text": "import Radon.defs\n\nopen_locale nnreal big_operators classical\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\nopen topological_space\n\nlocal attribute [instance]\n locally_constant.seminormed_add_comm_group\n locally_constant.pseudo_metric_space\n\nnamespace Profinite\n\n/-- Consider an element of `X.Radon_LC p c` as a function on the\ntype of locally constant functions. -/\ndef Radon_LC_to_fun (X : Profinite.{0}) (p c : ℝ≥0) :\n X.Radon_LC p c → locally_constant X ℝ → ℝ :=\nλ μ, μ.1\n\n/-- Consider an element of `X.Radon p c` as a function on the\ntype of continuous functions. -/\ndef Radon_to_fun (X : Profinite.{0}) (p c : ℝ≥0) :\n X.Radon p c → C(X,ℝ) → ℝ :=\nλ μ, μ.1\n\nlemma Radon_LC_to_fun_injective (X : Profinite.{0}) (p c : ℝ≥0) :\n function.injective (X.Radon_LC_to_fun p c) :=\nbegin\n intros a b h, ext x : 2,\n exact congr_fun h x\nend\n\nlemma Radon_to_fun_injective (X : Profinite.{0}) (p c : ℝ≥0) :\n function.injective (X.Radon_to_fun p c) :=\nbegin\n intros a b h, ext x : 2,\n exact congr_fun h x\nend\n\nlemma Radon_LC_to_fun_continuous (X : Profinite.{0}) (p c : ℝ≥0) :\n continuous (X.Radon_LC_to_fun p c) :=\nbegin\n apply continuous_pi,\n intros f,\n refine continuous.comp (weak_dual.eval_continuous f) (continuous_subtype_coe),\nend\n\nlemma Radon_to_fun_continuous (X : Profinite.{0}) (p c : ℝ≥0) :\n continuous (X.Radon_to_fun p c) :=\nbegin\n apply continuous_pi,\n intros f,\n refine continuous.comp (weak_dual.eval_continuous f) (continuous_subtype_coe),\nend\n\n--WHY!?!?!?\ninstance t2_space_fun_to_R (X : Type*) :\n t2_space (X → ℝ) :=\n@Pi.t2_space X (λ _, ℝ) infer_instance\nbegin\n intros a, dsimp,\n apply_instance\nend\n\ninstance t2_space_Radon_LC (X : Profinite.{0}) (p c : ℝ≥0) :\n t2_space (X.Radon_LC p c) :=\n⟨λ f g h, separated_by_continuous (X.Radon_LC_to_fun_continuous p c)\n $ (X.Radon_LC_to_fun_injective p c).ne h⟩\n\ninstance t2_space_Radon (X : Profinite.{0}) (p c : ℝ≥0) :\n t2_space (X.Radon p c) :=\n⟨λ f g h, separated_by_continuous (X.Radon_to_fun_continuous p c)\n $ (X.Radon_to_fun_injective p c).ne h⟩\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_comparison_component_equiv_aux (X : Profinite.{0}) (p : ℝ≥0)\n (T : discrete_quotient X) :\n weak_dual ℝ (locally_constant (X.diagram.obj T) ℝ) ≃\n real_measures p (X.fintype_diagram.obj T) :=\n{ to_fun := λ μ t,\n μ (clopens.indicator_LC $\n discrete_quotient.fibre ⊥ (discrete_quotient.equiv_bot t)),\n inv_fun := λ μ,\n { to_fun := λ e, ∑ t : T, μ t * e t,\n map_add' := begin\n intros x y,\n dsimp,\n simp only [mul_add, finset.sum_add_distrib],\n end,\n map_smul' := begin\n intros r e, dsimp,\n rw finset.mul_sum,\n simp_rw [← mul_assoc, mul_comm r],\n end,\n cont := begin\n apply continuous_finset_sum, intros t ht,\n refine continuous.comp (continuous_mul_left (μ t)) _,\n apply locally_constant.continuous_eval,\n end },\n left_inv := begin\n intros μ, ext t, dsimp,\n haveI : fintype (X.diagram.obj T),\n { show fintype T, by apply_instance },\n conv_rhs { rw t.eq_sum_of_fintype },\n rw μ.map_sum,\n apply finset.sum_congr, convert rfl,\n intros t ht,\n rw [μ.map_smul, mul_comm], change _ = _ * _,\n congr' 3, ext w, change _ = _ ↔ _ = _,\n split,\n { intros h, apply_fun discrete_quotient.equiv_bot.symm at h,\n erw discrete_quotient.equiv_bot.symm_apply_apply at h,\n rw discrete_quotient.equiv_bot.symm_apply_apply at h,\n exact h },\n { intros h, rw h, refl, }\n end,\n right_inv := begin\n intros μ, ext (t : T), dsimp,\n rw finset.sum_eq_single t,\n { change _ * ite _ _ _ = _, rw if_pos, erw mul_one,\n change _ = _, refl },\n { intros s _ hs, change _ * ite _ _ _ = _, rw [if_neg, mul_zero],\n change _ ≠ _, contrapose! hs,\n apply_fun discrete_quotient.equiv_bot.symm at hs,\n erw discrete_quotient.equiv_bot.symm_apply_apply at hs,\n rw discrete_quotient.equiv_bot.symm_apply_apply at hs,\n exact hs },\n { intros h, exact false.elim (h (finset.mem_univ _)) },\n end }\n\nlemma bdd_LC_iff_comparison\n (X : Profinite.{0}) (T : discrete_quotient X) (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)]\n (f : weak_dual ℝ (locally_constant (X.diagram.obj T) ℝ)) :\n f.bdd_LC p c ↔\n X.Radon_LC_comparison_component_equiv_aux p T f ∈\n pseudo_normed_group.filtration (real_measures p (X.fintype_diagram.obj T)) c :=\nbegin\n split,\n { intros h, change ∑ (t : T), _ ≤ _, specialize h ⊥,\n convert h using 1,\n fapply finset.sum_bij',\n { intros t _, exact discrete_quotient.equiv_bot t, },\n { intros, exact finset.mem_univ _ },\n { intros t _, congr, },\n { intros t _, exact discrete_quotient.equiv_bot.symm t, },\n { intros, exact finset.mem_univ _ },\n { intros, apply equiv.apply_symm_apply },\n { intros, exact discrete_quotient.equiv_bot.apply_symm_apply _, } },\n { intros h E, change ∑ (e : E), _ ≤ _,\n change ∑ (t : T), _ ≤ _ at h,\n dsimp [Radon_LC_comparison_component_equiv_aux] at h,\n refine le_trans _ h,\n have : ∀ e : E,\n (E.fibre e).indicator_LC =\n ∑ t in finset.univ.filter (λ t : T, E.proj t = e),\n ((⊥ : discrete_quotient T).fibre\n (discrete_quotient.equiv_bot t)).indicator_LC,\n { intros e,\n ext (q : T), rw locally_constant.sum_apply,\n change ite (_ = _) (1 : ℝ) 0 = _, split_ifs with hh hh,\n { rw finset.sum_eq_single q,\n change _ = ite (_ = _) (1 : ℝ) _, erw if_pos rfl,\n { intros t ht hh,\n change ite (_ = _) _ (0 : ℝ) = 0, rw if_neg,\n contrapose! hh,\n rw finset.mem_filter at ht,\n apply_fun discrete_quotient.equiv_bot.symm at hh,\n erw discrete_quotient.equiv_bot.symm_apply_apply at hh,\n rw discrete_quotient.equiv_bot.symm_apply_apply at hh,\n exact hh.symm },\n { intros h, refine false.elim (h _), rw finset.mem_filter,\n refine ⟨finset.mem_univ _, hh⟩ } },\n { symmetry, apply finset.sum_eq_zero,\n intros t ht, rw finset.mem_filter at ht,\n change ite (_ = _) _ (0 : ℝ) = 0, rw if_neg,\n contrapose! hh,\n apply_fun discrete_quotient.equiv_bot.symm at hh,\n erw discrete_quotient.equiv_bot.symm_apply_apply at hh,\n rw discrete_quotient.equiv_bot.symm_apply_apply at hh,\n rw hh,\n exact ht.2 } },\n simp_rw [this, f.map_sum], clear this,\n have : ∑ (x : ↥E),\n ∥∑ (i : ↥T) in\n finset.filter (λ (t : ↥T), E.proj t = x) finset.univ,\n f ((⊥ : discrete_quotient T).fibre\n (discrete_quotient.equiv_bot i)).indicator_LC∥₊^(p : ℝ) ≤\n ∑ (x : E), ∑ (i : T) in finset.filter (λ (t : ↥T), E.proj t = x) finset.univ,\n ∥ f ((⊥ : discrete_quotient T).fibre\n (discrete_quotient.equiv_bot i)).indicator_LC∥₊^(p : ℝ),\n { apply finset.sum_le_sum,\n intros e _,\n apply real.pow_nnnorm_sum_le },\n refine le_trans this _, clear this,\n erw ← finset.sum_bUnion,\n have : finset.univ.bUnion (λ (x : ↥E), finset.filter (λ (t : ↥T), E.proj t = x) finset.univ) =\n finset.univ,\n { rw finset.eq_univ_iff_forall,\n intros t,\n rw finset.mem_bUnion,\n refine ⟨E.proj t, finset.mem_univ _, _⟩,\n rw finset.mem_filter,\n refine ⟨finset.mem_univ _, rfl⟩ },\n rw this,\n intros a ha b hb hh q, dsimp, rw finset.mem_inter, rintros ⟨h1,h2⟩,\n simp only [finset.not_mem_empty], apply hh,\n rw finset.mem_filter at h1 h2,\n rw [← h1.2, h2.2] },\nend\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_comparison_component_equiv\n (X : Profinite.{0}) (T : discrete_quotient X) (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)] :\n Radon_LC (X.diagram.obj T) p c ≃\n pseudo_normed_group.filtration (real_measures p (X.fintype_diagram.obj T)) c :=\n{ to_fun := λ μ, ⟨X.Radon_LC_comparison_component_equiv_aux p T μ.1,\n begin\n rw ← bdd_LC_iff_comparison, exact μ.2,\n end⟩,\n inv_fun := λ μ, ⟨(X.Radon_LC_comparison_component_equiv_aux p T).symm μ.1,\n begin\n have := μ.2,\n rw ← (X.Radon_LC_comparison_component_equiv_aux p T).apply_symm_apply μ.val at this,\n rw ← bdd_LC_iff_comparison at this,\n exact this,\n end⟩,\n left_inv := begin\n intros μ, ext1,\n apply (X.Radon_LC_comparison_component_equiv_aux p T).symm_apply_apply,\n end,\n right_inv := begin\n intros μ, ext1,\n apply (X.Radon_LC_comparison_component_equiv_aux p T).apply_symm_apply,\n end }\n\nlemma continuous_Radon_LC_comparison_component_equiv_symm\n (X : Profinite.{0}) (T : discrete_quotient X) (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)] :\n continuous (X.Radon_LC_comparison_component_equiv T p c).symm :=\nbegin\n apply continuous.subtype_mk,\n apply weak_dual.continuous_of_continuous_eval,\n intros y,\n apply continuous_finset_sum,\n rintros t -,\n refine continuous.comp (continuous_mul_right (y t)) _,\n refine continuous.comp (continuous_apply t) continuous_subtype_coe,\nend\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_comparison_component_homeo\n (X : Profinite.{0}) (T : discrete_quotient X) (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)] :\n Radon_LC (X.diagram.obj T) p c ≃ₜ\n pseudo_normed_group.filtration (real_measures p (X.fintype_diagram.obj T)) c :=\n{ continuous_to_fun := begin\n rw continuous_iff_is_closed, intros S hS,\n erw ← (Radon_LC_comparison_component_equiv _ _ _ _).symm.image_eq_preimage,\n apply is_compact.is_closed,\n apply hS.is_compact.image,\n apply continuous_Radon_LC_comparison_component_equiv_symm,\n end,\n continuous_inv_fun := continuous_Radon_LC_comparison_component_equiv_symm _ _ _ _,\n ..(X.Radon_LC_comparison_component_equiv T p c) }\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_comparison_component_iso\n (X : Profinite.{0}) (T : discrete_quotient X) (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)] :\n Radon_LC (X.diagram.obj T) p c ≅\n Top.of (pseudo_normed_group.filtration (real_measures p (X.fintype_diagram.obj T)) c) :=\nTop.iso_of_homeo $ Radon_LC_comparison_component_homeo _ _ _ _\n\nlemma Radon_LC_comparison_naturality_aux (X : Profinite.{0})\n (S T : discrete_quotient X) (f : S ⟶ T) (t : T) (q : S) :\n ((⊥ : discrete_quotient T).fibre (discrete_quotient.equiv_bot t)).indicator_LC\n (X.fintype_diagram.map f q) =\n ∑ i : S in finset.univ.filter (λ j, X.fintype_diagram.map f j = t),\n ((⊥ : discrete_quotient S).fibre (discrete_quotient.equiv_bot i)).indicator_LC q :=\nbegin\n by_cases H : (X.fintype_diagram.map f q = t),\n { rw @finset.sum_eq_single ℝ S _\n (finset.filter (λ (j : (X.fintype_diagram.obj S).α),\n X.fintype_diagram.map f j = t) finset.univ)\n (λ i, ((⊥ : discrete_quotient S).fibre\n (discrete_quotient.equiv_bot i)).indicator_LC q) q _ _,\n { dsimp [clopens.indicator_LC, set.indicator, discrete_quotient.fibre],\n erw if_pos rfl,\n rw if_pos, congr' 1 },\n { intros s hs hsq, rw finset.mem_filter at hs,\n dsimp [clopens.indicator_LC, set.indicator, discrete_quotient.fibre],\n rw if_neg,\n contrapose! hsq,\n apply_fun discrete_quotient.equiv_bot.symm at hsq,\n rw equiv.symm_apply_apply at hsq,\n erw equiv.symm_apply_apply at hsq,\n exact hsq.symm },\n { intros hq,\n erw finset.mem_filter at hq,\n push_neg at hq, specialize hq (finset.mem_univ _),\n exact false.elim (hq H) } },\n { change ite _ _ _ = _, rw if_neg,\n { symmetry, apply finset.sum_eq_zero,\n intros s hs, rw finset.mem_filter at hs, replace hs := hs.2,\n change ite _ _ _ = _, rw if_neg,\n contrapose! H,\n dsimp [discrete_quotient.fibre] at H,\n apply_fun discrete_quotient.equiv_bot.symm at H,\n rw equiv.symm_apply_apply at H,\n erw equiv.symm_apply_apply at H,\n rw H, exact hs },\n { contrapose! H,\n dsimp [discrete_quotient.fibre] at H,\n apply_fun discrete_quotient.equiv_bot.symm at H,\n rw equiv.symm_apply_apply at H,\n erw equiv.symm_apply_apply at H,\n exact H } },\nend\n\n/-- The restriction of `Radon_LC_functor` to the discrete quotients of a profinite set `X`\nis isomorphic to the `c`-th level of the restriction of `real_measures.functor p`.\nThis is one of the key isomorphisms used in the comparison between Radon measures and `ℳ_p`.\n -/\ndef Radon_LC_comparison (X : Profinite.{0}) (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)] :\n X.diagram ⋙ Radon_LC_functor p c ≅\n X.fintype_diagram ⋙ real_measures.functor p ⋙ CompHausFiltPseuNormGrp₁.level.obj c ⋙\n CompHaus_to_Top :=\nnat_iso.of_components\n(λ T, Radon_LC_comparison_component_iso _ _ _ _)\nbegin\n intros S T f,\n ext a t,\n dsimp [Radon_functor, Radon_LC_comparison_component_iso,\n Radon_LC_comparison_component_homeo,\n Radon_LC_comparison_component_equiv,\n Radon_LC_comparison_component_equiv_aux,\n Radon_LC_functor, real_measures.map_hom,\n CompHausFiltPseuNormGrp₁.level,\n map_Radon_LC, weak_dual.comap\n ],\n let aa : weak_dual ℝ (locally_constant S ℝ) := a.1,\n erw ← aa.map_sum,\n congr' 1,\n ext q,\n rw locally_constant.sum_apply,\n dsimp [continuous_map.comap_LC],\n convert Radon_LC_comparison_naturality_aux X S T f t q,\nend\n\nend Profinite\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/Radon/LC_comparison.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5312093585306514, "lm_q2_score": 0.41869690935568665, "lm_q1q2_score": 0.22241571663760062}} {"text": "import data.cpi.transition.basic data.multiset2 data.option2\n\n-- TODO: Move this somewhere sensible\ninstance quot.lift.decidable_pred {α : Type*} [setoid α] (p : α → Prop) [dec : decidable_pred p] (h : ∀ a b, a ≈ b → p a = p b)\n : decidable_pred (quot.lift p h)\n| x := quot.hrec_on x dec (λ x y r, subsingleton.helim (congr_arg decidable (h x y r)) (dec x) (dec y))\n\nnamespace cpi\nnamespace transition\n\nvariables {ℍ : Type} {ω : context}\n\n/-- The set of all transitions from a nil species. -/\ndef enumerate_nil {Γ} {ℓ : lookup ℍ ω Γ}\n : fintype (transition.transition_from ℓ species.nil)\n := ⟨ finset.empty, (λ ⟨ k, α, E, t ⟩, by cases t) ⟩\n\n/-- ξ_choice acts as an embedding. This is effectively ξ_choice.inj but lifted\n to transitions. -/\ndef ξ_choice.embed\n {Γ f} (ℓ : lookup ℍ ω Γ)\n (π : prefix_expr ℍ Γ f) (A : species ℍ ω (f.apply Γ)) (As : species.choices ℍ ω Γ)\n : transition_from ℓ (Σ# As) ↪ transition_from ℓ (Σ# (whole.cons π A As))\n := { to_fun := λ t, transition_from.mk (ξ_choice t.2.2.2),\n inj := λ ⟨ k, α, E, t ⟩ ⟨ k', α', E', t' ⟩ eq, by { cases eq, from rfl} }\n\nprivate def enumerate_choice_communicate_ts {Γ} (ℓ : lookup ℍ ω Γ) :\n ∀ (a : name Γ) (b : list (name Γ)) (y : ℕ)\n (A : species ℍ ω (context.extend y Γ))\n {As : species.choices ℍ ω Γ}\n , fintype (transition_from ℓ (Σ# As))\n → finset (transition_from ℓ (Σ# (whole.cons (a#(b;y)) A As)))\n| a b y A As child :=\n finset.insert_nmem'\n (transition_from.mk (choice₁ a b rfl y A As))\n (finset.map (ξ_choice.embed ℓ _ A As) child.elems)\n (λ mem, begin\n rcases finset.mem_map.mp mem with ⟨ ⟨ k, α, E, t ⟩, mem, eql ⟩,\n\n unfold_coes at eql,\n simp only [ξ_choice.embed, transition_from.mk] at eql,\n unfold_projs at eql,\n cases eql,\n end)\n\nprivate def enumerate_choice_communicate {Γ} (ℓ : lookup ℍ ω Γ) :\n ∀ (a : name Γ) (b : list (name Γ)) (y : ℕ)\n (A : species ℍ ω (context.extend y Γ))\n {As : species.choices ℍ ω Γ}\n , fintype (transition_from ℓ (Σ# As))\n → fintype (transition_from ℓ (Σ# (whole.cons (a#(b;y)) A As)))\n| a b y A As child :=\n { elems := enumerate_choice_communicate_ts ℓ a b y A child,\n complete := λ x, begin\n rcases x with ⟨ k, α, E, t ⟩,\n cases t,\n case ξ_choice {\n have : transition_from.mk t_a ∈ child.elems := @fintype.complete _ child _,\n have this := finset.mem_map_of_mem (ξ_choice.embed ℓ (a#(b;y)) A As) this,\n from finset.mem_insert_nmem_of_mem this _,\n },\n case choice₁ {\n subst t_b_len,\n from finset.mem_insert_nmem_self _\n },\n end }\n\nprivate def enumerate_choice_spontaneous_ts {Γ} (ℓ : lookup ℍ ω Γ) :\n ∀ (k : ℍ) (A : species ℍ ω Γ) {As : species.choices ℍ ω Γ}\n , fintype (transition_from ℓ (Σ# As))\n → finset (transition_from ℓ (Σ# (whole.cons (τ@k) A As)))\n| k A As child :=\n finset.insert_nmem'\n (transition_from.mk (choice₂ k A As))\n (finset.map (ξ_choice.embed ℓ _ A As) child.elems)\n (λ mem, begin\n rcases finset.mem_map.mp mem with ⟨ ⟨ k, α, E, t ⟩, mem, eql ⟩,\n\n unfold_coes at eql,\n simp only [ξ_choice.embed, transition_from.mk] at eql,\n unfold_projs at eql,\n cases eql,\n end)\n\nprivate def enumerate_choice_spontaneous {Γ} (ℓ : lookup ℍ ω Γ) :\n ∀ (k : ℍ) (A : species ℍ ω Γ) {As : species.choices ℍ ω Γ}\n , fintype (transition_from ℓ (Σ# As))\n → fintype (transition_from ℓ (Σ# (whole.cons (τ@k) A As)))\n| k A As child :=\n { elems := enumerate_choice_spontaneous_ts ℓ k A child,\n complete := λ x, begin\n rcases x with ⟨ k', α, E, t ⟩,\n cases t,\n case ξ_choice {\n have : transition_from.mk t_a ∈ child.elems := @fintype.complete _ child _,\n have this := finset.mem_map_of_mem (ξ_choice.embed ℓ (τ@k) A As) this,\n from finset.mem_insert_nmem_of_mem this _,\n },\n case choice₂ { from finset.mem_insert_nmem_self _ },\n end }\n\n/-- The set of all transitions from a guarded choice species. -/\ndef enumerate_choices {Γ} (ℓ : lookup ℍ ω Γ) :\n ∀ (As : species.choices ℍ ω Γ), fintype (transition_from ℓ (Σ# As))\n| species.whole.empty :=\n { elems := finset.empty,\n complete := λ ⟨ k, α, E, t ⟩, by cases t }\n| (species.whole.cons (a#(b; y)) A As) := enumerate_choice_communicate ℓ a b y A (enumerate_choices As)\n| (species.whole.cons (τ@k) A As) := enumerate_choice_spontaneous ℓ k A (enumerate_choices As)\n\nprivate def defn.from {Γ n} (ℓ : lookup ℍ ω Γ) (D : reference n ω) (as : vector (name Γ) n)\n : transition_from ℓ (Σ# (species.rename (name.mk_apply as) (ℓ _ D)))\n → transition_from ℓ (apply D as)\n| ⟨ k, α, E, t ⟩ := ⟨ k, α, E, defn _ _ _ _ rfl t ⟩\n\nprivate def defn.embed {Γ n} (ℓ : lookup ℍ ω Γ) (D : reference n ω) (as : vector (name Γ) n)\n : transition_from ℓ (Σ# (species.rename (name.mk_apply as) (ℓ _ D)))\n ↪ transition_from ℓ (apply D as)\n := ⟨ defn.from ℓ D as, λ t t' eql, begin\n rcases t with ⟨ k, α, E, t ⟩, rcases t' with ⟨ k', α', E', t' ⟩,\n simp only [defn.from] at eql,\n\n rcases sigma.mk.inj eql with ⟨ ⟨ _ ⟩, eql₁ ⟩, clear eql,\n rcases sigma.mk.inj (eq_of_heq eql₁) with ⟨ ⟨ _ ⟩, eql₂ ⟩, clear eql₁,\n rcases sigma.mk.inj (eq_of_heq eql₂) with ⟨ ⟨ _ ⟩, eql₃ ⟩, clear eql₂,\n have eql := eq_of_heq (defn.inj (eq_of_heq eql₃)).2, clear eql₃, subst eql,\n end ⟩\n\nprivate def enumerate_apply_ts {Γ n} (ℓ : lookup ℍ ω Γ) (D : reference n ω) (as : vector (name Γ) n)\n : finset (transition_from ℓ (apply D as))\n := finset.map (defn.embed ℓ D as)\n (enumerate_choices ℓ (species.rename (name.mk_apply as) (ℓ _ D))).elems\n\nprivate lemma enumerate_apply_complete {Γ n} (ℓ : lookup ℍ ω Γ) (D : reference n ω) (as : vector (name Γ) n)\n : ∀ x, x ∈ enumerate_apply_ts ℓ D as\n| ⟨ k, α, E, defn ℓ' D as B eql t ⟩ := begin\n subst eql,\n have h :=\n @fintype.complete _\n (enumerate_choices ℓ (species.rename (name.mk_apply as) (ℓ _ D)))\n (transition_from.mk t),\n from finset.mem_map_of_mem (defn.embed ℓ D as) h,\nend\n\n/-- The set of all transitions from a species invocation. -/\ndef enumerate_apply {Γ n} (ℓ : lookup ℍ ω Γ) (D : reference n ω) (as : vector (name Γ) n)\n : fintype (transition_from ℓ (apply D as)) :=\n ⟨ enumerate_apply_ts ℓ D as, enumerate_apply_complete ℓ D as ⟩\n\n/-- Wrap a transition in parL. -/\ndef parL {Γ : context} {ℓ : lookup ℍ ω Γ} (A B : species ℍ ω Γ)\n : transition.transition_from ℓ A → transition.transition_from ℓ (A |ₛ B)\n| ⟨ _, α, production.species E, t ⟩ := ⟨ _, α, _, transition.parL_species B t ⟩\n| ⟨ _, α, production.concretion E, t ⟩ := ⟨ _, α, _, transition.parL_concretion B t ⟩\n\n/-- Wrap a transition in parL, as a function embedding. -/\ndef parL.embed {Γ} {ℓ : lookup ℍ ω Γ} (A B : species ℍ ω Γ)\n : transition.transition_from ℓ A ↪ transition.transition_from ℓ (A |ₛ B)\n := ⟨ parL A B, λ t t' eq, begin\n rcases t with ⟨ k, α, E, t ⟩, rcases t' with ⟨ k', α', E', t' ⟩,\n cases E; cases E'; cases eq; from rfl,\n end ⟩\n\n/-- Wrap a transition in parR. -/\ndef parR {Γ} {ℓ : lookup ℍ ω Γ} (A B : species ℍ ω Γ)\n : transition.transition_from ℓ B → transition.transition_from ℓ (A |ₛ B)\n| ⟨ _, α, production.species E, t ⟩ := ⟨ _, α, _, transition.parR_species A t ⟩\n| ⟨ _, α, production.concretion E, t ⟩ := ⟨ _, α, _, transition.parR_concretion A t ⟩\n\n/-- Wrap a transition in parL, as a function embedding. -/\ndef parR.embed {Γ} {ℓ : lookup ℍ ω Γ} (A B : species ℍ ω Γ)\n : transition.transition_from ℓ B ↪ transition.transition_from ℓ (A |ₛ B)\n := ⟨ parR A B, λ t t' eq, begin\n rcases t with ⟨ k, α, E, t ⟩, rcases t' with ⟨ k', α', E', t' ⟩,\n cases E; cases E'; cases eq; from rfl,\n end ⟩\n\n/-- Determine if two transitions result have products with compatible\n concretions. -/\nprivate def com₁.is_compatible {Γ} (ℓ : lookup ℍ ω Γ) (A B : species ℍ ω Γ)\n : transition.transition_from ℓ A × transition.transition_from ℓ B\n → Prop\n| ⟨ ⟨ _, l, @production.concretion _ _ _ a x F, t ⟩,\n ⟨ _, l', @production.concretion _ _ _ b y G, t' ⟩ ⟩ := a = y ∧ b = x\n| ⟨ ⟨ _, l, production.concretion F, t ⟩, ⟨ _, l', production.species G, t' ⟩ ⟩ := false\n| ⟨ ⟨ _, l, production.species F, t ⟩, ⟨ _, l', production.concretion G, t' ⟩ ⟩ := false\n| ⟨ ⟨ _, l, production.species F, t ⟩, ⟨ _, l', production.species G, t' ⟩ ⟩ := false\n\ninstance com₁.is_compatible.decide {Γ} (ℓ : lookup ℍ ω Γ) (A B : species ℍ ω Γ)\n : decidable_pred (com₁.is_compatible ℓ A B)\n| ⟨ ⟨ _, l, @production.concretion _ _ _ a x F, t ⟩,\n ⟨ _, l', @production.concretion _ _ _ b y G, t' ⟩ ⟩\n := by { unfold com₁.is_compatible, by apply_instance }\n| ⟨ ⟨ _, l, production.concretion F, t ⟩, ⟨ _, l', production.species G, t' ⟩ ⟩ := decidable.false\n| ⟨ ⟨ _, l, production.species F, t ⟩, ⟨ _, l', production.concretion G, t' ⟩ ⟩ := decidable.false\n| ⟨ ⟨ _, l, production.species F, t ⟩, ⟨ _, l', production.species G, t' ⟩ ⟩ := decidable.false\n\n/-- The subtype of all transition pairs which are compatible. -/\n@[nolint has_inhabited_instance]\ndef com₁.compatible {Γ} (ℓ : lookup ℍ ω Γ) (A B : species ℍ ω Γ) : Type\n := { p : transition.transition_from ℓ A × transition.transition_from ℓ B\n // com₁.is_compatible ℓ A B p }\n\n/-- Convert a compatible pair of transitions to a com₁ transition. -/\ndef com₁.of_compatible {Γ} (ℓ : lookup ℍ ω Γ) (A B : species ℍ ω Γ)\n : com₁.compatible ℓ A B → transition.transition_from ℓ (A |ₛ B)\n| ⟨ ⟨ ⟨ _, l, @production.concretion _ _ _ a x F, t ⟩,\n ⟨ _, l', @production.concretion _ _ _ b y G, t' ⟩ ⟩, p ⟩ := begin\n cases l with _ a, cases l' with _ b, rcases p with ⟨ ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n refine ⟨ _, _, _, com₁ rfl rfl t t' ⟩,\nend\n| ⟨ ⟨ ⟨ _, l, production.concretion F, t ⟩, ⟨ _, l', production.species G, t' ⟩ ⟩, p ⟩ := false.elim p\n| ⟨ ⟨ ⟨ _, l, production.species F, t ⟩, ⟨ _, l', production.concretion G, t' ⟩ ⟩, p ⟩ := false.elim p\n| ⟨ ⟨ ⟨ _, l, production.species F, t ⟩, ⟨ _, l', production.species G, t' ⟩ ⟩, p ⟩ := false.elim p\n\n/-- We need a separate lemma to show com₁.of_compatible - we need to\n generalise several variables, otherwise the case splits do not go through.\n-/\nprivate lemma com₁.of_compatible.inj_help {Γ} {ℓ : lookup ℍ ω Γ} (A B : species ℍ ω Γ) :\n ∀ {a x} {a₁ b₁} {F₁ : concretion ℍ ω Γ a x} {G₁ : concretion ℍ ω Γ x a}\n {b y} {a₂ b₂} {F₂ : concretion ℍ ω Γ b y} {G₂ : concretion ℍ ω Γ y b}\n {FG₁ FG₂ : species ℍ ω Γ} {α₁ α₂ : label ℍ Γ kind.species}\n (eFG₁ : FG₁ = concretion.pseudo_apply F₁ G₁)\n (eFG₂ : FG₂ = concretion.pseudo_apply F₂ G₂)\n (eα₁ : α₁ = τ⟨ a₁, b₁ ⟩) (eα₂ : α₂ = τ⟨ a₂, b₂ ⟩)\n (tf₁ : A [ℓ, #a₁]⟶ (production.concretion F₁)) (tg₁ : B [ℓ, #b₁]⟶ (production.concretion G₁))\n (tf₂ : A [ℓ, #a₂]⟶ (production.concretion F₂)) (tg₂ : B [ℓ, #b₂]⟶ (production.concretion G₂))\n , (τ⟨ a₁, b₁ ⟩ = (τ⟨ a₂, b₂ ⟩ : label ℍ Γ _))\n → sigma.mk (production.species FG₁) (com₁ eFG₁ eα₁ tf₁ tg₁)\n == sigma.mk (production.species FG₂) (com₁ eFG₂ eα₂ tf₂ tg₂)\n → a = b ∧ x = y ∧ a₁ = a₂ ∧ b₁ = b₂ ∧ F₁ == F₂ ∧ G₁ == G₂ ∧ tf₁ == tf₂ ∧ tg₁ == tg₂\n| a x a₁ b₁ F₁ G₁ b y a₂ b₂ F₂ G₂ FG₁ FG₂ α₁ α₂ eFG₁ eFG₂ eα₁ eα₂\n tf₁ tg₁ tf₂ tg₂ eqα eqT := begin\n have : α₁ = α₂ := trans eα₁ (trans eqα eα₂.symm), subst this,\n rcases sigma.mk.inj (eq_of_heq eqT) with ⟨ eqFG, eqT ⟩,\n have : FG₁ = FG₂ := production.species.inj eqFG, subst this,\n\n rcases com₁.inj (eq_of_heq eqT) with ⟨ ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩, F, G, tf, tg ⟩,\n from ⟨ rfl, rfl, rfl, rfl, F, G, tf, tg ⟩,\nend\n\nprivate lemma com₁.of_compatible.inj {Γ} {ℓ : lookup ℍ ω Γ} (A B : species ℍ ω Γ)\n : function.injective (com₁.of_compatible ℓ A B)\n| ⟨ ⟨ ⟨ k₁, α₁, E₁, t₁ ⟩, ⟨ k₁', α₁', E₁', t₁' ⟩ ⟩, is₁ ⟩\n ⟨ ⟨ ⟨ k₂, α₂, E₂, t₂ ⟩, ⟨ k₂', α₂', E₂', t₂' ⟩ ⟩, is₂ ⟩ eql := begin\n cases E₁; cases E₁'; try { unfold com₁.is_compatible at is₁, contradiction },\n rcases is₁ with ⟨ l, r ⟩, subst l, subst r, cases α₁, cases α₁',\n\n cases E₂; cases E₂'; try { unfold com₁.is_compatible at is₂, contradiction },\n rcases is₂ with ⟨ l, r ⟩, subst l, subst r, cases α₂, cases α₂',\n\n simp only [com₁.of_compatible] at eql,\n\n rcases sigma.mk.inj (eq_of_heq (sigma.mk.inj eql).2) with ⟨ eqα, eqT ⟩,\n rcases com₁.of_compatible.inj_help A B rfl rfl rfl rfl t₁ t₁' t₂ t₂' eqα eqT\n with ⟨ ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n from rfl,\nend\n\n/-- Convert a compatible pair of transitions to a com₁ transition. -/\ndef com₁.embed {Γ} (ℓ : lookup ℍ ω Γ) (A B : species ℍ ω Γ)\n : com₁.compatible ℓ A B ↪ transition.transition_from ℓ (A |ₛ B)\n := ⟨ com₁.of_compatible ℓ A B, com₁.of_compatible.inj A B ⟩\n\nprivate lemma com₁.impossible_l {Γ}\n (ℓ : lookup ℍ ω Γ) (A B : species ℍ ω Γ) {b y}\n {F : concretion ℍ ω Γ b y} {G : concretion ℍ ω Γ y b}\n : ∀ {a₁ a₂} {C FG : species ℍ ω Γ}\n (t : A [ℓ, τ⟨ a₁, a₂ ⟩]⟶ (production.species C))\n (t₁ : A [ℓ, #a₁]⟶ (production.concretion F))\n (t₂ : B [ℓ, #a₂]⟶ (production.concretion G))\n (h : FG = concretion.pseudo_apply F G)\n , (C |ₛ B) = FG\n → ¬ (parL_species B t == com₁ h rfl t₁ t₂)\n| a₁ a₂ C FG t t₁ t₂ h cfg eql := by { subst cfg, cases (eq_of_heq eql) }\n\nprivate lemma com₁.impossible_r {Γ}\n (ℓ : lookup ℍ ω Γ) (A B : species ℍ ω Γ) {b y}\n {F : concretion ℍ ω Γ b y} {G : concretion ℍ ω Γ y b}\n : ∀ {a₁ a₂} {C FG : species ℍ ω Γ}\n (t : B [ℓ, τ⟨ a₁, a₂ ⟩]⟶ (production.species C))\n (t₁ : A [ℓ, #a₁]⟶ (production.concretion F))\n (t₂ : B [ℓ, #a₂]⟶ (production.concretion G))\n (h : FG = concretion.pseudo_apply F G)\n , (A |ₛ C) = FG\n → ¬ (parR_species A t == com₁ h rfl t₁ t₂)\n| a₁ a₂ C FG t t₁ t₂ h cfg eql := by { subst cfg, cases (eq_of_heq eql) }\n\nprivate def enumerate_parallel_ts {Γ} {ℓ : lookup ℍ ω Γ} (A B : species ℍ ω Γ)\n : fintype (transition.transition_from ℓ A)\n → fintype (transition.transition_from ℓ B)\n → finset (transition.transition_from ℓ (A |ₛ B))\n| As Bs :=\n finset.union_disjoint\n (finset.map\n (com₁.embed ℓ A B)\n ((finset.product As.elems Bs.elems).subtype (com₁.is_compatible ℓ A B)))\n (finset.union_disjoint\n (As.elems.map (parL.embed A B))\n (Bs.elems.map (parR.embed A B))\n (λ x memL memR, begin\n rcases finset.mem_map.mp memL with ⟨ ⟨ k, α, E, t ⟩, mem, eql ⟩, clear mem,\n unfold_coes at eql, simp only [parL.embed] at eql, subst eql,\n\n rcases finset.mem_map.mp memR with ⟨ ⟨ k', α', E', t' ⟩, mem, eql ⟩, clear mem,\n unfold_coes at eql, simp only [parR.embed] at eql,\n\n cases E; cases E'; simp only [parL, parR] at eql; cases eql,\n end))\n (λ x memL memR, begin\n rcases finset.mem_map.mp memL with ⟨ ⟨ ⟨ ⟨ k₁, α₁, E₁, t₁ ⟩, ⟨ k₂, α₂, E₂, t₂ ⟩ ⟩, d ⟩, mem, eql ⟩, clear memL mem,\n unfold_coes at eql, simp only [com₁.embed] at eql,\n cases E₁; cases E₂; try { simpa only [com₁.is_compatible] using d },\n rcases d with ⟨ ⟨ _ ⟩, ⟨ _ ⟩ ⟩, cases α₁, cases α₂,\n simp only [com₁.of_compatible] at eql, subst eql,\n\n cases finset.mem_union_disjoint.mp memR,\n case or.inl {\n rcases finset.mem_map.mp h with ⟨ ⟨ k, α, E, t ⟩, mem, eql ⟩, clear mem memR,\n unfold_coes at eql, simp only [parL.embed] at eql,\n cases E,\n case production.species {\n rcases sigma.mk.inj eql with ⟨ ⟨ _ ⟩, eql₁ ⟩, clear eql,\n rcases sigma.mk.inj (eq_of_heq eql₁) with ⟨ ⟨ _ ⟩, eql₂ ⟩, clear eql₁,\n rcases sigma.mk.inj (eq_of_heq eql₂) with ⟨ eqlE, eqlT ⟩,\n\n from com₁.impossible_l ℓ A B t t₁ t₂ rfl (production.species.inj eqlE) eqlT,\n },\n case production.concretion { cases (sigma.mk.inj eql).1 },\n },\n case or.inr {\n rcases finset.mem_map.mp h with ⟨ ⟨ k, α, E, t ⟩, mem, eql ⟩, clear mem memR,\n unfold_coes at eql, simp only [parR.embed] at eql,\n cases E,\n case production.species {\n rcases sigma.mk.inj eql with ⟨ ⟨ _ ⟩, eql₁ ⟩, clear eql,\n rcases sigma.mk.inj (eq_of_heq eql₁) with ⟨ ⟨ _ ⟩, eql₂ ⟩, clear eql₁,\n rcases sigma.mk.inj (eq_of_heq eql₂) with ⟨ eqlE, eqlT ⟩,\n\n from com₁.impossible_r ℓ A B t t₁ t₂ rfl (production.species.inj eqlE) eqlT,\n },\n case production.concretion { cases (sigma.mk.inj eql).1 },\n },\n end)\n\nprivate lemma enumate_parallel_compute_l_species\n {Γ ℓ} {A B : species ℍ ω Γ} {l : label ℍ Γ kind.species} {E}\n (As : fintype (transition_from ℓ A)) (Bs : fintype (transition_from ℓ B))\n (t : transition A ℓ l (production.species E))\n : transition_from.mk (parL_species B t) ∈ enumerate_parallel_ts A B As Bs :=\n let h := @fintype.complete _ As (transition_from.mk t) in\n let g := finset.mem_map_of_mem (parL.embed A B) h in\n finset.mem_union_disjoint.mpr (or.inr (finset.mem_union_disjoint.mpr (or.inl g)))\n\nprivate lemma enumate_parallel_compute_l_concretion\n {Γ ℓ} {A B} {l : label ℍ Γ kind.concretion} {b y} {E : concretion ℍ ω Γ b y}\n (As : fintype (transition_from ℓ A)) (Bs : fintype (transition_from ℓ B))\n (t : transition A ℓ l (production.concretion E))\n : transition_from.mk (parL_concretion B t) ∈ enumerate_parallel_ts A B As Bs :=\n let h := @fintype.complete _ As (transition_from.mk t) in\n let g := finset.mem_map_of_mem (parL.embed A B) h in\n finset.mem_union_disjoint.mpr (or.inr (finset.mem_union_disjoint.mpr (or.inl g)))\n\nprivate lemma enumate_parallel_compute_r_species\n {Γ ℓ} {A B : species ℍ ω Γ} {l : label ℍ Γ kind.species} {E}\n (As : fintype (transition_from ℓ A)) (Bs : fintype (transition_from ℓ B))\n (t : transition B ℓ l (production.species E))\n : transition_from.mk (parR_species A t) ∈ enumerate_parallel_ts A B As Bs :=\n let h := @fintype.complete _ Bs (transition_from.mk t) in\n let g := finset.mem_map_of_mem (parR.embed A B) h in\n finset.mem_union_disjoint.mpr (or.inr (finset.mem_union_disjoint.mpr (or.inr g)))\n\nprivate lemma enumerate_parallel_complete {Γ} {ℓ : lookup ℍ ω Γ} (A B : species ℍ ω Γ)\n (As : fintype (transition.transition_from ℓ A)) (Bs : fintype (transition.transition_from ℓ B))\n : ∀ x, x ∈ enumerate_parallel_ts A B As Bs\n| ⟨ k, α, E, parL_species _ t ⟩ := enumate_parallel_compute_l_species As Bs t\n| ⟨ k, α, E, parL_concretion _ t ⟩ := enumate_parallel_compute_l_concretion As Bs t\n| ⟨ k, α, E, parR_species _ t ⟩ := enumate_parallel_compute_r_species As Bs t\n| ⟨ k, α, E, parR_concretion _ t ⟩ :=\n let h := @fintype.complete _ Bs (transition_from.mk t) in\n let g := finset.mem_map_of_mem (parR.embed A B) h in\n finset.mem_union_disjoint.mpr (or.inr (finset.mem_union_disjoint.mpr (or.inr g)))\n| ⟨ k, α, E, com₁ eqFG eqα tf tg ⟩ := begin\n subst eqFG, subst eqα,\n let t : com₁.compatible ℓ A B\n := ⟨ ( transition_from.mk tf, transition_from.mk tg ), ⟨ rfl, rfl ⟩ ⟩,\n have h\n := finset.mem_subtype.mpr\n (finset.mem_product.mpr ⟨ @fintype.complete _ As t.val.1, @fintype.complete _ Bs t.val.2 ⟩),\n from finset.mem_union_disjoint.mpr (or.inl (finset.mem_map_of_mem (com₁.embed ℓ A B) h)),\nend\n\n/-- The set of all transitions from a parallel composition of species -/\ndef enumerate_parallel {Γ} {ℓ : lookup ℍ ω Γ} {A B : species ℍ ω Γ}\n : fintype (transition.transition_from ℓ A)\n → fintype (transition.transition_from ℓ B)\n → fintype (transition.transition_from ℓ (A |ₛ B))\n| As Bs := ⟨ enumerate_parallel_ts A B As Bs, enumerate_parallel_complete A B As Bs ⟩\n\nprivate def is_restriction_name {Γ} (M : affinity ℍ)\n : name (context.extend M.arity Γ) → name (context.extend M.arity Γ)\n → Prop\n| (name.zero a) (name.zero b) := option.is_some' (M.f a b)\n| (name.extend _) (name.extend _) := true\n| (name.extend _) (name.zero _) := false\n| (name.zero _) (name.extend _) := false\n\nprivate def is_restriction_name.comm {Γ} (M : affinity ℍ)\n : ∀ (a b : name (context.extend M.arity Γ))\n , is_restriction_name M a b = is_restriction_name M b a\n| a b := by { cases a; cases b; from rfl <|> simp only [is_restriction_name, M.symm] }\n\nprivate def is_restriction_like {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ) (A : species ℍ ω (context.extend M.arity Γ))\n : transition.transition_from (lookup.rename name.extend ℓ) A\n → Prop\n| ⟨ _, τ⟨ p ⟩, E, t ⟩ := upair.lift_on p (is_restriction_name M) (is_restriction_name.comm M)\n| ⟨ _, τ@' k, E, t ⟩ := true\n| ⟨ _, # (name.zero n), E, t ⟩ := false\n| ⟨ _, # (name.extend n), E, t ⟩ := true\n\nprivate def is_restriction {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ) (A : species ℍ ω (context.extend M.arity Γ))\n := { t : transition_from (lookup.rename name.extend ℓ) A // is_restriction_like ℓ M A t }\n\nprivate def is_restriction.name_lift {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ)\n (A : species ℍ ω (context.extend M.arity Γ))\n (B : species ℍ ω (context.extend M.arity Γ)) :\n ∀ (a b : name (context.extend M.arity Γ))\n , is_restriction_name M a b\n → A [lookup.rename name.extend ℓ, τ⟨ a, b ⟩]⟶ (production.species B)\n → transition.transition_from ℓ (ν(M) A)\n| (name.zero a) (name.zero b) is_some t :=\n let this : M.get (upair.mk a b) = some (option.get' is_some) := option.eq_some_of_is_some' is_some in\n ⟨ _, _, _, com₂ M (option.get' is_some) this rfl t ⟩\n| (name.extend a) (name.extend b) fls t := begin\n have : τ⟨ name.extend a, name.extend b ⟩ = label.rename (@name.extend Γ M.arity) (τ⟨ a, b ⟩),\n { simpa only [label.rename] },\n from ⟨ _, _, _, ν₁_species M this t ⟩,\nend\n| (name.extend _) (name.zero _) fls t := false.elim fls\n| (name.zero a) (name.extend b) fls t := false.elim fls\n\nprivate lemma is_restriction_name_lift.comm_zero {Γ} {ℓ : lookup ℍ ω Γ} (M : affinity ℍ) (A B : species ℍ ω (context.extend M.arity Γ))\n {x y : fin M.arity}\n {tL : A [lookup.rename name.extend ℓ, τ⟨ (upair.mk (name.zero x) (name.zero y)) ⟩]⟶ (production.species B)}\n {tR : A [lookup.rename name.extend ℓ, τ⟨ (upair.mk (name.zero y) (name.zero x)) ⟩]⟶ (production.species B)}\n (eT : tL == tR)\n (k₁ k₂ : ℍ)\n (e₁ : M.get (upair.mk x y) = some k₁)\n (e₂ : M.get (upair.mk y x) = some k₂)\n : transition.transition_from.mk (com₂ M k₁ e₁ rfl tL) = transition.transition_from.mk (com₂ M k₂ e₂ rfl tR) := begin\n have : k₁ = k₂,\n {\n rw upair.mk.comm at e₁,\n from option.some.inj (trans e₁.symm e₂),\n }, subst this,\n\n refine sigma.mk.inj_iff.mpr ⟨ rfl, heq_of_eq _ ⟩, simp only [heq_iff_eq],\n from ⟨ rfl, ⟨ rfl, rfl ⟩, quot.sound (or.inr ⟨ rfl, rfl ⟩), quot.sound (or.inr ⟨ rfl, rfl ⟩), eT ⟩,\nend\n\nprivate lemma is_restriction_name_lift.comm_extend {Γ} {ℓ : lookup ℍ ω Γ} (M : affinity ℍ) (A B : species ℍ ω (context.extend M.arity Γ))\n {x y : name Γ}\n {tL : A [lookup.rename name.extend ℓ, τ⟨ (upair.mk (name.extend x) (name.extend y)) ⟩]⟶ (production.species B)}\n {tR : A [lookup.rename name.extend ℓ, τ⟨ (upair.mk (name.extend y) (name.extend x)) ⟩]⟶ (production.species B)}\n (eT : tL == tR)\n (l₁ l₂ : label ℍ Γ kind.species)\n (e₁ : τ⟨ (upair.mk (name.extend x) (name.extend y)) ⟩ = label.rename name.extend l₁)\n (e₂ : τ⟨ (upair.mk (name.extend y) (name.extend x)) ⟩ = label.rename name.extend l₂)\n : transition.transition_from.mk (ν₁_species M e₁ tL) = transition.transition_from.mk (ν₁_species M e₂ tR) := begin\n have : l₁ = l₂,\n {\n rw [upair.mk.comm] at e₁,\n from label.rename.inj (@name.extend.inj _ _) (trans e₁.symm e₂),\n }, subst this,\n\n refine sigma.mk.inj_iff.mpr ⟨ rfl, heq_of_eq _ ⟩, simp only [heq_iff_eq],\n from ⟨ rfl, ⟨ rfl, rfl ⟩, quot.sound (or.inr ⟨ rfl, rfl ⟩), eT ⟩,\nend\n\nprivate lemma is_restriction.name_lift.comm {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ) (A B : species ℍ ω (context.extend M.arity Γ)) :\n ∀ (a b : name (context.extend M.arity Γ))\n , is_restriction.name_lift ℓ M A B a b\n == is_restriction.name_lift ℓ M A B b a\n| (name.zero x) (name.zero y) := function.hfunext\n (by { unfold is_restriction_name, rw M.symm })\n (λ irlL irlR eIRL, function.hfunext\n (by rw upair.mk.comm)\n (λ tL tR eT, heq_of_eq (is_restriction_name_lift.comm_zero M A B eT _ _ _ _)))\n| (name.extend x) (name.extend y) := function.hfunext rfl\n (λ irlL irlR eIRL, function.hfunext\n (by rw upair.mk.comm)\n (λ tL tR eT, heq_of_eq (is_restriction_name_lift.comm_extend M A B eT _ _ _ _)))\n| (name.zero x) (name.extend y) := function.hfunext rfl\n (λ irlL irlR eIRL, function.hfunext (by rw upair.mk.comm) (λ x b z, heq.rfl))\n| (name.extend x) (name.zero y) := function.hfunext rfl\n (λ irlL irlR eIRL, function.hfunext (by rw upair.mk.comm) (λ x b z, heq.rfl))\n\nlemma ν₁_species.inj' {Γ} {ℓ : lookup ℍ ω Γ} (M : affinity ℍ) {A} :\n ∀ {E₁ E₂}\n {l₁ : label ℍ Γ kind.species} {l'₁ : label ℍ (context.extend M.arity Γ) kind.species}\n {l₂ : label ℍ Γ kind.species} {l'₂ : label ℍ (context.extend M.arity Γ) kind.species}\n {e₁ : l'₁ = label.rename name.extend l₁}\n {e₂ : l'₂ = label.rename name.extend l₂}\n {t₁ : A [lookup.rename name.extend ℓ, l'₁]⟶ (production.species E₁)}\n {t₂ : A [lookup.rename name.extend ℓ, l'₂]⟶ (production.species E₂)}\n , transition_from.mk (ν₁_species M e₁ t₁) = transition_from.mk (ν₁_species M e₂ t₂)\n → transition_from.mk t₁ = transition_from.mk t₂\n| E₁ E₂ l₁ l'₁ l₂ l'₂ e₁ e₂ t₁ t₂ eql := begin\n rcases sigma.mk.inj (eq_of_heq (sigma.mk.inj eql).2) with ⟨ this, eqR ⟩, subst ‹l₁ = l₂›,\n have : l'₁ = l'₂ := trans e₁ e₂.symm, subst ‹l'₁ = l'₂›,\n\n rcases sigma.mk.inj (eq_of_heq eqR) with ⟨ ⟨ _ ⟩, eqT ⟩,\n rcases ν₁_species.inj (eq_of_heq eqT) with ⟨ _, ⟨ _ ⟩ ⟩,\n from rfl,\nend\n\nlemma ν₁_concretion.inj' {Γ} {ℓ : lookup ℍ ω Γ} (M : affinity ℍ) {A} :\n ∀ {a x b y} {E₁ : concretion ℍ ω _ a x} {E₂ : concretion ℍ ω _ b y}\n {l₁ : label ℍ Γ kind.concretion} {l'₁ : label ℍ (context.extend M.arity Γ) kind.concretion}\n {l₂ : label ℍ Γ kind.concretion} {l'₂ : label ℍ (context.extend M.arity Γ) kind.concretion}\n {e₁ : l'₁ = label.rename name.extend l₁}\n {e₂ : l'₂ = label.rename name.extend l₂}\n {t₁ : A [lookup.rename name.extend ℓ, l'₁]⟶ (production.concretion E₁)}\n {t₂ : A [lookup.rename name.extend ℓ, l'₂]⟶ (production.concretion E₂)}\n , transition_from.mk (ν₁_concretion M e₁ t₁) = transition_from.mk (ν₁_concretion M e₂ t₂)\n → transition_from.mk t₁ = transition_from.mk t₂\n| a x b y E₁ E₂ l₁ l'₁ l₂ l'₂ e₁ e₂ t₁ t₂ eql := begin\n rcases sigma.mk.inj (eq_of_heq (sigma.mk.inj eql).2) with ⟨ this, eqR ⟩, subst ‹l₁ = l₂›,\n have : l'₁ = l'₂ := trans e₁ e₂.symm, subst ‹l'₁ = l'₂›,\n\n rcases sigma.mk.inj (eq_of_heq eqR) with ⟨ ⟨ _ ⟩, eqT ⟩,\n rcases ν₁_concretion.inj (eq_of_heq eqT) with ⟨ _, ⟨ _ ⟩ ⟩,\n from rfl,\nend\n\nprivate lemma is_restriction.name_lift.inj_zero {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ)\n (A : species ℍ ω (context.extend M.arity Γ)) :\n ∀ {B₁ B₂ : species ℍ ω (context.extend M.arity Γ)}\n {p q : upair (fin M.arity)}\n {t₁ : A [lookup.rename name.extend ℓ, τ⟨ (upair.map name.zero p) ⟩]⟶ (production.species B₁)}\n {t₂ : A [lookup.rename name.extend ℓ, τ⟨ (upair.map name.zero q) ⟩]⟶ (production.species B₂)}\n {k₁ k₂ : ℍ} {e₁ : M.get p = some k₁} {e₂ : M.get q = some k₂}\n , transition_from.mk (com₂ M k₁ e₁ rfl t₁) = transition_from.mk (com₂ M k₂ e₂ rfl t₂)\n → transition_from.mk t₁ = transition_from.mk t₂\n| B₁ B₂ p q t₁ t₂ k₁ k₂ e₁ e₂ eql := begin\n rcases sigma.mk.inj (eq_of_heq (sigma.mk.inj eql).2) with ⟨ ⟨ _ ⟩, eqR ⟩,\n rcases sigma.mk.inj (eq_of_heq eqR) with ⟨ ⟨ _ ⟩, eqT ⟩,\n rcases com₂.inj (eq_of_heq eqT) with ⟨ ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n from rfl,\nend\n\nprivate lemma is_restriction.name_lift.inj {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ)\n (A : species ℍ ω (context.extend M.arity Γ)) {B₁ B₂ : species ℍ ω (context.extend M.arity Γ)} :\n ∀ {a₁ b₁ a₂ b₂ : name (context.extend M.arity Γ)}\n (t₁ : A [lookup.rename name.extend ℓ, τ⟨ a₁, b₁ ⟩]⟶ (production.species B₁))\n (t₂ : A [lookup.rename name.extend ℓ, τ⟨ a₂, b₂ ⟩]⟶ (production.species B₂))\n (irl₁ : is_restriction_name M a₁ b₁)\n (irl₂ : is_restriction_name M a₂ b₂)\n , is_restriction.name_lift ℓ M A B₁ a₁ b₁ irl₁ t₁ = is_restriction.name_lift ℓ M A B₂ a₂ b₂ irl₂ t₂\n → transition_from.mk t₁ = transition_from.mk t₂\n| a₁ b₁ a₂ b₂ t₁ t₂ irl₁ irl₂ eql := begin\n cases a₁; cases b₁; try { from false.elim irl₁ };\n cases a₂; cases b₂; try { from false.elim irl₂ <|> cases eql };\n simp only [is_restriction.name_lift] at eql,\n\n case name.extend { from ν₁_species.inj' M eql },\n case name.zero { from is_restriction.name_lift.inj_zero ℓ M A eql },\nend\n\nprivate def is_restriction.lift {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ) (A : species ℍ ω (context.extend M.arity Γ))\n : is_restriction ℓ M A\n → transition.transition_from ℓ (ν(M) A)\n| ⟨ ⟨ _, τ@' k, production.species B, t ⟩, _ ⟩ := begin\n have : τ@' k = label.rename (@name.extend Γ M.arity) (τ@' k), { simp only [label.rename] },\n from ⟨ _, _, _, ν₁_species M this t ⟩,\nend\n| ⟨ ⟨ _, τ⟨ p ⟩, production.species B, t ⟩, irl ⟩ := begin\n unfold is_restriction_like at irl,\n from upair.rec_on p\n (λ a b irl t, is_restriction.name_lift ℓ M A B a b irl t)\n (is_restriction.name_lift.comm ℓ M A B)\n irl t,\nend\n| ⟨ ⟨ _, # (name.zero n), E, t ⟩, irl ⟩ := false.elim irl\n| ⟨ ⟨ _, # (name.extend n), production.concretion F, t ⟩, _ ⟩ := begin\n have : # (name.extend n) = label.rename (@name.extend Γ M.arity) (# n), { simp only [label.rename] },\n from ⟨ _, # n, production.concretion (ν'(M) F), ν₁_concretion M this t ⟩,\nend\n\nprivate def is_restriction.lift.inj_both {Γ : context} {ℓ : lookup ℍ ω Γ}\n (M : affinity ℍ) (A B : species ℍ ω (context.extend M.arity Γ)) :\n ∀ {B B' : species ℍ ω (context.extend M.arity Γ)}\n {p q : upair (name (context.extend M.arity Γ))}\n\n (t : A [lookup.rename name.extend ℓ, τ⟨ p ⟩]⟶ (production.species B))\n (irl : is_restriction_like ℓ M A ⟨kind.species, ⟨τ⟨ p ⟩, ⟨production.species B, t⟩⟩⟩)\n\n (t' : A [lookup.rename name.extend ℓ, τ⟨ q ⟩]⟶ (production.species B'))\n (irl' : is_restriction_like ℓ M A ⟨kind.species, ⟨τ⟨ q ⟩, ⟨production.species B', t'⟩⟩⟩)\n\n , is_restriction.lift ℓ M A ⟨⟨kind.species, ⟨τ⟨ p ⟩, ⟨production.species B, t⟩⟩⟩, irl⟩\n = is_restriction.lift ℓ M A ⟨⟨kind.species, ⟨τ⟨ q ⟩, ⟨production.species B', t'⟩⟩⟩, irl'⟩\n → (⟨⟨kind.species, ⟨τ⟨ p ⟩, ⟨production.species B, t⟩⟩⟩, irl⟩ : is_restriction ℓ M A)\n = ⟨⟨kind.species, ⟨τ⟨ q ⟩, ⟨production.species B', t'⟩⟩⟩, irl'⟩\n| B B' p q t irl t' irl' eql := begin\n unfold is_restriction.lift at eql,\n rcases upair.exists_rep p with ⟨ a, b, ⟨ _ ⟩ ⟩,\n rcases upair.exists_rep q with ⟨ a', b', ⟨ _ ⟩ ⟩,\n\n simp only [],\n from is_restriction.name_lift.inj ℓ M A t t' irl irl' eql,\nend\n\nprivate def is_restriction.lift.inj {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ) (A : species ℍ ω (context.extend M.arity Γ))\n : function.injective (is_restriction.lift ℓ M A)\n| ⟨ ⟨ _, # (name.zero n), E, t ⟩, irl ⟩ _ eql := false.elim irl\n\n| ⟨ ⟨ _, τ@' k, production.species B, t ⟩, _ ⟩ ⟨ ⟨ _, # (name.zero n), E, t' ⟩, irl ⟩ eql := false.elim irl\n| ⟨ ⟨ _, τ@' k, production.species B, t ⟩, _ ⟩ ⟨ ⟨ _, τ@' k', production.species B', t' ⟩, _ ⟩ eql\n := by { cases ν₁_species.inj' M eql, from rfl }\n| ⟨ ⟨ _, τ@' k, production.species B, t ⟩, _ ⟩ ⟨ ⟨ _, τ⟨ p ⟩, production.species B', t' ⟩, irl ⟩ eql := begin\n rcases upair.exists_rep p with ⟨ a, b, ⟨ _ ⟩ ⟩,\n simp only [is_restriction.lift, upair.rec_on_beta] at eql,\n cases a; cases b; cases eql <|> from false.elim irl,\nend\n| ⟨ ⟨ _, τ@' k, production.species B, t ⟩, _ ⟩ ⟨ ⟨ _, # (name.extend n), production.concretion F, t' ⟩, _ ⟩ eql := by cases eql\n\n| ⟨ ⟨ _, τ⟨ p ⟩, production.species B, t ⟩, _ ⟩ ⟨ ⟨ _, # (name.zero n'), E, t' ⟩, irl ⟩ eql := false.elim irl\n| ⟨ ⟨ _, τ⟨ p ⟩, production.species B, t ⟩, irl ⟩ ⟨ ⟨ _, # (name.extend n'), production.concretion F', t' ⟩, _ ⟩ eql := begin\n rcases upair.exists_rep p with ⟨ a, b, ⟨ _ ⟩ ⟩,\n simp only [is_restriction.lift, upair.rec_on_beta] at eql,\n cases a; cases b; cases eql <|> from false.elim irl,\nend\n| ⟨ ⟨ _, τ⟨ p ⟩, production.species B, t ⟩, irl ⟩ ⟨ ⟨ _, τ@' k', production.species B', t' ⟩, _ ⟩ eql := begin\n rcases upair.exists_rep p with ⟨ a, b, ⟨ _ ⟩ ⟩,\n simp only [is_restriction.lift, upair.rec_on_beta] at eql,\n cases a; cases b; cases eql <|> from false.elim irl,\nend\n| ⟨ ⟨ _, τ⟨ p ⟩, production.species B, t ⟩, irl ⟩ ⟨ ⟨ _, τ⟨ q ⟩, production.species B', t' ⟩, irl' ⟩ eql\n := is_restriction.lift.inj_both M A B t irl t' irl' eql\n\n| ⟨ ⟨ _, # (name.extend n), production.concretion F, t ⟩, _ ⟩ ⟨ ⟨ _, # (name.extend n'), production.concretion F', t' ⟩, _ ⟩ eql\n := by { cases ν₁_concretion.inj' M eql, from rfl }\n| ⟨ ⟨ _, # (name.extend n), production.concretion F, t ⟩, _ ⟩ ⟨ ⟨ _, # (name.zero n'), E, t' ⟩, irl ⟩ eql := false.elim irl\n| ⟨ ⟨ _, # (name.extend n), production.concretion F, t ⟩, _ ⟩ ⟨ ⟨ _, τ@' k', production.species B', t' ⟩, _ ⟩ eql := by cases eql\n| ⟨ ⟨ _, # (name.extend n), production.concretion F, t ⟩, _ ⟩ ⟨ ⟨ _, τ⟨ p ⟩, production.species B', t' ⟩, irl ⟩ eql := begin\n rcases upair.exists_rep p with ⟨ a, b, ⟨ _ ⟩ ⟩,\n simp only [is_restriction.lift, upair.rec_on_beta] at eql,\n cases a; cases b; cases eql <|> from false.elim irl,\nend\n\nprivate def is_restriction.embed {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ) (A : species ℍ ω (context.extend M.arity Γ))\n : is_restriction ℓ M A\n ↪ transition.transition_from ℓ (ν(M) A)\n := ⟨ is_restriction.lift ℓ M A, is_restriction.lift.inj ℓ M A ⟩\n\ninstance is_restriction_name.decide {Γ} (M : affinity ℍ)\n : decidable_pred (λ (p : upair.pair (name (context.extend M.arity Γ))), is_restriction_name M p.fst p.snd)\n| ⟨ name.zero a, name.zero b ⟩ := by { unfold is_restriction_name, apply_instance }\n| ⟨ name.extend _, name.extend _ ⟩ := decidable.true\n| ⟨ name.extend _, name.zero _ ⟩ := decidable.false\n| ⟨ name.zero _, name.extend _ ⟩ := decidable.false\n\ninstance is_restriction_like.decide {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ) (A : species ℍ ω (context.extend M.arity Γ))\n : decidable_pred (is_restriction_like ℓ M A)\n| ⟨ _, τ⟨ p ⟩, E, t ⟩ := quot.lift.decidable_pred _ _ _\n| ⟨ _, τ@' k, E, t ⟩ := decidable.true\n| ⟨ _, # (name.zero n), E, t ⟩ := decidable.false\n| ⟨ _, # (name.extend n), E, t ⟩ := decidable.true\n\nprivate def enumerate_restriction {Γ} (ℓ : lookup ℍ ω Γ) (M : affinity ℍ) (A : species ℍ ω (context.extend M.arity Γ))\n : fintype (transition.transition_from (lookup.rename name.extend ℓ) A)\n → fintype (transition.transition_from ℓ (ν(M) A))\n| As :=\n ⟨ finset.map (is_restriction.embed ℓ M A)\n (finset.subtype (is_restriction_like ℓ M A) As.elems)\n , λ t, begin\n rcases t with ⟨ k, α, E, t ⟩,\n cases t,\n case com₂ : p p' B k eql eqp t {\n rcases upair.exists_rep p with ⟨ a, b, ep' ⟩, subst ep',\n\n simp only [upair.map_beta] at eqp, subst eqp, cases eqp,\n\n have : is_restriction_like ℓ M A (transition_from.mk t),\n {\n show option.is_some' (M.f a b),\n have : M.f a b = some k := eql,\n rw this, from true.intro,\n },\n\n have kdef : k = option.get' this := option.some.inj (trans eql.symm (option.eq_some_of_is_some' this)),\n subst kdef,\n\n let t' : is_restriction ℓ M A := ⟨ ⟨ _, _, _, t ⟩, this ⟩,\n have this := finset.mem_map_of_mem (is_restriction.embed ℓ M A)\n (finset.mem_subtype.mpr (@fintype.complete _ As t'.val)),\n unfold_coes at this,\n simp only [is_restriction.embed, is_restriction.lift, upair.rec_on_beta, is_restriction.name_lift] at this,\n\n from this,\n },\n case ν₁_species : l l' B eql t {\n have : is_restriction_like ℓ M A (transition_from.mk t),\n {\n cases l; simp only [label.rename] at eql; subst eql;\n simp only [transition_from.mk, is_restriction_like],\n\n rcases upair.exists_rep l_k with ⟨ a, b, ⟨ _ ⟩ ⟩,\n from true.intro,\n },\n let t' : is_restriction ℓ M A := ⟨ ⟨ _, _, _, t ⟩, this ⟩,\n have this := finset.mem_map_of_mem (is_restriction.embed ℓ M A)\n (finset.mem_subtype.mpr (@fintype.complete _ As t'.val)),\n unfold_coes at this,\n\n cases l,\n case label.spontaneous { simp only [label.rename] at eql, subst eql, from this },\n\n have up : ∀ (a b : name Γ), (quot.mk setoid.r (upair.pair.mk a b)) = upair.mk a b := λ a b, rfl,\n rcases quot.exists_rep l_k with ⟨ ⟨ a, b ⟩, h ⟩, rw up at h, subst h,\n simp only [label.rename, upair.map_beta] at eql, subst eql,\n\n simp only [is_restriction.embed, is_restriction.lift, upair.rec_on_beta, is_restriction.name_lift] at this,\n from this,\n },\n case ν₁_concretion : l l' b y B eql t {\n cases l, simp only [label.rename] at eql, subst eql,\n let t' : is_restriction ℓ M A := ⟨ ⟨ _, _, _, t ⟩, true.intro ⟩,\n from finset.mem_map_of_mem (is_restriction.embed ℓ M A)\n (finset.mem_subtype.mpr (@fintype.complete _ As t'.val)),\n }\n end ⟩\n\n/-- Show that the available transitions from a species is finite and thus\n enumerable.-/\ndef enumerate :\n ∀ {Γ} (ℓ : lookup ℍ ω Γ) (A : species ℍ ω Γ)\n , fintype (transition_from ℓ A)\n| Γ ℓ nil := enumerate_nil\n| Γ ℓ (apply D as) := enumerate_apply ℓ D as\n| Γ ℓ (A |ₛ B) := enumerate_parallel (enumerate ℓ A) (enumerate ℓ B)\n| Γ ℓ (Σ# As) := enumerate_choices ℓ As\n| Γ ℓ (ν(M) A) := enumerate_restriction ℓ M A (enumerate (lookup.rename name.extend ℓ) A)\nusing_well_founded {\n rel_tac := λ _ _,\n `[exact ⟨_, measure_wf (λ x, whole.sizeof _ _ _ _ x.2.2 ) ⟩ ],\n dec_tac := tactic.fst_dec_tac,\n}\n\ninstance {Γ} (ℓ : lookup ℍ ω Γ) (A : species ℍ ω Γ)\n : fintype (transition_from ℓ A) := enumerate ℓ A\n\nend transition\nend cpi\n\n#lint-\n", "meta": {"author": "continuouspi", "repo": "lean-cpi", "sha": "443bf2cb236feadc45a01387099c236ab2b78237", "save_path": "github-repos/lean/continuouspi-lean-cpi", "path": "github-repos/lean/continuouspi-lean-cpi/lean-cpi-443bf2cb236feadc45a01387099c236ab2b78237/src/data/cpi/transition/enumerate.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.4378234991142019, "lm_q1q2_score": 0.22233196731042748}} {"text": "import Smt.Reconstruction.Defs\nimport Smt.Reconstruction.Term\n\nopen Types\nopen proof\nopen term\nopen sort\nopen Nat\n\nnamespace Rules\n\nsyntax \"absurdHyp\" ident \"(\" ident,+ \")\" : tactic\nmacro_rules\n | `(tactic| absurdHyp $h:ident ($n:ident)) => `(tactic| rewrite [($n)] at ($h); have z: False := ($h); cases z)\n | `(tactic| absurdHyp $h:ident ($n:ident, $m:ident)) => `(tactic| rewrite [($n), ($m)] at ($h); have z: False := ($h); simp at z)\n\nopen Classical\n\ntheorem notImplies1 : ∀ {t₁ t₂ : term},\n followsFrom (not $ implies t₁ t₂) t₁ :=\n by intros t₁ t₂ Γ Δ h\n simp at h\n split at h\n case h_1 _ k h' =>\n split at h'\n case h_1 _ k' h'' =>\n split at h''\n case h_1 _ k₁ k₂ rt₁ rt₂ =>\n simp\n rewrite [rt₁]\n have ek : (fun Γ Δ => ¬ k' Γ Δ) = k :=\n by injection h' with h'; injection h' with _ h'; exact h';\n have fe : (fun Γ Δ => k₁ Γ Δ → k₂ Γ Δ) = k' :=\n by injection h'' with h''; injection h'' with _ h''; exact h''\n rewrite [← ek, ← fe] at h\n apply byContradiction\n exact (λ hf => h (λ k₁w => False.elim (hf k₁w)))\n case h_2 => simp at h''\n case h_2 => simp at h'\n case h_2 => exact (False.elim h)\n\ntheorem notImplies2 : ∀ {t₁ t₂ : term},\n followsFrom (not $ implies t₁ t₂) (not t₂) :=\n by intros t₁ t₂ Γ Δ h\n simp at h\n match r₁: interpTerm t₁, r₂: interpTerm t₂ with\n | some ⟨ atom 1, k₁ ⟩, some ⟨ atom 1, k₂ ⟩ =>\n simp\n rewrite [r₂]\n show ¬ k₂ Γ Δ\n rewrite [r₁, r₂] at h\n have h₂ : ¬ ((k₁ Γ Δ) → (k₂ Γ Δ)) := h\n match em (k₂ Γ Δ) with\n | Or.inl r => exact False.elim (h₂ (λ _ => r))\n | Or.inr r => exact r\n | some ⟨ atom 0, _ ⟩, _ => rewrite [r₁] at h; simp at h\n | some ⟨ atom 1, k₁ ⟩, some ⟨ atom 0, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ atom (succ (succ _)), _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.undef, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.array _ _, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.bv _, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.arrow _ _, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.dep, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, none => absurdHyp h (r₁, r₂)\n | some ⟨ atom (succ (succ _)), _ ⟩, _ => absurdHyp h (r₁) \n | some ⟨ sort.undef, _ ⟩, _ => absurdHyp h (r₁) \n | some ⟨ sort.array _ _, _ ⟩, _ => absurdHyp h (r₁) \n | some ⟨ sort.bv _, _ ⟩, _ => absurdHyp h (r₁) \n | some ⟨ sort.arrow _ _, _ ⟩, _ => absurdHyp h (r₁) \n | some ⟨ sort.dep, _ ⟩, _ => absurdHyp h (r₁)\n | none, _ => absurdHyp h (r₁)\n\ntheorem impliesElim : ∀ {t₁ t₂ : term},\n followsFrom (implies t₁ t₂) (or (not t₁) t₂)\n | t₁, t₂, Γ, Δ, h =>\n by simp at h\n match r₁: interpTerm t₁, r₂: interpTerm t₂ with\n | some ⟨ atom 1, k₁ ⟩, some ⟨ atom 1, k₂ ⟩ =>\n simp\n rewrite [r₁, r₂]\n rewrite [r₁, r₂] at h\n show (¬ k₁ Γ Δ) ∨ (k₂ Γ Δ)\n have h₂ : k₁ Γ Δ → k₂ Γ Δ := h\n match em (k₁ Γ Δ), em (k₂ Γ Δ) with\n | Or.inl _, Or.inl k₂W => exact Or.inr k₂W\n | Or.inl k₁W, Or.inr nk₂W => have k₂W := h₂ k₁W\n exact (False.elim (nk₂W k₂W))\n | Or.inr _, Or.inl k₂W => exact Or.inr k₂W\n | Or.inr nk₁W, Or.inr _ => exact Or.inl nk₁W\n | some ⟨ atom 0, _ ⟩, _ => absurdHyp h (r₁)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ atom 0, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ atom (succ (succ _)), _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.undef, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.array _ _, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.bv _, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.arrow _ _, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, some ⟨ sort.dep, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, k₁ ⟩, none => absurdHyp h (r₁, r₂)\n | some ⟨ atom (succ (succ _)), _ ⟩, _ => absurdHyp h (r₁) \n | some ⟨ sort.undef, _ ⟩, _ => absurdHyp h (r₁) \n | some ⟨ sort.array _ _, _ ⟩, _ => absurdHyp h (r₁)\n | some ⟨ sort.bv _, _ ⟩, _ => absurdHyp h (r₁)\n | some ⟨ sort.arrow _ _, _ ⟩, _ => absurdHyp h (r₁)\n | some ⟨ sort.dep, _ ⟩, _ => absurdHyp h (r₁)\n | none, _ => absurdHyp h (r₁)\n\ntheorem contradiction: ∀ {t: term},\n followsFrom (and (not t) t) bot\n | t, Γ, Δ, h => by\n simp at h\n match r: interpTerm t with\n | some ⟨ atom 1, k ⟩ =>\n rewrite [r] at h;\n simp at h\n have ⟨nkW, kW⟩ : ¬ (k Γ Δ) ∧ k Γ Δ := h\n exact False.elim (nkW kW)\n | some ⟨ atom 0, _ ⟩ => absurdHyp h (r)\n | some ⟨ atom (succ (succ _)), _ ⟩ => absurdHyp h (r)\n | some ⟨ sort.undef, _ ⟩ => absurdHyp h (r)\n | some ⟨ sort.array _ _, _ ⟩ => absurdHyp h (r)\n | some ⟨ sort.bv _, _ ⟩ => absurdHyp h (r)\n | some ⟨ sort.arrow _ _, _ ⟩ => absurdHyp h (r)\n | some ⟨ sort.dep, _ ⟩ => absurdHyp h (r)\n | none => absurdHyp h (r)\n \ntheorem R1 : ∀ {t₁ t₂ : term},\n followsFrom (and (or (not t₁) t₂) t₁) t₂\n | t₁, t₂, Γ, Δ, h => by\n simp at h\n match r₁: interpTerm t₁, r₂: interpTerm t₂ with\n | some ⟨ atom 1, k₁ ⟩, some ⟨ atom 1, k₂ ⟩ =>\n simp at *\n rewrite [r₁, r₂] at h\n rewrite [r₂]\n have ⟨ H, k₁W ⟩: ((¬ (k₁ Γ Δ)) ∨ (k₂ Γ Δ)) ∧ (k₁ Γ Δ) := h\n match em (k₂ Γ Δ) with\n | Or.inl k₂W => exact k₂W\n | Or.inr _ => match em (k₁ Γ Δ) with\n | Or.inl k₁W => match H with\n | Or.inl nk₁W => exact (False.elim (nk₁W k₁W))\n | Or.inr k₂W => exact k₂W\n | Or.inr nk₁W => exact (False.elim (nk₁W k₁W))\n | some ⟨ atom 1, _ ⟩, some ⟨ atom 0, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ atom (succ (succ _)), _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.undef, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.array _ _, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.bv _, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.arrow _ _, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.dep, _ ⟩ => absurdHyp h (r₁, r₂)\n | some ⟨ atom 1, _ ⟩, none => absurdHyp h (r₁, r₂)\n | some ⟨ atom 0, _ ⟩, _ => absurdHyp h (r₁) \n | some ⟨ atom (succ (succ _)), _ ⟩, _ => absurdHyp h (r₁)\n | some ⟨ sort.undef, _ ⟩, _ => absurdHyp h (r₁)\n | some ⟨ sort.array _ _, _ ⟩, _ => absurdHyp h (r₁)\n | some ⟨ sort.bv _, _ ⟩, _ => absurdHyp h (r₁)\n | some ⟨ sort.arrow _ _, _ ⟩, _ => absurdHyp h (r₁)\n | some ⟨ sort.dep, _ ⟩, _ => absurdHyp h (r₁)\n | none, _ => absurdHyp h (r₁)\n\ntheorem conjunction: ∀ {t₁ t₂: term} {Γ: Environment} {Δ : SEnvironment},\n validWith Γ Δ t₁ → validWith Γ Δ t₂ → validWith Γ Δ (and t₁ t₂)\n | t₁, t₂, Γ, Δ, h₁, h₂ => by\n simp at *\n match r₁: interpTerm t₁, r₂: interpTerm t₂ with\n | some ⟨ atom 1, k₁ ⟩, some ⟨ atom 1, k₂ ⟩ =>\n show (k₁ Γ Δ) ∧ (k₂ Γ Δ)\n simp\n rewrite [r₁] at h₁\n rewrite [r₂] at h₂\n have k₁W: (k₁ Γ Δ) := h₁\n have k₂W: (k₂ Γ Δ) := h₂\n exact And.intro k₁W k₂W\n | some ⟨ atom 1, _ ⟩, some ⟨ atom 0, _ ⟩ => absurdHyp h₂ (r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ atom (succ (succ _)), _ ⟩ => absurdHyp h₂ (r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.undef, _ ⟩ => absurdHyp h₂ (r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.array _ _, _ ⟩ => absurdHyp h₂ (r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.bv _, _ ⟩ => absurdHyp h₂ (r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.arrow _ _, _ ⟩ => absurdHyp h₂ (r₂)\n | some ⟨ atom 1, _ ⟩, some ⟨ sort.dep, _ ⟩ => absurdHyp h₂ (r₂)\n | some ⟨ atom 1, _ ⟩, none => absurdHyp h₂ (r₂)\n | some ⟨ atom 0, _ ⟩, _ => absurdHyp h₁ (r₁)\n | some ⟨ atom (succ (succ _)), _ ⟩ , _ => absurdHyp h₁ (r₁)\n | some ⟨ sort.undef, _ ⟩, _ => absurdHyp h₁ (r₁)\n | some ⟨ sort.array _ _, _ ⟩, _ => absurdHyp h₁ (r₁)\n | some ⟨ sort.bv _, _ ⟩, _ => absurdHyp h₁ (r₁)\n | some ⟨ sort.arrow _ _, _ ⟩, _ => absurdHyp h₁ (r₁)\n | some ⟨ sort.dep, _ ⟩, _ => absurdHyp h₁ (r₁)\n | none, _ => absurdHyp h₁ (r₁)\n\ntheorem followsBot: ∀ {t: term},\n followsFrom t bot → ∀ {Γ : Environment} {Δ : SEnvironment}, ¬ validWith Γ Δ t\n | t, h, Γ, Δ => by\n intro validT\n have validBot := @h Γ Δ validT\n simp at validBot\n cases validBot\n\n@[simp] def isBool : term → Bool\n | t => match interpTerm t with\n | some ⟨ atom 1, _ ⟩ => true\n | _ => false\n\ntheorem interpNotTerm: ∀ {Γ: Environment} {Δ: SEnvironment} {t: term},\n isBool t → ¬ validWith Γ Δ (not t) → validWith Γ Δ t\n | Γ, Δ, t, bt, h => by\n simp\n match r: interpTerm t with\n | some ⟨ atom 1, k ⟩ => match em (k Γ Δ) with\n | Or.inl kW => exact kW\n | Or.inr nkW => simp at h\n rewrite [r] at h\n have nnkW : ¬ (¬ (k Γ Δ)) := h\n exact (False.elim (nnkW nkW))\n | some ⟨ atom 0, _ ⟩ => simp at bt; rewrite [r] at bt; cases bt\n | some ⟨ atom (succ (succ _)), _ ⟩ => simp at bt; rewrite [r] at bt; cases bt\n | some ⟨ sort.undef, _ ⟩ => simp at bt; rewrite [r] at bt; cases bt\n | some ⟨ sort.array _ _, _ ⟩ => simp at bt; rewrite [r] at bt; cases bt\n | some ⟨ sort.bv _, _ ⟩ => simp at bt; rewrite [r] at bt; cases bt\n | some ⟨ sort.arrow _ _, _ ⟩ => simp at bt; rewrite [r] at bt; cases bt\n | some ⟨ sort.dep, _ ⟩ => simp at bt; rewrite [r] at bt; cases bt\n | none => simp at bt; rewrite [r] at bt; cases bt\n\nend Rules\n", "meta": {"author": "ufmg-smite", "repo": "lean-smt", "sha": "6de0c4b216a918a14cf7a47d9a6faccaf8c8a209", "save_path": "github-repos/lean/ufmg-smite-lean-smt", "path": "github-repos/lean/ufmg-smite-lean-smt/lean-smt-6de0c4b216a918a14cf7a47d9a6faccaf8c8a209/Smt/Reconstruction/Certified/Rules.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5888891163376235, "lm_q2_score": 0.3775406687981454, "lm_q1q2_score": 0.22232959083005524}} {"text": "structure X := ( a : Type )\ndefinition x : X := { a := unit }\ndefinition y : X := { a := unit } \nlemma t : x^.a = unit := begin\n dsimp [ y ],\n dsimp [ x ],\n refl\n end", "meta": {"author": "semorrison", "repo": "proof", "sha": "5ee398aa239a379a431190edbb6022b1a0aa2c70", "save_path": "github-repos/lean/semorrison-proof", "path": "github-repos/lean/semorrison-proof/proof-5ee398aa239a379a431190edbb6022b1a0aa2c70/lean/20170310-dsimp-should-fail.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5117166047041652, "lm_q2_score": 0.43398146480389854, "lm_q1q2_score": 0.22207552167399117}} {"text": "/-\nCopyright (c) 2017 Daniel Selsam. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Daniel Selsam\n\nProperties of the multivariate Gaussian distribution.\n-/\nimport .tfacts .tgrads\n\nnamespace certigrad\nnamespace T\n\naxiom is_integrable_mvn_of_sub_exp {shape₁ shape₂ : S} (μ σ : T shape₁) (f : T shape₁ → T shape₂) :\n is_btw_exp₂ f → is_integrable (λ x, mvn_pdf μ σ x ⬝ f x)\n\naxiom is_uintegrable_mvn_of_bounded_exp₂_around {shape₁ shape₂ shape₃ : S} (pdf : T shape₁ → ℝ) (f : T shape₁ → T shape₂ → T shape₃) (θ : T shape₂) :\n is_bounded_btw_exp₂_around f θ → is_uniformly_integrable_around (λ θ₀ x, pdf x ⬝ f x θ₀) θ\n\nend T\n\nsection tactic\nopen tactic\n\nmeta def prove_is_mvn_integrable_core : tactic unit :=\nfirst [\n applyc `certigrad.T.is_btw_id\n , applyc `certigrad.T.is_btw_const\n , applyc `certigrad.T.is_btw_sigmoid\n , applyc `certigrad.T.is_btw_softplus\n , applyc `certigrad.T.is_btw_sum\n , applyc `certigrad.T.is_btw_log_sigmoid\n , applyc `certigrad.T.is_btw_log_1msigmoid\n , applyc `certigrad.T.is_btw_gemm\n , applyc `certigrad.T.is_btw_transpose\n , applyc `certigrad.T.is_btw_neg\n , applyc `certigrad.T.is_btw_inv\n , applyc `certigrad.T.is_btw_add\n , applyc `certigrad.T.is_btw_mul\n , applyc `certigrad.T.is_btw_sub\n , applyc `certigrad.T.is_btw_div\n , applyc `certigrad.T.is_btw_exp\n\n , applyc `certigrad.T.is_sub_quadratic_id\n , applyc `certigrad.T.is_sub_quadratic_const\n , applyc `certigrad.T.is_sub_quadratic_gemm\n , applyc `certigrad.T.is_sub_quadratic_transpose\n , applyc `certigrad.T.is_sub_quadratic_neg\n , applyc `certigrad.T.is_sub_quadratic_add\n , applyc `certigrad.T.is_sub_quadratic_softplus\n , applyc `certigrad.T.is_sub_quadratic_mul₁\n , applyc `certigrad.T.is_sub_quadratic_mul₂\n , applyc `certigrad.T.is_sub_quadratic_sub\n , prove_preconditions_core\n]\n\nmeta def prove_is_mvn_integrable : tactic unit :=\ndo applyc `certigrad.T.is_integrable_mvn_of_sub_exp,\n repeat prove_is_mvn_integrable_core\n\nmeta def prove_is_mvn_uintegrable_core_helper : tactic unit :=\nfirst [applyc `certigrad.T.is_bbtw_of_btw\n , applyc `certigrad.T.is_bbtw_id\n , applyc `certigrad.T.is_bbtw_bernoulli_neglogpdf\n , applyc `certigrad.T.is_bbtw_softplus\n , applyc `certigrad.T.is_bbtw_sum\n , applyc `certigrad.T.is_bbtw_log_sigmoid\n , applyc `certigrad.T.is_bbtw_log_1msigmoid\n , applyc `certigrad.T.is_bbtw_gemm\n , applyc `certigrad.T.is_bbtw_neg\n , applyc `certigrad.T.is_bbtw_inv\n , applyc `certigrad.T.is_bbtw_mul\n , applyc `certigrad.T.is_bbtw_sub\n , applyc `certigrad.T.is_bbtw_add\n , applyc `certigrad.T.is_bbtw_exp\n] <|> (intro1 >> skip)\n\nmeta def prove_is_mvn_uintegrable_core : tactic unit :=\ndo try T.simplify_grad,\n applyc `certigrad.T.is_uintegrable_mvn_of_bounded_exp₂_around,\n repeat (prove_is_mvn_uintegrable_core_helper <|> prove_is_mvn_integrable_core)\n\nmeta def prove_is_mvn_uintegrable : tactic unit :=\n-- TODO(dhs): why do I need the `try`?\n(split >> focus [prove_is_mvn_uintegrable, prove_is_mvn_uintegrable]) <|> try prove_is_mvn_uintegrable_core\n\nend tactic\n\nnamespace T\naxiom mvn_const_int {shape oshape : S} (μ σ : T shape) : σ > 0 → ∀ (y : T oshape), is_integrable (λ (x : T shape), mvn_pdf μ σ x ⬝ y)\naxiom mvn_moment₁_int {shape : S} (μ σ : T shape) : σ > 0 → is_integrable (λ (x : T shape), mvn_pdf μ σ x ⬝ x)\naxiom mvn_moment₂_int {shape : S} (μ σ : T shape) : σ > 0 → is_integrable (λ (x : T shape), mvn_pdf μ σ x ⬝ square x)\naxiom mvn_cmoment₂_int {shape : S} (μ σ : T shape) (H_σ : σ > 0) : is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ square (x - μ))\n\naxiom mvn_logpdf_int {shape : S} (μ μ' σ σ' : T shape) (H_σ : σ > 0) (H_σ' : σ' > 0) : is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ mvn_logpdf μ' σ' x)\n\n-- TODO(dhs): prove in terms of primitives (possibly for concrete p)\naxiom mvn_bernoulli_neglogpdf_int {shape₁ shape₂ : S} (μ σ : T shape₁) (H_σ : σ > 0) (p : T shape₁ → T shape₂)\n (H_p_cont : ∀ x, is_continuous p x) (H_p : ∀ x, p x > 0 ∧ p x < 1) (z : T shape₂) :\n is_integrable (λ (x : T shape₁), T.mvn_pdf μ σ x ⬝ bernoulli_neglogpdf (p x) z)\n\naxiom mvn_mvn_empirical_kl_int {shape : S} (μ σ : T shape) (H_σ : σ > 0) (μ' σ' : T shape) :\n is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ mvn_empirical_kl μ' σ' x)\n\naxiom mvn_mvn_kl_int {shape : S} (μ σ : T shape) (H_σ : σ > 0) (μ' σ' : T shape) :\n is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ mvn_kl μ' σ')\n\n-- mvn is a distribution (provable from first principles)\naxiom mvn_pdf_pos {shape : S} (μ σ : T shape) : σ > 0 → ∀ (x : T shape), mvn_pdf μ σ x > 0\naxiom mvn_pdf_int1 {shape : S} (μ σ : T shape) : σ > 0 → ∫ (λ (x : T shape), mvn_pdf μ σ x) = 1\n\nlemma mvn_expected {shape oshape : S} (μ σ : T shape) : σ > 0 → ∀ (y : T oshape), ∫ (λ (x : T shape), mvn_pdf μ σ x ⬝ y) = y :=\nby { intros H_σ y, rw [integral_fscale, (mvn_pdf_int1 _ _ H_σ), one_smul] }\n\n-- moments (provable from first principles)\naxiom mvn_moment₁ {shape : S} (μ σ : T shape) (H_σ : σ > 0) : ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ x) = μ\naxiom mvn_moment₂ {shape : S} (μ σ : T shape) (H_σ : σ > 0) : ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ square x) = square μ + square σ\n\n-- central moments (provable in terms of moments)\nlemma mvn_cmoment₁ {shape : S} (μ σ : T shape) (H_σ : σ > 0) : ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (x - μ)) = 0 :=\nhave H_int_x : is_integrable (λ x, mvn_pdf μ σ x ⬝ x), from mvn_moment₁_int μ σ H_σ,\nhave H_int_μ : is_integrable (λ x, - (mvn_pdf μ σ x ⬝ μ)), from iff.mp (is_integrable_neg _) (mvn_const_int μ σ H_σ μ),\ncalc ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (x - μ))\n = ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ x + - (T.mvn_pdf μ σ x ⬝ μ)) : begin simp [smul_addr, smul_neg], end\n... = ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ x) - ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ μ)\n : begin simp [integral_add, H_int_x, H_int_μ, integral_neg] end\n... = μ - μ : by { rw [mvn_expected _ _ H_σ, mvn_moment₁ _ _ H_σ], }\n... = 0 : by simp\n\n-- Exercise for the reader: prove\naxiom mvn_cmoment₂ {shape : S} (μ σ : T shape) (H_σ : σ > 0) : ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ square (x - μ)) = square σ\n\n-- central scaled moments (provable in terms of central moments)\nlemma mvn_csmoment₁ {shape : S} (μ σ : T shape) (H_σ : σ > 0) : ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ ((x - μ) / σ)) = 0 :=\nhave H_int_xσ : is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (x / σ)),\n by { simp [smul_div], exact iff.mp (is_integrable_div _ _ H_σ) (mvn_moment₁_int _ _ H_σ) },\n\nhave H_int_μσ : is_integrable (λ (x : T shape), -(T.mvn_pdf μ σ x ⬝ (μ / σ))),\n by { apply iff.mp (is_integrable_neg _), simp [smul_div], exact iff.mp (is_integrable_div _ _ H_σ) (mvn_const_int _ _ H_σ _) },\n\ncalc ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ ((x - μ) / σ))\n = ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (x / σ) - (T.mvn_pdf μ σ x ⬝ (μ / σ)))\n : by simp [T.div_add_div_same_symm, smul_addr, sum_add, neg_div, smul_neg, integral_neg]\n... = ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (x / σ)) - ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (μ / σ))\n : begin simp [integral_add, H_int_xσ, H_int_μσ, integral_neg] end\n... = ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ x) / σ - ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (μ / σ))\n : by simp [smul_div, integral_div]\n... = μ / σ - μ / σ : by rw [mvn_moment₁ _ _ H_σ, mvn_expected _ _ H_σ]\n... = 0 : by simp\n\n-- Exercise for the reader: prove\naxiom mvn_csmoment₂ {shape : S} (μ σ : T shape) (H_σ : σ > 0) : ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ square ((x - μ) / σ)) = (1 : T shape)\n\nlemma mvn_logpdf_correct {shape : S} (μ σ x : T shape) (H_σ : σ > 0) : log (mvn_pdf μ σ x) = mvn_logpdf μ σ x :=\nhave H_σ₂ : square σ > 0, from square_pos_of_pos H_σ,\nhave H_mul : (2 * pi shape) * square σ > 0, from mul_pos_of_pos_pos two_pi_pos H_σ₂,\nhave H_sqrt : (sqrt ((2 * pi shape) * square σ))⁻¹ > 0, from inv_pos (sqrt_pos H_mul),\nhave H_exp : exp ((- 2⁻¹) * (square $ (x - μ) / σ)) > 0, from exp_pos,\nhave H_mul₂ : (sqrt ((2 * pi shape) * square σ))⁻¹ * exp ((- 2⁻¹) * (square $ (x - μ) / σ)) > 0,\nfrom mul_pos_of_pos_pos H_sqrt H_exp,\ncalc log (mvn_pdf μ σ x)\n = log (prod ((sqrt ((2 * pi shape) * square σ))⁻¹ * exp ((- 2⁻¹) * (square $ (x - μ) / σ)))) : rfl\n... = sum (log ((sqrt ((2 * pi shape) * square σ))⁻¹) + ((- 2⁻¹) * (square $ (x - μ) / σ))) : by simp only [log_prod H_mul₂, log_mul H_sqrt H_exp, log_exp]\n... = sum ((- 2⁻¹) * log ((2 * pi shape) * square σ) + ((- 2⁻¹) * (square $ (x - μ) / σ))) : by simp [log_inv, log_sqrt]\n... = sum ((- 2⁻¹) * (log (2 * pi shape) + log (square σ)) + (- 2⁻¹) * (square $ (x - μ) / σ)) : by simp only [log_mul two_pi_pos H_σ₂]\n... = sum ((- 2⁻¹) * (log (2 * pi shape) + log (square σ) + (square $ (x - μ) / σ))) : by simp only [left_distrib]\n... = sum ((- (2 : ℝ)⁻¹) ⬝ (log (2 * pi shape) + log (square σ) + (square $ (x - μ) / σ))) : by simp only [smul.def, const_neg, const_inv, const_bit0, const_one]\n... = (- 2⁻¹) * sum (square ((x - μ) / σ) + log (2 * pi shape) + log (square σ)) : by simp [sum_smul]\n... = mvn_logpdf μ σ x : rfl\n\nlemma mvn_int_const {shape : S} (μ σ : T shape) (H_σ : σ > 0) (y : ℝ) :\n ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ y) = y :=\nby { rw [integral_fscale, (mvn_pdf_int1 _ _ H_σ), one_smul] }\n\nlemma mvn_integral₁ {shape : S} (μ σ : T shape) (H_σ : σ > 0) :\n∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ T.mvn_logpdf 0 1 x)\n=\n(- 2⁻¹) * sum (square μ + square σ) + (- 2⁻¹) * sum (log (2 * pi shape)) :=\nhave H_sq_x_int : is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ square x), from mvn_moment₂_int _ _ H_σ,\nhave H_log_pi_int : is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ log (2 * pi shape)), from mvn_const_int _ _ H_σ _,\nhave H_sum_int : is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (square x + log (2 * pi shape))),\n begin simp only [smul_addr], exact iff.mp (is_integrable_add _ _) (and.intro H_sq_x_int H_log_pi_int) end,\ncalc ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ ((- 2⁻¹) * sum (square ((x - 0) / 1) + log (2 * pi shape) + log (square 1))))\n = ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ ((- 2⁻¹) * sum (square x + log (2 * pi shape)))) : by simp [log_one, square, T.div_one]\n... = ∫ (λ (x : T shape), (- (2 : ℝ)⁻¹) ⬝ (T.mvn_pdf μ σ x ⬝ sum (square x + log (2 * pi shape)))) : by simp only [smul_mul_scalar_right]\n... = (- 2⁻¹) * ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ sum (square x + log (2 * pi shape))) : by { simp only [integral_scale], simp [smul.def] }\n... = (- 2⁻¹) * sum (∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (square x + log (2 * pi shape)))) : by { simp only [integral_sum, H_sum_int, smul_sum] }\n... = (- 2⁻¹) * sum (∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ square x + T.mvn_pdf μ σ x ⬝ log (2 * pi shape))) : by { simp only [smul_addr] }\n... = (- 2⁻¹) * sum (∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ square x) + ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ log (2 * pi shape)))\n : by { simp only [integral_add, H_sq_x_int, H_log_pi_int] }\n... = (- 2⁻¹) * (sum (square μ + square σ) + sum (log (2 * pi shape))) : by rw [mvn_moment₂ _ _ H_σ, mvn_expected _ _ H_σ, sum_add]\n... = (- 2⁻¹) * sum (square μ + square σ) + (- 2⁻¹) * sum (log (2 * pi shape)) : by rw left_distrib\n\nlemma mvn_integral₂ {shape : S} (μ σ : T shape) (H_σ : σ > 0) :\n∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ T.mvn_logpdf μ σ x)\n=\n(- 2⁻¹) * sum (1 : T shape) + (- 2⁻¹) * sum (log (2 * pi shape)) + (- 2⁻¹) * sum (log (square σ)) :=\nhave H_int₁ : is_integrable (λ (x : T shape), mvn_pdf μ σ x ⬝ (-2⁻¹ * sum (square ((x - μ) / σ)))),\nbegin\nsimp only [smul_mul_scalar_right, integral_scale],\napply iff.mp (is_integrable_scale _ _),\nsimp only [smul_sum],\napply iff.mp (is_integrable_sum _),\nsimp only [square_div, smul_div],\napply iff.mp (is_integrable_div _ _ (square_pos_of_pos H_σ)),\nexact mvn_cmoment₂_int _ _ H_σ,\nend,\n\nhave H_int₂ : is_integrable (λ (x : T shape), mvn_pdf μ σ x ⬝ (-2⁻¹ * sum (log (2 * pi shape)))),\nbegin\nsimp only [smul_mul_scalar_right, integral_scale],\napply iff.mp (is_integrable_scale _ _),\nsimp only [smul_sum],\napply iff.mp (is_integrable_sum _),\nexact mvn_const_int _ _ H_σ _\nend,\n\nhave H_int₁₂ : is_integrable (λ (x : T shape), mvn_pdf μ σ x ⬝ (-2⁻¹ * sum (square ((x - μ) / σ))) + mvn_pdf μ σ x ⬝ (-2⁻¹ * sum (log (2 * pi shape)))),\nfrom iff.mp (is_integrable_add _ _) (and.intro H_int₁ H_int₂),\n\nhave H_int₃ : is_integrable (λ (x : T shape), mvn_pdf μ σ x ⬝ (-2⁻¹ * sum (log (square σ)))),\nbegin\nsimp only [smul_mul_scalar_right, integral_scale],\napply iff.mp (is_integrable_scale _ _),\nsimp only [smul_sum],\napply iff.mp (is_integrable_sum _),\nexact mvn_const_int _ _ H_σ _\nend,\n\nhave H_int₄ : is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ square ((x - μ) / σ)),\nbegin\nsimp only [square_div, smul_div],\napply iff.mp (is_integrable_div _ _ (square_pos_of_pos H_σ)),\nexact mvn_cmoment₂_int _ _ H_σ,\nend,\n\nhave H₁ : ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ ((- 2⁻¹) * sum (square ((x - μ) / σ)))) = (- 2⁻¹) * sum (1 : T shape), from\ncalc ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ ((- 2⁻¹) * sum (square ((x - μ) / σ))))\n = ∫ (λ (x : T shape), (- (2 : ℝ)⁻¹) ⬝ (T.mvn_pdf μ σ x ⬝ sum (square ((x - μ) / σ)))) : by simp only [smul_mul_scalar_right]\n... = (- 2⁻¹) * ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ sum (square ((x - μ) / σ))) : by { simp only [integral_scale], simp [smul.def] }\n... = (- 2⁻¹) * sum (∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ square ((x - μ) / σ))) : by simp only [smul_sum, integral_sum, H_int₄]\n... = (- 2⁻¹) * sum (1 : T shape) : by rw (mvn_csmoment₂ _ _ H_σ),\n\nhave H₂ : ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ ((- 2⁻¹) * sum (log (2 * pi shape)))) = (- 2⁻¹) * sum (log (2 * pi shape)), by rw (mvn_int_const μ _ H_σ),\n\nhave H₃ : ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ ((- 2⁻¹) * sum (log (square σ)))) = (- 2⁻¹) * sum (log (square σ)), by rw mvn_int_const μ _ H_σ,\nbegin\ndunfold mvn_logpdf,\nsimp only [sum_add, left_distrib, smul_addr, integral_add, H₁, H₂, H₃, H_int₁₂, H_int₁, H_int₂, H_int₃],\nend\n\nlemma mvn_kl_identity {shape : S} (μ σ : T shape) (H_σ : σ > 0) :\n∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ T.mvn_empirical_kl μ σ x)\n=\nT.mvn_kl μ σ :=\nhave H_logpdf_int : is_integrable (λ (x : T shape), T.mvn_pdf μ σ x ⬝ mvn_logpdf μ σ x),\nfrom mvn_logpdf_int μ μ σ σ H_σ H_σ,\n\nhave H_std_logpdf_int : is_integrable (λ (x : T shape), - (T.mvn_pdf μ σ x ⬝ mvn_logpdf 0 1 x)),\nfrom iff.mp (is_integrable_neg _) (mvn_logpdf_int μ 0 σ 1 H_σ one_pos),\n\ncalc ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ T.mvn_empirical_kl μ σ x)\n = ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ (mvn_logpdf μ σ x - mvn_logpdf 0 1 x)) : rfl\n... = ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ mvn_logpdf μ σ x + - (T.mvn_pdf μ σ x ⬝ mvn_logpdf 0 1 x)) : by simp [smul_addr, smul_neg]\n... = ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ mvn_logpdf μ σ x) - ∫ (λ (x : T shape), T.mvn_pdf μ σ x ⬝ mvn_logpdf 0 1 x)\n : by simp [integral_add, H_logpdf_int, H_std_logpdf_int, integral_neg]\n... = ((- 2⁻¹) * sum (1 : T shape) + (- 2⁻¹) * sum (log (2 * pi shape)) + (- 2⁻¹) * sum (log (square σ))) - ((- 2⁻¹) * sum (square μ + square σ) + (- 2⁻¹) * sum (log (2 * pi shape))) : by rw [mvn_integral₁ μ σ H_σ, mvn_integral₂ μ σ H_σ]\n... = (- 2⁻¹) * sum ((1 : T shape) + log (2 * pi shape) + log (square σ) - square μ - square σ - log (2 * pi shape)) : by simp [sum_add, left_distrib, sum_neg]\n... = (- 2⁻¹) * sum ((1 : T shape) + log (square σ) - square μ - square σ + (log (2 * pi shape) - log (2 * pi shape))) : by simp\n... = (- 2⁻¹) * sum ((1 : T shape) + log (square σ) - square μ - square σ) : by simp\n... = T.mvn_kl μ σ : rfl\n\nend T\nend certigrad\n", "meta": {"author": "dselsam", "repo": "certigrad", "sha": "c9a06e93f1ec58196d6d3b8563b29868d916727f", "save_path": "github-repos/lean/dselsam-certigrad", "path": "github-repos/lean/dselsam-certigrad/certigrad-c9a06e93f1ec58196d6d3b8563b29868d916727f/src/certigrad/mvn.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5660185498374789, "lm_q2_score": 0.39233683016710835, "lm_q1q2_score": 0.22206992365901992}} {"text": "import aux\nimport parlang.def\nimport parlang.lemmas_exec\nimport data.bool\n\nnamespace parlang\n\nvariables {σ : Type} {ι : Type} {τ : ι → Type} [decidable_eq ι]\n\n/-\n\n because this holds for all n and ac the pre- and postcondition probably contain ite or forall quantifiers\n-/\ndef hoare (P : thread_state σ τ → Prop) (k : kernel σ τ) (Q : thread_state σ τ → Prop) : Prop :=\n∀ {n} {s u : state n σ τ} {ac : vector bool n}, (∀i : fin n, ac.nth i → P (s.threads.nth i)) → exec_state k ac s u → (∀i : fin n, ac.nth i → Q (u.threads.nth i))\n\nnotation `{* ` P : 1 ` *} ` k : 1 ` {* ` Q : 1 ` *}` := hoare P k Q\n\nexample (P Q : thread_state σ τ → Prop) (k₁ k₂ : kernel σ τ) (c : σ → bool) : \n {* λ (t : thread_state σ τ), P t ∧ c t.tlocal *} k₁ {* Q *} → -- how is it possible that by loosening up the assumptions (i. e. and something to P) the proof gets possible?\n {* λ (t : thread_state σ τ), P t ∧ ¬c t.tlocal *} k₂ {* Q *} → \n {* P *} kernel.ite c k₁ k₂ {* Q *} := \nbegin\n intros h_then h_else n s u ac hp he i hac,\n cases he,\n have : _ := exec_state_comm_distinct_ac _ he_a he_a_1,\n cases this with t' this,\n -- we reorder the execution (and state transition respectively) to macht the hoare triplets using exec_state_comm_distinct_ac\n -- either the condition holds or not for any thread i\n -- ?? in either case we have to go through both executions ??\n by_cases hc : (c (vector.nth (s.threads) i).tlocal = tt),\n {\n apply h_then,\n tactic.swap,\n exact this.right,\n intros i' hh,\n have hh' : _ := deactivate_threads_alive hh,\n have heqst' : vector.nth (s.threads) i' = vector.nth (t'.threads) i' := begin\n apply exec_state_inactive_threads_untouched this.left,\n apply deactivate_threads_complement hh,\n end,\n rw ← heqst',\n apply and.intro,\n {\n exact hp i' hh',\n }, {\n exact deactivate_threads_condition hh,\n }, {\n apply active_map_deactivate_threads hac (bool.eq_tt_coe.mpr hc),\n },\n }, {\n apply h_else,\n tactic.swap,\n exact he_a_1,\n intros i' hh,\n have hh' : _ := deactivate_threads_alive hh,\n have heqst' : vector.nth (s.threads) i' = vector.nth (he_t.threads) i' := begin\n apply exec_state_inactive_threads_untouched he_a,\n apply deactivate_threads_complement,\n rw bool.bnot_bnot,\n exact hh,\n end,\n rw ← heqst',\n apply and.intro,\n {\n exact hp i' hh',\n }, {\n exact deactivate_threads_condition' hh,\n }, {\n rw ← bool.eq_tt_coe at hc,\n apply active_map_deactivate_threads' hac hc,\n }\n }, {\n sorry,\n }\nend\n\nexample : \n {* λ (t : thread_state (ℕ × ℕ) τ), t.tlocal.1 = 0 ∧ t.tlocal.1 = 0 *} kernel.compute (λ l, (l.1, 1)) {* λ (t : thread_state (ℕ × ℕ) τ), t.tlocal.2 = 1 *} →\n {* λ (t : thread_state (ℕ × ℕ) τ), t.tlocal.1 = 0 ∧ ¬t.tlocal.1 = 0 *} kernel.compute (λ l, (l.1, 2)) {* λ (t : thread_state (ℕ × ℕ) τ), t.tlocal.2 = 1 *} →\n {* λ (t : thread_state (ℕ × ℕ) τ), t.tlocal.1 = 0 *} kernel.ite (λt, t.1 = 0) (kernel.compute (λ l, (l.1, 1))) (kernel.compute (λ l, (l.1, 2))) {* λ (t : thread_state (ℕ × ℕ) τ), t.tlocal.2 = 1 *} := begin\n intros h_then h_else n s u ac hp he i hac,\n cases he,\n sorry,\nend\n\nend parlang", "meta": {"author": "fischerman", "repo": "GPU-transformation-verifier", "sha": "75a5016f05382738ff93ce5859c4cfa47ccb63c1", "save_path": "github-repos/lean/fischerman-GPU-transformation-verifier", "path": "github-repos/lean/fischerman-GPU-transformation-verifier/GPU-transformation-verifier-75a5016f05382738ff93ce5859c4cfa47ccb63c1/alt/hoare.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5350984137988772, "lm_q2_score": 0.41489884579676883, "lm_q1q2_score": 0.22201171427283597}} {"text": "import condensed.top_comparison\n\nopen category_theory\n\nnamespace Condensed\n\nuniverses u\nvariables {X Y : Condensed.{u} Ab.{u+1}} (f : X ⟶ Y)\n\nlemma is_iso_iff_ExtrDisc :\n is_iso f ↔ (∀ S : ExtrDisc, is_iso (f.val.app (opposite.op S.val))) :=\nbegin\n split,\n { introsI h S,\n change is_iso ((Condensed.evaluation _ _).map f),\n apply_instance },\n { introsI h,\n suffices : is_iso ((Condensed_ExtrSheafProd_equiv Ab).functor.map f),\n { resetI,\n apply is_iso_of_fully_faithful (Condensed_ExtrSheafProd_equiv Ab.{u+1}).functor f },\n suffices : is_iso (((ExtrSheafProd_to_presheaf Ab.{u+1})).map\n ((Condensed_ExtrSheafProd_equiv Ab.{u+1}).functor.map f)),\n { resetI,\n apply is_iso_of_fully_faithful (ExtrSheafProd_to_presheaf Ab.{u+1}) },\n apply_with nat_iso.is_iso_of_is_iso_app { instances := ff },\n intros S, apply h }\nend\n\nend Condensed\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/is_iso_iff_extrdisc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5926665999540698, "lm_q2_score": 0.3738758227716966, "lm_q1q2_score": 0.2215837126871318}} {"text": "import for_mathlib.algebraic_topology.homotopical_algebra.bifibrant_object\nimport for_mathlib.category_theory.localization.equivalence\n\nnoncomputable theory\n\nopen category_theory category_theory.limits category_theory.category category_theory\n\nnamespace algebraic_topology\n\nnamespace model_category\n\nvariables {C : Type*} [category C] [model_category C]\n\nnamespace bifibrant_replacement\n\ndef obj (X : cofibrant_object C) : bifibrant_object C :=\nbifibrant_object.mk (CM5a.obj (terminal.from X.obj))\n\ndef app (X : cofibrant_object C) : X ⟶ cofibrant_object.mk (obj X).obj :=\nCM5a.i (terminal.from X.obj)\n\ninstance (X : cofibrant_object C) : cofibration ((cofibrant_object.forget C).map (app X)) :=\nby { dsimp [app], apply_instance, }\ninstance weak_eq_forget_map_app (X : cofibrant_object C) : weak_eq ((cofibrant_object.forget C).map (app X)) :=\nby { dsimp [app], apply_instance, }\n\ndef app' (X : bifibrant_object C) : X ⟶ obj (cofibrant_object.mk X.obj) :=\napp (cofibrant_object.mk X.obj)\n\ndef map' {X Y : cofibrant_object C} (f : X ⟶ Y) : obj X ⟶ obj Y :=\nbegin\n have sq : comm_sq ((cofibrant_object.forget C).map (f ≫ app Y))\n ((cofibrant_object.forget C).map (app X))\n (terminal.from (obj Y).obj) (terminal.from (obj X).obj) := by tidy,\n exact sq.lift,\nend\n\ninstance (X : bifibrant_object C) : weak_eq ((bifibrant_object.forget C).map (app' X)) :=\nbegin\n change weak_eq ((cofibrant_object.forget C).map (app ((bifibrant_object.forget_fib C).obj X))),\n apply_instance,\nend\n\n@[reassoc]\nlemma fac {X Y : cofibrant_object C} (f : X ⟶ Y) :\n app X ≫ (bifibrant_object.forget_fib C).map (map' f) = f ≫ app Y :=\nby apply comm_sq.fac_left\n\nlemma fac' {X Y : bifibrant_object C} (f : X ⟶ Y) :\n app' X ≫ map' ((bifibrant_object.forget_fib C).map f) = f ≫ app' Y :=\nby apply fac\n\ndef map {X Y : cofibrant_object C} (f : X ⟶ Y) :\n bifibrant_object.homotopy_category.Q.obj (obj X) ⟶\n bifibrant_object.homotopy_category.Q.obj (obj Y) :=\nbifibrant_object.homotopy_category.Q.map (map' f)\n\nlemma map_eq {X Y : cofibrant_object C} (f : X ⟶ Y) (f' : obj X ⟶ obj Y)\n (sq : comm_sq (app X) f ((bifibrant_object.forget_fib C).map f') (app Y)) :\n map f = bifibrant_object.homotopy_category.Q.map f' :=\nbegin\n dsimp only [map],\n let P := path_object.some (obj Y).obj,\n rw bifibrant_object.homotopy_category.Q_map_eq_iff' P,\n have sq : comm_sq ((cofibrant_object.forget C).map (f ≫ app Y) ≫ P.σ)\n ((cofibrant_object.forget C).map (app X)) P.π\n (prod.lift ((bifibrant_object.forget C).map (map' f))\n ((bifibrant_object.forget C).map f')),\n { refine comm_sq.mk _,\n ext,\n { simpa only [pre_path_object.π, cofibrant_object.forget_map, assoc, pre_path_object.d₀σ,\n comp_id, prod.lift_fst, bifibrant_object.forget_map] using (fac f).symm, },\n { simpa only [pre_path_object.π, cofibrant_object.forget_map, assoc, comp_id,\n pre_path_object.d₁σ, prod.lift_snd, bifibrant_object.forget_map] using sq.w.symm, }, },\n exact nonempty.intro\n { h := sq.lift,\n h₀' := by simpa using congr_arg (λ f, f ≫ limits.prod.fst) sq.fac_right,\n h₁' := by simpa using congr_arg (λ f, f ≫ limits.prod.snd) sq.fac_right, },\nend\n\nend bifibrant_replacement\n\nvariable (C)\n\n@[simps]\ndef bifibrant_replacement : cofibrant_object C ⥤ bifibrant_object.homotopy_category C :=\n{ obj := λ X, bifibrant_object.homotopy_category.Q.obj (bifibrant_replacement.obj X),\n map := λ X Y f, bifibrant_replacement.map f,\n map_id' := λ X, begin\n rw [bifibrant_replacement.map_eq _ (𝟙 _), bifibrant_object.homotopy_category.Q.map_id],\n exact comm_sq.mk (by { simpa only [bifibrant_object.forget_fib_map, id_comp] using comp_id _,})\n end,\n map_comp' := λ X Y Z f g, begin\n rw [bifibrant_replacement.map_eq (f ≫ g)\n (bifibrant_replacement.map' f ≫ bifibrant_replacement.map' g), functor.map_comp],\n { refl, },\n { refine comm_sq.mk _,\n rw [functor.map_comp, assoc, bifibrant_replacement.fac_assoc f,\n bifibrant_replacement.fac g], },\n end, }\n\n\nvariables {C} {Hocof : Type*} [category Hocof] (Lcof : cofibrant_object C ⥤ Hocof)\n [Lcof.is_localization cofibrant_object.weq]\n {Hobif : Type*} [category Hobif] (Lbif : bifibrant_object C ⥤ Hobif)\n [Lbif.is_localization bifibrant_object.weq]\n\nnamespace bifibrant_replacement\n\n@[simps]\ndef π : bifibrant_object.homotopy_category C ⥤ Hobif :=\nbifibrant_object.homotopy_category.lift Lbif (localization.inverts Lbif bifibrant_object.weq)\n\nlemma forget_comp_Lcof_inverts_weq :\n bifibrant_object.weq.is_inverted_by (bifibrant_object.forget_fib C ⋙ Lcof) :=\nλ X Y f hf, by convert localization.inverts Lcof cofibrant_object.weq f hf\n\ndef R : cofibrant_object C ⥤ Hobif := bifibrant_replacement C ⋙ π Lbif\n\nlemma R_inverts_weq : cofibrant_object.weq.is_inverted_by (R Lbif) := λ X Y f hf,\nbegin\n dsimp only [R, functor.comp_map],\n haveI : is_iso ((bifibrant_replacement C).map f),\n { dsimp only [bifibrant_replacement],\n apply bifibrant_object.homotopy_category.Q_inverts_weq,\n change model_category.weq ((bifibrant_object.forget C).map (map' f)),\n have h : weq ((cofibrant_object.forget C).map f ≫ (cofibrant_object.forget C).map (app Y)) :=\n CM2.of_comp _ _ hf weak_eq.property,\n have eq := (cofibrant_object.forget C).congr_map (fac f),\n simp only [functor.map_comp] at eq,\n rw ← eq at h,\n exact CM2.of_comp_left _ _ weak_eq.property h, },\n apply_instance,\nend\n\ndef forget_comp_R_iso : bifibrant_object.forget_fib C ⋙ R Lbif ≅ Lbif :=\nbegin\n symmetry,\n exact nat_iso.of_components\n (λ X, localization.iso_of_hom' Lbif bifibrant_object.weq (app' X) weak_eq.property)\n (λ X Y f, by { rw [localization.iso_of_hom'_hom, ← Lbif.map_comp, ← fac', Lbif.map_comp], refl, }),\nend\n\ndef R_comp_I'_iso {I' : Hobif ⥤ Hocof} (sq : Comm_sq (bifibrant_object.forget_fib C) Lbif Lcof I') :\n R Lbif ⋙ I' ≅ Lcof :=\nbegin\n symmetry,\n exact nat_iso.of_components (λ X, localization.iso_of_hom' Lcof cofibrant_object.weq\n (app X) weak_eq.property ≪≫ sq.iso.symm.app _) (λ X Y f, begin\n simp only [iso.trans_hom, localization.iso_of_hom'_hom, iso.app_hom, iso.symm_hom,\n functor.comp_map, assoc, ← Lcof.map_comp_assoc],\n simp only [← fac, functor.map_comp, assoc],\n congr' 1,\n apply sq.iso.inv.naturality,\n end),\nend\n\ndef is_equivalence (I' : Hobif ⥤ Hocof)\n (sq : Comm_sq (bifibrant_object.forget_fib C) Lbif Lcof I') : is_equivalence I' :=\nlocalization.lifting_is_equivalence sq bifibrant_object.weq cofibrant_object.weq\n (R Lbif) (localization.lift (R Lbif) (R_inverts_weq Lbif) Lcof)\n (R_comp_I'_iso Lcof Lbif sq) (forget_comp_R_iso Lbif)\n\nend bifibrant_replacement\n\ndef Hobif_to_Hocof : Hobif ⥤ Hocof :=\nlocalization.lift ((bifibrant_object.forget_fib C) ⋙ Lcof)\n (bifibrant_replacement.forget_comp_Lcof_inverts_weq Lcof) Lbif\n\ndef Lbif_comp_Hobif_to_Hocof_iso : Lbif ⋙ Hobif_to_Hocof Lcof Lbif ≅\n bifibrant_object.forget_fib C ⋙ Lcof := localization.fac _ _ _\n\ninstance : is_equivalence (Hobif_to_Hocof Lcof Lbif) :=\nbifibrant_replacement.is_equivalence Lcof Lbif (Hobif_to_Hocof Lcof Lbif)\n ⟨Lbif_comp_Hobif_to_Hocof_iso Lcof Lbif⟩\n\ninstance : full (bifibrant_object.forget_fib C ⋙ Lcof) :=\nfull.of_iso (Lbif_comp_Hobif_to_Hocof_iso Lcof bifibrant_object.homotopy_category.Q)\n\nend model_category\n\nend algebraic_topology\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebraic_topology/homotopical_algebra/bifibrant_replacement.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.411110869232168, "lm_q1q2_score": 0.22158186035846725}} {"text": "import tactic.induction\nimport data.int.basic\nimport data.set.basic\nimport logic.function.iterate\n\nimport .defs .game .played_move\n\nnoncomputable theory\nopen_locale classical\n\nlemma not_A_hws_at_of {pw : ℕ} {s : State}\n (h : D_hws_at pw s) : ¬A_hws_at pw s :=\nbegin\n cases h with d h, change ¬∃ _, _, push_neg,\n intro a, use d, rw not_A_wins_at, apply h,\nend\n\nlemma not_D_hws_at_of {pw : ℕ} {s : State}\n (h : A_hws_at pw s) : ¬D_hws_at pw s :=\nbegin\n cases h with d h, change ¬∃ _, _, push_neg,\n intro a, use d, rw not_D_wins_at, apply h,\nend\n\n-----\n\nlemma act_of_not_D_hws {pw : ℕ} {s : State}\n (h : ¬D_hws_at pw s) : s.act :=\nby { contrapose! h, use default, intro a, use 0 }\n\nlemma A_hvm_of_not_D_hws {pw : ℕ} {s : State}\n (h : ¬D_hws_at pw s) :\n ∀ (md : Valid_D_move s.board),\n A_has_valid_move pw (apply_D_move s md.m).board :=\nbegin\n intro md, rw D_hws_at at h, push_neg at h,\n let d := (default : D).set_move s md, specialize h d,\n cases h with a h, rw not_D_wins_at at h, specialize h 1, rw play_1 at h,\n rw Game.play_move at h, split_ifs at h with h₁, swap, { contradiction }, \n rw play_A_move_at at h, split_ifs at h with h₂, swap, { cases h },\n cases h₂ with h₂ h₃, convert h₃, change _ = dite _ _ _, rw dif_pos; refl,\nend\n\nlemma exi_moves_hws_of_not_D_hws {pw : ℕ} {s : State}\n (h : ¬D_hws_at pw s) :\n ∀ (md : Valid_D_move s.board) (d : D),\n ∃ (ma : Valid_A_move pw (apply_D_move s md.m).board) (a : A pw),\n (init_game a d (apply_A_move (apply_D_move s md.m) ma.m)).A_wins :=\nbegin\n have hs : s.act := act_of_not_D_hws h,\n have h₁ : ¬∃ _, _ := h, push_neg at h₁,\n simp_rw not_D_wins_at at h₁, rintro md d₀, let md₀ := d₀.f s hs,\n let d := d₀.set_move s md, let s' := apply_D_move s md.m,\n change apply_D_move s md.m with s',\n have h₂ : A_has_valid_move pw s'.board,\n { apply A_hvm_of_not_D_hws h },\n specialize h₁ d, cases h₁ with a h₁, let ma := a.f s' hs h₂, use [ma, a],\n have hh : d₀ = d.set_move s md₀,\n { change d₀ = (d₀.set_move s md).set_move s md₀,\n rw [D_set_move_set_move_eq, D_set_move_self] },\n rw hh, have h₃ : (init_game a d (apply_A_move s' ma.m)).A_wins,\n { convert A_wins_at_play_move_of h₁,\n rw init_game_play_move hs, change _ = dite _ _ _,\n have h₃ : (play_D_move_at (init_game a d s) hs).s = s',\n { change apply_D_move s _ = apply_D_move s _,\n congr, change dite _ _ _ = md, change (init_game a d s).s with s,\n rw dif_pos rfl },\n simp_rw h₃, rw dif_pos, swap, { split; assumption },\n ext; try {refl}, rw play_A_move_at', dsimp,\n\n sorry\n -- simp_rw h₃, change (play_D_move_at (init_game a d s) hs).a with a,\n -- generalize_proofs h₄, convert_to _ = apply_A_move s' (a.f s' hs h₂).m,\n -- { congr; try {exact h₃}, convert_to trivial == trivial,\n -- { exact eq_true_intro h₄ }, { exact eq_true_intro h₂ }, refl\n },\n let g : Game pw := _, change g.A_wins at h₃,\n let g₁ : Game pw := _, change g₁.A_wins,\n have h₄ : g₁ = g.set_D (d.set_move s md₀) := rfl, rw h₄, clear h₄,\n have h₄ : s.len < (g.set_D d).s.len,\n { exact length_lt_length_snoc₂ },\n apply (D_set_move_A_wins_iff h₄).mpr, exact h₃,\nend\n\ndef mk_D_st_for_ma_exi_D_st {pw : ℕ} {s' : State}\n (h : ∀ (ma : Valid_A_move pw s'.board),\n ∃ (d : D), ∀ (a : A pw),\n (init_game a d (apply_A_move s' ma.m)).D_wins) :\n D :=\nbegin\n refine ⟨λ sx, _⟩,\n apply dite (∃ (ma : Valid_A_move pw s'.board),\n A_played_move_at sx s' ma); rintro h₁,\n { exact (h h₁.some).some.f sx },\n { exact default },\nend\n\n-- Lemma 3.1.1\n-- Ross Bryant - Borel determinacy and metamathematics\n-- Master's thesis, University of North Texas, 2001\nlemma exi_A_move_hws_of_not_D_hws {pw : ℕ} {s : State}\n (h : ¬D_hws_at pw s) :\n ∀ (md : Valid_D_move s.board),\n ∃ (ma : Valid_A_move pw (apply_D_move s md.m).board),\n ¬D_hws_at pw (apply_A_move (apply_D_move s md.m) ma.m) :=\nbegin\n have hs := act_of_not_D_hws h,\n have h₁ := exi_moves_hws_of_not_D_hws h,\n intro md, specialize h₁ md, simp_rw D_hws_at, contrapose! h₁,\n simp_rw not_A_wins_at at h₁ ⊢,\n let D := mk_D_st_for_ma_exi_D_st h₁, use D,\n rintro ma a, have h₂ := h₁ ma, let s' := apply_D_move s md.m,\n change apply_D_move s md.m with s' at ma h₁ h₂ ⊢,\n let s₁ := apply_A_move s' ma.m,\n change apply_A_move s' ma.m with s₁ at h₁ h₂ ⊢,\n let d := h₂.some, have h₃ := h₂.some_spec,\n change ∀ (a : A pw), (init_game a d s₁).D_wins at h₃,\n specialize h₃ a, contrapose! h₃, rw not_D_wins_at at h₃ ⊢,\n intro n, specialize h₃ n, suffices h₄ : (init_game a D s₁).play n =\n ((init_game a d s₁).play n).set_D D, { rwa h₄ at h₃ }, clear h₃,\n induction n with n ih, { refl }, simp_rw [play_at_succ', ih], clear ih,\n let g : Game pw := _, change (init_game a d s₁).play n with g,\n simp_rw Game.play_move, change (g.set_D D).act with g.act,\n split_ifs with h₃, swap, { refl }, have h₅ : g.d = d := play_at_players_eq.2,\n simp_rw play_D_move_at, change (g.set_D D).s with g.s,\n change (g.set_D D).d with D, rw h₅,\n suffices h₆ : apply_D_move g.s (D.f g.s h₃).m =\n apply_D_move g.s (d.f g.s h₃).m,\n { rw [h₆, ←play_A_move_at_set_D], refl },\n simp_rw apply_D_move, congr' 3,\n have h₆ : ∃ (ma : Valid_A_move pw s'.board),\n A_played_move_at g.s s' ma,\n { exact ⟨_, A_played_move_at_play\n (A_played_move_at_apply_move hs rfl)⟩ },\n change (mk_D_st_for_ma_exi_D_st _).f _ _ = _,\n rw mk_D_st_for_ma_exi_D_st, dsimp,\n split_ifs with hx, swap, { contradiction }, clear hx,\n generalize_proofs h₇, change apply_D_move s md.m with s' at h₇,\n have h₈ := h₇.some_spec, change d with h₂.some, congr,\n suffices h₉ : apply_A_move (apply_D_move s md.m) h₆.some.m = s₁,\n { rw h₉ }, change apply_A_move s' _ = apply_A_move _ _, congr,\n apply A_played_move_at_eq h₆.some_spec,\n exact A_played_move_at_play (A_played_move_at_apply_move hs rfl),\nend\n\ndef mk_A_st_for_not_D_hws (pw : ℕ) : A pw :=\nbegin\n refine ⟨λ s' h, _⟩,\n apply dite (∃ (s : State) (md : Valid_D_move s.board),\n ¬D_hws_at pw s ∧ s' = apply_D_move s md.m); rintro h₁ h₂,\n { refine (_ : ∃ (ma : Valid_A_move pw s'.board),\n ¬D_hws_at pw (apply_A_move s' ma.m)).some,\n rcases h₁ with ⟨s, md, h₁, rfl⟩,\n use (exi_A_move_hws_of_not_D_hws h₁ _).some,\n generalize_proofs h₂, exact h₂.some_spec },\n { exact ⟨_, h₂.some_spec⟩ },\nend\n\nlemma not_D_hws_at_play_of_not_D_hws {pw n : ℕ} {g : Game pw}\n (h₁ : g.a = mk_A_st_for_not_D_hws pw)\n (h₂ : ¬D_hws_at pw g.s) :\n ¬D_hws_at pw (g.play n).s :=\nbegin\n rename g g₀, induction n with n ih, { exact h₂ }, clear h₂,\n rw play_at_succ', let g : Game pw := _,\n change ¬D_hws_at pw g.s at ih,\n change ¬D_hws_at pw g.play_move.s,\n change g.play_move with dite _ _ _,\n split_ifs, swap, { exact ih },\n let d := g.d, let s := g.s, let md := d.f s h,\n let s' := apply_D_move s md.m,\n have h₃ : ∃ (ma : Valid_A_move pw s'.board),\n ¬D_hws_at pw (apply_A_move s' ma.m),\n { exact exi_A_move_hws_of_not_D_hws ih md },\n have ma := h₃.some, have h₄ := h₃.some_spec,\n convert h₄, change Game.s (dite _ _ _) = _,\n have h₅ : A_has_valid_move pw s'.board := ⟨_, ma.h⟩,\n change (play_D_move_at g h).s with s',\n rw dif_pos, swap, { split; assumption },\n change apply_A_move _ _ = _, congr,\n change g.a.f s' h h₅ = _, let A : A pw := _, change g₀.a = A at h₁,\n have h₆ : g.a = A := by { rw ←h₁, exact play_at_players_eq.1 },\n rw h₆, change (mk_A_st_for_not_D_hws pw).f _ _ _ = _,\n rw mk_A_st_for_not_D_hws, dsimp, rw dif_pos, exact ⟨s, md, ih, rfl⟩,\nend\n\nlemma A_hws_at_of {pw : ℕ} {s : State}\n (h : ¬D_hws_at pw s) : A_hws_at pw s :=\nbegin\n have hs : s.act := act_of_not_D_hws h,\n let A := mk_A_st_for_not_D_hws pw, use A, rintro d n,\n induction n with n ih, { exact hs }, rw play_at_succ',\n let g : Game pw := _, change g.act at ih, change g.play_move.act,\n let s := g.s, let md := d.f s ih, let s' := apply_D_move s md.m,\n rw play_move_at_act ih, have h₁ : play_D_move_at g ih = g.set_state s',\n { convert play_D_move_eq, change apply_D_move _ (d.f s ih).m = _,\n congr, symmetry, exact play_at_players_eq.2 },\n rw h₁, clear h₁, have h₁ : A_has_valid_move pw s'.board,\n { have h₁ : ¬D_hws_at pw s := not_D_hws_at_play_of_not_D_hws rfl h,\n exact ⟨_, (exi_A_move_hws_of_not_D_hws h₁ md).some.h⟩ },\n change Game.act (dite _ _ _), change (g.set_state s').s with s',\n rw dif_pos, swap, { split; assumption }, exact ih,\nend\n\n-----\n\nlemma D_hws_at_of {pw : ℕ} {s : State}\n (h : ¬A_hws_at pw s) : D_hws_at pw s :=\nby { contrapose! h, exact A_hws_at_of h }\n\nlemma not_A_hws_at_iff {pw : ℕ} {s : State} :\n ¬A_hws_at pw s ↔ D_hws_at pw s :=\n⟨D_hws_at_of, not_A_hws_at_of⟩\n\nlemma not_D_hws_at_iff {pw : ℕ} {s : State} :\n ¬D_hws_at pw s ↔ A_hws_at pw s :=\n⟨A_hws_at_of, not_D_hws_at_of⟩", "meta": {"author": "user7230724", "repo": "lean-projects", "sha": "ab9a83874775efd18f8c5b867e480bae4d596b31", "save_path": "github-repos/lean/user7230724-lean-projects", "path": "github-repos/lean/user7230724-lean-projects/lean-projects-ab9a83874775efd18f8c5b867e480bae4d596b31/src/ap/determinacy.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.42632159254749036, "lm_q1q2_score": 0.22148315733699375}} {"text": "import category_theory.adjunction.basic\nimport category_theory.limits.has_limits\nimport category_theory.limits.preserves.basic\n\nnoncomputable theory\n\nnamespace category_theory\n\nopen category\n\nlemma adjunction.compatibility {C D : Type*} [category C] [category D]\n {G : C ⥤ D} {F : D ⥤ C} (adj : G ⊣ F) {X : C} {Y : D}\n (f : G.obj X ⟶ Y) : G.map (adj.unit.app X) ≫ (F ⋙ G).map f ≫ adj.counit.app Y = f :=\nby simp only [functor.comp_map, adjunction.counit_naturality, adjunction.left_triangle_components_assoc]\n\nsection\n\nvariables {C₁ C₂ D₁ D₂ : Type*} [category C₁] [category C₂]\n [category D₁] [category D₂] {G₁ : C₁ ⥤ D₁} {F₁ : D₁ ⥤ C₁}\n {G₂ : C₂ ⥤ D₂} {F₂ : D₂ ⥤ C₂}\n (adj₁ : G₁ ⊣ F₁) (adj₂ : G₂ ⊣ F₂)\n {L : C₁ ⥤ C₂} {L' : D₁ ⥤ D₂}\n\ninclude adj₁ adj₂\n\ndef adjunction.adjoint_nat_trans_equiv :\n (L ⋙ G₂ ⟶ G₁ ⋙ L') ≃ (F₁ ⋙ L ⟶ L' ⋙ F₂) :=\n{ to_fun := λ τ, begin\n let α := 𝟙 (F₁ ⋙ L) ◫ adj₂.unit,\n let β := (𝟙 F₁) ◫ τ ◫ (𝟙 F₂),\n let γ := adj₁.counit ◫ 𝟙 (L' ⋙ F₂),\n exact α ≫ β ≫ γ,\n end,\n inv_fun := λ τ', begin\n let α := adj₁.unit ◫ (𝟙 (L ⋙ G₂)),\n let β := (𝟙 G₁) ◫ τ' ◫ (𝟙 G₂),\n let γ := 𝟙 (G₁ ⋙ L') ◫ adj₂.counit,\n exact α ≫ β ≫ γ,\n end,\n left_inv := λ τ, begin\n ext X,\n dsimp,\n simp only [id_comp, functor.map_id, comp_id, assoc, functor.map_comp,\n adjunction.counit_naturality, adjunction.counit_naturality_assoc,\n adjunction.left_triangle_components_assoc],\n erw τ.naturality_assoc,\n dsimp,\n rw [← L'.map_comp, adj₁.left_triangle_components, L'.map_id,\n comp_id],\n end,\n right_inv := λ τ', begin\n ext Y,\n dsimp,\n simp only [functor.map_id, id_comp, assoc, functor.map_comp,\n adjunction.unit_naturality_assoc, adjunction.right_triangle_components_assoc],\n erw ← τ'.naturality,\n dsimp,\n rw [← L.map_comp_assoc, adj₁.right_triangle_components, L.map_id, id_comp],\n end, }\n\n@[simp]\nlemma adjunction.adjoint_nat_trans_equiv_app (τ : L ⋙ G₂ ⟶ G₁ ⋙ L') (Y₁ : D₁) :\n (adjunction.adjoint_nat_trans_equiv adj₁ adj₂ τ).app Y₁ =\n adj₂.unit.app (L.obj (F₁.obj Y₁)) ≫\n F₂.map (τ.app (F₁.obj Y₁)) ≫\n F₂.map (L'.map (adj₁.counit.app Y₁)) :=\nbegin\n dsimp [adjunction.adjoint_nat_trans_equiv],\n simp only [functor.map_id, comp_id, id_comp],\nend\n\n@[simp]\nlemma adjunction.adjoint_nat_trans_equiv_symm_app (τ : F₁ ⋙ L ⟶ L' ⋙ F₂) (X₁ : C₁) :\n ((adjunction.adjoint_nat_trans_equiv adj₁ adj₂).symm τ).app X₁ =\n G₂.map (L.map (adj₁.unit.app X₁)) ≫\n G₂.map (τ.app (G₁.obj X₁)) ≫ adj₂.counit.app (L'.obj (G₁.obj X₁)) :=\nbegin\n dsimp [adjunction.adjoint_nat_trans_equiv],\n simp only [id_comp, functor.map_id, comp_id],\nend\n\nend\n\ndef functor.comp_const {C D : Type*} [category C] [category D]\n (F : C ⥤ D) (J : Type*) [category J] :\n F ⋙ (functor.const J) ≅ (functor.const J) ⋙ (whiskering_right J C D).obj F :=\nnat_iso.of_components (λ X, nat_iso.of_components (λ j, iso.refl _) (by tidy)) (by tidy)\n\nnamespace limits\n\nsection\n\nvariables {J : Type*} {C : Type*} [category J] [category C]\n {F : (J ⥤ C) ⥤ C} (adj : functor.const J ⊣ F)\n\ninclude adj\n\nlemma is_limit_of_is_iso_adj {X : J ⥤ C} (c : cone X)\n (h : is_iso ((adj.hom_equiv _ _) c.π)) : is_limit c :=\nbegin\n haveI := h,\n exact\n { lift := λ s, (adj.hom_equiv _ _) s.π ≫ inv ((adj.hom_equiv _ _) c.π),\n fac' := λ s, begin\n suffices : (functor.const J).map ((adj.hom_equiv s.X X) s.π ≫ inv ((adj.hom_equiv c.X X) c.π)) ≫ c.π = s.π,\n { exact nat_trans.congr_app this, },\n apply (adj.hom_equiv _ _).injective,\n rw [adjunction.hom_equiv_naturality_left, assoc, is_iso.inv_hom_id, comp_id],\n end,\n uniq' := λ s m hm, begin\n rw [← cancel_mono ((adj.hom_equiv c.X X) c.π), assoc, is_iso.inv_hom_id, comp_id],\n apply (adj.hom_equiv _ _).symm.injective,\n simp only [adjunction.hom_equiv_naturality_left_symm, equiv.symm_apply_apply],\n ext j,\n exact hm j,\n end, },\nend\n\nlemma is_iso_adj_of_is_limit {X : J ⥤ C} {c : cone X} (hc : is_limit c) :\n is_iso ((adj.hom_equiv _ _) c.π) :=\nbegin\n refine is_iso.mk ⟨hc.lift (cone.mk (F.obj X) (adj.counit.app X)), _, _⟩,\n { apply hc.hom_ext,\n intro j,\n simpa only [adjunction.hom_equiv_unit, assoc, is_limit.fac, id_comp]\n using nat_trans.congr_app (adj.compatibility c.π) j, },\n { apply (adj.hom_equiv _ _).symm.injective,\n rw [adjunction.hom_equiv_naturality_left_symm, equiv.symm_apply_apply,\n adjunction.hom_equiv_counit, functor.map_id],\n ext j,\n rw id_comp,\n apply hc.fac, },\nend\n\n@[simps]\ndef limit_cone_of_adj (X : J ⥤ C) : limit_cone X :=\n⟨cone.mk (F.obj X) (adj.counit.app X), is_limit_of_is_iso_adj adj _ (by tidy)⟩\n\nlemma has_limits_of_shape_of_adj : has_limits_of_shape J C :=\n⟨λ X, ⟨nonempty.intro (limit_cone_of_adj adj X)⟩⟩\n\nend\n\nsection\n\nvariables {C₁ C₂ J : Type*} [category C₁] [category C₂] [category J]\n {F₁ : (J ⥤ C₁) ⥤ C₁} {F₂ : (J ⥤ C₂) ⥤ C₂} (adj₁ : functor.const J ⊣ F₁)\n (adj₂ : functor.const J ⊣ F₂) (L : C₁ ⥤ C₂)\n\ninclude adj₁ adj₂\n\n@[simp]\ndef limit_comparison_of_adj : F₁ ⋙ L ⟶ (whiskering_right J _ _).obj L ⋙ F₂ :=\n(adjunction.adjoint_nat_trans_equiv adj₁ adj₂)(L.comp_const J).hom\n\nlemma preserves_limit_of_adj (X : J ⥤ C₁)\n (hX : is_iso ((limit_comparison_of_adj adj₁ adj₂ L).app X)) : preserves_limit X L :=\nbegin\n refine preserves_limit_of_preserves_limit_cone (limit_cone_of_adj adj₁ X).is_limit _,\n refine is_limit_of_is_iso_adj adj₂ _ _,\n convert hX,\n apply (adj₂.hom_equiv _ _).symm.injective,\n ext j,\n dsimp [limit_cone_of_adj, functor.map_cone],\n rw [equiv.symm_apply_apply, cones.functoriality_obj_π_app,\n adjunction.adjoint_nat_trans_equiv_app, whiskering_right_obj_map, ← assoc,\n adjunction.hom_equiv_naturality_right_symm, nat_trans.comp_app, whisker_right_app,\n adjunction.hom_equiv_naturality_right_symm, adjunction.hom_equiv_counit,\n adjunction.left_triangle_components],\n dsimp [functor.comp_const],\n simp only [id_comp],\nend\n\nlemma preserves_limits_of_shape_of_adj\n [is_iso (limit_comparison_of_adj adj₁ adj₂ L)] : preserves_limits_of_shape J L :=\n⟨λ X, preserves_limit_of_adj adj₁ adj₂ L X infer_instance⟩\n\nend\n\nend limits\n\nend category_theory\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/category_theory/limits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.42632159254749036, "lm_q1q2_score": 0.22148315733699375}} {"text": "import for_mathlib.exact_functor\nimport for_mathlib.ab4\nimport for_mathlib.abelian_sheaves.functor_category\nimport for_mathlib.homological_complex2\nimport category_theory.limits.preserves.filtered\nimport for_mathlib.short_complex_colimits\n\nnamespace category_theory\n\nopen category_theory.limits\n\nuniverses v u\nvariables (A : Type u) [category.{v} A] [abelian A] [has_colimits A]\n\ninstance colim_additive (J : Type v) [small_category J]:\n functor.additive (limits.colim : ((J ⥤ A) ⥤ A)) := ⟨⟩ .\n\n/-\nTODO: Change `AB5` from this definition to saying that `colim : (J ⥤ A) ⥤ A`\npreserves finite limits and colimits whenever `J` is filtered.\n-/\nclass AB5 : Prop :=\n(cond [] : ∀ (J : Type v) [small_category J] [is_filtered J],\n functor.exact (limits.colim : (J ⥤ A) ⥤ A))\n\nvariables (J : Type v) [small_category J] [is_filtered J]\n\nlemma AB5.colim_exact [AB5 A] :\n functor.exact (limits.colim : (J ⥤ A) ⥤ A) :=\nAB5.cond A J\n\nvariables\n [preserves_finite_limits (limits.colim : (J ⥤ A) ⥤ A)]\n [preserves_finite_colimits (limits.colim : (J ⥤ A) ⥤ A)]\n\nnoncomputable\ndef colimit_homology_functor_iso\n {M : Type} (c : complex_shape M) (i : M) :\n homology_functor (J ⥤ A) c i ⋙ limits.colim ≅\n (limits.colim.map_homological_complex _) ⋙ homology_functor _ _ i :=\nfunctor.homology_functor_iso _ _ _\n\nnoncomputable\ndef eval_functor_colimit_iso\n {M : Type} (c : complex_shape M)\n (F : J ⥤ homological_complex A c) :\n colimit F ≅ (limits.colim.map_homological_complex c).obj\n (homological_complex.eval_functor.obj F) :=\nhomological_complex.hom.iso_of_components\n(λ i, preserves_colimit_iso (homological_complex.eval A c i) _)\nbegin\n intros i j hij,\n rw ←iso.eq_inv_comp,\n apply colimit.hom_ext,\n intro k,\n dsimp,\n simp only [colimit.ι_map, whisker_left_app, ι_preserves_colimits_iso_inv_assoc,\n homological_complex.eval_map, homological_complex.hom.comm_assoc],\n congr,\n rw [preserves_colimit_iso, ← limits.colimit.iso_colimit_cocone_ι_inv\n ⟨_, preserves_colimit.preserves (colimit.is_colimit F)⟩],\n refl\nend\n\nnoncomputable\ninstance homology_functor_preserves_filtered_colimit\n {M : Type} (c : complex_shape M) (i : M)\n (F : J ⥤ homological_complex A c) :\n preserves_colimit F (homology_functor A c i) :=\npreserves_colimit_of_nat_iso F (short_complex.homology_functor_iso A c i).symm\n\nnoncomputable\ninstance homology_functor_preserves_filtered_colimits\n {M : Type} (c : complex_shape M) (i : M)\n [∀ (J : Type v) [hJ : small_category J]\n [@is_filtered J hJ],\n by exactI preserves_finite_limits (limits.colim : (J ⥤ A) ⥤ A)]\n [∀ (J : Type v) [hJ : small_category J]\n [@is_filtered J hJ],\n by exactI preserves_finite_colimits (limits.colim : (J ⥤ A) ⥤ A)] :\n preserves_filtered_colimits\n (homology_functor A c i : homological_complex A c ⥤ A) :=\nbegin\n constructor, introsI J _ _, constructor,\nend\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/ab5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.38861802670584894, "lm_q1q2_score": 0.22145501290566572}} {"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (hα : ¬ is_rat α) : ∀ y ∈ Icc 0 1, ∃ x ∈ Icc 0 1, x ≠ y ∧ x ∈ {n : ℤ // n * α} :=\nbegin\n assume y h,\n have h1 : ∀ i j : ℤ, i ≠ j → {i * α} ≠ {j * α}, from by {\n assume i j h2,\n assume h3,\n have h4 : i * α - (i * α).floor = {i * α}, from by {\n rw ← h3,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw ← floor_eq_of_mem_Icc,\n rw\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (hα : ¬ is_rat α) : \n∀ y ∈ Icc 0 1, ∃ x ∈ set.range (λ n : ℤ, n • α % 1), abs (x - y) < 1 :=\nbegin\n assume y h1,\n have h2 : ∀ i j : ℤ, i ≠ j → (i • α % 1) ≠ (j • α % 1), from\n assume i j h2,\n have h3 : i • α - (i • α % 1) = (i • α % 1), from by {rw ← sub_eq_add_neg, rw ← floor_add, rw floor_eq_self, rw add_comm, rw add_neg_self, rw zero_add,},\n have h4 : j • α - (j • α % 1) = (j • α % 1), from by {rw ← sub_eq_add_neg, rw ← floor_add, rw floor_eq_self, rw add_comm, rw add_neg_self, rw zero_add,},\n have h5 : i • α = j • α, from by {rw [h3,h4], rw sub_eq_zero, rw h2,},\n have h6 : α = (j - i)⁻¹ • (j • α - i • α), from by {rw [mul_sub,mul_sub,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm,mul_assoc,mul_comm\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {α : ℝ} (hα_irrat : irrational α) : closure ((λ m : ℤ, int.fract (α * ↑m)) '' (@set.univ ℤ)) = set.Icc 0 1 :=density_of_irrational_orbit (α : ℝ) (hα : ¬ is_rat α) : ∀ y ∈ Icc 0 1, ∃ x ∈ Icc 0 1, x ≠ y :=\nbegin\n assume y h,\n have h1 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h2 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h3 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h4 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h5 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h6 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h7 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h8 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h9 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h10 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h11 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h12 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h13 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h14 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h15 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h16 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h17 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h18 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h19 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h20 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h21 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h22 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h23 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h24 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h25 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h26 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h27 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h28 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h29 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h30 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h31 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h32 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h33 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h34 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h35 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h36 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h37 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h38 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h39 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h40 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h41 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h42 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h43 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h44 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h45 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h46 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h47 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h48 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h49 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h50 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h51 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h52 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h53 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h54 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h55 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h56 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h57 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h58 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h59 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h60 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h61 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h62 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h63 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h64 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h65 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h66 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h67 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h68 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h69 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h70 : ∃ x ∈ Icc 0 1, x ≠ y, from by {\n have h71 : ∃ x ∈ I\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n -- Then $A ⊆ S$ and $B ⊆ S$, by power set definition\n 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},\n -- Then $(A ∩ B) ⊆ A$, by intersection of set is a subset\n have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,\n -- Then $(A ∩ B) ⊆ S$, by subset relation is transitive \n have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},\n -- Hence $(A ∩ B) ∈ 𝒫 S$, by power set definition\n show (A ∩ B) ∈ 𝒫 S, from by {apply set.mem_powerset h3},\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n -- expand the power\n calc (x + y)^2 = (x+y)*(x+y) : by rw sq\n -- distributive property of multiplication over addition gives:\n ... = x*(x+y) + y*(x+y) : by rw add_mul\n -- applying the above property further gives:\n ... = 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}\n -- rearranging the terms using commutativity and adding gives:\n ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n -- Group has Latin Square Property\n have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {\n assume a b : G, use a⁻¹ * b, obviously, },\n have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {\n assume a b : G, use b * a⁻¹, obviously, }, \n\n -- Setting $b = a$, this becomes:\n have h3 : ∀ a : G, ∃! x : G, a * x = a, from \n assume a : G, h1 a a,\n have h4 : ∀ a : G, ∃! y : G, y * a = a, from\n assume a : G, h2 a a,\n\n -- These $x$ and $y$ are both $(1 : G)$, by definition of identity element\n have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,\n exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))\n (mul_one a),\n have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,\n exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), \n\n show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n use (1 : G),\n have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),\n have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),\n exists_unique.unique (h3 a) (hident a).right\n (classical.some_spec (exists_unique.exists (h3 a))), \n have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),\n exists_unique.unique (h4 a) (hident a).left\n (classical.some_spec (exists_unique.exists (h4 a))),\n show e = (1 : G), from eq.trans (h9 e) (h6 _), \n },\n exact ⟨by obviously, h7⟩,\n }\nend\n\n/--`theorem`\nSqueeze Theorem for Real Numbers\nLet $\\sequence {x_n}$, $\\sequence {y_n}$ and $\\sequence {z_n}$ be sequences in $\\R$.\n\nLet $\\sequence {y_n}$ and $\\sequence {z_n}$ both be convergent to the following limit:\n:$\\ds \\lim_{n \\mathop \\to \\infty} y_n = l, \\lim_{n \\mathop \\to \\infty} z_n = l$\n\nSuppose that:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\n\nThen:\n:$x_n \\to l$ as $n \\to \\infty$\nthat is:\n:$\\ds \\lim_{n \\mathop \\to \\infty} x_n = l$\n\n`proof`\nFrom Negative of Absolute Value:\n:$\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n\nLet $\\epsilon > 0$.\n\nWe need to prove that:\n:$\\exists N: \\forall n > N: \\size {x_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} y_n = l$ we know that:\n:$\\exists N_1: \\forall n > N_1: \\size {y_n - l} < \\epsilon$\n\nAs $\\ds \\lim_{n \\mathop \\to \\infty} z_n = l$ we know that:\n:$\\exists N_2: \\forall n > N_2: \\size {z_n - l} < \\epsilon$\n\n\nLet $N = \\max \\set {N_1, N_2}$.\n\nThen if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n:$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n\nBut:\n:$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n\nSo:\n:$\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n\nand so:\n:$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n\nSo:\n:$\\forall n > N: \\size {x_n - l} < \\epsilon$\n\nHence the result.\n{{qed}}\n\n-/\ntheorem squeeze_theorem_real_numbers (x y z : ℕ → ℝ) (l : ℝ) : \nlet seq_limit : (ℕ → ℝ) → ℝ → Prop := λ (u : ℕ → ℝ) (l : ℝ), ∀ ε > 0, ∃ N, ∀ n > N, |u n - l| < ε in\n seq_limit y l → seq_limit z l → (∀ n : ℕ, (y n) ≤ (x n) ∧ (x n) ≤ (z n)) → seq_limit x l :=\nbegin\n assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : ∀ (n : ℕ), y n ≤ x n ∧ x n ≤ z n) (ε), \n\n --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n have h5 : ∀ x, |x - l| < ε ↔ (((l - ε) < x) ∧ (x < (l + ε))), \n from by \n {\n intro x0,\n have h6 : |x0 - l| < ε ↔ ((x0 - l) < ε) ∧ ((l - x0) < ε), \n from abs_sub_lt_iff, rw h6,\n split, \n rintro ⟨ S_1, S_2 ⟩, \n split; linarith, \n rintro ⟨ S_3, S_4 ⟩, \n split; linarith,\n },\n \n --Let $\\epsilon > 0$.\n assume (h7 : ε > 0),\n\n --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$\n cases h2 ε h7 with N1 h8,\n\n --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$\n cases h3 ε h7 with N2 h9,\n \n --Let $N = \\max \\set {N_1, N_2}$.\n let N := max N1 N2,\n use N,\n\n --Then if $n > N$, it follows that $n > N_1$ and $n > N_2$.\n have h10 : ∀ n > N, n > N1 ∧ n > N2 := by {\n assume n h,\n split,\n exact lt_of_le_of_lt (le_max_left N1 N2) h, \n exact lt_of_le_of_lt (le_max_right N1 N2) h,\n },\n \n --$\\forall n > N: l - \\epsilon < y_n < l + \\epsilon$\n --$\\forall n > N: l - \\epsilon < z_n < l + \\epsilon$\n --$\\forall n \\in \\N: y_n \\le x_n \\le z_n$\n --So $\\forall n > N: l - \\epsilon < y_n \\le x_n \\le z_n < l + \\epsilon$\n have h11 : ∀ n > N, (((l - ε) < (y n)) ∧ ((y n) ≤ (x n))) ∧ (((x n) ≤ (z n)) ∧ ((z n) < l+ε)), \n from by {\n intros n h12,\n split,\n {\n\n have h13 := (h8 n (h10 n h12).left), rw h5 (y n) at h13,\n split,\n exact h13.left,\n exact (h4 n).left,\n },\n { \n have h14 := (h9 n (h10 n h12).right),rw h5 (z n) at h14,\n split,\n exact (h4 n).right,\n exact h14.right,\n },\n \n },\n\n --$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n have h15 : ∀ n > N, ((l - ε) < (x n)) ∧ ((x n) < (l+ε)), \n from by {\n intros n1 h16, cases (h11 n1 h16);\n split; linarith,\n },\n\n --So $\\forall n > N: \\size {x_n - l} < \\epsilon$\n --Hence the result\n show ∀ (n : ℕ), n > N → |x n - l| < ε, \n from by {\n intros n h17,\n cases h5 (x n) with h18 h19,\n apply h19, exact h15 n h17,\n },\nend\n\n/--`theorem`\nDensity of irrational orbit\nThe fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval\n`proof`\nLet $\\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\n$$\ni \\alpha-\\lfloor i \\alpha\\rfloor=\\{i \\alpha\\}=\\{j \\alpha\\}=j \\alpha-\\lfloor j \\alpha\\rfloor,\n$$\nwhich yields the false statement $\\alpha=\\frac{\\lfloor i \\alpha\\rfloor-\\lfloor j \\alpha\\rfloor}{i-j} \\in \\mathbb{Q}$. Hence,\n$$\nS:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}\n$$\nis an infinite subset of $\\left[0,1\\right]$.\n\nBy 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$.\n\nTo 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$.\n\nQED\n-/\ntheorem \nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_with_comments-Natural-Language-Proof-Translation/lean_proof_with_comments-4_few_shot_temperature_0.2_max_tokens_2000_n_3/clean_files/Density of irrational orbit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.7341195152660688, "lm_q2_score": 0.3007455914759599, "lm_q1q2_score": 0.22078320783273883}} {"text": "import category_theory.sites.sheafification\n\nnamespace category_theory\n\nopen category_theory\n\nuniverses v u\nvariables {C : Type u} [category.{v} C] (J : grothendieck_topology C)\n\nnoncomputable theory\n\n@[simps]\ndef presheaf_to_SheafOfTypes : (Cᵒᵖ ⥤ Type (max v u)) ⥤ SheafOfTypes J :=\n{ obj := λ P,\n { val := J.sheafify P,\n cond := begin\n rw ← is_sheaf_iff_is_sheaf_of_type,\n exact grothendieck_topology.plus.is_sheaf_plus_plus J P,\n end },\n map := λ P Q η, ⟨J.sheafify_map η⟩,\n map_id' := λ P, SheafOfTypes.hom.ext _ _ $ J.sheafify_map_id _,\n map_comp' := λ P Q R η γ, SheafOfTypes.hom.ext _ _ $ J.sheafify_map_comp _ _ }\n\n-- Sanity check\ndef presheaf_to_SheafOfTypes_iso : presheaf_to_SheafOfTypes J ≅\n presheaf_to_Sheaf J _ ⋙ (Sheaf_equiv_SheafOfTypes J).functor := eq_to_iso rfl\n\n-- The adjunction for sheaves of types\ndef sheafification_adjunction_types :\n (presheaf_to_SheafOfTypes J) ⊣ SheafOfTypes_to_presheaf J :=\nshow presheaf_to_Sheaf J _ ⋙ (Sheaf_equiv_SheafOfTypes J).functor ⊣\n (Sheaf_equiv_SheafOfTypes J).inverse ⋙ Sheaf_to_presheaf J _,\nfrom adjunction.comp _ _ (sheafification_adjunction _ _) $\n (Sheaf_equiv_SheafOfTypes J).to_adjunction\n\n@[simp]\nlemma sheafification_adjunction_types_hom_equiv_apply (X : Cᵒᵖ ⥤ Type (max v u))\n (Y : SheafOfTypes J) (e : (presheaf_to_SheafOfTypes _).obj X ⟶ Y) :\n (sheafification_adjunction_types J).hom_equiv _ _ e =\n J.to_sheafify _ ≫ e.val := rfl\n\n@[simp]\nlemma sheafification_adjunction_types_hom_equiv_symm_apply (X : Cᵒᵖ ⥤ Type (max v u))\n (Y : SheafOfTypes J) (e : X ⟶ (SheafOfTypes_to_presheaf _).obj Y) :\n (((sheafification_adjunction_types J).hom_equiv _ _).symm e).val =\n J.sheafify_lift e (by { rw is_sheaf_iff_is_sheaf_of_type, exact Y.2 }) := rfl\n\n@[simp]\nlemma sheafification_adjunction_types_unit_app (X : Cᵒᵖ ⥤ Type (max v u)) :\n (sheafification_adjunction_types J).unit.app X = J.to_sheafify X := rfl\n\n@[simp]\nlemma sheafification_adjunction_types_counit_app (Y : SheafOfTypes J) :\n ((sheafification_adjunction_types J).counit.app Y).val =\n J.sheafify_lift (𝟙 _) (by { rw is_sheaf_iff_is_sheaf_of_type, exact Y.2 }) := rfl\n\ninstance is_iso_sheafification_types_adjunction_counit_app (X : SheafOfTypes J) :\n is_iso ((sheafification_adjunction_types J).counit.app X) :=\nbegin\n apply is_iso_of_reflects_iso _ (Sheaf_equiv_SheafOfTypes J).inverse,\n change is_iso ((sheafification_adjunction J (Type (max v u))).counit.app\n ((Sheaf_equiv_SheafOfTypes J).inverse.obj X)),\n apply_instance\nend\n\ninstance sheafification_types_reflective : is_iso (sheafification_adjunction_types J).counit :=\nnat_iso.is_iso_of_is_iso_app _\n\nend category_theory\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/for_mathlib/SheafOfTypes_sheafification.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5621765155565327, "lm_q2_score": 0.39233683016710835, "lm_q1q2_score": 0.22056255210784012}} {"text": "import data.cpi.concretion data.cpi.transition.label\n\nnamespace cpi\n\nvariables {ℍ : Type} {ω : context}\n\n/-- The right hand side of a transition, determined by a specific kind. -/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive production (ℍ : Type) (ω : context) (Γ : context) : kind → Type\n| species (A : species ℍ ω Γ) : production kind.species\n| concretion {b y} (F : concretion ℍ ω Γ b y) : production kind.concretion\n\ninstance production.has_repr [has_repr ℍ] {Γ k} : has_repr (production ℍ ω Γ k) :=\n ⟨ λ x, by from production.rec_on x repr (λ _ _ x, repr x), ⟩\n\n/-- Rename a production. This just wraps renaming for species and concretions. -/\ndef production.rename\n {Γ Δ} (ρ : name Γ → name Δ)\n : ∀ {k}, production ℍ ω Γ k → production ℍ ω Δ k\n| ._ (production.species A) := production.species (species.rename ρ A)\n| ._ (production.concretion A) := production.concretion (concretion.rename ρ A)\n\nlemma production.rename_compose {Γ Δ η} (ρ : name Γ → name Δ) (σ : name Δ → name η)\n : ∀ {k} (E : production ℍ ω Γ k)\n , production.rename σ (production.rename ρ E)\n = production.rename (σ ∘ ρ) E\n| ._ (production.species A) := congr_arg _ (species.rename_compose ρ σ A)\n| ._ (production.concretion F) := congr_arg _ (concretion.rename_compose ρ σ F)\n\nlemma production.rename_id\n {Γ} : ∀ {k} (E : production ℍ ω Γ k), production.rename id E = E\n| ._ (production.species A) := congr_arg _ (species.rename_id A)\n| ._ (production.concretion F) := congr_arg _ (concretion.rename_id F)\n\n/-- Equivalence of productions. This just wraps equivalence of species and\n concretions. -/\ninductive production.equiv [∀ Γ, setoid (species ℍ ω Γ)] [∀ Γ b y, setoid (concretion ℍ ω Γ b y)] {Γ} :\n ∀ {k : kind}, production ℍ ω Γ k → production ℍ ω Γ k → Prop\n| species {A B : species ℍ ω Γ}\n : A ≈ B → production.equiv (production.species A) (production.species B)\n| concretion {b y} {F G : concretion ℍ ω Γ b y}\n : F ≈ G → production.equiv (production.concretion F) (production.concretion G)\n\nnamespace production\n variables [∀ Γ, setoid (cpi.species ℍ ω Γ)] [∀ Γ b y, setoid (cpi.concretion ℍ ω Γ b y)]\n\n lemma equiv.refl {Γ} : ∀ {k : kind} (E : production ℍ ω Γ k), equiv E E\n | ._ (species A) := equiv.species (refl A)\n | ._ (concretion F) := equiv.concretion (refl F)\n\n lemma equiv.symm {Γ} : ∀ {k : kind} (E F : production ℍ ω Γ k), equiv E F → equiv F E\n | ._ ._ ._ (equiv.species eq) := equiv.species (symm eq)\n | ._ ._ ._ (equiv.concretion eq) := equiv.concretion (symm eq)\n\n lemma equiv.trans {Γ} : ∀ {k : kind} (E F G : production ℍ ω Γ k), equiv E F → equiv F G → equiv E G\n | ._ ._ ._ ._ (equiv.species ef) (equiv.species fg) := equiv.species (trans ef fg)\n | ._ ._ ._ ._ (equiv.concretion ef) (equiv.concretion fg) := equiv.concretion (trans ef fg)\n\n instance {Γ} {k} : is_equiv (production ℍ ω Γ k) equiv :=\n { refl := equiv.refl, symm := equiv.symm, trans := equiv.trans }\n instance {Γ} {k} : is_refl (production ℍ ω Γ k) equiv := ⟨ equiv.refl ⟩\n instance {Γ} {k} : setoid (production ℍ ω Γ k) :=\n ⟨ equiv, ⟨ equiv.refl, equiv.symm, equiv.trans ⟩ ⟩\n instance setoid.is_equiv {Γ} {k} : is_equiv (production ℍ ω Γ k) has_equiv.equiv :=\n production.is_equiv\nend production\n\nsection equivalence\nvariables [∀ Γ, setoid (cpi.species ℍ ω Γ)] [∀ Γ b y, setoid (cpi.concretion ℍ ω Γ b y)]\n\nlemma production.equiv.unwrap_s :\n ∀ {Γ} {A B : species ℍ ω Γ}, production.species A ≈ production.species B → A ≈ B\n| Γ A B (production.equiv.species eq) := eq\n\nlemma production.equiv.arity :\n ∀ {Γ} {a b x y} {F : concretion ℍ ω Γ a x} {G : concretion ℍ ω Γ b y}\n , production.concretion F ≈ production.concretion G\n → a = b ∧ x = y\n| Γ a b x y F G (production.equiv.concretion eq) := ⟨ rfl, rfl ⟩\n\nlemma production.equiv.unwrap_c :\n ∀ {Γ} {b y} {F : concretion ℍ ω Γ b y} {G : concretion ℍ ω Γ b y}\n , production.concretion F ≈ production.concretion G\n → F ≈ G\n| Γ b y F G (production.equiv.concretion eq) := eq\n\nend equivalence\n\nend cpi\n\n#lint-\n", "meta": {"author": "continuouspi", "repo": "lean-cpi", "sha": "443bf2cb236feadc45a01387099c236ab2b78237", "save_path": "github-repos/lean/continuouspi-lean-cpi", "path": "github-repos/lean/continuouspi-lean-cpi/lean-cpi-443bf2cb236feadc45a01387099c236ab2b78237/src/data/cpi/transition/production.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5621765155565326, "lm_q2_score": 0.39233683016710835, "lm_q1q2_score": 0.22056255210784007}} {"text": "import category_theory.abelian.diagram_lemmas.four\nimport for_mathlib.projectives\nimport for_mathlib.homological_complex\nimport for_mathlib.snake_lemma2\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nuniverses v u\n\nnamespace short_exact_sequence\n\nvariables {C : Type u} [category.{v} C] [abelian C] [enough_projectives C]\nvariables {D : Type*} [category D] [abelian D]\n\n-- move this\nlemma exact_of_epi_comp_kernel.ι_comp_mono {C : Type u} [category.{v} C] [abelian C] {X Y Z W : C}\n (g : Y ⟶ Z) (h : Z ⟶ W) (f : X ⟶ kernel g) (i : kernel g ⟶ Y) (hf : epi f) (hh : mono h)\n (hi : i = kernel.ι g) : exact (f ≫ i) (g ≫ h) :=\nbegin\n suffices : exact i g,\n { letI := hf, letI := hh,\n exact exact_comp_mono (exact_epi_comp this) },\n rw [hi],\n exact exact_kernel_ι\nend\n\n-- move this\nlemma biprod_factors (A B : C) [projective A] [projective B]\n (E X : C) (f : A ⊞ B ⟶ X) (e : E ⟶ X) [epi e] :\n ∃ f' : A ⊞ B ⟶ E, f' ≫ e = f :=\n⟨biprod.desc\n (projective.factor_thru (biprod.inl ≫ f) e)\n (projective.factor_thru (biprod.inr ≫ f) e),\n by ext; simp only [projective.factor_thru_comp, biprod.inl_desc_assoc, biprod.inr_desc_assoc]⟩\n\nvariables (A B : short_exact_sequence C) (f : A ⟶ B)\n\ndef horseshoe_base : short_exact_sequence C :=\nshort_exact_sequence.mk_split (projective.over A.1) (projective.over A.3)\n\ndef horseshoe_base_π : horseshoe_base A ⟶ A :=\n{ fst := projective.π _,\n snd := biprod.desc (projective.π _ ≫ A.f) (projective.factor_thru (projective.π _) A.g),\n trd := projective.π _,\n sq1' := by { dsimp [horseshoe_base], simp only [biprod.inl_desc], },\n sq2' :=\n begin\n dsimp [horseshoe_base], apply category_theory.limits.biprod.hom_ext',\n { simp only [zero_comp, exact.w_assoc, biprod.inl_desc_assoc, category.assoc,\n short_exact_sequence.f_comp_g, comp_zero, exact_inl_snd], },\n { simp only [projective.factor_thru_comp, biprod.inr_snd_assoc, biprod.inr_desc_assoc], }\n end }\n\ninstance epi_horseshoe_base_π_1 : epi (horseshoe_base_π A).1 :=\nshow epi (projective.π _), by apply_instance\n\ninstance epi_horseshoe_base_π_3 : epi (horseshoe_base_π A).3 :=\nshow epi (projective.π _), by apply_instance\n\nlocal attribute [instance] limits.has_zero_object.has_zero\n\ninstance epi_horseshoe_base_π_2 : epi (horseshoe_base_π A).2 :=\nbegin\n let φ := horseshoe_base_π A,\n have h : φ.3 ≫ (0 : A.3 ⟶ 0) = (0 : _ ⟶ 0) ≫ (0 : 0 ⟶ 0) := by simp,\n refine category_theory.abelian.epi_of_epi_of_epi_of_mono φ.sq1' φ.sq2' h _ _ _ _ _ _;\n try { rw ← epi_iff_exact_zero_right }; try { apply_instance },\n exact A.exact',\nend\n\nvariables {A B}\n\ndef horseshoe_ker [epi f.1] : short_exact_sequence C :=\n(snake_input.mk_of_short_exact_sequence_hom _ _ _ f).kernel_sequence _\nbegin\n dsimp [snake_input.mk_of_short_exact_sequence_hom, snake_diagram.mk_of_short_exact_sequence_hom],\n rw snake_diagram.mk_functor_map_f1,\n exact A.mono',\nend\n$ is_zero_of_iso_of_zero (is_zero_zero _) (limits.cokernel.of_epi _).symm\n\n@[simp] lemma horseshoe_ker_fst [epi f.1] : (horseshoe_ker f).1 = kernel f.1 := rfl\n\n@[simp] lemma horseshoe_ker_snd [epi f.1] : (horseshoe_ker f).2 = kernel f.2 := rfl\n\n@[simp] lemma horseshoe_ker_trd [epi f.1] : (horseshoe_ker f).3 = kernel f.3 := rfl\n\ndef horseshoe_ker_ι [epi f.1] : horseshoe_ker f ⟶ A :=\n{ fst := kernel.ι _,\n snd := kernel.ι _,\n trd := kernel.ι _,\n sq1' :=\n begin\n dsimp [horseshoe_ker, snake_input.kernel_sequence,\n snake_input.mk_of_short_exact_sequence_hom, snake_diagram.mk_of_short_exact_sequence_hom],\n delta kernel.map,\n rw [snake_diagram.mk_functor_map_f0, kernel.lift_ι],\n end,\n sq2' :=\n begin\n dsimp [horseshoe_ker, snake_input.kernel_sequence,\n snake_input.mk_of_short_exact_sequence_hom, snake_diagram.mk_of_short_exact_sequence_hom],\n delta kernel.map,\n rw [snake_diagram.mk_functor_map_g0, kernel.lift_ι],\n end }\n.\n\nlemma horseshoe_ker_ι_fst [epi f.1] : (horseshoe_ker_ι f).1 = kernel.ι f.1 := rfl\n\nlemma horseshoe_ker_ι_snd [epi f.1] : (horseshoe_ker_ι f).2 = kernel.ι f.2 := rfl\n\nlemma horseshoe_ker_ι_trd [epi f.1] : (horseshoe_ker_ι f).3 = kernel.ι f.3 := rfl\n\nvariables (A)\n\nlemma horseshoe_ker_ι_comp_base_π :\n (horseshoe_ker_ι (horseshoe_base_π A)) ≫ horseshoe_base_π A = 0 :=\nbegin\n dsimp [horseshoe_ker_ι, horseshoe_base_π],\n ext1; show kernel.ι _ ≫ _ = 0; exact exact.w exact_kernel_ι,\nend\n\nnoncomputable\ndef horseshoe_step (A : short_exact_sequence C) :\n ℕ → Σ (X Y Z : short_exact_sequence C) (ι : X ⟶ Y), Y ⟶ Z\n| 0 := ⟨horseshoe_ker (horseshoe_base_π A), _, _, horseshoe_ker_ι _, horseshoe_base_π _⟩\n| (n+1) :=\n⟨horseshoe_ker (horseshoe_base_π (horseshoe_step n).1), _, _, horseshoe_ker_ι _, horseshoe_base_π _⟩\n\n@[reassoc] lemma horseshoe_step_comp_eq_zero :\n ∀ n, (horseshoe_step A n).2.2.2.1 ≫ (horseshoe_step A n).2.2.2.2 = 0\n| 0 := horseshoe_ker_ι_comp_base_π _\n| (n+1) := horseshoe_ker_ι_comp_base_π _\n\nlemma step_fst_mono (n : ℕ) : mono (horseshoe_step A n).2.2.2.1.1 :=\nbegin\n cases n,\n { dsimp [horseshoe_step, horseshoe_ker_ι],\n apply_instance },\n { dsimp [horseshoe_step],\n cases n, --Why do I have to do this again?!\n { rw [horseshoe_ker_ι_fst],\n apply_instance },\n { rw [horseshoe_ker_ι_fst],\n apply_instance } }\nend\n\nlemma step_snd_mono (n : ℕ) : mono (horseshoe_step A n).2.2.2.1.2 :=\nbegin\n cases n,\n { dsimp [horseshoe_step, horseshoe_ker_ι],\n apply_instance },\n { dsimp [horseshoe_step],\n cases n, --Why do I have to do this again?!\n { rw [horseshoe_ker_ι_snd],\n apply_instance },\n { rw [horseshoe_ker_ι_snd],\n apply_instance } }\nend\n\nlemma step_trd_mono (n : ℕ) : mono (horseshoe_step A n).2.2.2.1.3 :=\nbegin\n cases n,\n { dsimp [horseshoe_step, horseshoe_ker_ι],\n apply_instance },\n { dsimp [horseshoe_step],\n cases n, --Why do I have to do this again?!\n { rw [horseshoe_ker_ι_trd],\n apply_instance },\n { rw [horseshoe_ker_ι_trd],\n apply_instance } }\nend\n\ndef horseshoe_obj (n : ℕ) := (horseshoe_step A n).2.1\n\ndef horseshoe_d (n : ℕ) : horseshoe_obj A (n+1) ⟶ horseshoe_obj A n :=\n(horseshoe_step A (n+1)).2.2.2.2 ≫ eq_to_hom (by { dsimp [horseshoe_step], refl })\n ≫ (horseshoe_step A n).2.2.2.1\n\nlemma horseshoe_d_d (n : ℕ) : horseshoe_d A (n+1) ≫ horseshoe_d A n = 0 :=\nbegin\n dsimp [horseshoe_d, horseshoe_ker_ι],\n simp only [category.id_comp, category.assoc, comp_zero, zero_comp,\n horseshoe_step_comp_eq_zero_assoc],\nend\n\ndef horseshoe (A : short_exact_sequence C) : chain_complex (short_exact_sequence C) ℕ :=\nchain_complex.of (horseshoe_obj A) (horseshoe_d A) (horseshoe_d_d A)\n\nvariables (A)\n\ndef horseshoe_π : (horseshoe A).X 0 ⟶ A := horseshoe_base_π _\n\nlemma horseshoe_d_π : (horseshoe A).d 1 0 ≫ horseshoe_π A = 0 :=\nbegin\n dsimp [horseshoe],\n erw [chain_complex.of_d],\n dsimp [horseshoe_d, horseshoe_π, horseshoe_step],\n simp only [category.id_comp, category.assoc, comp_zero, zero_comp,\n horseshoe_step_comp_eq_zero_assoc, horseshoe_ker_ι_comp_base_π],\nend\n\ndef horseshoe_to_single₁ :=\n(chain_complex.to_single₀_equiv ((homological_complex.Fst C).obj (horseshoe A)) A.1).symm\n⟨(short_exact_sequence.Fst C).map (horseshoe_π A),\nbegin\n have := horseshoe_d_π A, apply_fun (λ f, (short_exact_sequence.Fst C).map f) at this,\n rwa [functor.map_comp, functor.map_zero] at this,\nend⟩\n\ndef horseshoe_to_single₂ :=\n(chain_complex.to_single₀_equiv ((homological_complex.Snd C).obj (horseshoe A)) A.2).symm\n⟨(short_exact_sequence.Snd C).map (horseshoe_π A),\nbegin\n have := horseshoe_d_π A, apply_fun (λ f, (short_exact_sequence.Snd C).map f) at this,\n rwa [functor.map_comp, functor.map_zero] at this,\nend⟩\n\ndef horseshoe_to_single₃ :=\n(chain_complex.to_single₀_equiv ((homological_complex.Trd C).obj (horseshoe A)) A.3).symm\n⟨(short_exact_sequence.Trd C).map (horseshoe_π A),\nbegin\n have := horseshoe_d_π A, apply_fun (λ f, (short_exact_sequence.Trd C).map f) at this,\n rwa [functor.map_comp, functor.map_zero] at this,\nend⟩\n\nlemma horseshoe_exact₁ (A : short_exact_sequence C) (n : ℕ) :\n exact (((homological_complex.Fst C).obj (horseshoe A)).d (n + 2) (n + 1))\n (((homological_complex.Fst C).obj (horseshoe A)).d (n + 1) n) :=\nbegin\n dsimp [horseshoe_to_single₁],\n erw [chain_complex.of_d, chain_complex.of_d],\n dsimp [horseshoe_d, horseshoe_step],\n\n set f := horseshoe_base_π (horseshoe_step A n).1,\n set g := (horseshoe_step A n).2.2.2.1,\n\n cases n;\n convert exact_of_epi_comp_kernel.ι_comp_mono f.1 _ (horseshoe_base_π (horseshoe_ker f)).1 _\n infer_instance _ _ using 1,\n { simp [step_fst_mono] },\n { simpa },\n { simp [step_fst_mono] },\n { simpa }\nend\n\nlemma horseshoe_exact₂ (A : short_exact_sequence C) (n : ℕ) :\n exact (((homological_complex.Snd C).obj (horseshoe A)).d (n + 2) (n + 1))\n (((homological_complex.Snd C).obj (horseshoe A)).d (n + 1) n) :=\nbegin\n dsimp [horseshoe_to_single₂],\n erw [chain_complex.of_d, chain_complex.of_d],\n dsimp [horseshoe_d, horseshoe_step],\n\n set f := horseshoe_base_π (horseshoe_step A n).1,\n set g := (horseshoe_step A n).2.2.2.1,\n\n cases n;\n convert exact_of_epi_comp_kernel.ι_comp_mono f.2 _ (horseshoe_base_π (horseshoe_ker f)).2 _\n infer_instance _ _ using 1,\n { simp [step_snd_mono] },\n { simpa },\n { simp [step_snd_mono] },\n { simpa }\nend\n\nlemma horseshoe_exact₃ (A : short_exact_sequence C) (n : ℕ) :\n exact (((homological_complex.Trd C).obj (horseshoe A)).d (n + 2) (n + 1))\n (((homological_complex.Trd C).obj (horseshoe A)).d (n + 1) n) :=\nbegin\n dsimp [horseshoe_to_single₃],\n erw [chain_complex.of_d, chain_complex.of_d],\n dsimp [horseshoe_d, horseshoe_step],\n\n set f := horseshoe_base_π (horseshoe_step A n).1,\n set g := (horseshoe_step A n).2.2.2.1,\n\n cases n;\n convert exact_of_epi_comp_kernel.ι_comp_mono f.3 _ (horseshoe_base_π (horseshoe_ker f)).3 _\n infer_instance _ _ using 1,\n { simp [step_trd_mono] },\n { simpa },\n { simp [step_trd_mono] },\n { simpa }\nend\n\nlemma horseshoe_is_projective_resolution₁ (A : short_exact_sequence C) :\n chain_complex.is_projective_resolution\n ((homological_complex.Fst C).obj (horseshoe A)) A.1 (horseshoe_to_single₁ A) :=\n{ projective := by rintro (_|n); { show projective (projective.over _), apply_instance },\n exact₀ :=\n begin\n dsimp [horseshoe_to_single₁, chain_complex.to_single₀_equiv, horseshoe_π],\n erw [chain_complex.of_d],\n dsimp [horseshoe_d, horseshoe_step],\n rw [category.id_comp, ← short_exact_sequence.comp_fst],\n refine abelian.pseudoelement.exact_of_pseudo_exact _ _ ⟨λ a , _, λ a ha, _⟩,\n { rw [← abelian.pseudoelement.comp_apply, ← short_exact_sequence.comp_fst, category.assoc,\n horseshoe_ker_ι_comp_base_π, comp_zero, short_exact_sequence.hom_zero_fst,\n abelian.pseudoelement.zero_apply] },\n { obtain ⟨b, hb⟩ := is_snake_input.exists_of_exact exact_kernel_ι _ ha,\n obtain ⟨c, hc⟩ := abelian.pseudoelement.pseudo_surjective_of_epi\n (horseshoe_base_π (horseshoe_ker _)).1 b,\n refine ⟨c, _⟩,\n rw [short_exact_sequence.comp_fst, abelian.pseudoelement.comp_apply, hc, ← hb],\n refl }\n end,\n exact := λ n, horseshoe_exact₁ A n,\n epi := show epi (projective.π _), from infer_instance }\n\nlemma horseshoe_is_projective_resolution₂ (A : short_exact_sequence C) :\n chain_complex.is_projective_resolution\n ((homological_complex.Snd C).obj (horseshoe A)) A.2 (horseshoe_to_single₂ A) :=\n{ projective := by rintro (_|n); { show projective (projective.over _ ⊞ projective.over _),\n apply_instance },\n exact₀ :=\n begin\n dsimp [horseshoe_to_single₂, chain_complex.to_single₀_equiv, horseshoe_π],\n erw [chain_complex.of_d],\n dsimp [horseshoe_d, horseshoe_step],\n rw [category.id_comp, ← short_exact_sequence.comp_snd],\n refine abelian.pseudoelement.exact_of_pseudo_exact _ _ ⟨λ a , _, λ a ha, _⟩,\n { rw [← abelian.pseudoelement.comp_apply, ← short_exact_sequence.comp_snd, category.assoc,\n horseshoe_ker_ι_comp_base_π, comp_zero, short_exact_sequence.hom_zero_snd,\n abelian.pseudoelement.zero_apply] },\n { obtain ⟨b, hb⟩ := is_snake_input.exists_of_exact exact_kernel_ι _ ha,\n obtain ⟨c, hc⟩ := abelian.pseudoelement.pseudo_surjective_of_epi\n (horseshoe_base_π (horseshoe_ker _)).2 b,\n refine ⟨c, _⟩,\n rw [short_exact_sequence.comp_snd, abelian.pseudoelement.comp_apply, hc, ← hb],\n refl }\n end,\n exact := λ n, horseshoe_exact₂ A n,\n epi := show epi (horseshoe_base_π _).2, from infer_instance }\n\nlemma horseshoe_is_projective_resolution₃ (A : short_exact_sequence C) :\n chain_complex.is_projective_resolution\n ((homological_complex.Trd C).obj (horseshoe A)) A.3 (horseshoe_to_single₃ A) :=\n{ projective := by rintro (_|n); { show projective (projective.over _), apply_instance },\n exact₀ :=\n begin\n dsimp [horseshoe_to_single₃, chain_complex.to_single₀_equiv, horseshoe_π],\n erw [chain_complex.of_d],\n dsimp [horseshoe_d, horseshoe_step],\n rw [category.id_comp, ← short_exact_sequence.comp_trd],\n refine abelian.pseudoelement.exact_of_pseudo_exact _ _ ⟨λ a , _, λ a ha, _⟩,\n { rw [← abelian.pseudoelement.comp_apply, ← short_exact_sequence.comp_trd, category.assoc,\n horseshoe_ker_ι_comp_base_π, comp_zero, short_exact_sequence.hom_zero_trd,\n abelian.pseudoelement.zero_apply] },\n { obtain ⟨b, hb⟩ := is_snake_input.exists_of_exact exact_kernel_ι _ ha,\n obtain ⟨c, hc⟩ := abelian.pseudoelement.pseudo_surjective_of_epi\n (horseshoe_base_π (horseshoe_ker _)).3 b,\n refine ⟨c, _⟩,\n rw [short_exact_sequence.comp_trd, abelian.pseudoelement.comp_apply, hc, ← hb],\n refl }\n end,\n exact := λ n, horseshoe_exact₃ A n,\n epi := show epi (projective.π _), from infer_instance }\n.\n\nlemma horseshoe_split (A : short_exact_sequence C) (n : ℕ) :\n ((horseshoe A).X n).split :=\nbegin\n cases n;\n exact ⟨biprod.fst, biprod.inr, biprod.inl_fst, biprod.inr_snd, biprod.inr_fst, biprod.total⟩\nend\n\nlemma horseshoe_f_comp_to_single₂_f (A : short_exact_sequence C) (i : ℕ) :\n ((horseshoe A).X i).f ≫ (horseshoe_to_single₂ A).f i =\n (horseshoe_to_single₁ A).f i ≫ ((chain_complex.single₀ C).map A.f).f i :=\nbegin\n cases i,\n { dsimp [horseshoe_to_single₂, horseshoe_to_single₁, horseshoe, horseshoe_obj, horseshoe_step,\n horseshoe_base, horseshoe_π, horseshoe_base_π, chain_complex.to_single₀_equiv],\n simp },\n { dsimp [horseshoe_to_single₂, horseshoe_to_single₁, horseshoe, horseshoe_obj, horseshoe_step,\n horseshoe_base, horseshoe_π, horseshoe_base_π, chain_complex.to_single₀_equiv],\n simp }\nend\n\nlemma horseshoe_g_comp_to_single₃_f (A : short_exact_sequence C) (i : ℕ) :\n ((horseshoe A).X i).g ≫ (horseshoe_to_single₃ A).f i =\n (horseshoe_to_single₂ A).f i ≫ ((chain_complex.single₀ C).map A.g).f i :=\nbegin\n cases i,\n { dsimp [horseshoe_to_single₂, horseshoe_to_single₃, chain_complex.to_single₀_equiv, horseshoe,\n horseshoe_obj, horseshoe_π, horseshoe_step, horseshoe_base, horseshoe_base_π],\n ext,\n { simp },\n { simp } },\n { dsimp [horseshoe_to_single₂, horseshoe_to_single₃, horseshoe, horseshoe_obj, horseshoe_step,\n horseshoe_base, horseshoe_π, horseshoe_base_π, chain_complex.to_single₀_equiv],\n simp }\nend\n\nend short_exact_sequence\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/horseshoe.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.550607350786733, "lm_q2_score": 0.399811640739795, "lm_q1q2_score": 0.22013922832143556}} {"text": "def bad_theorem : Prop := \n ∀ (α : Type) (r : α → α → Prop), symmetric r → transitive r → reflexive r\n\ndef fail (a b : unit): Prop := false\ntheorem fail_symm : symmetric fail := λ x y h, h\ntheorem fail_trans : transitive fail := λ x y z h1 _, false.rec (fail x z) h1\n-- theorem not_refl_fail : ¬ reflexive fail := λ a, a ()\n\ntheorem correct_version : ¬ bad_theorem := λ a, a unit fail fail_symm fail_trans ()", "meta": {"author": "ezrasitorus", "repo": "codewars_lean", "sha": "6d1abcc1253403511f4cfd767c645596175e4fd3", "save_path": "github-repos/lean/ezrasitorus-codewars_lean", "path": "github-repos/lean/ezrasitorus-codewars_lean/codewars_lean-6d1abcc1253403511f4cfd767c645596175e4fd3/src/symm_trans_refl.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6370307806984444, "lm_q2_score": 0.3451052642223204, "lm_q1q2_score": 0.2198426758906877}} {"text": "import for_mathlib.algebra.homology.trunc_le\n\nnoncomputable theory\n\nopen category_theory category_theory.limits category_theory.category\nopen_locale zero_object\n\nlemma int.three_cases (a n : ℤ) :\n (n a)\n (h₁ : b =*> q)\n (h₂ : p =*> b)\n (h₃ : p =*> q)\n (h₄ : a =*> q)\n (h₅ : a =*> b)\n (h₆ : a =*> b ⊛ q)\n (h₇ : p =*> emp) :\n p ⊛ a =*> q ⊛ b :=\nbegin\n duplicate_goal 9,\n { s_apply h₀, admit },\n { s_apply h₁, admit },\n { s_apply h₂, admit },\n { s_apply h₃, admit },\n { s_apply h₄, admit },\n { s_apply h₅, admit },\n { s_apply h₆, s_apply h₇ },\n { s_assumptions, admit },\n { s_assumption, admit },\n s_show p =*> b,\n { assumption, },\n { assumption, },\nend\n", "meta": {"author": "cipher1024", "repo": "lean-pl", "sha": "829680605ac17e91038d793c0188e9614353ca25", "save_path": "github-repos/lean/cipher1024-lean-pl", "path": "github-repos/lean/cipher1024-lean-pl/lean-pl-829680605ac17e91038d793c0188e9614353ca25/src/test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5813030906443134, "lm_q2_score": 0.3775406687981454, "lm_q1q2_score": 0.21946555761628303}} {"text": "import .basic\n\nnamespace polya.field\n\nnamespace nterm\n\nnamespace pform\n\nvariables {α : Type} [discrete_field α]\nvariables {γ : Type} [const_space γ]\nvariables [morph γ α] {ρ : dict α}\n\ninstance : has_coe (option (nterm γ)) (nterm γ) := ⟨λ x, x.get_or_else (const 1)⟩\n\nprivate lemma eval_none : eval ρ ((none : option (nterm γ)) : nterm γ) = 1 :=\nby apply morph.morph_one'\n\nprivate lemma eval_some {x : nterm γ} : eval ρ (some x : nterm γ) = eval ρ x := rfl\n\nlocal attribute [simp] eval_none\nlocal attribute [simp] eval_some\n\nprivate def to_pform : nterm γ → option (nterm γ) | x :=\nif x = const 1 then none else some x --TODO\n\nprivate lemma eval_to_pform {x : nterm γ} : eval ρ (to_pform x : nterm γ) = eval ρ x :=\nbegin\n unfold to_pform,\n by_cases h1 : x = const 1,\n repeat { simp [h1, eval] },\nend\n\n@[simp] theorem eval_pow_mul_option {x : option (nterm γ)} {n : znum} : eval ρ (x.map (pow_mul n) : nterm γ) = eval ρ (x : nterm γ) ^ (n : ℤ) :=\nby cases x; simp\n\nprivate def mul' : option (nterm γ) → nterm γ → nterm γ\n| (some x) y :=\n let d := znum.gcd x.exp y.exp in\n some $ pow_mul d $ mul (x.pow_div d) (y.pow_div d)\n| none y := y\n\nprivate lemma eval_mul' {x : option (nterm γ)} {y : nterm γ} :\n eval ρ (mul' x y) = eval ρ (x : nterm γ) * eval ρ y :=\nbegin\n cases x with x,\n { simp [mul'] },\n rw eval_some, unfold mul',\n --generalize : d = znum.gcd (exp x) (exp y) : znum,\n --have h1 : (d : znum) ∣ exp x, from sorry,\n --have h2 : (d : znum) ∣ exp y, from sorry,\n rw [eval_some, eval_pow_mul], unfold eval,\n rw [mul_fpow, eval_pow_div, eval_pow_div],\n { sorry },\n { sorry }\nend\n\nprivate def left : nterm γ → option (nterm γ)\n| (mul x _) := some x\n| _ := none\n\nprivate def right : nterm γ → (nterm γ)\n| (mul _ x) := x\n| x := x\n\ndef rest (P : nterm γ) : option (nterm γ) := (left P.mem).map (pow_mul P.exp)\n\ndef lead (P : nterm γ) : nterm γ := pow_mul P.exp (right P.mem)\n\ntheorem eval_left_right (x : nterm γ) :\n eval ρ x = eval ρ (left x : nterm γ) * eval ρ (right x) :=\nbegin\n cases x,\n case mul : x y { simp [left, right, eval] }, \n repeat { simp [left, right, eval] } \nend\n\ntheorem eval_rest_lead {P : nterm γ} :\n eval ρ P = eval ρ (rest P : nterm γ) * eval ρ (lead P) :=\nbegin\n rw [eval_mem_exp, eval_left_right, mul_fpow],\n congr' 1,\n { unfold rest, cases (mem P); simp [left] },\n { unfold lead, rw eval_pow_mul }\nend\n\ninductive r : option (nterm γ) → option (nterm γ) → Prop\n| none {S : nterm γ} : r none (some S)\n| rest {S : nterm γ} : r (rest S) (some S)\n\nnamespace wf\n\nprivate lemma acc_r_none : @acc (option (nterm γ)) r none :=\nbegin\n apply acc.intro, intros x h, cases h\nend\n\nprivate def g : nterm γ → ℕ\n| (add x _) := g x + 1\n| (mul x (const _)) := g x\n| _ := 0\n\nprivate def f : option (nterm γ) → ℕ\n| (some x) := g x + 1\n| none := 0\n\nprivate lemma g_scale {x : nterm γ} {a : γ} : g (x.scale a) ≤ g x :=\nbegin\n sorry\nend\n\nprivate lemma f_none {S : nterm γ} : f (none : option (nterm γ)) < f (some S) :=\nby { unfold f, linarith }\n\nprivate lemma f_map_scale {x : option (nterm γ)} {a : γ} : f (x.map (scale a)) ≤ f x :=\nby { cases x; simp [f, g_scale] }\n\nprivate lemma f_rest {S : nterm γ} : f (rest S) < f (some S) :=\nbegin\n sorry\nend\n\ntheorem r_wf : @well_founded (option (nterm γ)) r :=\nbegin\n apply subrelation.wf,\n intros x y h,\n show f x < f y,\n cases h, { apply f_none }, { apply f_rest },\n apply measure_wf\nend\n\nmeta def rel_tac : tactic unit := `[exact ⟨psigma.lex r (λ _, r), psigma.lex_wf wf.r_wf (λ _, wf.r_wf)⟩]\n\nmeta def dec_tac : tactic unit :=\n`[apply psigma.lex.left, assumption, done]\n<|> `[apply psigma.lex.right, assumption, done]\n\nend wf\n\nprivate def aux (x y : nterm γ) (p1 p2 p3 : option (nterm γ)) : nterm γ :=\nif x.mem = y.mem then\n if x.exp + y.exp = 0 then (p1 : nterm γ)\n else mul' p1 (pow x.mem (x.exp + y.exp))\nelse if x.term < y.term then --TODO\n mul' p2 x\nelse\n mul' p3 y\n\nprivate lemma eval_aux_1 {x y : nterm γ} {p1 p2 p3 : option (nterm γ)}\n ( H0 : x.exp + y.exp ≠ 0)\n ( H1 : eval ρ (p2 : nterm γ) = eval ρ (p1 : nterm γ) * eval ρ y )\n ( H2 : eval ρ (p3 : nterm γ) = eval ρ (p1 : nterm γ) * eval ρ x ) :\n eval ρ (aux x y p1 p2 p3) = eval ρ (p1 : nterm γ) * eval ρ y * eval ρ x :=\nbegin\n unfold aux,\n by_cases h1 : x.mem = y.mem,\n { rw [if_pos h1, mul_assoc],\n { rw if_neg H0, rw [eval_mul'], congr,\n unfold eval,\n by_cases h2 : exp x = 0,\n { have : eval ρ x = 1, { rw [eval_mem_exp x, h2], simp }, rw [h1, h2, this, eval_mem_exp y], simp, },\n { by_cases h3 : eval ρ (mem x) = 0,\n { have : eval ρ x = 0, { rw [eval_mem_exp x, h3, zero_fpow], rw ← znum.cast_zero, exact_mod_cast h2 },\n rw [h3, zero_fpow, this, mul_zero],\n rw ← znum.cast_zero, exact_mod_cast H0 },\n { rw [znum.cast_add, fpow_add h3],\n rw [← eval_mem_exp, h1, ← eval_mem_exp, mul_comm] }}}},\n { rw if_neg h1,\n by_cases h2 : x.term < y.term,\n { rw if_pos h2, rw [eval_mul'], congr, apply H1 },\n { rw if_neg h2, rw [mul_assoc, mul_comm (eval ρ y), ← mul_assoc, eval_mul'], congr, apply H2 }}\nend\n\nprivate def mul_option : option (nterm γ) → option (nterm γ) → option (nterm γ)\n| (some x) (some y) := mul' (some x) y --TODO\n| none x := x\n| x none := x\n\nprivate lemma mul_pform_def1 {x : option (nterm γ)} :\n mul_option none x = x :=\nby cases x; unfold mul_option\n\nprivate lemma mul_pform_def2 {x : option (nterm γ)} :\n mul_option x none = x :=\nby cases x; unfold mul_option\n\nlocal attribute [simp] mul_pform_def1\nlocal attribute [simp] mul_pform_def2\n\nprivate lemma eval_mul_option {P Q : option (nterm γ)} : eval ρ (mul_option P Q : nterm γ) = eval ρ (P : nterm γ) * eval ρ (Q : nterm γ) :=\nbegin\n cases P, { simp },\n cases Q, { simp },\n exact eval_mul'\nend\n\nprotected def mul (x y : nterm γ) : nterm γ :=\nif x = const 0 ∨ y = const 0 then\n const 0\nelse\n mul (mul_option (to_pform x.term) (to_pform y.term)) (const (x.coeff * y.coeff))\n\ntheorem eval_mul {x y : nterm γ} : eval ρ (pform.mul x y) = eval ρ x * eval ρ y :=\nbegin\n unfold pform.mul,\n by_cases h1 : x = const 0 ∨ y = const 0,\n { cases h1; simp [h1, eval] },\n { rw if_neg h1, unfold eval,\n rw [eval_mul_option, eval_to_pform, eval_to_pform, morph.morph_mul],\n rw [mul_assoc, mul_comm (↑(coeff x)), ← mul_assoc (eval ρ (term y))],\n rw [← eval_term_coeff, mul_comm (eval ρ y), ← mul_assoc],\n rw [← eval_term_coeff] }\nend\n\nend pform\n\nend nterm\n\nend polya.field\n", "meta": {"author": "lean-forward", "repo": "field", "sha": "7e2127ad485aec25e58a1b9c82a6bb74a599467a", "save_path": "github-repos/lean/lean-forward-field", "path": "github-repos/lean/lean-forward-field/field-7e2127ad485aec25e58a1b9c82a6bb74a599467a/src/data/polya/field/pform.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5583270090337583, "lm_q2_score": 0.39233683016710835, "lm_q1q2_score": 0.2190522489209872}} {"text": "import Runtime.Execution.Basic\n\nnamespace Execution.Executable\nopen Network\n\ndef nextTime (exec : Executable net) : Option (Time.From exec.time) :=\n match exec.state with\n | .shuttingDown => none\n | .shutdownPending => some exec.time\n | .executing => exec.queue.nextTime\n\ntheorem nextTime_le_queue_nextTime {exec : Executable net} {t q} :\n (exec.nextTime = some t) → (exec.queue.nextTime = some q) → (t ≤ q) := by\n intro ht hq\n simp [nextTime] at ht\n split at ht <;> simp_all\n simp [←ht]\n exact q.property\n\nprivate def propagationEvents (exec : Executable net) : Queue (Event net) exec.time where\n events :=\n exec.toPropagate.uniqueMergeMap (le := (·.time ≤ ·.time)) fun port =>\n match exec.reactors port.reactor |>.interface .outputs port.port with\n | none => #[] -- TODO: This case is unreachable by the semantics of `toPropagate`.\n | some value =>\n let events := port.delayedDestinations.map fun { dst, delay, eqType } =>\n Event.propagation (exec.time + delay) dst (eqType ▸ value)\n events.insertionSort (·.time ≤ ·.time) -- TODO: Use `qsort` when it drops `[Inhabited α]`.\n sorted := sorry\n bounded := sorry\n\nprivate def nextTimerEvents (exec : Executable net) (timers : Array (TimerId net)) (anchor : Time) :\n Queue (Event net) anchor where\n events :=\n timers.filterMap fun ⟨reactor, timer⟩ =>\n match exec.reactors reactor |>.timer timer |>.val.period with\n | none => none\n | some period => return .timer (anchor + period) ⟨reactor, timer⟩\n sorted := sorry\n bounded := sorry\n\nstructure Next (net : Network) where\n tag : Tag\n events : Array (Event net)\n queue : Queue (Event net) tag.time\n\nnamespace Next\n\ndef empty (tag : Tag) : Next net where\n tag := tag\n events := #[]\n queue := °[]\n\nprotected def «for» (exec : Executable net) : Option (Next net) :=\n -- TODO: It feels like this doesn't belong here.\n let exec := { exec with queue := exec.queue.merge exec.propagationEvents }\n match h : exec.nextTime with\n | none => none\n | some time =>\n -- TODO: We can't destruct here, as this causes problems in the proof of `bounded` below.\n let eventSplit := exec.queue.split time (fun _ h' => nextTime_le_queue_nextTime h h')\n let events := eventSplit.fst\n let later := eventSplit.snd\n let timers := events.filterMap (·.timer?)\n let timerEvents := exec.nextTimerEvents timers time\n some {\n tag := exec.tag.advance time\n events := events\n queue := Tag.advance_time ▸ later.merge timerEvents\n }\n\ntheorem for_tag_strictly_monotonic (exec : Executable net) :\n (Next.for exec = some next) → (exec.tag < next.tag) := by\n intro h\n simp [Next.for] at h\n split at h\n · contradiction\n · simp at h\n simp [←h, Tag.lt_advance]\n\ntheorem for_isSome_if_shutdownPending {exec : Executable net} :\n (exec.state = .shutdownPending) → (Next.for exec).isSome :=\n sorry\n\n/- TODO: Requires List.Perm\ntheorem for_preserves_events :\n (Next.for exec = some next) →\n ∃ timerEvents propagationEvents,\n (next.events ++ next.queue.events) ~ (exec.queue.events ++ timerEvents ++ propagationEvents) := by\n sorry\n-/\n\n-- The actions-interface for a given reactor according to the `Next` instance.\ndef actions (next : Next net) (reactor : ReactorId net) :\n Interface? (reactor.class.interface .actions) :=\n fun action =>\n match h : next.events.findP? (·.id = .action ⟨reactor, action⟩) with\n | none => none\n | some event => have h := Array.findP?_property h; event.actionValue (of_decide_eq_true h)\n\n-- The inputs-interface for a given reactor according to the `Next` instance.\ndef inputs (next : Next net) (reactor : ReactorId net) :\n Interface? (reactor.class.interface .inputs) :=\n fun input =>\n match h : next.events.findP? (·.id = .propagation ⟨reactor, input⟩) with\n | none => none\n | some event => have h := Array.findP?_property h; event.propagationValue (of_decide_eq_true h)\n\ndef timers (next : Next net) (exec : Executable net) (reactor : ReactorId net) :\n reactor.class.timers → Reactor.Timer :=\n fun timer => {\n val := exec.reactors reactor |>.timer timer |>.val\n isFiring := next.events.any (·.timer? = some ⟨reactor, timer⟩)\n }\n\nend Next\nend Execution.Executable\n", "meta": {"author": "lf-lang", "repo": "reactor-lean", "sha": "d2eb5458446af838be34ebb6f69549b2f6d9c04d", "save_path": "github-repos/lean/lf-lang-reactor-lean", "path": "github-repos/lean/lf-lang-reactor-lean/reactor-lean-d2eb5458446af838be34ebb6f69549b2f6d9c04d/Runtime/Execution/Next.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.38121956625614994, "lm_q1q2_score": 0.2186974336595646}} {"text": "/-\nFile: signature_recover_public_key_ec_add_soundness.lean\n\nAutogenerated file.\n-/\nimport starkware.cairo.lean.semantics.soundness.hoare\nimport .signature_recover_public_key_code\nimport ..signature_recover_public_key_spec\nimport .signature_recover_public_key_fast_ec_add_soundness\nimport .signature_recover_public_key_is_zero_soundness\nimport .signature_recover_public_key_ec_double_soundness\nopen tactic\n\nopen starkware.cairo.common.cairo_secp.ec\nopen starkware.cairo.common.cairo_secp.bigint\nopen starkware.cairo.common.cairo_secp.field\n\nvariables {F : Type} [field F] [decidable_eq F] [prelude_hyps F]\nvariable mem : F → F\nvariable σ : register_state F\n\n/- starkware.cairo.common.cairo_secp.ec.ec_add autogenerated soundness theorem -/\n\ntheorem auto_sound_ec_add\n -- arguments\n (range_check_ptr : F) (point0 point1 : EcPoint F)\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_ec_add σ.pc)\n -- all dependencies are in memory\n (h_mem_4 : mem_at mem code_nondet_bigint3 (σ.pc - 404))\n (h_mem_5 : mem_at mem code_unreduced_mul (σ.pc - 392))\n (h_mem_6 : mem_at mem code_unreduced_sqr (σ.pc - 372))\n (h_mem_7 : mem_at mem code_verify_zero (σ.pc - 356))\n (h_mem_8 : mem_at mem code_is_zero (σ.pc - 333))\n (h_mem_12 : mem_at mem code_compute_doubling_slope (σ.pc - 228))\n (h_mem_13 : mem_at mem code_compute_slope (σ.pc - 184))\n (h_mem_14 : mem_at mem code_ec_double (σ.pc - 160))\n (h_mem_15 : mem_at mem code_fast_ec_add (σ.pc - 87))\n -- input arguments on the stack\n (hin_range_check_ptr : range_check_ptr = mem (σ.fp - 15))\n (hin_point0 : point0 = cast_EcPoint mem (σ.fp - 14))\n (hin_point1 : point1 = cast_EcPoint mem (σ.fp - 8))\n -- conclusion\n : ensures_ret mem σ (λ κ τ,\n ∃ μ ≤ κ, rc_ensures mem (rc_bound F) μ (mem (σ.fp - 15)) (mem $ τ.ap - 7)\n (spec_ec_add mem κ range_check_ptr point0 point1 (mem (τ.ap - 7)) (cast_EcPoint mem (τ.ap - 6)))) :=\nbegin\n apply ensures_of_ensuresb, intro νbound,\n have h_mem_rec := h_mem,\n unpack_memory code_ec_add at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15, hpc16, hpc17, hpc18, hpc19, hpc20, hpc21, hpc22, hpc23, hpc24, hpc25, hpc26, hpc27, hpc28, hpc29, hpc30, hpc31, hpc32, hpc33, hpc34, hpc35, hpc36, hpc37, hpc38, hpc39, hpc40, hpc41, hpc42, hpc43, hpc44, hpc45, hpc46, hpc47, hpc48, hpc49, hpc50, hpc51, hpc52, hpc53, hpc54, hpc55⟩,\n -- let\n generalize' hl_rev_x_diff: ({\n d0 := point0.x.d0 - point1.x.d0,\n d1 := point0.x.d1 - point1.x.d1,\n d2 := point0.x.d2 - point1.x.d2\n } : BigInt3 F) = x_diff,\n have hl_x_diff := hl_rev_x_diff.symm, clear hl_rev_x_diff,\n try { dsimp at hl_x_diff }, try { arith_simps at hl_x_diff },\n -- function call\n step_assert_eq hpc0 with arg0,\n step_assert_eq hpc1 with arg1,\n step_assert_eq hpc2 with arg2,\n step_assert_eq hpc3 with arg3,\n step_sub hpc4 (auto_sound_is_zero mem _ range_check_ptr x_diff _ _ _ _ _ _),\n { rw hpc5, norm_num2, exact h_mem_8 },\n { rw hpc5, norm_num2, exact h_mem_4 },\n { rw hpc5, norm_num2, exact h_mem_5 },\n { rw hpc5, norm_num2, exact h_mem_7 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, (eq_sub_of_eq_add arg1), (eq_sub_of_eq_add arg2), (eq_sub_of_eq_add arg3)] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, (eq_sub_of_eq_add arg1), (eq_sub_of_eq_add arg2), (eq_sub_of_eq_add arg3)] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call6 ap6 h_call6,\n rcases h_call6 with ⟨rc_m6, rc_mle6, hl_range_check_ptr₁, h_call6⟩,\n generalize' hr_rev_range_check_ptr₁: mem (ap6 - 2) = range_check_ptr₁,\n have htv_range_check_ptr₁ := hr_rev_range_check_ptr₁.symm, clear hr_rev_range_check_ptr₁,\n generalize' hr_rev_same_x: mem (ap6 - 1) = same_x,\n simp only [hr_rev_same_x] at h_call6,\n have htv_same_x := hr_rev_same_x.symm, clear hr_rev_same_x,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3] at hl_range_check_ptr₁ },\n rw [←htv_range_check_ptr₁, ←hin_range_check_ptr] at hl_range_check_ptr₁,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3] at h_call6 },\n rw [hin_range_check_ptr] at h_call6,\n clear arg0 arg1 arg2 arg3,\n -- if statement\n step_jnz hpc6 hpc7 with hcond hcond,\n {\n -- if: positive branch\n have a6 : same_x = 0, {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a6 }, try { arith_simps at a6 },\n clear hcond,\n -- tail function call\n step_assert_eq hpc8 with arg0,\n step_assert_eq hpc9 with arg1,\n step_assert_eq hpc10 with arg2,\n step_assert_eq hpc11 with arg3,\n step_assert_eq hpc12 with arg4,\n step_assert_eq hpc13 with arg5,\n step_assert_eq hpc14 with arg6,\n step_assert_eq hpc15 with arg7,\n step_assert_eq hpc16 with arg8,\n step_assert_eq hpc17 with arg9,\n step_assert_eq hpc18 with arg10,\n step_assert_eq hpc19 with arg11,\n step_assert_eq hpc20 with arg12,\n step_sub hpc21 (auto_sound_fast_ec_add mem _ range_check_ptr₁ point0 point1 _ _ _ _ _ _ _ _ _),\n { rw hpc22, norm_num2, exact h_mem_15 },\n { rw hpc22, norm_num2, exact h_mem_4 },\n { rw hpc22, norm_num2, exact h_mem_5 },\n { rw hpc22, norm_num2, exact h_mem_6 },\n { rw hpc22, norm_num2, exact h_mem_7 },\n { rw hpc22, norm_num2, exact h_mem_13 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call23 ap23 h_call23,\n rcases h_call23 with ⟨rc_m23, rc_mle23, hl_range_check_ptr₂, h_call23⟩,\n step_ret hpc23,\n generalize' hr_rev_range_check_ptr₂: mem (ap23 - 7) = range_check_ptr₂,\n have htv_range_check_ptr₂ := hr_rev_range_check_ptr₂.symm, clear hr_rev_range_check_ptr₂,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at hl_range_check_ptr₂ },\n rw [←htv_range_check_ptr₂, ←htv_range_check_ptr₁] at hl_range_check_ptr₂,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at h_call23 },\n rw [←htv_range_check_ptr₁, hl_range_check_ptr₁, hin_range_check_ptr] at h_call23,\n clear arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 arg10 arg11 arg12,\n -- finish\n step_done, use_only [rfl, rfl],\n -- range check condition\n use_only (rc_m6+rc_m23+0+0), split,\n linarith [rc_mle6, rc_mle23],\n split,\n { arith_simps,\n rw [←htv_range_check_ptr₂, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr],\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_ec_add mem _ range_check_ptr point0 point1 _ _,\n { apply sound_ec_add, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_ec_add],\n try { norm_num1 }, try { arith_simps },\n use_only [x_diff, hl_x_diff],\n use_only [κ_call6],\n use_only [range_check_ptr₁],\n use_only [same_x],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have spec6 := h_call6 rc_h_range_check_ptr',\n rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec6,\n try { dsimp at spec6, arith_simps at spec6 },\n use_only [spec6],\n left,\n use_only [a6],\n use_only [κ_call23],\n have rc_h_range_check_ptr₂ := range_checked_offset' rc_h_range_check_ptr₁,\n have rc_h_range_check_ptr₂' := range_checked_add_right rc_h_range_check_ptr₂, try { norm_cast at rc_h_range_check_ptr₂' },\n have spec23 := h_call23 rc_h_range_check_ptr₁',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁] at spec23,\n try { dsimp at spec23, arith_simps at spec23 },\n use_only [spec23],\n try { linarith },\n },\n {\n -- if: negative branch\n have a6 : same_x ≠ 0, {\n try { simp only [ne.def] },\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a6 }, try { arith_simps at a6 },\n clear hcond,\n -- let\n generalize' hl_rev_y_sum: ({\n d0 := point0.y.d0 + point1.y.d0,\n d1 := point0.y.d1 + point1.y.d1,\n d2 := point0.y.d2 + point1.y.d2\n } : BigInt3 F) = y_sum,\n have hl_y_sum := hl_rev_y_sum.symm, clear hl_rev_y_sum,\n try { dsimp at hl_y_sum }, try { arith_simps at hl_y_sum },\n -- function call\n step_assert_eq hpc24 with arg0,\n step_assert_eq hpc25 with arg1,\n step_assert_eq hpc26 with arg2,\n step_assert_eq hpc27 with arg3,\n step_sub hpc28 (auto_sound_is_zero mem _ range_check_ptr₁ y_sum _ _ _ _ _ _),\n { rw hpc29, norm_num2, exact h_mem_8 },\n { rw hpc29, norm_num2, exact h_mem_4 },\n { rw hpc29, norm_num2, exact h_mem_5 },\n { rw hpc29, norm_num2, exact h_mem_7 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x, hl_y_sum] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x, hl_y_sum] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call30 ap30 h_call30,\n rcases h_call30 with ⟨rc_m30, rc_mle30, hl_range_check_ptr₂, h_call30⟩,\n generalize' hr_rev_range_check_ptr₂: mem (ap30 - 2) = range_check_ptr₂,\n have htv_range_check_ptr₂ := hr_rev_range_check_ptr₂.symm, clear hr_rev_range_check_ptr₂,\n generalize' hr_rev_opposite_y: mem (ap30 - 1) = opposite_y,\n simp only [hr_rev_opposite_y] at h_call30,\n have htv_opposite_y := hr_rev_opposite_y.symm, clear hr_rev_opposite_y,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3] at hl_range_check_ptr₂ },\n rw [←htv_range_check_ptr₂, ←htv_range_check_ptr₁] at hl_range_check_ptr₂,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3] at h_call30 },\n rw [←htv_range_check_ptr₁, hl_range_check_ptr₁, hin_range_check_ptr] at h_call30,\n clear arg0 arg1 arg2 arg3,\n -- if statement\n step_jnz hpc30 hpc31 with hcond hcond,\n {\n -- if: positive branch\n have a30 : opposite_y = 0, {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x, hl_y_sum, htv_range_check_ptr₂, htv_opposite_y] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a30 }, try { arith_simps at a30 },\n clear hcond,\n -- tail function call\n step_assert_eq hpc32 with arg0,\n step_assert_eq hpc33 with arg1,\n step_assert_eq hpc34 with arg2,\n step_assert_eq hpc35 with arg3,\n step_assert_eq hpc36 with arg4,\n step_assert_eq hpc37 with arg5,\n step_assert_eq hpc38 with arg6,\n step_sub hpc39 (auto_sound_ec_double mem _ range_check_ptr₂ point0 _ _ _ _ _ _ _ _),\n { rw hpc40, norm_num2, exact h_mem_14 },\n { rw hpc40, norm_num2, exact h_mem_4 },\n { rw hpc40, norm_num2, exact h_mem_5 },\n { rw hpc40, norm_num2, exact h_mem_6 },\n { rw hpc40, norm_num2, exact h_mem_7 },\n { rw hpc40, norm_num2, exact h_mem_12 },\n { try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x, hl_y_sum, htv_range_check_ptr₂, htv_opposite_y] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n { try { ext } ; {\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x, hl_y_sum, htv_range_check_ptr₂, htv_opposite_y] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [arg0, arg1, arg2, arg3, arg4, arg5, arg6] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },}, },\n intros κ_call41 ap41 h_call41,\n rcases h_call41 with ⟨rc_m41, rc_mle41, hl_range_check_ptr₃, h_call41⟩,\n step_ret hpc41,\n generalize' hr_rev_range_check_ptr₃: mem (ap41 - 7) = range_check_ptr₃,\n have htv_range_check_ptr₃ := hr_rev_range_check_ptr₃.symm, clear hr_rev_range_check_ptr₃,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6] at hl_range_check_ptr₃ },\n rw [←htv_range_check_ptr₃, ←htv_range_check_ptr₂] at hl_range_check_ptr₃,\n try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6] at h_call41 },\n rw [←htv_range_check_ptr₂, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr] at h_call41,\n clear arg0 arg1 arg2 arg3 arg4 arg5 arg6,\n -- finish\n step_done, use_only [rfl, rfl],\n -- range check condition\n use_only (rc_m6+rc_m30+rc_m41+0+0), split,\n linarith [rc_mle6, rc_mle30, rc_mle41],\n split,\n { arith_simps,\n rw [←htv_range_check_ptr₃, hl_range_check_ptr₃, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr],\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_ec_add mem _ range_check_ptr point0 point1 _ _,\n { apply sound_ec_add, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_ec_add],\n try { norm_num1 }, try { arith_simps },\n use_only [x_diff, hl_x_diff],\n use_only [κ_call6],\n use_only [range_check_ptr₁],\n use_only [same_x],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have spec6 := h_call6 rc_h_range_check_ptr',\n rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec6,\n try { dsimp at spec6, arith_simps at spec6 },\n use_only [spec6],\n right,\n use_only [a6],\n use_only [y_sum, hl_y_sum],\n use_only [κ_call30],\n use_only [range_check_ptr₂],\n use_only [opposite_y],\n have rc_h_range_check_ptr₂ := range_checked_offset' rc_h_range_check_ptr₁,\n have rc_h_range_check_ptr₂' := range_checked_add_right rc_h_range_check_ptr₂, try { norm_cast at rc_h_range_check_ptr₂' },\n have spec30 := h_call30 rc_h_range_check_ptr₁',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←htv_range_check_ptr₂] at spec30,\n try { dsimp at spec30, arith_simps at spec30 },\n use_only [spec30],\n right,\n use_only [a30],\n use_only [κ_call41],\n have rc_h_range_check_ptr₃ := range_checked_offset' rc_h_range_check_ptr₂,\n have rc_h_range_check_ptr₃' := range_checked_add_right rc_h_range_check_ptr₃, try { norm_cast at rc_h_range_check_ptr₃' },\n have spec41 := h_call41 rc_h_range_check_ptr₂',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←hl_range_check_ptr₂] at spec41,\n try { dsimp at spec41, arith_simps at spec41 },\n use_only [spec41],\n try { linarith },\n },\n {\n -- if: negative branch\n have a30 : opposite_y ≠ 0, {\n try { simp only [ne.def] },\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x, hl_y_sum, htv_range_check_ptr₂, htv_opposite_y] },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hcond] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a30 }, try { arith_simps at a30 },\n clear hcond,\n -- let\n generalize' hl_rev_ZERO_POINT: ({\n x := { d0 := 0, d1 := 0, d2 := 0 },\n y := { d0 := 0, d1 := 0, d2 := 0 }\n } : EcPoint F) = ZERO_POINT,\n have hl_ZERO_POINT := hl_rev_ZERO_POINT.symm, clear hl_rev_ZERO_POINT,\n try { dsimp at hl_ZERO_POINT }, try { arith_simps at hl_ZERO_POINT },\n -- return\n step_assert_eq hpc42 with hret0,\n step_assert_eq hpc43 hpc44 with hret1,\n step_assert_eq hpc45 hpc46 with hret2,\n step_assert_eq hpc47 hpc48 with hret3,\n step_assert_eq hpc49 hpc50 with hret4,\n step_assert_eq hpc51 hpc52 with hret5,\n step_assert_eq hpc53 hpc54 with hret6,\n step_ret hpc55,\n -- finish\n step_done, use_only [rfl, rfl],\n -- range check condition\n use_only (rc_m6+rc_m30+0+0), split,\n linarith [rc_mle6, rc_mle30],\n split,\n { arith_simps, try { simp only [hret0 ,hret1 ,hret2 ,hret3 ,hret4 ,hret5 ,hret6] },\n rw [←htv_range_check_ptr₂, hl_range_check_ptr₂, hl_range_check_ptr₁, hin_range_check_ptr],\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_ec_add mem _ range_check_ptr point0 point1 _ _,\n { apply sound_ec_add, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_ec_add],\n try { norm_num1 }, try { arith_simps },\n use_only [x_diff, hl_x_diff],\n use_only [κ_call6],\n use_only [range_check_ptr₁],\n use_only [same_x],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁, try { norm_cast at rc_h_range_check_ptr₁' },\n have spec6 := h_call6 rc_h_range_check_ptr',\n rw [←hin_range_check_ptr, ←htv_range_check_ptr₁] at spec6,\n try { dsimp at spec6, arith_simps at spec6 },\n use_only [spec6],\n right,\n use_only [a6],\n use_only [y_sum, hl_y_sum],\n use_only [κ_call30],\n use_only [range_check_ptr₂],\n use_only [opposite_y],\n have rc_h_range_check_ptr₂ := range_checked_offset' rc_h_range_check_ptr₁,\n have rc_h_range_check_ptr₂' := range_checked_add_right rc_h_range_check_ptr₂, try { norm_cast at rc_h_range_check_ptr₂' },\n have spec30 := h_call30 rc_h_range_check_ptr₁',\n rw [←hin_range_check_ptr, ←hl_range_check_ptr₁, ←htv_range_check_ptr₂] at spec30,\n try { dsimp at spec30, arith_simps at spec30 },\n use_only [spec30],\n left,\n use_only [a30],\n use_only [ZERO_POINT, hl_ZERO_POINT],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_point0, hin_point1, hl_x_diff, htv_range_check_ptr₁, htv_same_x, hl_y_sum, htv_range_check_ptr₂, htv_opposite_y, hl_ZERO_POINT] }, },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hret0, hret1, hret2, hret3, hret4, hret5, hret6] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n }\n }\nend\n\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/common/cairo_secp/verification/verification/signature_recover_public_key_ec_add_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5467381667555714, "lm_q2_score": 0.399811640739795, "lm_q1q2_score": 0.21859228350561266}} {"text": "import order\n\nimport lib.list\n\nimport etv\nimport main.lemmas.join_n2_n3_n2\n\nopen order_dual\n\nvariables {α : Type*} [linear_order α] (C : config α)\n\nlemma config.join_n2_n2_interweaved {S : finset α} {n : ℕ}\n {c1 : list α} (c1_cup : C.ncup (n+2) c1) (c1_in_S : c1.in S)\n {c2 : list α} (c2_cup : C.ncup (n+2) c2) (c2_in_S : c2.in S)\n (x : α) (c1_last : x ∈ c1.last') (c2_head : x ∈ c2.head') :\n ∃ p q r s, C.has_interweaved_laced (n+2) S p q r s :=\nbegin\n rcases c1_cup.take_head_last with ⟨p, c1', q, eq_c1, c1'_cup⟩,\n rcases c2_cup.take_head_last with ⟨q, c2', r, eq_c2, c2'_cup⟩,\n rw eq_c1 at c1_last, rw eq_c2 at c2_head, \n simp at c1_last c2_head, subst c1_last, subst c2_head,\n use [p, q, q, r], refine ⟨_, _, _⟩,\n { refine ⟨_, _, _⟩, \n rw eq_c1 at c1_cup, apply c1_cup.head'_lt_last' p q; simp, simp,\n rw eq_c2 at c2_cup, apply c2_cup.head'_lt_last' q r; simp, },\n { existsi [1, n+1, [p], c1, c2.init, _, c1_cup, c2_cup.init], swap, simp,\n rw eq_c1 at ⊢ c1_in_S, rw eq_c2 at ⊢ c2_in_S, \n simp at ⊢ c1_in_S c2_in_S, ring_nf, tauto, },\n { existsi [n+1, 1, c1.tail, c2, [r], c1_cup.tail, c2_cup, _], swap, simp,\n rw eq_c1 at ⊢ c1_in_S, rw eq_c2 at ⊢ c2_in_S, \n simp at ⊢ c1_in_S c2_in_S, tauto, },\nend\n\nlemma config.join_n2_n3_join_n3_n2_main (S : finset α) (n : ℕ)\n (cap4_free : ¬C.has_ncap 4 S) (cup_free : ¬C.has_ncup (n+4) S)\n {cx : list α} (cx_cup : C.ncup (n+2) cx) (cx_in_S : cx.in S)\n {cx1 : list α} (cx1_cup : C.ncup (n+3) cx1) (cx1_in_S : cx1.in S)\n {cy1 : list α} (cy1_cup : C.ncup (n+3) cy1) (cy1_in_S : cy1.in S)\n {cy : list α} (cy_cup : C.ncup (n+2) cy) (cy_in_S : cy.in S)\n (x : α) (cx_last : x ∈ cx.last') (cx1_head : x ∈ cx1.head')\n (y : α) (cy1_last : y ∈ cy1.last') (cy_head : y ∈ cy.head') : \n ∃ p q r s, C.has_interweaved_laced (n+3) S p q r s :=\nbegin\n have l := cap4_free_label cap4_free,\n have x_in_S := cx_in_S _ (list.mem_of_mem_last' cx_last),\n have y_in_S := cy_in_S _ (list.mem_of_mem_head' cy_head),\n rcases lt_or_le y x with hxy | hxy,\n -- Case y < x\n { by_cases lyx : l.slope y x,\n { exfalso, apply cup_free, use cy1 ++ [x], split,\n apply cy1_cup.extend_right lyx; try { assumption },\n simp, split; assumption, },\n { exfalso, apply cup_free, use y :: cx1, split,\n apply cx1_cup.extend_left lyx; try { assumption },\n simp, split; assumption }, },\n -- Case x ≤ y\n rcases cx1_cup.take_head_last with ⟨x, cx1', z, eq_cx1, cx1'_cup⟩,\n rw eq_cx1 at cx1_head, simp at cx1_head, subst cx1_head,\n rcases cy1_cup.take_head_last with ⟨w, cy1', y, eq_cy1, cy1'_cup⟩,\n rw eq_cy1 at cy1_last, simp at cy1_last, subst cy1_last,\n have z_in_S : z ∈ S := by rw eq_cx1 at cx1_in_S; simp at cx1_in_S; tauto,\n have w_in_S : w ∈ S := by rw eq_cy1 at cy1_in_S; simp at cy1_in_S; tauto,\n rcases lt_trichotomy x w with hwx | hwx | hwx, swap,\n { subst hwx, apply C.join_n2_n3_n2 S cap4_free cup_free\n cx_cup cx_in_S cy1_cup cy1_in_S cy_cup cy_in_S \n x cx_last _ y _ cy_head; rw eq_cy1; simp, },\n { by_cases lxw : l.slope x w,\n { have cxw_cup : C.ncup (n + 3) (cx ++ [w]) := \n by apply cx_cup.extend_right lxw; try {assumption},\n apply C.join_n2_n2_interweaved cxw_cup _ cy1_cup cy1_in_S w,\n simp, rw eq_cy1, simp, simp, tauto, },\n { exfalso, apply cup_free, use x :: cy1, split,\n apply cy1_cup.extend_left lxw; try {assumption}, rw eq_cy1, simp,\n simp, split; assumption, }, },\n -- w < x\n rcases lt_trichotomy z y with hyz | hyz | hyz, swap,\n { subst hyz, apply C.join_n2_n3_n2 S cap4_free cup_free\n cx_cup cx_in_S cx1_cup cx1_in_S cy_cup cy_in_S \n x cx_last _ z _ cy_head; rw eq_cx1; simp, },\n { by_cases lzy : l.slope z y,\n { exfalso, apply cup_free, use cx1 ++ [y], split,\n apply cx1_cup.extend_right lzy; try {assumption}, rw eq_cx1, simp,\n simp, split; assumption, },\n { have zcy_cup : C.ncup (n + 3) (z :: cy) := \n by apply cy_cup.extend_left lzy; try {assumption},\n apply C.join_n2_n2_interweaved cx1_cup _ zcy_cup _ z,\n rw eq_cx1, simp, simp, tauto, simp, tauto, }, },\n -- y < z\n use [w, x, y, z], refine ⟨_, _, _⟩, tauto,\n { existsi [1, n+2, [w], cy1, cy, _, cy1_cup, cy_cup], swap, simp,\n split, simp, tauto, split, ring_nf, rw eq_cy1, simp, assumption, },\n { existsi [n+2, 1, cx, cx1, [z], cx_cup, cx1_cup, _], swap, simp,\n split, simp, tauto, split, ring_nf, rw eq_cx1, simp, assumption, },\nend\n\nlemma config.join_n2_n3_join_n3_n2 (S : finset α) (n : ℕ)\n (cap4_free : ¬C.has_ncap 4 S) (cup_free : ¬C.has_ncup (n+4) S)\n (hx : C.has_join (n+2) (n+3) S) (hy : C.has_join (n+3) (n+2) S) : \n ∃ p q r s, C.has_interweaved_laced (n+3) S p q r s := \nbegin\n rcases hx with ⟨x, cx, cx1, \n ⟨cx_cup, cx_in_S, cx_last⟩, ⟨cx1_cup, cx1_in_S, cx1_head⟩⟩,\n rcases hy with ⟨y, cy1, cy, \n ⟨cy1_cup, cy1_in_S, cy1_last⟩, ⟨cy_cup, cy_in_S, cy_head⟩⟩,\n apply C.join_n2_n3_join_n3_n2_main S n \n cap4_free cup_free cx_cup cx_in_S cx1_cup cx1_in_S \n cy1_cup cy1_in_S cy_cup cy_in_S x cx_last cx1_head\n y cy1_last cy_head,\nend", "meta": {"author": "jcpaik", "repo": "erdos-tuza-valtr", "sha": "7fceb6f4f7d73bc3a0a09f48426b0e9350bc82ef", "save_path": "github-repos/lean/jcpaik-erdos-tuza-valtr", "path": "github-repos/lean/jcpaik-erdos-tuza-valtr/erdos-tuza-valtr-7fceb6f4f7d73bc3a0a09f48426b0e9350bc82ef/src/main/lemmas/join_n2_n3_join_n3_n2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.43014734858584286, "lm_q1q2_score": 0.21843392700013367}} {"text": "-- Copyright 2022-2023 VMware, Inc.\n-- SPDX-License-Identifier: BSD-2-Clause\n\nimport .operators\nimport .linear\nimport .stream_elim\nimport .incremental\n\nimport tactic.induction\n\nnamespace ckt.\n\nsection ckts.\n\nparameter (Func: ∀ (a b: Type) [add_comm_group a] [add_comm_group b], Type).\nparameter (Func_denote: ∀ {a b: Type} [add_comm_group a] [add_comm_group b], Func a b → (a → b)).\n\ninductive ckt : ∀ (a b: Type) [add_comm_group a] [add_comm_group b], Type 1\n| delay {a: Type} [add_comm_group a]\n : ckt a a\n| derivative {a: Type} [add_comm_group a]\n : ckt a a\n| integral {a: Type} [add_comm_group a]\n : ckt a a\n| incremental {a b: Type} [add_comm_group a] [add_comm_group b]\n (f: ckt a b) : ckt a b\n| lifting {a b: Type} [add_comm_group a] [add_comm_group b]\n (f: Func a b) : ckt a b\n-- | ckt_lift {a b: Type} [add_comm_group a] [add_comm_group b]\n-- (f: ckt a b) : ckt (stream a) (stream b)\n| seq {a b c: Type} [add_comm_group a] [add_comm_group b] [add_comm_group c]\n (f1: ckt a b) (f2: ckt b c) : ckt a c\n| par {a₁ b₁ a₂ b₂: Type}\n [add_comm_group a₁] [add_comm_group a₂] [add_comm_group b₁] [add_comm_group b₂]\n (f1: ckt a₁ b₁) (f2: ckt a₂ b₂) : ckt (a₁ × a₂) (b₁ × b₂)\n| feedback {a b: Type} [add_comm_group a] [add_comm_group b]\n (F: ckt (a × b) b) : ckt a b\n-- | intro {a: Type} [add_comm_group a]\n-- : ckt a (stream a)\n-- | elim {a: Type} [add_comm_group a]\n-- : ckt (stream a) a\n.\n\nlocal notation f1 ` ~~> ` f2:25 := ckt _ f1 f2.\n\nvariables {a b c d: Type} [add_comm_group a] [add_comm_group b] [add_comm_group c] [add_comm_group d].\n\nsection denote.\n\ninclude Func_denote.\n\ndef denote (c: ckt a b) : (stream a → stream b) :=\nbegin\n -- unfreezingI { revert_deps a b, revert a b, },\n -- apply (@ckt.rec (λ {a b: Type} [_i1: add_comm_group a] [_i2: add_comm_group b] (f: @ckt a b _i1 _i2), (stream a → stream b))); dsimp; introv; resetI,\n\n -- resetI resets the (typeclass) instance cache, so that the new local\n -- hypotheses can be used for instance search\n -- unfortunately we need this unfreezingI thing and induction rather than\n -- mathlib induction' because of its improper handling of dependencies\n unfreezingI { induction c } ,\n { resetI, apply delay, },\n { resetI, apply D, },\n { resetI, apply I, },\n { resetI, apply c_ih^Δ, },\n { resetI, apply ↑↑(Func_denote c_f), },\n { -- seq\n exact (λ a, c_ih_f2 (c_ih_f1 a)), },\n { -- par\n resetI,\n apply (uncurry_op (λ x1 x2, sprod (c_ih_f1 x1, c_ih_f2 x2))), },\n { -- feedback\n resetI,\n intros s,\n apply fix (λ α, c_ih (sprod (s, z⁻¹ α))),\n },\n -- { resetI, exact ↑↑δ0, },\n -- { resetI, exact ↑↑stream_elim, }\nend\nend denote.\n\ndef equiv (f1 f2: ckt a b) := denote f1 = denote f2.\n\nlocal infix ` === `:50 := equiv.\n\n@[refl]\nlemma equiv_refl (f: ckt a b) : f === f :=\n by { unfold equiv }.\n\n@[symm]\nlemma equiv_symm (f1 f2: ckt a b) : f1 === f2 → f2 === f1 :=\n by { unfold equiv, cc, }.\n\n@[trans]\nlemma equiv_trans (f1 f2 f3: ckt a b) : f1 === f2 → f2 === f3 → f1 === f3 :=\n by { unfold equiv, cc, }.\n\n@[simp]\nlemma denote_seq (f1: ckt a b) (f2: ckt b c) :\n denote (ckt.seq f1 f2) = λ x, denote f2 (denote f1 x) := rfl.\n\n@[simp]\nlemma denote_par\n (f1: ckt a b) (f2: ckt c d) :\n denote (ckt.par f1 f2) = uncurry_op (λ x1 x2, sprod (denote f1 x1, denote f2 x2))\n := rfl.\n\n@[simp]\nlemma denote_delay :\n denote (@ckt.delay a _) = delay := rfl.\n\n@[simp]\nlemma denote_derivative :\n denote (@ckt.derivative a _) = D := rfl.\n\n@[simp]\nlemma denote_incremental (f: ckt a b) :\n denote (ckt.incremental f) = (denote f)^Δ := rfl.\n\n@[simp]\nlemma denote_integral :\n denote (@ckt.integral a _) = I := rfl.\n\n@[simp]\nlemma denote_lifting (f: Func a b) :\n denote (ckt.lifting f) = ↑↑(Func_denote f) := rfl.\n\n-- @[simp]\n-- lemma denote_ckt_lift (f: ckt a b) :\n-- denote (ckt.ckt_lift f) = ↑↑(denote f) := rfl.\n\n@[simp]\nlemma denote_feedback (F: ckt (a × b) b) :\n denote (ckt.feedback F) = λ s, fix (λ α, denote F (sprod (s, z⁻¹ α))) := rfl.\n\n-- @[simp]\n-- lemma denote_intro :\n-- denote (@ckt.intro a _) = ↑↑δ0 := rfl.\n--\n-- @[simp]\n-- lemma stream_elim_intro :\n-- denote (@ckt.elim a _) = ↑↑∫ := rfl.\n\nlocal notation x ` >>> `:55 y:55 := ckt.seq x y.\n\n-- These definitions rely on being able to lift a few fixed functions; they\n-- still make sense, but with relatively complicated assumptions that these\n-- functions are available in [Func] with the appropriate meaning according to\n-- [Func_denote].\n/-\ndef lifting2 (f: a → b → c) : ckt (a × b) c :=\n ckt.lifting (λ xy, f xy.1 xy.2).\n\ndef derivative : ckt a a :=\n ckt.lifting (λ a, (a, a)) >>> ckt.par (ckt.lifting id) ckt.delay >>>\n ckt.lifting2 (λ x y, x - y).\n\ntheorem derivative_denote :\n @derivative a _ === ckt.derivative :=\nbegin\n unfold derivative,\n funext s, simp,\n unfold lifting2, simp,\n funext t, simp,\n refl,\nend\n\ndef integral : ckt a a :=\n ckt.feedback (ckt.lifting2 (λ x y, x + y)).\n\ntheorem integral_denote :\n @integral a _ === ckt.integral :=\nbegin\n unfold integral,\n funext s, simp,\n unfold lifting2, simp,\n unfold I feedback, simp,\n refl,\nend\n-/\n\ndef ckt_causal (f: ckt a b) : causal (denote f) :=\nbegin\n unfreezingI { induction f }; resetI; try { simp },\n { apply delay_causal, },\n { apply causal_incremental, assumption, },\n { apply causal_comp_causal; assumption, },\n { rw causal2,\n introv heq1 heq2,\n simp,\n split,\n { apply f_ih_f1, assumption, },\n { apply f_ih_f2, assumption, },\n },\n { apply (feedback_ckt_causal delay _ (λ (s: stream f_a) (α: stream f_b), ckt.denote f_F (sprod (s, α)))),\n rw causal2,\n introv heq1 heq2,\n apply f_ih,\n intros m hle, simp,\n split, { apply heq1, omega, }, { apply heq2, omega, },\n apply delay_strict,\n },\nend\n\ndef is_strict (f: ckt a b) : {b:bool | b → strict (denote f)} :=\nbegin\n unfreezingI { induction f }; simp,\n { use true, simp, apply delay_strict, },\n { -- derivative\n use false, },\n { -- integral\n use false, },\n { -- incremental\n cases f_ih with b hstrict, simp at *,\n use b, intros hb,\n unfold incremental,\n apply causal_strict_strict, swap, simp,\n apply strict_causal_strict, simp,\n tauto,\n },\n { -- lifting\n use false, },\n { -- seq (composition)\n cases f_ih_f1 with b1 hstrict1,\n cases f_ih_f2 with b2 hstrict2, simp at *,\n use (b1 || b2), simp,\n intros h, cases h; resetI,\n apply causal_strict_strict, tauto, apply ckt_causal,\n apply strict_causal_strict, apply ckt_causal, tauto,\n },\n { -- par\n cases f_ih_f1 with b1 hstrict1, cases f_ih_f2 with b2 hstrict2,\n use (b1 && b2), simp at *, intros h1 h2,\n intros s1 s2 n heq,\n unfold uncurry_op sprod, simp,\n split,\n { apply (hstrict1 h1), intros, simp, rw heq, omega, },\n { apply (hstrict2 h2), intros, simp, rw heq, omega, },\n },\n { use false, },\nend\n\n/-\ndef incrementalize (f: ckt a b) : ckt a b :=\n ckt.integral >>> f >>> ckt.derivative.\n\ntheorem incrementalize_ok (f: ckt a b) :\n denote (incrementalize f) = (denote f)^Δ :=\nbegin\n unfold incrementalize, simp,\n funext s, rw incremental_unfold,\nend\n-/\n\ntheorem seq_assoc (f1: ckt a b) (f2: ckt b c) (f3: ckt c d) :\n f1 >>> f2 >>> f3 === f1 >>> (f2 >>> f3) :=\nbegin\n unfold equiv, simp,\nend\n\nsection recursive_opt.\n\nvariables (opt: Π {a b: Type} [inst1: add_comm_group a] [inst2: add_comm_group b],\n @ckt a b inst1 inst2 → option (@ckt a b inst1 inst2)).\n\ninclude opt\ndef recursive_opt : ckt a b → ckt a b :=\nbegin\n intros f, unfreezingI { induction f },\n { apply (opt $ ckt.delay).get_or_else ckt.delay, },\n { apply (opt $ ckt.derivative).get_or_else ckt.derivative, },\n { apply (opt $ ckt.integral).get_or_else ckt.integral, },\n { apply (opt $ ckt.incremental f_f).get_or_else (ckt.incremental f_ih), },\n { resetI, apply (opt $ ckt.lifting f_f).get_or_else (ckt.lifting f_f), },\n { resetI, apply (opt $ ckt.seq f_f1 f_f2).get_or_else (ckt.seq f_ih_f1 f_ih_f2), },\n { resetI, apply (opt $ ckt.par f_f1 f_f2).get_or_else (ckt.par f_ih_f1 f_ih_f2), },\n { resetI, apply (opt $ ckt.feedback f_F).get_or_else (ckt.feedback f_ih), },\n -- { apply (opt $ ckt.intro).get_or_else ckt.intro, },\n -- { apply (opt $ ckt.elim).get_or_else ckt.elim, },\nend\n\n@[simp]\nlemma recursive_opt_seq (f1: ckt a b) (f2: ckt b c) :\n recursive_opt @opt (ckt.seq f1 f2) =\n (opt $ ckt.seq f1 f2).get_or_else (ckt.seq (recursive_opt @opt f1) (recursive_opt @opt f2)) := rfl.\n\n@[simp]\nlemma recursive_opt_par (f1: ckt a b) (f2: ckt c d) :\n recursive_opt @opt (ckt.par f1 f2) =\n (opt $ ckt.par f1 f2).get_or_else (ckt.par (recursive_opt @opt f1) (recursive_opt @opt f2)) := rfl.\n\n@[simp]\nlemma recursive_opt_feedback (f: ckt (a × b) b) :\n recursive_opt @opt (ckt.feedback f) =\n (opt $ ckt.feedback f).get_or_else (ckt.feedback (recursive_opt @opt f)) := rfl.\n\n@[simp]\nlemma recursive_opt_incremental (f: ckt a b) :\n recursive_opt @opt (ckt.incremental f) =\n (opt $ ckt.incremental f).get_or_else (ckt.incremental (recursive_opt @opt f)) := rfl.\n\nvariables (h_opt: ∀ {a b: Type} [inst1: add_comm_group a] [inst2: add_comm_group b]\n (f1 f2: @ckt.ckt a b inst1 inst2),\n @opt a b inst1 inst2 f1 = some f2 ->\n @ckt.equiv a b inst1 inst2 f1 f2).\n\ninclude h_opt\n\nlemma opt_or_else_ok (f1 f2: ckt a b) :\n f2 === f1 →\n (opt f1).get_or_else f2 === f1 :=\nbegin\n intros heq,\n destruct (opt f1); introv hopt; rw hopt; simp,\n assumption,\n symmetry, apply h_opt, assumption,\nend\n\ntheorem recursive_opt_ok :\n ∀ (f: ckt a b), recursive_opt @opt f === f :=\nbegin\n intros f, unfreezingI { induction f },\n { apply (opt_or_else_ok _ @Func_denote _ @h_opt), refl, },\n { apply (opt_or_else_ok _ @Func_denote _ @h_opt), refl, },\n { apply (opt_or_else_ok _ @Func_denote _ @h_opt), refl, },\n { simp, apply (opt_or_else_ok _ @Func_denote _ @h_opt),\n unfold equiv at f_ih |-,\n simp, dsimp, rw f_ih, },\n { apply (opt_or_else_ok _ @Func_denote _ @h_opt), refl, },\n { simp, apply (opt_or_else_ok _ @Func_denote _ @h_opt),\n unfold equiv at f_ih_f1 f_ih_f2 |-,\n simp, dsimp, rw [f_ih_f2, f_ih_f1],\n },\n { simp, apply (opt_or_else_ok _ @Func_denote _ @h_opt),\n unfold equiv at f_ih_f1 f_ih_f2 |-,\n simp, dsimp, rw [f_ih_f1, f_ih_f2],\n },\n { simp, apply (opt_or_else_ok _ @Func_denote _ @h_opt),\n unfold equiv at f_ih |-,\n simp, dsimp, rw f_ih,\n },\nend\n\nend recursive_opt.\n\nsection incrementalize.\n\nparameters (is_linear: ∀ {a b: Type} [i1: add_comm_group a] [i2: add_comm_group b]\n (f: @Func a b i1 i2), bool)\n (is_linear_ok: ∀ {a b: Type} [i1: add_comm_group a] [i2: add_comm_group b]\n (f: @Func a b i1 i2), @is_linear _ _ i1 i2 f →\n ∀ (x y: a),\n -- use tactic mode to run resetI; something is weird about\n -- elaboration here where instances aren't picked up\n (by { resetI,\n exact Func_denote f (x + y) = Func_denote f x + Func_denote f y })).\n\ninclude is_linear.\n\n-- returns an optimized version of c^Δ\ndef incrementalize (c: ckt a b) : ckt a b :=\nbegin\n unfreezingI { induction c },\n { exact ckt.delay, },\n { exact ckt.derivative, },\n { exact ckt.integral, },\n { apply ckt.incremental c_ih, },\n { apply (if is_linear c_f\n then ckt.lifting c_f\n else ckt.incremental (ckt.lifting c_f)), },\n { apply ckt.seq c_ih_f1 c_ih_f2, },\n { apply ckt.par c_ih_f1 c_ih_f2, },\n { apply ckt.feedback c_ih, },\nend\n\n@[simp]\nlemma incrementalize_incremental (c: ckt a b) :\n incrementalize (ckt.incremental c) = ckt.incremental (incrementalize c) := rfl.\n\n@[simp]\nlemma incrementalize_lifting (f: Func a b) :\n incrementalize (ckt.lifting f) =\n if is_linear f then\n ckt.lifting f else ckt.incremental (ckt.lifting f) := rfl.\n\n@[simp]\nlemma incrementalize_seq (f1: ckt a b) (f2: ckt b c) :\n incrementalize (f1 >>> f2) = incrementalize f1 >>> incrementalize f2 := rfl.\n\n@[simp]\nlemma incrementalize_par (f1: ckt a b) (f2: ckt c d) :\n incrementalize (ckt.par f1 f2) = ckt.par (incrementalize f1) (incrementalize f2) := rfl.\n\n@[simp]\nlemma incrementalize_feedback (f: ckt (a × b) b) :\n incrementalize (ckt.feedback f) = ckt.feedback (incrementalize f) := rfl.\n\ninclude is_linear_ok.\n\ntheorem incrementalize_ok (f: ckt a b) :\n denote (incrementalize f) = (denote f)^Δ :=\nbegin\n unfreezingI { induction f, }; try { unfold incrementalize; simp; done },\n { simp, rw f_ih, },\n { simp, split_ifs,\n { simp, rw lti_incremental,\n apply lifting_lti,\n intros, apply is_linear_ok, assumption,\n },\n { simp, },\n },\n { simp, rw [f_ih_f1, f_ih_f2],\n funext s,\n rw (incremental_comp\n (denote _ @Func_denote f_f2) (denote _ @Func_denote f_f1)), },\n { simp, funext s,\n rw [f_ih_f1, f_ih_f2],\n unfold uncurry_op,\n unfold incremental,\n rw [derivative_sprod, integral_fst_comm, integral_snd_comm],\n },\n { simp,\n rw cycle_incremental (λ s α, denote _ @Func_denote f_F (sprod (s, α))),\n { dsimp,\n rw f_ih,\n funext s,\n congr' 1, funext α,\n rw incremental_sprod, },\n { dsimp,\n rw causal2, introv heq1 heq2,\n apply ckt_causal,\n intros t hle, simp,\n rw [heq1, heq2], finish, assumption, assumption,\n },\n },\nend\n\nend incrementalize.\n\nend ckts.\nend ckt.\n", "meta": {"author": "tchajed", "repo": "database-stream-processing-theory", "sha": "c4c3b7ced9f964f3ea17db77958df78f2d761509", "save_path": "github-repos/lean/tchajed-database-stream-processing-theory", "path": "github-repos/lean/tchajed-database-stream-processing-theory/database-stream-processing-theory-c4c3b7ced9f964f3ea17db77958df78f2d761509/src/circuits.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5312093733737562, "lm_q2_score": 0.411110869232168, "lm_q1q2_score": 0.21838594723196017}} {"text": "import category_theory.abelian.projective\nimport category_theory.limits.preserves.finite\nimport for_mathlib.abelian_category\n\nnoncomputable theory\n\nuniverses v v' u\n\nopen category_theory category_theory.limits\n\nnamespace category_theory\n\n/-- `endomorphisms C` is the category whose objects are an object of `C` equipped with an\nendomorphism. Morphisms are morphisms between objects which intertwine the endomorphisms. -/\nstructure endomorphisms (C : Type u) [category.{v} C] :=\n(X : C)\n(e : End X)\n\nnamespace endomorphisms\n\nsection category\n\nvariables {C : Type u} [category.{v} C]\n\n@[ext] protected structure hom (X Y : endomorphisms C) :=\n(f : X.X ⟶ Y.X)\n(comm : X.e ≫ f = f ≫ Y.e)\n\nattribute [reassoc, simp] hom.comm\n\ninstance (C : Type u) [category.{v} C] : quiver (endomorphisms C) :=\n{ hom := λ X Y, hom X Y }\n\nlemma f_injective (X Y : endomorphisms C) : function.injective (hom.f : (X ⟶ Y) → (X.X ⟶ Y.X)) :=\nby { intros f g h, ext, exact h }\n\nprotected def id (X : endomorphisms C) : X ⟶ X :=\n{ f := 𝟙 _,\n comm := by rw [category.comp_id, category.id_comp] }\n\nprotected def comp {X Y Z : endomorphisms C} (f : X ⟶ Y) (g : Y ⟶ Z) : X ⟶ Z :=\n{ f := f.f ≫ g.f,\n comm := by simp only [hom.comm, hom.comm_assoc, category.assoc] }\n\ninstance (C : Type u) [category.{v} C] : category_struct (endomorphisms C) :=\n{ id := λ X, X.id,\n comp := λ X Y Z f g, endomorphisms.comp f g }\n\n@[simp] lemma id_f (X : endomorphisms C) : hom.f (𝟙 X) = 𝟙 X.X := rfl\n\n@[simps]\ndef end_of_e (X : endomorphisms C) : X ⟶ X := ⟨X.e, rfl⟩\n\nlemma end_of_e_comm {X Y : endomorphisms C} (g : X ⟶ Y) : X.end_of_e ≫ g =\n g ≫ Y.end_of_e :=\nby { ext, apply endomorphisms.hom.comm, }\n\n@[simp, reassoc] lemma comp_f {X Y Z : endomorphisms C} (f : X ⟶ Y) (g : Y ⟶ Z) :\n hom.f (f ≫ g) = f.f ≫ g.f := rfl\n\ninstance (C : Type u) [category.{v} C] : category (endomorphisms C) :=\n{ id_comp' := λ X Y f, by { ext1, simp only [comp_f, id_f, category.id_comp] },\n comp_id' := λ X Y f, by { ext1, simp only [comp_f, id_f, category.comp_id] },\n assoc' := λ X Y Z W f g h, by { ext1, simp only [comp_f, category.assoc] } }\n\nlemma congr_f {X Y : endomorphisms C} (f₁ f₂ : X ⟶ Y) (h : f₁ = f₂) : f₁.f = f₂.f := by rw h\n\n@[simp, reassoc] lemma pow_comm {X Y : endomorphisms C} (f : X ⟶ Y) (n : ℕ) :\n (X.e ^ n : End X.X) ≫ f.f = f.f ≫ (Y.e ^ n : End Y.X) :=\nbegin\n induction n with n ih,\n { simp only [pow_zero, End.one_def, category.id_comp, category.comp_id] },\n { simp only [nat.succ_eq_add_one, pow_succ, End.mul_def, category.assoc, hom.comm, reassoc_of ih] }\nend\n\n@[simps]\nprotected def forget (C : Type u) [category.{v} C] : endomorphisms C ⥤ C :=\n{ obj := λ X, X.X,\n map := λ X Y f, f.f,\n map_id' := λ X, rfl,\n map_comp' := λ X Y Z f g, rfl }\n\ninstance forget_faithful : faithful (endomorphisms.forget C) :=\n{ map_injective' := by { intros X Y f g h, ext, exact h } }\n\nlemma epi_of_epi_f {X Y : endomorphisms C} (f : X ⟶ Y) [epi f.f] : epi f :=\n{ left_cancellation := λ Z g h w, begin\n ext, rw [← cancel_epi f.f, ← comp_f, w, comp_f],\n end }\n\ndef mk_iso {X Y : endomorphisms C} (e : X.X ≅ Y.X) (h : X.e ≫ e.hom = e.hom ≫ Y.e) : X ≅ Y :=\n{ hom := ⟨e.hom, h⟩,\n inv := ⟨e.inv, by rw [e.comp_inv_eq, category.assoc, e.eq_inv_comp, h]⟩,\n hom_inv_id' := by { ext, simp only [comp_f, iso.hom_inv_id, id_f] },\n inv_hom_id' := by { ext, simp only [comp_f, iso.inv_hom_id, id_f] } }\n\nend category\n\nsection limits\n\nvariables {C : Type u} [category.{v} C]\nvariables {J : Type v'} [small_category J]\n\n@[simps]\ndef twist_cone {K : J ⥤ endomorphisms C}\n (S : cone (K ⋙ endomorphisms.forget C)) :\n cone (K ⋙ endomorphisms.forget C) :=\n{ X := S.X,\n π :=\n { app := λ j, S.π.app j ≫ (K.obj j).e,\n naturality' := begin\n intros i j f,\n dsimp,\n simp only [category.id_comp, category.assoc, hom.comm],\n erw S.w_assoc,\n end } }\n\nabbreviation cone_e {K : J ⥤ endomorphisms C}\n (S : cone (K ⋙ endomorphisms.forget C)) (hS : is_limit S) :\n S.X ⟶ S.X :=\n@is_limit.lift J _ C _ (K ⋙ endomorphisms.forget C) S hS (twist_cone S)\n\n@[simps]\nprotected def cone {K : J ⥤ endomorphisms C}\n (S : cone (K ⋙ endomorphisms.forget C)) (hS : is_limit S) :\n cone K :=\n{ X :=\n { X := S.X,\n e := cone_e S hS },\n π :=\n { app := λ j,\n { f := S.π.app _,\n comm := by { dsimp, simp } },\n naturality' := λ i j f, begin\n ext, dsimp, simp, erw S.w,\n end } }\n\n@[simps]\nprotected def is_limit_cone {K : J ⥤ endomorphisms C}\n (S : cone (K ⋙ endomorphisms.forget C)) (hS : is_limit S) :\n is_limit (endomorphisms.cone S hS) :=\n{ lift := λ S,\n { f := hS.lift ⟨S.X.X,\n { app := λ j, (S.π.app _).f,\n naturality' := begin\n intros i j f,\n dsimp,\n simp [← comp_f],\n end }⟩,\n comm := begin\n apply hS.hom_ext, dsimp, simp,\n end },\n fac' := begin\n intros s j, ext, dsimp, simp,\n end,\n uniq' := begin\n intros s m hm, ext, apply hS.hom_ext,\n intros j, specialize hm j, apply_fun (λ e, e.f) at hm,\n dsimp at *, simp [hm],\n end }\n\n.\n\nprotected def cone_iso {K : J ⥤ endomorphisms C} (S : cone K)\n (hS : is_limit ((endomorphisms.forget C).map_cone S)) :\n endomorphisms.cone _ hS ≅ S :=\ncones.ext\n({ hom :=\n { f := 𝟙 _,\n comm := by { apply hS.hom_ext, intros j, dsimp, simp, erw hS.fac, dsimp, simp, } },\n inv :=\n { f := 𝟙 _,\n comm := by { apply hS.hom_ext, intros j, dsimp, simp, erw hS.fac, dsimp, simp } },\n hom_inv_id' := by { ext, dsimp, simp },\n inv_hom_id' := by { ext, dsimp, simp } })\nbegin\n intros j, ext,\n dsimp, simp,\nend\n\nprotected def cone_iso' {K : J ⥤ endomorphisms C}\n (S : cone (K ⋙ endomorphisms.forget C)) (hS : is_limit S) :\n (endomorphisms.forget C).map_cone (endomorphisms.cone S hS) ≅ S :=\ncones.ext\n(iso.refl _)\nbegin\n intros j,\n dsimp,\n simp,\nend\n\ninstance has_limit (K : J ⥤ endomorphisms C) [has_limit (K ⋙ endomorphisms.forget C)] :\n has_limit K :=\n⟨⟨⟨_, endomorphisms.is_limit_cone _ (limit.is_limit _)⟩⟩⟩\n\ninstance has_limits_of_shape [has_limits_of_shape J C] :\n has_limits_of_shape J (endomorphisms C) := ⟨⟩\n\ninstance has_limits [has_limits C] : has_limits (endomorphisms C) := ⟨⟩\n\ninstance creates_limit (K : J ⥤ endomorphisms C) : creates_limit K (endomorphisms.forget _) :=\n{ reflects := λ S hS, is_limit.of_iso_limit (endomorphisms.is_limit_cone _ _)\n (endomorphisms.cone_iso _ hS),\n lifts := λ S hS,\n { lifted_cone := endomorphisms.cone _ hS,\n valid_lift := endomorphisms.cone_iso' _ _ } }\n\ninstance preserves_limit (K : J ⥤ endomorphisms C) [has_limit (K ⋙ endomorphisms.forget C)] :\n preserves_limit K (endomorphisms.forget C) :=\ncategory_theory.preserves_limit_of_creates_limit_and_has_limit K (endomorphisms.forget C)\n\ninstance preserves_limits_of_shape [has_limits_of_shape J C] :\n preserves_limits_of_shape J (endomorphisms.forget C) := ⟨⟩\n\ninstance preserves_limits [has_limits C] : preserves_limits (endomorphisms.forget C) := ⟨⟩\n\ninstance [has_finite_limits C] : preserves_finite_limits (endomorphisms.forget C) :=\nbegin\n apply preserves_finite_limits_of_preserves_finite_limits_of_size.{v},\n introsI J hJ1 hJ2, apply_instance,\nend\n\nend limits\n\nsection colimits\n\nvariables {C : Type u} [category.{v} C]\nvariables {J : Type v} [small_category J]\n\n@[simps]\ndef twist_cocone {K : J ⥤ endomorphisms C}\n (S : cocone (K ⋙ endomorphisms.forget C)) :\n cocone (K ⋙ endomorphisms.forget C) :=\n{ X := S.X,\n ι :=\n { app := λ j, (K.obj j).e ≫ S.ι.app j,\n naturality' := begin\n intros i j f,\n dsimp,\n simp only [category.comp_id, ← hom.comm_assoc],\n erw S.w,\n end } }\n\nabbreviation cocone_e {K : J ⥤ endomorphisms C}\n (S : cocone (K ⋙ endomorphisms.forget C)) (hS : is_colimit S) :\n S.X ⟶ S.X :=\n@is_colimit.desc J _ C _ (K ⋙ endomorphisms.forget C) S hS (twist_cocone S)\n\n@[simps]\nprotected def cocone {K : J ⥤ endomorphisms C}\n (S : cocone (K ⋙ endomorphisms.forget C)) (hS : is_colimit S) :\n cocone K :=\n{ X :=\n { X := S.X,\n e := cocone_e S hS },\n ι :=\n { app := λ j,\n { f := S.ι.app j,\n comm := by { dsimp, simp } },\n naturality' := λ i j f, begin\n ext, dsimp, simp, erw S.w,\n end } }\n\n@[simps]\nprotected def is_colimit_cocone {K : J ⥤ endomorphisms C}\n (S : cocone (K ⋙ endomorphisms.forget C)) (hS : is_colimit S) :\n is_colimit (endomorphisms.cocone S hS) :=\n{ desc := λ S,\n { f := hS.desc ⟨S.X.X,\n { app := λ j, (S.ι.app j).f,\n naturality' := begin\n intros i j f,\n dsimp,\n simp [← comp_f],\n end }⟩,\n comm := begin\n apply hS.hom_ext, dsimp, simp,\n end },\n fac' := begin\n intros s j, ext, dsimp, simp,\n end,\n uniq' := begin\n intros s m hm, ext, apply hS.hom_ext,\n intros j, specialize hm j, apply_fun (λ e, e.f) at hm,\n dsimp at *, simp [hm],\n end }\n\n.\n\nprotected def cocone_iso {K : J ⥤ endomorphisms C} (S : cocone K)\n (hS : is_colimit ((endomorphisms.forget C).map_cocone S)) :\n endomorphisms.cocone _ hS ≅ S :=\ncocones.ext\n({ hom :=\n { f := 𝟙 _,\n comm := by { apply hS.hom_ext, intros j, dsimp, simp, erw hS.fac, dsimp, simp, } },\n inv :=\n { f := 𝟙 _,\n comm := by { apply hS.hom_ext, intros j, dsimp, simp, erw hS.fac, dsimp, simp } },\n hom_inv_id' := by { ext, dsimp, simp },\n inv_hom_id' := by { ext, dsimp, simp } })\nbegin\n intros j, ext,\n dsimp, simp,\nend\n\nprotected def cocone_iso' {K : J ⥤ endomorphisms C}\n (S : cocone (K ⋙ endomorphisms.forget C)) (hS : is_colimit S) :\n (endomorphisms.forget C).map_cocone (endomorphisms.cocone S hS) ≅ S :=\ncocones.ext\n(iso.refl _)\nbegin\n intros j,\n dsimp,\n simp,\nend\n\ninstance has_colimit (K : J ⥤ endomorphisms C) [has_colimit (K ⋙ endomorphisms.forget C)] :\n has_colimit K :=\n⟨⟨⟨_, endomorphisms.is_colimit_cocone _ (colimit.is_colimit _)⟩⟩⟩\n\ninstance has_colimits_of_shape [has_colimits_of_shape J C] :\n has_colimits_of_shape J (endomorphisms C) := ⟨⟩\n\ninstance has_colimits [has_colimits C] : has_colimits (endomorphisms C) := ⟨⟩\n\ninstance creates_colimit (K : J ⥤ endomorphisms C) : creates_colimit K (endomorphisms.forget _) :=\n{ reflects := λ S hS, is_colimit.of_iso_colimit (endomorphisms.is_colimit_cocone _ _)\n (endomorphisms.cocone_iso _ hS),\n lifts := λ S hS,\n { lifted_cocone := endomorphisms.cocone _ hS,\n valid_lift := endomorphisms.cocone_iso' _ _ } }\n\ninstance preserves_colimit (K : J ⥤ endomorphisms C) [has_colimit (K ⋙ endomorphisms.forget C)] :\n preserves_colimit K (endomorphisms.forget C) :=\ncategory_theory.preserves_colimit_of_creates_colimit_and_has_colimit K (endomorphisms.forget C)\n\ninstance preserves_colimits_of_shape [has_colimits_of_shape J C] :\n preserves_colimits_of_shape J (endomorphisms.forget C) := ⟨⟩\n\ninstance preserves_colimits [has_colimits C] : preserves_colimits (endomorphisms.forget C) := ⟨⟩\n\ninstance [has_finite_colimits C] : preserves_finite_colimits (endomorphisms.forget C) :=\nbegin\n apply preserves_finite_colimits_of_preserves_finite_colimits_of_size.{v},\n introsI J hJ1 hJ2, apply_instance,\nend\n\nend colimits\n\nsection projectives\n\nvariables {C : Type u} [category.{v} C]\n\nsection free\n\nvariable [has_coproducts_of_shape (ulift.{v} ℕ) C]\n\n/-- `free X` is ⨁ₙX, the direct sum over the naturals, equipped with the endomorphism\nsending `(a : X)` in degree `n` to `a` in degree `n+1`. An alternative way to view `free X`\nis `X ⨂_{ℤ} ℤ[T]` with the endomorphism given by multiplication by `T`. -/\n@[simps]\ndef free (X : C) : endomorphisms C :=\n{ X := ∐ (λ i : ulift.{v} ℕ, X),\n e := sigma.desc $ λ i, sigma.ι (λ i : ulift.{v} ℕ, X) ⟨i.down + 1⟩ }\n\n@[reassoc] lemma free.ι_comp_e (X : C) (i : ulift.{v} ℕ) :\n sigma.ι (λ i : ulift.{v} ℕ, X) i ≫ (free X).e = sigma.ι (λ i : ulift.{v} ℕ, X) ⟨i.down + 1⟩ :=\nbegin\n dsimp, simp only [colimit.ι_desc, cofan.mk_ι_app],\nend\n\n@[ext] lemma free.ext {X : C} {A : endomorphisms C} (f g : free X ⟶ A)\n (w : sigma.ι (λ i : ulift.{v} ℕ, X) ⟨0⟩ ≫ f.f = sigma.ι (λ i : ulift.{v} ℕ, X) ⟨0⟩ ≫ g.f) :\n f = g :=\nbegin\n ext ⟨⟨i⟩⟩, dsimp,\n induction i with i ih, { exact w },\n apply_fun (λ α, α ≫ A.e) at ih,\n simp only [category.assoc, ← hom.comm, free.ι_comp_e_assoc] at ih,\n exact ih,\nend\n\n/-- The map `free T ⟶ A` in `endomorphisms C` induced by a map `T ⟶ A.X` in `C`. Here `A.X`\nis the forgetful functor forgetting the endomorphism. -/\n@[simps]\ndef free.desc {X : C} {A : endomorphisms C} (f : X ⟶ A.X) : free X ⟶ A :=\n{ f := sigma.desc $ λ i, f ≫ (A.e ^ i.down : End A.X),\n comm := begin\n ext1 ⟨i⟩, dsimp,\n simp only [colimit.ι_desc_assoc, cofan.mk_ι_app,\n colimit.ι_desc, category.assoc, pow_succ, End.mul_def],\n end }\n\nlemma free.desc_comp {X : C} {A B : endomorphisms C} (f : X ⟶ A.X) (g : A ⟶ B) :\n free.desc f ≫ g = free.desc (f ≫ g.f) :=\nbegin\n ext1, dsimp,\n simp only [colimit.ι_desc_assoc, cofan.mk_ι_app, colimit.ι_desc, category.assoc, pow_comm],\nend\n\ndef free.map {X Y : C} (f : X ⟶ Y) : free X ⟶ free Y :=\n{ f := sigma.desc $ λ i, f ≫ sigma.ι (λ i : ulift.{v} ℕ, Y) i,\n comm := begin\n ext1 ⟨i⟩,\n dsimp,\n simp only [colimit.ι_desc_assoc, cofan.mk_ι_app, colimit.ι_desc, category.assoc],\n end }\n\nvariable (C)\n\ndef functor.free : C ⥤ endomorphisms C :=\n{ obj := free,\n map := λ _ _, free.map,\n map_id' := λ X, begin ext, dsimp, simp only [free.map, category.id_comp, colimit.ι_desc,\n cofan.mk_ι_app, category.comp_id], end,\n map_comp' := λ X Y Z f g, begin ext, dsimp, simp only [free.map, category.assoc, colimit.ι_desc,\n cofan.mk_ι_app, colimit.ι_desc_assoc], end }\n\nend free\n\nsection cofree\n\nvariable {C}\nvariable [has_products_of_shape (ulift.{v} ℕ) C]\n\n/-- `cofree X` is ∏ₙX, the product over the naturals, equipped with the endomorphism\nsending `(a : X)` in degree `n` to `a` in degree `n+1`. -/\ndef cofree (X : C) : endomorphisms C :=\n{ X := ∏ (λ i : ulift.{v} ℕ, X),\n e := pi.lift $ λ i, pi.π _ ⟨i.down + 1⟩ }\n\ndef cofree.lift {X : C} {A : endomorphisms C} (f : A.X ⟶ X) :\n A ⟶ cofree X :=\n{ f := pi.lift $ λ i, (A.e ^ i.down : End A.X) ≫ f,\n comm := begin\n dsimp [cofree],\n ext ⟨⟨j⟩⟩, dsimp,\n simp only [category.assoc, limit.lift_π, fan.mk_π_app],\n rw [← category.assoc, pow_succ, ← End.mul_def], congr' 1,\n induction j with j hj,\n { simp },\n { simp only [End.mul_def, pow_succ] at *,\n simp [reassoc_of hj] }\n end }\n\nend cofree\n\nvariables [has_products_of_shape (ulift.{v} ℕ) C] [has_coproducts_of_shape (ulift.{v} ℕ) C]\n\nlemma f_epi {X Y : endomorphisms C} (f : X ⟶ Y) [epi f] : epi f.f :=\n{ left_cancellation := λ Z g h w, begin\n let gg : Y ⟶ cofree Z := cofree.lift g,\n let hh : Y ⟶ cofree Z := cofree.lift h,\n have : f ≫ gg = f ≫ hh,\n { ext, dsimp [gg, hh, cofree.lift], simp,\n simp_rw [← category.assoc, ← pow_comm, category.assoc, w] },\n rw cancel_epi at this,\n apply_fun (λ e, e.f ≫ pi.π (λ i : ulift.{v} ℕ, Z) (ulift.up 0)) at this,\n dsimp [gg, hh, cofree.lift] at this, simpa using this,\n end }\n\nlemma f_mono {X Y : endomorphisms C} (f : X ⟶ Y) [mono f] : mono f.f :=\n{ right_cancellation := λ Z g h w, begin\n let gg : free Z ⟶ X := free.desc g,\n let hh : free Z ⟶ X := free.desc h,\n have : gg ≫ f = hh ≫ f,\n { ext, dsimp [gg,hh, free.desc], simpa },\n rw cancel_mono at this,\n apply_fun (λ e, sigma.ι ((λ i : ulift.{v} ℕ, Z)) (ulift.up 0) ≫ e.f) at this,\n dsimp [gg, hh, free.desc] at this, simpa using this\n end }\n\ninstance free.projective (X : C) [projective X] : projective (free X) :=\n{ factors := λ E Y f e he, begin\n resetI,\n let φ : X ⟶ Y.X := sigma.ι (λ i : ulift.{v} ℕ, X) ⟨0⟩ ≫ f.f,\n haveI : epi e.f := f_epi _,\n use free.desc (projective.factor_thru φ e.f),\n rw [free.desc_comp, projective.factor_thru_comp],\n ext1, dsimp, simp only [colimit.ι_desc, cofan.mk_ι_app, pow_zero, End.one_def, category.comp_id],\n end }\n\ndef free.presentation [enough_projectives C] (A : endomorphisms C) :\n projective_presentation A :=\n{ P := free (projective.over A.X),\n projective := infer_instance,\n f := free.desc $ projective.π _,\n epi := begin\n suffices : epi (free.desc (projective.π A.X)).f,\n { resetI, apply epi_of_epi_f },\n dsimp,\n refine @epi_of_epi _ _ _ _ _ (sigma.ι _ _) _ (id _), { exact ⟨0⟩ },\n simp only [colimit.ι_desc, cofan.mk_ι_app, pow_zero, End.one_def, category.comp_id],\n apply_instance\n end }\n\ninstance [enough_projectives C] : enough_projectives (endomorphisms C) :=\n{ presentation := λ A, ⟨free.presentation A⟩ }\n\n-- generalize to colimits\ninstance projective_sigma {C ι : Type*} [category C] (P : ι → C) [has_coproduct P]\n [∀ i, projective (P i)] :\n projective (∐ P) :=\n{ factors := begin\n introsI E X f e he,\n let φ : ∐ P ⟶ E := sigma.desc (λ i, projective.factor_thru (sigma.ι _ _ ≫ f) e),\n refine ⟨φ, _⟩,\n ext ⟨i⟩,\n rw [limits.colimit.ι_desc_assoc, limits.cofan.mk_ι_app, projective.factor_thru_comp],\nend }\n\ninstance projective_X [enough_projectives C] (P : endomorphisms C) [projective P] :\n projective P.X :=\n⟨λ E X f e he, begin\n let F := free.presentation P,\n haveI : projective F.P.X := endomorphisms.projective_sigma _,\n haveI : epi F.f := F.epi,\n let s : P ⟶ F.P := projective.factor_thru (𝟙 _) F.f,\n have hsπ : s ≫ F.f = 𝟙 _ := projective.factor_thru_comp _ _,\n let X' : endomorphisms C := ⟨X, 𝟙 _⟩,\n let E' : endomorphisms C := ⟨E, 𝟙 _⟩,\n let e' : E' ⟶ X' := ⟨e, by { dsimp only, rw [category.id_comp, category.comp_id] }⟩,\n haveI he' : epi e' := epi_of_epi_f e',\n let φ : F.P.X ⟶ E := projective.factor_thru (F.f.f ≫ f) e,\n refine ⟨s.f ≫ φ, _⟩,\n rw [category.assoc, projective.factor_thru_comp, ← comp_f_assoc, hsπ, id_f, category.id_comp],\nend⟩\n\nend projectives\n\nsection preadditive\nopen category_theory.preadditive\n\nvariables {𝓐 : Type u} [category.{v} 𝓐] [preadditive 𝓐]\nvariables (X Y : endomorphisms 𝓐)\n\ninstance : has_zero (X ⟶ Y) := ⟨⟨0, by simp only [comp_zero, zero_comp, hom.comm]⟩⟩\ninstance : has_add (X ⟶ Y) := ⟨λ f g, ⟨f.f + g.f, by simp only [comp_add, add_comp, hom.comm]⟩⟩\ninstance : has_sub (X ⟶ Y) := ⟨λ f g, ⟨f.f - g.f, by simp only [comp_sub, sub_comp, hom.comm]⟩⟩\ninstance : has_neg (X ⟶ Y) := ⟨λ f, ⟨-f.f, by simp only [comp_neg, neg_comp, hom.comm]⟩⟩\ninstance has_nsmul : has_smul ℕ (X ⟶ Y) := ⟨λ n f, ⟨n • f.f, by simp only [comp_nsmul, nsmul_comp, hom.comm]⟩⟩\ninstance has_zsmul : has_smul ℤ (X ⟶ Y) := ⟨λ n f, ⟨n • f.f, by simp only [comp_zsmul, zsmul_comp, hom.comm]⟩⟩\n\ninstance : add_comm_group (X ⟶ Y) :=\n(f_injective X Y).add_comm_group _ rfl (λ _ _, rfl) (λ _, rfl) (λ _ _, rfl) (λ _ _, rfl) (λ _ _, rfl)\n\n@[simp] lemma zero_f : hom.f (0 : X ⟶ Y) = 0 := rfl\nvariables {X Y} (f g : X ⟶ Y)\n@[simp] lemma add_f : (f + g).f = f.f + g.f := rfl\n@[simp] lemma sub_f : (f - g).f = f.f - g.f := rfl\n@[simp] lemma neg_f : (-f).f = -(f.f) := rfl\n@[simp] lemma nsmul_f (n : ℕ) (f : X ⟶ Y) : (n • f).f = n • f.f := rfl\n@[simp] lemma zsmul_f (n : ℤ) (f : X ⟶ Y) : (n • f).f = n • f.f := rfl\n\nvariables (𝓐)\n\ninstance : preadditive (endomorphisms 𝓐) :=\n{ add_comp' := by { intros, ext, dsimp, rw add_comp },\n comp_add' := by { intros, ext, dsimp, rw comp_add } }\n\ninstance forget_additive : (endomorphisms.forget 𝓐).additive := {}\n\ninstance functor.free_additive [has_coproducts_of_shape (ulift.{v} ℕ) 𝓐] :\n (functor.free 𝓐).additive := ⟨λ X Y f g, by { delta functor.free free.map,\n ext, simp, }⟩\n\nlemma is_zero_X {X : endomorphisms 𝓐} (h : is_zero X) : is_zero X.X :=\nby { rw is_zero_iff_id_eq_zero at h ⊢, apply_fun (λ a, a.f) at h, exact h }\n\nend preadditive\n\nsection abelian\n\nvariables {𝓐 : Type u} [category.{v} 𝓐] [abelian 𝓐]\n {X Y : endomorphisms 𝓐} (f : X ⟶ Y)\n\n@[simps]\nprotected def kernel_obj : endomorphisms 𝓐 :=\n{ X := kernel f.f,\n e := kernel.lift _ (kernel.ι _ ≫ X.e) (by simp) }\n\n@[simps]\nprotected def kernel_ι : endomorphisms.kernel_obj f ⟶ X :=\n{ f := kernel.ι _,\n comm := by { dsimp, simp } }\n\nprotected def kernel_fork : kernel_fork f :=\nkernel_fork.of_ι (endomorphisms.kernel_ι f) $ by { ext, dsimp, simp }\n\n@[simp]\nprotected lemma kernel_fork_ι_f :\n (endomorphisms.kernel_fork f).ι.f = kernel.ι _ := rfl\n\n@[simps]\nprotected def kernel_lift (s : kernel_fork f) :\n s.X ⟶ endomorphisms.kernel_obj f :=\n{ f := kernel.lift _ s.ι.f $ by { rw [← comp_f, s.condition, zero_f], },\n comm := by { ext, dsimp, simp } }\n\n@[simps]\nprotected def is_limit_kernel_fork : is_limit (endomorphisms.kernel_fork f) :=\nis_limit_aux _\n(λ s, endomorphisms.kernel_lift f s)\n(λ s, by { ext, dsimp, simp })\n(λ s m hm, by { apply_fun (λ e, e.f) at hm, ext, dsimp at *, simp [hm] } )\n\ninstance has_kernels : has_kernels (endomorphisms 𝓐) :=\n⟨λ X Y f, ⟨⟨⟨endomorphisms.kernel_fork _, endomorphisms.is_limit_kernel_fork _⟩⟩⟩⟩\n\n@[simps]\nprotected def cokernel_obj : endomorphisms 𝓐 :=\n{ X := cokernel f.f,\n e := cokernel.desc _ (Y.e ≫ cokernel.π _) $\n by { simp only [← (reassoc_of f.comm), cokernel.condition, comp_zero] } }\n\n@[simps]\nprotected def cokernel_π : Y ⟶ endomorphisms.cokernel_obj f :=\n{ f := cokernel.π _,\n comm := by simp }\n\nprotected def cokernel_cofork : cokernel_cofork f :=\ncokernel_cofork.of_π (endomorphisms.cokernel_π f) $ by { ext, dsimp, simp }\n\n@[simp]\nprotected lemma cokernel_cofork_π_f :\n (endomorphisms.cokernel_cofork f).π.f = cokernel.π _ := rfl\n\n@[simps]\nprotected def cokernel_desc (s : cokernel_cofork f) :\n endomorphisms.cokernel_obj f ⟶ s.X :=\n{ f := cokernel.desc _ s.π.f $ by { rw [← comp_f, s.condition, zero_f] },\n comm := by { ext, dsimp, simp } }\n\n@[simps]\nprotected def is_colimit_cokernel_cofork : is_colimit (endomorphisms.cokernel_cofork f) :=\nis_colimit_aux _\n(λ s, endomorphisms.cokernel_desc f s)\n(λ s, by { ext, dsimp, simp })\n(λ s m hm, by { apply_fun (λ e, e.f) at hm, ext, dsimp at *, simp [hm] })\n\ninstance has_cokernels : has_cokernels (endomorphisms 𝓐) :=\n⟨λ X Y f, ⟨⟨⟨endomorphisms.cokernel_cofork _, endomorphisms.is_colimit_cokernel_cofork _⟩⟩⟩⟩\n\ndef kernel_fork_iso :\n endomorphisms.kernel_fork f ≅ kernel_fork.of_ι (endomorphisms.kernel_ι f)\n (endomorphisms.kernel_fork f).condition :=\ncones.ext\n(iso.refl _)\n(by { rintro (_|_); tidy })\n\ndef is_limit_fork_of_is_limit\n (hF : is_limit (limits.kernel_fork.of_ι f.f (cokernel.condition _))) :\n is_limit (limits.kernel_fork.of_ι f (endomorphisms.cokernel_cofork _).condition) :=\nis_limit_aux _\n(λ S,\n{ f := hF.lift (kernel_fork.of_ι S.ι.f begin\n change _ ≫ (endomorphisms.cokernel_cofork _).π.f = _,\n erw [← comp_f, S.condition, zero_f],\n end),\n comm := begin\n apply hF.hom_ext, rintro (_|_),\n { dsimp, simp only [category.assoc, hom.comm], erw hF.fac _ (walking_parallel_pair.zero),\n erw hF.fac_assoc _ (walking_parallel_pair.zero),\n dsimp, simp, },\n { dsimp, simp, }\n end })\nbegin\n intros S,\n ext, dsimp, erw hF.fac _ walking_parallel_pair.zero, refl,\nend\nbegin\n intros S m hm,\n ext, dsimp, apply hF.hom_ext, rintros (_|_),\n { apply_fun (λ e, e.f) at hm,\n dsimp at *,\n simp only [hm],\n erw hF.fac _ (walking_parallel_pair.zero), refl },\n { dsimp, simp },\nend\n\ndef is_colimit_cofork_of_is_colimit\n (hF : is_colimit (limits.cokernel_cofork.of_π f.f (kernel.condition _))) :\n is_colimit (limits.cokernel_cofork.of_π f (endomorphisms.kernel_fork _).condition) :=\nis_colimit_aux _\n(λ S,\n{ f := hF.desc (cokernel_cofork.of_π S.π.f begin\n change (endomorphisms.kernel_fork _).ι.f ≫ _ = _,\n erw [← comp_f, S.condition, zero_f]\n end),\n comm := begin\n apply hF.hom_ext, rintro (_|_),\n { dsimp, simp },\n { dsimp, erw hF.fac_assoc _ (walking_parallel_pair.one),\n rw [← hom.comm_assoc],\n erw hF.fac _ (walking_parallel_pair.one),\n dsimp, simp }\n end })\nbegin\n intros S,\n ext, dsimp, erw hF.fac _ walking_parallel_pair.one, refl,\nend\nbegin\n intros S m hm,\n ext, dsimp, apply hF.hom_ext, rintros (_|_),\n { dsimp, simp },\n { apply_fun (λ e, e.f) at hm,\n dsimp at *,\n simp only [hm],\n erw hF.fac _ walking_parallel_pair.one, refl }\nend\n\ninstance [has_coproducts_of_shape (ulift.{v} ℕ) 𝓐] [has_products_of_shape (ulift.{v} ℕ) 𝓐] :\n abelian (endomorphisms 𝓐) :=\n{ normal_mono_of_mono := begin\n introsI X Y f _,\n haveI := f_mono f,\n let hE : is_limit (kernel_fork.of_ι f.f _) :=\n category_theory.abelian.mono_is_kernel_of_cokernel _ (colimit.is_colimit _),\n fconstructor,\n exact endomorphisms.cokernel_obj f,\n exact endomorphisms.cokernel_π f,\n exact (endomorphisms.cokernel_cofork f).condition,\n apply is_limit_fork_of_is_limit _ hE,\n end,\n normal_epi_of_epi := begin\n introsI X Y f _,\n haveI := f_epi f,\n let hE : is_colimit (cokernel_cofork.of_π f.f _) :=\n category_theory.abelian.epi_is_cokernel_of_kernel _ (limit.is_limit _),\n fconstructor,\n exact endomorphisms.kernel_obj f,\n exact endomorphisms.kernel_ι f,\n exact (endomorphisms.kernel_fork f).condition,\n apply is_colimit_cofork_of_is_colimit _ hE,\n end,\n has_finite_products := begin\n constructor, intros J _,\n haveI : has_finite_products 𝓐 := abelian.has_finite_products, -- WHY IS THIS NEEDED!?\n constructor,\n end,\n .. (_ : preadditive (endomorphisms 𝓐)) }\n\nend abelian\n\nend endomorphisms\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/endomorphisms/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.4263215925474903, "lm_q1q2_score": 0.21815583785047435}} {"text": "/-\nCopyright (c) 2020 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison\n-/\nimport category_theory.monoidal.natural_transformation\nimport category_theory.monoidal.discrete\n\n/-!\n# Braided and symmetric monoidal categories\n\nThe basic definitions of braided monoidal categories, and symmetric monoidal categories,\nas well as braided functors.\n\n## Implementation note\n\nWe make `braided_monoidal_category` another typeclass, but then have `symmetric_monoidal_category`\nextend this. The rationale is that we are not carrying any additional data,\njust requiring a property.\n\n## Future work\n\n* Construct the Drinfeld center of a monoidal category as a braided monoidal category.\n* Say something about pseudo-natural transformations.\n\n-/\n\nopen category_theory\n\nuniverses v v₁ v₂ v₃ u u₁ u₂ u₃\n\nnamespace category_theory\n\n/--\nA braided monoidal category is a monoidal category equipped with a braiding isomorphism\n`β_ X Y : X ⊗ Y ≅ Y ⊗ X`\nwhich is natural in both arguments,\nand also satisfies the two hexagon identities.\n-/\nclass braided_category (C : Type u) [category.{v} C] [monoidal_category.{v} C] :=\n-- braiding natural iso:\n(braiding : Π X Y : C, X ⊗ Y ≅ Y ⊗ X)\n(braiding_naturality' : ∀ {X X' Y Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y'),\n (f ⊗ g) ≫ (braiding Y Y').hom = (braiding X X').hom ≫ (g ⊗ f) . obviously)\n-- hexagon identities:\n(hexagon_forward' : Π X Y Z : C,\n (α_ X Y Z).hom ≫ (braiding X (Y ⊗ Z)).hom ≫ (α_ Y Z X).hom\n = ((braiding X Y).hom ⊗ (𝟙 Z)) ≫ (α_ Y X Z).hom ≫ ((𝟙 Y) ⊗ (braiding X Z).hom)\n . obviously)\n(hexagon_reverse' : Π X Y Z : C,\n (α_ X Y Z).inv ≫ (braiding (X ⊗ Y) Z).hom ≫ (α_ Z X Y).inv\n = ((𝟙 X) ⊗ (braiding Y Z).hom) ≫ (α_ X Z Y).inv ≫ ((braiding X Z).hom ⊗ (𝟙 Y))\n . obviously)\n\nrestate_axiom braided_category.braiding_naturality'\nattribute [simp,reassoc] braided_category.braiding_naturality\nrestate_axiom braided_category.hexagon_forward'\nrestate_axiom braided_category.hexagon_reverse'\n\nopen category\nopen monoidal_category\nopen braided_category\n\nnotation `β_` := braiding\n\nsection\n/-!\nWe now establish how the braiding interacts with the unitors.\n\nI couldn't find a detailed proof in print, but this is discussed in:\n\n* Proposition 1 of André Joyal and Ross Street,\n \"Braided monoidal categories\", Macquarie Math Reports 860081 (1986).\n* Proposition 2.1 of André Joyal and Ross Street,\n \"Braided tensor categories\" , Adv. Math. 102 (1993), 20–78.\n* Exercise 8.1.6 of Etingof, Gelaki, Nikshych, Ostrik,\n \"Tensor categories\", vol 25, Mathematical Surveys and Monographs (2015), AMS.\n-/\n\nvariables (C : Type u₁) [category.{v₁} C] [monoidal_category C] [braided_category C]\n\nlemma braiding_left_unitor_aux₁ (X : C) :\n (α_ (𝟙_ C) (𝟙_ C) X).hom ≫ (𝟙 _ ⊗ (β_ X (𝟙_ C)).inv) ≫ (α_ _ X _).inv ≫ ((λ_ X).hom ⊗ 𝟙 _) =\n ((λ_ _).hom ⊗ 𝟙 X) ≫ (β_ X _).inv :=\nby { rw [←left_unitor_tensor, left_unitor_naturality], simp, }\n\nlemma braiding_left_unitor_aux₂ (X : C) :\n ((β_ X (𝟙_ C)).hom ⊗ (𝟙 (𝟙_ C))) ≫ ((λ_ X).hom ⊗ (𝟙 (𝟙_ C))) = (ρ_ X).hom ⊗ (𝟙 (𝟙_ C)) :=\ncalc ((β_ X (𝟙_ C)).hom ⊗ (𝟙 (𝟙_ C))) ≫ ((λ_ X).hom ⊗ (𝟙 (𝟙_ C)))\n = ((β_ X (𝟙_ C)).hom ⊗ (𝟙 (𝟙_ C))) ≫ (α_ _ _ _).hom ≫ (α_ _ _ _).inv ≫\n ((λ_ X).hom ⊗ (𝟙 (𝟙_ C)))\n : by simp\n... = ((β_ X (𝟙_ C)).hom ⊗ (𝟙 (𝟙_ C))) ≫ (α_ _ _ _).hom ≫ (𝟙 _ ⊗ (β_ X _).hom) ≫\n (𝟙 _ ⊗ (β_ X _).inv) ≫ (α_ _ _ _).inv ≫ ((λ_ X).hom ⊗ (𝟙 (𝟙_ C)))\n : by { slice_rhs 3 4 { rw [←id_tensor_comp, iso.hom_inv_id, tensor_id], }, rw [id_comp], }\n... = (α_ _ _ _).hom ≫ (β_ _ _).hom ≫\n (α_ _ _ _).hom ≫ (𝟙 _ ⊗ (β_ X _).inv) ≫ (α_ _ _ _).inv ≫ ((λ_ X).hom ⊗ (𝟙 (𝟙_ C)))\n : by { slice_lhs 1 3 { rw ←hexagon_forward }, simp only [assoc], }\n... = (α_ _ _ _).hom ≫ (β_ _ _).hom ≫ ((λ_ _).hom ⊗ 𝟙 X) ≫ (β_ X _).inv\n : by rw braiding_left_unitor_aux₁\n... = (α_ _ _ _).hom ≫ (𝟙 _ ⊗ (λ_ _).hom) ≫ (β_ _ _).hom ≫ (β_ X _).inv\n : by { slice_lhs 2 3 { rw [←braiding_naturality] }, simp only [assoc], }\n... = (α_ _ _ _).hom ≫ (𝟙 _ ⊗ (λ_ _).hom)\n : by rw [iso.hom_inv_id, comp_id]\n... = (ρ_ X).hom ⊗ (𝟙 (𝟙_ C))\n : by rw triangle\n\n@[simp]\nlemma braiding_left_unitor (X : C) : (β_ X (𝟙_ C)).hom ≫ (λ_ X).hom = (ρ_ X).hom :=\nby rw [←tensor_right_iff, comp_tensor_id, braiding_left_unitor_aux₂]\n\nlemma braiding_right_unitor_aux₁ (X : C) :\n (α_ X (𝟙_ C) (𝟙_ C)).inv ≫ ((β_ (𝟙_ C) X).inv ⊗ 𝟙 _) ≫ (α_ _ X _).hom ≫ (𝟙 _ ⊗ (ρ_ X).hom) =\n (𝟙 X ⊗ (ρ_ _).hom) ≫ (β_ _ X).inv :=\nby { rw [←right_unitor_tensor, right_unitor_naturality], simp, }\n\nlemma braiding_right_unitor_aux₂ (X : C) :\n ((𝟙 (𝟙_ C)) ⊗ (β_ (𝟙_ C) X).hom) ≫ ((𝟙 (𝟙_ C)) ⊗ (ρ_ X).hom) = (𝟙 (𝟙_ C)) ⊗ (λ_ X).hom :=\ncalc ((𝟙 (𝟙_ C)) ⊗ (β_ (𝟙_ C) X).hom) ≫ ((𝟙 (𝟙_ C)) ⊗ (ρ_ X).hom)\n = ((𝟙 (𝟙_ C)) ⊗ (β_ (𝟙_ C) X).hom) ≫ (α_ _ _ _).inv ≫ (α_ _ _ _).hom ≫\n ((𝟙 (𝟙_ C)) ⊗ (ρ_ X).hom)\n : by simp\n... = ((𝟙 (𝟙_ C)) ⊗ (β_ (𝟙_ C) X).hom) ≫ (α_ _ _ _).inv ≫ ((β_ _ X).hom ⊗ 𝟙 _) ≫\n ((β_ _ X).inv ⊗ 𝟙 _) ≫ (α_ _ _ _).hom ≫ ((𝟙 (𝟙_ C)) ⊗ (ρ_ X).hom)\n : by { slice_rhs 3 4 { rw [←comp_tensor_id, iso.hom_inv_id, tensor_id], }, rw [id_comp], }\n... = (α_ _ _ _).inv ≫ (β_ _ _).hom ≫\n (α_ _ _ _).inv ≫ ((β_ _ X).inv ⊗ 𝟙 _) ≫ (α_ _ _ _).hom ≫ ((𝟙 (𝟙_ C)) ⊗ (ρ_ X).hom)\n : by { slice_lhs 1 3 { rw ←hexagon_reverse }, simp only [assoc], }\n... = (α_ _ _ _).inv ≫ (β_ _ _).hom ≫ (𝟙 X ⊗ (ρ_ _).hom) ≫ (β_ _ X).inv\n : by rw braiding_right_unitor_aux₁\n... = (α_ _ _ _).inv ≫ ((ρ_ _).hom ⊗ 𝟙 _) ≫ (β_ _ X).hom ≫ (β_ _ _).inv\n : by { slice_lhs 2 3 { rw [←braiding_naturality] }, simp only [assoc], }\n... = (α_ _ _ _).inv ≫ ((ρ_ _).hom ⊗ 𝟙 _)\n : by rw [iso.hom_inv_id, comp_id]\n... = (𝟙 (𝟙_ C)) ⊗ (λ_ X).hom\n : by rw [triangle_assoc_comp_right]\n\n@[simp]\nlemma braiding_right_unitor (X : C) : (β_ (𝟙_ C) X).hom ≫ (ρ_ X).hom = (λ_ X).hom :=\nby rw [←tensor_left_iff, id_tensor_comp, braiding_right_unitor_aux₂]\n\nend\n\n/--\nA symmetric monoidal category is a braided monoidal category for which the braiding is symmetric.\n\nSee https://stacks.math.columbia.edu/tag/0FFW.\n-/\nclass symmetric_category (C : Type u) [category.{v} C] [monoidal_category.{v} C]\n extends braided_category.{v} C :=\n-- braiding symmetric:\n(symmetry' : ∀ X Y : C, (β_ X Y).hom ≫ (β_ Y X).hom = 𝟙 (X ⊗ Y) . obviously)\n\nrestate_axiom symmetric_category.symmetry'\nattribute [simp,reassoc] symmetric_category.symmetry\n\nvariables (C : Type u₁) [category.{v₁} C] [monoidal_category C] [braided_category C]\nvariables (D : Type u₂) [category.{v₂} D] [monoidal_category D] [braided_category D]\nvariables (E : Type u₃) [category.{v₃} E] [monoidal_category E] [braided_category E]\n\n/--\nA lax braided functor between braided monoidal categories is a lax monoidal functor\nwhich preserves the braiding.\n-/\nstructure lax_braided_functor extends lax_monoidal_functor C D :=\n(braided' : ∀ X Y : C, μ X Y ≫ map (β_ X Y).hom = (β_ (obj X) (obj Y)).hom ≫ μ Y X . obviously)\n\nrestate_axiom lax_braided_functor.braided'\n\nnamespace lax_braided_functor\n\n/-- The identity lax braided monoidal functor. -/\n@[simps] def id : lax_braided_functor C C :=\n{ .. monoidal_functor.id C }\n\ninstance : inhabited (lax_braided_functor C C) := ⟨id C⟩\n\nvariables {C D E}\n\n/-- The composition of lax braided monoidal functors. -/\n@[simps]\ndef comp (F : lax_braided_functor C D) (G : lax_braided_functor D E) : lax_braided_functor C E :=\n{ braided' := λ X Y,\n begin\n dsimp,\n slice_lhs 2 3 { rw [←category_theory.functor.map_comp, F.braided,\n category_theory.functor.map_comp], },\n slice_lhs 1 2 { rw [G.braided], },\n simp only [category.assoc],\n end,\n ..(lax_monoidal_functor.comp F.to_lax_monoidal_functor G.to_lax_monoidal_functor) }\n\ninstance category_lax_braided_functor : category (lax_braided_functor C D) :=\ninduced_category.category lax_braided_functor.to_lax_monoidal_functor\n\n@[simp] lemma comp_to_nat_trans {F G H : lax_braided_functor C D} {α : F ⟶ G} {β : G ⟶ H} :\n (α ≫ β).to_nat_trans =\n @category_struct.comp (C ⥤ D) _ _ _ _ (α.to_nat_trans) (β.to_nat_trans) := rfl\n\n/--\nInterpret a natural isomorphism of the underlyling lax monoidal functors as an\nisomorphism of the lax braided monoidal functors.\n-/\n@[simps]\ndef mk_iso {F G : lax_braided_functor C D}\n (i : F.to_lax_monoidal_functor ≅ G.to_lax_monoidal_functor) : F ≅ G :=\n{ ..i }\n\nend lax_braided_functor\n\n/--\nA braided functor between braided monoidal categories is a monoidal functor\nwhich preserves the braiding.\n-/\nstructure braided_functor extends monoidal_functor C D :=\n-- Note this is stated differently than for `lax_braided_functor`.\n-- We move the `μ X Y` to the right hand side,\n-- so that this makes a good `@[simp]` lemma.\n(braided' :\n ∀ X Y : C, map (β_ X Y).hom = inv (μ X Y) ≫ (β_ (obj X) (obj Y)).hom ≫ μ Y X . obviously)\n\nrestate_axiom braided_functor.braided'\nattribute [simp] braided_functor.braided\n\nnamespace braided_functor\n\n/-- Turn a braided functor into a lax braided functor. -/\n@[simps]\ndef to_lax_braided_functor (F : braided_functor C D) : lax_braided_functor C D :=\n{ braided' := λ X Y, by { rw F.braided, simp, }\n .. F }\n\n/-- The identity braided monoidal functor. -/\n@[simps] def id : braided_functor C C :=\n{ .. monoidal_functor.id C }\n\ninstance : inhabited (braided_functor C C) := ⟨id C⟩\n\nvariables {C D E}\n\n/-- The composition of braided monoidal functors. -/\n@[simps]\ndef comp (F : braided_functor C D) (G : braided_functor D E) : braided_functor C E :=\n{ ..(monoidal_functor.comp F.to_monoidal_functor G.to_monoidal_functor) }\n\ninstance category_braided_functor : category (braided_functor C D) :=\ninduced_category.category braided_functor.to_monoidal_functor\n\n@[simp] lemma comp_to_nat_trans {F G H : braided_functor C D} {α : F ⟶ G} {β : G ⟶ H} :\n (α ≫ β).to_nat_trans =\n @category_struct.comp (C ⥤ D) _ _ _ _ (α.to_nat_trans) (β.to_nat_trans) := rfl\n\n/--\nInterpret a natural isomorphism of the underlyling monoidal functors as an\nisomorphism of the braided monoidal functors.\n-/\n@[simps]\ndef mk_iso {F G : braided_functor C D}\n (i : F.to_monoidal_functor ≅ G.to_monoidal_functor) : F ≅ G :=\n{ ..i }\n\n\nend braided_functor\n\nsection comm_monoid\n\nvariables (M : Type u) [comm_monoid M]\n\ninstance comm_monoid_discrete : comm_monoid (discrete M) := by { dsimp [discrete], apply_instance }\n\ninstance : braided_category (discrete M) :=\n{ braiding := λ X Y, eq_to_iso (mul_comm X Y), }\n\nvariables {M} {N : Type u} [comm_monoid N]\n\n/--\nA multiplicative morphism between commutative monoids gives a braided functor between\nthe corresponding discrete braided monoidal categories.\n-/\n@[simps]\ndef discrete.braided_functor (F : M →* N) : braided_functor (discrete M) (discrete N) :=\n{ ..discrete.monoidal_functor F }\n\nend comm_monoid\n\nend category_theory\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/category_theory/monoidal/braided.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.40733340004593027, "lm_q1q2_score": 0.2179634622917122}} {"text": "/-\nFile: signature_recover_public_key_verify_zero_soundness.lean\n\nAutogenerated file.\n-/\nimport starkware.cairo.lean.semantics.soundness.hoare\nimport .signature_recover_public_key_code\nimport ..signature_recover_public_key_spec\nopen tactic\n\nopen starkware.cairo.common.cairo_secp.field\nopen starkware.cairo.common.cairo_secp.bigint\nopen starkware.cairo.common.cairo_secp.constants\n\nvariables {F : Type} [field F] [decidable_eq F] [prelude_hyps F]\nvariable mem : F → F\nvariable σ : register_state F\n\n/- starkware.cairo.common.cairo_secp.field.verify_zero autogenerated soundness theorem -/\n\ntheorem auto_sound_verify_zero\n -- arguments\n (range_check_ptr : F) (val : UnreducedBigInt3 F)\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_verify_zero σ.pc)\n -- input arguments on the stack\n (hin_range_check_ptr : range_check_ptr = mem (σ.fp - 6))\n (hin_val : val = cast_UnreducedBigInt3 mem (σ.fp - 5))\n -- conclusion\n : ensures_ret mem σ (λ κ τ,\n τ.ap = σ.ap + 11 ∧\n ∃ μ ≤ κ, rc_ensures mem (rc_bound F) μ (mem (σ.fp - 6)) (mem $ τ.ap - 1)\n (spec_verify_zero mem κ range_check_ptr val (mem (τ.ap - 1)))) :=\nbegin\n apply ensures_of_ensuresb, intro νbound,\n have h_mem_rec := h_mem,\n unpack_memory code_verify_zero at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15, hpc16, hpc17, hpc18, hpc19, hpc20, hpc21, hpc22⟩,\n -- let (ap reference)\n apply of_register_state,\n intros regstate_q regstateeq_q,\n generalize' hl_rev_q: mem regstate_q.ap = q,\n have hl_q := hl_rev_q.symm,\n rw [regstateeq_q] at hl_q, try { dsimp at hl_q },\n -- let (ap reference)\n apply of_register_state,\n intros regstate_q_biased regstateeq_q_biased,\n generalize' hl_rev_q_biased: mem (regstate_q_biased.ap + 1) = q_biased,\n have hl_q_biased := hl_rev_q_biased.symm,\n rw [regstateeq_q_biased] at hl_q_biased, try { dsimp at hl_q_biased },\n -- assert eq\n step_assert_eq hpc0 hpc1 with temp0,\n have a0: q_biased = q + 2 ^ 127, {\n apply assert_eq_reduction temp0,\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, hl_q, hl_q_biased] },\n try { dsimp [cast_UnreducedBigInt3] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a0 }, try { arith_simps at a0 },\n clear temp0,\n -- assert eq\n step_assert_eq hpc2 with temp0,\n have a2: mem (range_check_ptr) = q_biased, {\n apply assert_eq_reduction temp0.symm,\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, hl_q, hl_q_biased] },\n try { dsimp [cast_UnreducedBigInt3] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a2 }, try { arith_simps at a2 },\n clear temp0,\n -- tempvar\n step_assert_eq hpc3 hpc4 with tv_r10,\n step_assert_eq hpc5 with tv_r11,\n step_assert_eq hpc6 hpc7 with tv_r12,\n generalize' hl_rev_r1: ((val.d0 + q * SECP_REM) / (BASE : ℤ) : F) = r1,\n have hl_r1 := hl_rev_r1.symm, clear hl_rev_r1,\n have htv_r1: r1 = _, {\n have h_δ3_c0 : ∀ x : F, x / (BASE : ℤ) = x * (-46768052394588894761721767695234645457402928824320 : ℤ),\n { intro x, apply div_eq_mul_inv', apply PRIME.int_cast_mul_eq_one, rw [PRIME], try { simp_int_casts }, norm_num1 },\n apply eq.symm, apply eq.trans tv_r12,\n try { simp only [h_δ3_c0] at hl_r1 },\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, hl_q, hl_q_biased, hl_r1] },\n try { dsimp [cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [tv_r10, tv_r11] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n clear tv_r10 tv_r11 tv_r12,\n try { dsimp at hl_r1 }, try { arith_simps at hl_r1 },\n -- compound assert eq\n step_assert_eq hpc8 hpc9 with temp0,\n step_assert_eq hpc10 with temp1,\n have a8: mem (range_check_ptr + 1) = r1 + 2 ^ 127, {\n apply assert_eq_reduction temp1.symm,\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, hl_q, hl_q_biased, hl_r1, htv_r1] },\n try { dsimp [cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [temp0] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a8 }, try { arith_simps at a8 },\n clear temp0 temp1,\n -- tempvar\n step_assert_eq hpc11 with tv_r20,\n step_assert_eq hpc12 hpc13 with tv_r21,\n generalize' hl_rev_r2: ((val.d1 + r1) / (BASE : ℤ) : F) = r2,\n have hl_r2 := hl_rev_r2.symm, clear hl_rev_r2,\n have htv_r2: r2 = _, {\n have h_δ11_c0 : ∀ x : F, x / (BASE : ℤ) = x * (-46768052394588894761721767695234645457402928824320 : ℤ),\n { intro x, apply div_eq_mul_inv', apply PRIME.int_cast_mul_eq_one, rw [PRIME], try { simp_int_casts }, norm_num1 },\n apply eq.symm, apply eq.trans tv_r21,\n try { simp only [h_δ11_c0] at hl_r2 },\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, hl_q, hl_q_biased, hl_r1, htv_r1, hl_r2] },\n try { dsimp [cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [tv_r20] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } }, },\n clear tv_r20 tv_r21,\n try { dsimp at hl_r2 }, try { arith_simps at hl_r2 },\n -- compound assert eq\n step_assert_eq hpc14 hpc15 with temp0,\n step_assert_eq hpc16 with temp1,\n have a14: mem (range_check_ptr + 2) = r2 + 2 ^ 127, {\n apply assert_eq_reduction temp1.symm,\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, hl_q, hl_q_biased, hl_r1, htv_r1, hl_r2, htv_r2] },\n try { dsimp [cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [temp0] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a14 }, try { arith_simps at a14 },\n clear temp0 temp1,\n -- compound assert eq\n have h_δ17_c0 : ((BASE : ℤ) / (4 : ℤ) : F) = (19342813113834066795298816 : ℤ),\n { apply PRIME.div_eq_const,\n { apply PRIME.cast_ne_zero, norm_num1, rw [PRIME], try { simp_int_casts }, norm_num1 },\n rw [PRIME], try { simp_int_casts }, norm_num1 },\n step_assert_eq hpc17 hpc18 with temp0,\n step_assert_eq hpc19 with temp1,\n have a17: val.d2 = q * ((BASE : ℤ) / (4 : ℤ)) - r2, {\n try { simp only [h_δ17_c0] },\n apply assert_eq_reduction (eq_sub_of_eq_add temp1),\n try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, hl_q, hl_q_biased, hl_r1, htv_r1, hl_r2, htv_r2] },\n try { dsimp [cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [temp0] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\n },\n try { dsimp at a17 }, try { arith_simps at a17 },\n clear temp0 temp1,\n -- let\n generalize' hl_rev_range_check_ptr₁: (range_check_ptr + 3 : F) = range_check_ptr₁,\n have hl_range_check_ptr₁ := hl_rev_range_check_ptr₁.symm, clear hl_rev_range_check_ptr₁,\n try { dsimp at hl_range_check_ptr₁ }, try { arith_simps at hl_range_check_ptr₁ },\n -- return\n step_assert_eq hpc20 hpc21 with hret0,\n step_ret hpc22,\n -- finish\n step_done, use_only [rfl, rfl],\n split, refl,\n -- range check condition\n use_only (3+0+0), split,\n linarith [],\n split,\n { arith_simps, try { simp only [hret0] },\n try { arith_simps, refl <|> norm_cast }, try { refl } },\n intro rc_h_range_check_ptr, repeat { rw [add_assoc] at rc_h_range_check_ptr },\n have rc_h_range_check_ptr' := range_checked_add_right rc_h_range_check_ptr,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_verify_zero mem _ range_check_ptr val _,\n { apply sound_verify_zero, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_verify_zero],\n try { norm_num1 }, try { arith_simps },\n use_only [q],\n use_only [q_biased],\n use_only [a0],\n use_only [a2],\n cases rc_h_range_check_ptr' (0) (by norm_num1) with n hn, arith_simps at hn,\n use_only [n], { simp only [a2.symm, hin_range_check_ptr], arith_simps, exact hn },\n use_only [r1, hl_r1],\n use_only [a8],\n cases rc_h_range_check_ptr' (1) (by norm_num1) with n hn, arith_simps at hn,\n use_only [n], { simp only [a8.symm, hin_range_check_ptr], arith_simps, exact hn },\n use_only [r2, hl_r2],\n use_only [a14],\n cases rc_h_range_check_ptr' (2) (by norm_num1) with n hn, arith_simps at hn,\n use_only [n], { simp only [a14.symm, hin_range_check_ptr], arith_simps, exact hn },\n use_only [a17],\n have rc_h_range_check_ptr₁ := range_checked_offset' rc_h_range_check_ptr,\n have rc_h_range_check_ptr₁' := range_checked_add_right rc_h_range_check_ptr₁,try { norm_cast at rc_h_range_check_ptr₁' },\n use_only [range_check_ptr₁, hl_range_check_ptr₁],\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_val, hl_q, hl_q_biased, hl_r1, htv_r1, hl_r2, htv_r2, hl_range_check_ptr₁] }, },\n try { dsimp [cast_UnreducedBigInt3] },\n try { arith_simps }, try { simp only [hret0] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\nend\n\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/common/cairo_secp/verification/verification/signature_recover_public_key_verify_zero_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.4073334000459302, "lm_q1q2_score": 0.21796346229171218}} {"text": "import data.padics.padic_numbers\n\nimport for_mathlib.punit_instances\n\nimport perfectoid_space\n\n/-!\n# An example of a perfectoid space\n\nIn this file we show that the empty space is perfectoid.\nEvery nonempty example requires a non-trivial amount of mathematical effort.\n-/\n\n/-- The structure presheaf on the empty space. -/\ndef CLVRS.empty_presheaf : presheaf_of_topological_rings empty :=\n{ F := λ _, unit,\n res := λ _ _ _ _, (),\n Hid := λ U, by {funext x, cases x, refl},\n Hcomp := λ U V W _ _, rfl,\n Fring := λ x, punit.comm_ring,\n res_is_ring_hom := λ U V _,\n { map_one := rfl,\n map_mul := λ _ _, rfl,\n map_add := λ _ _, rfl },\n Ftop := λ U, by apply_instance,\n Ftop_ring := λ U, by apply_instance,\n res_continuous := λ U V _, continuous_of_discrete_topology }\n\n/-- The structure sheaf on the empty space. -/\ndef CLVRS.empty_sheaf : sheaf_of_topological_rings empty :=\n{ F := CLVRS.empty_presheaf,\n locality := by {rintro _ _ ⟨s⟩ ⟨t⟩ _, refl},\n gluing := by {intros _ _ c _, use (), intro i, cases c i, refl},\n homeo :=\n begin\n rintros ⟨U, HU⟩ ⟨γ, Uis, _⟩ c d,\n dsimp at *,\n change set unit at c,\n rcases subset_subsingleton c with rfl|rfl,\n { convert is_open_empty,\n exact set.image_empty _ },\n { convert is_open_univ,\n apply set.image_univ_of_surjective,\n rintro ⟨s, hs⟩,\n use (),\n apply subtype.eq,\n funext i,\n show () = s i,\n apply subsingleton.elim, },\n end }\n\n/--The empty CLVRS-/\ndef CLVRS.empty : CLVRS := {\n space := empty,\n sheaf' := CLVRS.empty_sheaf,\n complete := λ U,\n { complete := λ f hf,\n begin\n use (),\n rintro V HV,\n convert f.univ_sets,\n funext x,\n cases x,\n show _ = true, rw eq_true,\n exact mem_of_nhds HV,\n end },\n valuation := by rintro ⟨⟩,\n local_stalks := by rintro ⟨⟩,\n supp_maximal := by rintro ⟨⟩ }\n\nexample : PerfectoidSpace ⟨37, by norm_num⟩ := ⟨CLVRS.empty, by rintro ⟨⟩⟩\n", "meta": {"author": "leanprover-community", "repo": "lean-perfectoid-spaces", "sha": "95a6520ce578b30a80b4c36e36ab2d559a842690", "save_path": "github-repos/lean/leanprover-community-lean-perfectoid-spaces", "path": "github-repos/lean/leanprover-community-lean-perfectoid-spaces/lean-perfectoid-spaces-95a6520ce578b30a80b4c36e36ab2d559a842690/src/examples/empty.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.4225046348141882, "lm_q1q2_score": 0.2178518041954752}} {"text": "/-\nCopyright (c) 2017 Mario Carneiro. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mario Carneiro\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.rat.default\nimport Mathlib.data.semiquot\nimport Mathlib.PostPort\n\nuniverses l u_1 \n\nnamespace Mathlib\n\n/-!\n# Implementation of floating-point numbers (experimental).\n-/\n\ndef int.shift2 (a : ℕ) (b : ℕ) : ℤ → ℕ × ℕ :=\n sorry\n\nnamespace fp\n\n\nstructure rmode \n NE ::\nwhere\n\nclass float_cfg \nwhere\n prec : ℕ\n emax : ℕ\n prec_pos : 0 < prec\n prec_max : prec ≤ emax\n\ndef prec [C : float_cfg] : ℕ :=\n float_cfg.prec\n\ndef emax [C : float_cfg] : ℕ :=\n float_cfg.emax\n\ndef emin [C : float_cfg] : ℤ :=\n 1 - ↑float_cfg.emax\n\ndef valid_finite [C : float_cfg] (e : ℤ) (m : ℕ) :=\n emin ≤ e + ↑prec - 1 ∧ e + ↑prec - 1 ≤ ↑emax ∧ e = max (e + ↑(nat.size m) - ↑prec) emin\n\nprotected instance dec_valid_finite [C : float_cfg] (e : ℤ) (m : ℕ) : Decidable (valid_finite e m) :=\n eq.mpr sorry and.decidable\n\ninductive float [C : float_cfg] \nwhere\n| inf : Bool → float\n| nan : float\n| finite : Bool → (e : ℤ) → (m : ℕ) → valid_finite e m → float\n\ndef float.is_finite [C : float_cfg] : float → Bool :=\n sorry\n\ndef to_rat [C : float_cfg] (f : float) : ↥(float.is_finite f) → ℚ :=\n sorry\n\ntheorem float.zero.valid [C : float_cfg] : valid_finite emin 0 := sorry\n\ndef float.zero [C : float_cfg] (s : Bool) : float :=\n float.finite s emin 0 sorry\n\nprotected instance float.inhabited [C : float_cfg] : Inhabited float :=\n { default := float.zero tt }\n\nprotected def float.sign' [C : float_cfg] : float → semiquot Bool :=\n sorry\n\nprotected def float.sign [C : float_cfg] : float → Bool :=\n sorry\n\nprotected def float.is_zero [C : float_cfg] : float → Bool :=\n sorry\n\nprotected def float.neg [C : float_cfg] : float → float :=\n sorry\n\ndef div_nat_lt_two_pow [C : float_cfg] (n : ℕ) (d : ℕ) : ℤ → Bool :=\n sorry\n\n-- TODO(Mario): Prove these and drop 'meta'\n\nnamespace float\n\n\nprotected instance has_neg [C : float_cfg] : Neg float :=\n { neg := float.neg }\n\n", "meta": {"author": "AurelienSaue", "repo": "Mathlib4_auto", "sha": "590df64109b08190abe22358fabc3eae000943f2", "save_path": "github-repos/lean/AurelienSaue-Mathlib4_auto", "path": "github-repos/lean/AurelienSaue-Mathlib4_auto/Mathlib4_auto-590df64109b08190abe22358fabc3eae000943f2/Mathlib/data/fp/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6113819732941511, "lm_q2_score": 0.3557749071749625, "lm_q1q2_score": 0.21751436479717204}} {"text": "import algebraic_geometry.pullback_carrier\nimport for_mathlib.surjective_on_stalks\nimport algebraic_geometry.pushforward_stalk\nimport topology.local_at_target\nimport category_theory.morphism_property\n\nopen category_theory category_theory.limits topological_space opposite\n\nnamespace algebraic_geometry\n\nuniverse u\n\nnoncomputable theory\n\nvariables {X Y Z : Scheme.{u}} (f : X ⟶ Z) (g : Y ⟶ Z)\nvariable (hg : ∀ y : Y.carrier, function.surjective (PresheafedSpace.stalk_map g.1 y))\n\n@[simps apply_coe_fst apply_coe_snd]\ndef pullback_comparison : \n (pullback f g).carrier ⟶ Top.of (types.pullback_obj f.1.base g.1.base) :=\n(Top.pullback_cone_is_limit f.1.base g.1.base).lift\n (pullback_cone.mk (pullback.fst : pullback f g ⟶ _).1.base\n (pullback.snd : pullback f g ⟶ _).1.base\n (by simp only [← Scheme.comp_val_base, pullback.condition]))\n\nlemma pullback_comparison_comp_pullback_iso_prod_subtype_inv :\n pullback_comparison f g ≫ (Top.pullback_iso_prod_subtype f.1.base g.1.base).inv =\n category_theory.limits.pullback_comparison Scheme.forget_to_Top f g :=\nbegin\n apply pullback.hom_ext; simp only [pullback_comparison, category.assoc,\n Top.pullback_iso_prod_subtype_inv_fst, Top.pullback_iso_prod_subtype_inv_snd,\n pullback_comparison_comp_fst, pullback_comparison_comp_snd],\n exacts [(Top.pullback_cone_is_limit f.1.base g.1.base).fac _ walking_cospan.left,\n (Top.pullback_cone_is_limit f.1.base g.1.base).fac _ walking_cospan.right]\nend\n\n-- move me\n@[simps]\ndef pullback.triplet_mk {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) (x : X.carrier) (y : Y.carrier)\n (h : f.1.base x = g.1.base y) : pullback.triplet f g :=\n⟨x, y, _, h, rfl⟩\n\nlemma is_open_immersion.base_open [is_open_immersion f] : open_embedding f.1.base :=\nPresheafedSpace.is_open_immersion.base_open\n\nlemma Scheme.Spec_map_val_base {R S : CommRing} (f : R ⟶ S) : \n (Scheme.Spec.map f.op).1.base = prime_spectrum.comap f := rfl\n\nsection open_cover\n\n-- move me\n/-- The coordinate ring of a component in the `affine_cover`. -/\ndef Scheme.affine_cover_ring (X : Scheme) (i : X.affine_cover.J) : CommRing :=\nCommRing.of $ (X.local_affine i).some_spec.some\n\n-- move me\nlemma Scheme.affine_cover_obj (X : Scheme) (i : X.affine_cover.J) :\n X.affine_cover.obj i = Scheme.Spec.obj (op $ X.affine_cover_ring i) := rfl\n\n-- local attribute [irreducible] Scheme.affine_cover\n\ndef pullback_affine_cover : Scheme.open_cover.{u} (pullback f g) := \n (Scheme.pullback.open_cover_of_base.{u u u} Z.affine_cover f g).bind\n (λ i, Scheme.pullback.open_cover_of_left_right.{u u u u}\n (pullback f (Z.affine_cover.map i)).affine_cover\n (pullback g (Z.affine_cover.map i)).affine_cover pullback.snd pullback.snd)\n\nvariable (i : (pullback_affine_cover f g).J)\n\ndef pullback_affine_cover_ring_left : CommRing :=\nScheme.affine_cover_ring _ i.2.1\n\ndef pullback_affine_cover_ring_right : CommRing :=\nScheme.affine_cover_ring _ i.2.2\n\ndef pullback_affine_cover_ring_base : CommRing :=\nScheme.affine_cover_ring _ i.1\n\n@[derive is_open_immersion]\ndef pullback_affine_cover_map_left : \n Scheme.Spec.obj (op $ pullback_affine_cover_ring_left f g i) ⟶ X :=\n(pullback f (Z.affine_cover.map i.1)).affine_cover.map i.2.1 ≫ pullback.fst\n\n@[derive is_open_immersion]\ndef pullback_affine_cover_map_right : \n Scheme.Spec.obj (op $ pullback_affine_cover_ring_right f g i) ⟶ Y :=\n(pullback g (Z.affine_cover.map i.1)).affine_cover.map i.2.2 ≫ pullback.fst\n\n@[derive is_open_immersion]\ndef pullback_affine_cover_map_base : \n Scheme.Spec.obj (op $ pullback_affine_cover_ring_base f g i) ⟶ Z :=\nZ.affine_cover.map i.1\n\ndef pullback_affine_cover_map_fst : \n Scheme.Spec.obj (op $ pullback_affine_cover_ring_left f g i) ⟶\n Scheme.Spec.obj (op $ pullback_affine_cover_ring_base f g i) :=\n(pullback f (Z.affine_cover.map i.1)).affine_cover.map i.2.1 ≫ pullback.snd\n\ndef pullback_affine_cover_map_snd : \n Scheme.Spec.obj (op $ pullback_affine_cover_ring_right f g i) ⟶\n Scheme.Spec.obj (op $ pullback_affine_cover_ring_base f g i) :=\n(pullback g (Z.affine_cover.map i.1)).affine_cover.map i.2.2 ≫ pullback.snd\n\ninstance :\n algebra (pullback_affine_cover_ring_base f g i) (pullback_affine_cover_ring_left f g i) :=\n(Scheme.Spec.preimage (pullback_affine_cover_map_fst f g i)).unop.to_algebra\n\ninstance :\n algebra (pullback_affine_cover_ring_base f g i) (pullback_affine_cover_ring_right f g i) :=\n(Scheme.Spec.preimage (pullback_affine_cover_map_snd f g i)).unop.to_algebra\n\ndef pullback_affine_cover_ring : CommRing :=\nCommRing.of $\n tensor_product (pullback_affine_cover_ring_base f g i) (pullback_affine_cover_ring_left f g i)\n (pullback_affine_cover_ring_right f g i)\n\ninstance pullback_affine_cover_ring.left_algebra :\n algebra (pullback_affine_cover_ring_left f g i) (pullback_affine_cover_ring f g i) :=\nalgebra.tensor_product.left_algebra\n\ninstance pullback_affine_cover_ring.right_algebra :\n algebra (pullback_affine_cover_ring_right f g i) (pullback_affine_cover_ring f g i) :=\nring_hom.to_algebra algebra.tensor_product.include_right.to_ring_hom\n\ninstance pullback_affine_cover_ring.algebra :\n algebra (pullback_affine_cover_ring_base f g i) (pullback_affine_cover_ring f g i) :=\nalgebra.tensor_product.left_algebra\n\ninstance pullback_affine_cover_ring.left_tower :\n is_scalar_tower (pullback_affine_cover_ring_base f g i)\n (pullback_affine_cover_ring_left f g i) (pullback_affine_cover_ring f g i) :=\nalgebra.tensor_product.tensor_product.is_scalar_tower\n\ninstance pullback_affine_cover_ring.right_tower :\n is_scalar_tower (pullback_affine_cover_ring_base f g i)\n (pullback_affine_cover_ring_right f g i) (pullback_affine_cover_ring f g i) :=\nis_scalar_tower.of_algebra_map_eq' algebra.tensor_product.include_right.comp_algebra_map.symm\n\nlemma pullback_affine_cover_obj :\n (pullback_affine_cover f g).obj i =\n pullback (pullback_affine_cover_map_fst f g i) (pullback_affine_cover_map_snd f g i) := rfl\n\ndef pullback_affine_cover_obj_iso :\n (pullback_affine_cover f g).obj i ≅ Scheme.Spec.obj (op $ pullback_affine_cover_ring f g i) :=\nbegin\n refine (as_iso $ pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) _ _) ≪≫ pullback_symmetry _ _ ≪≫\n limit.iso_limit_cone ⟨_, ((is_pushout.of_is_colimit (CommRing.pushout_cocone_is_colimit\n (Scheme.Spec.preimage (pullback_affine_cover_map_fst f g i)).unop\n (Scheme.Spec.preimage (pullback_affine_cover_map_snd f g i)).unop))\n .op.map Scheme.Spec).is_limit⟩,\n { simpa only [category.id_comp, quiver.hom.op_unop, functor.image_preimage, category.comp_id] },\n { simpa only [category.id_comp, quiver.hom.op_unop, functor.image_preimage, category.comp_id] },\n apply_instance\nend\n\nlemma pullback_affine_cover_obj_iso_inv_fst :\n (pullback_affine_cover_obj_iso f g i).inv ≫ pullback.fst = Scheme.Spec.map (quiver.hom.op $\n (algebra_map (pullback_affine_cover_ring_left f g i) (pullback_affine_cover_ring f g i) : _)) :=\nbegin\n rw iso.inv_comp_eq,\n simp only [pullback_affine_cover_obj_iso, iso.trans_hom, as_iso_hom, category.assoc],\n erw [limit.iso_limit_cone_hom_π ⟨_, ((is_pushout.of_is_colimit (CommRing.pushout_cocone_is_colimit\n (Scheme.Spec.preimage (pullback_affine_cover_map_fst f g i)).unop\n (Scheme.Spec.preimage (pullback_affine_cover_map_snd f g i)).unop))\n .op.map Scheme.Spec).is_limit⟩ walking_cospan.right, pullback_symmetry_hom_comp_snd],\n rw [pullback.lift_fst, category.comp_id],\nend\n\nlemma pullback_affine_cover_obj_iso_inv_snd :\n (pullback_affine_cover_obj_iso f g i).inv ≫ pullback.snd = Scheme.Spec.map (quiver.hom.op $\n (algebra_map (pullback_affine_cover_ring_right f g i) (pullback_affine_cover_ring f g i) : _)) :=\nbegin\n rw iso.inv_comp_eq,\n simp only [pullback_affine_cover_obj_iso, iso.trans_hom, as_iso_hom, category.assoc],\n erw [limit.iso_limit_cone_hom_π ⟨_, ((is_pushout.of_is_colimit (CommRing.pushout_cocone_is_colimit\n (Scheme.Spec.preimage (pullback_affine_cover_map_fst f g i)).unop\n (Scheme.Spec.preimage (pullback_affine_cover_map_snd f g i)).unop))\n .op.map Scheme.Spec).is_limit⟩ walking_cospan.left, pullback_symmetry_hom_comp_fst],\n rw [pullback.lift_snd, category.comp_id],\nend\n\nlemma pullback_affine_cover_map_fst_base :\n pullback_affine_cover_map_fst f g i ≫ pullback_affine_cover_map_base f g i =\n pullback_affine_cover_map_left f g i ≫ f := \nby simp only [category.assoc, pullback_affine_cover_map_base, pullback.condition,\n pullback_affine_cover_map_left, pullback_affine_cover_map_fst]\n\nlemma pullback_affine_cover_map_snd_base :\n pullback_affine_cover_map_snd f g i ≫ pullback_affine_cover_map_base f g i =\n pullback_affine_cover_map_right f g i ≫ g := \nby simp only [category.assoc, pullback_affine_cover_map_base, pullback.condition,\n pullback_affine_cover_map_right, pullback_affine_cover_map_snd]\n\nlemma pullback_affine_cover_map :\n (pullback_affine_cover f g).map i = \n pullback.map (pullback_affine_cover_map_fst f g i) (pullback_affine_cover_map_snd f g i)\n f g (pullback_affine_cover_map_left f g i) (pullback_affine_cover_map_right f g i)\n (pullback_affine_cover_map_base f g i)\n (pullback_affine_cover_map_fst_base f g i)\n (pullback_affine_cover_map_snd_base f g i) :=\nbegin\n delta pullback_affine_cover,\n apply pullback.hom_ext; simp only [pullback_affine_cover_map_base, pullback_affine_cover_map_left,\n pullback_affine_cover_map_right, pullback.lift_fst, pullback.lift_snd,\n Scheme.open_cover.bind_map, category.assoc, Scheme.pullback.open_cover_of_left_right_map,\n Scheme.pullback.open_cover_of_base_map, pullback.lift_fst_assoc, pullback.lift_snd_assoc],\nend\n.\n\nlemma pullback_affine_cover_f_exists (T : pullback.triplet f g) : \n ∃ i : (pullback_affine_cover f g).J, T.1 ∈ (pullback_affine_cover_map_left f g i).opens_range ∧ \n T.2 ∈ (pullback_affine_cover_map_right f g i).opens_range :=\nbegin\n let i := Z.affine_cover.f T.z,\n obtain ⟨x, hx⟩ : T.x ∈ (pullback.fst : pullback f (Z.affine_cover.map i) ⟶ _).opens_range,\n { rw [← opens.mem_coe, Scheme.hom.opens_range_coe, pullback.range_fst, set.mem_preimage,\n T.hx], exact Z.affine_cover.covers T.z },\n obtain ⟨y, hy⟩ : T.y ∈ (pullback.fst : pullback g (Z.affine_cover.map i) ⟶ _).opens_range,\n { rw [← opens.mem_coe, Scheme.hom.opens_range_coe, pullback.range_fst, set.mem_preimage,\n T.hy], exact Z.affine_cover.covers T.z },\n refine ⟨⟨i, x, y⟩, _, _⟩,\n { obtain ⟨x', hx'⟩ := (pullback f (Z.affine_cover.map i)).affine_cover.covers x,\n conv_lhs { rw [← hx, ← hx'] }, exact ⟨x', rfl⟩ },\n { obtain ⟨y', hy'⟩ := (pullback g (Z.affine_cover.map i)).affine_cover.covers y,\n conv_lhs { rw [← hy, ← hy'] }, exact ⟨y', rfl⟩ },\nend\n\nnoncomputable!\ndef pullback_Top_open_cover : opens (types.pullback_obj f.1.base g.1.base) :=\n⟨_, ⟨_, (pullback_affine_cover_map_left f g i).opens_range.prop.prod\n (pullback_affine_cover_map_right f g i).opens_range.prop, rfl⟩⟩ \n\nlemma pullback_Top_open_cover_supr :\n supr (pullback_Top_open_cover f g) = ⊤ :=\nbegin\n rw eq_top_iff,\n rintro ⟨⟨x, y⟩, e⟩ -,\n obtain ⟨i, ⟨x', rfl : _ = x⟩, ⟨y', rfl : _ = y⟩⟩ :=\n pullback_affine_cover_f_exists _ _ (pullback.triplet_mk f g x y e),\n refine opens.mem_supr.mpr ⟨i, ⟨x', rfl⟩, ⟨y', rfl⟩⟩\nend\n\nnoncomputable!\ndef pullback_Top_open_cover_preimage_homeo :\n pullback_comparison f g ⁻¹' (pullback_Top_open_cover f g i).1 ≃ₜ\n prime_spectrum (pullback_affine_cover_ring f g i) :=\nbegin\n have : pullback_comparison f g ⁻¹' (pullback_Top_open_cover f g i).1 =\n ((pullback_affine_cover f g).map i).opens_range,\n { ext x, simp only [pullback_affine_cover_map, set.mem_preimage, Scheme.hom.opens_range_coe,\n pullback.range_map], refl },\n exact ((homeomorph.set_congr this).trans (homeomorph.of_embedding _ (is_open_immersion.base_open\n ((pullback_affine_cover f g).map i)).to_embedding : _).symm).trans \n (Top.homeo_of_iso $ Scheme.forget_to_Top.map_iso $ pullback_affine_cover_obj_iso f g i),\nend\n\nnoncomputable!\ndef pullback_Top_open_cover_homeo :\n (pullback_Top_open_cover f g i).1 ≃ₜ types.pullback_obj\n (prime_spectrum.comap $ algebra_map\n (pullback_affine_cover_ring_base f g i) (pullback_affine_cover_ring_left f g i))\n (prime_spectrum.comap $ algebra_map\n (pullback_affine_cover_ring_base f g i) (pullback_affine_cover_ring_right f g i)) :=\nbegin\n refine (homeomorph.of_embedding _ $ embedding_subtype_coe.comp embedding_subtype_coe).trans\n ((homeomorph.set_congr _).trans (homeomorph.of_embedding _ $ \n ((is_open_immersion.base_open (pullback_affine_cover_map_left f g i)).to_embedding.prod_mk\n (is_open_immersion.base_open (pullback_affine_cover_map_right f g i)).to_embedding).comp\n embedding_subtype_coe).symm),\n ext x, split, swap,\n { rintros ⟨⟨⟨x, y⟩, e⟩, rfl⟩,\n refine ⟨⟨⟨⟨_, _⟩, _⟩, ⟨x, rfl⟩, ⟨y, rfl⟩⟩, rfl⟩,\n change (pullback_affine_cover_map_left f g i ≫ f).1.base x = \n (pullback_affine_cover_map_right f g i ≫ g).1.base y,\n simp only [ring_hom.algebra_map_to_algebra, ← Scheme.Spec_map_val_base,\n quiver.hom.op_unop, functor.image_preimage] at e,\n rw [← pullback_affine_cover_map_fst_base, ← pullback_affine_cover_map_snd_base,\n Scheme.comp_val_base_apply, Scheme.comp_val_base_apply, e] },\n { rintros ⟨⟨⟨⟨x', y'⟩, e⟩, ⟨x, (rfl : _ = x')⟩, ⟨y, (rfl : _ = y')⟩⟩, rfl⟩,\n refine ⟨⟨⟨x, y⟩, _⟩, rfl⟩,\n change (pullback_affine_cover_map_left f g i ≫ f).1.base x = \n (pullback_affine_cover_map_right f g i ≫ g).1.base y at e,\n apply (is_open_immersion.base_open $ pullback_affine_cover_map_base f g i).inj,\n simp only [ring_hom.algebra_map_to_algebra, ← Scheme.Spec_map_val_base,\n quiver.hom.op_unop, functor.image_preimage, ← Scheme.comp_val_base_apply,\n pullback_affine_cover_map_fst_base, pullback_affine_cover_map_snd_base, e] }\nend\n\nlemma homeomorph.trans_symm_apply {α β γ : Type*} [topological_space α] [topological_space β]\n [topological_space γ] (h₁ : α ≃ₜ β) (h₂ : β ≃ₜ γ) (x) :\n (h₁.trans h₂).symm x = h₁.symm (h₂.symm x) := rfl\n\nlemma homeomorph.symm_symm_apply {α β : Type*} [topological_space α] [topological_space β]\n (h : α ≃ₜ β) (x) : h.symm.symm x = h x := rfl \n\nlemma homeomorph.symm_apply_eq {α β : Type*} [topological_space α] [topological_space β]\n (h : α ≃ₜ β) {x y} : h.symm x = y ↔ x = h y := h.to_equiv.symm_apply_eq\n\nlemma homeomorph.coe_set_congr_symm {α : Type*} [topological_space α] (s t : set α)\n (h : s = t) (x) : ((homeomorph.set_congr h).symm x : α) = x := rfl\n\nlemma homeomorph.coe_of_embedding {α β : Type*} [topological_space α] [topological_space β]\n (f : α → β) (hf : embedding f) {x} : (homeomorph.of_embedding f hf x : β) = f x := rfl\n\nlemma Scheme.forget_to_Top_map' {X Y : Scheme} (f : X ⟶ Y) :\n Scheme.forget_to_Top.map f = f.1.base := rfl\n\nlemma pullback_comparison_restrict_pullback_Top_open_cover :\n (pullback_Top_open_cover f g i).1.restrict_preimage (pullback_comparison f g) = \n (pullback_Top_open_cover_homeo f g i).symm ∘ prime_spectrum.tensor_product_to _ _ _ ∘\n pullback_Top_open_cover_preimage_homeo f g i :=\nbegin\n rw [eq_comm, ← (pullback_Top_open_cover_preimage_homeo f g i).coe_to_equiv, \n ← function.comp.assoc, ← equiv.eq_comp_symm],\n ext x : 1,\n dsimp only [function.comp_apply, subtype.coe_mk,\n pullback_Top_open_cover_preimage_homeo, homeomorph.trans_apply,\n pullback_Top_open_cover_homeo, homeomorph.trans_apply, homeomorph.coe_symm_to_equiv,\n homeomorph.trans_symm_apply, homeomorph.symm_symm_apply],\n rw homeomorph.symm_apply_eq,\n ext1,\n dsimp only [functor.map_iso_inv, Top.homeo_of_iso_symm_apply, Scheme.forget_to_Top_map',\n homeomorph.coe_set_congr_symm, homeomorph.coe_of_embedding, function.comp_apply,\n set.restrict_preimage_coe, prime_spectrum.tensor_product_to_apply_coe_fst,\n prime_spectrum.tensor_product_to_apply_coe_snd],\n ext1,\n { simp only [pullback_comparison_apply_coe_fst, ← Scheme.comp_val_base_apply],\n convert_to (Scheme.Spec.map (quiver.hom.op $ algebra_map\n (pullback_affine_cover_ring_left f g i) (pullback_affine_cover_ring f g i)) ≫\n pullback_affine_cover_map_left f g i).1.base x = _,\n erw ← pullback_affine_cover_obj_iso_inv_fst,\n simp only [category.assoc, pullback_affine_cover_map, pullback.lift_fst] },\n { simp only [pullback_comparison_apply_coe_snd, ← Scheme.comp_val_base_apply],\n convert_to (Scheme.Spec.map (quiver.hom.op $ algebra_map\n (pullback_affine_cover_ring_right f g i) (pullback_affine_cover_ring f g i)) ≫\n pullback_affine_cover_map_right f g i).1.base x = _,\n erw ← pullback_affine_cover_obj_iso_inv_snd,\n simp only [category.assoc, pullback_affine_cover_map, pullback.lift_snd] },\nend\n\n\nend open_cover\n\ninstance {R : Type u} [comm_ring R] (x : prime_spectrum R) :\n epi (structure_sheaf.to_stalk R x) :=\nbegin\n constructor,\n intros Z g h e,\n exact is_localization.ring_hom_ext x.as_ideal.prime_compl e,\nend\n\ndef _root_.CommRing.iso_of (R : CommRing) : R ≅ CommRing.of R :=\n⟨ring_hom.id R, ring_hom.id R, rfl, rfl⟩\n\ndef Spec.stalk_map_iso {R S : CommRing.{u}} (f : R ⟶ S) (x) :\n arrow.mk (PresheafedSpace.stalk_map (Scheme.Spec.map f.op).val x) ≅ \n arrow.mk (CommRing.of_hom $ localization.at_prime.map f x.as_ideal) :=\nbegin\n refine arrow.iso_mk' _ _ (structure_sheaf.stalk_iso R (prime_spectrum.comap f x))\n (structure_sheaf.stalk_iso S x) _,\n rw ← cancel_epi (structure_sheaf.to_stalk R (prime_spectrum.comap f x)),\n rw [structure_sheaf.stalk_iso_hom, ← category.assoc, \n structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom, structure_sheaf.to_stalk,\n category.assoc],\n erw [PresheafedSpace.stalk_map_germ'_assoc (Scheme.Spec.map f.op).1 x,\n ← Spec_Γ_naturality'_assoc f, ← category.assoc (to_Spec_Γ S),\n structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom],\n convert_to (localization.at_prime.map f x.as_ideal).comp\n (algebra_map R (localization (prime_spectrum.comap f x).as_ideal.prime_compl)) = \n (algebra_map S (localization (@prime_spectrum.as_ideal S _ x).prime_compl)).comp f,\n exact is_localization.map_comp _\nend\n.\n\nlemma surjective_on_stalks_iff {R S : CommRing.{u}} (f : R ⟶ S) :\n f.surjective_on_stalks ↔\n ∀ x, function.surjective (PresheafedSpace.stalk_map (Scheme.Spec.map f.op).1 x) :=\nbegin\n delta ring_hom.surjective_on_stalks,\n have := λ x, (morphism_property.surjective_respects_iso CommRing).arrow_mk_iso_iff\n (Spec.stalk_map_iso f x),\n dsimp only [morphism_property.surjective] at this, simp_rw this,\n exact ⟨λ H x, H x.as_ideal, λ H x hx, H ⟨x, hx⟩⟩\nend\n\nlemma Scheme.open_cover.exists_covers {X : Scheme} (𝒰 : X.open_cover) (x : X.carrier) :\n ∃ i (y : (𝒰.obj i).carrier), (𝒰.map i).1.base y = x :=\n⟨_, 𝒰.covers x⟩\n\nlemma Scheme.comp_val' {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) :\n (f ≫ g).1 = @category_struct.comp (PresheafedSpace.{u} CommRing.{u}) _ _ _ _ f.1 g.1 := rfl\n\ninclude hg\n\nlemma pullback_snd_surjective_on_stalks (x) : function.surjective\n (PresheafedSpace.stalk_map (pullback.fst : pullback f g ⟶ _).1 x) :=\nbegin\n obtain ⟨i, y, rfl⟩ := (pullback_affine_cover f g).exists_covers x,\n refine ((morphism_property.surjective_respects_iso CommRing).cancel_right_is_iso _\n (PresheafedSpace.stalk_map ((pullback_affine_cover f g).map i).1 _)).mp _,\n rw ← PresheafedSpace.stalk_map.comp,\n change morphism_property.surjective _ (PresheafedSpace.stalk_map\n ((pullback_affine_cover f g).map i ≫ pullback.fst).1 y),\n rw [pullback_affine_cover_map, pullback.lift_fst, Scheme.comp_val',\n PresheafedSpace.stalk_map.comp,\n (morphism_property.surjective_respects_iso CommRing).cancel_left_is_iso,\n ← (pullback_affine_cover_obj_iso f g i).hom_inv_id_assoc pullback.fst,\n pullback_affine_cover_obj_iso_inv_fst, Scheme.comp_val',\n PresheafedSpace.stalk_map.comp,\n (morphism_property.surjective_respects_iso CommRing).cancel_right_is_iso],\n erw (morphism_property.surjective_respects_iso CommRing).arrow_mk_iso_iff\n (Spec.stalk_map_iso _ _),\n convert tensor_product_surjective_on_stalks\n (pullback_affine_cover_ring_base f g i) (pullback_affine_cover_ring_left f g i)\n (pullback_affine_cover_ring_right f g i) _\n (((pullback_affine_cover_obj_iso f g i).hom.1.base) y).as_ideal,\n intros x hx,\n refine ((morphism_property.surjective_respects_iso CommRing).arrow_mk_iso_iff\n (Spec.stalk_map_iso _ ⟨x, hx⟩)).mp _,\n rw [ring_hom.algebra_map_to_algebra, quiver.hom.op_unop, functor.image_preimage],\n refine ((morphism_property.surjective_respects_iso CommRing).cancel_left_is_iso\n (PresheafedSpace.stalk_map (pullback_affine_cover_map_base f g i).1 _) _).mp _,\n rw ← PresheafedSpace.stalk_map.comp,\n change morphism_property.surjective _ (PresheafedSpace.stalk_map\n (pullback_affine_cover_map_snd f g i ≫ pullback_affine_cover_map_base f g i).1 _),\n rw [pullback_affine_cover_map_snd_base, Scheme.comp_val', PresheafedSpace.stalk_map.comp,\n (morphism_property.surjective_respects_iso CommRing).cancel_right_is_iso],\n exact hg _,\nend\n\nlemma embedding_pullback_comparison_of_surjective_on_stalks : \n embedding (pullback_comparison f g) :=\nbegin\n refine (embedding_iff_embedding_of_supr_eq_top (pullback_Top_open_cover_supr f g)\n (pullback_comparison f g).2).mpr (λ i, _), \n erw pullback_comparison_restrict_pullback_Top_open_cover,\n refine (homeomorph.embedding _).comp (embedding.comp _ $ homeomorph.embedding _),\n apply prime_spectrum.tensor_product_to_embedding,\n rw surjective_on_stalks_iff,\n intro x,\n rw [ring_hom.algebra_map_to_algebra, quiver.hom.op_unop, functor.image_preimage,\n pullback_affine_cover_map_snd],\n refine ((morphism_property.surjective_respects_iso CommRing).cancel_left_is_iso\n (PresheafedSpace.stalk_map (Z.affine_cover.map i.fst).1 _) _).mp _,\n rw ← PresheafedSpace.stalk_map.comp,\n convert_to function.surjective\n (PresheafedSpace.stalk_map ((_ ≫ pullback.snd) ≫ Z.affine_cover.map i.1).1 x),\n rw [category.assoc, ← pullback.condition, ← category.assoc, Scheme.comp_val],\n erw PresheafedSpace.stalk_map.comp,\n exact (as_iso $ PresheafedSpace.stalk_map ((pullback g (Z.affine_cover.map i.1)).affine_cover.map\n i.2.2 ≫ pullback.fst).1 x).CommRing_iso_to_ring_equiv.surjective.comp (hg _),\nend\n\nlemma embedding_category_theory_pullback_comparison_of_surjective_on_stalks : \n embedding (category_theory.limits.pullback_comparison Scheme.forget_to_Top f g) :=\nbegin\n rw ← pullback_comparison_comp_pullback_iso_prod_subtype_inv,\n exact (Top.homeo_of_iso (Top.pullback_iso_prod_subtype f.val.base g.val.base).symm)\n .embedding.comp (embedding_pullback_comparison_of_surjective_on_stalks f g hg),\nend\n\nend algebraic_geometry", "meta": {"author": "erdOne", "repo": "lean-AG-morphisms", "sha": "bfb65e7d5c17f333abd7b1806717f12cd29427fd", "save_path": "github-repos/lean/erdOne-lean-AG-morphisms", "path": "github-repos/lean/erdOne-lean-AG-morphisms/lean-AG-morphisms-bfb65e7d5c17f333abd7b1806717f12cd29427fd/src/algebraic_geometry/surjective_on_stalks.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5698526368038304, "lm_q2_score": 0.3812195662561499, "lm_q1q2_score": 0.2172389750322795}} {"text": "import analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n let A : set (euclidean_space ℝ (fin n)), from sorry,\n have H_A_open : open A, from sorry,\n let B_0 : set (euclidean_space ℝ (fin n)), from sorry,\n have H_B_0_empty : B_0 = ∅, from sorry,\n let B_n : set (euclidean_space ℝ (fin n)), from sorry,\n have H_B_n_closed : is_closed B_n, from sorry,\n have H_ℝn_compact : is_compact ℝn, from sorry,\n let C_m : set (euclidean_space ℝ (fin n)), from sorry,\n have H_C_m_open : open C_m, from sorry,\n let C : set (euclidean_space ℝ (fin n)), from sorry,\n have H_C_open : open C, from sorry,\n have H_C_cover : ℝn ⊆ ⋃₀ C, from sorry,\n have H_C_open_refinement : 𝒪 A ⊆ ⋃₀ C, from sorry,\n have H_C_loc_finite : ∀ (x : ℝn), is_locally_finite (λ (U : set (euclidean_space ℝ (fin n))), x ∈ interior U), from sorry,\n exact paracompact_of_locally_finite H_C_open_refinement H_C_cover H_C_loc_finite,\nend\n\n--OUTPUT 2\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n intros A hA,\n show ∃ C : ι → set (euclidean_space ℝ (fin n)), ∀ c ∈ C, is_open c ∧ ∀ c ∈ C, ∃ U ∈ A, c ⊆ U ∧ ∀ c' ∈ C, c' ≠ c → c' ∩ c = ∅, from by {\n have h1 : ∀ m : ℕ, ∃ Cₘ : ι → set (euclidean_space ℝ (fin n)), ∀ c ∈ Cₘ, is_open c ∧ \n ∀ c ∈ Cₘ, ∃ U ∈ A, c ⊆ U ∧ ∀ c' ∈ Cₘ, c' ≠ c → c' ∩ c = ∅, from sorry,\n let C := λ i : ι, classical.some (h1 (i : ℕ)),\n show ∃ C : ι → set (euclidean_space ℝ (fin n)), ∀ c ∈ C, is_open c ∧ ∀ c ∈ C, ∃ U ∈ A, c ⊆ U ∧ ∀ c' ∈ C, c' ≠ c → c' ∩ c = ∅, from sorry,\n }, \nend\n\n--OUTPUT 3\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume A : set (euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n))),\n assume H : is_open_cover A,\n let A1 := (λ (a : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n))),\n if h : a.U ∈ A then ⟨{ x | a.U.1 x ∧ euclidean_space ℝ (fin n) ≤ a.U.2 + (1 : ℝ) ∧ euclidean_space ℝ (fin n) ≥ a.U.2 - (1 : ℝ)}, h⟩ else ⟨{ x // false }, _⟩),\n have h1 : ∀ a : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), (euclidean_space ℝ (fin n)) ∈ A ∧ (euclidean_space ℝ (fin n)) ∈ a.U.1 → ∃ c : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), c ∈ A1 ∧ c.U.1 < a.U.1, from sorry,\n have h2 : ∀ a : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), (euclidean_space ℝ (fin n)) ∈ A ∧ (euclidean_space ℝ (fin n)) ∈ a.U.1 → ∃ c : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), c ∈ A1 ∧ a.U.1 < c.U.1, from sorry,\n have h3 : ∀ a : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), (euclidean_space ℝ (fin n)) ∈ A → ∃ c : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), c ∈ A1, from sorry,\n have h4 : ∀ a : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), (euclidean_space ℝ (fin n)) ∈ A → ∃ c : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), c ∈ A1, from sorry,\n have h5 : ∀ a : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), (euclidean_space ℝ (fin n)) ∈ A ∧ (euclidean_space ℝ (fin n)) ∈ a.U.1 → ∃ c : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), c ∈ A1 ∧ c.U.1 < a.U.1 → ∃ c : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), c ∈ A1 ∧ c.U.1 < a.U.1 ∧ c.U.1 ∈ a.U.1, from sorry,\n have h6 : ∀ a : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), (euclidean_space ℝ (fin n)) ∈ A ∧ (euclidean_space ℝ (fin n)) ∈ a.U.1 → ∃ c : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), c ∈ A1 ∧ c.U.1 < a.U.1 ∧ c.U.1 ∈ a.U.1 → ∃ c : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), c ∈ A1 ∧ c.U.1 < a.U.1 ∧ c.U.1 ∈ a.U.1 ∧ c.U.2 > a.U.2, from sorry,\n have h7 : ∀ a : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), (euclidean_space ℝ (fin n)) ∈ A ∧ (euclidean_space ℝ (fin n)) ∈ a.U.1 → ∃ c : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n)), c ∈ A1 ∧ c.U.1 < a.U.1 ∧ c.U.1 ∈ a.U.1 ∧ c.U.2 > a.U.2, from sorry,\n have h8 : ∀ a : euclidean_space.sheaf.cover_data (euclidean_space ℝ (fin n))\nend\n\n--OUTPUT 4\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n intro U,\n by_cases h : nonempty (euclidean_space ℝ (fin n)),\n have h2 : U ⊆ ⋃₀ U, from Union_of_Union_of_Elements_of_Union h,\n have h3 : ∀ x ∈ U, ∃ T : set (euclidean_space ℝ (fin n)), x ∈ T ∧ is_open T ∧ T ∈ U, from @elements_of_Union_of_set_is_Union_of_Elements_of_Union (euclidean_space ℝ (fin n)) _ _ U h2 (nonempty.choose h) h2,\n let V := {T : set (euclidean_space ℝ (fin n)) | (∃x∈U, x∈T) ∧ is_open T},\n have h4 : V ⊆ ⋃₀U, from Union_of_Union_of_Elements_of_Union h,\n have h5 : ∃ T : set (euclidean_space ℝ (fin n)), x ∈ T ∧ is_open T ∧ T ∈ V, from @elements_of_Union_of_set_is_Union_of_Elements_of_Union (euclidean_space ℝ (fin n)) _ _ V h4 (nonempty.choose h) h4,\n show ∃ V : set (euclidean_space ℝ (fin n)), is_open V ∧ x ∈ V ∧ ∀ (T : set (euclidean_space ℝ (fin n))), T ∈ V → T ∈ U, from @elements_of_Union_of_set_is_Union_of_Elements_of_Union (euclidean_space ℝ (fin n)) _ _ V h4 (nonempty.choose h) h4,\nend\n\n--OUTPUT 5\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (U : opens (euclidean_space ℝ (fin n))),\n assume hU : is_open_cover U,\n have h_U₀ : (∀ (V : opens (euclidean_space ℝ (fin n))), V ∈ U → (V ≠ ∅)), from sorry,\n\n have h_B₀ : (∀ V : opens (euclidean_space ℝ (fin n)), V ∈ U → (ℝn.ball 0 0 = ∅)), from sorry,\n\n have h_B₁ : (∀ m : ℕ, (ℝn.ball 0 m ≠ ∅)), from sorry,\n\n have h_B₂ : (∀ m : ℕ, (ℝn.ball 0 m ∈ U → ℝn.ball 0 m ⊆ ℝn.ball 0 (m + 1))), from sorry, -- ⊆ ⒂ ⊆₁\n\n have h_B₃ : (∀ m : ℕ, (ℝn.ball 0 m ∈ U → ℝn.ball 0 m ≠ ℝn.ball 0 (m + 1))), from sorry, -- ≠ ⒂ ≠₁\n\n have h_R₁ : (∀ (m : ℕ) (x : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 m → ∃ (N : ℕ), (m ≤ N) ∧ (x ∈ ℝn.ball 0 N))), from sorry,\n\n have h_R₂ : (∀ (m : ℕ) (x : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 m → ∃ (N : ℕ), (m ≤ N) ∧ (x ∈ ℝn.ball 0 N) ∧ (∀ (n : ℕ), (m ≤ n) → (n ≤ N) → (x ∈ ℝn.ball 0 n)))), from sorry,\n\n have h_R₃ : (∀ (m : ℕ) (x : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 m → (∀ (n : ℕ), (m ≤ n) → (n ≤ m + 1) → (x ∈ ℝn.ball 0 n)))), from sorry,\n\n have h_R₄ : (∀ (m : ℕ) (x : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 m → (∃ (y : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 (m+1) ∧ x ∈ ℝn.ball y 1) ∧ (∀ (n : ℕ), (m ≤ n) → (n ≤ m + 1) → (x ∈ ℝn.ball 0 n))))), from sorry,\n\n have h_R₅ : (∀ (m : ℕ) (x : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 m → (∃ (y : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 (m+1) ∧ x ∈ ℝn.ball y 1) ∧ (∀ (n : ℕ) (z : ℝ ^ (fin n)), (m ≤ n) → (n ≤ m + 1) → (z ∈ ℝn.ball 0 n) → (z ∈ ℝn.ball y 1))))), from sorry,\n\n have h_R₆ : (∀ m : ℕ, (∃ (y : ℝ ^ (fin n)), (m ∈ ℕ) ∧ (∃ (x : ℝ ^ (fin n)), x ∈ ℝn.ball 0 (m+1) ∧ x ∈ ℝn.ball y 1) ∧ (∀ (n : ℕ) (z : ℝ ^ (fin n)), (m ≤ n) → (n ≤ m + 1) → (z ∈ ℝn.ball 0 n) → (z ∈ ℝn.ball y 1)))), from sorry,\n\n have h_R₇ : (∀ (m : ℕ) (x y : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 m → x ∈ ℝn.ball y 1 → ∃ (n : ℕ), (m ≤ n) ∧ (n ≤ m + 1) ∧ (x ∈ ℝn.ball 0 n))), from sorry,\n\n have h_R₈ : (∀ (m : ℕ) (x y : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 m → x ∈ ℝn.ball y 1 → ∃ (n : ℕ), (m ≤ n) ∧ (n ≤ m + 1) ∧ (x ∈ ℝn.ball 0 n) ∧ (∀ (k : ℕ), (m ≤ k) → (k ≤ n) → (x ∈ ℝk.ball 0 k)))), from sorry,\n\n have h_R₉ : (∀ (m : ℕ) (x y : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 m → x ∈ ℝn.ball y 1 → (∀ (k : ℕ), (m ≤ k) → (k ≤ m + 1) → (x ∈ ℝk.ball 0 k)))), from sorry,\n\n have h_R₁₀ : (∀ m : ℕ, ∃ (y : ℝ ^ (fin n)), (∃ (x : ℝ ^ (fin n)), x ∈ ℝn.ball 0 (m+1) ∧ x ∈ ℝn.ball y 1) ∧ (∀ (k : ℕ) (z : ℝ ^ (fin n)), (m ≤ k) → (k ≤ m + 1) → (z ∈ ℝk.ball 0 k) → (z ∈ ℝn.ball y 1))), from sorry,\n\n have h_R₁₁ : (∀ (m : ℕ) (y z : ℝ ^ (fin n)), (∃ (x : ℝ ^ (fin n)), x ∈ ℝn.ball 0 (m+1) ∧ x ∈ ℝn.ball y 1) → (∀ (k : ℕ) (w : ℝ ^ (fin n)), (m ≤ k) → (k ≤ m + 1) → (w ∈ ℝk.ball 0 k) → (w ∈ ℝn.ball y 1)) → (∃ (n : ℕ), (m ≤ n) ∧ (n ≤ m + 1) ∧ (z ∈ ℝn.ball 0 n)))), from sorry,\n\n have h_R₁₂ : (∀ (m : ℕ) (y z : ℝ ^ (fin n)), (∃ (x : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 (m+1) ∧ x ∈ ℝn.ball y 1)) → (∀ (k : ℕ) (w : ℝ ^ (fin n)), (m ≤ k) → (k ≤ m + 1) → (w ∈ ℝk.ball 0 k) → (w ∈ ℝn.ball y 1)) → (∃ (n : ℕ), (m ≤ n) ∧ (n ≤ m + 1) ∧ (z ∈ ℝn.ball 0 n) ∧ (∀ (p : ℕ), (m ≤ p) → (p ≤ n) → (z ∈ ℝp.ball 0 p)))), from sorry,\n\n have h_R₁₃ : (∀ (m : ℕ) (y z : ℝ ^ (fin n)), (∃ (x : ℝ ^ (fin n)), (x ∈ ℝn.ball 0 (m+1) ∧ x ∈ ℝn.ball y 1)) → (∀ (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) := sorry\n\n/--`theorem`\nEmpty set is Normal\n$\\emptyset$ is normal.\n`proof`\n$\\emptyset$ is discrete, so let $V$ be any set. Then $V \\cap \\emptyset = \\emptyset$, which is a neighborhood of $\\emptyset$, and $V - \\emptyset = V$, which is open in $\\emptyset$. So $\\emptyset$ is normal.\n\nQED\n-/\ntheorem empty_set_normal : normal_space (⊥) := sorry\n\n/--`theorem`\nConsequent is Contradictory\nLet $\\Gamma$ be a set of formulas, and let $\\phi, \\psi$ be formulas. Then $\\Gamma, \\frakgmod \\phi \\to \\phi \\models \\frakgmod \\psi \\to \\psi$ is true if and only if $\\Gamma, \\frakgmod \\phi \\models \\psi$.\n`proof`\n($\\implies$)\n\nSuppose $\\Gamma, \\frakgmod \\phi \\to \\phi \\models \\frakgmod \\psi \\to \\psi$. Then for any valuation $v$, if $\\Gamma \\cup \\{ \\frakgmod \\phi \\to \\phi \\} \\models \\frakgmod \\psi \\to \\psi$ under $v$, then $\\Gamma \\cup \\{ \\frakgmod \\phi \\} \\models \\psi$ under $v$.\n\n($\\impliedby$)\n\nSuppose $\\Gamma, \\frakgmod \\phi \\models \\psi$. Then for any valuation $v$, if $\\Gamma \\cup \\{ \\frakgmod \\phi \\} \\models \\psi$ under $v$, then $\\Gamma \\cup \\{ \\frakgmod \\phi \\to \\phi \\} \\models \\frakgmod \\psi \\to \\psi$ under $v$.\n\nQED\n-/\ntheorem consequent_is_contradictory {Γ : list form} {φ ψ : form} : Γ ⊢ (φ ⊃ φ) → (ψ ⊃ ψ) ↔ Γ ⊢ φ → ψ := sorry\n\n/--`theorem`\nSubset of Compact is Compact\nLet $A$ be compact, and let $B \\subseteq A$. Then $B$ is compact.\n`proof`\nLet $B \\subseteq A$ be compact. Then $A$ has a finite subcover $A_1, \\ldots, A_k$. So for any collection $\\{ V_i \\}_{i \\in I}$ of open sets in $B$ where $B \\subseteq \\bigcup_{i \\in I} V_i$, we can still find a finite subcover of $B$ whose union is $B$, namely, $V_1 \\cap B, \\ldots, V_k \\cap B$ cover $B$ and are open in $B$. So $B$ is compact.\n\nQED\n-/\ntheorem compact_subset_is_compact {A B : set (euclidean_space ℝ 1)} {hA : is_compact A} : B ⊆ A → is_compact B := sorry\n\n/--`theorem`\n(Upper) limit of a bounded sequence is bounded\nLet ${\\left({x_n}\\right)}_{n \\in \\mathbb{N}}$ be a sequence in $\\R$, and let $L$ be an upper bound for the sequence, i.e. $\\forall n \\in \\mathbb{N}: x_n \\leq L$. Then the limit $L'$ of the sequence is also an upper bound, i.e. $\\forall n \\in \\mathbb{N}: x_n \\leq L'$.\n`proof`\nBy the definition of a limit $L'$ of a sequence, for any $\\epsilon > 0$, there exists an $N_\\epsilon \\in \\mathbb{N}$ such that for all $n \\in \\mathbb{N}$ with $n > N_\\epsilon$, $\\abs{x_n - L'} < \\epsilon$. Since $L'$ is the limit, we know this holds for $\\epsilon = \\frac{L' - L}{2} > 0$ and some $N_\\frac{L' - L}{2} \\in \\mathbb{N}$. So for all $n \\in \\mathbb{N}$ with $n > N_\\frac{L' - L}{2}$, $\\abs{x_n - L'} < \\frac{L' - L}{2}$, so $\\frac{L' - L}{2} + L' > x_n > L' - \\frac{L' - L}{2} > L$, and so $L'$ is an upper bound.\n\nQED\n-/\ntheorem limit_is_bounded_upper {X : Type*} [linear_ordered_field X] [linear_order X] [topological_space X] {x : ℕ → X} {M : X} (hM : ∀ n, x n ≤ M) : is_limit x M → ∀ n, x n ≤ M := sorry\n\n/--`theorem`\nIf an ideal I is contained in the Jacobson radical J, then I is contained in the nilradical of the ring.\nLet $R$ be a ring, and let $J$ be the Jacobson radical of $R$. Further, let $I$ be an ideal of $R$ contained in $J$. Then $I$ is contained in the nilradical of $R$.\n`proof`\nLet $x \\in I \\subseteq J$. Then $1 - x$ is invertible by definition of the Jacobson radical, so $x$ is nilpotent. Hence, $I$ is contained in the nilradical of $R$.\n\nQED\n-/\nlemma mem_nilradical_of_mem_jradical_of_ring (R) (J : ideal R) (I : ideal R) : I ⊆ J → I ⊆ ⊥ := sorry\n\n/--`theorem`\nJacobson radical is the intersection of all prime ideals.\nLet $R$ be a ring. Then the Jacobson radical of $R$ equals the intersection of all prime ideals of $R$.\n`proof`\nBy the definition of a prime ideal of $R$, it is an ideal $P$ such that for any $a, b \\in R$, if $a b \\in P$, then either $a$ or $b$ is in $P$. Clearly, the intersection of all prime ideals is contained in the Jacobson radical, since the Jacobson radical is the intersection of all maximal ideals of $R$ which are prime by definition. Conversely, suppose $x \\in J$ where $J$ is the Jacobson radical of $R$. Then $1 - x$ is invertible by definition of the Jacobson radical, so suppose $1 - x = ab = ba$ for some $a, b \\in R$. Then if $x = 1$, which is in any prime ideal $P$, then either $a = x = 1$ in $R$, which is not in any prime ideal $P$, or $b = x = 1$ in $R$, which is not in any prime ideal $P$. Contradiction. Hence, $x$ is not in any prime ideal of $R$. It follows that the intersection of all prime ideals is the Jacobson radical.\n\nQED\n-/\nlemma jradical_eq_intersection_of_all_prime_ideals_of_ring (R) : jradical R = ⋂₀ {P // prime P} := sorry\n\n/--`theorem`\nJacobson radical is not null.\nLet $R$ be a ring. Then the Jacobson radical of $R$ is not null.\n`proof`\nSuppose $J$ is the Jacobson radical of $R$, and suppose $J = \\emptyset$. Then the intersection of all maximal ideals of $R$ is $\\emptyset$. But the maximal ideals of $R$ include the prime ideals of $R$ by definition, so the intersection of all prime ideals of $R$ is $\\emptyset$. Hence, the Jacobson radical of $R$ is not null.\n\nQED\n-/\nlemma jradical_of_ring_non_empty (R) : jradical R ≠ ⊥ := sorry\n\n/--`theorem`\nIf $a$ is a nonzero and nonunit in a ring $R$, then $a$ is not a unit in the quotient ring $R/\\gamma$ for any proper ideal $\\gam\nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) := \nbegin\n assume (A : set (euclidean_space ℝ (fin n))) (hA : A ≃ᵉ ℝn),\n have h1 : ∀ m : ℕ, ∃ C : set (euclidean_space ℝ (fin n)), \n (∀ x ∈ ℝn, exists i : fin n, x i ≤ m ∧ ∃ i : fin n, m ≤ x i) →\n (∀ j ≤ m, 𝓝 x j ⊆ (⋃ i ∈ C, ⋃ j ∈ A, 𝓝 x i ∩ 𝓝 x j)) →\n C ∈ finset.powerset A ∧ C.finite,\n { assume m,\n have h2 : ∃ C : set (euclidean_space ℝ (fin n)), C ∈ finset.powerset A ∧ C.finite, \n from sorry,\n have h3 : ∀ j ≤ m, 𝓝 x j ⊆ (⋃ i ∈ C, ⋃ j ∈ A, 𝓝 x i ∩ 𝓝 x j), from sorry,\n have h4 : ∀ x ∈ ℝn, exists i : fin n, x i ≤ m ∧ ∃ i : fin n, m ≤ x i, from sorry,\n show ∃ C : set (euclidean_space ℝ (fin n)), \n (∀ x ∈ ℝn, exists i : fin n, x i ≤ m ∧ ∃ i : fin n, m ≤ x i) →\n (∀ j ≤ m, 𝓝 x j ⊆ (⋃ i ∈ C, ⋃ j ∈ A, 𝓝 x i ∩ 𝓝 x j)) →\n C ∈ finset.powerset A ∧ C.finite, from sorry,\n },\n have h5 : ∀ j : ℕ, ∀ x : ℝn, x ∈ ℝn → 𝓝 x j ⊆ (⋃ s ∈ ((⋃ m ∈ ℕ, classical.some (h1 m)) : set (euclidean_space ℝ (fin n))), ⋃ t ∈ A, 𝓝 x s ∩ 𝓝 x t), from sorry,\n have h6 : (⋃ m ∈ ℕ, classical.some (h1 m)) ∈ finset.powerset A ∧ ((⋃ m ∈ ℕ, classical.some (h1 m)) : set (euclidean_space ℝ (fin n))).finite, from sorry,\n show ∃ C : set (euclidean_space ℝ (fin n)), \n (C ≃ᵈ₁ ℝn) ∧ \n (⋃ t ∈ C, 𝓝 x t) ≃ᵈ₂ ℝn ∧ \n C ∈ finset.powerset A ∧ C.finite, from sorry,\nend\n\n--OUTPUT 8\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n let B0 : ℝᵏ := (0 : ℝᵏ),\n let B1 : ℝᵏ := (1 : ℝᵏ),\n let A : set (set (euclidean_space ℝ (fin n))) := {s | ∃ x : ℝᵏ, s = (euclidean_space.ball x ℝ B1 : set (euclidean_space ℝ (fin n)))},\n have h1 : is_open (⋃₀ A), sorry,\n let C := (λ (x : ℝᵏ), { s | ∃ y : ℝᵏ, x ∈ (euclidean_space.ball y ℝ B1 : set (euclidean_space ℝ (fin n))) ∧ s = (euclidean_space.ball y ℝ B1 : set (euclidean_space ℝ (fin n)))} : set (euclidean_space ℝ (fin n)) → set (set (euclidean_space ℝ (fin n)))),\n have h2 : ∀ x : ℝᵏ, is_open (C x), sorry,\n have h3 : is_open (⋃₀ A), from sorry,\n have h4 : is_open (⋃₀ (C (0 : ℝᵏ))), from sorry,\n \n have h5 : (0 : ℝᵏ) ∈ euclidean_space.ball B0 ℝ B1, by { sorry },\n have h6 : (0 : ℝᵏ) ∈ euclidean_space.ball (0 : ℝᵏ) ℝ B1, by { sorry },\n have h7 : (0 : ℝᵏ) ∈ (⋃₀ A), from sorry,\n\n let Cm := (λ (m : ℕ), { s | ∃ y : ℝᴾᵐ, finset.prod y B1 < m ∧ s = (euclidean_space.ball y ℝ B1 : set (euclidean_space ℝ (fin n)))} : set (euclidean_space ℝ (fin n)) → set (set (euclidean_space ℝ (fin n)))),\n have h8 : ∀ m : ℕ, is_open (Cm m), sorry,\n have h9 : is_open (⋃₀ (Cm 1)), from sorry,\n\n let Cm := (λ (m : ℕ), { s | ∃ y : ℕ, finset.prod y B1 < m ∧ s = (euclidean_space.ball y ℝ B1 : set (euclidean_space ℝ (fin n)))} : set (euclidean_space ℝ (fin n)) → set (set (euclidean_space ℝ (fin n)))),\n have h10 : ∀ m : ℕ, is_open (Cm m), sorry,\n have h11 : is_open (⋃₀ (Cm 1)), from sorry,\n\n have h12 : is_open (⋃ (m : ℕ) (h : m < (1 : ℕ)), Cm m), from sorry,\n\n show paracompact_space (euclidean_space ℝ (fin n)), from sorry,\nend\n\n--OUTPUT 9\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) := \nbegin\n sorry\nend\n\n--OUTPUT 10\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n show (paracompact_space (euclidean_space ℝ (fin n))), from sorry\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n have h2 : (A ∩ B) ⊆ A, from sorry,\n have h3 : (A ∩ B) ⊆ S, from sorry,\n show (A ∩ B) ∈ 𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n calc (x + y)^2 = (x+y)*(x+y) : by sorry\n ... = x*(x+y) + y*(x+y) : by sorry\n ... = x*x + x*y + y*x + y*y : by sorry\n ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n use (1 : G),\n have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n show e = (1 : G), from sorry, \n },\n sorry,\n }\nend\n\n/--`theorem`\n\\mathbb{R}^n is paracompact\n$\\mathbb{R}^n$ is paracompact for all $n$.\n`proof`\nLet $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$. We now construct a locally finite open refinement $\\mathcal{C}$ of $\\mathcal{A}$ that covers $\\mathbb{R}^n$. First, we define a collection of pen balls. Let $B_0 = \\phi$, and for each $n \\in \\mathbb{N}$, let $B_m$ denote the ball of radius $m$\ncentered at 0. Given $m$, set $\\Bar{B_m}$ is compact in $\\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\\mathcal{A}$ that cover $\\Bar{B_m}$ and intersect each one with the open set $\\mathbb{R}^n \\setminus \\Bar{B_{m - 1}}$, and let $\\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\\mathcal{A}$). So $\\mathcal{C} = \\bigcup_{m = 0}^{\\infty} \\mathcal{C}_m$ is an open refinement of $\\mathcal{A}$. Note that $\\mathcal{C}$ covers $\\mathbb{R}^n$ since for any $x \\in \\mathbb{R}^n$, there is a smallest $m \\in \\mathbb{N}$ such that $x \\in \\Bar{B_{m}}$ (namely, some $m$ where $\\rVert x \\lVert \\leq m \\leq \\rVert x \\lVert + 1$), and so $x$ is an element of $\\mathcal{C}_m$. Now collection $\\mathcal{C}$ is locally finite since for given $x \\in \\mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\\mathcal{C}$, namely those elements in collection $\\mathcal{C}_1 \\cup \\mathcal{C}_2 \\cup \\cdots \\mathcal{C}_m$. So $\\mathcal{C}$ is a locally finite open refinement of $\\mathcal{A}$ that covers $\\mathbb{R}^n$, hence $\\mathbb{R}^n$ is paracompact.\n\nQED\n-/\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline-Natural-Language-Proof-Translation/Correct_statement-lean_proof_outline-3_few_shot_temperature_0.8_max_tokens_2000_n_10/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6477982043529715, "lm_q2_score": 0.33458944125318607, "lm_q1q2_score": 0.216746439239278}} {"text": "import for_mathlib.derived.bounded_homotopy_category\nimport for_mathlib.is_quasi_iso_sigma\nimport for_mathlib.coprod_op\nimport for_mathlib.derived.example\n\nopen category_theory\nopen category_theory.limits\n\nuniverses v u\nvariables {A : Type u} [category.{v} A] [abelian A] [has_coproducts A]\n\nopen_locale zero_object\n\nnamespace bounded_homotopy_category\n\nnoncomputable\ndef cofan {α : Type v} (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] : cofan X := cofan.mk\n{ val := (homotopy_category.colimit_cofan $ λ a : α, (X a).val).X,\n bdd := begin\n obtain ⟨n,hn⟩ := homotopy_category.is_uniformly_bounded_above.cond (val ∘ X),\n use n, intros i hi,\n dsimp [homotopy_category.colimit_cofan],\n let e : (∐ λ (a : α), (X a).val.as).X i ≅\n (∐ λ (a : α), (X a).val.as.X i) := homotopy_category.coproduct_iso _ _,\n refine is_zero_of_iso_of_zero _ e.symm,\n apply category_theory.is_zero_colimit,\n intros j,\n apply hn j _ hi,\n end }\n(λ a, (homotopy_category.colimit_cofan _).ι.app a)\n\nnoncomputable\ndef is_colimit_cofan {α : Type v} (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] : is_colimit (cofan X) :=\n{ desc := λ S, (homotopy_category.is_colimit_cofan\n (λ a : α, (X a).val)).desc ((forget A).map_cocone S),\n fac' := begin\n intros S j,\n erw (homotopy_category.is_colimit_cofan (λ a : α, (X a).val)).fac\n ((forget A).map_cocone S) j, refl,\n end,\n uniq' := begin\n intros S m hm,\n apply (homotopy_category.is_colimit_cofan (λ a : α, (X a).val)).hom_ext,\n intros j,\n specialize hm j,\n erw hm,\n erw (homotopy_category.is_colimit_cofan (λ a : α, (X a).val)).fac,\n refl,\n end }\n\ninstance has_coproduct_of_uniform_bound {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] :\n has_coproduct X :=\nbegin\n constructor, apply nonempty.intro,\n refine ⟨cofan X, is_colimit_cofan X⟩,\nend\n\ninstance is_K_projective_sigma {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n [∀ a, homotopy_category.is_K_projective (X a).val] :\n homotopy_category.is_K_projective (sigma_obj X).val :=\nbegin\n let e : (sigma_obj X) ≅ (cofan X).X :=\n (colimit.is_colimit _).cocone_point_unique_up_to_iso (is_colimit_cofan X),\n let ee := (forget A).map_iso e,\n suffices : homotopy_category.is_K_projective ((forget A).obj (cofan X).X),\n { resetI, apply homotopy_category.is_K_projective_of_iso _ _ ee.symm },\n dsimp [forget, cofan],\n apply_instance,\nend\n\nnoncomputable\ninstance forget_preserves_coproduct {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] :\n preserves_colimit (discrete.functor X) (forget A) :=\nbegin\n apply preserves_colimit_of_preserves_colimit_cocone (is_colimit_cofan X),\n let E : (forget A).map_cocone (cofan X) ≅\n homotopy_category.colimit_cofan (val ∘ X) :=\n cocones.ext (iso.refl _) _,\n rotate,\n { intros a, dsimp [forget, cofan], simpa only [category.comp_id] },\n apply is_colimit.of_iso_colimit _ E.symm,\n apply homotopy_category.is_colimit_cofan,\nend\n\nlemma is_quasi_iso_sigma\n [AB4 A]\n {α : Type v}\n (X P : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n [uniformly_bounded P]\n (π : Π a, P a ⟶ X a)\n [∀ a, homotopy_category.is_quasi_iso (π a)] :\n homotopy_category.is_quasi_iso\n (sigma.desc $ λ a : α, π a ≫ sigma.ι X a : sigma_obj P ⟶ sigma_obj X) :=\nbegin\n let t := sigma.desc (λ (a : α), π a ≫ sigma.ι X a),\n change homotopy_category.is_quasi_iso ((forget A).map t),\n let eP : (forget A).obj (∐ P) ≅ ∐ (λ a, (forget A).obj (P a)) :=\n preserves_colimit_iso (forget A) _,\n let eX : (forget A).obj (∐ X) ≅ ∐ (λ a, (forget A).obj (X a)) :=\n preserves_colimit_iso (forget A) _,\n let s : ∐ (λ a, (forget A).obj (P a)) ⟶ ∐ (λ a, (forget A).obj (X a)) :=\n sigma.desc (λ (a : α), π a ≫ sigma.ι (val ∘ X) a),\n suffices : (forget A).map t = eP.hom ≫ s ≫ eX.inv,\n { rw this,\n apply homotopy_category.is_quasi_iso_comp },\n apply (is_colimit_of_preserves (forget A) (colimit.is_colimit _)).hom_ext,\n swap, apply_instance,\n intros a,\n dsimp [t, s, eP, eX, preserves_colimit_iso, is_colimit.cocone_point_unique_up_to_iso],\n rw [← (forget A).map_comp, colimit.ι_desc],\n slice_rhs 0 1\n { erw (is_colimit_of_preserves (forget A) (colimit.is_colimit (discrete.functor P))).fac },\n erw colimit.ι_desc,\n dsimp, simp only [category.assoc], erw colimit.ι_desc,\n dsimp, simp only [functor.map_comp], refl,\nend\n\nvariables [enough_projectives A]\n\nnoncomputable\ndef uniform_π {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] : sigma_obj (replace_uniformly X) ⟶ sigma_obj X :=\nsigma.desc $ λ a, π_uniformly _ _ ≫ sigma.ι _ a\n\ninstance is_quasi_iso_sigma_map_π_uniformly\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X] :\n homotopy_category.is_quasi_iso (uniform_π X) :=\nis_quasi_iso_sigma _ _ _\n\nopen opposite\n\nnoncomputable\ndef Ext_coproduct_iso\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n (i : ℤ) (Y) :\n ((Ext i).obj (op (sigma_obj X))).obj Y ≅\n pi_obj (λ a : α, ((Ext i).obj (op (X a))).obj Y) :=\nExt_iso i _ _ _ (uniform_π X) ≪≫\ncategory_theory.preadditive_yoneda_coproduct_iso (replace_uniformly X) (Y⟦i⟧) ≪≫\ncategory_theory.pi_iso _ _ (λ a, (Ext_iso i _ _ _ (π_uniformly X a)).symm)\n\nlemma ι_Ext_coprodut_iso\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n (i : ℤ) (Y) (j) :\n (Ext_coproduct_iso X i Y).inv ≫\n ((Ext i).map (sigma.ι X j : X j ⟶ ∐ X).op).app Y =\n pi.π _ _ :=\nbegin\n rw iso.inv_comp_eq,\n dsimp [Ext_coproduct_iso, pi_iso],\n simp only [category.assoc, limit.lift_π, fan.mk_π_app],\n simp only [← category.assoc], rw iso.eq_comp_inv,\n dsimp [Ext, Ext_iso], --ext t, simp only [comp_apply],\n dsimp [preadditive_yoneda_coproduct_iso, preadditive_yoneda_coproduct_to_product],\n simp only [category.assoc, limit.lift_π],\n ext t, simp only [comp_apply], dsimp,\n simp only [← category.assoc], congr' 1,\n apply lift_ext (∐ X).π, swap, apply_instance,\n dsimp [uniform_π],\n simp,\nend\n\nlemma ι_Ext_coproduct_iso'\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n (i : ℤ) (Y) (j) :\n (Ext_coproduct_iso X i Y).hom ≫ pi.π _ _ =\n ((Ext i).map (sigma.ι X j : X j ⟶ ∐ X).op).app Y :=\nbegin\n rw [← iso.eq_inv_comp, ι_Ext_coprodut_iso],\nend\n\nlemma Ext_coproduct_iso_naturality\n [AB4 A]\n {α : Type v}\n (X₁ X₂ : α → bounded_homotopy_category A)\n [uniformly_bounded X₁]\n [uniformly_bounded X₂]\n (g : X₁ ⟶ X₂)\n (i : ℤ) (Y) :\n ((Ext i).map (sigma.desc (λ b, g b ≫ sigma.ι X₂ b) : ∐ X₁ ⟶ ∐ X₂).op).app Y ≫\n (Ext_coproduct_iso _ _ _).hom =\n (Ext_coproduct_iso _ _ _).hom ≫\n pi.lift (λ b, pi.π _ b ≫ ((Ext i).map (g b).op).app Y) :=\nbegin\n dsimp only [Ext_coproduct_iso, Ext, Ext0, Ext_iso, functor.comp_map, whiskering_left,\n whisker_left, iso.trans_hom, functor.map_iso, preadditive_yoneda_coproduct_iso,\n functor.flip, pi_iso, as_iso, preadditive_yoneda_coproduct_to_product],\n simp only [category.assoc],\n simp only [quiver.hom.unop_op, iso.op_hom, replacement_iso_hom, iso.op_inv,\n replacement_iso_inv, iso.symm_mk],\n apply limit.hom_ext,\n intros j,\n simp only [category.assoc, limit.lift_π, fan.mk_π_app, limit.lift_π_assoc],\n simp only [← functor.map_comp, ← op_comp],\n congr' 2,\n simp only [category.assoc],\n apply lift_ext (∐ X₂).π, swap, apply_instance,\n dsimp [quiver.hom.unop_op],\n simp only [category.assoc, lift_lifts, lift_lifts_assoc],\n dsimp [uniform_π],\n simp only [colimit.ι_desc_assoc, cofan.mk_ι_app, category.assoc, colimit.ι_desc,\n lift_lifts_assoc],\nend\n\nlemma Ext_coproduct_iso_naturality'\n [AB4 A]\n {α : Type v}\n (X : α → bounded_homotopy_category A)\n [uniformly_bounded X]\n (i : ℤ) (Y₁ Y₂) (f : Y₁ ⟶ Y₂) :\n ((Ext i).obj (op (sigma_obj X))).map f ≫\n (Ext_coproduct_iso _ _ _).hom =\n (Ext_coproduct_iso _ _ _).hom ≫\n pi.lift (λ a, pi.π _ a ≫ ((Ext i).obj _).map f) :=\nbegin\n dsimp only [Ext_coproduct_iso, Ext, Ext0, Ext_iso, functor.comp_map, whiskering_left,\n whisker_left, iso.trans_hom, functor.map_iso, preadditive_yoneda_coproduct_iso,\n functor.flip, pi_iso, as_iso, preadditive_yoneda_coproduct_to_product,\n functor.comp_map, functor.comp_obj],\n simp only [category.assoc],\n simp only [quiver.hom.unop_op, iso.op_hom, replacement_iso_hom, iso.op_inv,\n replacement_iso_inv, iso.symm_mk],\n apply limit.hom_ext,\n intros j,\n simp only [category.assoc, limit.lift_π, fan.mk_π_app, limit.lift_π_assoc],\n erw nat_trans.naturality,\n erw nat_trans.naturality_assoc,\n erw nat_trans.naturality_assoc,\n refl,\nend\n\nend bounded_homotopy_category\n\n-- TODO: find better names... And move this stuff!\n\ninstance chain_complex_embed_cofan_uniformly_bounded\n {α : Type v}\n (X : α → chain_complex A ℕ) :\n bounded_homotopy_category.uniformly_bounded\n (λ a, chain_complex.to_bounded_homotopy_category.obj (X a)) :=\nbegin\n constructor, use 1, intros a i hi,\n rcases i with (_|i)|_,\n { exfalso, revert hi, dec_trivial },\n { exact is_zero_zero _, },\n { exfalso, revert hi, dec_trivial }\nend\n\nuniverse u'\n\ndef whisker_discrete_functor {α : Type v}\n {C : Type u} {D : Type u'} [category.{v} C] [category.{v} D] (F : C ⥤ D)\n (X : α → C) : discrete.functor X ⋙ F ≅ discrete.functor (F.obj ∘ X) :=\n discrete.nat_iso (λ i, iso.refl _)\n\nnoncomputable\nlemma preserves_coproducts_aux\n {α : Type v} {C : Type u} {D : Type u'}\n [category.{v} C] [category.{v} D]\n (F : C ⥤ D)\n [has_coproducts_of_shape α C]\n [∀ (X : α → C), has_coproduct (λ a, F.obj (X a))]\n (e : Π (X : α → C), F.obj (∐ X) ≅ ∐ (λ a, F.obj (X a)))\n (he : ∀ (X : α → C) (a : α), F.map (sigma.ι X a) ≫ (e X).hom = sigma.ι _ a) :\n preserves_colimits_of_shape (discrete α) F :=\nbegin\n constructor, intros K,\n let E : K ≅ discrete.functor K.obj := discrete.nat_iso (λ _, iso.refl _),\n apply preserves_colimit_of_iso_diagram _ E.symm,\n apply preserves_colimit_of_preserves_colimit_cocone (colimit.is_colimit _),\n swap, apply_instance,\n let P := _, change is_colimit P,\n let P' := (cocones.precompose (whisker_discrete_functor F K.obj).inv).obj P,\n suffices : is_colimit P',\n { exact is_colimit.precompose_inv_equiv _ _ this },\n apply is_colimit.of_iso_colimit (colimit.is_colimit _), swap,\n change has_colimit (discrete.functor (λ a : α, F.obj (K.obj a))),\n apply_instance,\n symmetry,\n fapply cocones.ext,\n apply e,\n intros a,\n convert (he (λ b, (K.obj b))) a,\n dsimp [P', whisker_discrete_functor],\n rw category.id_comp,\nend\n\nnoncomputable\ninstance homological_complex_embed_preserves_coproducts {α : Type v}\n {M N : Type} (c₁ : complex_shape M) (c₂ : complex_shape N) (e : c₁.embedding c₂) :\n preserves_colimits_of_shape (discrete α)\n (homological_complex.embed e : homological_complex A _ ⥤ _) :=\npreserves_coproducts_aux\n(homological_complex.embed e : homological_complex A _ ⥤ _)\n(λ (X : α → homological_complex A c₁), homological_complex.hom.iso_of_components\n(λ i,\nbegin\n rcases h : e.r i with _ | j,\n { refine homological_complex.embed.X_iso_of_none _ h ≪≫ _,\n refine _ ≪≫ (preserves_colimit_iso (homological_complex.eval A c₂ i) _).symm,\n refine (is_zero.iso_zero _).symm,\n apply is_zero_colimit,\n intros a,\n dsimp,\n exact homological_complex.embed.X_is_zero_of_none _ h },\n { refine homological_complex.embed.X_iso_of_some _ h ≪≫ _,\n refine (preserves_colimit_iso (homological_complex.eval _ _ _) _) ≪≫ _,\n refine _ ≪≫ (preserves_colimit_iso (homological_complex.eval _ _ _) _).symm,\n refine has_colimit.iso_of_nat_iso _,\n refine discrete.nat_iso _,\n intros b,\n dsimp,\n refine (homological_complex.embed.X_iso_of_some _ h).symm }\nend) begin\n intros i j h,\n rcases h₁ : e.r i with _ | i';\n rcases h₂ : e.r j with _ | j',\n { apply is_zero.eq_of_src,\n apply homological_complex.embed.X_is_zero_of_none,\n assumption },\n { apply is_zero.eq_of_src,\n apply homological_complex.embed.X_is_zero_of_none,\n assumption },\n { apply is_zero.eq_of_tgt,\n refine is_zero.of_iso _\n (preserves_colimit_iso (homological_complex.eval _ _ _) _),\n apply is_zero_colimit, intros b,\n apply homological_complex.embed.X_is_zero_of_none,\n assumption },\n { simp_rw [h₁, h₂], dsimp,\n simp only [category.assoc],\n rw ← iso.eq_inv_comp,\n dsimp [homological_complex.embed, homological_complex.embed.obj],\n rw homological_complex.embed.d_of_some_of_some (∐ X) h₁ h₂,\n simp only [category.assoc, iso.inv_hom_id_assoc],\n apply (is_colimit_of_preserves (homological_complex.eval A c₁ i') _).hom_ext,\n intros a,\n simp only [functor.map_cocone_ι_app, colimit.cocone_ι, homological_complex.eval_map],\n slice_lhs 1 2 {\n erw (is_colimit_of_preserves (homological_complex.eval A c₁ i') _).fac },\n dsimp,\n simp only [has_colimit.iso_of_nat_iso_ι_hom, discrete.nat_iso_hom_app, iso.symm_hom,\n category.assoc, ι_preserves_colimits_iso_inv, homological_complex.eval_map,\n homological_complex.hom.comm, homological_complex.hom.comm_assoc],\n dsimp,\n rw iso.inv_comp_eq,\n slice_rhs 3 4\n { erw (is_colimit_of_preserves (homological_complex.eval A c₁ j') _).fac },\n dsimp,\n simp only [has_colimit.iso_of_nat_iso_ι_hom, discrete.nat_iso_hom_app, iso.symm_hom,\n category.assoc, ι_preserves_colimits_iso_inv, homological_complex.eval_map],\n slice_rhs 1 3\n { rw ← homological_complex.embed.d_of_some_of_some (X a) h₁ h₂ },\n apply colimit.is_colimit,\n apply_instance, }\n -- still annoying\n end)\nbegin\n intros X a, ext i,\n rcases h : e.r i with _ | i',\n { apply is_zero.eq_of_tgt,\n refine is_zero.of_iso _\n (preserves_colimit_iso (homological_complex.eval _ _ _) _),\n apply is_zero_colimit, intros b,\n apply homological_complex.embed.X_is_zero_of_none,\n exact h },\n dsimp [homological_complex.hom.iso_of_components],\n simp_rw [h], dsimp,\n simp only [← category.assoc, iso.comp_inv_eq],\n simp_rw [← iso.eq_comp_inv, category.assoc],\n slice_rhs 1 2\n { erw (is_colimit_of_preserves (homological_complex.eval A c₂ i) _).fac },\n dsimp,\n simp only [has_colimit.iso_of_nat_iso_ι_inv, discrete.nat_iso_inv_app, iso.symm_inv,\n category.assoc, ι_preserves_colimits_iso_inv, homological_complex.eval_map],\n apply homological_complex.embed.f_of_some,\nend\n\nnoncomputable\ndef embed_coproduct_iso\n {α : Type v}\n (X : α → chain_complex A ℕ) :\n (homological_complex.embed complex_shape.embedding.nat_down_int_up).obj (∐ X) ≅\n (∐ λ (a : α), (homological_complex.embed complex_shape.embedding.nat_down_int_up).obj (X a)) :=\npreserves_colimit_iso (homological_complex.embed complex_shape.embedding.nat_down_int_up) _ ≪≫\nhas_colimit.iso_of_nat_iso (whisker_discrete_functor _ _)\n\nnoncomputable\ndef chain_complex_embed_cofan_iso\n {α : Type v}\n (X : α → chain_complex A ℕ) :\n (bounded_homotopy_category.cofan\n (λ a, chain_complex.to_bounded_homotopy_category.obj (X a))) ≅\n ((cocones.precompose (whisker_discrete_functor _ X).inv).obj\n (chain_complex.to_bounded_homotopy_category.map_cocone\n (colimit.cocone (discrete.functor X)))) :=\ncocones.ext\n(bounded_homotopy_category.mk_iso $\n (homotopy_category.quotient _ _).map_iso $ (embed_coproduct_iso X).symm)\nbegin\n intros a,\n dsimp [bounded_homotopy_category.cofan,\n homotopy_category.colimit_cofan, whisker_discrete_functor],\n erw [category.id_comp, ← functor.map_comp],\n congr' 1,\n dsimp [embed_coproduct_iso],\n simp only [category.assoc],\n erw colimit.ι_desc_assoc,\n rw iso.comp_inv_eq,\n erw (is_colimit_of_preserves\n (homological_complex.embed complex_shape.embedding.nat_down_int_up) _).fac,\n dsimp [whisker_discrete_functor],\n rw category.id_comp,\nend\n\nnoncomputable\ninstance chain_complex_to_bounded_homotopy_category_preserves_coproducts\n {α : Type v} :\n preserves_colimits_of_shape (discrete α)\n (chain_complex.to_bounded_homotopy_category : chain_complex A _ ⥤ _) :=\nbegin\n constructor, intros K,\n let E : K ≅ discrete.functor K.obj := discrete.nat_iso (λ _, iso.refl _),\n apply preserves_colimit_of_iso_diagram _ E.symm,\n apply preserves_colimit_of_preserves_colimit_cocone (colimit.is_colimit _),\n let Q : α → bounded_homotopy_category A := λ a,\n chain_complex.to_bounded_homotopy_category.obj (K.obj a),\n let P := _, change is_colimit P,\n let T : discrete.functor K.obj ⋙ chain_complex.to_bounded_homotopy_category ≅\n discrete.functor Q := discrete.nat_iso (λ _, iso.refl _),\n let P' := (cocones.precompose T.inv).obj P,\n suffices : is_colimit P',\n { exact is_colimit.precompose_inv_equiv _ _ this },\n apply is_colimit.of_iso_colimit (bounded_homotopy_category.is_colimit_cofan Q),\n swap, apply_instance,\n apply chain_complex_embed_cofan_iso,\nend\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/for_mathlib/derived/ext_coproducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.42250463481418826, "lm_q1q2_score": 0.2162026371988897}} {"text": "import data.fintype.basic\nimport tactic.derive_fintype\nimport tactic.linarith\nimport .finmap\n\nnamespace col\n\ninductive ind_vec (σ : Type) : nat → Type\n| nil : ind_vec 0\n| cons : Π{n : nat}, σ → ind_vec n → ind_vec (n.succ)\n\ndef ind_vec.as_list {σ : Type} : ∀{n : nat}, ind_vec σ n → list σ\n| _ ind_vec.nil := []\n| _ (ind_vec.cons x xs) := x :: xs.as_list\n\nlemma ind_vec.as_list_length {σ : Type} {n : nat} (v : ind_vec σ n) : v.as_list.length = n := begin\n induction v, \n case nil { refl, },\n case cons { simp [ind_vec.as_list, v_ih], },\nend\n\ndef ind_vec.as_vector {σ : Type} {n : nat} (v : ind_vec σ n) : vector σ n :=\n ⟨v.as_list, v.as_list_length⟩\n\ndef list.as_ind_vec {σ : Type} : Π(xs : list σ), ind_vec σ xs.length\n| list.nil := ind_vec.nil\n| (x :: xs) := ind_vec.cons x xs.as_ind_vec\n\ndef vector.as_ind_vec {σ : Type} {n : nat} : vector σ n → ind_vec σ n\n| ⟨xs, h⟩ := eq.rec xs.as_ind_vec h\n\ndef ind_vec.map {σ τ : Type} : ∀{n : nat}, ind_vec σ n → (σ → τ) → ind_vec τ n\n| _ ind_vec.nil _ := ind_vec.nil\n| _ (ind_vec.cons x xs) f := ind_vec.cons (f x) (xs.map f)\n\nstructure domain :=\n (t_args : nat)\n\nvariable {domain_k : Type}\nvariable {domain_k_finite : fintype domain_k}\nvariable domains : finmap domain_k domain\n\ninductive atyp (type_bindings : nat)\n| binding : fin type_bindings → atyp\n| bool : atyp\n| int : atyp\n| perm : atyp\n| ref : atyp\n| domain : Π(k : domain_k), ind_vec atyp (domains k).t_args → atyp\n\ndef typ := atyp domains 0\n\nmutual def atyp.monomorphize, atyp.monomorphize_all {n : nat} (subs : vector (typ domains) n)\n\nwith atyp.monomorphize : atyp domains n → typ domains\n| (atyp.binding i) := subs.nth i\n| atyp.bool := atyp.bool\n| atyp.int := atyp.int\n| atyp.perm := atyp.perm\n| atyp.ref := atyp.ref\n| (atyp.domain k args) := atyp.domain k (atyp.monomorphize_all args)\n\nwith atyp.monomorphize_all : ∀{m : nat}, ind_vec (atyp domains n) m → ind_vec (typ domains) m\n| 0 ind_vec.nil := ind_vec.nil\n| (nat.succ i) (ind_vec.cons t ts) := ind_vec.cons (atyp.monomorphize t) (atyp.monomorphize_all ts)\n\nstructure domain_func :=\n (result : (typ domains))\n (args : list (typ domains))\n\nstructure function :=\n (result : typ domains)\n (args : list (typ domains))\n\nstructure field :=\n (t : typ domains)\n\nstructure predicate :=\n (args : list (typ domains))\n\nstructure method :=\n (args : list (typ domains))\n (locals : list (typ domains))\n (out_args : list (typ domains))\n\nstructure ctx_t \n (domain_k : Type)\n (domain_func_k : Type)\n (func_k : Type)\n (field_k : Type)\n (predicate_k : Type)\n (method_k : Type)\n :=\n [domain_k_finite : fintype domain_k]\n (domains : finmap domain_k domain)\n [domain_func_k_finite : fintype domain_func_k]\n (domain_funcs : finmap domain_func_k (domain_func domains))\n [func_k_finite : fintype func_k]\n (funcs : finmap func_k (function domains))\n [field_k_finite : fintype field_k]\n (fields : finmap field_k (field domains))\n [predicate_k_finite : fintype predicate_k]\n (predicates : finmap predicate_k (predicate domains))\n [method_finite : fintype method_k]\n (methods : finmap method_k (method domains))\n\nvariable {domain_func_k : Type}\nvariable {func_k : Type}\nvariable {field_k : Type}\nvariable {predicate_k : Type}\nvariable {method_k : Type}\n\nvariable (ctx : ctx_t domain_k domain_func_k func_k field_k predicate_k method_k)\n\ninductive want\n| yes \n| no\n\ndef want.typ : want → Type\n| want.yes := unit\n| want.no := empty\n\nstructure exp_cfg :=\n (have_heap : want)\n (have_method : want)\n (have_assn : want)\n (have_result : want)\n (type_bindings : nat)\n\nmutual inductive a_exp, domain_inv, func_inv, pred_inv\n(ctx : ctx_t domain_k domain_func_k func_k field_k predicate_k method_k)\n(cfg : exp_cfg)\n(here : cfg.have_method.typ → method_k)\n\nwith a_exp : Type\n-- pure, heap-independent\n| const_bool : bool → a_exp\n| const_int : ℤ → a_exp\n| domain_apply_indirect : domain_inv → a_exp\n| func_apply_indirect : func_inv → a_exp\n| and : a_exp → a_exp → a_exp\n| implies : a_exp → a_exp → a_exp\n| binding : nat → a_exp\n| all : (atyp ctx.domains cfg.type_bindings) → a_exp → a_exp\n| ex : (atyp ctx.domains cfg.type_bindings) → a_exp → a_exp\n\n-- normal, heap-dependent\n| deref : cfg.have_heap.typ → a_exp → field_k → a_exp\n\n-- local\n| arg (m : cfg.have_method.typ) : fin (ctx.methods (here m)).args.length → a_exp\n| out (m : cfg.have_method.typ) : fin (ctx.methods (here m)).out_args.length → a_exp\n| loc (m : cfg.have_method.typ) : fin (ctx.methods (here m)).locals.length → a_exp\n\n-- postcondition result\n| result : cfg.have_result.typ → a_exp\n\n-- assertions\n| acc_field : cfg.have_assn.typ → a_exp → field_k → a_exp → a_exp\n| acc_pred : cfg.have_assn.typ → pred_inv → a_exp → a_exp\n\nwith domain_inv : Type\n| apply (k : domain_func_k) : ind_vec a_exp (ctx.domain_funcs k).args.length → domain_inv\n\nwith func_inv : Type\n| apply (k : func_k) : ind_vec a_exp (ctx.funcs k).args.length → func_inv\n\nwith pred_inv : Type\n| apply (k : predicate_k) : ind_vec a_exp (ctx.predicates k).args.length → pred_inv\n\ndef pure_exp (type_bindings : nat) : Type := \n a_exp ctx { have_heap := want.no, have_method := want.no, have_assn := want.no, have_result := want.no, type_bindings := type_bindings }\n empty.elim\n\ndef exp : Type := \n a_exp ctx { have_heap := want.yes, have_method := want.no, have_assn := want.no, have_result := want.no, type_bindings := 0 }\n empty.elim\n\ndef assn (have_result : want) : Type := \n a_exp ctx { have_heap := want.yes, have_method := want.no, have_assn := want.yes, have_result := have_result, type_bindings := 0 }\n empty.elim\n\ndef local_exp (here : method_k) : Type :=\n a_exp ctx { have_heap := want.yes, have_method := want.yes, have_assn := want.no, have_result := want.no, type_bindings := 0 }\n (λ_, here)\n\ndef local_assn (here : method_k) : Type :=\n a_exp ctx { have_heap := want.yes, have_method := want.yes, have_assn := want.yes, have_result := want.no, type_bindings := 0 }\n (λ_, here)\n\nstructure domain_axiom :=\n (t_args : nat)\n (ax : pure_exp ctx t_args)\n\nstructure func_impl :=\n (requires : assn ctx want.no)\n (body : option $ exp ctx)\n (ensures : assn ctx want.yes)\n\nstructure predicate_impl :=\n (body : assn ctx want.no)\n\ninductive stat (here : method_k)\n| nop : stat\n| seqn : list stat → stat\n| cond : (local_exp ctx here) → stat → stat → stat\n| assign : fin (ctx.methods here).locals.length → (local_exp ctx here) → stat\n\nstructure method_impl (here : method_k) :=\n (requires : local_assn ctx here)\n (body : option $ exp ctx)\n (ensures : local_assn ctx here)\n\nstructure verification :=\n {domain_k : Type}\n {domain_func_k : Type}\n {func_k : Type}\n {field_k : Type}\n {predicate_k : Type}\n {method_k : Type}\n\n [domain_k_finite : fintype domain_k]\n [domain_func_k_finite : fintype domain_func_k]\n [func_k_finite : fintype func_k]\n [field_k_finite : fintype field_k]\n [predicate_k_finite : fintype predicate_k]\n [method_finite : fintype method_k]\n \n (ctx : ctx_t domain_k domain_func_k func_k field_k predicate_k method_k)\n\n (domain_axioms : list (domain_axiom ctx))\n (func_impls : finmap func_k (func_impl ctx))\n (predicate_impls : finmap predicate_k (predicate_impl ctx))\n (method_impls : Π(k : method_k), method_impl ctx k)\n\n-- typing rules\ninductive a_exp.t \n(ctx : ctx_t domain_k domain_func_k func_k field_k predicate_k method_k)\n(cfg : exp_cfg)\n(here : cfg.have_method.typ → method_k)\n: (list $ atyp ctx.domains cfg.type_bindings) → (a_exp ctx cfg here) → (atyp ctx.domains cfg.type_bindings) → Prop\n\n| const_bool (vs : (list $ atyp ctx.domains cfg.type_bindings)) (b : bool) : a_exp.t vs (a_exp.const_bool b) atyp.bool\n| const_int (vs : (list $ atyp ctx.domains cfg.type_bindings)) (i : ℤ) : a_exp.t vs (a_exp.const_int i) atyp.int\n| domain_apply\n (vs : (list $ atyp ctx.domains cfg.type_bindings))\n (k : domain_func_k) \n (args : ind_vec (a_exp ctx cfg here) (ctx.domain_funcs k).args.length)\n (args_ok : \n ∀(i : fin (ctx.domain_funcs k).args.length), \n a_exp.t vs (args.as_vector.nth i) \n ((ctx.domain_funcs k).args.nth_le i i.property))\n : a_exp.t vs (a_exp.domain_apply_indirect (domain_inv.apply k args)) (ctx.domain_funcs k).result\n| func_apply\n (vs : (list $ atyp ctx.domains cfg.type_bindings))\n (k : func_k)\n (args : ind_vec (a_exp ctx cfg here) (ctx.funcs k).args.length)\n (args_ok : \n ∀(i : fin (ctx.funcs k).args.length),\n a_exp.t vs (args.as_vector.nth i)\n ((ctx.funcs k).args.nth_le i i.property))\n : a_exp.t vs (a_exp.func_apply_indirect (func_inv.apply k args)) (ctx.funcs k).result\n| and (vs : (list $ atyp ctx.domains cfg.type_bindings)) : ∀l r, a_exp.t vs l atyp.bool → a_exp.t vs r atyp.bool → a_exp.t vs (a_exp.and l r) atyp.bool\n| implies (vs : (list $ atyp ctx.domains cfg.type_bindings)) : ∀l r, a_exp.t vs l atyp.bool → a_exp.t vs r atyp.bool → a_exp.t vs (a_exp.implies l r) atyp.bool\n| binding (vs : (list $ atyp ctx.domains cfg.type_bindings)) (i : nat) (h : i < vs.length) : a_exp.t vs (a_exp.binding i) $ vs.nth_le i h\n| all \n (vs : (list $ atyp ctx.domains cfg.type_bindings)) \n (v : atyp ctx.domains cfg.type_bindings) \n (e : a_exp ctx cfg here)\n : a_exp.t (v :: vs) e atyp.bool → a_exp.t vs (a_exp.all v e) atyp.bool\n| ex\n (vs : (list $ atyp ctx.domains cfg.type_bindings)) \n (v : atyp ctx.domains cfg.type_bindings) \n (e : a_exp ctx cfg here)\n : a_exp.t (v :: vs) e atyp.bool → a_exp.t vs (a_exp.ex v e) atyp.bool\n| deref\n (vs : (list $ atyp ctx.domains cfg.type_bindings)) \n (have_heap : cfg.have_heap.typ)\n (obj : a_exp ctx cfg here)\n (k : field_k)\n : a_exp.t vs obj atyp.ref → a_exp.t vs (a_exp.deref have_heap obj k) (ctx.fields k).t\n\n/-\n-- semantics definitions\ndef objects := nat\n\nstructure location :=\n (obj : objects)\n (field : field)\n\ninductive value\n| int : ℤ → value\n| rat : ℚ → value\n| obj : objects → value\n\nstructure heap :=\n (mask : location → ℚ)\n (value : location → value)\n\nstructure state :=\n (heap : heap)\n (locals : nat → value)\n\n-- semantics\ndef state.sat : state → exp → Prop := λ s e, match e with\n| _ := sorry\nend\n-/\n\nend col\n\nnamespace ex\n\n@[derive fintype]\ninductive domain_name\n| option\n\nopen domain_name\n\ndef domains : finmap domain_name col.domain\n| option := { t_args := 1 }\n\n@[derive fintype]\ninductive method_name\n| test\n\nopen method_name\n\ndef methods : finmap method_name (col.method domains)\n| test := { args := [col.atyp.domain option $ col.list.as_ind_vec [col.atyp.int]], locals := [], out_args := [] }\n\n#check methods test\n\nend ex", "meta": {"author": "pieter-bos", "repo": "vercors-lean", "sha": "45f545e3f85489ee1dcaefe2b79f99d4aa0d3e5f", "save_path": "github-repos/lean/pieter-bos-vercors-lean", "path": "github-repos/lean/pieter-bos-vercors-lean/vercors-lean-45f545e3f85489ee1dcaefe2b79f99d4aa0d3e5f/lean/col.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.41489884579676883, "lm_q1q2_score": 0.21554879684473494}} {"text": "/-\nCopyright 2020 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n -/\n\n\nimport order.bounded_lattice\n\nlemma with_top.not_none_lt {α:Type*} [preorder α] (a:with_top α):\n ¬(@has_lt.lt (with_top α) _ (none:with_top α) a):=\nbegin\n intro A1,\n rw lt_iff_le_not_le at A1,\n cases A1 with A1 A2,\n apply A2,\n apply with_top.le_none,\nend\n\nlemma with_top.not_none_le_some {α:Type*} [partial_order α] (a:α):\n ¬(@has_le.le (with_top α) _ (none) (some a)):=\nbegin\n intro A1,\n have B1:(some a) ≠ (none:with_top α),\n {\n simp,\n },\n have B3:(@has_le.le (with_top α) _ (some a) (none)) := with_top.le_none,\n have B4 := @le_antisymm (with_top α) _ (some a) (none) B3 A1,\n apply B1,\n apply B4\nend\n", "meta": {"author": "google", "repo": "formal-ml", "sha": "630011d19fdd9539c8d6493a69fe70af5d193590", "save_path": "github-repos/lean/google-formal-ml", "path": "github-repos/lean/google-formal-ml/formal-ml-630011d19fdd9539c8d6493a69fe70af5d193590/src/formal_ml/with_top.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.42632159254749036, "lm_q1q2_score": 0.21482608111446486}} {"text": "import data.vector\nimport data.equiv.denumerable\nimport data.list.sort\nimport ring_theory.tensor_product\nimport algebra.category.Module.basic\n\ninductive type (cT : Type) : Type\n| const : cT → type\n| arrow : type → type → type\n\nvariables (cT : Type)\n\n@[reducible] def context (cT : Type) : Type := list (string × type cT)\n\n-- instance : has_append (context cT) :=\n-- ⟨λ a b : list (string × type cT), list.append b a⟩\n\nvariables {cT}\n\ninductive term (ct : type cT → Type) : Π (Γ : context cT) (A : type cT), Type\n| const {T : type cT} (t : ct T) : term [] T\n| var (a : string) (T : type cT) : term [(a, T)] T\n| app (Γ₁ Γ₂ : context cT) {T₁ T₂ : type cT} (f : term Γ₁ (T₁.arrow T₂)) (x : term Γ₂ T₁) : \n term (Γ₁ ++ Γ₂) T₂\n| lambda {Γ : context cT} (a : string) (T₁ : type cT) {T₂ : type cT}\n (t : term (Γ ++ [(a, T₁)]) T₂) : term Γ (T₁.arrow T₂)\n\ninductive term2 (ct : type cT → Type) : Π (A : type cT), Type\n| const {T : type cT} (t : ct T) : term2 T\n| app {T₁ T₂ : type cT} (f : term2 (T₁.arrow T₂)) (x : term2 T₁) : term2 T₂\n| id {T₁ : type cT} : term2 (T₁.arrow T₁)\n| comp {T₁ T₂ T₃ : type cT} : term2 ((T₁.arrow T₂).arrow ((T₂.arrow T₃).arrow (T₁.arrow T₃)))\n| swap {T₁ T₂ T₃ : type cT} : term2 ((T₁.arrow (T₂.arrow T₃)).arrow (T₂.arrow (T₁.arrow T₃)))\n\ndef presheaf (ct : type cT → Type) : Type 1 := \nΣ (F : type cT → Type), Π {A B : type cT}, term2 ct (A.arrow B) → F A → F B\n\nnamespace presheaf\n\nvariable {ct : type cT → Type}\n\ndef hom (F G : presheaf ct) : Type :=\nΠ (A : type cT), F.1 A → G.1 A\n\ndef hom.comp {F G H : presheaf ct} (f : hom F G) (g : hom G H) : hom F H :=\nλ A, g A ∘ f A\n\ndef hom.id (F : presheaf ct) : hom F F := λ _, id\n\nvariable (ct)\n\ndef yoneda (A : type cT) : presheaf ct := \n⟨λ B, term2 ct (A.arrow B), λ B C f g, term2.app (term2.app term2.comp g) f⟩\n\nvariable {ct}\n\ndef yoneda_map {A B : type cT} (f : term2 ct (A.arrow B)) : hom (yoneda ct B) (yoneda ct A) :=\nλ C, term2.app (term2.app term2.comp f)\n\ndef yoneda_full {A B : type cT} (f : hom (yoneda ct B) (yoneda ct A)) : \n term2 ct (A.arrow B) :=\nf B term2.id\n\ndef sumthing (F : presheaf ct) : presheaf ct :=\n⟨λ c, Σ c' : type cT, term2 ct (c'.arrow c) × F.1 c', \n λ A B f a, ⟨a.1, (term2.app term2.comp a.2.1).app f, a.2.2⟩⟩\n\ndef to_sumthing (F : presheaf ct) : hom F (sumthing F) :=\nλ A a, ⟨A, term2.id, a⟩\n\ndef of_sumthing (F : presheaf ct) : hom (sumthing F) F :=\nλ A b, F.2 b.2.1 b.2.2\n\ndef tensor (F G : presheaf ct) : presheaf ct :=\n⟨λ c, Σ c₁ c₂ : type cT, term2 ct (c₁.arrow (c₂.arrow c)) × F.1 c × G.1 c, \n λ A B f x, ⟨x.1, x.2.1, term2.app (term2.app term2.comp x.2.2.1) \n (term2.app (term2.app term2.swap term2.comp) f), \n F.2 f x.2.2.2.1, G.2 f x.2.2.2.2⟩⟩\n\ndef tensor_assoc₁ (F G H : presheaf ct) : \n hom (tensor (tensor F G) H) (tensor F (tensor G H)) :=\nλ A a, begin\n rcases a with ⟨c₁, c₂, h₁, ⟨c₃, c₄, h₂, f, g⟩, h⟩,\n exact ⟨c₁, c₂, h₁, f, c₃, c₄, h₂, g, h⟩\nend\n\ndef tensor_assoc (F G H : presheaf ct) : \n hom (tensor F (tensor G H)) (tensor (tensor F G) H) :=\nλ A a, begin\n rcases a with ⟨c₁, c₂, h₁, f, c₃, c₄, h₂, g, h⟩,\n exact ⟨c₁, c₂, h₁, ⟨c₃, c₄, h₂, f, g⟩, h⟩\nend\n\ndef tensor_map {F₁ G₁ F₂ G₂ : presheaf ct} (f : hom F₁ F₂) (g : hom G₁ G₂) :\n hom (tensor F₁ G₁) (tensor F₂ G₂) :=\nλ A a, ⟨a.1, a.2.1, a.2.2.1, f _ a.2.2.2.1, g _ a.2.2.2.2⟩ \n\ndef homp (F G : presheaf ct) : presheaf ct :=\n⟨λ c, Σ c₁ c₂ : type cT, term2 ct (c₁.arrow (c₂.arrow c)) → F.1 c → G.1 c,\n sorry⟩\n\nsection curry\n\nvariables {F G H : presheaf ct}\n\n-- def curryFa (F G H : presheaf ct) : presheaf ct :=\n-- ⟨λ A, hom () H, _⟩ \n\n-- def currya₁ : hom (homp (tensor F G) H) (homp F (homp G H)) :=\n\n\ndef curry {F G H : presheaf ct} : (hom (tensor F G) H) → \n (hom F (homp G H)) :=\nbegin\n dsimp [tensor, yoneda, hom, homp] at *,\n exact f _ ⟨x.1, x.2.1, x.2.2, fA, gA⟩\nend\n\nend curry\n\ndef yoneda_hom (F G : type cT) : yoneda \n\ndef id : presheaf ct := ⟨λ _, unit, λ _ _ _, id⟩\n\ndef tensor_id₁ (F : presheaf ct) : hom (tensor F id) F :=\nλ A a, a.1\n\ndef tensor_id₂ (F : presheaf ct) : hom F (tensor F id) :=\nλ A a, (a, ())\n\ndef id_tensor₂ (F : presheaf ct) : hom F (tensor id F) :=\nλ A a, ((), a)\n\n\n\nend presheaf\n\nopen category_theory\n\nsection\n\ninductive type3 (cT : Type) : Type\n| const : cT → type3\n| arrow : type3 → type3 → type3\n| id {} : type3\n| tensor : type3 → type3 → type3\n\n\ndef type3.of_type : type cT → type3 cT \n| (type.const T) := type3.const T\n| (type.arrow T₁ T₂) := type3.arrow (type3.of_type T₁) (type3.of_type T₂)\n\ndef contexti : context cT → type3 cT\n| [] := type3.id\n| (T :: l) := type3.tensor (type3.of_type T.2) (contexti l)\n\ninductive term3 (const_term : type cT → Type) : Π (A : type3 cT), Type\n| const {T : type cT} (t : const_term T) : term3 (type3.of_type T)\n| id (T : type3 cT) : term3 (T.arrow T)\n| curry {T₁ T₂ T₃ : type3 cT} :\n term3 ((((T₁.tensor T₂).arrow T₃)).arrow (T₁.arrow (T₂.arrow T₃)))\n| uncurry {T₁ T₂ T₃ : type3 cT} :\n term3 ((T₁.arrow (T₂.arrow T₃)).arrow ((T₁.tensor T₂).arrow T₃))\n| tensor_map {T₁ T₂ T₃ T₄ : type3 cT} (f₁ : term3 (T₁.arrow T₃))\n (f₂ : term3 (T₂.arrow T₄)) : term3 ((T₁.tensor T₂).arrow (T₃.tensor T₄))\n| tensor_symm {T₁ T₂ : type3 cT} : term3 ((T₁.tensor T₂).arrow (T₂.tensor T₁))\n| lid₁ {T : type3 cT} : term3 ((type3.id.tensor T).arrow T)\n| lid₂ {T : type3 cT} : term3 (T.arrow (type3.id.tensor T))\n| app {T₁ T₂ : type3 cT} (f : term3 (T₁.arrow T₂)) (x : term3 T₁) : term3 T₂\n| comp {T₁ T₂ T₃ : type3 cT} (f : term3 (T₁.arrow T₂)) :\n term3 ((T₂.arrow T₃).arrow (T₁.arrow T₃))\n\nnamespace term3 \n\nvariables {const_term : type cT → Type}\n\ndef tensor_mk {T₁ T₂ : type3 cT} : term3 const_term (T₁.arrow (T₂.arrow (T₁.tensor T₂))) := \nterm3.app term3.curry (term3.id _)\n\ndef rid₁ {T : type3 cT} : term3 const_term ((T.tensor type3.id).arrow T) :=\nterm3.app (term3.comp term3.tensor_symm) term3.lid₁\n\ndef rid₂ (T : type3 cT) : term3 const_term (T.arrow (T.tensor type3.id)) :=\nterm3.app (term3.comp term3.lid₂) term3.tensor_symm\n\ndef lift {T : type3 cT} : term3 const_term (T.arrow (type3.id.arrow T)) :=\nterm3.app term3.curry term3.rid₁\n\ndef drop {T : type3 cT} : term3 const_term ((type3.id.arrow T).arrow T) :=\nterm3.app (term3.comp (term3.rid₂ _)) \n (term3.app (term3.uncurry) (term3.id _))\n\ndef assoc₁ {T₁ T₂ T₃ : type3 cT} : \n term3 const_term (((T₁.tensor T₂).tensor T₃).arrow (T₁.tensor (T₂.tensor T₃))) :=\nterm3.app term3.uncurry $ term3.app term3.uncurry $\n term3.app (term3.comp term3.tensor_mk) term3.curry\n\ndef assoc₂ {T₁ T₂ T₃ : type3 cT} :\n term3 const_term ((T₁.tensor (T₂.tensor T₃)).arrow ((T₁.tensor T₂).tensor T₃)) :=\nterm3.app term3.uncurry $ term3.app (term3.comp \n (term3.app term3.curry tensor_mk)) term3.uncurry\n\ndef contexti_append₁ : Π (Γ₁ Γ₂ : context cT), term3 const_term \n ((contexti (Γ₁ ++ Γ₂)).arrow ((contexti Γ₁).tensor (contexti Γ₂)))\n| [] Γ₂ := lid₂\n| (T::Γ₁) Γ₂ := term3.app (term3.comp (term3.tensor_map (term3.id _) \n (contexti_append₁ _ _))) term3.assoc₂\n \ndef contexti_append₂ : Π (Γ₁ Γ₂ : context cT), term3 const_term \n (((contexti Γ₁).tensor (contexti Γ₂)).arrow (contexti (Γ₁ ++ Γ₂)))\n| [] Γ₂ := lid₁\n| (T::Γ₁) Γ₂ := term3.app (term3.comp term3.assoc₁) \n (term3.tensor_map (term3.id _) (contexti_append₂ _ _))\n\nend term3\n\nvariables {const_term : type cT → Type}\nvariables (const_termi : Π {T : type cT}, const_term T → type3 cT)\n\ndef termi : Π {Γ : context cT} {A : type cT} (t : term const_term Γ A),\n term3 const_term ((contexti Γ).arrow (type3.of_type A))\n| _ A (term.const t) := term3.app term3.lift (term3.const t)\n| _ _ (term.var _ A) := term3.rid₁\n| _ T₂ (@term.app _ _ Γ₁ Γ₂ T₁ _ f x) := \nterm3.app (term3.comp (term3.contexti_append₁ _ _)) \n (term3.app term3.uncurry \n (term3.app (term3.comp (termi f)) \n (term3.comp (termi x))))\n| Γ (type.arrow _ T₂) (term.lambda a T₁ t) :=\nterm3.app term3.curry \n (term3.app (term3.comp \n (term3.app (term3.comp (term3.tensor_map (term3.id _) \n (term3.rid₂ _))) (term3.contexti_append₂ Γ [(a, T₁)]))) (termi t))\n\ninductive term₃ (const_term : type cT → Type) : Π (A : type cT), Type\n| const {T : type cT} (t : const_term T) : term₃ T\n| id (T : type cT) : term₃ (T.arrow T)\n| app {T₁ T₂ : type cT} (f : term₃ (T₁.arrow T₂)) (x : term₃ T₁) : term₃ T₂\n| comp {T₁ T₂ T₃ : type cT} (f : term₃ (T₁.arrow T₂)) : \n term₃ ((T₂.arrow T₃).arrow (T₁.arrow T₃))\n\nend\n\nopen term\n\ndef const_term : type unit → Type\n| (type.arrow (type.const ()) (type.arrow (type.const ()) (type.const ()))) := unit\n| _ := empty\n\ndef cTi : unit → Module R := λ _, M\n\ninclude op\n\ndef const_termi {T : type unit} (t : const_term T) : typei (@cTi R _ M) T :=\nbegin\n cases T with _ T₁ T₂; try { apply empty.elim t },\n cases T₁ with _ T₂ T₃; try { apply empty.elim t },\n cases T₁,\n cases T₂ with _ T₁ T₂; try { apply empty.elim t },\n cases T₁ with _ T₁ T₂; try { apply empty.elim t },\n cases T₁,\n cases T₂ with _ T₁ T₂; try { apply empty.elim t },\n exact op\nend\n\nomit op\n\ndef mult : const_term (type.arrow (type.const ()) (type.arrow (type.const ()) (type.const ()))) := ()\n\nnotation `T` := type.const ()\n\ndef exmpl₁ : @term unit const_term [] \n ((type.const ()).arrow ((type.const ()).arrow ((type.const ()).arrow (type.const ())))) :=\nlambda \"a\" T $ \nlambda \"b\" T $\nlambda \"c\" T $\n app [(\"a\", T), (\"b\", T)] [(\"c\", T)] \n (app [] [(\"a\", T), (\"b\", T)] (const mult) \n (app [(\"a\", T)] [(\"b\", T)] \n (app [] [(\"a\", T)] (const mult) (var \"a\" (type.const ()))) \n (var \"b\" (type.const ()))) : _) \n (var \"c\" (type.const ()))\n\nexample (p q r : M) : \n termi (@cTi R _ M) (@const_termi _ _ _ op) exmpl₁ = 0 :=\nbegin\n dunfold exmpl₁,\n simp[termi],\n dsimp [typei, contexti, contexti_append, cTi, const_termi],\n ext,\n simp,\n\nend\n\n\n", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/linear_lambda/monoidal_lambda2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.38861802670584894, "lm_q1q2_score": 0.21397594788401117}} {"text": "/-\nCopyright (c) 2018 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Simon Hudon\n-/\nimport data.pfun\n\nnamespace roption\nvariables {α : Type*} {β : Type*} {γ : Type*}\n\nopen function\nlemma assert_if_neg {p : Prop}\n (x : p → roption α)\n (h : ¬ p)\n: assert p x = roption.none :=\nby { dsimp [assert,roption.none],\n have : (∃ (h : p), (x h).dom) ↔ false,\n { split ; intros h' ; repeat { cases h' with h' },\n exact h h' },\n congr,\n repeat { rw this <|> apply hfunext },\n intros h h', cases h', }\n\nlemma assert_if_pos {p : Prop}\n (x : p → roption α)\n (h : p)\n: assert p x = x h :=\nby { dsimp [assert],\n have : (∃ (h : p), (x h).dom) ↔ (x h).dom,\n { split ; intros h'\n ; cases h' <|> split\n ; assumption, },\n cases hx : x h, congr, rw [this,hx],\n apply hfunext, rw [this,hx],\n intros, simp [hx] }\n\n@[simp]\nlemma roption.none_bind {α β : Type*} (f : α → roption β)\n: roption.none >>= f = roption.none :=\nby simp [roption.none,has_bind.bind,roption.bind,assert_if_neg]\n\nend roption\n", "meta": {"author": "leanprover-community", "repo": "mathlib-nursery", "sha": "0479b31fa5b4d39f41e89b8584c9f5bf5271e8ec", "save_path": "github-repos/lean/leanprover-community-mathlib-nursery", "path": "github-repos/lean/leanprover-community-mathlib-nursery/mathlib-nursery-0479b31fa5b4d39f41e89b8584c9f5bf5271e8ec/src/data/pfun/nursery.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5813030906443134, "lm_q2_score": 0.36658973632215985, "lm_q1q2_score": 0.21309974672255544}} {"text": "import Radon.LC_comparison\n\nopen_locale nnreal big_operators classical\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\nopen topological_space\n\nlocal attribute [instance]\n locally_constant.seminormed_add_comm_group\n locally_constant.pseudo_metric_space\n\nnamespace Profinite\n\n/--\nThis is the cone which will exhibit `X.Radon_LC p c` as the limit of `T.Radon_LC p c`\nwhere `T` varies over the discrete quotients of `X`.\n-/\ndef Radon_LC_cone (X : Profinite.{0}) (p c : ℝ≥0) [fact (0 < p)] :\n cone (X.diagram ⋙ Radon_LC_functor p c) :=\n(Radon_LC_functor p c).map_cone X.as_limit_cone\n\nnamespace is_limit_Radon_LC_cone\n\nvariables (X : Profinite.{0}) (p c : ℝ≥0) [fact (0 < p)]\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef linear_map (S : cone (X.diagram ⋙ Radon_LC_functor p c)) (t : S.X) :\n locally_constant X ℝ →ₗ[ℝ] ℝ :=\n{ to_fun := λ e, (S.π.app e.discrete_quotient t).1 e.locally_constant_lift,\n map_add' := begin\n intros e₁ e₂,\n let W₁ := e₁.discrete_quotient,\n let W₂ := e₂.discrete_quotient,\n let W₁₂ := (e₁ + e₂).discrete_quotient,\n let W := W₁ ⊓ W₂ ⊓ W₁₂,\n let π₁ : W ⟶ W₁ := hom_of_le (le_trans inf_le_left inf_le_left),\n let π₂ : W ⟶ W₂ := hom_of_le (le_trans inf_le_left inf_le_right),\n let π₁₂ : W ⟶ W₁₂ := hom_of_le inf_le_right,\n rw [← S.w π₁, ← S.w π₂, ← S.w π₁₂],\n dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap, continuous_map.comap_LC],\n erw ← ((S.π.app W) t).1.map_add, congr' 1,\n ext ⟨⟩, refl\n end,\n map_smul' := begin\n intros r e,\n let W₁ := e.discrete_quotient,\n let W₂ := (r • e).discrete_quotient,\n let W := W₁ ⊓ W₂,\n let π₁ : W ⟶ W₁ := hom_of_le inf_le_left,\n let π₂ : W ⟶ W₂ := hom_of_le inf_le_right,\n rw [← S.w π₁, ← S.w π₂],\n dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap, continuous_map.comap_LC],\n rw ← smul_eq_mul,\n erw ← ((S.π.app W) t).1.map_smul, congr' 1,\n ext ⟨⟩, refl\n end }\n\nvariables [fact (p ≤ 1)]\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef weak_dual (S : cone (X.diagram ⋙ Radon_LC_functor p c)) (t : S.X) :\n weak_dual ℝ (locally_constant X ℝ) :=\nlinear_map.mk_continuous_of_exists_bound (linear_map X p c S t)\nbegin\n use c^(1/(p : ℝ)),\n intros e,\n suffices : ∥ linear_map X p c S t e ∥₊ ≤ c^(1/(p : ℝ)) * ∥ e ∥₊,\n by exact_mod_cast this,\n have hp : 0 < (p : ℝ) := by exact_mod_cast (fact.out (0 < p)),\n have hp' : (p : ℝ) ≠ 0,\n { exact ne_of_gt hp },\n rw [← nnreal.rpow_le_rpow_iff hp, nnreal.mul_rpow, ← nnreal.rpow_mul],\n rw [(show 1 / (p : ℝ) * p = 1, by field_simp), nnreal.rpow_one],\n have H := ((S.π.app e.discrete_quotient) t).2 ⊥,\n replace H := mul_le_mul H (le_refl (∥e∥₊^(p : ℝ))) (zero_le _) (zero_le _),\n refine le_trans _ H,\n rw [mul_comm, finset.mul_sum],\n nth_rewrite 0 e.eq_sum,\n simp_rw [linear_map.map_sum, linear_map.map_smul],\n refine le_trans (real.pow_nnnorm_sum_le _ _ _) _,\n have : ∑ (x : (⊥ : discrete_quotient e.discrete_quotient)),\n ∥e∥₊ ^ (p : ℝ) * ∥(((S.π.app e.discrete_quotient) t).val)\n ((⊥ : discrete_quotient e.discrete_quotient).fibre x).indicator_LC∥₊ ^ (p : ℝ) =\n ∑ (x : e.discrete_quotient), ∥e∥₊^(p : ℝ) *\n ∥ (linear_map X p c S t) (e.discrete_quotient.fibre x).indicator_LC ∥₊^(p : ℝ),\n { fapply finset.sum_bij',\n { intros a _, exact discrete_quotient.equiv_bot.symm a },\n { intros, exact finset.mem_univ _ },\n { intros, congr' 3, dsimp [linear_map],\n let T₁ := e.discrete_quotient,\n let T₂ := (e.discrete_quotient.fibre\n ((discrete_quotient.equiv_bot.symm) a)).indicator_LC.discrete_quotient,\n let T := T₁ ⊓ T₂,\n let π₁ : T ⟶ T₁ := hom_of_le inf_le_left,\n let π₂ : T ⟶ T₂ := hom_of_le inf_le_right,\n rw [← S.w π₁, ← S.w π₂],\n dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap],\n congr' 1,\n ext b, obtain ⟨b,rfl⟩ := discrete_quotient.proj_surjective _ b,\n dsimp [continuous_map.comap_LC],\n change _ =\n (e.discrete_quotient.fibre ((discrete_quotient.equiv_bot.symm) a)).indicator_LC b,\n dsimp only [topological_space.clopens.indicator_LC_apply],\n rw (show X.fintype_diagram.map π₁ (T.proj b) = T₁.proj b, by refl),\n erw discrete_quotient.mem_fibre_iff' },\n { intros a _, exact discrete_quotient.equiv_bot a },\n { intros, exact finset.mem_univ _ },\n { intros, apply equiv.apply_symm_apply },\n { intros, apply equiv.symm_apply_apply } },\n rw this, clear this,\n apply finset.sum_le_sum, rintros x -,\n rw [smul_eq_mul, nnnorm_mul, nnreal.mul_rpow],\n refine mul_le_mul _ (le_refl _) (zero_le _) (zero_le _),\n apply nnreal.rpow_le_rpow _ (le_of_lt hp),\n obtain ⟨x,rfl⟩ := discrete_quotient.proj_surjective _ x,\n change ∥ e x ∥₊ ≤ _,\n apply locally_constant.nnnorm_apply_le_nnnorm,\nend\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC (S : cone (X.diagram ⋙ Radon_LC_functor p c)) (t : S.X) :\n X.Radon_LC p c :=\n{ val := weak_dual X p c S t,\n property := begin\n intros T,\n dsimp [weak_dual, linear_map],\n convert (S.π.app T t).2 ⊥ using 1,\n fapply finset.sum_bij',\n { intros a _, exact discrete_quotient.equiv_bot a },\n { intros, apply finset.mem_univ },\n { intros a ha, congr' 2,\n let W := (T.fibre a).indicator_LC.discrete_quotient,\n let E := T ⊓ W,\n let π₁ : E ⟶ T := hom_of_le inf_le_left,\n let π₂ : E ⟶ W := hom_of_le inf_le_right,\n rw [← S.w π₁, ← S.w π₂],\n dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap,\n continuous_map.comap_LC],\n congr' 1, ext b, obtain ⟨b,rfl⟩ := discrete_quotient.proj_surjective _ b,\n change (T.fibre a).indicator_LC b = _,\n dsimp [topological_space.clopens.indicator_LC_apply],\n erw discrete_quotient.mem_fibre_iff },\n { intros a _, exact discrete_quotient.equiv_bot.symm a },\n { intros, apply finset.mem_univ },\n { intros, apply equiv.symm_apply_apply },\n { intros, apply equiv.apply_symm_apply }\n end }\n\nlemma continuous_Radon_LC (S : cone (X.diagram ⋙ Radon_LC_functor p c)) :\n continuous (Radon_LC X p c S) :=\nbegin\n apply continuous.subtype_mk,\n apply weak_dual.continuous_of_continuous_eval,\n intros e, dsimp [weak_dual, linear_map],\n refine continuous.comp (weak_dual.eval_continuous _) _,\n refine continuous.comp continuous_subtype_coe (continuous_map.continuous _),\nend\n\nend is_limit_Radon_LC_cone\n\n/-- `X.Radon_LC_cone p c` is a limit cone, as promised. -/\ndef is_limit_Radon_LC_cone (X : Profinite.{0}) (p c : ℝ≥0) [fact (0 < p)] [fact (p ≤ 1)] :\n is_limit (X.Radon_LC_cone p c) :=\n{ lift := λ S, ⟨is_limit_Radon_LC_cone.Radon_LC X p c S,\n is_limit_Radon_LC_cone.continuous_Radon_LC X p c S⟩,\n fac' := begin\n intros S T, ext t e,\n dsimp [Radon_LC_cone, Radon_LC_functor, map_Radon_LC,\n is_limit_Radon_LC_cone.weak_dual, is_limit_Radon_LC_cone.Radon_LC,\n weak_dual.comap, is_limit_Radon_LC_cone.linear_map],\n let W₁ := ((continuous_map.comap_LC (X.as_limit_cone.π.app T)) e).discrete_quotient,\n let W := W₁ ⊓ T,\n let π₁ : W ⟶ W₁ := hom_of_le inf_le_left,\n let π₂ : W ⟶ T := hom_of_le inf_le_right,\n rw [← S.w π₁, ← S.w π₂],\n dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap],\n congr' 1, ext ⟨⟩, refl,\n end,\n uniq' := begin\n intros S m hm,\n ext t T,\n specialize hm T.discrete_quotient,\n apply_fun (λ e, (e t).1 T.locally_constant_lift) at hm,\n convert hm using 1,\n dsimp [is_limit_Radon_LC_cone.Radon_LC, is_limit_Radon_LC_cone.weak_dual,\n Radon_LC_cone, Radon_LC_functor, map_Radon_LC, weak_dual.comap],\n congr' 1, ext, refl,\n end }\n\n.\n\ninstance compact_space_Radon_LC_of_discrete_quotient (X : Profinite.{0}) (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)] (T : discrete_quotient X) :\n compact_space (Radon_LC (X.diagram.obj T) p c) :=\nbegin\n change compact_space ((X.diagram ⋙ Radon_LC_functor p c).obj T),\n let e := Top.homeo_of_iso ((Radon_LC_comparison X p c).app T),\n haveI : compact_space\n ((X.fintype_diagram ⋙ real_measures.functor p ⋙ CompHausFiltPseuNormGrp₁.level.obj c\n ⋙ CompHaus_to_Top).obj T),\n { change compact_space ((X.fintype_diagram ⋙ real_measures.functor p\n ⋙ CompHausFiltPseuNormGrp₁.level.obj c).obj T), apply_instance },\n exact e.symm.compact_space,\nend\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_CompHaus_diagram (X : Profinite.{0}) (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)] :\n discrete_quotient X ⥤ CompHaus.{0} :=\n{ obj := λ T, CompHaus.of $ (X.diagram.obj T).Radon_LC p c,\n map := λ S T e, (Radon_LC_functor p c).map $ X.diagram.map e,\n map_id' := begin\n intros T,\n rw X.diagram.map_id,\n rw (Radon_LC_functor p c).map_id,\n refl,\n end,\n map_comp' := begin\n intros S T W f g,\n rw X.diagram.map_comp,\n rw (Radon_LC_functor p c).map_comp,\n refl,\n end }\n\ninstance compact_space_Radon_LC (X : Profinite.{0}) (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)] :\n compact_space (X.Radon_LC p c) :=\nbegin\n let e₁ : X.Radon_LC p c ≅ limit (X.diagram ⋙ Radon_LC_functor p c) :=\n (X.is_limit_Radon_LC_cone p c).cone_point_unique_up_to_iso (limit.is_limit _),\n let e₂ :\n CompHaus_to_Top.obj (limit $ X.Radon_LC_CompHaus_diagram p c) ≅\n limit (X.diagram ⋙ Radon_LC_functor p c) :=\n (is_limit_of_preserves CompHaus_to_Top (limit.is_limit _)).cone_point_unique_up_to_iso\n (limit.is_limit _),\n let e := Top.homeo_of_iso (e₂ ≪≫ e₁.symm),\n haveI : compact_space\n (CompHaus_to_Top.obj (limit $ X.Radon_LC_CompHaus_diagram p c)),\n { show compact_space ↥((limit $ X.Radon_LC_CompHaus_diagram p c)), apply_instance },\n exact e.compact_space,\nend\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_CompHaus_functor (p c : ℝ≥0)\n [fact (0 < p)] [fact (p ≤ 1)] :\n Profinite.{0} ⥤ CompHaus.{0} :=\n{ obj := λ X, CompHaus.of $ X.Radon_LC p c,\n map := λ X Y f, (Radon_LC_functor p c).map f,\n map_id' := (Radon_LC_functor p c).map_id,\n map_comp' := λ X Y Z f g, (Radon_LC_functor p c).map_comp f g }\n\n/--\nThis is the cone which will exhibit `X.Radon_LC p c` as the limit of `T.Radon_LC p c`\nwhere `T` varies over the discrete quotients of `X`.\nThis is a variant of `X.Radon_LC_cone` taking values in `CompHaus` as opposed to `Top`.\n-/\ndef Radon_LC_CompHaus_cone (X : Profinite.{0}) (p c : ℝ≥0) [fact (0 < p)] [fact (p ≤ 1)] :\n cone (X.diagram ⋙ Radon_LC_CompHaus_functor p c) :=\n(Radon_LC_CompHaus_functor p c).map_cone X.as_limit_cone\n\n/--\n`X.Radon_LC_CompHaus_cone p c` is a limit cone, as promised.\nThis is another key construction which will be used in the main comparison between\nRadon measures and `ℳ_p`.\n-/\ndef is_limit_Radon_LC_CompHaus_cone (X : Profinite.{0}) (p c : ℝ≥0) [fact (0 < p)] [fact (p ≤ 1)] :\n is_limit (X.Radon_LC_CompHaus_cone p c) :=\nbegin\n apply is_limit_of_reflects CompHaus_to_Top,\n apply is_limit_Radon_LC_cone,\nend\n\nend Profinite\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/Radon/LC_limit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.41869690935568665, "lm_q1q2_score": 0.21261925810785232}} {"text": "import tactic\nimport tactic.induction\n\nimport .base .bounded .determinacy .induct\n\nnoncomputable theory\nopen_locale classical\n\ndef A_trapped_in_for {pw : ℕ} (a : A pw) (d : D) (B : set Point) :=\nall_b a d (λ b, b.A ∈ B)\n\nlemma exi_ma_inf_n_of_exi_A {pw : ℕ} {d : D} {s s' : State} {hs}\n (h₁ : ∀ (n : ℕ), ∃ (a : A pw), ((init_game a d s).play n).act)\n (h₂ : s' = apply_D_move s (d.f s hs).m) :\n ∃ (ma : Valid_A_move pw s'.board),\n {n : ℕ | ∃ (a : A pw) hs' hvm, a.f s' hs' hvm = ma ∧\n ((init_game a d s).play n).act}.infinite :=\nbegin\n fapply exi_set_infinite_of_forall_exi_P_nat, rintro n,\n obtain ⟨a, h₃⟩ := h₁ n, obtain ⟨a₁, h₄⟩ := h₁ 1, have hs' : s'.act,\n { subst h₂, assumption },\n have hvm : A_has_valid_move pw s'.board,\n { rw [play_1, play_move_at_act] at h₄, swap, { assumption },\n have h₅ : play_D_move_at (init_game a₁ d s) hs = init_game a₁ d s',\n { subst h₂, refl },\n rw [h₅, play_A_move_at] at h₄, clear h₅, split_ifs at h₄ with h₅,\n { exact h₅.2 },\n { cases h₄ }},\n exact ⟨a.f s' hs' hvm, a, hs', hvm, rfl, h₃⟩,\nend\n\nlemma exi_A_forall_n_play_act_of_swap {pw : ℕ} {d : D} {s : State}\n (h : ∀ (n : ℕ), ∃ (a : A pw), ((init_game a d s).play n).act) :\n ∃ (a : A pw), ∀ (n : ℕ), ((init_game a d s).play n).act :=\nbegin\n apply @exi_A_wins_of_invariant (λ s, ∀ (n : ℕ), ∃ (a : A pw),\n ((init_game a d s).play n).act); assumption <|> clear h; dsimp,\n { rintro s h₁, specialize h₁ 0, exact h₁.some_spec },\n { rintro s s' hs h₁ h₂, obtain ⟨ma, hma⟩ := exi_ma_inf_n_of_exi_A h₁ h₂,\n use ma, rintro n, obtain ⟨k, h₃, a, hs', hvm, hh, h₄⟩ := exi_ge_of_set_inf hma,\n use a, convert_to ((init_game a d s).play (n + 1)).act,\n { rw [play_add', play_1], congr, symmetry, ext,\n { exact play_move_at_players_eq.1 },\n { exact play_move_at_players_eq.2 },\n { have h₅ := act_of_act_play h₄, rw play_move_at_act h₅,\n have h₆ : play_D_move_at (init_game a d s) h₅ = init_game a d s',\n { ext; try { refl }, exact h₂.symm },\n rw [h₆, play_A_move_at, dif_pos], clear h₆, swap, { exact ⟨hs', hvm⟩ },\n change apply_A_move s' (a.f s' _ _).m = apply_A_move s' ma.m, congr' }},\n exact act_play_le h₃ h₄ },\nend\n\nlemma D_wins_n_of_D_hws {pw : ℕ}\n (h : D_hws pw) :\n ∃ (n : ℕ) (d : D), ∀ (a : A pw),\n D_wins_in a d n :=\nbegin\n contrapose! h, rw forall_swap at h, change ∀ (d : D) (n : ℕ), _ at h,\n simp_rw [D_wins_in, simulate] at h, push_neg at h, rw [D_hws, D_hws_at],\n push_neg, intro d, specialize h d,\n replace h : ∀ (n : ℕ), ∃ (a : A pw), ((init_game a d state₀).play n).act,\n { intro n, specialize h n, cases h with a h, use a, rcases h with ⟨k, h₁, h₂⟩,\n obtain ⟨k, rfl⟩ := nat.exists_eq_add_of_le h₁, apply act_play_le h₁ h₂ },\n simp_rw Game.D_wins, push_neg, exact exi_A_forall_n_play_act_of_swap h,\nend\n\nlemma A_bounded_n_pw {pw n k : ℕ} {a : A pw} {d : D}\n (h : k ≤ n) :\n (simulate a d k).s.board.A ∈ bounded (n * pw) :=\nbegin\n induction k with k ih generalizing n,\n { apply nat.zero_le },\n { rw simulate at ih ⊢, rw play_at_succ',\n let g₁ : Game pw := _, change (init_game a d state₀).play k with g₁ at ih ⊢,\n rw Game.play_move, split_ifs with h₁, swap, { exact ih (nat.le_of_succ_le h) },\n rw play_A_move_at, split_ifs with h₂,\n { let s' := (play_D_move_at g₁ h₁).s,\n change (apply_A_move_b s'.board (g₁.a.f _ _ _).m).A ∈ _,\n rw apply_A_move_b, dsimp, generalize_proofs h₃,\n let ma := g₁.a.f s' h₁ h₃, change ma.m ∈ _, have h₄ := ma.h.2.1,\n have h₅ : s'.board.A = g₁.s.board.A := apply_D_move_A_eq,\n rw h₅ at h₄, clear h₅, cases n, { cases h }, rw nat.succ_le_succ_iff at h,\n specialize ih h, change _ ≤ _ at ih, change _ ≤ _, rw nat.succ_mul,\n transitivity dist ma.m g₁.s.board.A + dist g₁.s.board.A center,\n { exact dist_triangle },\n { rw add_comm, exact add_le_add ih h₄ }},\n { have h₃ : (play_D_move_at g₁ h₁).finish.s.board.A = g₁.s.board.A,\n { exact apply_D_move_A_eq },\n rw h₃, exact ih (nat.le_of_succ_le h) }},\nend\n\nlemma lem_2_1 {pw : ℕ}\n (h : D_hws pw) :\n ∃ (N : ℕ) (d : D), ∀ (a : A pw),\n A_trapped_in_for a d (bounded N) :=\nbegin\n obtain ⟨n, d, h₁⟩ := D_wins_n_of_D_hws h,\n use [n * pw, d], intro a, specialize h₁ a, intro k,\n have h₂ := h₁ _ (le_refl _), by_cases h₃ : n ≤ k,\n { have h₄ := h₁ _ h₃, have h₅ := simulate_eq_of_not_act h₄ h₂,\n rw h₅, clear' k h₁ h₂ h₃ h₄ h₅, exact A_bounded_n_pw (le_refl _) },\n { push_neg at h₃, exact A_bounded_n_pw (le_of_lt h₃) },\nend", "meta": {"author": "user7230724", "repo": "lean-projects", "sha": "ab9a83874775efd18f8c5b867e480bae4d596b31", "save_path": "github-repos/lean/user7230724-lean-projects", "path": "github-repos/lean/user7230724-lean-projects/lean-projects-ab9a83874775efd18f8c5b867e480bae4d596b31/src/ap/lemma_2_1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.38861802670584894, "lm_q1q2_score": 0.21247230174906315}} {"text": "import data.cpi.transition.basic\n\nnamespace cpi\nnamespace transition\n\nvariables {ℍ : Type} {ω : context}\nopen_locale congruence\n\nopen species.equiv\n\nprivate def no_rename_zero {Γ} {n} {p : upair (fin n)} {q : upair (name Γ)}\n : upair.map name.extend q ≠ upair.map name.zero p\n := upair.rec_on q\n\n (λ a b eql, begin\n rcases upair.exists_rep p with ⟨ a', b', ⟨ _ ⟩ ⟩,\n rcases quotient.exact eql with ⟨ l, _ ⟩ | ⟨ l, _ ⟩; cases l\n end)\n (λ a b, function.hfunext (by rw upair.mk.comm) (λ a₂ b₂ _, heq.rfl))\n\nprivate def on_parallel_assoc₁_left {Γ ℓ} {A B C : species ℍ ω Γ} :\n ∀ {α : label ℍ Γ kind.species} {E : species ℍ ω Γ}\n , (A |ₛ B) [ℓ, α]⟶ (production.species E)\n → Σ' E' (eq : production.species (E |ₛ C) ≈ E')\n , (A |ₛ B |ₛ C) [ℓ, α]⟶ E'\n| α E (@com₁ _ _ _ _ x y _ _ a b F G _ _ rfl rfl tf tg) :=\n ⟨ _, production.equiv.species (symm (concretion.pseudo_apply.on_parallel₁ _ _ C)),\n com₁ rfl rfl tf (parL_concretion C tg) ⟩\n| α E (parL_species C t) :=\n ⟨ _, production.equiv.species parallel_assoc₁, parL_species _ t ⟩\n| α E (parR_species _ t) :=\n ⟨ _, production.equiv.species equiv.parallel_assoc₁, parR_species _ (parL_species _ t) ⟩\n\nprivate def on_parallel_assoc₁ {Γ ℓ} {A B C : species ℍ ω Γ} :\n ∀ {k} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , ((A |ₛ B) |ₛ C) [ℓ, α]⟶ E\n → Σ' E' (eq : E ≈ E'), (A |ₛ B |ₛ C) [ℓ, α]⟶ E'\n| k α E (@com₁ _ _ _ _ x y _ _ a b _ G _ _ rfl rfl (parL_concretion D tf) tg) :=\n ⟨ _, production.equiv.species (concretion.pseudo_apply.parallel_shift _ B G),\n com₁ rfl rfl tf (parR_concretion _ tg) ⟩\n| k α E (@com₁ _ _ _ _ x y _ _ a b _ G _ _ rfl rfl (parR_concretion D tf) tg) :=\n ⟨ _, production.equiv.species (concretion.pseudo_apply.on_parallel₂' A _ G),\n parR_species A (com₁ rfl rfl tf tg) ⟩\n| k α E (parL_species _ t) := on_parallel_assoc₁_left t\n| k α E (parL_concretion B (parL_concretion C t)) :=\n ⟨ _, production.equiv.concretion concretion.equiv.parallel_assoc₁, parL_concretion _ t ⟩\n| k α E (parL_concretion C (parR_concretion D t)) :=\n ⟨ _, production.equiv.concretion concretion.equiv.parallel_assoc₂, parR_concretion _ (parL_concretion _ t) ⟩\n| k α E (parR_species D t) :=\n ⟨ _, production.equiv.species equiv.parallel_assoc₁, parR_species A (parR_species B t) ⟩\n| k α E (parR_concretion D t) :=\n ⟨ _, production.equiv.concretion concretion.equiv.parallel_assoc₃, parR_concretion A (parR_concretion B t) ⟩\n\nprivate def on_parallel_symm {Γ ℓ} {A B : species ℍ ω Γ} :\n ∀ {k} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , (A |ₛ B) [ℓ, α]⟶ E\n → Σ' E' (eq : E ≈ E'), (B |ₛ A) [ℓ, α]⟶ E'\n| ._ ._ ._ (@com₁ _ _ _ _ x y _ _ a b F G _ _ rfl rfl tf tg) := begin\n rw upair.eq a b,\n from ⟨ _, production.equiv.species (concretion.pseudo_apply.symm F G), com₁ rfl rfl tg tf ⟩\n end\n| k α ._ (parL_species _ t) := ⟨ _, production.equiv.species parallel_symm, parR_species B t ⟩\n| k α ._ (parL_concretion _ t) := ⟨ _, production.equiv.concretion concretion.equiv.parallel_symm, parR_concretion B t ⟩\n| k α ._ (parR_species _ t) := ⟨ _, production.equiv.species parallel_symm, parL_species A t ⟩\n| k α ._ (parR_concretion _ t) := ⟨ _, production.equiv.concretion (symm concretion.equiv.parallel_symm), parL_concretion A t ⟩\n\nprivate def on_parallel_assoc₂_species {Γ ℓ} {A B C : species ℍ ω Γ} :\n ∀ {α : label ℍ Γ kind.species} {E : species ℍ ω Γ}\n , (B |ₛ C) [ℓ, α]⟶ (production.species E)\n → Σ' (E' : production ℍ ω Γ kind.species) (eq : production.species (A |ₛ E) ≈ E')\n , ((A |ₛ B) |ₛ C) [ℓ, α]⟶ E'\n| α E (parL_species _ t) :=\n ⟨ _, production.equiv.species equiv.parallel_assoc₂, parL_species _ (parR_species _ t) ⟩\n| α E (parR_species _ t) :=\n ⟨ _, production.equiv.species equiv.parallel_assoc₂, parR_species _ t ⟩\n| α E (com₁ rfl rfl tf tg) :=\n ⟨ _, production.equiv.species (concretion.pseudo_apply.on_parallel₂' A _ _).symm,\n com₁ rfl rfl (parR_concretion _ tf) tg ⟩\n\nprivate def on_parallel_assoc₂_concretion {Γ ℓ} {A B C : species ℍ ω Γ} {b y} :\n ∀ {α : label ℍ Γ kind.concretion} {E : concretion ℍ ω Γ b y}\n , (B |ₛ C) [ℓ, α]⟶ (production.concretion E)\n → Σ' (E' : production ℍ ω Γ kind.concretion) (eq : production.concretion (A |₂ E) ≈ E')\n , ((A |ₛ B) |ₛ C) [ℓ, α]⟶ E'\n| α E (parL_concretion _ t) :=\n ⟨ _, production.equiv.concretion concretion.equiv.parallel_assoc₂.symm\n , parL_concretion _ (parR_concretion _ t) ⟩\n| α E (parR_concretion _ t) :=\n ⟨ _, production.equiv.concretion concretion.equiv.parallel_assoc₃.symm, parR_concretion _ t ⟩\n\nprivate def on_parallel_assoc₂ {Γ ℓ} {A B C : species ℍ ω Γ} :\n ∀ {k} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , (A |ₛ B |ₛ C) [ℓ, α]⟶ E\n → Σ' E' (eq : E ≈ E'), ((A |ₛ B) |ₛ C) [ℓ, α]⟶ E'\n| ._ α E (@com₁ _ _ _ _ x y _ _ a b F G _ _ rfl rfl tf (parL_concretion _ tg)) :=\n ⟨ _, production.equiv.species (concretion.pseudo_apply.on_parallel₁ F _ C),\n parL_species _ (com₁ rfl rfl tf tg) ⟩\n| ._ α E (@com₁ _ _ _ _ x y _ _ a b F G _ _ rfl rfl tf (parR_concretion _ tg)) :=\n ⟨ _, production.equiv.species (concretion.pseudo_apply.parallel_shift F B _).symm,\n com₁ rfl rfl (parL_concretion _ tf) tg ⟩\n| k α ._ (parL_species _ t) :=\n ⟨ _, production.equiv.species equiv.parallel_assoc₂, parL_species _ (parL_species _ t) ⟩\n| k α ._ (parL_concretion _ t) :=\n ⟨ _, production.equiv.concretion concretion.equiv.parallel_assoc₁.symm, parL_concretion _ (parL_concretion _ t) ⟩\n| k α ._ (parR_species _ t) := on_parallel_assoc₂_species t\n| k α ._ (parR_concretion _ t) := on_parallel_assoc₂_concretion t\n\nprivate def on_choice_swap {Γ ℓ} {As : choices ℍ ω Γ} :\n ∀ {k f g} {α : label ℍ Γ k}\n {π₁ : prefix_expr ℍ Γ f} {π₂ : prefix_expr ℍ Γ g}\n {A : species ℍ ω (f.apply Γ)} {B : species ℍ ω (g.apply Γ)}\n {E : production ℍ ω Γ k}\n , (Σ# whole.cons π₁ A (whole.cons π₂ B As)) [ℓ, α]⟶ E\n → Σ' E' (eq : E ≈ E')\n , (Σ# whole.cons π₂ B (whole.cons π₁ A As)) [ℓ, α]⟶ E'\n| ._ α f g π₁ π₂ A B E (choice₁ a b b_len y _ _) := ⟨ _, refl _, ξ_choice (choice₁ a b b_len y _ _) ⟩\n| ._ α f g π₁ π₂ A B E (choice₂ k _ _) := ⟨ _, refl _, ξ_choice (choice₂ k _ _) ⟩\n| ._ α f g π₁ π₂ A B E (ξ_choice (choice₁ a b b_len y _ _)) := ⟨ _, refl _, choice₁ a b b_len y _ _ ⟩\n| ._ α f g π₁ π₂ A B E (ξ_choice (choice₂ k _ _)) := ⟨ _, refl _, choice₂ k _ _ ⟩\n| k α f g π₁ π₂ A B E (ξ_choice (ξ_choice t)) := ⟨ _, refl _, ξ_choice (ξ_choice t) ⟩\n\nprivate def on_ν_parallel₂ {Γ ℓ} {M : affinity ℍ} {A : species ℍ ω Γ} {B : species ℍ ω (context.extend (M.arity) Γ)} :\n ∀ {k} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , (A |ₛ ν(M) B) [ℓ, α]⟶ E\n → Σ' E' (eq : E ≈ E'), (ν(M) rename name.extend A |ₛ B) [ℓ, α]⟶ E'\n| ._ ._ _ (com₁ rfl rfl tf (ν₁_concretion M rfl tg)) :=\n -- Slighty bizzare, but the separate binding helps this to TC\n let tf' := transition.rename (@name.extend _ M.arity) tf in\n ⟨ _, production.equiv.species (concretion.pseudo_apply.on_restriction _ _ _),\n ν₁_species M rfl (com₁ rfl rfl tf' tg) ⟩\n| k α _ (parL_species E t) :=\n let t' := transition.rename (@name.extend _ M.arity) t in\n ⟨ _, production.equiv.species (ν_parallel₂ M), ν₁_species M rfl (parL_species _ t' ) ⟩\n| k α _ (parL_concretion E t) :=\n let t' := transition.rename (@name.extend _ M.arity) t in\n ⟨ _, production.equiv.concretion (concretion.equiv.ν_parallel₂ M).symm,\n ν₁_concretion M rfl (parL_concretion _ t' ) ⟩\n\n| k α _ (parR_species A (com₂ M k' ek rfl t)) :=\n ⟨ _, production.equiv.species (ν_parallel₂ M), com₂ M k' ek rfl (parR_species _ t) ⟩\n| k α _ (parR_species A (ν₁_species _ rfl t)) :=\n ⟨ _, production.equiv.species (ν_parallel₂ M), ν₁_species M rfl (parR_species _ t) ⟩\n| k α _ (parR_concretion A (ν₁_concretion _ rfl t)) :=\n ⟨ _, production.equiv.concretion (concretion.equiv.ν_parallel₁ M).symm,\n ν₁_concretion M rfl (parR_concretion _ t) ⟩\n\nprivate def upair_extend {n} {Γ} :\n ∀ {p : upair (name Γ)} {a b : name (context.extend n Γ)}\n , upair.map name.extend p = upair.mk a b\n → Σ' (a' b' : name Γ), p = upair.mk a' b' ∧ a = name.extend a' ∧ b = name.extend b'\n| p (name.zero _) (name.zero _) e := false.elim (begin\n rcases quot.exists_rep p with ⟨ ⟨ a, b ⟩, ep ⟩, have : upair.mk a b = p := ep, subst this,\n rcases quotient.exact e with ⟨ l, r ⟩ | ⟨ l, r ⟩; contradiction,\nend)\n| p (name.zero _) (name.extend _) e := false.elim (begin\n rcases quot.exists_rep p with ⟨ ⟨ a, b ⟩, ep ⟩, have : upair.mk a b = p := ep, subst this,\n rcases quotient.exact e with ⟨ l, r ⟩ | ⟨ l, r ⟩; contradiction,\nend)\n| p (name.extend _) (name.zero _) e := false.elim (begin\n rcases quot.exists_rep p with ⟨ ⟨ a, b ⟩, ep ⟩, have : upair.mk a b = p := ep, subst this,\n rcases quotient.exact e with ⟨ l, r ⟩ | ⟨ l, r ⟩; contradiction,\nend)\n| p (name.extend a) (name.extend b) e := ⟨ a, b, begin\n have : upair.map name.extend p = upair.map name.extend (upair.mk a b) := e,\n from ⟨ upair.map.inj (@name.extend.inj _ _) this, rfl, rfl ⟩,\nend ⟩\n\nprivate noncomputable def on_ν_parallel₁_species {Γ ℓ} {M : affinity ℍ} {A : species ℍ ω Γ}\n {B : species ℍ ω (context.extend M.arity Γ)} :\n ∀ {A' : species ℍ ω (context.extend (M.arity) Γ)}\n {α' : label ℍ (context.extend M.arity Γ) kind.species}\n {α : label ℍ Γ kind.species}\n {E : species ℍ ω (context.extend M.arity Γ)}\n , (A' |ₛ B) [lookup.rename name.extend ℓ, α']⟶ (production.species E)\n → A' = rename name.extend A → α' = label.rename name.extend α\n → Σ' E' (eq : production.species (ν(M)E) ≈ E')\n , (A |ₛ ν(M) B) [ℓ, α]⟶ E'\n| A' α' α E (parL_species _ t) eqA eqα := begin\n subst eqA, subst eqα,\n rcases transition.rename_from name.extend t with ⟨ α₂, ⟨ B ⟩, t₂, eα, eB ⟩,\n cases label.rename.inj (@name.extend.inj _ _) eα,\n rw ← production.species.inj eB,\n from ⟨ _, production.equiv.species (ν_parallel₁ M), parL_species _ t₂ ⟩,\nend\n| A' α' α E (parR_species _ t) eqA eqα := begin\n subst eqA, subst eqα,\n from ⟨ _, production.equiv.species (ν_parallel₁ M), parR_species _ (ν₁_species M rfl t) ⟩,\nend\n| A' α' α E (@com₁ _ _ _ _ x y _ _ a b F G _ _ rfl eα tf tg) eqA eqα := begin\n subst eqA, subst eqα,\n\n cases α with _ _ _ _ _ p,\n case label.spontaneous { cases eα },\n\n rcases upair_extend (label.of_affinity.inj eα) with ⟨ a, b, ⟨ _ ⟩, ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n rcases transition.rename_from name.extend tf with ⟨ ⟨ a₂ ⟩, ⟨ F ⟩, tf₂, ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n\n from ⟨ _, production.equiv.species (concretion.pseudo_apply.on_restriction _ M _).symm,\n com₁ rfl rfl tf₂ (ν₁_concretion M rfl tg) ⟩,\nend\n\nprivate noncomputable def on_ν_parallel₁_concretion {Γ ℓ} {M : affinity ℍ} {A : species ℍ ω Γ}\n {B : species ℍ ω (context.extend M.arity Γ)} {b y} :\n ∀ {A' : species ℍ ω (context.extend (M.arity) Γ)}\n {α' : label ℍ (context.extend M.arity Γ) kind.concretion}\n {α : label ℍ Γ kind.concretion}\n {E : concretion ℍ ω (context.extend M.arity Γ) b y}\n , (A' |ₛ B) [lookup.rename name.extend ℓ, α']⟶ (production.concretion E)\n → A' = rename name.extend A → α' = label.rename name.extend α\n → Σ' E' (eq : production.concretion (ν'(M)E) ≈ E')\n , (A |ₛ ν(M) B) [ℓ, α]⟶ E'\n| A' α' α E (parL_concretion _ t) eqA eqα := begin\n subst eqA, subst eqα,\n rcases transition.rename_from name.extend t with ⟨ α₂, ⟨ B ⟩, t₂, eα, ⟨ _ ⟩ ⟩,\n cases label.rename.inj (@name.extend.inj _ _) eα,\n from ⟨ _, production.equiv.concretion (concretion.equiv.ν_parallel₂ M), parL_concretion _ t₂ ⟩,\nend\n| A' α' α E (parR_concretion _ t) eqA eqα := begin\n subst eqA, subst eqα,\n from ⟨ _, production.equiv.concretion (concretion.equiv.ν_parallel₁ M), parR_concretion _ (ν₁_concretion M rfl t) ⟩,\nend\n\nprivate noncomputable def on_ν_parallel₁ {Γ ℓ} {M : affinity ℍ} {A : species ℍ ω Γ}\n {B : species ℍ ω (context.extend (M.arity) Γ)} :\n ∀ {k} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , (ν(M) rename name.extend A |ₛ B) [ℓ, α]⟶ E\n → Σ' E' (eq : E ≈ E'), (A |ₛ ν(M) B) [ℓ, α]⟶ E'\n| k α ._ (ν₁_species M rfl t) := on_ν_parallel₁_species t rfl rfl\n| k α ._ (ν₁_concretion M rfl t) := on_ν_parallel₁_concretion t rfl rfl\n| ._ α ._ (@com₂ _ _ _ _ M p q _ _ k ek rfl t) := begin\n generalize eqA : species.rename (@name.extend _ M.arity) A = A', rw eqA at t,\n\n cases t,\n case parL_species : E t {\n subst eqA, exfalso,\n rcases transition.rename_from name.extend t with ⟨ α₂, ⟨ E ⟩, tf₂, eα, eE ⟩, -- Annoying!\n\n cases α₂; simp only [label.rename] at eα,\n case label.spontaneous { cases eα },\n from absurd eα no_rename_zero,\n },\n case parR_species : E t {\n subst eqA,\n from ⟨ _, production.equiv.species (ν_parallel₁ M), parR_species _ (com₂ M k ek rfl t ) ⟩,\n },\n case com₁ : x y a b F G eF eα tf tg {\n subst eqA, exfalso,\n\n rcases transition.rename_from name.extend tf with ⟨ α₂, ⟨ E ⟩, tf₂, eα', eE ⟩, -- Annoying!\n cases α₂, simp only [label.rename] at eα', subst eα',\n\n rcases upair.exists_rep p with ⟨ p₁, p₂, h ⟩, subst h,\n rcases quotient.exact (label.of_affinity.inj eα) with ⟨ l, r ⟩ | ⟨ l, r ⟩; contradiction,\n }\nend\n\nprivate noncomputable def on_ν_drop₁ {Γ ℓ} {M : affinity ℍ} {A : species ℍ ω Γ} :\n ∀ {k} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , (ν(M) species.rename name.extend A) [ℓ, α]⟶ E\n → Σ' (E' : production ℍ ω Γ k) (eq : E ≈ E'), A [ℓ, α]⟶ E'\n| k α E t := begin\n generalize eqA : species.rename (@name.extend _ M.arity) A = A', rw eqA at t,\n\n cases t,\n case com₂ : a b B k eqk eqα t' {\n subst eqA, subst eqα, exfalso,\n\n rcases transition.rename_from name.extend t' with ⟨ α₂, ⟨ E₂ ⟩ , t₂, eqα, eqE ⟩,\n cases α₂; simp only [label.rename] at eqα,\n case label.spontaneous { cases eqα },\n from absurd eqα no_rename_zero,\n },\n case ν₁_species : α₁ α₂ E eα t' {\n subst eqA, subst eα,\n rcases transition.rename_from name.extend t' with ⟨ α₂, ⟨ E₂ ⟩ , t₂, eqα, eqE ⟩,\n cases label.rename.inj (@name.extend.inj _ _) eqα,\n rw ← production.species.inj eqE,\n from ⟨ _, production.equiv.species (ν_drop₁ M), t₂ ⟩,\n },\n case ν₁_concretion : α₁ α₂ b y E eα t' {\n subst eqA, subst eα,\n rcases transition.rename_from name.extend t' with ⟨ α₂, ⟨ E₂ ⟩ , t₂, eqα, ⟨ _ ⟩ ⟩,\n cases label.rename.inj (@name.extend.inj _ _) eqα,\n from ⟨ _, production.equiv.concretion (concretion.equiv.ν_drop M), t₂ ⟩,\n }\nend\n\nprivate def on_ν_drop₂ {Γ ℓ} {M : affinity ℍ} {A : species ℍ ω Γ} :\n ∀ {k} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , A [ℓ, α]⟶ E\n → Σ' (E' : production ℍ ω Γ k) (eq : E ≈ E'), (ν(M) species.rename name.extend A) [ℓ, α]⟶ E'\n| k α (production.species E) t :=\n let t' := transition.rename (@name.extend _ M.arity) t in\n ⟨ _, production.equiv.species (ν_drop₂ M), ν₁_species M rfl t' ⟩\n| k α (production.concretion E) t :=\n let t' := transition.rename (@name.extend _ M.arity) t in\n ⟨ _, production.equiv.concretion (concretion.equiv.ν_drop M).symm, ν₁_concretion M rfl t' ⟩\n\nprivate def on_ν_swap₁ {Γ ℓ} {M N : affinity ℍ} {A : species ℍ ω (context.extend (N.arity) (context.extend (M.arity) Γ))} :\n ∀ {k} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , (ν(M) ν(N) A) [ℓ, α]⟶ E\n → Σ' (E' : production ℍ ω Γ k) (eq : E ≈ E')\n , (ν(N) ν(M) species.rename name.swap A) [ℓ, α]⟶ E'\n| ._ α E₁ (ν₁_species _ eα₁ (ν₁_species _ eα₂ t)) := begin\n subst eα₁, subst eα₂,\n have t' := transition.rename name.swap t,\n rw [label.rename_compose, label.rename_compose, name.swap_comp_extend, name.ext_extend, ← label.rename_compose] at t',\n rw [lookup.rename_compose, lookup.rename_compose, name.swap_comp_extend, name.ext_extend, ← lookup.rename_compose] at t',\n from ⟨ _, production.equiv.species (ν_swap₁ M N), ν₁_species N rfl (ν₁_species M rfl t' ) ⟩,\nend\n| ._ α E₁ (ν₁_species _ eα (com₂ _ k ek rfl t)) := begin\n cases α; simp only [label.rename] at eα,\n case label.of_affinity { contradiction },\n subst eα,\n\n have t' := transition.rename name.swap t,\n rw [lookup.rename_compose, lookup.rename_compose, name.swap_comp_extend, name.ext_extend, ← lookup.rename_compose] at t',\n refine ⟨ _, production.equiv.species (ν_swap₁ M N), com₂ N k ek rfl (ν₁_species M _ t') ⟩,\n\n simp only [label.rename, upair.map_compose, function.comp, name.swap],\nend\n| ._ α E₁ (ν₁_concretion _ rfl (ν₁_concretion _ rfl t)) := begin\n have t' := transition.rename name.swap t,\n rw [label.rename_compose, label.rename_compose, name.swap_comp_extend, name.ext_extend, ← label.rename_compose] at t',\n rw [lookup.rename_compose, lookup.rename_compose, name.swap_comp_extend, name.ext_extend, ← lookup.rename_compose] at t',\n from ⟨ _, production.equiv.concretion (concretion.equiv.ν_swap M N), ν₁_concretion N rfl (ν₁_concretion M rfl t' ) ⟩,\nend\n| ._ α E₁ (com₂ _ k ek rfl (ν₁_species _ rfl t)) := begin\n have t' := transition.rename name.swap t,\n rw [lookup.rename_compose, lookup.rename_compose, name.swap_comp_extend, name.ext_extend, ← lookup.rename_compose] at t',\n refine ⟨ _, production.equiv.species (ν_swap₁ M N), ν₁_species N rfl (com₂ M k ek _ t') ⟩,\n\n rw [upair.map_compose, upair.map_compose, name.swap_comp_extend, name.ext_zero],\nend\n\nprivate def on_ν_swap₂ {Γ ℓ} {M N : affinity ℍ} {A : species ℍ ω (context.extend (N.arity) (context.extend (M.arity) Γ))}:\n ∀ {k} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , (ν(N) ν(M) species.rename name.swap A) [ℓ, α]⟶ E\n → Σ' (E' : production ℍ ω Γ k) (eq : E ≈ E'), (ν(M) ν(N) A) [ℓ, α]⟶ E'\n| k α E₁ t := begin\n rcases on_ν_swap₁ t with ⟨ E', eqE, t' ⟩,\n rw [species.rename_compose, name.swap_swap, species.rename_id] at t',\n from ⟨ E', eqE, t' ⟩,\nend\n\n/-- Convert a transition from one species to a transition from another\n equivalent species, with the same label and equivalent production. -/\nnoncomputable def equivalent_of :\n ∀ {Γ ℓ k} {A : species ℍ ω Γ} {B : species ℍ ω Γ} {α : label ℍ Γ k} {E : production ℍ ω Γ k}\n , species.equivalent A B → A [ℓ, α]⟶ E\n → Σ' (E' : production ℍ ω Γ k) (eq : E ≈ E'), B [ℓ, α]⟶ E'\n| Γ₁ ℓ₁ k₁ A₁ B₁ α₁ E₁ equ t₁ := begin\n induction equ generalizing k₁,\n\n case species.equivalent.refl { from ⟨ E₁, refl _, t₁ ⟩ },\n case species.equivalent.trans : Γ A B C ab bc ih_ab ih_bc {\n rcases ih_ab _ _ α₁ E₁ t₁ with ⟨ E₂, eq₂, t₂ ⟩,\n rcases ih_bc _ _ α₁ E₂ t₂ with ⟨ E₃, eq₃, t₃ ⟩,\n from ⟨ E₃, trans eq₂ eq₃, t₃ ⟩\n },\n\n case species.equivalent.ξ_parallel₁ : Γ A A' B eq ih {\n cases t₁,\n case com₁ : x y a b F G E' α' eE eα tf tg {\n subst eE, subst eα,\n rcases ih _ _ (#a) _ tf with ⟨ F', equ, tf' ⟩, cases F' with _ b y' F',\n rcases production.equiv.arity equ with ⟨ ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n\n from ⟨ _, production.equiv.species (concretion.pseudo_apply.equiv (production.equiv.unwrap_c equ) (refl G)),\n com₁ rfl rfl tf' tg ⟩,\n },\n case parL_species : α' E t {\n rcases ih _ _ _ _ t with ⟨ E', equ, t' ⟩, cases E',\n from ⟨ _, production.equiv.species (ξ_parallel₁ (production.equiv.unwrap_s equ)), parL_species B t' ⟩\n },\n case parL_concretion : α' b y E t {\n rcases ih _ _ _ _ t with ⟨ E', equ, t' ⟩, cases E',\n rcases production.equiv.arity equ with ⟨ ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n from ⟨ _, production.equiv.concretion (concretion.equiv.ξ_parallel₁ (production.equiv.unwrap_c equ)),\n parL_concretion _ t' ⟩,\n },\n case parR_species : α' E t {\n from ⟨ _, production.equiv.species (ξ_parallel₁ ⟨ eq ⟩), parR_species _ t ⟩,\n },\n case parR_concretion : α' b y E t {\n from ⟨ _, production.equiv.concretion (concretion.equiv.ξ_parallel' ⟨ eq ⟩), parR_concretion _ t ⟩,\n },\n },\n\n case species.equivalent.ξ_parallel₂ : Γ A B B' eq ih {\n cases t₁,\n case com₁ : x y a b F G E' α' eE eα tf tg {\n subst eE, subst eα,\n rcases ih _ _ (#b) _ tg with ⟨ G', equ, tg' ⟩, cases G' with _ b y' G',\n rcases production.equiv.arity equ with ⟨ ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n from ⟨ _, production.equiv.species (concretion.pseudo_apply.equiv (refl F) (production.equiv.unwrap_c equ)),\n com₁ rfl rfl tf tg' ⟩,\n },\n case parL_species : α' E t {\n from ⟨ _, production.equiv.species (ξ_parallel₂ ⟨ eq ⟩), parL_species _ t ⟩,\n },\n case parL_concretion : α' b y E t {\n from ⟨ _, production.equiv.concretion (concretion.equiv.ξ_parallel ⟨ eq ⟩), parL_concretion _ t ⟩,\n },\n case parR_species : α' E t {\n rcases ih _ _ _ _ t with ⟨ E', equ, t' ⟩, cases E',\n from ⟨ _, production.equiv.species (ξ_parallel₂ (production.equiv.unwrap_s equ)), parR_species _ t' ⟩\n },\n case parR_concretion : α' b y E t {\n rcases ih _ _ _ _ t with ⟨ E', equ, t' ⟩, cases E',\n rcases production.equiv.arity equ with ⟨ ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n from ⟨ _, production.equiv.concretion (concretion.equiv.ξ_parallel₂ (production.equiv.unwrap_c equ)),\n parR_concretion _ t' ⟩,\n },\n },\n\n case species.equivalent.ξ_restriction : Γ M A A' eq ih {\n cases t₁,\n\n case com₂ : p p' B k ek ep t {\n rcases ih _ _ _ _ t with ⟨ E', equ, t' ⟩,\n cases E' with B',\n\n from ⟨ _, production.equiv.species (ξ_restriction M (production.equiv.unwrap_s equ)), com₂ M k ek ep t' ⟩,\n },\n case ν₁_species : α α' E eα t {\n rcases ih _ _ _ _ t with ⟨ E', equ, t' ⟩, cases E',\n from ⟨ _, production.equiv.species (ξ_restriction M (production.equiv.unwrap_s equ)),\n ν₁_species M eα t' ⟩,\n },\n case ν₁_concretion : α α' b y E eα t {\n rcases ih _ _ _ _ t with ⟨ E', equ, t' ⟩, cases E',\n rcases production.equiv.arity equ with ⟨ ⟨ _ ⟩, ⟨ _ ⟩ ⟩,\n from ⟨ _, production.equiv.concretion (concretion.equiv.ξ_restriction M (production.equiv.unwrap_c equ)),\n ν₁_concretion M eα t' ⟩,\n },\n },\n\n case species.equivalent.ξ_choice_here : Γ f π A A' As eq ih {\n cases t₁,\n case ξ_choice : t { refine ⟨ _, refl _, ξ_choice t ⟩ },\n case choice₁ : a n b b_len y {\n from ⟨ _, production.equiv.concretion (concretion.equiv.ξ_apply ⟨ eq ⟩), choice₁ a b b_len y A' As ⟩,\n },\n case choice₂ : k { from ⟨ _, production.equiv.species ⟨ eq ⟩, choice₂ k A' As ⟩ },\n },\n\n case species.equivalent.ξ_choice_there : Γ f π A As As' eq ih {\n cases t₁,\n\n case ξ_choice : t {\n rcases ih _ _ α₁ E₁ t with ⟨ E', equ, t' ⟩,\n refine ⟨ _, equ, ξ_choice t' ⟩,\n },\n case choice₁ : a n b b_len y A As { from ⟨ _, refl _, choice₁ a b b_len y A As' ⟩ },\n case choice₂ : k A As { from ⟨ _, refl _, choice₂ k A As' ⟩ },\n },\n\n case species.equivalent.parallel_nil₁ : Γ A {\n cases t₁,\n\n -- No such transition for (nil ⟶ _)\n case com₁ : x y a b F G FG α eFG eα tf tg { cases tg },\n case parR_species : α E t { cases t },\n case parR_concretion : α b y E t { cases t },\n case parL_species : α E t { from ⟨ _, production.equiv.species parallel_nil₁, t ⟩ },\n case parL_concretion : α b y E t { from ⟨ _, production.equiv.concretion concretion.equiv.parallel_nil, t ⟩ },\n },\n\n case species.equivalent.parallel_nil₂ : Γ B {\n cases E₁,\n case production.species { from ⟨ _, production.equiv.species parallel_nil₂, parL_species _ t₁ ⟩ },\n case production.concretion { from ⟨ _, production.equiv.concretion concretion.equiv.parallel_nil.symm, parL_concretion _ t₁ ⟩ },\n },\n\n case species.equivalent.choice_swap { from on_choice_swap t₁ },\n\n case species.equivalent.parallel_assoc₁ { from on_parallel_assoc₁ t₁ },\n case species.equivalent.parallel_assoc₂ { from on_parallel_assoc₂ t₁ },\n\n case species.equivalent.parallel_symm { from on_parallel_symm t₁ },\n\n case species.equivalent.ν_parallel₁ { from on_ν_parallel₁ t₁ },\n case species.equivalent.ν_parallel₂ { from on_ν_parallel₂ t₁ },\n case species.equivalent.ν_drop₁ { from on_ν_drop₁ t₁ },\n case species.equivalent.ν_drop₂ { from on_ν_drop₂ t₁ },\n case species.equivalent.ν_swap₁ { from on_ν_swap₁ t₁ },\n case species.equivalent.ν_swap₂ { from on_ν_swap₂ t₁ },\nend\n\n/-- Drops the congruence restriction from `equivalent_of`. -/\nnoncomputable def equivalent_of.map {Γ ℓ} {A B : species ℍ ω Γ} (h : species.equivalent A B)\n {k} {α : label ℍ Γ k}\n : (Σ (E : production ℍ ω Γ k), A [ℓ, α]⟶ E)\n → (Σ (E : production ℍ ω Γ k), B [ℓ, α]⟶ E)\n| ⟨ E, t ⟩ :=\n let ⟨ E', _, t' ⟩ := equivalent_of h t in\n ⟨ E', t' ⟩\n\n/-- Show that 'equivalent_of' twice yields the same thing. This is not going to\n be fun. -/\naxiom equivalent_of.map_map {Γ ℓ} {A B : species ℍ ω Γ} (h : species.equivalent A B)\n {k} {α : label ℍ Γ k} (t : Σ (E : production ℍ ω Γ k), A [ℓ, α]⟶ E)\n : equivalent_of.map h.symm (equivalent_of.map h t) = t\n\n/-- Show that two equivalent species's transition sets are equivalent. -/\nnoncomputable def equivalent_of.is_equiv {Γ ℓ} {A B : species ℍ ω Γ} (h : species.equivalent A B)\n {k} {α : label ℍ Γ k}\n : (Σ (E : production ℍ ω Γ k), A [ℓ, α]⟶ E) ≃ (Σ (E : production ℍ ω Γ k), B [ℓ, α]⟶ E)\n := { to_fun := equivalent_of.map h,\n inv_fun := equivalent_of.map h.symm,\n left_inv := equivalent_of.map_map h,\n right_inv := λ x, begin\n have this := equivalent_of.map_map h.symm x,\n rw ← species.equivalent.symm_symm h at this,\n from this,\n end }\n\nlemma equivalent_of.map_equiv {Γ ℓ} {A B : species ℍ ω Γ} (h : species.equivalent A B)\n {k} {α : label ℍ Γ k}\n (E : production ℍ ω Γ k) (t : A [ℓ, α]⟶ E)\n : E ≈ (equivalent_of.map h ⟨ E, t ⟩).1 := begin\n unfold equivalent_of.map,\n rcases (equivalent_of h t) with ⟨ E', eqE, t' ⟩,\n from eqE,\nend\n\nend transition\nend cpi\n\n#lint-\n", "meta": {"author": "continuouspi", "repo": "lean-cpi", "sha": "443bf2cb236feadc45a01387099c236ab2b78237", "save_path": "github-repos/lean/continuouspi-lean-cpi", "path": "github-repos/lean/continuouspi-lean-cpi/lean-cpi-443bf2cb236feadc45a01387099c236ab2b78237/src/data/cpi/transition/equivalence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5195213219520929, "lm_q2_score": 0.4073334000459302, "lm_q1q2_score": 0.21161838646710235}} {"text": "import number_theory.bernoulli\n\n\n--OUTPUT 1\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n induction n with d hd,\n {\n unfold polynomial.bernoulli polynomial.eval,\n by_cases (x = 0),\n {\n replace h : x = 0, from h,\n clear h,\n rw h,\n auto [mul_zero, zero_add],\n },\n {\n have h2 : x ≠ 0, from h,\n have h3 : (1 : ℚ) ≠ 0, from by auto [ne.symm h2],\n have h4 : 1 / x ≠ 0, from by auto [div_ne_zero h3],\n have h5 : x ≠ 0, from ne.symm h,\n have h6 : (1 + x) ≠ 0, from by auto [add_ne_zero],\n have h7 : (1 + x) ≠ 0, from h6,\n have h8 : (1 + x) ≠ 0, from by auto [add_ne_zero],\n have h9 : 1 + x ≠ 0, from h8,\n have h10 : (1 + x) ≠ 0, from by auto [add_ne_zero],\n have h11 : (1 + x) ≠ 0, from by auto [add_ne_zero],\n have h12 : ↑(1 + x) ≠ 0, from h11,\n have h13 : (1 : ℚ) ≠ 0, from by auto [ne.symm h2],\n have h14 : 1 ≠ 0, from h13,\n have h15 : (1 : ℚ) ≠ 0, from by auto [ne.symm h2],\n have h16 : (1 : ℚ) ≠ 0, from by auto [ne.symm h2],\n have h17 : (1 : ℚ) ≠ 0, from by auto [ne.symm h2],\n have h18 : (1 : ℚ) ≠ 0, from by auto [ne.symm h2],\n have h19 : (1 : ℚ) ≠ 0, from by auto [ne.symm h2],\n have h20 : (1 : ℚ) ≠ 0, from by auto [ne.symm h2],\n have h21 : 1 + x ≠ 0, from mul_ne_zero (cast h19) (cast h20),\n have h22 : (1 + x) ≠ 0, from h21,\n have h23 : (1 + x) ≠ 0, from h22,\n have h24 : 1 ≠ 0, from ne.symm h2,\n have h25 : 1 + x ≠ 0, from mul_ne_zero (cast h23) (cast h24),\n have h26 : (1 + x) ≠ 0, from h25,\n have h27 : (1 + x) ≠ 0, from by auto [add_ne_zero],\n have h28 : (1 + x) ≠ 0, from h27,\n rw show (1 : ℚ) = 1, from rfl,\n rw show (1 : ℚ) = 1, from rfl,\n rw show (1 : ℚ) = 1, from rfl,\n rw show (1 : ℚ) = 1, from rfl,\n rw show 1 + x = ↑(1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show x = (↑x : ℚ), from rfl,\n rw show ↑(x : ℚ) = (↑x : ℚ), from rfl,\n rw show x = (↑x : ℚ), from rfl,\n rw show ↑(x : ℚ) = (↑x : ℚ), from rfl,\n rw show x = (↑x : ℚ), from rfl,\n rw show ↑(x : ℚ) = (↑x : ℚ), from rfl,\n rw show x = (↑x : ℚ), from rfl,\n rw show ↑(x : ℚ) = (↑x : ℚ), from rfl,\n rw show ↑(x : ℚ) = (↑x : ℚ), from rfl,\n have h29 : (1 + x) ≠ 0, from by auto [add_ne_zero],\n have h30 : (1 + x) ≠ 0, from by auto [add_ne_zero],\n rw show (1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (1 + x), from rfl,\n rw show (1 + x) = (1 + x), from rfl,\n rw show ↑(1 + x) = (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n apply nat.strong_induction_on n,\n assume d h,\n have h1 : (d + 1) * (1 + x)^d - (d + 1) * x^d = (polynomial.sum (λ (k : ℕ), (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k)).eval x, from begin\n calc (d + 1) * (1 + x)^d - (d + 1) * x^d = \n (polynomial.sum (λ (k : ℕ), (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k)).eval (1 + x) - (d + 1) * x^d : by auto [polynomial.eval_sum]\n ... = (polynomial.sum (λ (k : ℕ), (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k)).eval x : begin\n apply nat.induction_on d,\n repeat {rw ←add_zero},\n simp,\n assume d h,\n rw [nat.add_succ, polynomial.eval_sum],\n have h1 : ∀ k : ℕ, (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k * (1 + x) =\n (polynomial.C (nat.choose (d + 1) k)) * (polynomial.X^k * (1 + x)), from by repeat {rw polynomial.mul_one},\n rw h1,\n rw polynomial.eval_mul,\n rw polynomial.eval_X,\n rw polynomial.eval_C,\n rw polynomial.eval_X,\n rw polynomial.eval_C,\n ring,\n end\n ... = (polynomial.sum (λ (k : ℕ), (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k)).eval x : rfl,\n end,\n have h2 : (polynomial.sum (λ (k : ℕ), (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k)).eval x = (polynomial.sum (λ (k : ℕ), k * polynomial.X^(k - 1))).eval x, from begin\n rw polynomial.eval_sum,\n apply nat.induction_on d,\n simp,\n assume d h,\n rw [nat.add_succ, polynomial.eval_sum],\n have h1 : ∀ k : ℕ, (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k = \n polynomial.C k * polynomial.X^(k - 1), from by auto [polynomial.C_one, nat.choose_one],\n rw h1,\n rw polynomial.eval_mul,\n rw polynomial.eval_X,\n rw polynomial.eval_C,\n rw polynomial.eval_X,\n rw polynomial.eval_C,\n ring,\n end,\n rw h1,\n rw h2,\n rw [nat.add_succ, polynomial.eval_sum],\n have h3 : ∀ k : ℕ, (polynomial.C k * polynomial.X^(k - 1)) * x = \n k * (polynomial.X^(k - 1) * x), from by auto [polynomial.mul_one],\n rw h3,\n rw polynomial.eval_mul,\n rw polynomial.eval_X,\n rw polynomial.eval_C,\n rw polynomial.eval_X,\n rw polynomial.eval_C,\n ring,\nend\n\n--OUTPUT 3\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\ninduction n with d hd,\n{ simp [polynomial.bernoulli, polynomial.eval_add, polynomial.eval_C, polynomial.eval_mul,\n polynomial.eval_X, polynomial.eval_nat_cast, polynomial.eval_sub, polynomial.eval_X_sub_C,\n polynomial.eval_C_sub_X, polynomial.eval_sub_C_C, polynomial.eval_sub_X_C, polynomial.eval_sub_C_X,\n polynomial.eval_sub_X_X, polynomial.eval_pow, polynomial.eval_neg, polynomial.eval_one, \n polynomial.eval_C_add, polynomial.eval_add_C_C],\n},\n{ simp [polynomial.bernoulli, polynomial.eval_add, polynomial.eval_C, polynomial.eval_mul,\n polynomial.eval_X, polynomial.eval_nat_cast, polynomial.eval_sub, polynomial.eval_X_sub_C,\n polynomial.eval_C_sub_X, polynomial.eval_sub_C_C, polynomial.eval_sub_X_C, polynomial.eval_sub_C_X,\n polynomial.eval_sub_X_X, polynomial.eval_pow, polynomial.eval_neg, polynomial.eval_one, \n polynomial.eval_C_add, polynomial.eval_add_C_C],\n}\nend\n\n--OUTPUT 4\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n rw[polynomial.eval_add, polynomial.eval_one, polynomial.eval_one],\n have h : ∀ m : ℕ, m ≤ n → (m : ℚ) ≤ n, from λ m hm, by linarith,\n induction n with d hd,\n { calc (polynomial.bernoulli 0).eval (1 + x) = (polynomial.bernoulli 0).eval (x + 1) : by simp\n ... = (polynomial.bernoulli 0).eval x + (0 : ℚ) * x^(0 - 1) : by simp [hd (by linarith)]\n ... = (polynomial.bernoulli 0).eval x + (0 : ℚ) : by simp [polynomial.eval_zero]\n ... = (polynomial.bernoulli 0).eval x : by simp [zero_add]},\n {calc (polynomial.bernoulli (d + 1)).eval (1 + x) = (polynomial.bernoulli (d + 1)).eval (x + 1) : by simp\n ... = (polynomial.bernoulli (d + 1)).eval x + (d + 1 : ℚ) * x^(d + 1 - 1) : by rw[polynomial.eval_add, polynomial.eval_one, polynomial.eval_one, hd (by linarith)]\n ... = (polynomial.bernoulli (d + 1)).eval x + d * x^d + x^d : by simp\n ... = (polynomial.bernoulli (d + 1)).eval x + (d * x^d + x^d) : by simp [polynomial.eval_add, polynomial.eval_one, polynomial.eval_one]\n ... = (polynomial.bernoulli (d + 1)).eval x + d * x^d + x^d : by simp [polynomial.eval_add, polynomial.eval_one, polynomial.eval_one]\n ... = (polynomial.bernoulli (d + 1)).eval x + (d * x^d + x^d) : by simp [polynomial.eval_add, polynomial.eval_one, polynomial.eval_one]\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * (x^d + 1) : by simp [ring]\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * ((x + 1)^d) : by simp [polynomial.eval_add, polynomial.eval_one, polynomial.eval_one, polynomial.eval_one]\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * ((x + 1)^d - x^d) : by ring\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * (sum (λ (m : ℕ), (d : ℚ) choose m * x^m) (d - 1)) : by rw[polynomial.eval_one, polynomial.eval_one]\n ... = (polynomial.bernoulli (d + 1)).eval x + sum (λ (m : ℕ), (d : ℚ) choose m * (d : ℚ) * x^m) (d - 1) : by simp [ring]\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * sum (λ (m : ℕ), m * x^m) (d - 1) : by simp\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * sum (λ (m : ℕ), m * x^m) (d - 1) : by simp\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * sum (λ (m : ℕ), ((m + 1) - 1 : ℚ) * x^m) (d - 1) : by simp\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m - (1 : ℚ) * x^m) (d - 1) : by refl\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 1) - (d : ℚ) * sum (λ (m : ℕ), (1 : ℚ) * x^m) (d - 1) : by simp [sum_sub_sum]\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 1) - (d : ℚ) * (sum (λ (m : ℕ), (1 : ℚ) * x^m) (d - 1)) : by simp\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 1) - (d : ℚ) * (x^(d - 1) + sum (λ (m : ℕ), 1) (d - 2)) : by simp [sum_range_succ]\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 2) - (d : ℚ) * x^(d - 1) : by simp [sum_range_succ]\n ... = (polynomial.bernoulli (d + 1)).eval x + (d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 2) - (d : ℚ) * x^(d - 1) : by simp [sum_range_succ]\n ... = ((d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 2) + (polynomial.bernoulli (d + 1)).eval x - (d : ℚ) * x^(d - 1)) : by simp\n ... = ((d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 2) + ((polynomial.bernoulli (d + 1)).eval x - (d : ℚ) * x^(d - 1))) : by refl\n ... = ((d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 2) + ((polynomial.bernoulli (d + 1)).eval x - (d : ℚ) * x^(d - 1))) : by refl\n ... = (d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 2) + (polynomial.bernoulli (d + 1)).eval x - (d : ℚ) * x^(d - 1) : by simp\n ... = (d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ) * x^m) (d - 2) + (polynomial.bernoulli (d + 1)).eval x - (d : ℚ) * x^(d - 1) : by simp\n ... = (d : ℚ) * sum (λ (m : ℕ), (m + 1 : ℚ)\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n induction n with h hd,\n { simp },\n { have h1 : polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * (polynomial.X : polynomial ℚ)^k) (λ (k : ℕ), k * (polynomial.X : polynomial ℚ)^(k - 1)) =\n (n + 1) * (polynomial.X : polynomial ℚ) ^ n, from by auto [polynomial.sum],\n have h2 : polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * ((polynomial.X : polynomial ℚ)^k)) (λ (k : ℕ), k * ((polynomial.X : polynomial ℚ)^(k - 1))) =\n polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * ((polynomial.X : polynomial ℚ)^k)) (λ (k : ℕ), k * x^(k - 1)), from by auto [polynomial.sum],\n have h3 : n * (1 + x) ^ n - n * x ^ n = polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * ((polynomial.X : polynomial ℚ)^k)) (λ (k : ℕ), k * ((polynomial.X : polynomial ℚ)^(k - 1))), from\n calc n * (1 + x) ^ n - n * x ^ n = polynomial.sum (λ (k : ℕ), n * ↑(choose (n + 1) k) * ((polynomial.X : polynomial ℚ)^k)) (λ (k : ℕ), (k + 1) * ((polynomial.X : polynomial ℚ)^k)) : by auto [polynomial.sum, polynomial.sum, polynomial.sum, polynomial.sum]\n ... = polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * ((polynomial.X : polynomial ℚ)^k)) (λ (k : ℕ), k * ((polynomial.X : polynomial ℚ)^k)) + (n + 1) * ((polynomial.X : polynomial ℚ)^n) : by auto [polynomial.sum]\n ... = (n + 1) * ((polynomial.X : polynomial ℚ)^n) : by auto [polynomial.sum, h1],\n have h4 : (polynomial.bernoulli (n + 1)).eval (1 + x) - (polynomial.bernoulli (n + 1)).eval x =\n polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * ((polynomial.X : polynomial ℚ)^k)) (λ (k : ℕ), k * ((polynomial.X : polynomial ℚ)^(k - 1))), from by auto [polynomial.sum],\n have h5 : (polynomial.bernoulli (n + 1)).eval (1 + x) - (polynomial.bernoulli (n + 1)).eval x =\n polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * ((polynomial.X : polynomial ℚ)^k)) (λ (k : ℕ), k * x^(k - 1)), from by auto [h2],\n have h6 : (polynomial.bernoulli (n + 1)).eval (1 + x) - (polynomial.bernoulli (n + 1)).eval x =\n n * (1 + x) ^ n - n * x ^ n, from by auto [h3, h4],\n have h7 : (polynomial.bernoulli (n + 1)).eval (1 + x) - (polynomial.bernoulli (n + 1)).eval x =\n polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * x^k) (λ (k : ℕ), k * x^(k - 1)), from by auto [h5],\n have h8 : (polynomial.bernoulli (n + 1)).eval (1 + x) - (polynomial.bernoulli (n + 1)).eval x + (n + 1) * x ^ n =\n polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * x^k) (λ (k : ℕ), (k + 1) * x^k), from by auto [polynomial.sum, polynomial.sum, polynomial.sum],\n have h9 : (polynomial.bernoulli (n + 1)).eval (1 + x) =\n polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * x^k) (λ (k : ℕ), (k + 1) * x^k), from by auto [h6, h7, h8],\n have h10 : polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * x^k) (λ (k : ℕ), (k + 1) * x^k) =\n polynomial.sum (λ (k : ℕ), (n + 1) * ↑(choose (n + 1) k) * x^k) (λ (k : ℕ), n * x^(n - 1)), from by auto [polynomial.sum],\n have h11 : (polynomial.bernoulli (n + 1)).eval (1 + x) =\n (n + 1) * x^n + n * x^n, from by auto [h9, h10, polynomial.sum, polynomial.sum],\n show (polynomial.bernoulli (n + 1)).eval (1 + x) = (polynomial.bernoulli (n + 1)).eval x + (n + 1) * x^(n + 1 - 1), from by auto [(n + 1) * x^(n + 1 - 1)],\n },\nend\n\n--OUTPUT 6\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n induction n with l hl,\n rw polynomial.bernoulli,\n simp,\n rw add_zero,\n simp,\n\n rw polynomial.bernoulli at hl,\n simp [polynomial.eval_sum, polynomial.eval_C],\n rw polynomial.bernoulli,\n simp,\n rw add_comm,\n rw mul_comm (1 + x) x,\n rw add_assoc,\n rw hl,\n rw add_assoc (l * x ^ (l - 1)),\n rw mul_pow,\n rw mul_comm,\n rw add_comm,\n rw mul_comm ((1 + x) * x) x,\n rw ← mul_assoc,\n rw ← mul_comm x,\n rw ← pow_succ,\n rw mul_comm (l + 1) x,\nend\n\n--OUTPUT 7\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n induction n with n hn generalizing x,\n {\n show (polynomial.bernoulli 0).eval (1 + x) = (polynomial.bernoulli 0).eval x, from by simp [eval_C],\n },\n {\n have h1 : (polynomial.prod (λ (m : ℕ), C (m + 1) * (X^m + X^(m + 1))) n).eval (1 + x) =\n (polynomial.prod (λ (m : ℕ), C (m + 1) * (X^m + X^(m + 1))) n).eval x, from by auto [eval_prod],\n have h2 : (polynomial.prod (λ (m : ℕ), C (m + 1) * (X^m + X^(m + 1))) n).eval x =\n (polynomial.prod (λ (m : ℕ), C (m + 1) * X^m) n).eval x +\n (polynomial.prod (λ (m : ℕ), C (m + 1) * X^(m + 1)) n).eval x, from by auto [eval_prod, eval_add],\n have h3 : (polynomial.prod (λ (m : ℕ), C (m + 1) * X^m) n).eval x =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x *\n (polynomial.prod (λ (m : ℕ), X^m) n).eval x, from by auto [eval_prod],\n have h4 : (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval 0, from by auto [eval_prod_const],\n have h5 : (polynomial.prod (λ (m : ℕ), X^m) n).eval x =\n polynomial.prod (λ (m : ℕ), X) n, from by auto [eval_prod],\n have h6 : (polynomial.prod (λ (m : ℕ), C (m + 1) * X^(m + 1)) n).eval x =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x *\n (polynomial.prod (λ (m : ℕ), X) n) ^ (n + 1), from by auto [eval_prod],\n have h7 : (polynomial.prod (λ (m : ℕ), C (m + 1) * X^(m + 1)) n).eval x =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x *\n (polynomial.prod (λ (m : ℕ), X) n) *\n (polynomial.prod (λ (m : ℕ), X) n) ^ n, from by auto [eval_prod],\n have h8 : (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval 0, from by auto [eval_prod_const],\n have h9 : (polynomial.prod (λ (m : ℕ), C (m + 1) * X^m) n).eval (1 + x) =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval (1 + x) *\n (polynomial.prod (λ (m : ℕ), X^m) n).eval (1 + x), from by auto [eval_prod],\n have h10 : (polynomial.prod (λ (m : ℕ), C (m + 1) * X^(m + 1)) n).eval (1 + x) =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval (1 + x) *\n (polynomial.prod (λ (m : ℕ), X) n) *\n (polynomial.prod (λ (m : ℕ), X) n) ^ n, from by auto [eval_prod],\n have h11 : (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval (1 + x) =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x +\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n) *\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x, from by auto [eval_prod],\n have h12 : (polynomial.prod (λ (m : ℕ), X^m) n).eval (1 + x) =\n (polynomial.prod (λ (m : ℕ), X^m) n).eval x, from by auto [eval_prod],\n have h13 : (polynomial.prod (λ (m : ℕ), X) n) ^ (n + 1) =\n (polynomial.prod (λ (m : ℕ), X) n) * (polynomial.prod (λ (m : ℕ), X) n) ^ n, from by auto [eval_prod],\n have h14 : (polynomial.prod (λ (m : ℕ), C (m + 1)) n) *\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x *\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n), from by auto [eval_prod, mul_comm],\n have h15 : (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x =\n polynomial.prod (λ (m : ℕ), C (m + 1)) n, from by auto [eval_prod_const],\n have h16 : (polynomial.prod (λ (m : ℕ), C (m + 1)) n) *\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval 0 =\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval 0 *\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n), from by auto [eval_prod, mul_comm],\n have h17 : (polynomial.prod (λ (m : ℕ), C (m + 1)) n) *\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval x *\n (polynomial.prod (λ (m : ℕ), X^m) n).eval x =\n (polynomial.prod (λ (m : ℕ), C (m + 1) * X^m) n).eval x *\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n), from by auto [eval_prod, mul_comm],\n have h18 : (polynomial.prod (λ (m : ℕ), C (m + 1)) n) *\n (polynomial.prod (λ (m : ℕ), C (m + 1)) n).eval 0 *\n (polynomial.prod (λ (m : ℕ), X^m) n).eval x =\n (polynomial.prod (λ (m : ℕ), C (m + 1) * X^m) n).eval 0 *\n (polynomial.prod (λ (m :\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n have h1 : ∀ (m : ℕ) (x : ℚ), m < n → (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x ^ (m - 1),\n { assume m x h1,\n have h2 : ∀ k : ℕ, k ≤ m → (((C (1+x)) ^ (m - k))),\n { assume k h2,\n have h3 : (1 + x)^m = (C x)^m + m * (C x)^(m-1) * (C (1+x))^1, by simp [C, has_mul.one],\n rw has_pow.pow_eq_pow_of_nat_cast h2 at h3,\n have h4 : (1 + x) ^ (m - k) = (C x) ^ (m - k) + m * (C x) ^ (m - k - 1) * (C (1 + x)) ^ 1, from by simp [C, has_mul.one] at h3,\n exact h4,\n },\n have h3 : (polynomial.bernoulli m).eval (1 + x) = ∑ (k : ℕ) in finset.range m, (((C (1 + x)) ^ k) * C (mchoose k)), from by simp [C, has_mul.one],\n have h4 : (polynomial.bernoulli m).eval x = ∑ (k : ℕ) in finset.range m, ((C x ^ k) * C (mchoose k)), from by auto [C, has_mul.one] at h3,\n have h5 : (polynomial.bernoulli m).eval (1 + x) = ∑ (k : ℕ) in finset.range m, ((C x ^ k) * C (mchoose k) + m * C x ^ (k - 1) * C (mchoose k) * C (1 + x)), from by auto [C, has_mul.one] at h3 using [h2],\n have h6 : ∑ (k : ℕ) in finset.range m, (m * C x ^ (k - 1) * C (mchoose k) * C (1 + x)) = m * ∑ (k : ℕ) in finset.range m, (C x ^ (k - 1) * C (mchoose k) * C (1 + x)), from by auto [finset.sum_mul],\n have h7 : ∑ (k : ℕ) in finset.range m, (C x ^ (k - 1) * C (mchoose k) * C (1 + x)) = x ^ (m - 1), from by simp [C, has_mul.one] at h6,\n have h8 : m * (∑ (k : ℕ) in finset.range m, (C x ^ (k - 1) * C (mchoose k) * C (1 + x))) = m * x ^ (m - 1), from by auto at h7,\n have h9 : finset.sum finset.range m (λ (k : ℕ), C x ^ k * C (mchoose k) + m * C x ^ (k - 1) * C (mchoose k) * C (1 + x)) = finset.sum finset.range m (λ (k : ℕ), C x ^ k * C (mchoose k)) + m * x ^ (m - 1), from by rw finset.sum_add h4 h8,\n exact h9,\n },\n have h2 : ∀ (m : ℕ) (x : ℚ), m < n → (polynomial.bernoulli m).eval x = mchoose m, from by auto using [bernoulli_eval, nat.eq_zero_of_le_zero],\n have h3 : ∀ (m : ℕ) (x : ℚ), m < n → mchoose m * x^(m - 1) = m * x^(m - 1), from by auto [mul_comm, nat.choose_eq_mul_succ_pred_div_succ, nat.one_mul],\n have h4 : ∀ (m : ℕ) (x : ℚ), m < n → (polynomial.bernoulli m).eval x + m * x ^ (m - 1) = mchoose m + m * x ^ (m - 1), from by auto [h2, h3],\n have h5 : ∀ (m : ℕ) (x : ℚ), m < n → (polynomial.bernoulli m).eval (1 + x) = mchoose m + m * x ^ (m - 1), from by auto [h1, h4],\n by_contradiction h6,\n have h7 : ∀ (m : ℕ) (x : ℚ), m < n → (polynomial.bernoulli m).eval (1 + x) + m * (1 + x) ^ (m - 1) = mchoose m + m * (1 + x) ^ (m - 1) + m * (1 + x) ^ (m - 1), from by auto [h5],\n have h8 : ∀ (m : ℕ) (x : ℚ), m < n → (polynomial.bernoulli m).eval (1 + x) + m * (1 + x) ^ (m - 1) = mchoose m + (1 + m) * (1 + x) ^ (m - 1), from by auto [mul_comm, one_mul, nat.add_comm] at h7,\n have h9 : ∀ (m : ℕ) (x : ℚ), m < n → ((polynomial.bernoulli m).eval (1 + x) + m * (1 + x) ^ (m - 1)) * ((C (1 + x)) ^ n) = (mchoose m + (1 + m) * (1 + x) ^ (m - 1)) * ((C (1 + x)) ^ n), from by auto at h8,\n have h10 : ∀ (m : ℕ) (x : ℚ), m < n → ∑ (k : ℕ) in finset.range m, (polynomial.bernoulli k).eval (1 + x) + k * (1 + x) ^ (k - 1) = (1 + x) ^ (m - 1) * ∑ (k : ℕ) in finset.range m, (1 + k) * (1 + x) ^ (k - 1), from by auto [C, has_mul.one] at h9,\n have h11 : ∀ (m : ℕ) (x : ℚ), m < n → ∑ (k : ℕ) in finset.range m, (polynomial.bernoulli k).eval (1 + x) + k * (1 + x) ^ (k - 1) * (C (1 + x)) ^ n = (1 + x) ^ (m - 1) * ∑ (k : ℕ) in finset.range m, (1 + k) * (1 + x) ^ (k - 1) * (C (1 + x)) ^ n, from by auto [nat.cast_one, one_mul, has_mul.one] at h10,\n have h12 : ∀ (m : ℕ) (x : ℚ), m < n → (1 + x)^m * ∑ (k : ℕ) in finset.range (m + 1), (((C (1 + x)) ^ k) * C (mchoose k)) = (1 + x) ^ (m - 1) * ∑ (k : ℕ) in finset.range m, (1 + k) * (1 + x) ^ (k - 1) * (C (1 + x)) ^ n, from by auto [C, has_mul.one] at h11,\n have h13 : ∀ (m : ℕ) (x : ℚ), m < n → (1 + x)^m * ∑ (k : ℕ) in finset.range (m + 1), ((\nend --Needs more than 2000 tokens!\n\n--OUTPUT 9\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n apply nat.strong_induction_on n,\n intros,\n split_ifs with h,\n rw [h, nat.sub_self, pow_zero, add_zero],\n have h2 := polynomial.bernoulli_succ_eq_one_add_eval a x,\n rw [h, diff_pow, diff_pow, h2],\n ring,\n rw [h, pow_one, pow_zero],\n ring,\n rw [h, pow_one, pow_zero, mul_one, add_zero],\n rw polynomial.eval₂_zero,\n rw polynomial.eval₂_zero,\n ring,\n rw [h, pow_zero],\n ring,\n rw polynomial.eval₂_zero,\n ring,\nend\n\n--OUTPUT 10\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n induction n with d hd,\n rw [nat.zero_eq_zero, polynomial.bernoulli, polynomial.bernoulli, polynomial.eval_C],\n simp, \n assume x rw [nat.one_eq_one, polynomial.bernoulli, polynomial.bernoulli, polynomial.eval_X, polynomial.eval_add, polynomial.eval_C, nat.one_eq_one],\n suffices h :\n polynomial.eval (of_nat (d + 1) * (X^d - X^d)) (1 + x) =\n polynomial.eval (of_nat (d + 1) * (X^d - X^d)) x + d * x ^ (d - 1),\n simp at h,\n exact h,\n rw [polynomial.eval_mul, polynomial.eval_add, polynomial.eval_neg, polynomial.eval_C, polynomial.eval_X],\n have h1 : (1 + x)^d - x^d = (1 - x) * ((1 + x) ^ (d - 1) + (1 + x) ^ (d - 2) * x + ... + x ^ (d - 1)),\n begin\n have h10 : (1 + x) ^ d - x ^ d = (1 + x) ^ (d - 1) * (1 + x - x),\n by simp [polynomial.add_mul, polynomial.mul_C, polynomial.mul_X_pow, polynomial.mul_one],\n have h11 : (1 + x - x) = (1 - x), \n by simp,\n rw [h11] at h10,\n rw h10,\n rw [nat.mul_one, mul_comm, mul_assoc],\n induction d with d hd,\n by simp,\n assume x,\n simp,\n assume x d hd,\n have h11 : x ^ (d - 1) + (1 + x) ^ (d - 1) * x = (1 + x) ^ (d - 1) * (1 + x),\n by rw [← add_mul, polynomial.add_C, polynomial.add_X_pow],\n have h12 : (1 + x) ^ d - x ^ d = (1 + x - x) * ((1 + x) ^ (d - 1) + (1 + x) ^ (d - 2) * x + ... + x ^ (d - 1)),\n by simp; rw [← mul_assoc, mul_assoc, mul_comm, mul_assoc, mul_assoc, mul_comm, add_mul, add_mul, ↑_root_.add, nat.mul_one, polynomial.C_1, polynomial.C_0, hd],\n rw h12,\n rw [mul_comm, h11, mul_add, mul_assoc, mul_comm, mul_assoc, ← add_mul, add_mul, ← add_mul, h11, ← add_assoc, mul_comm, mul_assoc],\n rw [← mul_add],\n end,\n rw h1,\n rw mul_comm,\n rw [mul_add, mul_assoc],\n rw [← polynomial.eval_add],\n suffices h2 : polynomial.eval (of_nat (d + 1) * ((1 - x) * (X ^ (d - 1) + X ^ (d - 2) * X + ... + X ^ 0))) (1 + x) = polynomial.eval (of_nat (d + 1) * ((1 - x) * (X ^ (d - 1) + X ^ (d - 2) * X + ... + X ^ 0))) x + polynomial.eval (of_nat (d + 1) * (1 - x) * (X ^ (d - 1))) x,\n begin\n rw mul_comm,\n rw [mul_add, mul_comm],\n rw add_comm,\n end,\n rw [← h2],\n rw add_comm,\n induction d with d hd,\n rw [nat.add_one, nat.zero_eq_zero, zero_add, polynomial.eval_C, polynomial.eval_C],\n simp,\n have h20 : polynomial.eval (of_nat (d + 2) * (1 - x) * (X ^ (d + 1) + X ^ d * X + ... + X ^ 0)) (1 + x) = polynomial.eval ((of_nat (d + 2) * (1 - x) * (X ^ (d + 1) + X ^ d * X + ... + X ^ 0)) + (of_nat (d + 2) * (1 - x) * (X ^ (d + 1)))) (1 + x),\n by simp,\n rw h20,\n have h21 : polynomial.eval (of_nat (d + 2) * (1 - x) * (X ^ (d + 1) + X ^ d * X + ... + X ^ 0)) x + polynomial.eval (of_nat (d + 2) * (1 - x) * (X ^ (d + 1))) x = polynomial.eval ((of_nat (d + 2) * (1 - x) * (X ^ (d + 1) + X ^ d * X + ... + X ^ 0)) + (of_nat (d + 2) * (1 - x) * (X ^ (d + 1)))) x,\n by simp,\n rw h21,\n rw [← polynomial.eval_add],\n rw [polynomial.C_add, polynomial.eval_add, polynomial.eval_mul],\n rw [polynomial.eval_add],\n rw polynomial.eval_C,\n rw polynomial.eval_mul,\n rw polynomial.eval_C,\n rw polynomial.eval_X,\n rw [→ mul_comm, mul_comm (d + 2), ← mul_add],\n rw add_comm,\n rw mul_assoc,\n rw [← polynomial.eval_add],\n have h22 : polynomial.eval (of_nat (d + 2) * ((1 - x) * (X ^ (d + 1) + X ^ d * X + ... + X ^ 0))) (1 + x) + polynomial.eval (of_nat (d + 2) * ((1 - x) * (X ^ (d + 1) + X ^ d * X + ... + X ^ 0))) x + polynomial.eval (of_nat (d + 2) * (1 - x) * (X ^ (d + 1))) x =\n polynomial.eval ((of_nat (d + 2) * (1 - x) * (X ^ (d + 1)))) (1 + x) + polynomial.eval ((of_nat (d + 2) * (1 - x) * (X ^ (d + 1) + X ^ d * X + ... + X ^ 0))) (1 + x) + polynomial.eval ((of_nat (d + 2) * (1 - x) * (X ^ (d + 1) + X ^ d * X + ... + X ^ 0))) x + polynomial.eval (of_nat (d + 2) * (1 - x) * (X ^ (d + 1))) x,\n by simp,\n rw h22,\n rw [← polynomial.eval_add],\n have h23 :\n polynomial.eval ((of_nat (d + 2) * (1 - x) * (X ^ (d + 1)))) (1 + x) =\n polynomial.eval ((of_nat (d + 2) * (1 - x) * (X ^ (d + 1)))) x +\n polynomial.eval (of_nat (d + 2) * (1 - x) * X ^ (d + 1)) x,\n by rw [polynomial.eval_mul, po\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n have h1 : (A ⊆ S) ∧ (B ⊆ S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n have h2 : (A ∩ B) ⊆ A, from by auto [set.inter_subset_left],\n have h3 : (A ∩ B) ⊆ S, from by auto [set.subset.trans],\n show (A ∩ B) ∈ 𝒫 S, from by auto [set.mem_powerset],\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n calc (x + y)^2 = (x+y)*(x+y) : by auto [sq]\n ... = x*(x+y) + y*(x+y) : by auto [add_mul]\n ... = x*x + x*y + y*x + y*y : by auto [mul_comm, add_mul] using [ring]\n ... = x^2 + 2*x*y + y^2 : by auto [sq, mul_comm] using [ring]\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by auto using [use (a⁻¹ * b)],\n have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by auto using [use b * a⁻¹], \n\n have h3 : ∀ a : G, ∃! x : G, a * x = a, from by auto [h1],\n have h4 : ∀ a : G, ∃! y : G, y * a = a, from by auto [h2],\n\n have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from by auto [exists_unique.unique, h3, classical.some_spec, exists_unique.exists, mul_one],\n have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from by auto [exists_unique.unique, h4, classical.some_spec, exists_unique.exists, one_mul],\n\n show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by auto [h3, h4, exists_unique.unique, classical.some_spec, exists_unique.exists] using [use (1 : G)],\nend\n\n/--`theorem`\nBernoulli polynomial evaluation\nGiven a natural number $n$ and a rational $x$, let $B_n (x)$ denote the $n$-th Bernoulli polynomial evaluated at $x$. Then, $$B_n (1 + x) = B_n (x) + n x^{n - 1}$$\n`proof`\nWe apply strong induction on $n$. So, for all $m < d$, we have $B_{m} (1 + x) = B_{m} (x) + m x^{m - 1}$ and we want to show that $$B_{d} (1 + x) = B_{d} (x) + d x^{d - 1}$$\nMultiplying both sides by $d + 1$, and using the fact that, for all $l \\in \\mathbb{N}$, $\\sum_{k = 0}^{l} {l + 1 \\choose k} B_k = (l + 1) X^l$ (where $B_k$ is the $k$-th Bernoulli number), we get that \n$$ (d + 1) (1 + x)^d - (d + 1) x^d = \\sum_{l = 0}^{d} {d + 1 \\choose l} l x^{l - 1} $$\nThe conclusion then follows easily.\n\nQED\n\n-/\ntheorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) :\n (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_auto-Natural-Language-Proof-Translation/Correct_statement-lean_proof_auto-3_few_shot_temperature_0.8_max_tokens_2000_n_10/clean_files/Bernoulli polynomial evaluation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6584175139669997, "lm_q2_score": 0.3208213073183839, "lm_q1q2_score": 0.2112343675922131}} {"text": "import for_mathlib.algebra.homology.trunc\nimport for_mathlib.category_theory.localization.shift\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\nopen_locale zero_object\n\nnamespace category_theory\n\ninstance ess_surj_comp {C₁ C₂ C₃ : Type*} [category C₁] [category C₂] [category C₃] (F : C₁ ⥤ C₂)\n [ess_surj F] (G : C₂ ⥤ C₃) [ess_surj G] : ess_surj (F ⋙ G) :=\n⟨λ Z, ⟨_, ⟨G.map_iso (F.obj_obj_preimage_iso (G.obj_preimage Z)) ≪≫ G.obj_obj_preimage_iso Z⟩⟩⟩\n\ninstance ess_surj_Q {C : Type*} [category C] (W : morphism_property C) :\n ess_surj (W.Q) :=\nlocalization.ess_surj W.Q W\n\nlemma full_of_comp_ess_surj {C D E : Type*} [category C] [category D] [category E]\n (F : C ⥤ D) (G : D ⥤ E) [ess_surj F]\n (h : ∀ (X Y : C), function.surjective (λ (f : F.obj X ⟶ F.obj Y), G.map f)) : full G :=\nG.full_of_surjective (λ K₁ K₂ f, begin\n let K'₁ := F.obj_preimage K₁,\n let K'₂ := F.obj_preimage K₂,\n let e₁ : F.obj K'₁ ≅ K₁ := F.obj_obj_preimage_iso K₁,\n let e₂ : F.obj K'₂ ≅ K₂ := F.obj_obj_preimage_iso K₂,\n obtain ⟨f', hf'⟩ := h K'₁ K'₂ (G.map e₁.hom ≫ f ≫ G.map e₂.inv),\n dsimp at hf',\n refine ⟨e₁.inv ≫ f' ≫ e₂.hom, _⟩,\n simp only [G.map_comp, hf', assoc],\n rw [← G.map_comp, e₂.inv_hom_id, G.map_id, comp_id, ← G.map_comp_assoc, e₁.inv_hom_id, G.map_id,\n id_comp],\nend)\n\nlemma faithful_of_comp_ess_surj {C D E : Type*} [category C] [category D] [category E]\n (F : C ⥤ D) (G : D ⥤ E) [ess_surj F]\n (h : ∀ (X Y : C), function.injective (λ (f : F.obj X ⟶ F.obj Y), G.map f)) : faithful G :=\n⟨λ K₁ K₂ f₁ f₂ hf, begin\n let K'₁ := F.obj_preimage K₁,\n let K'₂ := F.obj_preimage K₂,\n let e₁ : F.obj K'₁ ≅ K₁ := F.obj_obj_preimage_iso K₁,\n let e₂ : F.obj K'₂ ≅ K₂ := F.obj_obj_preimage_iso K₂,\n rw [← cancel_mono e₂.inv, ← cancel_epi e₁.hom],\n apply h,\n dsimp,\n simp only [hf, functor.map_comp],\nend⟩\n\nend category_theory\n\nvariables {C : Type*} [category C] [abelian C]\n\nnamespace derived_category\n\ninstance zero_is_le (n : ℤ) : (0 : derived_category C).is_le n :=\n⟨λ i hi, is_zero.of_iso (is_zero_zero _)\n (derived_category.homology_functor C i).map_zero_object⟩\n\ninstance zero_is_ge (n : ℤ) : (0 : derived_category C).is_ge n :=\n⟨λ i hi, is_zero.of_iso (is_zero_zero _)\n (derived_category.homology_functor C i).map_zero_object⟩\n\ndef is_plus (K : derived_category C) : Prop := ∃ (n : ℤ), K.is_ge n\n\ndef is_minus (K : derived_category C) : Prop := ∃ (n : ℤ), K.is_le n\n\nvariable (C)\nopen category_theory.triangulated\n\ninstance plus_is_triangulated_subcategory :\n is_triangulated_subcategory (λ (K : derived_category C), K.is_plus) :=\n{ zero := ⟨0, infer_instance⟩,\n shift := begin\n rintros K k ⟨n, hn⟩,\n haveI := hn,\n exact ⟨n-k, shift_is_ge K n k (n-k) (by linarith)⟩,\n end,\n ext₂ := begin\n rintros T hT ⟨n₁, hn₁⟩ ⟨n₃, hn₃⟩,\n exact ⟨min n₁ n₃,\n ⟨λ n hn, short_complex.exact.is_zero_of_both_zeros (homology_sequence.ex₂ hT n)\n (is_zero.eq_of_src (hn₁.is_zero' _ (lt_of_lt_of_le hn (min_le_left n₁ n₃))) _ _)\n (is_zero.eq_of_tgt (hn₃.is_zero' _ (lt_of_lt_of_le hn (min_le_right n₁ n₃))) _ _)⟩⟩,\n end, }\n\nabbreviation plus := full_subcategory (λ (K : derived_category C), K.is_plus)\nabbreviation minus := full_subcategory (λ (K : derived_category C), K.is_minus)\n\nnamespace plus\n\ninstance : pretriangulated (plus C) := infer_instance\n\nvariable {C}\n\ndef mk (K : derived_category C) (n : ℤ) [hn : K.is_ge n] :\n derived_category.plus C :=\n⟨K, n, hn⟩\n\ndef mk' (K : derived_category C) (hK : K.is_plus) :\n derived_category.plus C :=\n⟨K, hK⟩\n\nabbreviation ι : plus C ⥤ derived_category C :=\nfull_subcategory_inclusion _\n\nend plus\n\nend derived_category\n\nnamespace cochain_complex\n\ndef is_plus (K : cochain_complex C ℤ) : Prop :=\n ∃ (n : ℤ), K.is_strictly_ge n\n\ndef is_minus (K : cochain_complex C ℤ) : Prop :=\n ∃ (n : ℤ), K.is_strictly_le n\n\nlemma is_plus.Q {K : cochain_complex C ℤ} (h : K.is_plus) :\n (derived_category.Q.obj K).is_plus :=\nbegin\n obtain ⟨n, hn⟩ := h,\n haveI := hn,\n exact ⟨n, infer_instance⟩,\nend\n\ninstance zero_is_strictly_ge (n : ℤ) : is_strictly_ge (0 : cochain_complex C ℤ) n :=\n⟨λ k hk, is_zero.of_iso (is_zero_zero _)\n (homological_complex.eval C (complex_shape.up ℤ) k).map_zero_object⟩\n\ninstance zero_is_strictly_le (n : ℤ) : is_strictly_le (0 : cochain_complex C ℤ) n :=\n⟨λ k hk, is_zero.of_iso (is_zero_zero _)\n (homological_complex.eval C (complex_shape.up ℤ) k).map_zero_object⟩\n\nlemma mapping_cone_is_strictly_le {K L : cochain_complex C ℤ} (f : K ⟶ L) (n k l : ℤ)\n [K.is_strictly_le k] [L.is_strictly_le l] (hk : k ≤ n+1) (hl : l ≤ n) :\n (mapping_cone f).is_strictly_le n :=\n⟨λ i hi, begin\n simp only [mapping_cone.X_is_zero_iff],\n split,\n { exact is_strictly_le.is_zero K k (i+1) (by linarith), },\n { exact is_strictly_le.is_zero L l i (by linarith), },\nend⟩\n\nlemma mapping_cone_is_strictly_ge {K L : cochain_complex C ℤ} (f : K ⟶ L) (n k l : ℤ)\n [K.is_strictly_ge k] [L.is_strictly_ge l] (hk : n+1 ≤ k) (hl : n ≤ l) :\n (mapping_cone f).is_strictly_ge n :=\n⟨λ i hi, begin\n simp only [mapping_cone.X_is_zero_iff],\n split,\n { exact is_strictly_ge.is_zero K k (i+1) (by linarith), },\n { exact is_strictly_ge.is_zero L l i (by linarith), },\nend⟩\n\nlemma mapping_cone_is_plus {K L : cochain_complex C ℤ} (f : K ⟶ L)\n (hK : K.is_plus) (hL : L.is_plus) : (mapping_cone f).is_plus :=\nbegin\n obtain ⟨k, hK⟩ := hK,\n obtain ⟨l, hL⟩ := hL,\n haveI := hK,\n haveI := hL,\n exact ⟨min (k-1) l, mapping_cone_is_strictly_ge f _ k l\n (by linarith [min_le_left (k-1) l]) (min_le_right _ _)⟩,\nend\n\nvariable (C)\nabbreviation plus :=\nfull_subcategory (λ (K : cochain_complex C ℤ), cochain_complex.is_plus K)\nabbreviation minus :=\nfull_subcategory (λ (K : cochain_complex C ℤ), cochain_complex.is_minus K)\n\nnamespace plus\n\nvariable {C}\n\nabbreviation ι : plus C ⥤ cochain_complex C ℤ :=\nfull_subcategory_inclusion _\n\nvariable (C)\n\ndef shift_functor (k : ℤ) : plus C ⥤ plus C :=\nfull_subcategory.lift _ (ι ⋙ shift_functor _ k) (λ K, begin\n obtain ⟨n, hn⟩ := K.2,\n haveI := hn,\n refine ⟨n-k, _⟩,\n dsimp,\n exact shift_is_strict_ge K.1 n k (n-k) (by linarith),\nend)\n\ninstance : has_shift (plus C) ℤ :=\nhas_shift_of_fully_faithful ι (shift_functor C)\n (λ n, full_subcategory.lift_comp_inclusion _ _ _)\n\nend plus\n\nnamespace minus\n\nvariable {C}\n\nabbreviation ι : minus C ⥤ cochain_complex C ℤ :=\nfull_subcategory_inclusion _\n\nend minus\n\nend cochain_complex\n\nopen category_theory.triangulated\n\nnamespace homotopy_category\n\nvariable (C)\n\ndef is_plus : set (homotopy_category C (complex_shape.up ℤ)) :=\nλ K, cochain_complex.is_plus K.1\n\nabbreviation plus :=\nfull_subcategory (homotopy_category.is_plus C)\n\ninstance plus_is_triangulated_subcategory' :\n category_theory.triangulated.is_triangulated_subcategory' (is_plus C) :=\n{ zero := begin\n refine ⟨⟨0⟩, _, ⟨0, infer_instance⟩⟩,\n rw is_zero.iff_id_eq_zero,\n change (homotopy_category.quotient _ _).map (𝟙 0) = 0,\n simp only [id_zero, functor.map_zero],\n end,\n shift := begin\n rintro ⟨X⟩ n hX,\n exact ((cochain_complex.plus.shift_functor C n).obj ⟨X, hX⟩).2,\n end,\n distinguished_cocone_triangle' := begin\n rintro ⟨X⟩ ⟨Y⟩ hX hY ⟨f : X ⟶ Y⟩,\n refine ⟨_, _, _, _, ⟨_, _, f, ⟨iso.refl _⟩⟩⟩,\n exact cochain_complex.mapping_cone_is_plus f hX hY,\n end, }\n\nnamespace plus\n\nvariable {C}\n\nabbreviation ι : plus C ⥤ homotopy_category C (complex_shape.up ℤ) :=\nfull_subcategory_inclusion _\n\nvariable (C)\n\nabbreviation homology_functor (n : ℤ) : plus C ⥤ C :=\nι ⋙ homotopy_category.homology_functor C (complex_shape.up ℤ) n\n\ndef shift_homology_functor_iso (n k m : ℤ) (h : k + n = m):\n shift_functor _ n ⋙ homology_functor C k ≅ homology_functor C m :=\n(functor.associator _ _ _).symm ≪≫ iso_whisker_right (ι.comm_shift_iso n) _ ≪≫\n functor.associator _ _ _ ≪≫\n iso_whisker_left ι (homotopy_category.shift_homology_functor_iso C n k m h)\n\ninstance : pretriangulated (plus C) :=\nis_triangulated_subcategory'.pretriangulated_full_subcategory _\n\n--instance : is_triangulated (plus C) := infer_instance\n\nabbreviation acyclic : set (plus C) :=\n(homology_functor C 0).kernel_of_is_homological\n\n--instance : saturated (acyclic C) := infer_instance\n\nvariable {C}\n\nlemma mem_acyclic_W_iff {K L : plus C} (φ : K ⟶ L) :\n (subcategory.W (acyclic C)) φ ↔ ∀ (n : ℤ), is_iso ((homology_functor C n).map φ) :=\nby simpa only [functor.kernel_of_is_homological_W,\n ← λ n, nat_iso.is_iso_map_iff (shift_homology_functor_iso C _ _ _ (zero_add n)) φ]\n\nvariable (C)\n\nlemma homology_functor_is_inverted_by (n : ℤ) :\n (subcategory.W (acyclic C)).is_inverted_by (homology_functor C n) :=\nλ K L f hf, begin\n rw mem_acyclic_W_iff f at hf,\n exact hf n,\nend\n\nvariable {C}\n\nlemma mem_W_iff_ι_map_mem {K L : homotopy_category.plus C} (f : K ⟶ L) :\n subcategory.W (homotopy_category.acyclic C) (homotopy_category.plus.ι.map f) ↔\n subcategory.W (homotopy_category.plus.acyclic C) f :=\nby simpa only [homotopy_category.mem_acyclic_W_iff, homotopy_category.plus.mem_acyclic_W_iff]\n\nvariable (C)\n\ndef single_functor (n : ℤ) : C ⥤ homotopy_category.plus C :=\nfull_subcategory.lift _ (homological_complex.single C (complex_shape.up ℤ) n ⋙\n homotopy_category.quotient _ _) (λ X, ⟨n, by { dsimp, apply_instance, }⟩)\n\ndef single_functor_factors (n : ℤ) :\n single_functor C n ⋙ homotopy_category.plus.ι ≅\n (homological_complex.single C (complex_shape.up ℤ) n ⋙ homotopy_category.quotient _ _) :=\nfull_subcategory.lift_comp_inclusion _ _ _\n\ninstance single_functor_additive (n : ℤ) : (single_functor C n).additive :=\n⟨λ K L f₁ f₂, homotopy_category.plus.ι.map_injective begin\n dsimp only [single_functor],\n simp only [full_subcategory.lift_map, functor.map_add],\nend⟩\n\nend plus\n\nend homotopy_category\n\nnamespace derived_category\n\nnamespace plus\n\nabbreviation Qh : homotopy_category.plus C ⥤ derived_category.plus C :=\nfull_subcategory.lift _ (homotopy_category.plus.ι ⋙ derived_category.Qh)\nbegin\n rintro ⟨⟨K⟩, n, hn⟩,\n refine ⟨n, (_ : (Q.obj K).is_ge n)⟩,\n rw ← cochain_complex.is_ge_iff_Q_obj_is_ge,\n dsimp at hn,\n haveI := hn,\n exact cochain_complex.is_ge_of_is_strictly_ge K n,\nend\n\nvariable (C)\n\ndef Qh_comp_ι_iso : (Qh : _ ⥤ derived_category.plus C) ⋙ derived_category.plus.ι ≅\n homotopy_category.plus.ι ⋙ derived_category.Qh :=\nfull_subcategory.lift_comp_inclusion _ _ _\n\nnamespace Qh_is_localization\n\nlemma inverts :\n (subcategory.W (homotopy_category.plus.acyclic C)).is_inverted_by Qh :=\nλ K L f hf, begin\n haveI : is_iso (derived_category.plus.ι.map (Qh.map f)),\n { erw [is_iso_map_iff_of_nat_iso (Qh_comp_ι_iso C) f],\n dsimp only [functor.comp_map],\n apply localization.inverts derived_category.Qh (subcategory.W (homotopy_category.acyclic C)),\n simpa only [homotopy_category.plus.mem_W_iff_ι_map_mem] using hf, },\n exact is_iso_of_reflects_iso (Qh.map f) ι,\nend\n\nabbreviation L := localization.lift _ (inverts C) (subcategory.W (homotopy_category.plus.acyclic C)).Q\n\ndef L_iso : (subcategory.W (homotopy_category.plus.acyclic C)).Q ⋙ L C ≅ Qh :=\nlocalization.lifting.iso (subcategory.W (homotopy_category.plus.acyclic C)).Q\n (subcategory.W (homotopy_category.plus.acyclic C)) _ _\n\nlemma full_L : full (L C) :=\nbegin\n let F := (subcategory.W (homotopy_category.plus.acyclic C)).Q,\n haveI := localization.ess_surj F\n (subcategory.W (homotopy_category.plus.acyclic C)), -- should be an instance\n have hF : (subcategory.W (homotopy_category.plus.acyclic C)).is_inverted_by F :=\n localization.inverts _ _,\n apply category_theory.full_of_comp_ess_surj F,\n rintros ⟨⟨K₁ : cochain_complex C ℤ⟩, hK₁⟩ ⟨⟨K₂ : cochain_complex C ℤ⟩, hK₂⟩ f,\n have hK₁' := hK₁,\n have hK₂' := hK₂,\n obtain ⟨n₁, hn₁⟩ := hK₁',\n obtain ⟨n₂, hn₂⟩ := hK₂',\n let n := min n₁ n₂,\n haveI : K₁.is_strictly_ge n,\n { haveI := hn₁, exact cochain_complex.is_strictly_ge_of_le _ _ _ (min_le_left n₁ n₂), },\n haveI : K₂.is_strictly_ge n,\n { haveI := hn₂, exact cochain_complex.is_strictly_ge_of_le _ _ _ (min_le_right n₁ n₂), },\n let f' : Qh.obj ⟨⟨K₁⟩, hK₁⟩ ⟶ Qh.obj ⟨⟨K₂⟩, hK₂⟩ :=\n (L_iso C).inv.app _ ≫ f ≫ (L_iso C).hom.app _,\n let f'' : derived_category.Q.obj K₁ ⟶ derived_category.Q.obj K₂ := f',\n obtain ⟨K₃, hK₃', s, g, hs, fac⟩ := right_factorisation_of_is_strictly_ge f'' n,\n replace fac := (Q.map s) ≫= fac,\n rw is_iso.hom_inv_id_assoc at fac,\n haveI := hK₃',\n haveI := hs,\n have hK₃ : homotopy_category.is_plus C ⟨K₃⟩ := ⟨n, hK₃'⟩,\n let s' : (⟨_, hK₃⟩ : homotopy_category.plus C) ⟶ ⟨_, hK₁⟩ := (homotopy_category.quotient _ _).map s,\n let g' : (⟨_, hK₃⟩ : homotopy_category.plus C) ⟶ ⟨_, hK₂⟩ := (homotopy_category.quotient _ _).map g,\n haveI : is_iso (F.map s') := hF _ begin\n rw ← homotopy_category.plus.mem_W_iff_ι_map_mem,\n erw homotopy_category.map_quotient_W_iff,\n exact hs,\n end,\n refine ⟨inv (F.map s') ≫ F.map g', _⟩,\n dsimp only,\n erw [functor.map_comp, ← cancel_epi ((L C).map (F.map s')), ← functor.map_comp_assoc,\n is_iso.hom_inv_id, (L C).map_id, id_comp, ← cancel_epi ((L_iso C).inv.app ⟨_, hK₃⟩),\n ← (L_iso C).inv.naturality g', ← fac],\n dsimp only [f'', f'],\n erw [assoc, ← (L_iso C).inv.naturality_assoc s'],\n dsimp,\n conv_lhs { congr, skip, erw assoc, congr, skip, erw assoc, },\n erw [(L_iso C).hom_inv_id_app, comp_id],\n refl,\nend\n\ninstance faithful_L : faithful (L C) :=\nbegin\n let F := (subcategory.W (homotopy_category.plus.acyclic C)).Q,\n haveI := localization.ess_surj F\n (subcategory.W (homotopy_category.plus.acyclic C)), -- should be an instance\n have hF : (subcategory.W (homotopy_category.plus.acyclic C)).is_inverted_by F :=\n localization.inverts _ _,\n apply category_theory.faithful_of_comp_ess_surj F,\n rintros ⟨⟨K₁ : cochain_complex C ℤ⟩, hK₁⟩ ⟨⟨K₂ : cochain_complex C ℤ⟩, hK₂⟩,\n suffices : ∀ (f : F.obj {obj := {as := K₁}, property := hK₁} ⟶ F.obj {obj := {as := K₂}, property := hK₂})\n (hf : (L C).map f = 0), f = 0,\n { intros f₁ f₂ hf,\n rw [← sub_eq_zero],\n apply this,\n simpa only [functor.map_sub, sub_eq_zero] using hf, },\n intros f hf,\n obtain ⟨⟨⟨⟨K₁'⟩, hK₁'⟩, s, g, hs⟩, hz⟩ := right_calculus_of_fractions.L_map_fac F\n (subcategory.W (homotopy_category.plus.acyclic C)) f,\n dsimp [right_calculus_of_fractions.map_roof] at hz,\n simp only [hz, preadditive.is_iso.comp_left_eq_zero],\n obtain ⟨g, rfl⟩ := (homotopy_category.quotient _ _).map_surjective g,\n let g' : (⟨⟨K₁'⟩, hK₁'⟩ : homotopy_category.plus C) ⟶ ⟨⟨K₂⟩, hK₂⟩ :=\n (homotopy_category.quotient _ _).map g,\n have hg : derived_category.Qh.map g' = derived_category.Qh.map 0,\n { rw [hz, functor.map_comp, preadditive.is_iso.comp_left_eq_zero] at hf,\n simpa only [functor.comp_map, functor.map_zero, hf, zero_comp,\n preadditive.is_iso.comp_left_eq_zero] using ((L_iso C).hom.naturality g').symm, },\n rw left_calculus_of_fractions.L_map_eq_iff derived_category.Qh\n (subcategory.W (homotopy_category.acyclic C)) at hg,\n obtain ⟨⟨K₂' : cochain_complex C ℤ⟩, s, hs, fac⟩ := hg,\n obtain ⟨s, rfl⟩ := (homotopy_category.quotient _ _).map_surjective s,\n have hK₂' := hK₂,\n obtain ⟨n, hn : K₂.is_strictly_ge n⟩ := hK₂',\n rw zero_comp at fac,\n let t : (⟨⟨K₂⟩, hK₂⟩ : homotopy_category.plus C) ⟶ ⟨⟨K₂'.trunc_ge n⟩, ⟨n, infer_instance⟩⟩ :=\n (homotopy_category.quotient _ _).map (s ≫ cochain_complex.trunc_ge.π K₂' n),\n haveI : is_iso (F.map t),\n { apply hF,\n erw [← homotopy_category.plus.mem_W_iff_ι_map_mem, homotopy_category.map_quotient_W_iff],\n haveI : quasi_iso s,\n { simpa only [← homotopy_category.map_quotient_W_iff] using hs, },\n haveI : quasi_iso (cochain_complex.trunc_ge.π K₂' n),\n { rw [cochain_complex.quasi_iso_trunc_ge_π_iff, ← cochain_complex.is_ge_iff_of_quasi_iso s],\n apply_instance, },\n apply_instance, },\n simp only [← cancel_mono (F.map t), zero_comp, ← F.map_comp, ← F.map_zero],\n congr' 1,\n dsimp [t],\n erw [functor.map_comp, ← assoc, fac, zero_comp],\nend\n\ninstance : ess_surj (L C) :=\n⟨begin\n rintro ⟨K, hK⟩,\n let K' := Q.obj_preimage K,\n let e : Q.obj K' ≅ K := Q.obj_obj_preimage_iso K,\n obtain ⟨n, hn⟩ := hK,\n haveI := hn,\n haveI := (cochain_complex.is_ge_iff_Q_obj_is_ge K' n).2 (derived_category.is_ge.of_iso e.symm n),\n exact ⟨(morphism_property.Q _).obj ⟨⟨K'.trunc_ge n⟩, ⟨n, infer_instance⟩⟩,\n ⟨derived_category.plus.ι.preimage_iso (ι.map_iso ((L_iso C).app _) ≪≫\n (as_iso (Q.map (cochain_complex.trunc_ge.π K' n))).symm ≪≫ e)⟩⟩,\nend⟩\n\nlemma is_equivalence : is_equivalence (L C) :=\nbegin\n haveI := full_L C,\n exact equivalence.of_fully_faithfully_ess_surj _\nend\n\ninstance : ess_surj (Qh : _ ⥤ derived_category.plus C) :=\ness_surj.of_iso (L_iso C)\n\nend Qh_is_localization\n\ninstance Qh_is_localization :\n (Qh : _ ⥤ derived_category.plus C).is_localization\n (triangulated.subcategory.W (homotopy_category.plus.acyclic C)) :=\nbegin\n haveI := Qh_is_localization.is_equivalence C,\n refine functor.is_localization.of_equivalence\n (triangulated.subcategory.W (homotopy_category.plus.acyclic C)).Q\n (triangulated.subcategory.W (homotopy_category.plus.acyclic C)) Qh\n (Qh_is_localization.L C).as_equivalence _,\n dsimp only [functor.as_equivalence],\n exact localization.lifting.iso _ (subcategory.W (homotopy_category.plus.acyclic C)) _ _,\nend\n\nabbreviation single_functor (n : ℤ) : C ⥤ derived_category.plus C :=\nhomotopy_category.plus.single_functor C n ⋙ derived_category.plus.Qh\n\ndef homology_functor (n : ℤ) : derived_category.plus C ⥤ C :=\nderived_category.plus.ι ⋙ derived_category.homology_functor C n\n\ninstance homology_functor_additive (n : ℤ) : (homology_functor C n).additive :=\nby { dsimp only [homology_functor], apply_instance, }\n\ninstance homology_functor_is_homological (n : ℤ) : (homology_functor C n).is_homological :=\nby { dsimp only [homology_functor], apply_instance, }\n\nvariable {C}\n\ndef triangle_of_ses {S : short_complex (cochain_complex C ℤ)} (ex : S.short_exact)\n (h₁ : S.X₁.is_plus) (h₂ : S.X₂.is_plus) (h₃ : S.X₃.is_plus) :\n pretriangulated.triangle (derived_category.plus C) :=\npretriangulated.full_subcategory_lift_triangle _ (derived_category.triangle_of_ses ex)\n h₁.Q h₂.Q h₃.Q\n\nlemma triangle_of_ses_dist {S : short_complex (cochain_complex C ℤ)} (ex : S.short_exact)\n (h₁ : S.X₁.is_plus) (h₂ : S.X₂.is_plus) (h₃ : S.X₃.is_plus) :\n triangle_of_ses ex h₁ h₂ h₃ ∈ dist_triang (derived_category.plus C) :=\nbegin\n change (full_subcategory_inclusion _).map_triangle.obj (triangle_of_ses ex h₁ h₂ h₃)\n ∈ dist_triang (derived_category C),\n refine pretriangulated.isomorphic_distinguished _ (derived_category.triangle_of_ses_dist ex) _\n (pretriangulated.full_subcategory_lift_triangle_iso derived_category.is_plus\n (derived_category.triangle_of_ses ex) _ _ _),\nend\n\nend plus\n\nend derived_category\n", "meta": {"author": "joelriou", "repo": "homotopical_algebra", "sha": "697f49d6744b09c5ef463cfd3e35932bdf2c78a3", "save_path": "github-repos/lean/joelriou-homotopical_algebra", "path": "github-repos/lean/joelriou-homotopical_algebra/homotopical_algebra-697f49d6744b09c5ef463cfd3e35932bdf2c78a3/src/for_mathlib/algebra/homology/derived_category_plus.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.39606816627404173, "lm_q1q2_score": 0.2103951224197264}} {"text": "import data.cpi.semantics.interaction_tensor data.cpi.transition\nimport tactic.abel\n\nnamespace cpi\n\nvariables {ℂ ℍ : Type} {ω : context} [half_ring ℂ] [decidable_eq ℂ]\n\n/-- Maps a potential transition to the interaction space. -/\ndef potential_interaction_space [cpi_equiv ℍ ω] {Γ} {ℓ : lookup ℍ ω Γ} {A : prime_species ℍ ω Γ}\n : transition.transition_from ℓ A.val\n → interaction_space ℂ ℍ ω Γ\n| ⟨ _, # a , @production.concretion _ _ _ b y G, tr ⟩ := fin_fn.single ⟨ ⟦ A ⟧, ⟨ b, y, ⟦ G ⟧ ⟩, a ⟩ 1\n| ⟨ _, τ@'_, E, tr ⟩ := 0\n| ⟨ _, τ⟨_⟩, E, tr ⟩ := 0\n\nlemma potential_interaction_space.equiv [cpi_equiv ℍ ω] {Γ} {ℓ : lookup ℍ ω Γ}\n {A B : prime_species ℍ ω Γ} :\n ∀ {k} {α : label ℍ Γ k} {E E' : production ℍ ω Γ k}\n {t : A.val [ℓ, α]⟶ E} {t' : B.val [ℓ, α]⟶ E'}\n , A ≈ B → E ≈ E'\n → @potential_interaction_space ℂ ℍ ω _ _ _ Γ ℓ _ (transition.transition_from.mk t)\n = potential_interaction_space (transition.transition_from.mk t')\n| _ (# a) (@production.concretion _ _ _ b y E) (production.concretion E') t t' eqA (production.equiv.concretion eqE) := begin\n unfold transition.transition_from.mk potential_interaction_space,\n have : ⟦ A ⟧ = ⟦ B ⟧ := quot.sound eqA,\n have : ⟦ E ⟧ = ⟦ E' ⟧ := quot.sound eqE,\n rw [‹⟦ A ⟧ = ⟦ B ⟧›, ‹⟦ E ⟧ = ⟦ E' ⟧›],\nend\n| _ (τ@'_) E E' t t' _ _ := rfl\n| _ (τ⟨_⟩) E E' t t' _ _ := rfl\n\n/-- Compute the potential interaction space for all transitions from a prime species. -/\ndef potential_interaction_space.from_prime [cpi_equiv ℍ ω] {Γ} (ℓ : lookup ℍ ω Γ) (A : prime_species ℍ ω Γ)\n : interaction_space ℂ ℍ ω Γ\n := finset.sum (fintype.elems (transition.transition_from ℓ A.val)) potential_interaction_space\n\n/-- Compute the potential interaction space for all transitions from a species's prime conponents. -/\ndef potential_interaction_space.from_species [cpi_equiv ℍ ω] {Γ} (ℓ : lookup ℍ ω Γ) (A : species ℍ ω Γ)\n : interaction_space ℂ ℍ ω Γ\n := (cpi_equiv.prime_decompose A).sum' (potential_interaction_space.from_prime ℓ)\n\n/-- `potential_interaction_space.from_species`, lifted to quotients. -/\ndef potential_interaction_space.from_species' [cpi_equiv_prop ℍ ω] {Γ} (ℓ : lookup ℍ ω Γ) (A : species' ℍ ω Γ)\n : interaction_space ℂ ℍ ω Γ := (cpi_equiv.prime_decompose' A).sum' (λ B, quot.lift_on B\n (potential_interaction_space.from_prime ℓ)\n (λ B₁ B₂ equ, begin\n cases cpi_equiv_prop.transition_iso ℓ equ with iso,\n let isoF := cpi_equiv_prop.transition_from_iso iso,\n suffices : ∀ x\n , (@potential_interaction_space ℂ ℍ ω _ _ _ _ ℓ _ x)\n = potential_interaction_space (isoF.to_fun x),\n from fintype.sum_iso _ _ isoF this,\n\n rintros ⟨ k, α, E, t ⟩,\n simp only [\n isoF, cpi_equiv_prop.transition_from_iso,\n cpi_equiv.transition_from_fwd, cpi_equiv.transition_from_inv],\n have eqE := (iso k α).2 E t,\n cases ((iso k α).fst).to_fun ⟨E, t⟩ with E' t',\n from potential_interaction_space.equiv equ eqE,\n end))\n\nlemma potential_interaction_space.species_eq [cpi_equiv_prop ℍ ω] {Γ} {ℓ : lookup ℍ ω Γ} {A : species ℍ ω Γ}\n : (potential_interaction_space.from_species ℓ A : interaction_space ℂ ℍ ω Γ)\n = potential_interaction_space.from_species' ℓ ⟦ A ⟧\n := by simp only\n [potential_interaction_space.from_species, potential_interaction_space.from_species',\n quot.lift_on, quotient.mk, cpi_equiv.prime_decompose', multiset.sum',\n function.comp, multiset.map_map]\n\n/-- Maps a spontaneous/immediate transition to a process space.\n\n This computes the Σ[x ∈ B [τ@k]—→ C] k and Σ[x ∈ B [τ⟨ a, b ⟩]—→ C] M(a, b)\n components of the definition of d(c ◯ A)/dt. -/\ndef immediate_process_space [cpi_equiv ℍ ω] {Γ} {ℓ : lookup ℍ ω Γ} (conc : ℍ ↪ ℂ)\n {A : prime_species ℍ ω Γ}\n : transition.transition_from ℓ A.val\n → process_space ℂ ℍ ω Γ\n| ⟨ _, # a , _, tr ⟩ := 0\n| ⟨ _, τ@'k, production.species B, tr ⟩ :=\n conc k • (to_process_space ⟦ B ⟧ - fin_fn.single ⟦ A ⟧ 1)\n| ⟨ _, τ⟨ n ⟩, _, tr ⟩ := 0\n\nlemma immediate_process_space.equiv [cpi_equiv ℍ ω] {Γ} {ℓ : lookup ℍ ω Γ} {conc : ℍ ↪ ℂ}\n {A B : prime_species ℍ ω Γ} :\n ∀ {k} {α : label ℍ Γ k} {E E' : production ℍ ω Γ k}\n {t : A.val [ℓ, α]⟶ E} {t' : B.val [ℓ, α]⟶ E'}\n , A ≈ B → E ≈ E'\n → immediate_process_space conc (transition.transition_from.mk t)\n = immediate_process_space conc (transition.transition_from.mk t')\n| _ (# a ) E E' t t' eqA eqE := rfl\n| _ (τ@'k) (production.species E) (production.species E') t t' eqA (production.equiv.species eqE) := begin\n unfold transition.transition_from.mk immediate_process_space,\n have : ⟦ A ⟧ = ⟦ B ⟧ := quot.sound eqA,\n have : ⟦ E ⟧ = ⟦ E' ⟧ := quot.sound eqE,\n rw [‹⟦ A ⟧ = ⟦ B ⟧›, ‹⟦ E ⟧ = ⟦ E' ⟧›],\nend\n| _ (τ⟨ n ⟩) E E' t t' eqA eqE := rfl\n\n/-- Compute the immediate process space for all transitions from a prime species. -/\ndef immediate_process_space.from_prime [cpi_equiv ℍ ω] {Γ} (conc : ℍ ↪ ℂ) (ℓ : lookup ℍ ω Γ)\n (A : prime_species ℍ ω Γ)\n : process_space ℂ ℍ ω Γ\n := finset.sum (fintype.elems (transition.transition_from ℓ A.val)) (immediate_process_space conc)\n\n/-- Compute the immediate process space for all transitions from a species's prime conponents. -/\ndef immediate_process_space.from_species [cpi_equiv ℍ ω] {Γ} (conc : ℍ ↪ ℂ) (ℓ : lookup ℍ ω Γ) (A : species ℍ ω Γ)\n : process_space ℂ ℍ ω Γ\n := (cpi_equiv.prime_decompose A).sum' (immediate_process_space.from_prime conc ℓ)\n\n/-- `immediate_process_space.from_species`, lifted to quotients. -/\ndef immediate_process_space.from_species' [cpi_equiv_prop ℍ ω] {Γ} (conc : ℍ ↪ ℂ) (ℓ : lookup ℍ ω Γ) (A : species' ℍ ω Γ)\n : process_space ℂ ℍ ω Γ := (cpi_equiv.prime_decompose' A).sum' (λ B, quot.lift_on B\n (immediate_process_space.from_prime conc ℓ)\n (λ B₁ B₂ equ, begin\n cases cpi_equiv_prop.transition_iso ℓ equ with iso,\n let isoF := cpi_equiv_prop.transition_from_iso iso,\n suffices : ∀ x\n , immediate_process_space conc x\n = immediate_process_space conc (isoF.to_fun x),\n from fintype.sum_iso _ _ isoF this,\n\n rintros ⟨ k, α, E, t ⟩,\n simp only [\n isoF, cpi_equiv_prop.transition_from_iso,\n cpi_equiv.transition_from_fwd, cpi_equiv.transition_from_inv],\n have eqE := (iso k α).2 E t,\n cases ((iso k α).fst).to_fun ⟨E, t⟩ with E' t',\n from immediate_process_space.equiv equ eqE,\n end))\n\nlemma immediate_process_space.species_eq [cpi_equiv_prop ℍ ω] {Γ} {conc : ℍ ↪ ℂ} {ℓ : lookup ℍ ω Γ} {A : species ℍ ω Γ}\n : immediate_process_space.from_species conc ℓ A\n = immediate_process_space.from_species' conc ℓ ⟦ A ⟧\n := by simp only\n [immediate_process_space.from_species, immediate_process_space.from_species',\n quot.lift_on, quotient.mk, cpi_equiv.prime_decompose', multiset.sum',\n function.comp, multiset.map_map]\n\n/-- The vector space of potential interactions of a process (∂P). -/\ndef process_potential [cpi_equiv ℍ ω] {Γ} (ℓ : lookup ℍ ω Γ)\n : process ℂ ℍ ω Γ → interaction_space ℂ ℍ ω Γ\n| (c ◯ A) := c • potential_interaction_space.from_species ℓ A\n| (P |ₚ Q) := process_potential P + process_potential Q\n\nlemma process_potential.nil_zero [cpi_equiv ℍ ω] {Γ} (ℓ : lookup ℍ ω Γ) (c : ℂ)\n : process_potential ℓ (c ◯ nil) = 0\n := by simp only\n [process_potential, potential_interaction_space.from_species,\n cpi_equiv.prime_decompose_nil, multiset.sum'_zero, smul_zero]\n\n/-- The vector space of immediate actions of a process (dP/dt)-/\ndef process_immediate [cpi_equiv ℍ ω]\n (M : affinity ℍ) (ℓ : lookup ℍ ω (context.extend M.arity context.nil)) (conc : ℍ ↪ ℂ)\n : process ℂ ℍ ω (context.extend M.arity context.nil)\n → process_space ℂ ℍ ω (context.extend M.arity context.nil)\n| (c ◯ A)\n := c • immediate_process_space.from_species conc ℓ A\n + (½ : ℂ) • (process_potential ℓ (c ◯ A) ⊘[conc] process_potential ℓ (c ◯ A))\n| (P |ₚ Q)\n := process_immediate P + process_immediate Q\n + (process_potential ℓ P ⊘[conc] process_potential ℓ Q)\n\nlemma process_immediate.nil_zero {conc : ℍ ↪ ℂ} [cpi_equiv ℍ ω]\n (M : affinity ℍ) (ℓ : lookup ℍ ω (context.extend M.arity context.nil))\n (c : ℂ)\n : process_immediate M ℓ conc (c ◯ nil) = 0\n := by simp only\n [process_immediate, immediate_process_space.from_species,\n process_potential.nil_zero, cpi_equiv.prime_decompose_nil,\n multiset.sum'_zero, interaction_tensor.zero_left, smul_zero, add_zero]\n\nlemma process_potential.equiv [cpi_equiv_prop ℍ ω] {Γ} (ℓ : lookup ℍ ω Γ) :\n ∀ {P Q : process ℂ ℍ ω Γ}\n , P ≈ Q → process_potential ℓ P = process_potential ℓ Q\n| P Q eq := begin\n induction eq,\n case process.equiv.refl { refl },\n case process.equiv.trans : P Q R ab bc ih_ab ih_bc { from trans ih_ab ih_bc },\n case process.equiv.symm : P Q eq ih { from symm ih },\n case process.equiv.ξ_species : c A B equ {\n suffices : potential_interaction_space.from_species ℓ A\n = potential_interaction_space.from_species ℓ B,\n { simp only [process_potential], from congr_arg ((•) c) this },\n\n calc potential_interaction_space.from_species ℓ A\n = potential_interaction_space.from_species' ℓ ⟦ A ⟧ : potential_interaction_space.species_eq\n ... = potential_interaction_space.from_species' ℓ ⟦ B ⟧ : by rw quotient.sound equ\n ... = potential_interaction_space.from_species ℓ B : potential_interaction_space.species_eq.symm\n },\n case process.equiv.ξ_parallel₁ : P P' Q eq ih {\n unfold process_potential, rw ih,\n },\n case process.equiv.ξ_parallel₂ : P Q Q' eq ih {\n unfold process_potential, rw ih,\n },\n case process.equiv.parallel_nil : P C {\n show process_potential ℓ P + process_potential ℓ (C ◯ nil) = process_potential ℓ P,\n simp only [process_potential.nil_zero, add_zero],\n },\n case cpi.process.equiv.parallel_symm { simp only [process_potential, add_comm] },\n case process.equiv.parallel_assoc { simp only [process_potential, add_assoc] },\n case process.equiv.join : A c d { simp only [process_potential, add_smul] },\n case process.equiv.split : A B c {\n simp only [process_potential, potential_interaction_space.from_species,\n cpi_equiv.prime_decompose_parallel, multiset.sum'_add, smul_add],\n },\nend\n\nprivate lemma process_immediate.join [cpi_equiv_prop ℍ ω] (M : affinity ℍ)\n (ℓ : lookup ℍ ω (context.extend M.arity context.nil)) {conc : ℍ ↪ ℂ} (c d : ℂ)\n (Ds : interaction_space ℂ ℍ ω (context.extend (M.arity) context.nil))\n (Ps : process_space ℂ ℍ ω (context.extend (M.arity) context.nil))\n : (c • Ds) ⊘[conc] (d • Ds) + ((½ : ℂ) • (c • Ds) ⊘[conc] (c • Ds) + (½ : ℂ) • (d • Ds) ⊘[conc] (d • Ds))\n = (½ : ℂ) • (c • Ds + d • Ds) ⊘[conc] (c • Ds + d • Ds) := begin\n generalize ehalf : (½ : ℂ) = half,\n\n rw [interaction_tensor.left_distrib (c • Ds) (d • Ds),\n interaction_tensor.right_distrib (c • Ds),\n interaction_tensor.right_distrib (d • Ds),\n interaction_tensor.comm (d • Ds) (c • Ds)],\n\n calc (c • Ds) ⊘ (d • Ds)\n + (half • (c • Ds) ⊘ (c • Ds) + half • (d • Ds) ⊘ (d • Ds))\n\n = (1 : ℂ) • (c • Ds) ⊘[conc] (d • Ds)\n + (half • (c • Ds) ⊘[conc] (c • Ds) + half • (d • Ds) ⊘[conc] (d • Ds))\n : by simp only [one_smul]\n\n ... = (half + half) • (c • Ds) ⊘[conc] (d • Ds)\n + (half • (c • Ds) ⊘[conc] (c • Ds) + half • (d • Ds) ⊘[conc] (d • Ds))\n : by rw [half_ring.one_is_two_halves, ← ehalf]\n\n ... = half • (c • Ds) ⊘[conc] (c • Ds) + half • (c • Ds) ⊘[conc] (d • Ds)\n + (half • (c • Ds) ⊘[conc] (d • Ds) + half • (d • Ds) ⊘[conc] (d • Ds))\n : begin\n simp only [add_smul],\n generalize : half • (c • Ds) ⊘[conc] (d • Ds) = cd,\n generalize : half • (c • Ds) ⊘[conc] (c • Ds) = cc,\n generalize : half • (d • Ds) ⊘[conc] (d • Ds) = dd,\n abel,\n end\n\n ... = half • ((c • Ds) ⊘ (c • Ds) + (c • Ds) ⊘ (d • Ds)\n + ((c • Ds) ⊘ (d • Ds) + (d • Ds) ⊘ (d • Ds)))\n : by simp only [smul_add]\nend\n\nprivate lemma process_immediate.split [cpi_equiv_prop ℍ ω] [add_monoid ℍ]\n (M : affinity ℍ) (ℓ : lookup ℍ ω (context.extend M.arity context.nil))\n (conc : ℍ ↪ ℂ) (c : ℂ)\n (A B : species ℍ ω (context.extend M.arity context.nil))\n : process_immediate M ℓ conc (c ◯ (A |ₛ B))\n = process_immediate M ℓ conc (c ◯ A |ₚ c ◯ B) := begin\n simp only [process_immediate, immediate_process_space.from_species,\n process_potential.equiv ℓ process.equiv.split,\n cpi_equiv.prime_decompose_parallel, multiset.sum'_add, smul_add],\n\n generalize : multiset.sum' (cpi_equiv.prime_decompose A) (immediate_process_space.from_prime conc ℓ) = dA,\n generalize : multiset.sum' (cpi_equiv.prime_decompose B) (immediate_process_space.from_prime conc ℓ) = dB,\n\n have : process_potential ℓ (c ◯ A |ₚ c ◯ B) = process_potential ℓ (c ◯ A) + process_potential ℓ (c ◯ B)\n := rfl,\n simp only [this],\n\n generalize : process_potential ℓ (c ◯ A) = pA,\n generalize : process_potential ℓ (c ◯ B) = pB,\n\n simp only [interaction_tensor.left_distrib, interaction_tensor.right_distrib, smul_add],\n rw interaction_tensor.comm pB pA,\n\n generalize : ½ • pA ⊘[conc] pA = iA,\n generalize : ½ • pB ⊘[conc] pB = iB,\n generalize : pA ⊘[conc] pB = iAB,\n\n calc c • dA + c • dB + (iA + (½ : ℂ) • iAB + ((½ : ℂ) • iAB + iB))\n = c • dA + c • dB + (iA + iB + ((½ : ℂ) • iAB + (½ : ℂ) • iAB)) : by abel\n ... = c • dA + c • dB + (iA + iB + iAB)\n : by rw [← add_smul, ← half_ring.one_is_two_halves, one_smul]\n ... = c • dA + iA + (c • dB + iB) + iAB : by abel\nend\n\nlemma process_immediate.equiv [cpi_equiv_prop ℍ ω] [add_monoid ℍ]\n (M : affinity ℍ) (ℓ : lookup ℍ ω (context.extend M.arity context.nil))\n (conc : ℍ ↪ ℂ)\n : ∀ {P Q : process ℂ ℍ ω (context.extend M.arity context.nil)}\n , P ≈ Q\n → process_immediate M ℓ conc P\n = process_immediate M ℓ conc Q\n| P Q eq := begin\n induction eq,\n case process.equiv.refl { from rfl },\n case process.equiv.symm : A B eq ih { from (symm ih) },\n case process.equiv.trans : P Q R ab bc ih_ab ih_bc { from trans ih_ab ih_bc },\n\n case process.equiv.ξ_species : c A B equ {\n suffices : immediate_process_space.from_species conc ℓ A\n = immediate_process_space.from_species conc ℓ B,\n { simp only [process_immediate],\n rw [process_potential.equiv ℓ (process.equiv.ξ_species equ), this]\n },\n\n calc immediate_process_space.from_species conc ℓ A\n = immediate_process_space.from_species' conc ℓ ⟦ A ⟧ : immediate_process_space.species_eq\n ... = immediate_process_space.from_species' conc ℓ ⟦ B ⟧ : by rw quotient.sound equ\n ... = immediate_process_space.from_species conc ℓ B : immediate_process_space.species_eq.symm\n },\n case process.equiv.ξ_parallel₁ : P P' Q eq ih {\n simp only [process_immediate, process_potential.equiv ℓ eq, ih],\n },\n case process.equiv.ξ_parallel₂ : P Q Q' eq ih {\n simp only [process_immediate, process_potential.equiv ℓ eq, ih],\n },\n case process.equiv.parallel_nil {\n simp only [process_immediate, process_immediate.nil_zero, add_zero,\n process_potential.nil_zero, interaction_tensor.zero_left],\n },\n case cpi.process.equiv.parallel_symm : P Q {\n simp only [process_immediate, add_comm, interaction_tensor.comm],\n },\n case process.equiv.parallel_assoc : P Q R {\n simp only [process_immediate, add_assoc] ,\n simp only [add_left_comm],\n refine congr_arg _ _,\n refine congr_arg _ _,\n refine congr_arg _ _,\n\n unfold process_potential,\n\n generalize : process_potential ℓ P = p,\n generalize : process_potential ℓ Q = q,\n generalize : process_potential ℓ R = r,\n\n calc p ⊘ q + (p + q) ⊘ r\n = p ⊘[conc] q + p ⊘[conc] r + q ⊘ r : by rw [interaction_tensor.left_distrib, add_assoc]\n ... = q ⊘[conc] r + p ⊘[conc] q + p ⊘[conc] r : by simp only [add_comm, add_left_comm, interaction_tensor.comm]\n ... = q ⊘[conc] r + p ⊘[conc] (q + r) : by rw [add_assoc, ← interaction_tensor.right_distrib]\n },\n case process.equiv.join : A c d {\n simp only [process_immediate, process_potential],\n\n generalize : potential_interaction_space.from_species ℓ A = Ds,\n generalize : immediate_process_space.from_species conc ℓ A = Ps,\n\n suffices\n : (c • Ds) ⊘[conc] (d • Ds) + ((½ : ℂ) • ((c • Ds) ⊘[conc] (c • Ds)) + (½ : ℂ) • (d • Ds) ⊘[conc] (d • Ds))\n = (½ : ℂ) • ((c • Ds + d • Ds) ⊘[conc] (c • Ds + d • Ds)),\n { simp only [add_assoc, add_comm, add_smul, add_left_comm, this] },\n\n from process_immediate.join M ℓ c d Ds Ps,\n },\n case process.equiv.split : A B c {\n from process_immediate.split M ℓ conc c A B\n },\nend\n\n/-- dP/dt lifted to quotients. -/\ndef process_immediate.quot [cpi_equiv_prop ℍ ω] [add_monoid ℍ]\n (M : affinity ℍ) (ℓ : lookup ℍ ω (context.extend M.arity context.nil))\n (conc : ℍ ↪ ℂ)\n : process' ℂ ℍ ω (context.extend M.arity context.nil)\n → process_space ℂ ℍ ω (context.extend M.arity context.nil)\n| P := quot.lift_on P (process_immediate M ℓ conc)\n (λ P Q, process_immediate.equiv M ℓ conc)\n\n/-- dP/dt lifted to process spaces. -/\ndef process_immediate.space [cpi_equiv_prop ℍ ω] [half_ring ℍ]\n (M : affinity ℍ) (ℓ : lookup ℍ ω (context.extend M.arity context.nil))\n (conc : ℍ ↪ ℂ)\n : process_space ℂ ℍ ω (context.extend M.arity context.nil)\n → process_space ℂ ℍ ω (context.extend M.arity context.nil)\n| P := process_immediate.quot M ℓ conc (process.from_space P)\n\nend cpi\n\n#lint-\n", "meta": {"author": "continuouspi", "repo": "lean-cpi", "sha": "443bf2cb236feadc45a01387099c236ab2b78237", "save_path": "github-repos/lean/continuouspi-lean-cpi", "path": "github-repos/lean/continuouspi-lean-cpi/lean-cpi-443bf2cb236feadc45a01387099c236ab2b78237/src/data/cpi/semantics/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5312093585306514, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.21039511654084508}} {"text": "/-\nFile: signature_recover_public_key_get_generator_point_soundness.lean\n\nAutogenerated file.\n-/\nimport starkware.cairo.lean.semantics.soundness.hoare\nimport .signature_recover_public_key_code\nimport ..signature_recover_public_key_spec\nopen tactic\n\nopen starkware.cairo.common.cairo_secp.signature\nopen starkware.cairo.common.cairo_secp.bigint\nopen starkware.cairo.common.cairo_secp.ec\n\nvariables {F : Type} [field F] [decidable_eq F] [prelude_hyps F]\nvariable mem : F → F\nvariable σ : register_state F\n\n/- starkware.cairo.common.cairo_secp.signature.get_generator_point autogenerated soundness theorem -/\n\ntheorem auto_sound_get_generator_point\n -- code is in memory at σ.pc\n (h_mem : mem_at mem code_get_generator_point σ.pc)\n -- input arguments on the stack\n -- conclusion\n : ensures_ret mem σ (λ κ τ, τ.ap = σ.ap + 6 ∧ spec_get_generator_point mem κ (cast_EcPoint mem (τ.ap - 6))) :=\nbegin\n apply ensures_of_ensuresb, intro νbound,\n have h_mem_rec := h_mem,\n unpack_memory code_get_generator_point at h_mem with ⟨hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12⟩,\n -- return\n step_assert_eq hpc0 hpc1 with hret0,\n step_assert_eq hpc2 hpc3 with hret1,\n step_assert_eq hpc4 hpc5 with hret2,\n step_assert_eq hpc6 hpc7 with hret3,\n step_assert_eq hpc8 hpc9 with hret4,\n step_assert_eq hpc10 hpc11 with hret5,\n step_ret hpc12,\n -- finish\n step_done, use_only [rfl, rfl],\n split, refl,\n -- Final Proof\n -- user-provided reduction\n suffices auto_spec: auto_spec_get_generator_point mem _ _,\n { apply sound_get_generator_point, apply auto_spec },\n -- prove the auto generated assertion\n dsimp [auto_spec_get_generator_point],\n try { norm_num1 }, try { arith_simps },\n try { split, linarith },\n try { ensures_simps; try { simp only [add_neg_eq_sub] }, },\n try { dsimp [cast_EcPoint, cast_BigInt3] },\n try { arith_simps }, try { simp only [hret0, hret1, hret2, hret3, hret4, hret5] },\n try { arith_simps; try { split }; triv <|> refl <|> simp <|> abel; try { norm_num } },\nend\n\n", "meta": {"author": "starkware-libs", "repo": "formal-proofs", "sha": "35613c65b6715601bbc0a550d52754f8e7d93e30", "save_path": "github-repos/lean/starkware-libs-formal-proofs", "path": "github-repos/lean/starkware-libs-formal-proofs/formal-proofs-35613c65b6715601bbc0a550d52754f8e7d93e30/src/starkware/cairo/common/cairo_secp/verification/verification/signature_recover_public_key_get_generator_point_soundness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.411110869232168, "lm_q1q2_score": 0.21037225816046312}} {"text": "import pseudo_normed_group.category.CompHausFiltPseuNormGrp\n\nuniverse variables u\n\nopen category_theory\nopen_locale nnreal\n\nlocal attribute [instance] type_pow\n\nnoncomputable theory\n\n/-- The category of CompHaus-ly filtered pseudo-normed groups with exhaustive filtrations\nand with strict morphisms. -/\nstructure CompHausFiltPseuNormGrp₁ : Type (u+1) :=\n(M : Type u)\n[str : comphaus_filtered_pseudo_normed_group M]\n(exhaustive' : ∀ m : M, ∃ c, m ∈ pseudo_normed_group.filtration M c)\n\nnamespace CompHausFiltPseuNormGrp₁\n\ninstance : has_coe_to_sort CompHausFiltPseuNormGrp₁ Type* := ⟨λ M, M.M⟩\ninstance (M : CompHausFiltPseuNormGrp₁) : comphaus_filtered_pseudo_normed_group M := M.str\n\nlemma exhaustive (M : CompHausFiltPseuNormGrp₁) (m : M) :\n ∃ c, m ∈ pseudo_normed_group.filtration M c := M.exhaustive' _\n\ninstance : large_category CompHausFiltPseuNormGrp₁.{u} :=\n{ hom := λ A B, strict_comphaus_filtered_pseudo_normed_group_hom A B,\n id := λ A, strict_comphaus_filtered_pseudo_normed_group_hom.id,\n comp := λ A B C f g, g.comp f }\n\n/-- The \"forget ₁\" functor from `CompHaus`-ly filtered normed groups with strict morphisms,\n to CompHaus-ly filtered pseudo-normed groups with bounded morphisms, which is the\n identity on objects. -/\n@[simps]\ndef _root_.CHFPNG₁_to_CHFPNGₑₗ : CompHausFiltPseuNormGrp₁ ⥤ CompHausFiltPseuNormGrp :=\n{ obj := λ M, CompHausFiltPseuNormGrp.of M,\n map := λ M₁ M₂ f, f.to_chfpsng_hom }\n\ninstance : faithful (CHFPNG₁_to_CHFPNGₑₗ.{u}) :=\n{ map_injective' := λ M₁ M₂ f g h,\n by { ext x, apply_fun (λ φ, φ.to_fun) at h, exact congr_fun h x } }\n\ninstance : concrete_category CompHausFiltPseuNormGrp₁.{u} :=\n{ forget :=\n { obj := λ M, M.M,\n map := λ A B f, f },\n forget_faithful := ⟨⟩ } .\n\ndef level : ℝ≥0 ⥤ CompHausFiltPseuNormGrp₁.{u} ⥤ CompHaus :=\n{ obj := λ c,\n { obj := λ M, CompHaus.of $ pseudo_normed_group.filtration M c,\n map := λ A B f, ⟨_, f.level_continuous _⟩ },\n map := λ c₁ c₂ h,\n { app := λ M, by letI : fact (c₁ ≤ c₂) := ⟨le_of_hom h⟩; exact\n ⟨_, comphaus_filtered_pseudo_normed_group.continuous_cast_le _ _⟩ } } .\n\nsection limits\n\n/-!\nIn this section, we show (hopefully ;)) that `CompHausFiltPseuNormGrp₁` has limits.\n-/\n\nvariables {J : Type u} [small_category J] (G : J ⥤ CompHausFiltPseuNormGrp₁.{u})\n\nopen pseudo_normed_group\nopen category_theory.limits\n\n/-- This is a bifunctor which associates to each `c : ℝ≥0` and `j : J`,\n the `c`-th term of the filtration of `G.obj j`. -/\ndef cone_point_diagram : as_small.{u} ℝ≥0 ⥤ J ⥤ CompHaus.{u} :=\nas_small.down ⋙ level ⋙ (whiskering_left _ _ _).obj G\n\n@[derive [topological_space, t2_space]]\ndef cone_point_type_filt (c : ℝ≥0) : Type u :=\n{ x : Π j : J, filtration (G.obj j) c | ∀ ⦃i j : J⦄ (e : i ⟶ j), (G.map e).level (x _) = x _ }\n\ninstance (c : ℝ≥0) : compact_space (cone_point_type_filt G c) :=\n(CompHaus.limit_cone.{_ u} (((cone_point_diagram G).obj (as_small.up.obj c)))).X.is_compact -- ;-)\n\nnamespace cone_point_type_filt\n\nvariable {G}\n\ninstance (c : ℝ≥0) : has_coe_to_fun (cone_point_type_filt G c)\n (λ x, Π j : J, filtration (G.obj j) c) := ⟨λ x, x.1⟩\n\n@[ext] lemma ext {c} (x y : cone_point_type_filt G c) :\n (⇑x : Π j : J, filtration (G.obj j) c) = y → x = y := subtype.ext\n\n@[simp] lemma level_apply {c : ℝ≥0} {i j : J} (x : cone_point_type_filt G c) (e : i ⟶ j) :\n (G.map e).level (x i) = x j := x.2 e\n\n@[simp] lemma map_apply {c : ℝ≥0} {i j : J} (x : cone_point_type_filt G c) (e : i ⟶ j) :\n (G.map e) (x i) = x j := by {rw ← (G.map e).coe_level, simp }\n\ndef trans {c₁ c₂ : ℝ≥0} (h : c₁ ≤ c₂) (x : cone_point_type_filt G c₁) : cone_point_type_filt G c₂ :=\n⟨λ j, cast_le' h (x j), λ i j e, by { ext, simp }⟩\n\n@[simp] lemma trans_apply {c₁ c₂ : ℝ≥0} (h : c₁ ≤ c₂) (x : cone_point_type_filt G c₁) (j : J) :\n x.trans h j = cast_le' h (x j) := by { ext, refl }\n\nlemma trans_injective {c₁ c₂ : ℝ≥0} (h : c₁ ≤ c₂) :\n function.injective (trans h : cone_point_type_filt G c₁ → cone_point_type_filt G c₂) :=\nbegin\n intros x y hh,\n ext j,\n apply_fun (λ e, (e j : G.obj j)) at hh,\n exact hh\nend\n\nlemma trans_continuous {c₁ c₂ : ℝ≥0} (h : c₁ ≤ c₂) :\n continuous (trans h : cone_point_type_filt G c₁ → cone_point_type_filt G c₂) :=\nbegin\n -- ;-)\n let η := ((cone_point_diagram G).map (as_small.up.map $ hom_of_le $ h)),\n let hS := (CompHaus.limit_cone_is_limit.{_ u} (((cone_point_diagram G).obj (as_small.up.obj c₂)))),\n let T := (CompHaus.limit_cone.{_ u} (((cone_point_diagram G).obj (as_small.up.obj c₁)))),\n exact (hS.map T η).continuous,\nend\n\nlemma continuous_apply {c : ℝ≥0} (j : J) : continuous (λ t : cone_point_type_filt G c, t j) :=\nbegin\n change continuous ((λ u : Π j, filtration (G.obj j) c, u j) ∘\n (λ u : cone_point_type_filt G c, ⇑u)),\n apply continuous.comp,\n apply continuous_apply,\n apply continuous_subtype_coe,\nend\n\ninstance {c} : has_zero (cone_point_type_filt G c) := has_zero.mk $\n⟨λ j, 0, λ i j e, by { ext, dsimp, simp }⟩\n\ninstance {c} : has_neg (cone_point_type_filt G c) := has_neg.mk $ λ x,\n⟨λ j, - (x j), λ i j e, by { ext, dsimp, simp, }⟩\n\ndef add' {c₁ c₂} (x : cone_point_type_filt G c₁) (y : cone_point_type_filt G c₂) :\n cone_point_type_filt G (c₁ + c₂) :=\n⟨λ j, add' (x j, y j), λ i j e, by { ext, dsimp, simp, }⟩\n\n@[simp] lemma zero_apply {c} (j : J) : (0 : cone_point_type_filt G c) j = 0 := rfl\n@[simp] lemma neg_apply {c} (j : J) (x : cone_point_type_filt G c) : (-x) j = - (x j) := rfl\n@[simp] lemma add'_apply_coe {c₁ c₂} (j : J) (x : cone_point_type_filt G c₁)\n (y : cone_point_type_filt G c₂) : ((x.add' y) j : G.obj j) = x j + y j := rfl\n\nlemma continuous_neg {c} : continuous (λ x : cone_point_type_filt G c, - x) :=\nbegin\n apply continuous.subtype_mk,\n apply continuous_pi,\n intros j,\n change continuous ((λ x, -x) ∘ (λ a : cone_point_type_filt G c, (a j))),\n apply continuous.comp,\n apply comphaus_filtered_pseudo_normed_group.continuous_neg',\n apply continuous_apply,\nend\n\nlemma continuous_add' {c1 c2} :\n continuous (λ t : cone_point_type_filt G c1 × cone_point_type_filt G c2, t.1.add' t.2) :=\nbegin\n apply continuous.subtype_mk,\n apply continuous_pi,\n intros j,\n let A : cone_point_type_filt G c1 × cone_point_type_filt G c2 →\n (Π j : J, filtration (G.obj j) c1) × (Π j : J, filtration (G.obj j) c2) :=\n λ t, (t.1,t.2),\n let B : (Π j : J, filtration (G.obj j) c1) × (Π j : J, filtration (G.obj j) c2) →\n filtration (G.obj j) c1 × filtration (G.obj j) c2 := λ t, (t.1 j, t.2 j),\n let C : filtration (G.obj j) c1 × filtration (G.obj j) c2 → filtration (G.obj j) (c1 + c2) :=\n pseudo_normed_group.add',\n change continuous (C ∘ B ∘ A),\n apply continuous.comp,\n apply comphaus_filtered_pseudo_normed_group.continuous_add',\n apply continuous.comp,\n { apply continuous.prod_mk,\n { change continuous ((λ t : Π j : J, filtration (G.obj j) c1, t j) ∘ prod.fst),\n apply continuous.comp,\n apply _root_.continuous_apply,\n exact continuous_fst },\n { change continuous ((λ t : Π j : J, filtration (G.obj j) c2, t j) ∘ prod.snd),\n apply continuous.comp,\n apply _root_.continuous_apply,\n exact continuous_snd } },\n apply continuous.prod_map,\n apply continuous_subtype_coe,\n apply continuous_subtype_coe,\nend\n\nend cone_point_type_filt\n\ndef cone_point_type_setoid : setoid (Σ (c : ℝ≥0), cone_point_type_filt G c) :=\n{ r := λ x y, ∃ (d : ℝ≥0) (hx : x.1 ≤ d) (hy : y.1 ≤ d), x.2.trans hx = y.2.trans hy,\n iseqv := begin\n refine ⟨_,_,_⟩,\n { rintro ⟨c,x⟩,\n use [c, le_refl _, le_refl _] },\n { rintro ⟨c,x⟩ ⟨d,y⟩ ⟨e,h1,h2,h⟩,\n dsimp at *,\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n ext j : 3,\n symmetry,\n apply_fun (λ e, (e j : G.obj j)) at h,\n exact h },\n { rintro ⟨c,x⟩ ⟨d,y⟩ ⟨e,z⟩ ⟨i,h1,hh1,hhh1⟩ ⟨j,h2,hh2,hhh2⟩,\n dsimp at *,\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n ext jj : 3,\n apply_fun (λ e, (e jj : G.obj jj)) at hhh1,\n apply_fun (λ e, (e jj : G.obj jj)) at hhh2,\n erw [hhh1, hhh2], refl },\n end }\n\ndef cone_point_type : Type u := quotient (cone_point_type_setoid G)\n\nnamespace cone_point_type\nvariable {G}\n\ndef incl (c : ℝ≥0) : cone_point_type_filt G c → cone_point_type G :=\nquotient.mk' ∘ sigma.mk c\n\nlemma incl_injective (c : ℝ≥0) :\n function.injective (incl c : cone_point_type_filt G c → cone_point_type G) :=\nbegin\n intros x y h,\n replace h := quotient.exact' h,\n obtain ⟨d,h1,h2,h⟩ := h,\n dsimp at h1 h2 h,\n rw (show h1 = h2, by refl) at h,\n apply cone_point_type_filt.trans_injective h2,\n exact h,\nend\n\n@[simp]\nlemma incl_trans {c₁ c₂ : ℝ≥0} (h : c₁ ≤ c₂) (x : cone_point_type_filt G c₁) :\n incl _ (x.trans h) = incl _ x :=\nbegin\n apply quotient.sound',\n refine ⟨c₁ ⊔ c₂, by simp, by simp, _⟩,\n ext,\n refl,\nend\n\nlemma incl_jointly_surjective (x : cone_point_type G) :\n ∃ (c : ℝ≥0) (y : cone_point_type_filt G c), incl c y = x :=\nbegin\n rcases x,\n obtain ⟨c,y⟩ := x,\n use [c,y],\n refl,\nend\n\ndef index (x : cone_point_type G) : ℝ≥0 := (incl_jointly_surjective x).some\n\ndef preimage (x : cone_point_type G) : cone_point_type_filt G x.index :=\n (incl_jointly_surjective x).some_spec.some\n\n@[simp]\nlemma preimage_spec (x : cone_point_type G) : incl _ x.preimage = x :=\n (incl_jointly_surjective x).some_spec.some_spec\n\n@[simp]\nlemma coe_incl_preimage_apply {c} (x : cone_point_type_filt G c) (j : J) :\n ((incl c x).preimage j : G.obj j) = x j :=\nbegin\n let e := c ⊔ (incl c x).index,\n change _ = (cast_le' le_sup_left (x j) : G.obj j),\n rw ← cone_point_type_filt.trans_apply (le_sup_left : _ ≤ e) x j,\n rw ← coe_cast_le' (le_sup_right : _ ≤ e),\n rw ← cone_point_type_filt.trans_apply,\n congr' 2,\n apply incl_injective,\n simp,\nend\n\n\ninstance : has_zero (cone_point_type G) := ⟨incl 0 0⟩\n\nlemma zero_def : (0 : cone_point_type G) = incl 0 0 := rfl\n\ninstance : has_neg (cone_point_type G) := has_neg.mk $\nλ x, incl _ (-x.preimage)\n\nlemma neg_def (x : cone_point_type G) : -x = incl _ (-x.preimage) := rfl\n\ninstance : has_add (cone_point_type G) := has_add.mk $\nλ x y, incl _ (x.preimage.add' y.preimage)\n\nlemma add_def (x y : cone_point_type G) : x + y = incl _ (x.preimage.add' y.preimage) := rfl\n\nlemma incl_add_incl (c₁ c₂ : ℝ≥0)\n (x₁ : cone_point_type_filt G c₁) (x₂ : cone_point_type_filt G c₂) :\n (incl c₁ x₁) + (incl c₂ x₂) = (incl (c₁ + c₂) (x₁.add' x₂)) :=\nbegin\n rw add_def,\n apply quotient.sound',\n refine ⟨max _ _, le_max_left _ _, le_max_right _ _, _⟩,\n ext,\n simp only [cone_point_type_filt.trans_apply, cone_point_type_filt.add'_apply_coe,\n coe_cast_le, coe_incl_preimage_apply, coe_cast_le'],\nend\n\nlemma zero_add (x : cone_point_type G) : 0 + x = x :=\nbegin\n conv_rhs {rw ← x.preimage_spec},\n apply quotient.sound',\n refine ⟨(0 : cone_point_type G).index + x.index, by simp, by simp, _⟩,\n dsimp,\n ext j : 3,\n simp only [cone_point_type_filt.trans_apply, cone_point_type_filt.add'_apply_coe, coe_cast_le'],\n simp only [add_left_eq_self],\n apply coe_incl_preimage_apply,\nend\n\nlemma add_comm (x y : cone_point_type G) : x + y = y + x :=\nbegin\n apply quotient.sound',\n refine ⟨x.index + y.index, le_refl _, le_of_eq (by {dsimp, rw add_comm}), _⟩,\n dsimp,\n ext j : 3,\n simp only [cone_point_type_filt.trans_apply, cone_point_type_filt.add'_apply_coe,\n coe_cast_le, coe_cast_le'],\n rw add_comm,\nend\n\nlemma add_zero (x : cone_point_type G) : x + 0 = x := by { rw add_comm, apply zero_add }\n\nlemma add_assoc (x y z : cone_point_type G) : x + y + z = x + (y + z) :=\nbegin\n apply quotient.sound',\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n dsimp,\n ext j : 3,\n simp only [cone_point_type_filt.trans_apply, cone_point_type_filt.add'_apply_coe,\n coe_cast_le, coe_cast_le'],\n erw [coe_incl_preimage_apply, coe_incl_preimage_apply],\n simp [add_assoc],\nend\n\nlemma add_left_neg (x : cone_point_type G) : -x + x = 0 :=\nbegin\n apply quotient.sound',\n refine ⟨_,le_sup_left, le_sup_right,_⟩,\n dsimp,\n ext j : 3,\n simp only [cone_point_type_filt.trans_apply, cone_point_type_filt.zero_apply,\n cone_point_type_filt.add'_apply_coe, coe_cast_le, filtration.coe_zero, coe_cast_le'],\n erw coe_incl_preimage_apply,\n simp,\nend\n\ninstance : add_comm_group (cone_point_type G) :=\n{ add_assoc := add_assoc,\n zero_add := zero_add,\n add_zero := add_zero,\n add_left_neg := add_left_neg,\n add_comm := add_comm,\n ..(infer_instance : has_add _),\n ..(infer_instance : has_zero _),\n ..(infer_instance : has_neg _) }\n\nvariable (G)\ndef filt (c : ℝ≥0) : set (cone_point_type G) := set.range (incl c)\n\ndef filt_equiv (c : ℝ≥0) : cone_point_type_filt G c ≃ filt G c :=\nequiv.of_bijective (λ x, ⟨_, x, rfl⟩)\nbegin\n split,\n { intros x y h,\n apply_fun (λ e, e.val) at h,\n apply incl_injective,\n exact h },\n { rintro ⟨_,x,rfl⟩, use x }\nend\n\ninstance {c} : topological_space (filt G c) :=\ntopological_space.induced (filt_equiv G c).symm infer_instance\n\ndef filt_homeo (c : ℝ≥0) : filt G c ≃ₜ cone_point_type_filt G c :=\nhomeomorph.homeomorph_of_continuous_open (filt_equiv G c).symm continuous_induced_dom\nbegin\n intros U hU,\n have : inducing (filt_equiv G c).symm := ⟨rfl⟩,\n rw this.is_open_iff at hU,\n obtain ⟨U,hU,rfl⟩ := hU,\n simpa,\nend\n\ninstance {c} : compact_space (filt G c) :=\n(filt_homeo G c).symm.compact_space\n\ninstance {c} : t2_space (filt G c) :=\n(filt_homeo G c).symm.t2_space\n\ndef filt_iso (c : ℝ≥0) : CompHaus.of (filt G c) ≅\n (CompHaus.limit_cone.{_ u} (((cone_point_diagram G).obj (as_small.up.obj c)))).X :=\n{ hom := (filt_homeo G c).to_continuous_map,\n inv := (filt_homeo G c).symm.to_continuous_map,\n hom_inv_id' := by { ext1, simp },\n inv_hom_id' := by { ext1, simp } }\n\nvariable {G}\n\n@[simp] lemma incl_neg {c} (x : cone_point_type_filt G c) :\n incl c (-x) = - incl c x :=\nbegin\n apply quotient.sound',\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n dsimp,\n ext j : 3,\n simp,\nend\n\n@[simp] lemma incl_add' {c1 c2} (x1 : cone_point_type_filt G c1) (x2 : cone_point_type_filt G c2) :\n incl (c1 + c2) (x1.add' x2) = incl c1 x1 + incl c2 x2 :=\nbegin\n apply quotient.sound',\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n dsimp,\n ext j : 3,\n simp,\nend\n\n@[simp] lemma incl_zero {c} : incl c (0 : cone_point_type_filt G c) = 0 :=\nbegin\n apply quotient.sound',\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n dsimp,\n ext j : 3,\n simp,\nend\n\ninstance : pseudo_normed_group (cone_point_type G) :=\n{ filtration := filt G,\n filtration_mono := begin\n rintro c1 c2 h x ⟨x,rfl⟩,\n dsimp [filt],\n use x.trans h,\n simp,\n end,\n zero_mem_filtration := begin\n intro c,\n use 0,\n simp,\n end,\n neg_mem_filtration := begin\n rintros c x ⟨x,rfl⟩,\n use -x,\n simp,\n end,\n add_mem_filtration := begin\n rintros c1 c2 x1 x2 ⟨x1,rfl⟩ ⟨x2,rfl⟩,\n use x1.add' x2,\n simp,\n end }\n\ninstance : comphaus_filtered_pseudo_normed_group (cone_point_type G) :=\n{ topology := by apply_instance,\n t2 := by apply_instance,\n compact := by apply_instance,\n continuous_add' := begin\n intros c1 c2,\n let E : filtration (cone_point_type G) c1 × filtration (cone_point_type G) c2 →\n cone_point_type_filt G c1 × cone_point_type_filt G c2 :=\n λ t, ⟨(filt_homeo G c1) t.1, (filt_homeo G c2) t.2⟩,\n let E' : cone_point_type_filt G c1 × cone_point_type_filt G c2 →\n filtration (cone_point_type G) c1 × filtration (cone_point_type G) c2 :=\n λ t, ⟨(filt_homeo G c1).symm t.1, (filt_homeo G c2).symm t.2⟩,\n have hE'E : E' ∘ E = id := by { dsimp [E,E'], ext, simp, simp },\n have : (filt_homeo G (c1 + c2)).symm ∘\n (λ t : cone_point_type_filt G c1 × cone_point_type_filt G c2, t.1.add' t.2) ∘ E = add',\n { suffices : add' ∘ E' = (filt_homeo G (c1 + c2)).to_equiv.symm ∘\n (λ t : cone_point_type_filt G c1 × cone_point_type_filt G c2, t.1.add' t.2),\n { erw [← function.comp.assoc, ← this, function.comp.assoc, hE'E],\n simp },\n dsimp only [filt_homeo, homeomorph.homeomorph_of_continuous_open, E'],\n ext,\n dsimp [filt_homeo, filt_equiv, E, E'],\n simp },\n rw ← this, clear this,\n apply continuous.comp (homeomorph.continuous _),\n apply continuous.comp,\n apply cone_point_type_filt.continuous_add',\n dsimp [E],\n continuity,\n end,\n continuous_neg' := begin\n intros c,\n have : (neg' : filtration (cone_point_type G) c → filtration (cone_point_type G) c) =\n (filt_homeo G c).symm ∘ (λ x, -x) ∘ filt_homeo G c,\n { suffices :\n (neg' : filtration (cone_point_type G) c → filtration (cone_point_type G) c) ∘\n (filt_homeo G c).to_equiv.symm = (filt_homeo G c).to_equiv.symm ∘ (λ x, -x),\n { erw [← function.comp.assoc, ← this, function.comp.assoc, equiv.symm_comp_self],\n simp },\n dsimp only [filt_homeo, homeomorph.homeomorph_of_continuous_open],\n simp only [equiv.symm_symm],\n ext,\n dsimp [filt_equiv],\n simp },\n rw this,\n simp [cone_point_type_filt.continuous_neg],\n end,\n continuous_cast_le := begin\n rintro c₁ c₂ ⟨h⟩,\n change continuous (cast_le' h),\n have : cast_le' h = (filt_homeo G c₂).symm ∘\n cone_point_type_filt.trans h ∘ (filt_homeo G c₁),\n { suffices : cast_le' h ∘ (filt_homeo G c₁).to_equiv.symm =\n (filt_homeo G c₂).to_equiv.symm ∘ cone_point_type_filt.trans h,\n { erw [← function.comp.assoc, ← this, function.comp.assoc, equiv.symm_comp_self],\n simp },\n dsimp only [filt_homeo, homeomorph.homeomorph_of_continuous_open],\n simp only [equiv.symm_symm],\n ext,\n dsimp [filt_equiv],\n simp },\n simp [this, cone_point_type_filt.trans_continuous],\n end }\n\nend cone_point_type\n\ndef cone_point : CompHausFiltPseuNormGrp₁ :=\n{ M := cone_point_type G,\n exhaustive' := cone_point_type.incl_jointly_surjective }\n\ndef proj (j : J) : cone_point G ⟶ G.obj j :=\n{ to_fun := λ x, x.preimage j,\n map_zero' := begin\n rw cone_point_type.zero_def,\n simp only [cone_point_type.coe_incl_preimage_apply,\n cone_point_type_filt.zero_apply, filtration.coe_zero],\n end,\n map_add' := begin\n intros x y,\n rw cone_point_type.add_def x y,\n simp only [cone_point_type.coe_incl_preimage_apply,\n cone_point_type_filt.add'_apply_coe],\n end,\n strict' := begin\n rintros c x ⟨x,rfl⟩,\n simp only [cone_point_type.coe_incl_preimage_apply,\n subtype.coe_prop],\n end,\n continuous' := begin\n intros c,\n dsimp,\n let E : filtration (cone_point_type G) c → filtration (G.obj j) c :=\n λ t, ((cone_point_type.filt_homeo G c) t) j,\n suffices : continuous E,\n { convert this,\n ext ⟨t,t,rfl⟩,\n dsimp [E],\n simp only [cone_point_type.coe_incl_preimage_apply],\n congr' 2,\n apply_fun (cone_point_type.filt_homeo G c).symm,\n simp only [homeomorph.symm_apply_apply],\n ext, refl },\n dsimp [E],\n change continuous ((λ (u : cone_point_type_filt G c), u j) ∘ cone_point_type.filt_homeo G c),\n simp only [homeomorph.comp_continuous_iff'],\n apply cone_point_type_filt.continuous_apply,\n end } .\n\ndef limit_cone : cone G :=\n{ X := cone_point G,\n π :=\n { app := λ j, proj G j,\n naturality' := begin\n intros i j e,\n ext,\n dsimp,\n simp only [comp_apply, category.id_comp],\n have := (cone_point_type.preimage x).2 e,\n apply_fun (λ e, (e : G.obj j)) at this,\n exact this.symm,\n end } }\n\ndef index {M : CompHausFiltPseuNormGrp₁} (x : M) : ℝ≥0 := (M.exhaustive x).some\ndef preimage {M : CompHausFiltPseuNormGrp₁} (x : M) : filtration M (index x) :=\n ⟨x,(M.exhaustive x).some_spec⟩\n\ndef limit_cone_lift_map (D : cone G) : D.X → cone_point G := λ x,\ncone_point_type.incl (index x) ⟨λ j, (D.π.app j).level (preimage x), begin\n intros i j e,\n ext,\n dsimp,\n simp,\nend⟩\n\nlemma limit_cone_lift_map_map_zero {D : cone G} :\n limit_cone_lift_map G D 0 = 0 :=\nbegin\n apply quotient.sound',\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n dsimp,\n ext j,\n simp only [cone_point_type_filt.trans_apply, cone_point_type_filt.zero_apply,\n coe_cast_le, filtration.coe_zero, coe_cast_le'],\n apply (D.π.app j).map_zero,\nend\n\nlemma limit_cone_lift_map_map_add {D : cone G} (a b : D.X) :\n limit_cone_lift_map G D (a + b) = limit_cone_lift_map G D a + limit_cone_lift_map G D b :=\nbegin\n apply quotient.sound',\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n dsimp,\n ext j,\n dsimp [limit_cone_lift_map],\n simp only [cone_point_type_filt.trans_apply, cone_point_type.coe_incl_preimage_apply,\n cone_point_type_filt.add'_apply_coe, coe_cast_le, coe_cast_le'],\n exact (D.π.app j).map_add a b,\nend\n\nlemma limit_cone_lift_map_strict {D : cone G} {x : D.X} (c : ℝ≥0) (hx : x ∈ filtration D.X c) :\n limit_cone_lift_map G D x ∈ filtration (cone_point_type G) c :=\nbegin\n dsimp [limit_cone_lift_map],\n change _ ∈ set.range _,\n refine ⟨⟨λ j, (D.π.app j).level ⟨x,hx⟩, _⟩, _⟩,\n { intros i j e,\n ext,\n dsimp,\n simp },\n { dsimp,\n apply quotient.sound',\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n dsimp,\n ext j,\n simpa }\nend\n\ndef limit_cone_lift (D : cone G) : D.X ⟶ cone_point G :=\n{ to_fun := limit_cone_lift_map _ D,\n map_zero' := limit_cone_lift_map_map_zero _,\n map_add' := limit_cone_lift_map_map_add _,\n strict' := λ c x hx, limit_cone_lift_map_strict G c hx,\n continuous' := begin\n intros c,\n rw (cone_point_type.filt_homeo G c).inducing.continuous_iff,\n let E : filtration D.X c → cone_point_type_filt G c := λ t,\n ⟨λ j, (D.π.app j).level t, _⟩,\n swap, {\n intros i j e,\n ext,\n dsimp,\n simp },\n have : (cone_point_type.filt_homeo G c) ∘ pseudo_normed_group.level\n (limit_cone_lift_map G D) (λ c x hx, limit_cone_lift_map_strict G c hx) c = E,\n { ext1,\n apply_fun (cone_point_type.filt_homeo G c).symm,\n dsimp [E],\n simp only [homeomorph.symm_apply_apply],\n ext,\n apply quotient.sound',\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n ext,\n dsimp,\n simp only [cone_point_type_filt.trans_apply, coe_cast_le, coe_cast_le'],\n refl },\n rw this,\n apply continuous.subtype_mk,\n apply continuous_pi,\n intros j,\n dsimp,\n apply (D.π.app j).level_continuous,\n end }\n\ndef limit_cone_is_limit : is_limit (limit_cone G) :=\n{ lift := λ S, limit_cone_lift _ _,\n fac' := begin\n intros S j,\n ext,\n change (limit_cone G).π.app j _ = _,\n dsimp [limit_cone_lift, limit_cone, limit_cone_lift_map, proj],\n simpa,\n end,\n uniq' := begin\n intros S m h,\n ext,\n dsimp [limit_cone_lift, limit_cone_lift_map],\n rw ← (m x).preimage_spec,\n apply quotient.sound',\n refine ⟨_, le_sup_left, le_sup_right, _⟩,\n ext j,\n dsimp,\n simp only [cone_point_type_filt.trans_apply, coe_cast_le, coe_cast_le'],\n specialize h j,\n apply_fun (λ e, e x) at h,\n exact h,\n end }\n\n-- This is the goal of this section...\ninstance : has_limit G := has_limit.mk ⟨limit_cone _, limit_cone_is_limit _⟩\n\ninstance : has_limits CompHausFiltPseuNormGrp₁ :=\n⟨λ J hJ, { has_limit := λ G, by resetI; apply_instance }⟩\n\ninstance (c : ℝ≥0) : preserves_limit G (level.obj c) :=\npreserves_limit_of_preserves_limit_cone (limit_cone_is_limit _)\n{ lift := λ S,\n (CompHaus.limit_cone_is_limit.{_ u} ((cone_point_diagram G).obj (as_small.up.obj c))).lift\n _ ≫ (cone_point_type.filt_iso _ _).inv,\n fac' := begin\n intros S j,\n dsimp,\n rw category.assoc,\n convert (CompHaus.limit_cone_is_limit.{_ u}\n ((cone_point_diagram G).obj (as_small.up.obj c))).fac S j,\n ext ⟨t,ht⟩,\n dsimp [limit_cone, cone_point_type.filt_iso, cone_point_type.filt_homeo,\n homeomorph.homeomorph_of_continuous_open, cone_point_type.filt_equiv,\n level, proj, CompHaus.limit_cone, Top.limit_cone],\n simpa,\n end,\n uniq' := begin\n intros S m hm,\n rw iso.eq_comp_inv,\n apply (CompHaus.limit_cone_is_limit.{_ u} ((cone_point_diagram G).obj (as_small.up.obj c))).uniq,\n intros j,\n rw [← hm, category.assoc],\n congr' 1,\n rw ← iso.eq_inv_comp,\n ext ⟨t,ht⟩,\n dsimp [limit_cone, cone_point_type.filt_iso, cone_point_type.filt_homeo,\n homeomorph.homeomorph_of_continuous_open, cone_point_type.filt_equiv,\n level, proj, CompHaus.limit_cone, Top.limit_cone],\n simpa,\n end } .\n\ninstance (c : ℝ≥0) : preserves_limits (level.obj c) :=\n{ preserves_limits_of_shape := λ J _, by exactI\n { preserves_limit := λ G, by apply_instance, } }\n\nlemma mem_filtration_iff_of_is_limit (C : cone G) (hC : is_limit C) (c : ℝ≥0) (x : C.X) :\n x ∈ pseudo_normed_group.filtration C.X c ↔\n (∀ j : J, C.π.app j x ∈ pseudo_normed_group.filtration (G.obj j) c) :=\nbegin\n split,\n { intros h j,\n apply (C.π.app j).strict h },\n { intro h,\n let E := limit_cone G,\n let e : C ≅ E := hC.unique_up_to_iso (limit_cone_is_limit _),\n let eX : C.X ≅ E.X := (cones.forget _).map_iso e,\n let w := eX.hom x,\n have hw : ∀ j, E.π.app j w ∈ filtration (G.obj j) c,\n { intros j,\n dsimp only [w],\n change (eX.hom ≫ E.π.app _) _ ∈ _,\n dsimp only [eX, functor.map_iso, cones.forget],\n convert h j,\n simp },\n suffices : w ∈ filtration (limit_cone G).X c,\n { convert eX.inv.strict this,\n change _ = (eX.hom ≫ eX.inv) x,\n rw iso.hom_inv_id,\n refl },\n change ∃ z, _,\n refine ⟨⟨λ j, ⟨_, hw _⟩, _⟩, _⟩,\n { intros i j f,\n ext1,\n dsimp,\n change (E.π.app i ≫ G.map f) _ = _,\n rw E.w },\n { obtain ⟨i,z,hz⟩ := cone_point_type.incl_jointly_surjective w,\n let d : ℝ≥0 := i ⊔ c,\n conv_rhs { rw ← hz },\n rw ← cone_point_type.incl_trans (le_sup_left : i ≤ d),\n rw ← cone_point_type.incl_trans (le_sup_right : c ≤ d),\n congr' 1,\n dsimp [cone_point_type_filt.trans],\n ext j,\n dsimp,\n change E.π.app j _ = _,\n rw ← hz,\n dsimp [E, limit_cone, proj],\n simp } }\nend\n\nlemma is_limit_ext (C : cone G) (hC : is_limit C) (x y : C.X)\n (h : ∀ j, C.π.app j x = C.π.app j y) : x = y :=\nbegin\n let E := limit_cone G,\n let e : C ≅ E := hC.unique_up_to_iso (limit_cone_is_limit _),\n let eX : C.X ≅ E.X := (cones.forget _).map_iso e,\n apply_fun eX.hom,\n swap,\n { intros a b hh,\n apply_fun (λ e, eX.inv e) at hh,\n change (eX.hom ≫ eX.inv) _ = (eX.hom ≫ eX.inv) _ at hh,\n simpa only [iso.hom_inv_id] using hh },\n have hh : ∀ j, (E.π.app j) (eX.hom x) = (E.π.app j) (eX.hom y),\n { intros j,\n change (eX.hom ≫ E.π.app j) x = (eX.hom ≫ E.π.app j) y,\n convert h j using 2,\n all_goals { simp } },\n obtain ⟨ca,a,ha⟩ := cone_point_type.incl_jointly_surjective (eX.hom x),\n obtain ⟨cb,b,hb⟩ := cone_point_type.incl_jointly_surjective (eX.hom y),\n rw [← ha, ← hb] at ⊢ hh,\n let d : ℝ≥0 := ca ⊔ cb,\n rw ← cone_point_type.incl_trans (le_sup_left : ca ≤ d) at ⊢ hh,\n rw ← cone_point_type.incl_trans (le_sup_right : cb ≤ d) at ⊢ hh,\n congr' 1,\n ext j,\n specialize hh j,\n convert hh using 1,\n all_goals { dsimp [E, limit_cone, proj],\n simp },\nend\n\nend limits\n\nsection products\n\n/-!\nIn this section, we construct explicit finite products.\n-/\n\ndef product {α : Type u} [fintype α] (X : α → CompHausFiltPseuNormGrp₁.{u}) :\n CompHausFiltPseuNormGrp₁.{u} :=\n{ M := Π i, X i,\n exhaustive' := begin\n intro m,\n choose cs hcs using (λ i, (X i).exhaustive (m i)),\n have : ∃ c : ℝ≥0, ∀ i, cs i ≤ c,\n { use finset.univ.sup cs,\n intros i,\n apply finset.le_sup (finset.mem_univ i) },\n obtain ⟨c,hc⟩ := this,\n refine ⟨c, λ i, pseudo_normed_group.filtration_mono (hc i) (hcs i)⟩,\n end }\n\n@[simps]\ndef product.π {α : Type u} [fintype α] (X : α → CompHausFiltPseuNormGrp₁.{u}) (i : α) :\n product X ⟶ X i :=\n{ to_fun := λ m, m i,\n map_zero' := rfl,\n map_add' := λ x y, rfl,\n strict' := λ c x hx, hx i,\n continuous' := begin\n -- This can be golfed.\n intros c,\n have h : inducing (pseudo_normed_group.filtration_pi_equiv (λ i, X i) c) := ⟨rfl⟩,\n let e : ↥(pseudo_normed_group.filtration ↥(product X) c) →\n ↥(pseudo_normed_group.filtration ↥(X i) c) :=\n pseudo_normed_group.level (λ (m : ↥(product X)), m i) _ c,\n swap,\n { intros c x hx,\n apply hx },\n change continuous e,\n have : e = _ ∘ (pseudo_normed_group.filtration_pi_equiv (λ i, X i) c),\n rotate 2,\n { intros x, exact x i },\n { ext, refl },\n erw [this],\n apply continuous.comp,\n apply continuous_apply,\n refine inducing.continuous h\n end }\n\n@[simps]\ndef product.lift {α : Type u} [fintype α] (X : α → CompHausFiltPseuNormGrp₁.{u})\n (M : CompHausFiltPseuNormGrp₁.{u}) (f : Π i, M ⟶ X i) :\n M ⟶ product X :=\n{ to_fun := λ m i, f _ m,\n map_zero' := by { ext, simp },\n map_add' := by { intros, ext, simp },\n strict' := λ c x hx i, (f i).strict hx,\n continuous' := begin\n intros c,\n have h : inducing (pseudo_normed_group.filtration_pi_equiv (λ i, X i) c) := ⟨rfl⟩,\n rw [h.continuous_iff, continuous_pi_iff],\n intros i,\n exact (f i).continuous' c,\n end }\n\n@[simp, reassoc]\nlemma product.lift_π {α : Type u} [fintype α] (X : α → CompHausFiltPseuNormGrp₁.{u})\n (M : CompHausFiltPseuNormGrp₁.{u}) (f : Π i, M ⟶ X i) (i) :\n product.lift X M f ≫ product.π X i = f i := by { ext, simp }\n\nlemma product.lift_unique {α : Type u} [fintype α] (X : α → CompHausFiltPseuNormGrp₁.{u})\n (M : CompHausFiltPseuNormGrp₁.{u}) (f : Π i, M ⟶ X i) (g : M ⟶ product X)\n (hg : ∀ i, g ≫ product.π X i = f i) : g = product.lift X M f :=\nby { ext, simp [← hg] }\n\nlemma product.hom_ext {α : Type u} [fintype α] (X : α → CompHausFiltPseuNormGrp₁.{u})\n (M : CompHausFiltPseuNormGrp₁.{u}) (g₁ g₂ : M ⟶ product X)\n (h : ∀ i, g₁ ≫ product.π X i = g₂ ≫ product.π X i) : g₁ = g₂ :=\nbegin\n rw [product.lift_unique X M _ g₁ (λ i, rfl), product.lift_unique X M _ g₂ (λ i, rfl)],\n simp [h],\nend\n\nend products\n\nend CompHausFiltPseuNormGrp₁\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/pseudo_normed_group/category/strictCompHausFiltPseuNormGrp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.3738758367247085, "lm_q1q2_score": 0.21018420965564658}} {"text": "example (f : Fin n → Prop) (h : ∀ i h, i = 0 → f ⟨i, h⟩) : f i := by\n apply h\n rw [show i.1 = 0 from sorry]\n\ndef foo (x : Fin n) : Nat :=\n match x with\n | ⟨i, _⟩ => 5 + i\n\nexample (x : Fin n) : foo x = 5 := by\n simp [foo]\n rw [show x.1 = 0 from sorry]\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/tests/lean/run/primProjEtaIssue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.38861802670584894, "lm_q1q2_score": 0.2094585956512109}} {"text": "import free_pfpng.setup\nimport for_mathlib.logic\n\nnoncomputable theory\n\nopen_locale classical big_operators\n\nopen category_theory\nopen opposite\n\nuniverse u\n\ninstance Condensed_Ab_to_CondensedSet_faithful :\n faithful Condensed_Ab_to_CondensedSet :=\n{ map_injective' := begin\n intros X Y f g h, ext W t : 4,\n apply_fun (λ e, e.val.app W t) at h, dsimp at h,\n exact h\n end }\n\nlemma category_theory.epi_to_colimit_of_exists {J : Type u}\n [small_category J] {C : Type*} [category.{u} C]\n {F : J ⥤ C} (T : C)\n (E : limits.cocone F) (hE : limits.is_colimit E)\n (f : T ⟶ E.X)\n (h : ∀ j : J,\n ∃ (Z : C) (p : Z ⟶ T) (q : Z ⟶ F.obj j) (hq : epi q),\n q ≫ E.ι.app j = p ≫ f) : epi f :=\nbegin\n constructor, intros W a b hh,\n apply hE.hom_ext, intros j, specialize h j,\n obtain ⟨Z,p,q,hq,w⟩ := h, resetI,\n rw ← cancel_epi q, simp_rw [← category.assoc, w,\n category.assoc, hh],\nend\n\nlemma epi_Profinite_to_Condensed_map_of_epi {X Y : Profinite.{u}}\n (f : X ⟶ Y) [hf : epi f] : epi (Profinite_to_Condensed.map f) :=\nbegin\n constructor, intros Z a b h, ext W q : 34, induction W using opposite.rec,\n have hZ := Z.2,\n rw is_sheaf_iff_is_sheaf_of_type at hZ,\n rw Z.val.is_proetale_sheaf_of_types_tfae.out 0 1 at hZ,\n let q' := q.down,\n dsimp at q q',\n dsimp [functor.is_proetale_sheaf_of_types] at hZ,\n specialize hZ punit W (λ _, Profinite.pullback f q')\n (λ _, Profinite.pullback.snd _ _) _ _,\n { intro w,\n rw Profinite.epi_iff_surjective at hf,\n obtain ⟨x, hx⟩ := hf (q' w),\n refine ⟨punit.star, ⟨(x, w), hx⟩, rfl⟩, },\n { intros i, dsimp, refine Z.val.map _ (b.val.app (op W) q),\n refine quiver.hom.op _, exact Profinite.pullback.snd _ _ },\n specialize hZ _,\n { clear hZ,\n rintro ⟨⟩ ⟨⟩ S g₁ g₂ H, dsimp only at H,\n apply_fun (λ φ, Z.val.map φ.op (b.val.app (op W) q)) at H,\n simp only [op_comp, Z.val.map_comp] at H, exact H, },\n obtain ⟨t,ht1,ht2⟩ := hZ,\n have : b.val.app (op W) q = t,\n { apply ht2,\n intros i, refl },\n rw this, apply ht2,\n intros i, dsimp,\n change (a.val.app (op W) ≫ Z.val.map _) q =\n (b.val.app (op W) ≫ Z.val.map _) q,\n simp only [← nat_trans.naturality],\n dsimp,\n apply_fun (λ e, Profinite_to_Condensed.map (Profinite.pullback.fst f q') ≫ e) at h,\n apply_fun (λ e, e.val.app (op (Profinite.pullback f q'))) at h,\n dsimp at h,\n let i : (Profinite.pullback f q').to_Condensed.val.obj (op (Profinite.pullback f q')) :=\n ulift.up (𝟙 _),\n apply_fun (λ e, e i) at h,\n dsimp [ulift_functor] at h,\n convert h,\n all_goals\n { ext1,\n dsimp [Profinite.to_Condensed],\n simp only [category.id_comp, Profinite.pullback.condition] },\nend\n\n/-\ninductive pmz : set ℤ\n| neg_one : pmz (-1)\n| zero : pmz 0\n| one : pmz 1\n\ndef pmz_eq : pmz = {0,1,-1} :=\nbegin\n ext, split,\n { intros h, cases h, right, right, simpa, left, simp, right, left, simp },\n { intros h, simp at h, rcases h with (rfl|rfl|rfl),\n apply pmz.zero,\n apply pmz.one,\n apply pmz.neg_one }\nend\n\nlemma pmz_finite : set.finite pmz :=\nby simp [pmz_eq]\n\ninstance fintype_pmz : fintype pmz := pmz_finite.fintype\n-/\n\n--abbreviation Profinite.pow (S : Profinite.{u}) (n : ℕ) : Profinite.{u} :=\n--Profinite.product (λ i : fin n, S)\n\n/-- `S.pmz n` is `(S × {-1,0,1})^n`. -/\ndef Profinite.pmz (S : Profinite.{u}) (n : ℕ) : Profinite.{u} :=\nProfinite.sigma $ λ (x : ulift.{u} (fin n → sign_type)), S.pow n\n\n/-- the canonical map of condensed sets `(S × {-1,0,1})^n ⟶ ℤ[S]` -/\ndef Profinite.pmz_to_free' (S : Profinite.{u}) (n : ℕ) :\n (S.pmz n).to_Condensed ⟶ Condensed_Ab_to_CondensedSet.obj S.free' :=\n(Profinite.to_Condensed_equiv (S.pmz n) (Condensed_Ab_to_CondensedSet.obj S.free')).symm $\n (CondensedSet.val_obj_sigma_equiv (λ (f : ulift.{u} (fin n → sign_type)), S.pow n)\n (Condensed_Ab_to_CondensedSet.obj S.free')).symm $\nλ (f : ulift.{u} (fin n → sign_type)),\nlet e := proetale_topology.to_sheafify (S.to_Condensed.val ⋙ AddCommGroup.free') in\ne.app (op $ S.pow n) $\n ∑ i : fin n, finsupp.single (ulift.up $ Profinite.product.π _ i) (f.down i : ℤ)\n\ndef Profinite.pmz_functor (n : ℕ) : Profinite.{u} ⥤ Profinite.{u} :=\n{ obj := λ S, S.pmz n,\n map := λ S T f,\n Profinite.sigma.desc _ $ λ e,\n (Profinite.product.lift (λ i : fin n, T)\n (λ i, Profinite.product.π _ i ≫ f)) ≫ Profinite.sigma.ι _ e,\n map_id' := begin\n intros X,\n apply Profinite.sigma.hom_ext, intros e,\n erw category.comp_id, refl,\n end,\n map_comp' := begin\n intros X Y Z f g,\n apply Profinite.sigma.hom_ext, intros e, dsimp, simp,\n erw [Profinite.sigma.ι_desc],\n refl,\n end }\n\ndef Profinite.pmz_diagram (S : Profinite.{u}) (n : ℕ) :\n discrete_quotient S ⥤ Profinite.{u} :=\nS.diagram ⋙ Profinite.pmz_functor n\n\ndef Profinite.pmz_cone (S : Profinite.{u}) (n : ℕ) : limits.cone (S.pmz_diagram n) :=\n(Profinite.pmz_functor n).map_cone S.as_limit_cone\n\ndef Profinite.sigma_functor {J : Type u} [small_category J]\n (F : J ⥤ Profinite.{u}) (α : Type u) [fintype α] :\n J ⥤ Profinite.{u} :=\n{ obj := λ j, Profinite.sigma (λ a : α, F.obj j),\n map := λ i j e, Profinite.sigma.desc _ $ λ a,\n F.map e ≫ Profinite.sigma.ι _ a,\n map_id' := begin\n intros j, apply Profinite.sigma.hom_ext, intros a,\n simp,\n end,\n map_comp' := begin\n intros i j k e f,\n apply Profinite.sigma.hom_ext, intros a,\n simp,\n end }\n\ndef Profinite.sigma_cone {J : Type u} [small_category J]\n {F : J ⥤ Profinite.{u}} (α : Type u) [fintype α]\n (E : limits.cone F) :\n limits.cone (Profinite.sigma_functor F α) :=\n{ X := Profinite.sigma (λ a : α, E.X),\n π :=\n { app := λ j, Profinite.sigma.desc _ $ λ a,\n E.π.app j ≫ Profinite.sigma.ι _ a,\n naturality' := begin\n intros i j e, dsimp,\n apply Profinite.sigma.hom_ext, intros a,\n simp, dsimp [Profinite.sigma_functor], simp,\n end } }\n\ndef Profinite.sigma_to_limit {J : Type u} [small_category J]\n (F : J ⥤ Profinite.{u}) (α : Type u) [fintype α]\n (E : limits.cone F) :\n (Profinite.sigma_cone α E).X ⟶\n (Profinite.limit_cone (Profinite.sigma_functor F α)).X :=\nProfinite.sigma.desc _ $ λ a, (Profinite.limit_cone_is_limit\n (Profinite.sigma_functor F α)).lift ⟨E.X,\n { app := λ j, E.π.app j ≫ Profinite.sigma.ι _ a,\n naturality' := begin\n intros i j e, dsimp [Profinite.sigma_functor],\n simp,\n end }⟩\n\nlemma Profinite.exists_of_sigma_limit {J : Type u} [small_category J]\n (F : J ⥤ Profinite.{u}) (α : Type u) [fintype α] [is_cofiltered J]\n (t : (Profinite.limit_cone (Profinite.sigma_functor F α)).X) :\n ∃ (a₀ : α) (t₀ : (Profinite.limit_cone F).X),\n ∀ j : J, Profinite.sigma.ι _ a₀\n ((Profinite.limit_cone F).π.app j t₀) =\n (Profinite.limit_cone (Profinite.sigma_functor F α)).π.app j t :=\nbegin\n rcases t with ⟨t,ht⟩, dsimp at ht,\n obtain ⟨j₀⟩ : nonempty J := is_cofiltered.nonempty,\n let a₀ := (t j₀).1, use a₀,\n have h1 : ∀ ⦃i j : J⦄ (f : i ⟶ j), (t i).1 = (t j).1,\n { intros i j e, specialize ht e,\n apply_fun (λ q, q.1) at ht,\n cases t i, exact ht },\n have h2 : ∀ j : J, (t j).1 = a₀,\n { intros j,\n let j₁ := is_cofiltered.min j j₀,\n rw ← h1 (is_cofiltered.min_to_left j j₀), dsimp [a₀],\n rw ← h1 (is_cofiltered.min_to_right j j₀) },\n let t₀ : (Profinite.limit_cone F).X := ⟨_,_⟩,\n rotate,\n { intros j, exact (t j).2 },\n { intros i j e,\n specialize ht e,\n cases (t i),\n dsimp [Profinite.sigma_functor, Profinite.sigma.desc, Profinite.sigma.ι] at ht,\n cases t j,\n erw sigma.mk.inj_iff at ht,\n exact eq_of_heq ht.2 },\n use t₀,\n intros j,\n dsimp [Profinite.limit_cone, Profinite.sigma_functor, Profinite.sigma.ι,\n Profinite.sigma.desc, CompHaus.limit_cone, Top.limit_cone], ext,\n exact (h2 _).symm, refl,\nend\n\nlemma Profinite.bijective_sigma_to_limit {J : Type u} [small_category J]\n (F : J ⥤ Profinite.{u}) (α : Type u) [fintype α]\n (E : limits.cone F) (hE : limits.is_limit E) [is_cofiltered J] :\n function.bijective (Profinite.sigma_to_limit F α E) :=\nbegin\n split,\n { rintros ⟨a,x⟩ ⟨b,y⟩ h,\n dsimp [Profinite.sigma_to_limit, Profinite.sigma.desc,\n Profinite.limit_cone_is_limit, CompHaus.limit_cone_is_limit,\n Top.limit_cone_is_limit] at h,\n apply_fun (λ e, e.1) at h,\n have hh := h,\n obtain ⟨j₀⟩ : nonempty J := is_cofiltered.nonempty,\n apply_fun (λ e, (e j₀).1) at h, dsimp [Profinite.sigma.ι] at h,\n subst h, ext, refl,\n apply heq_of_eq,\n apply limits.concrete.is_limit_ext _ hE,\n intros jj, apply_fun (λ e, e jj) at hh,\n erw sigma.mk.inj_iff at hh,\n exact eq_of_heq hh.2 },\n { rintros t,\n obtain ⟨a,s,ht⟩ := Profinite.exists_of_sigma_limit F α t,\n use a, let EE : E.X ≅ (Profinite.limit_cone F).X :=\n hE.cone_point_unique_up_to_iso (Profinite.limit_cone_is_limit _),\n use EE.inv s, dsimp, ext j : 2,\n convert ht j, ext, refl,\n apply heq_of_eq,\n change ((hE.lift (Profinite.limit_cone F)) ≫ E.π.app j) s = _,\n rw hE.fac, refl }\nend\n\nlemma Profinite.is_iso_lift_sigma_cone {J : Type u} [small_category J]\n {F : J ⥤ Profinite.{u}} (α : Type u) [fintype α] [is_cofiltered J]\n (E : limits.cone F) (hE : limits.is_limit E) :\n is_iso ((Profinite.limit_cone_is_limit _).lift (Profinite.sigma_cone α E)) :=\nbegin\n apply Profinite.is_iso_of_bijective,\n convert Profinite.bijective_sigma_to_limit F α E hE,\n symmetry,\n apply (Profinite.limit_cone_is_limit (Profinite.sigma_functor F α)).uniq,\n intros j,\n apply Profinite.sigma.hom_ext,\n intros a, refl,\nend\n\ndef Profinite.sigma_cone_is_limit {J : Type u} [small_category J]\n {F : J ⥤ Profinite.{u}} (α : Type u) [fintype α] [is_cofiltered J]\n (E : limits.cone F) (hE : limits.is_limit E) :\n limits.is_limit (Profinite.sigma_cone α E) :=\nbegin\n haveI : is_iso ((Profinite.limit_cone_is_limit _).lift (Profinite.sigma_cone α E)) :=\n Profinite.is_iso_lift_sigma_cone α E hE,\n apply limits.is_limit.of_point_iso (Profinite.limit_cone_is_limit _),\n assumption\nend\n\ndef Profinite.pmz_to_limit (S : Profinite.{u}) (n : ℕ) :\n S.pmz n ⟶ (Profinite.limit_cone (S.pmz_diagram n)).X :=\nProfinite.sigma.desc _ $ λ f,\n (Profinite.limit_cone_is_limit (S.pmz_diagram n)).lift ⟨S.pow n,\n { app := λ T, Profinite.map_pow (S.as_limit_cone.π.app T) n ≫\n Profinite.sigma.ι _ f,\n naturality' := begin\n intros A B e,\n dsimp [Profinite.pmz_diagram, Profinite.pmz_functor],\n simpa,\n end }⟩\n\ndef Profinite.pow_functor (n : ℕ) : Profinite.{u} ⥤ Profinite.{u} :=\n{ obj := λ S, S.pow n,\n map := λ S T f, Profinite.map_pow f n,\n map_id' := begin\n intros X, apply Profinite.product.hom_ext, intros i, dsimp [Profinite.map_pow], simp,\n end,\n map_comp' := begin\n intros X Y Z f g,\n apply Profinite.product.hom_ext, intros i, dsimp [Profinite.map_pow], simp,\n end }\n\ndef Profinite.pow_cone {J : Type u} [small_category J] {F : J ⥤ Profinite.{u}}\n (E : limits.cone F) (n : ℕ) : limits.cone (F ⋙ Profinite.pow_functor n) :=\n(Profinite.pow_functor n).map_cone E\n\ndef Profinite.pow_cone_is_limit\n {J : Type u} [small_category J] {F : J ⥤ Profinite.{u}}\n (E : limits.cone F) (hE : limits.is_limit E) (n : ℕ) :\n limits.is_limit (Profinite.pow_cone E n) :=\n{ lift := λ Q, Profinite.product.lift _ $ λ a,\n hE.lift ⟨Q.X,\n { app := λ j, Q.π.app j ≫ Profinite.product.π _ a,\n naturality' := begin\n intros i j e, dsimp,\n simp only [category.id_comp, category.assoc],\n rw ← Q.w e,\n dsimp [Profinite.pow_functor, Profinite.map_pow],\n simp,\n end }⟩,\n fac' := begin\n intros Q j, apply Profinite.product.hom_ext, intros i,\n dsimp [Profinite.pow_cone, Profinite.pow_functor, Profinite.map_pow],\n simp only [category.assoc, Profinite.product.lift_π, Profinite.product.lift_π_assoc,\n limits.is_limit.fac],\n end,\n uniq' := begin\n intros Q m hm,\n apply Profinite.product.hom_ext, intros a,\n dsimp [Profinite.pow_cone, Profinite.pow_functor, Profinite.map_pow],\n simp only [Profinite.product.lift_π],\n apply hE.hom_ext,\n intros j,\n simp only [category.assoc, limits.is_limit.fac], rw ← hm,\n dsimp [Profinite.pow_cone, Profinite.pow_functor, Profinite.map_pow],\n simp only [category.assoc, Profinite.product.lift_π],\n end }\n\nlemma Profinite.is_iso_pmz_to_limit (S : Profinite.{u}) (n : ℕ) :\n is_iso (S.pmz_to_limit n) :=\nbegin\n let E := Profinite.sigma_cone (ulift.{u} (fin n → sign_type))\n (Profinite.pow_cone S.as_limit_cone n),\n let hE : limits.is_limit E := Profinite.sigma_cone_is_limit _ _\n (Profinite.pow_cone_is_limit _ S.as_limit n),\n let q : E.X ≅ (Profinite.limit_cone (S.pmz_diagram n)).X :=\n hE.cone_point_unique_up_to_iso (Profinite.limit_cone_is_limit _),\n have : is_iso q.hom := infer_instance,\n convert this,\n apply Profinite.sigma.hom_ext, intros e,\n apply (Profinite.limit_cone_is_limit _).hom_ext,\n intros T,\n refl,\nend\n\ndef Profinite.pmz_cone_is_limit (S : Profinite.{u}) (n : ℕ) :\n limits.is_limit (S.pmz_cone n) :=\nbegin\n apply limits.is_limit.of_point_iso (Profinite.limit_cone_is_limit _),\n convert Profinite.is_iso_pmz_to_limit S n,\n apply Profinite.sigma.hom_ext, intros a,\n apply (Profinite.limit_cone_is_limit _).hom_ext, intros j,\n refl,\nend\n\n-- A finite product of finite discrete sets is discrete.\ninstance Profinite.discrete_topology_pow\n (S : Profinite.{u}) [discrete_topology S] (n : ℕ) :\n discrete_topology (S.pow n) :=\nPi.discrete_topology\n\n-- A finite union of finite products of finite discrete sets is discrete.\ninstance Profinite.discrete_topology_pmz\n (S : Profinite.{u}) [discrete_topology S] (n : ℕ) :\n discrete_topology (S.pmz n) :=\nsigma.discrete_topology\n\n-- move this\nlemma _root_.sign_type.nnnorm_coe_int_le_one : ∀ i : sign_type, ∥(i : ℤ)∥₊ ≤ 1\n| sign_type.zero := by { erw [nnnorm_zero], exact zero_le', }\n| sign_type.neg := by { erw [nnnorm_neg], norm_num, }\n| sign_type.pos := by { erw [nnnorm_one], }\n\ndef Profinite.pmz_to_level_component (S : Profinite.{u}) (j : nnreal) (T : discrete_quotient S)\n (e : fin ⌊j⌋₊ → sign_type) :\n (Profinite.of ↥T).pow ⌊j⌋₊ ⟶\n (ProFiltPseuNormGrp₁.level.obj j).obj (free_pfpng_functor.obj (Fintype.of ↥T)) :=\n{ to_fun := λ t,\n { val := ∑ i : fin ⌊j⌋₊, (λ s, if t i = s then (e i : ℤ) else 0),\n property := begin\n have : ∑ i : fin ⌊j⌋₊, (∑ s : T, if t i = s then (1 : nnreal) else 0) ≤ j,\n { calc _\n ≤ ∑ i : fin ⌊j⌋₊, (1 : nnreal) : _\n ... ≤ j : _,\n { apply finset.sum_le_sum, rintro i -, apply le_of_eq,\n erw [finset.sum_eq_single_of_mem (t i : T) (@finset.mem_univ T _ _), if_pos rfl],\n rintro s - hs, rw [if_neg hs.symm], },\n { simp only [finset.sum_const, finset.card_fin, nat.smul_one_eq_coe],\n exact nat.floor_le zero_le' } },\n apply pseudo_normed_group.filtration_mono this,\n apply pseudo_normed_group.sum_mem_filtration,\n rintro i -,\n apply finset.sum_le_sum,\n rintro s -,\n dsimp,\n split_ifs,\n { apply sign_type.nnnorm_coe_int_le_one },\n { rw nnnorm_zero },\n end },\n continuous_to_fun := continuous_of_discrete_topology }\n\ndef Profinite.pmz_to_level (S : Profinite.{u}) (j : nnreal) (T : discrete_quotient S) :\n (Profinite.of T).pmz ⌊j⌋₊ ⟶\n (ProFiltPseuNormGrp₁.level.obj j).obj (free_pfpng_functor.obj $ Fintype.of T) :=\nProfinite.sigma.desc _ $ λ e, S.pmz_to_level_component j T (ulift.down e)\n\nlemma Profinite.pmz_to_level_nat_trans_aux\n (S : Profinite.{u}) (j : nnreal) (T₁ T₂ : discrete_quotient S) (f : T₁ ⟶ T₂)\n (e : fin ⌊j⌋₊ → sign_type) (t : (Profinite.of T₁).pow ⌊j⌋₊) (s : T₂) :\n(∑ i : fin ⌊j⌋₊, λ s : T₂, ite (S.fintype_diagram.map f (t i) = s) (e i : ℤ) 0) s =\n (@finset.filter (@bundled.α fintype (S.fintype_diagram.obj T₁))\n (λ w : T₁, S.fintype_diagram.map f w = s)\n (λ (a : @bundled.α fintype (S.fintype_diagram.obj T₁)),\n classical.prop_decidable _)\n (@finset.univ (@bundled.α fintype (S.fintype_diagram.obj T₁))\n (@Fintype.fintype (S.fintype_diagram.obj T₁)))).sum\n (∑ (i : fin ⌊j⌋₊), λ s : T₁, @ite ℤ (t i = s) _ ↑(e i) 0) :=\nbegin\n simp only [finset.sum_apply],\n rw finset.sum_comm,\n refine finset.sum_congr rfl _,\n rintro i -,\n rw finset.sum_ite_eq,\n simp only [finset.mem_filter, finset.mem_univ, true_and],\nend\n\ndef Profinite.pmz_to_level_nat_trans (S : Profinite.{u}) (j : nnreal) :\n S.pmz_diagram ⌊j⌋₊ ⟶ (S.fintype_diagram ⋙ free_pfpng_functor) ⋙\n (ProFiltPseuNormGrp₁.level.obj j) :=\n{ app := λ T, S.pmz_to_level j T,\n naturality' := begin\n intros T₁ T₂ f,\n dsimp [Profinite.pmz_diagram, Profinite.pmz_to_level, Profinite.pmz_functor],\n apply Profinite.sigma.hom_ext,\n rintro ⟨e⟩,\n simp only [Profinite.sigma.ι_desc_assoc, category.assoc, Profinite.sigma.ι_desc],\n ext t s,\n exact Profinite.pmz_to_level_nat_trans_aux S j T₁ T₂ f e t s,\n end }\n\ndef Profinite.pmz_to_free_pfpng (S : Profinite.{u}) (j : nnreal) :\n S.pmz ⌊j⌋₊ ⟶ (ProFiltPseuNormGrp₁.level.obj j).obj S.free_pfpng :=\nlet E := limits.is_limit_of_preserves (ProFiltPseuNormGrp₁.level.obj j)\n (limits.limit.is_limit (S.fintype_diagram ⋙ free_pfpng_functor)) in\nE.map (S.pmz_cone _) (S.pmz_to_level_nat_trans j)\n\nlemma Profinite.is_limit.surjective_of_surjective\n {J : Type u} [small_category J] (F G : J ⥤ Profinite.{u})\n (α : F ⟶ G) (cF : limits.cone F)\n (cG : limits.cone G) (hcF : limits.is_limit cF) (hcG : limits.is_limit cG)\n [is_cofiltered J] (surj : ∀ (j : J), function.surjective ⇑(α.app j)) :\n function.surjective ⇑(limits.is_limit.map cF hcG α) :=\nbegin\n have := CompHaus.is_limit.surjective_of_surjective\n (F ⋙ Profinite_to_CompHaus)\n (G ⋙ Profinite_to_CompHaus)\n (whisker_right α _)\n (Profinite_to_CompHaus.map_cone cF)\n (Profinite_to_CompHaus.map_cone cG)\n (limits.is_limit_of_preserves _ hcF)\n (limits.is_limit_of_preserves _ hcG)\n surj,\n change function.surjective\n (Profinite_to_CompHaus.map (limits.is_limit.map cF hcG α)),\n convert this,\n apply hcG.hom_ext, intros j,\n simp only [limits.is_limit.map_π, iso.trans_hom, iso.symm_hom,\n functor.map_iso_hom, limits.is_limit.unique_up_to_iso_hom,\n limits.cone.category_comp_hom, limits.is_limit.lift_cone_morphism_hom,\n limits.limit.is_limit_lift, limits.cones.functoriality_map_hom,\n Profinite_to_CompHaus_map],\n erw [category.assoc, category.assoc],\n erw hcG.fac,\n have := (lifted_limit_maps_to_original\n (limits.limit.is_limit (G ⋙ Profinite_to_CompHaus))).inv.w j,\n erw this,\n dsimp, simp only [limits.limit.lift_π, limits.cones.postcompose_obj_π,\n nat_trans.comp_app, functor.map_cone_π_app,\n Profinite_to_CompHaus_map, whisker_right_app],\n refl,\nend\n\nsection\nvariables {α : Type*} [decidable_eq α] [nonempty α]\n\nopen finset\n\n-- TODO: Inlining this yields an app-builder exception\nlemma exists_signed_sum_aux {n : ℕ} (sgn : ℕ → sign_type) (b : α) [decidable_eq α]\n {f : α → ℤ}\n ⦃a : α⦄ (g : ℕ → α) (i : ℕ) :\n ite ((range (n - (f a).nat_abs)).piecewise g (λ _, a) i = b)\n ((range (n - (f a).nat_abs)).piecewise sgn (λ _, sign (f a)) i : ℤ) 0 =\n (range (n - (f a).nat_abs)).piecewise (λ j, ite (g j = b) ↑(sgn j) 0)\n (λ j, ite (a = b) ↑(sign (f a)) 0) i :=\nby { unfold piecewise, split_ifs; refl }\n\nlemma exists_signed_sum (s : finset α) (n : ℕ) (f : α → ℤ) (hn : ∑ i in s, (f i).nat_abs ≤ n) :\n ∃ (sgn : ℕ → sign_type) (g : ℕ → α), (∀ i, g i ∉ s → sgn i = 0) ∧\n ∀ a ∈ s, (∑ i in range n, if g i = a then (sgn i : ℤ) else 0) = f a :=\nbegin\n induction s using finset.cons_induction with a s ha ih generalizing n,\n { exact ⟨0, classical.arbitrary _, λ _ _, rfl, λ _, false.elim⟩ },\n rw sum_cons at hn,\n obtain ⟨sgn, g, hg, hf⟩ := ih _ (le_tsub_of_add_le_left hn),\n refine ⟨(range $ n - (f a).nat_abs).piecewise sgn (λ _, sign (f a)),\n (range $ n - (f a).nat_abs).piecewise g (λ _, a), λ i hi, _, λ b hb, _⟩,\n { by_cases i ∈ range (n - (f a).nat_abs),\n { rw piecewise_eq_of_mem _ _ _ h at ⊢ hi,\n exact hg _ (λ h, hi $ subset_cons _ h) },\n { rw piecewise_eq_of_not_mem _ _ _ h at hi,\n exact (hi $ mem_cons_self _ _).elim } },\n transitivity ∑ i in range n, (range $ n - (f a).nat_abs).piecewise\n (λ j, ite (g j = b) (sgn j : ℤ) 0) (λ j, ite (a = b) (sign $ f a) 0) i,\n { exact sum_congr rfl (λ i _, exists_signed_sum_aux _ _ _ _) },\n rw [sum_piecewise, (inter_eq_right_iff_subset _ _).2 (range_mono tsub_le_self)],\n rw mem_cons at hb,\n obtain rfl | hb := hb,\n { rw [sum_eq_zero, zero_add, sum_const, if_pos rfl, card_sdiff (range_mono tsub_le_self),\n card_range, card_range, tsub_tsub_cancel_of_le\n (nat.le_of_add_le_left hn), nsmul_eq_mul, mul_comm,\n ←int.sign_eq_sign, int.nat_cast_eq_coe_nat, (f b).sign_mul_nat_abs],\n refine λ i hi, ite_eq_right_iff.2 _,\n rintro rfl,\n rw [hg _ ha, sign_type.coe_zero] },\n { simp_rw [if_neg (ne_of_mem_of_not_mem hb ha).symm, hf _ hb, sum_const_zero, add_zero] }\nend\n\nlemma Profinite.pmz_to_free_pfpng_epi_aux' [fintype α]\n (r : nnreal) (f : α → ℤ) (hf : ∑ i : α, ∥f i∥₊ ≤ r) :\n ∃ (sgn : ℕ → sign_type) (g : ℕ → α),\n ∀ t, (∑ i in range ⌊r⌋₊, if g i = t then (sgn i : ℤ) else 0) = f t :=\nbegin\n refine Exists₂.imp (λ _ _ h t, _) (exists_signed_sum univ ⌊r⌋₊ f _),\n { exact h.2 t (mem_univ _) },\n refine nat.le_floor _,\n simp_rw [nat.cast_sum, nnreal.coe_nat_abs],\n exact hf,\nend\n\nlemma Profinite.pmz_to_free_pfpng_epi_aux [fintype α]\n (r : nnreal) (f : α → ℤ) (hf : ∑ i : α, ∥f i∥₊ ≤ r) :\n ∃ (sgn : fin ⌊r⌋₊ → sign_type) (g : fin ⌊r⌋₊ → α),\n (∑ i : fin ⌊r⌋₊, (λ t : α, if g i = t then (sgn i : ℤ) else 0)) = f :=\nbegin\n obtain ⟨e,g,h⟩ := Profinite.pmz_to_free_pfpng_epi_aux' r f hf,\n let e' : fin ⌊r⌋₊ → sign_type := λ i, e i.1,\n let g' : fin ⌊r⌋₊ → α := λ i, g i.1,\n use [e',g'],\n ext t, rw ← h,\n simp only [finset.sum_apply],\n rw finset.sum_range, refl,\nend\n\nend\n\n-- Move this\ninstance discrete_quotient.nonempty (X : Type*) [topological_space X] [h : nonempty X]\n (T : discrete_quotient X) : nonempty T := ⟨T.proj (nonempty.some h)⟩\n\ninstance Profinite.pmz_to_free_pfpng_epi (S : Profinite.{u}) [nonempty S] (j : nnreal) :\n epi (S.pmz_to_free_pfpng j) :=\nbegin\n rw Profinite.epi_iff_surjective,\n dsimp only [Profinite.pmz_to_free_pfpng],\n have := Profinite.is_limit.surjective_of_surjective _ _ (S.pmz_to_level_nat_trans j)\n (S.pmz_cone _)\n ((ProFiltPseuNormGrp₁.level.obj j).map_cone (limits.limit.cone _))\n (S.pmz_cone_is_limit _)\n (limits.is_limit_of_preserves _ (limits.limit.is_limit _)),\n apply this,\n intros T,\n rintros ⟨(f : T → ℤ), hf : ∑ i : T, _ ≤ _⟩,\n obtain ⟨e,t,ht⟩ := Profinite.pmz_to_free_pfpng_epi_aux j f hf,\n change ∃ a : Σ i, fin ⌊j⌋₊ → T, _,\n use ulift.up e, use t, apply subtype.ext,\n dsimp [Profinite.pmz_to_level_nat_trans, Profinite.pmz_to_level,\n Profinite.sigma.desc, Profinite.pmz_to_level_component],\n exact ht,\nend\n\n.\n\nnamespace Profinite.epi_free'_to_condensed_setup\n\nvariables (S : Profinite.{u}) (j : nnreal)\n\nlemma free'_lift_app_eq (A : Condensed.{u} Ab.{u+1})\n (η : S.to_Condensed ⟶ Condensed_Ab_to_CondensedSet.obj A)\n (T : Profinite.{u}) :\n (proetale_topology.to_sheafify _).app _ ≫ (S.free'_lift η).val.app (op T) =\n free'_lift (η.val.app _) :=\nbegin\n dsimp [Profinite.free'_lift],\n rw [← nat_trans.comp_app, proetale_topology.to_sheafify_sheafify_lift],\n dsimp [adjunction.whisker_right, free'_lift], simp,\nend\n\nlemma free'_lift_app_eq' (A : Condensed.{u} Ab.{u+1})\n (η : S.to_Condensed ⟶ Condensed_Ab_to_CondensedSet.obj A)\n (T : Profinite.{u}) :\n (proetale_topology.to_sheafify _).app _ ≫ (S.free'_lift η).val.app (op T) =\n ((finsupp.lift ↥(A.val.obj (op T)) ℤ\n (((Sheaf_to_presheaf proetale_topology (Type (u+1))).obj S.to_Condensed).obj (op T)))\n (η.val.app (op T))).to_add_monoid_hom :=\nbegin\n rw free'_lift_app_eq, rw free'_lift_eq_finsupp_lift,\nend\n\ninstance (A : Condensed.{u} Ab.{u+1}) (T) :\n add_comm_group ((Condensed_Ab_to_CondensedSet.obj A).val.obj T) :=\nshow add_comm_group (A.val.obj T), by apply_instance\n\nlemma free_pfpng_ext (u v : S.free_pfpng)\n (huv : ∀ T : discrete_quotient S, S.free_pfpng_π T u = S.free_pfpng_π T v) : u = v :=\nbegin\n let E : limits.cone (S.fintype_diagram ⋙ free_pfpng_functor) :=\n ProFiltPseuNormGrp₁.bounded_cone\n ⟨Ab.explicit_limit_cone.{u u} _, Ab.explicit_limit_cone_is_limit _⟩,\n let hE : limits.is_limit E := ProFiltPseuNormGrp₁.bounded_cone_is_limit _,\n let ee : S.free_pfpng ≅ E.X := (limits.limit.is_limit _).cone_point_unique_up_to_iso hE,\n apply_fun ee.hom, swap,\n { intros x y hh, apply_fun ee.inv at hh, simpa using hh },\n ext T : 3, exact huv T,\nend\n\nvariables (x : S.pmz ⌊j⌋₊) (T : discrete_quotient S)\n\nlemma lhs_helper : (S.free_pfpng_π T) ((S.pmz_to_free_pfpng j) x).1 =\n ∑ i : fin ⌊j⌋₊, pi.single (T.proj (x.2 i)) (x.1.down i : ℤ) :=\nbegin\n change (((S.pmz_to_free_pfpng _) ≫ (ProFiltPseuNormGrp₁.level.obj j).map\n (S.free_pfpng_π T)) _).val = _,\n dsimp [Profinite.pmz_to_free_pfpng, Profinite.free_pfpng_π],\n erw ← comp_apply,\n erw limits.is_limit.fac,\n dsimp [Profinite.pmz_to_level_nat_trans, Profinite.pmz_to_level],\n rcases x with ⟨x1,x2⟩,\n dsimp [Profinite.pmz_cone, Profinite.sigma.desc, Profinite.pmz_to_level_component,\n Profinite.pmz_functor, Profinite.product.lift, Profinite.sigma.ι],\n congr' 1, ext i t, erw pi.single_apply,\n split_ifs with h1 h2 h3 h4,\n { refl },\n { exact false.elim (h2 h1.symm) },\n { exact false.elim (h1 h3.symm) },\n { refl }\nend\n\nlemma rhs_helper₁ :\n (λ (f : ulift (fin ⌊j⌋₊ → sign_type)),\n ∑ (x : fin ⌊j⌋₊),\n ((proetale_topology.to_sheafify (S.to_Condensed.val ⋙ AddCommGroup.free')).app\n (op (S.pow ⌊j⌋₊)))\n (finsupp.single {down := Profinite.product.π (λ (i : fin ⌊j⌋₊), S) x} ↑(f.down x))) =\n ∑ (x : fin ⌊j⌋₊), (λ f, (proetale_topology.to_sheafify\n (S.to_Condensed.val ⋙ AddCommGroup.free')).app (op (S.pow ⌊j⌋₊)) $\n finsupp.single ⟨Profinite.product.π _ x⟩ (f.down x)) := by { ext, simp }\n\ndef _root_.CompHausFiltPseuNormGrp.coe_add_monoid_hom\n (A : CompHausFiltPseuNormGrp.{u}) (T : Profinite.{u}) :\n (CompHausFiltPseuNormGrp.to_Condensed.obj A).val.obj (op T) →+ T → A :=\n{ to_fun := λ f, f.down.1,\n map_zero' := rfl,\n map_add' := λ _ _, rfl }\n\nlemma _root_.CompHausFiltPseuNormGrp.to_Condensed_app_sum_apply (n : ℕ)\n (A : CompHausFiltPseuNormGrp.{u}) (T : Profinite.{u})\n (g : fin n → (CompHausFiltPseuNormGrp.to_Condensed.obj A).val.obj (op T)) (t : T) :\n (ulift.down (∑ i : fin n, g i)).1 t = ∑ i : fin n,\n (ulift.down (g i)).1 t :=\nbegin\n let e := A.coe_add_monoid_hom T,\n change _ = ∑ (i : fin n), (e (g i)) t,\n rw [← finset.sum_apply t finset.univ (λ i : fin n, (e (g i))), ← e.map_sum],\n refl,\nend\n\nlemma Profinite.free'_lift_val_obj_sigma_equiv_symm {α : Type u} [fintype α]\n (A : Condensed.{u} Ab.{u+1}) (η : S.to_Condensed ⟶ Condensed_Ab_to_CondensedSet.obj A)\n (X : α → Profinite.{u}) (t) :\n (S.free'_lift η).val.app (op $ Profinite.sigma X)\n ((Condensed.val_obj_sigma_add_equiv _ _ ).symm t) =\n (Condensed.val_obj_sigma_add_equiv _ _ ).symm (λ a, (S.free'_lift η).val.app _ (t a)) :=\nbegin\n apply_fun Condensed.val_obj_sigma_add_equiv (λ (a : α), X a) A,\n simp only [add_equiv.apply_symm_apply],\n funext a,\n dsimp,\n simp only [← comp_apply, ← nat_trans.naturality],\n simp only [comp_apply],\n congr' 1,\n rw ← Condensed.val_obj_sigma_add_equiv_apply_apply,\n simp only [add_equiv.apply_symm_apply],\nend\n\n-- move and rename\ndef rhs_helper_equiv\n (A : ProFiltPseuNormGrp₁.{u}) :\n A ≃ (CompHausFiltPseuNormGrp.to_Condensed.obj\n (CHFPNG₁_to_CHFPNGₑₗ.obj\n (PFPNG₁_to_CHFPNG₁ₑₗ.obj A))).val.obj\n (op Profinite.punit) :=\n{ to_fun := λ a, ulift.up $ ⟨λ _, a, begin\n obtain ⟨c,hc⟩ := ProFiltPseuNormGrp₁.exhaustive _ a,\n refine ⟨c, λ _, ⟨a,hc⟩, _, rfl⟩,\n apply continuous_of_discrete_topology\n end⟩,\n inv_fun := λ f, f.down.val punit.star,\n left_inv := λ t, rfl,\n right_inv := λ t, by { ext ⟨⟩, refl } }\n\n-- move and rename\ndef rhs_helper_equiv' :\n S ≃ S.to_Condensed.val.obj (op Profinite.punit) :=\n{ to_fun := λ s, ulift.up $ Profinite.pt s,\n inv_fun := λ s, (ulift.down s).1 punit.star,\n left_inv := λ t, rfl,\n right_inv := λ t, by { ext ⟨⟩, refl } }\n\nlemma rhs_helper₄ {α : Type u} [fintype α]\n (A : ProFiltPseuNormGrp₁.{u})\n (X : α → Profinite.{u})\n (e : Π (a : α),\n (CompHausFiltPseuNormGrp.to_Condensed.obj\n (CHFPNG₁_to_CHFPNGₑₗ.obj\n (PFPNG₁_to_CHFPNG₁ₑₗ.obj A))).val.obj (op $ X a))\n (a₀ : α) (x₀ : X a₀) :\n ((Condensed.val_obj_sigma_add_equiv X _).symm e).down.val ⟨a₀,x₀⟩ =\n (e a₀).down.val x₀ :=\nbegin\n let B := Condensed_Ab_to_CondensedSet.obj\n (CompHausFiltPseuNormGrp.to_Condensed.obj\n (CHFPNG₁_to_CHFPNGₑₗ.obj\n (PFPNG₁_to_CHFPNG₁ₑₗ.obj A))) ,\n let e₀ : (X a₀).to_Condensed ⟶ B :=\n (Profinite.to_Condensed_equiv _ B).symm (e a₀),\n let ee : (Profinite.sigma X).to_Condensed ⟶ B :=\n (Profinite.to_Condensed_equiv _ B).symm ((Condensed.val_obj_sigma_add_equiv X _).symm e),\n apply_fun rhs_helper_equiv A,\n let s₀ : (X a₀).to_Condensed.val.obj (op Profinite.punit) :=\n rhs_helper_equiv' _ x₀,\n have : (rhs_helper_equiv A) ((e a₀).down.val x₀) =\n e₀.val.app _ s₀, refl,\n rw this,\n have : e₀ = (Profinite_to_Condensed.map (Profinite.sigma.ι X a₀)) ≫ ee,\n { dsimp only [e₀, ee], symmetry,\n apply _root_.Condensed.val_obj_sigma_add_equiv_symm_apply },\n rw this, refl,\nend\n\nlemma rhs_helper₃ (i : fin ⌊j⌋₊) :\n ((((S.free'_lift S.to_condensed_free_pfpng).val.app (op (S.pmz ⌊j⌋₊)))\n (((Condensed.val_obj_sigma_add_equiv (λ (f : ulift (fin ⌊j⌋₊ → sign_type)), S.pow ⌊j⌋₊)\n S.free').symm)\n (λ (f : ulift (fin ⌊j⌋₊ → sign_type)),\n ((proetale_topology.to_sheafify (S.to_Condensed.val ⋙ AddCommGroup.free')).app\n (op (S.pow ⌊j⌋₊)))\n (finsupp.single {down := Profinite.product.π (λ (i : fin ⌊j⌋₊), S) i}\n ↑(f.down i))))).down).1 x =\n (x.1.down i : ℤ) • (S.to_free_pfpng (x.2 i)).1 :=\nbegin\n erw Profinite.free'_lift_val_obj_sigma_equiv_symm,\n simp only [← comp_apply],\n erw [free'_lift_app_eq'],\n simp only [continuous_map.to_fun_eq_coe, linear_map.to_add_monoid_hom_coe, finsupp.lift_apply,\n Profinite.to_condensed_free_pfpng_app, finsupp.sum_single_index, zero_smul, subtype.val_eq_coe],\n -- This is now very close...\n let Q := Condensed.val_obj_sigma_add_equiv (λ (a : ulift (fin ⌊j⌋₊ → sign_type)), S.pow ⌊j⌋₊)\n S.condensed_free_pfpng,\n change (Q.symm _).down.1 _ = _,\n cases x with x1 x2,\n erw rhs_helper₄,\n refl,\nend\n\nlemma rhs_helper₂ (i : fin ⌊j⌋₊) : (S.free_pfpng_π T)\n (((((S.free'_lift S.to_condensed_free_pfpng).val.app (op (S.pmz ⌊j⌋₊)))\n (((Condensed.val_obj_sigma_add_equiv (λ (f : ulift (fin ⌊j⌋₊ → sign_type)), S.pow ⌊j⌋₊)\n S.free').symm)\n (λ (f : ulift (fin ⌊j⌋₊ → sign_type)),\n ((proetale_topology.to_sheafify (S.to_Condensed.val ⋙ AddCommGroup.free')).app\n (op (S.pow ⌊j⌋₊)))\n (finsupp.single {down := Profinite.product.π (λ (i : fin ⌊j⌋₊), S) i}\n ↑(f.down i))))).down).1 x) =\n pi.single (T.proj (x.snd i)) ↑(x.fst.down i) :=\nbegin\n rw rhs_helper₃,\n erw (S.free_pfpng_π T).to_add_monoid_hom.map_zsmul,\n change\n _ • (((S.to_free_pfpng) ≫ (ProFiltPseuNormGrp₁.level.obj 1).map (S.free_pfpng_π T)) _).val = _,\n dsimp [Profinite.to_free_pfpng, Profinite.free_pfpng_π,\n Profinite.free_pfpng_level_iso],\n dsimp [limits.is_limit.cone_point_unique_up_to_iso],\n erw ← comp_apply,\n erw ← comp_apply,\n erw limits.is_limit.fac,\n erw limits.is_limit.fac,\n dsimp [Fintype.free_pfpng_unit, Profinite.as_limit_cone],\n ext t, erw pi.single_apply, split_ifs; simp,\n { intros hh, exact false.elim (hh h.symm) },\n { intros hh, exact false.elim (h hh.symm) },\nend\n\nlemma rhs_helper :\n (S.free_pfpng_π T)\n ((((S.free'_lift S.to_condensed_free_pfpng).val.app (op (S.pmz ⌊j⌋₊)))\n ((S.pmz_to_free' ⌊j⌋₊).val.app (op (S.pmz ⌊j⌋₊)) {down := 𝟙 (S.pmz ⌊j⌋₊)})).1.1 x) =\n ∑ i : fin ⌊j⌋₊, pi.single (T.proj (x.2 i)) (x.1.down i : ℤ) :=\nbegin\n dsimp [Profinite.pmz_to_free'],\n rw [category_theory.functor.map_id, id_apply],\n simp only [add_monoid_hom.map_sum],\n rw [rhs_helper₁],\n rw [add_equiv.map_sum, add_monoid_hom.map_sum],\n have := _root_.CompHausFiltPseuNormGrp.to_Condensed_app_sum_apply ⌊j⌋₊ _ _ _ x,\n dsimp at this, erw this, clear this,\n erw (S.free_pfpng_π T).to_add_monoid_hom.map_sum,\n congr' 1, funext i, dsimp,\n erw rhs_helper₂,\nend\n\nlemma key (j : (ulift.{u+1} nnreal)) :\n Profinite_to_Condensed.map (S.pmz_to_free_pfpng j.down) ≫\n (CHFPNG₁_to_CHFPNGₑₗ.obj\n (PFPNG₁_to_CHFPNG₁ₑₗ.obj S.free_pfpng)).level_Condensed_diagram_cocone.ι.app j =\n S.pmz_to_free' ⌊j.down⌋₊ ≫\n Condensed_Ab_to_CondensedSet.map S.free'_to_condensed_free_pfpng :=\nbegin\n apply_fun Profinite.to_Condensed_equiv _ _,\n ext x : 3, dsimp at x,\n dsimp [CompHausFiltPseuNormGrp.level_Condensed_diagram_cocone,\n Profinite.free'_to_condensed_free_pfpng],\n apply free_pfpng_ext, intros T,\n erw lhs_helper, erw rhs_helper,\nend\n\nend Profinite.epi_free'_to_condensed_setup\n\ninstance Profinite.epi_free'_to_condensed_free_pfpng_of_nonempty\n (S : Profinite.{u}) [nonempty S] : epi S.free'_to_condensed_free_pfpng :=\nbegin\n apply faithful_reflects_epi (Condensed_Ab_to_CondensedSet),\n let E := CompHausFiltPseuNormGrp.level_Condensed_diagram_cocone\n (CHFPNG₁_to_CHFPNGₑₗ.obj\n ((PFPNG₁_to_CHFPNG₁ₑₗ.obj S.free_pfpng))),\n have hh : is_iso (limits.colimit.desc _ E),\n { change is_iso (CompHausFiltPseuNormGrp.colimit_to_Condensed_obj _),\n apply_instance },\n let hE : limits.is_colimit E := @limits.is_colimit.of_point_iso\n _ _ _ _ _ _ _ _ hh, -- <-- move this\n apply category_theory.epi_to_colimit_of_exists _ E hE,\n intros j,\n let j' : nnreal := ulift.down j,\n use [(S.pmz ⌊j'⌋₊).to_Condensed, S.pmz_to_free' ⌊j'⌋₊,\n Profinite_to_Condensed.map (S.pmz_to_free_pfpng j')],\n split,\n { apply epi_Profinite_to_Condensed_map_of_epi },\n { apply Profinite.epi_free'_to_condensed_setup.key },\nend\n", "meta": {"author": "bentoner", "repo": "debug", "sha": "b8a75381caa90aa9942c20e08a44e45d0ae60d18", "save_path": "github-repos/lean/bentoner-debug", "path": "github-repos/lean/bentoner-debug/debug-b8a75381caa90aa9942c20e08a44e45d0ae60d18/src/free_pfpng/epi.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.4073334000459302, "lm_q1q2_score": 0.20843926445410693}} {"text": "import pseudo_normed_group.profinitely_filtered\n/-!\n\n# Profinitely filtered pseudo-normed groups with T⁻¹\n\nThe definition of `profinitely_filtered_pseudo_normed_group_with_Tinv`,\nand morphisms between them.\n\n-/\nopen pseudo_normed_group profinitely_filtered_pseudo_normed_group\n comphaus_filtered_pseudo_normed_group\nopen_locale nnreal big_operators\n\nlocal attribute [instance] type_pow\n\nclass comphaus_filtered_pseudo_normed_group_with_Tinv (r' : out_param $ ℝ≥0) (M : Type*)\n extends comphaus_filtered_pseudo_normed_group M :=\n(Tinv : comphaus_filtered_pseudo_normed_group_hom M M)\n(Tinv_mem_filtration : ∀ c x, x ∈ filtration c → Tinv x ∈ filtration (r'⁻¹ * c))\n\n/-- A *profinitely filtered pseudo-normed topological group with action by `T⁻¹`* is\na profinitely filtered pseudo-normed topological group `M` together with a\nnonnegative real `r'` and homomorphism `Tinv : M → M` such that\n`Tinv x ∈ filtration M (r'⁻¹ * c)` for all `x ∈ filtration M c`.\n-/\nclass profinitely_filtered_pseudo_normed_group_with_Tinv (r' : out_param $ ℝ≥0) (M : Type*)\n extends profinitely_filtered_pseudo_normed_group M :=\n(Tinv : comphaus_filtered_pseudo_normed_group_hom M M)\n(Tinv_mem_filtration : ∀ c x, x ∈ filtration c → Tinv x ∈ filtration (r'⁻¹ * c))\n\nnamespace profinitely_filtered_pseudo_normed_group_with_Tinv\n\nvariables {r' : ℝ≥0} {M M₁ M₂ M₃ : Type*}\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M₁]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M₂]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M₃]\n\nlemma aux {r' c c₂ : ℝ≥0} (h : c ≤ r' * c₂) : r'⁻¹ * c ≤ c₂ :=\nbegin\n by_cases hr' : r' = 0,\n { subst r', rw [inv_zero, zero_mul], exact zero_le' },\n { rwa [nnreal.mul_le_iff_le_inv, inv_inv], exact inv_ne_zero hr' }\nend\n\n@[simps]\ndef Tinv₀ (c c₂ : ℝ≥0) [h : fact (c ≤ r' * c₂)] (x : filtration M c) : filtration M c₂ :=\n⟨Tinv (x : M), filtration_mono (aux h.1) (Tinv_mem_filtration _ _ x.2)⟩\n\nlemma Tinv₀_continuous (c c₂ : ℝ≥0) [fact (c ≤ r' * c₂)] :\n continuous (@Tinv₀ r' M _ c c₂ _) :=\nTinv.continuous _ $ λ x, rfl\n\nlemma Tinv_bound_by : (@Tinv _ M _).bound_by (r'⁻¹) := Tinv_mem_filtration\n\ninstance to_comphaus_filtered_pseudo_normed_group_with_Tinv\n (M : Type*) [profinitely_filtered_pseudo_normed_group_with_Tinv r' M] :\n comphaus_filtered_pseudo_normed_group_with_Tinv r' M :=\n{ ..(infer_instance : profinitely_filtered_pseudo_normed_group_with_Tinv r' M) }\n\nend profinitely_filtered_pseudo_normed_group_with_Tinv\n\nsection\nset_option old_structure_cmd true\n\nopen comphaus_filtered_pseudo_normed_group_with_Tinv\n\n/-- The type of strict morphisms between two compact Hausdorff filtered pseudo-normed groups\nwith an action of T⁻¹. -/\nstructure comphaus_filtered_pseudo_normed_group_with_Tinv_hom (r' : ℝ≥0) (M₁ M₂ : Type*)\n [comphaus_filtered_pseudo_normed_group_with_Tinv r' M₁]\n [comphaus_filtered_pseudo_normed_group_with_Tinv r' M₂]\n extends M₁ →+ M₂ :=\n(strict' : ∀ ⦃c x⦄, x ∈ filtration M₁ c → to_fun x ∈ filtration M₂ c)\n(continuous' : ∀ c, continuous (pseudo_normed_group.level to_fun strict' c))\n(map_Tinv' : ∀ x, to_fun (Tinv x) = Tinv (to_fun x))\n\nend\n\nattribute [nolint doc_blame] comphaus_filtered_pseudo_normed_group_with_Tinv_hom.mk\n comphaus_filtered_pseudo_normed_group_with_Tinv_hom.to_add_monoid_hom\n\nnamespace comphaus_filtered_pseudo_normed_group_with_Tinv_hom\n\nopen comphaus_filtered_pseudo_normed_group_with_Tinv\n\nvariables {r' : ℝ≥0} {M M₁ M₂ M₃ : Type*}\nvariables [comphaus_filtered_pseudo_normed_group_with_Tinv r' M]\nvariables [comphaus_filtered_pseudo_normed_group_with_Tinv r' M₁]\nvariables [comphaus_filtered_pseudo_normed_group_with_Tinv r' M₂]\nvariables [comphaus_filtered_pseudo_normed_group_with_Tinv r' M₃]\nvariables (f g : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂)\n\ninstance : has_coe_to_fun (comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂)\n (λ _, M₁ → M₂):=\n⟨comphaus_filtered_pseudo_normed_group_with_Tinv_hom.to_fun⟩\n\n@[simp] lemma coe_mk (f) (h₁) (h₂) (h₃) (h₄) (h₅) :\n ⇑(⟨f, h₁, h₂, h₃, h₄, h₅⟩ : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂) = f :=\nrfl\n\n@[simp] lemma mk_to_monoid_hom (f) (h₁) (h₂) (h₃) (h₄) (h₅) :\n (⟨f, h₁, h₂, h₃, h₄, h₅⟩ :\n comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂).to_add_monoid_hom =\n ⟨f, h₁, h₂⟩ := rfl\n\n@[simp] lemma coe_to_add_monoid_hom : ⇑f.to_add_monoid_hom = f := rfl\n\n@[simp] lemma map_zero : f 0 = 0 := f.to_add_monoid_hom.map_zero\n\n@[simp] lemma map_add (x y) : f (x + y) = f x + f y := f.to_add_monoid_hom.map_add _ _\n\n@[simp] lemma map_sum {ι : Type*} (x : ι → M₁) (s : finset ι) :\n f (∑ i in s, x i) = ∑ i in s, f (x i) :=\nf.to_add_monoid_hom.map_sum _ _\n\n@[simp] lemma map_sub (x y) : f (x - y) = f x - f y := f.to_add_monoid_hom.map_sub _ _\n\n@[simp] lemma map_neg (x) : f (-x) = -(f x) := f.to_add_monoid_hom.map_neg _\n\n@[simp] lemma map_zsmul (n : ℤ) (x) : f (n • x) = n • (f x) := f.to_add_monoid_hom.map_zsmul _ _\n\nlemma strict : ∀ ⦃c x⦄, x ∈ filtration M₁ c → f x ∈ filtration M₂ c := f.strict'\n\n/-- `f.level c` is the function `filtration M₁ c → filtration M₂ c`\ninduced by a `comphaus_filtered_pseudo_normed_group_with_Tinv_hom M₁ M₂`. -/\n@[simps] def level : ∀ (c : ℝ≥0), filtration M₁ c → filtration M₂ c :=\npseudo_normed_group.level f f.strict\n\nlemma level_continuous (c : ℝ≥0) : continuous (f.level c) := f.continuous' c\n\nlemma map_Tinv (x : M₁) : f (Tinv x) = Tinv (f x) := f.map_Tinv' x\n\nvariables {f g}\n\n@[ext] theorem ext (H : ∀ x, f x = g x) : f = g :=\nby cases f; cases g; congr'; exact funext H\n\ninstance : has_zero (comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂) :=\n⟨{ strict' := λ c x h, zero_mem_filtration _,\n continuous' := λ c, @continuous_const _ (filtration M₂ c) _ _ 0,\n map_Tinv' := λ x, show 0 = Tinv (0 : M₂), from Tinv.map_zero.symm,\n .. (0 : M₁ →+ M₂) }⟩\n\ninstance : inhabited (comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂) := ⟨0⟩\n\nlemma coe_inj ⦃f g : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂⦄\n (h : (f : M₁ → M₂) = g) :\n f = g :=\nby cases f; cases g; cases h; refl\n\n/-- The identity function as `comphaus_filtered_pseudo_normed_group_with_Tinv_hom`. -/\n@[simps] def id : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M M :=\n{ strict' := λ c x, id,\n continuous' := λ c, by { convert continuous_id, ext, refl },\n map_Tinv' := λ x, rfl,\n .. add_monoid_hom.id _ }\n\n/-- The composition of `comphaus_filtered_pseudo_normed_group_with_Tinv_hom`s. -/\n@[simps] def comp\n (g : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₂ M₃)\n (f : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂) :\n comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₃ :=\n{ strict' := λ c x hx, g.strict (f.strict hx),\n continuous' := λ c, (g.level_continuous c).comp (f.level_continuous c),\n map_Tinv' := λ x,\n calc g (f (Tinv x)) = g (Tinv (f x)) : by rw f.map_Tinv\n ... = Tinv (g (f x)) : by rw g.map_Tinv,\n .. (g.to_add_monoid_hom.comp f.to_add_monoid_hom) }\n\nvariables (f)\n\n/-- The `comphaus_filtered_pseudo_normed_group_hom` underlying a\n`comphaus_filtered_pseudo_normed_group_with_Tinv_hom`. -/\ndef to_comphaus_filtered_pseudo_normed_group_hom :\n comphaus_filtered_pseudo_normed_group_hom M₁ M₂ :=\ncomphaus_filtered_pseudo_normed_group_hom.mk_of_strict f.to_add_monoid_hom\n(λ c, ⟨λ x h, f.strict h, f.level_continuous c⟩)\n\nlemma to_profinitely_filtered_pseudo_normed_group_hom_strict :\n f.to_comphaus_filtered_pseudo_normed_group_hom.strict :=\ncomphaus_filtered_pseudo_normed_group_hom.mk_of_strict_strict _ _\n\nvariables {f}\n\ndef mk' (f : comphaus_filtered_pseudo_normed_group_hom M₁ M₂)\n (hf1 : f.bound_by 1) (hfT) :\n comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₁ M₂ :=\n{ to_fun := f,\n strict' := λ c x hx, by simpa only [one_mul] using hf1 hx,\n continuous' := λ c, f.continuous _ (λ x, rfl),\n map_Tinv' := hfT,\n .. f }\n\n@[simp] lemma mk'_apply\n (f : comphaus_filtered_pseudo_normed_group_hom M₁ M₂) (hf1) (hfT) (x : M₁) :\n @mk' r' _ _ _ _ f hf1 hfT x = f x := rfl\n\n/-- If the inverse of `comphaus_filtered_pseudo_normed_group_with_Tinv_hom` is strict, then it\nis a `comphaus_filtered_pseudo_normed_group_with_Tinv_hom`. -/\ndef inv_of_equiv_of_strict (e : M₁ ≃+ M₂) (he : ∀ x, f x = e x)\n (strict : ∀ ⦃c x⦄, x ∈ filtration M₂ c → e.symm x ∈ filtration M₁ c) :\n comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M₂ M₁ :=\n{ strict' := strict,\n continuous' := λ c,\n begin\n simp only [add_equiv.coe_to_add_monoid_hom, add_monoid_hom.to_fun_eq_coe],\n have hcont := f.continuous' c,\n let g : (filtration M₁ c) ≃ (filtration M₂ c) :=\n ⟨λ x, ⟨f x, f.strict x.2⟩, λ x, ⟨e.symm x, strict x.2⟩, λ x, by simp [he], λ x, by simp [he]⟩,\n change continuous g.symm,\n rw continuous_iff_is_closed,\n intros U hU,\n rw [← g.image_eq_preimage],\n exact (hcont.closed_embedding g.injective).is_closed_map U hU,\n end,\n map_Tinv' := λ x,\n begin\n apply e.injective,\n simp only [add_equiv.coe_to_add_monoid_hom, add_monoid_hom.to_fun_eq_coe],\n rw [e.apply_symm_apply, ← he, map_Tinv, he, e.apply_symm_apply],\n end,\n .. e.symm.to_add_monoid_hom }\n\n@[simp]\nlemma inv_of_equiv_of_strict.apply (x : M₁) (e : M₁ ≃+ M₂) (he : ∀ x, f x = e x)\n (strict : ∀ ⦃c x⦄, x ∈ filtration M₂ c → e.symm x ∈ filtration M₁ c) :\n (inv_of_equiv_of_strict e he strict) (f x) = x := by simp [inv_of_equiv_of_strict, he]\n\n@[simp]\nlemma inv_of_equiv_of_strict_symm.apply (x : M₂) (e : M₁ ≃+ M₂) (he : ∀ x, f x = e x)\n (strict : ∀ ⦃c x⦄, x ∈ filtration M₂ c → e.symm x ∈ filtration M₁ c) :\n f (inv_of_equiv_of_strict e he strict x) = x := by simp [inv_of_equiv_of_strict, he]\n\nend comphaus_filtered_pseudo_normed_group_with_Tinv_hom\n\nnamespace punit\n\ninstance profinitely_filtered_pseudo_normed_group_with_Tinv (r' : ℝ≥0) :\n profinitely_filtered_pseudo_normed_group_with_Tinv r' punit :=\n{ Tinv := comphaus_filtered_pseudo_normed_group_hom.id,\n Tinv_mem_filtration := λ c x h, set.mem_univ _,\n .. punit.profinitely_filtered_pseudo_normed_group }\n\nend punit\n\nnamespace profinitely_filtered_pseudo_normed_group_with_Tinv\n\nsection\n-- TODO: Generalize this section to `comphaus_filtered...` as needed.\n/-! ## Powers -/\n\nnoncomputable theory\n\nvariables (r' : ℝ≥0) {ι : Type*} (M M₁ M₂ : ι → Type*)\nvariables [Π i, profinitely_filtered_pseudo_normed_group_with_Tinv r' (M i)]\nvariables [Π i, profinitely_filtered_pseudo_normed_group_with_Tinv r' (M₁ i)]\nvariables [Π i, profinitely_filtered_pseudo_normed_group_with_Tinv r' (M₂ i)]\n\ninstance pi : profinitely_filtered_pseudo_normed_group_with_Tinv r' (Π i, M i) :=\n{ Tinv := comphaus_filtered_pseudo_normed_group.pi_map (λ i, Tinv)\n ⟨r'⁻¹, λ i, Tinv_bound_by⟩,\n Tinv_mem_filtration := λ c x hx i, Tinv_mem_filtration _ _ (hx i),\n .. profinitely_filtered_pseudo_normed_group.pi _ }\n\ninstance pi' (M : Type*) [profinitely_filtered_pseudo_normed_group_with_Tinv r' M] (N : ℕ) :\n profinitely_filtered_pseudo_normed_group_with_Tinv r' (M^N) :=\nprofinitely_filtered_pseudo_normed_group_with_Tinv.pi r' (λ i, M)\n\ninclude r'\n@[simp] lemma pi_Tinv_apply (x : Π i, M i) (i : ι) : Tinv x i = Tinv (x i) := rfl\nomit r'\n\n@[simps {fully_applied := ff}]\ndef pi_proj (i : ι) : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' (Π i, M i) (M i) :=\n{ to_fun := pi.eval_add_monoid_hom M i,\n strict' := λ c x hx, hx i,\n continuous' := λ c, (continuous_apply i).comp (filtration_pi_homeo M c).continuous,\n map_Tinv' := λ x, rfl,\n .. pi.eval_add_monoid_hom M i }\n\n/-- Universal property of the product of\nprofinitely filtered pseudo-normed groups with `T⁻¹`-action -/\n@[simps {fully_applied := ff}]\ndef pi_lift {N : Type*} [profinitely_filtered_pseudo_normed_group_with_Tinv r' N]\n (f : Π i, comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' N (M i)) :\n comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' N (Π i, M i) :=\n{ to_fun := add_monoid_hom.mk_to_pi (λ i, (f i).to_add_monoid_hom),\n strict' := λ c x hx i, (f i).strict hx,\n continuous' :=\n begin\n intros c,\n rw continuous_induced_rng,\n apply continuous_pi,\n intro i,\n exact (f i).continuous' c,\n end,\n map_Tinv' := λ x, by { ext i, exact (f i).map_Tinv x },\n .. add_monoid_hom.mk_to_pi (λ i, (f i).to_add_monoid_hom) }\n\n@[simps {fully_applied := ff}]\ndef pi_map (f : Π i, comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' (M₁ i) (M₂ i)) :\n comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' (Π i, M₁ i) (Π i, M₂ i) :=\npi_lift r' _ $ λ i, (f i).comp (pi_proj r' _ i)\n\nend\n\nend profinitely_filtered_pseudo_normed_group_with_Tinv\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/pseudo_normed_group/with_Tinv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5312093585306514, "lm_q2_score": 0.39233683016710835, "lm_q1q2_score": 0.20841299588101875}} {"text": "import analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume A : set (euclidean_space ℝ (fin n)),\n assume h1 : is_open_cover A,\n have h2 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open_cover Cm ∧ ∀ c ∈ Cm, ∃ a ∈ A, c ⊆ a ∧ c ⊆ (ℝn \\ (closure (ball (0 : ℝn) m))), from sorry,\n have h3 : ∀ m : ℕ, is_open_cover (⋃ m : ℕ, classical.some (h2 m)), from sorry,\n have h4 : ∀ m : ℕ, ∀ c ∈ (⋃ m : ℕ, classical.some (h2 m)), ∃ a ∈ A, c ⊆ a ∧ c ⊆ (ℝn \\ (closure (ball (0 : ℝn) m))), from sorry,\n have h5 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ closure (ball (0 : ℝn) m)), from sorry,\n have h6 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h7 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h8 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h9 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h10 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h11 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h12 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h13 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h14 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h15 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h16 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h17 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h18 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h19 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h20 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h21 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h22 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h23 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h24 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h25 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h26 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h27 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry,\n have h28 : ∀ x : ℝn, ∃ m : ℕ, ∀ y : ℝn, (y ∈ (⋃ m : ℕ, classical.some (h2 m))) → (x ∈ ball (0 : ℝn) m), from sorry\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open_cover A),\n have h1 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h2 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h3 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h4 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h5 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h6 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h7 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h8 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h9 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h10 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h11 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h12 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h13 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h14 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h15 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h16 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h17 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h18 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h19 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h20 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h21 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h22 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h23 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h24 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h25 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h26 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h27 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h28 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h29 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h30 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h31 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h32 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h33 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h34 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h35 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h36 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h37 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h38 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h39 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h40 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h41 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h42 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h43 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ), x ≤ m ∧ m ≤ x + 1, from sorry,\n have h44 : ∀ (x : ℝ) (n : ℕ), ∃ (m : ℕ),\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open A) (hA2 : is_cover A),\n have h1 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h2 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h3 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h4 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h5 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h6 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h7 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n\n have h8 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h9 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h10 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h11 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h12 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h13 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h14 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h15 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h16 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h17 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h18 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h19 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h20 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open Cm ∧ ∀ x : euclidean_space ℝ (fin n), x ∈ Cm → x ∉ (closure (ball (0 : euclidean_space ℝ (fin n)) (m - 1))), from sorry,\n have h21 : ∀ m : ℕ, ∃ Cm : set (euclidean_space ℝ (fin n)), is_open C\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open A) (hA_cover : ⋃₀ A = univ),\n\n have h1 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h2 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h3 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h4 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h5 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h6 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h7 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h8 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h9 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h10 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h11 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h12 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h13 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h14 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h15 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h16 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h17 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h18 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h19 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h20 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h21 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_m ∧ ∀ U ∈ A, ∃ V ∈ C_m, U ⊆ V ∧ V ∩ (closure (ball (0 : ℝ^n) m)) = ∅, from sorry,\n\n have h22 : ∀ m : ℕ, ∃ C_m : set (euclidean_space ℝ (fin n)), is_open C_\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open_cover A),\n have h1 : ∀ m : ℕ, is_open (ball (0 : ℝ^(fin n)) m), from sorry,\n have h2 : ∀ m : ℕ, is_compact (closure (ball (0 : ℝ^(fin n)) m)), from sorry,\n have h3 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h4 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h5 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h6 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h7 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h8 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h9 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h10 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h11 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h12 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h13 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h14 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h15 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h16 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h17 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h18 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h19 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h20 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h21 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h22 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h23 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h24 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h25 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h26 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h27 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h28 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h29 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h30 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h31 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h32 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h33 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h34 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h35 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h36 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h37 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h38 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h39 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h40 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h41 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h42 : ∀ m : ℕ, ∃ (C : set (euclidean_space ℝ (fin n))) (hC : is_open_cover C), sorry,\n have h43 : ∀ m : ℕ\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume A : set (euclidean_space ℝ (fin n)),\n assume hA : is_open A,\n assume hA2 : is_cover A,\n have h1 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h2 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h3 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h4 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h5 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h6 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h7 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h8 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h9 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h10 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h11 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h12 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h13 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h14 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h15 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h16 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h17 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h18 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h19 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h20 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h21 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h22 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h23 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h24 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h25 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h26 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h27 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h28 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h29 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h30 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h31 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h32 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h33 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h34 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h35 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h36 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h37 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h38 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h39 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h40 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h41 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h42 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h43 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h44 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h45 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h46 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h47 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h48 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 > 0, from sorry,\n have h49 : ∀ x : ℝ, ∃ m : ℕ, x - m ≤ 0 ∧ x + m + 1 >\nend --Needs more than 2000 tokens!\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n have h2 : (A ∩ B) ⊆ A, from sorry,\n have h3 : (A ∩ B) ⊆ S, from sorry,\n show (A ∩ B) ∈ 𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n calc (x + y)^2 = (x+y)*(x+y) : by sorry\n ... = x*(x+y) + y*(x+y) : by sorry\n ... = x*x + x*y + y*x + y*y : by sorry\n ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n use (1 : G),\n have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n show e = (1 : G), from sorry, \n },\n sorry,\n }\nend\n\n/--`theorem`\n\\mathbb{R}^n is paracompact\n$\\mathbb{R}^n$ is paracompact for all $n$.\n`proof`\nLet $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$. We now construct a locally finite open refinement $\\mathcal{C}$ of $\\mathcal{A}$ that covers $\\mathbb{R}^n$. First, we define a collection of pen balls. Let $B_0 = \\phi$, and for each $n \\in \\mathbb{N}$, let $B_m$ denote the ball of radius $m$\ncentered at 0. Given $m$, set $\\Bar{B_m}$ is compact in $\\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\\mathcal{A}$ that cover $\\Bar{B_m}$ and intersect each one with the open set $\\mathbb{R}^n \\setminus \\Bar{B_{m - 1}}$, and let $\\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\\mathcal{A}$). So $\\mathcal{C} = \\bigcup_{m = 0}^{\\infty} \\mathcal{C}_m$ is an open refinement of $\\mathcal{A}$. Note that $\\mathcal{C}$ covers $\\mathbb{R}^n$ since for any $x \\in \\mathbb{R}^n$, there is a smallest $m \\in \\mathbb{N}$ such that $x \\in \\Bar{B_{m}}$ (namely, some $m$ where $\\rVert x \\lVert \\leq m \\leq \\rVert x \\lVert + 1$), and so $x$ is an element of $\\mathcal{C}_m$. Now collection $\\mathcal{C}$ is locally finite since for given $x \\in \\mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\\mathcal{C}$, namely those elements in collection $\\mathcal{C}_1 \\cup \\mathcal{C}_2 \\cup \\cdots \\mathcal{C}_m$. So $\\mathcal{C}$ is a locally finite open refinement of $\\mathcal{A}$ that covers $\\mathbb{R}^n$, hence $\\mathbb{R}^n$ is paracompact.\n\nQED\n-/\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline-Natural-Language-Proof-Translation/Correct_statement-lean_proof_outline-3_few_shot_temperature_0.4_max_tokens_2000_n_6/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6992544210587586, "lm_q2_score": 0.2974699363766584, "lm_q1q2_score": 0.20800716814344603}} {"text": "import analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (A : set (euclidean_space ℝ (fin n))),\n assume hA : is_open_cover A,\n have h1 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ n : ℕ, n < m → x ∉ closure (ball (0 : euclidean_space ℝ (fin n)) n), from sorry,\n \n have h2 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ n : ℕ, n < m → x ∉ ball (0 : euclidean_space ℝ (fin n)) n, from sorry,\n \n have h3 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∃ Cₘ : set (euclidean_space ℝ (fin n)), x ∈ Cₘ ∧ Cₘ ⊆ ⋃₀ A ∧ ∀ y ∈ Cₘ, y ∈ ball (0 : euclidean_space ℝ (fin n)) m ∧ y ∉ ball (0 : euclidean_space ℝ (fin n)) (m - 1), from sorry,\n\n show ∃ C : set (euclidean_space ℝ (fin n)), is_open_cover C ∧ is_locally_finite_cover C ∧ A ≤ C, from sorry,\nend\n\n--OUTPUT 2\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (U : set (euclidean_space ℝ (fin n))) (h1 : is_open U),\n have h2 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = (⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1), from sorry,\n have h3 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h4 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h5 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h6 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h7 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h8 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h9 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h10 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h11 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h12 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h13 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h14 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h15 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h16 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h17 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h18 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h19 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h20 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h21 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h22 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h23 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h24 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h25 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h26 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_open_ball x 1, from sorry,\n have h27 : ∃ (K : set (euclidean_space ℝ (fin n))), is_compact K ∧ U = ⋃ (x : (euclidean_space ℝ (fin n))) (h2 : x ∈ K), is_\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open A) (hA2 : ⋃₀ A = univ),\n\n let C0 : set (euclidean_space ℝ (fin n)) := {},\n let B0 : set (euclidean_space ℝ (fin n)) := {},\n let Bm : ℕ → set (euclidean_space ℝ (fin n)) := λ m, {x | ∃ (y : euclidean_space ℝ (fin n)), y ∈ Bm 0 ∧ x ∈ ball (euclidean_space ℝ (fin n)) y m},\n let Cm : ℕ → set (euclidean_space ℝ (fin n)) := λ m, {x | ∃ (y : euclidean_space ℝ (fin n)), y ∈ Bm 0 ∧ x ∈ ball (euclidean_space ℝ (fin n)) y m ∧ y ∉ Bm 0},\n let C : set (euclidean_space ℝ (fin n)) := {x | ∃ (m : ℕ) (y : euclidean_space ℝ (fin n)), y ∈ Bm 0 ∧ x ∈ ball (euclidean_space ℝ (fin n)) y m ∧ y ∉ Bm 0},\n let B : set (euclidean_space ℝ (fin n)) := {x | ∃ (m : ℕ) (y : euclidean_space ℝ (fin n)), y ∈ Bm 0 ∧ x ∈ ball (euclidean_space ℝ (fin n)) y m},\n\n have hB0 : is_open B0, from sorry,\n have hBm : ∀ m : ℕ, is_open (Bm m), from sorry,\n have hB : is_open B, from sorry,\n\n have hC0 : is_open C0, from sorry,\n have hCm : ∀ m : ℕ, is_open (Cm m), from sorry,\n have hC : is_open C, from sorry,\n\nend\n\n--OUTPUT 4\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (φ : set (euclidean_space ℝ (fin n))),\n assume (h1 : φ = ∅),\n have h2 : φ = ∅, from sorry,\n have h3 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h4 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h5 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h6 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h7 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h8 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h9 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h10 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h11 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h12 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h13 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h14 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h15 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h16 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h17 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h18 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h19 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h20 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h21 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h22 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h23 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h24 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h25 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h26 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h27 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h28 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h29 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h30 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h31 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h32 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h33 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h34 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h35 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h36 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h37 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h38 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h39 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h40 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h41 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h42 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h43 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h44 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h45 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h46 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h47 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h48 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h49 : ∀ (U : set (euclidean_space ℝ (fin n))), U ∈ φ → U = ∅, from sorry,\n have h50 : ∀ (U : set (euclidean_space\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open A) (h1 : A₀ ⊆ A),\n have h2 : is_open (A₀), from sorry,\n have h3 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h4 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h5 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h6 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h7 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h8 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h9 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h10 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h11 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h12 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h13 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h14 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h15 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h16 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h17 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h18 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h19 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h20 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h21 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h22 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h23 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h24 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h25 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h26 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h27 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h28 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h29 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h30 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h31 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h32 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h33 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h34 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h35 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h36 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h37 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h38 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h39 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h40 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h41 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h42 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h43 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h44 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h45 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h46 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h47 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h48 : ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, x ∈ (B_m), from sorry,\n have h49\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume (A : set (euclidean_space ℝ (fin n))) (hA : is_open A) (hA_cover : ⟪A⟫ = ⊤),\n \n let B0 : set (euclidean_space ℝ (fin n)) := ∅,\n let B : ℕ → set (euclidean_space ℝ (fin n)) := λ m, (ball (0 : ℝ ^ n) m),\n let Bbar : ℕ → set (euclidean_space ℝ (fin n)) := λ m, closure (B m),\n\n let Bbar_compact : ℕ → Prop := λ m, compact (Bbar m),\n let Bbar_compact_true : ∀ m : ℕ, Bbar_compact m := by {\n assume m : ℕ,\n have h1 : compact (Bbar m), from sorry,\n show Bbar_compact m, from h1,\n },\n\n let C : ℕ → set (euclidean_space ℝ (fin n)) := λ m, (B m) ∩ (⊤ \\ (Bbar (m-1))),\n let C_union : set (euclidean_space ℝ (fin n)) := ⋃ (m : ℕ), (C m),\n\n let C_union_cover : ⟪C_union⟫ = ⊤ := by {\n have h1 : ⟪C_union⟫ ⊆ ⊤, from by {\n assume x : (euclidean_space ℝ (fin n)),\n assume h1 : x ∈ ⟪C_union⟫,\n have h2 : ∃ m : ℕ, x ∈ (C m), from sorry,\n cases h2 with m h2,\n have h3 : x ∈ (⊤ \\ (Bbar (m-1))), from sorry,\n have h4 : x ∈ ⊤, from sorry,\n show x ∈ ⊤, from h4,\n },\n have h2 : ⊤ ⊆ ⟪C_union⟫, from by {\n assume x : (euclidean_space ℝ (fin n)),\n assume h2 : x ∈ ⊤,\n have h3 : ∃ m : ℕ, x ∈ (B m), from sorry,\n cases h3 with m h3,\n have h4 : x ∈ (B m), from h3,\n have h5 : x ∈ (⊤ \\ (Bbar (m-1))), from sorry,\n have h6 : x ∈ (C m), from sorry,\n have h7 : x ∈ ⟪C_union⟫, from sorry,\n show x ∈ ⟪C_union⟫, from h7,\n },\n show ⟪C_union⟫ = ⊤, from sorry,\n },\n\n let C_union_open : is_open C_union := by {\n have h1 : ∀ m : ℕ, is_open (C m), from by {\n assume m : ℕ,\n have h1 : is_open (B m), from sorry,\n have h2 : is_open (⊤ \\ (Bbar (m-1))), from sorry,\n have h3 : is_open ((B m) ∩ (⊤ \\ (Bbar (m-1)))), from sorry,\n show is_open (C m), from h3,\n },\n have h2 : ∀ m : ℕ, is_open (C m), from h1,\n show is_open C_union, from sorry,\n },\n\n let C_union_locally_finite : locally_finite_open C_union := by {\n assume x : (euclidean_space ℝ (fin n)),\n assume h1 : x ∈ C_union,\n have h2 : ∃ m : ℕ, x ∈ (C m), from sorry,\n cases h2 with m h2,\n have h3 : x ∈ (C m), from h2,\n have h4 : x ∈ (ball (0 : ℝ ^ n) m), from sorry,\n have h5 : x ∈ (⊤ \\ (Bbar (m-1))), from sorry,\n have h6 : x ∈ (Bbar m), from sorry,\n have h7 : x ∈ (closure (Bbar m)), from sorry,\n have h8 : x ∈ (⟪(closure (Bbar m))⟫), from sorry,\n have h9 : ⟪(closure (Bbar m))⟫ ⊆ ⟪(Bbar m)⟫, from sorry,\n have h10 : ⟪(Bbar m)⟫ ⊆ ⟪(B m)⟫, from sorry,\n have h11 : ⟪(closure (Bbar m))⟫ ⊆ ⟪(B m)⟫, from sorry,\n have h12 : ⟪(closure (Bbar m))⟫ ⊆ (B m), from sorry,\n have h13 : ⟪(closure (Bbar m))⟫ ⊆ ((B m) ∩ (⊤ \\ (Bbar (m-1)))), from sorry,\n have h14 : ⟪(closure (Bbar m))⟫ ⊆ (C m), from sorry,\n have h15 : ⟪(closure (Bbar m))⟫ ⊆ (⋃ (n : ℕ), (C n)), from sorry,\n have h16 : ∃ m : ℕ, ⟪(closure (Bbar m))⟫ ⊆ (C m), from sorry,\n have h17 : locally_finite_family (λ n : ℕ, ⟪(closure (Bbar n))⟫), from sorry,\n have h18 : locally_finite_open (⋃ (n : ℕ), ⟪(closure (Bbar n))⟫), from sorry,\n show locally_finite_open C_union, from h18,\n },\n\n show ∃ C_union : set (euclidean_space ℝ (fin n)),\n is_open C_union ∧ locally_finite_open C_union ∧ ⟪C_union⟫ = ⊤, \n from sorry,\nend\n\n--OUTPUT 7\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nbegin\n assume A,\n assume hA : open_cover (euclidean_space ℝ (fin n)) A,\n have h1 : ∀ n : ℕ, ∃ Bn : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bn, from sorry,\n have h2 : ∃ B0 : set (euclidean_space ℝ (fin 0)), ∀ x : euclidean_space ℝ (fin 0), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ B0, from sorry,\n have h3 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h4 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h5 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h6 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h7 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h8 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h9 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h10 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h11 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h12 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h13 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h14 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h15 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h16 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h17 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h18 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h19 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h20 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h21 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h22 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h23 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h24 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m : ℕ, ∀ k : ℕ, m ≤ k → x ∈ Bm, from sorry,\n have h25 : ∀ m : ℕ, ∃ Bm : set (euclidean_space ℝ (fin n)), ∀ x : euclidean_space ℝ (fin n), ∃ m :\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\n{ open_cover := sorry,\n locally_finite_refinement := sorry,\n locally_finite_refinement_is_open := sorry,\n locally_finite_refinement_covers := sorry,\n locally_finite_refinement_locally_finite := sorry,\n}\n\n/--`theorem`\n\\mathbb{R}^n is locally compact\n$\\mathbb{R}^n$ is locally compact for all $n$.\n`proof`\nLet $x \\in \\mathbb{R}^n$ and let $d = \\rVert x \\lVert$. Then $B_d(x)$ is compact by the Heine-Borel theorem. So $\\mathbb{R}^n$ is locally compact.\n\nQED\n-/\ntheorem ℝn_locally_compact (n : ℕ) : locally_compact_space (euclidean_space ℝ (fin n)) :=\n{ compact_nhds := sorry }\n\n/--`theorem`\n\\mathbb{R}^n is Hausdorff\n$\\mathbb{R}^n$ is Hausdorff for all $n$.\n`proof`\nLet $x, y \\in \\mathbb{R}^n$ with $x \\neq y$. If $x = 0$ or $y = 0$ the result is clear, so we assume $x \\neq 0 \\neq y$. Let $a = \\rVert x \\lVert$ and $b = \\rVert y \\lVert$. Then $x \\in B_a(0)$ and $y \\in B_b(0)$, and $\\bar{B_a(0)} \\cap \\bar{B_b(0)} = \\phi$. So $B_a(0)$ and $B_b(0)$ are disjoint open neighborhoods of $x$ and $y$ in $\\mathbb{R}^n$, so $\\mathbb{R}^n$ is Hausdorff.\n\nQED\n-/\ntheorem ℝn_hausdorff (n : ℕ) : hausdorff_space (euclidean_space ℝ (fin n)) :=\n{ disjoint_nhds := sorry }\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n have h1 : (A ⊆ S) ∧ (B ⊆ S), from sorry,\n have h2 : (A ∩ B) ⊆ A, from sorry,\n have h3 : (A ∩ B) ⊆ S, from sorry,\n show (A ∩ B) ∈ 𝒫 S, from sorry,\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n calc (x + y)^2 = (x+y)*(x+y) : by sorry\n ... = x*(x+y) + y*(x+y) : by sorry\n ... = x*x + x*y + y*x + y*y : by sorry\n ... = x^2 + 2*x*y + y^2 : by sorry,\nend\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n have h1 : ∀ a b : G, ∃! x : G, a * x = b, from sorry,\n have h2 : ∀ a b : G, ∃! y : G, y * a = b, from sorry,\n\n have h3 : ∀ a : G, ∃! x : G, a * x = a, from sorry,\n have h4 : ∀ a : G, ∃! y : G, y * a = a, from sorry,\n\n have h5 : ∀ a : G, classical.some (h3 a) = (1 : G), from sorry,\n have h6 : ∀ a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n use (1 : G),\n have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n assume (e : G) (h7 : ∀ a : G, e * a = a ∧ a * e = a),\n have h8 : ∀ a : G, e = classical.some (h3 a), from sorry,\n have h9 : ∀ a : G, e = classical.some (h4 a), from sorry,\n show e = (1 : G), from sorry, \n },\n sorry,\n }\nend\n\n/--`theorem`\n\\mathbb{R}^n is paracompact\n$\\mathbb{R}^n$ is paracompact for all $n$.\n`proof`\nLet $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$. We now construct a locally finite open refinement $\\mathcal{C}$ of $\\mathcal{A}$ that covers $\\mathbb{R}^n$. First, we define a collection of pen balls. Let $B_0 = \\phi$, and for each $n \\in \\mathbb{N}$, let $B_m$ denote the ball of radius $m$\ncentered at 0. Given $m$, set $\\Bar{B_m}$ is compact in $\\mathbb{R}^n$ by the Heine-Borel theorem, so choose finitely many elements of $\\mathcal{A}$ that cover $\\Bar{B_m}$ and intersect each one with the open set $\\mathbb{R}^n \\setminus \\Bar{B_{m - 1}}$, and let $\\mathcal{C}_{m}$ denote this collection of open sets (each an open subset of an element of $\\mathcal{A}$). So $\\mathcal{C} = \\bigcup_{m = 0}^{\\infty} \\mathcal{C}_m$ is an open refinement of $\\mathcal{A}$. Note that $\\mathcal{C}$ covers $\\mathbb{R}^n$ since for any $x \\in \\mathbb{R}^n$, there is a smallest $m \\in \\mathbb{N}$ such that $x \\in \\Bar{B_{m}}$ (namely, some $m$ where $\\rVert x \\lVert \\leq m \\leq \\rVert x \\lVert + 1$), and so $x$ is an element of $\\mathcal{C}_m$. Now collection $\\mathcal{C}$ is locally finite since for given $x \\in \\mathbb{R}^n$, neighborhood $B_m$ intersects only finitely many elements of $\\mathcal{C}$, namely those elements in collection $\\mathcal{C}_1 \\cup \\mathcal{C}_2 \\cup \\cdots \\mathcal{C}_m$. So $\\mathcal{C}$ is a locally finite open refinement of $\\mathcal{A}$ that covers $\\mathbb{R}^n$, hence $\\mathbb{R}^n$ is paracompact.\n\nQED\n-/\ntheorem ℝn_paracompact (n : ℕ) : paracompact_space (euclidean_space ℝ (fin n)) :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof_outline-Natural-Language-Proof-Translation/Correct_statement-lean_proof_outline-3_few_shot_temperature_0.6_max_tokens_2000_n_8/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.3106943704494217, "lm_q1q2_score": 0.20781733140201578}} {"text": "namespace Papyrus\n\n/--\n A valid (non-zero power of two) alignment.\n\n LLVM alignments are in terms of bytes (i.e. an alignment of 1 is byte-aligned).\n-/\nstructure Align where\n shiftVal : UInt8\n h : shiftVal < 64\n deriving Repr\n\n-- TODO: Add way to compute `Align` from a raw alignment.\nnamespace Align\n\ndef val (self : Align) : UInt64 :=\n (1 : UInt64) <<< self.shiftVal.toUInt64\n\npartial def ofValAux (i : UInt8) (n : UInt64) : UInt8 :=\n if n < 2 then i else ofValAux (i + 1) (n / 2)\n\ndef ofVal (n : UInt64) : Align :=\n mk (ofValAux 0 n % (64 : Nat)) <| Fin.modn_lt _ (Nat.zero_lt_succ _)\n\n-- ## OfNat Instances\n\nsection\nopen Lean\n\nlocal macro \"gen_ofNat_instances\" : command => do\n let mut instances := Array.mkEmpty 64\n for i in [0:64] do\n let shiftVal := quote i\n let val := quote <| 1 <<< i\n instances := instances.push <| ←\n `(instance : OfNat Align (nat_lit $val) := ⟨⟨$shiftVal, by decide⟩⟩)\n mkNullNode instances\n\ngen_ofNat_instances\nend\n\n/-- The default is byte-aligned. -/\ndef default : Align := 1\n\ninstance : Inhabited Align := ⟨Align.default⟩\n\n-- ## Propositional Relations\n\ntheorem eq_of_shiftVal_eq : {a b : Align} → a.shiftVal = b.shiftVal → a = b\n | ⟨v, h⟩, ⟨_, _⟩, rfl => rfl\n\ntheorem shiftVal_eq_of_eq {a b : Align} (h : a = b) : a.shiftVal = b.shiftVal :=\n h ▸ rfl\n\ntheorem ne_of_shiftVal_ne {a b : Align} (h : a.shiftVal ≠ b.shiftVal) : a ≠ b :=\n fun h' => absurd (shiftVal_eq_of_eq h') h\n\ninstance decEq : DecidableEq Align :=\n fun a b =>\n if h : a.shiftVal = b.shiftVal\n then isTrue (eq_of_shiftVal_eq h)\n else isFalse (ne_of_shiftVal_ne h)\n\ninstance : LT Align := ⟨fun a b => a.shiftVal < b.shiftVal⟩\ninstance : LE Align := ⟨fun a b => a.shiftVal <= b.shiftVal⟩\n\ninstance decLt (a b : Align) : Decidable (a < b) := UInt8.decLt ..\ninstance decLe (a b : Align) : Decidable (a <= b) := UInt8.decLe ..\n", "meta": {"author": "tydeu", "repo": "lean4-papyrus", "sha": "02e82973a5badda26fc0f9fd15b3d37e2eb309e0", "save_path": "github-repos/lean/tydeu-lean4-papyrus", "path": "github-repos/lean/tydeu-lean4-papyrus/lean4-papyrus-02e82973a5badda26fc0f9fd15b3d37e2eb309e0/Papyrus/IR/Align.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041652, "lm_q2_score": 0.40356685373537454, "lm_q1q2_score": 0.20651186016460832}} {"text": "-- Copyright (c) Microsoft Corporation. All rights reserved.\n-- Licensed under the MIT license.\n\nimport ..smtexpr\nimport ..smtcompile\nimport ..bitvector\nimport .spec\nimport .lemmas\nimport .irstate\nimport .freevar\nimport .equiv\nimport smt2.syntax\nimport system.io\nimport init.meta.tactic\nimport init.meta.interactive\n\nnamespace spec\n\nopen irsem\nopen freevar\n\nmeta def solve_left :=\n `[ unfold freevar.env.replace_sbv,\n split, refl]\n\nlemma foldr_and_replace: ∀ {α:Type} {f:α → poisonty_smt} p0 (l:list α) (η:freevar.env),\n η⟦list.foldr (λ itm (p:poisonty_smt), p & (f itm)) p0 l⟧ =\n list.foldr (λ itm (p:poisonty_smt), p & η⟦(f itm)⟧) (η⟦p0⟧) l\n:= begin\n intros,\n induction l,\n { simp },\n {\n simp,\n rw env.replace_sb_and,\n rw ← l_ih\n }\nend\n\nlemma bop_poison_replace: ∀ sz bopc (v1 v2:sbitvec sz) (η:freevar.env),\n η⟦bop_poison irsem_smt sz bopc v1 v2⟧ =\n bop_poison irsem_smt sz bopc (η⟦v1⟧) (η⟦v2⟧)\n:= begin\n intros,\n cases bopc,\n any_goals { unfold bop_poison,\n delta bop_poison._match_1, delta id_rhs,\n simp, rw env.replace_b2p, refl\n },\n any_goals { -- shl\n unfold bop_poison,\n delta bop_poison._match_1, delta id_rhs,\n simp, rw env.replace_b2p,\n try { unfold has_ult.ult, unfold has_comp.ult },\n try { unfold has_sgt.sgt, unfold has_comp.sgt },\n try { unfold has_ugt.ugt, unfold has_comp.ugt },\n unfold freevar.env.replace_sb,\n congr, unfold uint_like.from_z, rw env.replace_sbv_of_int\n }\nend\n\nlemma bop_poison_flag_replace: ∀ sz bopc (v1 v2:sbitvec sz) (η:freevar.env) flag,\n η⟦bop_poison_flag irsem_smt sz bopc flag v1 v2⟧ =\n bop_poison_flag irsem_smt sz bopc flag (η⟦v1⟧) (η⟦v2⟧)\n:= begin\n intros,\n cases flag,\n any_goals { -- nsw, nuw\n unfold bop_poison_flag,\n cases bopc; unfold bop_overflow_check; rw env.replace_sb_not;\n rw env.replace_b2p,\n { unfold has_overflow_check.add_chk,\n rw env.replace_sb_overflowchk_add },\n { unfold has_overflow_check.sub_chk,\n rw env.replace_sb_overflowchk_sub },\n any_goals {\n unfold has_overflow_check.mul_chk,\n rw env.replace_sb_overflowchk_mul },\n { unfold has_overflow_check.shl_chk,\n rw env.replace_sb_overflowchk_shl }\n },\n { -- exact\n have HZERO: η⟦uint_like.zero sz⟧ = uint_like.zero sz,\n { unfold uint_like.zero, unfold sbitvec.zero, rw env.replace_sbv_of_int },\n unfold bop_poison_flag,\n cases bopc; unfold bop_exact_check; rw env.replace_sb_not; simp,\n any_goals {\n unfold bop_exact_check._match_1,\n rw env.replace_eq2p\n },\n any_goals {\n unfold has_umod.umod, unfold uint_like.urem,\n rw env.replace_sbv_urem, rw HZERO\n },\n any_goals {\n unfold has_mod.mod, unfold uint_like.srem,\n rw env.replace_sbv_srem, rw HZERO\n },\n any_goals {\n unfold has_shl.shl, unfold uint_like.shl,\n rw env.replace_sbv_shl,\n try { unfold has_lshr.lshr, unfold uint_like.lshr,\n rw env.replace_sbv_lshr },\n try { unfold has_ashr.ashr, unfold uint_like.ashr,\n rw env.replace_sbv_ashr },\n unfold has_umod.umod, unfold uint_like.urem,\n rw env.replace_sbv_urem,\n congr; unfold uint_like.from_z; rw env.replace_sbv_of_int\n }\n }\nend\n\nlemma bop_replace: ∀ sz bopc flags η v1 p1 v2 p2 ubres vres pres\n (H:(ubres, vres, pres) = bop irsem_smt sz bopc flags v1 p1 v2 p2),\n bop irsem_smt sz bopc flags (η⟦v1⟧) (η⟦p1⟧) (η⟦v2⟧) (η⟦p2⟧) =\n (η⟦ubres⟧, η⟦vres⟧, η⟦pres⟧)\n:= begin\n intros,\n unfold bop at *,\n simp at *,\n injection H with HUB H,\n injection H with HV HPOISON,\n congr,\n {\n rw HUB,\n unfold bop_ub,\n cases bopc,\n any_goals { simp, refl, done }, -- non-divison ops\n any_goals { -- udiv, urem\n simp,\n rw env.replace_sb_and, rw env.replace_sb_and,\n rw env.replace_eq2p', refl,\n unfold uint_like.zero, unfold sbitvec.zero,\n rw env.replace_sbv_of_int\n },\n any_goals {\n simp,\n unfold_coes,\n unfold id,\n rw env.replace_sb_and, rw env.replace_sb_and,\n rw env.replace_sb_or, rw env.replace_sb_and,\n rw env.replace_eq2p',\n rw env.replace_eq2p',\n rw env.replace_eq2p',\n { unfold uint_like.allone, unfold sbitvec.uintmax, rw env.replace_sbv_of_int },\n { unfold uint_like.signonly, unfold sbitvec.intmin, rw env.replace_sbv_of_int },\n { unfold uint_like.zero, unfold sbitvec.zero, rw env.replace_sbv_of_int }\n }\n },\n {\n rw HV,\n cases bopc,\n { unfold bop_val,\n unfold has_add.add, unfold uint_like.add, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_sub.sub, unfold uint_like.sub, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_mul.mul, unfold uint_like.mul, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_udiv.udiv, unfold uint_like.udiv, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_umod.umod, unfold uint_like.urem, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_div.div, unfold uint_like.sdiv, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_mod.mod, unfold uint_like.srem, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_and.and, unfold uint_like.and, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_or.or, unfold uint_like.or, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_xor.xor, unfold uint_like.xor, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_shl.shl, unfold uint_like.shl, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_lshr.lshr, unfold uint_like.lshr, unfold freevar.env.replace_sbv },\n { unfold bop_val,\n unfold has_ashr.ashr, unfold uint_like.ashr, unfold freevar.env.replace_sbv }\n },\n {\n rw HPOISON,\n unfold bop_poison_all,\n rw env.replace_sb_and, rw env.replace_sb_and,\n have AND:∀ (p1 p2 q1 q2:poisonty_smt),\n p1&p2 = q1&q2 ↔ p1 = q1 ∧ p2 = q2,\n {\n intros,\n split,\n {\n unfold has_and.and, unfold bool_like.and,\n intros H,\n injection H, split; assumption\n },\n { intros H, cases H with H1 H2, rw [H1, H2] }\n },\n rw AND, rw AND,\n split,\n {\n rw foldr_and_replace,\n rw bop_poison_replace,\n apply list.foldr_eq; try { refl },\n { intros, rw AND, split, refl,\n rw bop_poison_flag_replace },\n },\n split ; refl\n }\nend\n\nlemma replace_to_ival: ∀ {sz:size} (v:intty_smt sz) (p:poisonty_smt) (η:freevar.env),\n η⟦to_ival irsem_smt (v, p)⟧ = to_ival irsem_smt (η⟦v⟧, η⟦p⟧)\n:= begin\n intros,\n unfold to_ival,\n unfold freevar.env.replace_valty\nend\n\nlemma step_bop_replace: ∀ (ss:irstate_smt) bopc flags\n (vop1 vop2: valty_smt)\n vop1' vop2' (η:freevar.env) lhsn\n (HVOP1:vop1' = η⟦vop1⟧)\n (HVOP2:vop2' = η⟦vop2⟧),\n step_bop irsem_smt vop1' vop2' bopc flags (η⟦ss⟧) lhsn =\n η⟦step_bop irsem_smt vop1 vop2 bopc flags ss lhsn⟧'\n:= begin\n intros,\n cases vop1 with sz1 v1 p1,\n cases vop2 with sz2 v2 p2,\n unfold freevar.env.replace_valty at *,\n rw [HVOP1, HVOP2],\n unfold step_bop,\n have HSZ: decidable(sz1 = sz2), apply_instance,\n cases HSZ,\n { -- sz1 ≠ sz2\n rw dif_neg, rw dif_neg, assumption, assumption },\n { -- sz1 = sz2\n rw dif_pos, rw dif_pos,\n have HTY: sbitvec sz2 = irsem_smt.intty sz1,\n { rw HSZ, refl },\n generalize HRES1: bop irsem_smt sz1 bopc flags\n (η⟦v1⟧) (η⟦p1⟧) (cast HTY (η⟦v2⟧)) (η⟦p2⟧) = res1,\n generalize HRES2: (bop irsem_smt sz1 bopc flags\n v1 p1 (cast HTY v2) p2) = res2,\n cases res1 with resub1 resvp1,\n cases resvp1 with resv1 resp1,\n cases res2 with resub2 resvp2,\n cases resvp2 with resv2 resp2,\n unfold step_bop._match_2,\n unfold apply,\n rw replace_updatereg,\n rw replace_updateub,\n rw ← env.replace_sbv_cast at HRES1,\n rw bop_replace at HRES1,\n injection HRES1,\n injection h_2 with h_2 h_3,\n congr,\n rw h_1, rw replace_to_ival, congr, rw h_2, rw h_3,\n rw HRES2, repeat { rw HSZ }\n }\nend\n\nlemma icmpop_replace: ∀ sz cond η v1 p1 v2 p2 vres pres\n (H:(vres, pres) = icmpop irsem_smt sz cond v1 p1 v2 p2),\n icmpop irsem_smt sz cond (η⟦v1⟧) (η⟦p1⟧) (η⟦v2⟧) (η⟦p2⟧) = (η⟦vres⟧, η⟦pres⟧)\n:= begin\n intros,\n cases cond,\n all_goals {\n unfold icmpop at *,\n simp at *,\n unfold icmpop._match_1 at *,\n injection H,\n rw h_1,\n rw h_2,\n rw env.replace_sb_and,\n unfold_coes,\n rw env.replace_sbv_of_bool,\n unfold_ops\n },\n { rw env.replace_sb_eqbv },\n { rw env.replace_sb_nebv },\n { rw env.replace_sb_ult },\n { rw env.replace_sb_ule },\n { rw env.replace_sb_ult },\n { rw env.replace_sb_ule },\n { rw env.replace_sb_slt },\n { rw env.replace_sb_sle },\n { rw env.replace_sb_slt },\n { rw env.replace_sb_sle }\nend\n\nlemma step_icmpop_replace: ∀ (ss:irstate_smt) cond\n (vop1 vop2: valty_smt)\n vop1' vop2' (η:freevar.env) lhsn\n (HVOP1:vop1' = η⟦vop1⟧)\n (HVOP2:vop2' = η⟦vop2⟧),\n step_icmpop irsem_smt vop1' vop2' cond (η⟦ss⟧) lhsn =\n η⟦step_icmpop irsem_smt vop1 vop2 cond ss lhsn⟧'\n:= begin\n intros,\n cases vop1 with sz1 v1 p1,\n cases vop2 with sz2 v2 p2,\n unfold freevar.env.replace_valty at *,\n rw [HVOP1, HVOP2],\n unfold step_icmpop,\n have HSZ: decidable(sz1 = sz2), apply_instance,\n cases HSZ,\n { -- sz1 ≠ sz2\n rw dif_neg, rw dif_neg, assumption, assumption },\n { -- sz1 = sz2\n rw dif_pos, rw dif_pos,\n have HTY: sbitvec sz2 = irsem_smt.intty sz1,\n { rw HSZ, refl },\n generalize HRES1: icmpop irsem_smt sz1 cond (η⟦v1⟧) (η⟦p1⟧)\n (cast HTY (η⟦v2⟧)) (η⟦p2⟧) = res1,\n generalize HRES2: (icmpop irsem_smt sz1 cond v1 p1\n (cast HTY v2) p2) = res2,\n cases res1 with resv1 resp1,\n cases res2 with resv2 resp2,\n unfold apply,\n rw replace_updatereg,\n rw ← env.replace_sbv_cast at HRES1,\n rw icmpop_replace at HRES1,\n injection HRES1,\n congr,\n rw replace_to_ival, rw h_1, rw h_2,\n rw HRES2, repeat { rw HSZ }\n }\nend\n\nlemma selectop_replace: ∀ sz η vcond pcond v1 p1 v2 p2 vres pres\n (H:(vres, pres) = selectop irsem_smt vcond pcond sz v1 p1 v2 p2),\n selectop irsem_smt (η⟦vcond⟧) (η⟦pcond⟧) sz (η⟦v1⟧) (η⟦p1⟧) (η⟦v2⟧) (η⟦p2⟧)\n = (η⟦vres⟧, η⟦pres⟧)\n:= begin\n intros,\n unfold selectop at *,\n simp at *,\n injection H,\n rw [h_1, h_2],\n unfold has_ite.ite,\n unfold has_eq.eq, unfold has_comp.eq,\n congr,\n {\n rw env.replace_sbv_ite,\n rw env.replace_sb_eqbv,\n congr\n },\n {\n rw env.replace_sb_and,\n rw env.replace_sb_ite,\n rw env.replace_sb_eqbv,\n congr\n }\nend\n\nlemma step_selectop_replace: ∀ (ss:irstate_smt)\n (vcond vop1 vop2: valty_smt)\n vcond' vop1' vop2' (η:freevar.env) lhsn\n (HVCOND:vcond' = η⟦vcond⟧)\n (HVOP1:vop1' = η⟦vop1⟧)\n (HVOP2:vop2' = η⟦vop2⟧),\n step_selectop irsem_smt vcond' vop1' vop2' (η⟦ss⟧) lhsn =\n η⟦step_selectop irsem_smt vcond vop1 vop2 ss lhsn⟧'\n:= begin\n intros,\n cases vcond with szcond vcond pcond,\n cases vop1 with sz1 v1 p1,\n cases vop2 with sz2 v2 p2,\n unfold freevar.env.replace_valty at *,\n rw [HVCOND, HVOP1, HVOP2],\n unfold step_selectop,\n have HSZ: decidable(szcond = size.one), apply_instance,\n cases HSZ,\n { -- szcond != size.one\n rw dif_neg, rw dif_neg, assumption, assumption\n },\n { -- szcond = size.one\n rw dif_pos, rw dif_pos HSZ,\n have HSZ2: decidable(sz1 = sz2), apply_instance,\n cases HSZ2,\n {\n rw dif_neg, rw dif_neg, assumption, assumption\n },\n {\n rw dif_pos, rw dif_pos,\n rw ← env.replace_sbv_cast,\n rw ← env.replace_sbv_cast,\n unfold apply,\n rw replace_updatereg,\n rw selectop_replace,\n { congr },\n { refl },\n any_goals { assumption },\n rw HSZ2\n }\n }\nend\n\nlemma castop_replace: ∀ fromsz code op1 op1p tosz η vres pres\n (H:(vres, pres) = castop irsem_smt fromsz code op1 op1p tosz),\n castop irsem_smt fromsz code (η⟦op1⟧) (η⟦op1p⟧) tosz\n = (η⟦vres⟧, η⟦pres⟧)\n:= begin\n intros,\n cases code,\n any_goals {\n unfold castop at *,\n have H1: decidable (fromsz.val < tosz.val), apply_instance,\n have H2: decidable (fromsz.val = tosz.val), apply_instance,\n cases H1,\n {\n rw if_neg at *, any_goals { assumption },\n cases H2,\n {\n rw if_neg at *, any_goals { assumption },\n injection H with h_1 h_2, rw h_1, rw h_2,\n congr,\n unfold uint_like.trunc, rw env.replace_sbv_trunc\n },\n {\n rw if_pos at *, any_goals { assumption },\n injection H with h_1 h_2, rw h_1, rw h_2,\n congr, unfold uint_like.zero, unfold sbitvec.zero,\n rw env.replace_sbv_of_int\n }\n },\n {\n rw if_pos at *, any_goals { assumption },\n injection H with h_1 h_2, rw h_1, rw h_2,\n try { unfold uint_like.sext, rw env.replace_sbv_sext },\n try { unfold uint_like.zext, rw env.replace_sbv_zext },\n }\n }\nend\n\nlemma step_unaryop_replace: ∀ (ss:irstate_smt)\n (vop:valty_smt) (code:uopcode) (toisz:nat) vop' (η:freevar.env) lhsn\n (HVOP:vop' = η⟦vop⟧),\n step_unaryop irsem_smt vop' code toisz (η⟦ss⟧) lhsn =\n η⟦step_unaryop irsem_smt vop code toisz ss lhsn⟧'\n:= begin\n intros,\n cases vop with sz v p,\n unfold freevar.env.replace_valty at *,\n rw HVOP,\n cases code,\n { unfold step_unaryop },\n all_goals { unfold step_unaryop,\n have HSZ: decidable (toisz > 0), apply_instance,\n cases HSZ,\n {\n rw dif_neg, rw dif_neg, assumption, assumption\n },\n {\n rw dif_pos, rw dif_pos,\n simp,\n unfold apply,\n rw replace_updatereg,\n rw castop_replace,\n { congr },\n { simp },\n { assumption }\n }\n }\nend\n\nlemma step_replace: ∀ (ss:irstate_smt) (i:instruction)\n (η:freevar.env),\n step irsem_smt (η⟦ss⟧) i = η⟦step irsem_smt ss i⟧'\n:= begin\n intros,\n cases i,\n case instruction.binop : retty lhs bopc flags op1 op2 {\n cases lhs,\n\n unfold step,\n unfold has_bind.bind,\n rw get_value_replace,\n generalize HOP1: η⟦get_value irsem_smt ss op1 retty⟧' = vop1,\n generalize HOP2: η⟦get_value irsem_smt ss op2 retty⟧' = vop2,\n simp at HOP1,\n cases vop1,\n { -- none\n rw apply_none at HOP1, rw HOP1, unfold option.bind\n },\n {\n have HOP1' := apply_some HOP1,\n cases HOP1' with vop1' HOP1',\n rw HOP1',\n rw get_value_replace,\n simp at HOP2,\n cases vop2,\n { -- none\n rw apply_none at HOP2, rw HOP2,\n unfold option.bind,\n },\n {\n have HOP2' := apply_some HOP2,\n cases HOP2' with vop2' HOP2',\n rw HOP2',\n unfold option.bind,\n rw step_bop_replace,\n {\n rw HOP1' at HOP1, unfold apply at HOP1, injection HOP1, rw h_1\n },\n { rw HOP2' at HOP2 }\n }\n }\n },\n case instruction.icmpop : opty lhs cond op1 op2 {\n cases lhs,\n \n unfold step,\n unfold has_bind.bind,\n rw get_value_replace,\n generalize HOP1: η⟦get_value irsem_smt ss op1 opty⟧' = vop1,\n generalize HOP2: η⟦get_value irsem_smt ss op2 opty⟧' = vop2,\n simp at HOP1,\n cases vop1,\n { -- none\n rw apply_none at HOP1, rw HOP1, unfold option.bind\n },\n {\n have HOP1' := apply_some HOP1,\n cases HOP1' with vop1' HOP1',\n rw HOP1',\n rw get_value_replace,\n simp at HOP2,\n cases vop2,\n { -- none\n rw apply_none at HOP2, rw HOP2,\n unfold option.bind,\n },\n {\n have HOP2' := apply_some HOP2,\n cases HOP2' with vop2' HOP2',\n rw HOP2',\n unfold option.bind,\n rw step_icmpop_replace,\n {\n rw HOP1' at HOP1, unfold apply at HOP1, injection HOP1, rw h_1\n },\n { rw HOP2' at HOP2 }\n }\n }\n },\n case instruction.selectop : lhs condty cond opty op1 op2 {\n cases lhs,\n \n unfold step,\n unfold has_bind.bind,\n rw get_value_replace,\n\n generalize HOPCOND: η⟦get_value irsem_smt ss cond condty⟧' = vopcond,\n generalize HOP1: η⟦get_value irsem_smt ss op1 opty⟧' = vop1,\n generalize HOP2: η⟦get_value irsem_smt ss op2 opty⟧' = vop2,\n simp at *,\n cases vopcond,\n { rw apply_none at HOPCOND, rw HOPCOND, unfold option.bind },\n {\n have HOPCOND' := apply_some HOPCOND,\n cases HOPCOND' with vopcond' HOPCOND',\n rw HOPCOND',\n unfold option.bind,\n rw get_value_replace,\n \n cases vop1,\n { rw apply_none at HOP1, rw HOP1, unfold option.bind },\n {\n have HOP1' := apply_some HOP1,\n cases HOP1' with vop1' HOP1',\n rw HOP1',\n rw get_value_replace,\n unfold option.bind,\n\n cases vop2,\n { rw apply_none at HOP2, rw HOP2, unfold option.bind },\n {\n have HOP2' := apply_some HOP2,\n cases HOP2' with vop2' HOP2',\n rw HOP2',\n unfold option.bind,\n rw step_selectop_replace,\n { rw HOPCOND' at HOPCOND, unfold apply at HOPCOND, injection HOPCOND,\n rw h_1 },\n { rw HOP1' at HOP1 },\n { rw HOP2' at HOP2 }\n }\n }\n }\n },\n case instruction.unaryop : lhs ucode fromty op toty {\n cases lhs,\n cases toty,\n {\n unfold step,\n unfold has_bind.bind,\n rw get_value_replace,\n\n generalize HOP: η⟦get_value irsem_smt ss op fromty⟧' = vop,\n simp at *,\n cases vop,\n { unfold option.bind, rw apply_none at HOP, rw HOP, refl },\n {\n have HOP' := apply_some HOP,\n cases HOP' with vop' HOP',\n rw HOP',\n unfold option.bind,\n rw step_unaryop_replace,\n { rw HOP' at HOP, unfold apply at HOP, injection HOP, rw h_1 }\n }\n },\n {\n unfold step\n }\n }\nend\n\ntheorem step_encode_both: ∀ ss se i oss ose η\n (HENC:encode ss se η)\n (HOSS': oss = step irsem_smt ss i)\n (HOSE': ose = step irsem_exec se i),\n none_or_some oss ose (λ ss' se', encode ss' se' η)\n:= begin\n intros,\n have HSTEP : none_or_some (step irsem_smt (η⟦ss⟧) i)\n (step irsem_exec se i) (λ ss' se', irstate_equiv ss' se'),\n {\n apply step_both_prf,\n apply HENC,\n refl, refl\n },\n have HOSS'': η⟦oss⟧' = step irsem_smt (η⟦ss⟧) i, {\n rw step_replace,\n rw HOSS'\n },\n simp at HOSS'',\n rw ← HOSS'' at *,\n rw ← HOSE' at *,\n unfold encode at *,\n cases oss,\n {\n unfold none_or_some at *,\n cases HSTEP,\n { rw apply_none at HSTEP, left, assumption },\n { cases HSTEP with _ HSTEP,\n cases HSTEP with _ HSTEP,\n cases HSTEP with HSTEP _,\n unfold apply at HSTEP,\n cases HSTEP\n }\n },\n {\n unfold none_or_some at *,\n cases HSTEP,\n {\n left, cases HSTEP with HSTEP _,\n cases HSTEP\n },\n {\n unfold apply at HSTEP,\n cases HSTEP with s HSTEP,\n cases HSTEP with e HSTEP,\n cases HSTEP with HSTEP_l HSTEP,\n cases HSTEP with HSTEP_r HSTEP_r2,\n injection HSTEP_l,\n rw ← h_1 at HSTEP_r2,\n right,\n apply exists.intro oss,\n apply exists.intro e,\n split, refl,\n split, assumption,\n assumption\n }\n }\nend\n\n\ntheorem bigstep_both_prf: bigstep_both\n:= begin\n unfold bigstep_both,\n intros,\n revert ss se oss' ose',\n cases p,\n induction p with i p',\n { -- empty instruction\n intros,\n unfold irsem.bigstep at HOSS' HOSE',\n simp at HOSS' HOSE',\n right,\n apply exists.intro ss,\n apply exists.intro se,\n split, assumption, split, assumption, assumption\n },\n { -- a new instruction at the front\n intros,\n generalize HSS:irsem.step irsem_smt ss i = oss0,\n generalize HSE:irsem.step irsem_exec se i = ose0,\n have HENC0 : none_or_some oss0 ose0 (λ ss0 se0, encode ss0 se0 η),\n {\n apply step_encode_both,\n apply HENC, rw HSS, rw HSE\n },\n cases oss0,\n { -- none, none\n have H: ose0 = none, {\n apply none_or_some_none,\n apply HENC0, refl\n },\n rw H at *,\n rw bigstep_unroll_none_smt at HOSS',\n rw bigstep_unroll_none_exec at HOSE',\n rw HOSS', rw HOSE',\n apply none_or_some_none2; refl,\n rw HSE, rw HSS\n },\n { -- some, some\n have H: (∃ se0', ose0 = some se0'), {\n apply none_or_some_some,\n apply HENC0, refl\n },\n cases H with se0' H,\n rw H at *,\n unfold none_or_some at HENC0,\n cases HENC0,\n {\n cases HENC0, cases HENC0_left\n },\n {\n cases HENC0 with s HENC0,\n cases HENC0 with e HENC0,\n cases HENC0 with _ HENC0,\n cases HENC0 with _ HENC0,\n apply p_ih,\n apply HENC0,\n rw ← bigstep_unroll_some_smt, apply HOSS', rw HSS, rw HENC0_left,\n rw ← bigstep_unroll_some_exec, apply HOSE', rw HSE, rw HENC0_left_1\n }\n }\n }\nend\n\nlemma bigstep_replace: ∀ ss p (η:freevar.env),\n η⟦bigstep irsem_smt ss p⟧' = bigstep irsem_smt (η⟦ss⟧) p\n:= begin\n intros,\n simp,\n cases p,\n revert ss,\n induction p with i p,\n {\n intros,\n refl\n },\n {\n intros,\n generalize HSS: step irsem_smt ss i = ss',\n generalize HRSS: step irsem_smt (η⟦ss⟧) i = rss',\n cases ss'; cases rss',\n {\n rw bigstep_unroll_none_smt,\n rw bigstep_unroll_none_smt,\n rw HRSS, rw HSS\n },\n any_goals {\n rw step_replace at HRSS,\n rw HSS at HRSS, cases HRSS, done\n },\n {\n rw bigstep_unroll_some_smt,\n rw bigstep_unroll_some_smt,\n apply p_ih,\n have HTMP: η⟦step irsem_smt ss i⟧' = η⟦some ss'⟧',\n {\n rw HSS\n },\n rw ← step_replace at HTMP, rw HRSS at HTMP,\n unfold apply at HTMP, injection HTMP,\n rw h_1 at HRSS,\n apply (eq.symm HRSS),\n rw HSS\n }\n }\nend\n\nend spec", "meta": {"author": "microsoft", "repo": "AliveInLean", "sha": "34370c2c15aa69f010d97b8d38e9e1955e9e387d", "save_path": "github-repos/lean/microsoft-AliveInLean", "path": "github-repos/lean/microsoft-AliveInLean/AliveInLean-34370c2c15aa69f010d97b8d38e9e1955e9e387d/src/spec/openprog.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.3849121444839335, "lm_q1q2_score": 0.20596588367265212}} {"text": "import tactic\nimport category_theory.functor\nimport data.W.basic\nimport category_theory.closed.types\nimport algebra.category.CommRing.basic\nimport algebra.category.Module.basic\n\nuniverses w x u v \n\nopen category_theory\n\nvariables (𝒞 : Type u) [category.{v} 𝒞]\n\n@[protect_proj] structure struc : Type (max u v (w+1) (x+1)) :=\n( F : 𝒞 → Type w )\n( F_iso : Π {A B : 𝒞}, (A ≅ B) → F A ≃ F B )\n( F_iso_refl : Π {A : 𝒞}, F_iso (iso.refl A) = equiv.refl (F A) )\n( F_iso_trans : Π {A B C : 𝒞} (e₁ : A ≅ B) (e₂ : B ≅ C), \n equiv.trans (F_iso e₁) (F_iso e₂) = F_iso (iso.trans e₁ e₂) )\n( hom : Π {A B : 𝒞} (f : A ⟶ B) (a : F A) (b : F B), Type x )\n( hom_iso : Π {A₁ A₂ B₁ B₂ : 𝒞} \n (f₁ : A₁ ⟶ B₁) (a₁ : F A₁) (b₁ : F B₁)\n (f₂ : A₂ ⟶ B₂) (a₂ : F A₂) (b₂ : F B₂)\n (eA : A₁ ≅ A₂) (eB : B₁ ≅ B₂)\n (hf : f₁ ≫ eB.hom = eA.hom ≫ f₂)\n (ha : a₂ = F_iso eA a₁)\n (hb : b₂ = F_iso eB b₁),\n hom f₁ a₁ b₁ ≃ hom f₂ a₂ b₂ )\n( hom_iso_refl : Π {A B : 𝒞} \n (f : A ⟶ B) (a : F A) (b : F B)\n (hf : f ≫ (iso.refl B).hom = (iso.refl A).hom ≫ f)\n (ha : a = F_iso (iso.refl A) a)\n (hb : b = F_iso (iso.refl B) b),\n hom_iso f a b f a b (iso.refl A) (iso.refl B) hf ha hb = equiv.refl (hom f a b) )\n( hom_iso_trans : Π {A₁ A₂ A₃ B₁ B₂ B₃ : 𝒞}\n (f₁ : A₁ ⟶ B₁) (a₁ : F A₁) (b₁ : F B₁)\n (f₂ : A₂ ⟶ B₂) (a₂ : F A₂) (b₂ : F B₂)\n (f₃ : A₃ ⟶ B₃) (a₃ : F A₃) (b₃ : F B₃) \n (eA₁₂ : A₁ ≅ A₂) (eB₁₂ : B₁ ≅ B₂)\n (eA₂₃ : A₂ ≅ A₃) (eB₂₃ : B₂ ≅ B₃)\n (hf₁₂ : f₁ ≫ eB₁₂.hom = eA₁₂.hom ≫ f₂)\n (hf₂₃ : f₂ ≫ eB₂₃.hom = eA₂₃.hom ≫ f₃)\n (ha₁₂ : a₂ = F_iso eA₁₂ a₁)\n (ha₂₃ : a₃ = F_iso eA₂₃ a₂)\n (hb₁₂ : b₂ = F_iso eB₁₂ b₁)\n (hb₂₃ : b₃ = F_iso eB₂₃ b₂),\n (hom_iso f₁ a₁ b₁ f₂ a₂ b₂ eA₁₂ eB₁₂ hf₁₂ ha₁₂ hb₁₂).trans\n (hom_iso f₂ a₂ b₂ f₃ a₃ b₃ eA₂₃ eB₂₃ hf₂₃ ha₂₃ hb₂₃) =\n hom_iso f₁ a₁ b₁ f₃ a₃ b₃ (eA₁₂.trans eA₂₃) (eB₁₂.trans eB₂₃) \n (by simp [← hf₁₂, ← hf₂₃, category.assoc]) \n (by simp [ha₂₃, ha₁₂, ← F_iso_trans]) \n (by simp [hb₂₃, hb₁₂, ← F_iso_trans]) )\n( id : Π {A : 𝒞} (a : F A), hom (𝟙 A) a a )\n( hom_iso_id : Π {A₁ A₂ : 𝒞}\n (a₁ : F A₁) (a₂ : F A₂)\n (eA : A₁ ≅ A₂)\n (hf : 𝟙 A₁ ≫ eA.hom = eA.hom ≫ 𝟙 A₂)\n (ha : a₂ = F_iso eA a₁),\n hom_iso (𝟙 A₁) a₁ a₁ (𝟙 A₂) a₂ a₂ eA eA hf ha ha (id a₁) = id a₂ )\n( comp : Π {A B C : 𝒞} {a : F A} {b : F B} {c : F C}\n {f : A ⟶ B} {g : B ⟶ C} (f' : hom f a b) (g' : hom g b c), \n hom (f ≫ g) a c )\n( hom_iso_comp : Π {A₁ A₂ B₁ B₂ C₁ C₂}\n (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (a₁ : F A₁) (b₁ : F B₁) (c₁ : F C₁)\n (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (a₂ : F A₂) (b₂ : F B₂) (c₂ : F C₂)\n (eA : A₁ ≅ A₂) (eB : B₁ ≅ B₂) (eC : C₁ ≅ C₂)\n (hf : f₁ ≫ eB.hom = eA.hom ≫ f₂)\n (hg : g₁ ≫ eC.hom = eB.hom ≫ g₂)\n (hfg : (f₁ ≫ g₁) ≫ eC.hom = eA.hom ≫ (f₂ ≫ g₂))\n (ha : a₂ = F_iso eA a₁)\n (hb : b₂ = F_iso eB b₁)\n (hc : c₂ = F_iso eC c₁)\n (f₁' : hom f₁ a₁ b₁)\n (g₁' : hom g₁ b₁ c₁),\n hom_iso (f₁ ≫ g₁) a₁ c₁ (f₂ ≫ g₂) a₂ c₂ eA eC hfg\n ha hc (comp f₁' g₁') = \n comp (hom_iso f₁ a₁ b₁ f₂ a₂ b₂ eA eB hf ha hb f₁') \n (hom_iso g₁ b₁ c₁ g₂ b₂ c₂ eB eC hg hb hc g₁') )\n( id_comp : Π {A B : 𝒞} {f : A ⟶ B} {a : F A} {b : F B}\n (f' : hom f a b), comp (id a) f' = hom_iso f a b (𝟙 A ≫ f) a b (iso.refl A) (iso.refl B) \n (by simp) (by rw F_iso_refl; refl) (by rw F_iso_refl; refl) f' )\n( comp_id : Π {A B : 𝒞} {f : A ⟶ B} {a : F A} {b : F B}\n (f' : hom f a b), comp f' (id b) = hom_iso f a b (f ≫ 𝟙 B) a b (iso.refl A) (iso.refl B) \n (by simp) (by rw F_iso_refl; refl) (by rw F_iso_refl; refl) f' )\n( assoc : Π {A B C D : 𝒞} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D}\n {a : F A} {b : F B} {c : F C} {d : F D}\n (f' : hom f a b) (g' : hom g b c) (h' : hom h c d),\n comp (comp f' g') h' = hom_iso (f ≫ (g ≫ h)) a d ((f ≫ g) ≫ h) a d \n (iso.refl A) (iso.refl D) (by simp) (by rw F_iso_refl; refl) (by rw F_iso_refl; refl)\n (comp f' (comp g' h')) )\n\nnamespace struc\n\ninstance : has_coe_to_fun (struc 𝒞) (λ _, 𝒞 → Type w) :=\n{ coe := struc.F }\n\nvariables {𝒞}\n\n-- @[protect_proj] class GS (F : 𝒞 → Type w) :=\n-- ( hom : Π {A B : 𝒞} (f : A ⟶ B) (a : F A) (b : F B), Type x )\n-- ( id : Π {A : 𝒞} (a b : F A) (h : a = b) (f : A ⟶ A) (hf : f = 𝟙 A), hom f a b )\n\nattribute [simp] struc.id_comp struc.comp_id struc.hom_iso_refl struc.F_iso_refl struc.F_iso_trans\n struc.hom_iso_trans\n\nvariables (F : struc 𝒞) \n\n-- lemma assoc_left {A B C D : 𝒞} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D}\n-- {a : F A} {b : F B} {c : F C} {d : F D}\n-- (f' : F.hom f a b) (g' : F.hom g b c) (h' : F.hom h c d)\n-- (i : A ⟶ C) (k : A ⟶ D)\n-- (hi : f ≫ g = i) (hk : i ≫ h = k) :\n-- F.comp (F.comp f' g' hi) h' hk = F.comp f'\n-- (F.comp g' h' rfl) (by rw [← hk, ← hi, category.assoc]) :=\n-- begin\n-- substs i k,\n-- rw struc.assoc,\n-- end\n\n-- lemma comp_eq_cast {A B C : 𝒞} {f : A ⟶ B} {g : B ⟶ C} \n-- {a : F A} {b : F B} {c : F C} (f' : F.hom f a b) (g' : F.hom g b c)\n-- (i : A ⟶ C) (hi : f ≫ g = i)\n-- (j : A ⟶ C) (hj : f ≫ g = j) :\n-- F.comp f' g' hi = cast (by substs i j) (F.comp f' g' hj) :=\n-- begin\n-- substs i j, refl\n-- end\n\n-- lemma assoc_left' {A B C D : 𝒞} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D}\n-- {a : F A} {b : F B} {c : F C} {d : F D}\n-- (f' : F.hom f a b) (g' : F.hom g b c) (h' : F.hom h c d)\n-- (i : A ⟶ C) (k : A ⟶ D)\n-- (hi : f ≫ g = i) (hk : i ≫ h = k) :\n-- F.comp (F.comp f' g' hi) h' hk = cast (by rw [← hk, ← hi, category.assoc]) \n-- (F.comp f' (F.comp g' h' rfl) rfl) :=\n-- begin\n-- rw struc.assoc_left,\n-- substs i k,\n-- rw [comp_eq_cast]\n-- end\n\n-- lemma id_comp' {A B : 𝒞} {f : A ⟶ B} (g : A ⟶ B) {a : F A} {b : F B}\n-- (h : 𝟙 A ≫ f = g) (f' : F.hom f a b) : \n-- F.comp (F.id a) f' h = cast (by rw [← h, category.id_comp]) f' :=\n-- begin\n-- rw [category.id_comp] at h,\n-- subst h,\n-- simp\n-- end\n\n-- lemma comp_id' {A B : 𝒞} {f : A ⟶ B} (g : A ⟶ B) {a : F A} {b : F B}\n-- (h : f ≫ 𝟙 B = g) (f' : F.hom f a b) : \n-- F.comp f' (F.id b) h = cast (by rw [← h, category.comp_id]) f' :=\n-- begin\n-- rw [category.comp_id] at h,\n-- subst h,\n-- simp\n-- end \n\ndef sigma₂ (F : struc 𝒞) : Type* := sigma F\n\ninstance : category_struct (sigma₂ F) :=\n{ hom := λ A B, Σ (f : A.1 ⟶ B.1), F.hom f A.2 B.2,\n id := λ A, ⟨𝟙 A.1, F.id A.2⟩,\n comp := λ A B C f g, ⟨f.1 ≫ g.1, F.comp f.2 g.2⟩ }\n\nvariable {F}\n\nlemma sigma₂.hom_ext {A B : sigma₂ F} {f g : A ⟶ B} \n (h₁ : f.1 = g.1) (h₂ : F.hom_iso f.1 A.2 B.2 g.1 A.2 B.2 \n (iso.refl A.1) (iso.refl B.1) (by simp *) (by simp *) (by simp *) f.2 = g.2) :\n f = g :=\nbegin\n cases A,\n cases B,\n cases f,\n cases g,\n dsimp at *,\n subst h₁,\n simp at h₂,\n subst h₂\nend\n\ndef sigma_category : category_struct (sigma F) :=\n{ hom := λ A B, Σ (f : A.1 ⟶ B.1), F.hom f A.2 B.2,\n id := λ A, ⟨𝟙 A.1, F.id A.2⟩,\n comp := λ A B C f g, ⟨f.1 ≫ g.1, F.comp f.2 g.2⟩ }\n\n@[simp] lemma comp_fst {A B C : sigma₂ F} (f : A ⟶ B) (g : B ⟶ C) :\n (f ≫ g).fst = f.1 ≫ g.1 := rfl\n\n@[simp] lemma comp_snd {A B C : sigma₂ F} (f : A ⟶ B) (g : B ⟶ C) :\n (f ≫ g).snd = F.comp f.2 g.2 := rfl\n\n@[simp] lemma id_fst {A : sigma₂ F} : sigma.fst (𝟙 A) = 𝟙 A.1 := rfl\n\n@[simp] lemma id_snd {A : sigma₂ F} : sigma.snd (𝟙 A) = F.id A.2 := rfl\n\nsection\n\nlocal attribute [instance] sigma_category\n\ninstance sigma.category : category (sigma₂ F) :=\n{ id_comp' := λ A B f, begin\n refine sigma₂.hom_ext _ _,\n { simp },\n { simp,\n rw [← equiv.trans_apply], \n erw F.hom_iso_trans,\n simp }\n end,\n comp_id' := λ A B f, begin\n refine sigma₂.hom_ext _ _,\n { simp },\n { simp,\n rw [← equiv.trans_apply], \n erw F.hom_iso_trans,\n simp }\n end,\n assoc' := λ A B C D f g h, begin\n refine sigma₂.hom_ext _ _,\n { simp [category.assoc] },\n { simp [struc.assoc],\n rw ← equiv.trans_apply,\n erw F.hom_iso_trans,\n simp,\n erw [F.hom_iso_refl], \n refl }\n end, }\n\nend\n\ninstance (X : 𝒞) : category_struct (F X) :=\n{ hom := λ A B, F.hom (𝟙 X) A B,\n id := λ A, F.id A,\n comp := λ A B C f g, F.hom_iso (𝟙 X ≫ 𝟙 X) A C (𝟙 X) A C (iso.refl X) (iso.refl X) \n (by simp) (by simp) (by simp) (F.comp f g) }\n\nlemma id_def {X : 𝒞} (x : F X) : 𝟙 x = F.id x := rfl \n\nlemma comp_def (X : 𝒞) (A B C : F X) (f : A ⟶ B) (g : B ⟶ C) :\n f ≫ g = F.hom_iso (𝟙 X ≫ 𝟙 X) A C (𝟙 X) A C (iso.refl X) (iso.refl X) \n (by simp) (by simp) (by simp) (F.comp f g) := rfl\n\ninstance (X : 𝒞) : category (F X) :=\n{ id_comp' := λ A B f, begin \n simp [id_def, comp_def],\n rw [← equiv.trans_apply, F.hom_iso_trans],\n simp\n end,\n comp_id' := λ A B f, begin \n simp [id_def, comp_def],\n rw [← equiv.trans_apply, F.hom_iso_trans],\n simp\n end,\n assoc' := λ A B C D f g h,\n begin\n simp only [comp_def, ← F.hom_iso_comp],\n erw F.hom_iso_comp,\n end }\n\ndef forget : sigma₂ F ⥤ 𝒞 :=\n{ obj := sigma.fst,\n map := λ _ _, sigma.fst }\n\ndef thing (X : 𝒞) : F X ⥤ sigma₂ F :=\n{ obj := λ A, ⟨X, A⟩,\n map := λ A B f, ⟨𝟙 X, f⟩,\n map_id' := λ A, rfl,\n map_comp' := λ A B C f g, sigma.ext \n (by simp) begin \n simp only [comp_snd],\n rw [struc.comp_eq_cast F f g (𝟙 X ≫ 𝟙 X) rfl (𝟙 X)\n (category.comp_id _)],\n symmetry,\n rw [← cast_eq_iff_heq],\n simp, refl,\n simp,\n end }\n\nopen opposite\n\nprotected def op (F : struc 𝒞) : struc 𝒞ᵒᵖ :=\n{ F := λ A, F.F (unop A),\n hom := λ A B f a b, F.hom f.unop b a,\n id := λ A a, F.id a,\n comp := λ A B C a b c f g f' g' h hH, \n F.comp g' f' (by simp [← hH]),\n id_comp := λ A B f a b f', F.comp_id _,\n comp_id := λ A B f a b f', F.id_comp _,\n assoc := λ A B C D f g h a b c d f' g' h', \n by rw F.assoc_left; refl }\n\ndef unop (F : struc 𝒞ᵒᵖ) : struc 𝒞 :=\n{ F := λ A, F.F (op A),\n hom := λ A B f a b, F.hom f.op b a,\n id := λ A a, F.id a,\n comp := λ A B C a b c f g f' g' h hH, \n F.comp g' f' (by simp [← hH]),\n id_comp := λ A B f a b f', F.comp_id _,\n comp_id := λ A B f a b f', F.id_comp _,\n assoc := λ A B C D f g h a b c d f' g' h', \n by rw F.assoc_left; refl }\n\ndef of_functor (F : 𝒞 ⥤ Type w) : struc 𝒞 :=\n{ F := F.obj,\n hom := λ A B f a b, plift (F.map f a = b),\n id := λ A a, ⟨by simp⟩,\n comp := λ A B C a b c f g h₁ h₂ _ h, ⟨by simp [← h, F.map_comp, h₁.down, h₂.down]⟩,\n assoc := λ _ _ _ _ _ _ _ _ _ _ _ h₁ h₂ h₃, \n begin simp [h₁.down, h₂.down, h₃.down] end,\n id_comp := λ _ _ _ _ _ h, \n begin simp [h.down] end,\n comp_id := λ _ _ _ _ _ h, \n begin simp [h.down] end }\n\ndef Module₂ : struc Ring :=\n{ F := λ R, Module R,\n hom := λ R S f M₁ M₂, M₁ →ₛₗ[f] M₂,\n id := λ R M, linear_map.id,\n comp := λ R S T M₁ M₂ M₃ f g f' g' _ h, \n @linear_map.comp _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ⟨h⟩ g' f',\n id_comp := λ R S f M₁ M₂ f', begin\n cases f', cases f, refl\n end,\n comp_id := λ R S f M₁ M₂ f', begin\n cases f', cases f, refl,\n end,\n assoc := λ R S T U f g h M₁ M₂ M₃ M₄ f' g' h', \n begin\n cases f, cases g, cases h, cases f', cases g', cases h',\n refl\n end }\n\ndef pi.struc (F : 𝒞 ⥤ Type) (G : struc (sigma₂ (of_functor F))) : struc 𝒞 :=\n{ F := λ X, Π a : F.obj X, G.F ⟨X, a⟩,\n hom := λ X Y f x y, Π (a : F.obj X), \n @struc.hom _ _ G ⟨X, a⟩ ⟨Y, F.map f a⟩ ⟨f, ⟨rfl⟩⟩ (x a) (y (F.map f a)),\n id := λ X x a, by convert (G.id (x a)); simp,\n comp := λ X Y Z x y z f g f' g' h H a, \n by convert struc.comp G (f' a) (g' (F.map f a)) rfl; subst H; simp,\n id_comp := λ X a, begin\n intros,\n ext,\n simp,\n \n end }\n\n-- Maybe think about W.\n\nend struc", "meta": {"author": "ChrisHughes24", "repo": "coq-and-lean-playground", "sha": "7da672891e29c0434909abad315ca6efefcbb989", "save_path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground", "path": "github-repos/lean/ChrisHughes24-coq-and-lean-playground/coq-and-lean-playground-7da672891e29c0434909abad315ca6efefcbb989/lean/parametricity/sigma_category/struc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.4073334000459302, "lm_q1q2_score": 0.20525781374573468}} {"text": "import model_theory.substructures\nimport model_theory.bundled\n\n\n--OUTPUT 1\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n let Γ := F.fold \n ((λ (x : first_order.prop L) (y : L.Theory), y.union {x.to_true_logic_formula}) ∘ \n (λ (x : first_order.predicate L) (y : L.Theory), y.union\n (λ (n : ℕ), {∃ (a1 : F.Model.σ), ∃ (a2 : F.Model.σ), ∃ (a3 : F.Model.σ), ∃ (L : F.Model.σ → F.Model.σ), ∃ (R : F.Model.σ → F.Model.σ),\n (∃* (a1 a2) (x.relation_symbol 2)) ∧ ¬ ((∃*)* (a1 a3) (x.relation_symbol 2)) ∧ ¬ ((∃*)* (a2 a3) (x.relation_symbol 2)) ∧\n ((∀* (b : F.Model.σ), (L b =* a1 ∧ R b =* a2) ∨ (L b =* a2 ∧ R b =* a3) ∨ (L b =* a1 ∧ R b =* a3))) ∧\n ((∀* (b : F.Model.σ), ¬ ((∃*)* (L b) (x.relation_symbol 1))) ∧ (∀* (b : F.Model.σ), ¬ ((∃*)* (R b) (x.relation_symbol 1))) ∧\n ((∀* (b : F.Model.σ), (L b =* b) ∨ (R b =* b)) ∨ (∀* (b : F.Model.σ), ¬ ((∃*)* (b) (x.relation_symbol 1)))))} n))) F,\n have h1 : ∀ n : ℕ, ∃ (M : F.Model) [mfin : fintype M], M ⊧ Γ n, from by {\n assume n : ℕ,\n let A := (λ (n : ℕ), {∃ (a1 : F.Model.σ), ∃ (a2 : F.Model.σ), ∃ (a3 : F.Model.σ), ∃ (L : F.Model.σ → F.Model.σ), ∃ (R : F.Model.σ → F.Model.σ),\n (∃* (a1 a2) (x.relation_symbol 2)) ∧ ¬ ((∃*)* (a1 a3) (x.relation_symbol 2)) ∧ ¬ ((∃*)* (a2 a3) (x.relation_symbol 2)) ∧\n ((∀* (b : F.Model.σ), (L b =* a1 ∧ R b =* a2) ∨ (L b =* a2 ∧ R b =* a3) ∨ (L b =* a1 ∧ R b =* a3))) ∧\n ((∀* (b : F.Model.σ), ¬ ((∃*)* (L b) (x.relation_symbol 1))) ∧ (∀* (b : F.Model.σ), ¬ ((∃*)* (R b) (x.relation_symbol 1))) ∧\n ((∀* (b : F.Model.σ), (L b =* b) ∨ (R b =* b)) ∨ (∀* (b : F.Model.σ), ¬ ((∃*)* (b) (x.relation_symbol 1)))))} n),\n let B := λ (n : ℕ), F.fold \n ((λ (x : first_order.prop L) (y : L.Theory), y.union {x.to_true_logic_formula}) ∘ \n (λ (x : first_order.predicate L) (y : L.Theory), y.union A)) F n,\n have h2 : B n ⊆ Γ n, from by\n apply subset.trans (λ (x : first_order.formula L), subset_union.mpr ⟨by {intros,simp [B,A],from λ a b,by {apply F.mem_fold_right}},\n by {intros, simp [B,A],from λ a b,by {apply F.mem_fold_right}}⟩) subset_union_right,\n have h3 : ∃ (M : F.Model) [mfin : fintype M], M ⊧ B n, from by\n apply fintype.induction_on (h n).right (λ a,\n begin\n {\n let a3 := mk F.Model (a.val ∪ {a1,a2,a3,L,R}),\n have h3 : (∃ (a1 : F.Model.σ), ∃ (a2 : F.Model.σ), ∃ (a3 : F.Model.σ), ∃ (L : F.Model.σ → F.Model.σ), ∃ (R : F.Model.σ → F.Model.σ), (∃* (a1 a2) (x.relation_symbol 2)) ∧ ¬ ((∃*)* (a1 a3) (x.relation_symbol 2)) ∧ ¬ ((∃*)* (a2 a3) (x.relation_symbol 2)) ∧ ((∀* (b : F.Model.σ), (L b =* a1 ∧ R b =* a2) ∨ (L b =* a2 ∧ R b =* a3) ∨ (L b =* a1 ∧ R b =* a3))) ∧ ((∀* (b : F.Model.σ), ¬ ((∃*)* (L b) (x.relation_symbol 1))) ∧ (∀* (b : F.Model.σ), ¬ ((∃*)* (R b) (x.relation_symbol 1))) ∧ ((∀* (b : F.Model.σ), (L b =* b) ∨ (R b =* b)) ∨ (∀* (b : F.Model.σ), ¬ ((∃*)* (b) (x.relation_symbol 1)))))), from\n have h3 : ∀ x y, x ≠ y → ¬ (∃* (a1 x) (x.relation_symbol 1) ∧ ∃* (a1 y) (x.relation_symbol 1)), from assume x y h12,\n begin\n apply not_and.mp,\n suffices : ¬ ∃* (a1 x) (x.relation_symbol 1) ∨ ¬ ∃* (a1 y) (x.relation_symbol 1), from or_not_and.mp this,\n suffices : ¬ (∃* (a1 x) (x.relation_symbol 1) ∧ ∃* (a1 y) (x.relation_symbol 1)), from by {split,assumption, assumption,},\n simp [h12],\n end,\n have h4 : ∀ x y, x ≠ y → ¬ (∃* (a2 x) (x.relation_symbol 1) ∧ ∃* (a2 y) (x.relation_symbol 1)), from assume x y h12,\n begin\n apply not_and.mp,\n suffices : ¬ ∃* (a2 x) (x.relation_symbol 1) ∨ ¬ ∃* (a2 y) (x.relation_symbol 1), from or_not_and.mp this,\n suffices : ¬ (∃* (a2 x) (x.relation_symbol 1) ∧ ∃* (a2 y) (x.relation_symbol 1)), from by {split,assumption, assumption,},\n simp [h12],\n end,\n have h5 : ∀ (b : F.Model.σ), ∃ (a1 : F.Model.σ), ∃ (a2 : F.Model.σ), ∃ (a3 : F.Model.σ), ∃ (L : F.Model.σ → F.Model.σ), ∃ (R : F.Model.σ → F.Model.σ), (∃* (a1 a2) (x.relation\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n have h1 : ∀ n : ℕ, ∃ (m : F.Model) (h1 : n ≤ fintype.card m), first_order.Model.sat_of_mem L.Theory.rel_model (@first_order.Model.rel_sat L F.Model) F.Model.rel m (F.Model.model_to_set m) (encode_model_of_model m),\n from assume n : ℕ,\n let ⟨M, hM⟩ := h n in\n let ⟨m : F.Model, h1, h2⟩ := F.Model.encode hM in\n have h3 : sat_of_mem F.Theory.rel_model F.Model.rel_sat m (F.Model.model_to_set m), from h2,\n ⟨m, h1, h3⟩,\n have h2 : ∃ (M : F.Model), ∀ n : ℕ, n ≤ fintype.card M, from by {\n apply first_order.compactness h1,\n have h3 : ∀ x : F.Model, first_order.Model.sat_of_mem L.Theory.rel_model F.Model.rel_sat x (F.Model.model_to_set x) → finite x, from \n assume x : F.Model,\n assume h3 : sat_of_mem F.Theory.rel_model F.Model.rel_sat x (F.Model.model_to_set x),\n have h4 : finite (F.Model.model_to_set x), from assume s : set F.Lang.symbol, ⟨@F.Model.Model_to_Set.mk_struct \n (@first_order.Model.Model_to_Set.mk_struct x s) h3,@F.Model.Model_to_Set.mk_struct \n (@first_order.Model.Model_to_Set.mk_struct x s) h3⟩,\n show finite x, from fintype.of_finset (finset.coe_to_finset $ F.Model.model_to_set x),\n\n show finite (F.Model.model_to_set _), from @h3 _ _,\n },\n let ⟨M, hM⟩ := h2 in\n have h3 : ∃ (n : ℕ), n ≤ fintype.card M ∧ n ≥ fintype.card M, from by {\n let ⟨n, hn⟩ := classical.axiom_of_infinitude M in\n use n, apply and.intro hn,\n have h4 : finite M, from by {\n have h4 : F.Model.sat_of_mem L.Theory.rel_model F.Model.rel_sat M (F.Model.model_to_set M), from hM M,\n have h5 : finite (F.Model.model_to_set M), from assume s : set F.Lang.symbol, ⟨@F.Model.Model_to_Set.mk_struct \n (@first_order.Model.Model_to_Set.mk_struct M s) h4,@F.Model.Model_to_Set.mk_struct \n (@first_order.Model.Model_to_Set.mk_struct M s) h4⟩,\n show finite (M), from fintype.of_finset (finset.coe_to_finset $ F.Model.model_to_set M),\n },\n exact le_of_not_gt hn h4,\n },\n let ⟨n, hn⟩ := h3 in\n have h4 : n = fintype.card M, from le_antisymm hn.right hn.left,\n have h5 : infinite M, from by {\n have h5 : ∀ m : F.Model, fintype.card M = fintype.card m → m.type = M.type, from assume m : F.Model, by {\n assume h5 : fintype.card M = fintype.card m,\n have h6 : m.type = M.type, from (M.injective M.to_set M.to_set),\n show m.type = M.type, from h6,\n },\n refine ⟨by {\n have h6 : M.type = M.type, from eq.refl M.type,\n have h7 : (M.type).to_set = M.type.to_set, from rfl,\n have h8 : M.type.to_set = M.type.to_set, from rfl,\n have h9 : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin, from assume n : ℕ, by {\n use M, split, use mfin, exact le_refl n,\n },\n have h10 : ∃ (M : F.Model) [mfin : fintype M], ∀ n : ℕ, n ≤ @fintype.card M mfin, from h9 _,\n let ⟨N, hN⟩ := h10 in\n let ⟨m : F.Model, hm, hm2⟩ := F.Model.encode hN in\n have h11 : M.type = m.type, from h5 m (h4.symm ▸ hm2),\n have h12 : F.Model.Model_to_Set.to_model M.type = F.Model.Model_to_Set.to_model m.type, from by {\n rw ← h11,\n\n have h13 : F.Model.Model_to_Set.to_model M.type.to_set = M, from rfl,\n have h14 : F.Model.Model_to_Set.to_model m.type.to_set = m, from rfl,\n\n have h15 : M.to_set = m.to_set, from eq.trans h12 h13.symm,\n have h16 : (M.type).to_set = m.to_set, from eq.trans h7.symm h15,\n have h17 : (M.type).to_set = m.type.to_set, from eq.trans h11.symm h16,\n have h18 : (M.type).to_set.to_set = m.type.to_set, from h17,\n show F.Model.Model_to_Set.to_model (M.type).to_set = F.Model.Model_to_Set.to_model m.type.to_set, from\n eq.trans (F.Model.Model_to_Set.mk_struct h8.symm) (eq.trans (@F.Model.Model_to_Set.to_model M.type (M.type).to_set).symm (eq.trans (F.Model.Model_to_Set.mk_struct h18) (@F.Model.Model_to_Set.to_model m.type m.type.to_set))),\n },\n have h13 : M.type = F.Model.Model_to_Set.to_model M.type.to_set, from rfl,\n have h14 : M.type = M, from eq.trans (eq.trans h13.symm h12) h13, \n show (M.type).to_set = M.to_set, from eq.trans (h11.symm ▸ h7) (eq.trans h8.symm h14),\n }⟩,\n },\n use M, use h5,\nend\n\n--OUTPUT 3\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n assume L : first_order.language,\n assume F : L.Theory,\n assume h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin,\n have h0 : ∀ ⦃L : first_order.language⦄ {F : L.Theory} [decidable_pred (F.Model.relations)] ⦃n : ℕ⦄, (∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) → ∃ (M : F.Model) [hM : infinite M], n ≤ @fintype.card M hM, from by {\n assume L : first_order.language,\n assume F : L.Theory,\n assume h : decidable_pred (F.Model.relations),\n assume n : ℕ,\n assume hn : ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin,\n cases hn with m hm,\n cases hm with hmfin hmn,\n use (m : F.Model),\n show infinite m, from @infinite_of_finite_nat' L F h m hmfin hmn, \n show n ≤ @fintype.card m _, from hmn,\n },\n cases (classical.choice (λ n : ℕ, ∃ (M : F.Model) [hM : infinite M], n ≤ @fintype.card M hM)) with n hn,\n have h1 : ∃ (M : F.Model) [hM : infinite M], n ≤ @fintype.card M hM, from h0 _ (h n),\n cases h1 with M hM,\n use M,\n show infinite M, from hM.left,\nend\n\n--OUTPUT 4\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n /- Let $A_n$ be the formula:\n -\n - $(\\exists x_1 \\exists x_2 \\ldots \\exists x_n: \\{x_1 \\ne x_2 \\land x_1 \\ne x_3 \\land \\ldots \\land x_{n - 1} \\ne x_n\\}$\n -\n - Then $A_i$ is true in a structure $\\AA$ iff $\\AA$ has at least $n$ elements.\n -/\n have A_n : L.formula, from by {\n let vars : L.Variables := L.Variables.mk $ λ (x), x.name ≠ ``0 ∧ x.arity = 0, \n let prefix : L.Formula_Prefix := L.Formula_Prefix.mk $ λ (x), x.name ≠ ``0 ∧ x.arity = 0,\n let φ : L.formula := L.formula.mk $ λ (x), x.name ≠ ``0 ∧ x.arity = 0,\n let qvars : L.Variables := L.Variables.mk $ λ (x), x.name ≠ ``0 ∧ x.arity = 0,\n let bvars : L.Variables := L.Variables.mk $ λ (x), x.name ≠ ``0 ∧ x.arity = 0,\n have h0 : ∀ (x : L.Var) (h1 : (x : L.Variables) ∈ qvars), x.name ≠ ``0 ∧ x.arity = 0, from by simp [h1.1,h1.2],\n have h1 : ∀ (x : L.Var) (h2 : (x : L.Variables) ∈ vars), x.name ≠ ``0 ∧ x.arity = 0, from by {\n assume x h2,\n have h3 : (x : L.Variables) ∈ qvars, from by {\n simp [h2.1,h2.2,bvars],\n simp [vars,lvars] at h2,\n },\n apply h0 _ h3,\n },\n have h2 : ∀ (x : L.Var) (h3 : (x : L.Variables) ∈ prefix), x.name ≠ ``0 ∧ x.arity = 0, from by {\n assume x h3,\n have h4 : (x : L.Variables) ∈ vars, from by {\n simp [h3.1,h3.2,qvars],\n simp [lvars,vars] at h3,\n },\n apply h1 _ h4,\n },\n have h3 : ∀ (x : L.Var) (h4 : (x : L.Variables) ∈ φ), x.name ≠ ``0 ∧ x.arity = 0, from by { apply h2, },\n exact L.formula.mk h3, \n },\n let Γ : Type* := fintype.finset (F.Model), \n /- Take:\n -\n - ${\\Gamma} := F \\cup \\bigcup_{i \\mathop = 1}^\\infty A_i $\n -\n - Since $F$ has models of arbitrarily large size, every finite subset of $\\Gamma$ is satisfiable.\n -/\n have finite_model_exists : F.Model, from by {\n have h0 : ∃ (M : F.Model) [mfin : fintype M], 0 ≤ @fintype.card M mfin, from by simp,\n exact classical.choice h0,\n },\n\n\n have overflowed : ∀ (n : ℕ), ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin, from by {\n assume n : ℕ,\n use finite_model_exists,\n exact ⟨by obviously⟩,\n },\n have ∀ (n : ℕ), (∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin), from by exact overflowed,\n\n\n /- From the Compactness Theorem, $\\Gamma$ is satisfiable in some model $\\mathbf{M}$.\n -/\n have h_compactness : ∃ (m : F.Model), ∀ (h : m ∈ Γ), F.Model.satisfies m h, from by {\n admit,\n },\n have M_exists : F.Model, from classical.choice h_compactness,\n let M : F.Model := M_exists,\n have M_satisfies : ∀ (h : M ∈ Γ), F.Model.satisfies M h, from by {\n apply classical.choice h_compactness,\n },\n have M_satisfies_all_formulas : F.Model.satisfies M 𝟙, from begin\n have h0 : M ∈ Γ, from by simp [M,Γ,fintype.eqv'],\n have h1 : F.Model.satisfies M h0, from M_satisfies h0,\n have h2 : ∀ (h : Γ), F.Model.satisfies M h, from by {exact M_satisfies,},\n simp [M,h1,h2,fintype.eqv],\n end,\n\n\n /- But since $\\mathbf{M} \\models A_i$ for each $i$, $\\mathbf{M}$ must be infinite.\n -/\n have M_is_infinite : infinite M, from begin\n have h0 : ∃ a : M, ∀ b : M, a ≠ b, from by {\n have h0 : ∀ (n : ℕ), ∃ a : M, ∀ b : M, a ≠ b, from begin\n /- \n Let $\\mathbf A_n$ be the formula:\n :$\\exists x_1 \\exists x_2 \\ldots \\exists x_n: \\{x_1 \\ne x_2 \\land x_1 \\ne x_3 \\land \\ldots \\land x_{n - 1} \\ne x_n\\}$\n -/\n assume n : ℕ,\n have h1 : (1 : ℚ) ≤ (n : ℚ), from by ring,\n have h2 : n ≤ n + 1 := by apply le_succ,\n have h3 : (1 : ℚ) ≤ (n + 1 : ℚ), from by apply le_trans h1 h2,\n have h4 : (n : ℚ) ≤ (n + 1 : ℚ), from by ring, \n have h5 : (n : ℝ) ≤ (n + 1 : ℝ), from by apply @rat.cast_le ℚ,\n have h6 : (n : ℝ) < (n + 1 : ℝ), from by apply lt_succ_iff.mp h5,\n have h7 : ((n + 1) : ℕ) < (n + 2), from by apply lt_succ_iff.mpr h6,\n have h8 : n < n + 2, from by apply nat.lt_succ_iff.mp h7,\n /- Then $\\mathbf A_i$ is true in a structure $\\AA$ iff $\\AA$ has at least $n$ elements.\n -/\n have h9 : ∃ (M : F.Model) [mfin : fintype M], (n :ℕ) ≤ fintype.card M, from by {\n have h9 : ∃ (M : F.Model) [mfin : fintype M], (n :ℕ) ≤ @fintype.card M mfin, from by {\n apply overflowed,\n },\n exact h9,\n },\n have h10 : ∃ (M : F.Model) [mfin : fintype M], n + 2 ≤ @fintype.card M mfin := by {\n let M : F.Model := classical.choice h9,\n have mfin : fintype M, from classical.choice h\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n have h1 : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm' : m' ≃ m], n ≤ @fintype.card m' mfin'), from \n assume n : ℕ,\n begin\n have h2 : ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin, by apply h,\n have h3 : ∀ (m : F.Model) [mfin : fintype m], ∃ [mm' : m ≃ m], n ≤ @fintype.card m mfin, from \n assume (m : F.Model) [mfin : fintype m], let ⟨pm,hp⟩ := mfin.equiv_fin, let mm' : m ≃ m := ⟨pm,hp⟩, ⟨mm'⟩,\n have h4 : ∃ (m : F.Model) [mfin : fintype m] [mm' : m ≃ m], n ≤ @fintype.card m mfin, from exists_imp_exists _ h3,\n have h5 : ∃ (m : F.Model) [mfin : fintype m] [mm' : m ≃ m], n ≤ @fintype.card m mfin', from exists_imp_exists _ h4, \n exact h5,\n end, \n have h2 : ∀ n : ℕ, ∃ (a : F.Model) [mfin : fintype a] [ma : a ⊧ L.A n], n ≤ @fintype.card a mfin, from \n assume n : ℕ, begin\n have h3 : ∃ (m : F.Model) [mfin : fintype m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm' : m' ≃ m], n ≤ @fintype.card m' mfin'), from (h1 n),\n have h4 : ∃ a [mfin : fintype a] [mm' : a ≃ a], (∀ (m : F.Model) [mfin' : fintype m] [mm : m ≃ a], n ≤ @fintype.card m mfin'), from \n exists_imp_exists_const (λ (m : F.Model) [mfin : fintype m], ∀ (m' : F.Model) [mfin' : fintype m'] [mm : m' ≃ m], n ≤ @fintype.card m' mfin') h3,\n have h5 : ∃ a [mfin : fintype a] [mm' : a ≃ a], (∀ (m : F.Model) [mfin' : fintype m] [mm : a ≃ m], n ≤ @fintype.card m mfin'), from exists_imp_exists_const (λ (m : F.Model) [mfin' : fintype m], ∀ [mm : a ≃ m], n ≤ @fintype.card m mfin') h4,\n have h6 : ∃ a [mfin : fintype a] [mm' : a ≃ a], (∀ (m : F.Model) [mfin' : fintype m] [mm : a ≃ m], n ≤ @fintype.card a mfin), from exists_imp_exists_const (λ (m : F.Model) [mfin' : fintype m], n ≤ @fintype.card a mfin) h5, \n have h7 : ∃ (m : F.Model) [mfin : fintype m] [mm' : m ≃ m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm : m ≃ m'], n ≤ @fintype.card m' mfin'), from \n begin \n have h8 : ∃ (a : F.Model) [mfin : fintype a] [mm' : a ≃ a], (∀ (m : F.Model) [mfin' : fintype m] [mm : a ≃ m], n ≤ @fintype.card a mfin), from h6,\n exact exists_imp_exists_const (λ (m : F.Model) [mfin' : fintype m], ∀ [mm : m ≃ a], n ≤ @fintype.card m mfin') h8,\n end,\n have h8 : ∃ (m : F.Model) [mfin : fintype m] [mm' : m ≃ m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm : m ≃ m'], n ≤ @fintype.card m mfin'), from exists_imp_exists_const (λ (m : F.Model) [mfin' : fintype m], n ≤ @fintype.card m mfin') h7,\n have h9 : ∃ (m : F.Model) [mfin : fintype m] [mm' : m ≃ m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm : m ≃ m'], n ≤ @fintype.card m mfin) ∧ (∀ (m' : F.Model) [mfin' : fintype m'] [mm : m ≃ m'], m' ⊧ L.A n), from exists_imp_exists_const (λ (m : F.Model) [mfin : fintype m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm : m ≃ m'], m' ⊧ L.A n)) h8,\n exact h9,\n end,\n have h3 : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm' : m ≃ m'], n ≤ @fintype.card m mfin) ∧ (∀ n : ℕ, m ⊧ L.A n), from \n assume n : ℕ, begin\n have h3 : ∃ (m : F.Model) [mfin : fintype m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm' : m ≃ m'], n ≤ @fintype.card m mfin), from h2 n,\n have h4 : ∃ (m : F.Model) [mfin : fintype m], (∃ [mm' : m ≃ m], n ≤ @fintype.card m mfin), from \n exists_imp_exists_const (λ (m : F.Model) [mfin : fintype m], ∃ [mm : m ≃ m], n ≤ @fintype.card m mfin) h3,\n have h5 : ∃ (m : F.Model) [mfin : fintype m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm : m' ≃ m], n ≤ @fintype.card m mfin) ∧ (∀ n : ℕ, m ⊧ L.A n), from \n exists_imp_exists_const (λ (m : F.Model) [mfin : fintype m], (∀ n : ℕ, m ⊧ L.A n)) h4,\n exact h5,\n end,\n have h4 : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm : m' ≃ m], m' ⊧ F ∧ (∀ n : ℕ, m' ⊧ L.A n)), from\n assume n : ℕ, begin\n have h5 : ∃ (m : F.Model) [mfin : fintype m], (∀ (m' : F.Model) [mfin' : fintype m'] [mm : m' ≃\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n use (F.Model.empty),\n sorry\nend\n\n--OUTPUT 7\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n assume L F (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin),\n use [L,F], split,\n assume (n : ℕ), let L' := L.add_sorts (n + 3) in\n let F' := F.add_variables (n + 3) in \n let g := function.update (finset.range n) (λ i : fin (n + 3), 0) (n + 1) in\n let h := function.update (finset.range n) (λ i : fin (n + 3), 0) (n + 2) in\n let i := function.update (finset.range n) (λ i : fin (n + 3), 0) (n + 3) in\n let G := function.update (finset.range n) (λ i : fin (n + 3), 0) (n + 4) in\n let Γ := L' \n in\n let φ := (∃(g),\n (∃(h), \n (∃(i), \n (∃(G),\n ((∀(x), \n (∃(g), \n (∃(h), \n (∃(i), \n (∃(G), \n (∀(x), \n (∀(g), \n (∀(h), \n (∀(i), \n (∀(G), \n ((∀(x), \n (∀(g), \n (∀(h), \n ((neg (g = h)) ∧ (neg (h = i)) ∧ (neg (g = i))))))) ∧ \n (∀(x), \n (∀(g), \n (∀(h), \n (∀(i), \n (∀(G), \n ((x < i) = (x < G)))))))))))))))))))))))))) ∧\n (∀(x), \n (∀(g), \n (∀(h), \n (∀(i), \n (∀(G), \n ((g < h) = (g < i)))))))) ∧ \n (∀(x), \n (∀(g), \n (∀(h), \n (∀(i), \n (∀(G), \n ((x = i) = (x = G)))))))) ∧ \n (∀(x), \n (∀(g), \n (∀(h), \n (∀(i), \n (∀(G), \n ((x = i) = (x = G)))))))) ∧ \n (∀(x), \n (∀(g), \n (∀(h), \n (∀(i), \n (∀(G), \n ((x = i) = (x = G)))))))) ∧ \n (∀(x), \n (∀(g), \n (∀(h), \n (∀(i), \n (∀(G), \n ((x = i) = (x = G)))))))) ∧ \n (∀(x), \n (∀(g), \n (∀(h), \n (∀(i), \n (∀(G), \n ((x = i) = (x = G))))))))) in\n show ∃ (M : F'.Model), infinite M, from\n begin\n have h1 : ∀ n : ℕ, ∃ (m : F'.Model) [mfin : fintype m], n ≤ @fintype.card m mfin,\n from by {\n assume n,\n cases h n,\n use F'.Model.add_variables h_w,\n use [n, h_h],\n rw add_comm, exact h_w_1,\n },\n have h2 : ∀ n : ℕ, ∃ (m : F'.Model), n ≠ @fintype.card m,\n from by {\n assume (n : ℕ), \n cases h1 n,\n use g,\n have h5 : @fintype.card g ≠ n, from by rw [←(card_insert_of_not_mem @@ set.not_mem_range_self _ _)],\n have h6 : fintype.card g ≠ n, from by rw [fintype.card_eq_nat_card, ← h5], show n ≠ @fintype.card g, from not_congr h6,\n },\n have h3 : ∀ f : F'.Model, ∃ g : F'.Model, fintype.card g = fintype.card f + 1,\n from by {\n assume f,\n have h5 : @fintype.card f < @fintype.card (fintype.card f + 1), from by {\n rw [←nat.add_sub_cancel' (@fintype.card f), nat.sub_lt_iff_lt_add' (fintype.card_pos _)],\n },\n let g := (fintype.card f + 1),\n have h6 : ∃ (m : F'.Model), g ≠ @fintype.card m, from by {\n cases h2 g,\n use h_w, apply not_congr h_h,\n },\n cases h2 g,\n use h_w,\n apply h_h,\n },\n have h4 : F'.Theory.infinite_model φ := by { \n apply F'.Model.infinite_model_of_card_succ h3,},\n use h4,\n end\nend\n\n--OUTPUT 8\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nbegin\n let A_1 : L.formula := ∃ (x : L.sort) (y : L.sort), x ≠ y,\n let A_2 : L.formula := ∃ (x : L.sort) (y : L.sort) (z : L.sort), x ≠ y ∧ x ≠ z ∧ y ≠ z,\n let A_3 : L.formula := ∃ (x : L.sort) (y : L.sort) (z : L.sort) (w : L.sort), x ≠ y ∧ x ≠ z ∧ x ≠ w ∧ y ≠ z ∧ y ≠ w ∧ z ≠ w,\n -- continue with other A_n, or just say \"define A_n inductively\"\n let A_n : L.formula := λ (n : ℕ), sorry,\n let Gamma : set L.formula := F.theory.to_set.cup (set.range A_n),\n sorry,\nend\n\n--OUTPUT 9\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M := by sorry\n\n\n\n/--`theorem`\nAny enumeration of the positive integers is eventually periodic.\n`proof`\nBy the Pigeonhole Principle, the positive integers must be eventually periodic.\n\nThis is because we can map each positive integer to its index in the enumeration, which is a bijection.\n{{qed}}\n-/\ntheorem pigeonhole (n : ℕ) : ∃ (p : ℕ), ∀ (m : ℕ), m ≥ p → m % n = n % n := by sorry\nend\n\n--OUTPUT 10\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M := by {\n\nlet Aₙ := λ (n : ℕ), first_order.Theory.has_model F \n (first_order.existsn (n : ℕ) (first_order.var 0) ∧\n first_order.bigand (n - 1) (λ n : ℕ,\n first_order.∀' first_order.var (n+1) (first_order.var 0) (ne first_order.var 1) ∧\n first_order.impl (n ≠ 0) (first_order.∀' first_order.var (n+1) (first_order.var n) (ne first_order.var (n+1))))),\n\n let hₙ₊₁₋ₙₖ := by {intros, rw succ_sub, rw add_comm,simp},\n let hₙ₊₁₋ₙₖ₊₁ := by {intros, rw succ_sub, rw add_comm,rw succ_sub, rw add_comm,simp},\n let hₖ₊₁ := by {intros, rw succ_sub, rw add_comm,simp},\n let Γ := (first_order.Theory.has_model.map Aₙ) h,\n\n\n have h0 : (∀ n : ℕ, Γ n), from by {intros, simp [Γ],},\n have h1 : (ty), from by {\n have h1 : ((∀ n : ℕ, Γ n)), from by {intros, from h0 _,},\n have h2 : (has_finite.finite Γ), from by {apply _,},\n have h3 : (∃ (m : F.Model) [mfin : fintype m], nat.find (λ n, Γ n)), from by {exact h2,},\n have h4 : (∃ (m : F.Model) [mfin : fintype m], nat.find (λ n, Γ n)), from by {exact h3,},},\n\n\nhave h2 : (has_finite.finite Γ), from by {apply _,},\nhave h3 : (∃ (m : F.Model) [mfin : fintype m], nat.find (λ n, Γ n)), from by {exact h2,},\nhave h4 : (∃ (m : F.Model) [mfin : fintype m], nat.find (λ n, Γ n)), from by {exact h3,},\nexact h4,\n}\nend\n\n/- FEW SHOT PROMPTS TO CODEX(START)\n/--`theorem`\nPower Set is Closed under Intersection\nLet $S$ be a set.\n\nLet $\\powerset S$ be the power set of $S$.\n\n\nThen:\n:$\\forall A, B \\in \\powerset S: A \\cap B \\in \\powerset S$\n`proof`\nLet $A, B \\in \\powerset S$.\n\nThen by the definition of power set, $A \\subseteq S$ and $B \\subseteq S$.\n\nFrom Intersection is Subset we have that $A \\cap B \\subseteq A$.\n\nIt follows from Subset Relation is Transitive that $A \\cap B \\subseteq S$.\n\nThus $A \\cap B \\in \\powerset S$ and closure is proved.\n{{qed}}\n-/\ntheorem power_set_intersection_closed {α : Type*} (S : set α) : ∀ A B ∈ 𝒫 S, (A ∩ B) ∈ 𝒫 S :=\nbegin\n assume (A : set α) (hA : A ∈ 𝒫 S) (B : set α) (hB : B ∈ 𝒫 S),\n 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},\n have h2 : (A ∩ B) ⊆ A, from by apply set.inter_subset_left,\n have h3 : (A ∩ B) ⊆ S, from by {apply set.subset.trans h2 h1.left},\n show (A ∩ B) ∈ 𝒫 S, from by {apply set.mem_powerset h3},\nend\n\n/--`theorem`\nSquare of Sum\n :$\\forall x, y \\in \\R: \\paren {x + y}^2 = x^2 + 2 x y + y^2$\n`proof`\nFollows from the distribution of multiplication over addition:\n\n{{begin-eqn}}\n{{eqn | l = \\left({x + y}\\right)^2\n | r = \\left({x + y}\\right) \\cdot \\left({x + y}\\right)\n}}\n{{eqn | r = x \\cdot \\left({x + y}\\right) + y \\cdot \\left({x + y}\\right)\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x \\cdot x + x \\cdot y + y \\cdot x + y \\cdot y\n | c = Real Multiplication Distributes over Addition\n}}\n{{eqn | r = x^2 + 2xy + y^2\n | c = \n}}\n{{end-eqn}}\n{{qed}}\n-/\ntheorem square_of_sum (x y : ℝ) : (x + y)^2 = (x^2 + 2*x*y + y^2) := \nbegin\n calc (x + y)^2 = (x+y)*(x+y) : by rw sq\n ... = x*(x+y) + y*(x+y) : by rw add_mul\n ... = 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}\n ... = x^2 + 2*x*y + y^2 : by {repeat {rw ← sq}, rw mul_comm y x, ring}\nend\n\n\n/--`theorem`\nIdentity of Group is Unique\nLet $\\struct {G, \\circ}$ be a group. Then there is a unique identity element $e \\in G$.\n`proof`\nFrom Group has Latin Square Property, there exists a unique $x \\in G$ such that:\n:$a x = b$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = b$\n\nSetting $b = a$, this becomes:\n\nThere exists a unique $x \\in G$ such that:\n:$a x = a$\n\nand there exists a unique $y \\in G$ such that:\n:$y a = a$\n\nThese $x$ and $y$ are both $e$, by definition of identity element.\n{{qed}}\n-/\ntheorem group_identity_unique {G : Type*} [group G] : ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a :=\nbegin\n have h1 : ∀ a b : G, ∃! x : G, a * x = b, from by {\n assume a b : G, use a⁻¹ * b, obviously, },\n have h2 : ∀ a b : G, ∃! y : G, y * a = b, from by {\n assume a b : G, use b * a⁻¹, obviously, }, \n\n have h3 : ∀ a : G, ∃! x : G, a * x = a, from \n assume a : G, h1 a a,\n have h4 : ∀ a : G, ∃! y : G, y * a = a, from\n assume a : G, h2 a a,\n\n have h5 : ∀ a : G, classical.some (h3 a).exists = (1 : G), from assume a :G,\n exists_unique.unique (h3 a) (classical.some_spec (exists_unique.exists (h3 a)))\n (mul_one a),\n have h6 : ∀ a : G, classical.some (h4 a).exists = (1 : G), from assume a : G,\n exists_unique.unique (h4 a) (classical.some_spec (exists_unique.exists (h4 a))) (one_mul a), \n\n show ∃! e : G, ∀ a : G, e * a = a ∧ a * e = a, from by {\n use (1 : G),\n have h7 : ∀ e : G, (∀ a : G, e * a = a ∧ a * e = a) → e = 1, from by {\n assume (e : G) (hident : ∀ a : G, e * a = a ∧ a * e = a),\n have h8 : ∀ a : G, e = classical.some (h3 a).exists, from assume (a : G),\n exists_unique.unique (h3 a) (hident a).right\n (classical.some_spec (exists_unique.exists (h3 a))), \n have h9 : ∀ a : G, e = classical.some (h4 a).exists, from assume (a : G),\n exists_unique.unique (h4 a) (hident a).left\n (classical.some_spec (exists_unique.exists (h4 a))),\n show e = (1 : G), from eq.trans (h9 e) (h6 _), \n },\n exact ⟨by obviously, h7⟩,\n }\nend\n\n/--`theorem`\nOverflow theorem\nLet $F$ be a set of first-order formulas which has finite models of arbitrarily large size. Then $F$ has an infinite model.\n`proof`\nFor each $n$, let $\\mathbf A_n$ be the formula:\n\n$\\exists x_1 \\exists x_2 \\ldots \\exists x_n: \\{x_1 \\ne x_2 \\land x_1 \\ne x_3 \\land \\ldots \\land x_{n - 1} \\ne x_n\\}$\n\nThen $\\mathbf A_i$ is true in a structure $\\AA$ iff $\\AA$ has at least $n$ elements.\n\nTake:\n$$ \\Gamma := F \\cup \\bigcup_{i \\mathop = 1}^\\infty A_i $$\n\nSince $F$ has models of arbitrarily large size, every finite subset of $\\Gamma$ is satisfiable.\n\nFrom the Compactness Theorem, $\\Gamma$ is satisfiable in some model $\\mathbf{M}$.\n\nBut since $\\mathbf{M} \\models A_i$ for each $i$, $\\mathbf{M}$ must be infinite.\n\nSo $F$ has an infinite model.\n\nQED\n-/\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : ∀ n : ℕ, ∃ (m : F.Model) [mfin : fintype m], n ≤ @fintype.card m mfin) : ∃ (M : F.Model), infinite M :=\nFEW SHOT PROMPTS TO CODEX(END)-/\n", "meta": {"author": "ayush1801", "repo": "Autoformalisation_benchmarks", "sha": "51e1e942a0314a46684f2521b95b6b091c536051", "save_path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks", "path": "github-repos/lean/ayush1801-Autoformalisation_benchmarks/Autoformalisation_benchmarks-51e1e942a0314a46684f2521b95b6b091c536051/proof/lean_proof-Natural-Language-Proof-Translation/Correct_statement-lean_proof-3_few_shot_temperature_0.8_max_tokens_2000_n_10/clean_files/Overflow theorem.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.35936413143782797, "lm_q1q2_score": 0.2047846031229919}} {"text": "import Lean\n\nopen Lean Meta\n\ndef ctor (mvarId : MVarId) (idx : Nat) : MetaM (List MVarId) := do\n /- Set `MetaM` context using `mvarId` -/\n withMVarContext mvarId do \n /- Fail if the metavariable is already assigned. -/\n checkNotAssigned mvarId `ctor\n /- Retrieve the target type, instantiateMVars, and use `whnf`. -/\n let target ← getMVarType' mvarId\n let .const declName us := target.getAppFn\n | throwTacticEx `ctor mvarId \"target is not an inductive datatype\"\n let .inductInfo { ctors, .. } ← getConstInfo declName\n | throwTacticEx `ctor mvarId \"target is not an inductive datatype\"\n if idx = 0 then\n throwTacticEx `ctor mvarId \"invalid index, it must be > 0\" \n else if h : idx - 1 < ctors.length then\n apply mvarId (.const ctors[idx - 1] us)\n else\n throwTacticEx `ctor mvarId \"invalid index, inductive datatype has only {ctors.length} contructors\" \n\nopen Elab Tactic\n\nelab \"ctor\" idx:num : tactic => \n liftMetaTactic (ctor · idx.getNat)\n\nexample (p : Prop) : p := by \n ctor 1 -- Error\n\nexample (h : q) : p ∨ q := by \n ctor 0 -- Error\n exact h\n\nexample (h : q) : p ∨ q := by \n ctor 3 -- Error\n exact h\n\nexample (h : q) : p ∨ q := by \n ctor 2\n exact h\n\nexample (h : q) : p ∨ q := by \n ctor 1\n exact h -- Error \n\n", "meta": {"author": "leanprover", "repo": "lean4", "sha": "742d053a97bdd109a41a921facd1cd6a55e89bc7", "save_path": "github-repos/lean/leanprover-lean4", "path": "github-repos/lean/leanprover-lean4/lean4-742d053a97bdd109a41a921facd1cd6a55e89bc7/doc/examples/ICERM2022/ctor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.399811640739795, "lm_q1q2_score": 0.20459025532056946}} {"text": "import ..syntax_directed\nimport ..type_system\nimport .structural_subtyping\n\nnamespace flow_analysis\n\nlemma syntax_directed_subtyping.expr {Λ : location} {γ : identifier} {e : base_expr}\n {ρ ρ' : phrase} :\n ((Λ, γ) ⊢ₛₑ e : ρ ∧ ρ ⊆ₛ ρ') → ((Λ, γ) ⊢ₛₑ e : ρ')\n:= begin\n intro h,\n cases h with h_ctx h_sub,\n induction h_ctx,\n case syntax_directed.expr_typing.int : n _ {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with x h_lemma4,\n cases h_lemma4 with y h_lemma4,\n cases h_lemma4,\n have h2 := h_lemma4.right.left,\n rw h2,\n apply syntax_directed.expr_typing.int,\n cc,\n },\n case syntax_directed.expr_typing.var : Λ γ v x ih {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with a h_lemma4,\n cases h_lemma4 with b h_lemma4,\n cases h_lemma4,\n cc,\n repeat { cases h_lemma4, },\n rw eq.symm h_lemma4_right,\n apply syntax_directed.expr_typing.var ih,\n cc,\n },\n case syntax_directed.expr_typing.varloc : Λ γ v x ih {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with a h_lemma4,\n cases h_lemma4 with b h_lemma4,\n cases h_lemma4,\n cc,\n repeat { cases h_lemma4, },\n rw eq.symm h_lemma4_right,\n apply syntax_directed.expr_typing.varloc ih,\n cc,\n },\n case syntax_directed.expr_typing.binop : Λ γ a b z τ iha ihb ihsuba ihsubb {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with x h_lemma4,\n cases h_lemma4 with y h_lemma4,\n cases h_lemma4,\n have h := h_lemma4.right.left,\n simp[h] at *,\n apply syntax_directed.expr_typing.binop (ihsuba h_sub) (ihsubb h_sub),\n cc,\n },\n case syntax_directed.expr_typing.r_val : Λ γ e τ τ' he hxy ih {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with x h_lemma4,\n cases h_lemma4 with y h_lemma4,\n cases h_lemma4,\n cases h_lemma4 with h1 h_lemma4,\n cases h_lemma4 with h2 h3,\n simp at h1,\n simp[h1, h2] at *,\n have h := le_trans hxy h3,\n apply syntax_directed.expr_typing.r_val he h,\n cc,\n },\nend\n\n/- Lemma 6.1\n - If (Λ, γ) ⊢ₛ p : ρ and ⊢ ρ ⊆ₛ ρ', then (Λ, γ) ⊢ₛ p : ρ'\n -/\nlemma syntax_directed_subtyping {Λ : location} {γ : identifier} {p : program}\n {ρ ρ' : phrase} :\n ((Λ, γ) ⊢ₛ p : ρ ∧ ρ ⊆ₛ ρ') → ((Λ, γ) ⊢ₛ p : ρ')\n:= begin\n intro h,\n cases h with h_ctx h_sub,\n induction h_ctx,\n case syntax_directed.program_typing.assign_var : Λ γ v e τ τ' ihv ihe ihyx {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with x h_lemma4,\n cases h_lemma4 with y h_lemma4,\n repeat { cases h_lemma4, cc, },\n cases h_lemma4 with h1 h_lemma4,\n cases h_lemma4 with h2 h3,\n simp at h1,\n simp[h1, h2] at *,\n have h := le_trans h3 ihyx,\n apply syntax_directed.program_typing.assign_var ihv ihe h,\n },\n case syntax_directed.program_typing.assign_loc : Λ γ v e τ τ' ihv ihe ihyx {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with x h_lemma4,\n cases h_lemma4 with y h_lemma4,\n repeat { cases h_lemma4, cc, },\n cases h_lemma4 with h1 h_lemma4,\n cases h_lemma4 with h2 h3,\n simp at h1,\n simp[h1, h2] at *,\n have h := le_trans h3 ihyx,\n apply syntax_directed.program_typing.assign_loc ihv ihe h,\n },\n case syntax_directed.program_typing.compose : Λ γ c c' τ hc hc' ihc ihc' {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with x h_lemma4,\n cases h_lemma4 with y h_lemma4,\n repeat { cases h_lemma4, cc, },\n have h := h_lemma4.right.left,\n simp[h] at *,\n apply syntax_directed.program_typing.compose (ihc h_sub) (ihc' h_sub),\n },\n case syntax_directed.program_typing.branch\n : Λ γ e c c' τ τ' he hc hc' ihc ihc' ih {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with x h_lemma4,\n cases h_lemma4 with y h_lemma4,\n repeat { cases h_lemma4, cc, },\n cases h_lemma4 with h1 h_lemma4,\n cases h_lemma4 with h2 h3,\n simp at h1,\n simp[h1, h2] at *,\n have h := le_trans h3 ihc,\n apply syntax_directed.program_typing.branch he hc hc' h,\n },\n case syntax_directed.program_typing.while : Λ γ e c τ τ' he hc hττ' ihc {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with x h_lemma4,\n cases h_lemma4 with y h_lemma4,\n repeat { cases h_lemma4, cc, },\n cases h_lemma4 with h1 h_lemma4,\n cases h_lemma4 with h2 h3,\n simp at h1,\n simp[h1, h2] at *,\n have h := le_trans h3 hττ',\n apply syntax_directed.program_typing.while he hc h,\n },\n case syntax_directed.program_typing.letvar : Λ γ x e c τ τ' he hc ih {\n have h_lemma4 := structural_subtyping h_sub,\n cases h_lemma4 with x h_lemma4,\n cases h_lemma4 with y h_lemma4,\n repeat { cases h_lemma4, cc, },\n cases h_lemma4 with h1 h_lemma4,\n cases h_lemma4 with h2 h3,\n simp at h1,\n simp[h1, h2] at *,\n apply syntax_directed.program_typing.letvar he (ih h_sub),\n },\nend\n\nlemma program_typing_eq.expr {Λ : location} {γ : identifier} {e : base_expr}\n {ρ : phrase} : ((Λ, γ) ⊢ₑ e : ρ) ↔ ((Λ, γ) ⊢ₛₑ e : ρ)\n:= begin\n apply iff.intro,\n { intro h,\n induction h,\n { exact syntax_directed.expr_typing.int, },\n { rename h_h h,\n exact syntax_directed.expr_typing.var h, },\n { rename h_h h,\n exact syntax_directed.expr_typing.varloc h, },\n { rename h_ih_a ha, rename h_ih_a_1 hb,\n exact syntax_directed.expr_typing.binop ha hb, },\n case type_system.expr_typing.r_val : Λ γ e τ he ihe {\n exact syntax_directed.expr_typing.r_val ihe (le_refl τ), },\n case type_system.expr_typing.subtype : Λ γ p ρ ρ' hp hρρ' ih {\n exact syntax_directed_subtyping.expr (and.intro ih hρρ'),\n },\n },\n { intro h,\n induction h,\n { exact type_system.expr_typing.int, },\n { rename h_h h,\n exact type_system.expr_typing.var h, },\n { rename h_h h,\n exact type_system.expr_typing.varloc h, },\n { rename h_ih_a ha, rename h_ih_a_1 hb,\n exact type_system.expr_typing.binop ha hb, },\n case syntax_directed.expr_typing.r_val : Λ γ e τ τ' he hττ' ih {\n have h := phrase.ss.base hττ',\n have h_rval := type_system.expr_typing.r_val ih,\n exact type_system.expr_typing.subtype h_rval h, },\n },\nend\n\n/- Theorem 6.2\n - (Λ, γ) ⊢ₜ p : ρ ↔ (Λ, γ) ⊢ₛ p : ρ -/\ntheorem program_typing_eq {Λ : location} {γ : identifier}\n {p : program} {ρ : phrase} : ((Λ, γ) ⊢ₜ p : ρ) ↔ ((Λ, γ) ⊢ₛ p : ρ)\n:= begin\n apply iff.intro,\n { intro h,\n induction h,\n case type_system.program_typing.assign_var : Λ γ e e' τ he he' {\n have ha := program_typing_eq.expr.1 he,\n have hb := program_typing_eq.expr.1 he',\n exact syntax_directed.program_typing.assign_var ha hb (le_refl τ),\n },\n case type_system.program_typing.assign_loc : Λ γ e e' τ he he' {\n have ha := program_typing_eq.expr.1 he,\n have hb := program_typing_eq.expr.1 he',\n exact syntax_directed.program_typing.assign_loc ha hb (le_refl τ),\n },\n case type_system.program_typing.compose : Λ γ c c' τ hc hc' ihc ihc' {\n exact syntax_directed.program_typing.compose ihc ihc',\n },\n case type_system.program_typing.branch : Λ γ e c c' τ he hc hc' ihc ihc' {\n have ihe := program_typing_eq.expr.1 he,\n exact syntax_directed.program_typing.branch ihe ihc ihc' (le_refl τ),\n },\n case type_system.program_typing.while : Λ γ e c τ he hc ihc {\n have ihe := program_typing_eq.expr.1 he,\n exact syntax_directed.program_typing.while ihe ihc (le_refl τ),\n },\n case type_system.program_typing.letvar : Λ γ x e c τ τ' he hc ihc {\n have ihe := program_typing_eq.expr.1 he,\n exact syntax_directed.program_typing.letvar ihe ihc,\n },\n case type_system.program_typing.subtype : Λ γ p ρ ρ' hp hρρ' ihp {\n exact syntax_directed_subtyping (and.intro ihp hρρ'),\n },\n },\n { intro h,\n induction h,\n case syntax_directed.program_typing.assign_var : Λ γ e e' τ τ' he he' hττ' {\n have ha := program_typing_eq.expr.2 he,\n have hb := program_typing_eq.expr.2 he',\n have h_cmd := (phrase.ss.cmd (phrase.ss.base hττ')),\n have h_assign := type_system.program_typing.assign_var ha hb,\n exact type_system.program_typing.subtype h_assign h_cmd,\n },\n case syntax_directed.program_typing.assign_loc : Λ γ e e' τ τ' he he' hττ' {\n have ha := program_typing_eq.expr.2 he,\n have hb := program_typing_eq.expr.2 he',\n have h_cmd := (phrase.ss.cmd (phrase.ss.base hττ')),\n have h_assign := type_system.program_typing.assign_loc ha hb,\n exact type_system.program_typing.subtype h_assign h_cmd,\n },\n case syntax_directed.program_typing.compose : Λ γ c c' τ hc hc' ihc ihc' {\n exact type_system.program_typing.compose ihc ihc',\n },\n case syntax_directed.program_typing.branch\n : Λ γ e c c' τ τ' he hc hc' hτ'τ ihc ihc' {\n have ihe := program_typing_eq.expr.2 he,\n have h_sub := phrase.ss.cmd (phrase.ss.base hτ'τ),\n have h_ctx := type_system.program_typing.branch ihe ihc ihc',\n exact type_system.program_typing.subtype h_ctx h_sub,\n },\n case syntax_directed.program_typing.while : Λ γ e c τ τ' he hc hττ' ihc {\n have ihe := program_typing_eq.expr.2 he,\n have h_sub := phrase.ss.cmd (phrase.ss.base hττ'),\n have h_ctx := type_system.program_typing.while ihe ihc,\n exact type_system.program_typing.subtype h_ctx h_sub,\n },\n case syntax_directed.program_typing.letvar\n : Λ γ x e c τ τ' he hc ihc {\n have ihe := program_typing_eq.expr.2 he,\n exact type_system.program_typing.letvar ihe ihc,\n },\n },\nend\nend flow_analysis", "meta": {"author": "denismazzucato", "repo": "noninterference-lean", "sha": "a70674cb2af3959bd188b7079868f2505834ac74", "save_path": "github-repos/lean/denismazzucato-noninterference-lean", "path": "github-repos/lean/denismazzucato-noninterference-lean/noninterference-lean-a70674cb2af3959bd188b7079868f2505834ac74/src/lemmata/syntax_directed.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.3522017684487511, "lm_q1q2_score": 0.20339488888940022}} {"text": "import breen_deligne.eval2\nimport condensed.tensor\nimport condensed.evaluation_homology\nimport condensed.sheafification_homology\nimport for_mathlib.AddCommGroup\nimport for_mathlib.map_to_sheaf_is_iso\nimport condensed.is_iso_iff_extrdisc\nimport condensed.ab5\nimport condensed.ab4\nimport for_mathlib.endomorphisms.ab4\nimport for_mathlib.homology_exact\nimport for_mathlib.free_abelian_group2\nimport for_mathlib.embed_preserves_colimits\n\n.\n\nnoncomputable theory\n\nuniverses u\n\nopen category_theory category_theory.limits breen_deligne opposite\nopen bounded_homotopy_category\n\nabbreviation freeCond' := Condensed_Ab_to_CondensedSet ⋙ CondensedSet_to_Condensed_Ab\n\nnamespace Condensed\n\nvariables (BD : package)\n\nabbreviation freeFunc : (Profiniteᵒᵖ ⥤ Ab) ⥤ Profiniteᵒᵖ ⥤ Ab :=\n(whiskering_right _ _ _).obj (forget _ ⋙ AddCommGroup.free)\n\nnamespace eval_freeCond'_iso\n\ndef component_zero (M : Condensed.{u} Ab.{u+1}) :\n ((BD.eval' freeCond').obj M).X (int.of_nat 0) ≅\n ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).X\n (int.of_nat 0) :=\npresheaf_to_Condensed_Ab.map_iso begin\n refine functor.associator _ _ _ ≪≫ _,\n refine iso_whisker_right _ _,\n refine (Condensed_Ab_to_presheaf.map_biproduct _),\n end\n\ndef component_pos (M : Condensed.{u} Ab.{u+1}) (i : ℕ) :\n ((BD.eval' freeCond').obj M).X (int.of_nat (i+1)) ≅\n ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).X\n (int.of_nat (i+1)) :=\nis_zero.iso (is_zero_zero _) (functor.map_is_zero _ $ is_zero_zero _)\n\ndef component_neg (M : Condensed.{u} Ab.{u+1}) (i : ℕ) :\n ((BD.eval' freeCond').obj M).X (-[1+i]) ≅\n ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).X\n (-[1+i]) :=\npresheaf_to_Condensed_Ab.map_iso begin\n refine functor.associator _ _ _ ≪≫ _,\n refine iso_whisker_right _ _,\n refine (Condensed_Ab_to_presheaf.map_biproduct _),\n end\n\nend eval_freeCond'_iso\n\nopen_locale big_operators\nopen category_theory.preadditive\n\nlemma eval_freeCond'_iso_component_aux₀ (M : Condensed.{u} Ab.{u+1}) :\n (eval_freeCond'_iso.component_neg BD M 0).hom ≫\n ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).d\n -[1+ 0] (int.of_nat 0) =\n ((BD.eval' freeCond').obj M).d -[1+ 0] (int.of_nat 0) ≫\n (eval_freeCond'_iso.component_zero BD M).hom :=\nbegin\n dsimp [eval_freeCond'_iso.component_neg, eval_freeCond'_iso.component_zero, package.eval',\n homological_complex.embed, homological_complex.embed.obj],\n erw homological_complex.embed.d_some_some,\n erw homological_complex.embed.d_some_some,\n dsimp [data.eval_functor', universal_map.eval_Pow],\n simp_rw free_abelian_group.lift_eq_sum,\n simp only [nat_trans.app_sum, nat_trans.app_zsmul],\n --dsimp,\n rw [functor.map_sum, sum_comp, comp_sum],\n refine finset.sum_congr rfl _, rintro x -,\n rw [functor.map_zsmul, zsmul_comp, comp_zsmul],\n refine congr_arg2 _ rfl _,\n dsimp,\n rw ← presheaf_to_Condensed_Ab.map_comp,\n erw ← presheaf_to_Condensed_Ab.map_comp,\n congr' 1,\n ext t : 2, dsimp only [nat_trans.comp_app, whisker_right_app, functor.associator],\n simp only [category.id_comp, category.comp_id],\n simp only [← functor.map_comp],\n congr' 1, simp only [← nat_trans.comp_app], congr' 1,\n apply biproduct.hom_ext, intros j,\n simp only [category.assoc, biproduct.matrix_π, biproduct.lift_π],\n dsimp only [functor.map_bicone],\n rw biproduct.lift_desc,\n erw [← Condensed_Ab_to_presheaf.map_comp, biproduct.matrix_π],\n simp_rw [comp_zsmul, category.comp_id, ← functor.map_zsmul, ← functor.map_sum],\n congr' 1,\n apply biproduct.hom_ext', intros k,\n rw [biproduct.ι_desc, comp_sum],\n rw finset.sum_eq_single_of_mem k (finset.mem_univ _),\n { simp },\n { rintros b - hb, dsimp, rw comp_zsmul, rw biproduct.ι_π,\n rw [dif_neg hb.symm, zsmul_zero] }\nend\n\nlemma eval_freeCond'_iso_component_aux_i (M : Condensed.{u} Ab.{u+1}) (i : ℕ) :\n(eval_freeCond'_iso.component_neg BD M (i+1)).hom ≫\n ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).d\n -[1+ (i+1)] -[1+ i] =\n ((BD.eval' freeCond').obj M).d -[1+ (i+1)] -[1+ i] ≫\n (eval_freeCond'_iso.component_neg BD M i).hom :=\nbegin\n dsimp [eval_freeCond'_iso.component_neg, eval_freeCond'_iso.component_zero, package.eval',\n homological_complex.embed, homological_complex.embed.obj],\n erw homological_complex.embed.d_some_some,\n erw homological_complex.embed.d_some_some,\n dsimp [data.eval_functor', universal_map.eval_Pow],\n simp_rw free_abelian_group.lift_eq_sum,\n simp only [nat_trans.app_sum, nat_trans.app_zsmul],\n --dsimp,\n rw [functor.map_sum, sum_comp, comp_sum],\n refine finset.sum_congr rfl _, rintro x -,\n rw [functor.map_zsmul, zsmul_comp, comp_zsmul],\n refine congr_arg2 _ rfl _,\n dsimp,\n rw ← presheaf_to_Condensed_Ab.map_comp,\n erw ← presheaf_to_Condensed_Ab.map_comp,\n congr' 1,\n ext t : 2, dsimp only [nat_trans.comp_app, whisker_right_app, functor.associator],\n simp only [category.id_comp, category.comp_id],\n simp only [← functor.map_comp],\n congr' 1, simp only [← nat_trans.comp_app], congr' 1,\n apply biproduct.hom_ext, intros j,\n simp only [category.assoc, biproduct.matrix_π, biproduct.lift_π],\n dsimp only [functor.map_bicone],\n rw biproduct.lift_desc,\n erw [← Condensed_Ab_to_presheaf.map_comp, biproduct.matrix_π],\n simp_rw [comp_zsmul, category.comp_id, ← functor.map_zsmul, ← functor.map_sum],\n congr' 1,\n apply biproduct.hom_ext', intros k,\n rw [biproduct.ι_desc, comp_sum],\n rw finset.sum_eq_single_of_mem k (finset.mem_univ _),\n { simp },\n { rintros b - hb, dsimp, rw comp_zsmul, rw biproduct.ι_π,\n rw [dif_neg hb.symm, zsmul_zero] }\nend\n\ndef eval_freeCond'_iso_component (M : Condensed.{u} Ab.{u+1}) :\n ((BD.eval' freeCond').obj M) ≅\n (presheaf_to_Condensed_Ab.map_homological_complex _).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M)) :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| int.of_nat 0 := eval_freeCond'_iso.component_zero _ _\n| int.of_nat (i+1) := eval_freeCond'_iso.component_pos _ _ _\n| -[1+i] := eval_freeCond'_iso.component_neg _ _ _\nend )\nbegin\n rintros ((_|i)|(_|i)) ((_|j)|(_|j)) ⟨rfl⟩,\n { apply is_zero.eq_of_tgt,\n apply functor.map_is_zero,\n apply is_zero_zero },\n { apply is_zero.eq_of_tgt,\n apply functor.map_is_zero,\n apply is_zero_zero },\n { apply eval_freeCond'_iso_component_aux₀ },\n { apply eval_freeCond'_iso_component_aux_i },\n { apply eval_freeCond'_iso_component_aux_i },\nend\n.\n\nlemma eval_freeCond'_iso_component_hom_zero (M : Condensed.{u} Ab.{u+1}) :\n (eval_freeCond'_iso_component BD M).hom.f 0 =\n begin\n refine presheaf_to_Condensed_Ab.map _,\n refine _ ≫ (functor.associator _ _ _).hom,\n refine whisker_right _ _,\n refine whisker_right _ _,\n refine (Condensed_Ab_to_presheaf.map_biproduct _).hom,\n end := rfl\n\nlemma eval_freeCond'_iso_component_hom_neg (M : Condensed.{u} Ab.{u+1}) (i : ℕ) :\n (eval_freeCond'_iso_component BD M).hom.f (-[1+i]) =\n begin\n refine presheaf_to_Condensed_Ab.map _,\n refine _ ≫ (functor.associator _ _ _).hom,\n refine whisker_right _ _,\n refine whisker_right _ _,\n refine (Condensed_Ab_to_presheaf.map_biproduct _).hom,\n end := rfl\n\nnamespace eval_freeAb_iso\n\ndef component_zero (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) :\n ((((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj\n (op S.val)).map_homological_complex (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).X (int.of_nat 0) ≅\n ((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).obj (M.val.obj (op S.val))).X\n (int.of_nat 0) :=\nbegin\n refine AddCommGroup.free.map_iso _,\n refine (category_theory.forget _).map_iso _,\n refine ((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op S.val)).map_biproduct _\nend\n\ndef component_pos (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) (i : ℕ) :\n ((((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj\n (op S.val)).map_homological_complex (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).X\n (int.of_nat (i + 1)) ≅\n ((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).obj\n (M.val.obj (op S.val))).X (int.of_nat (i + 1)) :=\nis_zero.iso (functor.map_is_zero _ $ is_zero_zero _) (is_zero_zero _)\n\ndef component_neg (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) (i : ℕ) :\n ((((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op S.val)).map_homological_complex\n (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).X -[1+ i] ≅\n ((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).obj (M.val.obj (op S.val))).X -[1+ i] :=\nbegin\n refine AddCommGroup.free.map_iso _,\n refine (category_theory.forget _).map_iso _,\n refine ((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op S.val)).map_biproduct _\nend\n\nend eval_freeAb_iso\n\nlocal attribute [-simp] forget_map_eq_coe\n\nlemma eval_freeAb_iso_component_aux₀ (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) :\n (eval_freeAb_iso.component_neg BD M S 0).hom ≫\n ((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).obj (M.val.obj (op S.val))).d\n -[1+ 0] (int.of_nat 0) =\n ((((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op S.val)).map_homological_complex\n (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).d -[1+ 0] (int.of_nat 0) ≫\n (eval_freeAb_iso.component_zero BD M S).hom :=\nbegin\n dsimp only [eval_freeAb_iso.component_neg, eval_freeAb_iso.component_zero, functor.map_iso,\n package.eval', data.eval_functor', functor.map_homological_complex,\n category_theory.evaluation, functor.comp_obj, homological_complex.embed,\n homological_complex.embed.obj],\n erw homological_complex.embed.d_some_some,\n erw homological_complex.embed.d_some_some,\n dsimp only [data.eval_functor, data.eval_functor', functor.comp_obj, functor.flip,\n homological_complex.functor_eval, homological_complex.functor_eval.obj,\n category_theory.evaluation, functor.map_homological_complex,\n universal_map.eval_Pow_functor, universal_map.eval_Pow, functor.map_biproduct],\n simp only [free_abelian_group.lift_eq_sum, sum_comp, comp_sum, nat_trans.app_sum],\n apply finset.sum_congr rfl, rintro x -,\n simp only [nat_trans.app_zsmul],\n dsimp [functor.map_bicone],\n simp only [zsmul_comp, comp_zsmul, ← functor.map_comp], congr' 3,\n apply biproduct.hom_ext, intros j,\n simp only [category.assoc, biproduct.lift_π, biproduct.matrix_π, biproduct.lift_desc],\n erw biproduct.lift_π,\n rw [← nat_trans.comp_app, biproduct.matrix_π],\n simp_rw [← nat_trans.id_app, ← nat_trans.app_zsmul, ← nat_trans.comp_app,\n ← nat_trans.app_sum], congr' 1,\n apply biproduct.hom_ext', intro k, simp only [comp_sum, biproduct.ι_desc],\n rw [finset.sum_eq_single_of_mem k (finset.mem_univ _),\n biproduct.ι_π_assoc, dif_pos rfl],\n { simpa, },\n { rintros b - hb, rw [biproduct.ι_π_assoc, dif_neg hb.symm, zero_comp] }\nend\n\nlemma eval_freeAb_iso_component_aux (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) (i : ℕ) :\n (eval_freeAb_iso.component_neg BD M S (i+1)).hom ≫\n ((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).obj\n (M.val.obj (op S.val))).d -[1+ (i+1)] -[1+ i] =\n ((((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj\n (op S.val)).map_homological_complex (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).d -[1+ (i+1)] -[1+ i] ≫\n (eval_freeAb_iso.component_neg BD M S i).hom :=\nbegin\n dsimp only [eval_freeAb_iso.component_neg, eval_freeAb_iso.component_zero, functor.map_iso,\n package.eval', data.eval_functor', functor.map_homological_complex,\n category_theory.evaluation, functor.comp_obj, homological_complex.embed,\n homological_complex.embed.obj],\n erw homological_complex.embed.d_some_some,\n erw homological_complex.embed.d_some_some,\n dsimp only [data.eval_functor, data.eval_functor', functor.comp_obj, functor.flip,\n homological_complex.functor_eval, homological_complex.functor_eval.obj,\n category_theory.evaluation, functor.map_homological_complex,\n universal_map.eval_Pow_functor, universal_map.eval_Pow, functor.map_biproduct],\n simp only [free_abelian_group.lift_eq_sum, sum_comp, comp_sum, nat_trans.app_sum],\n apply finset.sum_congr rfl, rintro x -,\n simp only [nat_trans.app_zsmul],\n dsimp [functor.map_bicone],\n simp only [zsmul_comp, comp_zsmul, ← functor.map_comp], congr' 3,\n apply biproduct.hom_ext, intros j,\n simp only [category.assoc, biproduct.lift_π, biproduct.matrix_π, biproduct.lift_desc],\n erw biproduct.lift_π,\n rw [← nat_trans.comp_app, biproduct.matrix_π],\n simp_rw [← nat_trans.id_app, ← nat_trans.app_zsmul, ← nat_trans.comp_app,\n ← nat_trans.app_sum], congr' 1,\n apply biproduct.hom_ext', intro k, simp only [comp_sum, biproduct.ι_desc],\n rw [finset.sum_eq_single_of_mem k (finset.mem_univ _),\n biproduct.ι_π_assoc, dif_pos rfl],\n { simpa, },\n { rintros b - hb, rw [biproduct.ι_π_assoc, dif_neg hb.symm, zero_comp] }\nend\n\ndef eval_freeAb_iso_component (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) :\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj (op S.val)).map_homological_complex\n (complex_shape.up ℤ)).obj\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M)) ≅\n (BD.eval' $ category_theory.forget _ ⋙ AddCommGroup.free).obj (M.val.obj (op S.val)) :=\nhomological_complex.hom.iso_of_components\n(λ i,\nmatch i with\n| int.of_nat 0 := eval_freeAb_iso.component_zero _ _ _\n| int.of_nat (i+1) := eval_freeAb_iso.component_pos _ _ _ _\n| -[1+i] := eval_freeAb_iso.component_neg _ _ _ _\nend )\nbegin\n rintros ((_|i)|(_|i)) ((_|j)|(_|j)) ⟨rfl⟩,\n { apply is_zero.eq_of_tgt,\n apply is_zero_zero },\n { apply is_zero.eq_of_tgt,\n apply is_zero_zero },\n { apply eval_freeAb_iso_component_aux₀ },\n { apply eval_freeAb_iso_component_aux },\n { apply eval_freeAb_iso_component_aux },\nend\n.\n\n@[simp]\nlemma eval_freeAb_iso_component_zero (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) :\n (eval_freeAb_iso_component BD M S).hom.f 0 =\n (eval_freeAb_iso.component_zero BD M S).hom := rfl\n\n@[simp]\nlemma eval_freeAb_iso_component_neg (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) (i : ℕ) :\n (eval_freeAb_iso_component BD M S).hom.f (-[1+i]) =\n (eval_freeAb_iso.component_neg BD M S i).hom := rfl\n\nlemma eval_freeCond'_iso_aux_zero\n (X Y : Condensed Ab) (f : X ⟶ Y) :\n ((BD.eval' freeCond').map f ≫ (eval_freeCond'_iso_component BD Y).hom).f (int.of_nat 0) =\n ((eval_freeCond'_iso_component BD X).hom ≫\n (Condensed_Ab_to_presheaf ⋙\n BD.eval' freeFunc ⋙ presheaf_to_Condensed_Ab.map_homological_complex\n (complex_shape.up ℤ)).map f).f (int.of_nat 0) :=\nbegin\n dsimp only [\n homological_complex.hom.iso_of_components,\n homological_complex.comp_f, package.eval', data.eval_functor', data.eval_functor,\n functor.comp_map, int.of_nat_zero,\n homological_complex.embed_nat_obj_down_up_zero_f,\n homological_complex.comp_f, functor.map_homological_complex_map_f,\n functor.comp_obj, functor.flip,\n homological_complex.functor_eval, universal_map.eval_Pow_functor,\n functor.map_homological_complex],\n rw eval_freeCond'_iso_component_hom_zero,\n rw eval_freeCond'_iso_component_hom_zero,\n dsimp,\n rw ← presheaf_to_Condensed_Ab.map_comp,\n erw ← presheaf_to_Condensed_Ab.map_comp,\n congr' 1, -- we got rid of the sheafification :)\n ext t : 2,\n dsimp,\n simp only [category.id_comp, category.comp_id, ← functor.map_comp],\n congr' 2,\n simp_rw ← nat_trans.comp_app, congr' 1,\n dsimp [functor.map_bicone],\n apply biproduct.hom_ext, intros j,\n simp only [category.assoc, biproduct.map_π, biproduct.lift_π_assoc, biproduct.lift_π],\n erw [← Condensed_Ab_to_presheaf.map_comp, ← Condensed_Ab_to_presheaf.map_comp,\n biproduct.map_π],\nend\n\n.\n\nlemma eval_freeAb_iso_component_naturality (M : Condensed.{u} Ab.{u+1}) (S T : ExtrDisc.{u})\n (f : S ⟶ T) :\n (eval_freeAb_iso_component BD M T).hom ≫\n (BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).map\n (M.val.map (ExtrDisc_to_Profinite.map f).op) =\n (nat_trans.map_homological_complex ((category_theory.evaluation Profiniteᵒᵖ Ab).map f.val.op)\n (complex_shape.up ℤ)).app ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))\n ≫ (eval_freeAb_iso_component BD M S).hom :=\nbegin\n ext ((_|i)|i) : 2,\n { change AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) ≫ AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) =\n AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) ≫ AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _),\n simp only [← functor.map_comp], congr' 2,\n apply biproduct.hom_ext, rintro ⟨j⟩,\n dsimp [functor.map_bicone],\n simp only [category.assoc],\n erw biproduct.lift_π,\n erw biproduct.map_π,\n erw biproduct.lift_π_assoc,\n simp only [nat_trans.naturality],\n refl },\n { apply is_zero.eq_of_tgt,\n apply is_zero_zero },\n { change AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) ≫ AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) =\n AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) ≫ AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _),\n simp only [← functor.map_comp], congr' 2,\n apply biproduct.hom_ext, rintro ⟨j⟩,\n dsimp [functor.map_bicone],\n simp only [category.assoc],\n erw biproduct.lift_π,\n erw biproduct.map_π,\n erw biproduct.lift_π_assoc,\n simp only [nat_trans.naturality],\n refl },\nend\n\nlemma eval_freeCond'_iso_aux_neg\n (X Y : Condensed Ab) (f : X ⟶ Y) (i : ℕ) :\n ((BD.eval' freeCond').map f ≫ (eval_freeCond'_iso_component BD Y).hom).f (-[1+i]) =\n ((eval_freeCond'_iso_component BD X).hom ≫\n (Condensed_Ab_to_presheaf ⋙\n BD.eval' freeFunc ⋙ presheaf_to_Condensed_Ab.map_homological_complex\n (complex_shape.up ℤ)).map f).f (-[1+i]) :=\nbegin\n dsimp only [\n homological_complex.hom.iso_of_components,\n homological_complex.comp_f, package.eval', data.eval_functor', data.eval_functor,\n functor.comp_map, int.of_nat_zero,\n homological_complex.embed_nat_obj_down_up_zero_f,\n homological_complex.comp_f, functor.map_homological_complex_map_f,\n functor.comp_obj, functor.flip,\n homological_complex.functor_eval, universal_map.eval_Pow_functor,\n functor.map_homological_complex],\n rw eval_freeCond'_iso_component_hom_neg,\n rw eval_freeCond'_iso_component_hom_neg,\n dsimp,\n rw ← presheaf_to_Condensed_Ab.map_comp,\n erw ← presheaf_to_Condensed_Ab.map_comp,\n congr' 1, -- we got rid of the sheafification :)\n ext t : 2,\n dsimp,\n simp only [category.id_comp, category.comp_id, ← functor.map_comp],\n congr' 2,\n simp_rw ← nat_trans.comp_app, congr' 1,\n dsimp [functor.map_bicone],\n apply biproduct.hom_ext, intros j,\n simp only [category.assoc, biproduct.map_π, biproduct.lift_π_assoc, biproduct.lift_π],\n erw [← Condensed_Ab_to_presheaf.map_comp, ← Condensed_Ab_to_presheaf.map_comp,\n biproduct.map_π],\nend\n\ndef eval_freeCond'_iso :\n BD.eval' freeCond' ≅\n Condensed_Ab_to_presheaf ⋙ BD.eval' freeFunc ⋙ presheaf_to_Condensed_Ab.map_homological_complex _ :=\nnat_iso.of_components\n(λ M, eval_freeCond'_iso_component _ _)\nbegin\n intros X Y f,\n ext ((_|i)|i) : 2,\n { apply eval_freeCond'_iso_aux_zero },\n { apply is_zero.eq_of_src, apply is_zero_zero },\n { apply eval_freeCond'_iso_aux_neg },\nend\n\ndef eval_freeAb_iso (S : ExtrDisc.{u}) :\n Condensed_Ab_to_presheaf ⋙ BD.eval' freeFunc ⋙\n ((category_theory.evaluation _ _).obj (op S.val)).map_homological_complex _ ≅\n evaluation _ S.val ⋙ BD.eval' (category_theory.forget _ ⋙ AddCommGroup.free) :=\nnat_iso.of_components\n(λ M, eval_freeAb_iso_component _ _ _)\nbegin\n intros X Y f,\n ext ((_|i)|i) : 2,\n { change AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) ≫ AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) =\n AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) ≫ AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _),\n simp only [← functor.map_comp], congr' 2,\n apply biproduct.hom_ext, intros j,\n dsimp [functor.map_bicone],\n simp only [category.assoc, biproduct.map_π, biproduct.lift_π],\n erw biproduct.lift_π_assoc,\n erw biproduct.lift_π,\n simp_rw [← nat_trans.comp_app, biproduct.map_π],\n refl },\n { apply is_zero.eq_of_tgt, apply is_zero_zero },\n { change AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) ≫ AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) =\n AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) ≫ AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _),\n simp only [← functor.map_comp], congr' 2,\n apply biproduct.hom_ext, intros j,\n dsimp [functor.map_bicone],\n simp only [category.assoc, biproduct.map_π, biproduct.lift_π],\n erw biproduct.lift_π_assoc,\n erw biproduct.lift_π,\n simp_rw [← nat_trans.comp_app, biproduct.map_π],\n refl },\nend\n\n-- Move this.\ndef point {A : Type u} (a : A) : punit.{u+1} ⟶ A := λ _, a\n\ndef tensor_to_unsheafified_homology_component_applied\n (M : Condensed.{u} Ab.{u+1}) (i : ℤ) (S : ExtrDisc.{u}) (m : M.val.obj (op S.val)) :\n ((BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).obj\n (AddCommGroup.free.obj punit)).val.as.homology i ⟶\n (homological_complex.homology ((BD.eval' freeFunc).obj\n (Condensed_Ab_to_presheaf.obj M)) i).obj (op S.val) :=\n(homotopy_category.homology_functor _ _ _).map\n ((BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).map\n ((AddCommGroup.adj.hom_equiv _ _).symm (point m))) ≫\n (homology_functor _ _ _).map (eval_freeAb_iso_component _ _ _).inv ≫\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj\n (op S.val)).homology_functor_iso _ _).inv.app _\n\nopen category_theory.preadditive\n\ndef tensor_to_unsheafified_homology_component (M : Condensed.{u} Ab.{u+1}) (i : ℤ)\n (S : ExtrDisc.{u}) :\n M.val.obj (op S.val) ⟶\n AddCommGroup.of\n (((BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).obj\n (AddCommGroup.free.obj punit)).val.as.homology i ⟶\n (homological_complex.homology ((BD.eval' freeFunc).obj\n (Condensed_Ab_to_presheaf.obj M)) i).obj (op S.val)) :=\nadd_monoid_hom.mk' (λ m, tensor_to_unsheafified_homology_component_applied _ _ _ _ m)\nbegin\n intros x y, rcases i with ((_|i)|i),\n { erw [← add_comp, ← functor.map_add, ← functor.map_add], apply congr_arg2 _ _ rfl, congr' 2,\n dsimp only [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv],\n ext ⟨⟩, simp only [equiv.symm_symm, add_monoid_hom.add_apply, free_abelian_group.lift.of],\n refl },\n { apply is_zero.eq_of_src,\n apply is_zero.homology_is_zero, apply is_zero_zero },\n { erw [← add_comp, ← functor.map_add, ← functor.map_add], apply congr_arg2 _ _ rfl, congr' 2,\n dsimp only [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv],\n ext ⟨⟩, simp only [equiv.symm_symm, add_monoid_hom.add_apply, free_abelian_group.lift.of],\n refl },\nend\n.\n\nlemma tensor_to_unsheafified_homology_natural (M : Condensed.{u} Ab.{u+1}) (i : ℤ) (S T : ExtrDiscᵒᵖ)\n (f : S ⟶ T)\n (x : (((ExtrSheaf_ExtrSheafProd_equiv Ab).functor.obj\n ((Condensed_ExtrSheaf_equiv Ab).inverse.obj M)).val.obj S)) :\n ((tensor_to_unsheafified_homology_component_applied BD M i (unop T)) ((M.val.map f.unop.val.op) x)) =\n ((tensor_to_unsheafified_homology_component_applied BD M i (unop S)) x) ≫\n ((homological_complex.homology ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M)) i).map f.unop.val.op) :=\nbegin\n dsimp only [tensor_to_unsheafified_homology_component_applied],\n rw [← nat_iso.app_inv, ← category.assoc, iso.comp_inv_eq],\n simp only [category.assoc],\n have := functor.naturality_homology_functor_iso\n ((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).map (ExtrDisc_to_Profinite.op.map f))\n (complex_shape.up ℤ) i,\n apply_fun (λ e, e.app ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))) at this,\n dsimp [-homology_functor_map] at this, simp only [category.id_comp, category.comp_id] at this,\n erw this, rw [← nat_iso.app_inv, ← nat_iso.app_hom, iso.inv_hom_id_assoc],\n clear this,\n rw [← functor.map_iso_inv, ← category.assoc, iso.comp_inv_eq, category.assoc, category.assoc],\n dsimp [-homology_functor_map], simp only [← functor.map_comp],\n rw [← eval_freeAb_iso_component_naturality, iso.inv_hom_id_assoc],\n have :\n ((AddCommGroup.adj.hom_equiv punit (M.val.obj (op (unop T).val))).symm)\n (point ((M.val.map f.unop.val.op) x)) =\n (((AddCommGroup.adj.hom_equiv punit (M.val.obj (op (unop S).val))).symm) (point x)) ≫\n (M.val.map (ExtrDisc_to_Profinite.map f.unop).op),\n { ext ⟨⟩,\n dsimp only [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv, equiv.symm,\n equiv.to_fun_as_coe],\n simp only [comp_apply],\n erw free_abelian_group.lift.of,\n erw free_abelian_group.lift.of,\n refl },\n rw [this, functor.map_comp],\n erw [functor.map_comp],\n refl,\nend\n\ndef tensor_to_unsheafified_homology (M : Condensed.{u} Ab.{u+1}) (i : ℤ) :\n (((Condensed_ExtrSheaf_equiv Ab).inverse.obj M).tensor\n (((BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).obj\n (AddCommGroup.free.obj punit)).val.as.homology i)).val ⟶\n ExtrDisc_to_Profinite.op ⋙ homological_complex.homology\n ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M)) i :=\n{ app := λ S, AddCommGroup.tensor_uncurry $\n tensor_to_unsheafified_homology_component _ _ _ _,\n naturality' := λ S T f, begin\n apply AddCommGroup.tensor_ext, intros x y,\n dsimp only [ExtrSheaf.tensor, ExtrSheafProd.tensor,\n ExtrSheaf_ExtrSheafProd_equiv, ExtrSheafProd.tensor_presheaf_map,\n AddCommGroup.map_tensor, AddCommGroup.tensor_uncurry],\n erw [comp_apply, comp_apply, tensor_product.map_tmul,\n tensor_product.lift.tmul, tensor_product.lift.tmul],\n dsimp only [add_monoid_hom.coe_to_int_linear_map, linear_map.comp_apply,\n add_monoid_hom.coe_mk, functor.comp_map, Condensed_ExtrSheaf_equiv_inverse_val,\n ExtrDisc_to_Profinite_map, functor.op_map, tensor_to_unsheafified_homology_component,\n add_monoid_hom.mk'_apply],\n erw [id_apply, ← comp_apply], congr' 1,\n apply tensor_to_unsheafified_homology_natural,\n end }\n\ndef plain_eval_comparison_component (i : ℤ) (A : AddCommGroup.{u+1}) :\n A ⟶ AddCommGroup.of\n ((homotopy_category.homology_functor _ _ i).obj\n ((BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).obj (AddCommGroup.free.obj punit)).val ⟶\n (homotopy_category.homology_functor _ _ i).obj\n ((BD.eval (category_theory.forget AddCommGroup ⋙ AddCommGroup.free)).obj A).val) :=\nadd_monoid_hom.mk' (λ a, (homotopy_category.homology_functor _ _ _).map $ (BD.eval _).map $\n (AddCommGroup.adj.hom_equiv _ _).symm (point a))\nbegin\n intros x y, rw [← functor.map_add, ← functor.map_add], congr' 2,\n dsimp only [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv],\n ext ⟨⟩, simp only [equiv.symm_symm, add_monoid_hom.add_apply, free_abelian_group.lift.of],\n refl\nend\n\nlemma plain_eval_comparison_natural (i : ℤ) (A B : AddCommGroup.{u+1}) (f : A ⟶ B) (x) :\n ((plain_eval_comparison_component BD i B) (f x)) =\n ((plain_eval_comparison_component BD i A) x) ≫\n (homotopy_category.homology_functor AddCommGroup (complex_shape.up ℤ) i).map\n ((BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).map f) :=\nbegin\n dsimp only [plain_eval_comparison_component, add_monoid_hom.mk'_apply, functor.comp_map],\n rw [← functor.map_comp], congr' 1,\n erw [← (BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).map_comp], congr' 1,\n dsimp only [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv, equiv.symm, equiv.coe_fn_mk,\n equiv.to_fun_as_coe],\n ext ⟨⟩,\n simp only [free_abelian_group.lift.of, comp_apply],\n refl,\nend\n\nlemma plain_eval_comparison_natural' (i : ℤ) (A B : AddCommGroup.{u+1}) (f : A ⟶ B) :\n (AddCommGroup.tensor_functor.flip.obj\n (homological_complex.homology\n ((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).obj (AddCommGroup.free.obj punit)) i)).map f ≫\n AddCommGroup.tensor_uncurry (plain_eval_comparison_component BD i B) =\n AddCommGroup.tensor_uncurry (plain_eval_comparison_component BD i A) ≫\n (BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free) ⋙\n homology_functor AddCommGroup (complex_shape.up ℤ) i).map f :=\nbegin\n apply AddCommGroup.tensor_ext, intros x y,\n rw [comp_apply, comp_apply],\n dsimp only [functor.flip_obj_map, AddCommGroup.tensor_functor_map_app],\n delta AddCommGroup.tensor_uncurry AddCommGroup.map_tensor,\n dsimp only [linear_map.to_add_monoid_hom_coe],\n rw [tensor_product.map_tmul, tensor_product.lift.tmul, tensor_product.lift.tmul],\n dsimp only [add_monoid_hom.coe_to_int_linear_map, linear_map.comp_apply,\n add_monoid_hom.coe_mk],\n rw [plain_eval_comparison_natural],\n refl\nend\n\ndef plain_eval_comparison (i : ℤ) :\n AddCommGroup.tensor_functor.flip.obj\n (((BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free)).obj\n (AddCommGroup.free.obj punit)).homology i) ⟶\n BD.eval' (forget AddCommGroup ⋙ AddCommGroup.free) ⋙ homology_functor _ _ i :=\n{ app := λ A, AddCommGroup.tensor_uncurry $ plain_eval_comparison_component _ _ _,\n naturality' := λ A B f, by apply plain_eval_comparison_natural' }\n\nlocal attribute [-simp] homology_functor_map\n\nlemma tensor_to_unsheafified_homology_app_eq\n (M : Condensed.{u} Ab.{u+1}) (i : ℤ) (S : ExtrDisc.{u}) :\n (tensor_to_unsheafified_homology BD M i).app (op S) =\n (plain_eval_comparison BD i).app (M.val.obj (op S.val)) ≫\n (homology_functor _ _ _).map\n ((eval_freeAb_iso_component _ _ _).inv) ≫\n (((category_theory.evaluation Profinite.{u}ᵒᵖ Ab.{u+1}).obj\n (op S.val)).homology_functor_iso _ _).inv.app _ :=\nbegin\n rw [← nat_iso.app_inv, ← category.assoc, iso.eq_comp_inv, ← functor.map_iso_inv,\n iso.eq_comp_inv, category.assoc, functor.map_iso_hom, nat_iso.app_hom],\n apply_fun AddCommGroup.tensor_curry_equiv _ _ _,\n swap, apply add_equiv.injective,\n dsimp [plain_eval_comparison, tensor_to_unsheafified_homology],\n rw AddCommGroup.tensor_curry_uncurry,\n rw AddCommGroup.tensor_curry_uncurry_comp,\n ext x y,\n dsimp [plain_eval_comparison_component,\n tensor_to_unsheafified_homology_component],\n simp only [comp_apply],\n dsimp [preadditive_yoneda],\n simp only [comp_apply],\n dsimp [tensor_to_unsheafified_homology_component_applied],\n simp only [← comp_apply, category.assoc],\n dsimp only [← nat_iso.app_inv, ← nat_iso.app_hom],\n simp only [iso.inv_hom_id_assoc],\n congr' 2,\n simp only [← category.assoc],\n congr' 1,\n simp only [category.assoc, iso.inv_hom_id, category.comp_id,\n ← functor.map_iso_hom, ← functor.map_iso_inv],\nend\n\ndef tensor_to_homology_aux (M : Condensed.{u} Ab.{u+1}) (i : ℤ) :\n((Condensed_ExtrSheaf_equiv Ab).inverse.obj M).tensor\n (((BD.eval (forget AddCommGroup ⋙ AddCommGroup.free)).obj\n (AddCommGroup.free.obj punit)).val.as.homology i) ⟶\n (presheaf_to_Sheaf ExtrDisc.proetale_topology Ab).obj\n (ExtrDisc_to_Profinite.op ⋙\n homological_complex.homology ((BD.eval' freeFunc).obj\n (Condensed_Ab_to_presheaf.obj M)) i) := Sheaf.hom.mk $\ntensor_to_unsheafified_homology _ _ _ ≫ grothendieck_topology.to_sheafify _ _\n\ndef tensor_to_homology (M : Condensed.{u} Ab.{u+1}) (i : ℤ) :\n (tensor M $ ((BD.eval $\n category_theory.forget AddCommGroup ⋙ AddCommGroup.free).obj\n (AddCommGroup.free.obj punit)).val.as.homology i) ⟶\n ((BD.eval freeCond').obj M).val.as.homology i :=\n(Condensed_ExtrSheaf_equiv Ab).functor.map\n (tensor_to_homology_aux _ _ _ ≫ ExtrDisc_sheafification_iso.hom.app _)\n≫ ((Condensed_ExtrSheaf_equiv _).counit_iso.app _).hom\n≫ (homology_functor_sheafification_iso _ _).hom.app _\n≫ (homology_functor _ _ _).map (eval_freeCond'_iso_component _ _).inv\n\n.\n\ninstance preserves_filtered_colimits_tensor_flip (A) :\n preserves_filtered_colimits (AddCommGroup.tensor_functor.flip.obj A) :=\ninfer_instance\n\ninstance preserves_filtered_colimits_tensor_flip_eval' (i : ℤ) :\n preserves_filtered_colimits\n (AddCommGroup.tensor_functor.flip.obj (homological_complex.homology\n ((BD.eval' (forget AddCommGroup.{u+1} ⋙ AddCommGroup.free)).obj\n (AddCommGroup.free.obj punit)) i)) :=\nCondensed.preserves_filtered_colimits_tensor_flip _\n\nset_option pp.universes true\n\ninstance additive_tensor_flip (A : AddCommGroup.{u}) : functor.additive\n (AddCommGroup.tensor_functor.flip.obj A) :=\n{ map_add' := λ X Y f g, begin\n dsimp [AddCommGroup.map_tensor], ext x,\n dsimp only [linear_map.to_add_monoid_hom_coe, add_monoid_hom.add_apply],\n rw [← linear_map.add_apply],\n congr' 1, apply tensor_product.ext', intros x y,\n apply tensor_product.add_tmul,\n end }\n\ninstance additive_tensor_flip_eval' (i : ℤ) : functor.additive\n (AddCommGroup.tensor_functor.flip.obj (homological_complex.homology\n ((BD.eval' (forget AddCommGroup.{u+1} ⋙ AddCommGroup.free)).obj\n (AddCommGroup.free.obj punit)) i)) :=\nCondensed.additive_tensor_flip _\n\n-- move me\ninstance AddCommGroup.free_preserves_limits : preserves_colimits AddCommGroup.free :=\nAddCommGroup.adj.left_adjoint_preserves_colimits\n\ninstance preserves_filtered_colimits_eval'_forget_free :\n preserves_filtered_colimits.{u+1 u+2 u+2}\n (BD.eval' (forget.{u+2 u+1 u+1} AddCommGroup.{u+1} ⋙ AddCommGroup.free.{u+1})) :=\nbegin\n apply_with limits.comp_preserves_filtered_colimits.{u+1 u+2 _ u+2} {instances:=ff},\n { apply_with data.eval_functor_preserves_filtered_colimits {instances:=ff},\n apply limits.comp_preserves_filtered_colimits.{u+1 u+2 _ u+2}, },\n { constructor,\n intro J,\n introI,\n introI,\n apply_instance, },\nend\n\ninstance preserves_filtered_colimits_homology (i : ℤ) :\n preserves_filtered_colimits.{u+1 u+2 u+2}\n (homology_functor.{u+1 u+2 0} AddCommGroup.{u+1} (complex_shape.up.{0} ℤ) i) :=\n⟨λ J, begin\n introI,\n introI,\n constructor,\n intro K,\n apply_instance,\nend⟩\n\ninstance preserves_filtered_colimits_eval'_forget_free_homology (i : ℤ) :\n preserves_filtered_colimits\n (BD.eval' (forget AddCommGroup.{u+1} ⋙ AddCommGroup.free) ⋙\n homology_functor AddCommGroup.{u+1} (complex_shape.up ℤ) i) :=\nlimits.comp_preserves_filtered_colimits.{u+1 u+2 _ u+2}\n (BD.eval' (forget AddCommGroup.{u+1} ⋙ AddCommGroup.free))\n (homology_functor AddCommGroup.{u+1} (complex_shape.up ℤ) i)\n\ninstance _root_.bounded_homotopy_category.forget_additive (𝓐 : Type*) [category 𝓐] [abelian 𝓐] :\n (bounded_homotopy_category.forget 𝓐).additive :=\n{ map_add' := λ X Y f g, rfl }\n\ninstance additive_eval'_forget_free (i : ℤ) : functor.additive\n (BD.eval' (forget AddCommGroup.{u+1} ⋙ AddCommGroup.free) ⋙\n homology_functor AddCommGroup.{u+1} (complex_shape.up ℤ) i) :=\nbegin\n show functor.additive (\n (BD.eval (forget AddCommGroup.{u+1} ⋙ AddCommGroup.free) ⋙ bounded_homotopy_category.forget _) ⋙\n homotopy_category.homology_functor _ _ i),\n exact functor.comp.additive (package.eval BD (forget AddCommGroup ⋙ AddCommGroup.free) ⋙ forget AddCommGroup)\n (homotopy_category.homology_functor AddCommGroup (complex_shape.up ℤ) i)\nend\n.\n\nlemma coeff_star_smul (x : free_abelian_group.{u} punit) :\n free_abelian_group.coeff punit.star x • free_abelian_group.of.{u} punit.star = x :=\nbegin\n refine free_abelian_group.induction_on'' x _ _ _; clear x,\n { simp only [map_zero, zero_smul], },\n { rintro n hn ⟨⟩, simp only [map_zsmul, free_abelian_group.coeff_of_self, smul_assoc, one_smul], },\n { rintro x n hn ⟨⟩ hx IH1 IH2, simp only [map_add, add_smul, IH1, IH2], },\nend\n\nlemma AddCommGroup.adj_hom_equiv_punit (a) :\n ((AddCommGroup.adj.{u+1}.hom_equiv punit.{u+2}\n (AddCommGroup.free.{u+1}.obj punit.{u+2})).symm) (point.{u+1} a) =\n (free_abelian_group.coeff punit.star a) • 𝟙 _ :=\nbegin\n dsimp only [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv, equiv.symm, equiv.coe_fn_mk, equiv.to_fun_as_coe],\n ext ⟨⟩,\n rw [free_abelian_group.lift.of, add_monoid_hom.smul_apply, id_apply, coeff_star_smul],\n refl\nend\n\nlemma homology_functor.map_id_bo_ho_ca {𝓐 : Type*} [category 𝓐] [abelian 𝓐] [enough_projectives 𝓐]\n (X : bounded_homotopy_category 𝓐) (i : ℤ) :\n (homotopy_category.homology_functor _ (complex_shape.up ℤ) i).map (𝟙 X : _) =\n 𝟙 ((homotopy_category.homology_functor _ (complex_shape.up ℤ) i).obj X.val) :=\ncategory_theory.functor.map_id _ _\n\nlemma plain_eval_comparison_is_iso_aux (A : AddCommGroup) :\n is_iso (AddCommGroup.tensor_uncurry $ add_monoid_hom.mk' (λ (a : (AddCommGroup.free.obj punit)),\n (free_abelian_group.coeff punit.star) a • 𝟙 A) $ by intros; simp only [map_add, add_smul]) :=\nbegin\n constructor,\n refine ⟨add_monoid_hom.mk' (λ a, free_abelian_group.of punit.star ⊗ₜ a) _, _, _⟩,\n { intros, rw tensor_product.tmul_add, },\n { apply AddCommGroup.tensor_ext, intros x y,\n erw [comp_apply, id_apply],\n dsimp only [AddCommGroup.tensor_uncurry, add_monoid_hom.mk'_apply,\n linear_map.to_add_monoid_hom_coe],\n rw [tensor_product.lift.tmul],\n dsimp only [add_monoid_hom.coe_to_int_linear_map, linear_map.comp_apply,\n add_monoid_hom.coe_mk, add_monoid_hom.mk'_apply, add_monoid_hom.smul_apply],\n rw [← tensor_product.smul_tmul, id_apply, coeff_star_smul], },\n { ext a, rw [id_apply, comp_apply],\n dsimp only [AddCommGroup.tensor_uncurry, add_monoid_hom.mk'_apply,\n linear_map.to_add_monoid_hom_coe],\n rw [tensor_product.lift.tmul],\n dsimp only [add_monoid_hom.coe_to_int_linear_map, linear_map.comp_apply,\n add_monoid_hom.coe_mk, add_monoid_hom.mk'_apply, add_monoid_hom.smul_apply],\n rw [free_abelian_group.coeff_of_self, one_smul], refl }\nend\n\ninstance (i : ℤ) : is_iso ((plain_eval_comparison BD i).app\n (AddCommGroup.free.obj (punit : Type (u+1)))) :=\nbegin\n dsimp only [plain_eval_comparison, plain_eval_comparison_component],\n simp only [AddCommGroup.adj_hom_equiv_punit, functor.map_smul,\n category_theory.functor.map_id, homology_functor.map_id_bo_ho_ca],\n apply plain_eval_comparison_is_iso_aux\nend\n\nlemma AddCommGroup.free_punit_is_tensor_unit :\n (AddCommGroup.free.{u+1}.obj punit.{u+2}).is_tensor_unit :=\nbegin\n constructor, intros B, swap, exact free_abelian_group.of punit.star,\n split, { intros f g h, ext ⟨⟩, exact h },\n intros b, refine ⟨free_abelian_group.lift (point b), _⟩,\n dsimp only, rw [free_abelian_group.lift.of], refl,\nend\n\ninstance is_iso_map_tensor_to_homology_aux_comp (M : Condensed.{u} Ab.{u+1}) (i : ℤ)\n [∀ S : ExtrDisc.{u}, no_zero_smul_divisors ℤ (M.val.obj (op S.val))] :\n is_iso (tensor_to_homology_aux BD M i) :=\nbegin\n suffices : ∀ (X : ExtrDisc), is_iso ((tensor_to_unsheafified_homology BD M i).app (op X)),\n { resetI,\n apply Sheaf.is_iso_of_eval _ (tensor_to_homology_aux BD M i)\n (tensor_to_unsheafified_homology _ _ _) rfl },\n intros S,\n rw tensor_to_unsheafified_homology_app_eq,\n suffices : is_iso ((plain_eval_comparison BD i).app (M.val.obj (op S.val))),\n { resetI, apply is_iso.comp_is_iso },\n apply AddCommGroup.is_iso_of_preserves_of_is_tensor_unit.{u+1 u+2} _ _\n (plain_eval_comparison BD i) (AddCommGroup.free.obj punit),\n apply AddCommGroup.free_punit_is_tensor_unit,\nend\n\ninstance is_iso_tensor_to_homology (M : Condensed.{u} Ab.{u+1}) (i : ℤ)\n [∀ S : ExtrDisc.{u}, no_zero_smul_divisors ℤ (M.val.obj (op S.val))] :\n is_iso (tensor_to_homology BD M i) :=\nbegin\n dsimp only [tensor_to_homology],\n apply is_iso.comp_is_iso,\nend\n\ndef homology_bd_eval (M : Condensed.{u} Ab.{u+1})\n [∀ S : ExtrDisc.{u}, no_zero_smul_divisors ℤ (M.val.obj (op S.val))] (i : ℤ) :\n ((BD.eval freeCond').obj M).val.as.homology i ≅\n (tensor M $ ((BD.eval $\n category_theory.forget AddCommGroup ⋙ AddCommGroup.free).obj\n (AddCommGroup.free.obj punit)).val.as.homology i) :=\n(as_iso (tensor_to_homology BD M i)).symm\n\nsection\nvariables (M N : Condensed.{u} Ab.{u+1}) (f : M ⟶ N)\n\nset_option pp.universes false\n\n@[simp] lemma embed_f_0 {𝓐 : Type*} [category 𝓐] [abelian 𝓐]\n {X Y : chain_complex 𝓐 ℕ} (f : X ⟶ Y) :\n ((homological_complex.embed complex_shape.embedding.nat_down_int_up).map f).f 0 = f.f 0 := rfl\n\n@[simp] lemma embed_f_neg {𝓐 : Type*} [category 𝓐] [abelian 𝓐]\n {X Y : chain_complex 𝓐 ℕ} (f : X ⟶ Y) (n : ℕ) :\n ((homological_complex.embed complex_shape.embedding.nat_down_int_up).map f).f -[1+ n] = f.f (n+1) := rfl\n\nlemma eval_freeCond'_iso_component_zero_natural :\n (eval_freeCond'_iso.component_zero BD M).inv ≫ ((BD.eval' freeCond').map f).f 0 =\n ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up ℤ)).map\n ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))).f 0 ≫\n (eval_freeCond'_iso.component_zero BD N).inv :=\nbegin\n dsimp only [eval_freeCond'_iso.component_zero, package.eval',\n functor.map_iso_trans, iso.trans_inv, functor.map_iso_inv,\n iso_whisker_right_inv,\n functor.map_homological_complex_map_f, functor.comp_map,\n functor.comp_obj, functor.flip_obj_map, homological_complex.functor_eval,\n embed_f_0, data.eval_functor, data.eval_functor'_obj_X_map],\n simp only [functor.map_biproduct, category.assoc],\n simp only [biproduct.unique_up_to_iso_inv, functor.map_comp,\n Condensed_Ab_to_CondensedSet_map, CondensedSet_to_Condensed_Ab_map,\n whisker_right_twice, category.assoc, whiskering_right_obj_map],\n dsimp only [presheaf_to_Condensed_Ab],\n simp only [← functor.map_comp], congr' 1,\n ext t : 2, dsimp only [nat_trans.comp_app, whisker_right_app, functor.associator],\n simp only [category.id_comp, category.comp_id],\n simp only [← functor.map_comp], congr' 1,\n simp only [← nat_trans.comp_app], congr' 1,\n apply biproduct.hom_ext', intros j,\n simp only [category.assoc, biproduct.ι_desc_assoc, biproduct.ι_desc,\n biproduct.ι_map_assoc],\n dsimp only [functor.map_bicone, Condensed_Ab_to_presheaf, ← Sheaf_to_presheaf_map],\n simp only [← functor.map_comp], congr' 1,\n erw biproduct.ι_map,\nend\n\nlemma eval_freeCond'_iso_component_neg_natural (n : ℕ) :\n (eval_freeCond'_iso.component_neg BD M n).inv ≫ ((BD.eval' freeCond').map f).f (-[1+ n]) =\n ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up ℤ)).map\n ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))).f -[1+ n] ≫\n (eval_freeCond'_iso.component_neg BD N n).inv :=\nbegin\n dsimp only [eval_freeCond'_iso.component_neg, package.eval',\n functor.map_iso_trans, iso.trans_inv, functor.map_iso_inv,\n iso_whisker_right_inv,\n functor.map_homological_complex_map_f, functor.comp_map,\n functor.comp_obj, functor.flip_obj_map, homological_complex.functor_eval,\n embed_f_neg, data.eval_functor, data.eval_functor'_obj_X_map],\n simp only [functor.map_biproduct, category.assoc],\n simp only [biproduct.unique_up_to_iso_inv, functor.map_comp,\n Condensed_Ab_to_CondensedSet_map, CondensedSet_to_Condensed_Ab_map,\n whisker_right_twice, category.assoc, whiskering_right_obj_map],\n dsimp only [presheaf_to_Condensed_Ab],\n simp only [← functor.map_comp], congr' 1,\n ext t : 2, dsimp only [nat_trans.comp_app, whisker_right_app, functor.associator],\n simp only [category.id_comp, category.comp_id],\n simp only [← functor.map_comp], congr' 1,\n simp only [← nat_trans.comp_app], congr' 1,\n apply biproduct.hom_ext', intros j,\n simp only [category.assoc, biproduct.ι_desc_assoc, biproduct.ι_desc,\n biproduct.ι_map_assoc],\n dsimp only [functor.map_bicone, Condensed_Ab_to_presheaf, ← Sheaf_to_presheaf_map],\n simp only [← functor.map_comp], congr' 1,\n erw biproduct.ι_map,\nend\n\nlemma eval_freeCond'_iso_component_natural :\n (eval_freeCond'_iso_component.{u} BD M).inv ≫ (BD.eval' freeCond'.{u}).map f =\n (presheaf_to_Condensed_Ab.{u}.map_homological_complex (complex_shape.up.{0} ℤ)).map\n ((BD.eval' freeFunc.{u u+1}).map (Condensed_Ab_to_presheaf.{u}.map f)) ≫\n (eval_freeCond'_iso_component.{u} BD N).inv :=\nbegin\n ext ((_|n)|n) : 2,\n { apply eval_freeCond'_iso_component_zero_natural },\n { apply is_zero.eq_of_tgt, exact is_zero_zero _, },\n { apply eval_freeCond'_iso_component_neg_natural },\nend\n\nend\n\nend Condensed\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/condensed/Qprime_isoms.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.588889130767832, "lm_q2_score": 0.34510527769342453, "lm_q1q2_score": 0.20322874700427204}} {"text": "import topology.category.CompHaus\n\nnamespace CompHaus\n\nopen category_theory\n\nnoncomputable instance : limits.preserves_limits (forget CompHaus) :=\nby apply limits.comp_preserves_limits CompHaus_to_Top (forget Top)\n\n@[simp] lemma coe_id (X : CompHaus) : (𝟙 X : X → X) = id := rfl\n@[simp] lemma coe_comp {A B C : CompHaus} (f : A ⟶ B) (g : B ⟶ C) :\n (f ≫ g : A → C) = g ∘ f := rfl\n\nlemma coe_id_apply {X : CompHaus} (x : X) : (𝟙 X : X → X) x = x := by simp\nlemma coe_comp_apply {X Y Z : CompHaus} (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :\n (f ≫ g) x = g (f x) := by simp\n\nend CompHaus\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/CompHaus.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.39981164073979497, "lm_q1q2_score": 0.2030290946446028}} {"text": "/-\nCopyright (c) 2019 Scott Morrison. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Scott Morrison, Justus Springer\n-/\nimport topology.category.Top.open_nhds\nimport topology.sheaves.presheaf\nimport topology.sheaves.sheaf_condition.unique_gluing\nimport category_theory.adjunction.evaluation\nimport category_theory.limits.types\nimport category_theory.limits.preserves.filtered\nimport category_theory.limits.final\nimport tactic.elementwise\nimport algebra.category.Ring.colimits\nimport category_theory.sites.pushforward\n\n/-!\n# Stalks\n\nFor a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F`\nat the point `x : X` is defined as the colimit of the composition of the inclusion of categories\n`(nhds x)ᵒᵖ ⥤ (opens X)ᵒᵖ` and the functor `F : (opens X)ᵒᵖ ⥤ C`.\nFor an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the\ncanonical morphism into this colimit.\n\nTaking stalks is functorial: For every point `x : X` we define a functor `stalk_functor C x`,\nsending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between\ntopological spaces, we define `stalk_pushforward` as the induced map on the stalks\n`(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`.\n\nSome lemmas about stalks and germs only hold for certain classes of concrete categories. A basic\nproperty of forgetful functors of categories of algebraic structures (like `Mon`, `CommRing`,...)\nis that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that\nthe stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves.\nFor example, in `germ_exist` we prove that in such a category, every element of the stalk is the\ngerm of a section.\n\nFurthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as\nis the case for most algebraic structures), we have access to the unique gluing API and can prove\nfurther properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such\na category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are\nisomorphisms.\n\nSee also the definition of \"algebraic structures\" in the stacks project:\nhttps://stacks.math.columbia.edu/tag/007L\n\n-/\n\nnoncomputable theory\n\nuniverses v u v' u'\n\nopen category_theory\nopen Top\nopen category_theory.limits\nopen topological_space\nopen opposite\n\nvariables {C : Type u} [category.{v} C]\n\nvariables [has_colimits.{v} C]\n\nvariables {X Y Z : Top.{v}}\n\nnamespace Top.presheaf\n\nvariables (C)\n/-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/\ndef stalk_functor (x : X) : X.presheaf C ⥤ C :=\n((whiskering_left _ _ C).obj (open_nhds.inclusion x).op) ⋙ colim\n\nvariables {C}\n\n/--\nThe stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor\nnbhds x ⥤ opens F.X ⥤ C\n-/\ndef stalk (ℱ : X.presheaf C) (x : X) : C :=\n(stalk_functor C x).obj ℱ -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ)\n\n@[simp] lemma stalk_functor_obj (ℱ : X.presheaf C) (x : X) :\n (stalk_functor C x).obj ℱ = ℱ.stalk x := rfl\n\n/--\nThe germ of a section of a presheaf over an open at a point of that open.\n-/\ndef germ (F : X.presheaf C) {U : opens X} (x : U) : F.obj (op U) ⟶ stalk F x :=\ncolimit.ι ((open_nhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩)\n\n@[simp, elementwise]\nlemma germ_res (F : X.presheaf C) {U V : opens X} (i : U ⟶ V) (x : U) :\n F.map i.op ≫ germ F x = germ F (i x : V) :=\nlet i' : (⟨U, x.2⟩ : open_nhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i in\ncolimit.w ((open_nhds.inclusion x.1).op ⋙ F) i'.op\n\n/--\nA morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its\ncomposition with the `germ` morphisms.\n-/\nlemma stalk_hom_ext (F : X.presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y}\n (ih : ∀ (U : opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ :=\ncolimit.hom_ext $ λ U, by { induction U using opposite.rec, cases U with U hxU, exact ih U hxU }\n\n@[simp, reassoc, elementwise]\nlemma stalk_functor_map_germ {F G : X.presheaf C} (U : opens X) (x : U)\n (f : F ⟶ G) : germ F x ≫ (stalk_functor C x.1).map f = f.app (op U) ≫ germ G x :=\ncolimit.ι_map (whisker_left ((open_nhds.inclusion x.1).op) f) (op ⟨U, x.2⟩)\n\nvariables (C)\n\n/--\nFor a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the\nstalk of `f _ * F` at `f x` and the stalk of `F` at `x`.\n-/\ndef stalk_pushforward (f : X ⟶ Y) (F : X.presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x :=\nbegin\n -- This is a hack; Lean doesn't like to elaborate the term written directly.\n transitivity,\n swap,\n exact colimit.pre _ (open_nhds.map f x).op,\n exact colim.map (whisker_right (nat_trans.op (open_nhds.inclusion_map_iso f x).inv) F),\nend\n\n@[simp, elementwise, reassoc]\nlemma stalk_pushforward_germ (f : X ⟶ Y) (F : X.presheaf C) (U : opens Y)\n (x : (opens.map f).obj U) :\n (f _* F).germ ⟨f x, x.2⟩ ≫ F.stalk_pushforward C f x = F.germ x :=\nbegin\n rw [stalk_pushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whisker_right_app],\n erw [category_theory.functor.map_id, category.id_comp],\n refl,\nend\n\n-- Here are two other potential solutions, suggested by @fpvandoorn at\n-- \n-- However, I can't get the subsequent two proofs to work with either one.\n\n-- def stalk_pushforward (f : X ⟶ Y) (ℱ : X.presheaf C) (x : X) :\n-- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x :=\n-- colim.map ((functor.associator _ _ _).inv ≫\n-- whisker_right (nat_trans.op (open_nhds.inclusion_map_iso f x).inv) ℱ) ≫\n-- colimit.pre ((open_nhds.inclusion x).op ⋙ ℱ) (open_nhds.map f x).op\n\n-- def stalk_pushforward (f : X ⟶ Y) (ℱ : X.presheaf C) (x : X) :\n-- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x :=\n-- (colim.map (whisker_right (nat_trans.op (open_nhds.inclusion_map_iso f x).inv) ℱ) :\n-- colim.obj ((open_nhds.inclusion (f x) ⋙ opens.map f).op ⋙ ℱ) ⟶ _) ≫\n-- colimit.pre ((open_nhds.inclusion x).op ⋙ ℱ) (open_nhds.map f x).op\n\nnamespace stalk_pushforward\nlocal attribute [tidy] tactic.op_induction'\n\n@[simp] lemma id (ℱ : X.presheaf C) (x : X) :\n ℱ.stalk_pushforward C (𝟙 X) x = (stalk_functor C x).map ((pushforward.id ℱ).hom) :=\nbegin\n dsimp [stalk_pushforward, stalk_functor],\n ext1,\n tactic.op_induction',\n rcases j with ⟨⟨_, _⟩, _⟩,\n rw [colimit.ι_map_assoc, colimit.ι_map, colimit.ι_pre, whisker_left_app, whisker_right_app,\n pushforward.id_hom_app, eq_to_hom_map, eq_to_hom_refl],\n dsimp,\n -- FIXME A simp lemma which unfortunately doesn't fire:\n erw [category_theory.functor.map_id],\nend\n\n-- This proof is sadly not at all robust:\n-- having to use `erw` at all is a bad sign.\n@[simp] lemma comp (ℱ : X.presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) :\n ℱ.stalk_pushforward C (f ≫ g) x =\n ((f _* ℱ).stalk_pushforward C g (f x)) ≫ (ℱ.stalk_pushforward C f x) :=\nbegin\n dsimp [stalk_pushforward, stalk_functor],\n ext U,\n induction U using opposite.rec,\n rcases U with ⟨⟨_, _⟩, _⟩,\n simp only [colimit.ι_map_assoc, colimit.ι_pre_assoc,\n whisker_right_app, category.assoc],\n dsimp,\n -- FIXME: Some of these are simp lemmas, but don't fire successfully:\n erw [category_theory.functor.map_id, category.id_comp, category.id_comp, category.id_comp,\n colimit.ι_pre, colimit.ι_pre],\n refl,\nend\n\nlemma stalk_pushforward_iso_of_open_embedding {f : X ⟶ Y} (hf : open_embedding f)\n (F : X.presheaf C) (x : X) : is_iso (F.stalk_pushforward _ f x) :=\n begin\n haveI := functor.initial_of_adjunction (hf.is_open_map.adjunction_nhds x),\n convert is_iso.of_iso ((functor.final.colimit_iso (hf.is_open_map.functor_nhds x).op\n ((open_nhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.map_iso _),\n swap,\n { fapply nat_iso.of_components,\n { intro U,\n refine F.map_iso (eq_to_iso _),\n dsimp only [functor.op],\n exact congr_arg op (opens.ext $ set.preimage_image_eq (unop U).1.1 hf.inj) },\n { intros U V i, erw [← F.map_comp, ← F.map_comp], congr } },\n { ext U,\n rw ← iso.comp_inv_eq,\n erw colimit.ι_map_assoc,\n rw [colimit.ι_pre, category.assoc],\n erw [colimit.ι_map_assoc, colimit.ι_pre, ← F.map_comp_assoc],\n apply colimit.w ((open_nhds.inclusion (f x)).op ⋙ f _* F) _,\n dsimp only [functor.op],\n refine ((hom_of_le _).op : op (unop U) ⟶ _),\n exact set.image_preimage_subset _ _ },\n end\n\nend stalk_pushforward\n\nsection stalk_pullback\n\n/-- The morphism `ℱ_{f x} ⟶ (f⁻¹ℱ)ₓ` that factors through `(f_*f⁻¹ℱ)_{f x}`. -/\ndef stalk_pullback_hom (f : X ⟶ Y) (F : Y.presheaf C) (x : X) :\n F.stalk (f x) ⟶ (pullback_obj f F).stalk x :=\n(stalk_functor _ (f x)).map ((pushforward_pullback_adjunction C f).unit.app F) ≫\n stalk_pushforward _ _ _ x\n\n/-- The morphism `(f⁻¹ℱ)(U) ⟶ ℱ_{f(x)}` for some `U ∋ x`. -/\ndef germ_to_pullback_stalk (f : X ⟶ Y) (F : Y.presheaf C) (U : opens X) (x : U) :\n (pullback_obj f F).obj (op U) ⟶ F.stalk (f x) :=\ncolimit.desc (Lan.diagram (opens.map f).op F (op U))\n{ X := F.stalk (f x),\n ι := { app := λ V, F.germ ⟨f x, V.hom.unop.le x.2⟩,\n naturality' := λ _ _ i, by { erw category.comp_id, exact F.germ_res i.left.unop _ } } }\n\n/-- The morphism `(f⁻¹ℱ)ₓ ⟶ ℱ_{f(x)}`. -/\ndef stalk_pullback_inv (f : X ⟶ Y) (F : Y.presheaf C) (x : X) :\n (pullback_obj f F).stalk x ⟶ F.stalk (f x) :=\ncolimit.desc ((open_nhds.inclusion x).op ⋙ presheaf.pullback_obj f F)\n{ X := F.stalk (f x),\n ι := { app := λ U, F.germ_to_pullback_stalk _ f (unop U).1 ⟨x, (unop U).2⟩,\n naturality' := λ _ _ _, by { erw [colimit.pre_desc, category.comp_id], congr } } }\n\n/-- The isomorphism `ℱ_{f(x)} ≅ (f⁻¹ℱ)ₓ`. -/\ndef stalk_pullback_iso (f : X ⟶ Y) (F : Y.presheaf C) (x : X) :\n F.stalk (f x) ≅ (pullback_obj f F).stalk x :=\n{ hom := stalk_pullback_hom _ _ _ _,\n inv := stalk_pullback_inv _ _ _ _,\n hom_inv_id' :=\n begin\n delta stalk_pullback_hom stalk_pullback_inv stalk_functor presheaf.pullback stalk_pushforward\n germ_to_pullback_stalk germ,\n ext j,\n induction j using opposite.rec,\n cases j,\n simp only [topological_space.open_nhds.inclusion_map_iso_inv, whisker_right_app,\n whisker_left_app, whiskering_left_obj_map, functor.comp_map, colimit.ι_map_assoc,\n nat_trans.op_id, Lan_obj_map, pushforward_pullback_adjunction_unit_app_app, category.assoc,\n colimit.ι_pre_assoc],\n erw [colimit.ι_desc, colimit.pre_desc, colimit.ι_desc, category.comp_id],\n simpa\n end,\n inv_hom_id' :=\n begin\n delta stalk_pullback_hom stalk_pullback_inv stalk_functor presheaf.pullback stalk_pushforward,\n ext U j,\n induction U using opposite.rec,\n cases U, cases j, rcases j_right with ⟨⟨⟩⟩,\n erw [colimit.map_desc, colimit.map_desc, colimit.ι_desc_assoc,\n colimit.ι_desc_assoc, colimit.ι_desc, category.comp_id],\n simp only [cocone.whisker_ι, colimit.cocone_ι, open_nhds.inclusion_map_iso_inv,\n cocones.precompose_obj_ι, whisker_right_app, whisker_left_app, nat_trans.comp_app,\n whiskering_left_obj_map, nat_trans.op_id, Lan_obj_map,\n pushforward_pullback_adjunction_unit_app_app],\n erw ←colimit.w _\n (@hom_of_le (open_nhds x) _\n ⟨_, U_property⟩ ⟨(opens.map f).obj (unop j_left), j_hom.unop.le U_property⟩\n j_hom.unop.le).op,\n erw colimit.ι_pre_assoc (Lan.diagram _ F _) (costructured_arrow.map _),\n erw colimit.ι_pre_assoc (Lan.diagram _ F _) (costructured_arrow.map _),\n congr,\n simp only [category.assoc, costructured_arrow.map_mk],\n delta costructured_arrow.mk,\n congr,\n end }\n\nend stalk_pullback\n\nsection stalk_specializes\n\nvariables {C}\n\n/-- If `x` specializes to `y`, then there is a natural map `F.stalk y ⟶ F.stalk x`. -/\nnoncomputable\ndef stalk_specializes (F : X.presheaf C) {x y : X} (h : x ⤳ y) : F.stalk y ⟶ F.stalk x :=\nbegin\n refine colimit.desc _ ⟨_,λ U, _,_⟩,\n { exact colimit.ι ((open_nhds.inclusion x).op ⋙ F)\n (op ⟨(unop U).1, (specializes_iff_forall_open.mp h _ (unop U).1.2 (unop U).2 : _)⟩) },\n { intros U V i,\n dsimp,\n rw category.comp_id,\n let U' : open_nhds x := ⟨_, (specializes_iff_forall_open.mp h _ (unop U).1.2 (unop U).2 : _)⟩,\n let V' : open_nhds x := ⟨_, (specializes_iff_forall_open.mp h _ (unop V).1.2 (unop V).2 : _)⟩,\n exact colimit.w ((open_nhds.inclusion x).op ⋙ F) (show V' ⟶ U', from i.unop).op }\nend\n\n@[simp, reassoc, elementwise]\nlemma germ_stalk_specializes (F : X.presheaf C) {U : opens X} {y : U} {x : X} (h : x ⤳ y) :\n F.germ y ≫ F.stalk_specializes h =\n F.germ (⟨x, h.mem_open U.is_open y.prop⟩ : U) := colimit.ι_desc _ _\n\n@[simp, reassoc, elementwise]\nlemma germ_stalk_specializes' (F : X.presheaf C) {U : opens X} {x y : X} (h : x ⤳ y) (hy : y ∈ U) :\n F.germ ⟨y, hy⟩ ≫ F.stalk_specializes h =\n F.germ ⟨x, h.mem_open U.is_open hy⟩ := colimit.ι_desc _ _\n\n@[simp]\nlemma stalk_specializes_refl {C : Type*} [category C] [limits.has_colimits C]\n {X : Top} (F : X.presheaf C) (x : X) :\n F.stalk_specializes (specializes_refl x) = 𝟙 _ :=\nF.stalk_hom_ext $ λ _ _, by { dsimp, simpa }\n\n@[simp, reassoc, elementwise]\nlemma stalk_specializes_comp {C : Type*} [category C] [limits.has_colimits C]\n {X : Top} (F : X.presheaf C)\n {x y z : X} (h : x ⤳ y) (h' : y ⤳ z) :\n F.stalk_specializes h' ≫ F.stalk_specializes h = F.stalk_specializes (h.trans h') :=\nF.stalk_hom_ext $ λ _ _, by simp\n\n@[simp, reassoc, elementwise]\nlemma stalk_specializes_stalk_functor_map {F G : X.presheaf C} (f : F ⟶ G) {x y : X} (h : x ⤳ y) :\n F.stalk_specializes h ≫ (stalk_functor C x).map f =\n (stalk_functor C y).map f ≫ G.stalk_specializes h :=\nby { ext, delta stalk_functor, simpa [stalk_specializes] }\n\n@[simp, reassoc, elementwise]\nlemma stalk_specializes_stalk_pushforward (f : X ⟶ Y) (F : X.presheaf C) {x y : X} (h : x ⤳ y) :\n (f _* F).stalk_specializes (f.map_specializes h) ≫ F.stalk_pushforward _ f x =\n F.stalk_pushforward _ f y ≫ F.stalk_specializes h :=\nby { ext, delta stalk_pushforward, simpa [stalk_specializes] }\n\n/-- The stalks are isomorphic on inseparable points -/\n@[simps]\ndef stalk_congr {X : Top} {C : Type*} [category C] [has_colimits C]\n (F : X.presheaf C) {x y : X}\n (e : inseparable x y) : F.stalk x ≅ F.stalk y :=\n⟨F.stalk_specializes e.ge, F.stalk_specializes e.le, by simp, by simp⟩\n\nend stalk_specializes\n\nsection concrete\n\nvariables {C}\nvariables [concrete_category.{v} C]\n\nlocal attribute [instance] concrete_category.has_coe_to_sort concrete_category.has_coe_to_fun\n\n@[ext]\nlemma germ_ext (F : X.presheaf C) {U V : opens X} {x : X} {hxU : x ∈ U} {hxV : x ∈ V}\n (W : opens X) (hxW : x ∈ W) (iWU : W ⟶ U) (iWV : W ⟶ V) {sU : F.obj (op U)} {sV : F.obj (op V)}\n (ih : F.map iWU.op sU = F.map iWV.op sV) :\n F.germ ⟨x, hxU⟩ sU = F.germ ⟨x, hxV⟩ sV :=\nby erw [← F.germ_res iWU ⟨x, hxW⟩,\n ← F.germ_res iWV ⟨x, hxW⟩, comp_apply, comp_apply, ih]\n\nvariables [preserves_filtered_colimits (forget C)]\n\n/--\nFor presheaves valued in a concrete category whose forgetful functor preserves filtered colimits,\nevery element of the stalk is the germ of a section.\n-/\nlemma germ_exist (F : X.presheaf C) (x : X) (t : stalk F x) :\n ∃ (U : opens X) (m : x ∈ U) (s : F.obj (op U)), F.germ ⟨x, m⟩ s = t :=\nbegin\n obtain ⟨U, s, e⟩ := types.jointly_surjective.{v v} _\n (is_colimit_of_preserves (forget C) (colimit.is_colimit _)) t,\n revert s e,\n rw [(show U = op (unop U), from rfl)],\n generalize : unop U = V, clear U,\n cases V with V m,\n intros s e,\n exact ⟨V, m, s, e⟩,\nend\n\nlemma germ_eq (F : X.presheaf C) {U V : opens X} (x : X) (mU : x ∈ U) (mV : x ∈ V)\n (s : F.obj (op U)) (t : F.obj (op V))\n (h : germ F ⟨x, mU⟩ s = germ F ⟨x, mV⟩ t) :\n ∃ (W : opens X) (m : x ∈ W) (iU : W ⟶ U) (iV : W ⟶ V), F.map iU.op s = F.map iV.op t :=\nbegin\n obtain ⟨W, iU, iV, e⟩ := (types.filtered_colimit.is_colimit_eq_iff.{v v} _\n (is_colimit_of_preserves _ (colimit.is_colimit ((open_nhds.inclusion x).op ⋙ F)))).mp h,\n exact ⟨(unop W).1, (unop W).2, iU.unop, iV.unop, e⟩,\nend\n\nlemma stalk_functor_map_injective_of_app_injective {F G : presheaf C X} (f : F ⟶ G)\n (h : ∀ U : opens X, function.injective (f.app (op U))) (x : X) :\n function.injective ((stalk_functor C x).map f) := λ s t hst,\nbegin\n rcases germ_exist F x s with ⟨U₁, hxU₁, s, rfl⟩,\n rcases germ_exist F x t with ⟨U₂, hxU₂, t, rfl⟩,\n simp only [stalk_functor_map_germ_apply _ ⟨x,_⟩] at hst,\n obtain ⟨W, hxW, iWU₁, iWU₂, heq⟩ := G.germ_eq x hxU₁ hxU₂ _ _ hst,\n rw [← comp_apply, ← comp_apply, ← f.naturality, ← f.naturality, comp_apply, comp_apply] at heq,\n replace heq := h W heq,\n convert congr_arg (F.germ ⟨x,hxW⟩) heq,\n exacts [(F.germ_res_apply iWU₁ ⟨x,hxW⟩ s).symm,\n (F.germ_res_apply iWU₂ ⟨x,hxW⟩ t).symm],\nend\n\n\nvariables [has_limits C] [preserves_limits (forget C)] [reflects_isomorphisms (forget C)]\n\n/--\nLet `F` be a sheaf valued in a concrete category, whose forgetful functor reflects isomorphisms,\npreserves limits and filtered colimits. Then two sections who agree on every stalk must be equal.\n-/\nlemma section_ext (F : sheaf C X) (U : opens X) (s t : F.1.obj (op U))\n (h : ∀ x : U, F.presheaf.germ x s = F.presheaf.germ x t) :\n s = t :=\nbegin\n -- We use `germ_eq` and the axiom of choice, to pick for every point `x` a neighbourhood\n -- `V x`, such that the restrictions of `s` and `t` to `V x` coincide.\n choose V m i₁ i₂ heq using λ x : U, F.presheaf.germ_eq x.1 x.2 x.2 s t (h x),\n -- Since `F` is a sheaf, we can prove the equality locally, if we can show that these\n -- neighborhoods form a cover of `U`.\n apply F.eq_of_locally_eq' V U i₁,\n { intros x hxU,\n rw [opens.mem_supr],\n exact ⟨⟨x, hxU⟩, m ⟨x, hxU⟩⟩ },\n { intro x,\n rw [heq, subsingleton.elim (i₁ x) (i₂ x)] }\nend\n\n/-\nNote that the analogous statement for surjectivity is false: Surjectivity on stalks does not\nimply surjectivity of the components of a sheaf morphism. However it does imply that the morphism\nis an epi, but this fact is not yet formalized.\n-/\nlemma app_injective_of_stalk_functor_map_injective {F : sheaf C X} {G : presheaf C X}\n (f : F.1 ⟶ G) (U : opens X) (h : ∀ x : U, function.injective ((stalk_functor C x.val).map f)) :\n function.injective (f.app (op U)) :=\nλ s t hst, section_ext F _ _ _ $ λ x, h x $ by\n rw [stalk_functor_map_germ_apply, stalk_functor_map_germ_apply, hst]\n\nlemma app_injective_iff_stalk_functor_map_injective {F : sheaf C X}\n {G : presheaf C X} (f : F.1 ⟶ G) :\n (∀ x : X, function.injective ((stalk_functor C x).map f)) ↔\n (∀ U : opens X, function.injective (f.app (op U))) :=\n⟨λ h U, app_injective_of_stalk_functor_map_injective f U (λ x, h x.1),\n stalk_functor_map_injective_of_app_injective f⟩\n\ninstance stalk_functor_preserves_mono (x : X) :\n functor.preserves_monomorphisms (sheaf.forget C X ⋙ stalk_functor C x) :=\n⟨λ 𝓐 𝓑 f m, concrete_category.mono_of_injective _ $\n (app_injective_iff_stalk_functor_map_injective f.1).mpr\n (λ c, (@@concrete_category.mono_iff_injective_of_preserves_pullback _ _ (f.1.app (op c)) _).mp\n ((nat_trans.mono_iff_mono_app _ f.1).mp\n (@@category_theory.presheaf_mono_of_mono _ _ _ _ _ _ _ _ _ _ _ m) $ op c)) x⟩\n\nlemma stalk_mono_of_mono {F G : sheaf C X} (f : F ⟶ G) [mono f] :\n Π x, mono $ (stalk_functor C x).map f.1 :=\nλ x, by convert functor.map_mono (sheaf.forget.{v} C X ⋙ stalk_functor C x) f\n\nlemma mono_of_stalk_mono {F G : sheaf C X} (f : F ⟶ G)\n [Π x, mono $ (stalk_functor C x).map f.1] : mono f :=\n(Sheaf.hom.mono_iff_presheaf_mono _ _ _).mpr $ (nat_trans.mono_iff_mono_app _ _).mpr $ λ U,\n (concrete_category.mono_iff_injective_of_preserves_pullback _).mpr $\n app_injective_of_stalk_functor_map_injective f.1 U.unop $ λ ⟨x, hx⟩,\n (concrete_category.mono_iff_injective_of_preserves_pullback _).mp $ infer_instance\n\n\n\n/-- For surjectivity, we are given an arbitrary section `t` and need to find a preimage for it.\nWe claim that it suffices to find preimages *locally*. That is, for each `x : U` we construct\na neighborhood `V ≤ U` and a section `s : F.obj (op V))` such that `f.app (op V) s` and `t`\nagree on `V`. -/\nlemma app_surjective_of_injective_of_locally_surjective {F G : sheaf C X} (f : F ⟶ G)\n (U : opens X) (hinj : ∀ x : U, function.injective ((stalk_functor C x.1).map f.1))\n (hsurj : ∀ (t) (x : U), ∃ (V : opens X) (m : x.1 ∈ V) (iVU : V ⟶ U) (s : F.1.obj (op V)),\n f.1.app (op V) s = G.1.map iVU.op t) :\n function.surjective (f.1.app (op U)) :=\nbegin\n intro t,\n -- We use the axiom of choice to pick around each point `x` an open neighborhood `V` and a\n -- preimage under `f` on `V`.\n choose V mV iVU sf heq using hsurj t,\n -- These neighborhoods clearly cover all of `U`.\n have V_cover : U ≤ supr V,\n { intros x hxU,\n rw [opens.mem_supr],\n exact ⟨⟨x, hxU⟩, mV ⟨x, hxU⟩⟩ },\n -- Since `F` is a sheaf, we can glue all the local preimages together to get a global preimage.\n obtain ⟨s, s_spec, -⟩ := F.exists_unique_gluing' V U iVU V_cover sf _,\n { use s,\n apply G.eq_of_locally_eq' V U iVU V_cover,\n intro x,\n rw [← comp_apply, ← f.1.naturality, comp_apply, s_spec, heq] },\n { intros x y,\n -- What's left to show here is that the secions `sf` are compatible, i.e. they agree on\n -- the intersections `V x ⊓ V y`. We prove this by showing that all germs are equal.\n apply section_ext,\n intro z,\n -- Here, we need to use injectivity of the stalk maps.\n apply (hinj ⟨z, (iVU x).le ((inf_le_left : V x ⊓ V y ≤ V x) z.2)⟩),\n dsimp only,\n erw [stalk_functor_map_germ_apply, stalk_functor_map_germ_apply],\n simp_rw [← comp_apply, f.1.naturality, comp_apply, heq, ← comp_apply, ← G.1.map_comp],\n refl }\nend\n\nlemma app_surjective_of_stalk_functor_map_bijective {F G : sheaf C X} (f : F ⟶ G)\n (U : opens X) (h : ∀ x : U, function.bijective ((stalk_functor C x.val).map f.1)) :\n function.surjective (f.1.app (op U)) :=\nbegin\n refine app_surjective_of_injective_of_locally_surjective f U (λ x, (h x).1) (λ t x, _),\n -- Now we need to prove our initial claim: That we can find preimages of `t` locally.\n -- Since `f` is surjective on stalks, we can find a preimage `s₀` of the germ of `t` at `x`\n obtain ⟨s₀,hs₀⟩ := (h x).2 (G.presheaf.germ x t),\n -- ... and this preimage must come from some section `s₁` defined on some open neighborhood `V₁`\n obtain ⟨V₁,hxV₁,s₁,hs₁⟩ := F.presheaf.germ_exist x.1 s₀,\n subst hs₁, rename hs₀ hs₁,\n erw stalk_functor_map_germ_apply V₁ ⟨x.1,hxV₁⟩ f.1 s₁ at hs₁,\n -- Now, the germ of `f.app (op V₁) s₁` equals the germ of `t`, hence they must coincide on\n -- some open neighborhood `V₂`.\n obtain ⟨V₂, hxV₂, iV₂V₁, iV₂U, heq⟩ := G.presheaf.germ_eq x.1 hxV₁ x.2 _ _ hs₁,\n -- The restriction of `s₁` to that neighborhood is our desired local preimage.\n use [V₂, hxV₂, iV₂U, F.1.map iV₂V₁.op s₁],\n rw [← comp_apply, f.1.naturality, comp_apply, heq],\nend\n\nlemma app_bijective_of_stalk_functor_map_bijective {F G : sheaf C X} (f : F ⟶ G)\n (U : opens X) (h : ∀ x : U, function.bijective ((stalk_functor C x.val).map f.1)) :\n function.bijective (f.1.app (op U)) :=\n⟨app_injective_of_stalk_functor_map_injective f.1 U (λ x, (h x).1),\n app_surjective_of_stalk_functor_map_bijective f U h⟩\n\nlemma app_is_iso_of_stalk_functor_map_iso {F G : sheaf C X} (f : F ⟶ G) (U : opens X)\n [∀ x : U, is_iso ((stalk_functor C x.val).map f.1)] : is_iso (f.1.app (op U)) :=\nbegin\n -- Since the forgetful functor of `C` reflects isomorphisms, it suffices to see that the\n -- underlying map between types is an isomorphism, i.e. bijective.\n suffices : is_iso ((forget C).map (f.1.app (op U))),\n { exactI is_iso_of_reflects_iso (f.1.app (op U)) (forget C) },\n rw is_iso_iff_bijective,\n apply app_bijective_of_stalk_functor_map_bijective,\n intro x,\n apply (is_iso_iff_bijective _).mp,\n exact functor.map_is_iso (forget C) ((stalk_functor C x.1).map f.1)\nend\n\n/--\nLet `F` and `G` be sheaves valued in a concrete category, whose forgetful functor reflects\nisomorphisms, preserves limits and filtered colimits. Then if the stalk maps of a morphism\n`f : F ⟶ G` are all isomorphisms, `f` must be an isomorphism.\n-/\n-- Making this an instance would cause a loop in typeclass resolution with `functor.map_is_iso`\nlemma is_iso_of_stalk_functor_map_iso {F G : sheaf C X} (f : F ⟶ G)\n [∀ x : X, is_iso ((stalk_functor C x).map f.1)] : is_iso f :=\nbegin\n -- Since the inclusion functor from sheaves to presheaves is fully faithful, it suffices to\n -- show that `f`, as a morphism between _presheaves_, is an isomorphism.\n suffices : is_iso ((sheaf.forget C X).map f),\n { exactI is_iso_of_fully_faithful (sheaf.forget C X) f },\n -- We show that all components of `f` are isomorphisms.\n suffices : ∀ U : (opens X)ᵒᵖ, is_iso (f.1.app U),\n { exact @nat_iso.is_iso_of_is_iso_app _ _ _ _ F.1 G.1 f.1 this, },\n intro U, induction U using opposite.rec,\n apply app_is_iso_of_stalk_functor_map_iso\nend\n\n/--\nLet `F` and `G` be sheaves valued in a concrete category, whose forgetful functor reflects\nisomorphisms, preserves limits and filtered colimits. Then a morphism `f : F ⟶ G` is an\nisomorphism if and only if all of its stalk maps are isomorphisms.\n-/\nlemma is_iso_iff_stalk_functor_map_iso {F G : sheaf C X} (f : F ⟶ G) :\n is_iso f ↔ ∀ x : X, is_iso ((stalk_functor C x).map f.1) :=\nbegin\n split,\n { intros h x, resetI,\n exact @functor.map_is_iso _ _ _ _ _ _ (stalk_functor C x) f.1\n ((sheaf.forget C X).map_is_iso f) },\n { intro h,\n exactI is_iso_of_stalk_functor_map_iso f }\nend\n\nend concrete\n\ninstance (F : X.presheaf CommRing) {U : opens X} (x : U) :\n algebra (F.obj $ op U) (F.stalk x) :=\n(F.germ x).to_algebra\n\n@[simp]\nlemma stalk_open_algebra_map {X : Top} (F : X.presheaf CommRing) {U : opens X} (x : U) :\n algebra_map (F.obj $ op U) (F.stalk x) = F.germ x := rfl\n\nend Top.presheaf\n", "meta": {"author": "leanprover-community", "repo": "mathlib", "sha": "5e526d18cea33550268dcbbddcb822d5cde40654", "save_path": "github-repos/lean/leanprover-community-mathlib", "path": "github-repos/lean/leanprover-community-mathlib/mathlib-5e526d18cea33550268dcbbddcb822d5cde40654/src/topology/sheaves/stalks.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.39981164073979497, "lm_q1q2_score": 0.2030290946446028}} {"text": "import category_theory.abelian.basic\nimport category_theory.preadditive.additive_functor\nimport for_mathlib.short_exact_sequence\nimport for_mathlib.abelian_category\nimport for_mathlib.exact_lift_desc\n\n/-!\n\nRefs:\n1. Grothendieck's Tôhoku paper\n2. Stacks tag 010T\n\n-/\n\nnoncomputable theory\nnamespace category_theory\n\nuniverses v v' u u'\nvariables (A : Type u) (B : Type u')\n [category.{v} A] [category.{v} B] [abelian A] [abelian B]\n\n/-- Cohomological covariant delta functor. -/\n@[nolint has_inhabited_instance]\nstructure delta_functor :=\n(F : ℕ → A ⥤ B)\n[additive : ∀ n, functor.additive (F n)]\n(δ : Π (n : ℕ),\n short_exact_sequence.Trd A ⋙ (F n) ⟶ short_exact_sequence.Fst A ⋙ (F (n+1)))\n(mono : ∀ (S : short_exact_sequence _), mono ((F 0).map S.f))\n(exact' : ∀ (n : ℕ) (S : short_exact_sequence _), exact ((F n).map S.f) ((F n).map S.g))\n(exact_δ : ∀ (n : ℕ) (S : short_exact_sequence _),\n exact ((F n).map S.g) ((δ n).app S))\n(δ_exact : ∀ (n : ℕ) (S : short_exact_sequence _),\n exact ((δ n).app S) ((F (n+1)).map S.f))\n\nnamespace delta_functor\n\ninfixr ` ⥤δ `:26 := delta_functor\n\ninstance : has_coe_to_fun (A ⥤δ B) (λ F, ℕ → (A ⥤ B)) := ⟨F⟩\n\ninstance additive_apply (F : A ⥤δ B) (n : ℕ) :\n functor.additive (F n) := F.additive n\n\nvariables {A B}\n\n/-- Morphisms of cohomological covariant delta functors. -/\n@[nolint has_inhabited_instance]\nstructure hom (F G : A ⥤δ B) :=\n(η : Π n, F n ⟶ G n)\n(comm' : ∀ n, F.δ n ≫ whisker_left _ (η _) = whisker_left _ (η _) ≫ G.δ _)\n\ninstance : quiver (A ⥤δ B) :=\n{ hom := hom }\n\nnamespace hom\n\ninstance {F G : A ⥤δ B} : has_coe_to_fun (F ⟶ G) (λ η, Π n, F n ⟶ G n) :=\n⟨η⟩\n\n@[ext]\nlemma ext {F G : A ⥤δ B} (η γ : F ⟶ G) (h : ∀ n, η n = γ n) : η = γ :=\nby { cases η, cases γ, congr, ext1, apply h }\n\n@[simp]\nlemma η_eq_coe {F G : A ⥤δ B} (η : F ⟶ G) (n : ℕ) :\n η.η n = η n := rfl\n\n@[simp, reassoc]\nlemma comm {F G : A ⥤δ B} (η : F ⟶ G) (n : ℕ) (S : short_exact_sequence A) :\n (F.δ n).app S ≫ (η (n+1)).app S.fst =\n (η n).app S.trd ≫ (G.δ n).app S :=\nbegin\n have := η.comm' n,\n apply_fun (λ e, e.app S) at this,\n exact this,\nend\n\n/-- Identity morphisms of delta functors. -/\ndef id (F : A ⥤δ B) : F ⟶ F :=\n⟨λ n, 𝟙 _, begin\n intros n,\n ext, dsimp,\n erw nat_trans.id_app,\n erw nat_trans.id_app,\n simp,\nend⟩\n\n@[simp]\nlemma id_apply (F : A ⥤δ B) (n : ℕ) :\n id F n = 𝟙 _ := rfl\n\n/-- Compositions of morphisms of delta functors. -/\ndef comp {F G H : A ⥤δ B} (η : F ⟶ G) (γ : G ⟶ H) :\n hom F H :=\n{ η := λ n, η n ≫ γ n,\n comm' := begin\n intros n, ext,\n dsimp,\n simp,\n end }\n\n@[simp]\nlemma comp_apply {F G H : A ⥤δ B} (η : F ⟶ G) (γ : G ⟶ H) (n : ℕ) :\n (hom.comp η γ) n = η n ≫ γ n := rfl\n\nend hom\n\n/-- delta functors form a category. -/\ninstance category : category (A ⥤δ B) :=\n{ id := λ F, hom.id _,\n comp := λ X Y Z F G, hom.comp F G,\n id_comp' := by { intros F G f, ext, dsimp, simp },\n comp_id' := by { intros F G f, ext, dsimp, simp },\n assoc' := by { intros F G H W a b c, ext, dsimp, simp },\n ..(infer_instance : quiver (A ⥤δ B)) }\n\n/-- Universal delta functors. -/\nclass universal (F : A ⥤δ B) : Prop :=\n(cond : ∀ (G : A ⥤δ B) (e0 : F 0 ⟶ G 0), ∃! e : F ⟶ G, (e : Π n, F n ⟶ G n) 0 = e0)\n\nnamespace tohoku\n\n/-- An effacement relative to a δ functor. -/\n@[nolint has_inhabited_instance]\nstructure effacement (F : A ⥤δ B) (X : A) (n : ℕ) :=\n(I : A)\n(ι : X ⟶ I)\n[mono : category_theory.mono ι]\n(w : (F (n+1)).map ι = 0)\n\n/-- Morphisms between effacements. -/\n@[ext, nolint has_inhabited_instance]\nstructure effacement.hom (F : A ⥤δ B) (X : A) (n : ℕ)\n (e₁ e₂ : effacement F X n) :=\n(t : e₁.I ⟶ e₂.I)\n(w : e₁.ι ≫ t = e₂.ι)\n\ninstance effacement.category (F : A ⥤δ B) (X : A) (n : ℕ) :\n category (effacement F X n) :=\n{ hom := λ e₁ e₂, e₁.hom _ _ _ e₂,\n id := λ e, ⟨𝟙 _, category.comp_id _⟩,\n comp := λ a b c f g, ⟨f.t ≫ g.t, by simp [reassoc_of f.w, g.w]⟩,\n id_comp' := λ a b f, effacement.hom.ext _ _ $ category.id_comp _,\n comp_id' := λ a b f, effacement.hom.ext _ _ $ category.comp_id _,\n assoc' := λ a b c d f g h,\n effacement.hom.ext _ _ $ category.assoc _ _ _ }\n\ninstance effacement_mono (F : A ⥤δ B) (X : A) (n : ℕ)\n (e : effacement F X n) : category_theory.mono e.ι := e.mono\n\n/-- Effacable δ functors. -/\nclass effaceable (F : A ⥤δ B) : Prop :=\n(cond [] : ∀ (X : A) (n : ℕ), nonempty (effacement F X n))\n\n/-- A choice of effacement. -/\ndef choose_effacement (F : A ⥤δ B) [effaceable F] (X : A) (n : ℕ) : effacement F X n :=\n(effaceable.cond F X n).some\n\n/-- A short exact sequence associated to an effacement -/\ndef effacement.ses {F : A ⥤δ B} {X n} (e : effacement F X n) : short_exact_sequence A :=\n{ fst := X,\n snd := e.I,\n trd := limits.cokernel e.ι,\n f := e.ι,\n g := limits.cokernel.π _,\n exact' := abelian.exact_cokernel e.ι }\n\n/-- An auxiliary definition used to obtain the isomorphism below -/\ndef effacement.cokernel_comparison {F : A ⥤δ B} {X n} (e : effacement F X n) :\n limits.cokernel ((F n).map (limits.cokernel.π e.ι)) ⟶ (F (n+1)).obj X :=\nlimits.cokernel.desc _ ((F.δ n).app e.ses) (F.exact_δ n e.ses).w\n\nopen_locale zero_object\ninstance effacement.epi_cokernel_comparison {F : A ⥤δ B} {X n} (e : effacement F X n) :\n epi e.cokernel_comparison :=\nbegin\n dsimp [effacement.cokernel_comparison],\n let t := _, change epi t,\n suffices : epi (limits.cokernel.π _ ≫ t),\n { resetI,\n apply epi_of_epi (limits.cokernel.π _) t },\n simp only [limits.cokernel.π_desc],\n have : exact ((F.δ n).app e.ses) ((F (n+1)).map e.ι) :=\n F.δ_exact n e.ses,\n rw e.w at this,\n\n apply abelian.pseudoelement.epi_of_pseudo_surjective,\n intros q,\n exact (abelian.pseudoelement.pseudo_exact_of_exact this).2 q (by simp),\nend\n\n/- This is true with fewer assumptions... -/\ninstance effacement.mono_cokernel_comparison {F : A ⥤δ B} {X n} (e : effacement F X n) :\n category_theory.mono e.cokernel_comparison :=\nbegin\n dsimp [effacement.cokernel_comparison],\n let t := _, change category_theory.mono t,\n suffices : exact ((F n).map (limits.cokernel.π e.ι)) ((F.δ n).app e.ses),\n exact abelian.category_theory.limits.cokernel.desc.category_theory.mono\n ((F n).map (limits.cokernel.π e.ι))\n ((F.δ n).app (effacement.ses e)) this,\n exact F.exact_δ n e.ses,\nend\n\ninstance effacement.is_iso_cokernel_comparison {F : A ⥤δ B} {X n} (e : effacement F X n) :\n is_iso e.cokernel_comparison :=\nis_iso_of_mono_of_epi _\n\n/-- The cokernel isomorphism associated to an effacement. -/\ndef effacement.cokernel_iso {F : A ⥤δ B} {X n} (e : effacement F X n) :\n limits.cokernel ((F n).map (limits.cokernel.π e.ι)) ≅ (F (n+1)).obj X :=\nas_iso e.cokernel_comparison\n\n@[simp, reassoc]\nlemma effacement.cokernel_iso_spec {F : A ⥤δ B} {X n} (e : effacement F X n) :\n limits.cokernel.π _ ≫ e.cokernel_iso.hom =\n (F.δ n).app e.ses :=\nlimits.cokernel.π_desc _ _ _\n\n/-- An auxiliary definition used in `lift` below. -/\ndef effacement.lift_app_aux {F G : A ⥤δ B} {X n}\n (η : F n ⟶ G n) (e : effacement F X n) :\n (F (n+1)).obj X ⟶ (G (n+1)).obj X :=\ne.cokernel_iso.inv ≫\nlimits.cokernel.desc _\n(η.app _ ≫ (G.δ n).app e.ses)\nbegin\n rw [← category.assoc, η.naturality, category.assoc],\n erw (G.exact_δ n e.ses).w,\n rw [limits.comp_zero]\nend\n\n/-- An auxiliary definition used in `lift` below. -/\ndef effacement.map_ses {F : A ⥤δ B} {X n}\n (e₁ e₂ : effacement F X n) (q : e₁ ⟶ e₂) :\n e₁.ses ⟶ e₂.ses :=\n{ fst := 𝟙 _,\n snd := q.t,\n trd := begin\n refine limits.cokernel.desc _ _ _,\n refine _ ≫ limits.cokernel.π _,\n exact q.t,\n rw [← category.assoc, q.w, limits.cokernel.condition]\n end,\n sq1' := by { simp only [category.id_comp], exact q.w.symm },\n sq2' := begin\n erw limits.cokernel.π_desc,\n refl,\n end }\n\n\nlemma effacement.lift_app_aux_eq_of_hom\n {F G : A ⥤δ B} {X n}\n (η : F n ⟶ G n) (e₁ e₂ : effacement F X n) (q : e₁ ⟶ e₂) :\n e₁.lift_app_aux η = e₂.lift_app_aux η :=\nbegin\n dsimp only [effacement.lift_app_aux],\n rw iso.inv_comp_eq,\n apply limits.coequalizer.hom_ext,\n simp only [limits.cokernel.π_desc, effacement.cokernel_iso_spec_assoc],\n rw ← category.assoc, let t := _, change _ = t ≫ _,\n have ht : t = (F n).map (e₁.map_ses e₂ q).trd ≫ limits.cokernel.π _,\n { dsimp [t], rw iso.comp_inv_eq,\n simp only [category.assoc, effacement.cokernel_iso_spec],\n erw (F.δ n).naturality (e₁.map_ses e₂ q),\n dsimp [effacement.map_ses],\n simp },\n rw ht, clear ht t,\n simp only [category.assoc, limits.cokernel.π_desc],\n erw [nat_trans.naturality_assoc],\n congr' 1,\n erw (G.δ n).naturality (e₁.map_ses e₂ q),\n symmetry,\n convert category.comp_id _,\n exact functor.map_id _ _,\nend\n\nlemma effacement.lift_app_aux_well_defined\n {F G : A ⥤δ B} {X n}\n (η : F n ⟶ G n) (e₁ e₂ : effacement F X n) :\n e₁.lift_app_aux η = e₂.lift_app_aux η :=\nbegin\n let II := limits.biprod e₁.I e₂.I,\n let ι : X ⟶ II := limits.biprod.lift e₁.ι e₂.ι,\n let e : effacement F X n := ⟨II, ι, _⟩, -- use additivity of `F n`.\n swap,\n { haveI : limits.preserves_binary_biproducts (F (n+1)) :=\n limits.preserves_binary_biproducts_of_preserves_biproducts (F (n + 1)),\n let E : (F (n + 1)).obj (e₁.I ⊞ e₂.I) ≅ (F (n + 1)).obj (e₁.I) ⊞ (F (n+1)).obj (e₂.I) :=\n functor.map_biprod (F (n+1)) _ _,\n rw [← cancel_mono E.hom, limits.zero_comp],\n rw functor.map_biprod_hom,\n apply limits.biprod.hom_ext,\n { simp only [category.assoc, limits.biprod.lift_fst, limits.zero_comp],\n simp only [← functor.map_comp, limits.biprod.lift_fst, e₁.w] },\n { simp only [category.assoc, limits.biprod.lift_snd, limits.zero_comp],\n simp only [← functor.map_comp, limits.biprod.lift_snd, e₂.w] } },\n let π₁ : e ⟶ e₁ := ⟨limits.biprod.fst, _⟩,\n swap, { dsimp [e], simp, },\n let π₂ : e ⟶ e₂ := ⟨limits.biprod.snd, _⟩,\n swap, { dsimp [e], simp, },\n rw ← effacement.lift_app_aux_eq_of_hom η _ _ π₁,\n rw ← effacement.lift_app_aux_eq_of_hom η _ _ π₂,\nend\n\nlemma effacement.lift_naturality\n {F G : A ⥤δ B} {X Y n}\n (η : F n ⟶ G n) (e₁ : effacement F X n) (e₂ : effacement F Y n) (f : X ⟶ Y) :\n e₁.lift_app_aux η ≫ (G (n+1)).map f =\n (F (n+1)).map f ≫ e₂.lift_app_aux η :=\nbegin\n let e₁' : effacement F X n :=\n ⟨limits.biprod e₁.I e₂.I, limits.biprod.lift e₁.ι (f ≫ e₂.ι), _⟩, -- again, additivity\n swap,\n { haveI : limits.preserves_binary_biproducts (F (n+1)) :=\n limits.preserves_binary_biproducts_of_preserves_biproducts (F (n + 1)),\n let E : (F (n + 1)).obj (e₁.I ⊞ e₂.I) ≅ (F (n + 1)).obj (e₁.I) ⊞ (F (n+1)).obj (e₂.I) :=\n functor.map_biprod (F (n+1)) _ _,\n rw [← cancel_mono E.hom, limits.zero_comp],\n rw functor.map_biprod_hom,\n apply limits.biprod.hom_ext,\n simp only [category.assoc, limits.biprod.lift_fst, limits.zero_comp],\n simp only [← functor.map_comp, limits.biprod.lift_fst],\n exact e₁.w,\n simp only [category.assoc, limits.biprod.lift_snd, limits.zero_comp],\n simp only [← functor.map_comp, limits.biprod.lift_snd],\n simp only [functor.map_comp, e₂.w, limits.comp_zero] },\n rw e₁.lift_app_aux_well_defined η e₁',\n dsimp [effacement.lift_app_aux],\n simp only [category.assoc, iso.inv_comp_eq],\n apply limits.coequalizer.hom_ext,\n simp only [limits.coequalizer_as_cokernel, limits.cokernel.π_desc_assoc, category.assoc],\n erw limits.cokernel.π_desc_assoc,\n let q : e₁'.ses ⟶ e₂.ses := ⟨f, limits.biprod.snd,\n limits.cokernel.desc _ (limits.biprod.snd ≫ limits.cokernel.π _) _, _, _⟩,\n erw ← (F.δ n).naturality_assoc q,\n erw ← (G.δ n).naturality q,\n dsimp,\n have : (F.δ n).app e₂.ses ≫ e₂.cokernel_iso.inv = limits.cokernel.π _,\n { rw iso.comp_inv_eq, simp, },\n rw reassoc_of this, clear this,\n simp only [category.assoc, limits.cokernel.π_desc],\n erw ← nat_trans.naturality_assoc,\n refl,\n { dsimp [e₁'],\n simp },\n { dsimp [e₁', effacement.ses],\n simp },\n { dsimp [e₁', effacement.ses], simp, },\nend\n\nlemma effacement.lift_δ_naturality\n {F G : A ⥤δ B} {n}\n (η : F n ⟶ G n) (S : short_exact_sequence A)\n (e₁ : effacement F S.fst n) (e₂ : effacement F S.snd n) :\n (F.δ n).app S ≫ e₁.lift_app_aux η =\n η.app _ ≫ (G.δ _).app S :=\nbegin\n let e₁' : effacement F S.fst n :=\n ⟨e₂.I, S.f ≫ e₂.ι, by simp [e₂.w]⟩,\n rw e₁.lift_app_aux_well_defined η e₁',\n let q : S ⟶ e₁'.ses :=\n ⟨𝟙 _, e₂.ι, S.exact'.epi_desc (e₂.ι ≫ limits.cokernel.π _) _, _, _⟩,\n dsimp only [effacement.lift_app_aux],\n have : (F.δ n).app S ≫ e₁'.cokernel_iso.inv = (F n).map q.trd ≫\n limits.cokernel.π _,\n { rw iso.comp_inv_eq,\n simp,\n erw (F.δ n).naturality q,\n dsimp,\n simp only [functor.map_id, category.comp_id] },\n slice_lhs 1 2\n { erw this },\n simp only [category.assoc, limits.cokernel.π_desc],\n erw η.naturality_assoc,\n congr' 1,\n erw (G.δ n).naturality q, convert category.comp_id _,\n { dsimp, simpa only [functor.map_id], },\n rw ← category.assoc, exact limits.cokernel.condition _,\n { dsimp, simpa },\n { dsimp, simpa only [exact.comp_epi_desc] }\nend\n\n/-- An auxiliary definition used in `lift` below. -/\ndef effaceable.lift_component (F G : A ⥤δ B) [effaceable F] (n) (η : F n ⟶ G n) :\n F (n+1) ⟶ G (n+1) :=\n{ app := λ X, (choose_effacement F X n).lift_app_aux η,\n naturality' := begin\n intros X Y f,\n symmetry,\n apply effacement.lift_naturality,\n end }\n\n/-- The lift of η0. -/\nnoncomputable\ndef effaceable.lift (F G : A ⥤δ B) [effaceable F] (η0 : F 0 ⟶ G 0) : Π n, F n ⟶ G n\n| 0 := η0\n| (n+1) := effaceable.lift_component _ _ _ (effaceable.lift n)\n\n/-- The lift of η0, as an actual delta functor. -/\ndef effaceable.lift_with_δ (F G : A ⥤δ B) [effaceable F] (η0 : F 0 ⟶ G 0) :\n F ⟶ G :=\n{ η := effaceable.lift _ _ η0,\n comm' := begin\n intros n, ext S : 2,\n dsimp,\n rcases n with (_|n),\n { dsimp [effaceable.lift],\n apply effacement.lift_δ_naturality,\n apply choose_effacement },\n { dsimp [effaceable.lift],\n apply effacement.lift_δ_naturality,\n apply choose_effacement },\n end }\n\nlemma effaceable.lift_with_δ_unique (F G : A ⥤δ B) [effaceable F] (η0 : F 0 ⟶ G 0)\n (η : F ⟶ G) (hη : η 0 = η0) : η = effaceable.lift_with_δ F G η0 :=\nbegin\n ext1 n, induction n with n hn,\n { rw hη, refl },\n { ext T, dsimp [effaceable.lift_with_δ] at ⊢ hn,\n change _ = ((effaceable.lift F G η0) _).app _,\n dsimp [effaceable.lift],\n change _ = effaceable.lift F G η0 n at hn,\n erw ← hn,\n dsimp [effaceable.lift_component],\n dsimp [effacement.lift_app_aux],\n rw iso.eq_inv_comp,\n apply limits.coequalizer.hom_ext,\n dsimp,\n simp only [effacement.cokernel_iso_spec_assoc, limits.cokernel.π_desc],\n have := effacement.lift_δ_naturality (η n) ((choose_effacement F T n).ses)\n (choose_effacement _ _ _) (choose_effacement _ _ _),\n erw ← this, congr' 1,\n dsimp only [effacement.lift_app_aux],\n rw iso.eq_inv_comp,\n\n apply limits.coequalizer.hom_ext,\n simp only [effacement.cokernel_iso_spec_assoc, limits.cokernel.π_desc],\n clear this,\n have := η.comm' n,\n apply_fun (λ e, e.app ((choose_effacement F (choose_effacement F T n).ses.fst n).ses)) at this,\n exact this },\nend\n\nend tohoku\nopen tohoku\n\ntheorem universal_of_effaceable (F : A ⥤δ B) [effaceable F] : universal F :=\nbegin\n constructor, intros G η0,\n use effaceable.lift_with_δ F G η0,\n split,\n { ext, refl, },\n { intros η hη, apply effaceable.lift_with_δ_unique, exact hη, }\nend\n\n-- Sketch:\n-- TODO: Prove stacks tag 010T. -- DONE!\n-- TODO: Construct `Ext^*(-,X)` a delta functor (on objects!).\n-- These should be functors `Aᵒᵖ ⥤ Ab` (assuming `A` has enough projectives).\n-- Use `010T` to see that `Ext^*(-,X)` is universal.\n\nend delta_functor\n\nend category_theory\n", "meta": {"author": "leanprover-community", "repo": "lean-liquid", "sha": "92f188bd17f34dbfefc92a83069577f708851aec", "save_path": "github-repos/lean/leanprover-community-lean-liquid", "path": "github-repos/lean/leanprover-community-lean-liquid/lean-liquid-92f188bd17f34dbfefc92a83069577f708851aec/src/for_mathlib/universal_delta_functor/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.3849121444839335, "lm_q1q2_score": 0.20147084897560927}} {"text": "import data.finsupp.pointwise\nimport verification.semantics.stream\nimport verification.semantics.stream_props\n\nnoncomputable theory\nopen_locale classical\n\nclass Eval (α : Type*) (ι : out_param Type) (β : out_param Type*) [has_zero β] :=\n(eval : α → (ι →₀ β))\n\ninstance Stream.Eval_base {ι : Type} {α : Type*} [add_zero_class α] : \n Eval (StreamExec ι α) ι α :=\n{ eval := λ s, s.eval }\n\ninstance SimpleStream.Eval_base {ι : Type} {α : Type*} [linear_order ι] [add_zero_class α] : \n Eval (SimpleStream ι α) ι α :=\n{ eval := λ s, Eval.eval (↑s : StreamExec ι α) }\n\ninstance Stream.Eval_ind {ι α ι' α' : Type*} [add_zero_class α'] [Eval α ι' α'] :\n Eval (StreamExec ι α) ι (ι' →₀ α') :=\n{ eval := λ s, (Eval.eval <$₂> s).eval }\n\ninstance SimpleStream.Eval_ind {ι α ι' α' : Type*} [linear_order ι] [add_zero_class α'] [Eval α ι' α'] :\n Eval (SimpleStream ι α) ι (ι' →₀ α') :=\n{ eval := λ s, Eval.eval (↑s : StreamExec ι α) }\n\nclass AddZeroEval (α : Type*) (ι : out_param Type) (β : out_param Type*) [add_zero_class β] \n extends Eval α ι β, has_add α, has_zero α :=\n(hadd : ∀ (x y : α), eval (x + y) = eval x + eval y)\n(hzero : eval 0 = 0)\n\nclass MulEval (α : Type*) (ι : out_param Type) (β : out_param Type*) [non_unital_non_assoc_semiring β]\n extends Eval α ι β, has_mul α :=\n(hmul : ∀ (x y : α), eval (x * y) = eval x * eval y)\n\nattribute [simp] AddZeroEval.hadd AddZeroEval.hzero\n MulEval.hmul\n\n@[simp] lemma Eval.contract {ι ι' : Type} {α α' : Type*} [add_comm_monoid α'] [Eval α ι' α']\n (s : StreamExec ι α) :\n Eval.eval (contract_stream s) () = (Eval.eval s).sum_range :=\nby simp [Eval.eval, contract_stream, StreamExec.bimap_bimap, ← contract_stream_spec_apply]\n\n@[simp] lemma Eval.contract' {ι ι' : Type} {α α' : Type*} [linear_order ι] [add_comm_monoid α'] [Eval α ι' α']\n (s : SimpleStream ι α) :\n Eval.eval s.contract () = (Eval.eval s).sum_range :=\nEval.contract _", "meta": {"author": "kovach", "repo": "etch", "sha": "26ef67eb83cf7c5cfd1667059e16c3873b9098ca", "save_path": "github-repos/lean/kovach-etch", "path": "github-repos/lean/kovach-etch/etch-26ef67eb83cf7c5cfd1667059e16c3873b9098ca/src/verification/semantics/finsuppeval.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.399811640739795, "lm_q1q2_score": 0.2014675528181386}} {"text": "import .functor\nimport .for_mathlib.coprod.free_group_subgroup\nimport neat.initial\nimport data.nat.digits\n/-!\n# The base case of the `group_thingy` tactic\n\n## Main definitions\nThe only definition used outside of this file is `base_case_solver`.\n`base_case_solver T r₁ r₂` solves the word problem for the relation `of' r₁ r₂`, returning\na normalized word in `T` when possible, and `none` otherwise\n-/\nvariables {ι : Type} [decidable_eq ι]\n\nopen multiplicative free_group P semidirect_product\n\n@[simp] lemma gpowers_hom_apply {G : Type*} [group G] (x : G) (y : C∞) :\n gpowers_hom G x y = x ^ y.to_add := rfl\n\ndef base_case'_cons (r₁ : ι) (r₂ : C∞) (i : ι) (n : C∞) :\n P (free_group ι) → P (free_group ι)\n| ⟨w, ⟨[], _⟩⟩ :=\n if i = r₁ ∧ to_add r₂ ∣ to_add n\n then ⟨of' (1 : free_group ι) (of_add (to_add n / to_add r₂)) * w, 1⟩\n else ⟨mul_free (of' i n) w, ⟨[⟨i, n⟩], sorry⟩⟩\n| ⟨w, ⟨(j::l), h⟩⟩ :=\n if i = r₁\n then let x := to_add n + to_add j.2 in\n if j.1 = r₁ ∧ to_add r₂ ∣ x\n then ⟨mul_free (of' i n) w * of' (1 : free_group ι) (of_add (x / (to_add r₂))), ⟨l, sorry⟩⟩\n else if (to_add r₂ : ℤ) ∣ to_add n\n then ⟨mul_free (of' i n) w * of' (1 : free_group ι) (of_add (to_add n / to_add r₂)),\n ⟨(j :: l), h⟩⟩\n else ⟨mul_free (of' i n) w, of' i n * ⟨j :: l, h⟩⟩\n else ⟨mul_free (of' i n) w, of' i n * ⟨j :: l, h⟩⟩\n\ndef base_case' (r₁ : ι) (r₂ : C∞) : free_group ι → P (free_group ι)\n| ⟨[], h⟩ := ⟨1, ⟨[], h⟩⟩\n| ⟨(i::l), h⟩ :=\n base_case'_cons r₁ r₂ i.1 i.2 $ base_case' ⟨l, coprod.pre.reduced_of_reduced_cons h⟩\nusing_well_founded { rel_tac := λ _ _, `[exact ⟨λ _ _, true, sorry⟩], dec_tac := `[trivial] }\n\ndef base_case'_solver (T : set ι) [decidable_pred T] (r₁ : ι) (r₂ : C∞) : solver (of' r₁ r₂) T :=\nλ w, let p := base_case' r₁ r₂ w in\nif p.right ∈ closure_var T\n then some p\n else none\n\n/-- `base_case_core` takes a word `l₁` in the free_group as a `list (Σ i : ι, C∞)`\nand a normalized word with proof `p` as a `P (free_group ι)`.\nIt returns a normalized version `reverse l₁ * p`, reduced modulo `of' r₁ r₂` -/\n@[inline] def base_case_core (r₁ : ι) (r₂ : C∞) : list (Σ i : ι, C∞) →\n P (free_group ι) → P (free_group ι)\n| [] p := p\n| (i::l₁) ⟨p, ⟨[], _⟩⟩ :=\n if i.1 = r₁\n then if to_add r₂ ∣ i.2\n then let q := to_add i.2 / to_add r₂ in\n base_case_core l₁ (inl (of' (1 : free_group ι) q) * ⟨p, 1⟩)\n else base_case_core l₁ (inr (of' i.1 i.2) * ⟨p, 1⟩)\n else base_case_core l₁ (inr (of' i.1 i.2) * inl p)\n| (i::l₁) ⟨p, ⟨j::l₂, _⟩⟩ :=\n if i.1 = r₁\n then if j.1 = r₁\n then\n let x := to_add i.2 + to_add j.2 in\n if to_add r₂ ∣ x\n then base_case_core l₁ (inl (of' (1 : free_group ι) (of_add (to_add x / to_add r₂))) *\n inr (of' j.1 j.2⁻¹) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n else base_case_core l₁ (inr (of' i.1 i.2) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n else if to_add r₂ ∣ i.2\n then let q := to_add i.2 / to_add r₂ in\n base_case_core l₁ (inl (of' (1 : free_group ι) q) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n else base_case_core l₁ (inr (of' i.1 i.2) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n else base_case_core l₁ (inr (of' i.1 i.2) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n\n-- def normalize_single (r₁ : ι) (r₂ : C∞) (i : ι) (n : C∞) : P (free_group ι) :=\n-- if i = r₁ ∧ to_add r₂ ∣ to_add n\n-- then ⟨of' 1 (of_add (to_add n / to_add r₂)), 1⟩\n-- else ⟨1, of' i n⟩\n\n-- def mul_left (r₁ : ι) (r₂ : C∞) (i : ι) (n : C∞) :\n-- P (free_group ι) → P (free_group ι)\n-- | ⟨p, ⟨[], _⟩⟩ := normalize_single r₁ r₂ i n * inl p\n-- | ⟨p, ⟨(j::l), _⟩⟩ :=\n-- if i = j.1\n-- then _\n-- else _\n\n-- -- @[inline] def base_case_core₂ (r₁ : ι) (r₂ : C∞) : list (Σ i : ι, C∞) →\n-- -- P (free_group ι) → P (free_group ι)\n-- -- | [] p := p\n-- -- | (i::l₁) ⟨p, ⟨[], _⟩⟩ :=\n-- -- if i.1 = r₁\n-- -- then if to_add r₂ ∣ i.2\n-- -- then let q := to_add i.2 / to_add r₂ in\n-- -- base_case_core l₁ (inl (of' (1 : free_group ι) q) * ⟨p, 1⟩)\n-- -- else base_case_core l₁ (inr (of' i.1 i.2) * ⟨p, 1⟩)\n-- -- else base_case_core l₁ (inr (of' i.1 i.2) * inl p)\n-- -- | (i::l₁) ⟨p, ⟨j::l₂, _⟩⟩ :=\n-- -- if i.1 = r₁\n-- -- then if j.1 = r₁\n-- -- then\n-- -- let x := to_add i.2 + to_add j.2 in\n-- -- if to_add r₂ ∣ x\n-- -- then base_case_core l₁ (inl (of' (1 : free_group ι) (of_add (to_add x / to_add r₂))) *\n-- -- inr (of' j.1 j.2⁻¹) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n-- -- else base_case_core l₁ (inr (of' i.1 i.2) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n-- -- else if to_add r₂ ∣ i.2\n-- -- then let q := to_add i.2 / to_add r₂ in\n-- -- base_case_core l₁ (inl (of' (1 : free_group ι) q) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n-- -- else base_case_core l₁ (inr (of' i.1 i.2) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n-- -- else base_case_core l₁ (inr (of' i.1 i.2) * ⟨p, ⟨j::l₂, sorry⟩⟩)\n\n/-- `base_case` reduces a word `w` in the `free_group ι` modulo `of' r₁ r₂` -/\n@[inline] def base_case (r₁ : ι) (r₂ : C∞) (w : free_group ι) : P (free_group ι) :=\nbase_case_core r₁ r₂ w.to_list.reverse 1\n\n/-- `base_case_solver T r₁ r₂` solves the word problem for the relation `of' r₁ r₂`, returning\na normalized word in `T` when possible, and `none` otherwise -/\n@[inline] def base_case_solver (T : set ι) [decidable_pred T] (r₁ : ι) (r₂ : C∞) : solver (of' r₁ r₂) T :=\nλ w, let p := base_case r₁ r₂ w in\nif p.right ∈ closure_var T\n then some p\n else none\n\n#eval --(of' 0 (of_add 2))\n P.lhs (of' 0 (of_add 2)) ((base_case 0 (of_add 2) ((of 1)⁻¹ *of 0^(-2 : ℤ) * (of 1)⁻¹ * of 0 ^2* (of 1)^(-2 : ℤ) * (of 0)^2)))\n#eval ((base_case 1 (of_add 1) ((of 0)⁻¹ * of 1 * of 0 ^ 2 * (of 1) * (of 0)⁻¹)).left)\n#eval ((base_case' 0 (of_add 2) (of 1 *of 0^2 * (of 1) * of 0 ^2* (of 1)^(-2 : ℤ) * (of 0)^2)).left)\n#eval ((base_case' 1 (of_add 1) ((of 0)⁻¹ * of 1 * of 0 ^ 2 * (of 1) * (of 0)⁻¹)).left)\n\n@[simp] lemma lhs_base_case'_cons (r₁ : ι) (r₂ : C∞) (hr₂ : to_add r₂ ≠ 0) (i : ι) (n : C∞) :\n Π (x : P (free_group ι)), lhs (of' r₁ r₂) (base_case'_cons r₁ r₂ i n x) =\n of' i n * lhs (of' r₁ r₂) x\n| ⟨w, ⟨[], _⟩⟩ := begin\n rw [base_case'_cons],\n split_ifs,\n { clear_aux_decl,\n rcases h with ⟨rfl, m, hm⟩,\n simp [lhs_inl, free_group.lift, gpowers_hom_apply],\n simp only [of'_eq_of_pow, ← gpow_add, ← gpow_neg, ← gpow_mul,\n int.div_eq_of_eq_mul_right hr₂ hm],\n rw hm },\n { simp [inl_aut] }\nend\n| ⟨w, ⟨(j::l), _⟩⟩ := begin\n clear_aux_decl,\n rw [base_case'_cons],\n dsimp only,\n split_ifs,\n { subst r₁,\n rcases h_1 with ⟨rfl, m, hm⟩,\n rw [int.div_eq_of_eq_mul_right hr₂ hm],\n rw [← eq_sub_iff_add_eq] at hm,\n simp [lhs_inl, free_group.lift, mul_assoc, gpowers_hom_apply, inl_aut, hm],\n simp only [of'_eq_of_pow, ← gpow_add, ← gpow_neg, ← gpow_mul, ← mul_assoc, hm],\n simp },\n { subst r₁,\n rcases h_2 with ⟨m, hm⟩,\n rw [int.div_eq_of_eq_mul_right hr₂ hm],\n simp [lhs_inl, free_group.lift, mul_assoc, gpowers_hom_apply, inl_aut, hm],\n simp only [of'_eq_of_pow, ← gpow_add, ← gpow_neg, ← gpow_mul, ← mul_assoc, hm],\n simp },\n { simp [inl_aut_inv, inl_aut, mul_assoc] },\n { simp [inl_aut_inv, inl_aut, mul_assoc] }\nend\n\nlemma lhs_base_case' (r₁ : ι) (r₂ : C∞) (hr₂ : to_add r₂ ≠ 0) :\n ∀ x : free_group ι, lhs (of' r₁ r₂) (base_case' r₁ r₂ x) = x\n| ⟨[], h⟩ := by rw [base_case']; simp\n| ⟨(i::l), _⟩ := by rw [base_case', lhs_base_case'_cons, lhs_base_case'];\n simp [inl_aut, inl_aut_inv, mul_assoc, hr₂]\nusing_well_founded { rel_tac := λ _ _, `[exact ⟨λ _ _, true, sorry⟩], dec_tac := `[trivial] }", "meta": {"author": "ChrisHughes24", "repo": "single_relation", "sha": "556990dab75054a1c14717a72c8901dc9f2f01e4", "save_path": "github-repos/lean/ChrisHughes24-single_relation", "path": "github-repos/lean/ChrisHughes24-single_relation/single_relation-556990dab75054a1c14717a72c8901dc9f2f01e4/scratch/base_case.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5774953651858117, "lm_q2_score": 0.3486451488696663, "lm_q1q2_score": 0.2013409575667496}}