{"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 \u27f6 X') (hs : W s) (f : X \u27f6 Y) :=\n(obj : C)\n(g : X' \u27f6 obj)\n(s' : Y \u27f6 obj)\n(hs' : W s')\n(fac : f \u226b s' = s \u226b g)\n\nvariable (W)\n\nclass left_calculus_of_fractions : Prop :=\n(id : W.contains_identities)\n(comp [] : W.stable_under_composition)\n(ex : \u2200 \u2983X' X Y : C\u2984 (s : X \u27f6 X') (hs : W s) (u : X \u27f6 Y),\n  nonempty (left_calculus_of_fractions.to_sq s hs u))\n(ext : \u2200 \u2983X' X Y : C\u2984 (f\u2081 f\u2082 : X \u27f6 Y) (s : X' \u27f6 X) (hs : W s) (eq : s \u226b f\u2081 = s \u226b f\u2082),\n  \u2203 (Y' : C) (t : Y \u27f6 Y') (ht : W t), f\u2081 \u226b t = f\u2082 \u226b 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 \u27f6 Z) (s : Y \u27f6 Z) (hs : W s)\n\nvariable {W}\ndef roof_rel \u2983X Y : C\u2984 (z\u2081 z\u2082 : roof W X Y) : Prop :=\n\u2203 (Z\u2083 : C) (t\u2081 : z\u2081.Z \u27f6 Z\u2083) (t\u2082 : z\u2082.Z \u27f6 Z\u2083) (hst : z\u2081.s \u226b t\u2081 = z\u2082.s \u226b t\u2082)\n  (hft : z\u2081.f \u226b t\u2081 = z\u2082.f \u226b t\u2082), W (z\u2081.s \u226b t\u2081)\n\nvariables [left_calculus_of_fractions W] (W)\n\n@[simps]\ndef roof.of_hom {X Y : C} (f : X \u27f6 Y) : roof W X Y :=\n\u27e8Y, f, \ud835\udfd9 Y, morphism_property.contains_identities.id W Y\u27e9\n\n@[simps]\ndef roof.id (X : C) := roof.of_hom W (\ud835\udfd9 X)\n\nnamespace roof_rel\n\nvariables {W}\n\nlemma refl {X Y : C} (z : roof W X Y) : roof_rel z z :=\n\u27e8z.Z, \ud835\udfd9 _, \ud835\udfd9 _, rfl, rfl, by simpa only [comp_id] using z.hs\u27e9\n\nlemma symm {X Y : C} {z\u2081 z\u2082 : roof W X Y} (h : roof_rel z\u2081 z\u2082) : roof_rel z\u2082 z\u2081 :=\nbegin\n  rcases h with \u27e8Z\u2083, t\u2081, t\u2082, hst, hft, ht\u27e9,\n  refine \u27e8Z\u2083, t\u2082, t\u2081, hst.symm, hft.symm, by simpa only [\u2190 hst] using ht\u27e9,\nend\n\nlemma trans {X Y : C} {z\u2081 z\u2082 z\u2083 : roof W X Y} (h\u2081\u2082 : roof_rel z\u2081 z\u2082)\n  (h\u2082\u2083 : roof_rel z\u2082 z\u2083) : roof_rel z\u2081 z\u2083 :=\nbegin\n  rcases h\u2081\u2082 with \u27e8Z\u2084, t\u2081, t\u2082, hst, hft, ht\u27e9,\n  rcases h\u2082\u2083 with \u27e8Z\u2085, u\u2082, u\u2083, hsu, hfu, hu\u27e9,\n  rcases left_calculus_of_fractions.ex (z\u2081.s \u226b t\u2081) ht (z\u2083.s \u226b u\u2083) with \u27e8Z\u2086, v\u2084, v\u2085, hv\u2085, fac\u27e9,\n  simp only [assoc] at fac,\n  have eq : z\u2082.s \u226b u\u2082 \u226b v\u2085 = z\u2082.s \u226b t\u2082 \u226b v\u2084,\n  { simpa only [\u2190 reassoc_of hsu, reassoc_of hst] using fac, },\n  rcases left_calculus_of_fractions.ext _ _ _ z\u2082.hs eq with \u27e8Z\u2087, w, hw, fac'\u27e9,\n  simp only [assoc] at fac',\n  refine \u27e8Z\u2087, t\u2081 \u226b v\u2084 \u226b w, u\u2083 \u226b v\u2085 \u226b w, _, _, _\u27e9,\n  { rw reassoc_of fac, },\n  { rw [reassoc_of hft, \u2190 fac', reassoc_of hfu], },\n  { rw [\u2190 reassoc_of fac, \u2190 reassoc_of hsu, \u2190 assoc],\n    exact left_calculus_of_fractions.comp _ _ _ hu\n      (left_calculus_of_fractions.comp _ _ _ hv\u2085 hw), },\nend\n\nend roof_rel\n\ninstance is_equiv_roof_rel (X Y : C) :\n  is_equiv (roof W X Y) (\u03bb z\u2081 z\u2082, roof_rel z\u2081 z\u2082) :=\n{ refl := roof_rel.refl,\n  symm := \u03bb z\u2081 z\u2082, roof_rel.symm,\n  trans := \u03bb z\u2081 z\u2082 z\u2083, roof_rel.trans, }\n\nvariable {W}\n\ndef roof.comp\u2080 {X\u2081 X\u2082 X\u2083 : C} (z\u2081\u2082 : roof W X\u2081 X\u2082) (z\u2082\u2083 : roof W X\u2082 X\u2083)\n  (sq : to_sq z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f) :\n  roof W X\u2081 X\u2083 :=\n\u27e8sq.obj, z\u2081\u2082.f \u226b sq.g , z\u2082\u2083.s \u226b sq.s', left_calculus_of_fractions.comp _ _ _ z\u2082\u2083.hs sq.hs'\u27e9\n\nlemma roof.comp\u2080_rel {X\u2081 X\u2082 X\u2083 : C} (z\u2081\u2082 : roof W X\u2081 X\u2082) (z\u2082\u2083 : roof W X\u2082 X\u2083)\n  (sq sq' : to_sq z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f) :\n  roof_rel (roof.comp\u2080 z\u2081\u2082 z\u2082\u2083 sq) (roof.comp\u2080 z\u2081\u2082 z\u2082\u2083 sq') :=\nbegin\n  let H := (left_calculus_of_fractions.ex sq.s' sq.hs' sq'.s').some,\n  have eq : z\u2081\u2082.s \u226b sq.g \u226b H.g = z\u2081\u2082.s \u226b sq'.g \u226b H.s',\n  { rw [\u2190 reassoc_of sq.fac, \u2190 reassoc_of sq'.fac, H.fac], },\n  rcases left_calculus_of_fractions.ext _ _ _ (z\u2081\u2082.hs) eq with \u27e8Y, t, ht, fac\u27e9,\n  refine \u27e8Y, H.g \u226b t, H.s' \u226b t, _, _, _\u27e9,\n  { dsimp [roof.comp\u2080],\n    simp only [assoc, reassoc_of H.fac], },\n  { dsimp [roof.comp\u2080],\n    simp only [assoc] at \u22a2 fac,\n    rw \u2190 fac, },\n  { dsimp [roof.comp\u2080],\n    simp only [assoc, \u2190 reassoc_of H.fac],\n    refine left_calculus_of_fractions.comp _ _ _ z\u2082\u2083.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 ((\u03bb (z\u2081 z\u2082 : roof W X Y), roof_rel z\u2081 z\u2082))\n\nvariable {W}\n\ndef roof.comp {X\u2081 X\u2082 X\u2083 : C} (z\u2081\u2082 : roof W X\u2081 X\u2082) (z\u2082\u2083 : roof W X\u2082 X\u2083) :\n  hom W X\u2081 X\u2083 :=\nquot.mk _ (roof.comp\u2080 z\u2081\u2082 z\u2082\u2083 (left_calculus_of_fractions.ex z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f).some)\n\nlemma roof.comp_eq {X\u2081 X\u2082 X\u2083 : C} (z\u2081\u2082 : roof W X\u2081 X\u2082) (z\u2082\u2083 : roof W X\u2082 X\u2083)\n  (sq : to_sq z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f) :\n  roof.comp z\u2081\u2082 z\u2082\u2083 = quot.mk _ (roof.comp\u2080 z\u2081\u2082 z\u2082\u2083 sq) :=\nquot.sound (roof.comp\u2080_rel z\u2081\u2082 z\u2082\u2083 _ _)\n\ndef hom.comp {X\u2081 X\u2082 X\u2083 : C} : hom W X\u2081 X\u2082 \u2192 hom W X\u2082 X\u2083 \u2192 hom W X\u2081 X\u2083 :=\nbegin\n  refine quot.lift\u2082 (\u03bb z\u2081\u2082 z\u2082\u2083, roof.comp z\u2081\u2082 z\u2082\u2083) (\u03bb z\u2081\u2082 z\u2082\u2083 z\u2082\u2083' h\u2082\u2083, _)\n    (\u03bb z\u2081\u2082 z\u2081\u2082' z\u2082\u2083 h\u2081\u2082, _),\n  { dsimp,\n    let sq := (left_calculus_of_fractions.ex z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f).some,\n    let sq' := (left_calculus_of_fractions.ex z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083'.f).some,\n    rw [roof.comp_eq _ _ sq, roof.comp_eq _ _ sq'],\n    apply quot.sound,\n    rcases h\u2082\u2083 with \u27e8Y, t, t', hst, hft, ht\u27e9,\n    let H\u2080 := (left_calculus_of_fractions.ex sq.s' sq.hs' t).some,\n    let H\u2080' := (left_calculus_of_fractions.ex sq'.s' sq'.hs' t').some,\n    have h : W (z\u2082\u2083.s \u226b sq.s' \u226b H\u2080.g),\n    { rw [\u2190 H\u2080.fac, \u2190 assoc],\n      exact left_calculus_of_fractions.comp _ _ _ ht H\u2080.hs', },\n    let H\u2081 := (left_calculus_of_fractions.ex H\u2080.s' H\u2080.hs' H\u2080'.s').some,\n    have eq : z\u2081\u2082.s \u226b sq.g \u226b H\u2080.g \u226b H\u2081.g = z\u2081\u2082.s \u226b sq'.g \u226b H\u2080'.g \u226b H\u2081.s',\n    { simp only [\u2190 reassoc_of sq.fac, \u2190 reassoc_of sq'.fac,\u2190 reassoc_of H\u2080.fac,\n        \u2190 reassoc_of H\u2080'.fac, reassoc_of hft, H\u2081.fac], },\n    rcases left_calculus_of_fractions.ext _ _ _ z\u2081\u2082.hs eq with \u27e8Z, u, hu, fac\u27e9,\n    simp only [assoc] at fac,\n    refine \u27e8Z, H\u2080.g \u226b H\u2081.g \u226b u, H\u2080'.g \u226b H\u2081.s' \u226b u, _, _, _\u27e9; dsimp [roof.comp\u2080],\n    { simp only [assoc, \u2190 reassoc_of H\u2080.fac, \u2190 reassoc_of H\u2080'.fac,\n        reassoc_of hst, reassoc_of H\u2081.fac], },\n    { simp only [assoc, fac], },\n    { simp only [assoc],\n      rw [\u2190 reassoc_of H\u2080.fac, \u2190 reassoc_of H\u2081.fac, \u2190 assoc],\n      refine left_calculus_of_fractions.comp _ _ _ ht\n        (left_calculus_of_fractions.comp _ _ _ H\u2080'.hs'\n          (left_calculus_of_fractions.comp _ _ _ H\u2081.hs' hu)), }, },\n  { dsimp,\n    let sq := (left_calculus_of_fractions.ex z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f).some,\n    let sq' := (left_calculus_of_fractions.ex z\u2081\u2082'.s z\u2081\u2082'.hs z\u2082\u2083.f).some,\n    rw [roof.comp_eq _ _ sq, roof.comp_eq _ _ sq'],\n    apply quot.sound,\n    rcases h\u2081\u2082 with \u27e8Y, t, t', hst, hft, ht\u27e9,\n    let H := (left_calculus_of_fractions.ex (z\u2081\u2082.s \u226b t) ht (z\u2082\u2083.f \u226b sq.s')).some,\n    let H' := (left_calculus_of_fractions.ex (z\u2081\u2082'.s \u226b t') (by { rw \u2190 hst, exact ht, })\n      (z\u2082\u2083.f \u226b sq'.s')).some,\n    let z : roof W X\u2081 X\u2083 := \u27e8H.obj, z\u2081\u2082.f \u226b t \u226b H.g, z\u2082\u2083.s \u226b sq.s' \u226b H.s',\n      left_calculus_of_fractions.comp _ _ _ z\u2082\u2083.hs\n        (left_calculus_of_fractions.comp _ _ _ sq.hs' H.hs')\u27e9,\n    let z' : roof W X\u2081 X\u2083 := \u27e8H'.obj, z\u2081\u2082'.f \u226b t' \u226b H'.g, z\u2082\u2083.s \u226b sq'.s' \u226b H'.s',\n      left_calculus_of_fractions.comp _ _ _ z\u2082\u2083.hs\n        (left_calculus_of_fractions.comp _ _ _ sq'.hs' H'.hs')\u27e9,\n    refine trans _ (trans (_ : roof_rel z z') (symm _)),\n    { have eq : z\u2081\u2082.s \u226b sq.g \u226b H.s' = z\u2081\u2082.s \u226b t \u226b H.g,\n      { have h := H.fac,\n        simp only [assoc] at h,\n        rw [\u2190 h, reassoc_of sq.fac], },\n      rcases left_calculus_of_fractions.ext _ _ _ z\u2081\u2082.hs eq with \u27e8Z, u, hu, fac\u27e9,\n      simp only [assoc] at fac,\n      refine \u27e8Z, H.s' \u226b u, u, _,_, _\u27e9; dsimp [roof.comp\u2080],\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\u2082\u2083.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' \u226b H.s')\n        (left_calculus_of_fractions.comp _ _ _ sq.hs' H.hs') (sq'.s' \u226b 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\u2081\u2082.s \u226b t \u226b H.g \u226b T.g = z\u2081\u2082.s \u226b t \u226b H'.g \u226b T.s',\n      { simp only [reassoc_of hst, \u2190 reassoc_of fac', Tfac, reassoc_of fac], },\n      rcases left_calculus_of_fractions.ext _ _ _ z\u2081\u2082.hs eq with \u27e8Z, u, hu, fac''\u27e9,\n      simp only [assoc] at fac'',\n      refine \u27e8Z, T.g \u226b u, T.s' \u226b u, _, _, _\u27e9; dsimp [z, z'],\n      { simp only [assoc, reassoc_of Tfac], },\n      { rw [assoc, assoc, assoc, assoc, fac'', reassoc_of hft], },\n      { simp only [assoc, \u2190 reassoc_of Tfac],\n        exact left_calculus_of_fractions.comp _ _ _ z\u2082\u2083.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\u2081\u2082'.s \u226b sq'.g \u226b H'.s' = z\u2081\u2082'.s \u226b t' \u226b H'.g,\n      { have h := H'.fac,\n        simp only [assoc] at h,\n        rw [\u2190 h, reassoc_of sq'.fac], },\n      rcases left_calculus_of_fractions.ext _ _ _ z\u2081\u2082'.hs eq with \u27e8Z, u, hu, fac\u27e9,\n      simp only [assoc] at fac,\n      refine \u27e8Z, H'.s' \u226b u, u, _,_, _\u27e9; dsimp [roof.comp\u2080],\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\u2082\u2083.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\u2081 X\u2082 X\u2083 : C} (z\u2081\u2082 : roof W X\u2081 X\u2082) (z\u2082\u2083 : roof W X\u2082 X\u2083)\n  (sq : to_sq z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f) : hom.comp (quot.mk _ z\u2081\u2082) (quot.mk _ z\u2082\u2083) =\n  quot.mk _ (roof.comp\u2080 z\u2081\u2082 z\u2082\u2083 sq) :=\nbegin\n  let sq' := (left_calculus_of_fractions.ex z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f).some,\n  have eq : (quot.mk _ (z\u2081\u2082.comp\u2080 z\u2082\u2083 sq) : hom W _ _) = quot.mk _ (z\u2081\u2082.comp\u2080 z\u2082\u2083 sq'),\n  { rw [\u2190 roof.comp_eq, \u2190 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 := \u03bb X Y, hom W X.obj Y.obj,\n  id := \u03bb X, quot.mk _ (roof.id W X.obj),\n  comp := \u03bb X\u2081 X\u2082 X\u2083, hom.comp,\n  id_comp' := \u03bb 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 (\ud835\udfd9 X.obj) (morphism_property.contains_identities.id W X.obj) g.f :=\n      \u27e8g.Z, g.f, \ud835\udfd9 g.Z, morphism_property.contains_identities.id W g.Z, by rw [id_comp, comp_id]\u27e9,\n    rw roof.comp_eq (roof.id W X.obj) g sq,\n    congr' 1,\n    dsimp [roof.comp\u2080],\n    cases g,\n    tidy,\n  end,\n  comp_id' := \u03bb 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 (\ud835\udfd9 Y.obj) := \u27e8g.Z, \ud835\udfd9 g.Z, g.s, g.hs, by rw [id_comp, comp_id]\u27e9,\n    rw roof.comp_eq g (roof.id W Y.obj) sq,\n    congr' 1,\n    dsimp [roof.comp\u2080],\n    cases g,\n    tidy,\n  end,\n  assoc' := \u03bb X\u2081 X\u2082 X\u2083 X\u2084 f\u2081\u2082 f\u2082\u2083 f\u2083\u2084, begin\n    cases surjective_quot_mk _ f\u2081\u2082 with z\u2081\u2082 h\u2081\u2082,\n    cases surjective_quot_mk _ f\u2082\u2083 with z\u2082\u2083 h\u2082\u2083,\n    cases surjective_quot_mk _ f\u2083\u2084 with z\u2083\u2084 h\u2083\u2084,\n    let sq\u2081\u2083 := (left_calculus_of_fractions.ex z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f).some,\n    let sq\u2082\u2084 := (left_calculus_of_fractions.ex z\u2082\u2083.s z\u2082\u2083.hs z\u2083\u2084.f).some,\n    dsimp,\n    let H := (left_calculus_of_fractions.ex sq\u2081\u2083.s' sq\u2081\u2083.hs' sq\u2082\u2084.g).some,\n    let sq : to_sq (z\u2081\u2082.comp\u2080 z\u2082\u2083 sq\u2081\u2083).s (z\u2081\u2082.comp\u2080 z\u2082\u2083 sq\u2081\u2083).hs z\u2083\u2084.f := begin\n      refine \u27e8H.obj, H.g, sq\u2082\u2084.s' \u226b H.s', left_calculus_of_fractions.comp _ _ _ sq\u2082\u2084.hs' H.hs', _\u27e9,\n      dsimp [roof.comp\u2080],\n      rw [assoc, \u2190 H.fac, reassoc_of sq\u2082\u2084.fac],\n    end,\n    let sq' : to_sq z\u2081\u2082.s z\u2081\u2082.hs (z\u2082\u2083.comp\u2080 z\u2083\u2084 sq\u2082\u2084).f := begin\n      refine \u27e8H.obj, sq\u2081\u2083.g \u226b H.g, H.s', H.hs', _\u27e9,\n      dsimp [roof.comp\u2080],\n      rw [assoc, H.fac, reassoc_of sq\u2081\u2083.fac],\n    end,\n    simp only [\u2190 h\u2081\u2082, \u2190 h\u2082\u2083, \u2190 h\u2083\u2084],\n    rw [hom.comp_eq z\u2081\u2082 z\u2082\u2083 sq\u2081\u2083, hom.comp_eq z\u2082\u2083 z\u2083\u2084 sq\u2082\u2084,\n      hom.comp_eq (z\u2081\u2082.comp\u2080 z\u2082\u2083 sq\u2081\u2083) z\u2083\u2084 sq, hom.comp_eq z\u2081\u2082 (z\u2082\u2083.comp\u2080 z\u2083\u2084 sq\u2082\u2084) sq'],\n    congr' 1,\n    dsimp [roof.comp\u2080],\n    tidy,\n  end, }\n\nvariable {W}\n\ndef roof.hom {X Y : localization W} (z : roof W X.obj Y.obj) : X \u27f6 Y := quot.mk _ z\n\ndef map_roof {D : Type*} [category D] (F : C \u2964 D) (hF : W.is_inverted_by F)\n  {X Y : C} (z : roof W X Y) : F.obj X \u27f6 F.obj Y :=\nF.map z.f \u226b by { haveI := hF z.s z.hs, exact inv (F.map z.s), }\n\nnamespace localization\n\nlemma comp_eq {X\u2081 X\u2082 X\u2083 : localization W} (z\u2081\u2082 : roof W X\u2081.obj X\u2082.obj) (z\u2082\u2083 : roof W X\u2082.obj X\u2083.obj)\n  (sq : to_sq z\u2081\u2082.s z\u2081\u2082.hs z\u2082\u2083.f) : z\u2081\u2082.hom \u226b z\u2082\u2083.hom = (roof.comp\u2080 z\u2081\u2082 z\u2082\u2083 sq).hom :=\nhom.comp_eq z\u2081\u2082 z\u2082\u2083 sq\n\nvariable (W)\n\ndef hom_obj {X Y : C} (f : X \u27f6 Y) :\n  (\u27e8X\u27e9 : localization W).obj \u27f6 (\u27e8Y\u27e9 : localization W).obj := f\n\n@[simps]\ndef Q : C \u2964 localization W :=\n{ obj := \u03bb X, \u27e8X\u27e9,\n  map := \u03bb X Y f, (roof.of_hom W (hom_obj W f)).hom,\n  map_comp' := \u03bb X\u2081 X\u2082 X\u2083 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      \u27e8X\u2083, g, \ud835\udfd9 X\u2083, morphism_property.contains_identities.id W X\u2083, by tidy\u27e9,\n    dsimp [roof.of_hom, roof.comp\u2080],\n    congr' 1,\n    tidy,\n  end, }\n\nvariable {W}\n\n@[simps]\ndef roof.inv {X Y : C} (s : X \u27f6 Y) (hs : W s) :\n  roof W (\u27e8Y\u27e9 : localization W).obj (\u27e8X\u27e9 : localization W).obj := \u27e8Y, \ud835\udfd9 Y, s, hs\u27e9\n\ndef inv_Q_map {X Y : C} (s : X \u27f6 Y) (hs : W s) : (Q W).obj Y \u27f6 (Q W).obj X :=\nroof.hom (roof.inv s hs)\n\nlemma comp_inv_Q_map {X Y : C} (s : X \u27f6 Y) (hs : W s) :\n  (Q W).map s \u226b inv_Q_map s hs = \ud835\udfd9 _ :=\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    \u27e8Y, \ud835\udfd9 Y, \ud835\udfd9 Y, morphism_property.contains_identities.id W Y, rfl\u27e9,\n  dsimp [roof.comp\u2080],\n  exact quot.sound \u27e8Y, \ud835\udfd9 Y, s, by tidy, by tidy, by tidy\u27e9,\nend\n\nlemma inv_Q_map_comp {X Y : C} (s : X \u27f6 Y) (hs : W s) :\n   inv_Q_map s hs \u226b (Q W).map s = \ud835\udfd9 _ :=\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    \u27e8Y, \ud835\udfd9 Y, \ud835\udfd9 Y, morphism_property.contains_identities.id W Y, rfl\u27e9,\n  dsimp [roof.comp\u2080],\n  exact quot.sound \u27e8Y, \ud835\udfd9 Y, \ud835\udfd9 Y, by tidy, by tidy,\n    by { dsimp, simp only [comp_id], exact morphism_property.contains_identities.id W _, }\u27e9,\nend\n\nvariable (W)\n\nlemma Q_inverts_W : W.is_inverted_by (Q W) :=\n\u03bb X Y s hs, \u27e8\u27e8inv_Q_map s hs, comp_inv_Q_map s hs, inv_Q_map_comp s hs\u27e9\u27e9\n\nlemma inv_Q_map_eq {X Y : C} (s : X \u27f6 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 [\u2190 cancel_mono ((Q W).map s), is_iso.inv_hom_id, inv_Q_map_comp],\nend\n\ninstance {X Y : C} (s : X \u27f6 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) : \ud835\udfd9 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 \u2190 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    \u27e8z.Z, \ud835\udfd9 _, \ud835\udfd9 _, morphism_property.contains_identities.id W _, rfl\u27e9,\n  dsimp [roof.of_hom, roof.comp\u2080, 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 \u27f6 (Q W).obj Y) :\n  \u2203 (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 \u27e8z, (map_roof_eq z).symm\u27e9,\nend\n\nvariable {W}\n\ndef lift {D : Type*} [category D] (F : C \u2964 D) (hF : W.is_inverted_by F) :\n  localization W \u2964 D :=\n{ obj := \u03bb X, F.obj X.obj,\n  map := \u03bb X Y, quot.lift (\u03bb (f : roof W X.obj Y.obj),\n    by { haveI := hF f.s f.hs, exact F.map f.f \u226b inv (F.map f.s)})\n    (\u03bb z z' (h : roof_rel z z'), begin\n      dsimp,\n      rcases h with \u27e8Y, t\u2081, t\u2082, hst, hft, ht\u27e9,\n      haveI := hF _ ht,\n      rw [\u2190 cancel_mono (F.map (z.s \u226b t\u2081)), 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        \u2190 F.map_comp z'.f, \u2190 hft, F.map_comp],\n    end),\n  map_comp' := \u03bb X\u2081 X\u2082 X\u2083 f\u2081 f\u2082, begin\n    dsimp,\n    cases surjective_quot_mk _ f\u2081 with g\u2081 h\u2081,\n    cases surjective_quot_mk _ f\u2082 with g\u2082 h\u2082,\n    substs h\u2081 h\u2082,\n    let sq := (left_calculus_of_fractions.ex g\u2081.s g\u2081.hs g\u2082.f).some,\n    erw comp_eq g\u2081 g\u2082 sq,\n    dsimp [roof.comp\u2080, roof.hom],\n    simp only [functor.map_comp, assoc],\n    haveI := hF g\u2081.s g\u2081.hs,\n    haveI := hF g\u2082.s g\u2082.hs,\n    haveI := hF sq.s' sq.hs',\n    rw is_iso.inv_comp,\n    congr' 1,\n    simp only [\u2190 cancel_mono (F.map g\u2082.s), \u2190 cancel_mono (F.map sq.s'), \u2190 cancel_epi (F.map g\u2081.s),\n      assoc, is_iso.inv_hom_id, comp_id, is_iso.hom_inv_id_assoc, \u2190 F.map_comp, sq.fac],\n  end, }\n\nlemma fac {D : Type*} [category D] (F : C \u2964 D) (hF : W.is_inverted_by F) :\n  Q W \u22d9 lift F hF = F :=\nfunctor.ext (\u03bb X, rfl) (\u03bb 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\u2081 F\u2082 : localization W \u2964 D) (h : Q W \u22d9 F\u2081 = Q W \u22d9 F\u2082) :\n  F\u2081 = F\u2082 :=\nbegin\n  have eq : \u2200 (X : localization W), F\u2081.obj X = F\u2082.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 \u27e8\u03c6, h\u03c6\u27e9,\n  subst f,\n  have eq\u2081 := functor.congr_map_conjugate h \u03c6.f,\n  have eq\u2082 := functor.congr_map_conjugate h \u03c6.s,\n  dsimp only [functor.comp_map] at eq\u2081 eq\u2082,\n  dsimp only [map_roof],\n  simpa only [functor.map_comp, functor.map_inv, eq\u2081, eq\u2082, 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\u2081 : C \u2964 D) (hL\u2081 : W.is_inverted_by L\u2081) (L\u2082 : C \u2964 E) (hL\u2082 : W.is_inverted_by L\u2082)\n  (M : D \u2964 E) (e : L\u2081 \u22d9 M \u2245 L\u2082) {X Y : C} (z : roof W X Y) :\n  map_roof L\u2082 hL\u2082 z = e.inv.app X \u226b M.map (map_roof L\u2081 hL\u2081 z) \u226b e.hom.app Y :=\nbegin\n  dsimp [map_roof],\n  simp only [M.map_comp, assoc],\n  erw \u2190 e.inv.naturality_assoc,\n  congr' 1,\n  haveI := hL\u2082 z.s z.hs,\n  simp only [\u2190 cancel_mono (L\u2082.map z.s), is_iso.inv_hom_id, functor.map_inv, assoc,\n    \u2190 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\u2081 : C \u2964 D) (hL\u2081 : W.is_inverted_by L\u2081) (L\u2082 : C \u2964 E) (hL\u2082 : W.is_inverted_by L\u2082)\n  (M : D \u2964 E) (e : L\u2081 \u22d9 M \u2245 L\u2082) {X Y : C} (z z' : roof W X Y)\n  (eq : map_roof L\u2081 hL\u2081 z = map_roof L\u2081 hL\u2081 z') :\n  map_roof L\u2082 hL\u2082 z = map_roof L\u2082 hL\u2082 z' :=\nby simp only [map_roof_compatibility L\u2081 hL\u2081 L\u2082 hL\u2082 M e, eq]\n\nlemma L_map_fac {D : Type*} [category D] (L : C \u2964 D) (W : morphism_property C)\n  [left_calculus_of_fractions W] [L.is_localization W] {X Y : C} (f : L.obj X \u27f6 L.obj Y) :\n  \u2203 (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 \u22d9 E.functor \u2245 L :=\n    localization.comp_uniq_equivalence_functor_iso W (localization.Q W) L,\n  let f' := e.hom.app X \u226b f \u226b 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 \u27e8z, _\u27e9,\n  simp only [map_roof_compatibility (localization.Q W) (localization.inverts _ W)\n    L (localization.inverts _ W) E.functor e, \u2190 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 \u2964 D) {W : morphism_property C}\n  [left_calculus_of_fractions W] [L.is_localization W] {X Y : C} (z\u2081 z\u2082 : roof W X Y) :\n  map_roof L (localization.inverts L W) z\u2081 =\n    map_roof L (localization.inverts L W) z\u2082 \u2194 roof_rel z\u2081 z\u2082 :=\nbegin\n  have eq : map_roof L (localization.inverts _ W) z\u2081 =\n      map_roof L (localization.inverts _ W) z\u2082 \u2194\n    map_roof (localization.Q W) (localization.inverts _ W) z\u2081 =\n      map_roof (localization.Q W) (localization.inverts _ W) z\u2082,\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\u2081 s\u2082 h s s\u2081 s\u2082 h' h s\u2081 s\u2082 s\u2083 h'\u2081 h'\u2082 h\u2081 h\u2082,\n    exacts [h, roof_rel.refl _, h.symm, h\u2081.trans h\u2082], },\n  { exact quot.sound, },\nend\n\nlemma L_map_eq_iff {D : Type*} [category D] (L : C \u2964 D) (W : morphism_property C)\n  [left_calculus_of_fractions W] [L.is_localization W] {X Y : C} (f\u2081 f\u2082 : X \u27f6 Y) :\n  L.map f\u2081 = L.map f\u2082 \u2194 \u2203 (Z : C) (s : Y \u27f6 Z) (hs : W s), f\u2081 \u226b s = f\u2082 \u226b s :=\nbegin\n  split,\n  { intro h,\n    rcases (L_map_roof_eq_iff L\n      (roof.mk Y f\u2081 (\ud835\udfd9 Y) (morphism_property.contains_identities.id W Y))\n      (roof.mk Y f\u2082 (\ud835\udfd9 Y) (morphism_property.contains_identities.id W Y))).mp\n      (by { dsimp [map_roof], rw h, }) with \u27e8Z, t\u2081, t\u2082, hst, hft, ht\u27e9,\n    dsimp at t\u2081 t\u2082 ht hst hft,\n    simp only [id_comp] at ht hst,\n    refine \u27e8Z, t\u2081, ht, by rw [hft, hst]\u27e9, },\n  { rintro \u27e8Z, s, hs, eq\u27e9,\n    haveI := localization.inverts L W s hs,\n    simp only [\u2190 cancel_mono (L.map s), \u2190 L.map_comp, eq], },\nend\n\nsection\n\nvariables {D : Type*} [category D] (L : C \u2964 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  \u2203 (g : arrow C), nonempty (f \u2245 L.map_arrow.obj g) :=\nbegin\n  haveI : ess_surj L := localization.ess_surj L W',\n  let e\u2081 := L.obj_obj_preimage_iso _,\n  let e\u2082 := L.obj_obj_preimage_iso _,\n  let f' := e\u2081.hom \u226b f.hom \u226b e\u2082.inv,\n  rcases L_map_fac L W' f' with \u27e8z, hz\u27e9,\n  refine \u27e8arrow.mk z.f, nonempty.intro _\u27e9,\n  haveI := localization.inverts L W' z.s z.hs,\n  refine arrow.iso_mk e\u2081.symm (e\u2082.symm \u226a\u226b as_iso (L.map z.s)) _,\n  dsimp [map_roof] at hz \u22a2,\n  simp only [\u2190 cancel_mono (inv (L.map z.s)), assoc, \u2190 hz, is_iso.hom_inv_id, comp_id,\n    \u2190 cancel_epi e\u2081.hom, e\u2081.hom_inv_id_assoc],\nend\n\ndef lift_map\u2081 {X Y : D} (f : X \u27f6 Y) : C := (exists_lift_arrow L W' (arrow.mk f)).some.left\ndef lift_map\u2082 {X Y : D} (f : X \u27f6 Y) : C := (exists_lift_arrow L W' (arrow.mk f)).some.right\ndef lift_map {X Y : D} (f : X \u27f6 Y) : lift_map\u2081 L W' f \u27f6 lift_map\u2082 L W' f :=\n(exists_lift_arrow L W' (arrow.mk f)).some.hom\ndef map_lift_map_iso {X Y : D} (f : X \u27f6 Y) :\n  arrow.mk f \u2245 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\u2081 {X Y : D} (f : X \u27f6 Y) : X \u2245 L.obj (lift_map\u2081 L W' f) :=\narrow.left_func.map_iso (map_lift_map_iso L W' f)\ndef lift_map_iso\u2082 {X Y : D} (f : X \u27f6 Y) : Y \u2245 L.obj (lift_map\u2082 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 \u27f6 Y) : f \u226b (lift_map_iso\u2082 L W' f).hom =\n  (lift_map_iso\u2081 L W' f).hom \u226b 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' \u27f6 Y) (hs : W s) (f : X \u27f6 Y) :=\n(obj : C)\n(g : obj \u27f6 Y')\n(s' : obj \u27f6 X)\n(hs' : W s')\n(fac : s' \u226b f = g \u226b s)\n\nvariable (W)\n\nclass right_calculus_of_fractions : Prop :=\n(id : W.contains_identities)\n(comp : W.stable_under_composition)\n(ex : \u2200 \u2983X Y Y' : C\u2984 (s : Y' \u27f6 Y) (hs : W s) (u : X \u27f6 Y),\n  nonempty (right_calculus_of_fractions.to_sq s hs u))\n(ext : \u2200 \u2983X Y Y' : C\u2984 (f\u2081 f\u2082 : X \u27f6 Y) (s : Y \u27f6 Y') (hs : W s) (eq : f\u2081 \u226b s = f\u2082 \u226b s),\n  \u2203 (X' : C) (t : X' \u27f6 X) (ht : W t), t \u226b f\u2081 = t \u226b f\u2082)\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 := \u03bb X Y Y' s hs u, begin\n    let sq := (h.ex s.unop hs u.unop).some,\n    exact nonempty.intro \u27e8opposite.op sq.obj, sq.g.op, sq.s'.op, sq.hs',\n      quiver.hom.unop_inj sq.fac\u27e9,\n  end,\n  ext := \u03bb X Y Y' f\u2081 f\u2082 s hs eq, begin\n    rcases h.ext f\u2081.unop f\u2082.unop s.unop hs (by simp only [\u2190 unop_comp, eq])\n      with \u27e8X', t, ht, fac\u27e9,\n    exact \u27e8opposite.op X', t.op, ht, quiver.hom.unop_inj fac\u27e9,\n  end, }\n\ndef left_calculus_of_fractions.unop {W : morphism_property C\u1d52\u1d56}\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 := \u03bb X Y Y' s hs u, begin\n    let sq := (h.ex s.op hs u.op).some,\n    exact nonempty.intro \u27e8opposite.unop sq.obj, sq.g.unop, sq.s'.unop, sq.hs',\n      quiver.hom.op_inj sq.fac\u27e9,\n  end,\n  ext := \u03bb X Y Y' f\u2081 f\u2082 s hs eq, begin\n    rcases h.ext f\u2081.op f\u2082.op s.op hs (by simp only [\u2190 op_comp, eq])\n      with \u27e8X', t, ht, fac\u27e9,\n    exact \u27e8opposite.unop X', t.unop, ht, quiver.hom.op_inj fac\u27e9,\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 := \u03bb X' X Y s hs u, begin\n    let sq := (h.ex s.unop hs u.unop).some,\n    exact nonempty.intro \u27e8opposite.op sq.obj, sq.g.op, sq.s'.op, sq.hs',\n      quiver.hom.unop_inj sq.fac\u27e9,\n  end,\n  ext := \u03bb X' X Y f\u2081 f\u2082 s hs eq, begin\n    have pif := h.ext f\u2081.unop f\u2082.unop s.unop hs (by simp only [\u2190 unop_comp, eq]),\n    rcases h.ext f\u2081.unop f\u2082.unop s.unop hs (by simp only [\u2190 unop_comp, eq])\n      with \u27e8Y', t, ht, fac\u27e9,\n    exact \u27e8opposite.op Y', t.op, ht, quiver.hom.unop_inj fac\u27e9,\n  end, }\n\ndef right_calculus_of_fractions.unop {W : morphism_property C\u1d52\u1d56}\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 := \u03bb X' X Y s hs u, begin\n    let sq := (h.ex s.op hs u.op).some,\n    exact nonempty.intro \u27e8opposite.unop sq.obj, sq.g.unop, sq.s'.unop, sq.hs',\n      quiver.hom.op_inj sq.fac\u27e9,\n  end,\n  ext := \u03bb X' X Y f\u2081 f\u2082 s hs eq, begin\n    have pif := h.ext f\u2081.op f\u2082.op s.op hs (by simp only [\u2190 op_comp, eq]),\n    rcases h.ext f\u2081.op f\u2082.op s.op hs (by simp only [\u2190 op_comp, eq])\n      with \u27e8Y', t, ht, fac\u27e9,\n    exact \u27e8opposite.unop Y', t.unop, ht, quiver.hom.op_inj fac\u27e9,\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 \u27f6 X) (f : Z \u27f6 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\u27e8opposite.op z.Z, z.f.op, z.s.op, z.hs\u27e9\n\ndef roof_rel \u2983X Y : C\u2984 (z\u2081 z\u2082 : roof W X Y) : Prop :=\n\u2203 (Z\u2083 : C) (t\u2081 : Z\u2083 \u27f6 z\u2081.Z) (t\u2082 : Z\u2083 \u27f6 z\u2082.Z) (hts : t\u2081 \u226b z\u2081.s = t\u2082 \u226b z\u2082.s)\n  (htf : t\u2081 \u226b z\u2081.f = t\u2082 \u226b z\u2082.f), W (t\u2081 \u226b z\u2081.s)\n\nlemma roof_rel.iff_op {X Y : C} (z\u2081 z\u2082 : roof W X Y) :\n  roof_rel z\u2081 z\u2082 \u2194 left_calculus_of_fractions.roof_rel z\u2081.op z\u2082.op :=\nbegin\n  split,\n  { intro h,\n    rcases h with \u27e8Z\u2083, t\u2081, t\u2082, hts, htf, ht\u27e9,\n    exact \u27e8opposite.op Z\u2083, t\u2081.op, t\u2082.op, quiver.hom.unop_inj hts, quiver.hom.unop_inj htf, ht\u27e9, },\n  { intro h,\n    rcases h with \u27e8Z\u2083, t\u2081, t\u2082, hst, hft, ht\u27e9,\n    refine \u27e8opposite.unop Z\u2083, t\u2081.unop, t\u2082.unop, quiver.hom.op_inj hst, quiver.hom.op_inj hft, ht\u27e9, },\nend\n\nvariables (W) [right_calculus_of_fractions W]\n\n@[simps]\ndef roof.of_hom {X Y : C} (f : X \u27f6 Y) : roof W X Y :=\n\u27e8X, \ud835\udfd9 X, f, morphism_property.contains_identities.id W X\u27e9\n\n@[simps]\ndef roof.id (X : C) := roof.of_hom W (\ud835\udfd9 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\u2081 z\u2082 : roof W X Y} (h : roof_rel z\u2081 z\u2082) : roof_rel z\u2082 z\u2081 :=\nby { rw roof_rel.iff_op at h \u22a2, exact h.symm, }\n\nlemma trans {X Y : C} {z\u2081 z\u2082 z\u2083 : roof W X Y} (h\u2081\u2082 : roof_rel z\u2081 z\u2082)\n  (h\u2082\u2083 : roof_rel z\u2082 z\u2083) : roof_rel z\u2081 z\u2083 :=\nby { rw roof_rel.iff_op at h\u2081\u2082 h\u2082\u2083 \u22a2, exact h\u2081\u2082.trans h\u2082\u2083, }\n\nend roof_rel\n\ninstance is_equiv_roof_rel (X Y : C) :\n  is_equiv (roof W X Y) (\u03bb z\u2081 z\u2082, roof_rel z\u2081 z\u2082) :=\n{ refl := roof_rel.refl,\n  symm := \u03bb z\u2081 z\u2082, roof_rel.symm,\n  trans := \u03bb z\u2081 z\u2082 z\u2083, 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\u27e8opposite.unop z.Z, z.s.unop, z.f.unop, z.hs\u27e9\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 \u2964 D) (hF : W.is_inverted_by F)\n  {X Y : C} (z : roof W X Y) : F.obj X \u27f6 F.obj Y :=\nby { haveI := hF z.s z.hs, exact inv (F.map z.s), } \u226b F.map z.f\n\nlemma map_roof_eq_unop_map_roof_op {D : Type*} [category D] (F : C \u2964 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 \u2964 D) (W : morphism_property C)\n  [right_calculus_of_fractions W]\n  [L.is_localization W] {X Y : C} (f : L.obj X \u27f6 L.obj Y) :\n  \u2203 (z : roof W X Y), f = map_roof L (localization.inverts L W) z :=\nbegin\n  let f' : L.op.obj (opposite.op Y) \u27f6 L.op.obj (opposite.op X) := f.op,\n  rcases left_calculus_of_fractions.L_map_fac L.op W.op f' with \u27e8z, hz\u27e9,\n  refine \u27e8z.unop, _\u27e9,\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 \u2964 D) {W : morphism_property C}\n  [right_calculus_of_fractions W] [L.is_localization W]\n  {X Y : C} (z\u2081 z\u2082 : roof W X Y) :\n  map_roof L (localization.inverts L W) z\u2081 =\n    map_roof L (localization.inverts L W) z\u2082 \u2194 roof_rel z\u2081 z\u2082 :=\nbegin\n  simp only [roof_rel.iff_op, \u2190 left_calculus_of_fractions.L_map_roof_eq_iff L.op z\u2081.op,\n    map_roof_eq_unop_map_roof_op],\n  exact \u27e8\u03bb h, quiver.hom.unop_inj h, \u03bb h, quiver.hom.op_inj h\u27e9,\nend\n\nlemma L_map_eq_iff {D : Type*} [category D] (L : C \u2964 D) (W : morphism_property C)\n  [right_calculus_of_fractions W] [L.is_localization W] {Y Z : C} (f\u2081 f\u2082 : Y \u27f6 Z) :\n  L.map f\u2081 = L.map f\u2082 \u2194 \u2203 (X : C) (s : X \u27f6 Y) (hs : W s), s \u226b f\u2081 = s \u226b f\u2082 :=\nbegin\n  split,\n  { intro h,\n    rcases (L_map_roof_eq_iff L\n      (roof.mk Y (\ud835\udfd9 Y) f\u2081 (morphism_property.contains_identities.id W Y))\n      (roof.mk Y (\ud835\udfd9 Y) f\u2082 (morphism_property.contains_identities.id W Y))).mp\n      (by { dsimp [map_roof], rw h, }) with \u27e8Z, t\u2081, t\u2082, hts, htf, ht\u27e9,\n    dsimp at t\u2081 t\u2082 ht hts htf,\n    simp only [comp_id] at ht hts,\n    exact \u27e8Z, t\u2081, ht, by rw [htf, hts]\u27e9, },\n  { rintro \u27e8Z, s, hs, eq\u27e9,\n    haveI := localization.inverts L W s hs,\n    simp only [\u2190 cancel_epi (L.map s), \u2190 L.map_comp, eq], },\nend\n\nend right_calculus_of_fractions\n\nvariable (W)\n\nclass morphism_property.is_saturated : Prop :=\n(condition' : \u2200 \u2983X Y Z T : C\u2984 (f : X \u27f6 Y) (g : Y \u27f6 Z) (h : Z \u27f6 T) (hfg : W (f \u226b g))\n  (hgh : W (g \u226b h)), W g)\n\nlemma morphism_property.is_saturated.condition [W.is_saturated] {X Y Z T : C}\n  (f : X \u27f6 Y) (g : Y \u27f6 Z) (h : Z \u27f6 T) (hfg : W (f \u226b g))\n  (hgh : W (g \u226b 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 \u2964 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 \u27f6 Y) :\n  is_iso (L.map f) \u2194 W f :=\nbegin\n  refine \u27e8_ ,\u03bb hf, localization.inverts L W f hf\u27e9,\n  introI,\n  rcases left_calculus_of_fractions.L_map_fac L W (inv (L.map f)) with \u27e8z\u2081, h\u2081\u27e9,\n  rcases right_calculus_of_fractions.L_map_fac L W (inv (L.map f)) with \u27e8z\u2082, h\u2082\u27e9,\n  dsimp [left_calculus_of_fractions.map_roof] at h\u2081,\n  dsimp [right_calculus_of_fractions.map_roof] at h\u2082,\n  rcases (left_calculus_of_fractions.L_map_roof_eq_iff L\n    (left_calculus_of_fractions.roof.mk _ (f \u226b z\u2081.f) z\u2081.s z\u2081.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, \u2190 h\u2081, is_iso.hom_inv_id],\n    end with \u27e8Z, t\u2081, t\u2081', hst, hft, H\u2081\u27e9,\n  rcases (right_calculus_of_fractions.L_map_roof_eq_iff L\n    (right_calculus_of_fractions.roof.mk _ z\u2082.s (z\u2082.f \u226b f) z\u2082.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, \u2190 reassoc_of h\u2082, is_iso.inv_hom_id],\n    end with \u27e8Z', t\u2082, t\u2082', hts, htf, H\u2082\u27e9,\n  dsimp at t\u2081 t\u2081' hst hft H\u2081 t\u2082 t\u2082' hts htf H\u2082,\n  simp only [assoc, id_comp, comp_id] at hst hft hts htf,\n  rw \u2190 hft at hst,\n  rw \u2190 htf at hts,\n  exact morphism_property.is_saturated.condition W (t\u2082 \u226b z\u2082.f)\n    f (z\u2081.f \u226b t\u2081) (by simpa only [assoc, \u2190 hts] using H\u2082)\n    (by simpa only [\u2190 hst] using H\u2081),\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 \u27f6 Y) :\n  mono f \u2194 function.injective f := sorry\n\ninstance {\u03b1 : Type u} : limits.has_coproducts_of_shape \u03b1 Ab.{u+1} := sorry\n\nvariables {C : Type (u+1)} [category.{u} C] (J : grothendieck_topology C)\n  (F : C\u1d52\u1d56 \u2964 Ab.{u+1}) (G : Sheaf J Ab.{u+1}) (\u03b7 : F \u27f6 G.val)\n\n-- TODO: This theorem may need additional assumptions on `J`.\ntheorem sheafify_lift_mono_iff :\n  mono (sheafify_lift J \u03b7 G.cond) \u2194\n  \u2200 (B : C) (t : F.obj (op B)), \u03b7.app (op B) t = 0 \u2192\n  (\u2203 W : (J.cover B), \u2200 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 : \u2200 B : C, ((J.sheafify_lift \u03b7 G.cond).app (op B)).ker = \u22a5, sorry,\n    specialize h B,\n    let t' := (J.to_sheafify F).app (op B) t,\n    have : t' \u2208 add_monoid_hom.ker ((J.sheafify_lift \u03b7 _).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 \u03b7 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}\u1d52\u1d56 \u2964 Ab.{u+1}) (G : Condensed.{u} Ab.{u+1})\nvariables (\u03b7 : F \u27f6 G.val)\n\ntheorem Condensed_Ab_sheafify_lift_mono_iff :\n  mono (sheafify_lift _ \u03b7 G.cond) \u2194\n  \u2200 (B : Profinite.{u}) (t : F.obj (op B)), \u03b7.app (op B) t = 0 \u2192\n    (\u2203 (\u03b1 : Type u) [fintype \u03b1] (X : \u03b1 \u2192 Profinite.{u}) (\u03c0 : \u03a0 a : \u03b1, X a \u27f6 B)\n      (surj : \u2200 b : B, \u2203 (a : \u03b1) (x : X a), \u03c0 a x = b),\n      \u2200 a : \u03b1, F.map (\u03c0 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 \u27e8W,hw\u27e9 := h,\n    rcases W with \u27e8W,hW\u27e9,\n    have HW : W \u2208 proetale_topology B := hW,\n    rcases hW with \u27e8W, \u27e8\u03b1, h\u03b1, X, \u03c0, surj, rfl\u27e9, h\u27e9,\n    use [\u03b1, h\u03b1, X, \u03c0, surj], intros a,\n    let W' : proetale_topology.cover B := \u27e8W,HW\u27e9,\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 \u27e8\u03b1, h\u03b1, X, \u03c0, surj, hh\u27e9 := h,\n    refine \u27e8\u27e8sieve.generate (presieve.of_arrows X \u03c0),_\u27e9,_\u27e9,\n    constructor, use [\u03b1, h\u03b1, X, \u03c0, surj], exact sieve.le_generate (presieve.of_arrows X \u03c0),\n    rintros \u27e8X,f,\u27e8W,e1,e2,hhh,rfl\u27e9\u27e9,\n    dsimp, simp only [F.map_comp, comp_apply],\n    obtain \u27e8a\u27e9 := 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 field_theory.galois\nimport order.filter.ultrafilter\n\nexample (X Y Z : Type*) (f : X \u2192 Y) (g : Y \u2192 Z) (s : set Z) :\nf\u207b\u00b9' (g\u207b\u00b9' s) = (g \u2218 f)\u207b\u00b9' s :=\nbegin\n  refl,\nend\n", "meta": {"author": "Sebastian-Monnet", "repo": "galois-group-topology", "sha": "65bca7563dea0b37cddb4c45346f6cacba4e2dbe", "save_path": "github-repos/lean/Sebastian-Monnet-galois-group-topology", "path": "github-repos/lean/Sebastian-Monnet-galois-group-topology/galois-group-topology-65bca7563dea0b37cddb4c45346f6cacba4e2dbe/src/scratch.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.546738151984614, "lm_q2_score": 0.4571367168274948, "lm_q1q2_score": 0.24993408376257828}}
{"text": "/-\nCopyright (c) 2021 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Gabriel Ebner\n-/\nimport Lean\nimport Std.Util.TermUnsafe\nimport Std.Tactic.OpenPrivate\n\n/-!\nDefines a command wrapper that prints the changes the command makes to the\nenvironment.\n\n```\nwhatsnew in\ntheorem foo : 42 = 6 * 7 := rfl\n```\n-/\n\nopen Lean Elab Command\n\nnamespace Mathlib.WhatsNew\n\nprivate def throwUnknownId (id : Name) : CommandElabM Unit :=\n  throwError \"unknown identifier '{mkConst id}'\"\n\nprivate def levelParamsToMessageData (levelParams : List Name) : MessageData :=\n  match levelParams with\n  | []    => \"\"\n  | u::us => Id.run <| do\n    let mut m := m!\".\\{{u}\"\n    for u in us do\n      m := m ++ \", \" ++ toMessageData u\n    return m ++ \"}\"\n\nprivate def mkHeader (kind : String) (id : Name) (levelParams : List Name) (type : Expr)\n    (safety : DefinitionSafety) : CoreM MessageData := do\n  let m : MessageData :=\n    match safety with\n    | DefinitionSafety.unsafe  => \"unsafe \"\n    | DefinitionSafety.partial => \"partial \"\n    | DefinitionSafety.safe    => \"\"\n  let m := if isProtected (\u2190 getEnv) id then m ++ \"protected \" else m\n  let (m, id) := match privateToUserName? id with\n    | some id => (m ++ \"private \", id)\n    | none    => (m, id)\n  let m := m ++ kind ++ \" \" ++ id ++ levelParamsToMessageData levelParams ++ \" : \" ++ type\n  pure m\n\nprivate def mkHeader' (kind : String) (id : Name) (levelParams : List Name) (type : Expr)\n    (isUnsafe : Bool) : CoreM MessageData :=\n  mkHeader kind id levelParams type\n    (if isUnsafe then DefinitionSafety.unsafe else DefinitionSafety.safe)\n\nprivate def printDefLike (kind : String) (id : Name) (levelParams : List Name) (type : Expr)\n    (value : Expr) (safety := DefinitionSafety.safe) : CoreM MessageData :=\n  return (\u2190 mkHeader kind id levelParams type safety) ++ \" :=\" ++ Format.line ++ value\n\nprivate def printInduct (id : Name) (levelParams : List Name) (_numParams : Nat) (_numIndices : Nat)\n    (type : Expr) (ctors : List Name) (isUnsafe : Bool) : CoreM MessageData := do\n  let mut m \u2190 mkHeader' \"inductive\" id levelParams type isUnsafe\n  m := m ++ Format.line ++ \"constructors:\"\n  for ctor in ctors do\n    let cinfo \u2190 getConstInfo ctor\n    m := m ++ Format.line ++ ctor ++ \" : \" ++ cinfo.type\n  pure m\n\nprivate def printIdCore (id : Name) : ConstantInfo \u2192 CoreM MessageData\n  | ConstantInfo.axiomInfo { levelParams := us, type := t, isUnsafe := u, .. } =>\n    mkHeader' \"axiom\" id us t u\n  | ConstantInfo.defnInfo  { levelParams := us, type := t, value := v, safety := s, .. } =>\n    printDefLike \"def\" id us t v s\n  | ConstantInfo.thmInfo  { levelParams := us, type := t, value := v, .. } =>\n    printDefLike \"theorem\" id us t v\n  | ConstantInfo.opaqueInfo  { levelParams := us, type := t, isUnsafe := u, .. } =>\n    mkHeader' \"constant\" id us t u\n  | ConstantInfo.quotInfo  { levelParams := us, type := t, .. } =>\n    mkHeader' \"Quotient primitive\" id us t false\n  | ConstantInfo.ctorInfo { levelParams := us, type := t, isUnsafe := u, .. } =>\n    mkHeader' \"constructor\" id us t u\n  | ConstantInfo.recInfo { levelParams := us, type := t, isUnsafe := u, .. } =>\n    mkHeader' \"recursor\" id us t u\n  | ConstantInfo.inductInfo\n      { levelParams := us, numParams, numIndices, type := t, ctors, isUnsafe := u, .. } =>\n    printInduct id us numParams numIndices t ctors u\n\ndef diffExtension (old new : Environment)\n    (ext : PersistentEnvExtension EnvExtensionEntry EnvExtensionEntry EnvExtensionState) :\n    CoreM (Option MessageData) := unsafe do\n  let oldSt := ext.toEnvExtension.getState old\n  let newSt := ext.toEnvExtension.getState new\n  if ptrAddrUnsafe oldSt == ptrAddrUnsafe newSt then return none\n  let oldEntries := ext.exportEntriesFn oldSt.state\n  let newEntries := ext.exportEntriesFn newSt.state\n  pure m!\"-- {ext.name} extension: {(newEntries.size - oldEntries.size : Int)} new entries\"\n\ndef whatsNew (old new : Environment) : CoreM MessageData := do\n  let mut diffs := #[]\n\n  for (c, i) in new.constants.map\u2082.toList do\n    unless old.constants.map\u2082.contains c do\n      diffs := diffs.push (\u2190 printIdCore c i)\n\n  for ext in \u2190 persistentEnvExtensionsRef.get do\n    if let some diff := \u2190 diffExtension old new ext then\n      diffs := diffs.push diff\n\n  if diffs.isEmpty then return \"no new constants\"\n\n  pure $ MessageData.joinSep diffs.toList \"\\n\\n\"\n\n/-- `whatsnew in $command` executes the command and then prints the\ndeclarations that were added to the environment. -/\nelab \"whatsnew\" \"in\" ppLine cmd:command : command => do\n  let oldEnv \u2190 getEnv\n  try\n    elabCommand cmd\n  finally\n    let newEnv \u2190 getEnv\n    logInfo (\u2190 liftCoreM <| whatsNew oldEnv newEnv)\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/Util/WhatsNew.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.48828339529583464, "lm_q1q2_score": 0.24986272117420633}}
{"text": "/-\nCopyright (c) 2019 Simon Hudon. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n-/\nimport tactic.monotonicity.interactive\n\nopen list tactic tactic.interactive\n\nmeta class elaborable (\u03b1 : Type) (\u03b2 : out_param Type) :=\n  (elaborate : \u03b1 \u2192 tactic \u03b2)\n\nexport elaborable (elaborate)\n\nmeta instance : elaborable pexpr expr :=\n\u27e8 to_expr \u27e9\n\nmeta instance elaborable_list {\u03b1 \u03b1'} [elaborable \u03b1 \u03b1'] : elaborable (list \u03b1) (list \u03b1') :=\n\u27e8 mmap elaborate \u27e9\n\nmeta def mono_function.elaborate : mono_function ff \u2192 tactic mono_function\n| (mono_function.non_assoc x y z) :=\nmono_function.non_assoc <$> elaborate x\n                        <*> elaborate y\n                        <*> elaborate z\n| (mono_function.assoc x y z) :=\nmono_function.assoc <$> elaborate x\n                    <*> traverse elaborate y\n                    <*> traverse elaborate z\n| (mono_function.assoc_comm x y) :=\nmono_function.assoc_comm <$> elaborate x\n                         <*> elaborate y\n\nmeta instance elaborable_mono_function : elaborable (mono_function ff) mono_function :=\n\u27e8 mono_function.elaborate \u27e9\n\nmeta instance prod_elaborable {\u03b1 \u03b1' \u03b2 \u03b2' : Type} [elaborable \u03b1 \u03b1']  [elaborable \u03b2 \u03b2']\n: elaborable (\u03b1 \u00d7 \u03b2) (\u03b1' \u00d7 \u03b2') :=\n\u27e8 \u03bb i, prod.rec_on i (\u03bb x y, prod.mk <$> elaborate x <*> elaborate y) \u27e9\n\nmeta def parse_mono_function' (l r : pexpr) :=\ndo l' \u2190 to_expr l,\n   r' \u2190 to_expr r,\n   parse_ac_mono_function { mono_cfg . } l' r'\n\nrun_cmd\ndo xs \u2190 mmap to_expr [``(1),``(2),``(3)],\n   ys \u2190 mmap to_expr [``(1),``(2),``(4)],\n   x \u2190 match_prefix { unify := ff } xs ys,\n   p \u2190 elaborate ([``(1),``(2)] , [``(3)], [``(4)]),\n   guard $ x = p\n\nrun_cmd\ndo xs \u2190 mmap to_expr [``(1),``(2),``(3),``(6),``(7)],\n   ys \u2190 mmap to_expr [``(1),``(2),``(4),``(5),``(6),``(7)],\n   x \u2190 match_assoc { unify := ff } xs ys,\n   p \u2190 elaborate ([``(1), ``(2)], [``(3)], ([``(4), ``(5)], [``(6), ``(7)])),\n   guard (x = p)\n\nrun_cmd\ndo x \u2190 to_expr ``(7 + 3 : \u2115) >>= check_ac,\n   x \u2190 pp x.2.2.1,\n   let y := \"(some (is_left_id.left_id, (is_right_id.right_id, 0)))\",\n   guard (x.to_string = y) <|> fail (\"guard: \" ++ x.to_string)\n\nmeta def test_pp {\u03b1} [has_to_tactic_format \u03b1] (tag : format) (expected : string) (prog : tactic \u03b1) :\n  tactic unit :=\ndo r \u2190 prog,\n   pp_r \u2190 pp r,\n   guard (pp_r.to_string = expected) <|> fail format!\"test_pp: {tag}\"\n\nrun_cmd\ndo test_pp \"test1\"\n           \"(3 + 6, (4 + 5, ([], has_add.add _ 2 + 1)))\"\n           (parse_mono_function' ``(1 + 3 + 2 + 6) ``(4 + 2 + 1 + 5)),\n   test_pp \"test2\"\n           \"([1] ++ [3] ++ [2] ++ [6], ([4] ++ [2] ++ [1] ++ [5], ([], append none _ none)))\"\n           (parse_mono_function' ``([1] ++ [3] ++ [2] ++ [6]) ``([4] ++ [2] ++ ([1] ++ [5]))),\n   test_pp \"test3\"\n           \"([3] ++ [2], ([5] ++ [4], ([], append (some [1]) _ (some [2]))))\"\n           (parse_mono_function' ``([1] ++ [3] ++ [2] ++ [2]) ``([1] ++ [5] ++ ([4] ++ [2])))\n\ndef my_id {\u03b1 : Type*} : \u03b1 \u2192 \u03b1 := id\n\n@[mono]\nlemma test_monotone {\u03b1 : Type*} [preorder \u03b1] : monotone (my_id : \u03b1 \u2192 \u03b1) :=\n\u03bb x y h, h\n\nexample : my_id 0 \u2264 my_id 1 :=\nbegin\n  mono,\n  simp,\nend\n\n@[mono]\nlemma test_strict_mono {\u03b1 : Type*} [preorder \u03b1] : strict_mono (my_id : \u03b1 \u2192 \u03b1) :=\n\u03bb x y h, h\n\nexample : my_id 0 < my_id 1 :=\nbegin\n  mono,\n  simp,\nend\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/monotonicity/test_cases.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.48438008427698437, "lm_q1q2_score": 0.24975601823280585}}
{"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 \u2192 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 : \u2115)\n(map : fin n \u2192 map_to S X)\n(jointly_surjective : \u2200 x, \u2203 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} (\ud835\udcdb : cover S K) : K.cover :=\n{ n := \ud835\udcdb.n,\n  obj := \u03bb i, as_Def S (\ud835\udcdb.map i).obj,\n  map := \u03bb i,\n    \u27e8(\ud835\udcdb.map i).to_fun \u2218 (equiv_Def S (\ud835\udcdb.map i).obj).symm,\n     (definable_iff_def_fun.mp (\ud835\udcdb.map i).is_definable).comp def_fun_equiv_Def_symm\u27e9,\n  jointly_surjective := \u03bb k,\n    let \u27e8i, l, h\u27e9 := \ud835\udcdb.jointly_surjective k in\n    \u27e8i, (equiv_Def S (\ud835\udcdb.map i).obj) l, show (\ud835\udcdb.map i).to_fun _ = k, by simp [h]\u27e9 }\n\ndef cover.pullback {X' X : Type*} [has_coordinates R X'] [definable_rep S X']\n  [has_coordinates R X] [definable_rep S X] (\ud835\udcdb : cover S X) (f : X' \u2192 X) (df : definable S f) :\n  cover S X' :=\n{ n := \ud835\udcdb.n,\n  map := \u03bb i,\n  { obj := {p : X' \u00d7 (\ud835\udcdb.map i).obj | f p.1 = (\ud835\udcdb.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 (\ud835\udcdb.map i).is_definable).comp def_fun.snd),\n    to_fun := prod.fst \u2218 subtype.val,\n    is_definable := definable.fst.comp definable.subtype.val },\n  jointly_surjective := \u03bb x',\n    let \u27e8i, l, h\u27e9 := \ud835\udcdb.jointly_surjective (f x') in\n    \u27e8i, \u27e8\u27e8x', l\u27e9, h.symm\u27e9, rfl\u27e9 }\n\ndef cover_of_Def {K : Def S} (\ud835\udcdb : K.cover) : cover S K :=\n{ n := \ud835\udcdb.n,\n  map := \u03bb i,\n  { obj := \ud835\udcdb.obj i,\n    to_fun := \ud835\udcdb.map i,\n    is_definable := definable_iff_def_fun.mpr (\ud835\udcdb.map i).is_definable },\n  jointly_surjective := \ud835\udcdb.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 \u2192 Y) (\ud835\udcdb : cover S K)\n  (h : \u2200 i, definable S (f \u2218 (\ud835\udcdb.map i).to_fun)) : definable S f :=\nbegin\n  rw definable_yoneda,\n  let \ud835\udcdb' := Def.cover_of_general \ud835\udcdb,\n  apply definable_sheaf.definable_cover _ \ud835\udcdb',\n  intro i,\n  rw \u2190definable_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 \u2192 Y) (\ud835\udcdb : cover S X)\n  (h : \u2200 i, definable S (f \u2218 (\ud835\udcdb.map i).to_fun)) : definable S f :=\nbegin\n  rw definable_fun,\n  intros K \u03c6 h\u03c6,\n  let \ud835\udcdb' := \ud835\udcdb.pullback \u03c6 (definable_yoneda.mpr h\u03c6),\n  rw \u2190definable_yoneda at \u22a2 h\u03c6,\n  apply definable_cover_of_Def _ \ud835\udcdb',\n  intro i,\n  change definable S (f \u2218 (\u03c6 \u2218 (\ud835\udcdb'.map i).to_fun)),\n  let \u03c8 : (\ud835\udcdb'.map i).obj \u2192 (\ud835\udcdb.map i).obj := \u03bb z, z.val.snd,\n  have d\u03c8 : definable S \u03c8 := definable.snd.comp definable.subtype.val,\n  have : \u03c6 \u2218 (\ud835\udcdb'.map i).to_fun = (\ud835\udcdb.map i).to_fun \u2218 \u03c8,\n  { ext x,\n    exact x.property },\n  rw this,\n  refine (h i).comp d\u03c8\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 := \u21a5(s\u1d9c),\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 \u2208 s,\n    { refine \u27e80, by exact \u27e8x, hx\u27e9, by exact rfl\u27e9 },\n    { refine \u27e81, by exact \u27e8x, hx\u27e9, by exact rfl\u27e9 }\n  end }\n\n-- TODO: is this true for any sheaf X?\nlemma definable_if (f : X \u2192 Y) (s : set X) (ds : definable S s)\n  (hpos : definable S (f \u2218 (subtype.val : s \u2192 X)))\n  (hneg : definable S (f \u2218 (subtype.val : s\u1d9c \u2192 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 (\u03b7:freevar.env) (n1 n2:string) (\u03b7':freevar.env):=\n  (\u2200 n, n \u2209 \u03b7 \u2192 n \u2260 n1 \u2227 n \u2260 n2 \u2192 n \u2209 \u03b7') \u2227\n  (\u2200 n, n \u2208 \u03b7 \u2228 n = n1 \u2228 n = n2 \u2192 n \u2208 \u03b7')\n\ndef env.has_only (\u03b7:freevar.env) (names:list string) :=\n  \u2200 name, name \u2208 names \u2194 name \u2208 \u03b7\n\nuniverses u v\n@[reducible]\ndef apply {\u03b1:Type u} (f:\u03b1 \u2192 \u03b1) : option \u03b1 \u2192 option \u03b1\n| (some x) := some (f x)\n| none := none\n\nlemma apply_none: \u2200 {\u03b1:Type u} (f:\u03b1 \u2192 \u03b1) o,\n  apply f o = none \u2194 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: \u2200 {\u03b1:Type u} {f:\u03b1 \u2192 \u03b1} {o} {v}\n  (H:apply f o = some v), \u2203 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 \u03b7 `\u27e6` s `\u27e7'` := apply (freevar.env.replace \u03b7) s\nnotation \u03b7 `\u27e6` s `\u27e7'` := apply (freevar.env.replace_valty \u03b7) s\nnotation \u03b7 `\u27e6` s `\u27e7'` := apply (freevar.env.replace_sbv \u03b7) s\nnotation \u03b7 `\u27e6` s `\u27e7'` := apply (freevar.env.replace_sb \u03b7) s\n\n\n-- Induction principles for sbool & sbitvec which are mutually defined\nsection\n@[reducible]\nparameters (P:sbool \u2192 Prop) (P':\u03a0 {sz:size}, sbitvec sz \u2192 Prop)\n  (Hbtt: P sbool.tt) (Hbff: P sbool.ff) (Hbvar: \u2200 s, P (sbool.var s))\n  (Hband: \u2200 b1 b2, P b1 \u2192 P b2 \u2192 P (sbool.and b1 b2))\n  (Hbor: \u2200 b1 b2, P b1 \u2192 P b2 \u2192 P (sbool.or b1 b2))\n  (Hbxor: \u2200 b1 b2, P b1 \u2192 P b2 \u2192 P (sbool.xor b1 b2))\n  (Hbeqb: \u2200 b1 b2, P b1 \u2192 P b2 \u2192 P (sbool.eqb b1 b2))\n  (Hbneb: \u2200 b1 b2, P b1 \u2192 P b2 \u2192 P (sbool.neb b1 b2))\n  (Hbite: \u2200 b1 b2 b3, P b1 \u2192 P b2 \u2192 P b3 \u2192 P (sbool.ite b1 b2 b3))\n  (Hbnot: \u2200 b, P b \u2192 P (sbool.not b))\n  (Hbeqbv: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P (sbool.eqbv v1 v2))\n  (Hbnebv: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P (sbool.nebv v1 v2))\n  (Hbsle: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P (sbool.sle v1 v2))\n  (Hbslt: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P (sbool.slt v1 v2))\n  (Hbule: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P (sbool.ule v1 v2))\n  (Hbult: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P (sbool.ult v1 v2))\n  (Hvconst: \u2200 sz n, P' (sbitvec.const sz n))\n  (Hvvar: \u2200 sz n, P' (sbitvec.var sz n))\n  (Hvadd: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.add v1 v2))\n  (Hvsub: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.sub v1 v2))\n  (Hvmul: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.mul v1 v2))\n  (Hvudiv: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.udiv v1 v2))\n  (Hvurem: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.urem v1 v2))\n  (Hvsdiv: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.sdiv v1 v2))\n  (Hvsrem: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.srem v1 v2))\n  (Hvand: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.and v1 v2))\n  (Hvor: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.or v1 v2))\n  (Hvxor: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.xor v1 v2))\n  (Hvshl: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.shl v1 v2))\n  (Hvlshr: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.lshr v1 v2))\n  (Hvashr: \u2200 {sz} (v1 v2:sbitvec sz), P' v1 \u2192 P' v2 \u2192 P' (sbitvec.ashr v1 v2))\n  (Hvzext: \u2200 {sz} (v:sbitvec sz) sz', P' v \u2192 P' (sbitvec.zext sz' v))\n  (Hvsext:\u2200 {sz} (v:sbitvec sz) sz', P' v \u2192 P' (sbitvec.sext sz' v))\n  (Hvtrunc: \u2200 {sz} (v:sbitvec sz) sz', P' v \u2192 P' (sbitvec.trunc sz' v))\n  (Hvextract: \u2200 {sz sz':size} (v:sbitvec sz) highbit lowbit\n      (H:sz'.val = highbit - lowbit + 1),\n      P' v \u2192 P' (sbitvec.extract highbit lowbit H v))\n  (Hvite: \u2200 {sz} (b:sbool) (v1 v2:sbitvec sz), P b \u2192 P' v1 \u2192 P' v2 \u2192\n      P' (sbitvec.ite b v1 v2))\n\n@[reducible]\nmutual def sbool.induction, sbitvec.induction\nwith sbool.induction : \u2200 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: \u2200 {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: \u2200 (b1 b2:sbool) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.and b1 b2\u27e7 = sbool.and (\u03b7\u27e6b1\u27e7) (\u03b7\u27e6b2\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\nlemma env.replace_sb_and: \u2200 (b1 b2:sbool) (\u03b7:freevar.env),\n  \u03b7\u27e6b1 & b2\u27e7 = \u03b7\u27e6b1\u27e7 & \u03b7\u27e6b2\u27e7\n:= begin intros, apply env.replace_sb_and0 end\n\nlemma env.replace_sb_or0: \u2200 (b1 b2:sbool) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.or b1 b2\u27e7 = sbool.or (\u03b7\u27e6b1\u27e7) (\u03b7\u27e6b2\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\nlemma env.replace_sb_or: \u2200 (b1 b2:sbool) (\u03b7:freevar.env),\n  \u03b7\u27e6b1 |b b2\u27e7 = \u03b7\u27e6b1\u27e7 |b \u03b7\u27e6b2\u27e7\n:= begin intros, apply env.replace_sb_or0 end\n\nlemma env.replace_sb_not0: \u2200 (b:sbool) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.not b\u27e7 = sbool.not (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\nlemma env.replace_sb_not: \u2200 (b:sbool) (\u03b7:freevar.env),\n  \u03b7\u27e6~ b\u27e7 = ~ \u03b7\u27e6b\u27e7\n:= begin intros, apply env.replace_sb_not0 end\n\nlemma env.replace_sb_eqbv: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.eqbv a b\u27e7 = sbool.eqbv (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_nebv: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.nebv a b\u27e7 = sbool.nebv (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_sle: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.sle a b\u27e7 = sbool.sle (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_slt: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.slt a b\u27e7 = sbool.slt (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_ule: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.ule a b\u27e7 = sbool.ule (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_ult: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.ult a b\u27e7 = sbool.ult (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_sb_ite: \u2200 (c:sbool) (a b:sbool) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.ite c a b\u27e7 = sbool.ite (\u03b7\u27e6c\u27e7) (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sb end\n\nlemma env.replace_b2p: \u2200 (b:sbool) (\u03b7:freevar.env),\n  \u03b7\u27e6b2p irsem_smt b\u27e7 = b2p irsem_smt (\u03b7\u27e6b\u27e7)\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: \u2200 (a:bool) (\u03b7:freevar.env),\n  \u03b7\u27e6sbool.of_bool a\u27e7 = sbool.of_bool a\n:= begin\n  intros, cases a; refl\nend\n\nlemma env.replace_eq2p: \u2200 {sz:size} (v1:sbitvec sz) (v2:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6irsem.eq2p irsem_smt v1 v2\u27e7 = (irsem.eq2p irsem_smt (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7))\n:= begin\n  intros,\n  unfold eq2p,\n  unfold has_ne.ne,\n  unfold has_comp.ne,\n  have HNE: sbool.nebv (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7) = \u03b7\u27e6sbool.nebv v1 v2\u27e7,\n  {\n    unfold freevar.env.replace_sb\n  },\n  rw HNE,\n  apply env.replace_b2p,\nend\n\nlemma env.replace_neq2p: \u2200 {sz:size} (v1:sbitvec sz) (v2:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6irsem.neq2p irsem_smt v1 v2\u27e7 = (irsem.neq2p irsem_smt (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7))\n:= begin\n  intros,\n  unfold neq2p,\n  unfold has_eq.eq,\n  unfold has_comp.eq,\n  have HNE: sbool.eqbv (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7) = \u03b7\u27e6sbool.eqbv v1 v2\u27e7,\n  {\n    unfold freevar.env.replace_sb\n  },\n  rw HNE,\n  apply env.replace_b2p,\nend\n\nlemma env.replace_eq2p': \u2200 {sz:size} (v1:sbitvec sz) (v2:sbitvec sz) (\u03b7:freevar.env)\n    (H:v2 = \u03b7\u27e6v2\u27e7),\n  (irsem.eq2p irsem_smt (\u03b7\u27e6v1\u27e7) v2) = \u03b7\u27e6irsem.eq2p irsem_smt v1 v2\u27e7\n:= begin\n  intros,\n  have H0: irsem.eq2p irsem_smt (\u03b7\u27e6v1\u27e7) v2 = irsem.eq2p irsem_smt (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7),\n  { rw \u2190 H },\n  rw H0,\n  rw \u2190 env.replace_eq2p\nend\n\n-- replace_sbv\n\nlemma env.replace_sbv_add: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.add a b\u27e7 = sbitvec.add (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_sub: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.sub a b\u27e7 = sbitvec.sub (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_mul: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.mul a b\u27e7 = sbitvec.mul (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_udiv: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.udiv a b\u27e7 = sbitvec.udiv (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_urem: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.urem a b\u27e7 = sbitvec.urem (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_sdiv: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.sdiv a b\u27e7 = sbitvec.sdiv (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_srem: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.srem a b\u27e7 = sbitvec.srem (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_shl: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.shl a b\u27e7 = sbitvec.shl (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_lshr: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.lshr a b\u27e7 = sbitvec.lshr (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_ashr: \u2200 {sz:size} (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.ashr a b\u27e7 = sbitvec.ashr (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_mk_zext: \u2200 {sz sz2:size} (a:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.mk_zext sz2 a\u27e7 = sbitvec.mk_zext sz2 (\u03b7\u27e6a\u27e7)\n:= begin intros, unfold sbitvec.mk_zext, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_mk_sext: \u2200 {sz sz2:size} (a:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.mk_sext sz2 a\u27e7 = sbitvec.mk_sext sz2 (\u03b7\u27e6a\u27e7)\n:= begin intros, unfold sbitvec.mk_sext, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_trunc: \u2200 {sz sz':size} (b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.trunc sz' b\u27e7 = sbitvec.trunc sz' (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_zext: \u2200 {sz sz':size} (b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.zext sz' b\u27e7 = sbitvec.zext sz' (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_sext: \u2200 {sz sz':size} (b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.sext sz' b\u27e7 = sbitvec.sext sz' (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_extract: \u2200 {sz sz':size} (b:sbitvec sz) (\u03b7:freevar.env) h l \n    (H:sz'.val = h - l + 1),\n  \u03b7\u27e6sbitvec.extract h l H b\u27e7 = sbitvec.extract h l H (\u03b7\u27e6b\u27e7)\n:= begin\n  intros,\n  unfold freevar.env.replace_sbv\nend\n\nlemma env.replace_sbv_ite: \u2200 {sz:size} (c:sbool) (a b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.ite c a b\u27e7 = sbitvec.ite (\u03b7\u27e6c\u27e7) (\u03b7\u27e6a\u27e7) (\u03b7\u27e6b\u27e7)\n:= begin intros, unfold freevar.env.replace_sbv end\n\nlemma env.replace_sbv_of_int: \u2200 sz z (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.of_int sz z\u27e7 = 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: \u2200 (a:sbool) (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.of_bool a\u27e7 = sbitvec.of_bool (\u03b7\u27e6a\u27e7)\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  (\u2200 (\u03b7:freevar.env) (b:sbool), \u03b7\u27e6\u03b7\u27e6b\u27e7\u27e7 = \u03b7\u27e6b\u27e7) \u2227\n  (\u2200 {sz:size} (\u03b7:freevar.env) (b:sbitvec sz), \u03b7\u27e6\u03b7\u27e6b\u27e7\u27e7 = \u03b7\u27e6b\u27e7) \n:= begin\n  split; intros; revert b,\n  apply (sbool.induction (\u03bb b, \u03b7\u27e6\u03b7\u27e6b\u27e7\u27e7 = \u03b7\u27e6b\u27e7)\n                        (\u03bb {sz:size} (v:sbitvec sz), \u03b7\u27e6\u03b7\u27e6v\u27e7\u27e7 = \u03b7\u27e6v\u27e7)),\n  any_goals  {\n    apply (sbitvec.induction (\u03bb b, \u03b7\u27e6\u03b7\u27e6b\u27e7\u27e7 = \u03b7\u27e6b\u27e7)\n                          (\u03bb {sz:size} (v:sbitvec sz), \u03b7\u27e6\u03b7\u27e6v\u27e7\u27e7 = \u03b7\u27e6v\u27e7))\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': \u03b7.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': \u03b7.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: \u2200 (\u03b7:freevar.env) (b:sbool), \u03b7\u27e6\u03b7\u27e6b\u27e7\u27e7 = \u03b7\u27e6b\u27e7\n:= begin\n  apply (and.elim_left env.replace_idemp)\nend\n\nlemma env.replace_sbv_idemp: \u2200 {sz} (\u03b7:freevar.env) (b:sbitvec sz), \u03b7\u27e6\u03b7\u27e6b\u27e7\u27e7 = \u03b7\u27e6b\u27e7\n:= begin\n  intros,\n  apply (and.elim_right env.replace_idemp)\nend\n\nlemma env.empty_replace: (\u2200 (b:sbool), freevar.env.empty\u27e6b\u27e7 = b) \u2227\n  (\u2200 {sz} (b:sbitvec sz), freevar.env.empty\u27e6b\u27e7 = b)\n:= begin\n  intros,\n  split; intros; revert b,\n  apply (sbool.induction (\u03bb b, freevar.env.empty\u27e6b\u27e7 = b)\n              (\u03bb {sz:size} (v:sbitvec sz), freevar.env.empty\u27e6v\u27e7 = v)),\n  any_goals {\n    apply (sbitvec.induction (\u03bb b, freevar.env.empty\u27e6b\u27e7 = b)\n              (\u03bb {sz:size} (v:sbitvec sz), freevar.env.empty\u27e6v\u27e7 = 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: \u2200 (b:sbool), freevar.env.empty\u27e6b\u27e7 = b\n:= begin\n  apply (and.elim_left env.empty_replace)\nend\n\nlemma env.empty_replace_sbv {sz:size} : \u2200 (b:sbitvec sz), freevar.env.empty\u27e6b\u27e7 = b\n:= begin\n  apply (and.elim_right env.empty_replace)\nend\n\nlemma env.replace_sbv_cast: \u2200 {sz sz':size} {H:sz = sz'} {H':sbitvec sz = sbitvec sz'}\n    (b:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6cast H' b\u27e7 = cast H' (\u03b7\u27e6b\u27e7)\n:= begin\n  intros,\n  induction H,\n  unfold cast\nend\n\nlemma env.replace_sb_overflowchk_add: \u2200\n    {sz1:size} (sz2:size) (v1 v2:sbitvec sz1) nsw (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.overflow_chk @sbitvec.add sz2 nsw v1 v2\u27e7 =\n    sbitvec.overflow_chk @sbitvec.add sz2 nsw (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7)\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: \u2200\n    {sz1:size} (sz2:size) (v1 v2:sbitvec sz1) nsw (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.overflow_chk @sbitvec.sub sz2 nsw v1 v2\u27e7 =\n    sbitvec.overflow_chk @sbitvec.sub sz2 nsw (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7)\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: \u2200\n    {sz1:size} (sz2:size) (v1 v2:sbitvec sz1) nsw (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.overflow_chk @sbitvec.mul sz2 nsw v1 v2\u27e7 =\n    sbitvec.overflow_chk @sbitvec.mul sz2 nsw (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7)\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: \u2200\n    {sz1:size} (sz2:size) (v1 v2:sbitvec sz1) nsw (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.shl_overflow_chk sz2 nsw v1 v2\u27e7 =\n    sbitvec.shl_overflow_chk sz2 nsw (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7)\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: \u2200 ss ss' (\u03b7:freevar.env) (name name':string)\n    (H:irstate.getreg irsem_smt ss name = none)\n    (H':ss' = \u03b7\u27e6ss\u27e7),\n  irstate.getreg irsem_smt ss' name = none\n:= begin\n  intros,\n  unfold freevar.env.replace at H',\n  rw H',\n  rw \u2190 irstate.getreg_apply_none_smt,\n  assumption\nend\n\nlemma getreg_replace_none_inv: \u2200 ss ss' (\u03b7:freevar.env) (name name':string)\n    (H:irstate.getreg irsem_smt ss' name = none)\n    (H':ss' = \u03b7\u27e6ss\u27e7),\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: \u2200 {ss:irstate_smt} {name:string} {\u03b7:freevar.env} {ov}\n    (HV:irstate.getreg irsem_smt ss name = ov),\n  irstate.getreg irsem_smt (\u03b7\u27e6ss\u27e7) name = \u03b7\u27e6ov\u27e7'\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 \u2190 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 \u2190 H, rw HNAME, rw HNAME\n    }\n  }\nend\n\nlemma replace_updatereg: \u2200 (ss:irstate_smt) (name:string)\n    (\u03b7:freevar.env) v,\n  \u03b7\u27e6irstate.updatereg irsem_smt ss name v\u27e7 =\n    irstate.updatereg irsem_smt (\u03b7\u27e6ss\u27e7) name (\u03b7\u27e6v\u27e7)\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: \u2200 (ss:irstate_smt) (\u03b7:freevar.env) ub,\n  \u03b7\u27e6irstate.updateub irsem_smt ss ub\u27e7 =\n    irstate.updateub irsem_smt (\u03b7\u27e6ss\u27e7) (\u03b7\u27e6ub\u27e7)\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: \u2200 (ss:irstate_smt) (\u03b7:freevar.env),\n  \u03b7\u27e6irstate.getub irsem_smt ss\u27e7 =\n    irstate.getub irsem_smt (\u03b7\u27e6ss\u27e7)\n:= begin\n  intros,\n  unfold irstate.getub,\n  cases ss, refl\nend\n\nlemma empty_replace_st: \u2200 (ss:irstate_smt),\n  freevar.env.empty\u27e6ss\u27e7 = 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-- \u2209\n\nlemma env.not_in_split: \u2200 (\u03b7:freevar.env) n,\n  n \u2209 \u03b7 \u2194 \u03b7.b n = none \u2227 \u03b7.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: \u2200 n (\u03b7:freevar.env), n \u2209 \u03b7 \u2228 n \u2208 \u03b7\n:= begin\n  intros,\n  rw env.not_in_split,\n  unfold has_mem.mem,\n  generalize Hb: \u03b7.b n = b',\n  generalize Hb: \u03b7.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: \u2200 (\u03b7:freevar.env) n1 n2 z\n    (HNEQ:n1 \u2260 n2)\n    (HNOTIN:n1 \u2209 \u03b7),\n  n1 \u2209 (\u03b7.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: \u2200 (\u03b7:freevar.env) n1 n2 z\n    (HNEQ:n1 \u2260 n2)\n    (HNOTIN:n1 \u2209 \u03b7),\n  n1 \u2209 (\u03b7.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: \u2200 n, n \u2209 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: \u2200 (\u03b7:freevar.env) n\n    (HNOTIN:n \u2209 \u03b7),\n  \u03b7\u27e6sbool.var n\u27e7 = 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:\u03b7.b n = g,\n  cases g,\n  { refl },\n  { rw HNOTIN_left at H, cases H }\nend\n\nlemma env.not_in_replace_sbv: \u2200 (\u03b7:freevar.env) n sz\n    (HNOTIN:n \u2209 \u03b7),\n  \u03b7\u27e6sbitvec.var sz n\u27e7 = 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:\u03b7.bv n = g,\n  cases g,\n  { refl },\n  { rw HNOTIN_right at H, cases H }\nend\n\nlemma env.in_replace_sbv: \u2200 (\u03b7:freevar.env) n sz\n    (HIN:\u2203 z, \u03b7.bv n = some z),\n  \u2203 z, \u03b7\u27e6sbitvec.var sz n\u27e7 = 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: \u2200 (\u03b7:freevar.env) sz n,\n  \u03b7\u27e6sbitvec.var sz n\u27e7 = sbitvec.var sz n \u2228\n  \u2203 z, \u03b7\u27e6sbitvec.var sz n\u27e7 = sbitvec.const sz z\n:= begin\n  intros,\n  unfold freevar.env.replace_sbv,\n  generalize H: (\u03b7.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: \u2200 (\u03b7:freevar.env) n,\n  \u03b7\u27e6sbool.var n\u27e7 = sbool.var n \u2228\n  \u03b7\u27e6sbool.var n\u27e7 = sbool.tt \u2228\n  \u03b7\u27e6sbool.var n\u27e7 = sbool.ff\n:= begin\n  intros,\n  unfold freevar.env.replace_sb,\n  generalize H: (\u03b7.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: \u2200 (\u03b7:freevar.env) n n2 sz z\n    (HNEQ:n \u2260 n2),\n  (\u03b7.add_bv n2 z)\u27e6sbitvec.var sz n\u27e7 = \u03b7\u27e6sbitvec.var sz n\u27e7\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: \u2200 (\u03b7:freevar.env) n n2 z\n    (HNEQ:n \u2260 n2),\n  (\u03b7.add_b n2 z)\u27e6sbool.var n\u27e7 = \u03b7\u27e6sbool.var n\u27e7\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: \u2200 (\u03b7:freevar.env) n b,\n  (freevar.env.add_b \u03b7 n b)\u27e6sbool.var n\u27e7 = 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: \u2200 (\u03b7:freevar.env) n z sz,\n  (freevar.env.add_bv \u03b7 n z)\u27e6sbitvec.var sz n\u27e7 = 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: \u2200 (\u03b7:freevar.env) n n' z,\n  (freevar.env.add_bv \u03b7 n z)\u27e6sbool.var n'\u27e7 = \u03b7\u27e6sbool.var n'\u27e7\n:= begin\n  intros,\n  unfold freevar.env.replace_sb,\n  unfold freevar.env.add_bv\nend\n\nlemma env.add_b_replace_sbv: \u2200 (\u03b7:freevar.env) n n' b sz,\n  (freevar.env.add_b \u03b7 n b)\u27e6sbitvec.var sz n'\u27e7 = \u03b7\u27e6sbitvec.var sz n'\u27e7\n:= begin\n  intros,\n  unfold freevar.env.replace_sbv,\n  unfold freevar.env.add_b\nend\n\nlemma env.replace_sb_cases: \u2200 s (\u03b7:freevar.env), \n  \u03b7\u27e6sbool.var s\u27e7 = sbool.var s \u2228 \u03b7\u27e6sbool.var s\u27e7 = sbool.tt \u2228 \u03b7\u27e6sbool.var s\u27e7 = sbool.ff\n:= begin\n  intros,\n  unfold freevar.env.replace_sb,\n  generalize Hb: \u03b7.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: \u2200 sz s (\u03b7:freevar.env),\n  \u03b7\u27e6sbitvec.var sz s\u27e7 = sbitvec.var sz s\n    \u2228 \u2203 n, \u03b7\u27e6sbitvec.var sz s\u27e7 = sbitvec.const sz n\n:= begin\n  intros,\n  unfold freevar.env.replace_sbv,\n  generalize Hb: \u03b7.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: \u2200 (\u03b7:freevar.env) z,\n  (\u2200 (v:sbool) n, n \u2209 \u03b7 \u2192 (\u03b7.add_bv n z)\u27e6v\u27e7 =\n      (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6v\u27e7\u27e7) \u2227\n  (\u2200 {sz} (v:sbitvec sz) n, n \u2209 \u03b7 \u2192 \n        (\u03b7.add_bv n z)\u27e6v\u27e7 = (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6v\u27e7\u27e7)\n:= begin\n  intros,\n  split,\n  apply sbool.induction\n      (\u03bb v, \u2200 n, n \u2209 \u03b7 \u2192 (\u03b7.add_bv n z)\u27e6v\u27e7 = (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6v\u27e7\u27e7)\n      (\u03bb {sz} (v:sbitvec sz), \u2200 n, n \u2209 \u03b7 \u2192 \n            (\u03b7.add_bv n z)\u27e6v\u27e7 = (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6v\u27e7\u27e7),\n  any_goals {\n    apply sbitvec.induction\n      (\u03bb v, \u2200 n, n \u2209 \u03b7 \u2192 (\u03b7.add_bv n z)\u27e6v\u27e7 = (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6v\u27e7\u27e7)\n      (\u03bb {sz} (v:sbitvec sz), \u2200 n, n \u2209 \u03b7 \u2192 \n            (\u03b7.add_bv n z)\u27e6v\u27e7 = (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6v\u27e7\u27e7),\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: \u03b7.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 \u03b7 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: \u2200 (\u03b7:freevar.env) z (v:sbool) n,\n  n \u2209 \u03b7 \u2192 (\u03b7.add_bv n z)\u27e6v\u27e7 = (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6v\u27e7\u27e7\n:= begin\n  intros, apply (and.elim_left (env.not_in_add_b_bv_bv_comm \u03b7 z)),\n  assumption\nend\n\nlemma env.not_in_add_bv_bv_comm: \u2200 (\u03b7:freevar.env) z {sz} (v:sbitvec sz) n,\n  n \u2209 \u03b7 \u2192 (\u03b7.add_bv n z)\u27e6v\u27e7 = (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6v\u27e7\u27e7\n:= begin\n  intros, apply (and.elim_right (env.not_in_add_b_bv_bv_comm \u03b7 z)),\n  assumption\nend\n\n\n\n\nlemma env.not_in_add_b_bv_b_comm: \u2200 (\u03b7:freevar.env) z,\n  (\u2200 (v:sbool) n, n \u2209 \u03b7 \u2192 (\u03b7.add_b n z)\u27e6v\u27e7 =\n      (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6v\u27e7\u27e7) \u2227\n  (\u2200 {sz} (v:sbitvec sz) n, n \u2209 \u03b7 \u2192 \n        (\u03b7.add_b n z)\u27e6v\u27e7 = (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6v\u27e7\u27e7)\n:= begin\n  intros,\n  split,\n  apply sbool.induction\n      (\u03bb v, \u2200 n, n \u2209 \u03b7 \u2192 (\u03b7.add_b n z)\u27e6v\u27e7 = (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6v\u27e7\u27e7)\n      (\u03bb {sz} (v:sbitvec sz), \u2200 n, n \u2209 \u03b7 \u2192 \n            (\u03b7.add_b n z)\u27e6v\u27e7 = (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6v\u27e7\u27e7),\n  any_goals {\n    apply sbitvec.induction\n      (\u03bb v, \u2200 n, n \u2209 \u03b7 \u2192 (\u03b7.add_b n z)\u27e6v\u27e7 = (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6v\u27e7\u27e7)\n      (\u03bb {sz} (v:sbitvec sz), \u2200 n, n \u2209 \u03b7 \u2192 \n            (\u03b7.add_b n z)\u27e6v\u27e7 = (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6v\u27e7\u27e7),\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 \u03b7 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: \u03b7.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: \u2200 (\u03b7:freevar.env) z (v:sbool) n,\n  n \u2209 \u03b7 \u2192 (\u03b7.add_b n z)\u27e6v\u27e7 = (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6v\u27e7\u27e7\n:= begin\n  intros, apply (and.elim_left (env.not_in_add_b_bv_b_comm \u03b7 z)),\n  assumption\nend\n\nlemma env.not_in_add_b_bv_comm: \u2200 (\u03b7:freevar.env) z {sz} (v:sbitvec sz) n,\n  n \u2209 \u03b7 \u2192 (\u03b7.add_b n z)\u27e6v\u27e7 = (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6v\u27e7\u27e7\n:= begin\n  intros, apply (and.elim_right (env.not_in_add_b_bv_b_comm \u03b7 z)),\n  assumption\nend\n\nlemma env.not_in_add_bv_valty_comm: \u2200 (\u03b7:freevar.env) (vv:valty_smt) n z,\n  n \u2209 \u03b7 \u2192 (\u03b7.add_bv n z)\u27e6vv\u27e7 = (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6vv\u27e7\u27e7\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: \u2200 (\u03b7:freevar.env) (vv:valty_smt) n z,\n  n \u2209 \u03b7 \u2192 (\u03b7.add_b n z)\u27e6vv\u27e7 = (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6vv\u27e7\u27e7\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: \u2200 (\u03b7:freevar.env) (ss:irstate irsem_smt) n z,\n  n \u2209 \u03b7 \u2192 (\u03b7.add_bv n z)\u27e6ss\u27e7 = (freevar.env.empty.add_bv n z)\u27e6\u03b7\u27e6ss\u27e7\u27e7\n:= begin\n  intros,\n  cases ss,\n  unfold freevar.env.replace,\n  rw \u2190 irstate.setub_apply_to_values,\n  rw \u2190 irstate.setub_apply_to_values,\n  rw \u2190 irstate.setub_apply_to_values,\n  rw \u2190 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: \u2200 (\u03b7:freevar.env) (ss:irstate irsem_smt) n z,\n  n \u2209 \u03b7 \u2192 (\u03b7.add_b n z)\u27e6ss\u27e7 = (freevar.env.empty.add_b n z)\u27e6\u03b7\u27e6ss\u27e7\u27e7\n:= begin\n  intros,\n  cases ss,\n  unfold freevar.env.replace,\n  rw \u2190 irstate.setub_apply_to_values,\n  rw \u2190 irstate.setub_apply_to_values,\n  rw \u2190 irstate.setub_apply_to_values,\n  rw \u2190 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: \u2200 {\u03b7:freevar.env} (s:string) (l1 l2:list string),\n  env.has_only \u03b7 (s::(l1 ++ l2)) \u2194 env.has_only \u03b7 (l1 ++ s::l2)\n:= begin\n  intros, rw \u2190 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 \u2208 l2) (name \u2208 l1), apply a\n  },\n  {\n    intros, simp, simp at a,\n    rw or.comm, rw or.assoc,\n    rw @or.comm (name \u2208 l2) (name = s), apply a\n  }\nend\n\nlemma env.has_only_shuffle2: \u2200 {\u03b7:freevar.env} (s1 s2:string) (l:list string),\n  env.has_only \u03b7 (s1::s2::l) \u2194 env.has_only \u03b7 (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 \u2208 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 \u2208 l) (name = s1), apply a\n  }\nend\n\nlemma env.has_only_added2: \u2200 {\u03b7 \u03b7':freevar.env} {n1 n2:string}\n    {l:list string}\n    (H1: env.has_only \u03b7 l)\n    (H2: env.added2 \u03b7 n1 n2 \u03b7'),\n  env.has_only \u03b7' (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 \u2190 decidable.not_not_iff (name \u2208 \u03b7') at a,\n    rw \u2190 decidable.not_not_iff (name = n1 \u2228 name = n2 \u2228 name \u2208 \u03b7),\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: \u2200 {\u03b7:freevar.env} {l n}\n  (H:env.has_only \u03b7 l) (HNOTIN:n \u2209 l), n \u2209 \u03b7\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: \u2200 (ss:irstate_smt) (op:operand)\n    (\u03b7:freevar.env) (t:ty),\n  get_value irsem_smt (\u03b7\u27e6ss\u27e7) op t = \u03b7\u27e6get_value irsem_smt ss op t\u27e7'\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 \u27e8t, H0\u27e9 op), apply_instance,\n        cases H1,\n        {\n          rw if_neg,\n          {\n            have H2: decidable (\u2191(int_min_nat \u27e8t, H0\u27e9) \u2264 op \u2227 op \u2264 \u2191(all_one_nat \u27e8t, H0\u27e9)),\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 + -\u2191(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 \u27f6 Z) [has_kernel f] (G : C \u2964 D)\n  [G.preserves_zero_morphisms] [has_kernel (G.map f)] [is_iso (kernel_comparison f G)]\n  {g : X \u27f6 Y} (w : g \u226b f = 0) :\n  kernel.lift (G.map f) (G.map g) (by simp only [\u2190 G.map_comp, w, functor.map_zero]) \u226b\n  category_theory.inv (kernel_comparison f G) = G.map (kernel.lift f g w) :=\nby simp [\u2190 cancel_mono (kernel_comparison f G)]\n\n@[simp, reassoc]\nlemma inv_cokernel_comparison_desc_map {X Y Z : C} (f : X \u27f6 Y) [has_cokernel f] (G : C \u2964 D)\n  [G.preserves_zero_morphisms] [has_cokernel (G.map f)] [is_iso (cokernel_comparison f G)]\n  {g : Y \u27f6 Z} (w : f \u226b g = 0) :\n  category_theory.inv (cokernel_comparison f G) \u226b\n    cokernel.desc (G.map f) (G.map g) (by simp only [\u2190 G.map_comp, w, functor.map_zero]) =\n  G.map (cokernel.desc f g w) :=\nby simp [\u2190 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  [\u2200 (P : C\u1d52\u1d56 \u2964 D) (X : C) (S : J.cover X), has_multiequalizer (S.index P)]\n  [\u2200 (X : C), has_colimits_of_shape (J.cover X)\u1d52\u1d56 D]\n  [\u2200 (X : C), preserves_colimits_of_shape (J.cover X)\u1d52\u1d56 (forget D)]\n  [reflects_isomorphisms (forget D)]\n\nlemma is_iso_of_eval {F : Sheaf J D} {G : C\u1d52\u1d56 \u2964 D}\n  (\u03b3 : F \u27f6 (presheaf_to_Sheaf _ _).obj G)\n  (\u03b7 : F.val \u27f6 G)\n  [\u2200 X : C, is_iso (\u03b7.app (op X))]\n  (h : \u03b3.val = \u03b7 \u226b J.to_sheafify _) :\n  is_iso \u03b3 :=\nbegin\n  haveI : is_iso (J.to_sheafify F.val) :=\n    grothendieck_topology.is_iso_to_sheafify J F.2,\n  have : \u03b3.val = (J.to_sheafify F.val) \u226b (J.sheafify_map \u03b7),\n  { rw \u2190 is_iso.inv_comp_eq,\n    apply J.sheafify_hom_ext, apply Sheaf.cond,\n    rw [\u2190 grothendieck_topology.to_sheafify_naturality, \u2190 h],\n    simp },\n  suffices : is_iso ((Sheaf_to_presheaf _ _).map \u03b3),\n  { resetI, apply is_iso_of_fully_faithful (Sheaf_to_presheaf J D) },\n  dsimp, rw this,\n  suffices : is_iso (J.sheafify_map \u03b7),\n  { resetI, apply is_iso.comp_is_iso },\n  change is_iso ((Sheaf_to_presheaf _ _).map ((presheaf_to_Sheaf _ _).map \u03b7)),\n  haveI : is_iso \u03b7,\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 {\u03c3: env} {P P' Q: prop}:\n  (\u03c3 \u22a8 vc.implies P'.to_vc P.to_vc) \u2192 (\u03c3 \u22a8 (prop.implies P Q).to_vc) \u2192 (\u03c3 \u22a8 (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} {\u03c3: env}:\n  (\u03c3 \u22a8 vc.implies P'.to_vc P.to_vc) \u2192 (FV P \u2286 FV P') \u2192\n  (closed_subst \u03c3 (prop.implies P Q) \u2192 \u03c3 \u22a8 (prop.implies P Q).to_vc) \u2192\n  (closed_subst \u03c3 (prop.implies P' Q) \u2192 \u03c3 \u22a8 (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 \u03c3 P P' Q,\n    from h1,\n\n    have h5: closed_subst \u03c3 (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 \u2208 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\u2081 h10,\n      from h4 h12,\n\n      have h12: free_in_prop x (prop.implies P' Q), from free_in_prop.implies\u2082 h8,\n      from h4 h12\n    end,\n    from h3 h5\n  end\n\nlemma strengthen_vc_with_q {P P' Q S: prop} {\u03c3: env}:\n  (\u03c3 \u22a8 vc.implies P'.to_vc P.to_vc) \u2192 (FV P \u2286 FV P') \u2192\n  (closed_subst \u03c3 (prop.implies (P \u22c0 Q) S) \u2192 \u03c3 \u22a8 (prop.implies (P \u22c0 Q) S).to_vc) \u2192\n  (closed_subst \u03c3 (prop.implies (P' \u22c0 Q) S) \u2192 \u03c3 \u22a8 (prop.implies (P' \u22c0 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 \u03c3 (P \u22c0 Q) (P' \u22c0 Q) S,\n    from vc.implies.same_right (\u03bb_, h1),\n    have h5: closed_subst \u03c3 (prop.implies (P\u22c0Q) 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 \u2208 FV P, from h8,\n      have h10, from set.mem_of_mem_of_subset h9 h2,\n      have h11: free_in_prop x (P' \u22c0 Q), from free_in_prop.and\u2081 h10,\n      have h12: free_in_prop x (prop.implies (P' \u22c0 Q) S), from free_in_prop.implies\u2081 h11,\n      from h4 h12,\n\n\n      have h11: free_in_prop x (P' \u22c0 Q), from free_in_prop.and\u2082 h9,\n      have h12: free_in_prop x (prop.implies (P' \u22c0 Q) S), from free_in_prop.implies\u2081 h11,\n      from h4 h12,\n\n      have h12: free_in_prop x (prop.implies (P' \u22c0 Q) S), from free_in_prop.implies\u2082 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 \u22a9 e : Q) \u2192 \u2200P': prop, (FV P' = FV P) \u2192 (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc) \u2192 (P' \u22a9 e: Q) :=\n  assume e_verified: (P \u22a9 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: (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc),\n\n      have h1: FV (P' \u22c0 x \u2261 value.true) = FV (P \u22c0 x \u2261 value.true),\n      from free_in_prop.same_right free_P'_P,\n      have h2: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 x \u2261 value.true).to_vc (P \u22c0 x \u2261 value.true).to_vc),\n      from \u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3),\n      have e'_verified': P' \u22c0 x \u2261 value.true \u22a9 e': Q, from ih (P' \u22c0 x \u2261 value.true) h1 h2,\n      have x_not_free_in_P': x \u2209 FV P', from free_P'_P.symm \u25b8 x_not_free_in_P,\n      show P' \u22a9 lett x = true in e' : propctx.exis x (x \u2261 value.true \u22c0 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: (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc),\n\n      have h1: FV (P' \u22c0 (x \u2261 value.false)) = FV (P \u22c0 x \u2261 value.false),\n      from free_in_prop.same_right free_P'_P,\n      have h2: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 x \u2261 value.false).to_vc (P \u22c0 x \u2261 value.false).to_vc),\n      from \u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3),\n      have e'_verified': P' \u22c0 x \u2261 value.false \u22a9 e': Q, from ih (P' \u22c0 x \u2261 value.false) h1 h2,\n      have x_not_free_in_P': x \u2209 FV P', from free_P'_P.symm \u25b8 x_not_free_in_P,\n      show P' \u22a9 letf x = false in e' : propctx.exis x ((x \u2261 value.false) \u22c0 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: (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc),\n\n      have h1: FV (P' \u22c0 x \u2261 value.num n) = FV (P \u22c0 x \u2261 value.num n),\n      from free_in_prop.same_right free_P'_P,\n      have h2: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 x \u2261 value.num n).to_vc (P \u22c0 x \u2261 value.num n).to_vc),\n      from \u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3),\n      have e'_verified': P' \u22c0 (x \u2261 value.num n) \u22a9 e': Q, from ih (P' \u22c0 (x \u2261 value.num n)) h1 h2,\n      have x_not_free_in_P': x \u2209 FV P', from free_P'_P.symm \u25b8 x_not_free_in_P,\n      show P' \u22a9 letn x = n in e' : propctx.exis x ((x \u2261 value.num n) \u22c0 Q),\n      from exp.dvcgen.num x_not_free_in_P' e'_verified'\n    },\n    case exp.dvcgen.func f x R S e\u2081 e\u2082 P Q\u2081 Q\u2082 f_not_free_in_P x_not_free_in_P f_neq_x x_free_in_R fv_R fv_S\n                        e\u2081_verified e\u2082_verified func_vc ih\u2081 ih\u2082 { from\n      assume P': prop,\n      assume free_P'_P: FV P' = FV P,\n      assume P'_dominates_p_P: (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc),\n\n      have f_not_free_in_P': f \u2209 FV P', from free_P'_P.symm \u25b8 f_not_free_in_P,\n      have x_not_free_in_P': x \u2209 FV P', from free_P'_P.symm \u25b8 x_not_free_in_P,\n      have fv_R': FV R.to_prop \u2286 FV P' \u222a { f, x }, from free_P'_P.symm \u25b8 fv_R,\n      have fv_S': FV S.to_prop \u2286 FV P' \u222a { f, x }, from free_P'_P.symm \u25b8 fv_S,\n\n      have h1: FV (P' \u22c0 ((spec.func f x R S) \u22c0 R)) = FV (P \u22c0 ((spec.func f x R S) \u22c0 R)),\n      from free_in_prop.same_right free_P'_P,\n      have h2: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 (spec.func f x R S) \u22c0 R).to_vc (P \u22c0 (spec.func f x R S) \u22c0 R).to_vc),\n      from \u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3),\n      have e\u2081_verified': P' \u22c0 (spec.func f x R S) \u22c0 R \u22a9 e\u2081 : Q\u2081,\n      from ih\u2081 (P' \u22c0 (spec.func f x R S) \u22c0 R) h1 h2,\n\n      have h3: FV (P' \u22c0 (prop.func f x R (Q\u2081 (term.app \u2191f \u2191x) \u22c0 \u2191S)))\n             = FV (P \u22c0 (prop.func f x R (Q\u2081 (term.app \u2191f \u2191x) \u22c0 \u2191S))),\n      from free_in_prop.same_right free_P'_P,\n\n      have h5: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 (prop.func f x R (Q\u2081 (term.app \u2191f \u2191x) \u22c0 \u2191S))).to_vc\n                      (P \u22c0 (prop.func f x R (Q\u2081 (term.app \u2191f \u2191x) \u22c0 \u2191S))).to_vc),\n      from (\u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3)),\n\n      have e\u2082_verified': P' \u22c0 (prop.func f x R (Q\u2081 (term.app \u2191f \u2191x) \u22c0 \u2191S)) \u22a9 e\u2082 : Q\u2082,\n      from ih\u2082 (P' \u22c0 (prop.func f x R (Q\u2081 (term.app \u2191f \u2191x) \u22c0 \u2191S))) h3 h5,\n\n      have func_vc': \u2200 (\u03c3 : env),\n            closed_subst \u03c3 (prop.implies (P'\u22c0\u2191(spec.func \u2191f x R S) \u22c0 R \u22c0 Q\u2081 (term.app \u2191f \u2191x)) \u2191S) \u2192\n             \u03c3 \u22a8 (prop.implies (P' \u22c0 \u2191(spec.func \u2191f x R S) \u22c0 R \u22c0 Q\u2081 (term.app \u2191f \u2191x)) \u2191S).to_vc,\n      from (\u03bb\u03c3, strengthen_vc_with_q (P'_dominates_p_P \u03c3) (set.subset_of_eq free_P'_P.symm) (func_vc \u03c3)),\n\n      show P' \u22a9 letf f[x] req R ens S {e\u2081} in e\u2082 : propctx.exis f (prop.func f x R (Q\u2081 (term.app \u2191f \u2191x) \u22c0 \u2191S) \u22c0 Q\u2082),\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\u2081_verified'\n           e\u2082_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: (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc),\n\n      have x_free_in_P': x \u2208 FV P', from free_P'_P.symm \u25b8 x_free_in_P,\n      have y_not_free_in_P': y \u2209 FV P', from free_P'_P.symm \u25b8 y_not_free_in_P,\n\n      have h1: FV (P' \u22c0 y \u2261 term.unop op x) = FV (P \u22c0 y \u2261 term.unop op x),\n      from free_in_prop.same_right free_P'_P,\n      have h2: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 y \u2261 term.unop op x).to_vc (P \u22c0 y \u2261 term.unop op x).to_vc),\n      from (\u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3)),\n      have e'_verified': P' \u22c0 y \u2261 term.unop op x \u22a9 e' : Q',\n      from ih (P' \u22c0 y \u2261 term.unop op x) h1 h2,\n\n      have FV P \u2286 FV P', from set.subset_of_eq free_P'_P.symm,\n      have vc_valid': \u2200 (\u03c3 : env),\n           closed_subst \u03c3 (prop.implies P' (prop.pre\u2081 op x)) \u2192 \u03c3 \u22a8 (prop.implies P' (prop.pre\u2081 op x)).to_vc,\n      from (\u03bb\u03c3, strengthen_vc (P'_dominates_p_P \u03c3) this (vc_valid \u03c3)),\n\n      show P' \u22a9 letop y = op [x] in e' : propctx.exis y (y \u2261 term.unop op x \u22c0 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: (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc),\n\n      have x_free_in_P': x \u2208 FV P', from free_P'_P.symm \u25b8 x_free_in_P,\n      have y_free_in_P': y \u2208 FV P', from free_P'_P.symm \u25b8 y_free_in_P,\n      have z_not_free_in_P': z \u2209 FV P', from free_P'_P.symm \u25b8 z_not_free_in_P,\n\n      have h1: FV (P' \u22c0 z \u2261 term.binop op x y) = FV (P \u22c0 z \u2261 term.binop op x y),\n      from free_in_prop.same_right free_P'_P,\n      have h2: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 z \u2261 term.binop op x y).to_vc (P \u22c0 z \u2261 term.binop op x y).to_vc),\n      from (\u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3)),\n      have e'_verified': P' \u22c0 z \u2261 term.binop op x y \u22a9 e' : Q',\n      from ih (P' \u22c0 z \u2261 term.binop op x y) h1 h2,\n\n      have FV P \u2286 FV P', from set.subset_of_eq free_P'_P.symm,\n      have vc_valid': \u2200 (\u03c3 : env),\n        closed_subst \u03c3 (prop.implies P' (prop.pre\u2082 op x y)) \u2192\n        \u03c3 \u22a8 (prop.implies P' (prop.pre\u2082 op x y)).to_vc,\n      from (\u03bb\u03c3, strengthen_vc (P'_dominates_p_P \u03c3) this (vc_valid \u03c3)),\n\n      show P' \u22a9 letop2 z = op [x, y] in e' : propctx.exis z (z \u2261 term.binop op x y \u22c0 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: (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc),\n\n      have f_free_in_P': f \u2208 FV P', from free_P'_P.symm \u25b8 f_free_in_P,\n      have x_free_in_P': x \u2208 FV P', from free_P'_P.symm \u25b8 x_free_in_P,\n      have y_not_free_in_P': y \u2209 FV P', from free_P'_P.symm \u25b8 y_not_free_in_P,\n\n      have h1: FV (P' \u22c0 prop.call x \u22c0 prop.post f x \u22c0 y \u2261 term.app f x)\n             = FV (P \u22c0 prop.call x \u22c0 prop.post f x \u22c0 y \u2261 term.app f x),\n      from free_in_prop.same_right free_P'_P,\n\n      have h2: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 prop.call x \u22c0 prop.post f x \u22c0 y \u2261 term.app f x).to_vc\n                                (P \u22c0 prop.call x \u22c0 prop.post f x \u22c0 y \u2261 term.app f x).to_vc),\n      from (\u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3)),\n\n      have e'_verified': P' \u22c0 prop.call x \u22c0 prop.post f x \u22c0 y \u2261 term.app f x \u22a9 e' : Q',\n      from ih (P' \u22c0 prop.call x \u22c0 prop.post f x \u22c0 y \u2261 term.app f x) h1 h2,\n\n      have vc_valid': \u2200 (\u03c3 : env),\n           closed_subst \u03c3 (prop.implies (P' \u22c0 prop.call x) (term.unop unop.isFunc f \u22c0 prop.pre f x)) \u2192\n           \u03c3 \u22a8 (prop.implies (P' \u22c0 prop.call x) (term.unop unop.isFunc f \u22c0 prop.pre f x)).to_vc,\n      from (\u03bb\u03c3, strengthen_vc_with_q (P'_dominates_p_P \u03c3) (set.subset_of_eq free_P'_P.symm) (vc_valid \u03c3)),\n\n      show P' \u22a9 letapp y = f [x] in e' : propctx.exis y (prop.call x \u22c0 prop.post f x \u22c0 y \u2261 term.app f x \u22c0 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\u2082 e\u2081 P Q\u2081 Q\u2082 x_free_in_P e\u2081_verified e\u2082_verified vc_valid ih\u2081 ih\u2082 { from\n      assume P': prop,\n      assume free_P'_P: FV P' = FV P,\n      assume P'_dominates_p_P: (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc),\n\n      have x_free_in_P': x \u2208 FV P', from free_P'_P.symm \u25b8 x_free_in_P,\n\n      have h1: FV (P' \u22c0 x) = FV (P \u22c0 x), from free_in_prop.same_right free_P'_P,\n      have h2: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 x).to_vc (P \u22c0 x).to_vc),\n      from (\u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3)),\n      have e\u2081_verified': P' \u22c0 x \u22a9 e\u2081 : Q\u2081, from ih\u2081 (P' \u22c0 x) h1 h2,\n\n      have h1: FV (P' \u22c0 prop.not x) = FV (P \u22c0 prop.not x), from free_in_prop.same_right free_P'_P,\n      have h2: (\u2200\u03c3, \u03c3 \u22a8 vc.implies (P' \u22c0 prop.not x).to_vc (P \u22c0 prop.not x).to_vc),\n      from (\u03bb\u03c3, vc.implies.same_right (\u03bb_, P'_dominates_p_P \u03c3)),\n      have e\u2082_verified': P' \u22c0 prop.not x \u22a9 e\u2082 : Q\u2082, from ih\u2082 (P' \u22c0 prop.not x) h1 h2,\n\n      have FV P \u2286 FV P', from set.subset_of_eq free_P'_P.symm,\n      have vc_valid': \u2200 (\u03c3 : env),\n           closed_subst \u03c3 (prop.implies P' (term.unop unop.isBool x)) \u2192\n           \u03c3 \u22a8 (prop.implies P' (term.unop unop.isBool x)).to_vc,\n      from (\u03bb\u03c3, strengthen_vc (P'_dominates_p_P \u03c3) this (vc_valid \u03c3)),\n\n      show P' \u22a9 exp.ite x e\u2081 e\u2082 : propctx.implies x Q\u2081 \u22c0 propctx.implies (prop.not x) Q\u2082,\n      from exp.dvcgen.ite x_free_in_P' e\u2081_verified' e\u2082_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: (\u2200\u03c3, \u03c3 \u22a8 vc.implies P'.to_vc P.to_vc),\n\n      have x_free_in_P': x \u2208 FV P', from free_P'_P.symm \u25b8 x_free_in_P,\n\n      show P' \u22a9 exp.return x : (x \u2263 \u2022), 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 \u03b1] (rtr : \u03b1) : Prop :=\n  \u2200 {cpt i}, Subsingleton (Member cpt i rtr)\n\nclass Indexable (\u03b1) extends LawfulUpdatable \u03b1 where\n  unique_ids : \u2200 {rtr : \u03b1}, UniqueIDs rtr\n\nstructure Container (\u03b1) where\n  id  : WithTop ID \n  rtr : \u03b1 \n\ninstance [Coe \u03b1 \u03b2] : Coe (Container \u03b1) (Container \u03b2) where\n  coe i := { id := i.id, rtr := i.rtr }\n\nnamespace Member\n\nvariable [LawfulUpdatable \u03b1] \n\ndef container {rtr : \u03b1} : (Member cpt i rtr) \u2192 Container \u03b1\n  | .nest _ (.nest h l)             => container (.nest h l)\n  | .nest (rtr\u2082 := con) (j := j) .. => { id := j, rtr := con }\n  | .final _                        => { id := \u22a4, rtr := rtr }\n\ntheorem nest_container  {rtr\u2081 rtr\u2082 : \u03b1} \n    (h : ReactorType.nest rtr\u2081 i = some rtr\u2082) (m : Member cpt j rtr\u2082) : \n    \u2203 (k : ID) (con : \u03b1), (Member.nest h m).container = \u27e8k, con\u27e9 := by\n  induction m generalizing i rtr\u2081\n  case final => simp [container]\n  case nest hn _ hi => simp [container, hi hn]\n\ntheorem container_eq_root {rtr : \u03b1} {m : Member cpt i rtr} (h : m.container = \u27e8\u22a4, con\u27e9) : \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 \u27e8_, _, _\u27e9 := nest_container hn m\n    simp_all\n\nend Member\n\nnamespace Indexable\n\nvariable [a : Indexable \u03b1]\n\ndef con? (rtr : \u03b1) (cpt : Component) : ID \u21c0 Container \u03b1 := \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 : \u03b1) : (cpt : Component) \u2192 cpt.idType \u21c0 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,     \u22a4        => 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\u2081 rtr\u2082 : \u03b1}\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 (\ud835\udc9e : Type) [category.{0} \ud835\udc9e]\n\ninductive bicompletion_aux : bool \u2192 Type 1\n| of_cat_obj : \ud835\udc9e \u2192 bicompletion_aux ff\n| limit_obj {D : Type} (F : D \u2192 bicompletion_aux tt) : bicompletion_aux ff\n| colimit_obj {D : Type} (F : D \u2192 bicompletion_aux tt) : bicompletion_aux ff\n| of_cat_hom : \u03a0 {X Y : \ud835\udc9e}, (X \u27f6 Y) \u2192 bicompletion_aux tt -- of_cat_obj X \u27f6 of_cat_obj Y\n| limit_cone_comp {D : Type} (F : D \u2192 bicompletion_aux tt) \n  (X : D) (Y : bicompletion_aux ff) (f : bicompletion_aux tt) : -- F_obj X \u27f6 Y\n  bicompletion_aux tt -- limit_obj F \u27f6 Y\n| colimit_cocone_comp {D : Type} (F : D \u2192 bicompletion_aux tt)  \n  (X : D) (Y : bicompletion_aux ff) (f : bicompletion_aux tt) : -- Y \u27f6 F_obj X\n  bicompletion_aux tt -- Y \u27f6 colimit_obj F\n| is_limit {D : Type} (F : D \u2192 bicompletion_aux tt) \n  (cone_obj : bicompletion_aux ff)\n  (cone : \u03a0 (X : D), bicompletion_aux tt) : -- cone_obj \u27f6 F_obj X\n  bicompletion_aux tt -- cone_obj \u2192 limit_obj F\n| is_colimit {D : Type} (F : D \u2192 bicompletion_aux tt) \n  (cocone_obj : bicompletion_aux ff)\n  (cocone : \u03a0 (X : D), bicompletion_aux tt) : -- F_obj X \u27f6 cocone_obj\n  bicompletion_aux tt -- colimit_obj F \u27f6 cocone_obj\n| id (X : bicompletion_aux ff) : bicompletion_aux tt -- X \u27f6 X\n\nnamespace bicompletion_aux\n\nvariable {\ud835\udc9e}\n\n@[simp] def dom : \u03a0 (X : bicompletion_aux \ud835\udc9e tt), bicompletion_aux \ud835\udc9e 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 : \u03a0 (X : bicompletion_aux \ud835\udc9e tt), bicompletion_aux \ud835\udc9e ff\n| (@of_cat_hom _ _ X Y f) := of_cat_obj Y \n| (@colimit_cocone_comp _ _ \ud835\udc9f F X _ _) := by exactI colimit_obj F\n| (@is_colimit _ _ \ud835\udc9f F cocone_obj cocone) := cocone_obj\n| (@limit_cone_comp _ _ \ud835\udc9f F X Y f) := Y\n| (@is_limit _ _ \ud835\udc9f F cone_obj cone) := by exactI limit_obj F\n| (id X) := X\n\nopen sum\n\ninductive valid : bicompletion_aux \ud835\udc9e ff \u2295 bicompletion_aux \ud835\udc9e tt \u2192 Type 1\n| of_cat_obj : \u03a0 (X : \ud835\udc9e), valid (inl (of_cat_obj X))\n| limit_obj {D : Type} (F : D \u2192 bicompletion_aux \ud835\udc9e tt) (hF : \u03a0 (X : D), valid (inr (F X))) :\n    valid (inl (limit_obj F))\n| colimit_obj {D : Type} (F : D \u2192 bicompletion_aux \ud835\udc9e tt) (hF : \u03a0 (X : D), valid (inr (F X))) :\n    valid (inl (colimit_obj F))\n| limit_cone_comp {D : Type} (F : D \u2192 bicompletion_aux \ud835\udc9e tt)\n  (hF : \u03a0 (X : D), valid (inr (F X))) \n  (X : D) (Y : bicompletion_aux \ud835\udc9e ff) \n  (hY : valid (inl Y))\n  (f : bicompletion_aux \ud835\udc9e tt) \n  (hf : valid (inr f))\n  (hfd : f.dom = (F X).dom)\n  (hfc : f.cod = Y)\n\n  : -- F_obj X \u27f6 Y\n  bicompletion_aux tt -- limit_obj F \u27f6 Y\n\nvariable (\ud835\udc9e)\n\ndef obj\u2081 : Type 1 := bicompletion_aux \ud835\udc9e ff\n\nvariable {\ud835\udc9e}\nvariables {D : Type} [category.{0} \ud835\udc9f]\n\ndef hom\u2081 (X Y : obj\u2081 \ud835\udc9e) : Type 1 :=\n{ f : bicompletion_aux \ud835\udc9e tt // f.dom = X \u2227 f.cod = Y }\n\n@[simp] lemma coe_dom {X Y : obj\u2081 \ud835\udc9e} (f : hom\u2081 X Y) :\n  (@coe { f : bicompletion_aux \ud835\udc9e tt // f.dom = X \u2227 f.cod = Y } \n    (bicompletion_aux \ud835\udc9e tt) _ f).dom = X := f.2.1\n\n@[simp] lemma coe_cod {X Y : obj\u2081 \ud835\udc9e} (f : hom\u2081 X Y) :\n  (@coe { f : bicompletion_aux \ud835\udc9e tt // f.dom = X \u2227 f.cod = Y } \n    (bicompletion_aux \ud835\udc9e tt) _ f).cod = Y := f.2.2\n\ndef of_cat_obj\u2081 (X : \ud835\udc9e) : obj\u2081 \ud835\udc9e := of_cat_obj X\n\ndef limit_obj\u2081 (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e) \n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y)) : obj\u2081 \ud835\udc9e :=\nlimit_obj _\n\ndef colimit_obj\u2081 (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e) \n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y)) : obj\u2081 \ud835\udc9e :=\ncolimit_obj F_obj (\u03bb X Y f, (F_hom f).1)\n\ndef of_cat_hom\u2081 {X Y : \ud835\udc9e} (f : X \u27f6 Y) : hom\u2081 (of_cat_obj X) (of_cat_obj Y) :=\n\u27e8of_cat_hom f, by simp\u27e9\n\ndef limit_cone_comp\u2081 (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e)\n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y)) (X : \ud835\udc9f) \n  {Y : obj\u2081 \ud835\udc9e} (f : hom\u2081 (F_obj X) Y) :\n  hom\u2081 (limit_obj\u2081 F_obj @F_hom) Y :=\n\u27e8limit_cone_comp F_obj (\u03bb X Y f, (F_hom f).1) X Y f.1, by simp [limit_obj\u2081]\u27e9\n\ndef colimit_cocone_comp\u2081 (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e)\n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y)) (X : \ud835\udc9f) \n  {Y : obj\u2081 \ud835\udc9e} (f : hom\u2081 Y (F_obj X)) :\n  hom\u2081 Y (colimit_obj\u2081 F_obj @F_hom) :=\n\u27e8colimit_cocone_comp F_obj (\u03bb X Y f, (F_hom f).1) X Y f.1, by simp [colimit_obj\u2081]\u27e9\n\ndef is_limit\u2081 (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e) \n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y))\n  (cone_obj : obj\u2081 \ud835\udc9e)\n  (cone : \u03a0 (X : \ud835\udc9f), hom\u2081 cone_obj (F_obj X)) :\n  hom\u2081 cone_obj (limit_obj\u2081 F_obj @F_hom) :=\n\u27e8is_limit F_obj (\u03bb X Y f, (F_hom f).1) cone_obj (\u03bb X, (cone X).1), by simp [limit_obj\u2081]\u27e9\n\ndef is_colimit\u2081 (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e) \n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y))\n  (cocone_obj : obj\u2081 \ud835\udc9e)\n  (cocone : \u03a0 (X : \ud835\udc9f), hom\u2081 (F_obj X) cocone_obj) :\n  hom\u2081 (colimit_obj\u2081 F_obj @F_hom) cocone_obj  :=\n\u27e8is_colimit F_obj (\u03bb X Y f, (F_hom f).1) cocone_obj (\u03bb X, (cocone X).1), by simp [colimit_obj\u2081]\u27e9\n\ndef id\u2081 (X : obj\u2081 \ud835\udc9e) : hom\u2081 X X := \u27e8id X, rfl, rfl\u27e9\n\n@[elab_as_eliminator] def bicompletion_tt_rec_on \n  {motive : bicompletion_aux \ud835\udc9e tt \u2192 Sort u} \n  (f : bicompletion_aux \ud835\udc9e tt)\n  (of_cat_hom : \u03a0 {X Y : \ud835\udc9e} (f : X \u27f6 Y), motive (of_cat_hom f))\n  (limit_cone_comp : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e ff)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt) (X : \ud835\udc9f) (Y : bicompletion_aux \ud835\udc9e ff)\n    (f : bicompletion_aux \ud835\udc9e tt)\n    (ih : \u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f)),\n      motive f \u2192 by exactI motive (limit_cone_comp F_obj @F_hom X Y f))\n  (colimit_cone_comp : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e ff)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt) (X : \ud835\udc9f) (Y : bicompletion_aux \ud835\udc9e ff)\n    (f : bicompletion_aux \ud835\udc9e tt)\n    (ih : \u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f)),\n      motive f \u2192 by exactI motive (colimit_cocone_comp F_obj @F_hom X Y f))\n  (is_limit : \u03a0 {\ud835\udc9f : Type} [_inst_2 : category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e ff)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt) (cone_obj : bicompletion_aux \ud835\udc9e ff)\n    (cone : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e tt)\n    (ih_F_hom : \u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f))\n    (ih_cone : \u03a0 (X : \ud835\udc9f), motive (cone X)), \n    by exactI motive (is_limit F_obj @F_hom cone_obj cone))\n  (is_colimit : \u03a0 {\ud835\udc9f : Type} [_inst_2 : category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e ff)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt) (cone_obj : bicompletion_aux \ud835\udc9e ff)\n    (cone : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e tt)\n    (ih_F_hom : \u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f))\n    (ih_cone : \u03a0 (X : \ud835\udc9f), motive (cone X)), \n    by exactI motive (is_colimit F_obj @F_hom cone_obj cone))\n  (id : \u03a0 (X : bicompletion_aux \ud835\udc9e ff), motive X.id) :\n  motive f := sorry\n\ndef comp\u2081 (f : bicompletion_aux \ud835\udc9e tt) : bicompletion_aux \ud835\udc9e tt \u2192 part (bicompletion_aux \ud835\udc9e 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 \u27e8Y = B, \u03bb h, by subst h; exact of_cat_hom (f \u226b g)\u27e9 },\n    { intros, exact part.none },\n    { introsI \ud835\udc9f _ F_obj F_hom A B g ih\u2081 ih\u2082,\n      exact ih\u2082 >>= \u03bb ih\u2082, return (colimit_cocone_comp F_obj @F_hom A B ih\u2082) },\n    { introsI \ud835\udc9f _ F_obj F_hom A cone ih\u2081 ih\u2082,  \n      exact \u27e8\u2200 (X : \ud835\udc9f), (ih\u2082 X).dom, \u03bb h, is_limit F_obj @F_hom (of_cat_obj X) (\u03bb X, (ih\u2082 X).get (h X))\u27e9 },\n    { intros, exact part.none },\n    { intros, exact return (of_cat_hom f) }\n  end  \n  begin\n    introsI \ud835\udc9f _ F_obj F_hom A B f _ ih\u2082 g,\n    exact ih\u2082 g >>= \u03bb ih\u2082, return (limit_cone_comp F_obj @F_hom A B ih\u2082)\n  end\n  begin\n    introsI \ud835\udc9f _ F_obj F_hom A B f ih\u2081 ih\u2082 g,\n    revert ih\u2082 A,\n    refine bicompletion_tt_rec_on g _ _ _ _ _ _,\n    { intros, exact part.none },\n    { intros, exact part.none },\n    { introsI \u2130 _ G_obj G_hom C Y g ih\u2083 ih\u2084 ih\u2082 A,\n      exact ih\u2084 ih\u2082 A >>= \u03bb ih\u2084, return (colimit_cocone_comp G_obj @G_hom C Y ih\u2084) },\n    { introsI \u2130 _ G_obj G_hom _ g ih\u2083 ih\u2084 ih\u2082 A,\n      exact \u27e8\u03a0 (X : \u2130), (ih\u2084 X ih\u2082 A).dom, \n        \u03bb h, is_limit G_obj @G_hom B (\u03bb X, (ih\u2084 X ih\u2082 A).get (h X))\u27e9 },\n    { introsI \u2130 _ G_obj G_hom cocone_obj cocone _ g ih\u2082 A,\n      exact ih\u2082 (cocone A) },\n    { intros A f _,\n      exact colimit_cocone_comp\u2082 F_obj @F_hom A f }\n  end\n  _ _ (\u03bb _, return)\n  -- begin\n  --   introsI \ud835\udc9f _ F_obj F_hom ih\u2081 cone_obj cone ih\u2082 Z g,\n  --   revert ih\u2082,\n  --   refine hom\u2082_limit_obj_rec_on g _ _ _ _,\n  --   { introsI \u2130 _ G_obj G_hom A B g ih\u2082,\n  --     exact ih\u2082 A g },\n  --   { introsI \u2130 _ F_obj F_hom A \u2131 _ G_obj G_hom g ih\u2083 ih\u2082,\n  --     exact colimit_cocone_comp\u2082 F_obj @F_hom A (ih\u2083 @ih\u2082) },\n  --   { introsI \u2130 _ F_obj F_hom \u2131 _ G_obj G_hom ih\u2083 ih\u2084 ih\u2082,\n  --     exact is_limit\u2082 F_obj @F_hom cone_obj (\u03bb X, ih\u2084 _ @ih\u2082) },\n  --   { introsI ih,\n  --     exact is_limit\u2082 F_obj @F_hom cone_obj cone }\n  -- end\n  -- begin\n  --   introsI \ud835\udc9f _ F_obj F_hom ih\u2081 cocone_obj cocone ih\u2082 Z g,\n  --   exact is_colimit\u2082 F_obj @F_hom Z (\u03bb A, ih\u2082 A g)\n  -- end\n  -- (\u03bb _ _ g, g)\n\ninductive valid_obj\u2081 : \u03a0 (X : obj\u2081 \ud835\udc9e), Prop\n| of_cat_obj (X : \ud835\udc9e) : valid_obj\u2081 (of_cat_obj X)\n| limit_obj {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e) \n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y)) \n  (h : \u03a0 X : \ud835\udc9f, valid_obj\u2081 (F_obj X)) : \n  valid_obj\u2081 (limit_obj\u2081 F_obj @F_hom)\n| colimit_obj {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e)\n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y))\n  (h : \u03a0 X : \ud835\udc9f, valid_obj\u2081 (F_obj X)) :\n  valid_obj\u2081 (colimit_obj\u2081 F_obj @F_hom)\n\ndef valid_obj\u2081_limit_obj \n  {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] {F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e}\n  {F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt}\n  (h : valid_obj\u2081 (limit_obj F_obj @F_hom)) :\n  \u03a0 (X : \ud835\udc9f), valid_obj\u2081 (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\u2081] at hX,\n    rcases hX with \u27e8hX\u2081, hX\u2082, hX\u2082, hX\u2084\u27e9,\n    subst hX\u2081,\n    simp at *,\n    subst hX\u2082,\n    assumption },\n  { simp [*, colimit_obj\u2081] at * }\nend\n\ndef valid_obj\u2081_colimit_obj \n  {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] {F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e}\n  {F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt}\n  (h : valid_obj\u2081 (colimit_obj F_obj @F_hom)) :\n  \u03a0 (X : \ud835\udc9f), valid_obj\u2081 (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\u2081] at * },\n  { simp [colimit_obj\u2081] at hX,\n    rcases hX with \u27e8hX\u2081, hX\u2082, hX\u2082, hX\u2084\u27e9,\n    subst hX\u2081,\n    simp at *,\n    subst hX\u2082,\n    assumption }\nend\n\n@[elab_as_eliminator] def hom_rec_on {motive : bicompletion_aux \ud835\udc9e tt \u2192 Sort u}\n  (f : bicompletion_aux \ud835\udc9e tt)\n  (of_cat_hom : \u03a0 {X Y : \ud835\udc9e} (f : X \u27f6 Y), motive (of_cat_hom f))\n  (limit_cone_comp : \u03a0 {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e ff)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt) (X : \ud835\udc9f) (Y : bicompletion_aux \ud835\udc9e ff)\n    (f : bicompletion_aux \ud835\udc9e tt),\n    (\u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f)) \u2192\n    motive f \u2192 motive (by exactI limit_cone_comp F_obj @F_hom X Y f))\n  (is_limit : \u03a0 {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e ff)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt) (cone_obj : bicompletion_aux \ud835\udc9e ff)\n    (cone : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e tt),\n    (\u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f)) \u2192\n    (\u03a0 (X : \ud835\udc9f), motive (cone X)) \u2192 motive (by exactI is_limit F_obj @F_hom cone_obj cone))\n  (colimit_cocone_comp : \u03a0 {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e ff)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt) (X : \ud835\udc9f) (Y : bicompletion_aux \ud835\udc9e ff)\n    (f : bicompletion_aux \ud835\udc9e tt),\n    (\u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f)) \u2192\n    motive f \u2192 motive (by exactI colimit_cocone_comp F_obj @F_hom X Y f))\n  (is_colimit : \u03a0 {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e ff)\n   (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 bicompletion_aux \ud835\udc9e tt) (cocone_obj : bicompletion_aux \ud835\udc9e ff)\n   (cocone : \ud835\udc9f \u2192 bicompletion_aux \ud835\udc9e tt),\n     (\u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f)) \u2192\n     (\u03a0 (X : \ud835\udc9f), motive (cocone X)) \u2192 motive (by exactI is_colimit F_obj @F_hom cocone_obj cocone))\n  (id : \u03a0 (X : obj\u2081 \ud835\udc9e), motive (id X)) :\n  motive f :=\nhave \u2200 b (f : bicompletion_aux \ud835\udc9e 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 \ud835\udc9f _ F_obj F_hom X Y f ih\u2081 ih\u2082 ih\u2083 ih\u2084 _,\n      exact limit_cone_comp F_obj @F_hom X Y f (\u03bb X Y f, ih\u2082 f rfl) (ih\u2084 rfl) },\n    { introsI \ud835\udc9f _ F_obj F_hom X Y f ih\u2081 ih\u2082 ih\u2083 ih\u2084 _,\n      exact colimit_cocone_comp F_obj @F_hom X Y f (\u03bb X Y f, ih\u2082 f rfl) (ih\u2084 rfl) },\n    { introsI \ud835\udc9f _ F_obj F_hom cone_obj cone ih\u2081 ih\u2082 ih\u2083 ih\u2084 _,\n      exact is_limit F_obj @F_hom cone_obj cone (\u03bb X Y f, ih\u2082 f rfl) (\u03bb X, ih\u2084 X rfl) },\n    { introsI \ud835\udc9f _ F_obj F_hom cone_obj cone ih\u2081 ih\u2082 ih\u2083 ih\u2084 _,\n      exact is_colimit F_obj @F_hom cone_obj cone (\u03bb X Y f, ih\u2082 f rfl) (\u03bb X, ih\u2084 X rfl) },\n    { intros X _ _, exact id X }\n  end,\nthis tt f rfl\n\ninductive valid_hom\u2081 : \u03a0 {X Y : obj\u2081 \ud835\udc9e}, hom\u2081 X Y \u2192 Prop\n| of_cat_hom {X Y : \ud835\udc9e} (f : X \u27f6 Y) : valid_hom\u2081 (of_cat_hom\u2081 f)\n| id (X : obj\u2081 \ud835\udc9e) : valid_hom\u2081 (id\u2081 X)\n| limit_cone_comp {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e)\n  (obj_valid : \u2200 X, valid_obj\u2081 (F_obj X))\n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y)) \n  (X : \ud835\udc9f) {Y : obj\u2081 \ud835\udc9e} (f : hom\u2081 (F_obj X) Y) \n  (F_hom_valid : \u03a0 {X Y : \ud835\udc9f} (f : X \u27f6 Y), valid_hom\u2081 (F_hom f))\n  (f_valid : valid_hom\u2081 f) :\n  valid_hom\u2081 (limit_cone_comp\u2081 F_obj @F_hom X f)\n| colimit_cocone_comp {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e)\n  (obj_valid : \u2200 X, valid_obj\u2081 (F_obj X))\n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y)) \n  (X : \ud835\udc9f) {Y : obj\u2081 \ud835\udc9e} (f : hom\u2081 Y (F_obj X)) \n  (F_hom_valid : \u03a0 {X Y : \ud835\udc9f} (f : X \u27f6 Y), valid_hom\u2081 (F_hom f))\n  (f_valid : valid_hom\u2081 f) :\n  valid_hom\u2081 (colimit_cocone_comp\u2081 F_obj @F_hom X f)\n| is_limit {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e)\n  (obj_valid : \u2200 X, valid_obj\u2081 (F_obj X))\n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y))\n  (cone_obj : obj\u2081 \ud835\udc9e)\n  (cone : \u03a0 (X : \ud835\udc9f), hom\u2081 cone_obj (F_obj X)) \n  (F_hom_valid : \u03a0 {X Y : \ud835\udc9f} (f : X \u27f6 Y), valid_hom\u2081 (F_hom f))\n  (cone_valid : \u03a0 (X : \ud835\udc9f), valid_hom\u2081 (cone X)) :\n  valid_hom\u2081 (is_limit\u2081 F_obj @F_hom cone_obj cone)\n| is_colimit {\ud835\udc9f : Type} [category.{0} \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2081 \ud835\udc9e)\n  (obj_valid : \u2200 X, valid_obj\u2081 (F_obj X))\n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2081 (F_obj X) (F_obj Y))\n  (cocone_obj : obj\u2081 \ud835\udc9e)\n  (cocone : \u03a0 (X : \ud835\udc9f), hom\u2081 (F_obj X) cocone_obj) \n  (F_hom_valid : \u03a0 {X Y : \ud835\udc9f} (f : X \u27f6 Y), valid_hom\u2081 (F_hom f))\n  (cocone_valid : \u03a0 (X : \ud835\udc9f), valid_hom\u2081 (cocone X)) :\n  valid_hom\u2081 (is_colimit\u2081 F_obj @F_hom cocone_obj cocone)\n\nvariable (\ud835\udc9e)\n\ndef obj\u2082 : Type 1 := { X : obj\u2081 \ud835\udc9e // valid_obj\u2081 X } \n\nvariable {\ud835\udc9e}\n\ndef hom\u2082 (X Y : obj\u2082 \ud835\udc9e) : Type 1 := { f : hom\u2081 X.1 Y.1 // valid_hom\u2081 f }\n\nopen valid_hom\u2081\n\ndef of_cat_obj\u2082 (X : \ud835\udc9e) : obj\u2082 \ud835\udc9e :=\n\u27e8of_cat_obj X, valid_obj\u2081.of_cat_obj _\u27e9 \n\nlemma of_cat_obj\u2082_injective : function.injective (@of_cat_obj\u2082 \ud835\udc9e _) :=\nbegin\n  intros X Y hXY,\n  simp [of_cat_obj\u2082] at hXY,\n  injection hXY,\nend\n\ndef limit_obj\u2082 (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e) \n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)) : obj\u2082 \ud835\udc9e :=\n\u27e8limit_obj\u2081 (\u03bb X, (F_obj X).1) (\u03bb X Y f, (F_hom f).1), valid_obj\u2081.limit_obj _ _ (\u03bb X, (F_obj X).2)\u27e9\n\nlemma limit_obj\u2082_injective {\ud835\udc9f\u2081 \ud835\udc9f\u2082 : Type} [i\u2081 : category \ud835\udc9f\u2081] [i\u2082 : category \ud835\udc9f\u2082] \n  {F_obj\u2081 : \ud835\udc9f\u2081 \u2192 obj\u2082 \ud835\udc9e} {F_obj\u2082 : \ud835\udc9f\u2082 \u2192 obj\u2082 \ud835\udc9e} \n  {F_hom\u2081 : \u03a0 {X Y : \ud835\udc9f\u2081}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj\u2081 X) (F_obj\u2081 Y)}\n  {F_hom\u2082 : \u03a0 {X Y : \ud835\udc9f\u2082}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj\u2082 X) (F_obj\u2082 Y)}\n  (h : limit_obj\u2082 F_obj\u2081 @F_hom\u2081 = limit_obj\u2082 F_obj\u2082 @F_hom\u2082) : \n  \ud835\udc9f\u2081 = \ud835\udc9f\u2082 \u2227 i\u2081 == i\u2082 \u2227 F_obj\u2081 == F_obj\u2082 \u2227 @F_hom\u2081 == @F_hom\u2082 :=\nbegin\n  simp [limit_obj\u2082, limit_obj\u2081] at h,\n  injection h with h\u2081 h\u2082 h\u2083 h\u2084,\n  unfreezingI { subst h\u2081 },\n  rw heq_iff_eq at h\u2082,\n  unfreezingI { subst h\u2082 },\n  simp [heq_iff_eq, function.funext_iff, subtype.coe_injective.eq_iff] at h\u2083,\n  rw [\u2190 function.funext_iff] at h\u2083,\n  dsimp at h\u2083,\n  subst h\u2083,\n  simp [heq_iff_eq, function.funext_iff, subtype.coe_injective.eq_iff] at h\u2084,\n  simp,\n  ext,\n  simp *\nend\n\ndef colimit_obj\u2082 (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e) \n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)) : obj\u2082 \ud835\udc9e :=\n\u27e8colimit_obj\u2081 (\u03bb X, (F_obj X).1) (\u03bb X Y f, (F_hom f).1), valid_obj\u2081.colimit_obj _ _ (\u03bb X, (F_obj X).2)\u27e9\n\nlemma colimit_obj\u2082_injective {\ud835\udc9f\u2081 \ud835\udc9f\u2082 : Type} [i\u2081 : category \ud835\udc9f\u2081] [i\u2082 : category \ud835\udc9f\u2082] \n  {F_obj\u2081 : \ud835\udc9f\u2081 \u2192 obj\u2082 \ud835\udc9e} {F_obj\u2082 : \ud835\udc9f\u2082 \u2192 obj\u2082 \ud835\udc9e} \n  {F_hom\u2081 : \u03a0 {X Y : \ud835\udc9f\u2081}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj\u2081 X) (F_obj\u2081 Y)}\n  {F_hom\u2082 : \u03a0 {X Y : \ud835\udc9f\u2082}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj\u2082 X) (F_obj\u2082 Y)}\n  (h : colimit_obj\u2082 F_obj\u2081 @F_hom\u2081 = colimit_obj\u2082 F_obj\u2082 @F_hom\u2082) : \n  \ud835\udc9f\u2081 = \ud835\udc9f\u2082 \u2227 i\u2081 == i\u2082 \u2227 F_obj\u2081 == F_obj\u2082 \u2227 @F_hom\u2081 == @F_hom\u2082 :=\nbegin\n  simp [colimit_obj\u2082, colimit_obj\u2081] at h,\n  injection h with h\u2081 h\u2082 h\u2083 h\u2084,\n  unfreezingI { subst h\u2081 },\n  rw heq_iff_eq at h\u2082,\n  unfreezingI { subst h\u2082 },\n  simp [heq_iff_eq, function.funext_iff, subtype.coe_injective.eq_iff] at h\u2083,\n  rw [\u2190 function.funext_iff] at h\u2083,\n  dsimp at h\u2083,\n  subst h\u2083,\n  simp [heq_iff_eq, function.funext_iff, subtype.coe_injective.eq_iff] at h\u2084,\n  simp,\n  ext,\n  simp *\nend\n\ndef of_cat_hom\u2082 {X Y : \ud835\udc9e} (f : X \u27f6 Y) : hom\u2082 (of_cat_obj\u2082 X) (of_cat_obj\u2082 Y) :=\n\u27e8of_cat_hom\u2081 f, valid_hom\u2081.of_cat_hom _\u27e9 \n\ndef limit_cone_comp\u2082 (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)) (X : \ud835\udc9f) \n  {Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 (F_obj X) Y) :\n  hom\u2082 (limit_obj\u2082 F_obj @F_hom) Y :=\n\u27e8limit_cone_comp\u2081 (\u03bb X, (F_obj X).1) (\u03bb X Y f, (F_hom f).1) X f.1, \n  valid_hom\u2081.limit_cone_comp _ (\u03bb X, (F_obj X).2) _ _ _ (\u03bb X Y f, (F_hom f).2) f.2\u27e9\n\ndef colimit_cocone_comp\u2082 (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)) (X : \ud835\udc9f) \n  {Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 Y (F_obj X)):\n  hom\u2082 Y (colimit_obj\u2082 F_obj @F_hom) :=\n\u27e8colimit_cocone_comp\u2081 (\u03bb X, (F_obj X).1) (\u03bb X Y f, (F_hom f).1) X f.1, \n  valid_hom\u2081.colimit_cocone_comp _ (\u03bb X, (F_obj X).2) _ _ _ (\u03bb X Y f, (F_hom f).2) f.2\u27e9\n\ndef is_limit\u2082 (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e) \n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n  (cone_obj : obj\u2082 \ud835\udc9e)\n  (cone : \u03a0 (X : \ud835\udc9f), hom\u2082 cone_obj (F_obj X)) :\n  hom\u2082 cone_obj (limit_obj\u2082 F_obj @F_hom) :=\n\u27e8is_limit\u2081 (\u03bb X, (F_obj X).1) (\u03bb X Y f, (F_hom f).1) cone_obj.1 (\u03bb X, (cone X).1), \n  valid_hom\u2081.is_limit _ (\u03bb X, (F_obj X).2) _ _ _ (\u03bb X Y f, (F_hom f).2) (\u03bb X, (cone X).2)\u27e9\n\ndef is_colimit\u2082 (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e) \n  (F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n  (cocone_obj : obj\u2082 \ud835\udc9e)\n  (cocone : \u03a0 (X : \ud835\udc9f), hom\u2082 (F_obj X) cocone_obj) :\n  hom\u2082 (colimit_obj\u2082 F_obj @F_hom) cocone_obj  :=\n\u27e8is_colimit\u2081 (\u03bb X, (F_obj X).1) (\u03bb X Y f, (F_hom f).1) cocone_obj.1 (\u03bb X, (cocone X).1), \n  valid_hom\u2081.is_colimit _ (\u03bb X, (F_obj X).2) _ _ _ (\u03bb X Y f, (F_hom f).2) (\u03bb X, (cocone X).2)\u27e9\n\ndef id\u2082 (X : obj\u2082 \ud835\udc9e) : hom\u2082 X X := \u27e8id\u2081 X.1, valid_hom\u2081.id _\u27e9 \n\n@[elab_as_eliminator] protected def hom\u2082.rec_on \n  {motive : \u03a0 {X Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 X Y), Sort*} {X Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 X Y)\n  (of_cat_hom : \u03a0 {X Y : \ud835\udc9e} (f : X \u27f6 Y), motive (of_cat_hom\u2082 f))\n  (limit_cone_comp : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n    (ih_F_hom : \u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f))\n    (X : \ud835\udc9f) {Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 (F_obj X) Y)\n    (ih_f : motive f),\n      motive (by exactI limit_cone_comp\u2082 F_obj @F_hom X f))\n  (colimit_cocone_comp : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)) \n    (ih_F_hom : \u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f))\n    (X : \ud835\udc9f) {Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 Y (F_obj X))\n    (ih_f : motive f),\n      motive (by exactI colimit_cocone_comp\u2082 F_obj @F_hom X f))\n  (is_limit : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n    (ih_F_hom : \u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f)) \n    (cone_obj : obj\u2082 \ud835\udc9e) (cone : \u03a0 (X : \ud835\udc9f), hom\u2082 cone_obj (F_obj X))\n    (ih_cone : \u03a0 (X : \ud835\udc9f), motive (cone X)),\n      motive (by exactI is_limit\u2082 F_obj @F_hom cone_obj cone))\n  (is_colimit : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)) \n    (ih_F_hom : \u03a0 {X Y : \ud835\udc9f} (f : by exactI X \u27f6 Y), motive (F_hom f))\n    (cocone_obj : obj\u2082 \ud835\udc9e) (cocone : \u03a0 (X : \ud835\udc9f), hom\u2082 (F_obj X) cocone_obj)\n    (ih_cone : \u03a0 (X : \ud835\udc9f), motive (cocone X)),\n      motive (by exactI is_colimit\u2082 F_obj @F_hom cocone_obj cocone))\n  (id : \u03a0 (X : obj\u2082 \ud835\udc9e), motive (id\u2082 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 \u27e8f, hfd, hfc\u27e9,\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 \ud835\udc9f _ F_obj F_hom A B g ih\u2081 ih\u2082 X Y hX hY hfd hfc hf,\n    dsimp at hfd hfc, substs hfc hfd,\n    have valid_F_obj : \u2200 X, valid_obj\u2081 (F_obj X),\n    { cases hf, assumption },\n    let F_obj' : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e := \u03bb X, \u27e8F_obj X, valid_F_obj X\u27e9,\n    have valid_F_hom : \u2200 X Y f, \n      \u2203 (h\u2081 : (@F_hom X Y f).dom = F_obj X) \n      (h\u2082 : (@F_hom X Y f).cod = F_obj Y),\n      valid_hom\u2081 \u27e8@F_hom X Y f, h\u2081, h\u2082\u27e9,\n    { cases hf, simpa },\n     let F_hom' : \u03a0 (X Y : \ud835\udc9f) (f : X \u27f6 Y), hom\u2082 (F_obj' X) (F_obj' Y) :=\n      \u03bb X Y f, \u27e8\u27e8@F_hom X Y f, (valid_F_hom X Y f).fst, (valid_F_hom X Y f).snd.fst\u27e9,\n        (valid_F_hom X Y f).snd.snd\u27e9,\n    have valid_g : \n      \u2203 (h\u2081 : g.dom = F_obj A) (h\u2082 : g.cod = B),\n      valid_hom\u2081 \u27e8g, h\u2081, h\u2082\u27e9,\n    { cases hf, simpa },\n    let g' : hom\u2082 (F_obj' A) \u27e8B, hY\u27e9 :=\n      \u27e8\u27e8g, valid_g.fst, valid_g.snd.fst\u27e9, valid_g.snd.snd\u27e9,\n    exact limit_cone_comp F_obj' F_hom'\n      (\u03bb X Y f, ih\u2081 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\u2082 (F_obj' A).1 B (F_obj' A).2 hY g'.1.2.1 g'.1.2.2 g'.2) },\n  { introsI \ud835\udc9f _ F_obj F_hom cone_obj cone ih\u2081 ih\u2082 X Y hX hY hfd hfc hf,\n    dsimp at hfd hfc,\n    substs hfc hfd,\n    have valid_F_obj : \u2200 X, valid_obj\u2081 (F_obj X),\n    { cases hf, assumption },\n    let F_obj' : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e := \u03bb X, \u27e8F_obj X, valid_F_obj X\u27e9,\n    have valid_F_hom : \u2200 X Y f, \n      \u2203 (h\u2081 : (@F_hom X Y f).dom = F_obj X) \n      (h\u2082 : (@F_hom X Y f).cod = F_obj Y),\n      valid_hom\u2081 \u27e8@F_hom X Y f, h\u2081, h\u2082\u27e9,\n    { cases hf, simpa },\n    let F_hom' : \u03a0 (X Y : \ud835\udc9f) (f : X \u27f6 Y), hom\u2082 (F_obj' X) (F_obj' Y) :=\n      \u03bb X Y f, \u27e8\u27e8@F_hom X Y f, (valid_F_hom X Y f).fst, (valid_F_hom X Y f).snd.fst\u27e9,\n        (valid_F_hom X Y f).snd.snd\u27e9,\n    let cone_obj' : obj\u2082 \ud835\udc9e := \u27e8cone_obj, hX\u27e9,\n    have valid_cone : \u2200 (X : \ud835\udc9f), \u2203 (h\u2081 : (cone X).dom = cone_obj'.1)\n      (h\u2082 : (cone X).cod = (F_obj' X).1),\n      valid_hom\u2081 \u27e8cone X, h\u2081, h\u2082\u27e9,\n    { cases hf, simpa },\n    let cone' : \u03a0 (X : \ud835\udc9f), hom\u2082 cone_obj' (F_obj' X) :=\n      \u03bb X, \u27e8\u27e8cone X, (valid_cone X).fst, (valid_cone X).snd.fst\u27e9, (valid_cone X).snd.snd\u27e9,\n    exact is_limit F_obj' F_hom'\n      (\u03bb A B f, ih\u2081 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        (\u03bb X, ih\u2082 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 \ud835\udc9f _ F_obj F_hom A B g ih\u2081 ih\u2082 X Y hX hY hfd hfc hf,\n    dsimp at hfd hfc, substs hfc hfd,\n    have valid_F_obj : \u2200 X, valid_obj\u2081 (F_obj X),\n    { cases hf, assumption },\n    let F_obj' : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e := \u03bb X, \u27e8F_obj X, valid_F_obj X\u27e9,\n    have valid_F_hom : \u2200 X Y f, \n      \u2203 (h\u2081 : (@F_hom X Y f).dom = F_obj X) \n      (h\u2082 : (@F_hom X Y f).cod = F_obj Y),\n      valid_hom\u2081 \u27e8@F_hom X Y f, h\u2081, h\u2082\u27e9,\n    { cases hf, simpa },\n    have valid_g : \n      \u2203 (h\u2081 : g.dom = B) (h\u2082 : g.cod = F_obj A),\n      valid_hom\u2081 \u27e8g, h\u2081, h\u2082\u27e9,\n    { cases hf, simpa },\n    let g' : hom\u2082 \u27e8B, hX\u27e9 (F_obj' A) :=\n      \u27e8\u27e8g, valid_g.fst, valid_g.snd.fst\u27e9, valid_g.snd.snd\u27e9,\n    let F_hom' : \u03a0 (X Y : \ud835\udc9f) (f : X \u27f6 Y), hom\u2082 (F_obj' X) (F_obj' Y) :=\n      \u03bb X Y f, \u27e8\u27e8@F_hom X Y f, (valid_F_hom X Y f).fst, (valid_F_hom X Y f).snd.fst\u27e9,\n        (valid_F_hom X Y f).snd.snd\u27e9,\n    exact colimit_cocone_comp F_obj' F_hom'\n      (\u03bb X Y f, ih\u2081 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\u2082 B (F_obj' A).1 hX (F_obj' A).2 g'.1.2.1 g'.1.2.2 g'.2) },\n  { introsI \ud835\udc9f _ F_obj F_hom cocone_obj cocone ih\u2081 ih\u2082 X Y hX hY hfd hfc hf,\n    dsimp at hfd hfc,\n    substs hfc hfd,\n    have valid_F_obj : \u2200 X, valid_obj\u2081 (F_obj X),\n    { cases hf, assumption },\n    let F_obj' : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e := \u03bb X, \u27e8F_obj X, valid_F_obj X\u27e9,\n    have valid_F_hom : \u2200 X Y f, \n      \u2203 (h\u2081 : (@F_hom X Y f).dom = F_obj X) \n      (h\u2082 : (@F_hom X Y f).cod = F_obj Y),\n      valid_hom\u2081 \u27e8@F_hom X Y f, h\u2081, h\u2082\u27e9,\n    { cases hf, simpa },\n    let F_hom' : \u03a0 (X Y : \ud835\udc9f) (f : X \u27f6 Y), hom\u2082 (F_obj' X) (F_obj' Y) :=\n      \u03bb X Y f, \u27e8\u27e8@F_hom X Y f, (valid_F_hom X Y f).fst, (valid_F_hom X Y f).snd.fst\u27e9,\n        (valid_F_hom X Y f).snd.snd\u27e9,\n    let cocone_obj' : obj\u2082 \ud835\udc9e := \u27e8cocone_obj, hY\u27e9,\n    have valid_cocone : \u2200 (X : \ud835\udc9f), \u2203 (h\u2081 : (cocone X).dom = (F_obj' X).1)\n      (h\u2082 : (cocone X).cod = cocone_obj'.1),\n      valid_hom\u2081 \u27e8cocone X, h\u2081, h\u2082\u27e9,\n    { cases hf, simpa },\n    let cocone' : \u03a0 (X : \ud835\udc9f), hom\u2082 (F_obj' X) cocone_obj' :=\n      \u03bb X, \u27e8\u27e8cocone X, (valid_cocone X).fst, (valid_cocone X).snd.fst\u27e9, (valid_cocone X).snd.snd\u27e9,\n    exact is_colimit F_obj' F_hom'\n      (\u03bb A B f, ih\u2081 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        (\u03bb X, ih\u2082 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 \u27e8B, hB\u27e9 }\nend\n\ndef hom\u2082_of_cat_obj_rec_on\n  {motive : \u03a0 {X : \ud835\udc9e} {Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 (of_cat_obj\u2082 X) Y), Sort*} \n  {X : \ud835\udc9e} {Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 (of_cat_obj\u2082 X) Y)\n  (of_cat_hom : \u03a0 {Y : \ud835\udc9e} (f : X \u27f6 Y), motive (of_cat_hom\u2082 f))\n  (colimit_cocone_comp : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)) \n    (X : \ud835\udc9f) {Y : \ud835\udc9e} (f : hom\u2082 (of_cat_obj\u2082 Y) (F_obj X))\n    (ih_f : motive f),\n      motive (by exactI colimit_cocone_comp\u2082 F_obj @F_hom X f))\n  (is_limit : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n    (cone_obj : \ud835\udc9e) (cone : \u03a0 (X : \ud835\udc9f), hom\u2082 (of_cat_obj\u2082 cone_obj) (F_obj X))\n    (ih_cone : \u03a0 (X : \ud835\udc9f), motive (cone X)),\n      motive (by exactI is_limit\u2082 F_obj @F_hom (of_cat_obj\u2082 cone_obj) cone)) \n  (id : motive (id\u2082 (of_cat_obj\u2082 X))):\n  motive f := \n@hom\u2082.rec_on \ud835\udc9e _ (\u03bb A B f, \u2200 (h : A = of_cat_obj\u2082 X),\n  motive (show hom\u2082 (of_cat_obj\u2082 X) B, from eq.rec_on h f))\n  (of_cat_obj\u2082 X) Y f \n  (\u03bb A B g h, begin\n      have := of_cat_obj\u2082_injective h,\n      subst this,\n      dsimp,\n      exact of_cat_hom g\n    end) \n  begin \n    intros,\n    simp [limit_obj\u2082, of_cat_obj\u2082, limit_obj\u2081] at h,\n    contradiction\n  end \n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 A B g ih\u2082 h,\n    subst h,\n    exact colimit_cocone_comp _ _ _ _ (ih\u2082 rfl)\n  end \n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 cone_obj cone ih\u2082 h,\n    subst h,\n    exact is_limit _ _ _ _ (\u03bb A, ih\u2082 A rfl),\n  end \n  begin \n    intros,\n    simp [colimit_obj\u2082, of_cat_obj\u2082] 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\u2082_limit_obj_rec_on\n  {motive : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] {F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e}\n    {F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)} {Y : obj\u2082 \ud835\udc9e}, \n    hom\u2082 (by exactI limit_obj\u2082 F_obj @F_hom) Y \u2192 Sort*}\n  {\ud835\udc9f : Type} [category \ud835\udc9f] {F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e}\n  {F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)} {Y : obj\u2082 \ud835\udc9e}\n  (f : hom\u2082 (limit_obj\u2082 F_obj @F_hom) Y)\n  (limit_cone_comp : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n    (X : \ud835\udc9f) {Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 (F_obj X) Y),\n      by exactI motive (limit_cone_comp\u2082 F_obj @F_hom X f))\n  (colimit_cocone_comp : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n    (X : \ud835\udc9f)\n    {\u2130 : Type} [category \u2130] (G_obj : \u2130 \u2192 obj\u2082 \ud835\udc9e)\n    (G_hom : \u03a0 {X Y : \u2130}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (G_obj X) (G_obj Y))\n    (f : hom\u2082 (by exactI limit_obj\u2082 G_obj @G_hom) (F_obj X))\n    (ih_f : by exactI motive f),\n      by exactI motive (colimit_cocone_comp\u2082 F_obj @F_hom X f))\n  (is_limit : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n    {\u2130 : Type} [category \u2130] (G_obj : \u2130 \u2192 obj\u2082 \ud835\udc9e)\n    (G_hom : \u03a0 {X Y : \u2130}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (G_obj X) (G_obj Y))\n    (cone : \u03a0 (X : \ud835\udc9f), hom\u2082 (by exactI limit_obj\u2082 G_obj @G_hom) (F_obj X))\n    (ih_cone : \u03a0 (X : \ud835\udc9f), by exactI motive (cone X)),\n      by exactI motive (is_limit\u2082 F_obj @F_hom (limit_obj\u2082 G_obj @G_hom) cone))\n  (id : by exactI motive (id\u2082 (limit_obj\u2082 F_obj @F_hom))) :\n  motive f :=\n@hom\u2082.rec_on \ud835\udc9e _ (\u03bb A B f, \u2200 (h : A = limit_obj\u2082 F_obj @F_hom),\n  motive (show hom\u2082 (limit_obj\u2082 F_obj @F_hom) B, from eq.rec_on h f))\n  (limit_obj\u2082 F_obj @F_hom) Y f \n  begin \n    intros,\n    simp [limit_obj\u2082, of_cat_obj\u2082, limit_obj\u2081] at h,\n    contradiction\n  end  \n  begin \n    introsI \u2130 _ G_obj G_hom ih\u2081 A B g ih\u2082 h,\n    unfreezingI { rcases (limit_obj\u2082_injective h) with \u27e8rfl, h\u2081, h\u2082, h\u2083\u27e9 },\n    unfreezingI { subst h\u2081, subst h\u2082, subst h\u2083 },\n    exact limit_cone_comp _ _ _ _\n  end \n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 A B g ih\u2082 h,\n    subst h,\n    exact colimit_cocone_comp _ _ _ _ _ _ (ih\u2082 rfl)\n  end \n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 cone_obj cone ih\u2082 h,\n    subst h,\n    exact is_limit _ _ _ _ _ (\u03bb A, ih\u2082 A rfl),\n  end \n  begin \n    intros,\n    simp [colimit_obj\u2082, of_cat_obj\u2082, limit_obj\u2082] 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\u2082_colimit_obj_rec_on\n  {motive : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] {F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e}\n    {F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)} {Y : obj\u2082 \ud835\udc9e}, \n    hom\u2082 (by exactI colimit_obj\u2082 F_obj @F_hom) Y \u2192 Sort*}\n  {\ud835\udc9f : Type} [category \ud835\udc9f] {F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e}\n  {F_hom : \u03a0 {X Y : \ud835\udc9f}, (X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)} {Y : obj\u2082 \ud835\udc9e}\n  (f : hom\u2082 (colimit_obj\u2082 F_obj @F_hom) Y)\n  (colimit_cocone_comp : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n    (X : \ud835\udc9f) \n    {\u2130 : Type} [category \u2130] {G_obj : \u2130 \u2192 obj\u2082 \ud835\udc9e}\n    {G_hom : \u03a0 {X Y : \u2130}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (G_obj X) (G_obj Y)} \n    (f : hom\u2082 (by exactI colimit_obj\u2082 G_obj @G_hom) (F_obj X))\n    (ih_f : by exactI motive f),\n      by exactI motive (by exactI colimit_cocone_comp\u2082 F_obj @F_hom X f))\n  (is_limit : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y))\n    {\u2130 : Type} [category \u2130] {G_obj : \u2130 \u2192 obj\u2082 \ud835\udc9e}\n    {G_hom : \u03a0 {X Y : \u2130}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (G_obj X) (G_obj Y)}\n    (cone : \u03a0 (X : \ud835\udc9f), hom\u2082 (by exactI colimit_obj\u2082 G_obj @G_hom) (F_obj X))\n    (ih_cone : \u03a0 (X : \ud835\udc9f), by exactI motive (cone X)),\n      by exactI motive (by exactI is_limit\u2082 F_obj @F_hom _ cone))\n  (is_colimit : \u03a0 {\ud835\udc9f : Type} [category \ud835\udc9f] (F_obj : \ud835\udc9f \u2192 obj\u2082 \ud835\udc9e)\n    (F_hom : \u03a0 {X Y : \ud835\udc9f}, (by exactI X \u27f6 Y) \u2192 hom\u2082 (F_obj X) (F_obj Y)) \n    (cocone_obj : obj\u2082 \ud835\udc9e) (cocone : \u03a0 (X : \ud835\udc9f), hom\u2082 (F_obj X) cocone_obj),\n      by exactI motive (is_colimit\u2082 F_obj @F_hom cocone_obj cocone)) \n  (id : by exactI motive (id\u2082 (colimit_obj\u2082 F_obj @F_hom))):\n  motive f :=\n@hom\u2082.rec_on \ud835\udc9e _ (\u03bb A B f, \u2200 (h : A = colimit_obj\u2082 F_obj @F_hom),\n  motive (show hom\u2082 (colimit_obj\u2082 F_obj @F_hom) B, from eq.rec_on h f))\n  (colimit_obj\u2082 F_obj @F_hom) Y f \n  begin \n    intros,\n    simp [colimit_obj\u2082, of_cat_obj\u2082, colimit_obj\u2081] at h,\n    contradiction\n  end \n  begin \n    intros,\n    simp [colimit_obj\u2082, of_cat_obj\u2082, colimit_obj\u2081, limit_obj\u2081, limit_obj\u2082] at h,\n    contradiction\n  end\n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 A B f ih\u2082 h,\n    subst h,\n    exact colimit_cocone_comp _ _ _ _ (ih\u2082 rfl)\n  end\n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 cone_obj cone ih\u2082 h,\n    subst h,\n    exact is_limit _ _ _ (\u03bb X, ih\u2082 X rfl)\n  end\n  begin\n    introsI \u2130 _ G_obj G_hom ih\u2081 cocone_obj cocone ih\u2082 h,\n    unfreezingI { rcases (colimit_obj\u2082_injective h) with \u27e8rfl, h\u2081, h\u2082, h\u2083\u27e9 },\n    unfreezingI { subst h\u2081, subst h\u2082, subst h\u2083 },\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\u2082 {X Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 X Y) : \u03a0 {Z : obj\u2082 \ud835\udc9e}, hom\u2082 Y Z \u2192 hom\u2082 X Z :=\nhom\u2082.rec_on f \n  begin\n    intros X Y f Z g,\n    refine hom\u2082_of_cat_obj_rec_on g _ _ _ _,\n    { intros B g,\n      exact of_cat_hom\u2082 (f \u226b g) },\n    { introsI \ud835\udc9f _ F_obj F_hom A B g ih,\n      exact colimit_cocone_comp\u2082 F_obj @F_hom A ih },\n    { introsI \ud835\udc9f _ F_obj F_hom A cone ih,\n      exact is_limit\u2082 F_obj @F_hom (of_cat_obj\u2082 X) (\u03bb X, ih _) },\n    { exact of_cat_hom\u2082 f }\n  end\n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 A B f ih\u2082 Z g,\n    refine limit_cone_comp\u2082 F_obj @F_hom A (ih\u2082 g),\n  end\n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 A B f ih\u2082 Z g,\n    revert ih\u2082 A,\n    refine hom\u2082_colimit_obj_rec_on g _ _ _ _,\n    { introsI \u2130 _ G_obj G_hom C \u2131 _ H_obj H_hom ih\u2083 ih\u2084 A g ih\u2082,\n      refine colimit_cocone_comp\u2082 G_obj @G_hom C (ih\u2084 A g @ih\u2082) },\n    { introsI \u2130 _ G_obj G_hom \u2131 _ H_obj H_hom ih\u2083 ih\u2084 A g ih\u2082,\n      exact is_limit\u2082 G_obj @G_hom B (\u03bb X, ih\u2084 X A g @ih\u2082) },\n    { introsI \u2130 _ G_obj G_hom cocone_obj cocone A g ih\u2082,\n      exact ih\u2082 (cocone A) },\n    { intros A f _,\n      exact colimit_cocone_comp\u2082 F_obj @F_hom A f }\n  end \n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 cone_obj cone ih\u2082 Z g,\n    revert ih\u2082,\n    refine hom\u2082_limit_obj_rec_on g _ _ _ _,\n    { introsI \u2130 _ G_obj G_hom A B g ih\u2082,\n      exact ih\u2082 A g },\n    { introsI \u2130 _ F_obj F_hom A \u2131 _ G_obj G_hom g ih\u2083 ih\u2082,\n      exact colimit_cocone_comp\u2082 F_obj @F_hom A (ih\u2083 @ih\u2082) },\n    { introsI \u2130 _ F_obj F_hom \u2131 _ G_obj G_hom ih\u2083 ih\u2084 ih\u2082,\n      exact is_limit\u2082 F_obj @F_hom cone_obj (\u03bb X, ih\u2084 _ @ih\u2082) },\n    { introsI ih,\n      exact is_limit\u2082 F_obj @F_hom cone_obj cone }\n  end\n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 cocone_obj cocone ih\u2082 Z g,\n    exact is_colimit\u2082 F_obj @F_hom Z (\u03bb A, ih\u2082 A g)\n  end\n  (\u03bb _ _ g, g)\n#print has_limits_of_size\nvariables {\u2130 : Type u} [category \u2130] [has_limits_of_size.{0} \u2130] [has_colimits_of_size.{0} \u2130] (F : \ud835\udc9e \u2964 \u2130)\n\ndef UMP_obj {X Y : obj\u2082 \ud835\udc9e} (f : hom\u2082 X Y) : \u03a3 A B : \u2130, A \u27f6 B :=\nhom\u2082.rec_on f \n  (\u03bb X Y f, \u27e8F.obj X, F.obj Y, F.map f\u27e9) \n  begin\n    introsI \ud835\udc9f _ F_obj F_hom ih\u2081 A B g ih\u2082,\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) [\ud835\udd5c :field k] (L : Type u) [\ud835\udd43 :field L] (F : Type u) [\ud835\udd3d :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 := \u03bb F, F.k} \ninstance fieldIsField (a : fields) : field a := a.fStruct\n\ninstance fields_has_hom : has_hom fields :=\n{ hom:= \u03bb a b, ring_hom a b }\ninstance fields_has_cat_struct : category_struct fields :=\n{to_has_hom:= fields_has_hom, id:=\u03bb X, ring_hom.id X, comp := \u03bb 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 \u2192+* k )\n\ninstance ext_fields_coe (L : fields.{u}) : has_coe (fieldsOver L) fields.{u}:=\n\u27e8fieldsOver.k\u27e9\n\n@[ext] structure kLinearMor {L : fields.{u}} (k\u2081 k\u2082 : fieldsOver L) : Type u :=\n(mor : k\u2081 \u2192+* k\u2082 )\n(coincide : ring_hom.comp mor k\u2081.L2k = k\u2082.L2k )\n\n\ninstance morphism_to_fun {L : fields.{u}} (k\u2081 k\u2082 : fieldsOver L) :\n  has_coe_to_fun ( kLinearMor k\u2081 k\u2082) :=\n{ F   := \u03bb _, k\u2081 \u2192 k\u2082,\n  coe := \u03bb 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:=\u03bb X, {mor :=  ring_hom.id X, coincide:= ring_hom.id_comp _ },\n comp := \u03bb a b c fab fbc,\u27e8ring_hom.comp fbc.mor fab.mor, by rw [ring_hom.comp_assoc,fab.coincide,fbc.coincide] \u27e9 }\n\n/- variables (L : fields.{u})(X Y Z :fieldsOver L)\n#check (ext_fields_has_cat_struct L).comp\n#check kLinearMor.mor (\ud835\udfd9X)\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) [\ud835\udd3d :field F] : Type (u+1):=\n(k : Type u)\n(\ud835\udd5c :field k)\n(k2F : k \u2192+* F ) -/\n\n\n\n\n\n\n def AutGrp (L : fields.{u})(F : fieldsOver L):Type u :=\n --F \u2243\u2090[L] F\n F \u2245 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:= \u03bb 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 \u27f6 F)\ninstance bet_fields_coe (L : fields.{u})(F : fieldsOver L) : has_coe (fieldsBetween L F) (fieldsOver L) :=\n\u27e8fieldsBetween.k\u27e9\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\u27e8 \u03bb E, {k:= E.k, L2k:= ring_hom.comp E.L2k F.L2k }\u27e9\n\nlemma induce1 : (\u2191E: 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 := \u03bb E , \u2191E,\n  map := \u03bb A B f , \u27e8f.mor, begin cases f,dsimp,rw [induce1,induce1, \u2190ring_hom.comp_assoc ,f_coincide], end \u27e9,\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 \u2191E) :=\n\u27e8functor.map_iso (base_change_functor L F)\u27e9\n\nlemma lift_inj(g: AutGrp F.k E) : \u21d1(g.hom.mor)=(\u2191 g : (AutGrp L \u2191E)).hom.mor :=\nbegin ext, refl, end\n\ndef AutSubGrp : monoid_hom (AutGrp F.k E) (AutGrp L \u2191E) :=\n{ to_fun :=\u03bb g, \u2191g,\n  map_one' := by refl,\n  map_mul' := begin intros x y, ext, refl, end,\n}\n\nlemma AutSub_inj : function.injective \u21d1(AutSubGrp L F E) :=\nbegin \nrw monoid_hom.injective_iff,\nintros a h,\napply iso.ext,\nhave h0 : \u21d1(AutSubGrp L F E)  = \u03bba, \u2191a := 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\u2200 (K : fieldsOver L) (f g : F \u27f6 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\u2081 C\u2082 C\u2083 : Type*} [category C\u2081] [category C\u2082] [category C\u2083] [has_zero_morphisms C\u2083]\n  [has_zero_object C\u2083]\n\nlemma is_zero_of_comp (F : C\u2081 \u2964 C\u2082) (G : C\u2082 \u2964 C\u2083) (h : limits.is_zero G) :\n  limits.is_zero (F \u22d9 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 \u2964 C :=\nhomological_complex.eval _ c (c.prev i)\n\n@[simps]\ndef next_functor (i : M) : homological_complex C c \u2964 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 \u2245 homological_complex.eval C c j :=\nnat_iso.of_components\n  (\u03bb X, X.X_prev_iso hij)\n  (\u03bb X Y f, by { dsimp, rw [\u2190 iso.eq_comp_inv, assoc, \u2190 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 \u2245 homological_complex.eval C c j :=\nnat_iso.of_components\n  (\u03bb X, X.X_next_iso hij)\n  (\u03bb X Y f, by { dsimp, rw [\u2190 iso.eq_comp_inv, assoc, \u2190 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_\u03c0\u2081_iso_prev_functor (i : M) :\n  functor_homological_complex C c i \u22d9 \u03c0\u2081 \u2245 homological_complex.prev_functor C c i := by refl\n\ndef functor_homological_complex_\u03c0\u2082_iso_eval (i : M) :\n  functor_homological_complex C c i \u22d9 \u03c0\u2082 \u2245 homological_complex.eval C c i := by refl\n\ndef functor_homological_complex_\u03c0\u2083_iso_next_functor (i : M) :\n  functor_homological_complex C c i \u22d9 \u03c0\u2083 \u2245 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, S\u00e9bastien Gou\u00ebzel, 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    (f : \u03b1 \u2192 \u03b2)\n    where\n  comap_uniformity :\n    filter.comap (fun (x : \u03b1 \u00d7 \u03b1) => (f (prod.fst x), f (prod.snd x))) (uniformity \u03b2) = uniformity \u03b1\n\ntheorem uniform_inducing.mk' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2}\n    (h :\n      \u2200 (s : set (\u03b1 \u00d7 \u03b1)),\n        s \u2208 uniformity \u03b1 \u2194\n          \u2203 (t : set (\u03b2 \u00d7 \u03b2)), \u2203 (H : t \u2208 uniformity \u03b2), \u2200 (x y : \u03b1), (f x, f y) \u2208 t \u2192 (x, y) \u2208 s) :\n    uniform_inducing f :=\n  sorry\n\ntheorem uniform_inducing.comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] {g : \u03b2 \u2192 \u03b3} (hg : uniform_inducing g) {f : \u03b1 \u2192 \u03b2}\n    (hf : uniform_inducing f) : uniform_inducing (g \u2218 f) :=\n  sorry\n\nstructure uniform_embedding {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    (f : \u03b1 \u2192 \u03b2)\n    extends uniform_inducing f where\n  inj : function.injective f\n\ntheorem uniform_embedding_subtype_val {\u03b1 : Type u_1} [uniform_space \u03b1] {p : \u03b1 \u2192 Prop} :\n    uniform_embedding subtype.val :=\n  uniform_embedding.mk (uniform_inducing.mk rfl) subtype.val_injective\n\ntheorem uniform_embedding_subtype_coe {\u03b1 : Type u_1} [uniform_space \u03b1] {p : \u03b1 \u2192 Prop} :\n    uniform_embedding coe :=\n  uniform_embedding_subtype_val\n\ntheorem uniform_embedding_set_inclusion {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set \u03b1} {t : set \u03b1}\n    (hst : s \u2286 t) : uniform_embedding (set.inclusion hst) :=\n  sorry\n\ntheorem uniform_embedding.comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] {g : \u03b2 \u2192 \u03b3} (hg : uniform_embedding g) {f : \u03b1 \u2192 \u03b2}\n    (hf : uniform_embedding f) : uniform_embedding (g \u2218 f) :=\n  sorry\n\ntheorem uniform_embedding_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2} :\n    uniform_embedding f \u2194\n        function.injective f \u2227\n          \u2200 (s : set (\u03b1 \u00d7 \u03b1)),\n            s \u2208 uniformity \u03b1 \u2194\n              \u2203 (t : set (\u03b2 \u00d7 \u03b2)),\n                \u2203 (H : t \u2208 uniformity \u03b2), \u2200 (x y : \u03b1), (f x, f y) \u2208 t \u2192 (x, y) \u2208 s :=\n  sorry\n\ntheorem uniform_embedding_def' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2} :\n    uniform_embedding f \u2194\n        function.injective f \u2227\n          uniform_continuous f \u2227\n            \u2200 (s : set (\u03b1 \u00d7 \u03b1)),\n              s \u2208 uniformity \u03b1 \u2192\n                \u2203 (t : set (\u03b2 \u00d7 \u03b2)),\n                  \u2203 (H : t \u2208 uniformity \u03b2), \u2200 (x y : \u03b1), (f x, f y) \u2208 t \u2192 (x, y) \u2208 s :=\n  sorry\n\ntheorem uniform_inducing.uniform_continuous {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : uniform_inducing f) : uniform_continuous f :=\n  sorry\n\ntheorem uniform_inducing.uniform_continuous_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3}\n    [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3}\n    (hg : uniform_inducing g) : uniform_continuous f \u2194 uniform_continuous (g \u2218 f) :=\n  sorry\n\ntheorem uniform_inducing.inducing {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (h : uniform_inducing f) : inducing f :=\n  sorry\n\ntheorem uniform_inducing.prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {\u03b1' : Type u_3} {\u03b2' : Type u_4} [uniform_space \u03b1'] [uniform_space \u03b2'] {e\u2081 : \u03b1 \u2192 \u03b1'}\n    {e\u2082 : \u03b2 \u2192 \u03b2'} (h\u2081 : uniform_inducing e\u2081) (h\u2082 : uniform_inducing e\u2082) :\n    uniform_inducing fun (p : \u03b1 \u00d7 \u03b2) => (e\u2081 (prod.fst p), e\u2082 (prod.snd p)) :=\n  sorry\n\ntheorem uniform_inducing.dense_inducing {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {s : set (\u03b1 \u00d7 \u03b1)} {e : \u03b1 \u2192 \u03b2} (b : \u03b2) (he\u2081 : uniform_inducing e)\n    (he\u2082 : dense_inducing e) (hs : s \u2208 uniformity \u03b1) :\n    \u2203 (a : \u03b1), closure (e '' set_of fun (a' : \u03b1) => (a, a') \u2208 s) \u2208 nhds b :=\n  sorry\n\ntheorem uniform_embedding_subtype_emb {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] (p : \u03b1 \u2192 Prop) {e : \u03b1 \u2192 \u03b2} (ue : uniform_embedding e)\n    (de : dense_embedding e) : uniform_embedding (dense_embedding.subtype_emb p e) :=\n  sorry\n\ntheorem uniform_embedding.prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {\u03b1' : Type u_3} {\u03b2' : Type u_4} [uniform_space \u03b1'] [uniform_space \u03b2'] {e\u2081 : \u03b1 \u2192 \u03b1'}\n    {e\u2082 : \u03b2 \u2192 \u03b2'} (h\u2081 : uniform_embedding e\u2081) (h\u2082 : uniform_embedding e\u2082) :\n    uniform_embedding fun (p : \u03b1 \u00d7 \u03b2) => (e\u2081 (prod.fst p), e\u2082 (prod.snd p)) :=\n  sorry\n\ntheorem is_complete_of_complete_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {m : \u03b1 \u2192 \u03b2} {s : set \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {m : \u03b1 \u2192 \u03b2} {s : set \u03b1} (hm : uniform_embedding m) : is_complete (m '' s) \u2194 is_complete s :=\n  sorry\n\ntheorem complete_space_iff_is_complete_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : uniform_embedding f) :\n    complete_space \u03b1 \u2194 is_complete (set.range f) :=\n  sorry\n\ntheorem complete_space_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {e : \u03b1 \u2243 \u03b2} (he : uniform_embedding \u21d1e) : complete_space \u03b1 \u2194 complete_space \u03b2 :=\n  sorry\n\ntheorem complete_space_coe_iff_is_complete {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set \u03b1} :\n    complete_space \u21a5s \u2194 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) \u2194 is_complete s)) subtype.range_coe))\n      (iff.refl (is_complete s)))\n\ntheorem is_complete.complete_space_coe {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set \u03b1}\n    (hs : is_complete s) : complete_space \u21a5s :=\n  iff.mpr complete_space_coe_iff_is_complete hs\n\ntheorem is_closed.complete_space_coe {\u03b1 : Type u_1} [uniform_space \u03b1] [complete_space \u03b1] {s : set \u03b1}\n    (hs : is_closed s) : complete_space \u21a5s :=\n  is_complete.complete_space_coe (is_closed.is_complete hs)\n\ntheorem complete_space_extension {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {m : \u03b2 \u2192 \u03b1} (hm : uniform_inducing m) (dense : dense_range m)\n    (h : \u2200 (f : filter \u03b2), cauchy f \u2192 \u2203 (x : \u03b1), filter.map m f \u2264 nhds x) : complete_space \u03b1 :=\n  sorry\n\ntheorem totally_bounded_preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2} {s : set \u03b2} (hf : uniform_embedding f) (hs : totally_bounded s) :\n    totally_bounded (f \u207b\u00b9' s) :=\n  sorry\n\ntheorem uniform_embedding_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} [u : uniform_space \u03b2]\n    (hf : function.injective f) : uniform_embedding f :=\n  uniform_embedding.mk (uniform_inducing.mk rfl) hf\n\ntheorem uniformly_extend_exists {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] {e : \u03b2 \u2192 \u03b1} (h_e : uniform_inducing e)\n    (h_dense : dense_range e) {f : \u03b2 \u2192 \u03b3} (h_f : uniform_continuous f) [complete_space \u03b3] (a : \u03b1) :\n    \u2203 (c : \u03b3), filter.tendsto f (filter.comap e (nhds a)) (nhds c) :=\n  sorry\n\ntheorem uniform_extend_subtype {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] [complete_space \u03b3] {p : \u03b1 \u2192 Prop} {e : \u03b1 \u2192 \u03b2} {f : \u03b1 \u2192 \u03b3}\n    {b : \u03b2} {s : set \u03b1} (hf : uniform_continuous fun (x : Subtype p) => f (subtype.val x))\n    (he : uniform_embedding e) (hd : \u2200 (x : \u03b2), x \u2208 closure (set.range e))\n    (hb : closure (e '' s) \u2208 nhds b) (hs : is_closed s) (hp : \u2200 (x : \u03b1), x \u2208 s \u2192 p x) :\n    \u2203 (c : \u03b3), filter.tendsto f (filter.comap e (nhds b)) (nhds c) :=\n  sorry\n\ntheorem uniformly_extend_of_ind {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] {e : \u03b2 \u2192 \u03b1} (h_e : uniform_inducing e)\n    (h_dense : dense_range e) {f : \u03b2 \u2192 \u03b3} (h_f : uniform_continuous f) [separated_space \u03b3] (b : \u03b2) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] {e : \u03b2 \u2192 \u03b1} (h_e : uniform_inducing e)\n    (h_dense : dense_range e) {f : \u03b2 \u2192 \u03b3} [separated_space \u03b3] {g : \u03b1 \u2192 \u03b3}\n    (hg : \u2200 (b : \u03b2), 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] {e : \u03b2 \u2192 \u03b1} (h_e : uniform_inducing e)\n    (h_dense : dense_range e) {f : \u03b2 \u2192 \u03b3} (h_f : uniform_continuous f) [separated_space \u03b3]\n    [complete_space \u03b3] (a : \u03b1) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3}\n    [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] {e : \u03b2 \u2192 \u03b1} (h_e : uniform_inducing e)\n    (h_dense : dense_range e) {f : \u03b2 \u2192 \u03b3} (h_f : uniform_continuous f) [separated_space \u03b3]\n    [c\u03b3 : complete_space \u03b3] :\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": "import tactic data.set\nimport prop.language prop.semantics prop.syntax\n \nnamespace prop\n \ntheorem completeness (v \u03c6) : v \u22a8 \u03c6 \u2192 \u22a2\u2097 \u03c6 :=\nbegin\n  intro hm,\n  sorry\nend \n\nend prop", "meta": {"author": "SnO2WMaN", "repo": "lean-modal-logic", "sha": "b58e6723ffd38db50d0b50bb5b6ed8102de9929b", "save_path": "github-repos/lean/SnO2WMaN-lean-modal-logic", "path": "github-repos/lean/SnO2WMaN-lean-modal-logic/lean-modal-logic-b58e6723ffd38db50d0b50bb5b6ed8102de9929b/src/prop/completeness.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5926665999540697, "lm_q2_score": 0.41869690935568665, "lm_q1q2_score": 0.2481476736791121}}
{"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 $ \u03bb 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 \u2218 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 \u2190 tactic.infer_type pf,\n  env \u2190 tactic.get_env,\n  let decl := (declaration.defn `_ (expr.collect_univ_params pf) tp pf reducibility_hints.opaque ff),\n  res \u2190 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 (\u03bb _, (\"\" : 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 \u2190 tactic.get_env,\n    pf \u2190 pure $ env.unfold_untrusted_macros pf,\n    pft \u2190 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 \u2190 tactic.pp tgt,\n      pft_fmt \u2190 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 \u2190 tactic.get_env,\n  d \u2190 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 \u2192 tactic unit := \u03bb nm, do\nenv \u2190 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 \u2115 := do {\n  gs \u2190 tactic.get_goals,\n  hs \u2190 gs.mmap $ \u03bb g, do {\n    tactic.set_goals [g],\n    es \u2190 (::) <$> tactic.target <*> tactic.local_context,\n    es.mfoldl (\u03bb 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 \u2190 tactic.get_env,\n  declaration.is_theorem <$> env.get nm\n}\n\nend misc\n\nmeta def run_with_input' {\u03b1} : lean.parser \u03b1 \u2192 string \u2192 tactic \u03b1 := \u03bb p s,\ndo\n  (p, \"\") \u2190 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 $ (\u03bb 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 \u2192 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 : \u2203 (X : Scheme) (h\u2081 : affine X) (h\u2082 : quasi_compact X), True := by {\n  aesop;\n}\n\n#print thm\n\n-- example : \u2203 (X : Scheme) (h\u2081 : P X) (h\u2082 : 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": "import ..evaluation\nimport utils\nimport ..tactic_state\nimport meta.expr\nimport all\nimport linear_algebra.tensor_algebra\n\nmeta def json.load (path : string) : tactic json := do {\n  msg \u2190 tactic.unsafe_run_io $ do {\n    f \u2190 io.mk_file_handle path io.mode.read,\n    buffer.to_string <$> io.fs.read_to_end f\n  },\n  tactic.trace format!\"[json.load] MESSAGE: {msg}\",\n  json.parse msg\n}\n\nsection hom_ext'\nmeta def tactic.interactive.trace_tactic_state_data (f : string) : tactic unit :=\n  do { msg \u2190 (format.to_string \u2218 format.flatten \u2218 has_to_format.to_format) <$>\n         (tactic_state_data.get >>= has_to_tactic_json.to_tactic_json),\n       dest_handle \u2190 tactic.unsafe_run_io $ io.mk_file_handle f io.mode.write,\n       tactic.unsafe_run_io $ io.fs.put_str_ln dest_handle msg \n  }\n\nmeta def test_tactic_state (msg\u2080 : option json) (tac : tactic unit) : tactic unit := do {\n  (some msg) \u2190 (do\n    if msg\u2080.is_some then do {msg \u2190 msg\u2080, pure (some msg) } else \n      some <$> json.load \"TEST_JSON.json\" ),\n\n  tactic.trace format!\"MSG LENGTH {(json.unparse msg).length}\",\n  tactic.trace \"REBUILDING TSD\",\n  tsd \u2190 (has_from_json.from_json : json \u2192 tactic tactic_state_data) msg,\n  tactic.trace \"REBUILT TSD\",\n  rebuild_tactic_state tsd,\n  env \u2190 tactic.get_env,\n  ts \u2190 tactic.read,\n  ctx \u2190 tactic.local_context,\n  tactic.trace format!\"LOCAL CONTEXT: {ctx.map expr.to_raw_fmt}\",\n  result \u2190 run_tac_with_tactic_state (tac *> pure ()) ts,\n  tactic.trace \"EVALUATION RESULT: \" *> tactic.trace result,\n  tactic.trace \"OK\"\n}\n\nset_option formatter.hide_full_terms false\nset_option pp.implicit true\n-- theorem t2 {p q r : Prop} (h\u2081 : p) (h\u2082 : q) : (p \u2227 q) \u2228 r :=\n-- begin\n--   apply or.inl,\n--   trace_tactic_state_data \"TEST_JSON.json\",\n--   -- do { tsd_msg \u2190 tactic_state_data.get >>= has_to_tactic_json.to_tactic_json, test_tactic_state tsd_msg `[apply and.intro] },\n--   do { msg \u2190 (format.to_string \u2218 format.flatten \u2218 has_to_format.to_format) <$>\n--          (tactic_state_data.get >>= has_to_tactic_json.to_tactic_json),\n--        dest_handle \u2190 tactic.unsafe_run_io $ io.mk_file_handle \"TEST_JSON.json\" io.mode.write,\n--        tactic.unsafe_run_io $ io.fs.put_str_ln dest_handle msg\n--   },\n--   recover, sorry\n--   -- apply and.intro, from \u2039_\u203a, from \u2039_\u203a\n-- end\n\nnamespace tensor_algebra\nvariables (R : Type*) [comm_semiring R]\nvariables (M : Type*) [add_comm_monoid M] [semimodule R M]\n\n-- @[ext]\n-- theorem hom_ext' {A : Type*} [semiring A] [algebra R A] {f g : tensor_algebra R M \u2192\u2090[R] A}\n--   (w : f.to_linear_map.comp (\u03b9 R) = g.to_linear_map.comp (\u03b9 R)) : f = g :=\n-- begin\n--   rw [\u2190lift_symm_apply, \u2190lift_symm_apply] at w,\n--   do { msg \u2190 (format.to_string \u2218 format.flatten \u2218 has_to_format.to_format) <$>\n--          (tactic_state_data.get >>= has_to_tactic_json.to_tactic_json),\n--        dest_handle \u2190 tactic.unsafe_run_io $ io.mk_file_handle \"TEST_JSON.json\" io.mode.write,\n--        tactic.unsafe_run_io $ io.fs.put_str_ln dest_handle msg\n--   },\n--   exact (lift R).symm.injective w,\n-- end\n-- #check has_from_json_name_aux\n\n-- run_cmd do {msg \u2190 json.load \"TEST_JSON.json\", tactic.trace msg, tactic.trace \"HELLO\", pure ()}\n\n\n-- run_cmd test_tactic_state none `[apply and.intro] -- we have liftoff\n\nsetup_tactic_parser\n-- #check lean.parser_state\n-- run_cmd do {\n--   ps \u2190 lean.parser.mk_parser_state,\n--   tactic.trace ps.cur_pos,\n--   -- result \u2190 (lean.parser.run' (texpr) \" and.intro \"),\n--   result \u2190 (lean.parser.run' (lean.parser.itactic) \" { pure () }\"),\n--   -- let x := result.val,\n--   -- x,\n--   tactic.trace \"HELLO\"\n-- }\n\n\nend tensor_algebra\nend hom_ext'\n", "meta": {"author": "jesse-michael-han", "repo": "lean-tpe-public", "sha": "87c7bb8dfb8271d8fcf917aae0e731600c4f4c6c", "save_path": "github-repos/lean/jesse-michael-han-lean-tpe-public", "path": "github-repos/lean/jesse-michael-han-lean-tpe-public/lean-tpe-public-87c7bb8dfb8271d8fcf917aae0e731600c4f4c6c/src/tests/test_tactic_state.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.24781554514906315}}
{"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 : \u2115) : \u2191n = \u2191n := sorry\n\n/-- Coercion `\u2115 \u2192 \u2124` as a `ring_hom`. -/\ndef of_nat_hom : \u2115 \u2192+* \u2124 := ring_hom.mk coe sorry of_nat_mul sorry of_nat_add\n\n/-- Canonical homomorphism from the integers to any ring(-like) structure `\u03b1` -/\nprotected def cast {\u03b1 : Type u_1} [HasZero \u03b1] [HasOne \u03b1] [Add \u03b1] [Neg \u03b1] : \u2124 \u2192 \u03b1 := sorry\n\n-- see Note [coercion into rings]\n\nprotected instance cast_coe {\u03b1 : Type u_1} [HasZero \u03b1] [HasOne \u03b1] [Add \u03b1] [Neg \u03b1] : has_coe_t \u2124 \u03b1 :=\n  has_coe_t.mk int.cast\n\n@[simp] theorem cast_zero {\u03b1 : Type u_1} [HasZero \u03b1] [HasOne \u03b1] [Add \u03b1] [Neg \u03b1] : \u21910 = 0 := rfl\n\ntheorem cast_of_nat {\u03b1 : Type u_1} [HasZero \u03b1] [HasOne \u03b1] [Add \u03b1] [Neg \u03b1] (n : \u2115) :\n    \u2191(Int.ofNat n) = \u2191n :=\n  rfl\n\n@[simp] theorem cast_coe_nat {\u03b1 : Type u_1} [HasZero \u03b1] [HasOne \u03b1] [Add \u03b1] [Neg \u03b1] (n : \u2115) :\n    \u2191\u2191n = \u2191n :=\n  rfl\n\ntheorem cast_coe_nat' {\u03b1 : Type u_1} [HasZero \u03b1] [HasOne \u03b1] [Add \u03b1] [Neg \u03b1] (n : \u2115) : \u2191\u2191n = \u2191n :=\n  sorry\n\n@[simp] theorem cast_neg_succ_of_nat {\u03b1 : Type u_1} [HasZero \u03b1] [HasOne \u03b1] [Add \u03b1] [Neg \u03b1] (n : \u2115) :\n    \u2191(Int.negSucc n) = -(\u2191n + 1) :=\n  rfl\n\n@[simp] theorem cast_one {\u03b1 : Type u_1} [add_monoid \u03b1] [HasOne \u03b1] [Neg \u03b1] : \u21911 = 1 := nat.cast_one\n\n@[simp] theorem cast_sub_nat_nat {\u03b1 : Type u_1} [add_group \u03b1] [HasOne \u03b1] (m : \u2115) (n : \u2115) :\n    \u2191(sub_nat_nat m n) = \u2191m - \u2191n :=\n  sorry\n\n@[simp] theorem cast_neg_of_nat {\u03b1 : Type u_1} [add_group \u03b1] [HasOne \u03b1] (n : \u2115) :\n    \u2191(neg_of_nat n) = -\u2191n :=\n  nat.cases_on n (idRhs (0 = -0) (Eq.symm neg_zero))\n    fun (n : \u2115) => idRhs (\u2191(neg_of_nat (n + 1)) = \u2191(neg_of_nat (n + 1))) rfl\n\n@[simp] theorem cast_add {\u03b1 : Type u_1} [add_group \u03b1] [HasOne \u03b1] (m : \u2124) (n : \u2124) :\n    \u2191(m + n) = \u2191m + \u2191n :=\n  sorry\n\n@[simp] theorem cast_neg {\u03b1 : Type u_1} [add_group \u03b1] [HasOne \u03b1] (n : \u2124) : \u2191(-n) = -\u2191n :=\n  int.cases_on n (fun (n : \u2115) => idRhs (\u2191(neg_of_nat n) = -\u2191n) (cast_neg_of_nat n))\n    fun (n : \u2115) =>\n      idRhs (\u2191(-Int.negSucc n) = --\u2191(-Int.negSucc n)) (Eq.symm (neg_neg \u2191(-Int.negSucc n)))\n\n@[simp] theorem cast_sub {\u03b1 : Type u_1} [add_group \u03b1] [HasOne \u03b1] (m : \u2124) (n : \u2124) :\n    \u2191(m - n) = \u2191m - \u2191n :=\n  sorry\n\n@[simp] theorem cast_mul {\u03b1 : Type u_1} [ring \u03b1] (m : \u2124) (n : \u2124) : \u2191(m * n) = \u2191m * \u2191n := sorry\n\n/-- `coe : \u2124 \u2192 \u03b1` as an `add_monoid_hom`. -/\ndef cast_add_hom (\u03b1 : Type u_1) [add_group \u03b1] [HasOne \u03b1] : \u2124 \u2192+ \u03b1 :=\n  add_monoid_hom.mk coe sorry cast_add\n\n@[simp] theorem coe_cast_add_hom {\u03b1 : Type u_1} [add_group \u03b1] [HasOne \u03b1] :\n    \u21d1(cast_add_hom \u03b1) = coe :=\n  rfl\n\n/-- `coe : \u2124 \u2192 \u03b1` as a `ring_hom`. -/\ndef cast_ring_hom (\u03b1 : Type u_1) [ring \u03b1] : \u2124 \u2192+* \u03b1 := ring_hom.mk coe sorry cast_mul sorry sorry\n\n@[simp] theorem coe_cast_ring_hom {\u03b1 : Type u_1} [ring \u03b1] : \u21d1(cast_ring_hom \u03b1) = coe := rfl\n\ntheorem cast_commute {\u03b1 : Type u_1} [ring \u03b1] (m : \u2124) (x : \u03b1) : commute (\u2191m) x :=\n  int.cases_on m (fun (n : \u2115) => nat.cast_commute n x)\n    fun (n : \u2115) => commute.neg_left (nat.cast_commute (n + 1) x)\n\ntheorem commute_cast {\u03b1 : Type u_1} [ring \u03b1] (x : \u03b1) (m : \u2124) : commute x \u2191m :=\n  commute.symm (cast_commute m x)\n\n@[simp] theorem coe_nat_bit0 (n : \u2115) : \u2191(bit0 n) = bit0 \u2191n := sorry\n\n@[simp] theorem coe_nat_bit1 (n : \u2115) : \u2191(bit1 n) = bit1 \u2191n := sorry\n\n@[simp] theorem cast_bit0 {\u03b1 : Type u_1} [ring \u03b1] (n : \u2124) : \u2191(bit0 n) = bit0 \u2191n := cast_add n n\n\n@[simp] theorem cast_bit1 {\u03b1 : Type u_1} [ring \u03b1] (n : \u2124) : \u2191(bit1 n) = bit1 \u2191n := sorry\n\ntheorem cast_two {\u03b1 : Type u_1} [ring \u03b1] : \u2191(bit0 1) = bit0 1 := sorry\n\ntheorem cast_mono {\u03b1 : Type u_1} [ordered_ring \u03b1] : monotone coe := sorry\n\n@[simp] theorem cast_nonneg {\u03b1 : Type u_1} [ordered_ring \u03b1] [nontrivial \u03b1] {n : \u2124} :\n    0 \u2264 \u2191n \u2194 0 \u2264 n :=\n  sorry\n\n@[simp] theorem cast_le {\u03b1 : Type u_1} [ordered_ring \u03b1] [nontrivial \u03b1] {m : \u2124} {n : \u2124} :\n    \u2191m \u2264 \u2191n \u2194 m \u2264 n :=\n  sorry\n\ntheorem cast_strict_mono {\u03b1 : Type u_1} [ordered_ring \u03b1] [nontrivial \u03b1] : strict_mono coe :=\n  strict_mono_of_le_iff_le fun (m n : \u2124) => iff.symm cast_le\n\n@[simp] theorem cast_lt {\u03b1 : Type u_1} [ordered_ring \u03b1] [nontrivial \u03b1] {m : \u2124} {n : \u2124} :\n    \u2191m < \u2191n \u2194 m < n :=\n  strict_mono.lt_iff_lt cast_strict_mono\n\n@[simp] theorem cast_nonpos {\u03b1 : Type u_1} [ordered_ring \u03b1] [nontrivial \u03b1] {n : \u2124} :\n    \u2191n \u2264 0 \u2194 n \u2264 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n \u2264 0 \u2194 n \u2264 0)) (Eq.symm cast_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n \u2264 \u21910 \u2194 n \u2264 0)) (propext cast_le))) (iff.refl (n \u2264 0)))\n\n@[simp] theorem cast_pos {\u03b1 : Type u_1} [ordered_ring \u03b1] [nontrivial \u03b1] {n : \u2124} : 0 < \u2191n \u2194 0 < n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (0 < \u2191n \u2194 0 < n)) (Eq.symm cast_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u21910 < \u2191n \u2194 0 < n)) (propext cast_lt))) (iff.refl (0 < n)))\n\n@[simp] theorem cast_lt_zero {\u03b1 : Type u_1} [ordered_ring \u03b1] [nontrivial \u03b1] {n : \u2124} :\n    \u2191n < 0 \u2194 n < 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n < 0 \u2194 n < 0)) (Eq.symm cast_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n < \u21910 \u2194 n < 0)) (propext cast_lt))) (iff.refl (n < 0)))\n\n@[simp] theorem cast_min {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] {a : \u2124} {b : \u2124} :\n    \u2191(min a b) = min \u2191a \u2191b :=\n  monotone.map_min cast_mono\n\n@[simp] theorem cast_max {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] {a : \u2124} {b : \u2124} :\n    \u2191(max a b) = max \u2191a \u2191b :=\n  monotone.map_max cast_mono\n\n@[simp] theorem cast_abs {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] {q : \u2124} : \u2191(abs q) = abs \u2191q := sorry\n\ntheorem coe_int_dvd {\u03b1 : Type u_1} [comm_ring \u03b1] (m : \u2124) (n : \u2124) (h : m \u2223 n) : \u2191m \u2223 \u2191n :=\n  ring_hom.map_dvd (cast_ring_hom \u03b1) h\n\nend int\n\n\nnamespace add_monoid_hom\n\n\n/-- Two additive monoid homomorphisms `f`, `g` from `\u2124` to an additive monoid are equal\nif `f 1 = g 1`. -/\ntheorem ext_int {A : Type u_1} [add_monoid A] {f : \u2124 \u2192+ A} {g : \u2124 \u2192+ 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 : \u2124 \u2192+ 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 : \u2124 \u2192+ A) (h1 : coe_fn f 1 = 1)\n    (n : \u2124) : coe_fn f n = \u2191n :=\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 \u2124 \u2192* M} {g : multiplicative \u2124 \u2192* 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 \u2124) => 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 {\u03b1 : Type u_1} [ring \u03b1] (f : \u2124 \u2192+* \u03b1) (n : \u2124) : coe_fn f n = \u2191n :=\n  add_monoid_hom.eq_int_cast (to_add_monoid_hom f) (map_one f) n\n\ntheorem eq_int_cast' {\u03b1 : Type u_1} [ring \u03b1] (f : \u2124 \u2192+* \u03b1) : f = int.cast_ring_hom \u03b1 :=\n  ext (eq_int_cast f)\n\n@[simp] theorem map_int_cast {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ring \u03b1] [ring \u03b2] (f : \u03b1 \u2192+* \u03b2) (n : \u2124) :\n    coe_fn f \u2191n = \u2191n :=\n  eq_int_cast (comp f (int.cast_ring_hom \u03b1)) n\n\ntheorem ext_int {R : Type u_1} [semiring R] (f : \u2124 \u2192+* R) (g : \u2124 \u2192+* 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 (\u2124 \u2192+* R) :=\n  subsingleton.intro ext_int\n\nend ring_hom\n\n\n@[simp] theorem int.cast_id (n : \u2124) : \u2191n = n := Eq.symm (ring_hom.eq_int_cast (ring_hom.id \u2124) 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 \u2192+ B) = (A \u27f6 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_\u03c0 (A : AddCommGroup.{u}) (i : fin 2) : (preadditive.Pow 2).obj A \u27f6 (preadditive.Pow 1).obj A :=\nbiproduct.\u03c0 _ (ulift.up i) \u226b biproduct.\u03b9 (\u03bb _, A) (ulift.up 0)\n\nlemma eval_free_\u03c0_eq (A : AddCommGroup.{u}) (k : fin 2) :\n  eval_free_\u03c0 A k = biproduct.matrix\n    (\u03bb (i : ulift (fin 2)) (j : ulift (fin 1)), basic_universal_map.proj 1 k j.down i.down \u2022 \ud835\udfd9 A) :=\nbegin\n  apply biproduct.hom_ext, rintro \u27e8j\u27e9, fin_cases j,\n  rw [biproduct.matrix_\u03c0, eval_free_\u03c0, category.assoc, biproduct.\u03b9_\u03c0, dif_pos rfl, eq_to_hom_refl,\n    category.comp_id],\n  apply biproduct.hom_ext', rintro \u27e8i\u27e9, rw [biproduct.\u03b9_desc],\n  suffices : basic_universal_map.proj 1 k 0 i = if i = k then 1 else 0,\n  { rw [this, biproduct.\u03b9_\u03c0], 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_\u03c3 (A : AddCommGroup.{u}) : (preadditive.Pow 2).obj A \u27f6 (preadditive.Pow 1).obj A :=\neval_free_\u03c0 A 0 + eval_free_\u03c0 A 1\n\nlemma eval_free_d10 (A : AddCommGroup.{u}) :\n  (((data.eval_functor (forget _ \u22d9 AddCommGroup.free)).obj breen_deligne.eg.data).obj A).d 1 0 =\n  ((forget _ \u22d9 AddCommGroup.free).map $ eval_free_\u03c0 A 0) +\n  ((forget _ \u22d9 AddCommGroup.free).map $ eval_free_\u03c0 A 1) -\n  ((forget _ \u22d9 AddCommGroup.free).map $ eval_free_\u03c3 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.\u03c3\u03c0, 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_\u03c0_eq, refl, },\n  { rw eval_free_\u03c0_eq, refl, },\n  { rw [eval_free_\u03c3, eval_free_\u03c0_eq, eval_free_\u03c0_eq],\n    apply biproduct.hom_ext, rintro \u27e8j\u27e9, fin_cases j, simp only [add_comp, biproduct.matrix_\u03c0],\n    erw [biproduct.matrix_\u03c0, biproduct.matrix_\u03c0],\n    apply biproduct.hom_ext', rintro \u27e8i\u27e9, simp only [comp_add, biproduct.\u03b9_desc, \u2190 add_smul],\n    refl }\nend\n\ndef Pow_1_iso (A : AddCommGroup.{u}) : (preadditive.Pow 1).obj A \u2245 A :=\n{ hom := biproduct.\u03c0 (\u03bb _, A) (ulift.up 0),\n  inv := biproduct.\u03b9 (\u03bb _, A) (ulift.up 0),\n  hom_inv_id' := begin\n    erw [\u2190 biproduct.total, \u2190 equiv.ulift.symm.sum_comp, fin.sum_univ_one], refl,\n  end,\n  inv_hom_id' := by simp only [biproduct.\u03b9_\u03c0, dif_pos rfl, eq_to_hom_refl] }\n\ndef Pow_2_iso (A : AddCommGroup.{u}) : (preadditive.Pow 2).obj A \u2245 AddCommGroup.of (A \u00d7 A) :=\n{ hom := add_monoid_hom.prod (biproduct.\u03c0 (\u03bb _, A) (ulift.up 0)) (biproduct.\u03c0 (\u03bb _, A) (ulift.up 1)),\n  inv := add_monoid_hom.coprod (biproduct.\u03b9 (\u03bb _, A) (ulift.up 0)) (biproduct.\u03b9 (\u03bb _, A) (ulift.up 1)),\n  hom_inv_id' := begin\n    ext x, erw [\u2190 biproduct.total, \u2190 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 [\u2190 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, \u2190 comp_apply, biproduct.\u03b9_\u03c0, 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_\u03c0_eq_fst (A : AddCommGroup.{u}) :\n  (Pow_2_iso A).inv \u226b eval_free_\u03c0 A 0 \u226b (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_\u03c0, add_monoid_hom.coprod_apply],\n  simp only [\u2190 comp_apply, category.assoc, biproduct.\u03b9_\u03c0, 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_\u03c0_eq_snd (A : AddCommGroup.{u}) :\n  (Pow_2_iso A).inv \u226b eval_free_\u03c0 A 1 \u226b (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_\u03c0, add_monoid_hom.coprod_apply],\n  simp only [\u2190 comp_apply, category.assoc, biproduct.\u03b9_\u03c0, 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_\u03c3_eq_add (A : AddCommGroup.{u}) :\n  (Pow_2_iso A).inv \u226b eval_free_\u03c3 A \u226b (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_\u03c3, add_comp, comp_add, eval_free_\u03c0_eq_fst, eval_free_\u03c0_eq_snd], refl, }\n\nlemma eval_free_homology_zero_exact (A : AddCommGroup.{u}) :\n  exact\n  ((((data.eval_functor (forget _ \u22d9 AddCommGroup.free)).obj breen_deligne.eg.data).obj A).d 1 0)\n  ((forget _ \u22d9 AddCommGroup.free).map (Pow_1_iso A).hom \u226b AddCommGroup.of_hom (free_abelian_group.lift id)) :=\nbegin\n  let F := forget _ \u22d9 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_\u03c3\u03c0 A),\n  swap,\n  { dsimp only [functor.map_iso_hom, iso.symm_hom, iso.refl_hom, F],\n    rw [category.comp_id, \u2190 functor.map_iso_inv, \u2190 functor.map_iso_hom, iso.inv_hom_id_assoc], },\n  rw [\u2190 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      \u2190 functor.map_comp, eval_free_\u03c0_eq_fst], refl },\n  { simp only [functor.map_iso_hom, functor.map_iso_inv, iso.symm_hom, iso.symm_inv,\n      \u2190 functor.map_comp, eval_free_\u03c0_eq_snd], refl },\n  { simp only [functor.map_iso_hom, functor.map_iso_inv, iso.symm_hom, iso.symm_inv,\n      \u2190 functor.map_comp, eval_free_\u03c3_eq_add], refl },\nend\n\ninstance eval_free_homology_zero_epi (A : AddCommGroup.{u}) :\n  epi ((forget _ \u22d9 AddCommGroup.free).map (Pow_1_iso A).hom \u226b 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 \u27e8free_abelian_group.of a, free_abelian_group.lift.of _ _\u27e9\nend\n\nopen_locale zero_object\n\nsection\n\nvariables {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0]\nvariables {A B C X : \ud835\udcd0} (f : A \u27f6 B) (g : B \u27f6 C) (\u03b3 : B \u27f6 X)\n\ndef of_epi_g (hfg : exact f g) (hg : epi g) (h\u03b3 : \u03b3 = 0) :\n  homology_iso_datum f \u03b3 C :=\n{ w := by rw [h\u03b3, comp_zero],\n  K := B,\n  \u03b9 := \ud835\udfd9 B,\n  f' := f,\n  fac' := category.comp_id _,\n  zero\u2081' := by rw [h\u03b3, comp_zero],\n  \u03c0 := g,\n  zero\u2082' := hfg.w,\n  fork_is_limit := is_limit_aux _ (\u03bb s, s.\u03b9) (\u03bb s, by apply category.comp_id)\n      (\u03bb s m hm, begin rw [\u2190 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_\u03c0\n  (hfg : exact f g) (hg : epi g) (h\u03b3 : \u03b3 = 0) :\n  (of_epi_g f g \u03b3 hfg hg h\u03b3).to_homology_iso_predatum.\u03c0 = g := rfl\n\nend\n\ndef nat_trans_eval_free :\n  ((data.eval_functor (forget _ \u22d9 AddCommGroup.free.{u})).obj breen_deligne.eg.data) \u22d9\n    homological_complex.eval _ _ 0 \u27f6 \ud835\udfed AddCommGroup :=\n{ app := \u03bb A, (forget _ \u22d9 AddCommGroup.free).map (Pow_1_iso A).hom \u226b\n    AddCommGroup.of_hom (free_abelian_group.lift id),\n  naturality' := \u03bb A\u2081 A\u2082 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 : \u2203 y, x = (Pow_1_iso A\u2081).inv y,\n    { use (Pow_1_iso A\u2081).hom x,\n      rw [\u2190 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) := \u27e80, begin\n      dsimp [eg, eg.BD, eg.rank],\n      linarith,\n    end\u27e9,\n    rw finset.sum_eq_single (ulift.up z), rotate,\n    { intros b hb\u2081 hb\u2082,\n      exfalso,\n      apply hb\u2082,\n      cases b,\n      simp only [ulift.up_inj],\n      rw fin.eq_mk_iff_coe_eq,\n      have hb\u2083 := b.is_lt,\n      dsimp [eg, eg.BD, eg.rank] at hb\u2083,\n      linarith, },\n    { intro h,\n      exfalso,\n      apply h,\n      simp only [finset.mem_univ], },\n    simp only [\u2190 comp_apply, category.assoc],\n    congr' 1,\n    dsimp,\n    change _ \u226b (Pow_1_iso A\u2081).hom \u226b _ \u226b (Pow_1_iso A\u2082).inv \u226b _ = _,\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 _ \u22d9 AddCommGroup.free)).obj breen_deligne.eg.data)\n    \u22d9 short_complex.functor_homological_complex _ _ 0 \u27f6 short_complex.\u03b9_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.\u03b9_middle_\u03c0\u2083_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.\u03c0\u2082.map_id, category.comp_id],\n  dsimp only [short_complex.\u03c6\u2081\u2082, short_complex.functor_homological_complex, functor.comp_obj,\n    short_complex.mk],\n  simp only [@homological_complex.d_to_eq _ _ _ _ (complex_shape.down \u2115) _ _ 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_\u03c4\u2082 (A : AddCommGroup) :\n  (short_complex_nat_trans_eval_free.app A).\u03c4\u2082 = nat_trans_eval_free.app A := rfl\n\ndef eval_free_homology_zero_nat_trans :=\nshort_complex_nat_trans_eval_free \u25eb (\ud835\udfd9 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\u2081 S\u2082 : short_complex A} (\u03c6 : S\u2081 \u27f6 S\u2082) (hg\u2081 : S\u2081.1.g = 0) (hf\u2082 : S\u2082.1.f = 0) (hg\u2082 : S\u2082.1.g = 0)\n  (ex : exact S\u2081.1.f \u03c6.\u03c4\u2082) (epi_\u03c4\u2082 : epi \u03c6.\u03c4\u2082) :\n  is_iso (short_complex.homology_functor.map \u03c6) :=\nbegin\n  let h\u2081 := homology_iso_datum.of_g_is_zero S\u2081.1.f S\u2081.1.g hg\u2081,\n  let h\u2082 := homology_iso_datum.of_both_zeros S\u2082.1.f S\u2082.1.g hf\u2082 hg\u2082,\n  let \u03c8 := cokernel.desc _ \u03c6.\u03c4\u2082 ex.w,\n  let \u03bc : homology_map_datum \u03c6 h\u2081 h\u2082 \u03c8 :=\n  { \u03ba := \u03c6.\u03c4\u2082,\n    fac\u2081' := by { erw [\u03c6.comm\u2081\u2082], simp only [hf\u2082], refl, },\n    fac\u2082' := by { erw [category.id_comp, category.comp_id], },\n    fac\u2083' := by { erw [category.comp_id], apply cokernel.\u03c0_desc, }, },\n  rw \u03bc.homology_map_eq,\n  suffices : is_iso \u03c8,\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 : \u2200 A, is_iso ((short_complex_nat_trans_eval_free \u25eb\n    (\ud835\udfd9 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 \u2115).next 0 with _ | \u27e8i, hi\u27e9,\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_\u03c4\u2082,\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 _ \u22d9 AddCommGroup.free)).obj breen_deligne.eg.data) \u22d9\n    homology_functor _ _ 0 \u2245 \ud835\udfed _ :=\n  iso_whisker_left _ (short_complex.homology_functor_iso _ _ _) \u226a\u226b\n    (functor.associator _ _ _).symm \u226a\u226b as_iso eval_free_homology_zero_nat_trans \u226a\u226b\n    short_complex.\u03b9_middle_homology_nat_iso.symm\n\nend\n\nopen bounded_homotopy_category\n\nnamespace Condensed\n\ndef HQ'Z (n : \u2124) : Ab :=\n((eg.eval $ category_theory.forget AddCommGroup \u22d9 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} \u2115) (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 \u2115) (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\u03bb (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  [\u2200 S : ExtrDisc.{u}, no_zero_smul_divisors \u2124 (A.X.val.obj (op S.val))]\n  (n : \u2115) :\n  ((package.endo_T tensor_functor).obj A).obj (HQ'Z (-n)) \u2245\n      ((eg.eval freeCond'.map_endomorphisms).obj A).val.as.homology (-n) :=\nbegin\n  refine endomorphisms.mk_iso _ _,\n  { refine _ \u226a\u226b ((package.hH_endo\u2081 eg freeCond' n).app A).symm,\n    refine (homology_bd_eval eg A.X (-n)).symm \u226a\u226b _,\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, \u2190 homology_bd_eval_natural_assoc],\n    refine congr_arg2 _ rfl _,\n    dsimp only [iso.app_hom, iso.app_inv],\n    rw [\u2190 functor.comp_map, nat_trans.naturality_assoc],\n    refine congr_arg2 _ rfl _,\n    dsimp only [\u2190 iso.app_inv],\n    rw [iso.comp_inv_eq, category.assoc, iso.eq_inv_comp],\n    exact (eg.hH_endo\u2081_natural freeCond' A n).symm, }\nend\n.\n\n-- move this\nlemma is_tensor_unit_of_iso (A B : Ab) (e : A \u2245 B) (ha : AddCommGroup.is_tensor_unit A) :\n  AddCommGroup.is_tensor_unit B :=\nbegin\n  obtain \u27e8a, ha\u27e9 := ha,\n  refine \u27e8e.hom a, _\u27e9,\n  intro C, specialize ha C,\n  let \u03c6 := iso.AddCommGroup_iso_to_add_equiv ((preadditive_yoneda.obj C).map_iso e.op),\n  exact ha.comp \u03c6.bijective,\nend\n\nlemma bd_lemma (A : Condensed.{u} Ab.{u+1}) (B : Condensed.{u} Ab.{u+1})\n  [\u2200 S : ExtrDisc.{u}, no_zero_smul_divisors \u2124 (A.val.obj (op S.val))]\n  (f : A \u27f6 A) (g : B \u27f6 B) :\n  (\u2200 i, is_iso $ ((Ext' i).map f.op).app B - ((Ext' i).obj (op A)).map g) \u2194\n  (\u2200 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 (\u03bb 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 \u226a\u226b _, clear e,\n      let e := (package.eval'_homology eg (forget AddCommGroup \u22d9 AddCommGroup.free) 0).symm,\n      exact e.app (AddCommGroup.free.obj punit), },\n    { refine \u27e8free_abelian_group.of punit.star, _\u27e9,\n      intro B, split,\n      { intros f g h, ext \u27e8\u27e9, exact h },\n      { intros b, refine \u27e8free_abelian_group.lift (\u03bb _, b), _\u27e9,\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 \u27e8cont, r\u27e9\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 (\u03bb 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 (\u03bb 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 : \u2200 t, t \u2208 s.threads \u2192 t.valid \n\ndef to_system (s : TracedSystem spec) : System spec :={\n  state := s.state\n  threads := s.threads.map \u03bb \u27e8t, _\u27e9 => t\n  panics := 0\n}\n\ndef mk_initial (s : System spec) : TracedSystem spec :={\n  state := s.state\n  threads := s.threads.map \u03bb t => \u27e8t, IsReservation.empty\u27e9\n}\n\ntheorem mk_initial.valid (s : System spec)\n  (initial_valid : spec.validate IsReservation.empty s.state)\n  (threads_valid : \u2200 t, t \u2208 s.threads \u2192 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  : \u2203 ts' : TracedSystem spec,\n    ts'.to_system = s' \u2227 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 \u2208 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 :=\u27e8idx.val, by calc\n          idx.val < ts.threads.length :=idx'.isLt\n                _ = ts'.threads.length :=Eq.symm <| List.length_set ..\u27e9\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 \u2208 ts.threads.set idx.val \u27e8cont, r'\u27e9)\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 : \u211d\u22650) :\n  Top.{0} :=\nTop.of { \u03bc : weak_dual \u211d C(X,\u211d) // \u03bc.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 : \u211d\u22650) :\n  Top.{0} :=\nTop.of { \u03bc : weak_dual \u211d (locally_constant X \u211d) // \u03bc.bdd_LC p c }\n\n/--\nA continuous map `X \u2192 Y` induces a map between spaces of `p`-Radon measures\nwith a given bound.\n-/\ndef map_Radon {X Y : Profinite.{0}} (f : X \u27f6 Y)\n  (p c : \u211d\u22650) [fact (0 < p)] :\n  X.Radon p c \u27f6 Y.Radon p c :=\n{ to_fun := \u03bb \u03bc, \u27e8weak_dual.comap f.comap \u03bc.1,\n    weak_dual.bdd_comap _ \u03bc.2 _\u27e9,\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 \u2192 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 \u27f6 Y)\n  (p c : \u211d\u22650) [fact (0 < p)] :\n  X.Radon_LC p c \u27f6 Y.Radon_LC p c :=\n{ to_fun := \u03bb \u03bc, \u27e8weak_dual.comap f.comap_LC \u03bc.1,\n    weak_dual.bdd_LC_comap _ \u03bc.2 _\u27e9,\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 : \u211d\u22650) [fact (0 < p)] :\n  Profinite.{0} \u2964 Top.{0} :=\n{ obj := \u03bb X, X.Radon p c,\n  map := \u03bb X Y f, map_Radon f _ _,\n  map_id' := \u03bb X, by { ext, dsimp [map_Radon, weak_dual.comap], congr' 1,\n    ext, refl },\n  map_comp' := \u03bb 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 : \u211d\u22650) [fact (0 < p)] :\n  Profinite.{0} \u2964 Top.{0} :=\n{ obj := \u03bb X, X.Radon_LC p c,\n  map := \u03bb X Y f, map_Radon_LC f _ _,\n  map_id' := \u03bb X,\n    by { ext, dsimp [map_Radon_LC, weak_dual.comap], congr' 1, ext, refl },\n  map_comp' := \u03bb 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 \u211d C(X,\u211d) \u2192L[\u211d] weak_dual \u211d (locally_constant X \u211d) :=\nweak_dual.comap $ lc_to_c _\n\nlemma dense_range_coe\u2082 (X : Profinite.{0}) :\n  dense_range (\u03bb p : locally_constant X \u211d \u00d7 locally_constant X \u211d,\n    (lc_to_c X p.1, lc_to_c X p.2)) :=\nbegin\n  letI : uniform_space (locally_constant.pkg X \u211d).space :=\n    (locally_constant.pkg X \u211d).uniform_struct,\n  exact (locally_constant.pkg X \u211d).dense.prod_map (locally_constant.pkg X \u211d).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 \u211d (locally_constant X \u211d) \u2192\u2097[\u211d] weak_dual \u211d C(X,\u211d) :=\n{ to_fun := \u03bb f,\n  { to_fun := (locally_constant.pkg X \u211d).extend f,\n    map_add' := begin\n      letI : uniform_space (locally_constant.pkg X \u211d).space :=\n        (locally_constant.pkg X \u211d).uniform_struct,\n      letI : add_group (locally_constant.pkg X \u211d).space :=\n        continuous_map.add_group,\n      letI : topological_add_group (locally_constant.pkg X \u211d).space :=\n        continuous_map.topological_add_group,\n      rw \u2190 prod.forall',\n      refine is_closed_property (dense_range_coe\u2082 X) _ _,\n      { apply is_closed_eq,\n        { refine (locally_constant.pkg X \u211d).continuous_extend.comp continuous_add },\n        { refine continuous.add _ _;\n          refine (locally_constant.pkg X \u211d).continuous_extend.comp _,\n          exact continuous_fst,\n          exact continuous_snd } },\n      { rintro \u27e8\u03c6, \u03c8\u27e9, dsimp only,\n        have hf := continuous_linear_map.uniform_continuous f,\n        rw [\u2190 (lc_to_c X).map_add],\n        erw [(locally_constant.pkg X \u211d).extend_coe hf, (locally_constant.pkg X \u211d).extend_coe hf,\n          (locally_constant.pkg X \u211d).extend_coe hf, map_add], }\n    end,\n    map_smul' := begin\n      letI : uniform_space (locally_constant.pkg X \u211d).space :=\n        (locally_constant.pkg X \u211d).uniform_struct,\n      letI : add_group (locally_constant.pkg X \u211d).space :=\n        continuous_map.add_group,\n      letI : topological_add_group (locally_constant.pkg X \u211d).space :=\n        continuous_map.topological_add_group,\n      letI : has_smul \u211d (locally_constant.pkg X \u211d).space :=\n        continuous_map.has_smul,\n      letI : has_continuous_smul \u211d (locally_constant.pkg X \u211d).space :=\n        continuous_map.has_continuous_smul,\n      intros r \u03c6,\n      apply (locally_constant.pkg X \u211d).induction_on \u03c6; clear \u03c6,\n      { apply is_closed_eq,\n        { refine (locally_constant.pkg X \u211d).continuous_extend.comp\n            (continuous_const.smul continuous_id), },\n        { refine continuous_const.smul (locally_constant.pkg X \u211d).continuous_extend } },\n      { intro \u03c6,\n        have hf := continuous_linear_map.uniform_continuous f,\n        erw [\u2190 (lc_to_c X).map_smul, (locally_constant.pkg X \u211d).extend_coe hf,\n          (locally_constant.pkg X \u211d).extend_coe hf, map_smul],\n        refl }\n    end,\n    cont := (locally_constant.pkg X \u211d).continuous_extend },\n  map_add' := begin\n    letI : uniform_space (locally_constant.pkg X \u211d).space :=\n      (locally_constant.pkg X \u211d).uniform_struct,\n    intros f g, ext ff, dsimp,\n    apply (locally_constant.pkg X \u211d).induction_on ff,\n    { apply is_closed_eq,\n      apply (locally_constant.pkg X \u211d).continuous_extend, apply_instance,\n      let G : C(X,\u211d) \u2192 \u211d \u00d7 \u211d := \u03bb ff,\n        ((locally_constant.pkg X \u211d).extend f ff, (locally_constant.pkg X \u211d).extend g ff),\n      change continuous ((\u03bb a : \u211d \u00d7 \u211d, a.1 + a.2) \u2218 G),\n      refine continuous.comp continuous_add _,\n      apply continuous.prod_mk,\n      apply (locally_constant.pkg X \u211d).continuous_extend, apply_instance,\n      apply (locally_constant.pkg X \u211d).continuous_extend, apply_instance },\n    { intros a,\n      rw [(locally_constant.pkg X \u211d).extend_coe],\n      rw [(locally_constant.pkg X \u211d).extend_coe],\n      rw [(locally_constant.pkg X \u211d).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 \u211d).space :=\n      (locally_constant.pkg X \u211d).uniform_struct,\n    intros r f, ext ff, dsimp,\n    apply (locally_constant.pkg X \u211d).induction_on ff,\n    { apply is_closed_eq,\n      apply (locally_constant.pkg X \u211d).continuous_extend, apply_instance,\n      refine continuous.comp (continuous_mul_left r) _,\n      apply (locally_constant.pkg X \u211d).continuous_extend, apply_instance },\n    { intros a,\n      rw [(locally_constant.pkg X \u211d).extend_coe],\n      rw [(locally_constant.pkg X \u211d).extend_coe],\n      refl,\n      any_goals { apply_instance },\n      exact f.uniform_continuous,\n      exact (r \u2022 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": "import ReactorModel.Objects.Reactor.Indexable\n\nnamespace ReactorType\n\nopen Indexable\n\n-- About the `\u2194`-condition in `prio`:  We want to establish a dependency between mutations with \n-- priorities as well normal reactions with priorities, but not between normal reactions and\n-- mutations. Otherwise a normal reaction might take precedence over a mutation. Also the precedence\n-- of mutations over normal reactions is handled by `mutNorm`, so this would potentially create a\n-- redundancy.\n--\n-- Note: `Dependency rtr i\u2081 i\u2082` means that in `i\u2081` must occur before `i\u2082`. \ninductive Dependency [Indexable \u03b1] (rtr : \u03b1) : ID \u2192 ID \u2192 Prop\n  | prio : \n    (rtr[.rtr][i] = some con) \u2192 (rcns con i\u2081 = some rcn\u2081) \u2192 (rcns con i\u2082 = some rcn\u2082) \u2192 \n    (rcn\u2081.Mutates \u2194 rcn\u2082.Mutates) \u2192 (rcn\u2081.prio > rcn\u2082.prio) \u2192 Dependency rtr i\u2081 i\u2082\n  | depOverlap {d : Reaction.Dependency} :\n    (rtr[.rcn][i\u2081] = some rcn\u2081) \u2192 (rtr[.rcn][i\u2082] = some rcn\u2082) \u2192 (d \u2208 rcn\u2081.deps .out) \u2192 \n    (d \u2208 rcn\u2082.deps .in) \u2192 (d.cpt \u2260 .stv) \u2192 Dependency rtr i\u2081 i\u2082\n  | mutNorm : \n    (rtr[.rtr][i] = some con) \u2192 (rcns con i\u2098 = some m) \u2192 (rcns con i\u2099 = some n) \u2192 (m.Mutates) \u2192 \n    (n.Normal) \u2192 Dependency rtr i\u2098 i\u2099\n  | mutNest :\n    (rtr[.rtr][i] = some rtr\u2081) \u2192 (nest rtr\u2081 j = some rtr\u2082) \u2192 (rcns rtr\u2081 i\u2098 = some m) \u2192 (m.Mutates) \u2192\n    (i\u1d63 \u2208 rcns rtr\u2082) \u2192 Dependency rtr i\u2098 i\u1d63\n  | trans : \n    Dependency rtr i\u2081 i\u2082 \u2192 Dependency rtr i\u2082 i\u2083 \u2192 Dependency rtr i\u2081 i\u2083\n\nnotation i\u2081 \" <[\" rtr \"] \" i\u2082 => Dependency rtr i\u2081 i\u2082\n\ndef Dependency.Acyclic [Indexable \u03b1] (rtr : \u03b1) : Prop :=\n  \u2200 i, \u00ac(i <[rtr] i)\n\nnamespace Wellformed\n\n-- `ValidDependency rtr rk dk d` means that in reactor `rtr`, reactions of kind `rk` can have `d` as \n-- a valid dependency target of kind `dk`. For example `ValidDependency rtr .mut .out (.port .in i)` \n-- states that mutations can specify the input port identified by `i` as effect and \n-- `ValidDependency rtr .norm .in (.action i)` states that normal reactions can specify the action \n-- identified by `i` as source.\ninductive ValidDependency [ReactorType \u03b1] (rtr : \u03b1) : \n    Reaction.Kind \u2192 Kind \u2192 Reaction.Dependency \u2192 Prop\n  | stv       : (i \u2208 state rtr) \u2192 ValidDependency rtr _ _ \u27e8.stv, i\u27e9  \n  | act       : (i \u2208 acts rtr) \u2192 ValidDependency rtr _ _ \u27e8.act, i\u27e9 \n  | prt       : (i \u2208 ports rtr dk) \u2192 ValidDependency rtr _ dk \u27e8.prt k, i\u27e9  \n  | nestedIn  : (nest rtr j = some con) \u2192 (i \u2208 ports con .in) \u2192 \n                ValidDependency rtr _ .out \u27e8.prt .in, i\u27e9\n  | nestedOut : (nest rtr j = some con) \u2192 (i \u2208 ports con .out) \u2192 \n                ValidDependency rtr .norm .in \u27e8.prt .in, i\u27e9 \n\nvariable [Indexable \u03b1] [Indexable \u03b2] {rtr rtr\u2081 : \u03b1}\n\n-- TODO: Refactor the `prio` conditions into one.\nstructure _root_.ReactorType.Wellformed (rtr : \u03b1) : Prop where\n  unique_inputs : (rtr[.rcn][i\u2081] = some rcn\u2081) \u2192 (rtr[.rcn][i\u2082] = some rcn\u2082) \u2192 (i\u2081 \u2260 i\u2082) \u2192 \n                  (i \u2208 rtr[.prt .in]) \u2192 (\u27e8.prt .in, i\u27e9 \u2208 rcn\u2081.deps .out) \u2192 \n                  (\u27e8.prt .in, i\u27e9 \u2209 rcn\u2082.deps .out)  \n  overlap_prio  : (rtr[.rtr][i] = some con) \u2192 (rcns con i\u2081 = some rcn\u2081) \u2192 \n                  (rcns con i\u2082 = some rcn\u2082) \u2192 (i\u2081 \u2260 i\u2082) \u2192 \n                  (rcn\u2081.deps .out \u2229 rcn\u2082.deps .out).Nonempty \u2192 \n                  (rcn\u2081.prio < rcn\u2082.prio \u2228 rcn\u2082.prio < rcn\u2081.prio)\n  hazards_prio  : (rtr[.rtr][i] = some con) \u2192 (rcns con i\u2081 = some rcn\u2081) \u2192 \n                  (rcns con i\u2082 = some rcn\u2082) \u2192 (i\u2081 \u2260 i\u2082) \u2192 (\u27e8.stv, s\u27e9 \u2208 rcn\u2081.deps k\u2081) \u2192 \n                  (\u27e8.stv, s\u27e9 \u2208 rcn\u2082.deps k\u2082) \u2192 (k\u2081 = .out \u2228 k\u2082 = .out) \u2192 \n                  (rcn\u2081.prio < rcn\u2082.prio \u2228 rcn\u2082.prio < rcn\u2081.prio)\n  mutation_prio : (rtr[.rtr][i] = some con) \u2192 (rcns con i\u2081 = some rcn\u2081) \u2192 \n                  (rcns con i\u2082 = some rcn\u2082) \u2192 (i\u2081 \u2260 i\u2082) \u2192 (rcn\u2081.Mutates) \u2192 (rcn\u2082.Mutates) \u2192\n                  (rcn\u2081.prio < rcn\u2082.prio \u2228 rcn\u2082.prio < rcn\u2081.prio)\n  valid_deps    : (rtr[.rtr][i] = some con) \u2192 (rcns con j = some rcn) \u2192 (d \u2208 rcn.deps k) \u2192 \n                  (ValidDependency con rcn.kind k d) \n  acyclic_deps  : Dependency.Acyclic rtr\n\nend Wellformed\n\nclass Proper (\u03b1) extends Indexable \u03b1 where\n  wellformed : \u2200 rtr : \u03b1, Wellformed rtr\n\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/Wellformed.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5544704649604273, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.24703296844699485}}
{"text": "import Smt\n\ntheorem verum : true := by\n  smt\n  simp_all\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/Test/Bool/Verum.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": "/-\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    (\u03bb 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 : \u2191(k.succ) = \u2191k + 1, by simp,\n      rw [this, mul_sub, add_zero, add_zero, \u2190add_assoc, mul_one],\n      have : \u00ac(j * 16 + \u2191k) % 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 [\u2190two_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 : \u2115) (hj : j \u2260 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    (\u03bb 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 : \u00ac (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 \u2190sub_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 \u2190sub_eq_iff_eq_add.mpr h.symm,\n      ring\n    end,\n  h_op1_addr :=\n    begin\n      have coe3 : \u2191(3 : fin 15) = 3 := fin.coe_eq_val _,\n      have coe4 : \u2191(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 \u2190sub_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 : \u2191(5 : fin 15) = 5 := fin.coe_eq_val _,\n      have coe6 : \u2191(6 : fin 15) = 6 := fin.coe_eq_val _,\n      have coe9 : \u2191(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 _ \u27e8h0, h1\u27e9)\n    end,\n  h_t1_eq := eq_of_sub_eq_zero (upd.update_pc__tmp1 _ \u27e8h0, h1\u27e9),\n  h_next_pc_eq :=\n    begin\n      have coe9 : \u2191(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 _ \u27e8h0, h1\u27e9,\n      convert h using 2,\n      simp [column.off], ring\n    end,\n  h_next_pc_eq' :=\n    begin\n      dsimp,\n      have coe7 : \u2191(7 : fin 15) = 7 := fin.coe_eq_val _,\n      have coe8 : \u2191(8 : fin 15) = 8 := fin.coe_eq_val _,\n      have coe9 : \u2191(9 : fin 15) = 9 := fin.coe_eq_val _,\n      rw \u2190upd.update_pc__pc_cond_negative _ \u27e8h0, h1\u27e9,\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 \u2190opcodes.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, \u2190two_mul],\n      refl\n    end,\n  h_opcode_call' :=\n    begin\n      have coe12 : \u2191(12 : fin 15) = 12 := fin.coe_eq_val _,\n      rw \u2190opcodes.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, \u2190two_mul, coe12],\n      ring\n    end,\n  h_opcode_assert_eq :=\n    begin\n      have coe14 : \u2191(14 : fin 15) = 14 := fin.coe_eq_val _,\n      rw \u2190opcodes.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, \u2190two_mul, coe14]\n    end,\n  h_next_ap :=\n    begin\n      have coe10 : \u2191(10 : fin 15) = 10 := fin.coe_eq_val _,\n      have coe11 : \u2191(11 : fin 15) = 11 := fin.coe_eq_val _,\n      have coe12 : \u2191(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 _ \u27e8h0, h1\u27e9) },\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        \u2190two_mul],\n      norm_num, ring\n    end,\n  h_next_fp :=\n    begin\n      have coe12 : \u2191(12 : fin 15) = 12 := fin.coe_eq_val _,\n      have coe13 : \u2191(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 _ \u27e8h0, h1\u27e9) },\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, \u2190two_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 \u2264 ring_char F) :\n  range_check_constraints\n    (inp.trace_length / 16 - 1)                               -- T\n    (inp.trace_length / 16)                                   -- rc16_len\n    (\u03bb j, c.cpu__decode__off1 (j * 16))                       -- off_op0_tilde : fin T \u2192 F\n    (\u03bb j, c.cpu__decode__off2 (j * 16))                       -- off_op1_tilde : fin T \u2192 F\n    (\u03bb j, c.cpu__decode__off0 (j * 16))                       -- off_dst_tilde : fin T \u2192 F\n    (\u03bb j, c.rc_builtin__inner_rc (j * 16))                    -- rc16_val      : fin rc16_len \u2192 F\n    pd.rc_min\n    pd.rc_max :=\nhave h : \u2200 j : \u2115, \u2200 i : fin (inp.trace_length / 16 - 1),\n           j < 16 \u2192 (\u2191i * 16 + j) < inp.trace_length - 1 + 1,\n  begin\n    rintros j \u27e8i, ilt\u27e9 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 \u2264 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' : \u2200 j : \u2115, \u2200 i : fin (inp.trace_length / 16),\n           j < 16 \u2192 (\u2191i * 16 + j) < inp.trace_length - 1 + 1,\n  begin\n    rintros j \u27e8i, ilt\u27e9 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 \u2264 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  := \u03bb i, c.rc16_pool i,\n  a' := \u03bb i, c.rc16__sorted i,\n  p  := \u03bb i, ci.rc16__perm__cum_prod0 i,\n  z  := pd.rc16__perm__interaction_elm,\n  embed_off_op0 := \u03bb i, \u27e8\u2191i * 16 + 8, h 8 i (by norm_num)\u27e9,\n  embed_off_op1 := \u03bb i, \u27e8\u2191i * 16 + 4, h 4 i (by norm_num)\u27e9,\n  embed_off_dst := \u03bb i, \u27e8\u2191i * 16, h 0 i (by norm_num)\u27e9,\n  embed_rc16_vals := \u03bb i, \u27e8\u2191i * 16 + 12, h' 12 i (by norm_num)\u27e9,\n  h_embed_op0   := \u03bb i, rfl,\n  h_embed_op1   := \u03bb i, rfl,\n  h_embed_dst   := \u03bb i, rfl,\n  h_embed_rc16  := \u03bb i, rfl,\n  h_continuity  :=\n    begin\n      intro i,\n      rw [\u2190rc16.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 [\u2190sub_eq_zero, \u2190rc16.perm__init0 _ rfl],\n      simp [column.off], abel\n    end,\n  h_cumulative :=\n    begin\n      intro i,\n      rw [\u2190sub_eq_zero, \u2190rc16.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 * \u220f 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    (\u03bb i, c.mem_pool__addr (2 * i))    -- a\n    (\u03bb i, c.mem_pool__value (2 * i))   -- v\n    inp.m_star\n    :=\nhave h0 : \u2200 j : fin (inp.trace_length / 2 - 1), \u2191j * 2 % 2 = 0, by intro j; simp,\nhave h1 : \u2200 j : fin (inp.trace_length / 2 - 1), \u00ac (\u2191j * 2 = 2 * (inp.trace_length / 2 - 1)),\n  begin\n    rintros \u27e8j, jlt\u27e9,\n    have hj : j \u2260 inp.trace_length / 2 - 1 := ne_of_lt jlt,\n    rwa [mul_comm, mul_right_inj' _], norm_num\n  end,\n{ a'    := (\u03bb j, c.column20 (2 * j)),\n  v'    := (\u03bb j, c.column20 (2 * j + 1)),\n  p     := (\u03bb 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 [\u2190m.diff_is_bit (\u2191j * 2) \u27e8h0 j, h1 j\u27e9, 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, \u2190m.is_func (\u2191j * 2) \u27e8h0 j, h1 j\u27e9],\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 [\u2190sub_eq_zero, \u2190m.multi_column_perm__perm__init0 _ rfl],\n      simp [column.off], ring\n    end,\n  h_cumulative :=\n    begin\n      intro j,\n      rw [\u2190sub_eq_zero, \u2190m.multi_column_perm__perm__step0 (\u2191j * 2) \u27e8h0 j, h1 j\u27e9],\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 [\u2190eq_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) \u2192 fin 8 \u2192 fin (inp.trace_length / 16) :=\n\u03bb i j, \u27e8i * 8 + j,\n  begin\n    cases i with i hi,\n    cases j with j hj,\n    calc\n      \u2191i * 8 + \u2191j < (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      ... \u2264 inp.trace_length / 16 :\n        by { apply nat.div_le_div_right, rw mul_assoc, norm_num,\n              rw \u2190 nat.le_div_iff_mul_le, exact nat.succ_le_of_lt hi, norm_num }\n  end\u27e9\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    (\u03bb j, c.rc_builtin__inner_rc (j * 16))\n    (\u03bb j, c.rc_builtin__mem__addr (j * 128))\n    (\u03bb j, c.rc_builtin__mem__value (j * 128))\n    rc_to_rc16 :=\n{ h_rc_init_addr := \u03bb 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, \u2190eq_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 \u2264 inp.trace_length) :\n  4 * fintype.card { x // option.is_some (inp.m_star x) } \u2264 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, \u2190mul_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 \u2264 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  \u27e84 * 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))\u27e9\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 \u2264 inp.trace_length) :\n  memory_embedding_constraints\n    (inp.trace_length / 16 - 1)                               -- T\n    (inp.trace_length / 128)                                  -- rc_len\n    (\u03bb j, c.cpu__decode__pc (j * 16))                         -- pc\n    (\u03bb j, c.cpu__decode__instruction (j * 16))                -- inst\n    (\u03bb j, c.cpu__operands__mem_dst__addr (j * 16))            -- dst_addr\n    (\u03bb j, c.cpu__operands__mem_dst__value (j * 16))           -- dst\n    (\u03bb j, c.cpu__operands__mem_op0__addr (j * 16))            -- op0_addr\n    (\u03bb j, c.cpu__operands__mem_op0__value (j * 16))           -- op0\n    (\u03bb j, c.cpu__operands__mem_op1__addr (j * 16))            -- op1_addr\n    (\u03bb j, c.cpu__operands__mem_op1__value (j * 16))           -- op1\n    (\u03bb j, c.rc_builtin__mem__addr (j * 128))                  -- rc_addr\n    (\u03bb j, c.rc_builtin__mem__value (j * 128))                 -- rc\n    inp.m_star                                                -- mem_star\n    (inp.trace_length / 2 - 1)                                -- n\n    (\u03bb i, c.mem_pool__addr (2 * i))                           -- a\n    (\u03bb i, c.mem_pool__value (2 * i))                          -- v\n    :=\nhave h : \u2200 j : \u2115, \u2200 i : fin (inp.trace_length / 16 - 1), j < 8 \u2192\n    (\u2191i * 8 + j) < inp.trace_length / 2 - 1 + 1,\n  begin\n    rintros j \u27e8i, ilt\u27e9 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 [\u2190nat.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 : \u2200 i : fin (inp.trace_length / 128),\n    (\u2191i * 64 + 51) < inp.trace_length / 2 - 1 + 1,\n  begin\n    rintros \u27e8i, ilt\u27e9,\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 : \u2200 j : fin (inp.trace_length / 16 - 1), (j : \u2115) * 8 = 4 * (2 * j),\n  by { intro j, rw [\u2190mul_assoc, mul_comm (4 * 2)], refl },\n{ embed_inst := \u03bb i, \u27e8\u2191i * 8 + 0, h 0 i (by norm_num)\u27e9,\n  embed_dst  := \u03bb i, \u27e8\u2191i * 8 + 4, h 4 i (by norm_num)\u27e9,\n  embed_op0  := \u03bb i, \u27e8\u2191i * 8 + 2, h 2 i (by norm_num)\u27e9,\n  embed_op1  := \u03bb i, \u27e8\u2191i * 8 + 6, h 6 i (by norm_num)\u27e9,\n  embed_rc   := \u03bb i, \u27e8\u2191i * 64 + 51, h1 i\u27e9,\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 [\u2190mul_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 [\u2190mul_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 \u2260 0, by norm_num), \u2190fin.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 (\u03bb 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 (\u03bb 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 (\u03bb 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 (\u03bb 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 (\u03bb 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', \u2190mul_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 \u2264 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 * \u220f 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 \u2264 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 \u2264 pd.rc_max)\n    (trace_length_le_char : inp.trace_length \u2264 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 := \u03bb j, c.cpu__registers__fp (j * 16),\n  ap := \u03bb j, c.cpu__registers__ap (j * 16),\n  pc := \u03bb j, c.cpu__decode__pc (j * 16),\n  inst := \u03bb j, c.cpu__decode__instruction (j * 16),\n  off_op0_tilde := \u03bb j, c.cpu__decode__off1 (j * 16),\n  off_op1_tilde := \u03bb j, c.cpu__decode__off2 (j * 16),\n  off_dst_tilde := \u03bb j, c.cpu__decode__off0 (j * 16),\n  rc16_val      := \u03bb j, c.rc_builtin__inner_rc (j * 16),\n  f_tilde := \u03bb j k, c.cpu__decode__opcode_rc__column (j * 16 + k),\n  dst_addr := \u03bb j, c.cpu__operands__mem_dst__addr (j * 16),\n  dst := \u03bb j, c.cpu__operands__mem_dst__value (j * 16),\n  op0_addr := \u03bb j, c.cpu__operands__mem_op0__addr (j * 16),\n  op0 := \u03bb j, c.cpu__operands__mem_op0__value (j * 16),\n  op1_addr := \u03bb j, c.cpu__operands__mem_op1__addr (j * 16),\n  op1 := \u03bb j, c.cpu__operands__mem_op1__value (j * 16),\n  rc_addr := \u03bbj, c.rc_builtin__mem__addr (j * 128),\n  rc_val := \u03bbj, 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 := \u03bb i, c.mem_pool__addr (2 * i),\n          v := \u03bb 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 := \u03bb i, cd.to_instruction_constraints i,\n  sc := \u03bb 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 \u2264 inp.trace_length)\n    (c19 c20 : column F) : finset F :=\nbad_set_1\n  (real_a inp.m_star (\u03bb i, c19 (2 * i))     (embed_mem h_card))\n  (real_v inp.m_star (\u03bb i, c19 (2 * i + 1)) (embed_mem h_card))\n  (\u03bb j, c20 (2 * \u2191j))\n  (\u03bb j, c20 (2 * \u2191j + 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 \u2264 inp.trace_length)\n    (c19 c20 : column F) : finset F :=\nbad_set_2\n  (real_a inp.m_star (\u03bb i, c19 (2 * i))     (embed_mem h_card))\n  (real_v inp.m_star (\u03bb i, c19 (2 * i + 1)) (embed_mem h_card))\n  (\u03bb j, c20 (2 * \u2191j))\n  (\u03bb j, c20 (2 * \u2191j + 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  (\u03bb (i : fin (inp.trace_length - 1 + 1)), c0 i)\n  (\u03bb (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 \u2264 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 \u2264 inp.trace_length)\n    (c19 c20 : column F) :\n  (bad1 h_card c19 c20).card \u2264 (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 \u2264 inp.trace_length)\n    (c19 c20 : column F) :\n  (bad2 pd h_card c19 c20).card \u2264 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 \u2264 inp.trace_length)\n    (c0 c2 : column F) :\n  (bad3 inp c0 c2).card \u2264 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 \u2192 Type v) [functor f] [LawfulFunctor f] :\n  \u03b1 \u2243 \u03b2 \u2192 f \u03b1 \u2243 f \u03b2\n```\n\n-/\n\nopen Equiv\n\nnamespace Functor\n\nvariable (f : Type u \u2192 Type v) [Functor f] [LawfulFunctor f]\n\n/-- Apply a functor to an `Equiv`. -/\ndef map_equiv (h : \u03b1 \u2243 \u03b2) : f \u03b1 \u2243 f \u03b2 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 : \u03b1 \u2243 \u03b2) (x : f \u03b1) :\n  (map_equiv f h : f \u03b1 \u2243 f \u03b2) x = map h x := rfl\n\n@[simp]\nlemma map_equiv_symm_apply (h : \u03b1 \u2243 \u03b2) (y : f \u03b2) :\n  (map_equiv f h : f \u03b1 \u2243 f \u03b2).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 ` \u2218 `:80 g:80 := g \u226b 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 := \u27e8initial\u27e9\n\ndef initial.induced (a : C) : \u2205 \u27f6 a :=\nhas_initial_object.initial_object.is_initial_object.induced\n\nnotation `!` a := initial.induced a\n\ndef initial.uniqueness {a : C} (k k' : \u2205 \u27f6 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 \u2205.\ninstance initial_hom.subsingleton (a : C) : subsingleton (\u2205 \u27f6 a) := \u27e8initial.uniqueness\u27e9\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\u2080 a\u2081 : C) :=\n(has_coproducts.coproduct.{v} a\u2080 a\u2081).ob\n\ninfix ` \u2294 ` := coprod\n\n-- The \"left\" inclusion.\ndef i\u2080 {a\u2080 a\u2081 : C} : a\u2080 \u27f6 a\u2080 \u2294 a\u2081 :=\n(has_coproducts.coproduct.{v} a\u2080 a\u2081).map\u2080\n\n-- The \"right\" inclusion.\ndef i\u2081 {a\u2080 a\u2081 : C} : a\u2081 \u27f6 a\u2080 \u2294 a\u2081 :=\n(has_coproducts.coproduct.{v} a\u2080 a\u2081).map\u2081\n\n-- The map out of a coproduct induced by a map on each summand.\ndef coprod.induced {a\u2080 a\u2081 b : C} (f\u2080 : a\u2080 \u27f6 b) (f\u2081 : a\u2081 \u27f6 b) : a\u2080 \u2294 a\u2081 \u27f6 b :=\n(has_coproducts.coproduct.{v} a\u2080 a\u2081).is_coproduct.induced f\u2080 f\u2081\n\ndef coprod.induced_Is_equiv {a\u2080 a\u2081 b : C} :\n  Is_equiv (\u03bb p : (a\u2080 \u27f6 b) \u00d7 (a\u2081 \u27f6 b), coprod.induced p.1 p.2) :=\n{ e := ((has_coproducts.coproduct a\u2080 a\u2081).is_coproduct.universal b).e.symm,\n  h := by funext p; cases p; refl }\n\n@[simp] lemma coprod.induced_commutes\u2080 {a\u2080 a\u2081 b : C} (f\u2080 : a\u2080 \u27f6 b) (f\u2081 : a\u2081 \u27f6 b) :\n  coprod.induced f\u2080 f\u2081 \u2218 i\u2080 = f\u2080 :=\n(has_coproducts.coproduct.{v} a\u2080 a\u2081).is_coproduct.induced_commutes\u2080 f\u2080 f\u2081\n\n@[simp] lemma coprod.induced_commutes\u2081 {a\u2080 a\u2081 b : C} (f\u2080 : a\u2080 \u27f6 b) (f\u2081 : a\u2081 \u27f6 b) :\n  coprod.induced f\u2080 f\u2081 \u2218 i\u2081 = f\u2081 :=\n(has_coproducts.coproduct.{v} a\u2080 a\u2081).is_coproduct.induced_commutes\u2081 f\u2080 f\u2081\n\ndef coprod.fold (a : C) : a \u2294 a \u27f6 a :=\ncoprod.induced (\ud835\udfd9 a) (\ud835\udfd9 a)\n\n@[simp] lemma coprod.fold_i\u2080 {a : C} : coprod.fold a \u2218 i\u2080 = \ud835\udfd9 a :=\ncoprod.induced_commutes\u2080 _ _\n\n@[simp] lemma coprod.fold_i\u2081 {a : C} : coprod.fold a \u2218 i\u2081 = \ud835\udfd9 a :=\ncoprod.induced_commutes\u2081 _ _\n\n-- This is a kind of \"co-extensionality\" lemma; does that count?\n@[ext] lemma coprod.uniqueness {a\u2080 a\u2081 b : C} {k k' : a\u2080 \u2294 a\u2081 \u27f6 b}\n  (e\u2080 : k \u2218 i\u2080 = k' \u2218 i\u2080) (e\u2081 : k \u2218 i\u2081 = k' \u2218 i\u2081) : k = k' :=\n(has_coproducts.coproduct.{v} a\u2080 a\u2081).is_coproduct.uniqueness e\u2080 e\u2081\n\nlemma coprod.ext {a\u2080 a\u2081 b : C} {k k' : a\u2080 \u2294 a\u2081 \u27f6 b} :\n  k = k' \u2194 k \u2218 i\u2080 = k' \u2218 i\u2080 \u2227 k \u2218 i\u2081 = k' \u2218 i\u2081 :=\niff.intro (assume h, by rw h; simp) (assume \u27e8h\u2080, h\u2081\u27e9, coprod.uniqueness h\u2080 h\u2081)\n\n-- Similarly, this is a \"co-eta reduction\".\n@[simp] lemma coprod.eta {a\u2080 a\u2081 b : C} {k : a\u2080 \u2294 a\u2081 \u27f6 b} :\n  coprod.induced (k \u2218 i\u2080) (k \u2218 i\u2081) = k :=\ncoprod.uniqueness (by simp) (by simp)\n\ndef coprod_of_maps {a\u2080 a\u2081 b\u2080 b\u2081 : C} (f\u2080 : a\u2080 \u27f6 b\u2080) (f\u2081 : a\u2081 \u27f6 b\u2081) : a\u2080 \u2294 a\u2081 \u27f6 b\u2080 \u2294 b\u2081 :=\ncoprod.induced (i\u2080 \u2218 f\u2080) (i\u2081 \u2218 f\u2081)\n\n@[simp] lemma coprod_of_maps_commutes\u2080 {a\u2080 a\u2081 b\u2080 b\u2081 : C} {f\u2080 : a\u2080 \u27f6 b\u2080} {f\u2081 : a\u2081 \u27f6 b\u2081} :\n  coprod_of_maps f\u2080 f\u2081 \u2218 i\u2080 = i\u2080 \u2218 f\u2080 :=\ncoprod.induced_commutes\u2080 _ _\n\n@[simp] lemma coprod_of_maps_commutes\u2081 {a\u2080 a\u2081 b\u2080 b\u2081 : C} {f\u2080 : a\u2080 \u27f6 b\u2080} {f\u2081 : a\u2081 \u27f6 b\u2081} :\n  coprod_of_maps f\u2080 f\u2081 \u2218 i\u2081 = i\u2081 \u2218 f\u2081 :=\ncoprod.induced_commutes\u2081 _ _\n\ndef isomorphic_coprod_of_Is_coproduct {a\u2080 a\u2081 b : C} {f\u2080 : a\u2080 \u27f6 b} {f\u2081 : a\u2081 \u27f6 b}\n  (h : Is_coproduct f\u2080 f\u2081) : iso (a\u2080 \u2294 a\u2081) b :=\n{ hom := coprod.induced f\u2080 f\u2081,\n  inv := h.induced i\u2080 i\u2081,\n  hom_inv_id' := by apply coprod.uniqueness; { rw \u2190assoc, simp },\n  inv_hom_id' := by apply h.uniqueness; { rw \u2190assoc, simp } }\n\ndef coprod_of_isomorphisms {a\u2080 a\u2081 b\u2080 b\u2081 : C} (j\u2080 : iso a\u2080 b\u2080) (j\u2081 : iso a\u2081 b\u2081) :\n  iso (a\u2080 \u2294 a\u2081) (b\u2080 \u2294 b\u2081) :=\n{ hom := coprod_of_maps j\u2080.hom j\u2081.hom,\n  inv := coprod_of_maps j\u2080.inv j\u2081.inv,\n  hom_inv_id' := by apply coprod.uniqueness; rw \u2190assoc; simp,\n  inv_hom_id' := by apply coprod.uniqueness; rw \u2190assoc; simp }\n\nvariables [has_initial_object.{v} C]\n\ndef coprod_initial_right (a : C) : a \u2245 a \u2294 \u2205 :=\n{ hom := i\u2080,\n  inv := coprod.induced (\ud835\udfd9 a) (! a),\n  hom_inv_id' := by simp,\n  inv_hom_id' :=\n    by apply coprod.uniqueness; try { apply initial.uniqueness };\n       rw \u2190assoc; simp }\n\n@[simp] lemma coprod_initial_right_hom {a : C} : (coprod_initial_right a).hom = i\u2080 :=\nrfl\n\ndef coprod_initial_left (a : C) : a \u2245 \u2205 \u2294 a :=\n{ hom := i\u2081,\n  inv := coprod.induced (! a) (\ud835\udfd9 a),\n  hom_inv_id' := by simp,\n  inv_hom_id' :=\n    by apply coprod.uniqueness; try { apply initial.uniqueness };\n       rw \u2190assoc; simp }\n\n@[simp] lemma coprod_initial_left_hom {a : C} : (coprod_initial_left a).hom = i\u2081 :=\nrfl\n\nend coproduct\n\n\nsection pushout_induced_eq\nparameters {C : Type u} [category.{v} C]\nparameters {a b\u2080 b\u2081 c c' : C} {f\u2080 : a \u27f6 b\u2080} {f\u2081 : a \u27f6 b\u2081}\nparameters {g\u2080 : b\u2080 \u27f6 c} {g\u2081 : b\u2081 \u27f6 c} (po : Is_pushout f\u2080 f\u2081 g\u2080 g\u2081)\n\nlemma pushout_induced_eq_iff {x : C} {h\u2080 : b\u2080 \u27f6 x} {h\u2081 : b\u2081 \u27f6 x} {k : c \u27f6 x} {e}\n  (H\u2080 : h\u2080 = g\u2080 \u226b k) (H\u2081 : h\u2081 = g\u2081 \u226b k) : po.induced h\u2080 h\u2081 e = k :=\nby apply po.uniqueness; simp [H\u2080, H\u2081]\n\nend pushout_induced_eq\n\n\nsection pushout_induced_comp\nparameters {C : Type u} [category.{v} C]\nparameters {a b\u2080 b\u2081 c c' : C} {f\u2080 : a \u27f6 b\u2080} {f\u2081 : a \u27f6 b\u2081}\nparameters {g\u2080 : b\u2080 \u27f6 c} {g\u2081 : b\u2081 \u27f6 c} (po : Is_pushout f\u2080 f\u2081 g\u2080 g\u2081)\n\nlemma pushout_induced_comp {x y : C} {h\u2080 : b\u2080 \u27f6 x} {h\u2081 : b\u2081 \u27f6 x} {k : x \u27f6 y} {e} :\n  k \u2218 po.induced h\u2080 h\u2081 e = po.induced (k \u2218 h\u2080) (k \u2218 h\u2081)\n    (by rw [\u2190assoc, \u2190assoc, e]) :=\nby apply po.uniqueness; rw \u2190assoc; 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\u2080 b\u2081 b c : C} {f\u2080 : a \u27f6 b\u2080} {f\u2081 : a \u27f6 b\u2081} {g\u2080 : b\u2080 \u27f6 c} {g\u2081 : b\u2081 \u27f6 c}\n\ndef Is_pushout_of_Is_coequalizer\n  (H : Is_coequalizer (i\u2080 \u2218 f\u2080) (i\u2081 \u2218 f\u2081) (coprod.induced g\u2080 g\u2081)) :\n  Is_pushout f\u2080 f\u2081 g\u2080 g\u2081 :=\nIs_pushout.mk'\n  (begin convert H.commutes using 1; rw assoc; simp end)\n  (\u03bb x h\u2080 h\u2081 e, H.induced (coprod.induced h\u2080 h\u2081)\n    (begin rw [assoc, assoc], simpa using e end))\n  (assume x h\u2080 h\u2081 e,\n    -- Weird trick to avoid repeating the proof argument\n    (\u03bb p, let K := H.induced (coprod.induced h\u2080 h\u2081) p in calc\n      K \u2218 g\u2080 = K \u2218 (coprod.induced g\u2080 g\u2081 \u2218 i\u2080)  : by simp\n      ...    = (K \u2218 coprod.induced g\u2080 g\u2081) \u2218 i\u2080  : by rw assoc\n      ...    = h\u2080 : by simp) _)\n  (assume x h\u2080 h\u2081 e,\n    (\u03bb p, let K := H.induced (coprod.induced h\u2080 h\u2081) p in calc\n      K \u2218 g\u2081 = K \u2218 (coprod.induced g\u2080 g\u2081 \u2218 i\u2081)  : by simp\n      ...    = (K \u2218 coprod.induced g\u2080 g\u2081) \u2218 i\u2081  : by rw assoc\n      ...    = h\u2081 : by simp) _)\n  (assume x k k' e\u2080 e\u2081, H.uniqueness $ coprod.uniqueness\n    (by rw [\u2190assoc, \u2190assoc]; simpa using e\u2080)\n    (by rw [\u2190assoc, \u2190assoc]; simpa using e\u2081))\n\ndef pushout_of_coequalizer (E : coequalizer (i\u2080 \u2218 f\u2080) (i\u2081 \u2218 f\u2081)) : pushout f\u2080 f\u2081 :=\n{ ob := E.ob,\n  map\u2080 := E.map \u2218 i\u2080,\n  map\u2081 := E.map \u2218 i\u2081,\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 := \u03bb a b\u2080 b\u2081 f\u2080 f\u2081,\n    pushout_of_coequalizer $ has_coequalizers.coequalizer (i\u2080 \u2218 f\u2080) (i\u2081 \u2218 f\u2081) }\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\u2080 b\u2081 c c' : C} {f\u2080 : a \u27f6 b\u2080} {f\u2081 : a \u27f6 b\u2081}\nparameters {g\u2080 : b\u2080 \u27f6 c} {g\u2081 : b\u2081 \u27f6 c} (po : Is_pushout f\u2080 f\u2081 g\u2080 g\u2081)\nparameters {g'\u2080 : b\u2080 \u27f6 c'} {g'\u2081 : b\u2081 \u27f6 c'} (po' : Is_pushout f\u2080 f\u2081 g'\u2080 g'\u2081)\n\n@[reducible] private def h : c \u27f6 c' := po.induced g'\u2080 g'\u2081 po'.commutes\n@[reducible] private def h' : c' \u27f6 c := po'.induced g\u2080 g\u2081 po.commutes\n\ndef pushout.unique : iso c c' :=\n{ hom := h,\n  inv := h',\n  hom_inv_id' := by apply po.uniqueness; {rw \u2190category.assoc, simp},\n  inv_hom_id' := by apply po'.uniqueness; {rw \u2190category.assoc, simp} }\n\n@[simp] lemma pushout.unique_commutes\u2080 : pushout.unique.hom \u2218 g\u2080 = g'\u2080 :=\nby apply po.induced_commutes\u2080\n\n@[simp] lemma pushout.unique_commutes\u2081 : pushout.unique.hom \u2218 g\u2081 = g'\u2081 :=\nby apply po.induced_commutes\u2081\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 \u27f6 b)\n\ndef Is_pushout.refl : Is_pushout f (\ud835\udfd9 a) (\ud835\udfd9 b) f :=\nIs_pushout.mk $ \u03bb x,\n  Bij_on.mk\n    { to_fun := \u03bb h, \u27e8(h \u2218 \ud835\udfd9 b, h \u2218 f), by simp\u27e9,\n      inv_fun := \u03bb p, \u27e8p.val.1, trivial\u27e9,\n      left_inv := assume h, by simp,\n      right_inv := assume \u27e8\u27e8pv1, pv2\u27e9, pp\u27e9, 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 (\u03bb (k : a \u27f6 x), (k \u2218 i.hom : a' \u27f6 x)) univ univ :=\nBij_on.of_equiv $ show (a \u27f6 x) \u2243 (a' \u27f6 x), from\n{ to_fun := \u03bb k, k \u2218 i.hom,\n  inv_fun := \u03bb k', k' \u2218 i.inv,\n  left_inv := \u03bb k, by simp,\n  right_inv := \u03bb k', by simp }\n\nparameters {a b\u2080 b\u2081 c : C} {f\u2080 : a \u27f6 b\u2080} {f\u2081 : a \u27f6 b\u2081}\nparameters {g\u2080 : b\u2080 \u27f6 c} {g\u2081 : b\u2081 \u27f6 c} (po : Is_pushout f\u2080 f\u2081 g\u2080 g\u2081)\nparameters {a' b'\u2080 b'\u2081 : C} (f'\u2080 : a' \u27f6 b'\u2080) (f'\u2081 : a' \u27f6 b'\u2081)\nparameters (i : iso a' a) (j\u2080 : iso b'\u2080 b\u2080) (j\u2081 : iso b'\u2081 b\u2081)\nparameters (e\u2080 : f\u2080 \u2218 i.hom = j\u2080.hom \u2218 f'\u2080) (e\u2081 : f\u2081 \u2218 i.hom = j\u2081.hom \u2218 f'\u2081)\n\ninclude e\u2080 e\u2081\ndef Is_pushout_of_isomorphic : Is_pushout f'\u2080 f'\u2081 (g\u2080 \u2218 j\u2080.hom) (g\u2081 \u2218 j\u2081.hom) :=\nIs_pushout.mk $ \u03bb x,\n  have _ := calc\n  univ ~~ {p : (b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x) | p.1 \u2218 f\u2080 = p.2 \u2218 f\u2081}\n       : po.universal x\n  ...  ~~ {p : (b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x) | (p.1 \u2218 j\u2080.hom) \u2218 f'\u2080 = (p.2 \u2218 j\u2081.hom) \u2218 f'\u2081}\n       : begin\n           convert Bij_on.refl _, funext p, apply propext,\n           rw [\u2190assoc, \u2190assoc, \u2190e\u2080, \u2190e\u2081], simp [cancel_epi],\n         end\n  ...  ~~ {p : (b'\u2080 \u27f6 x) \u00d7 (b'\u2081 \u27f6 x) | p.1 \u2218 f'\u2080 = p.2 \u2218 f'\u2081}\n       : Bij_on.restrict''\n           (Bij_on.prod' (precomposition_bij j\u2080) (precomposition_bij j\u2081))\n           {p | p.1 \u2218 f'\u2080 = p.2 \u2218 f'\u2081},\n  by convert this; funext; simp\nomit e\u2080 e\u2081\n\nparameters {c' : C} (k : iso c c')\n\ndef Is_pushout_of_isomorphic' : Is_pushout f\u2080 f\u2081 (k.hom \u2218 g\u2080) (k.hom \u2218 g\u2081) :=\nIs_pushout.mk $ \u03bb x,\n  have _ := calc\n  univ ~~ univ\n       : precomposition_bij k\n  ...  ~~ {p : (b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x) | p.1 \u2218 f\u2080 = p.2 \u2218 f\u2081 }\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\u2080 b\u2081 c : C} {f\u2080 : a \u27f6 b\u2080} {f\u2081 : a \u27f6 b\u2081}\nparameters {g\u2080 : b\u2080 \u27f6 c} {g\u2081 : b\u2081 \u27f6 c} (po : Is_pushout f\u2080 f\u2081 g\u2080 g\u2081)\n\ndef Is_pushout.transpose : Is_pushout f\u2081 f\u2080 g\u2081 g\u2080 :=\nIs_pushout.mk $ \u03bb x, calc\n  univ ~~ {p : (b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x) | p.1 \u2218 f\u2080 = p.2 \u2218 f\u2081}\n       : po.universal x\n  ...  ~~ {p : (b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x) | p.2 \u2218 f\u2081 = p.1 \u2218 f\u2080}\n       : begin convert Bij_on.refl _; ext p; split; exact eq.symm, end\n  ...  ~~ {p' : (b\u2081 \u27f6 x) \u00d7 (b\u2080 \u27f6 x) | p'.1 \u2218 f\u2081 = p'.2 \u2218 f\u2080}\n       : Bij_on.restrict_equiv (equiv.prod_comm _ _)\n           {p' | p'.1 \u2218 f\u2081 = p'.2 \u2218 f\u2080}\n\nparameters {c' : C} {g\u2080' : b\u2080 \u27f6 c'} {g\u2081' : b\u2081 \u27f6 c'}\nparameters (po' : Is_pushout f\u2081 f\u2080 g\u2081' g\u2080')\ndef Is_pushout.iso_transpose : c \u2245 c' :=\npushout.unique po.transpose po'\n\n@[simp] lemma Is_pushout.iso_transpose_map\u2080 : g\u2080 \u226b (po.iso_transpose po').hom = g\u2080' :=\nby apply pushout.unique_commutes\u2081\n\n@[simp] lemma Is_pushout.iso_transpose_map\u2081 : g\u2081 \u226b (po.iso_transpose po').hom = g\u2081' :=\nby apply pushout.unique_commutes\u2080\n\nlemma Is_pushout.transpose_induced {x : C} {h\u2080 : b\u2080 \u27f6 x} {h\u2081 : b\u2081 \u27f6 x} {e : f\u2080 \u226b h\u2080 = f\u2081 \u226b h\u2081} :\n  (po.iso_transpose po').hom \u226b po'.induced h\u2081 h\u2080 e.symm = po.induced h\u2080 h\u2081 e :=\nbegin\n  symmetry,\n  apply pushout_induced_eq_iff; rw \u2190assoc; simp\nend\n\nend pushout_tranpose\n\nsection pushout_initial\nparameters {C : Type u} [category.{v} C]\nparameters {a b\u2080 b\u2081 c : C} {f\u2080 : a \u27f6 b\u2080} {f\u2081 : a \u27f6 b\u2081}\nparameters {g\u2080 : b\u2080 \u27f6 c} {g\u2081 : b\u2081 \u27f6 c}\n\n-- TODO: Somehow prove these two simultaneously?\ndef Is_pushout_of_Is_coproduct_of_Is_initial (copr : Is_coproduct g\u2080 g\u2081)\n  (h : Is_initial_object.{v} a) : Is_pushout f\u2080 f\u2081 g\u2080 g\u2081 :=\nIs_pushout.mk $ \u03bb x, calc\n  univ ~~ {p : (b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x) | true}\n       : Bij_on.of_Is_equiv (copr.universal x)\n  ...  ~~ {p : (b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x) | p.1 \u2218 f\u2080 = p.2 \u2218 f\u2081}\n       : by convert Bij_on.refl _; ext p; change (_ = _) \u2194 true;\n            simp; apply h.uniqueness\n\ndef Is_coproduct_of_Is_pushout_of_Is_initial (po : Is_pushout f\u2080 f\u2081 g\u2080 g\u2081)\n  (h : Is_initial_object.{v} a) : Is_coproduct g\u2080 g\u2081 :=\nhave _ := \u03bb x, calc\n  univ ~~ {p : (b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x) | p.1 \u2218 f\u2080 = p.2 \u2218 f\u2081}\n       : po.universal x\n  ...  ~~ (univ : set ((b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x)))\n       : begin\n           convert Bij_on.refl _, symmetry, rw \u2190univ_subset_iff,\n           intros p _, apply h.uniqueness\n         end,\nIs_coproduct.mk $ \u03bb 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\u2080 b\u2081 c : C} {f\u2080 : a \u27f6 b\u2080} {f\u2081 : a \u27f6 b\u2081}\nparameters {g\u2080 : b\u2080 \u27f6 c} {g\u2081 : b\u2081 \u27f6 c} (po : Is_pushout f\u2080 f\u2081 g\u2080 g\u2081)\nparameters {a' b\u2080' b\u2081' c' : C} {f\u2080' : a' \u27f6 b\u2080'} {f\u2081' : a' \u27f6 b\u2081'}\nparameters {g\u2080' : b\u2080' \u27f6 c'} {g\u2081' : b\u2081' \u27f6 c'} (po' : Is_pushout f\u2080' f\u2081' g\u2080' g\u2081')\ninclude po po'\n\ndef Is_pushout_coprod :\n  Is_pushout\n    (coprod_of_maps f\u2080 f\u2080') (coprod_of_maps f\u2081 f\u2081')\n    (coprod_of_maps g\u2080 g\u2080') (coprod_of_maps g\u2081 g\u2081') :=\nIs_pushout.mk $ \u03bb x,\n  have _ := calc\n  univ ~~ (univ : set ((c \u27f6 x) \u00d7 (c' \u27f6 x)))\n       : Bij_on.of_Is_equiv ((has_coproducts.coproduct c c').is_coproduct.universal x)\n  ...  ~~ {pp : ((b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x)) \u00d7 ((b\u2080' \u27f6 x) \u00d7 (b\u2081' \u27f6 x))\n          | pp.1.1 \u2218 f\u2080 = pp.1.2 \u2218 f\u2081 \u2227 pp.2.1 \u2218 f\u2080' = pp.2.2 \u2218 f\u2081'}\n       :\n  begin\n    convert Bij_on.prod (po.universal x) (po'.universal x),\n    ext p, simp\n  end\n  ...  ~~ {qq : ((b\u2080 \u27f6 x) \u00d7 (b\u2080' \u27f6 x)) \u00d7 ((b\u2081 \u27f6 x) \u00d7 (b\u2081' \u27f6 x))\n          | qq.1.1 \u2218 f\u2080 = qq.2.1 \u2218 f\u2081 \u2227 qq.1.2 \u2218 f\u2080' = qq.2.2 \u2218 f\u2081'}\n       : Bij_on.restrict_equiv\n           { to_fun := \u03bb (pp : ((b\u2080 \u27f6 x) \u00d7 (b\u2081 \u27f6 x)) \u00d7 ((b\u2080' \u27f6 x) \u00d7 (b\u2081' \u27f6 x))), ((pp.1.1, pp.2.1), (pp.1.2, pp.2.2)),\n             inv_fun := \u03bb qq, \u27e8\u27e8qq.1.1, qq.2.1\u27e9, \u27e8qq.1.2, qq.2.2\u27e9\u27e9,\n             left_inv := assume \u27e8\u27e8_,_\u27e9,\u27e8_,_\u27e9\u27e9, rfl,\n             right_inv := assume \u27e8\u27e8_,_\u27e9,\u27e8_,_\u27e9\u27e9, rfl }\n           {qq : ((b\u2080 \u27f6 x) \u00d7 (b\u2080' \u27f6 x)) \u00d7 ((b\u2081 \u27f6 x) \u00d7 (b\u2081' \u27f6 x))\n          | qq.1.1 \u2218 f\u2080 = qq.2.1 \u2218 f\u2081 \u2227 qq.1.2 \u2218 f\u2080' = qq.2.2 \u2218 f\u2081'}\n  ...  ~~ {qq : ((b\u2080 \u27f6 x) \u00d7 (b\u2080' \u27f6 x)) \u00d7 ((b\u2081 \u27f6 x) \u00d7 (b\u2081' \u27f6 x))\n          | coprod.induced qq.1.1 qq.1.2 \u2218 coprod_of_maps f\u2080 f\u2080' =\n            coprod.induced qq.2.1 qq.2.2 \u2218 coprod_of_maps f\u2081 f\u2081' }\n       :\n  begin\n    convert Bij_on.refl _,\n    ext qq, change _ = _ \u2194 _ = _ \u2227 _ = _,\n    rw [coprod.ext, \u2190assoc, \u2190assoc, \u2190assoc, \u2190assoc],\n    simp\n  end\n  ...  ~~ {qq : (b\u2080 \u2294 b\u2080' \u27f6 x) \u00d7 (b\u2081 \u2294 b\u2081' \u27f6 x)\n          | qq.1 \u2218 coprod_of_maps f\u2080 f\u2080' = qq.2 \u2218 coprod_of_maps f\u2081 f\u2081'}\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\u2080 \u2294 b\u2080' \u27f6 x) \u00d7 (b\u2081 \u2294 b\u2081' \u27f6 x)\n           | qq.1 \u2218 coprod_of_maps f\u2080 f\u2080' = qq.2 \u2218 coprod_of_maps f\u2081 f\u2081'},\n  begin\n    convert this,\n    funext k, apply prod.ext; apply coprod.uniqueness;\n    { change _ \u2218 _ \u2218 _ = _ \u2218 _, simp [coproduct_comparison],\n      rw \u2190assoc, 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 \u27f6 b)\n\n/-\n  a \u2192 a \u2294 c\n  \u2193     \u2193\n  b \u2192 b \u2294 c\n-/\n\ndef Is_pushout_i\u2080 : Is_pushout f i\u2080 i\u2080 (coprod_of_maps f (\ud835\udfd9 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\u2080\n     (coprod_initial_right a) (coprod_initial_right b) (iso.refl _) _ _; simp\n\n/-\n  a \u2192 c \u2294 a\n  \u2193     \u2193\n  b \u2192 c \u2294 b\n-/\n\ndef Is_pushout_i\u2081 : Is_pushout f i\u2081 i\u2081 (coprod_of_maps (\ud835\udfd9 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\u2081\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 \u27f6 b} {g\u2080 g\u2081 : b \u27f6 c} (po : Is_pushout f f g\u2080 g\u2081)\n\ndef Is_pushout.swap : c \u27f6 c := po.induced g\u2081 g\u2080 po.commutes.symm\n\ndef Is_pushout.swap_iso : c \u2245 c :=\n{ hom := po.swap,\n  inv := po.swap,\n  hom_inv_id' := by apply po.uniqueness; unfold Is_pushout.swap; rw \u2190assoc; simp,\n  inv_hom_id' := by apply po.uniqueness; unfold Is_pushout.swap; rw \u2190assoc; simp }\n\n@[simp] def Is_pushout.induced_swap {x} {h\u2080 h\u2081 : b \u27f6 x} {p p'} :\n  po.induced h\u2080 h\u2081 p \u2218 po.swap = po.induced h\u2081 h\u2080 p' :=\nby apply po.uniqueness; unfold Is_pushout.swap; rw \u2190assoc; simp\n\nend pushout_swap\n\nsection pushout_of_maps\nparameters {C : Type u} [category.{v} C]\nvariables {a b\u2080 b\u2081 c : C} {f\u2080 : a \u27f6 b\u2080} {f\u2081 : a \u27f6 b\u2081}\nvariables {g\u2080 : b\u2080 \u27f6 c} {g\u2081 : b\u2081 \u27f6 c} (po : Is_pushout f\u2080 f\u2081 g\u2080 g\u2081)\nvariables {a' b\u2080' b\u2081' c' : C} {f\u2080' : a' \u27f6 b\u2080'} {f\u2081' : a' \u27f6 b\u2081'}\nvariables {g\u2080' : b\u2080' \u27f6 c'} {g\u2081' : b\u2081' \u27f6 c'} (po' : Is_pushout f\u2080' f\u2081' g\u2080' g\u2081')\nvariables {a'' b\u2080'' b\u2081'' c'' : C} {f\u2080'' : a'' \u27f6 b\u2080''} {f\u2081'' : a'' \u27f6 b\u2081''}\nvariables {g\u2080'' : b\u2080'' \u27f6 c''} {g\u2081'' : b\u2081'' \u27f6 c''} (po'' : Is_pushout f\u2080'' f\u2081'' g\u2080'' g\u2081'')\nvariables (ha : a \u27f6 a') (hb\u2080 : b\u2080 \u27f6 b\u2080') (hb\u2081 : b\u2081 \u27f6 b\u2081')\nvariables (h\u2080 : hb\u2080 \u2218 f\u2080 = f\u2080' \u2218 ha) (h\u2081 : hb\u2081 \u2218 f\u2081 = f\u2081' \u2218 ha)\nvariables (ka : a' \u27f6 a'') (kb\u2080 : b\u2080' \u27f6 b\u2080'') (kb\u2081 : b\u2081' \u27f6 b\u2081'')\nvariables (k\u2080 : kb\u2080 \u2218 f\u2080' = f\u2080'' \u2218 ka) (k\u2081 : kb\u2081 \u2218 f\u2081' = f\u2081'' \u2218 ka)\n\ninclude po po' h\u2080 h\u2081\n\ndef pushout_of_maps : c \u27f6 c' :=\npo.induced (g\u2080' \u2218 hb\u2080) (g\u2081' \u2218 hb\u2081)\n  (by rw [\u2190assoc, \u2190assoc, h\u2080, h\u2081]; simp [po'.commutes])\n\nomit po po' h\u2080 h\u2081\n\nlemma induced_pushout_of_maps {x : C} {k\u2080 : b\u2080' \u27f6 x} {k\u2081 : b\u2081' \u27f6 x} {e} :\n  po'.induced k\u2080 k\u2081 e \u2218 pushout_of_maps po po' ha hb\u2080 hb\u2081 h\u2080 h\u2081 = po.induced (k\u2080 \u2218 hb\u2080) (k\u2081 \u2218 hb\u2081)\n    (by rw [\u2190assoc, \u2190assoc, h\u2080, h\u2081]; simp [e]) :=\nbegin\n  unfold pushout_of_maps,\n  apply po.uniqueness; { rw \u2190assoc, simp }\nend\n\n@[simp] lemma pushout_of_maps_commutes\u2080 : pushout_of_maps po po' ha hb\u2080 hb\u2081 h\u2080 h\u2081 \u2218 g\u2080 = g\u2080' \u2218 hb\u2080 :=\nby simp [pushout_of_maps]\n\n@[simp] lemma pushout_of_maps_commutes\u2081 : pushout_of_maps po po' ha hb\u2080 hb\u2081 h\u2080 h\u2081 \u2218 g\u2081 = g\u2081' \u2218 hb\u2081 :=\nby simp [pushout_of_maps]\n\nlemma pushout_of_maps_id : pushout_of_maps po po (\ud835\udfd9 a) (\ud835\udfd9 b\u2080) (\ud835\udfd9 b\u2081) (by simp) (by simp) = \ud835\udfd9 _ :=\nby apply pushout_induced_eq_iff; simp\n\nlemma pushout_of_maps_comp :\n  pushout_of_maps po po'' (ha \u226b ka) (hb\u2080 \u226b kb\u2080) (hb\u2081 \u226b kb\u2081)\n    (by rw [\u2190assoc, h\u2080, assoc, k\u2080, \u2190assoc]) (by rw [\u2190assoc, h\u2081, assoc, k\u2081, \u2190assoc]) =\n  pushout_of_maps po po' ha hb\u2080 hb\u2081 h\u2080 h\u2081 \u226b pushout_of_maps po' po'' ka kb\u2080 kb\u2081 k\u2080 k\u2081 :=\nby apply pushout_induced_eq_iff; rw \u2190assoc; 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 {\ud835\udc9e : Type u} [category.{v} \ud835\udc9e]\n\n@[protect_proj] class struc (F : \ud835\udc9e \u2192 Type w) :=\n( hom : \u03a0 {A B : \ud835\udc9e} (f : A \u27f6 B) (a : F A) (b : F B), Type x )\n( id : \u03a0 {A : \ud835\udc9e} (a : F A), hom (\ud835\udfd9 A) a a )\n( comp : \u03a0 {A B C : \ud835\udc9e} {a : F A} {b : F B} {c : F C}\n    {f : A \u27f6 B} {g : B \u27f6 C} (f' : hom f a b) (g' : hom g b c) \n    {h : A \u27f6 C} (H : f \u226b g = h), hom h a c )\n( id_comp : \u03a0 {A B : \ud835\udc9e} {f : A \u27f6 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 : \u03a0 {A B : \ud835\udc9e} {f : A \u27f6 B} {a : F A} {b : F B}\n    (f' : hom f a b), comp f' (id b) (category.comp_id f) = f' )\n( assoc : \u03a0 {A B C D : \ud835\udc9e} {f : A \u27f6 B} {g : B \u27f6 C} {h : C \u27f6 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 : \ud835\udc9e \u2192 Type w) :=\n-- ( hom : \u03a0 {A B : \ud835\udc9e} (f : A \u27f6 B) (a : F A) (b : F B), Type x )\n-- ( id : \u03a0 {A : \ud835\udc9e} (a b : F A) (h : a = b) (f : A \u27f6 A) (hf : f = \ud835\udfd9 A), hom f a b )\n\nattribute [simp] struc.id_comp struc.comp_id\n\nnamespace struc\n\nvariables (F : \ud835\udc9e \u2192 Type w) [struc F]\n\nlemma assoc_left {A B C D : \ud835\udc9e} {f : A \u27f6 B} {g : B \u27f6 C} {h : C \u27f6 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 \u27f6 C) (k : A \u27f6 D)\n    (hi : f \u226b g = i) (hk : i \u226b h = k) :\n    struc.comp (struc.comp f' g' hi) h' hk = struc.comp f'\n      (struc.comp g' h' rfl) (by rw [\u2190 hk, \u2190 hi, category.assoc]) :=\nbegin\n  substs i k,\n  rw struc.assoc,\nend\n\nlemma comp_eq_cast {A B C : \ud835\udc9e} {f : A \u27f6 B} {g : B \u27f6 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 \u27f6 C) (hi : f \u226b g = i)\n  (j : A \u27f6 C) (hj : f \u226b 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 : \ud835\udc9e} {f : A \u27f6 B} {g : B \u27f6 C} {h : C \u27f6 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 \u27f6 C) (k : A \u27f6 D)\n    (hi : f \u226b g = i) (hk : i \u226b h = k) :\n    struc.comp (struc.comp f' g' hi) h' hk = cast (by rw [\u2190 hk, \u2190 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 : \ud835\udc9e} {f : A \u27f6 B} (g : A \u27f6 B) {a : F A} {b : F B}\n  (h : \ud835\udfd9 A \u226b f = g) (f' : struc.hom f a b) : \n  struc.comp (struc.id a) f' h = cast (by rw [\u2190 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 : \ud835\udc9e} {f : A \u27f6 B} (g : A \u27f6 B) {a : F A} {b : F B}\n  (h : f \u226b \ud835\udfd9 B = g) (f' : struc.hom f a b) : \n  struc.comp f' (struc.id b) h = cast (by rw [\u2190 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 := \u03bb A B, \u03a3 (f : A.1 \u27f6 B.1), struc.hom f A.2 B.2,\n  id := \u03bb A, \u27e8\ud835\udfd9 A.1, struc.id A.2\u27e9,\n  comp := \u03bb A B C f g, \u27e8f.1 \u226b g.1, struc.comp f.2 g.2 rfl\u27e9 }\n\n@[simp] lemma comp_fst {A B C : sigma F} (f : A \u27f6 B) (g : B \u27f6 C) :\n  (f \u226b g).fst = f.1 \u226b g.1 := rfl\n\n@[simp] lemma comp_snd {A B C : sigma F} (f : A \u27f6 B) (g : B \u27f6 C) :\n  (f \u226b g).snd = struc.comp f.2 g.2 rfl := rfl\n\n@[simp] lemma id_fst {A : sigma F} : sigma.fst (\ud835\udfd9 A) = \ud835\udfd9 A.1 := rfl\n\n@[simp] lemma id_snd {A : sigma F} : sigma.snd (\ud835\udfd9 A) = struc.id A.2 := rfl\n\ninstance sigma.category : category (sigma F) :=\n{ id_comp' := \u03bb A B f, sigma.ext (category.id_comp _) $\n    by simp [struc.id_comp'],\n  comp_id' := \u03bb A B f, sigma.ext (category.comp_id _) $\n    by simp [struc.comp_id'],\n  assoc' := \u03bb A B C D f g h, sigma.ext (category.assoc _ _ _) $\n    by simp [assoc_left'] }\n\ninstance (X : \ud835\udc9e) : category_struct (F X) :=\n{ hom := \u03bb A B, struc.hom (\ud835\udfd9 X) A B,\n  id := \u03bb A, struc.id A,\n  comp := \u03bb A B C f g, (struc.comp f g (category.id_comp _)) }\n\n\ninstance (X : \ud835\udc9e) : category (F X) :=\n{ id_comp' := \u03bb A B f, struc.id_comp _,\n  comp_id' := \u03bb A B f, struc.comp_id _,\n  assoc' := \u03bb A B C D f g h,\n    show (f \u226b g) \u226b h = f \u226b g \u226b h,\n      begin\n        dsimp [category_struct.comp],\n        rw [struc.assoc_left],\n        congr' 2; simp\n      end }\n\ndef forget : sigma F \u2964 \ud835\udc9e :=\n{ obj := sigma.fst,\n  map := \u03bb _ _, sigma.fst }\n\ndef thing (X : \ud835\udc9e) : F X \u2964 sigma F :=\n{ obj := \u03bb A, \u27e8X, A\u27e9,\n  map := \u03bb A B f, \u27e8\ud835\udfd9 X, f\u27e9,\n  map_id' := \u03bb A, rfl,\n  map_comp' := \u03bb A B C f g, sigma.ext \n    (by simp) begin simp only [comp_snd],\n       rw [struc.comp_eq_cast F f g (\ud835\udfd9 X \u226b \ud835\udfd9 X) rfl (\ud835\udfd9 X)\n         (category.comp_id _)],\n       symmetry,\n       rw [\u2190 cast_eq_iff_heq],\n       simp, refl,\n       simp,\n     end }\n\ninstance inst1 (F : \ud835\udc9e \u2964 Type) : struc F.obj :=\n{ hom := \u03bb A B f a b, plift (F.map f a = b),\n  id := \u03bb A a, \u27e8by simp\u27e9,\n  comp := \u03bb A B C a b c f g h\u2081 h\u2082 _ h, \u27e8by simp [\u2190 h, F.map_comp, h\u2081.down, h\u2082.down]\u27e9,\n  assoc := \u03bb _ _ _ _ _ _ _ _ _ _ _ h\u2081 h\u2082 h\u2083, \n    begin simp [h\u2081.down, h\u2082.down, h\u2083.down] end,\n  id_comp := \u03bb _ _ _ _ _ h, \n    begin simp [h.down] end,\n  comp_id := \u03bb _ _ _ _ _ h, \n    begin simp [h.down] end }\n\n-- instance inst2 (F : \ud835\udc9e \u2964 Type\u1d52\u1d56) : struc (\u03bb x, (F.obj x).unop) :=\n-- { hom := \u03bb A B f a b, plift ((F.map f).unop b = a),\n--   id := \u03bb A a, \u27e8by simp\u27e9,\n--   comp := \u03bb A B C a b c f g h\u2081 h\u2082, \u27e8by simp [F.map_comp, h\u2081.down, h\u2082.down]\u27e9,\n--   assoc := \u03bb _ _ _ _ _ _ _ _ _ _ _ h\u2081 h\u2082 h\u2083, \n--     begin refine heq_of_cast_eq _ _;\n--       simp [h\u2081.down, h\u2082.down, h\u2083.down] end,\n--   id_comp := \u03bb _ _ _ _ _ h, \n--     begin refine heq_of_cast_eq _ _; simp [h.down] end,\n--   comp_id := \u03bb _ _ _ _ _ h, \n--     begin refine heq_of_cast_eq _ _; simp [h.down] end } \n\nexample : struc (\u03bb R : Ring, Module R) :=\n{ hom := \u03bb R S f M\u2081 M\u2082, M\u2081 \u2192\u209b\u2097[f] M\u2082,\n  id := \u03bb R M, linear_map.id,\n  comp := \u03bb R S T M\u2081 M\u2082 M\u2083 f g f' g' _ h, \n    @linear_map.comp _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \u27e8h\u27e9 g' f',\n  id_comp := \u03bb R S f M\u2081 M\u2082 f', begin\n      cases f', cases f, refl\n    end,\n  comp_id := \u03bb R S f M\u2081 M\u2082 f', begin\n      cases f', cases f, refl,\n    end,\n  assoc := \u03bb R S T U f g h M\u2081 M\u2082 M\u2083 M\u2084 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 : \ud835\udc9e \u2964 Type) (G : \ud835\udc9e \u2192 Type) [struc G] : struc (\u03bb A : \ud835\udc9e, F.obj A \u2192 G A) :=\n{ hom := \u03bb X Y f x y, \u03a0 (a : F.obj X) (b : F.obj Y), struc.hom f (x a) (y (F.map f a)),\n  id := \u03bb X x a, cast (by simp) (struc.id (x a)),\n  comp := \u03bb 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 := \u03bb 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 := \u03bb 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 : \ud835\udc9e \u2964 Type) (G : (\u03a3 A : \ud835\udc9e, F.obj A) \u2192 Type) [struc G] : \n  struc (\u03bb A : \ud835\udc9e, \u03a0 a : F.obj A, G \u27e8A, a\u27e9) :=\n{ hom := \u03bb X Y f x y, \u03a0 (a : F.obj X),\n    @struc.hom _ _ G _ \u27e8X, a\u27e9 \u27e8Y, F.map f a\u27e9 \u27e8f, \u27e8rfl\u27e9\u27e9 (x a) (y (F.map f a)),\n  id := \u03bb X x a, by convert @struc.id _ _ G _ \u27e8X, a\u27e9 (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 (\u210d : Type) (\u03c9 : context) : context \u2192 \u2115 \u2192 \u2115 \u2192 Type\n| apply {\u0393} {b} (bs : vector (name \u0393) b) (y : \u2115)\n  : species \u210d \u03c9 (context.extend y \u0393)\n  \u2192 concretion \u0393 b y\n| parallel\u2081 {\u0393} {b y} : concretion \u0393 b y \u2192 species \u210d \u03c9 \u0393 \u2192 concretion \u0393 b y\n| parallel\u2082 {\u0393} {b y} : species \u210d \u03c9 \u0393 \u2192 concretion \u0393 b y \u2192 concretion \u0393 b y\n| restriction {\u0393} {b y} (M : affinity \u210d)\n  : concretion (context.extend M.arity \u0393) b y\n  \u2192 concretion \u0393 b y\n\nnotation `#(` b ` ; ` y `)` A := concretion.apply b y A\n\nreserve infixr ` |\u2081 ` :50\nreserve infixr ` |\u2082 ` :50\n\ninfixr ` |\u2081 ` := concretion.parallel\u2081\ninfixr ` |\u2082 ` := concretion.parallel\u2082\n\nnotation `\u03bd'(` M `) ` A := concretion.restriction M A\n\nvariables {\u210d : Type} {\u03c9 : context}\n\nnamespace concretion\n\n/-- Convert a concretion to a string. Can use `repr` normally. -/\nprotected def to_string [has_repr \u210d]: \u2200 {\u0393} {b y} , concretion \u210d \u03c9 \u0393 b y \u2192 string\n| ._ ._ ._ (concretion.apply bs y A') := \"(\" ++ repr bs.val ++ \";\" ++ repr y ++ \")\" ++ repr A'\n| ._ ._ ._ (F |\u2081 A') := \"(\" ++ to_string F ++ \" | \" ++ repr A' ++ \")\"\n| ._ ._ ._ (A' |\u2082 F) := \"(\" ++ repr A' ++ \" | \" ++ to_string F ++ \")\"\n| ._ ._ ._ (\u03bd'(M) A') := \"(\u03bd ?)(\" ++ to_string A' ++ \")\"\n\ninstance [has_repr \u210d] {b y} {\u0393} : has_repr (concretion \u210d \u03c9 b y \u0393) := \u27e8 concretion.to_string \u27e9\n\nsection free\n  /-- Determine whether a level occurs within a concretion. -/\n  def free_in : \u2200 {\u0393} {b y} (l : level \u0393) (F : concretion \u210d \u03c9 \u0393 b y), Prop\n  | \u0393 b y l (#(bs; _) A) := (\u2203 b \u2208 bs.val, l \u2208 b) \u2228 level.extend l \u2208 A\n  | \u0393 b y l (F |\u2081 A) := free_in l F \u2228 l \u2208 A\n  | \u0393 b y l (A |\u2082 F) := l \u2208 A \u2228 free_in l F\n  | \u0393 b y l (\u03bd'(M) F) := free_in (level.extend l) F\n\n  instance {\u0393} {b y} : has_mem (level \u0393) (concretion \u210d \u03c9 \u0393 b y) := \u27e8 free_in \u27e9\n\n  private def free_in_decide : \u2200 {\u0393} {b y} (l : level \u0393) (F : concretion \u210d \u03c9 \u0393 b y), decidable (free_in l F)\n  | \u0393 b y l (#(bs; _) A) := by { unfold free_in, apply_instance }\n  | \u0393 b y l (F |\u2081 A) := @or.decidable _ _ (free_in_decide l F) _\n  | \u0393 b y l (A |\u2082 F) := @or.decidable _ _ _ (free_in_decide l F)\n  | \u0393 b y l (\u03bd'(M) F) := free_in_decide (level.extend l) F\n\n  instance free_in.decidable {\u0393} {b y} {l} {F : concretion \u210d \u03c9 \u0393 b y} : decidable (l \u2208 F)\n    := free_in_decide l F\nend free\n\nsection rename\n  /-- Rename a concretion. -/\n  def rename : \u2200 {\u0393 \u0394} {b y} (\u03c1 : name \u0393 \u2192 name \u0394), concretion \u210d \u03c9 \u0393 b y \u2192 concretion \u210d \u03c9 \u0394 b y\n  | \u0393 \u0394 b y \u03c1 (#(bs; _) A) := #( vector.map \u03c1 bs; y) species.rename (name.ext \u03c1) A\n  | \u0393 \u0394 b y \u03c1 (F |\u2081 A) := rename \u03c1 F |\u2081 species.rename \u03c1 A\n  | \u0393 \u0394 b y \u03c1 (A |\u2082 F) := species.rename \u03c1 A |\u2082 rename \u03c1 F\n  | \u0393 \u0394 b y \u03c1 (\u03bd'(M) A) := \u03bd'(M) (rename (name.ext \u03c1) A)\n\n  lemma rename_id\n    : \u2200 {\u0393} {b y} (F : concretion \u210d \u03c9 \u0393 b y)\n    , rename id F = F\n  | \u0393 b ._ (#(\u27e8 list, n \u27e9; y) A) := begin\n      simp only [rename, vector.map, list.map_id, subtype.mk_eq_mk],\n      rw name.ext_id,\n      from \u27e8 rfl, species.rename_id A \u27e9\n    end\n  | \u0393 b y (F |\u2081 A) := begin\n      simp only [rename],\n      from \u27e8 rename_id F, species.rename_id A \u27e9\n    end\n  | \u0393 b y (A |\u2082 F) := begin\n      simp only [rename],\n      from \u27e8 species.rename_id A, rename_id F \u27e9\n    end\n  | \u0393 b y (\u03bd'(M) F) := begin\n      simp only [rename], rw name.ext_id,\n      from \u27e8 rfl, heq_of_eq (rename_id F) \u27e9,\n    end\n\n  lemma rename_compose :\n    \u2200 {\u0393 \u0394 \u03b7} {b y} (\u03c1 : name \u0393 \u2192 name \u0394) (\u03c3 : name \u0394 \u2192 name \u03b7) (A : concretion \u210d \u03c9 \u0393 b y)\n    , rename \u03c3 (rename \u03c1 A) = rename (\u03c3 \u2218 \u03c1) A\n  | \u0393 \u0394 \u03b7 b ._ \u03c1 \u03c3 (#(\u27e8 elem, n \u27e9; y) A) := begin\n      unfold rename vector.map,\n      rw [species.rename_compose _ _ A, name.ext_comp],\n      simp\n    end\n  | \u0393 \u0394 \u03b7 b y \u03c1 \u03c3 (F |\u2081 A) := begin\n      unfold rename,\n      rw [rename_compose \u03c1 \u03c3 F, species.rename_compose \u03c1 \u03c3 A]\n    end\n  | \u0393 \u0394 \u03b7 b y \u03c1 \u03c3 (A |\u2082 F) := begin\n      unfold rename,\n      rw [rename_compose \u03c1 \u03c3 F, species.rename_compose \u03c1 \u03c3 A]\n    end\n  | \u0393 \u0394 \u03b7 b y \u03c1 \u03c3 (\u03bd'(M) A) := begin\n      unfold rename,\n      rw [rename_compose (name.ext \u03c1) (name.ext \u03c3) 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' (\u210d : Type) (\u03c9 \u0393 : context) (b y : \u2115) [r : setoid (concretion \u210d \u03c9 \u0393 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 \u2192 eventval\n| EVlong       : int64 \u2192 eventval\n| EVfloat      : float \u2192 eventval\n| EVsingle     : float32 \u2192 eventval\n| EVptr_global : ident \u2192 ptrofs \u2192 eventval\nopen eventval\n\ninductive event : Type\n| syscall : string \u2192 list eventval \u2192 eventval \u2192 event\n| vload   : memory_chunk \u2192 ident \u2192 ptrofs \u2192 eventval \u2192 event\n| vstore  : memory_chunk \u2192 ident \u2192 ptrofs \u2192 eventval \u2192 event\n| annot   : string \u2192 list eventval \u2192 event\n\n/- * Relating values and event values -/\n\nnamespace eventval\n\ndef type : eventval \u2192 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 \u2192 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 \u2190 Senv.find_symbol ge id,\n     return (Vptr b ofs)\n\ndef matchv (ev : eventval) (t : typ) (v : val) : Prop :=\nev.type = t \u2227 ev.to_val ge = some v\n\ndef list_match (evl : list eventval) (tl : list typ) (vl : list val) : Prop :=\nevl.map type = tl \u2227 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 \u2192 val.has_type v ty := sorry'\n\nlemma match_lessdef {ev ty v1 v2} :\n  matchv ge ev ty v1 \u2192 val.lessdef v1 v2 \u2192 matchv ge ev ty v2 := sorry'\n\nlemma list_match_lessdef {evl tyl vl1} :\n  list_match ge evl tyl vl1 \u2192\n  \u2200 vl2, list.forall2 val.lessdef vl1 vl2 \u2192 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 \u2192 matchv ge ev ty v2 \u2192 v1 = v2 := sorry'\n\nlemma match_determ_2 {ev1 ev2 ty v} :\n  matchv ge ev1 ty v \u2192 matchv ge ev2 ty v \u2192 ev1 = ev2 := sorry'\n\nlemma list_match_determ_2 {evl1 tyl vl} :\n  list_match ge evl1 tyl vl \u2192\n  \u2200 evl2, list_match ge evl2 tyl vl \u2192 evl1 = evl2 := sorry'\n\n/- Validity -/\n\ndef valid : eventval \u2192 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 \u2192\n  valid ge ev1 \u2192 valid ge ev2 \u2192 type ev1 = type ev2 \u2192\n  \u2203 v2, matchv ge ev2 ty v2 := sorry'\n\nlemma match_valid {ev ty v} :\n  matchv ge ev ty v \u2192 valid ge ev := sorry'\n\nlemma match_same_type {ev1 ty v1 ev2 v2} :\n  matchv ge ev1 ty v1 \u2192 matchv ge ev2 ty v2 \u2192 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 : \u2200 id,\n  Senv.public_symbol ge2 id = Senv.public_symbol ge1 id)\n\nlemma eventval_valid_preserved {ev} :\n  eventval.valid ge1 ev \u2192 eventval.valid ge2 ev := sorry'\n\nparameter (symbols_preserved : \u2200 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 \u2192 eventval.matchv ge2 ev ty v := sorry'\n\nlemma eventval_list_match_preserved :\n  \u2200 evl tyl vl,\n  eventval.list_match ge1 evl tyl vl \u2192 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 \u2192 option (block \u00d7 \u2124))\nparameters (ge1 ge2 : Senv)\n\ndef symbols_inject : Prop :=\n   (\u2200 id, Senv.public_symbol ge2 id = Senv.public_symbol ge1 id)\n\u2227 (\u2200 id b1 b2 delta,\n     f b1 = some (b2, delta) \u2192 Senv.find_symbol ge1 id = some b1 \u2192\n     delta = 0 \u2227 Senv.find_symbol ge2 id = some b2)\n\u2227 (\u2200 id b1,\n     Senv.public_symbol ge1 id = tt \u2192 Senv.find_symbol ge1 id = some b1 \u2192\n     \u2203 b2, f b1 = some (b2, 0) \u2227 Senv.find_symbol ge2 id = some b2)\n\u2227 (\u2200 b1 b2 delta,\n     f b1 = some (b2, delta) \u2192\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 \u2192 val.inject f v1 v2 \u2192 eventval.matchv ge2 ev ty v2 := sorry'\n\nlemma eventval_match_inject_2 :\n  \u2200 ev ty v1,\n  eventval.matchv ge1 ev ty v1 \u2192\n  \u2203 v2, eventval.matchv ge2 ev ty v2 \u2227 val.inject f v1 v2 := sorry'\n\nlemma eventval_list_match_inject {evl tyl vl1} :\n  eventval.list_match ge1 evl tyl vl1 \u2192\n  \u2200 vl2, list.forall2 (val.inject f) vl1 vl2 \u2192 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 \u2192 event \u2192 Prop\n| (event.syscall id args res1)    (event.syscall id' args' res2)      :=\n  id = id' \u2227 args = args' \u2227 res1.valid ge \u2227 res2.valid ge \u2227 res1.type = res2.type\n| (event.vload chunk id ofs res1) (event.vload chunk' id' ofs' res2)  :=\n  chunk = chunk' \u2227 id = id' \u2227 ofs = ofs' \u2227 res1.valid ge \u2227 res2.valid ge \u2227 res1.type = res2.type\n| (event.vstore chunk id ofs arg) (event.vstore chunk' id' ofs' arg') :=\n  chunk = chunk' \u2227 id = id' \u2227 ofs = ofs' \u2227 arg = arg'\n| (event.annot id args)           (event.annot id' args')             :=\n  id = id' \u2227 args = args'\n| _                               _                                   := false\n\ninductive match_traces : list event \u2192 list event \u2192 Prop\n| nil : match_traces [] []\n| evt (e1 e2) : match_events e1 e2 \u2192 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 : \u2200 id, Senv.public_symbol ge2 id = Senv.public_symbol ge1 id)\n  {t1 t2} : match_traces ge1 t1 t2 \u2192 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 \u2192 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 \u2192 list val \u2192 mem \u2192 list event \u2192 val \u2192 mem \u2192 Prop\n\n/- We now specify the expected properties of this predicate. -/\n\ndef loc_out_of_bounds (m : mem) (b : block) (ofs : \u2115) : Prop :=\n  \u00ac perm m b ofs Max Nonempty\n\ndef loc_not_writable (m : mem) (b : block) (ofs : \u2115) : Prop :=\n  \u00ac perm m b ofs Max Writable\n\ndef loc_unmapped (f : meminj) (b : block) (ofs : \u2115) : Prop :=\n  f b = none\n\ndef loc_out_of_reach (f : meminj) (m : mem) (b : block) (ofs : \u2115) : Prop :=\n  \u2200 b0 delta,\n  f b0 = some (b, delta) \u2192 \u00ac perm_Z m b0 (ofs - delta) Max Nonempty\n\ndef inject_separated (f f' : meminj) (m1 m2 : mem) : Prop :=\n  \u2200 b1 b2 delta,\n  f b1 = none \u2192 f' b1 = some (b2, delta) \u2192\n  \u00ac valid_block m1 b1 \u2227 \u00ac 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  \u2200 ge vargs m1 t vres m2,\n  sem ge vargs m1 t vres m2 \u2192\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  \u2200 ge1 ge2 vargs m1 t vres m2,\n  Senv.equiv ge1 ge2 \u2192\n  sem ge1 vargs m1 t vres m2 \u2192\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  \u2200 ge vargs m1 t vres m2 b,\n  sem ge vargs m1 t vres m2 \u2192\n  valid_block m1 b \u2192 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  \u2200 ge vargs m1 t vres m2 b ofs p,\n  sem ge vargs m1 t vres m2 \u2192\n  memory.valid_block m1 b \u2192 perm m2 b ofs Max p \u2192 perm m1 b ofs Max p)\n\n/- External call cannot modify memory unless they have [Max, Writable]\n   permissions. -/\n(readonly :\n  \u2200 ge vargs m1 t vres m2,\n  sem ge vargs m1 t vres m2 \u2192\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  \u2200 ge vargs m1 t vres m2 m1' vargs',\n  sem ge vargs m1 t vres m2 \u2192\n  extends' m1 m1' \u2192\n  list.forall2 lessdef vargs vargs' \u2192\n  \u2203 vres', \u2203 m2',\n      sem ge vargs' m1' t vres' m2'\n  \u2227 lessdef vres vres'\n  \u2227 extends' m2 m2'\n  \u2227 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  \u2200 ge1 ge2 vargs m1 t vres m2 f m1' vargs',\n  symbols_inject f ge1 ge2 \u2192\n  sem ge1 vargs m1 t vres m2 \u2192\n  inject f m1 m1' \u2192\n  list.forall2 (val.inject f) vargs vargs' \u2192\n  \u2203 f', \u2203 vres', \u2203 m2',\n      sem ge2 vargs' m1' t vres' m2'\n  \u2227 inject f' vres vres'\n  \u2227 inject f' m2 m2'\n  \u2227 unchanged_on (loc_unmapped f) m1 m2\n  \u2227 unchanged_on (loc_out_of_reach f m1) m1' m2'\n  \u2227 inject_incr f f'\n  \u2227 inject_separated f f' m1 m1')\n\n/- External calls produce at most one event. -/\n(trace_length :\n  \u2200 ge vargs m t vres m',\n  sem ge vargs m t vres m' \u2192 t.length \u2264 1)\n\n/- External calls must be receptive to changes of traces by another, matching trace. -/\n(receptive :\n  \u2200 ge vargs m t1 vres1 m1 t2,\n  sem ge vargs m t1 vres1 m1 \u2192 match_traces ge t1 t2 \u2192\n  \u2203 vres2 m2, sem ge vargs m t2 vres2 m2)\n\n/- External calls must be deterministic up to matching between traces. -/\n(determ :\n  \u2200 ge vargs m t1 vres1 m1 t2 vres2 m2,\n  sem ge vargs m t1 vres1 m1 \u2192 sem ge vargs m t2 vres2 m2 \u2192\n  match_traces ge t1 t2 \u2227 (t1 = t2 \u2192 vres1 = vres2 \u2227 m1 = m2))\n\n/- * Semantics of volatile memory accesses -/\n\ninductive volatile_load (ge) (chunk : memory_chunk) (m b ofs) :\n    list event \u2192 val \u2192 Prop\n| volatile_load_vol (id ev v) :\n    Senv.block_is_volatile ge b = tt \u2192\n    Senv.find_symbol ge id = some b \u2192\n    eventval.matchv ge ev chunk.type v \u2192\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 \u2192\n    load chunk m b (unsigned ofs) = some v \u2192\n    volatile_load [] v\n\ninductive volatile_store (ge) (chunk : memory_chunk) (m b ofs v) :\n    list event \u2192 mem \u2192 Prop\n| volatile_store_vol (id ev) :\n    Senv.block_is_volatile ge b = tt \u2192\n    Senv.find_symbol ge id = some b \u2192\n    eventval.matchv ge ev chunk.type (load_result chunk v) \u2192\n    volatile_store [event.vstore chunk id ofs ev] m\n| volatile_store_nonvol (m') :\n    Senv.block_is_volatile ge b = ff \u2192\n    store chunk m b (unsigned ofs) v = some m' \u2192\n    volatile_store [] m'\n\n/- ** Semantics of volatile loads -/\n\ninductive volatile_load_sem (chunk : memory_chunk) (ge : Senv) :\n  list val \u2192 mem \u2192 list event \u2192 val \u2192 mem \u2192 Prop\n| mk (b ofs m t v) :\n  volatile_load ge chunk m b ofs t v \u2192\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 \u2192\n  volatile_load ge1 chunk m b ofs t v \u2192\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 \u2192\n  extends' m m' \u2192\n  \u2203 v', volatile_load ge chunk m' b ofs t v' \u2227 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 \u2192\n  volatile_load ge1 chunk m b ofs t v \u2192\n  inject f (Vptr b ofs) (Vptr b' ofs') \u2192\n  inject f m m' \u2192\n  \u2203 v', volatile_load ge2 chunk m' b' ofs' t v' \u2227 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 \u2192 match_traces ge t1 t2 \u2192\n  \u2203 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  \u27e8[Tptr], some chunk.type, cc_default\u27e9 :=\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 \u2192 mem \u2192 list event \u2192 val \u2192 mem \u2192 Prop\n| mk (b ofs m1 v t m2) :\n  volatile_store ge chunk m1 b ofs v t m2 \u2192\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 \u2192\n  volatile_store ge1 chunk m1 b ofs v t m2 \u2192\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 \u2192\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 \u2192\n  extends' m1 m1' \u2192\n  lessdef v v' \u2192\n  \u2203 m2',\n     volatile_store ge chunk m1' b ofs v' t m2'\n  \u2227 extends' m2 m2'\n  \u2227 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 \u2192\n  volatile_store ge1 chunk m1 b ofs v t m2 \u2192\n  inject f (Vptr b ofs) (Vptr b' ofs') \u2192\n  inject f v v' \u2192\n  inject f m1 m1' \u2192\n  \u2203 m2',\n       volatile_store ge2 chunk m1' b' ofs' v' t m2'\n    \u2227 inject f m2 m2'\n    \u2227 unchanged_on (loc_unmapped f) m1 m2\n    \u2227 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 \u2192 match_traces ge t1 t2 \u2192 t1 = t2 := sorry'\n\nlemma volatile_store_ok {chunk} :\n  extcall_properties (volatile_store_sem chunk) \u27e8[Tptr, chunk.type], none, cc_default\u27e9 :=\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 \u2192 mem \u2192 list event \u2192 val \u2192 mem \u2192 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' \u2192\n  extcall_malloc_sem [Vptrofs sz] m [] (Vptr m.nextblock Mptr.size) m'\n\nlemma extcall_malloc_ok :\n  extcall_properties extcall_malloc_sem \u27e8[Tptr], some Tptr, cc_default\u27e9 :=\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 \u2192 mem \u2192 list event \u2192 val \u2192 mem \u2192 Prop\n| mk (b) (lo : ptrofs) (sz m m') :\n  load Mptr m b (unsigned lo - Mptr.size) = some (Vptrofs sz) \u2192\n  unsigned sz > 0 \u2192\n  free m b (unsigned lo - Mptr.size) (unsigned lo + unsigned sz) = some m' \u2192\n  extcall_free_sem [Vptr b lo] m [] Vundef m'\n\nlemma extcall_free_ok :\n  extcall_properties extcall_free_sem \u27e8[Tptr], none, cc_default\u27e9 :=\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 : \u2115) (ge : Senv) :\n  list val \u2192 mem \u2192 list event \u2192 val \u2192 mem \u2192 Prop\n| mk (bdst bsrc) (odst osrc : ptrofs) (m bytes m') :\n  al = 1 \u2228 al = 2 \u2228 al = 4 \u2228 al = 8 \u2192 al \u2223 sz \u2192\n  (sz > 0 \u2192 al \u2223 unsigned osrc \u2227 al \u2223 unsigned odst) \u2192\n  bsrc \u2260 bdst \u2228 unsigned osrc = unsigned odst\n                \u2228 unsigned osrc + sz \u2264 unsigned odst\n                \u2228 unsigned odst + sz \u2264 unsigned osrc \u2192\n  load_bytes m bsrc (unsigned osrc) sz = some bytes \u2192\n  store_bytes m bdst (unsigned odst) bytes = some m' \u2192\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) \u27e8[Tptr, Tptr], none, cc_default\u27e9 :=\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 \u2192 mem \u2192 list event \u2192 val \u2192 mem \u2192 Prop\n| mk (vargs m args) : eventval.list_match ge args targs vargs \u2192\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) \u27e8targs, none, cc_default\u27e9 :=\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 \u2192 mem \u2192 list event \u2192 val \u2192 mem \u2192 Prop\n| mk (varg m arg) :\n  eventval.matchv ge arg targ varg \u2192\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) \u27e8[targ], some targ, cc_default\u27e9 :=\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 \u2192 mem \u2192 list event \u2192 val \u2192 mem \u2192 Prop\n| mk (vargs m) : extcall_debug_sem vargs m [] Vundef m\n\nlemma extcall_debug_ok (targs) :\n  extcall_properties extcall_debug_sem \u27e8targs, none, cc_default\u27e9 :=\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 \u2192 signature \u2192 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 \u2192 signature \u2192 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 \u2192 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 \u2192\n  m1.nextblock \u2264 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 \u2192 option (block \u00d7 \u2124)) : Prop :=\n     (\u2200 id b, Genv.find_symbol ge id = some b \u2192 f b = some (b, 0))\n  \u2227 (\u2200 b gv, Genv.find_var_info ge b = some gv \u2192 f b = some (b, 0))\n  \u2227 (\u2200 b1 b2 delta gv, Genv.find_var_info ge b2 = some gv \u2192 f b1 = some (b2, delta) \u2192 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 \u2192\n  external_call ef ge vargs m1 t vres m2 \u2192\n  inject f m1 m1' \u2192\n  list.forall2 (val.inject f) vargs vargs' \u2192\n  \u2203 f' vres' m2',\n     external_call ef ge vargs' m1' t vres' m2'\n    \u2227 inject f' vres vres'\n    \u2227 inject f' m2 m2'\n    \u2227 unchanged_on (loc_unmapped f) m1 m2\n    \u2227 unchanged_on (loc_out_of_reach f m1) m1' m2'\n    \u2227 inject_incr f f'\n    \u2227 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 \u2192\n  external_call ef ge vargs m t2 vres2 m2 \u2192\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 \u2192\n  external_call ef ge vargs m t vres2 m2 \u2192\n  vres1 = vres2 \u2227 m1 = m2 := sorry'\n\n/- * Evaluation of builtin arguments -/\n\nsection eval_builtin_arg\n\nparameters {A : Type} (ge : Senv) (e : A \u2192 val) (sp : val) (m : mem)\n\ndef eval_builtin_arg : builtin_arg A \u2192 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 \u2190 eval_builtin_arg hi,\n     vlo \u2190 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 \u2192 val) (sp : val) (m : mem)\n\nparameter (symbols_preserved : \u2200 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 \u2192 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 \u2192 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 \u2192 val} (sp : val) {m1 m2 : mem}\n\nparameter env_lessdef : \u2200 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 \u2192\n  \u2203 v2, eval_builtin_arg ge e2 sp m2 a = some v2 \u2227 lessdef v1 v2 := sorry'\n\nlemma eval_builtin_args_lessdef {al vl1} :\n  eval_builtin_args ge e1 sp m1 al = some vl1 \u2192\n  \u2203 vl2, eval_builtin_args ge e2 sp m2 al = some vl2 \u2227 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 (\u03b1 : Type*) [grid \u03b1] := relative_grid.carrier \u03b1\n\nend grid\n\nopen grid\n\nsection cautomatons\n\nstructure cautomaton (\u03b1 : Type) [decidable_eq \u03b1] :=\n  (g     : vec_grid\u2080 \u03b1)\n  (empty : \u03b1)\n  (neigh : point \u2192 list point)\n  (bound : (bounding_box \u2192 bounding_box) \u2295 (\u03b1 \u2192 vec_grid\u2080 \u03b1 \u2192 point \u2192 \u03b1))\n  (f     : \u03b1 \u2192 list \u03b1 \u2192 \u03b1)\n\nend cautomatons\n\nsection cautomaton_instances\n\nvariables {\u03b1 : Type} [decidable_eq \u03b1] [has_to_string \u03b1] (a : cautomaton \u03b1)\n\nopen grid\n\ndef cautomaton_to_str := grid_str a.g\n\ninstance : has_to_string (cautomaton \u03b1) := \u27e8cautomaton_to_str\u27e9\n\ninstance : has_repr (cautomaton \u03b1) := \u27e8cautomaton_to_str\u27e9\n\nend cautomaton_instances\n\nsection cautomaton_quot_setoid_eq \n\nvariables {\u03b1 : Type} [decidable_eq \u03b1] (a a\u2081 a\u2082 a\u2083 : cautomaton \u03b1)\n\nend cautomaton_quot_setoid_eq\n\nnamespace cautomaton\n\nend cautomaton\n\nnamespace cautomatons\n\nopen cautomaton grid\n\ndef neumann : point \u2192 list point\n  | \u27e8x, y\u27e9 := \n  [            \u27e8x, y - 1\u27e9,\n   \u27e8x - 1, y\u27e9,             \u27e8x + 1, y\u27e9,\n               \u27e8x, y + 1\u27e9             ]\n\ndef moore : point \u2192 list point\n  | \u27e8x, y\u27e9 :=\n  [ \u27e8x - 1, y - 1\u27e9, \u27e8x, y - 1\u27e9, \u27e8x + 1, y - 1\u27e9,\n    \u27e8x - 1, y    \u27e9,             \u27e8x + 1, y    \u27e9,\n    \u27e8x - 1, y + 1\u27e9, \u27e8x, y + 1\u27e9, \u27e8x + 1, y + 1\u27e9 ]\n\n\ndef bounded_neigh {\u03b1} [grid \u03b1] (g : \u03b1)\n  (f : point \u2192 list point) (p : grid_point g) : list point := f p\n\ninstance neigh_gridpoint_coe {\u03b1} [grid \u03b1] (g : \u03b1) :\n  has_coe (point \u2192 list point)\n          (grid_point g \u2192 list point) := \u27e8bounded_neigh g\u27e9\n\ndef ext_id : bounding_box \u2192 bounding_box := id\n\ndef ext_one (bb : bounding_box) : bounding_box :=\n  \u27e8\u27e8bb.1.1 - 1, bb.1.2 - 1\u27e9, \u27e8bb.2.1 + 1, bb.2.2 + 1\u27e9,\n  \u27e8\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)\u27e9\n  \u27e9\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\u2081 p\u2082 h,\n  simp [ext_one, rows_of_box],\n  rw \u2190 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\u2081 p\u2082 h,\n  simp [ext_one, cols_of_box],\n  rw \u2190 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\u2081 = \u27e8bb.p\u2081.x - 1, bb.p\u2081.y - 1\u27e9 := rfl\n\nlemma tr_ext_one {bb} : (ext_one bb).p\u2082 = \u27e8bb.p\u2082.x + 1, bb.p\u2082.y + 1\u27e9 := rfl\n\nend cautomatons\n\nsection cautomaton_props\n\nvariables {\u03b1 : Type} [decidable_eq \u03b1] (a : cautomaton \u03b1)\n\nend cautomaton_props\n\nsection cautomaton_ops\n\nopen function list prod relative_grid\n\nvariables variables {\u03b1 : Type} [decidable_eq \u03b1] (a : cautomaton \u03b1)\n\ndef asize := size a.g\n\ndef bbox_of_caut := grid_bounds a.g\n\ntheorem caut_eq_iff {a\u2081 a\u2082 : cautomaton \u03b1}\n  (hempty : a\u2081.empty = a\u2082.empty)\n  (hneigh : a\u2081.neigh = a\u2082.neigh)\n  (hbound : a\u2081.bound = a\u2082.bound)\n  (hf : a\u2081.f = a\u2082.f)\n  (hext : a\u2081.bound = a\u2082.bound) : a\u2081 = a\u2082 \u2194 a\u2081.g = a\u2082.g :=\n  \u27e8\u03bbh, by simp [h], \u03bbh, by cases a\u2081; cases a\u2082; congr; cc\u27e9\n\nprivate lemma pres_nonempty {\u03b1 \u03b2 : Type} {f} {filtered : list (\u03b1 \u00d7 \u03b2)}\n  {l : list \u2124}\n  (h : \u00acempty_list filtered) (h\u2081 : l = map f ((fst \u2218 unzip) filtered)) : \n  \u00acempty_list l :=\n  by simp [h\u2081, 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   := \u2118 a.g in\n  let zipped   := zip bounded mapped in\n  let filtered := filter (\u03bbx, snd x \u2260 a.empty) zipped in\n  if h : empty_list filtered\n  then \u27e8gbl a.g, gtr a.g, grid_is_bounding_box\u27e9 else\n  let unzipped := fst \u2218 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  \u27e8\u27e8min_x, min_y\u27e9, \u27e8max_x + 1, max_y + 1\u27e9,\n  begin\n    simp [(\u2197), 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\u27e9\n\nlemma compute_bounds_pres_overlaid\n  : overlaid_by (compute_bounds a) \u27e8gbl a.g, gtr a.g, grid_is_bounding_box\u27e9\n  :=\nbegin\n  simp [overlaid_by, compute_bounds],\n  generalize h\u2082 : gip_g a.g = indices,\n  by_cases h : empty_list (filter (\u03bb (x : point \u00d7 \u03b1), x.snd \u2260 a.empty)\n                                  (zip indices \u2118 (a.g))); simp [h\u2082, h],\n  {exact \u27e8\u27e8le_refl _, le_refl _\u27e9, \u27e8le_refl _, le_refl _\u27e9\u27e9},\n  {\n    split; split,\n    {\n      apply le_min_elem_of_all _ _ _ (\u03bbx, \u03bbh\u2081, _),\n      simp at h\u2081, rcases h\u2081 with \u27e8y\u2081, rest, h\u2083\u27e9, subst h\u2083,\n      apply (zunzip_filter_first_irrel rest),\n      rw \u2190 h\u2082, intros y h\u2084,\n      have h\u2085 := gip_g_in_grid h\u2084,\n      simp [flip, is_in_grid, grid_bounds] at h\u2085,\n      exact h\u2085.2.1\n    },    \n    { \n      rw [add_comm, \u2190 sub_le_sub_iff_right (1 : \u2124), add_sub_assoc],\n      have : 1 - 1 = (0 : \u2124), from dec_trivial, rw this, rw add_zero,\n      apply max_le_elem_of_all _ _ _ (\u03bbx, \u03bbh\u2081, _),\n      simp at h\u2081, rcases h\u2081 with \u27e8y\u2081, rest, h\u2083\u27e9, subst h\u2083,\n      apply (zunzip_filter_first_irrel rest), rw \u2190 h\u2082, intros y h\u2084,\n      have h\u2085 := gip_g_in_grid h\u2084,\n      simp [flip, is_in_grid, grid_bounds] at h\u2085,\n      simp [gtr],\n      rw [add_comm (-1 : \u2124), \u2190 sub_eq_add_neg, int.le_sub_one_iff],\n      exact h\u2085.2.2\n    },\n    {\n      rw [add_comm, \u2190 sub_le_sub_iff_right (1 : \u2124), add_sub_assoc],\n      have : 1 - 1 = (0 : \u2124), from dec_trivial, rw [this, add_zero],\n      apply max_le_elem_of_all _ _ _ (\u03bbx, \u03bbh\u2081, _),\n      simp at h\u2081, rcases h\u2081 with \u27e8y\u2081, rest, h\u2083\u27e9, subst h\u2083,\n      apply (zunzip_filter_first_irrel rest),\n      rw \u2190 h\u2082, intros y h\u2084,\n      have h\u2085 := gip_g_in_grid h\u2084,\n      simp [flip, is_in_grid, grid_bounds] at h\u2085,\n      rw int.le_sub_one_iff,\n      exact h\u2085.1.2\n    }, \n    {\n      apply le_min_elem_of_all _ _ _ (\u03bbx, \u03bbh\u2081, _),\n      simp at h\u2081, rcases h\u2081 with \u27e8y\u2081, rest, h\u2083\u27e9, subst h\u2083,\n      simp [expand_gtr, point.x, point.y],\n      apply (zunzip_filter_first_irrel rest),\n      rw \u2190 h\u2082, intros y h\u2084,\n      have h\u2085 := gip_g_in_grid h\u2084,\n      simp [flip, is_in_grid, grid_bounds, expand_gtr, point.x] at h\u2085,\n      rcases h\u2085 with \u27e8\u27e8h\u2085, h\u2086\u27e9, \u27e8h\u2087, h\u2088\u27e9\u27e9,\n      linarith\n    }\n  }\nend\n\nlemma compute_bounds_pres_grid :\n    uncurry (\u2197) (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\u2081 : point} {e\u2082} :\n  (e\u2081, e\u2082) \u2208 zip (gip_g a.g) \u2118(a.g) \u2192\n    (\u2200{H\u2081} {H\u2082}, e\u2082 = abs_data a.g \u27e8\u27e8e\u2081.y, H\u2081\u27e9, \u27e8e\u2081.x, H\u2082\u27e9\u27e9) :=\nbegin\n  intros H\u2080 H\u2081 H\u2082,\n  rw mem_iff_nth_le at H\u2080,\n  cases H\u2080 with i H\u2080r, cases H\u2080r with H\u2080r\u2081 H\u2080r\u2082,\n  symmetry' at H\u2080r\u2082,\n  have leneq : length (gip_g a.g) = length \u2118(a.g),\n    by simp [length_gip_g, length_generate_eq_size],\n  have len\u2081 : i < length \u2118(a.g),\n    { rw [length_zip, leneq, min_self] at H\u2080r\u2081, exact H\u2080r\u2081 },\n  have len\u2082 : i < length (gip_g a.g),\n    { rw [length_zip, \u2190 leneq, min_self] at H\u2080r\u2081, exact H\u2080r\u2081 }, \n  have eq : nth_le (gip_g (a.g)) i len\u2082 = e\u2081 \u2227\n            nth_le \u2118(a.g) i len\u2081 = e\u2082, from nth_le_zip' H\u2080r\u2082,\n  cases eq with eq\u2081 eq\u2082, rw \u2190 eq\u2082,\n  rw nth_generate, rw nth_le_gip_g at eq\u2081,\n  congr, rw \u2190 eq\u2081, rw \u2190 eq\u2081\nend\n\nlemma in_zip_dep {p} {e} {i} {hi}\n  (h : (p, e) = nth_le (zip (gip_g a.g) \u2118(a.g)) i hi) :\n  nth_le (gip_g (a.g)) i \n    begin\n      have leneq : length (gip_g a.g) = length (\u2118(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 \u2227 nth_le \u2118(a.g) i\n    begin\n      have leneq : length (gip_g a.g) = length (\u2118(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 \u2227\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 (\u2118(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 \u2227 nth_le \u2118(a.g) i \n    begin\n      have leneq : length (gip_g a.g) = length (\u2118(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 (\u2118(a.g)),\n        by simp [length_gip_g, length_generate_eq_size],\n      cases this with h\u2081 h\u2082, clear h\u2082, clear h,\n      rw [length_zip, leneq, min_self] at hi, rw \u2190 leneq at hi, clear leneq,\n      rw nth_le_gip_g at h\u2081, rw length_gip_g at hi,\n      rw \u2190 h\u2081,\n      simp [bl, cols], rw mod_add_div_coe\n    },\n  exact \u27e8this.1, this.2, ieq\u27e9\nend\n\nlemma nth_le_gen_iff_abs_data_gip {i} {H} {H\u2081} {e} :\n  nth_le \u2118(a.g) i H = e \u2194\n  abs_data a.g \u27e8\n    \u27e8(nth_le (gip_g a.g) i H\u2081).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\u27e9,\n    \u27e8(nth_le (gip_g a.g) i H\u2081).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\u27e9\n  \u27e9 = e :=\nbegin\n  split; intros h,\n    {rw nth_generate at h, rw \u2190 h, simp [nth_le_gip_g]},\n    {rw nth_generate, rw \u2190 h, simp [nth_le_gip_g]}\nend\n\nlemma mem_zip_gip_gen {p} {elem} \n  (h : p \u2208 a.g)\n  (h\u2081 : elem = abs_data (a.g) {x := \u27e8p.x, h.2\u27e9, y := \u27e8p.y, h.1\u27e9}) :\n  (p, elem) \u2208 zip (gip_g (a.g)) \u2118(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 \u27e8\u27e8a\u2081, a\u2082\u27e9, \u27e8a\u2083, a\u2084\u27e9\u27e9, \n          simp [expand_gtr, gbl, bl, rows, cols] at a\u2081 a\u2082 a\u2083 a\u2084,\n          rw \u2190 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 \u27e8\u27e8a\u2081, a\u2082\u27e9, \u27e8a\u2083, a\u2084\u27e9\u27e9, \n          simp [expand_gtr, gbl, bl, rows, cols] at a\u2081 a\u2082 a\u2083 a\u2084,\n          rw \u2190 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 \u2118(a.g),\n    by simp [length_gip_g, length_generate_eq_size],\n  have H\u2080 : i < length (gip_g a.g),\n    by rw length_gip_g; exact H,\n  have H\u2081 : i < length (zip (gip_g a.g) \u2118(a.g)),\n    by rwa [length_zip, leneq, min_self, length_generate_eq_size],\n  use i, use H\u2081, symmetry,\n  rcases h with \u27e8\u27e8a\u2081, a\u2082\u27e9, \u27e8a\u2083, a\u2084\u27e9\u27e9, \n  simp [expand_gtr, gbl, bl, rows, cols] at a\u2081 a\u2082 a\u2083 a\u2084,\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 \u2190 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\u2081, 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\u2080,\n  rw \u2190 leneq, exact H\u2080\nend\n\nlemma y_notin_elem_empty {x} {y} {H\u2081} {H\u2082}\n  (notin : x \u2209 map point.x\n         ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n         (zip (gip_g (a.g)) \u2118(a.g)))).fst)) :\n  abs_data (a.g) {x := \u27e8x, H\u2081\u27e9, y := \u27e8y, H\u2082\u27e9} = a.empty :=\nbegin\n  let p : point := \u27e8x, y\u27e9,\n  have eqp : p = \u27e8x, y\u27e9, from rfl,\n  have eq\u2081 : p \u2208 gip_g a.g,\n    {apply in_gip_g_of_in_g, exact \u27e8H\u2082, H\u2081\u27e9},\n  rw [mem_map, not_exists] at notin,\n  let elem := abs_data a.g \u27e8\u27e8p.y, H\u2082\u27e9, \u27e8p.x, H\u2081\u27e9\u27e9,\n  have eqelem : elem = abs_data a.g \u27e8\u27e8p.y, H\u2082\u27e9, \u27e8p.x, H\u2081\u27e9\u27e9, from rfl,\n  specialize notin p, simp at notin,\n  by_contradiction contra,\n  have eq\u2082 : (p, elem) \u2208\n    filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty) (zip (gip_g a.g) \u2118(a.g)),\n    {\n      rw @mem_filter _ (\u03bb (x : point \u00d7 \u03b1), \u00acx.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\u2081) eqelem\n    },\n  have eq\u2083 : p \u2208 (unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                          (zip (gip_g (a.g)) \u2118(a.g)))).fst,\n    {rw in_unzip_iff, use elem, exact eq\u2082},\n  contradiction\nend\n\nlemma x_notin_elem_empty {y} {x} {H\u2081} {H\u2082}\n  (notin : y \u2209 map point.y\n         ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n         (zip (gip_g (a.g)) \u2118(a.g)))).fst)) :\n  abs_data (a.g) {x := \u27e8x, H\u2081\u27e9, y := \u27e8y, H\u2082\u27e9} = a.empty :=\nbegin\n  let p : point := \u27e8x, y\u27e9,\n  have eqp : p = \u27e8x, y\u27e9, from rfl,\n  have eq\u2081 : p \u2208 gip_g a.g,\n    {apply in_gip_g_of_in_g, exact \u27e8H\u2082, H\u2081\u27e9},\n  rw [mem_map, not_exists] at notin,\n  let elem := abs_data a.g \u27e8\u27e8p.y, H\u2082\u27e9, \u27e8p.x, H\u2081\u27e9\u27e9,\n  have eqelem : elem = abs_data a.g \u27e8\u27e8p.y, H\u2082\u27e9, \u27e8p.x, H\u2081\u27e9\u27e9, from rfl,\n  specialize notin p, simp at notin,\n  by_contradiction contra,\n  have eq\u2082 : (p, elem) \u2208\n    filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty) (zip (gip_g a.g) \u2118(a.g)),\n    {\n      rw @mem_filter _ (\u03bb (x : point \u00d7 \u03b1), \u00acx.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\u2081) eqelem\n    },\n  have eq\u2083 : p \u2208 (unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                          (zip (gip_g (a.g)) \u2118(a.g)))).fst,\n    {rw in_unzip_iff, use elem, exact eq\u2082},\n  contradiction\nend\n\nlemma y_lt_min_elem_empty {x} {H\u2081} {H\u2082}\n  (h : x < min_element (map point.x\n             ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                        (zip (gip_g (a.g)) \u2118(a.g)))).fst)) H\u2081) :\n  \u2200y {H\u2083}, abs_data (a.g) {x := \u27e8x, H\u2082\u27e9, y := \u27e8y, H\u2083\u27e9} = a.empty :=\nbegin\n  intros,\n  have notin : x \u2209 map point.x\n               ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                          (zip (gip_g (a.g)) \u2118(a.g)))).fst),\n    from not_mem_of_lt_min_element H\u2081 h,\n  apply y_notin_elem_empty _ notin\nend\n\nlemma add_one_y_gt_max_elem_empty {x} {H\u2081} {H\u2082}\n  (h : 1 + max_element (map point.x\n             ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                        (zip (gip_g (a.g)) \u2118(a.g)))).fst)) H\u2081 \u2264 x) :\n  \u2200y {H\u2083}, abs_data (a.g) {x := \u27e8x, H\u2082\u27e9, y := \u27e8y, H\u2083\u27e9} = a.empty :=\nbegin\n  intros,\n  have notin : x \u2209 (map point.x\n             ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                        (zip (gip_g (a.g)) \u2118(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\u2081} {H\u2082}\n  (h : y < min_element (map point.y\n             ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                        (zip (gip_g (a.g)) \u2118(a.g)))).fst)) H\u2081) :\n  \u2200x {H\u2083}, abs_data (a.g) {x := \u27e8x, H\u2083\u27e9, y := \u27e8y, H\u2082\u27e9} = a.empty :=\nbegin\n  intros,\n  have notin : y \u2209 map point.y\n             ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                        (zip (gip_g (a.g)) \u2118(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\u2081} {H\u2082}\n  (h : 1 + max_element (map point.y\n             ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                        (zip (gip_g (a.g)) \u2118(a.g)))).fst)) H\u2081 \u2264 y) :\n  \u2200x {H\u2083}, abs_data (a.g) {x := \u27e8x, H\u2083\u27e9, y := \u27e8y, H\u2082\u27e9} = a.empty :=\nbegin\n  intros,\n  have notin : y \u2209 map point.y\n             ((unzip (filter (\u03bb (x : point \u00d7 \u03b1), \u00acx.snd = a.empty)\n                        (zip (gip_g (a.g)) \u2118(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 \u2208 a.g)\n  (h\u2081 : p \u2209 compute_bounds a) :\n  abs_data (a.g) {x := \u27e8p.x, h.2\u27e9, y := \u27e8p.y, h.1\u27e9} = a.empty :=\nbegin\n  unfold compute_bounds at h\u2081,\n  simp [flip, is_in_grid, is_in_grid', is_bounded] at h,\n  rcases h with \u27e8\u27e8B\u2081, B\u2082\u27e9, \u27e8B\u2083, B\u2084\u27e9\u27e9,\n  simp [expand_gtr, bl, cols, rows] at B\u2081 B\u2082 B\u2083 B\u2084,\n  let i := |p.y - a.g.o.y| * a.g.c + |p.x - a.g.o.x|,\n  have A\u2081 : p.y - a.g.o.y \u2265 0, by linarith,\n  have A\u2082 : p.x - a.g.o.x \u2265 0, by linarith,\n  have A\u2083 : i < size a.g,\n    {\n      simp [i, size, rows, cols, -sub_eq_add_neg, -add_comm],\n      apply linearize_array,\n        {\n          rw \u2190 int.coe_nat_lt_coe_nat_iff,\n          rw int.nat_abs_of_nonneg; try { assumption },\n          linarith\n        },\n        {\n          rw \u2190 int.coe_nat_lt_coe_nat_iff,\n          rw int.nat_abs_of_nonneg; try { assumption },\n          linarith\n        }\n    },\n  have A\u2084 : 0 \u2264 i, by linarith,\n  cases p with x y,\n  have eq\u2081 : (bl (a.g)).x + \u2191|\u2191i| % \u2191(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 \u2190 sub_eq_add_neg,\n      rw int.mod_eq_of_lt,\n      linarith,\n      linarith\n    },\n  have eq\u2082 : (bl (a.g)).y + \u2191|\u2191i| / \u2191(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 \u2190 sub_eq_add_neg,\n      rw \u2190 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 (\u03bb (x : point \u00d7 \u03b1), x.snd \u2260 a.empty)\n                       (zip (gip_g (a.g)) \u2118(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 \u27e8x, y\u27e9,\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\u2083, exact le_refl _,\n        rw nth_le_zip, rw nth_le_gip_g,\n          {congr, exact eq\u2081, exact eq\u2082},\n          {\n            rw nth_generate, congr, \n            exact eq\u2082, exact eq\u2081\n          },\n        rw length_gip_g, exact A\u2083,\n        rw length_generate_eq_size, exact A\u2083\n      },\n      {\n        simp [eq, flip, is_in_grid, is_bounded, -not_and] at h\u2081,\n        rw not_and_distrib at h\u2081, cases h\u2081, rw not_and_distrib at h\u2081,\n        cases h\u2081,\n          {\n            simp only [point.x, point.y] at *,\n            rw not_le at h\u2081,\n            apply x_lt_min_elem_empty _ h\u2081\n          }, \n          {\n            rw not_lt at h\u2081,\n            apply add_one_x_lt_max_elem_empty _ h\u2081\n          },\n        rw not_and_distrib at h\u2081, cases h\u2081,\n          {\n            rw not_le at h\u2081,\n            apply y_lt_min_elem_empty _ h\u2081\n          },\n          {\n            rw not_lt at h\u2081,\n            apply add_one_y_gt_max_elem_empty _ h\u2081\n          }\n      }\nend\n\nlemma exists_p_of_in_generate {x} (h : x \u2208 \u2118(a.g)) :\n  \u2203(p : point) (H : p \u2208 gip_g a.g),\n    abs_data a.g \u27e8\n      \u27e8p.y, begin rw \u2190 in_grid_iff_in_gip_g at H, exact H.1 end\u27e9,\n      \u27e8p.x, begin rw \u2190 in_grid_iff_in_gip_g at H, exact H.2 end\u27e9\n    \u27e9 = x :=\nbegin\n  rw mem_iff_nth_le at h,\n  rcases h with \u27e8i, \u27e8h\u2081, h\u2082\u27e9\u27e9, \n  have : i < length (gip_g (a.g)),\n    {rw length_gip_g, rw length_generate_eq_size at h\u2081, exact h\u2081},\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 \u2190 h\u2082,\n  rw nth_generate, simp [nth_le_gip_g, bl, cols, eqp],\n  have : p \u2208 gip_g (a.g), { rw eqp, apply nth_le_mem },\n  use this, congr\nend\n\ndef canonical_grid :=\n  compute_bounds a = \u27e8gbl a.g, gtr a.g, grid_is_bounding_box\u27e9\n\ndef make_canonical : cautomaton \u03b1 :=\n  {a with g := \u2191(subgrid a.g (compute_bounds a) (compute_bounds_pres_overlaid _))}\n\ndef is_canonical := make_canonical a = a\n\ndef aut_eq (a\u2081 a\u2082 : cautomaton \u03b1) : Prop :=\n  (band : bool \u2192 bool \u2192 bool) (\u2118(make_canonical a\u2081).g = \u2118(make_canonical a\u2082).g)\n  $ (band : bool \u2192 bool \u2192 bool)\n    ((make_canonical a\u2081).g.r = (make_canonical a\u2082).g.r)\n    ((make_canonical a\u2081).g.c = (make_canonical a\u2082).g.c)\n\ninfix ` ~\u2090 `:100 := aut_eq\n\ninstance decidable_aut_eq {\u03b1} [decidable_eq \u03b1] {a\u2081 a\u2082} :\n  decidable (@aut_eq \u03b1 _ a\u2081 a\u2082) := by simp [(~\u2090)]; apply_instance\n\ndef ext_aut (a : cautomaton \u03b1) : cautomaton \u03b1 :=\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\u2080.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\u2081\n        (\u03bbx y, if h : (\u27e8y, x\u27e9 : point) \u2208 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    \u27e8new_grid, a.empty, a.neigh, a.bound, a.f\u27e9\n  end\n\ndef default_if_nex {\u03b1 : Type*} [grid \u03b1] (empty : carrier \u03b1)\n  (g : \u03b1) (p : point) : carrier \u03b1 :=\n  if h : p \u2208 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 : \u2124} {c} (h : a > 0) :\n  b \u2264 (b + a) - 1 - (b - c - 1) % a :=\nbegin\n  simp, repeat { rw \u2190 sub_eq_add_neg },\n  rw [\n    \u2190 add_sub_assoc, \u2190 sub_eq_add_neg,\n    \u2190 le_add_iff_nonneg_left (1 : \u2124)\n  ],\n  change (1 : \u2124) with (0 + 1),\n  rw int.add_one_le_iff, simp [-sub_eq_add_neg],\n  rw \u2190 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 : \u2124} {c} (h : a > 0) :\n  (b + a) - 1 - (b - c - 1) % a < b + a :=\nbegin\n  simp, rw \u2190 add_assoc, repeat { rw \u2190 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 {\u03b1 : Type*} [grid \u03b1] (empty : carrier \u03b1)\n  (g : \u03b1) (p : point) : carrier \u03b1 :=\n  if h : p \u2208 g\n  then abs_data g (grid_point_of_prod' (in_grid_bounded g p h))\n  else\n    if b\u2081 : is_bounded (gbl g).y (gtr g).y p.y \n    then\n      if p\u2081 : p.x \u2265 (gtr g).x\n      then abs_data g \u27e8\n        make_bounded b\u2081,\n        \u27e8(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        \u27e9\n      \u27e9\n      else abs_data g \u27e8\n        make_bounded b\u2081,\n        \u27e8(gtr g).x - 1 - ((gbl g).x - p.x - 1) % cols g,\n         have h\u2082 : p.x < (gbl g).x,\n           {\n             by_cases p\u2083 : (gbl g).x \u2264 p.x,\n               {\n                 have contra : is_bounded (gbl g).x (gtr g).x p.x,\n                   from \u27e8p\u2083, lt_of_not_ge p\u2081\u27e9,\n                 simp only [(\u2209), flip, is_in_grid'] at h,\n                 finish\n               },\n             {linarith}\n           },\n          \u27e8\n            bound_periodic_modulo' cols_pos,\n            bound_periodic_modulo'' cols_pos\n          \u27e9\n        \u27e9\n      \u27e9\n    else\n    if b\u2082 : is_bounded (gbl g).x (gtr g).x p.x\n    then\n      if p\u2082 : p.y \u2265 (gtr g).y\n      then abs_data g \u27e8\n        \u27e8(gbl g).y + (p.y - (gbl g).y) % rows g,\n          \u27e8\n            begin\n              simp only [gbl, le_add_iff_nonneg_right, sub_eq_add_neg],\n              rw \u2190 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          \u27e9\n        \u27e9,\n        make_bounded b\u2082\n      \u27e9\n      else abs_data g \u27e8\n        \u27e8(gtr g).y - 1 - ((gbl g).y - p.y - 1) % rows g,\n          have h\u2082 : p.y < (gbl g).y,\n            {\n              replace p\u2082 := lt_of_not_ge p\u2082,\n              by_cases p\u2083 : (gbl g).y \u2264 p.y,\n                {\n                  have contra : is_bounded (gbl g).y (gtr g).y p.y,\n                    from \u27e8p\u2083, p\u2082\u27e9,\n                  contradiction\n                },\n                {linarith}\n            },\n          \u27e8\n            bound_periodic_modulo' rows_pos,\n            bound_periodic_modulo'' rows_pos\n          \u27e9\n        \u27e9,\n        make_bounded b\u2082\n      \u27e9\n    else empty\n\ndef bound_const {\u03b1 : Type*} [grid \u03b1]\n  (const : carrier \u03b1) (g : \u03b1) (p : point) : carrier \u03b1 := default_if_nex const g p\n\nend boundary\n\ndef next_gen (a : cautomaton \u03b1) : cautomaton \u03b1 :=\n  let new_grid := (ext_aut a).g in\n  let cells := \u2118 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\u2080 \u03b1) _ 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\u2080.mk _\n      \u27e8grid_rows new_grid, grid_cols new_grid,\n       mul_pos rows_pos cols_pos,\n      \u27e8new_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                  \u27e9\u27e9 new_grid.o in\n    let next_config := (\u27e8grid, a.empty, a.neigh, a.bound, a.f\u27e9 : cautomaton \u03b1) 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 : \u2115) := iterate next_gen a n\n\ndef periodic := {n // n \u2260 0 \u2227 step_n a n = a}\n\ndef count_at_single {\u03b1 : Type} [decidable_eq \u03b1] (neigh : list \u03b1) (valid : \u03b1) :=\n  list.sum \u2218 map (\u03bbc, if c = valid then 1 else 0) $ neigh\n\ndef yield_at_if_in_neigh {\u03b1 : Type} [decidable_eq \u03b1]\n  (a : cautomaton \u03b1) (p : point) :=\n  if p \u2208 a.neigh p\n  then some $ @default_if_nex (vec_grid\u2080 \u03b1) _ 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) : \u03b1 := @default_if_nex (vec_grid\u2080 \u03b1) _ a.empty a.g p\n\ndef mod_at (p : point) (x : \u03b1) (a : cautomaton \u03b1) : cautomaton \u03b1 :=\n  \u27e8modify_at p x a.g, a.empty, a.neigh, a.bound, a.f\u27e9\n\ndef mod_many (l : list (point \u00d7 \u03b1)) (a : cautomaton \u03b1) : cautomaton \u03b1 :=\n  \u27e8modify_many l a.g, a.empty, a.neigh, a.bound, a.f\u27e9\n\nend cautomaton_ops\n\nsection counting\n\nvariables {\u03b1 : Type} [decidable_eq \u03b1] (a : cautomaton \u03b1)\n\ndef count (c : \u03b1) : \u2115 := 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\u2080 \u03b1) {x} : count_grid \u2191a 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\u2080 \u03b1) {x} : count_grid \u2191a 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 \u03b1}\n  (h : yield_at a p \u2260 a.empty) : p \u2208 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 \u03b1} {x} (h : x \u2260 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\u2081 h\u2082,\n  have : (abs_data (a.g) \u2218 inject_filter_bounded (a.g)) \u27e8p, h\u2081\u27e9 = a.empty,\n    {\n      rw list.mem_filter at h\u2081,\n      cases h\u2081 with h\u2082 h\u2083,\n      simp [(\u2218), 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\u2082,\n      exact h\u2083\n    },\n  cc\nend\n\nlemma count_nonempty_compute_bounds {a : cautomaton \u03b1} {x} (h : x \u2260 a.empty) :\n  list.count x (\u2118 a.g) =\n  list.count x \u2118(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 \u03b1} {x} (h : x \u2260 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 {\u03b1 : Type} [decidable_eq \u03b1] (a : cautomaton \u03b1) (p : point)\n          (neigh : point \u2192 list point)\n\ndef neigh_with_NW := \u2200p : point, point.mk (p.x - 1) (p.y - 1) \u2208 neigh p\n\ndef neigh_with_N  := \u2200p : point, point.mk p.x       (p.y - 1) \u2208 neigh p\n\ndef neigh_with_NE := \u2200p : point, point.mk (p.x + 1) (p.y - 1) \u2208 neigh p\n\ndef neigh_with_W  := \u2200p : point, point.mk (p.x - 1) p.y       \u2208 neigh p\n\ndef neigh_with_E  := \u2200p : point, point.mk (p.x + 1) p.y       \u2208 neigh p\n\ndef neigh_with_SW := \u2200p : point, point.mk (p.x - 1) (p.y + 1) \u2208 neigh p\n\ndef neigh_with_S  := \u2200p : point, point.mk p.x       (p.y + 1) \u2208 neigh p\n\ndef neigh_with_SE := \u2200p : point, point.mk (p.x + 1) (p.y + 1) \u2208 neigh p\n\nopen cautomatons\n\nlemma neumann_N : neigh_with_N neumann :=\n  \u03bb\u27e8x, y\u27e9, by simp [neumann]\n\nlemma neumann_W : neigh_with_W neumann :=\n  \u03bb\u27e8x, y\u27e9, by simp [neumann]\n\nlemma neumann_E : neigh_with_E neumann :=\n  \u03bb\u27e8x, y\u27e9, by simp [neumann]\n\nlemma neumann_S : neigh_with_S neumann :=\n  \u03bb\u27e8x, y\u27e9, by simp [neumann]\n\nlemma moore_NW : neigh_with_NW moore :=\n  \u03bb\u27e8x, y\u27e9, by simp [moore]\n\nlemma moore_N : neigh_with_N moore :=\n  \u03bb\u27e8x, y\u27e9, by simp [moore]\n\nlemma moore_NE : neigh_with_NE moore :=\n  \u03bb\u27e8x, y\u27e9, by simp [moore]\n\nlemma moore_W : neigh_with_W moore :=\n  \u03bb\u27e8x, y\u27e9, by simp [moore]\n\nlemma moore_E : neigh_with_E moore :=\n  \u03bb\u27e8x, y\u27e9, by simp [moore]\n\nlemma moore_SW : neigh_with_SW moore :=\n  \u03bb\u27e8x, y\u27e9, by simp [moore]\n\nlemma moore_S : neigh_with_S moore :=\n  \u03bb\u27e8x, y\u27e9, by simp [moore]\n\nlemma moore_SE : neigh_with_SE moore :=\n  \u03bb\u27e8x, y\u27e9, by simp [moore]\n\ndef NW (h : neigh_with_NW a.neigh) := yield_at a \u27e8p.x - 1, p.y - 1\u27e9\n\ndef N (h : neigh_with_N a.neigh) := yield_at a \u27e8p.x, p.y - 1\u27e9\n\ndef NE (h : neigh_with_NE a.neigh) := yield_at a \u27e8p.x + 1, p.y - 1\u27e9\n\ndef W (h : neigh_with_W a.neigh) := yield_at a \u27e8p.x - 1, p.y\u27e9\n\ndef E (h : neigh_with_E a.neigh) := yield_at a \u27e8p.x + 1, p.y\u27e9\n\ndef SW (h : neigh_with_SW a.neigh) := yield_at a \u27e8p.x - 1, p.y + 1\u27e9\n\ndef S (h : neigh_with_S a.neigh) := yield_at a \u27e8p.x, p.y + 1\u27e9\n\ndef SE (h : neigh_with_SE a.neigh) := yield_at a \u27e8p.x + 1, p.y + 1\u27e9\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 (\u03b1 \u03b2 : Type) extends signature \u03b1 :=\n(class_of: \u03b2 \u2192 class_name \u03b1)\n(encodable_object: encodable \u03b2)\n(decidable_object: decidable_eq \u03b2) -- redundant\n(data_type: record_name \u03b1 \u2192 datatype)\n(data_type_boolean:\n  (data_type (boolean_name \u03b1)).host = bool)\n(data_type_boolean_inhabited:\n  (cast data_type_boolean (data_type (boolean_name \u03b1))\n    .inhabited_host.default) = ff)\nopen objects\n\nlemma data_type_booleanr {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] :\n  bool = (data_type (boolean_name \u03b1)).host :=\nbegin symmetry, apply data_type_boolean end\ninstance objects.decidable_eq {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] :\n  decidable_eq \u03b2 := decidable_object \u03b1 \u03b2\ninstance objects.encodable {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] :\n  encodable \u03b2 := encodable_object \u03b1 \u03b2\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 {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] : type \u03b1 \u2192 Type\n| object {c : class_name \u03b1} :\n    {o : \u03b2 // c = class_of \u03b1 o} \u2192 value (type.ref c)\n| null (c : class_name \u03b1) :\n    value (type.ref c)\n| term {r : record_name \u03b1} :\n    (data_type r).host \u2192 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 {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] :\n    \u03a0{ty : type \u03b1}, inhabited (value ty)\n| (type.ref c) := \u27e8value.null c\u27e9\n| (type.data r) := \u27e8value.term (data_type r).default\u27e9\n-- Projection of value to term\ndef value.unterm {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2]\n    {r : record_name \u03b1} : \u03a0 (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 {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] :\n    \u03a0 (x : value (boolean \u03b1)), bool\n| (value.term t) := cast (data_type_boolean \u03b1 \u03b2) t\n-- Projection of value to potential object\ndef value.unobject {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2]\n    {c : class_name \u03b1} : \u03a0 (x : value (type.ref c)), option \u03b2\n| (value.object o) := o\n| (value.null _) := none\ndef value.not_null {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2]\n    {c : class_name \u03b1} (x : value (type.ref c)) : Prop :=\n  x \u2260 value.null c\n-- Projection of not-null value to object identity\ndef value.the_object {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2]\n    {c : class_name \u03b1} : \u03a0 {x : value (type.ref c)},\n    value.not_null x \u2192 \u03b2\n| (value.object o) _ := o\n| (value.null .(c)) G := begin exfalso, apply G, refl end\nlemma value.class_of_the_object {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2]\n  {c : class_name \u03b1} {x : value (type.ref c)}\n  (G : value.not_null x) :\n  class_of \u03b1 (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 {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] :\n    list (type \u03b1) \u2192 Type\n| nil : vallist []\n| cons {ty : type \u03b1} {l : list (type \u03b1)} :\n  value ty \u2192 vallist l \u2192 vallist (ty::l)\ndef vallist.default {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] :\n    \u03a0(l : list (type \u03b1)), vallist l\n| [] := vallist.nil\n| (t :: l) := vallist.cons (default (value t))\n    (vallist.default l)\ninstance vallist.inhabited {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2]\n    (l : list (type \u03b1)) : inhabited (vallist l) :=\n  \u27e8vallist.default l\u27e9\n/- A value list of a single type is just a value. -/\ndef vallist.single {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] {ty : type \u03b1}\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 {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] {ty : type \u03b1} :\n    vallist [ty] \u2192 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 {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2]\n    {ty : type \u03b1} {l : list (type \u03b1)}\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 {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] {ty : type \u03b1} :\n    \u03a0 {l : context \u03b1}, vallist l \u2192 list_at ty l \u2192 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 {\u03b1 \u03b2 : Type} [objects \u03b1 \u03b2] {ty : type \u03b1} :\n    \u03a0 {l : context \u03b1}, vallist l \u2192 list_at ty l \u2192\n    value ty \u2192 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 (\u03b1 \u03b2 : Type) extends objects \u03b1 \u03b2 :=\n  (interp {args : list (type \u03b1)} {result : type \u03b1}\n    {s : symbol_name \u03b1} (sym : symbol args result s):\n    vallist args \u2192 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 \u2964 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 \u2964 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 \u2964 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 \ud835\udfed\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 \u2964 C`. -/\ndef forget (C : Type u) [category C] : Monad C \u2964 C \u2964 C :=\n  functor.mk func fun (_x _x_1 : Monad C) (f : _x \u27f6 _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 \u27f6 N) (g : N \u27f6 L) :\n    monad_hom.to_nat_trans (f \u226b 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 \u03bc_ X) \u226b nat_trans.app \u03bc_ X =\n        nat_trans.app \u03bc_ (functor.obj (func M) X) \u226b nat_trans.app \u03bc_ 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 \ud835\udfed\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 \u2964 C`. -/\ndef forget (C : Type u) [category C] : Comonad C \u2964 C \u2964 C :=\n  functor.mk func fun (_x _x_1 : Comonad C) (f : _x \u27f6 _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 \u27f6 N) (g : N \u27f6 L) :\n    comonad_hom.to_nat_trans (f \u226b 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 \u03b4_ X \u226b functor.map (func M) (nat_trans.app \u03b4_ X) =\n        nat_trans.app \u03b4_ X \u226b nat_trans.app \u03b4_ (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": "/-\nCopyright (c) 2022 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\n\nimport Aesop\nimport Lean\n\nopen Lean Lean.Meta Lean.Elab.Tactic\n\nset_option aesop.check.all true\nset_option aesop.check.script false\n\n-- When rules add declarations to the environment, Aesop must copy these\n-- declarations during proof extraction.\n\ndef falso : TacticM Unit := do\n  addDecl $ .axiomDecl {\n    name := `someaxiom\n    levelParams := []\n    type := mkConst ``False\n    isUnsafe := false\n  }\n  closeMainGoal (mkConst `someaxiom)\n\nexample : False := by\n  aesop (add safe falso)\n\n-- A more complex example with dependencies between the rules.\n\ndef falso\u2082 : TacticM Unit := do\n  addDecl $ .axiomDecl {\n    name := `someaxiom\u2082\n    levelParams := []\n    type := \u2190 mkArrow (mkConst ``Nat) (mkConst ``False)\n    isUnsafe := false\n  }\n  addDecl $ .defnDecl {\n    name := `fromsomeaxiom\u2082\n    levelParams := []\n    type := mkConst ``False\n    value := mkApp (mkConst `someaxiom\u2082) (mkConst ``Nat.zero)\n    hints := .regular 0\n    safety := .safe\n  }\n  closeMainGoal (mkConst `fromsomeaxiom\u2082)\n\nexample : False := by\n  aesop (add safe falso\u2082)\n", "meta": {"author": "JLimperg", "repo": "aesop", "sha": "c68fb1d5a9172498230d81d95c61f6461bea6722", "save_path": "github-repos/lean/JLimperg-aesop", "path": "github-repos/lean/JLimperg-aesop/aesop-c68fb1d5a9172498230d81d95c61f6461bea6722/tests/run/Environment.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5813031051514762, "lm_q2_score": 0.42250463481418826, "lm_q1q2_score": 0.24560325615837814}}
{"text": "\nimport tactic\n\nuniverses u v w\n\nclass is_lawful_monad_lift (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) [has_monad_lift m n] [monad m] [monad n] :=\n(monad_lift_pure : \u2200 {\u03b1} (x : \u03b1),\n  has_monad_lift.monad_lift (pure x : m \u03b1) = (pure x : n \u03b1))\n(monad_lift_bind : \u2200 {\u03b1 \u03b2} (x : m \u03b1) (f : \u03b1 \u2192 m \u03b2),\n  (has_monad_lift.monad_lift $ x >>= f : n \u03b2) =\n  has_monad_lift.monad_lift x >>= has_monad_lift.monad_lift \u2218 f )\n\nclass is_lawful_monad_lift_t (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) [has_monad_lift_t m n] [monad m] [monad n] :=\n(monad_lift_pure : \u2200 {\u03b1} (x : \u03b1),\n  has_monad_lift_t.monad_lift (pure x : m \u03b1) = (pure x : n \u03b1))\n(monad_lift_bind : \u2200 {\u03b1 \u03b2} (x : m \u03b1) (f : \u03b1 \u2192 m \u03b2),\n  (has_monad_lift_t.monad_lift $ x >>= f : n \u03b2) =\n  has_monad_lift_t.monad_lift x >>= has_monad_lift_t.monad_lift \u2218 f )\n\nlemma is_lawful_monad_lift_t.monad_lift_and_then  (m : Type u \u2192 Type v) (n : Type u \u2192 Type w)\n  [has_monad_lift_t m n] [monad m] [monad n] [is_lawful_monad_lift_t m n]\n  {\u03b1 \u03b2} (x : m \u03b1) (f : m \u03b2) :\n  (has_monad_lift_t.monad_lift $ x >> f : n \u03b2) =\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 (\u03c3 : out_param (Type u)) (m : Type u \u2192 Type v) [monad m] [monad_state \u03c3 m] :=\n(lift_pure : \u2200 {\u03b1} (x : \u03b1),\n  monad_state.lift (pure x : state \u03c3 \u03b1) = (pure x : m \u03b1))\n(lift_bind  : \u2200 {\u03b1 \u03b2} (x : state \u03c3 \u03b1) (f : \u03b1 \u2192 state \u03c3 \u03b2),\n  (monad_state.lift $ x >>= f : m \u03b2) =\n  monad_state.lift x >>= monad_state.lift \u2218 f )\n(lift_put : \u2200 (x : \u03c3),\n  monad_state.lift (put x : state \u03c3 punit) = (put x : m punit))\n(lift_get :\n  monad_state.lift (get : state \u03c3 \u03c3) = (get : m \u03c3))\nopen is_lawful_monad_state\n\nlemma is_lawful_monad_state.lift_and_then {m} [monad m] {\u03b1 \u03b2 \u03c3} [monad_state \u03c3 m] [is_lawful_monad_state \u03c3 m] (x : state \u03c3 \u03b1) (f : state \u03c3 \u03b2) :\n  (monad_state.lift $ x >> f : m \u03b2) =\n  monad_state.lift x >> monad_state.lift f :=\nby { simp [(>>),lift_bind m] }\n\ninstance (\u03c3 : (Type u)) (m : Type u \u2192 Type v) [monad m] [is_lawful_monad m] : is_lawful_monad_state \u03c3 (state_t \u03c3 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 (\u03c3 \u03c3' : (Type u)) (m : Type u \u2192 Type v) [monad m] [is_lawful_monad m] [monad_state \u03c3 m] [is_lawful_monad_state \u03c3 m] :\n  is_lawful_monad_state \u03c3 (reader_t \u03c3' m) :=\nby { constructor; intros; simp [monad_state.lift,lift_pure m,lift_bind m]; refl }\n\ninstance (\u03c3 : (Type u)) (m : Type u \u2192 Type v) [monad m] [is_lawful_monad m] : is_lawful_monad_lift m (state_t \u03c3 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 (\u03c3 : (Type u)) (m : Type u \u2192 Type v) [monad m] : is_lawful_monad_lift m (reader_t \u03c3 m) :=\nby { constructor; intros; refl }\n\n-- class is_lawful_monad_reader (\u03c3 : out_param (Type u)) (m : Type u \u2192 Type v) [monad m] [monad_reader \u03c3 m] :=\n-- (lift_pure {} : \u2200 {\u03b1} (x : \u03b1),\n--   monad_reader.lift (pure x : reader \u03c3 \u03b1) = (pure x : m \u03b1))\n-- (lift_bind {} : \u2200 {\u03b1 \u03b2} (x : state \u03c3 \u03b1) (f : \u03b1 \u2192 state \u03c3 \u03b2),\n--   (monad_state.lift $ x >>= f : m \u03b2) =\n--   monad_state.lift x >>= monad_state.lift \u2218 f )\n\n-- instance (\u03c3 : (Type u)) (m : Type u \u2192 Type v) [monad m] [is_lawful_monad m] : is_lawful_monad_state \u03c3 (state_t \u03c3 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": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nprelude\nimport Init.Core\nimport Init.Control.Basic\nimport Init.Coe\n\nnamespace Option\n\ndef toMonad [Monad m] [Alternative m] : Option \u03b1 \u2192 m \u03b1\n  | none     => failure\n  | some a   => pure a\n\n@[inline] def toBool : Option \u03b1 \u2192 Bool\n  | some _ => true\n  | none   => false\n\n@[inline] def isSome : Option \u03b1 \u2192 Bool\n  | some _ => true\n  | none   => false\n\n@[inline] def isNone : Option \u03b1 \u2192 Bool\n  | some _ => false\n  | none   => true\n\n@[inline] def isEqSome [BEq \u03b1] : Option \u03b1 \u2192 \u03b1 \u2192 Bool\n  | some a, b => a == b\n  | none,   _ => false\n\n@[inline] protected def bind : Option \u03b1 \u2192 (\u03b1 \u2192 Option \u03b2) \u2192 Option \u03b2\n  | none,   b => none\n  | some a, b => b a\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (o : Option \u03b1) : Option \u03b2 :=\n  Option.bind o (some \u2218 f)\n\n@[inline] protected def mapM [Monad m] (f : \u03b1 \u2192 m \u03b2) (o : Option \u03b1) : m (Option \u03b2) := do\n  if let some a := o then\n    return some (\u2190 f a)\n  else\n    return none\n\ntheorem map_id : (Option.map id : Option \u03b1 \u2192 Option \u03b1) = id :=\n  funext (fun o => match o with | none => rfl | some x => rfl)\n\ninstance : Functor Option where\n  map := Option.map\n\n@[inline] protected def filter (p : \u03b1 \u2192 Bool) : Option \u03b1 \u2192 Option \u03b1\n  | some a => if p a then some a else none\n  | none   => none\n\n@[inline] protected def all (p : \u03b1 \u2192 Bool) : Option \u03b1 \u2192 Bool\n  | some a => p a\n  | none   => true\n\n@[inline] protected def any (p : \u03b1 \u2192 Bool) : Option \u03b1 \u2192 Bool\n  | some a => p a\n  | none   => false\n\n@[macroInline] protected def orElse : Option \u03b1 \u2192 (Unit \u2192 Option \u03b1) \u2192 Option \u03b1\n  | some a, _ => some a\n  | none,   b => b ()\n\ninstance : OrElse (Option \u03b1) where\n  orElse := Option.orElse\n\n@[inline] protected def lt (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Option \u03b1 \u2192 Option \u03b1 \u2192 Prop\n  | none, some x     => True\n  | some x,   some y => r x y\n  | _, _             => False\n\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [s : DecidableRel r] : DecidableRel (Option.lt r)\n  | none,   some y => isTrue  trivial\n  | some x, some y => s x y\n  | some x, none   => isFalse not_false\n  | none,   none   => isFalse not_false\n\nend Option\n\nderiving instance DecidableEq for Option\nderiving instance BEq for Option\n\ninstance [LT \u03b1] : LT (Option \u03b1) where\n  lt := Option.lt (\u00b7 < \u00b7)\n", "meta": {"author": "Kha", "repo": "lean4-nightly", "sha": "b4c92de57090e6c47b29d3575df53d86fce52752", "save_path": "github-repos/lean/Kha-lean4-nightly", "path": "github-repos/lean/Kha-lean4-nightly/lean4-nightly-b4c92de57090e6c47b29d3575df53d86fce52752/stage0/src/Init/Data/Option/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5195213219520929, "lm_q2_score": 0.47268347662043286, "lm_q1q2_score": 0.24556914463875848}}
{"text": "/- Provides simplification lemmas for applicative laws. -/\n\nuniverse variables u\n\n@[simp]\nlemma fmap_pure {m : Type u \u2192 Type u} [hm : applicative m] {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) (v : \u03b1) :\n  f <$> (pure v : m \u03b1) = 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 tidy.command.rfl_lemma\n\n-- structure metype (A B : Type) :=\n-- (v : \u2115)\n\n-- structure a_dummy (C D : Type) :=\n-- (map'      : \u03a0 {X Y : Type}, (C \u2192 X \u2192 Y) \u2192 metype C D)\n\n-- def a_dummy.map {C D : Type} (F : a_dummy C D) {X Y : Type} (f : C \u2192 X \u2192 Y) : metype C D := F.map' f\n\n-- def lol (E F : Type) [has_lt \u2115] : a_dummy F E :=\n-- { map' := \u03bb X Y, \u03bb f, \u27e8F, E, 42\u27e9 }.\n\n-- -- We'd like one of these please:\n-- @[simp] lemma lol_map2\n--   (E F : Type) [has_lt \u2115] {X Y : Type} (f : F \u2192 X \u2192 Y) :\n--   (lol E F).map f = \u27e8F, E, 42\u27e9 := rfl.\n\n\n\n-- -- Try `rfl_lemma` + `?`, trace version, both private and public mode\n-- namespace eg1\n-- private rfl_lemma? lol map\n\n-- #check lol_map\n-- end eg1\n\n-- namespace eg2\n-- rfl_lemma? lol map\n\n-- #check lol_map\n-- end eg2\n\n-- -- Try `rfl_lemma` vanilla version, both private and public mode\n-- namespace eg3\n-- private rfl_lemma lol map\n\n-- #check lol_map\n-- end eg3\n\n-- namespace eg4\n-- rfl_lemma lol map\n\n-- #check lol_map\n-- end eg4", "meta": {"author": "semorrison", "repo": "lean-tidy", "sha": "6c1d46de6cff05e1c2c4c9692af812bca3e13b6c", "save_path": "github-repos/lean/semorrison-lean-tidy", "path": "github-repos/lean/semorrison-lean-tidy/lean-tidy-6c1d46de6cff05e1c2c4c9692af812bca3e13b6c/test/rfl_lemma.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5506073655352404, "lm_q2_score": 0.44552953503957266, "lm_q1q2_score": 0.24531184355627966}}
{"text": "import data.rat.defs\nimport data.fintype.card\nimport data.polynomial.eval\nimport algebra.group.basic\nimport algebra.algebra.basic\nimport algebra.big_operators.intervals\nimport ring_theory.algebraic\nimport ring_theory.int.basic\n\n-- This code is a perfect example of how *NOT* to use Lean\n-- There are some `sorry`s because I attempted to refactor my old code\n-- to make it more idiomatic, but I just gave up halfway...\n\nnamespace rat\ntheorem pow_num_denom (q : \u211a) (n : \u2115) : q ^ n = rat.mk (q.num ^ n) (\u2191q.denom ^ n) :=\nsorry\n\ntheorem div_mk_div_cancel_right {a b c : \u2124} (c0 : c \u2260 0) :\n  rat.mk (c * a) (c * b) = rat.mk a b :=\nby rw [mul_comm c a, mul_comm c b, rat.div_mk_div_cancel_left c0]\n\ntheorem sum_same_denom {n : \u2115} {num : fin (n + 1) \u2192 \u2124} {denom : \u2124} :\n  finset.univ.sum (\u03bb x : fin (n + 1), rat.mk (num x) denom) =\n  rat.mk (finset.univ.sum (\u03bb x : fin (n + 1), num x)) denom := by {\n  induction n with i hi,\n    repeat {rw fin.sum_univ_one},\n  repeat {rw @fin.sum_univ_succ _ _ i.succ _},\n  repeat {rw rat.add_mk},\n  congr,\n  apply hi, \n}\nend rat\n\n-- The ring of integers of \u211a is \u2124\ntheorem int_of_algebraic_rat (r : \u211a) (hr : is_integral \u2124 r) : r.denom = 1 :=\nbegin\n  obtain \u27e8p, hp1, hp2\u27e9 := hr,\n  set n := p.nat_degree with hn,\n  set P := r.num with hP,\n  set Q : \u2124 := \u2191r.denom with hQ,\n\n  by_cases p.nat_degree = 0,\n  { rw [polynomial.eq_C_of_nat_degree_eq_zero h,\n      polynomial.eval\u2082_C,\n      algebra_map_int_eq,\n      ring_hom.eq_int_cast,\n      rat.coe_int_eq_mk,\n      rat.mk_eq_zero one_ne_zero,\n      \u2190h,\n      polynomial.monic.coeff_nat_degree hp1]\n      at hp2,\n    exact false.elim (one_ne_zero hp2) },\n\n  have Qpow : \u2200 n : \u2115, Q ^ n \u2260 0 := sorry,\n  rw [polynomial.eval\u2082_eq_sum,\n    polynomial.sum_over_range, -- generates an intermediate goal...\n    \u2190fin.sum_univ_eq_sum_range]\n    at hp2,\n  simp_rw [algebra_map_int_eq,\n    ring_hom.eq_int_cast,\n    rat.coe_int_eq_mk,\n    rat.pow_num_denom,\n    rat.mul_def one_ne_zero $ Qpow _,\n    one_mul,\n    rat.mk_eq_div] at hp2,\n\n  swap, -- ...which we immediately handle\n  { intro n, simp },\n  \n  have : (\u03bb x : fin (n + 1), ((p.coeff (x : \u2115) * P ^ \u2191x) / Q ^ (x : \u2115))) =\n    (\u03bb x : fin (n + 1), ((p.coeff (x : \u2115) * P ^ (x : \u2115) * Q ^ (n -(x : \u2115))) / Q ^ n : \u211a)) := by {\n    funext,\n    calc ((p.coeff \u2191x * P ^ \u2191x) / Q ^ \u2191x : \u211a)\n      = ((p.coeff \u2191x * P ^ \u2191x * Q ^ (n-\u2191x)) / (Q ^ \u2191x * Q ^ (n-\u2191x)) : \u211a) : sorry\n    ... = ((p.coeff \u2191x * P ^ \u2191x * Q ^ (n-\u2191x)) / Q ^ n : \u211a) : sorry,\n  },\n\n  -- Tedious rewriting lemmas\n  have h1 : \u2200 x : \u2115, x \u2264 n \u2192 rat.mk (P ^ x) (Q ^ x) =\n    rat.mk (Q ^ (n - x) * P ^ x) (Q ^ n) := by {\n    intros x hx,\n    calc rat.mk (P ^ x) (Q ^ x)\n      = rat.mk (Q ^ (n - x) * P ^ x) (Q ^ (n - x) * Q ^ x) :\n        rat.mk_mul_num_and_denom (Qpow x) (Qpow (n - x))\n    ... = rat.mk (Q ^ (n - x) * P ^ x) (Q ^ n) : by rw [\u2190pow_add, nat.sub_add_cancel hx]\n  },\n  \n  have h2 : (\u03bb x : fin (n + 1), rat.mk (p.coeff \u2191x) 1 * rat.mk (P ^ \u2191x) (Q ^ \u2191x)) =\n    (\u03bb x : fin (n + 1), rat.mk (p.coeff \u2191x * Q ^ (n - \u2191x) * P ^ \u2191x) (Q ^ n)) := by {\n    funext,\n    rw [h1 x $ nat.le_of_lt_succ x.is_lt,\n      rat.mul_def one_ne_zero (Qpow n),\n      \u2190mul_assoc, one_mul]\n  },\n\n  rw [h2,\n    rat.sum_same_denom,\n    rat.mk_eq_zero $ Qpow n,\n  -- Just to extract one term out...\n    fin.sum_univ_eq_sum_range (\u03bb x : \u2115, p.coeff x * Q ^ (n - x) * P ^ x) (n + 1),\n    eq_add_of_sub_eq $ finset.sum_range_succ_sub_top _,\n    \u2190fin.sum_univ_eq_sum_range (\u03bb x : \u2115, p.coeff x * Q ^ (n - x) * P ^ x) n]\n    at hp2,\n  dsimp at hp2,\n  clear h1 h2,\n  \n  have h3 : (\u03bb x : fin n, (p.coeff (\u2191x : \u2115)) * Q ^ (n - (\u2191x : \u2115)) * P ^ (\u2191x : \u2115)) =\n    (\u03bb x : fin n, Q * ((p.coeff (\u2191x : \u2115)) * Q ^ (n - (\u2191x : \u2115) - 1) * P ^ (\u2191x : \u2115))) := by {\n    funext,\n    have : Q ^ (n - \u2191x) = Q * Q ^ (n - \u2191x - 1) :=\n      calc Q ^ (n - \u2191x) = Q ^ (n - \u2191x).pred.succ : by rw nat.succ_pred_eq_of_pos (nat.sub_pos_of_lt x.is_lt)\n      ... = Q * Q ^ (n - \u2191x - 1) : by rw [pow_succ, nat.pred_eq_sub_one],\n    -- idk why `ring` tactic hangs\n    rw [this, \u2190mul_assoc (p.coeff \u2191x) _ _, mul_comm (p.coeff \u2191x) Q,\n      mul_assoc Q _ _, mul_assoc Q _ _]\n  },\n\n  rw [h3, \u2190finset.mul_sum, polynomial.monic.leading_coeff hp1,\n    one_mul, nat.sub_self, pow_zero, one_mul] at hp2,\n  clear h3,\n\n  obtain \u27e8a, b, hab\u27e9 := (is_coprime.pow_left_iff $ nat.pos_of_ne_zero h).mpr\n    ((@int.coprime_iff_nat_coprime P Q).mpr r.cop),\n  replace hp2 := congr_arg (\u03bb x : \u2124, a * x) hp2,\n  dsimp at hp2,\n  rw [mul_add, mul_zero] at hp2,\n\n  rw \u2190eq_sub_iff_add_eq at hab,\n  rw [hab, int.sub_eq_add_neg, add_comm, add_assoc, add_eq_zero_iff_eq_neg,\n    \u2190mul_assoc, mul_comm b Q, mul_comm a Q, mul_assoc Q a _,\n    neg_mul_eq_mul_neg, \u2190mul_add, neg_mul_eq_mul_neg]\n    at hp2,\n  clear hab,\n\n  rw [\u2190int.nat_abs_of_nat r.denom,\n    int.eq_one_of_dvd_one (le_of_lt $ int.pos_of_pos_nat r.pos) \u27e8_, hp2\u27e9,\n    int.nat_abs_one],\nend", "meta": {"author": "greysome", "repo": "lean-practice", "sha": "00729df4b18a2538cd3f63f68ab9c59308e3a6c2", "save_path": "github-repos/lean/greysome-lean-practice", "path": "github-repos/lean/greysome-lean-practice/lean-practice-00729df4b18a2538cd3f63f68ab9c59308e3a6c2/src/new/algintrat.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6370308082623217, "lm_q2_score": 0.3849121444839335, "lm_q1q2_score": 0.24520089451058372}}
{"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\u2081 C\u2082 C\u2083 D\u2081 D\u2082 D\u2083 : Type*} [category C\u2081] [category C\u2082]\n  [category C\u2083] [category D\u2081] [category D\u2082] [category D\u2083]\n  {P\u2081 : C\u2081 \u2964 D\u2081} {P\u2082 : C\u2082 \u2964 D\u2082} {P\u2083 : C\u2083 \u2964 D\u2083}\n  {A : C\u2081 \u2964 C\u2082} {B : D\u2081 \u2964 D\u2082} {A' : C\u2082 \u2964 C\u2083} {B' : D\u2082 \u2964 D\u2083}\n  (\u03c4 : P\u2081 \u22d9 B \u27f6 A \u22d9 P\u2082) (\u03c4' : P\u2082 \u22d9 B' \u27f6 A' \u22d9 P\u2083) (Y : D\u2081)\n\n@[simps]\ndef whisker :\n  structured_arrow Y P\u2081 \u2964 structured_arrow (B.obj Y) P\u2082 :=\n{ obj := \u03bb X, structured_arrow.mk (B.map X.hom \u226b \u03c4.app X.right),\n  map := \u03bb X X' f, structured_arrow.hom_mk (A.map f.right) begin\n    dsimp,\n    simp only [\u2190 structured_arrow.w f, category.assoc, B.map_comp],\n    erw \u03c4.naturality,\n    refl,\n  end, }\n\n-- unnecessary\n@[simps]\ndef whisker_comp_iso\n  (\u03c4'' : P\u2081 \u22d9 (B \u22d9 B') \u27f6 (A \u22d9 A') \u22d9 P\u2083)\n  (h\u03c4 : \u03c4'' = (functor.associator P\u2081 B B').inv \u226b whisker_right \u03c4 B' \u226b\n    (functor.associator A P\u2082 B').hom \u226b whisker_left A \u03c4' \u226b (functor.associator A A' P\u2083).inv) :\n  whisker \u03c4 Y \u22d9 whisker \u03c4' (B.obj Y) \u2245\n    whisker \u03c4'' Y :=\nnat_iso.of_components (\u03bb X, structured_arrow.iso_mk (iso.refl _) begin\n  dsimp,\n  simp only [h\u03c4, 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 \u03c4] : full (whisker \u03c4 Y) :=\nfunctor.full_of_surjective _ (\u03bb X\u2081 X\u2082 f, begin\n  refine \u27e8structured_arrow.hom_mk (A.preimage f.right) (B.map_injective _), _\u27e9,\n  { have eq := structured_arrow.w f,\n    dsimp at eq,\n    erw [B.map_comp, \u2190 cancel_mono (\u03c4.app X\u2082.right), \u2190 eq, assoc, assoc, \u03c4.naturality],\n    dsimp,\n    simp only [functor.image_preimage], },\n  { ext,\n    dsimp,\n    simp, },\nend)\n\ninstance faithful_whisker [faithful A] : faithful (whisker \u03c4 Y) :=\n\u27e8\u03bb X\u2081 X\u2082 f\u2081 f\u2082 hf, begin\n  ext,\n  exact A.map_injective ((structured_arrow.proj _ _).congr_map hf),\nend\u27e9\n\ninstance ess_surj [ess_surj A] [full B] [is_iso \u03c4] : ess_surj (whisker \u03c4 Y) :=\n\u27e8\u03bb X, \u27e8structured_arrow.mk (B.preimage (X.hom \u226b\n  P\u2082.map (A.obj_obj_preimage_iso X.right).inv \u226b (inv \u03c4).app _)),\n  \u27e8structured_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      \u2190 P\u2082.map_comp, iso.inv_hom_id, P\u2082.map_id],\n  end\u27e9\u27e9\u27e9\n\ninstance is_equivalence_whisker\n  [is_iso \u03c4] [is_equivalence A] [full B] [faithful B] : is_equivalence (whisker \u03c4 Y) :=\nbegin\n  haveI : ess_surj A := -- `ess_surj_of_is_equivalence` should be an instance\n    \u27e8\u03bb X, \u27e8(is_equivalence.inverse A).obj X, \u27e8is_equivalence.counit_iso.app X\u27e9\u27e9\u27e9,\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 \u2964 D} (RF : H \u2964 D) {L : C \u2964 H} (\u03b1 : F \u27f6 L \u22d9 RF) (e : D \u224c D')\n  (W : morphism_property C) [L.is_localization W]\n\nlemma of_equivalence_comp_right [RF.is_right_derived_functor \u03b1]\n  (\u03b2 : F \u22d9 e.functor \u27f6 L \u22d9 RF \u22d9 e.functor)\n  (h\u03b2 : \u03b2 = whisker_right \u03b1 e.functor \u226b (functor.associator _ _ _).hom) :\n  (RF \u22d9 e.functor).is_right_derived_functor \u03b2 :=\nbegin\n  let e' : (whiskering_left C H D).obj L \u22d9 (whiskering_right C D D').obj e.functor \u2245\n    (whiskering_right H D D').obj e.functor \u22d9 (whiskering_left C H D').obj L :=\n    nat_iso.of_components (\u03bb X, iso.refl _) (by tidy),\n  exact \u27e8\u27e8limits.is_initial.of_iso (limits.is_initial.is_initial_obj (structured_arrow.whisker e'.hom F) (structured_arrow.mk \u03b1)\n    (is_right_derived_functor.is_initial \u03b1).some)\n    (structured_arrow.iso_mk (iso.refl _) (by { rw h\u03b2, tidy, }))\u27e9\u27e9,\nend\n\ninstance of_equivalence_comp_right' [RF.is_right_derived_functor \u03b1] (G : D \u2964 D')\n  [is_equivalence G] :\n  (RF \u22d9 G).is_right_derived_functor (whisker_right \u03b1 G \u226b (functor.associator _ _ _).hom) :=\nof_equivalence_comp_right RF \u03b1 (as_equivalence G) _ rfl\n\ninstance has_right_derived_functor_equivalence_comp_right (G : D \u2964 D')\n  [is_equivalence G] [F.has_right_derived_functor W] :\n  (F \u22d9 G).has_right_derived_functor W :=\nis_right_derived_functor.has_right_derived_functor (F \u22d9 G)\n  (F.right_derived_functor W.Q W \u22d9 G) W.Q\n  (whisker_right (F.right_derived_functor_\u03b1 W.Q W) G \u226b (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' \u2964 D} (RF' : H' \u2964 D) {L' : C' \u2964 H'} (\u03b1' : F' \u27f6 L' \u22d9 RF') {L : C \u2964 H}\n  {G : C \u2964 C'} {G' : H \u2964 H'} (e : G \u22d9 L' \u2245 L \u22d9 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 \u03b1']\n  (\u03b1 : G \u22d9 F' \u27f6 L \u22d9 (G' \u22d9 RF'))\n  (h\u03b1 : \u03b1 = whisker_left G \u03b1' \u226b (functor.associator _ _ _).inv \u226b\n      whisker_right e.hom RF' \u226b (functor.associator _ _ _).hom) :\n  (G' \u22d9 RF').is_right_derived_functor \u03b1 :=\nbegin\n  let e' : (whiskering_left C' H' D).obj L' \u22d9 (whiskering_left C C' D).obj G \u2245\n    (whiskering_left H H' D).obj G' \u22d9 (whiskering_left C H D).obj L :=\n    nat_iso.of_components (\u03bb X, iso_whisker_right e X) (by tidy),\n  exact \u27e8\u27e8limits.is_initial.of_iso (limits.is_initial.is_initial_obj\n    (structured_arrow.whisker e'.hom F') (structured_arrow.mk \u03b1')\n    (is_right_derived_functor.is_initial \u03b1').some) (structured_arrow.iso_mk (iso.refl _)\n    (by { rw h\u03b1, tidy, }))\u27e9\u27e9,\nend\n\ninstance of_equivalence_comp_left' [RF'.is_right_derived_functor \u03b1'] :\n  (G' \u22d9 RF').is_right_derived_functor (whisker_left G \u03b1' \u226b (functor.associator _ _ _).inv \u226b\n      whisker_right e.hom RF' \u226b (functor.associator _ _ _).hom) :=\nof_equivalence_comp_left RF' \u03b1' e _ rfl\n\nlemma _root_.category_theory.functor.has_right_derived_functor_equivalence_comp_right\n  [F'.has_right_derived_functor W'] :\n  (G \u22d9 F').has_right_derived_functor W :=\nis_right_derived_functor.has_right_derived_functor (G \u22d9 F') _ _\n    ((whisker_left G (F'.right_derived_functor_\u03b1 L' W') \u226b (functor.associator _ _ _).inv \u226b\n    whisker_right e.hom _ \u226b (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": "/-\nCopyright (c) 2019 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Y. Lewis\n-/\nimport data.set\nimport algebra.category.Mon.basic\n\n@[derive has_coe_to_sort] def X : Type := set \u2115\n\n@[derive ring] def T := \u2124\n\nclass binclass (T1 T2 : Type)\n\ninstance : binclass \u2124 \u2124 := \u27e8\u27e9\n\n@[derive [ring, binclass \u2124]] def U := \u2124\n\n@[derive \u03bb \u03b1, binclass \u03b1 \u2124] def V := \u2124\n\n-- test instance naming\nexample := U.ring\nexample := U.binclass\nexample := V.binclass\n\n@[derive ring] def id_ring (\u03b1) [ring \u03b1] : Type := \u03b1\n\n@[derive decidable_eq] def S := \u2115\n\n@[derive decidable_eq] inductive P | a | b | c\n\nopen category_theory\n\n-- Test that `delta_instance` works in the presence of universe metavariables.\nattribute [derive large_category] Mon\n\n-- test deriving instances on function types\n@[derive monad]\nmeta def my_tactic : Type \u2192 Type :=\ntactic\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/delta_instance.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.66192288918838, "lm_q2_score": 0.3702253786982541, "lm_q1q2_score": 0.2450606523188105}}
{"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 (\u03b1 : Type*) := (jump : \u03b1 \u2192 \u03b1)\n\npostfix `\u207a`:(max+1) := has_jump.jump\n\ntheorem equivalence_of_t_reducible_equiv (\u03b1) [primcodable \u03b1] :\n  equivalence (@t_reducible_equiv \u03b1 \u03b1 _ _) :=\n\u27e8\u03bb x, t_reducible_equiv.refl x,\n \u03bb _ _, t_reducible_equiv.symm,\n \u03bb _ _ _, t_reducible_equiv.trans\u27e9\n\ndef turing_degree : Type :=\nquotient (\u27e8t_reducible_equiv, equivalence_of_t_reducible_equiv \u2115\u27e9 : setoid (set \u2115))\n\nnotation `\ud835\udc03` := turing_degree\n\nnamespace turing_degree\n\ndef deg (A : set \u2115) : \ud835\udc03 := quotient.mk' A\n\n@[elab_as_eliminator]\nprotected lemma ind_on {C : \ud835\udc03 \u2192 Prop} (d : \ud835\udc03)\n  (h : \u2200 p : set \u2115, C (deg p)) : C d :=\nquotient.induction_on' d h\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on {\u03c6} (d : \ud835\udc03) (f : set \u2115 \u2192 \u03c6)\n  (h : \u2200 p q, p \u2261\u209c q \u2192 f p = f q) : \u03c6 :=\nquotient.lift_on' d f h\n\n@[simp]\nprotected lemma lift_on_eq {\u03c6} (p : set \u2115) (f : set \u2115 \u2192 \u03c6)\n  (h : \u2200 p q, t_reducible_equiv p q \u2192 f p = f q) : (deg p).lift_on f h = f p :=\nrfl\n\n@[elab_as_eliminator, reducible, simp]\nprotected def lift_on\u2082 {\u03c6} (d\u2081 d\u2082 : \ud835\udc03) (f : set \u2115 \u2192 set \u2115 \u2192 \u03c6)\n  (h : \u2200 p\u2081 p\u2082 q\u2081 q\u2082, p\u2081 \u2261\u209c q\u2081 \u2192 p\u2082 \u2261\u209c q\u2082 \u2192 f p\u2081 p\u2082 = f q\u2081 q\u2082) : \u03c6 :=\nquotient.lift_on\u2082' d\u2081 d\u2082 f h\n\n@[simp]\nprotected lemma lift_on\u2082_eq {\u03c6} (p q : set \u2115) (f : set \u2115 \u2192 set \u2115 \u2192 \u03c6)\n  (h : \u2200 p\u2081 p\u2082 q\u2081 q\u2082, p\u2081 \u2261\u209c q\u2081 \u2192 p\u2082 \u2261\u209c q\u2082 \u2192 f p\u2081 p\u2082 = f q\u2081 q\u2082) :\n  (deg p).lift_on\u2082 (deg q) f h = f p q := rfl\n\n@[simp] lemma of_eq_of {p q} : deg p = deg q \u2194 p \u2261\u209c q :=\nby simp [deg, quotient.eq']\n\ninstance : has_le \ud835\udc03 :=\n\u27e8\u03bb d\u2081 d\u2082, turing_degree.lift_on\u2082 d\u2081 d\u2082 (\u2264\u209c) $\n \u03bb p\u2081 p\u2082 q\u2081 q\u2082 hp hq, propext \n \u27e8\u03bb hpq, (hp.2.trans hpq).trans hq.1, \u03bb hpq, (hp.1.trans hpq).trans hq.2\u27e9\u27e9\n\n@[simp] lemma of_le_of {A B} : deg A \u2264 deg B \u2194 A \u2264\u209c B := by refl\n\ninstance : semilattice_sup_bot \ud835\udc03 :=\n{ le := (\u2264),\n  sup := \u03bb a b, turing_degree.lift_on\u2082 a b (\u03bb A B, deg (Join\u2082 A B)) (\u03bb A\u2081 B\u2081 A\u2082 B\u2082 hA hB,\n   by { simp, split,\n        { have lmm\u2081 : A\u2081 \u2264\u209c Join\u2082 A\u2082 B\u2082, from hA.1.trans (le_Join\u2082_left _ _).to_turing,\n          have lmm\u2082 : B\u2081 \u2264\u209c Join\u2082 A\u2082 B\u2082, from hB.1.trans (le_Join\u2082_right _ _).to_turing,\n          refine Join\u2082_le A\u2081 B\u2081 _ lmm\u2081 lmm\u2082 },\n        { have lmm\u2081 : A\u2082 \u2264\u209c Join\u2082 A\u2081 B\u2081, from hA.2.trans (le_Join\u2082_left _ _).to_turing,\n          have lmm\u2082 : B\u2082 \u2264\u209c Join\u2082 A\u2081 B\u2081, from hB.2.trans (le_Join\u2082_right _ _).to_turing,\n          refine Join\u2082_le A\u2082 B\u2082 _ lmm\u2081 lmm\u2082 } }),\n  bot := deg \u2205,\n  le_refl := \u03bb d, by induction d using turing_degree.ind_on; simp,\n  le_trans := \u03bb 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 := \u03bb 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 := \u03bb 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\u2082_left _ _).to_turing },\n  le_sup_right := \u03bb 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\u2082_right _ _).to_turing },\n  sup_le := \u03bb 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\u2082_le a b c },\n  bot_le := \u03bb a, by { induction a using turing_degree.ind_on, simp, exact computable_le _ computable_0 } }\n\nlemma of_sup_of {A B} : deg A \u2294 deg B = deg (Join\u2082 A B) := rfl\n\ninstance : inhabited \ud835\udc03 := \u27e8\u22a5\u27e9\n\ndef djump : \ud835\udc03 \u2192 \ud835\udc03 :=\n\u03bb d, turing_degree.lift_on d (\u03bb d, deg d\u2032)\n(\u03bb A B \u27e8ab, ba\u27e9, by { simp, exact \n \u27e8(le_le_Jump ab).to_many_one.to_turing, (le_le_Jump ba).to_many_one.to_turing\u27e9 })\n\ninstance : has_jump \ud835\udc03 := \u27e8djump\u27e9\n\ndef djump_itr (d : \ud835\udc03) : \u2115 \u2192 \ud835\udc03\n| 0     := d\n| (n+1) := (djump_itr n)\u207a\n\n@[simp] lemma of_jump {A} : (deg A)\u207a = deg A\u2032 := rfl\n\ndef re_degree := {d // \u2203 R : set \u2115, r.e. R \u2227 d = deg R}\n\nnotation `\ud835\udc11` := re_degree\n\ninstance : has_coe \ud835\udc11 \ud835\udc03 := \u27e8subtype.val\u27e9\n\ninstance : semilattice_sup_bot \ud835\udc11 :=\n  { le := \u03bb a b, (a : \ud835\udc03) \u2264 (b : \ud835\udc03),\n    sup := \u03bb a b, \u27e8(a : \ud835\udc03) \u2294 (b : \ud835\udc03),\n      by { rcases a with \u27e8a, A, reA, rfl\u27e9, rcases b with \u27e8b, B, reB, rfl\u27e9,\n           refine \u27e8Join\u2082 A B, re_Join_of_re_re reA reB, by simp[of_sup_of]\u27e9 }\u27e9,\n    bot := \u27e8\u22a5, \u2205, re_pred_0, rfl\u27e9,\n    le_refl := by simp,\n    le_trans := \u03bb \u27e8a, _\u27e9 \u27e8b, _\u27e9 \u27e8c, _\u27e9, by {simp, exact le_trans },\n    le_antisymm := \u03bb \u27e8a, _\u27e9 \u27e8b, _\u27e9, by { simp, exact le_antisymm },\n    bot_le := \u03bb \u27e8a, _\u27e9, by simp,\n    le_sup_left := \u03bb \u27e8a, _\u27e9 \u27e8b, _\u27e9, by simp,\n    le_sup_right := \u03bb \u27e8a, _\u27e9 \u27e8b, _\u27e9, by simp,\n    sup_le := \u03bb \u27e8a, _\u27e9 \u27e8b, _\u27e9 \u27e8c, _\u27e9, by { simp[-sup_le_iff], exact sup_le } }\n\ninstance : semilattice_sup_top \ud835\udc11 :=\n  { top := \u27e8\u22a5\u207a, (\u2205 : set \u2115)\u2032, re_pred_Jump_0, rfl\u27e9,\n    le_top := \u03bb \u27e8a, R, reR, rfl\u27e9, by { simp[has_top.top, show \u22a5\u207a = deg \u2205\u2032, by refl],\n    exact (re_many_one_reducible_to_0'.mp reR).to_turing },\n    ..re_degree.semilattice_sup_bot }\n\ndef High := {d : \ud835\udc11 | (d : \ud835\udc03)\u207a = \u22a5\u207a\u207a}\n\ndef Low  := {d : \ud835\udc11 | (d : \ud835\udc03)\u207a = \u22a5\u207a}\n\n@[simp] lemma of_lt_of {A B} : deg A < deg B \u2194 A <\u209c B := by refl\n\ntheorem lt_djump (d : \ud835\udc03) : d < d\u207a :=\nby { induction d using turing_degree.ind_on, simp,\n     exact lt_Jump _ } \n\ntheorem djump_neq (d : \ud835\udc03) : d \u2260 d\u207a := \u03bb h,\nby { have : d\u207a \u2264 d, rw \u2190h,\n     exact (lt_djump d).2 this }\n\ninstance : nontrivial \ud835\udc03 := \u27e8\u27e8\u22a5, \u22a5\u207a, djump_neq \u22a5\u27e9\u27e9\n\nlemma jump_order_preserving (a b : \ud835\udc03) (le : a \u2264 b) : a\u207a \u2264 b\u207a :=\nby { induction a using turing_degree.ind_on,\n     induction b using turing_degree.ind_on,\n     simp at le \u22a2, exact (le_le_Jump le).to_turing }\n\ntheorem friedberg_muchnik : \u2203 a b : \ud835\udc11, \u00aca \u2264 b \u2227 \u00acb \u2264 a :=\nby rcases friedberg_muchnik.incomparable_re_sets with \u27e8I\u2080, I\u2081, re\u2080, re\u2081, nle\u2080, nle\u2081\u27e9;\n   refine \u27e8\u27e8deg I\u2080, I\u2080, re\u2080, rfl\u27e9, \u27e8deg I\u2081, I\u2081, re\u2081, rfl\u27e9, nle\u2081, nle\u2080\u27e9\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( \u03b1 : Type )\n( \u03b2 : \u03b1 \u2192 Type )\n\nvariable (P : PFunctor)\n\nnamespace PFunctor\n\ndef obj (X : Type) : Type :=\n\u03a3 (a : P.\u03b1), P.\u03b2 a \u2192 X\n\ndef map {X Y : Type} (f : X \u2192 Y) (x : P.obj X) : P.obj Y :=\n\u27e8x.1, \u03bb a => f (x.2 a)\u27e9\n\ninductive Z (P : PFunctor) : Type\n| bud : Z P\n| some (a : P.\u03b1) (f : P.\u03b2 a \u2192 Z P) : Z P\n\nvariable {P}\n\ndef of_\u03b1 (a : P.\u03b1) : Z P :=\nZ.some a (\u03bb _ => Z.bud)\n\ninductive bud : Z P \u2192 Type\n| bud : bud (@Z.bud P)\n| some {a : P.\u03b1} {f : P.\u03b2 a \u2192 Z P} {p : P.\u03b2 a} (b : bud (f p)) : \n    bud (Z.some a f)\n\ninductive is_extension : Z P \u2192 Z P \u2192 Prop\n| bud (z : Z P) : is_extension Z.bud z\n| some {a : P.\u03b1} {f\u2081 f\u2082 : P.\u03b2 a \u2192 Z P} (h : \u2200 p : P.\u03b2 a, is_extension (f\u2081 p) (f\u2082 p)) :\n  is_extension (Z.some a f\u2081) (Z.some a f\u2082)\n\ntheorem is_extension.refl : (z : Z P) \u2192 is_extension z z\n| Z.bud => is_extension.bud _\n| Z.some _ _ => is_extension.some (\u03bb _ => is_extension.refl _)\n\ninductive extends_at {P : PFunctor}: (z\u2081 : Z P) \u2192 (b : bud z) \u2192 Z P \u2192 Type\n| bud {a : P.\u03b1} {f : P.\u03b2 a \u2192 Z P} : extends_at (@Z.bud P) (@bud.bud P) (Z.some a f)\n| some {a : P.\u03b1} {f\u2081 f\u2082 : P.\u03b2 a \u2192 Z P} {p : P.\u03b2 a} (b : bud (f\u2081 p)) \n  (h : extends_at (f\u2081 p) b (f\u2082 p)) :  \n    extends_at (Z.some a f\u2081) (bud.some b) (Z.some a f\u2082)\n\nstructure M' (P : PFunctor) : Type :=\n( s : Z P \u2192 Prop )\n( bud_mem : s Z.bud )\n( extension_pair {z\u2081 z\u2082 : Z P} : s z\u2081 \u2192 s z\u2082 \u2192 \n  \u2203 z\u2083 : Z P, s z\u2083 \u2227 is_extension z\u2081 z\u2083 \u2227 is_extension z\u2082 z\u2083 )\n( extend {z : Z P} : s z \u2192 bud z \u2192 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.\u03b1 :=\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.\u03b2 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, _ => \u27e8a, \u03bb p => \n  { s := \u03bb z => z = Z.bud \u2228 \u2203 f : P.\u03b2 a \u2192 Z P, m.s (Z.some a f) \u2227 z = f p,\n    bud_mem := Or.inl rfl,\n    extension_pair := @\u03bb z\u2081 z\u2082 hz\u2081 hz\u2082 => \n      match z\u2081, z\u2082, hz\u2081, hz\u2082 with \n      | _, z\u2082, Or.inl rfl, hz\u2082 => \n        \u27e8z\u2082, hz\u2082, is_extension.bud _, is_extension.refl _\u27e9\n      | z\u2081, _, hz\u2081, Or.inl rfl => \n        \u27e8z\u2081, hz\u2081, is_extension.refl _, is_extension.bud _\u27e9\n      | _, _, Or.inr \u27e8f\u2081, hf\u2081, rfl\u27e9, Or.inr \u27e8f\u2082, hf\u2082, rfl\u27e9 => \n        match m.extension_pair hf\u2081 hf\u2082 with\n        | \u27e8Z.some _ f, h\u2081, is_extension.some h\u2082, is_extension.some h\u2083\u27e9 => \n          \u27e8f p, Or.inr \u27e8f, h\u2081, rfl\u27e9, h\u2082 p, h\u2083 p\u27e9,\n    extend := @\u03bb 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       }\u27e9\n\n-- def M'.rel (m\u2081 m\u2082 : M' P) : Prop :=\n-- \u2203 m\u2083 : M' P, (\u2200 z, m\u2081.s z \u2192 m\u2083.s z) \u2227 (\u2200 z, m\u2082.s z \u2192 m\u2083.s z)\n\n-- def M'.rel.refl (m : M' P) : M'.rel m m :=\n-- \u27e8m, \u03bb _ => id, \u03bb _ => id\u27e9\n\n-- def M'.rel.symm {m\u2081 m\u2082 : M' P} : M'.rel m\u2081 m\u2082 \u2192 M'.rel m\u2082 m\u2081 \n-- | \u27e8m\u2083, h\u2081, h\u2082\u27e9 => \u27e8m\u2083, h\u2082, h\u2081\u27e9\n\n-- def M'.rel.trans {m\u2081 m\u2082 m\u2083 : M' P} : M'.rel m\u2081 m\u2082 \u2192 M'.rel m\u2082 m\u2083 \u2192 M'.rel m\u2081 m\u2083\n-- | \u27e8n, hn\u2081, hn\u2082\u27e9, \u27e8o, ho\u2081, ho\u2082\u27e9 => \n--   \u27e8{ s := \u03bb z => n.s z \u2228 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 \u2192 Prop\naxiom Q : Scheme \u2192 Prop\naxiom R : Scheme \u2192 Prop\naxiom S : Scheme \u2192 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 \u2192 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 tactic.basic\nimport tactic.ext\nimport data.set.basic\n\nmeta def my_tactic : tactic unit := `[exact 7, refl]\nexample : \u2203 (n : \u2115), n = 7 :=\nbegin\n    split,\n    swap,\n    my_tactic,\nend\n\nmeta def my_tactic_5 : tactic unit :=\ndo `[induction a],\n    tactic.reflexivity,\n    `[simpa]\n\n", "meta": {"author": "MartinSkilleter", "repo": "real_ip_spaces", "sha": "1ad1e0456602038711cbb0de7aa92b88d6eff06f", "save_path": "github-repos/lean/MartinSkilleter-real_ip_spaces", "path": "github-repos/lean/MartinSkilleter-real_ip_spaces/real_ip_spaces-1ad1e0456602038711cbb0de7aa92b88d6eff06f/src/Writing Tactics.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.4263215925474903, "lm_q1q2_score": 0.24457149227526195}}
{"text": "import data.complex.exponential\nimport analysis.special_functions.trigonometric.basic\n\ntheorem AMC_2021_A_19 (s:finset \u211d)\n(h:\u2200(x:\u211d), x\u2208s \u2194 real.sin ((real.pi/2)*real.cos x)=real.cos ((real.pi/2)*real.sin x)):\nfinset.card s = 2\n:=\nbegin\n  sorry\nend", "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/AMC_2021_A_19.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5736783928749127, "lm_q2_score": 0.42632159254749036, "lm_q1q2_score": 0.24457148606051765}}
{"text": "import data.list.alist\nimport .presheaf2\n\nnamespace o_minimal\n\nvariables {R : Type*} {S : struc R}\n\nstructure sect (\u0393 : Def S) (X : Type*) [definable_psh S X] :=\n(to_fun : \u0393 \u2192 X)\n(definable : definable_psh.definable to_fun)\n\ninfixr ` \u22a2 `:10 := sect\n\ndef sect.precomp {\u0393' \u0393 : Def S} {X : Type*} [definable_psh S X]\n  (\u03c3 : \u0393 \u22a2 X) (\u03c6 : Hom \u0393' \u0393) : \u0393' \u22a2 X :=\n{ to_fun := \u03c3.to_fun \u2218 \u03c6.to_fun,\n  definable := definable_psh.definable_precomp \u03c6 \u03c3.definable }\n\nlemma begin_lem {X : Type*} [definable_psh S X] {x : X} :\n  definable S x \u2194 \u2200 (\u0393 : Def S), definable_psh.definable (\u03bb (\u03b3 : \u0393), x) :=\nbegin\n  unfold definable,\n  split; intro H,\n  { intro \u0393,\n    let u : Hom \u0393 pt := \u27e8\u03bb _, default _, by exact pt.definable\u27e9,\n    exact definable_psh.definable_precomp u H },\n  { apply H }\nend\n\nlemma intro_lem\u2081 {X Y : Type*} [definable_psh S X] [definable_psh S Y]\n  (f : X \u2192 Y) :\n  (\u2200 (\u0393 : Def S), definable S (\u03bb (\u03b3 : \u0393), f)) \u2194\n  (\u2200 (\u0393 : Def S) (x : \u0393 \u2192 X), definable S x \u2192 definable S (\u03bb (\u03b3 : \u0393), f (x \u03b3))) :=\nsorry\n\nlemma definable_fun' {\u0393 : Def S} {X Y : Type*} [definable_psh S X] [definable_psh S Y]\n  {f : \u0393 \u2192 X \u2192 Y} : definable_psh.definable f \u2194\n  (\u2200 (\u0393' : Def S) (\u03c0 : Hom \u0393' \u0393) (g : \u0393' \u22a2 X),\n   definable_psh.definable (\u03bb \u03b3_1, f (\u03c0.to_fun \u03b3_1) (g.to_fun \u03b3_1))) :=\nbegin\n  split; intro H,\n  { intros \u0393' \u03c0 g,\n    have : definable_psh.definable (\u03bb \u03b3', (\u03c0.to_fun \u03b3', g.to_fun \u03b3')) :=\n      \u27e8\u03c0.is_definable, g.definable\u27e9,\n    exact H \u0393' this },\n  { intros M g hg,\n    exact H M \u27e8_, hg.1\u27e9 \u27e8_, hg.2\u27e9 }\nend\n\nlemma definable.app_ctx' {\u0393 : Def S} {X Y : Type*} [definable_psh S X] [definable_psh S Y]\n  (f : \u0393 \u2192 X \u2192 Y) {hf : definable_psh.definable f} (x : \u0393 \u2192 X) {hx : definable_psh.definable x} :\n  definable_psh.definable (\u03bb \u03b3, f \u03b3 (x \u03b3)) :=\nbegin\n  have : definable_psh.definable (\u03bb \u03b3, (\u03b3, x \u03b3)) :=\n    \u27e8(Def.id _).is_definable, hx\u27e9,\n  exact hf \u0393 this\nend\n\nlemma definable_const {\u0393 : Def S} {X : Type*} [definable_psh S X] {x : X} :\n  definable S x \u2192 definable_psh.definable (\u03bb (_ : \u0393), x) :=\n\u03bb H, begin_lem.mp H \u0393\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 \u0393]\n\n/-- Return the variable representing the definable context. -/\nmeta def guess_ctx_var : tactic expr :=\ndo `(o_minimal.definable_psh.definable (\u03bb (_ : \u21a5%%var), _)) \u2190 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 \u00d7 expr)) :=\ndo l \u2190 local_context,\n   -- some kind of moption_map?\n   l \u2190 l.mmap (\u03bb var,\n     (do `(o_minimal.sect %%ctx_var %%ty) \u2190 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 \u00d7 expr)) :=\nguess_ctx_var >>= guess_defin_vars\n\n/-- Goal should look like\n  \u22a2 definable_psh.definable (\u03bb \u03b3, \u03bb x, e)\nWe want to \"intro\" `x` as a definable variable, and leave\n  \u22a2 definable_psh.definable (\u03bb \u03b3, e)\nas the new goal.\n\nStrategy:\nBy `definable_fun'` it's enough to check the new goal\nfor an arbitrary context extension \u03c0 : \u0393' \u2192 \u0393 and section x : \u0393' \u22a2 \u03b1.\nHowever, we also have to move any existing definable variables from \u0393 to \u0393'.\nSo, we proceed as follows:\n* Identify the variables `\u03b3` (`i_var`) and `\u0393` (`ctx_var`) in the goal\n  `definable_psh.definable (\u03bb (\u03b3 : \u0393), 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 `\u0393'` and `\u03c0`.\n* For each existing definable variable `p`, we add a let binding\n  `p' := p.precomp \u03c0`.\n* Now intro the new variable `x` (`new_var`) as well, and build a new function\n  (\u03bb (\u03b3' : \u0393'), body' (x.to_fun \u03b3')), by making the following replacements:\n  - each old `p` becomes `p'`;\n  - `i` becomes `i'`;\n  - `\u0393` becomes `\u0393'`.\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 `\u0393'` 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, `\u03c0`, and the old `\u0393`.\n\nThe tactic reuses the same user-visible names for the new `\u0393` and `\u03b3`.\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 : \u03a0 {\u03b1 : Type} [has_to_tactic_format \u03b1] (a : \u03b1), tactic unit :=\n  \u03bb _ _ _, tactic.skip in       -- comment this for debugging\ndo `(o_minimal.definable_psh.definable %%f) \u2190 target,\n   ([i_var], body) \u2190 open_n_lambdas f 1,\n   ctx_var \u2190 guess_ctx_var,\n   trace i_var,\n   trace body,\n   `[rw definable_fun'],\n   new_ctx_var \u2190 tactic.intro ctx_var.local_pp_name,\n   proj_var \u2190 tactic.intro `\u03c0,\n   defin_vars \u2190 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 \u03c0`\n   defin_var_list \u2190 defin_vars.mmap (\u03bb \u27e8dvar, dvar_ty\u27e9, do\n     -- \"let p' := p.precomp \u03c0,\"\n     new_body \u2190 to_expr ``((%%dvar).precomp %%proj_var),\n     new_dvar \u2190 tactic.pose dvar.local_pp_name none new_body,\n     return (sigma.mk dvar new_dvar)),\n   new_i_type \u2190 to_expr ``(\u21a5%%new_ctx_var),\n   new_i_var \u2190 mk_local' i_var.local_pp_name f.binding_info new_i_type,\n   -- * replace variables `p` \u2192 `p'` in `body`, and also the \u03b3 and \u0393 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 (\u03bb 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 \u2190 tactic.intro var,\n   new_var' \u2190 to_expr ``((%%new_var).to_fun %%new_i_var),\n   new_f \u2190 tactic.lambdas [new_i_var] (body'.subst new_var'),\n   trace new_f,\n   new_target \u2190 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 (\u03bb \u27e8dvar, new_dvar\u27e9, do tactic.clear dvar),\n   tactic.clear proj_var,\n   tactic.clear ctx_var,\n   return ()\n\n/-- Goal should look like\n \u22a2 definable_psh.definable (\u03bb \u03b3, f x)\nand we want to produce\n \u22a2 definable_psh.definable (\u03bb \u03b3, f)\n \u22a2 definable_psh.definable (\u03bb \u03b3, 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) \u2190 target,\n   ([i_var], body) \u2190 open_n_lambdas e 1,\n   (expr.app f x) \u2190 pure body,\n   f' \u2190 tactic.lambdas [i_var] f,\n   x' \u2190 tactic.lambdas [i_var] x,\n   `[apply o_minimal.definable.app_ctx' %%f' %%x'],\n   return ()\n\n/-- Goal should look like\n \u22a2 definable_psh.definable (\u03bb \u03b3, p.to_fun \u03b3)\nwhere p : \u0393 \u22a2 \u03b1. 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 := \u03bb _ 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 \u2192 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 \u03b3` 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 $ \u03bb 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 \u2190 infer_type l,\n   val \u2190 try_core (shorten <$> local_def_value l),\n   match ty with\n   | `(o_minimal.sect %%\u0393 %%ty') := return \u27e8ff, l, shorten ty', val\u27e9\n   | _ := return \u27e8tt, l, shorten ty, val\u27e9\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 \u2190 read,\n   `(o_minimal.definable_psh.definable (\u03bb (_ : \u21a5%%\u0393), %%body)) \u2190 target\n     | pure (\u03bb _, to_fmt s),\n   lc \u2190 local_context,\n   ctx_var \u2190 tactic.interactive.guess_ctx_var,\n   dat \u2190 (lc.filter (\u03bb l, l \u2260 ctx_var)).mmap get_hyp_data,\n   return $ \u03bb _, format.intercalate format.line\n     [format.intercalate (\",\" ++ format.line) $ dat.map $ \u03bb d,\n        decl_to_fmt s d.crisp [d.var] d.ty d.val,\n      format! \"\u22a2 {s.format_expr (shorten body)} def\"]\n\nmeta def save_info (p : pos) : defin unit :=\ndo gs \u2190 get_goals,\n   fmt \u2190 gs.mmap goal_to_fmt,\n   set_goals gs,\n   tactic.save_info_thunk p (\u03bb _,\n     let header := if fmt.length > 1 then format! \"{fmt.length} goals\\n\" else \"\",\n         eval : thunk format \u2192 format := \u03bb 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 \u2192 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 \u2190 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 ` \u22a2 `:10 := sect\n\nexample : definable S (\u03bb p q, (q \u2227 p) \u2227 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 (\u03bb p q, (q \u2227 p) \u2227 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 \u27e8x.definable, y.definable\u27e9\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 (\u03bb (X : set Y) (h : nonempty X), true) :=\nbegin\n  defin_start, rw \u2190definable_yoneda, -- TODO: combine these\n\n  -- \"intro X\",\n  rw definable_fun', intros \u0393' \u03c0 p,\n  -- now we need to pull back any variables mentioning \u0393\n  -- to use \u0393' -- there aren't any yet \u2713\n  -- since that's done, we can dispose of the old context\n  clear \u03c0 \u0393,\n  rename \u0393' \u2192 \u0393,\n\n  -- \"intro x\",\n  rw definable_fun', intros \u0393' \u03c0, -- don't intro q just yet\n  -- this time we need to deal with p\n  have : \u2200 d, p.to_fun (\u03c0.to_fun d) = (p.precomp \u03c0).to_fun d := \u03bb d, rfl,\n  simp only [this],\n  generalize H : (p.precomp \u03c0) = p', clear this H p, rename p' \u2192 p,\n  -- okay, now it's safe to intro q\n  intro q,\n  -- dispose of old context again\n  clear \u03c0 \u0393,\n  rename \u0393' \u2192 \u0393,\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 (\ud835\udc9e : Type u) [category.{v} \ud835\udc9e]\n\n@[protect_proj] structure struc : Type (max u v (w+1) (x+1)) :=\n( F : \ud835\udc9e \u2192 Type w )\n( hom : \u03a0 (A B : sigma F) (f : A.1 \u27f6 B.1), Type x )\n( id : \u03a0 (A : sigma F), \u03a3 f : A.1 \u27f6 A.1, hom A A f )\n( id_fst' : \u03a0 (A : sigma F), (id A).fst = \ud835\udfd9 A.1 )\n( comp : \u03a0 {A B C : sigma F}\n    (f : \u03a3 f : A.1 \u27f6 B.1, hom A B f)\n    (g : \u03a3 g : B.1 \u27f6 C.1, hom B C g),\n    \u03a3 h : A.1 \u27f6 C.1, hom A C h )\n( comp_fst' : \u03a0 {A B C : sigma F}\n    (f : \u03a3 f : A.1 \u27f6 B.1, hom A B f)\n    (g : \u03a3 g : B.1 \u27f6 C.1, hom B C g),\n    (comp f g).fst = f.1 \u226b g.1)\n( id_comp' : \u03a0 {A B : sigma F} (f : \u03a3 f : A.1 \u27f6 B.1, hom A B f), \n    comp (id A) f = f )\n( comp_id' : \u03a0 {A B : sigma F} (f : \u03a3 f : A.1 \u27f6 B.1, hom A B f), \n    comp f (id B) = f )\n( assoc' : \u03a0 {A B C D : sigma F} \n    (f : \u03a3 f : A.1 \u27f6 B.1, hom A B f)\n    (g : \u03a3 g : B.1 \u27f6 C.1, hom B C g)\n    (h : \u03a3 h : C.1 \u27f6 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 \ud835\udc9e) (\u03bb _, \ud835\udc9e \u2192 Type w) :=\n{ coe := struc.F }\n\nvariables {\ud835\udc9e} {F : struc \ud835\udc9e}\n\n@[simp] lemma id_comp {A B : sigma F} (f : \u03a3 (f : A.fst \u27f6 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 : \u03a3 (f : A.fst \u27f6 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 : \u03a3 f : A.1 \u27f6 B.1, F.hom A B f)\n  (g : \u03a3 g : B.1 \u27f6 C.1, F.hom B C g)\n  (h : \u03a3 h : C.1 \u27f6 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\u2081 (A : sigma F) : (F.id A).fst = \ud835\udfd9 A.1 := F.id_fst' _\n\n@[simp] lemma comp_fst\u2081 {A B C : sigma F}\n  (f : \u03a3 f : A.1 \u27f6 B.1, F.hom A B f)\n  (g : \u03a3 g : B.1 \u27f6 C.1, F.hom B C g) :\n  (F.comp f g).fst = f.1 \u226b g.1 := F.comp_fst' _ _\n\ninstance : category_struct (sigma F) :=\n{ hom := \u03bb A B, \u03a3 (f : A.1 \u27f6 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 \u27f6 B) (g : B \u27f6 C) :\n  (f \u226b g).fst = f.1 \u226b g.1 := struc.comp_fst\u2081 f g\n\n@[simp] lemma id_fst {A : sigma F} : sigma.fst (\ud835\udfd9 A) = \ud835\udfd9 A.1 := struc.id_fst\u2081 _\n\ninstance (X : \ud835\udc9e) : category_struct (F X) :=\n{ hom := \u03bb A B, F.hom \u27e8X, A\u27e9 \u27e8X, B\u27e9 (\ud835\udfd9 X),\n  id := \u03bb A, (F.id \u27e8X, A\u27e9).snd,\n  comp := \u03bb A B C f g, begin\n    have := (F.comp \u27e8(F.id \u27e8X, B\u27e9).fst, f\u27e9 _).snd,\n  end }\n\nlemma id_def {X : \ud835\udc9e} (x : F X) : \ud835\udfd9 x = F.id x := rfl \n\nlemma comp_def (X : \ud835\udc9e) (A B C : F X) (f : A \u27f6 B) (g : B \u27f6 C) :\n  f \u226b g = F.hom_iso (\ud835\udfd9 X \u226b \ud835\udfd9 X) A C (\ud835\udfd9 X) A C (iso.refl X) (iso.refl X) \n    (by simp) (by simp) (by simp) (F.comp f g) := rfl\n\ninstance (X : \ud835\udc9e) : category (F X) :=\n{ id_comp' := \u03bb A B f, begin \n      simp [id_def, comp_def],\n      rw [\u2190 equiv.trans_apply, F.hom_iso_trans],\n      simp\n    end,\n  comp_id' := \u03bb A B f, begin \n      simp [id_def, comp_def],\n      rw [\u2190 equiv.trans_apply, F.hom_iso_trans],\n      simp\n    end,\n  assoc' := \u03bb A B C D f g h,\n      begin\n        simp only [comp_def, \u2190 F.hom_iso_comp],\n        erw F.hom_iso_comp,\n      end }\n\ndef forget : sigma\u2082 F \u2964 \ud835\udc9e :=\n{ obj := sigma.fst,\n  map := \u03bb _ _, sigma.fst }\n\ndef thing (X : \ud835\udc9e) : F X \u2964 sigma\u2082 F :=\n{ obj := \u03bb A, \u27e8X, A\u27e9,\n  map := \u03bb A B f, \u27e8\ud835\udfd9 X, f\u27e9,\n  map_id' := \u03bb A, rfl,\n  map_comp' := \u03bb 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 (\ud835\udfd9 X \u226b \ud835\udfd9 X) rfl (\ud835\udfd9 X)\n        (category.comp_id _)],\n      symmetry,\n      rw [\u2190 cast_eq_iff_heq],\n      simp, refl,\n      simp,\n    end }\n\nopen opposite\n\nprotected def op (F : struc \ud835\udc9e) : struc \ud835\udc9e\u1d52\u1d56 :=\n{ F := \u03bb A, F.F (unop A),\n  hom := \u03bb A B f a b, F.hom f.unop b a,\n  id := \u03bb A a, F.id a,\n  comp := \u03bb A B C a b c f g f' g' h hH, \n    F.comp g' f' (by simp [\u2190 hH]),\n  id_comp := \u03bb A B f a b f', F.comp_id _,\n  comp_id := \u03bb A B f a b f', F.id_comp _,\n  assoc := \u03bb 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 \ud835\udc9e\u1d52\u1d56) : struc \ud835\udc9e :=\n{ F := \u03bb A, F.F (op A),\n  hom := \u03bb A B f a b, F.hom f.op b a,\n  id := \u03bb A a, F.id a,\n  comp := \u03bb A B C a b c f g f' g' h hH, \n     F.comp g' f' (by simp [\u2190 hH]),\n  id_comp := \u03bb A B f a b f', F.comp_id _,\n  comp_id := \u03bb A B f a b f', F.id_comp _,\n  assoc := \u03bb 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 : \ud835\udc9e \u2964 Type w) : struc \ud835\udc9e :=\n{ F := F.obj,\n  hom := \u03bb A B f a b, plift (F.map f a = b),\n  id := \u03bb A a, \u27e8by simp\u27e9,\n  comp := \u03bb A B C a b c f g h\u2081 h\u2082 _ h, \u27e8by simp [\u2190 h, F.map_comp, h\u2081.down, h\u2082.down]\u27e9,\n  assoc := \u03bb _ _ _ _ _ _ _ _ _ _ _ h\u2081 h\u2082 h\u2083, \n    begin simp [h\u2081.down, h\u2082.down, h\u2083.down] end,\n  id_comp := \u03bb _ _ _ _ _ h, \n    begin simp [h.down] end,\n  comp_id := \u03bb _ _ _ _ _ h, \n    begin simp [h.down] end }\n\ndef Module\u2082 : struc Ring :=\n{ F := \u03bb R, Module R,\n  hom := \u03bb R S f M\u2081 M\u2082, M\u2081 \u2192\u209b\u2097[f] M\u2082,\n  id := \u03bb R M, linear_map.id,\n  comp := \u03bb R S T M\u2081 M\u2082 M\u2083 f g f' g' _ h, \n    @linear_map.comp _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \u27e8h\u27e9 g' f',\n  id_comp := \u03bb R S f M\u2081 M\u2082 f', begin\n      cases f', cases f, refl\n    end,\n  comp_id := \u03bb R S f M\u2081 M\u2082 f', begin\n      cases f', cases f, refl,\n    end,\n  assoc := \u03bb R S T U f g h M\u2081 M\u2082 M\u2083 M\u2084 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 : \ud835\udc9e \u2964 Type) (G : struc (sigma\u2082 (of_functor F))) : struc \ud835\udc9e :=\n{ F := \u03bb X, \u03a0 a : F.obj X, G.F \u27e8X, a\u27e9,\n  hom := \u03bb X Y f x y, \u03a0 (a : F.obj X), \n    @struc.hom _ _ G \u27e8X, a\u27e9 \u27e8Y, F.map f a\u27e9 \u27e8f, \u27e8rfl\u27e9\u27e9 (x a) (y (F.map f a)),\n  id := \u03bb X x a, by convert (G.id (x a)); simp,\n  comp := \u03bb 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 := \u03bb 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 \u03b1` which is classically isomorphic to `\u03b1`,\nbut erased in the VM. That is, at runtime every value of `erased \u03b1` is\nrepresented as `0`, just like types and proofs.\n-/\n\n/-- `erased \u03b1` is the same as `\u03b1`, except that the elements\n  of `erased \u03b1` 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 (\u03b1 : Sort u) := psigma fun (s : \u03b1 \u2192 Prop) => \u2203 (a : \u03b1), (fun (b : \u03b1) => a = b) = s\n\nnamespace erased\n\n\n/-- Erase a value. -/\ndef mk {\u03b1 : Sort u_1} (a : \u03b1) : erased \u03b1 := psigma.mk (fun (b : \u03b1) => a = b) sorry\n\n/-- Extracts the erased value, noncomputably. -/\ndef out {\u03b1 : Sort u_1} : erased \u03b1 \u2192 \u03b1 := 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 {\u03b1 : Sort u_1} (a : \u03b1) : out (mk a) = a :=\n  let h : \u2203 (x : \u03b1), (fun (b : \u03b1) => x = b) = fun (b : \u03b1) => 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 {\u03b1 : Sort u_1} (a : erased \u03b1) : mk (out a) = a := sorry\n\ntheorem out_inj {\u03b1 : Sort u_1} (a : erased \u03b1) (b : erased \u03b1) (h : out a = out b) : a = b := sorry\n\n/-- Equivalence between `erased \u03b1` and `\u03b1`. -/\ndef equiv (\u03b1 : Sort u_1) : erased \u03b1 \u2243 \u03b1 := equiv.mk out mk mk_out out_mk\n\nprotected instance has_repr (\u03b1 : Type u) : has_repr (erased \u03b1) :=\n  has_repr.mk\n    fun (_x : erased \u03b1) =>\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 (\u03b1 : Type u) : has_to_string (erased \u03b1) :=\n  has_to_string.mk\n    fun (_x : erased \u03b1) =>\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 {\u03b1 : Sort u_1} (h : Nonempty \u03b1) : erased \u03b1 := mk (Classical.choice h)\n\n@[simp] theorem nonempty_iff {\u03b1 : Sort u_1} : Nonempty (erased \u03b1) \u2194 Nonempty \u03b1 := sorry\n\nprotected instance inhabited {\u03b1 : Sort u_1} [h : Nonempty \u03b1] : Inhabited (erased \u03b1) :=\n  { default := choice h }\n\n/--\n`(>>=)` operation on `erased`.\n\nThis is a separate definition because `\u03b1` and `\u03b2` can live in different\nuniverses (the universe is fixed in `monad`).\n-/\ndef bind {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} (a : erased \u03b1) (f : \u03b1 \u2192 erased \u03b2) : erased \u03b2 :=\n  psigma.mk (fun (b : \u03b2) => psigma.fst (f (out a)) b) sorry\n\n@[simp] theorem bind_eq_out {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} (a : erased \u03b1) (f : \u03b1 \u2192 erased \u03b2) :\n    bind a f = f (out a) :=\n  sorry\n\n/--\nCollapses two levels of erasure.\n-/\ndef join {\u03b1 : Sort u_1} (a : erased (erased \u03b1)) : erased \u03b1 := bind a id\n\n@[simp] theorem join_eq_out {\u03b1 : Sort u_1} (a : erased (erased \u03b1)) : join a = out a :=\n  bind_eq_out a id\n\n/--\n`(<$>)` operation on `erased`.\n\nThis is a separate definition because `\u03b1` and `\u03b2` can live in different\nuniverses (the universe is fixed in `functor`).\n-/\ndef map {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} (f : \u03b1 \u2192 \u03b2) (a : erased \u03b1) : erased \u03b2 := bind a (mk \u2218 f)\n\n@[simp] theorem map_out {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} {f : \u03b1 \u2192 \u03b2} (a : erased \u03b1) :\n    out (map f a) = f (out a) :=\n  sorry\n\nprotected instance monad : Monad erased :=\n  { toApplicative :=\n      { toFunctor := { map := map, mapConst := fun (\u03b1 \u03b2 : Type u_1) => map \u2218 function.const \u03b2 },\n        toPure := { pure := mk },\n        toSeq :=\n          { seq :=\n              fun (\u03b1 \u03b2 : Type u_1) (f : erased (\u03b1 \u2192 \u03b2)) (x : erased \u03b1) =>\n                bind f fun (_x : \u03b1 \u2192 \u03b2) => map _x x },\n        toSeqLeft :=\n          { seqLeft :=\n              fun (\u03b1 \u03b2 : Type u_1) (a : erased \u03b1) (b : erased \u03b2) =>\n                (fun (\u03b1 \u03b2 : Type u_1) (f : erased (\u03b1 \u2192 \u03b2)) (x : erased \u03b1) =>\n                    bind f fun (_x : \u03b1 \u2192 \u03b2) => map _x x)\n                  \u03b2 \u03b1 (map (function.const \u03b2) a) b },\n        toSeqRight :=\n          { seqRight :=\n              fun (\u03b1 \u03b2 : Type u_1) (a : erased \u03b1) (b : erased \u03b2) =>\n                (fun (\u03b1 \u03b2 : Type u_1) (f : erased (\u03b1 \u2192 \u03b2)) (x : erased \u03b1) =>\n                    bind f fun (_x : \u03b1 \u2192 \u03b2) => map _x x)\n                  \u03b2 \u03b2 (map (function.const \u03b1 id) a) b } },\n    toBind := { bind := bind } }\n\n@[simp] theorem pure_def {\u03b1 : Type u_1} : pure = mk := rfl\n\n@[simp] theorem bind_def {\u03b1 : Type u_1} {\u03b2 : Type u_1} : bind = bind := rfl\n\n@[simp] theorem map_def {\u03b1 : Type u_1} {\u03b2 : 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 Smt\n\ntheorem length : \"a\".length = 1 := by\n  smt\n  rfl\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/Test/String/Length.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5428632831725053, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.24395876097908098}}
{"text": "import Architectural.ArchWithContracts\n\nvariables {\u03a6 Var : Type} [fintype Var] [decidable_eq Var] [AssertionLang \u03a6 Var]\n\ndef isCorrectDecompositionImpl \n{S : Component Var} \n(A : ArchitectureWithContracts \u03a6  S)\n(Is : Implementations A.to_Architecture)\n  : Prop := \n(\u2200 (S' : Component Var) (h : S' \u2208 A.subs), (Is S' h).satisfiesContract (A.contracts.find_val S').iget)\n   \u2192 (@CompositeImplementation Var _ _ _ _ S {..A} Is).satisfiesContract A.parent\n\ndef isCorrectDecompositionEnv \n{S : Component Var}\n(A : ArchitectureWithContracts \u03a6  S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : Prop := \n\u2200 (S'' : Component Var) (h'': S'' \u2208 A.subs) , \n(E.satisfiesContract A.parent \u2227 \n(\u2200 (S' : Component Var) {S' \u2208 A.subs.erase S''}, (Is S' (list.mem_of_mem_erase H)).satisfiesContract (A.contracts.find_val S').iget) \u2192 \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 \u03a6 S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) := \nisCorrectDecompositionImpl A Is \u2227 \nisCorrectDecompositionEnv A Is E \n\nnamespace Claim \n\n\ndef correctDecompositionImpl \n{S : Component Var} \n(A : ArchitectureWithContracts \u03a6 S)\n(Is :Implementations A.to_Architecture)\n(\u03c3 : Trace Var) : Prop := \n(\u2200 (S' : Component Var) {S' \u2208 A.subs}, \u2200 \u03c3',(\u03c3' \u2208 (Is S' H) \u2227 \n(\u03c3' \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ (A.contracts.find_val S').iget.A))) \u2192 \n(\u03c3' \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ (A.contracts.find_val S').iget.G))) \u2192 ( (\u03c3 \u2208 (@CompositeImplementation Var _ _ _ _ S \u2191A Is) \u2227 (\u03c3 \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ A.parent.A))) \u2192 (\u03c3 \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ A.parent.G)))\n\n\n-- example {C : Contract \u03a6 Var} {\u03c3 : Trace Var}  :\n-- (\u03c3 \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ C.A)) \u2192 (\u03c3 \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ C.G))\n-- \u2194 (\u03c3 \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ C.nf)) := \n-- begin\n--   split,\n--   intro H,\n--   rw AssertionLang.disj_def,\n--   rw AssertionLang.compl_def,\n--   simp,\n--   rw \u2190 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 \u2190 imp_iff_not_or at H, exact H,\n-- end \n\ndef correctDecompositionImpl' \n{S : Component Var} \n(A : ArchitectureWithContracts \u03a6  S)\n(Is :Implementations A.to_Architecture)\n(\u03c3 : Trace Var) : Prop := \n(\u2200 (S' : Component Var) {S' \u2208 A.subs}, \u2200 \u03c3',(\u03c3' \u2208 (Is S' H) \u2227 \n(\u03c3' \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ (A.contracts.find_val S').iget.A))) \u2192 \n(\u03c3' \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ (A.contracts.find_val S').iget.G))) \u2192 \n( (\u03c3 \u2208 (@CompositeImplementation Var _ _ _ _ S \u2191A Is) \u2227 (\u03c3 \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ A.parent.A))) \u2192 (\u03c3 \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ A.parent.G)))\n\ndef correctDecompositionEnv \n{S : Component Var}\n(A : ArchitectureWithContracts \u03a6  S)\n(Is :Implementations A.to_Architecture)\n(E : Env Var) (\u03c3 : Trace Var) : Prop := \n\u2200 (S'' : Component Var) {S'' \u2208 A.subs},\nE.satisfiesContract A.parent \u2192 \n(\u2200 (S' : Component Var) {S' \u2208 A.subs.erase S''}, (Is S' (list.mem_of_mem_erase H)).satisfiesContract (A.contracts.find_val S').iget) \u2192 \n(\u03c3 \u2208 (CompositeEnvironment A.to_Architecture S'' Is E)) \u2192 \u03c3 \u2208 (@AssertionLang.sem \u03a6 Var _ _ _ ((A.contracts.find_val S'').iget).A)\n\n\ndef correctDecomposition \n{S : Component Var}\n(A : ArchitectureWithContracts \u03a6 S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : Claim (Trace Var) := \n{\n  X := set.univ, \n  P := \n  \u03bb \u03c3, correctDecompositionImpl A Is \u03c3 \u2227 correctDecompositionEnv A Is E \u03c3 \n}\n\nend Claim \n-- def correctDecompositionImplProperty\n-- (A : ArchWithContracts S)\n-- (Is : Implementations A)  : Property (Trace Var) := \u03bb \u03c3,\n-- (\u2200 (S' : Component Var) {S' \u2208 A.subs}, \n--     (\u2200 \u03c3', \u03c3' \u2208 (Is S' H) \u2227 \u03c3' \u2208 $\\llparenthesis$(A.contracts.get S').A$\\rrparenthesis$ \n--   \u2192 (\u03c3' \u2208 $\\llparenthesis$(A.contracts.get S').G$\\rrparenthesis$))  \n-- \u2192 ((\u03c3 \u2208 CompositeImplementation A Is \u2227 \u03c3 \u2208 $\\llparenthesis$S.C.A$\\rrparenthesis$) \n-- \u2192 \u03c3 \u2208 $\\llparenthesis$S.C.G$\\rrparenthesis$)\n\n-- def correctDecompositionEnvProperty\n-- {S : ComponentWithContract \u03a6 Var}\n-- (A : ArchWithContracts S)\n-- (Is :Implementations A) \n-- (E : Env Var)  : Property (Trace Var) :=\u03bb \u03c3, \n-- \u2200 (S'' : Component Var),\n--   E.satisfiesContract S.C \u2192 \n--   (\u2200 (S' : Component Var) {S' \u2208 A.subs}, \n--   (Is S' H).satisfies (A.contracts.get S')) \u2192 \n--  (\u03c3 \u2208 CompositeEnvironment A S'' Is E) \u2192 \n--  \u03c3 \u2208 {{((A.contracts.get S'')).A}}\ntheorem  \nclaim_imp_correctDecomp\n{S : Component Var}\n(A : ArchitectureWithContracts \u03a6  S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : \n\u27e6Claim.correctDecomposition A Is E\u27e7 \u2192 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\u2082 h\u2083,\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\u2082, simp at h\u2082, \n    intro h'', apply h,split, exact h\u2082,\n    exact h\u2083,\n  }, \n  {\n    rintros S'' h\u2084 \u27e8h\u2085, h\u2086\u27e9 s,\n    replace clm := clm s, rw [Claim.correctDecomposition] at clm, \n    simp at clm, replace clm := clm.2 S'' h\u2085 h\u2086, exact clm,\n    rw Claim.correctDecompositionEnv at clm, assumption,\n}\nend \n\n\n\ntheorem decompCorrectImpClaim \n{S : Component Var}\n(A : ArchitectureWithContracts \u03a6  S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : \nisCorrectDecomposition A Is E \u2192 \n\u27e6Claim.correctDecomposition A Is  E\u27e7 := \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 \u03c3' h\u2082 h\u2083,\n    rw CompositeImplementation at h\u2083,\n    intros h\u2084,\n    rw Impl.satisfiesContract at h,\n    simp at h,\n    apply h,\n    intros S' h',\n    replace h\u2082 := h\u2082 S' h',\n    intros \u03c3 h\u2085, cases h\u2085 with L R,\n    replace h\u2082 := h\u2082 \u03c3 L R, simp, \n    apply h\u2082,split, rw CompositeImplementation, apply h\u2083, assumption,\n  },\n  {\n    intros \u03c3, 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\u2082, apply s, exact smem, \n  }\n\nend\n\ntheorem decompositionCorrectAsClaim \n{S : Component Var}\n(A : ArchitectureWithContracts \u03a6  S)\n(Is : Implementations A.to_Architecture)\n(E : Env Var) : \nisCorrectDecomposition A Is E \u2194 \u27e6Claim.correctDecomposition A Is E\u27e7 := \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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((a2).write i3 (v1)) \u2260 (a2) \u2192 ((a1).write i3 (v1)) = (a2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test51.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.4649015713733885, "lm_q1q2_score": 0.24333894270930437}}
{"text": "/-\nCopyright (c) 2021 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Lean.Meta.Transform\nimport Lean.Meta.Tactic.Injection\nimport Lean.Meta.Tactic.Apply\nimport Lean.Meta.Tactic.Cases\nimport Lean.Meta.Tactic.Subst\nimport Lean.Meta.Tactic.Simp.Types\nimport Lean.Meta.Tactic.Assumption\n\nnamespace Lean.Meta\n\nprivate def mkAnd? (args : Array Expr) : Option Expr := Id.run <| do\n  if args.isEmpty then\n    return none\n  else\n    let mut result := args.back\n    for arg in args.reverse[1:] do\n      result := mkApp2 (mkConst ``And) arg result\n    return result\n\ndef elimOptParam (type : Expr) : CoreM Expr := do\n  Core.transform type fun e =>\n    if e.isAppOfArity  ``optParam 2 then\n      return TransformStep.visit (e.getArg! 0)\n    else\n      return TransformStep.visit e\n\nprivate partial def mkInjectiveTheoremTypeCore? (ctorVal : ConstructorVal) (useEq : Bool) : MetaM (Option Expr) := do\n  let us := ctorVal.levelParams.map mkLevelParam\n  let type \u2190 elimOptParam ctorVal.type\n  forallBoundedTelescope type ctorVal.numParams fun params type =>\n  forallTelescope type fun args1 resultType => do\n    let jp (args2 args2New : Array Expr) : MetaM (Option Expr) := do\n      let lhs := mkAppN (mkAppN (mkConst ctorVal.name us) params) args1\n      let rhs := mkAppN (mkAppN (mkConst ctorVal.name us) params) args2\n      let eq \u2190 mkEq lhs rhs\n      let mut eqs := #[]\n      for arg1 in args1, arg2 in args2 do\n        let arg1Type \u2190 inferType arg1\n        if !(\u2190 isProp arg1Type) && arg1 != arg2 then\n          if (\u2190 isDefEq arg1Type (\u2190 inferType arg2)) then\n            eqs := eqs.push (\u2190 mkEq arg1 arg2)\n          else\n            eqs := eqs.push (\u2190 mkHEq arg1 arg2)\n      if let some andEqs := mkAnd? eqs then\n        let result \u2190\n          if useEq then\n            mkEq eq andEqs\n          else\n            mkArrow eq andEqs\n        mkForallFVars params (\u2190 mkForallFVars args1 (\u2190 mkForallFVars args2New result))\n      else\n        return none\n    let rec mkArgs2 (i : Nat) (type : Expr) (args2 args2New : Array Expr) : MetaM (Option Expr) := do\n      if h : i < args1.size then\n        match (\u2190 whnf type) with\n        | Expr.forallE n d b _ =>\n          let arg1 := args1.get \u27e8i, h\u27e9\n          if arg1.occurs resultType then\n            mkArgs2 (i + 1) (b.instantiate1 arg1) (args2.push arg1) args2New\n          else\n            withLocalDecl n (if useEq then BinderInfo.default else BinderInfo.implicit) d fun arg2 =>\n              mkArgs2 (i + 1) (b.instantiate1 arg2) (args2.push arg2) (args2New.push arg2)\n        | _ => throwError \"unexpected constructor type for '{ctorVal.name}'\"\n      else\n        jp args2 args2New\n    if useEq then\n      mkArgs2 0 type #[] #[]\n    else\n      withNewBinderInfos (params.map fun param => (param.fvarId!, BinderInfo.implicit)) <|\n      withNewBinderInfos (args1.map fun arg1 => (arg1.fvarId!, BinderInfo.implicit)) <|\n        mkArgs2 0 type #[] #[]\n\nprivate def mkInjectiveTheoremType? (ctorVal : ConstructorVal) : MetaM (Option Expr) :=\n  mkInjectiveTheoremTypeCore? ctorVal false\n\nprivate def injTheoremFailureHeader (ctorName : Name) : MessageData :=\n  m!\"failed to prove injectivity theorem for constructor '{ctorName}', use 'set_option genInjectivity false' to disable the generation\"\n\nprivate def throwInjectiveTheoremFailure {\u03b1} (ctorName : Name) (mvarId : MVarId) : MetaM \u03b1 :=\n  throwError \"{injTheoremFailureHeader ctorName}{indentD <| MessageData.ofGoal mvarId}\"\n\nprivate def solveEqOfCtorEq (ctorName : Name) (mvarId : MVarId) (h : FVarId) : MetaM Unit := do\n  match (\u2190 injection mvarId h) with\n  | InjectionResult.solved => unreachable!\n  | InjectionResult.subgoal mvarId .. =>\n    (\u2190 splitAnd mvarId).forM fun mvarId =>\n      unless (\u2190 assumptionCore mvarId) do\n        throwInjectiveTheoremFailure ctorName mvarId\n\nprivate def mkInjectiveTheoremValue (ctorName : Name) (targetType : Expr) : MetaM Expr :=\n  forallTelescopeReducing targetType fun xs type => do\n    let mvar \u2190 mkFreshExprSyntheticOpaqueMVar type\n    solveEqOfCtorEq ctorName mvar.mvarId! xs.back.fvarId!\n    mkLambdaFVars xs mvar\n\ndef mkInjectiveTheoremNameFor (ctorName : Name) : Name :=\n  ctorName ++ `inj\n\nprivate def mkInjectiveTheorem (ctorVal : ConstructorVal) : MetaM Unit := do\n  let some type \u2190 mkInjectiveTheoremType? ctorVal\n    | return ()\n  let value \u2190 mkInjectiveTheoremValue ctorVal.name type\n  addDecl <| Declaration.thmDecl {\n    name        := mkInjectiveTheoremNameFor ctorVal.name\n    levelParams := ctorVal.levelParams\n    type        := (\u2190 instantiateMVars type)\n    value       := (\u2190 instantiateMVars value)\n  }\n\ndef mkInjectiveEqTheoremNameFor (ctorName : Name) : Name :=\n  ctorName ++ `injEq\n\nprivate def mkInjectiveEqTheoremType? (ctorVal : ConstructorVal) : MetaM (Option Expr) :=\n  mkInjectiveTheoremTypeCore? ctorVal true\n\nprivate def mkInjectiveEqTheoremValue (ctorName : Name) (targetType : Expr) : MetaM Expr := do\n  forallTelescopeReducing targetType fun xs type => do\n    let mvar \u2190 mkFreshExprSyntheticOpaqueMVar type\n    let [mvarId\u2081, mvarId\u2082] \u2190 apply mvar.mvarId! (mkConst ``Eq.propIntro)\n      | throwError \"unexpected number of subgoals when proving injective theorem for constructor '{ctorName}'\"\n    let (h, mvarId\u2081) \u2190 intro1 mvarId\u2081\n    let (_, mvarId\u2082) \u2190 intro1 mvarId\u2082\n    solveEqOfCtorEq ctorName mvarId\u2081 h\n    let mvarId\u2082 \u2190 casesAnd mvarId\u2082\n    let mvarId\u2082 \u2190 substEqs mvarId\u2082\n    applyRefl mvarId\u2082 (injTheoremFailureHeader ctorName)\n    mkLambdaFVars xs mvar\n\nprivate def mkInjectiveEqTheorem (ctorVal : ConstructorVal) : MetaM Unit := do\n  let some type \u2190 mkInjectiveEqTheoremType? ctorVal\n    | return ()\n  let value \u2190 mkInjectiveEqTheoremValue ctorVal.name type\n  let name := mkInjectiveEqTheoremNameFor ctorVal.name\n  addDecl <| Declaration.thmDecl {\n    name\n    levelParams := ctorVal.levelParams\n    type        := (\u2190 instantiateMVars type)\n    value       := (\u2190 instantiateMVars value)\n  }\n  addSimpTheorem (ext := simpExtension) name (post := true) (inv := false) AttributeKind.global (prio := eval_prio default)\n\nregister_builtin_option genInjectivity : Bool := {\n  defValue := true\n  descr    := \"generate injectivity theorems for inductive datatype constructors\"\n}\n\ndef mkInjectiveTheorems (declName : Name) : MetaM Unit := do\n  if (\u2190 getEnv).contains ``Eq.propIntro && genInjectivity.get (\u2190 getOptions) &&  !(\u2190 isInductivePredicate declName) then\n    let info \u2190 getConstInfoInduct declName\n    unless info.isUnsafe do\n      for ctor in info.ctors do\n        let ctorVal \u2190 getConstInfoCtor ctor\n        if ctorVal.numFields > 0 then\n          mkInjectiveTheorem ctorVal\n          mkInjectiveEqTheorem ctorVal\n\nend Lean.Meta\n", "meta": {"author": "Kha", "repo": "lean4-nightly", "sha": "b4c92de57090e6c47b29d3575df53d86fce52752", "save_path": "github-repos/lean/Kha-lean4-nightly", "path": "github-repos/lean/Kha-lean4-nightly/lean4-nightly-b4c92de57090e6c47b29d3575df53d86fce52752/stage0/src/Lean/Meta/Injective.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5234203489363239, "lm_q2_score": 0.4649015713733884, "lm_q1q2_score": 0.24333894270930426}}
{"text": "import system.io\nimport tactic\nimport data.nat.basic\nimport algebra.char_p\nimport ring_theory.power_series.basic\nimport combinatorics.partition\nimport data.nat.parity\nimport data.finset.nat_antidiagonal\nimport tactic.interval_cases\nimport tactic.apply_fun\n\n\nopen finset\nopen_locale big_operators\nopen_locale classical\n\n\nopen lean\ndef test1 := \"theorem group_with_all_squares_equal_to_one_is_abelian (G : Type*)\n   [group G] (hG : \u2200 x : G, x^2 = 1) :\n   \u2200 x y : G, x * y = y * x := sorry\"\n\ndef test2 := \"theorem binomial_theorem_char_p (F : Type*) [field F] (p : \u2115) (hp : char_p F p)\n  (a b : F) : (a + b)^p = \u2211 i in finset.range p, (p choose i) * a^i * b^(p - i) := sorry\"\n\n-- theorem binomial_theorem_char_p (F : Type*) [field F] (p : \u2115) (hp : char_p F p)\n--   (a b : F) : (a + b)^p = \u2211 i in finset.range p, (p choose i) * a^i * b^(p - i) := sorry\n\nmeta structure decl_parse_result : Type :=\n  (name : name)\n  (binders : list expr)\n  (type : expr)\n\nopen lean.parser\n\nmeta def binder.to_pi : binder \u2192 expr \u2192 expr\n| b body := expr.pi b.name b.info b.type body\n\nmeta def mk_type_mvar : tactic expr :=\ndo u \u2190 tactic.mk_meta_univ,\n   t \u2190 tactic.mk_meta_var (expr.sort u),\n   return t\n\nmeta def expr.local_binder_info : pexpr \u2192 binder_info\n  | (expr.local_const _ _ bi _) := bi\n  | _ := inhabited.default\n\nmeta def pexpr.local_uniq_name : pexpr \u2192 name\n  | (expr.local_const un _ _ _) := un\n  | _ := inhabited.default\n\n\nmeta def pi_intro (b : binder) : tactic expr := do\n  (main :: rest) \u2190 tactic.get_goals,\n  u \u2190 tactic.mk_meta_univ,\n  (new_goal, fvar) \u2190 tactic.unsafe.type_context.run (do\n    fvar \u2190 tactic.unsafe.type_context.push_local b.name b.type b.info,\n    new_goal \u2190 tactic.unsafe.type_context.mk_mvar `T (expr.sort u),\n    let assignment := binder.to_pi b $ expr.mk_delayed_abstraction new_goal [fvar.local_uniq_name],\n    tactic.unsafe.type_context.assign main assignment,\n    return (new_goal, fvar)\n  ),\n  tactic.set_goals (new_goal :: rest),\n  return fvar\n\nmeta def add_binders : list pexpr \u2192 parser unit\n  | [] := pure ()\n  | ((expr.local_const un pn bi t) :: tail) := do\n    parser.add_local (expr.local_const un pn bi (inhabited.default)),\n    add_binders tail\n  | _ := pure ()\n\nmeta def parse_decl : parser decl_parse_result := do\n  (tk \"theorem\" <|> tk \"def\"),\n  name \u2190 ident,\n  binders \u2190 interactive.parse_binders,\n  add_binders binders,\n  tk \":\",\n  smt \u2190 parser.pexpr 0,\n  tk \":=\",\n  (T,fvars) \u2190 parser.of_tactic (do\n   T \u2190 mk_type_mvar,\n   tactic.set_goals [T],\n   fvars : list expr \u2190 binders.mmap (\u03bb b, do\n         t \u2190 pure $ b.local_type,\n         type \u2190 tactic.i_to_expr ``(%%t : Sort*),\n         let b : binder := \u27e8b.local_pp_name, b.local_binder_info, type\u27e9,\n         fvar \u2190 pi_intro b,\n         pure fvar\n   ),\n   smt \u2190 tactic.i_to_expr ``(%%smt : Sort*),\n   tactic.exact smt,\n   T \u2190 tactic.instantiate_mvars T,\n   return (T, fvars)\n  ),\n  _ \u2190 fvars.mmap parser.add_local,\n  return {\n     name := name,\n     binders := fvars,\n     type := T,\n  }\n\n-- set_option pp.all true\n\n-- run_cmd do {\n--    d1 \u2190 parser.run_with_input parse_decl test1,\n--    tactic.trace d1.name,\n--    tactic.trace d1.type,\n--    -- this step errors\n--    d2 \u2190 parser.run_with_input parse_decl test2,\n--    tactic.trace d2.name,\n--    tactic.trace d2.type\n-- }\n\n", "meta": {"author": "zhangir-azerbayev", "repo": "lean-chat", "sha": "cc2832852e1858b879234b0a0f3ac7017df4a195", "save_path": "github-repos/lean/zhangir-azerbayev-lean-chat", "path": "github-repos/lean/zhangir-azerbayev-lean-chat/lean-chat-cc2832852e1858b879234b0a0f3ac7017df4a195/src/parse.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.45713671682749485, "lm_q1q2_score": 0.2428353088920698}}
{"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 \u2964 D} (h : W.is_inverted_by L) :\n  W.op.is_inverted_by L.op := \u03bb 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\u1d52\u1d56 \u2964 D} (h : W.op.is_inverted_by L):\n  W.is_inverted_by L.right_op := \u03bb 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 \u2964 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\u1d52\u1d56):\n  strict_universal_property_fixed_target L.op W.op E :=\n{ inverts := h.inverts.op,\n  lift := \u03bb F hF, (h.lift F.right_op hF.right_op).left_op,\n  fac := \u03bb 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 := \u03bb F\u2081 F\u2082 eq, begin\n    suffices : F\u2081.right_op = F\u2082.right_op,\n    { rw [\u2190 F\u2081.right_op_left_op_eq, \u2190 F\u2082.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 \u2192 F\nvariable  \u03c3 : 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 \u03c3.pc\n    (h_mem : mem_at mem code_validate_reduced_field_element \u03c3.pc)\n    -- all dependencies are in memory\n    (h_mem_0 : mem_at mem code_assert_nn (\u03c3.pc  - 152))\n    (h_mem_1 : mem_at mem code_assert_le (\u03c3.pc  - 148))\n    (h_mem_2 : mem_at mem code_assert_nn_le (\u03c3.pc  - 143))\n    -- input arguments on the stack\n    (hin_range_check_ptr : range_check_ptr = mem (\u03c3.fp - 6))\n    (hin_val : val = cast_BigInt3 mem (\u03c3.fp - 5))\n    -- conclusion\n  : ensures_ret mem \u03c3 (\u03bb \u03ba \u03c4,\n      \u2203 \u03bc \u2264 \u03ba, rc_ensures mem (rc_bound F) \u03bc (mem (\u03c3.fp - 6)) (mem $ \u03c4.ap - 1)\n        (spec_validate_reduced_field_element mem \u03ba range_check_ptr val (mem (\u03c4.ap - 1)))) :=\nbegin\n  apply ensures_of_ensuresb, intro \u03bdbound,\n  have h_mem_rec := h_mem,\n  unpack_memory code_validate_reduced_field_element at h_mem with \u27e8hpc0, 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\u27e9,\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 \u03ba_call6 ap6 h_call6,\n  rcases h_call6 with \u27e8h_call6_ap_offset, h_call6\u27e9,\n  rcases h_call6 with \u27e8rc_m6, rc_mle6, hl_range_check_ptr\u2081, h_call6\u27e9,\n  generalize' hr_rev_range_check_ptr\u2081: mem (ap6 - 1) = range_check_ptr\u2081,\n  have htv_range_check_ptr\u2081 := hr_rev_range_check_ptr\u2081.symm, clear hr_rev_range_check_ptr\u2081,\n  try { simp only [arg0 ,arg1 ,arg2] at hl_range_check_ptr\u2081 },\n  rw [\u2190htv_range_check_ptr\u2081, \u2190hin_range_check_ptr] at hl_range_check_ptr\u2081,\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\u2081 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\u2081] },\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\u2081] },\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\u2081] },\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 \u03ba_call11 ap11 h_call11,\n  rcases h_call11 with \u27e8h_call11_ap_offset, h_call11\u27e9,\n  rcases h_call11 with \u27e8rc_m11, rc_mle11, hl_range_check_ptr\u2082, h_call11\u27e9,\n  generalize' hr_rev_range_check_ptr\u2082: mem (ap11 - 1) = range_check_ptr\u2082,\n  have htv_range_check_ptr\u2082 := hr_rev_range_check_ptr\u2082.symm, clear hr_rev_range_check_ptr\u2082,\n  try { simp only [arg0 ,arg1] at hl_range_check_ptr\u2082 },\n  rw [\u2190htv_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2081] at hl_range_check_ptr\u2082,\n  try { simp only [arg0 ,arg1] at h_call11 },\n  rw [\u2190htv_range_check_ptr\u2081, hl_range_check_ptr\u2081, 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\u2082 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\u2081, htv_range_check_ptr\u2082] },\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\u2081, htv_range_check_ptr\u2082] },\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\u2081, htv_range_check_ptr\u2082] },\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 \u03ba_call16 ap16 h_call16,\n  rcases h_call16 with \u27e8h_call16_ap_offset, h_call16\u27e9,\n  rcases h_call16 with \u27e8rc_m16, rc_mle16, hl_range_check_ptr\u2083, h_call16\u27e9,\n  generalize' hr_rev_range_check_ptr\u2083: mem (ap16 - 1) = range_check_ptr\u2083,\n  have htv_range_check_ptr\u2083 := hr_rev_range_check_ptr\u2083.symm, clear hr_rev_range_check_ptr\u2083,\n  try { simp only [arg0 ,arg1] at hl_range_check_ptr\u2083 },\n  rw [\u2190htv_range_check_ptr\u2083, \u2190htv_range_check_ptr\u2082] at hl_range_check_ptr\u2083,\n  try { simp only [arg0 ,arg1] at h_call16 },\n  rw [\u2190htv_range_check_ptr\u2082, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083] },\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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083] },\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\u2083 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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083] },\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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083] },\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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083] },\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 \u03ba_call30 ap30 h_call30,\n      rcases h_call30 with \u27e8h_call30_ap_offset, h_call30\u27e9,\n      rcases h_call30 with \u27e8rc_m30, rc_mle30, hl_range_check_ptr\u2084, h_call30\u27e9,\n      generalize' hr_rev_range_check_ptr\u2084: mem (ap30 - 1) = range_check_ptr\u2084,\n      have htv_range_check_ptr\u2084 := hr_rev_range_check_ptr\u2084.symm, clear hr_rev_range_check_ptr\u2084,\n      try { simp only [arg0 ,arg1 ,arg2] at hl_range_check_ptr\u2084 },\n      rw [\u2190htv_range_check_ptr\u2084, \u2190htv_range_check_ptr\u2083] at hl_range_check_ptr\u2084,\n      try { simp only [arg0 ,arg1 ,arg2] at h_call30 },\n      rw [\u2190htv_range_check_ptr\u2083, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u2190htv_range_check_ptr\u2084, hl_range_check_ptr\u2084, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u03ba_call6],\n      use_only [range_check_ptr\u2081],\n      have rc_h_range_check_ptr\u2081 := range_checked_offset' rc_h_range_check_ptr,\n      have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n      have spec6 := h_call6 rc_h_range_check_ptr',\n      rw [\u2190hin_range_check_ptr, \u2190htv_range_check_ptr\u2081] at spec6,\n      try { dsimp at spec6, arith_simps at spec6 },\n      use_only [spec6],\n      use_only [\u03ba_call11],\n      use_only [range_check_ptr\u2082],\n      have rc_h_range_check_ptr\u2082 := range_checked_offset' rc_h_range_check_ptr\u2081,\n      have rc_h_range_check_ptr\u2082' := range_checked_add_right rc_h_range_check_ptr\u2082, try { norm_cast at rc_h_range_check_ptr\u2082' },\n      have spec11 := h_call11 rc_h_range_check_ptr\u2081',\n      rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190htv_range_check_ptr\u2082] at spec11,\n      try { dsimp at spec11, arith_simps at spec11 },\n      use_only [spec11],\n      use_only [\u03ba_call16],\n      use_only [range_check_ptr\u2083],\n      have rc_h_range_check_ptr\u2083 := range_checked_offset' rc_h_range_check_ptr\u2082,\n      have rc_h_range_check_ptr\u2083' := range_checked_add_right rc_h_range_check_ptr\u2083, try { norm_cast at rc_h_range_check_ptr\u2083' },\n      have spec16 := h_call16 rc_h_range_check_ptr\u2082',\n      rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2083] 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 [\u03ba_call30],\n      use_only [range_check_ptr\u2084],\n      have rc_h_range_check_ptr\u2084 := range_checked_offset' rc_h_range_check_ptr\u2083,\n      have rc_h_range_check_ptr\u2084' := range_checked_add_right rc_h_range_check_ptr\u2084, try { norm_cast at rc_h_range_check_ptr\u2084' },\n      have spec30 := h_call30 rc_h_range_check_ptr\u2083',\n      rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190hl_range_check_ptr\u2083, \u2190htv_range_check_ptr\u2084] 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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083, htv_range_check_ptr\u2084] }, },\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\u2083 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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083] },\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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083] },\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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083] },\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 \u03ba_call37 ap37 h_call37,\n      rcases h_call37 with \u27e8h_call37_ap_offset, h_call37\u27e9,\n      rcases h_call37 with \u27e8rc_m37, rc_mle37, hl_range_check_ptr\u2084, h_call37\u27e9,\n      generalize' hr_rev_range_check_ptr\u2084: mem (ap37 - 1) = range_check_ptr\u2084,\n      have htv_range_check_ptr\u2084 := hr_rev_range_check_ptr\u2084.symm, clear hr_rev_range_check_ptr\u2084,\n      try { simp only [arg0 ,arg1 ,arg2] at hl_range_check_ptr\u2084 },\n      rw [\u2190htv_range_check_ptr\u2084, \u2190htv_range_check_ptr\u2083] at hl_range_check_ptr\u2084,\n      try { simp only [arg0 ,arg1 ,arg2] at h_call37 },\n      rw [\u2190htv_range_check_ptr\u2083, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u2190htv_range_check_ptr\u2084, hl_range_check_ptr\u2084, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u03ba_call6],\n      use_only [range_check_ptr\u2081],\n      have rc_h_range_check_ptr\u2081 := range_checked_offset' rc_h_range_check_ptr,\n      have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n      have spec6 := h_call6 rc_h_range_check_ptr',\n      rw [\u2190hin_range_check_ptr, \u2190htv_range_check_ptr\u2081] at spec6,\n      try { dsimp at spec6, arith_simps at spec6 },\n      use_only [spec6],\n      use_only [\u03ba_call11],\n      use_only [range_check_ptr\u2082],\n      have rc_h_range_check_ptr\u2082 := range_checked_offset' rc_h_range_check_ptr\u2081,\n      have rc_h_range_check_ptr\u2082' := range_checked_add_right rc_h_range_check_ptr\u2082, try { norm_cast at rc_h_range_check_ptr\u2082' },\n      have spec11 := h_call11 rc_h_range_check_ptr\u2081',\n      rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190htv_range_check_ptr\u2082] at spec11,\n      try { dsimp at spec11, arith_simps at spec11 },\n      use_only [spec11],\n      use_only [\u03ba_call16],\n      use_only [range_check_ptr\u2083],\n      have rc_h_range_check_ptr\u2083 := range_checked_offset' rc_h_range_check_ptr\u2082,\n      have rc_h_range_check_ptr\u2083' := range_checked_add_right rc_h_range_check_ptr\u2083, try { norm_cast at rc_h_range_check_ptr\u2083' },\n      have spec16 := h_call16 rc_h_range_check_ptr\u2082',\n      rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2083] 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 [\u03ba_call37],\n      use_only [range_check_ptr\u2084],\n      have rc_h_range_check_ptr\u2084 := range_checked_offset' rc_h_range_check_ptr\u2083,\n      have rc_h_range_check_ptr\u2084' := range_checked_add_right rc_h_range_check_ptr\u2084, try { norm_cast at rc_h_range_check_ptr\u2084' },\n      have spec37 := h_call37 rc_h_range_check_ptr\u2083',\n      rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190hl_range_check_ptr\u2083, \u2190htv_range_check_ptr\u2084] 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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083, htv_range_check_ptr\u2084] }, },\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 [\u2190htv_range_check_ptr\u2083, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u03ba_call6],\n    use_only [range_check_ptr\u2081],\n    have rc_h_range_check_ptr\u2081 := range_checked_offset' rc_h_range_check_ptr,\n    have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n    have spec6 := h_call6 rc_h_range_check_ptr',\n    rw [\u2190hin_range_check_ptr, \u2190htv_range_check_ptr\u2081] at spec6,\n    try { dsimp at spec6, arith_simps at spec6 },\n    use_only [spec6],\n    use_only [\u03ba_call11],\n    use_only [range_check_ptr\u2082],\n    have rc_h_range_check_ptr\u2082 := range_checked_offset' rc_h_range_check_ptr\u2081,\n    have rc_h_range_check_ptr\u2082' := range_checked_add_right rc_h_range_check_ptr\u2082, try { norm_cast at rc_h_range_check_ptr\u2082' },\n    have spec11 := h_call11 rc_h_range_check_ptr\u2081',\n    rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190htv_range_check_ptr\u2082] at spec11,\n    try { dsimp at spec11, arith_simps at spec11 },\n    use_only [spec11],\n    use_only [\u03ba_call16],\n    use_only [range_check_ptr\u2083],\n    have rc_h_range_check_ptr\u2083 := range_checked_offset' rc_h_range_check_ptr\u2082,\n    have rc_h_range_check_ptr\u2083' := range_checked_add_right rc_h_range_check_ptr\u2083, try { norm_cast at rc_h_range_check_ptr\u2083' },\n    have spec16 := h_call16 rc_h_range_check_ptr\u2082',\n    rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2083] 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\u2081, htv_range_check_ptr\u2082, htv_range_check_ptr\u2083] }, },\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": "/-\nCopyright (c) 2019 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Lean.Meta.Basic\nimport Lean.Meta.FunInfo\nimport Lean.Meta.InferType\n\nnamespace Lean.Meta.DiscrTree\n/-\n  (Imperfect) discrimination trees.\n  We use a hybrid representation.\n  - A `PersistentHashMap` for the root node which usually contains many children.\n  - A sorted array of key/node pairs for inner nodes.\n\n  The edges are labeled by keys:\n  - Constant names (and arity). Universe levels are ignored.\n  - Free variables (and arity). Thus, an entry in the discrimination tree\n    may reference hypotheses from the local context.\n  - Literals\n  - Star/Wildcard. We use them to represent metavariables and terms\n    we want to ignore. We ignore implicit arguments and proofs.\n  - Other. We use to represent other kinds of terms (e.g., nested lambda, forall, sort, etc).\n\n  We reduce terms using `TransparencyMode.reducible`. Thus, all reducible\n  definitions in an expression `e` are unfolded before we insert it into the\n  discrimination tree.\n\n  Recall that projections from classes are **NOT** reducible.\n  For example, the expressions `Add.add \u03b1 (ringAdd ?\u03b1 ?s) ?x ?x`\n  and `Add.add Nat Nat.hasAdd a b` generates paths with the following keys\n  respctively\n  ```\n  \u27e8Add.add, 4\u27e9, *, *, *, *\n  \u27e8Add.add, 4\u27e9, *, *, \u27e8a,0\u27e9, \u27e8b,0\u27e9\n  ```\n\n  That is, we don't reduce `Add.add Nat inst a b` into `Nat.add a b`.\n  We say the `Add.add` applications are the de-facto canonical forms in\n  the metaprogramming framework.\n  Moreover, it is the metaprogrammer's responsibility to re-pack applications such as\n  `Nat.add a b` into `Add.add Nat inst a b`.\n\n  Remark: we store the arity in the keys\n  1- To be able to implement the \"skip\" operation when retrieving \"candidate\"\n     unifiers.\n  2- Distinguish partial applications `f a`, `f a b`, and `f a b c`.\n-/\n\ndef Key.ctorIdx : Key \u2192 Nat\n  | Key.star      => 0\n  | Key.other     => 1\n  | Key.lit _     => 2\n  | Key.fvar _ _  => 3\n  | Key.const _ _ => 4\n  | Key.arrow     => 5\n\ndef Key.lt : Key \u2192 Key \u2192 Bool\n  | Key.lit v\u2081,      Key.lit v\u2082      => v\u2081 < v\u2082\n  | Key.fvar n\u2081 a\u2081,  Key.fvar n\u2082 a\u2082  => Name.quickLt n\u2081 n\u2082 || (n\u2081 == n\u2082 && a\u2081 < a\u2082)\n  | Key.const n\u2081 a\u2081, Key.const n\u2082 a\u2082 => Name.quickLt n\u2081 n\u2082 || (n\u2081 == n\u2082 && a\u2081 < a\u2082)\n  | k\u2081,              k\u2082              => k\u2081.ctorIdx < k\u2082.ctorIdx\n\ninstance : LT Key := \u27e8fun a b => Key.lt a b\u27e9\ninstance (a b : Key) : Decidable (a < b) := inferInstanceAs (Decidable (Key.lt a b))\n\ndef Key.format : Key \u2192 Format\n  | Key.star                   => \"*\"\n  | Key.other                  => \"\u25fe\"\n  | Key.lit (Literal.natVal v) => fmt v\n  | Key.lit (Literal.strVal v) => repr v\n  | Key.const k _              => fmt k\n  | Key.fvar k _               => fmt k\n  | Key.arrow                  => \"\u2192\"\n\ninstance : ToFormat Key := \u27e8Key.format\u27e9\n\ndef Key.arity : Key \u2192 Nat\n  | Key.const _ a => a\n  | Key.fvar _ a  => a\n  | Key.arrow     => 2\n  | _             => 0\n\ninstance : Inhabited (Trie \u03b1) := \u27e8Trie.node #[] #[]\u27e9\n\ndef empty : DiscrTree \u03b1 := { root := {} }\n\npartial def Trie.format [ToFormat \u03b1] : Trie \u03b1 \u2192 Format\n  | Trie.node vs cs => Format.group $ Format.paren $\n    \"node\" ++ (if vs.isEmpty then Format.nil else \" \" ++ fmt vs)\n    ++ Format.join (cs.toList.map $ fun \u27e8k, c\u27e9 => Format.line ++ Format.paren (fmt k ++ \" => \" ++ format c))\n\ninstance [ToFormat \u03b1] : ToFormat (Trie \u03b1) := \u27e8Trie.format\u27e9\n\npartial def format [ToFormat \u03b1] (d : DiscrTree \u03b1) : Format :=\n  let (_, r) := d.root.foldl\n    (fun (p : Bool \u00d7 Format) k c =>\n      (false, p.2 ++ (if p.1 then Format.nil else Format.line) ++ Format.paren (fmt k ++ \" => \" ++ fmt c)))\n    (true, Format.nil)\n  Format.group r\n\ninstance [ToFormat \u03b1] : ToFormat (DiscrTree \u03b1) := \u27e8format\u27e9\n\n/- The discrimination tree ignores implicit arguments and proofs.\n   We use the following auxiliary id as a \"mark\". -/\nprivate def tmpMVarId : MVarId := `_discr_tree_tmp\nprivate def tmpStar := mkMVar tmpMVarId\n\ninstance : Inhabited (DiscrTree \u03b1) where\n  default := {}\n\n/--\n  Return true iff the argument should be treated as a \"wildcard\" by the discrimination tree.\n\n  - We ignore proofs because of proof irrelevance. It doesn't make sense to try to\n    index their structure.\n\n  - We ignore instance implicit arguments (e.g., `[Add \u03b1]`) because they are \"morally\" canonical.\n    Moreover, we may have many definitionally equal terms floating around.\n    Example: `Ring.hasAdd Int Int.isRing` and `Int.hasAdd`.\n\n  - We considered ignoring implicit arguments (e.g., `{\u03b1 : Type}`) since users don't \"see\" them,\n    and may not even understand why some simplification rule is not firing.\n    However, in type class resolution, we have instance such as `Decidable (@Eq Nat x y)`,\n    where `Nat` is an implicit argument. Thus, we would add the path\n    ```\n    Decidable -> Eq -> * -> * -> * -> [Nat.decEq]\n    ```\n    to the discrimination tree IF we ignored the implict `Nat` argument.\n    This would be BAD since **ALL** decidable equality instances would be in the same path.\n    So, we index implicit arguments if they are types.\n    This setting seems sensible for simplification lemmas such as:\n    ```\n    forall (x y : Unit), (@Eq Unit x y) = true\n    ```\n    If we ignore the implicit argument `Unit`, the `DiscrTree` will say it is a candidate\n    simplification lemma for any equality in our goal.\n\n  Remark: if users have problems with the solution above, we may provide a `noIndexing` annotation,\n  and `ignoreArg` would return true for any term of the form `noIndexing t`.\n-/\nprivate def ignoreArg (a : Expr) (i : Nat) (infos : Array ParamInfo) : MetaM Bool := do\n  if h : i < infos.size then\n    let info := infos.get \u27e8i, h\u27e9\n    if info.instImplicit then\n      return true\n    else if info.implicit then\n      return not (\u2190 isType a)\n    else\n      isProof a\n  else\n    isProof a\n\nprivate partial def pushArgsAux (infos : Array ParamInfo) : Nat \u2192 Expr \u2192 Array Expr \u2192 MetaM (Array Expr)\n  | i, Expr.app f a _, todo => do\n    if (\u2190 ignoreArg a i infos) then\n      pushArgsAux infos (i-1) f (todo.push tmpStar)\n    else\n      pushArgsAux infos (i-1) f (todo.push a)\n  | _, _, todo => return todo\n\nprivate partial def whnfEta (e : Expr) : MetaM Expr := do\n  let e \u2190 whnf e\n  match e.etaExpandedStrict? with\n  | some e => whnfEta e\n  | none   => return e\n\n/--\n  Return true if `e` is one of the following\n  - A nat literal (numeral)\n  - `Nat.zero`\n  - `Nat.succ x` where `isNumeral x`\n  - `OfNat.ofNat _ x _` where `isNumeral x` -/\nprivate partial def isNumeral (e : Expr) : Bool :=\n  if e.isNatLit then true\n  else\n    let f := e.getAppFn\n    if !f.isConst then false\n    else\n      let fName := f.constName!\n      if fName == ``Nat.succ && e.getAppNumArgs == 1 then isNumeral e.appArg!\n      else if fName == ``OfNat.ofNat && e.getAppNumArgs == 3 then isNumeral (e.getArg! 1)\n      else if fName == ``Nat.zero && e.getAppNumArgs == 0 then true\n      else false\n\nprivate def isNatType (e : Expr) : MetaM Bool :=\n  return (\u2190 whnf e).isConstOf ``Nat\n\n/--\n  Return true if `e` is one of the following\n  - `Nat.add _ k` where `isNumeral k`\n  - `Add.add Nat _ _ k` where `isNumeral k`\n  - `HAdd.hAdd _ Nat _ _ k` where `isNumeral k`\n  - `Nat.succ _`\n  This function assumes `e.isAppOf fName`\n-/\nprivate def isOffset (fName : Name) (e : Expr) : MetaM Bool := do\n  if fName == ``Nat.add && e.getAppNumArgs == 2 then\n    return isNumeral e.appArg!\n  else if fName == ``Add.add && e.getAppNumArgs == 4 then\n    if (\u2190 isNatType (e.getArg! 0)) then return isNumeral e.appArg! else return false\n  else if fName == ``HAdd.hAdd && e.getAppNumArgs == 6 then\n    if (\u2190 isNatType (e.getArg! 1)) then return isNumeral e.appArg! else return false\n  else\n    return fName == ``Nat.succ && e.getAppNumArgs == 1\n\n/-\n  TODO: add hook for users adding their own functions for controlling `shouldAddAsStar`\n  Different `DiscrTree` users may populate this set using, for example, attributes.\n\n  Remark: we currently tag `Nat.zero` and \"offset\" terms to avoid having to add special\n  support for `Expr.lit` and offset terms.\n  Example, suppose the discrimination tree contains the entry\n  `Nat.succ ?m |-> v`, and we are trying to retrieve the matches for `Expr.lit (Literal.natVal 1) _`.\n  In this scenario, we want to retrieve `Nat.succ ?m |-> v` -/\nprivate def shouldAddAsStar (fName : Name) (e : Expr) : MetaM Bool := do\n  if fName == `Nat.zero then\n    return true\n  else\n    isOffset fName e\n\ndef mkNoindexAnnotation (e : Expr) : Expr :=\n  mkAnnotation `noindex e\n\ndef hasNoindexAnnotation (e : Expr) : Bool :=\n  annotation? `noindex e |>.isSome\n\n/- Remark: we use `shouldAddAsStar` only for nested terms, and `root == false` for nested terms -/\n\nprivate def pushArgs (root : Bool) (todo : Array Expr) (e : Expr) : MetaM (Key \u00d7 Array Expr) := do\n  if hasNoindexAnnotation e then\n    return (Key.star, todo)\n  else\n    let e \u2190 whnfEta e\n    let fn := e.getAppFn\n    let push (k : Key) (nargs : Nat) : MetaM (Key \u00d7 Array Expr) := do\n      let info \u2190 getFunInfoNArgs fn nargs\n      let todo \u2190 pushArgsAux info.paramInfo (nargs-1) e todo\n      return (k, todo)\n    match fn with\n    | Expr.lit v _       => return (Key.lit v, todo)\n    | Expr.const c _ _   =>\n      unless root do\n        if (\u2190 shouldAddAsStar c e) then\n          return (Key.star, todo)\n      let nargs := e.getAppNumArgs\n      push (Key.const c nargs) nargs\n    | Expr.fvar fvarId _ =>\n      let nargs := e.getAppNumArgs\n      push (Key.fvar fvarId nargs) nargs\n    | Expr.mvar mvarId _ =>\n      if mvarId == tmpMVarId then\n        -- We use `tmp to mark implicit arguments and proofs\n        return (Key.star, todo)\n      else if (\u2190 isReadOnlyOrSyntheticOpaqueExprMVar mvarId) then\n        return (Key.other, todo)\n      else\n        return (Key.star, todo)\n    | Expr.forallE _ d b _ =>\n      if b.hasLooseBVars then\n        return (Key.other, todo)\n      else\n        return (Key.arrow, todo.push d |>.push b)\n    | _ =>\n      return (Key.other, todo)\n\npartial def mkPathAux (root : Bool) (todo : Array Expr) (keys : Array Key) : MetaM (Array Key) := do\n  if todo.isEmpty then\n    return keys\n  else\n    let e    := todo.back\n    let todo := todo.pop\n    let (k, todo) \u2190 pushArgs root todo e\n    mkPathAux false todo (keys.push k)\n\nprivate def initCapacity := 8\n\ndef mkPath (e : Expr) : MetaM (Array Key) := do\n  withReducible do\n    let todo : Array Expr := Array.mkEmpty initCapacity\n    let keys : Array Key  := Array.mkEmpty initCapacity\n    mkPathAux (root := true) (todo.push e) keys\n\nprivate partial def createNodes (keys : Array Key) (v : \u03b1) (i : Nat) : Trie \u03b1 :=\n  if h : i < keys.size then\n    let k := keys.get \u27e8i, h\u27e9\n    let c := createNodes keys v (i+1)\n    Trie.node #[] #[(k, c)]\n  else\n    Trie.node #[v] #[]\n\nprivate def insertVal [BEq \u03b1] (vs : Array \u03b1) (v : \u03b1) : Array \u03b1 :=\n  if vs.contains v then vs else vs.push v\n\nprivate partial def insertAux [BEq \u03b1] (keys : Array Key) (v : \u03b1) : Nat \u2192 Trie \u03b1 \u2192 Trie \u03b1\n  | i, Trie.node vs cs =>\n    if h : i < keys.size then\n      let k := keys.get \u27e8i, h\u27e9\n      let c := Id.run $ cs.binInsertM\n          (fun a b => a.1 < b.1)\n          (fun \u27e8_, s\u27e9 => let c := insertAux keys v (i+1) s; (k, c)) -- merge with existing\n          (fun _ => let c := createNodes keys v (i+1); (k, c))\n          (k, arbitrary)\n      Trie.node vs c\n    else\n      Trie.node (insertVal vs v) cs\n\ndef insertCore [BEq \u03b1] (d : DiscrTree \u03b1) (keys : Array Key) (v : \u03b1) : DiscrTree \u03b1 :=\n  if keys.isEmpty then panic! \"invalid key sequence\"\n  else\n    let k := keys[0]\n    match d.root.find? k with\n    | none =>\n      let c := createNodes keys v 1\n      { root := d.root.insert k c }\n    | some c =>\n      let c := insertAux keys v 1 c\n      { root := d.root.insert k c }\n\ndef insert [BEq \u03b1] (d : DiscrTree \u03b1) (e : Expr) (v : \u03b1) : MetaM (DiscrTree \u03b1) := do\n  let keys \u2190 mkPath e\n  return d.insertCore keys v\n\nprivate def getKeyArgs (e : Expr) (isMatch : Bool) : MetaM (Key \u00d7 Array Expr) := do\n  let e \u2190 whnfEta e\n  match e.getAppFn with\n  | Expr.lit v _       => return (Key.lit v, #[])\n  | Expr.const c _ _   =>\n    let nargs := e.getAppNumArgs\n    return (Key.const c nargs, e.getAppRevArgs)\n  | Expr.fvar fvarId _ =>\n    let nargs := e.getAppNumArgs\n    return (Key.fvar fvarId nargs, e.getAppRevArgs)\n  | Expr.mvar mvarId _ =>\n    if isMatch then\n      return (Key.other, #[])\n    else do\n      let ctx \u2190 read\n      if ctx.config.isDefEqStuckEx then\n        /-\n          When the configuration flag `isDefEqStuckEx` is set to true,\n          we want `isDefEq` to throw an exception whenever it tries to assign\n          a read-only metavariable.\n          This feature is useful for type class resolution where\n          we may want to notify the caller that the TC problem may be solveable\n          later after it assigns `?m`.\n          The method `DiscrTree.getUnify e` returns candidates `c` that may \"unify\" with `e`.\n          That is, `isDefEq c e` may return true. Now, consider `DiscrTree.getUnify d (Add ?m)`\n          where `?m` is a read-only metavariable, and the discrimination tree contains the keys\n          `HadAdd Nat` and `Add Int`. If `isDefEqStuckEx` is set to true, we must treat `?m` as\n          a regular metavariable here, otherwise we return the empty set of candidates.\n          This is incorrect because it is equivalent to saying that there is no solution even if\n          the caller assigns `?m` and try again. -/\n        return (Key.star, #[])\n      else if (\u2190 isReadOnlyOrSyntheticOpaqueExprMVar mvarId) then\n        return (Key.other, #[])\n      else\n        return (Key.star, #[])\n  | Expr.forallE _ d b _ =>\n    if b.hasLooseBVars then\n      return (Key.other, #[])\n    else\n      return (Key.arrow, #[d, b])\n  | _ =>\n    return (Key.other, #[])\n\nprivate abbrev getMatchKeyArgs (e : Expr) : MetaM (Key \u00d7 Array Expr) :=\n  getKeyArgs e (isMatch := true)\n\nprivate abbrev getUnifyKeyArgs (e : Expr) : MetaM (Key \u00d7 Array Expr) :=\n  getKeyArgs e (isMatch := false)\n\nprivate def getStarResult (d : DiscrTree \u03b1) : Array \u03b1 :=\n  let result : Array \u03b1 := Array.mkEmpty initCapacity\n  match d.root.find? Key.star with\n  | none                  => result\n  | some (Trie.node vs _) => result ++ vs\n\nprivate abbrev findKey (cs : Array (Key \u00d7 Trie \u03b1)) (k : Key) : Option (Key \u00d7 Trie \u03b1) :=\n  cs.binSearch (k, arbitrary) (fun a b => a.1 < b.1)\n\npartial def getMatch (d : DiscrTree \u03b1) (e : Expr) : MetaM (Array \u03b1) :=\n  withReducible do\n    let result := getStarResult d\n    let (k, args) \u2190 getMatchKeyArgs e\n    match k with\n    | Key.star => return result\n    | _        =>\n      match d.root.find? k with\n      | none   => return result\n      | some c => process args c result\nwhere\n  process (todo : Array Expr) (c : Trie \u03b1) (result : Array \u03b1) : MetaM (Array \u03b1) := do\n    match c with\n    | Trie.node vs cs =>\n      if todo.isEmpty then\n        return result ++ vs\n      else if cs.isEmpty then\n        return result\n      else\n        let e     := todo.back\n        let todo  := todo.pop\n        let first := cs[0] /- Recall that `Key.star` is the minimal key -/\n        let (k, args) \u2190 getMatchKeyArgs e\n        /- We must always visit `Key.star` edges since they are wildcards.\n           Thus, `todo` is not used linearly when there is `Key.star` edge\n           and there is an edge for `k` and `k != Key.star`. -/\n        let visitStar (result : Array \u03b1) : MetaM (Array \u03b1) :=\n          if first.1 == Key.star then\n            process todo first.2 result\n          else\n            return result\n        let visitNonStar (k : Key) (args : Array Expr) (result : Array \u03b1) : MetaM (Array \u03b1) :=\n          match findKey cs k with\n          | none   => result\n          | some c => process (todo ++ args) c.2 result\n        let result \u2190 visitStar result\n        match k with\n        | Key.star  => result\n        /-\n          Recall that dependent arrows are `(Key.other, #[])`, and non-dependent arrows are `(Key.arrow, #[a, b])`.\n          A non-dependent arrow may be an instance of a dependent arrow (stored at `DiscrTree`). Thus, we also visit the `Key.other` child.\n        -/\n        | Key.arrow => visitNonStar Key.other #[] (\u2190 visitNonStar k args result)\n        | _         => visitNonStar k args result\n\npartial def getUnify (d : DiscrTree \u03b1) (e : Expr) : MetaM (Array \u03b1) :=\n  withReducible do\n    let (k, args) \u2190 getUnifyKeyArgs e\n    match k with\n    | Key.star => d.root.foldlM (init := #[]) fun result k c => process k.arity #[] c result\n    | _ =>\n      let result := getStarResult d\n      match d.root.find? k with\n      | none   => return result\n      | some c => process 0 args c result\nwhere\n  process (skip : Nat) (todo : Array Expr) (c : Trie \u03b1) (result : Array \u03b1) : MetaM (Array \u03b1) := do\n    match skip, c with\n    | skip+1, Trie.node vs cs =>\n      if cs.isEmpty then\n        return result\n      else\n        cs.foldlM (init := result) fun result \u27e8k, c\u27e9 => process (skip + k.arity) todo c result\n    | 0, Trie.node vs cs => do\n      if todo.isEmpty then\n        return result ++ vs\n      else if cs.isEmpty then\n        return result\n      else\n        let e     := todo.back\n        let todo  := todo.pop\n        let (k, args) \u2190 getUnifyKeyArgs e\n        let visitStar (result : Array \u03b1) : MetaM (Array \u03b1) :=\n          let first := cs[0]\n          if first.1 == Key.star then\n            process 0 todo first.2 result\n          else\n            return result\n        let visitNonStar (k : Key) (args : Array Expr) (result : Array \u03b1) : MetaM (Array \u03b1) :=\n          match findKey cs k with\n          | none   => result\n          | some c => process 0 (todo ++ args) c.2 result\n        match k with\n        | Key.star  => cs.foldlM (init := result) fun result \u27e8k, c\u27e9 => process k.arity todo c result\n        -- See comment a `getMatch` regarding non-dependent arrows vs dependent arrows\n        | Key.arrow => visitNonStar Key.other #[] (\u2190 visitNonStar k args (\u2190 visitStar result))\n        | _         => visitNonStar k args (\u2190 visitStar result)\n\nend Lean.Meta.DiscrTree\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/stage0/src/Lean/Meta/DiscrTree.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.4532618480153861, "lm_q1q2_score": 0.24253970262942712}}
{"text": "import ReactorModel.Objects.Reaction\n\nopen Reactor (Component)\n\nclass ReactorType (\u03b1 : Type) where\n  ports : \u03b1 \u2192 Kind \u2192 ID \u21c0 Value             \n  acts  : \u03b1 \u2192 ID \u21c0 Action\n  state : \u03b1 \u2192 ID \u21c0 Value            \n  rcns  : \u03b1 \u2192 ID \u21c0 Reaction         \n  nest  : \u03b1 \u2192 ID \u21c0 \u03b1      \n \nnamespace ReactorType\n\nabbrev cptType [ReactorType \u03b1] : Component \u2192 Type\n  | .rtr     => \u03b1 \n  | .rcn     => Reaction\n  | .val cpt => cpt.type\n\nabbrev cpt? [inst : ReactorType \u03b1] : (cpt : Component) \u2192 \u03b1 \u2192 ID \u21c0 inst.cptType cpt\n  | .rtr   => nest \n  | .rcn   => rcns\n  | .prt k => (ports \u00b7 k)\n  | .act   => acts\n  | .stv   => state\n\ninductive Member [ReactorType \u03b1] (cpt : Component) (i : ID) : \u03b1 \u2192 Type _ \n  | final : (i \u2208 cpt? cpt rtr) \u2192 Member cpt i rtr\n  | nest : (nest rtr\u2081 j = some rtr\u2082) \u2192 (m : Member cpt i rtr\u2082) \u2192 Member cpt i rtr\u2081\n\nclass Extensional (\u03b1) extends ReactorType \u03b1 where\n  ext_iff : \n    rtr\u2081 = rtr\u2082 \u2194 \n    (ports rtr\u2081 = ports rtr\u2082) \u2227 (acts rtr\u2081 = acts rtr\u2082) \u2227 (state rtr\u2081 = state rtr\u2082) \u2227 \n    (rcns rtr\u2081 = rcns rtr\u2082) \u2227 (nest rtr\u2081 = nest rtr\u2082)\n\n@[ext]\ntheorem Extensional.ext [inst : Extensional \u03b1] {rtr\u2081 rtr\u2082 : \u03b1} : \n    (ports rtr\u2081 = ports rtr\u2082) \u2227 (acts rtr\u2081 = acts rtr\u2082) \u2227 (state rtr\u2081 = state rtr\u2082) \u2227 \n    (rcns rtr\u2081 = rcns rtr\u2082) \u2227 (nest rtr\u2081 = nest rtr\u2082) \u2192 rtr\u2081 = rtr\u2082 \n  := inst.ext_iff.mpr\n\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/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5736784074525096, "lm_q2_score": 0.4225046348141883, "lm_q1q2_score": 0.24238178604150773}}
{"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 \u27f6 Y) [is_iso f] :\n  function.bijective ((forget _).map f) :=\nby { rw \u2190 is_iso_iff_bijective, apply_instance, }\n\nlemma strong_epi_of_is_split_epi\n  {C : Type*} [category C] {A B : C} (f : A \u27f6 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 \u226b u,\n    fac_left' := by simp only [\u2190 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 \u2964 D) {A B : C} (f : A \u27f6 B)\n\nnamespace functor\n\ndef is_split_epi_iff [full F] [faithful F] : is_split_epi f \u2194 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 \u2964 C} (adj : F \u22a3 F') (f : A \u27f6 B)\n  [h\u2081 : preserves_monomorphisms F']\n  [h\u2082 : preserves_epimorphisms F] :\n  strong_epi f \u2192 strong_epi (F.map f) :=\nbegin\n  introI hf,\n  refine \u27e8infer_instance, _\u27e9,\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 \u27f6 B} {g : A' \u27f6 B'}\n  (e : arrow.mk f \u2245 arrow.mk g) [h : strong_epi f] : strong_epi g :=\n{ epi := begin\n    haveI : epi (f \u226b (arrow.right_func.map_iso e).hom) := epi_comp _ _,\n    have eq : g = (arrow.left_func.map_iso e).inv \u226b f \u226b\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 := \u03bb 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 \u27f6 B} {g : A' \u27f6 B'}\n  (e : arrow.mk f \u2245 arrow.mk g) : strong_epi f \u2194 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 \u2964 D} (e : F \u2245 G) (f : arrow C) :\n  F.map_arrow.obj f \u2245 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 \u2194 strong_epi (F.map f) :=\nbegin\n  split,\n  { introI,\n    apply_instance, },\n  { introI,\n    have e : arrow.mk f \u2245 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 _ \u226b s.m)),\n  { simp only [\u2190 F.mono_map_iff_mono, as_equivalence_counit, image_preimage],\n    apply mono_comp, },\n  haveI : strong_epi (F.preimage (s.e \u226b F.as_equivalence.counit_iso.inv.app _)),\n  { simp only [\u2190 @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 _ \u226b s.m),\n    e := F.preimage (s.e \u226b 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\u27e8\u03bb 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\u27e9\n\nend functor\n\nend category_theory\n\nopen category_theory\n\nnamespace simplex_category\n\nlemma skeletal_equivalence.functor.map_eq\n  {\u0394\u2081 \u0394\u2082 : simplex_category} (f : \u0394\u2081 \u27f6 \u0394\u2082) :\n  coe_fn (simplex_category.skeletal_equivalence.{u}.functor.map f) =\n    ulift.up \u2218 f.to_order_hom \u2218 ulift.down := rfl\n\nlemma skeletal_equivalence.functor.surjective_iff_map\n  {\u0394\u2081 \u0394\u2082 : simplex_category} (f : \u0394\u2081 \u27f6 \u0394\u2082) :\n  function.surjective f.to_order_hom \u2194\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  {\u0394\u2081 \u0394\u2082 : simplex_category} (f : \u0394\u2081 \u27f6 \u0394\u2082) :\n  function.injective f.to_order_hom \u2194\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 \u27f6 B) :\n  epi f \u2194 function.surjective f :=\nbegin\n  have eq := simplex_category.skeletal_equivalence.counit_iso.hom.naturality f,\n  simp only [\u2190 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 [\u2190 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    \u2190 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\u27e8\u03bb X Y f hf, begin\n  have H : \u2200 (y : Y), nonempty (f\u207b\u00b9' { y }),\n  { rw epi_iff_surjective at hf,\n    intro y,\n    exact nonempty.intro \u27e8(hf y).some, (hf y).some_spec\u27e9, },\n  let \u03c6 : Y \u2192 X := \u03bb y, (H y).some.1,\n  have h\u03c6 : \u2200 (y : Y), f (\u03c6 y) = y := \u03bb y, (H y).some.2,\n  refine is_split_epi.mk' \u27e8\u27e8\u03c6, _\u27e9, _\u27e9, swap,\n  { ext b,\n    apply h\u03c6, },\n  { intros a b,\n    contrapose,\n    intro h,\n    simp only [not_le] at h \u22a2,\n    suffices : b \u2264 a,\n    { cases this.lt_or_eq with h\u2081 h\u2082,\n      { assumption, },\n      { exfalso,\n        simpa only [h\u2082, lt_self_iff_false] using h, }, },\n    simpa only [h\u03c6] using f.monotone (le_of_lt h), },\nend\u27e9\n\nlemma mono_iff_injective {A B : NonemptyFinLinOrd.{u}} {f : A \u27f6 B} :\n  mono f \u2194 function.injective f :=\nbegin\n  have eq := simplex_category.skeletal_equivalence.counit_iso.hom.naturality f,\n  simp only [\u2190 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 [\u2190 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    \u2190 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 \u27f6 Y) :\n  limits.strong_epi_mono_factorisation f :=\nbegin\n  let I : NonemptyFinLinOrd.{u} := \u27e8set.image (coe_fn f) \u22a4, \u27e8\u27e9\u27e9,\n  let e : X \u27f6 I := \u27e8\u03bb x, \u27e8f x, \u27e8x, by tidy\u27e9\u27e9, \u03bb x\u2081 x\u2082 h, f.monotone h\u27e9,\n  let m : I \u27f6 Y := \u27e8\u03bb y, y, by tidy\u27e9,\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\u27e8\u03bb X Y f, nonempty.intro (NonemptyFinLinOrd.strong_epi_mono_factorisation f)\u27e9\n\nend NonemptyFinLinOrd\n\nnamespace simplex_category\n\nopen category_theory.limits\n\ninstance : split_epi_category simplex_category :=\n\u27e8\u03bb X Y f, begin\n  introI,\n  rw \u2190 simplex_category.skeletal_equivalence.{0}.functor.is_split_epi_iff,\n  apply is_split_epi_of_epi,\nend\u27e9\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 {\u0394 \u0394' \u0394'' : simplex_category } {\u03c6 : \u0394 \u27f6 \u0394''}\n  {e : \u0394 \u27f6 \u0394'} [epi e] {i : \u0394' \u27f6 \u0394''} [mono i] (fac : e \u226b i = \u03c6) :\n  image \u03c6 = \u0394' :=\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_\u03b9_eq {\u0394 \u0394'' : simplex_category } {\u03c6 : \u0394 \u27f6 \u0394''}\n  {e : \u0394 \u27f6 image \u03c6} [epi e] {i : image \u03c6 \u27f6 \u0394''} [mono i] (fac : e \u226b i = \u03c6) :\n  image.\u03b9 \u03c6 = i :=\nbegin\n  haveI := strong_epi_of_epi e,\n  rw \u2190 image.iso_strong_epi_mono_hom_comp_\u03b9 e i fac,\n  conv_lhs { rw \u2190 category.id_comp (image.\u03b9 \u03c6), },\n  congr,\n  symmetry,\n  apply simplex_category.eq_id_of_is_iso,\n  apply_instance,\nend\n\nlemma factor_thru_image_eq {\u0394 \u0394'' : simplex_category } {\u03c6 : \u0394 \u27f6 \u0394''}\n  {e : \u0394 \u27f6 image \u03c6} [epi e] {i : image \u03c6 \u27f6 \u0394''} [mono i] (fac : e \u226b i = \u03c6) :\n  factor_thru_image \u03c6 = e :=\nby rw [\u2190 cancel_mono i, fac, \u2190 image_\u03b9_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\u2080 u\u2081 u\u2082\n\nnamespace temporal\nnamespace feasibility\nopen fairness predicate nat\nlocal infix ` \u2243 `:75 := v_eq\nsection feasibility\n\nparameters {\u03b1 : Type u}\nparameters {evt : Type u\u2082}\nparameters {p : pred' \u03b1}\nparameters (A : evt \u2192 act \u03b1)\nparameters {cs\u2080 fs\u2080 : evt \u2192 pred' \u03b1}\nparameters (J : pred' \u03b1)\nparameters [inhabited evt] [inhabited \u03b1]\n\nparameter init_FIS : \u2203 s, s \u22a8 p\nparameter init_INV : \u2200 s, s \u22a8 p \u2192 s \u22a8 J\nparameter DLF : \u2200 s, s \u22a8 J \u2192 \u2203 e, s \u22a8 cs\u2080 e \u2227 s \u22a8 fs\u2080 e\nparameter evt_FIS : \u2200 e s, s \u22a8 J \u2192 s \u22a8 cs\u2080 e \u2192 s \u22a8 fs\u2080 e \u2192 \u2203 s', A e s s'\nparameter evt_INV : \u2200 e s s', A e s s' \u2192 s \u22a8 J \u2192 s' \u22a8 J\n\ndef SPEC\u2080 (v : tvar \u03b1) : cpred :=\nspec p cs\u2080 fs\u2080 A v\n\ndef p' : pred' (unit \u00d7 \u03b1) :=\np ! pair.snd\n\ndef q' : pred' (unit \u00d7 unit) :=\nTrue\n\nopen prod\ndef A' (e : evt) : act (unit \u00d7 \u03b1) :=\n\u03bb \u03c3 \u03c3',\n     (A e on snd) \u03c3 \u03c3'\n\ndef C (e : evt) : act (unit \u00d7 unit) :=\n\u03bb _ _, true\n\ndef C' (e : evt) : act (evt \u00d7 unit \u00d7 unit) :=\n\u03bb \u27e8sch,_\u27e9 _, sch = e\n\nabbreviation J' : pred' (unit \u00d7 \u03b1 \u00d7 unit) :=\nJ ! pair.fst ! pair.snd\n\nabbreviation cs\u2080' (e : evt) : pred' (unit \u00d7 \u03b1) :=\ncs\u2080 e ! pair.snd\n\nabbreviation fs\u2080' (e : evt) : pred' (unit \u00d7 \u03b1) :=\nfs\u2080 e ! pair.snd\n\nabbreviation cs\u2081 (e : evt) : pred' (unit \u00d7 unit) :=\nTrue\n\nabbreviation fs\u2081 (e : evt) : pred' (unit \u00d7 unit) :=\nTrue\nsection\ninclude init_FIS init_INV DLF\nlemma SIM\u2080' (v o : unit)\n  (h : (o, v) \u22a8 q')\n: (\u2203 (w : \u03b1), (o, w) \u22a8 p' \u2227 (o, w, v) \u22a8 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 : \u03b1) (v o v' o' : unit) (e : evt)\n  (hJ : (o, w, v) \u22a8 J')\n  (_ : true)\n  (_ : true)\n  (_ : true)\n  (hC : C e (o, v) (o', v'))\n: (\u2203 (w' : \u03b1),\n        (o,w) \u22a8 cs\u2080' e \u2227\n        (o,w) \u22a8 fs\u2080' e \u2227\n        A' e (o, w) (o', w') \u2227\n        (o', w', v') \u22a8 J') :=\nbegin\n  -- simp [comp,A',on_fun] at *,\n  -- casesm* [_ \u2227 _, Exists _, unit],\n  -- constructor_matching* [_ \u2227 _],\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 := \u2191()\n\n-- parameter Hpo\n-- : \u2200 c a e, one_to_one_po' (SPEC\u2080.saf a o \u22c0 \u25fb(J ! \u2983o,a,c\u2984))\n--          \u27e8cs\u2081 e,fs\u2081 e,C' e\u27e9\n--          \u27e8cs\u2080 e,fs\u2080 e,A' e\u27e9 \u2983o,c\u2984 \u2983o,a\u2984)\n\ndef SPEC\u2080.saf' (v : tvar \u03b1) (sch : tvar evt) : cpred :=\nspec_saf_spec p' cs\u2080' fs\u2080' A' \u2983o,v\u2984 sch\n\ndef SPEC\u2081 (v : tvar unit) : cpred :=\nspec q' cs\u2081 fs\u2081 C \u2983o,v\u2984\n\nlemma Hpo'\n : \u2200 c a e sch, one_to_one_po' (SPEC\u2081 c \u22c0 SPEC\u2080.saf' a sch \u22c0 \u25fb(J' ! \u2983o,a,c\u2984))\n         \u27e8cs\u2081 e!pair.snd,fs\u2081 e!pair.snd,one_to_one.C' C e\u27e9\n         \u27e8cs\u2080' e,fs\u2080' e,A' e\u27e9 \u2983sch,o,c\u2984 \u2983o,a\u2984 :=\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\u2081,q',sched,SPEC\u2080.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: \u22a9 (\u2203\u2203 v, SPEC\u2080 v) :=\nbegin [temporal]\n  have := temporal.feasibility.SIM',\n  have :=  @one_to_one.refinement \u03b1 unit unit evt\n     temporal.feasibility.p' temporal.feasibility.q'\n       temporal.feasibility.A'\n       temporal.feasibility.C\n       temporal.feasibility.cs\u2080'\n       temporal.feasibility.fs\u2080'\n       temporal.feasibility.cs\u2081\n       temporal.feasibility.fs\u2081\n       temporal.feasibility.J' True _ _\n       _ _\n       temporal.feasibility.SIM\u2080'\n       temporal.feasibility.SIM'\n       o _ _ \u0393 _,\n  { simp [one_to_one.SPEC\u2080,SPEC\u2080] at this \u22a2,\n    casesm* [p_exists _, _ \u22c0 _],\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\u2081,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 {\u03b9 : Type} {\u03b1 : Type*}\n[linear_order \u03b9]\n\n@[mk_iff]\nstructure Stream.mul.ready {\u03b9 : Type} (a : Stream \u03b9 \u03b1) (b : Stream \u03b9 \u03b1) (s : a.\u03c3 \u00d7 b.\u03c3) : Prop :=\n(v\u2081 : a.valid s.1)\n(v\u2082 : b.valid s.2)\n(r\u2081 : a.ready s.1)\n(r\u2082 : b.ready s.2)\n(index : a.index s.1 v\u2081 = b.index s.2 v\u2082)\n\nsection defs\nvariables [has_mul \u03b1]\n\n@[simps]\ninstance : has_mul (Stream \u03b9 \u03b1) := \u27e8\u03bb (a b : Stream \u03b9 \u03b1),\n{ \u03c3 := a.\u03c3 \u00d7 b.\u03c3,\n  valid := \u03bb p, a.valid p.1 \u2227 b.valid p.2,\n  ready := \u03bb p, Stream.mul.ready a b p,\n  next  := \u03bb p hv,\n  if a.to_order p.1 \u2264 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 := \u03bb p hv, max (a.index p.1 hv.1) (b.index p.2 hv.2),\n  value := \u03bb p hr, a.value p.1 hr.r\u2081 * b.value p.2 hr.r\u2082 }\u27e9\n\nend defs\n\n\nsection index_lemmas\nvariables [has_mul \u03b1]\n\nlemma Stream.mul.ready.index' {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} {x y} (h : (a * b).ready (x, y)) :\n  a.index' x = b.index' y :=\nby simp [Stream.index'_val h.v\u2081, Stream.index'_val h.v\u2082, h.index]\n\nlemma Stream.mul.ready.order_eq {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} {x y} (h : (a * b).ready (x, y)) :\n  a.to_order x = b.to_order y :=\nby ext : 1; simp [h.r\u2081, h.r\u2082, h.index']\n\nlemma Stream.mul_index' (a : Stream \u03b9 \u03b1) (b : Stream \u03b9 \u03b1) (xy : a.\u03c3 \u00d7 b.\u03c3) :\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 \u03b1]\n\nlemma Stream.mul_eval\u2080_of_neq {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} {x y} (h : a.to_order x \u2260 b.to_order y) (H) :\n  (a * b).eval\u2080 (x, y) H = 0 :=\nby { contrapose! h, apply Stream.mul.ready.order_eq, simp [Stream.eval\u2080] at h, exact h.fst, }\n\nlemma Stream.mul_eval\u2080 (a : Stream \u03b9 \u03b1) (b : Stream \u03b9 \u03b1) (x : a.\u03c3) (y : b.\u03c3) (H) :\n  (a * b).eval\u2080 (x, y) H = (a.eval\u2080 x H.1) * (b.eval\u2080 y H.2) :=\nbegin\n  rw [Stream.eval\u2080], split_ifs with hr,\n  { simp [Stream.eval\u2080, hr.r\u2081, hr.r\u2082, hr.index], },\n  simp [Stream.mul.ready_iff, H.1, H.2] at hr,\n  simp [Stream.eval\u2080], split_ifs with h\u2081 h\u2082; try { simp },\n  rw finsupp.mul_single_eq_zero _ _ (hr h\u2081 h\u2082),\nend\n\n/-- This lemma states that if `a.to_order x \u2264 b.to_order y`, \n  then the support of `a.eval\u2080 x h\u2081` (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 \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} (hb : b.simple) {x : a.\u03c3} {y : b.\u03c3}\n  (h\u2081 : a.valid x) (h\u2082 : b.valid y) (H : a.to_order x \u2264 b.to_order y) (n : \u2115) :\n  disjoint (a.eval\u2080 x h\u2081).support (b.eval_steps n (b.next y h\u2082)).support :=\nbegin\n  -- Assume `a` is ready, or else `a.eval\u2080 x h\u2081 = 0` has trivial support.\n  by_cases hr : a.ready x, swap, { simp [Stream.eval\u2080, hr], },\n  rw finset.disjoint_iff_ne,\n  intros i\u2081 hi\u2081 i\u2082 hi\u2082,\n  cases finset.mem_singleton.mp (a.eval\u2080_support _ _ hi\u2081),\n  rw le_iff_eq_or_lt at H,\n  refine ne_of_lt (with_top.coe_lt_coe.mp _), rw \u2190 Stream.index'_val h\u2081,\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\u2082 H.2 _ hi\u2082, },\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\u2082).trans (hb.monotonic.index_le_support _ hi\u2082),\nend\n\nlemma Stream.mul_eq_zero {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} (hb : b.simple) {x : a.\u03c3} {y : b.\u03c3}\n  (h\u2081 : a.valid x) (h\u2082 : b.valid y) (H : a.to_order x \u2264 b.to_order y) (n : \u2115) :\n  a.eval\u2080 x h\u2081 * b.eval_steps n (b.next y h\u2082) = 0 :=\nby { rw [finsupp.mul_eq_zero_of_disjoint_support], exact Stream.mul_eq_zero_aux hb h\u2081 h\u2082 H n, }\n\nlemma Stream.mul_eq_zero' {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} (ha : a.simple) {x : a.\u03c3} {y : b.\u03c3}\n  (h\u2081 : a.valid x) (h\u2082 : b.valid y) (H : b.to_order y \u2264 a.to_order x) (n : \u2115) :\n  a.eval_steps n (a.next x h\u2081) * b.eval\u2080 y h\u2082 = 0 :=\nby { rw [finsupp.mul_eq_zero_of_disjoint_support], exact (Stream.mul_eq_zero_aux ha h\u2082 h\u2081 H n).symm, }\n\nend value_lemmas\n\n\n@[elab_as_eliminator]\ntheorem Stream.mul_induction [has_mul \u03b1] {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} {x : a.\u03c3} {y : b.\u03c3}\n  {B\u2081 B\u2082 : \u2115} (ha : a.bound_valid B\u2081 x) (hb : b.bound_valid B\u2082 y)\n  (P : \u2200 (x : a.\u03c3) (y : b.\u03c3) (k\u2081 : \u2115) (k\u2082 : \u2115) (N : \u2115), Prop)\n  (hP_base : \u2200 (x y), P x y 0 0 0)\n  (hP_invalid : \u2200 (x y B\u2081 B\u2082 N) (H : \u00ac(a * b).valid (x, y)) (hvx : \u00aca.valid x \u2228 \u00acb.valid y), a.bound_valid B\u2081 x \u2192 b.bound_valid B\u2082 y \u2192 P x y B\u2081 B\u2082 N)\n  (hP_advance_a : \u2200 (x y k\u2081 k\u2082 N) (H : (a * b).valid (x, y)), a.to_order x \u2264 b.to_order y \u2192 P (a.next x H.1) y k\u2081 (k\u2082 + 1) N \u2192 P x y (k\u2081 + 1) (k\u2082 + 1) (N + 1))\n  (hP_advance_b : \u2200 (x y k\u2081 k\u2082 N) (H : (a * b).valid (x, y)), b.to_order y < a.to_order x \u2192 P x (b.next y H.2) (k\u2081 + 1) k\u2082 N \u2192 P x y (k\u2081 + 1) (k\u2082 + 1) (N + 1)) :\n  P x y B\u2081 B\u2082 (B\u2081 + B\u2082) :=\nbegin\n  suffices : \u2200 n, n = B\u2081 + B\u2082 \u2192 \u2203 (k\u2081 k\u2082 : \u2115), k\u2081 \u2264 B\u2081 \u2227 k\u2082 \u2264 B\u2082 \u2227 n = k\u2081 + k\u2082 \u2227 P x y k\u2081 k\u2082 n,\n  { obtain \u27e8k\u2081, k\u2082, hk\u2081, hk\u2082, hn, he\u27e9 := this (B\u2081 + B\u2082) rfl,\n    obtain \u27e8rfl, rfl\u27e9 : k\u2081 = B\u2081 \u2227 k\u2082 = B\u2082 := by split; linarith only [hk\u2081, hk\u2082, hn],\n    exact he, },\n  intros n hn,\n  induction n with n ih generalizing B\u2081 B\u2082 x y,\n  { use [0, 0], simpa using hP_base x y, },\n  by_cases H : (a * b).valid (x, y), swap,\n  { refine \u27e8B\u2081, B\u2082, rfl.le, rfl.le, hn, hP_invalid _ _ _ _ _ H _ ha hb\u27e9, \n    simpa [not_and_distrib] using H, },\n  cases B\u2081, { cases H.1.bound_pos ha, },\n  cases B\u2082, { cases H.2.bound_pos hb, },\n  simp [nat.succ_eq_add_one, \u2190 add_assoc] at hn,\n  by_cases h : a.to_order x \u2264 b.to_order y,\n  { -- Advance `a` (i.e. `a` \u2264 `b`)\n    rw [Stream.bound_valid_succ] at ha,\n    obtain \u27e8k\u2081, k\u2082, hk\u2081, hk\u2082, rfl, he\u27e9 := ih (ha H.1) hb (hn.trans (add_right_comm _ _ _)),\n    refine \u27e8k\u2081 + 1, k\u2082, nat.succ_le_succ hk\u2081, hk\u2082, (add_right_comm k\u2081 k\u2082 1), _\u27e9,\n    cases k\u2082, { exfalso, linarith only [hn, hk\u2081], },\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 \u27e8k\u2081, k\u2082, hk\u2081, hk\u2082, rfl, he\u27e9 := ih ha (hb H.2) hn,\n    refine \u27e8k\u2081, k\u2082 + 1, hk\u2081, nat.succ_le_succ  hk\u2082, rfl, _\u27e9,\n    cases k\u2081, { exfalso, linarith only [hn, hk\u2082], },\n    apply hP_advance_b _ _ _ _ _ H (lt_of_not_le h) he, }\nend\n\ntheorem Stream.mul_spec_value [non_unital_non_assoc_semiring \u03b1] {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} (hsa : a.simple) (hsb : b.simple)\n  {x y B\u2081 B\u2082} (ha : a.bound_valid B\u2081 x) (hb : b.bound_valid B\u2082 y) :\n  (a * b).eval_steps (B\u2081 + B\u2082) (x, y) = (a.eval_steps B\u2081 x) * (b.eval_steps B\u2082 y) :=\nbegin\n  apply Stream.mul_induction ha hb (\u03bb x y k\u2081 k\u2082 N, (a * b).eval_steps N (x, y) = (a.eval_steps k\u2081 x) * (b.eval_steps k\u2082 y)); clear_except hsa hsb,\n  { intros, simp, },\n  { intros x y B\u2081 B\u2082 N H h ha hb,\n    cases h; simp [H, Stream.eval_invalid h, Stream.eval_invalid H], },\n  { intros x y k\u2081 k\u2082 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\u2080], },\n  { intros x y k\u2081 k\u2082 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\u2080, Stream.mul_eq_zero' hsa H.1 H.2 h.le], },\nend\n\ntheorem Stream.mul_spec_index [has_mul \u03b1] {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1}\n  {x y B\u2081 B\u2082} (ha : a.bound_valid B\u2081 x) (hb : b.bound_valid B\u2082 y) :\n  ((a * b).valid ((a * b).next'^[B\u2081 + B\u2082] (x, y)) \u2192 ((a * b).next'^[B\u2081 + B\u2082] (x, y)) = (a.next'^[B\u2081] x, b.next'^[B\u2082] y)) :=\nbegin\n  apply Stream.mul_induction ha hb (\u03bb x y k\u2081 k\u2082 N, (a * b).valid ((a * b).next'^[N] (x, y)) \u2192 ((a * b).next'^[N] (x, y)) = (a.next'^[k\u2081] x, b.next'^[k\u2082] y)); clear_except hsa hsb,\n  { intros, simp, },\n  { intros x y B\u2081 B\u2082 N H h ha hb, simp only [Stream.next'_val_invalid' H], exact false.elim \u2218 H, },\n  { intros x y k\u2081 k\u2082 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\u2081 k\u2082 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 {\u03b9 : Type} {\u03b1 : Type*} [linear_order \u03b9] [has_mul \u03b1] : has_mul (StreamExec \u03b9 \u03b1) := \u27e8\u03bb 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 [\u2190 bound_valid_iff_next'_iterate],\n    exact a.bound_valid,\n  end }\u27e9\n\nlemma StreamExec.mul_spec [non_unital_non_assoc_semiring \u03b1] (a : StreamExec \u03b9 \u03b1) (b : StreamExec \u03b9 \u03b1) (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 \u03b1] {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} (hsa : a.monotonic) (hsb : b.monotonic) :\n  (a * b).monotonic :=\nbegin\n  rintros \u27e8x, y\u27e9 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 \u03b1] {a : Stream \u03b9 \u03b1} {b : Stream \u03b9 \u03b1} (hsa : a.simple) (hsb : b.simple) :\n  (a * b).simple :=\nbegin\n  refine \u27e8Stream.mul_is_monotonic hsa.monotonic hsb.monotonic, _\u27e9,\n  rintros \u27e8x, y\u27e9 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 [\u2190 hr.index', ne, max_ne_self_iff'], exact hsa.index_lt_next _ hr.r\u2081, },\n  { simp only [hr.index', ne, max_ne_self_iff], exact hsb.index_lt_next _ hr.r\u2082, },\nend\n\n@[simps]\ninstance {\u03b9 : Type} {\u03b1 : Type*} [linear_order \u03b9] [has_mul \u03b1] : has_mul (SimpleStream \u03b9 \u03b1) := \u27e8\u03bb a b,\n{ simple := Stream.mul_is_simple a.simple b.simple,\n  ..(@has_mul.mul (StreamExec \u03b9 \u03b1) _ a b) }\u27e9\n\nlemma SimpleStream.coe_mul {\u03b9 : Type} {\u03b1 : Type*} [linear_order \u03b9] [has_mul \u03b1] (a b : SimpleStream \u03b9 \u03b1) :\n  (\u2191(a * b) : StreamExec \u03b9 \u03b1) = (\u2191a) * (\u2191b) := rfl\n\ninstance SimpleStream.MulEval [non_unital_non_assoc_semiring \u03b1] : MulEval (SimpleStream \u03b9 \u03b1) \u03b9 \u03b1 :=\n{ hmul := \u03bb a b, StreamExec.mul_spec a b a.simple b.simple  }\n\nsection\n\nlemma mul_value_eval {\u03b9 \u03b1 \u03b9' \u03b1' : Type*} [linear_order \u03b9] [non_unital_non_assoc_semiring \u03b1'] [MulEval \u03b1 \u03b9' \u03b1'] \n  (a b : StreamExec \u03b9 \u03b1) :\n  (Eval.eval <$\u2082> (a * b)) = (Eval.eval <$\u2082> a) * (Eval.eval <$\u2082> b) :=\nbegin\n  ext; solve_refl,\n  { simp only [Stream.mul.ready_iff], refl, },\n  { simp, refl, },\nend\n\n-- huh??\ninstance {\u03b9 \u03b1 \u03b9' \u03b1' : Type*} [linear_order \u03b9] [non_unital_non_assoc_semiring \u03b1'] [MulEval \u03b1 \u03b9' \u03b1'] :\n  Eval (SimpleStream \u03b9 \u03b1) \u03b9 (\u03b9' \u2192\u2080 \u03b1') := SimpleStream.Eval_ind\n\ninstance {\u03b9 \u03b1 \u03b9' \u03b1' : Type*} [linear_order \u03b9] [non_unital_non_assoc_semiring \u03b1'] [MulEval \u03b1 \u03b9' \u03b1'] :\n  MulEval (SimpleStream \u03b9 \u03b1) \u03b9 (\u03b9' \u2192\u2080 \u03b1') :=\n{ hmul := \u03bb x y, by { simp [Eval.eval, mul_value_eval, SimpleStream.coe_mul], rw StreamExec.mul_spec, exacts [\u27e8x.monotonic, x.reduced\u27e9, \u27e8y.monotonic, y.reduced\u27e9], } }\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": "/-\nCopyright (c) 2020 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\n\nimport tactic.fresh_names\n\nopen tactic\nopen native\n\nexample {\u03b1 \u03b2 \u03b3 \u03b4 \u03b5 \u03b8} (a : \u03b1) (b : \u03b2) (c : \u03b3) (d : \u03b4) (e : \u03b5) (f : \u03b8) : true :=\nbegin\n  (do [a, b, c, d, e, f] \u2190 [`a, `b, `c, `d, `e, `f].mmap get_local,\n      [na, nb, nc, nd, ne, nf] \u2190 pure $\n        [a, b, c, d, e, f].map expr.local_uniq_name,\n\n      let renames : name_map (name \u2295 list name) := rb_map.of_list\n        [ (na, sum.inr [`p, `j]),\n          (nb, sum.inr [`i, `k]),\n          (nc, sum.inr [`i, `k]),\n          (nd, sum.inr [`i]),\n          (ne, sum.inl `i_2),\n          (nf, sum.inl `i_2) ],\n      let reserved := name_set.of_list [`i_1],\n      rename_fresh renames reserved),\n\n  guard_hyp p : \u03b1,\n  guard_hyp i : \u03b2,\n  guard_hyp k : \u03b3,\n  guard_hyp i_3 : \u03b4,\n  guard_hyp i_2 : \u03b8,\n  dedup,\n  guard_hyp i_2 : \u03b5,\n  guard_hyp i_2_1 : \u03b8,\n  trivial\nend\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/fresh_names.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.48047867804790706, "lm_q1q2_score": 0.2421161706759958}}
{"text": "import Smt\n\ntheorem verum : True := by\n  smt\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/Test/Prop/Verum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.47657965106367595, "lm_q1q2_score": 0.24201280108417803}}
{"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 \u2124]\n  [\u2200 (n : \u2124), functor.additive (shift_functor C n)] [pretriangulated C]\n\nnamespace triangulated\n\nopen pretriangulated\n\nvariables {X\u2081 X\u2082 X\u2083 Z\u2081\u2082 Z\u2082\u2083 Z\u2081\u2083 : C} (u\u2081\u2082 : X\u2081 \u27f6 X\u2082) (u\u2082\u2083 : X\u2082 \u27f6 X\u2083) (u\u2081\u2083 : X\u2081 \u27f6 X\u2083)\n  (comm : u\u2081\u2082 \u226b u\u2082\u2083 = u\u2081\u2083)\n  {v\u2081\u2082 : X\u2082 \u27f6 Z\u2081\u2082} {w\u2081\u2082 : Z\u2081\u2082 \u27f6 X\u2081\u27e6(1 : \u2124)\u27e7} (h\u2081\u2082 : triangle.mk u\u2081\u2082 v\u2081\u2082 w\u2081\u2082 \u2208 dist_triang C)\n  {v\u2082\u2083 : X\u2083 \u27f6 Z\u2082\u2083} {w\u2082\u2083 : Z\u2082\u2083 \u27f6 X\u2082\u27e6(1 : \u2124)\u27e7} (h\u2082\u2083 : triangle.mk u\u2082\u2083 v\u2082\u2083 w\u2082\u2083 \u2208 dist_triang C)\n  {v\u2081\u2083 : X\u2083 \u27f6 Z\u2081\u2083} {w\u2081\u2083 : Z\u2081\u2083 \u27f6 X\u2081\u27e6(1 : \u2124)\u27e7} (h\u2081\u2083 : triangle.mk u\u2081\u2083 v\u2081\u2083 w\u2081\u2083 \u2208 dist_triang C)\n\nlemma octahedron.of_iso {X\u2081' X\u2082' X\u2083' Z\u2081\u2082' Z\u2082\u2083' Z\u2081\u2083' : C} (u\u2081\u2082' : X\u2081' \u27f6 X\u2082') (u\u2082\u2083' : X\u2082' \u27f6 X\u2083')\n  (e\u2081 : X\u2081 \u2245 X\u2081') (e\u2082 : X\u2082 \u2245 X\u2082')(e\u2083 : X\u2083 \u2245 X\u2083')\n  (comm\u2081\u2082 : u\u2081\u2082 \u226b e\u2082.hom = e\u2081.hom \u226b u\u2081\u2082') (comm\u2082\u2083 : u\u2082\u2083 \u226b e\u2083.hom = e\u2082.hom \u226b u\u2082\u2083')\n  (v\u2081\u2082' : X\u2082' \u27f6 Z\u2081\u2082') (w\u2081\u2082' : Z\u2081\u2082' \u27f6 X\u2081'\u27e6(1 : \u2124)\u27e7)\n  (h\u2081\u2082' : triangle.mk u\u2081\u2082' v\u2081\u2082' w\u2081\u2082' \u2208 dist_triang C)\n  (v\u2082\u2083' : X\u2083' \u27f6 Z\u2082\u2083') (w\u2082\u2083' : Z\u2082\u2083' \u27f6 X\u2082'\u27e6(1 : \u2124)\u27e7)\n  (h\u2082\u2083' : triangle.mk u\u2082\u2083' v\u2082\u2083' w\u2082\u2083' \u2208 dist_triang C)\n  (v\u2081\u2083' : X\u2083' \u27f6 Z\u2081\u2083') (w\u2081\u2083' : Z\u2081\u2083' \u27f6 X\u2081'\u27e6(1 : \u2124)\u27e7)\n  (h\u2081\u2083' : triangle.mk (u\u2081\u2082' \u226b u\u2082\u2083') v\u2081\u2083' w\u2081\u2083' \u2208 dist_triang C)\n  (H : octahedron rfl h\u2081\u2082' h\u2082\u2083' h\u2081\u2083') : octahedron comm h\u2081\u2082 h\u2082\u2083 h\u2081\u2083 :=\nbegin\n  let iso\u2081\u2082 := iso_triangle_of_distinguished_of_is_iso\u2081\u2082 _ _ h\u2081\u2082 h\u2081\u2082' e\u2081 e\u2082 comm\u2081\u2082,\n  let iso\u2082\u2083 := iso_triangle_of_distinguished_of_is_iso\u2081\u2082 _ _ h\u2082\u2083 h\u2082\u2083' e\u2082 e\u2083 comm\u2082\u2083,\n  let iso\u2081\u2083 := iso_triangle_of_distinguished_of_is_iso\u2081\u2082 _ _ h\u2081\u2083 h\u2081\u2083' e\u2081 e\u2083\n    (by { dsimp, simp only [\u2190 comm, assoc, comm\u2082\u2083, reassoc_of comm\u2081\u2082], }),\n  have eq\u2081\u2082 := iso\u2081\u2082.hom.comm\u2082,\n  have eq\u2081\u2082' := iso\u2081\u2082.hom.comm\u2083,\n  have eq\u2081\u2083 := iso\u2081\u2083.hom.comm\u2082,\n  have eq\u2081\u2083' := iso\u2081\u2083.hom.comm\u2083,\n  have eq\u2082\u2083 := iso\u2082\u2083.hom.comm\u2082,\n  have eq\u2082\u2083' := iso\u2082\u2083.hom.comm\u2083,\n  have rel\u2081\u2082 := H.triangle_morphism\u2081.comm\u2082,\n  have rel\u2081\u2083 := H.triangle_morphism\u2081.comm\u2083,\n  have rel\u2082\u2082 := H.triangle_morphism\u2082.comm\u2082,\n  have rel\u2082\u2083 := H.triangle_morphism\u2082.comm\u2083,\n  dsimp at eq\u2081\u2082 eq\u2081\u2082' eq\u2081\u2083 eq\u2081\u2083' eq\u2082\u2083 eq\u2082\u2083' rel\u2081\u2082 rel\u2081\u2083 rel\u2082\u2082 rel\u2082\u2083,\n  rw [functor.map_id, comp_id] at rel\u2081\u2083,\n  rw id_comp at rel\u2082\u2082,\n  refine \u27e8iso\u2081\u2082.hom.hom\u2083 \u226b H.m\u2081 \u226b iso\u2081\u2083.inv.hom\u2083,\n    iso\u2081\u2083.hom.hom\u2083 \u226b H.m\u2083 \u226b iso\u2082\u2083.inv.hom\u2083, _, _, _, _, _\u27e9,\n  { simp only [reassoc_of eq\u2081\u2082, \u2190 cancel_mono iso\u2081\u2083.hom.hom\u2083, assoc,\n      iso\u2081\u2083.triangle_inv_hom_id\u2083, eq\u2081\u2083, reassoc_of comm\u2082\u2083, \u2190 rel\u2081\u2082],\n    dsimp,\n    rw comp_id, },\n  { rw [\u2190 cancel_mono ((shift_functor C (1 : \u2124)).map e\u2081.hom), eq\u2081\u2082', assoc, assoc, assoc, eq\u2081\u2083',\n      iso\u2081\u2083.triangle_inv_hom_id\u2083_assoc, \u2190 rel\u2081\u2083], },\n  { rw [reassoc_of eq\u2081\u2083, reassoc_of rel\u2082\u2082, \u2190 cancel_mono iso\u2082\u2083.hom.hom\u2083, assoc, assoc,\n      iso\u2082\u2083.triangle_inv_hom_id\u2083, eq\u2082\u2083],\n    dsimp,\n    rw comp_id, },\n  { rw [\u2190 cancel_mono ((shift_functor C (1 : \u2124)).map e\u2082.hom), assoc, assoc, assoc, assoc, eq\u2082\u2083',\n      iso\u2082\u2083.triangle_inv_hom_id\u2083_assoc, \u2190 rel\u2082\u2083, \u2190 functor.map_comp, comm\u2081\u2082, functor.map_comp,\n      reassoc_of eq\u2081\u2083'], },\n  { refine pretriangulated.isomorphic_distinguished _ H.mem _ _,\n    refine triangle.mk_iso _ _ iso\u2081\u2082.triangle_eval\u2083 iso\u2081\u2083.triangle_eval\u2083 iso\u2082\u2083.triangle_eval\u2083\n      _ _ _ ,\n    { dsimp, erw [assoc, assoc, iso.triangle_inv_hom_id\u2083, comp_id], },\n    { dsimp, erw [assoc, assoc, iso.triangle_inv_hom_id\u2083, comp_id], },\n    { dsimp, erw [assoc, \u2190 functor.map_comp, eq\u2081\u2082, functor.map_comp, reassoc_of eq\u2082\u2083'], }, },\nend\n\n\nend triangulated\n\nopen pretriangulated triangulated\n\nlemma is_triangulated.mk' (h : \u2200 \u2983X\u2081' X\u2082' X\u2083' : C\u2984 (u\u2081\u2082' : X\u2081' \u27f6 X\u2082') (u\u2082\u2083' : X\u2082' \u27f6 X\u2083'),\n  \u2203 (X\u2081 X\u2082 X\u2083 Z\u2081\u2082 Z\u2082\u2083 Z\u2081\u2083 : C) (u\u2081\u2082 : X\u2081 \u27f6 X\u2082) (u\u2082\u2083 : X\u2082 \u27f6 X\u2083) (e\u2081 : X\u2081' \u2245 X\u2081) (e\u2082 : X\u2082' \u2245 X\u2082)\n    (e\u2083 : X\u2083' \u2245 X\u2083) (comm\u2081\u2082 : u\u2081\u2082' \u226b e\u2082.hom = e\u2081.hom \u226b u\u2081\u2082)\n    (comm\u2082\u2083 : u\u2082\u2083' \u226b e\u2083.hom = e\u2082.hom \u226b u\u2082\u2083)\n    (v\u2081\u2082 : X\u2082 \u27f6 Z\u2081\u2082) (w\u2081\u2082 : Z\u2081\u2082 \u27f6 X\u2081\u27e61\u27e7) (h\u2081\u2082 : triangle.mk u\u2081\u2082 v\u2081\u2082 w\u2081\u2082 \u2208 dist_triang C)\n    (v\u2082\u2083 : X\u2083 \u27f6 Z\u2082\u2083) (w\u2082\u2083 : Z\u2082\u2083 \u27f6 X\u2082\u27e61\u27e7) (h\u2082\u2083 : triangle.mk u\u2082\u2083 v\u2082\u2083 w\u2082\u2083 \u2208 dist_triang C)\n    (v\u2081\u2083 : X\u2083 \u27f6 Z\u2081\u2083) (w\u2081\u2083 : Z\u2081\u2083 \u27f6 X\u2081\u27e61\u27e7)\n      (h\u2081\u2083 : triangle.mk (u\u2081\u2082 \u226b u\u2082\u2083) v\u2081\u2083 w\u2081\u2083 \u2208 dist_triang C),\n        nonempty (octahedron rfl h\u2081\u2082 h\u2082\u2083 h\u2081\u2083)) : is_triangulated C :=\n\u27e8\u03bb X\u2081' X\u2082' X\u2083' Z\u2081\u2082' Z\u2082\u2083' Z\u2081\u2083' u\u2081\u2082' u\u2082\u2083' u\u2081\u2083' comm' v\u2081\u2082' w\u2081\u2082' h\u2081\u2082' v\u2082\u2083' w\u2082\u2083' h\u2082\u2083'\n  v\u2081\u2083' w\u2081\u2083' h\u2081\u2083', begin\n  obtain \u27e8X\u2081, X\u2082, X\u2083, Z\u2081\u2082, Z\u2082\u2083, Z\u2081\u2083, u\u2081\u2082, u\u2082\u2083, e\u2081, e\u2082, e\u2083, comm\u2081\u2082, comm\u2082\u2083,\n    v\u2081\u2082, w\u2081\u2082, h\u2081\u2082, v\u2082\u2083, w\u2082\u2083, h\u2082\u2083, v\u2081\u2083, w\u2081\u2083, h\u2081\u2083, H\u27e9 := h u\u2081\u2082' u\u2082\u2083',\n  exact \u27e8octahedron.of_iso _ _ _ _ _ _ _ u\u2081\u2082 u\u2082\u2083 e\u2081 e\u2082 e\u2083 comm\u2081\u2082 comm\u2082\u2083 v\u2081\u2082 w\u2081\u2082 h\u2081\u2082\n    v\u2082\u2083 w\u2082\u2083 h\u2082\u2083 v\u2081\u2083 w\u2081\u2083 h\u2081\u2083 H.some\u27e9\nend\u27e9\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 : \u2115 \u2192 \u2115 \u2192 part \u2115) : \u2115 \u2192 \u2115 \u2192 part \u2115\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\u2082_continuous' easy.intl\n  (\u03bb x, pi.omega_complete_partial_order.flip\u2082_continuous' _ (\u03bb x_1, const_continuous' (pure x)))\n\n-- automation coming soon\ntheorem easy.equations.eqn_1 (x y : \u2115) : 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 : \u2115 \u2192 \u2115 \u2192 part \u2115) : \u2115 \u2192 \u2115 \u2192 part \u2115\n| x y :=\nif y \u2264 x \u2227 y > 0\n  then div (x - y) y\n  else pure x\n\ndef div : \u2115 \u2192 \u2115 \u2192 part \u2115 :=\nfix div.intl\n\n-- automation coming soon\ntheorem div.cont : continuous' div.intl :=\npi.omega_complete_partial_order.flip\u2082_continuous' div.intl\n  (\u03bb (x : \u2115),\n     pi.omega_complete_partial_order.flip\u2082_continuous' (\u03bb (g : \u2115 \u2192 \u2115 \u2192 part \u2115), div.intl g x)\n       (\u03bb (x_1 : \u2115),\n            (continuous_hom.ite_continuous' (\u03bb (x_2 : \u2115 \u2192 \u2115 \u2192 part \u2115), x_2 (x - x_1) x_1)\n               (\u03bb (x_1 : \u2115 \u2192 \u2115 \u2192 part \u2115), pure x)\n               (pi.omega_complete_partial_order.flip\u2081_continuous'\n                 (\u03bb (v_1 : \u2115) (x_2 : \u2115 \u2192 \u2115 \u2192 part \u2115), x_2 (x - x_1) v_1) _ $\n                 pi.omega_complete_partial_order.flip\u2081_continuous'\n                   (\u03bb (v : \u2115) (g : \u2115 \u2192 \u2115 \u2192 part \u2115) (x : \u2115), g v x) _ id_continuous')\n               (const_continuous' (pure x)))))\n\n-- automation coming soon\ntheorem div.equations.eqn_1 (x y : \u2115) : div x y = if y \u2264 x \u2227 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 (\u03b1 : Type*)\n| nil {} : tree\n| node (x : \u03b1) : tree \u2192 tree \u2192 tree\n\nopen part.examples.tree\n\n/-! `map` on a `tree` using monadic notation -/\ndef tree_map.intl {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) (tree_map : tree \u03b1 \u2192 part (tree \u03b2)) :\n  tree \u03b1 \u2192 part (tree \u03b2)\n| nil := pure nil\n| (node x t\u2080 t\u2081) :=\ndo tt\u2080 \u2190 tree_map t\u2080,\n   tt\u2081 \u2190 tree_map t\u2081,\n   pure $ node (f x) tt\u2080 tt\u2081\n\n-- automation coming soon\ndef tree_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) : tree \u03b1 \u2192 part (tree \u03b2) :=\nfix (tree_map.intl f)\n\n-- automation coming soon\ntheorem tree_map.cont :\n  \u2200 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2), continuous' (tree_map.intl f) :=\n\u03bb {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2),\n  pi.omega_complete_partial_order.flip\u2082_continuous' (tree_map.intl f)\n    (\u03bb (x : tree \u03b1),\n       tree.cases_on x (id (const_continuous' (pure nil)))\n         (\u03bb (x_x : \u03b1) (x_a x_a_1 : tree \u03b1),\n              (continuous_hom.bind_continuous' (\u03bb (x : tree \u03b1 \u2192 part (tree \u03b2)), x x_a)\n                 (\u03bb (x : tree \u03b1 \u2192 part (tree \u03b2)) (tt\u2080 : tree \u03b2),\n                    x x_a_1 >>= \u03bb (tt\u2081 : tree \u03b2), pure (node (f x_x) tt\u2080 tt\u2081))\n                 (pi.omega_complete_partial_order.flip\u2081_continuous' (\u03bb (v : tree \u03b1) (x : tree \u03b1 \u2192 part (tree \u03b2)), x v) x_a id_continuous')\n                 (pi.omega_complete_partial_order.flip\u2082_continuous'\n                    (\u03bb (x : tree \u03b1 \u2192 part (tree \u03b2)) (tt\u2080 : tree \u03b2),\n                       x x_a_1 >>= \u03bb (tt\u2081 : tree \u03b2), pure (node (f x_x) tt\u2080 tt\u2081))\n                    (\u03bb (x : tree \u03b2),\n                       continuous_hom.bind_continuous' (\u03bb (x : tree \u03b1 \u2192 part (tree \u03b2)), x x_a_1)\n                         (\u03bb (x_1 : tree \u03b1 \u2192 part (tree \u03b2)) (tt\u2081 : tree \u03b2), pure (node (f x_x) x tt\u2081))\n                         (pi.omega_complete_partial_order.flip\u2081_continuous' (\u03bb (v : tree \u03b1) (x : tree \u03b1 \u2192 part (tree \u03b2)), x v) x_a_1\n                            id_continuous')\n                         (pi.omega_complete_partial_order.flip\u2082_continuous'\n                            (\u03bb (x_1 : tree \u03b1 \u2192 part (tree \u03b2)) (tt\u2081 : tree \u03b2), pure (node (f x_x) x tt\u2081))\n                            (\u03bb (x_1 : tree \u03b2), const_continuous' (pure (node (f x_x) x x_1)))))))))\n\n-- automation coming soon\ntheorem tree_map.equations.eqn_1 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (x : \u03b1)\n  (t\u2080 t\u2081 : tree \u03b1) :\n  tree_map f (node x t\u2080 t\u2081) = tree_map f t\u2080 >>= \u03bb (tt\u2080 : tree \u03b2), tree_map f t\u2081 >>=\n    \u03bb (tt\u2081 : tree \u03b2), pure (node (f x) tt\u2080 tt\u2081) :=\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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (tree_map : tree \u03b1 \u2192 part (tree \u03b2)) :\n  tree \u03b1 \u2192 part (tree \u03b2)\n| nil := pure nil\n| (node x t\u2080 t\u2081) :=\nnode (f x) <$> tree_map t\u2080 <*> tree_map t\u2081\n\n-- automation coming soon\ndef tree_map' {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) : tree \u03b1 \u2192 part (tree \u03b2) :=\nfix (tree_map'.intl f)\n\n-- automation coming soon\ntheorem tree_map'.cont :\n  \u2200 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2), continuous' (tree_map'.intl f) :=\n\u03bb {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2),\n  pi.omega_complete_partial_order.flip\u2082_continuous' (tree_map'.intl f)\n    (\u03bb (x : tree \u03b1),\n       tree.cases_on x (id (const_continuous' (pure nil)))\n         (\u03bb (x_x : \u03b1) (x_a x_a_1 : tree \u03b1),\n              (continuous_hom.seq_continuous' (\u03bb (x : tree \u03b1 \u2192 part (tree \u03b2)), node (f x_x) <$> x x_a)\n                 (\u03bb (x : tree \u03b1 \u2192 part (tree \u03b2)), x x_a_1)\n                 (continuous_hom.map_continuous' (node (f x_x)) (\u03bb (x : tree \u03b1 \u2192 part (tree \u03b2)), x x_a)\n                    (pi.omega_complete_partial_order.flip\u2081_continuous' (\u03bb (v : tree \u03b1) (x : tree \u03b1 \u2192 part (tree \u03b2)), x v) x_a id_continuous'))\n                 (pi.omega_complete_partial_order.flip\u2081_continuous' (\u03bb (v : tree \u03b1) (x : tree \u03b1 \u2192 part (tree \u03b2)), x v) x_a_1 id_continuous'))))\n\n-- automation coming soon\ntheorem tree_map'.equations.eqn_1 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (x : \u03b1) (t\u2080 t\u2081 : tree \u03b1) :\n  tree_map' f (node x t\u2080 t\u2081) = node (f x) <$> tree_map' f t\u2080 <*> tree_map' f t\u2081 :=\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 : \u2115 \u2192 part \u2115) (n : \u2115) : part \u2115 :=\nif n > 100\n  then pure $ n - 10\n  else f91 (n + 11) >>= f91\n\n-- automation coming soon\ndef f91 : \u2115 \u2192 part \u2115 := fix f91.intl\n\n-- automation coming soon\nlemma f91.cont : continuous' f91.intl :=\npi.omega_complete_partial_order.flip\u2082_continuous' f91.intl\n  (\u03bb (x : \u2115),\n     id\n       (continuous_hom.ite_continuous' (\u03bb (x_1 : \u2115 \u2192 part \u2115), pure (x - 10)) (\u03bb (x_1 : \u2115 \u2192 part \u2115), x_1 (x + 11) >>= x_1)\n          (const_continuous' (pure (x - 10)))\n          (continuous_hom.bind_continuous' (\u03bb (x_1 : \u2115 \u2192 part \u2115), x_1 (x + 11)) (\u03bb (x : \u2115 \u2192 part \u2115), x)\n             (pi.omega_complete_partial_order.flip\u2081_continuous' (\u03bb (v : \u2115) (x : \u2115 \u2192 part \u2115), x v) (x + 11) id_continuous')\n             (pi.omega_complete_partial_order.flip\u2082_continuous' (\u03bb (x : \u2115 \u2192 part \u2115), x)\n                (\u03bb (x_1 : \u2115), pi.omega_complete_partial_order.flip\u2081_continuous' (\u03bb (v : \u2115) (g : \u2115 \u2192 part \u2115), g v) x_1 id_continuous')))))\n.\n-- automation coming soon\ntheorem f91.equations.eqn_1 (n : \u2115) : 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 : \u2115) : (\u2203 n', n < n' + 11 \u2227 n' \u2208 f91 n) :=\nbegin\n  apply well_founded.induction (measure_wf $ \u03bb 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 \u27e8n',hn\u2080,hn\u2081\u27e9,\n    rcases ih (n') _ with \u27e8n'',hn'\u2080,hn'\u2081\u27e9,\n    refine \u27e8n'',_,_,hn\u2081,hn'\u2081\u27e9,\n    { clear ih hn\u2081 hn'\u2081, omega },\n    { clear ih hn\u2081, omega },\n    { clear ih, omega } },\nend\n\nlemma f91_dom (n : \u2115) : (f91 n).dom :=\nby rw part.dom_iff_mem; apply exists_imp_exists _ (f91_spec n); simp\n\ndef f91' (n : \u2115) : \u2115 := (f91 n).get (f91_dom n)\n\nrun_cmd guard (f91' 109 = 99)\n\nlemma f91_spec' (n : \u2115) : f91' n = if n > 100 then n - 10 else 91 :=\nbegin\n  suffices : (\u2203 n', n' \u2208 f91 n \u2227 n' = if n > 100 then n - 10 else 91),\n  { dsimp [f91'], rw part.get_eq_of_mem,\n    rcases this with \u27e8n,_,_\u27e9, subst n, assumption },\n  apply well_founded.induction (measure_wf $ \u03bb 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 \u27e8n',hn'\u2080,hn'\u2081\u27e9,\n    split_ifs at hn'\u2081,\n    { subst hn'\u2081, norm_num at hn'\u2080, refine \u27e8_,hn'\u2080,_\u27e9,\n      rcases ih (n+1) _ with \u27e8n',hn'\u2080,hn'\u2081\u27e9,\n      split_ifs at hn'\u2081,\n      { subst n', convert hn'\u2080, clear hn'\u2080 hn'\u2080 ih, omega },\n      { subst n', exact hn'\u2080 },\n      { clear ih hn'\u2080, omega } },\n    { refine \u27e8_,hn'\u2080,_\u27e9, subst n',\n      rcases ih 91 _ with \u27e8n',hn'\u2080,hn'\u2081\u27e9,\n      rw if_neg at hn'\u2081, subst n', exact hn'\u2080,\n      { clear ih hn'\u2080 hn'\u2080, omega, },\n      { clear ih hn'\u2080, 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 \u2245 opposite.op S.homology :=\nbegin\n  let h := S.some_homology_data,\n  exact h.op.homology_iso \u226a\u226b h.iso.op \u226a\u226b 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 \u2124) :\n  cochain_complex C\u1d52\u1d56 \u2124 :=\n{ X := \u03bb n, opposite.op (K.X (-n)),\n  d := \u03bb n m, (K.d _ _).op,\n  shape' := \u03bb i j hij, begin\n    rw K.shape,\n    { refl, },\n    { simp only [complex_shape.up_rel] at \u22a2 hij,\n      intro h,\n      apply hij,\n      linarith, },\n  end,\n  d_comp_d' := \u03bb i j k hij hjk,\n    by simpa only [\u2190 op_comp, homological_complex.d_comp_d], }\n\n@[simps]\ndef unop_obj (K : cochain_complex C\u1d52\u1d56 \u2124) :\n  cochain_complex C \u2124 :=\n{ X := \u03bb n, opposite.unop (K.X (-n)),\n  d := \u03bb n m, (K.d _ _).unop,\n  shape' := \u03bb i j hij, begin\n    rw K.shape,\n    { refl, },\n    { simp only [complex_shape.up_rel] at \u22a2 hij,\n      intro h,\n      apply hij,\n      linarith, },\n  end,\n  d_comp_d' := \u03bb i j k hij hjk,\n    by simpa only [\u2190 unop_comp, homological_complex.d_comp_d], }\n\n@[simps]\ndef unop_op_obj (K : cochain_complex C \u2124) :\n  unop_obj (op_obj K) \u2245 K :=\nhomological_complex.hom.iso_of_components\n  (\u03bb n, homological_complex.X_iso_of_eq K (by linarith)) (by tidy)\n\n@[simps]\ndef op_unop_obj (K : cochain_complex C\u1d52\u1d56 \u2124) :\n  op_obj (unop_obj K) \u2245 K :=\nhomological_complex.hom.iso_of_components\n  (\u03bb n, homological_complex.X_iso_of_eq K (by linarith)) (by tidy)\n\nvariable (C)\n\n@[simps]\ndef functor : (cochain_complex C \u2124)\u1d52\u1d56 \u2964 cochain_complex C\u1d52\u1d56 \u2124 :=\n{ obj := \u03bb K, op_obj (opposite.unop K) ,\n  map := \u03bb K L \u03c6,\n  { f := \u03bb n, (\u03c6.unop.f (-n)).op,\n    comm' := \u03bb i j hij, begin\n      dsimp,\n      simp only [\u2190 op_comp, homological_complex.hom.comm],\n    end, }, }\n\n@[simps]\ndef inverse : cochain_complex C\u1d52\u1d56 \u2124 \u2964 (cochain_complex C \u2124)\u1d52\u1d56 :=\n{ obj := \u03bb K, opposite.op (unop_obj K),\n  map := \u03bb K L \u03c6, quiver.hom.op\n  { f := \u03bb n, (\u03c6.f (-n)).unop,\n    comm' := \u03bb i j hij, begin\n      dsimp,\n      simp only [\u2190 unop_comp, homological_complex.hom.comm],\n    end, }, }\n\n@[simps]\ndef unit_iso :\n  \ud835\udfed (cochain_complex C \u2124)\u1d52\u1d56 \u2245 op_equivalence.functor C \u22d9 op_equivalence.inverse C :=\nnat_iso.of_components (\u03bb K, (unop_op_obj (opposite.unop K)).op)\n  (\u03bb 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 \u22d9 op_equivalence.functor C \u2245 \ud835\udfed (cochain_complex C\u1d52\u1d56 \u2124) :=\nnat_iso.of_components (\u03bb K, (op_unop_obj K))\n  (\u03bb 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 \u2124)\u1d52\u1d56 \u224c cochain_complex C\u1d52\u1d56 \u2124 :=\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' := \u03bb 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 \u2124) (n : \u2124) [K.is_strictly_ge (-n)] :\n  (op_equivalence.op_obj K).is_strictly_le n :=\n\u27e8\u03bb i hi, (cochain_complex.is_strictly_ge.is_zero K (-n) (-i) (by linarith)).op\u27e9\n\nlemma op_obj_is_strictly_ge (K : cochain_complex C \u2124) (n : \u2124) [K.is_strictly_le (-n)] :\n  (op_equivalence.op_obj K).is_strictly_ge n :=\n\u27e8\u03bb i hi, (cochain_complex.is_strictly_le.is_zero K (-n) (-i) (by linarith)).op\u27e9\n\nlemma unop_obj_is_strictly_le (K : cochain_complex C\u1d52\u1d56 \u2124) (n : \u2124) [K.is_strictly_ge (-n)] :\n  (op_equivalence.unop_obj K).is_strictly_le n :=\n\u27e8\u03bb i hi, (cochain_complex.is_strictly_ge.is_zero K (-n) (-i) (by linarith)).unop\u27e9\n\nlemma unop_obj_is_strictly_ge (K : cochain_complex C\u1d52\u1d56 \u2124) (n : \u2124) [K.is_strictly_le (-n)] :\n  (op_equivalence.unop_obj K).is_strictly_ge n :=\n\u27e8\u03bb i hi, (cochain_complex.is_strictly_le.is_zero K (-n) (-i) (by linarith)).unop\u27e9\n\ndef unop_homotopy {K L : cochain_complex C \u2124} {f\u2081 f\u2082 : K \u27f6 L}\n  (h : homotopy ((op_equivalence.functor C).map f\u2081.op) ((op_equivalence.functor C).map f\u2082.op)) :\n  homotopy f\u2081 f\u2082 :=\n{ hom := \u03bb i j, (K.X_iso_of_eq (by simp)).hom \u226b (h.hom (-j) (-i)).unop \u226b\n      (L.X_iso_of_eq (by simp)).hom,\n  zero' := \u03bb i j hij, begin\n    rw [h.zero, unop_zero, zero_comp, comp_zero],\n    simp only [complex_shape.up_rel] at hij \u22a2,\n    intro h,\n    apply hij,\n    linarith,\n  end,\n  comm := \u03bb n, quiver.hom.op_inj begin\n    obtain \u27e8m, rfl\u27e9 : \u2203 (m : \u2124), n = -m := \u27e8-n, by rw neg_neg n\u27e9,\n    have eq := h.comm m,\n    have eq\u2081 : (complex_shape.up \u2124).rel m (m+1) := rfl,\n    have eq\u2082 : (complex_shape.up \u2124).rel (m-1) m := by simp,\n    have eq\u2083 : (complex_shape.up \u2124).rel (-m) (-(m-1)),\n    { simp only [neg_sub, complex_shape.up_rel], linarith, },\n    have eq\u2084 : (complex_shape.up \u2124).rel (-(m+1)) (-m) := by simp,\n    rw [d_next_eq _ eq\u2081, prev_d_eq _ eq\u2082] at eq,\n    rw [d_next_eq _ eq\u2083, prev_d_eq _ eq\u2084],\n    dsimp at eq \u22a2,\n    rw eq,\n    have eq\u2085 : \u2200 (a a' b b' : \u2124) (ha : a = a') (hb : b = b'),\n      h.hom a b = eq_to_hom (by rw ha) \u226b h.hom a' b' \u226b 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\u2085 _ _ _ _ (neg_neg _).symm (neg_neg _).symm, },\n  end, }\n\ndef homology_op_iso (K : cochain_complex C \u2124) (n : \u2124) :\n  (op_equivalence.op_obj K).homology n \u2245 opposite.op (K.homology (-n)) :=\nbegin\n  have r\u2081 : (complex_shape.up \u2124).rel (-(n+1)) (-n) := by simp,\n  have r\u2082 : (complex_shape.up \u2124).rel (-n) (-(n-1)) := by { rw complex_shape.up_rel, linarith, },\n  have r\u2083 : (complex_shape.up \u2124).rel (n-1) n := by simp,\n  have r\u2084 : (complex_shape.up \u2124).rel n (n+1) := by simp,\n  refine _ \u226a\u226b short_complex.homology_op_iso _ \u226a\u226b\n    (short_complex.homology_map_iso\n      ((homological_complex.short_complex_functor_nat_iso C _ r\u2081 r\u2082).app K)).op,\n  exact short_complex.homology_map_iso\n    ((homological_complex.short_complex_functor_nat_iso C\u1d52\u1d56 _ r\u2083 r\u2084).app ((op_equivalence.op_obj K))),\nend\n\nlemma acyclic_op {K : cochain_complex C \u2124} (hK : homological_complex.acyclic K) :\n  homological_complex.acyclic (op_equivalence.op_obj K) :=\n\u03bb 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' (\u03b1 \u03b2 \u03b3 : Type*) [function.has_uncurry \u03b1 \u03b2 \u03b3]\n  [definable_sheaf S \u03b1] [definable_sheaf S \u03b2] [definable_sheaf S \u03b3] :=\n(definable_iff : \u2200 (K : Def S) (f : K \u2192 \u03b1),\n   definable S f \u2194 definable S (\u03bb k, \u21bf(f k)))\n\ninstance base.is_good_uncurry' {\u03b1 \u03b2 : Type*}\n  [definable_sheaf S \u03b1] [definable_sheaf S \u03b2] : is_good_uncurry' S (\u03b1 \u2192 \u03b2) \u03b1 \u03b2 :=\n\u27e8\u03bb K f, iff.rfl\u27e9\n\ninstance induction.is_good_uncurry' {\u03b1 \u03b2 \u03b3 \u03b4 : Type*} [function.has_uncurry \u03b2 \u03b3 \u03b4]\n  [definable_sheaf S \u03b1] [definable_sheaf S \u03b2] [definable_sheaf S \u03b3] [definable_sheaf S \u03b4] :\n  is_good_uncurry' S (\u03b1 \u2192 \u03b2) (\u03b1 \u00d7 \u03b3) \u03b4 :=\nbegin\n  refine \u27e8\u03bb K f, _\u27e9,\n  change _ \u2194 definable S (\u03bb k, function.uncurry (\u03bb a c, \u21bf(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 := \u03bb k, function.uncurry (\u03bb a c, \u21bf(f k a) c),\n    change definable S g at H,\n    sorry }\nend\n\nclass is_good_uncurry (\u03b1 \u03b2 \u03b3 : Type*) [function.has_uncurry \u03b1 \u03b2 \u03b3]\n  [definable_sheaf S \u03b1]\n  [has_coordinates R \u03b2] [is_definable S \u03b2]\n  [has_coordinates R \u03b3] [is_definable S \u03b3] :=\n(x : @is_good_uncurry' R S \u03b1 \u03b2 \u03b3 _ _ definable_sheaf.rep definable_sheaf.rep)\n\nvariables {S}\n\nlemma definable_iff_uncurry' {\u03b1 \u03b2 \u03b3 : Type*} [function.has_uncurry \u03b1 \u03b2 \u03b3]\n  [definable_sheaf S \u03b1]\n  [has_coordinates R \u03b2] [is_definable S \u03b2]\n  [has_coordinates R \u03b3] [is_definable S \u03b3]\n  [i : is_good_uncurry S \u03b1 \u03b2 \u03b3]\n  {f : \u03b1} :\n  definable S f \u2194 def_fun S \u21bff :=\nbegin\n  letI : definable_sheaf S \u03b2 := definable_sheaf.rep,\n  letI : definable_sheaf S \u03b3 := definable_sheaf.rep,\n  letI : definable_rep S \u03b2 := \u27e8\u03bb _ _, iff.rfl\u27e9,\n  letI : definable_rep S \u03b3 := \u27e8\u03bb _ _, iff.rfl\u27e9,\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 \u2964 D` and functors `G H : D \u2964 E` and a natural transformation `\u03b1 : G \u27f6 H`,\nwe can construct a new natural transformation `F \u22d9 G \u27f6 F \u22d9 H`,\ncalled `whisker_left F \u03b1`. This is the same as the horizontal composition of `\ud835\udfd9 F` with `\u03b1`.\n\nThis operation is functorial in `F`, and we package this as `whiskering_left`. Here\n`(whiskering_left.obj F).obj G` is `F \u22d9 G`, and\n`(whiskering_left.obj F).map \u03b1` is `whisker_left F \u03b1`.\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\u2081 v\u2081 u\u2082 v\u2082 u\u2083 v\u2083 u\u2084 v\u2084\n\nsection\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n          {D : Type u\u2082} [category.{v\u2082} D]\n          {E : Type u\u2083} [category.{v\u2083} E]\n\n/--\nIf `\u03b1 : G \u27f6 H` then\n`whisker_left F \u03b1 : (F \u22d9 G) \u27f6 (F \u22d9 H)` has components `\u03b1.app (F.obj X)`.\n-/\n@[simps] def whisker_left (F : C \u2964 D) {G H : D \u2964 E} (\u03b1 : G \u27f6 H) : (F \u22d9 G) \u27f6 (F \u22d9 H) :=\n{ app := \u03bb X, \u03b1.app (F.obj X),\n  naturality' := \u03bb X Y f, by rw [functor.comp_map, functor.comp_map, \u03b1.naturality] }\n\n/--\nIf `\u03b1 : G \u27f6 H` then\n`whisker_right \u03b1 F : (G \u22d9 F) \u27f6 (G \u22d9 F)` has components `F.map (\u03b1.app X)`.\n-/\n@[simps] def whisker_right {G H : C \u2964 D} (\u03b1 : G \u27f6 H) (F : D \u2964 E) : (G \u22d9 F) \u27f6 (H \u22d9 F) :=\n{ app := \u03bb X, F.map (\u03b1.app X),\n  naturality' := \u03bb X Y f,\n    by rw [functor.comp_map, functor.comp_map, \u2190F.map_comp, \u2190F.map_comp, \u03b1.naturality] }\n\nvariables (C D E)\n\n/--\nLeft-composition gives a functor `(C \u2964 D) \u2964 ((D \u2964 E) \u2964 (C \u2964 E))`.\n\n`(whiskering_left.obj F).obj G` is `F \u22d9 G`, and\n`(whiskering_left.obj F).map \u03b1` is `whisker_left F \u03b1`.\n-/\n@[simps] def whiskering_left : (C \u2964 D) \u2964 ((D \u2964 E) \u2964 (C \u2964 E)) :=\n{ obj := \u03bb F,\n  { obj := \u03bb G, F \u22d9 G,\n    map := \u03bb G H \u03b1, whisker_left F \u03b1 },\n  map := \u03bb F G \u03c4,\n  { app := \u03bb H,\n    { app := \u03bb c, H.map (\u03c4.app c),\n      naturality' := \u03bb X Y f, begin dsimp, rw [\u2190H.map_comp, \u2190H.map_comp, \u2190\u03c4.naturality] end },\n    naturality' := \u03bb X Y f, begin ext, dsimp, rw [f.naturality] end } }\n\n/--\nRight-composition gives a functor `(D \u2964 E) \u2964 ((C \u2964 D) \u2964 (C \u2964 E))`.\n\n`(whiskering_right.obj H).obj F` is `F \u22d9 H`, and\n`(whiskering_right.obj H).map \u03b1` is `whisker_right \u03b1 H`.\n-/\n@[simps] def whiskering_right : (D \u2964 E) \u2964 ((C \u2964 D) \u2964 (C \u2964 E)) :=\n{ obj := \u03bb H,\n  { obj := \u03bb F, F \u22d9 H,\n    map := \u03bb _ _ \u03b1, whisker_right \u03b1 H },\n  map := \u03bb G H \u03c4,\n  { app := \u03bb F,\n    { app := \u03bb c, \u03c4.app (F.obj c),\n      naturality' := \u03bb X Y f, begin dsimp, rw [\u03c4.naturality] end },\n    naturality' := \u03bb X Y f, begin ext, dsimp, rw [\u2190nat_trans.naturality] end } }\n\nvariables {C} {D} {E}\n\ninstance faithful_whiskering_right_obj {F : D \u2964 E} [faithful F] :\n  faithful ((whiskering_right C D E).obj F) :=\n{ map_injective' := \u03bb G H \u03b1 \u03b2 h\u03b1\u03b2, nat_trans.ext _ _ $ funext $ \u03bb X,\n    functor.map_injective _ $ congr_fun (congr_arg nat_trans.app h\u03b1\u03b2) X }\n\n@[simp] lemma whisker_left_id (F : C \u2964 D) {G : D \u2964 E} :\n  whisker_left F (nat_trans.id G) = nat_trans.id (F.comp G) :=\nrfl\n@[simp] lemma whisker_left_id' (F : C \u2964 D) {G : D \u2964 E} :\n  whisker_left F (\ud835\udfd9 G) = \ud835\udfd9 (F.comp G) :=\nrfl\n\n@[simp] lemma whisker_right_id {G : C \u2964 D} (F : D \u2964 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 \u2964 D} (F : D \u2964 E) :\n  whisker_right (\ud835\udfd9 G) F = \ud835\udfd9 (G.comp F) :=\n((whiskering_right C D E).obj F).map_id _\n\n@[simp] lemma whisker_left_comp (F : C \u2964 D) {G H K : D \u2964 E} (\u03b1 : G \u27f6 H) (\u03b2 : H \u27f6 K) :\n  whisker_left F (\u03b1 \u226b \u03b2) = (whisker_left F \u03b1) \u226b (whisker_left F \u03b2) :=\nrfl\n\n@[simp] lemma whisker_right_comp {G H K : C \u2964 D} (\u03b1 : G \u27f6 H) (\u03b2 : H \u27f6 K) (F : D \u2964 E)  :\n  whisker_right (\u03b1 \u226b \u03b2) F = (whisker_right \u03b1 F) \u226b (whisker_right \u03b2 F) :=\n((whiskering_right C D E).obj F).map_comp \u03b1 \u03b2\n\n/--\nIf `\u03b1 : G \u2245 H` is a natural isomorphism then\n`iso_whisker_left F \u03b1 : (F \u22d9 G) \u2245 (F \u22d9 H)` has components `\u03b1.app (F.obj X)`.\n-/\ndef iso_whisker_left (F : C \u2964 D) {G H : D \u2964 E} (\u03b1 : G \u2245 H) : (F \u22d9 G) \u2245 (F \u22d9 H) :=\n((whiskering_left C D E).obj F).map_iso \u03b1\n@[simp] lemma iso_whisker_left_hom (F : C \u2964 D) {G H : D \u2964 E} (\u03b1 : G \u2245 H) :\n  (iso_whisker_left F \u03b1).hom = whisker_left F \u03b1.hom :=\nrfl\n@[simp] lemma iso_whisker_left_inv (F : C \u2964 D) {G H : D \u2964 E} (\u03b1 : G \u2245 H) :\n  (iso_whisker_left F \u03b1).inv = whisker_left F \u03b1.inv :=\nrfl\n\n/--\nIf `\u03b1 : G \u2245 H` then\n`iso_whisker_right \u03b1 F : (G \u22d9 F) \u2245 (H \u22d9 F)` has components `F.map_iso (\u03b1.app X)`.\n-/\ndef iso_whisker_right {G H : C \u2964 D} (\u03b1 : G \u2245 H) (F : D \u2964 E) : (G \u22d9 F) \u2245 (H \u22d9 F) :=\n((whiskering_right C D E).obj F).map_iso \u03b1\n@[simp] lemma iso_whisker_right_hom {G H : C \u2964 D} (\u03b1 : G \u2245 H) (F : D \u2964 E) :\n  (iso_whisker_right \u03b1 F).hom = whisker_right \u03b1.hom F :=\nrfl\n@[simp] lemma iso_whisker_right_inv {G H : C \u2964 D} (\u03b1 : G \u2245 H) (F : D \u2964 E) :\n  (iso_whisker_right \u03b1 F).inv = whisker_right \u03b1.inv F :=\nrfl\n\ninstance is_iso_whisker_left (F : C \u2964 D) {G H : D \u2964 E} (\u03b1 : G \u27f6 H) [is_iso \u03b1] :\n  is_iso (whisker_left F \u03b1) :=\nis_iso.of_iso (iso_whisker_left F (as_iso \u03b1))\ninstance is_iso_whisker_right {G H : C \u2964 D} (\u03b1 : G \u27f6 H) (F : D \u2964 E) [is_iso \u03b1] :\n  is_iso (whisker_right \u03b1 F) :=\nis_iso.of_iso (iso_whisker_right (as_iso \u03b1) F)\n\nvariables {B : Type u\u2084} [category.{v\u2084} B]\n\nlocal attribute [elab_simple] whisker_left whisker_right\n\n@[simp] lemma whisker_left_twice (F : B \u2964 C) (G : C \u2964 D) {H K : D \u2964 E} (\u03b1 : H \u27f6 K) :\n  whisker_left F (whisker_left G \u03b1) = whisker_left (F \u22d9 G) \u03b1 :=\nrfl\n\n@[simp] lemma whisker_right_twice {H K : B \u2964 C} (F : C \u2964 D) (G : D \u2964 E) (\u03b1 : H \u27f6 K) :\n  whisker_right (whisker_right \u03b1 F) G = whisker_right \u03b1 (F \u22d9 G) :=\nrfl\n\nlemma whisker_right_left (F : B \u2964 C) {G H : C \u2964 D} (\u03b1 : G \u27f6 H) (K : D \u2964 E) :\n  whisker_right (whisker_left F \u03b1) K = whisker_left F (whisker_right \u03b1 K) :=\nrfl\nend\n\nnamespace functor\n\nuniverses u\u2085 v\u2085\n\nvariables {A : Type u\u2081} [category.{v\u2081} A]\nvariables {B : Type u\u2082} [category.{v\u2082} B]\n\n/--\nThe left unitor, a natural isomorphism `((\ud835\udfed _) \u22d9 F) \u2245 F`.\n-/\n@[simps] def left_unitor (F : A \u2964 B) : ((\ud835\udfed A) \u22d9 F) \u2245 F :=\n{ hom := { app := \u03bb X, \ud835\udfd9 (F.obj X) },\n  inv := { app := \u03bb X, \ud835\udfd9 (F.obj X) } }\n\n/--\nThe right unitor, a natural isomorphism `(F \u22d9 (\ud835\udfed B)) \u2245 F`.\n-/\n@[simps] def right_unitor (F : A \u2964 B) : (F \u22d9 (\ud835\udfed B)) \u2245 F :=\n{ hom := { app := \u03bb X, \ud835\udfd9 (F.obj X) },\n  inv := { app := \u03bb X, \ud835\udfd9 (F.obj X) } }\n\nvariables {C : Type u\u2083} [category.{v\u2083} C]\nvariables {D : Type u\u2084} [category.{v\u2084} D]\n\n/--\nThe associator for functors, a natural isomorphism `((F \u22d9 G) \u22d9 H) \u2245 (F \u22d9 (G \u22d9 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 \u2964 B) (G : B \u2964 C) (H : C \u2964 D) : ((F \u22d9 G) \u22d9 H) \u2245 (F \u22d9 (G \u22d9 H)) :=\n{ hom := { app := \u03bb _, \ud835\udfd9 _ },\n  inv := { app := \u03bb _, \ud835\udfd9 _ } }\n\n@[protected]\nlemma assoc (F : A \u2964 B) (G : B \u2964 C) (H : C \u2964 D) : ((F \u22d9 G) \u22d9 H) = (F \u22d9 (G \u22d9 H)) := rfl\n\nlemma triangle (F : A \u2964 B) (G : B \u2964 C) :\n  (associator F (\ud835\udfed B) G).hom \u226b (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\u2085} [category.{v\u2085} E]\n\nvariables (F : A \u2964 B) (G : B \u2964 C) (H : C \u2964 D) (K : D \u2964 E)\n\nlemma pentagon :\n  (whisker_right (associator F G H).hom K) \u226b\n    (associator F (G \u22d9 H) K).hom \u226b\n    (whisker_left F (associator G H K).hom) =\n  ((associator (F \u22d9 G) H K).hom \u226b (associator F G (H \u22d9 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' : \u211d\u22650) [fact (0 < r')]\n\nabbreviation category_theory.nat_trans.conj_by {F G : C \u2964 D} (\u03b1 : F \u2245 G) (\u03b2 : G \u27f6 G) :\n  F \u27f6 F := \u03b1.hom \u226b \u03b2 \u226b \u03b1.inv\n\nopen category_theory\n\nopen ProFiltPseuNormGrpWithTinv\u2081 CompHausFiltPseuNormGrp\u2081 CompHausFiltPseuNormGrp\n\nvariables {r'}\n\n/--\nGiven a functor `F` from `Fintype` to `CompHausFiltPseuNormGrp\u2081`, we can obtain\na functor `Profinite \u2964 CompHausFiltPseuNormGrp\u2081` 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} \u2964 CompHausFiltPseuNormGrp\u2081.{u}) :\n  Profinite.{u} \u2964 Condensed.{u} Ab.{u+1} :=\n(Profinite.extend.{u} F \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u}) \u22d9 to_Condensed.{u}\n\nvariables {F G H : Fintype.{u} \u2964 CompHausFiltPseuNormGrp\u2081.{u}}\nvariables (\u03b1 \u03b2 : F \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u} \u27f6 G \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u})\nvariables (c c\u03b1 c\u03b2 c\u03b1\u03b2 : \u211d\u22650) [fact (0 < c)]  [fact (0 < c\u03b1)] [fact (0 < c\u03b2)] [fact (0 < c\u03b1\u03b2)]\n\n/--\nGiven functors `F G : Fintype \u2964 CompHausFiltPseuNormGrp\u2081` and a\nnatural transformation `\u03b7` between the induced functors `Fintype \u2964 CompHausFiltPseuNormGrp`\n(obtained by composing with `CHFPNG\u2081_to_CHFPNG\u2091\u2097`), such that the components of `\u03b7` are bounded\nby a *single* `c : \u211d\u22650`, this is the morphism between the associated condensed abelian groups.\n-/\ndef condensify_nonstrict\n  (\u03b1 : F \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u} \u27f6 G \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u}) (c : \u211d\u22650) [fact (0 < c)]\n  (h : \u2200 X, (\u03b1.app X).bound_by c) :\n  condensify F \u27f6 condensify G :=\nwhisker_right (nonstrict_extend.{u} \u03b1 c h) to_Condensed\n\nlemma condensify_nonstrict_id (c : \u211d\u22650) [fact (0 < c)]\n  (h : \u2200 X, (nat_trans.app (\ud835\udfd9 (F \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u})) X).bound_by c) :\n  condensify_nonstrict (\ud835\udfd9 _) c h = \ud835\udfd9 _ :=\nby { simp only [condensify_nonstrict, nonstrict_extend_id, whisker_right_id'], refl }\n\nlemma condensify_nonstrict_comp\n  (\u03b1 : F \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097 \u27f6 G \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097)\n  (\u03b2 : G \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097 \u27f6 H \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097)\n  (h\u03b1 : \u2200 X, (\u03b1.app X).bound_by c\u03b1) (h\u03b2 : \u2200 X, (\u03b2.app X).bound_by c\u03b2)\n  (h\u03b1\u03b2 : \u2200 X, ((\u03b1 \u226b \u03b2).app X).bound_by c\u03b1\u03b2) :\n  condensify_nonstrict (\u03b1 \u226b \u03b2) c\u03b1\u03b2 h\u03b1\u03b2 =\n    condensify_nonstrict \u03b1 c\u03b1 h\u03b1 \u226b condensify_nonstrict \u03b2 c\u03b2 h\u03b2 :=\nbegin\n  simp only [condensify_nonstrict, whisker_right_comp],\n  rw [nonstrict_extend_comp c\u03b1 c\u03b2 c\u03b1\u03b2 _ _ _ _, whisker_right_comp],\nend\n\ndef condensify_map (\u03b1 : F \u27f6 G) : condensify F \u27f6 condensify G :=\ncondensify_nonstrict (whisker_right \u03b1 _) 1\n  (\u03bb X, (comphaus_filtered_pseudo_normed_group_hom.mk_of_strict_strict _ _).bound_by_one)\n\nlemma condensify_map_id (F : Fintype.{u} \u2964 CompHausFiltPseuNormGrp\u2081.{u}) :\n  condensify_map (\ud835\udfd9 F) = \ud835\udfd9 (condensify F) :=\ncondensify_nonstrict_id _ _\n\nlemma condensify_map_comp (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H) :\n  condensify_map (\u03b1 \u226b \u03b2) = condensify_map \u03b1 \u226b condensify_map \u03b2 :=\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} \u2964 CompHausFiltPseuNormGrp\u2081.{u}) :\n  condensify F \u2245 Profinite.extend.{u} F \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u} \u22d9 to_Condensed.{u} :=\niso.refl _\n\n/-- Given a family `F` of profinitely filtered normed groups with `T\u207b\u00b9`,\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\u207b\u00b9`.\n  -/\ndef Tinv_nat_trans (F : C \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') :\n  (F \u22d9 PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097.{u} r') \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097 \u27f6\n  (F \u22d9 PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097.{u} r') \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097 :=\n{ app := \u03bb X, profinitely_filtered_pseudo_normed_group_with_Tinv.Tinv,\n  naturality' := \u03bb X Y f, by { ext x, exact ((F.map f).map_Tinv x).symm } }\n\n/-- The endomorphism `T\u207b\u00b9 - 2` of a strict family of profinitely-filtered\npseudo-normed groups with `T\u207b\u00b9`, considered as a possibly non-strict\nendomorphism of the associated `CompHaus`ly filtered pseudo-normed groups. -/\ndef Tinv2_nat_trans (F : C \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') :\n  (F \u22d9 PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097.{u} r') \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097 \u27f6\n  (F \u22d9 PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097.{u} r') \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097 :=\nTinv_nat_trans F - 2 \u2022 \ud835\udfd9 _\n\nlemma Tinv_bound_by (F : C \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') (X : C) :\n  ((Tinv_nat_trans F).app X).bound_by r'\u207b\u00b9 :=\nprofinitely_filtered_pseudo_normed_group_with_Tinv.Tinv_bound_by\n\nlemma twoid_bound_by (F : C \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') (X : C) :\n  comphaus_filtered_pseudo_normed_group_hom.bound_by\n    ((2 \u2022 \ud835\udfd9 ((F \u22d9 PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r') \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097)).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 \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') (X : C) :\n  ((Tinv2_nat_trans F).app X).bound_by (r'\u207b\u00b9 + 2) :=\n(Tinv_bound_by F X).sub (twoid_bound_by F X)\n\n@[reassoc]\nlemma Tinv_nat_trans_comp {F G : C \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r'} (\u03b1 : F \u27f6 G) :\n  Tinv_nat_trans F \u226b @whisker_right _ _ _ _ _ _ F G \u03b1 (PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r' \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u}) =\n  @whisker_right _ _ _ _ _ _ F G \u03b1 (PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r' \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u}) \u226b Tinv_nat_trans G :=\nby { ext X x, exact (\u03b1.app X).map_Tinv x }\n\n-- move me\ninstance fact_inv_pos : fact (0 < r'\u207b\u00b9) := \u27e8nnreal.inv_pos.2 $ fact.out _\u27e9\n\n--set_option pp.universes true\n\n/--\nGiven a functor from `Fintype` to `ProFiltPseuNormGrpWithTinv\u2081`, the `T\u207b\u00b9` 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} \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') :\n  condensify.{u} (F \u22d9 PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r') \u27f6 condensify.{u} (F \u22d9 PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r') :=\ncondensify_nonstrict (Tinv_nat_trans _) r'\u207b\u00b9 (Tinv_bound_by _)\n\n/--\nA variant of `condensify_Tinv` with a different bound, given by `r'\u207b\u00b9 + 2`.\n-/\ndef condensify_Tinv2 (F : Fintype.{u} \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') :\n  condensify.{u} (F \u22d9 PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r') \u27f6 condensify.{u} (F \u22d9 PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r') :=\ncondensify_nonstrict (Tinv2_nat_trans _) (r'\u207b\u00b9 + 2) (Tinv2_bound_by _)\n\nlemma condensify_map_comp_Tinv {F G : Fintype.{u} \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r'}\n  (\u03b1 : F \u27f6 G) :\n  condensify_map (whisker_right \u03b1 (PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r')) \u226b condensify_Tinv G =\n  condensify_Tinv F \u226b condensify_map (whisker_right \u03b1 (PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r')) :=\nbegin\n  delta condensify_map condensify_Tinv,\n  rw [\u2190 condensify_nonstrict_comp 1 r'\u207b\u00b9 r'\u207b\u00b9, \u2190 condensify_nonstrict_comp r'\u207b\u00b9 1 r'\u207b\u00b9],\n  swap, {\n    intro X,\n    rw nat_trans.comp_app,\n    rw \u2190 one_mul r'\u207b\u00b9,\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\u2081_to_CHFPNG\u2091\u2097_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 \u2190 mul_one r'\u207b\u00b9,\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\u2081_to_CHFPNG\u2091\u2097_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\u03b1 : \u2200 X, (\u03b1.app X).bound_by c\u03b1) (h\u03b2 : \u2200 X, (\u03b2.app X).bound_by c\u03b2)\n  (h\u03b1\u03b2 : \u2200 X, ((\u03b1 + \u03b2).app X).bound_by c\u03b1\u03b2) :\n  condensify_nonstrict (\u03b1 + \u03b2) c\u03b1\u03b2 h\u03b1\u03b2 =\n  condensify_nonstrict \u03b1 c\u03b1 h\u03b1 + condensify_nonstrict \u03b2 c\u03b2 h\u03b2 :=\nbegin\n  delta condensify_nonstrict,\n  rw [nonstrict_extend_map_add _ _ c\u03b1 c\u03b2 c\u03b1\u03b2 h\u03b1 h\u03b2],\n  refl,\nend\n\nlemma condensify_nonstrict_map_neg\n  (h\u03b1 : \u2200 X, (\u03b1.app X).bound_by c\u03b1) (h\u03b2 : \u2200 X, ((-\u03b1).app X).bound_by c\u03b2) :\n  condensify_nonstrict (-\u03b1) c\u03b2 h\u03b2 = -condensify_nonstrict \u03b1 c\u03b1 h\u03b1 :=\nbegin\n  delta condensify_nonstrict,\n  rw [nonstrict_extend_map_neg _ _ c\u03b2 h\u03b1],\n  refl,\nend\n\nlemma condensify_nonstrict_map_sub\n  (h\u03b1 : \u2200 X, (\u03b1.app X).bound_by c\u03b1) (h\u03b2 : \u2200 X, (\u03b2.app X).bound_by c\u03b2)\n  (h\u03b1\u03b2 : \u2200 X, ((\u03b1 - \u03b2).app X).bound_by c\u03b1\u03b2) :\n  condensify_nonstrict (\u03b1 - \u03b2) c\u03b1\u03b2 h\u03b1\u03b2 =\n  condensify_nonstrict \u03b1 c\u03b1 h\u03b1 - condensify_nonstrict \u03b2 c\u03b2 h\u03b2 :=\nbegin\n  delta condensify_nonstrict,\n  rw [nonstrict_extend_map_sub _ _ c\u03b1 c\u03b2 c\u03b1\u03b2 h\u03b1 h\u03b2],\n  refl,\nend\n\nlemma condensify_nonstrict_map_nsmul (n : \u2115)\n  (h\u03b1 : \u2200 X, (\u03b1.app X).bound_by c\u03b1) (h\u03b2 : \u2200 X, ((n \u2022 \u03b1).app X).bound_by c\u03b2) :\n  condensify_nonstrict (n \u2022 \u03b1) c\u03b2 h\u03b2 = n \u2022 condensify_nonstrict \u03b1 c\u03b1 h\u03b1 :=\nbegin\n  delta condensify_nonstrict,\n  rw [nonstrict_extend_map_nsmul _ _ c\u03b2 n h\u03b1],\n  clear h\u03b2,\n  induction n with n ih,\n  { rw [zero_smul, zero_smul], refl },\n  { rw [succ_nsmul, succ_nsmul, \u2190 ih], refl, }\nend\n\n-- lemma nonstrict_extend_Tinv (F : Fintype.{u} \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') :\n--   nonstrict_extend (Tinv_nat_trans F) r'\u207b\u00b9 (Tinv_bound_by _) =\n--     nat_trans.conj_by (iso_whisker_right\n--       (Profinite.extend_commutes F (PFPNG\u2081_to_CHFPNG\u2081\u2091\u2097.{u} r')).symm enlarging_functor.{u})\n--         (Tinv_nat_trans (Profinite.extend F)) :=\n-- begin\n--   refine nonstrict_extend_ext' _ _ r'\u207b\u00b9 (nonstrict_extend_bound_by _ _ _) _ _,\n--   { admit },\n--   { rw [nonstrict_extend_whisker_left],\n--     simp only [whisker_left_comp, \u2190 iso_whisker_left_hom, \u2190 iso_whisker_left_inv,\n--       \u2190 iso.inv_comp_eq, iso.eq_comp_inv, category.assoc],\n--     admit }\n-- end\n\nlemma condensify_nonstrict_Tinv (F : Fintype.{u} \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') :\n  condensify_nonstrict (Tinv_nat_trans F) r'\u207b\u00b9 (Tinv_bound_by _) = condensify_Tinv F :=\nrfl\n\nlemma condensify_nonstrict_whisker_right_enlarging (\u03b1 : F \u27f6 G) :\n  condensify_nonstrict (whisker_right \u03b1 _) 1\n    (\u03bb X, (comphaus_filtered_pseudo_normed_group_hom.mk_of_strict_strict _ _).bound_by_one) =\n  condensify_map \u03b1 :=\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 \u27f6 B) {g : B \u27f6 C} {h : C \u27f6 D} (hf : is_iso f) (hgh : exact g h) :\n  exact (f \u226b g) h :=\nby rwa exact_iso_comp\n\nlemma condensify_nonstrict_exact\n  (\u03b1 : F \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u} \u27f6 G \u22d9 CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u}) (\u03b2 : G \u27f6 H)\n  (c : \u211d\u22650) [fact (0 < c)]\n  (h : \u2200 X, (\u03b1.app X).bound_by c)\n  (c\u03b1 c\u03b2 : \u211d\u22650 \u2192 \u211d\u22650) (hc\u03b1 : id \u2264 c\u03b1) (hc\u03b2 : id \u2264 c\u03b2)\n  (H1 : \u2200 S, function.injective (\u03b1.app S))\n  (H2a : \u2200 S, (\u03b1.app S) \u226b ((whisker_right \u03b2 _).app S) = 0)\n  (H2b : \u2200 S c', (\u03b2.app S) \u207b\u00b9' {0} \u2229 filtration (G.obj S) c' \u2286\n    (\u03b1.app S) '' filtration (F.obj S) (c\u03b1 c' * c\u207b\u00b9))\n  (H3b : \u2200 S c', filtration (H.obj S) c' \u2286 (\u03b2.app S) '' filtration (G.obj S) (c\u03b2 c'))\n  (X : Profinite.{u}) :\n  short_exact ((condensify_nonstrict \u03b1 c h).app X) ((condensify_map \u03b2).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\u03b2,\n    apply exact_with_constant_extend_zero_right,\n    intro S,\n    apply exact_with_constant_of_epi _ _ _ hc\u03b2 (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\u03b1,\n    apply exact_with_constant.extend,\n    intro S,\n    refine \u27e8_, _, hc\u03b1\u27e9,\n    { ext x, specialize H2a S, apply_fun (\u03bb \u03c6, \u03c6.to_fun) at H2a, exact congr_fun H2a x },\n    { intros c' y hy,\n      obtain \u27e8x, hx, rfl\u27e9 := H2b S c' hy,\n      refine \u27e8@rescale.of c _ x, hx, rfl\u27e9, } }\nend\n.\n\nlemma condensify_exact (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H)\n  (c\u03b1 c\u03b2 : \u211d\u22650 \u2192 \u211d\u22650) (hc\u03b1 : id \u2264 c\u03b1) (hc\u03b2 : id \u2264 c\u03b2)\n  (H1 : \u2200 S, function.injective (\u03b1.app S))\n  (H2a : \u2200 S, \u03b1.app S \u226b \u03b2.app S = 0)\n  (H2b : \u2200 S c, (\u03b2.app S) \u207b\u00b9' {0} \u2229 filtration (G.obj S) c \u2286\n    (\u03b1.app S) '' filtration (F.obj S) (c\u03b1 c))\n  (H3b : \u2200 S c, filtration (H.obj S) c \u2286 (\u03b2.app S) '' filtration (G.obj S) (c\u03b2 c))\n  (X : Profinite.{u}) :\n  short_exact ((condensify_map \u03b1).app X) ((condensify_map \u03b2).app X) :=\nbegin\n  refine condensify_nonstrict_exact _ _ 1 _ c\u03b1 c\u03b2 hc\u03b1 hc\u03b2 H1 _ _ H3b _,\n  { intro S, simp only [whisker_right_app, \u2190 functor.map_comp, H2a], refl, },\n  { intros S c' x H, obtain \u27e8x, hx, rfl\u27e9 := H2b S c' H,\n    refine \u27e8x, pseudo_normed_group.filtration_mono _ hx, rfl\u27e9,\n    simp only [inv_one, mul_one], },\nend\n\n-- move me\nattribute [simps] Ab.ulift\n\nlemma condensify_Tinv2_eq (F : Fintype.{u} \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r') :\n  condensify_Tinv2 F = condensify_Tinv F - 2 \u2022 \ud835\udfd9 _ :=\nbegin\n  delta condensify_Tinv2 Tinv2_nat_trans,\n  rw [condensify_nonstrict_map_sub _ _ r'\u207b\u00b9 2 (r'\u207b\u00b9 + 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 [\u2190 condensify_map_id, \u2190 condensify_nonstrict_whisker_right_enlarging],\n  refl\nend\n\nopen category_theory.preadditive\n\nlemma condensify_map_comp_Tinv2 {F G : Fintype.{u} \u2964 ProFiltPseuNormGrpWithTinv\u2081.{u} r'}\n  (\u03b1 : F \u27f6 G) :\n  condensify_map (whisker_right \u03b1 (PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 r')) \u226b condensify_Tinv2 G =\n  condensify_Tinv2 F \u226b condensify_map (whisker_right \u03b1 (PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 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} {\u03b1 \u03b2 \u03b3 : 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 := \u03bb i \u27e8t, seed\u27e9, match seed.lookup_fst i t with\n    -- Once the seed is empty, just keep it empty going forward\n    | none := (\u03bb 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 \u03b1) (i : spec.\u03b9)\n  (choose_fork : \u03b1 \u2192 query_log spec \u2192 option \u2115) :\n\u2045do{ \u27e8a, log\u27e9 \u2190 simulate (logging_oracle spec) oa (query_log.init spec),\n      seed \u2190 return (log.fork_cache i $ choose_fork a log).to_seed,\n      \u27e8a', log'\u27e9 \u2190 simulate (seeded_oracle spec) oa seed,\n      return (a, log) }\u2046 =\n  \u2045(simulate (logging_oracle spec) oa (query_log.init spec))\u2046 :=\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 \u03b1) (i : spec.\u03b9)\n  (choose_fork : \u03b1 \u2192 query_log spec \u2192 option \u2115) :\n\u2045do{ \u27e8a, log\u27e9 \u2190 simulate (logging_oracle spec) oa (query_log.init spec),\n      seed \u2190 return (log.fork_cache i $ choose_fork a log).to_seed,\n      \u27e8a', log'\u27e9 \u2190 simulate (seeded_oracle spec) oa (seed),\n      return (a', log') }\u2046 =  \n  \u2045(simulate (logging_oracle spec) oa (query_log.init spec))\u2046 :=\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 \u03b1) (i : spec.\u03b9)\n  (choose_fork : \u03b1 \u2192 query_log spec \u2192 option \u2115) :\ndo{ \u27e8a, log\u27e9 \u2190 simulate (logging_oracle spec) oa (query_log.init spec),\n    seed \u2190 return (log.fork_cache i $ choose_fork a log).to_seed,\n    \u27e8a', log'\u27e9 \u2190 simulate (seeded_oracle spec) oa (seed),\n    return (a, log, log') }.support\n  \u2286 \u03bb \u27e8a, log, log'\u27e9, 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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (((((a3).write i3 ((a2).read i1)).write i1 (v2)).write i3 (v2)).read i1) \u2260 (v2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test62.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.4610167793123159, "lm_q1q2_score": 0.24130556349315269}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i1 (v1)).write i2 (v1)).read i1) \u2260 (v1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test53.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.4571367168274948, "lm_q1q2_score": 0.2410557442266242}}
{"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 \u2192 F\nvariable  \u03c3 : 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 \u03c3.pc\n    (h_mem : mem_at mem code_assert_nn \u03c3.pc)\n    -- input arguments on the stack\n    (hin_range_check_ptr : range_check_ptr = mem (\u03c3.fp - 4))\n    (hin_a : a = mem (\u03c3.fp - 3))\n    -- conclusion\n  : ensures_ret mem \u03c3 (\u03bb \u03ba \u03c4,\n      \u03c4.ap = \u03c3.ap + 1 \u2227\n      \u2203 \u03bc \u2264 \u03ba, rc_ensures mem (rc_bound F) \u03bc (mem (\u03c3.fp - 4)) (mem $ \u03c4.ap - 1)\n        (spec_assert_nn mem \u03ba range_check_ptr a (mem (\u03c4.ap - 1)))) :=\nbegin\n  apply ensures_of_ensuresb, intro \u03bdbound,\n  have h_mem_rec := h_mem,\n  unpack_memory code_assert_nn at h_mem with \u27e8hpc0, hpc1, hpc2, hpc3\u27e9,\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\u2081: (range_check_ptr + 1 : F) = range_check_ptr\u2081,\n  have hl_range_check_ptr\u2081 := hl_rev_range_check_ptr\u2081.symm, clear hl_rev_range_check_ptr\u2081,\n  try { dsimp at hl_range_check_ptr\u2081 }, try { arith_simps at hl_range_check_ptr\u2081 },\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\u2081 := range_checked_offset' rc_h_range_check_ptr,\n  have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081,try { norm_cast at rc_h_range_check_ptr\u2081' },\n  use_only [range_check_ptr\u2081, hl_range_check_ptr\u2081],\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\u2081] }, },\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": "\nimport topology.basic\nimport topology.compact_open\nimport data.nat.prime\nimport data.real.basic\nimport data.real.irrational\nimport data.complex.basic\nimport data.fin.basic\nimport geometry.euclidean.basic\nimport analysis.inner_product_space.pi_L2\nimport algebra.group.defs\nimport algebra.field.basic\nimport combinatorics.configuration\nimport ring_theory.polynomial.basic\nimport group_theory.free_group\nimport combinatorics.simple_graph.basic\nimport ring_theory.integral_closure\nimport data.fintype.card\nimport category_theory.category.basic\nimport ring_theory.discrete_valuation_ring\nimport group_theory.torsion\nimport linear_algebra.matrix.charpoly.basic\nimport algebra.order.absolute_value\nimport analysis.convex.basic\nimport topology.uniform_space.uniform_convergence_topology\nimport topology.sequences\nimport analysis.normed.group.infinite_sum\nimport data.nat.choose.sum\nimport group_theory.specific_groups.cyclic\nimport group_theory.order_of_element\nimport analysis.mean_inequalities\nimport analysis.normed_space.banach\nimport topology.algebra.continuous_monoid_hom\nimport linear_algebra.matrix.symmetric\nimport analysis.inner_product_space.spectrum\nimport ring_theory.class_group\nimport ring_theory.dedekind_domain.basic\nimport ring_theory.principal_ideal_domain\nimport model_theory.satisfiability\nimport probability.integration\nimport ring_theory.simple_module\nimport category_theory.preadditive.schur\nimport representation_theory.maschke\nimport topology.paracompact\nimport combinatorics.simple_graph.coloring\n--Prove that Symmetric real matrices have real eigenvalues in Lean mathlib\n \n--OUTPUT 1\ntheorem symmetric_real_matrix_real_eigenvalues (n : \u2115) (A : matrix (fin n) (fin n) \u211d) (h : symmetric A) :\n  \u2200 (i : fin n), \u2203 (\u03bb : \u211d), is_eigenvalue A \u03bb i :=\nbegin\n  intros i,\n  have h1 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h2 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h3 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h4 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h5 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h6 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h7 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h8 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h9 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h10 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h11 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h12 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h13 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h14 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h15 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h16 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h17 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h18 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h19 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h20 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h21 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h22 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h23 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h24 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h25 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h26 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h27 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h28 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h29 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h30 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n  },\n  have h31 : is_eigenvector A (A.mul_vec (\u03bb i) (\u03bb i)) (\u03bb i),\n  {\n    apply is_eigenvector_mul_vec,\n    apply is_eigenvector_self,\n\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/Zero-shot-theorem-names/Zero-Shot-prompts_temperature_0_max_tokens_2000_n_1/clean_files/Symmetric real matrices have real eigenvalues.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6370307944803832, "lm_q2_score": 0.37754066879814546, "lm_q1q2_score": 0.24050503219313785}}
{"text": "import data.option.basic\n\nexample (\u03b1 : Type*) (a : \u03b1) [subsingleton \u03b1] : option.choice \u03b1 = some a :=\nbegin\n  sorry\nend\n", "meta": {"author": "kbuzzard", "repo": "xena", "sha": "cd2f0b5e948b7171dbafc5cb519a3220d318bd9d", "save_path": "github-repos/lean/kbuzzard-xena", "path": "github-repos/lean/kbuzzard-xena/xena-cd2f0b5e948b7171dbafc5cb519a3220d318bd9d/Examples/termle.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.2404692925384661}}
{"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\u2081 P\u2082` (notation: `P\u2081 \u2243\u1d43[k] P\u2082`) to be the type of affine\nequivalences between `P\u2081` and `P\u2082, 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\u2081 : Type u_2) (P\u2082 : Type u_3) {V\u2081 : Type u_4} {V\u2082 : Type u_5} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] \nextends P\u2081 \u2243 P\u2082\nwhere\n  linear : linear_equiv k V\u2081 V\u2082\n  map_vadd' : \u2200 (p : P\u2081) (v : V\u2081), coe_fn _to_equiv (v +\u1d65 p) = coe_fn linear v +\u1d65 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 \u2192 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\u2081 : Type u_2} {V\u2082 : Type u_3} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] (e : linear_equiv k V\u2081 V\u2082) : affine_equiv k V\u2081 V\u2082 :=\n  affine_equiv.mk (to_equiv e) e sorry\n\n@[simp] theorem coe_to_affine_equiv {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] (e : linear_equiv k V\u2081 V\u2082) : \u21d1(to_affine_equiv e) = \u21d1e :=\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\u2081 : Type u_2} (P\u2081 : Type u_6) [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] : affine_equiv k P\u2081 P\u2081 :=\n  mk (equiv.refl P\u2081) (linear_equiv.refl k V\u2081) sorry\n\n@[simp] theorem coe_refl (k : Type u_1) {V\u2081 : Type u_2} (P\u2081 : Type u_6) [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] : \u21d1(refl k P\u2081) = id :=\n  rfl\n\ntheorem refl_apply (k : Type u_1) {V\u2081 : Type u_2} (P\u2081 : Type u_6) [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (x : P\u2081) : coe_fn (refl k P\u2081) x = x :=\n  rfl\n\n@[simp] theorem to_equiv_refl (k : Type u_1) {V\u2081 : Type u_2} (P\u2081 : Type u_6) [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] : to_equiv (refl k P\u2081) = equiv.refl P\u2081 :=\n  rfl\n\n@[simp] theorem linear_refl (k : Type u_1) {V\u2081 : Type u_2} (P\u2081 : Type u_6) [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] : linear (refl k P\u2081) = linear_equiv.refl k V\u2081 :=\n  rfl\n\n@[simp] theorem map_vadd {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) (p : P\u2081) (v : V\u2081) : coe_fn e (v +\u1d65 p) = coe_fn (linear e) v +\u1d65 coe_fn e p :=\n  map_vadd' e p v\n\n@[simp] theorem coe_to_equiv {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : \u21d1(to_equiv e) = \u21d1e :=\n  rfl\n\n/-- Reinterpret an `affine_equiv` as an `affine_map`. -/\ndef to_affine_map {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : affine_map k P\u2081 P\u2082 :=\n  affine_map.mk (\u21d1e) (\u2191(linear e)) (map_vadd' e)\n\n@[simp] theorem coe_to_affine_map {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : \u21d1(to_affine_map e) = \u21d1e :=\n  rfl\n\n@[simp] theorem to_affine_map_mk {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (f : P\u2081 \u2243 P\u2082) (f' : linear_equiv k V\u2081 V\u2082) (h : \u2200 (p : P\u2081) (v : V\u2081), coe_fn f (v +\u1d65 p) = coe_fn f' v +\u1d65 coe_fn f p) : to_affine_map (mk f f' h) = affine_map.mk (\u21d1f) (\u2191f') h :=\n  rfl\n\n@[simp] theorem linear_to_affine_map {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : affine_map.linear (to_affine_map e) = \u2191(linear e) :=\n  rfl\n\ntheorem injective_to_affine_map {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] : function.injective to_affine_map := sorry\n\n@[simp] theorem to_affine_map_inj {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] {e : affine_equiv k P\u2081 P\u2082} {e' : affine_equiv k P\u2081 P\u2082} : to_affine_map e = to_affine_map e' \u2194 e = e' :=\n  function.injective.eq_iff injective_to_affine_map\n\ntheorem ext {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] {e : affine_equiv k P\u2081 P\u2082} {e' : affine_equiv k P\u2081 P\u2082} (h : \u2200 (x : P\u2081), 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\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] : function.injective fun (e : affine_equiv k P\u2081 P\u2082) (x : P\u2081) => coe_fn e x := sorry\n\n@[simp] theorem coe_fn_inj {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] {e : affine_equiv k P\u2081 P\u2082} {e' : affine_equiv k P\u2081 P\u2082} : \u21d1e = \u21d1e' \u2194 e = e' :=\n  function.injective.eq_iff injective_coe_fn\n\ntheorem injective_to_equiv {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] : function.injective to_equiv :=\n  fun (e e' : affine_equiv k P\u2081 P\u2082) (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\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] {e : affine_equiv k P\u2081 P\u2082} {e' : affine_equiv k P\u2081 P\u2082} : to_equiv e = to_equiv e' \u2194 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\u2081 \u2243 P\u2082`, a linear equivalece\n`e' : V\u2081 \u2243\u2097[k] V\u2082`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -\u1d65 p) +\u1d65 e p`. -/\ndef mk' {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : P\u2081 \u2243 P\u2082) (e' : linear_equiv k V\u2081 V\u2082) (p : P\u2081) (h : \u2200 (p' : P\u2081), coe_fn e p' = coe_fn e' (p' -\u1d65 p) +\u1d65 coe_fn e p) : affine_equiv k P\u2081 P\u2082 :=\n  mk e e' sorry\n\n@[simp] theorem coe_mk' {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : P\u2081 \u2243 P\u2082) (e' : linear_equiv k V\u2081 V\u2082) (p : P\u2081) (h : \u2200 (p' : P\u2081), coe_fn e p' = coe_fn e' (p' -\u1d65 p) +\u1d65 coe_fn e p) : \u21d1(mk' e e' p h) = \u21d1e :=\n  rfl\n\n@[simp] theorem to_equiv_mk' {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : P\u2081 \u2243 P\u2082) (e' : linear_equiv k V\u2081 V\u2082) (p : P\u2081) (h : \u2200 (p' : P\u2081), coe_fn e p' = coe_fn e' (p' -\u1d65 p) +\u1d65 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\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : P\u2081 \u2243 P\u2082) (e' : linear_equiv k V\u2081 V\u2082) (p : P\u2081) (h : \u2200 (p' : P\u2081), coe_fn e p' = coe_fn e' (p' -\u1d65 p) +\u1d65 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\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : affine_equiv k P\u2082 P\u2081 :=\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\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : equiv.symm (to_equiv e) = to_equiv (symm e) :=\n  rfl\n\n@[simp] theorem symm_linear {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : linear_equiv.symm (linear e) = linear (symm e) :=\n  rfl\n\nprotected theorem bijective {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : function.bijective \u21d1e :=\n  equiv.bijective (to_equiv e)\n\nprotected theorem surjective {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : function.surjective \u21d1e :=\n  equiv.surjective (to_equiv e)\n\nprotected theorem injective {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : function.injective \u21d1e :=\n  equiv.injective (to_equiv e)\n\n@[simp] theorem range_eq {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : set.range \u21d1e = set.univ :=\n  function.surjective.range_eq (affine_equiv.surjective e)\n\n@[simp] theorem apply_symm_apply {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) (p : P\u2082) : 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\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) (p : P\u2081) : 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\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) {p\u2081 : P\u2081} {p\u2082 : P\u2082} : coe_fn e p\u2081 = p\u2082 \u2194 p\u2081 = coe_fn (symm e) p\u2082 :=\n  equiv.apply_eq_iff_eq_symm_apply (to_equiv e)\n\n@[simp] theorem apply_eq_iff_eq {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) {p\u2081 : P\u2081} {p\u2082 : P\u2081} : coe_fn e p\u2081 = coe_fn e p\u2082 \u2194 p\u2081 = p\u2082 :=\n  equiv.apply_eq_iff_eq (to_equiv e)\n\n@[simp] theorem symm_refl {k : Type u_1} {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] : symm (refl k P\u2081) = refl k P\u2081 :=\n  rfl\n\n/-- Composition of two `affine_equiv`alences, applied left to right. -/\ndef trans {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {V\u2083 : Type u_4} {P\u2081 : Type u_6} {P\u2082 : Type u_7} {P\u2083 : Type u_8} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] [add_comm_group V\u2083] [semimodule k V\u2083] [add_torsor V\u2083 P\u2083] (e : affine_equiv k P\u2081 P\u2082) (e' : affine_equiv k P\u2082 P\u2083) : affine_equiv k P\u2081 P\u2083 :=\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\u2081 : Type u_2} {V\u2082 : Type u_3} {V\u2083 : Type u_4} {P\u2081 : Type u_6} {P\u2082 : Type u_7} {P\u2083 : Type u_8} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] [add_comm_group V\u2083] [semimodule k V\u2083] [add_torsor V\u2083 P\u2083] (e : affine_equiv k P\u2081 P\u2082) (e' : affine_equiv k P\u2082 P\u2083) : \u21d1(trans e e') = \u21d1e' \u2218 \u21d1e :=\n  rfl\n\ntheorem trans_apply {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {V\u2083 : Type u_4} {P\u2081 : Type u_6} {P\u2082 : Type u_7} {P\u2083 : Type u_8} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] [add_comm_group V\u2083] [semimodule k V\u2083] [add_torsor V\u2083 P\u2083] (e : affine_equiv k P\u2081 P\u2082) (e' : affine_equiv k P\u2082 P\u2083) (p : P\u2081) : coe_fn (trans e e') p = coe_fn e' (coe_fn e p) :=\n  rfl\n\ntheorem trans_assoc {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {V\u2083 : Type u_4} {V\u2084 : Type u_5} {P\u2081 : Type u_6} {P\u2082 : Type u_7} {P\u2083 : Type u_8} {P\u2084 : Type u_9} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] [add_comm_group V\u2083] [semimodule k V\u2083] [add_torsor V\u2083 P\u2083] [add_comm_group V\u2084] [semimodule k V\u2084] [add_torsor V\u2084 P\u2084] (e\u2081 : affine_equiv k P\u2081 P\u2082) (e\u2082 : affine_equiv k P\u2082 P\u2083) (e\u2083 : affine_equiv k P\u2083 P\u2084) : trans (trans e\u2081 e\u2082) e\u2083 = trans e\u2081 (trans e\u2082 e\u2083) :=\n  ext fun (_x : P\u2081) => rfl\n\n@[simp] theorem trans_refl {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : trans e (refl k P\u2082) = e :=\n  ext fun (_x : P\u2081) => rfl\n\n@[simp] theorem refl_trans {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : trans (refl k P\u2081) e = e :=\n  ext fun (_x : P\u2081) => rfl\n\n@[simp] theorem trans_symm {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : trans e (symm e) = refl k P\u2081 :=\n  ext (symm_apply_apply e)\n\n@[simp] theorem symm_trans {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) : trans (symm e) e = refl k P\u2082 :=\n  ext (apply_symm_apply e)\n\n@[simp] theorem apply_line_map {k : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {P\u2081 : Type u_6} {P\u2082 : Type u_7} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [add_comm_group V\u2082] [semimodule k V\u2082] [add_torsor V\u2082 P\u2082] (e : affine_equiv k P\u2081 P\u2082) (a : P\u2081) (b : P\u2081) (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\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] : group (affine_equiv k P\u2081 P\u2081) :=\n  group.mk (fun (e e' : affine_equiv k P\u2081 P\u2081) => trans e' e) sorry (refl k P\u2081) trans_refl refl_trans symm\n    (div_inv_monoid.div._default (fun (e e' : affine_equiv k P\u2081 P\u2081) => trans e' e) sorry (refl k P\u2081) trans_refl refl_trans\n      symm)\n    trans_symm\n\ntheorem one_def {k : Type u_1} {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] : 1 = refl k P\u2081 :=\n  rfl\n\n@[simp] theorem coe_one {k : Type u_1} {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] : \u21d11 = id :=\n  rfl\n\ntheorem mul_def {k : Type u_1} {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (e : affine_equiv k P\u2081 P\u2081) (e' : affine_equiv k P\u2081 P\u2081) : e * e' = trans e' e :=\n  rfl\n\n@[simp] theorem coe_mul {k : Type u_1} {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (e : affine_equiv k P\u2081 P\u2081) (e' : affine_equiv k P\u2081 P\u2081) : \u21d1(e * e') = \u21d1e \u2218 \u21d1e' :=\n  rfl\n\ntheorem inv_def {k : Type u_1} {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (e : affine_equiv k P\u2081 P\u2081) : e\u207b\u00b9 = symm e :=\n  rfl\n\n/-- The map `v \u21a6 v +\u1d65 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\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (b : P\u2081) : affine_equiv k V\u2081 P\u2081 :=\n  mk (equiv.vadd_const b) (linear_equiv.refl k V\u2081) sorry\n\n@[simp] theorem linear_vadd_const (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (b : P\u2081) : linear (vadd_const k b) = linear_equiv.refl k V\u2081 :=\n  rfl\n\n@[simp] theorem vadd_const_apply (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (b : P\u2081) (v : V\u2081) : coe_fn (vadd_const k b) v = v +\u1d65 b :=\n  rfl\n\n@[simp] theorem vadd_const_symm_apply (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (b : P\u2081) (p : P\u2081) : coe_fn (symm (vadd_const k b)) p = p -\u1d65 b :=\n  rfl\n\n/-- `p' \u21a6 p -\u1d65 p'` as an equivalence. -/\ndef const_vsub (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (p : P\u2081) : affine_equiv k P\u2081 V\u2081 :=\n  mk (equiv.const_vsub p) (linear_equiv.neg k) sorry\n\n@[simp] theorem coe_const_vsub (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (p : P\u2081) : \u21d1(const_vsub k p) = has_vsub.vsub p :=\n  rfl\n\n@[simp] theorem coe_const_vsub_symm (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (p : P\u2081) : \u21d1(symm (const_vsub k p)) = fun (v : V\u2081) => -v +\u1d65 p :=\n  rfl\n\n/-- The map `p \u21a6 v +\u1d65 p` as an affine automorphism of an affine space. -/\ndef const_vadd (k : Type u_1) {V\u2081 : Type u_2} (P\u2081 : Type u_6) [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (v : V\u2081) : affine_equiv k P\u2081 P\u2081 :=\n  mk (equiv.const_vadd P\u2081 v) (linear_equiv.refl k V\u2081) sorry\n\n@[simp] theorem linear_const_vadd (k : Type u_1) {V\u2081 : Type u_2} (P\u2081 : Type u_6) [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (v : V\u2081) : linear (const_vadd k P\u2081 v) = linear_equiv.refl k V\u2081 :=\n  rfl\n\n@[simp] theorem const_vadd_apply (k : Type u_1) {V\u2081 : Type u_2} (P\u2081 : Type u_6) [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (v : V\u2081) (p : P\u2081) : coe_fn (const_vadd k P\u2081 v) p = v +\u1d65 p :=\n  rfl\n\n@[simp] theorem const_vadd_symm_apply (k : Type u_1) {V\u2081 : Type u_2} (P\u2081 : Type u_6) [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (v : V\u2081) (p : P\u2081) : coe_fn (symm (const_vadd k P\u2081 v)) p = -v +\u1d65 p :=\n  rfl\n\n/-- Point reflection in `x` as a permutation. -/\ndef point_reflection (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (x : P\u2081) : affine_equiv k P\u2081 P\u2081 :=\n  trans (const_vsub k x) (vadd_const k x)\n\ntheorem point_reflection_apply (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (x : P\u2081) (y : P\u2081) : coe_fn (point_reflection k x) y = x -\u1d65 y +\u1d65 x :=\n  rfl\n\n@[simp] theorem point_reflection_symm (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (x : P\u2081) : 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\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (x : P\u2081) : to_equiv (point_reflection k x) = equiv.point_reflection x :=\n  rfl\n\n@[simp] theorem point_reflection_self (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (x : P\u2081) : coe_fn (point_reflection k x) x = x :=\n  vsub_vadd x x\n\ntheorem point_reflection_involutive (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (x : P\u2081) : function.involutive \u21d1(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 \u2194 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\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] {x : P\u2081} {y : P\u2081} (h : function.injective bit0) : coe_fn (point_reflection k x) y = y \u2194 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\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (h : function.injective bit0) (y : P\u2081) : function.injective fun (x : P\u2081) => 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\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [invertible (bit0 1)] (y : P\u2081) : function.injective fun (x : P\u2081) => coe_fn (point_reflection k x) y := sorry\n\ntheorem point_reflection_fixed_iff_of_module (k : Type u_1) {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] [invertible (bit0 1)] {x : P\u2081} {y : P\u2081} : coe_fn (point_reflection k x) y = y \u2194 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\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (v : V\u2081) (v' : V\u2081) (p : P\u2081) (c : k) : coe_fn (line_map v v') c +\u1d65 p = coe_fn (line_map (v +\u1d65 p) (v' +\u1d65 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\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (p\u2081 : P\u2081) (p\u2082 : P\u2081) (p\u2083 : P\u2081) (c : k) : coe_fn (line_map p\u2081 p\u2082) c -\u1d65 p\u2083 = coe_fn (line_map (p\u2081 -\u1d65 p\u2083) (p\u2082 -\u1d65 p\u2083)) c :=\n  affine_equiv.apply_line_map (affine_equiv.symm (affine_equiv.vadd_const k p\u2083)) p\u2081 p\u2082 c\n\ntheorem vsub_line_map {k : Type u_1} {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (p\u2081 : P\u2081) (p\u2082 : P\u2081) (p\u2083 : P\u2081) (c : k) : p\u2081 -\u1d65 coe_fn (line_map p\u2082 p\u2083) c = coe_fn (line_map (p\u2081 -\u1d65 p\u2082) (p\u2081 -\u1d65 p\u2083)) c :=\n  affine_equiv.apply_line_map (affine_equiv.const_vsub k p\u2081) p\u2082 p\u2083 c\n\ntheorem vadd_line_map {k : Type u_1} {V\u2081 : Type u_2} {P\u2081 : Type u_6} [ring k] [add_comm_group V\u2081] [semimodule k V\u2081] [add_torsor V\u2081 P\u2081] (v : V\u2081) (p\u2081 : P\u2081) (p\u2082 : P\u2081) (c : k) : v +\u1d65 coe_fn (line_map p\u2081 p\u2082) c = coe_fn (line_map (v +\u1d65 p\u2081) (v +\u1d65 p\u2082)) c :=\n  affine_equiv.apply_line_map (affine_equiv.const_vadd k P\u2081 v) p\u2081 p\u2082 c\n\ntheorem homothety_neg_one_apply {V\u2081 : Type u_2} {P\u2081 : Type u_6} [add_comm_group V\u2081] [add_torsor V\u2081 P\u2081] {R' : Type u_10} [comm_ring R'] [semimodule R' V\u2081] (c : P\u2081) (p : P\u2081) : 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 : \u00ac \u2200 (\u03b1 : Type) (r : Prop), r \u2192 (\u2203 x : \u03b1, r) :=\nbegin\n  intro h,\n  cases h empty _ true.intro with w,\n  cases w\nend\n\nexample (\u03b1 : Type) [inhabited \u03b1] (r : Prop) : r \u2192 (\u2203 x : \u03b1, r) :=\n\u03bb h, \u27e8inhabited.default \u03b1, h\u27e9\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}} (\ud835\udcd5 : sheaf Ab X) (U V : X.oc)\n\nsection\n\nvariables {U}\n\ndef vec_o.single (i : U.\u03b9) : vec_o U 1 :=\n{ to_fun := \u03bb _, i,\n  is_strict_mono := \u03bb \u27e8i, hi\u27e9 \u27e8j, hj\u27e9 (h : i < j), by linarith }\n\ndef vec_o.double {i j : U.\u03b9} (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 : \u00ac 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.\u03b9} (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.\u03b9} (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.\u03b9} (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.\u03b9} (h : i < j) :\n  ignore_o (vec_o.double h) 1 = vec_o.single i :=\nsorry\n\nlemma face.vec_o_single (i : U.\u03b9) :\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 \u22a2,\n  { erw opens.fintype_infi at hx,\n    specialize hx 0,\n    convert hx,  },\n  { erw opens.fintype_infi,\n    rintros \u27e8i, hi\u27e9,\n    interval_cases i,\n    convert hx, },\nend\n\nlemma face.double_le_single1 {i j : U.\u03b9} (h : i < j) :\n  face_o (vec_o.double h) \u2264 face_o (vec_o.single i) := sorry\n\nlemma face.double_le_single2 {i j : U.\u03b9} (h : i < j) :\n  face_o (vec_o.double h) \u2264 face_o (vec_o.single j) := sorry\n\n\nend\n\ndef d_o_from_to (i j : \u2115) : C_o \ud835\udcd5 U i \u27f6 C_o \ud835\udcd5 U j :=\ndite (j = i + 1)\n(\u03bb h, d_o \ud835\udcd5 U i \u226b eq_to_hom (by rw h))\n(\u03bb h, 0)\n\nlemma d_o_to_succ {i : \u2115} (f \u03b1) :\n  d_o_from_to \ud835\udcd5 U i (i + 1) f \u03b1 = d_o \ud835\udcd5 U i f \u03b1 :=\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 : \u2115) :\n  d_o_from_to \ud835\udcd5 U i (i + 1) = d_o \ud835\udcd5 U i :=\nbegin\n  ext f \u03b1,\n  rw d_o_from_to,\n  rw dif_pos rfl,\n  refl,\nend\n\nlemma d_o_not_to_succ {i j : \u2115} (h : j \u2260 i + 1) (f \u03b1) :\n  d_o_from_to \ud835\udcd5 U i j f \u03b1 = 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} \u2115 :=\n{ X := \u03bb n, C_o \ud835\udcd5 U (n + 1),\n  d := \u03bb i j, d_o_from_to \ud835\udcd5 U _ _,\n  shape' := \u03bb i j h, begin\n    ext f \u03b1,\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' := \u03bb 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 \u03b1,\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 : \u2115) (m) (h : (complex_shape.up \u2115).prev n = some m) :\n  (Cech_complex_wrt_cover_ordered \ud835\udcd5 U).d m.1 n =\n  d_o \ud835\udcd5 U (m.1 + 1) \u226b 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 \ud835\udcd5 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 : \u2115) : Ab :=\n@homological_complex.homology \u2115 Ab _ _ (complex_shape.up \u2115) (abelian.has_zero_object) _ _ _\n  (Cech_complex_wrt_cover_ordered \ud835\udcd5 U) n\n\nsection zeroth\n\ndef ex1 :\n  Cech_Cohomology_Group_wrt_cover_ordered_nth \ud835\udcd5 U 0 \u2245\n  kernel ((Cech_complex_wrt_cover_ordered \ud835\udcd5 U).d 0 1) :=\nbegin\n  refine homology_iso_cokernel_image_to_kernel' _ _ _ \u226a\u226b _,\n  change cokernel (kernel.lift _ _ _) \u2245 _,\n\n  simp only [image.\u03b9_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 \u226a\u226b _,\n  refine AddCommGroup.kernel_iso_ker _ \u226a\u226b _,\n  refine _ \u226a\u226b (AddCommGroup.kernel_iso_ker (d_o \ud835\udcd5 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 \u27e8x.1, _\u27e9,\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 \ud835\udcd5 U) (show 1 = 0 + 1, from rfl),\n      generalize_proofs h1 h2 at eq1,\n      change _ = d_o _ _ _ \u226b _ at eq1,\n      have eq2 : homological_complex.d_from (Cech_complex_wrt_cover_ordered \ud835\udcd5 U) 0 x.1 = (d_o \ud835\udcd5 _ _ \u226b (homological_complex.X_next_iso (Cech_complex_wrt_cover_ordered \ud835\udcd5 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 \ud835\udcd5 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 \u2190eq2, \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 \u27e8x.1, _\u27e9,\n      have := x.2,\n      rw add_monoid_hom.mem_ker at this \u22a2,\n      have eq1 := homological_complex.d_from_eq (Cech_complex_wrt_cover_ordered \ud835\udcd5 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 \ud835\udcd5 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 \ud835\udcd5 U) h1).inv,\n      refine \u27e8_, _\u27e9,\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 \u03c3,\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 \u03c3,\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 \ud835\udcd5 U).d 0 1) \u2245\n  kernel (d_o \ud835\udcd5 U 1) :=\neq_to_iso rfl\n\ndef ex3 :\n  kernel (d_o \ud835\udcd5 U 1) \u2245\n  AddCommGroup.of (add_monoid_hom.ker (d_o \ud835\udcd5 U 1)) :=\nAddCommGroup.kernel_iso_ker _\n\nlemma ex41.forward.aux1 {i j : U.\u03b9} {f : C_o \ud835\udcd5 U 1} \n  (h : d_o _ _ _ f = 0) :\n  \ud835\udcd5.1.map ((U.cover i).inf_le_left (U.cover j) \u226b eq_to_hom begin\n    rw \u2190 face.vec_o_single,\n    refl,\n  end).op (f (vec_o.single i)) = \n  \ud835\udcd5.1.map (hom_of_le begin\n    convert inf_le_left,\n    rw \u2190 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.\u03b9} {f : C_o \ud835\udcd5 U 1} \n  (h : d_o _ _ _ f = 0) :\n  \ud835\udcd5.1.map ((U.cover i).inf_le_right (U.cover j) \u226b eq_to_hom begin\n    rw \u2190 face.vec_o_single,\n    refl,\n  end).op (f (vec_o.single j)) = \n  \ud835\udcd5.1.map (hom_of_le begin\n    convert inf_le_right,\n    rw \u2190 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.\u03b9} {f : C_o \ud835\udcd5 U 1} \n  (h : d_o _ _ _ f = 0) :\n  \ud835\udcd5.1.map ((U.cover i).inf_le_right (U.cover j) \u226b eq_to_hom begin\n    rw \u2190 face.vec_o_single,\n    refl,\n  end).op (f (vec_o.single j)) = \n  \ud835\udcd5.1.map (hom_of_le begin\n    convert inf_le_right,\n    rw \u2190 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.\u03b9} {f : C_o \ud835\udcd5 U 1} \n  (h : d_o _ _ _ f = 0) :\n  \ud835\udcd5.1.map ((U.cover i).inf_le_left (U.cover j) \u226b eq_to_hom begin\n    rw \u2190 face.vec_o_single,\n    refl,\n  end).op (f (vec_o.single i)) = \n  \ud835\udcd5.1.map (hom_of_le begin\n    convert inf_le_left,\n    rw \u2190 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.\u03b9} (ineq : i < j) (f : C_o \ud835\udcd5 U 1) :\n  \ud835\udcd5.1.map (hom_of_le (face.le_ignore_o _ _)).op (f (ignore_o (vec_o.double ineq) 0)) =\n  \ud835\udcd5.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 [\u2190 comp_apply, \u2190 \ud835\udcd5.1.map_comp],\n  congr,\nend\n\nlemma ex41.forward.aux3' {i j : U.\u03b9} (ineq : j < i) (f : C_o \ud835\udcd5 U 1) :\n  \ud835\udcd5.1.map (hom_of_le (face.le_ignore_o _ _)).op \n  (f (ignore_o (vec_o.double ineq) 0)) =\n  \ud835\udcd5.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 [\u2190 comp_apply, \u2190 \ud835\udcd5.1.map_comp],\n  congr,\nend\n\nlemma ex41.forward.aux4 {i j : U.\u03b9} (ineq : i < j) (f : C_o \ud835\udcd5 U 1) :\n  \ud835\udcd5.1.map (hom_of_le (face.le_ignore_o _ _)).op (f (ignore_o (vec_o.double ineq) 1)) =\n  \ud835\udcd5.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 [\u2190 comp_apply, \u2190 \ud835\udcd5.1.map_comp],\n  congr,\nend\n\nlemma ex41.forward.aux4' {i j : U.\u03b9} (ineq : j < i) (f : C_o \ud835\udcd5 U 1) :\n  \ud835\udcd5.1.map (hom_of_le (face.le_ignore_o _ _)).op \n  (f (ignore_o (vec_o.double ineq) 1)) =\n  \ud835\udcd5.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 [\u2190 comp_apply, \u2190 \ud835\udcd5.1.map_comp],\n  congr,\nend\n\nlemma ex41.forward.aux5 (f : C_o \ud835\udcd5 U 1) \n  (o1 o2 o3 o4 : opens X)\n  (oop2 : \ud835\udcd5.val.obj (op o2))\n  (oop3 : \ud835\udcd5.val.obj (op o3))\n-- o1 : face ij\n-- o2 : face i\n-- o3 : face j\n-- o4 : cover i \u2293 cover j\n  (h12 : o1 \u2264 o2)\n  (h13 : o1 \u2264 o3)\n  (h42 : o4 \u2264 o2)\n  (h43 : o4 \u2264 o3)\n  (h14 : o4 \u2264 o1)\n  (eq1 : \ud835\udcd5.1.map (hom_of_le h12).op oop2 = \ud835\udcd5.1.map (hom_of_le h13).op oop3) : \n  \ud835\udcd5.1.map (hom_of_le h42).op oop2 = \ud835\udcd5.1.map (hom_of_le h43).op oop3 :=\nbegin\n  have : hom_of_le h42 = hom_of_le h14 \u226b hom_of_le h12,\n  { ext, },\n  rw this,\n  have : hom_of_le h43 = hom_of_le h14 \u226b 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 \ud835\udcd5 U 1)) : \n  presheaf.is_compatible \ud835\udcd5.1 U.cover \n  (\u03bb i, begin\n    refine \ud835\udcd5.1.map (eq_to_hom _).op (f.1 (vec_o.single i)),\n    rw \u2190 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.\u03b9 (<) _ i j with ineq|ineq|ineq,\n  { dsimp only,\n    change (\ud835\udcd5.1.map _ \u226b _) _ = (\ud835\udcd5.1.map _ \u226b _) _,\n    rw [\u2190 category_theory.functor.map_comp, \u2190 category_theory.functor.map_comp, \u2190 op_comp, \u2190 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 \ud835\udcd5 U ineq f.1),\n          \n    refine ex41.forward.aux5 \ud835\udcd5 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 \u2293 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 \u27e8hp1, hp2\u27e9,\n      rw opens.mem_coe at hp1 hp2 \u22a2,\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 (\ud835\udcd5.1.map _ \u226b _) _ = (\ud835\udcd5.1.map _ \u226b _) _,\n    rw [\u2190 category_theory.functor.map_comp, \u2190 category_theory.functor.map_comp, \u2190 op_comp, \u2190 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' \ud835\udcd5 U ineq f.1),\n\n    refine ex41.forward.aux5 \ud835\udcd5 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 \u2293 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 \u27e8hp1, hp2\u27e9,\n      rw opens.mem_coe at hp1 hp2 \u22a2,\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 \ud835\udcd5 U 1)) :\n  \u2203! (s : \ud835\udcd5.val.obj (op \u22a4)),\n  \u2200 (i : U.\u03b9),\n    (\ud835\udcd5.val.map (hom_of_le le_top).op) s =\n    (\ud835\udcd5.val.map (eq_to_hom (by rw \u2190 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  \ud835\udcd5 U.cover \u22a4 \n  (\u03bb i, hom_of_le le_top) \n  begin\n    rw U.is_cover,\n    exact le_refl _,\n  end \n  (\u03bb i, begin\n    refine \ud835\udcd5.1.map (eq_to_hom _).op (f.1 (vec_o.single i)),\n    rw \u2190 face.vec_o_single,\n    refl,\n  end) \n  (ker_compatible \ud835\udcd5 U f)\n\ndef unique_gluing (f : add_monoid_hom.ker (d_o \ud835\udcd5 U 1)) :\n  \ud835\udcd5.1.obj (op \u22a4) :=\nclassical.some (unique_gluing_prop _ _ f)\n\nlemma unique_gluing_is_glueing \n  (f : add_monoid_hom.ker (d_o \ud835\udcd5 U 1))  \n  (i : U.\u03b9) :\n  \ud835\udcd5.1.map (hom_of_le le_top).op (unique_gluing _ _ f) = \n  \ud835\udcd5.1.map (eq_to_hom (begin\n    rw \u2190 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 \u27e8h1, h2\u27e9,\n  exact h1 i,\nend\n\nlemma unique_gluing_is_unique \n  (f : add_monoid_hom.ker (d_o \ud835\udcd5 U 1))  \n  (s : \ud835\udcd5.1.obj (op \u22a4))\n  (is_glue : \u2200 (i : U.\u03b9), \n    \ud835\udcd5.1.map (hom_of_le le_top).op s = \n    \ud835\udcd5.1.map (eq_to_hom (begin\n      rw \u2190 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 \u27e8h1, h2\u27e9,\n  symmetry,\n  apply h2,\n  assumption,\nend\n\ndef ex41.forward :\n  (AddCommGroup.of $ add_monoid_hom.ker (d_o \ud835\udcd5 U 1)) \u27f6 \ud835\udcd5.1.obj (op \u22a4) :=\n{ to_fun := \u03bb f, unique_gluing _ _ f,\n  map_zero' := begin\n    apply unique_gluing_is_unique,\n    intros i,\n    simp,\n  end,\n  map_add' := \u03bb 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 \ud835\udcd5 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 \u03c3,\n  -- have eq1 : \u2203 i, \u03c3.to_finset = {i},\n  -- { have := \u03c3.card_eq,\n  --   simp only [nat.pred_succ] at this,\n  --   rwa finset.card_eq_one at this, },\n  -- rcases eq1 with \u27e8i, hi\u27e9,\n  specialize h1 (\u03c3 0),\n  \n  have h2 := unique_gluing_is_glueing _ _ g,\n  specialize h2 (\u03c3 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 : \u03c3 = vec_o.single (\u03c3 0),\n  { ext, rcases x with \u27e8x, hx\u27e9, 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 \u226b eq_to_hom h3.symm) x = (eq_to_hom h3 \u226b 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 \ud835\udcd5 U) :=\nbegin\n  rw function.surjective_iff_has_right_inverse,\n  fconstructor,\n  { intros s,\n    refine \u27e8\u03bb \u03c3, _, _\u27e9,\n    exact \ud835\udcd5.1.map (hom_of_le le_top).op s,\n    rw add_monoid_hom.mem_ker,\n    ext \u03c3,\n    rw pi.zero_apply,\n    rw d_o_small.d_o.one_apply,\n    rw sub_eq_zero,\n    dsimp only,\n    change (\ud835\udcd5.1.map _ \u226b \ud835\udcd5.1.map _) _ = (\ud835\udcd5.1.map _ \u226b \ud835\udcd5.1.map _) _,\n    rw [\u2190 \ud835\udcd5.1.map_comp,  \u2190 \ud835\udcd5.1.map_comp, \u2190 op_comp],\n    refl, },\n  { intros s,\n    apply unique_gluing_is_unique,\n    intros i,\n    dsimp only,\n    change _ = (\ud835\udcd5.1.map _ \u226b \ud835\udcd5.1.map _) _,\n    congr' 1,\n    rw \u2190 \ud835\udcd5.1.map_comp,\n    rw \u2190 op_comp,\n    congr' 1,\n  },\nend\n\ndef ex41 :\n  (AddCommGroup.of $ add_monoid_hom.ker (d_o \ud835\udcd5 U 1)) \u2243+\n  \ud835\udcd5.1.obj (op \u22a4) :=\nadd_equiv.of_bijective (ex41.forward _ _) \u27e8inj _ _, surj _ _\u27e9\n\n\ndef zeroth_Cech_Cohomology :\n  (Cech_Cohomology_Group_wrt_cover_ordered_nth \ud835\udcd5 U 0) \u2245\n  \ud835\udcd5.1.obj (op \u22a4) :=\nex1 \ud835\udcd5 U \u226a\u226b ex2 \ud835\udcd5 U \u226a\u226b ex3 \ud835\udcd5 U \u226a\u226b \n{ hom := (ex41 _ _).to_add_monoid_hom,\n  inv := (ex41 _ _).symm.to_add_monoid_hom,\n  hom_inv_id' := begin\n    ext f \u03c3,\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 \u03c3,\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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((a2).write i2 (v3)) \u2260 (a2) \u2192 ((a1).write i2 (v3)) = (a2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test25.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.46490157137338844, "lm_q1q2_score": 0.2397125090510441}}
{"text": "theorem eq_of_isEqvAux [DecidableEq \u03b1] (a b : Array \u03b1) (hsz : a.size = b.size) (i : Nat) (hi : i \u2264 a.size) (heqv : Array.isEqvAux a b hsz (fun x y => x = y) i) : \u2200 (j : Nat) (hl : i \u2264 j) (hj : j < a.size), a.get \u27e8j, hj\u27e9 = b.get \u27e8j, hsz \u25b8 hj\u27e9 := by\n  intro j low high\n  by_cases h : i < a.size\n  \u00b7 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    \u00b7 subst heq; exact heqv.1\n    \u00b7 exact hind j (Nat.succ_le_of_lt (Nat.lt_of_le_of_ne low heq)) high\n  \u00b7 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 \u2192 Nat :=\n  if h : x > 0 then\n    fun z => f (x - 1) (y + 1) z + 1\n  else\n    (\u00b7 + 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 ..src.struct_tact\n\n@[auto] inductive rel : nat \u2192 Type\n| a : rel 0\n| b : rel 1\n| c : rel 2\n\nlemma test_1 : rel 2 :=\nbegin\n    auto,\nend\n", "meta": {"author": "uwplse", "repo": "struct_tact", "sha": "22188ea2e97705d1185f75dde24e6bab88054ab0", "save_path": "github-repos/lean/uwplse-struct_tact", "path": "github-repos/lean/uwplse-struct_tact/struct_tact-22188ea2e97705d1185f75dde24e6bab88054ab0/test/auto_test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4610167793123159, "lm_q1q2_score": 0.23950804663043065}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a1).write i2 (v2)).write i1 (v2)).read i2) \u2260 (v2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test40.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.4571367168274948, "lm_q1q2_score": 0.2392746598334529}}
{"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} {\u03b9 : Type*} [category.{v} C] [abelian C] {c : complex_shape \u03b9}\n\ndef homotopy_category.quotient_map_hom (A B : homological_complex C c) :\n  (A \u27f6 B) \u2192+ ((homotopy_category.quotient C c).obj A \u27f6 (homotopy_category.quotient C c).obj B) :=\nadd_monoid_hom.mk' (\u03bb f, (homotopy_category.quotient C c).map f) $ \u03bb f g, rfl\n\nlemma quot.mk_surjective {X : Type*} (r : X \u2192 X \u2192 Prop) :\n  function.surjective (quot.mk r) :=\n\u03bb x, quot.induction_on x $ \u03bb x, \u27e8x, rfl\u27e9\n\nnoncomputable\ndef homotopy.to_single [decidable_eq \u03b9] [decidable_rel c.rel] {X : homological_complex C c} {B : C}\n  {i j : \u03b9} (r : c.rel i j)\n  (f g : X \u27f6 (homological_complex.single C c i).obj B) (h : X.X j \u27f6 B)\n  (H : f.f i = X.d i j \u226b h \u226b eq_to_hom (if_pos rfl).symm + g.f i) :\n  homotopy f g :=\n{ hom := \u03bb i\u2081 i\u2082, if r' : c.rel i\u2082 i\u2081 then if e : i\u2082 = i then\n    (X.X_eq_to_iso (c.next_eq (e \u25b8 r' : c.rel i i\u2081) r)).hom \u226b h \u226b eq_to_hom (if_pos e).symm\n    else 0 else 0,\n  zero' := \u03bb _ _ e, dif_neg e,\n  comm := \u03bb 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 [\u2190 d_next_eq_d_from_from_next, \u2190 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 \u2190 add_monoid.add_zero (X.d k j \u226b h \u226b 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 \u03b9] {X : homological_complex C c}\n  {B : C} {i j : \u03b9} (r : c.rel i j)\n  (f g : X \u27f6 (homological_complex.single C c i).obj B) :\n  homotopic _ _ f g \u2194\n    \u2203 (h : X.X j \u27f6 B), f.f i = X.d i j \u226b h \u226b eq_to_hom (if_pos rfl).symm + g.f i :=\nbegin\n  haveI : decidable_rel c.rel := \u03bb _ _, classical.dec _,\n  refine \u27e8_, \u03bb \u27e8h, H\u27e9, \u27e8homotopy.to_single r f g h H\u27e9\u27e9,\n  rintro \u27e8h\u27e9,\n  use h.hom j i \u226b eq_to_hom (if_pos rfl),\n  rw [category.assoc, eq_to_hom_trans, eq_to_hom_refl, category.comp_id, \u2190 add_zero (_ \u226b _)],\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 \u2124).rel :=\n\u03bb 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 \u2124) (B : C) (i : \u2124) :\n  (P \u27f6 (homological_complex.single C (complex_shape.up \u2124) i).obj B) \u2243+\n    (add_monoid_hom.ker ((((preadditive_yoneda.obj B).map_homological_complex\n      (complex_shape.up \u2124).symm).obj P.op).d i (i - 1))) :=\n{ to_fun := \u03bb f, begin\n    refine \u27e8f.f i \u226b eq_to_hom (if_pos rfl), _\u27e9,\n    change P.d (i - 1) i \u226b f.f i \u226b eq_to_hom _ = 0,\n    rw \u2190 f.comm_assoc,\n    dsimp,\n    rw [zero_comp, comp_zero],\n  end,\n  inv_fun := \u03bb f, begin\n    refine \u27e8\u03bb j, if e : j = i then\n      (P.X_eq_to_iso $ e).hom \u226b f.1 \u226b eq_to_hom (if_pos e).symm else 0, _\u27e9,\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, \u2190 category.assoc, \u2190 subtype.val_eq_coe,\n        show P.d (i - 1) i \u226b 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 := \u03bb f, by { ext, dsimp, simp },\n  map_add' := \u03bb 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\u2081 P\u2082 : bounded_homotopy_category C} (f : P\u2081 \u27f6 P\u2082) (B : C) :\n  hom_complex P\u2082 B \u27f6 hom_complex P\u2081 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\u2081 B\u2082 : C} (f : B\u2081 \u27f6 B\u2082) :\n  hom_complex P B\u2081 \u27f6 hom_complex P B\u2082 :=\n(nat_trans.map_homological_complex (preadditive_yoneda.map f) _).app _\n\ndef aux\u2081\n  (P : bounded_homotopy_category C) (B : C) (i : \u2124) :\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 _ _ _) \u2245\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\u2081 P\u2082 : bounded_homotopy_category C} (f : P\u2081 \u27f6 P\u2082) (B : C) (i : \u2124) :\n  homology ((hom_complex P\u2082 B).d (i + 1) i) ((hom_complex P\u2082 B).d i (i - 1))\n    ((hom_complex _ B).d_comp_d _ _ _) \u27f6\n  homology ((hom_complex P\u2081 B).d (i + 1) i) ((hom_complex P\u2081 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\u2081_naturality\n  (P\u2081 P\u2082 : bounded_homotopy_category C) (f : P\u2081 \u27f6 P\u2082) (B : C) (i : \u2124) :\n  (aux\u2081 P\u2082 B i).hom \u226b (homology_functor _ _ _).map (map_hom_complex f B) =\n  (map_homology f _ _) \u226b (aux\u2081 P\u2081 B i).hom :=\nbegin\n  dsimp only [map_homology, aux\u2081, 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.\u03c0'_desc', category.assoc, homology.\u03c0'_desc'_assoc,\n    homology.lift_\u03b9, homology.lift_\u03b9_assoc],\n  let t := _, change t \u226b _ = _,\n  have ht : t = kernel.lift _ (kernel.\u03b9 _) _ \u226b homology.\u03c0' _ _ _,\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_\u03b9_assoc, category.assoc, arrow.hom_mk_left, arrow.iso_mk_inv_left,\n    iso.refl_inv, homological_complex.hom.sq_from_left, homology.\u03c0'_desc'],\n  let t := _, change _ = _ \u226b t,\n  have ht : t = homology.\u03b9 _ _ _ \u226b cokernel.desc _ (cokernel.\u03c0 _) _,\n  rotate 2,\n  { have := (hom_complex P\u2081 B).d_to_eq (by simp : (complex_shape.up \u2124).symm.rel (i+1) i),\n    rw \u2190 iso.inv_comp_eq at this,\n    rw [\u2190 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.\u03c0_desc, homology.lift_\u03b9_assoc],\nend\n\ndef aux\u2082\n  (P : bounded_homotopy_category C) (B : C) (i : \u2124) :\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 _ _ _ _) \u2245\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\u2081 P\u2082 : bounded_homotopy_category C} (f : P\u2081 \u27f6 P\u2082) (B : C) (i : \u2124) :\n  ((hom_complex P\u2082 B).d i (i - 1)).ker \u2192+\n  ((hom_complex P\u2081 B).d i (i - 1)).ker :=\n{ to_fun := \u03bb x, \u27e8(map_hom_complex f B).f _ \u2191x, begin\n    change _ = _,\n    have : _ = _ := x.2,\n    dsimp [hom_complex, map_hom_complex] at *,\n    rw [\u2190 category.assoc, \u2190 f.out.comm, category.assoc, this, comp_zero],\n  end\u27e9,\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\u2081 P\u2082 : bounded_homotopy_category C} (f : P\u2081 \u27f6 P\u2082) (B : C) (i : \u2124) :\n  AddCommGroup.homology ((hom_complex P\u2082 B).d (i+1) i) ((hom_complex P\u2082 B).d i (i-1)) \u27f6\n  AddCommGroup.homology ((hom_complex P\u2081 B).d (i+1) i) ((hom_complex P\u2081 B).d i (i-1)) :=\nquotient_add_group.lift _\n(add_monoid_hom.comp (quotient_add_group.mk' _) $ ker_hom f _ _)\nbegin\n  rintros \u27e8x,(hx : _ = _)\u27e9 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 \u2203 e, _,\n  obtain \u27e8e,he\u27e9 := hh,\n  dsimp [hom_complex] at *,\n  use f.out.f _ \u226b e,\n  rw [\u2190 category.assoc, \u2190 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\u2082_naturality`.\nlemma map_explicit_homology_eq\n  {P\u2081 P\u2082 : bounded_homotopy_category C} (f : P\u2081 \u27f6 P\u2082) (B : C) (i : \u2124) :\n  map_explicit_homology f B i =\n  AddCommGroup.homology_map\n    ((hom_complex P\u2082 B).d_comp_d _ _ _)\n    ((hom_complex P\u2081 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 \u27e8t\u27e9,\n  symmetry, apply AddCommGroup.homology_map_apply_mk,\nend\n\nlemma aux\u2082_naturality\n  (P\u2081 P\u2082 : bounded_homotopy_category C) (f : P\u2081 \u27f6 P\u2082) (B : C) (i : \u2124) :\n  (aux\u2082 P\u2082 B i).hom \u226b map_explicit_homology f _ _ =\n  map_homology f _ _ \u226b (aux\u2082 P\u2081 B i).hom :=\nbegin\n  rw map_explicit_homology_eq,\n  dsimp [aux\u2082],\n  dsimp [AddCommGroup.homology_iso, AddCommGroup.homology_map, map_homology],\n  generalize_proofs _ _ w _ w',\n  apply (homology.has _ _ w).ext_\u03c0,\n  apply (AddCommGroup.has_homology _ _ w').ext_\u03b9,\n  rw has_homology.homology_map_eq,\n  simp only [has_homology.\u03c0_map, category.assoc, has_homology.\u03c0_map_assoc,\n    has_homology.map_\u03b9, has_homology.map_\u03b9_assoc],\n  let t := _, change t \u226b _ = _,\n  have ht : t = kernel.lift _ (kernel.\u03b9 _) _ \u226b (AddCommGroup.has_homology _ _ w).\u03c0,\n  rotate 2,\n  { apply kernel.condition },\n  { apply (AddCommGroup.has_homology _ _ w).ext_\u03b9,\n    simp [has_homology.\u03c0_\u03b9] },\n  rw ht, clear ht, clear t,\n  let t := _, change _ = _ \u226b t,\n  have ht : t = (homology.has _ _ w').\u03b9 \u226b cokernel.desc _ (cokernel.\u03c0 _) _,\n  rotate 2,\n  { apply cokernel.condition },\n  { apply (homology.has _ _ w').ext_\u03c0,\n    rw [\u2190 category.assoc, has_homology.\u03c0_\u03b9],\n    simp },\n  rw ht, clear ht, clear t,\n  simp,\nend\n\nlemma aux\u2082_naturality_inv\n  (P\u2081 P\u2082 : bounded_homotopy_category C) (f : P\u2081 \u27f6 P\u2082) (B : C) (i : \u2124) :\n  map_explicit_homology f _ _ \u226b (aux\u2082 P\u2081 B i).inv =\n  (aux\u2082 P\u2082 B i).inv \u226b  map_homology f _ _ :=\nby rw [iso.comp_inv_eq, category.assoc, iso.eq_inv_comp, aux\u2082_naturality]\n\ndef aux\u2083\n  (P : bounded_homotopy_category C) (B : C) (i : \u2124) :\n  (P \u27f6 (single C i).obj B) \u2243+\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 \u2190 (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 \u2124).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 [\u2190 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\u2083_apply\n  (P : bounded_homotopy_category C) (B : C) (i : \u2124)\n  (f : P \u27f6 (single C i).obj B) :\n  aux\u2083 P B i f = quotient_add_group.mk \u27e8f.out.f i \u226b eq_to_hom (if_pos rfl), begin\n    change _ = _, dsimp [hom_complex],\n    rw [\u2190 category.assoc, \u2190 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\u27e9 := rfl\n\nlemma aux\u2083_naturality\n  (P\u2081 P\u2082 : bounded_homotopy_category C) (f : P\u2081 \u27f6 P\u2082) (B : C) (i : \u2124) :\n  (map_explicit_homology f B i).comp (aux\u2083 P\u2082 B i).to_add_monoid_hom =\n  add_monoid_hom.comp (aux\u2083 P\u2081 B i).to_add_monoid_hom ((preadditive_yoneda.obj _).map f.op) :=\nbegin\n  ext \u27e8x\u27e9,\n  dsimp, simp_rw aux\u2083_apply,\n  dsimp [map_explicit_homology, ker_hom, map_hom_complex],\n  rw \u2190 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 [\u2190 category.assoc, \u2190 homological_complex.comp_f],\n  let t := _, let s := _,\n  change \u2203 _, _ = homological_complex.hom.f t i \u226b _ - homological_complex.hom.f s i \u226b _,\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 \u226b eq_to_hom (if_pos rfl),\n  rw [\u2190 preadditive.sub_comp _ _ (eq_to_hom _), \u2190 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' \u2243+ B) (f : X \u27f6 X') :\n  f \u226b (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 \u2192+ B) :\n  (AddCommGroup.of A) \u27f6 (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 : \u2124) :\n  AddCommGroup.of (P \u27f6 (bounded_homotopy_category.single C i).obj B) \u2245\n  (((preadditive_yoneda.obj B).map_homological_complex _).obj P.val.as.op).homology i :=\nbegin\n  refine _ \u226a\u226b aux\u2081 P B i,\n  refine add_equiv_iso_AddCommGroup_iso.hom _ \u226a\u226b (aux\u2082 P B i).symm,\n  exact aux\u2083 P B i,\nend\n\n.\n\nopen opposite\n\nvariables {X Y Z : cochain_complex C \u2124} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n\ndef of' (X : cochain_complex C \u2124)\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 \u27f6 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 \u27f6 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 \u2124)).obj P.val.as).is_bounded_above :=\nby { rcases P with \u27e8P, \u27e8a, ha\u27e9\u27e9, use a, intros i hi, exact ha i hi }\n\nlemma hom_single_iso_naturality\n  (P\u2081 P\u2082 : bounded_homotopy_category C) (B : C) (i : \u2124)\n  (f : P\u2081 \u27f6 P\u2082) :\n  (preadditive_yoneda.obj _).map f.op \u226b (hom_single_iso P\u2081 B i).hom =\n  (hom_single_iso P\u2082 B i).hom \u226b\n  (((preadditive_yoneda.obj B).right_op.map_homological_complex _ \u22d9\n      homological_complex.unop_functor.right_op \u22d9\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 [\u2190 category.assoc, comp_add_equiv_iso_AddcommGroup_iso_eq_comp],\n  rw \u2190 aux\u2083_naturality,\n  rw [category.assoc],\n\n  let t := hom_mk (aux\u2083 P\u2082 B i).to_add_monoid_hom,\n  change (t \u226b (map_explicit_homology f B i)) \u226b _ \u226b _ = _,\n  slice_lhs 2 3\n  { rw aux\u2082_naturality_inv },\n  simp_rw category.assoc,\n  rw \u2190 aux\u2081_naturality,\n  refl,\nend\n\nlemma hom_single_iso_naturality'\n  (P\u2081 P\u2082 : bounded_homotopy_category C) (B : C) (i : \u2124)\n  (f : P\u2081.val.as \u27f6 P\u2082.val.as) :\n  (preadditive_yoneda.obj ((single C i).obj B)).map (of_hom f).op \u226b (hom_single_iso P\u2081 B i).hom =\n  (hom_single_iso P\u2082 B i).hom \u226b\n  (((preadditive_yoneda.obj B).right_op.map_homological_complex _ \u22d9\n      homological_complex.unop_functor.right_op \u22d9\n      (_root_.homology_functor _ _ _).op).map f).unop :=\nbegin\n  erw hom_single_iso_naturality P\u2081 P\u2082 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 \u27e8\u03bb i j, (h.hom j i).unop, _, _\u27e9,\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\u2081 B\u2082 : C} (i : \u2124) (f : B\u2081 \u27f6 B\u2082) (w\u2081 w\u2082) :\n  homology ((hom_complex P B\u2081).d (i + 1) i) ((hom_complex P B\u2081).d i (i - 1)) w\u2081 \u27f6\n  homology ((hom_complex P B\u2082).d (i + 1) i) ((hom_complex P B\u2082).d i (i - 1)) w\u2082 :=\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 {\u03b1 \u03b1' \u03b2 : Type}\nparameters abs : \u03b1' \u2192 \u03b1\n\nstructure evt_ref (lbl : Type) (mc : program \u03b1') (ea : event \u03b1) (ecs : lbl \u2192 event \u03b1') : Type :=\n  (witness : lbl \u2192 \u03b1' \u2192 Prop)\n  (witness_fis : \u2983 \u2203\u2203 e, witness e \u2984)\n  (sim : \u2200 ec, \u27e6 (ecs ec).step_of \u27e7 \u27f9 \u27e6 ea.step_of on abs \u27e7)\n  (delay : \u2200 ec, witness ec \u22c0 (ea.coarse_sch \u22c0 ea.fine_sch) \u2218 abs \u21a6 witness ec \u22c0 (ecs ec).coarse_sch in mc)\n  (stable : \u2200 ec, unless_except mc (witness ec \u22c0 (ecs ec).coarse_sch) (-(ea.coarse_sch \u2218 abs))\n                                   { e | \u2203 l, ecs l = e })\n  (resched : \u2200 ec, (ea.coarse_sch \u22c0 ea.fine_sch) \u2218 abs \u22c0 witness ec \u21a6 (ecs ec).fine_sch in mc)\n\nstructure evt_ref_wk (lbl : Type) (mc : program \u03b1') (ea : event \u03b1) (ecs : lbl \u2192 event \u03b1')\n: Type :=\n  (witness : lbl \u2192 \u03b1' \u2192 Prop)\n  (sim : \u2200 ec, \u27e6 (ecs ec).step_of \u27e7 \u27f9 \u27e6 ea.step_of on abs \u27e7)\n  (delay : (ea.coarse_sch \u22c0 ea.fine_sch) \u2218 abs\n            >~>\n           -(ea.coarse_sch \u2218 abs)\n            \u22c1 \u2203\u2203 ec, witness ec \u22c0 (ecs ec).coarse_sch in mc)\n  (stable : \u2200 ec, unless_except mc (witness ec \u22c0 (ecs ec).coarse_sch) (-(ea.coarse_sch \u2218 abs))\n                                   { e | \u2203 l, ecs l = e })\n  (resched : \u2200 ec, (ea.coarse_sch \u22c0 ea.fine_sch) \u2218 abs \u22c0 witness ec \u22c0 (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 \u03b1')\n  (ea : event \u03b1)\n  (ecs : lbl \u2192 event \u03b1')\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 : \u2200 ec, H.witness ec \u22c0 (ea.coarse_sch \u22c0 ea.fine_sch) \u2218 abs\n               \u21a6\n              -(ea.coarse_sch \u2218 abs)\n              \u22c1 H.witness ec \u22c0 (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\u2080 : (\u2203\u2203 (ec : lbl), H.witness ec \u22c0 (ea.coarse_sch \u2218 abs \u22c0 ea.fine_sch \u2218 abs))\n            = (ea.coarse_sch \u22c0 ea.fine_sch) \u2218 abs,\n    { rw [\u2190 p_and_over_p_exists_right,ew_eq_true H.witness_fis],\n      simp },\n    simp [H\u2080] 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\u2080 := H.resched ce,\n    apply often_imp_often.basis,\n    revert P\u2080,\n    apply leads_to.antimono_left,\n    apply p_and_elim_left }\nend\n\nparameters (ma : program \u03b1) (mc : program \u03b1')\n\nstructure refined : Type :=\n  (sim_init : mc^.first \u27f9 ma^.first\u2218abs)\n  (ref : option mc.lbl \u2192 option ma.lbl \u2192 Prop)\n  (evt_sim : \u2200 ec, \u27e6 mc.step_of ec \u27e7\n               \u27f9 \u2203\u2203 ea : { ea // ref ec ea }, \u27e6 ma.step_of ea.val on abs \u27e7)\n  (events : \u2200 ae, evt_ref_wk { ec // ref ec ae } mc (ma.event ae) (\u03bb ec, mc.event ec.val) )\n\nparameters {ma mc}\n\nlemma refined.sim\n  (R : refined)\n: \u27e6 is_step mc \u27e7 \u27f9 \u27e6 is_step ma on abs \u27e7 :=\nbegin\n  simp [is_step_exists_event'],\n  intro \u03c4,\n  simp,\n  intros ce H,\n  apply exists_imp_exists' subtype.val _ (R.evt_sim ce \u03c4 H),\n  intro, apply id,\nend\n\nend defs\n\nsection soundness\n\nparameters {\u03b1 \u03b1' \u03b2 : Type}\nparameters {abs : \u03b1' \u2192 \u03b1}\nparameter {ma : program \u03b1}\nparameter {mc : program \u03b1'}\n\nopen temporal\n\nparameter R : refined abs ma mc\nparameter {\u03c4 : stream \u03b1'}\nparameter M\u2081 : system_sem.ex mc \u03c4\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 \u2218 abs\ndef AF := (program.event ma e).fine_sch \u2218 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 : (\u25c7\u25fb(\u2022AC \u22c0 -\u27e6 ma.step_of e on abs \u27e7)) \u03c4\n\nparameter abs_fine : (\u25fb\u25c7\u2022AF) \u03c4\n\ninclude M\u2081\ninclude abs_coarse\ninclude abs_fine\n\nlemma abs_coarse_and_fine\n: (\u25fb\u25c7(\u2022AC \u22c0 \u2022AF)) \u03c4 :=\nbegin\n  apply coincidence,\n  { apply stable_entails_stable _ _ abs_coarse,\n    apply \u03bb _, and.left },\n  { apply abs_fine },\nend\n\ninclude R\n\nlemma evt_ref_wk.delay_sem\n: \u25fb\u25c7(\u2203\u2203 ce, \u2022W ce \u22c0 \u2022CC ce.val) $ \u03c4 :=\nbegin\n  have Hdelay := (R.events e).delay,\n  have H := system_sem.often_imp_often_sem' _ M\u2081 Hdelay\n                (abs_coarse_and_fine M\u2081 e abs_coarse abs_fine),\n  clear Hdelay,\n  rw [init_p_or,inf_often_p_or,\u2190 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 (\u03bb _, and.left) \u03c4 abs_coarse,\n  apply H Hc,\nend\n-- lemma conc_coarse : \u2203 e', (\u25c7\u25fb(\u2022 W e' \u22c0 \u2022 CC e'.val) ) \u03c4 :=\n\nlemma conc_event : \u2203 e' : imp_lbl, (\u25c7\u25fb\u2022 CC e'.val \u22c0 \u25fb\u25c7\u2022CF e'.val ) \u03c4 :=\nbegin\n  have H : ((\u2203\u2203 e', \u25c7\u25fb(\u2022 W R e e' \u22c0 \u2022 CC e'.val))\n                   \u22c1 \u25fb\u25c7((-\u2022AC  e) \u22c1 \u2203\u2203 e' : imp_lbl R e, \u27e6 mc.step_of e'.val \u27e7)) \u03c4,\n  { rw exists_action,\n    apply p_or_p_imp_p_or_right _ (unless_sem_exists' M\u2081.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 \u03c3 \u03c3',\n      simp [mem_set_of,imp_lbl],\n      intros ec H x H' H\u2082,\n      existsi x,\n      cases H with H\u2080 H,\n      cases H with H\u2081 STEP,\n      unfold program.step_of,\n      simp [H',event.step_of,STEP,H\u2080,H\u2081,H\u2082], },\n    have H' := (R.events e).delay,\n    have H'' := system_sem.often_imp_often_sem' _ M\u2081 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\u2081 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\u2081 ((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 : ((\u2022(program.event ma e).coarse_sch \u2218 abs) i)  = X\u2080,\n    generalize : ((\u2022(program.event ma e).fine_sch \u2218 abs) i)    = X\u2081,\n    generalize : ((\u2022(program.event mc (ce.val)).coarse_sch) i) = X\u2082,\n    generalize : ((\u2022(R.events e).witness ce) i) = X\u2083,\n    begin [smt] by_cases X\u2080 end, },\n  { exfalso,\n    revert abs_coarse,\n    change \u00ac _,\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\u2081\ninclude R\n\ntheorem soundness : system_sem.ex ma (map abs \u03c4) :=\nbegin\n  apply nondet.program.ex.mk,\n  { apply R.sim_init,\n    apply M\u2081.init },\n  { intro i,\n    rw [drop_map],\n    rw [comp_map_app_eq_map \u27e6 step ma \u27e7, \u2190 action_trading ],\n    apply R.sim abs,\n    apply M\u2081.safety },\n  { intros e COARSE\u2080 FINE\u2080,\n    apply assume_neg _, intro ACT,\n    have COARSE\u2081 :  (\u25c7\u25fb(\u2022AC e \u22c0 -\u27e6program.step_of ma e on abs\u27e7)) \u03c4,\n    { rw [\u2190 inf_often_trace_action_trading] at ACT,\n      rw [\u2190 stable_trace_init_trading] at COARSE\u2080,\n      rw [p_not_eq_not,not_henceforth,not_eventually] at ACT,\n      apply stable_and_of_stable_of_stable COARSE\u2080 ACT },\n    clear COARSE\u2080 ACT,\n    cases conc_event R M\u2081 _ COARSE\u2081 FINE\u2080 with e' C_EVT,\n    cases C_EVT with C_COARSE C_FINE,\n    rw [\u2190 inf_often_trace_trading,\u2190 action_trading],\n    apply inf_often_entails_inf_often _ _ (M\u2081.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 \u2192 F\nvariable  \u03c3 : 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 \u03c3.pc\n    (h_mem : mem_at mem code_assert_le \u03c3.pc)\n    -- all dependencies are in memory\n    (h_mem_0 : mem_at mem code_assert_nn (\u03c3.pc  - 4))\n    -- input arguments on the stack\n    (hin_range_check_ptr : range_check_ptr = mem (\u03c3.fp - 5))\n    (hin_a : a = mem (\u03c3.fp - 4))\n    (hin_b : b = mem (\u03c3.fp - 3))\n    -- conclusion\n  : ensures_ret mem \u03c3 (\u03bb \u03ba \u03c4,\n      \u03c4.ap = \u03c3.ap + 5 \u2227\n      \u2203 \u03bc \u2264 \u03ba, rc_ensures mem (rc_bound F) \u03bc (mem (\u03c3.fp - 5)) (mem $ \u03c4.ap - 1)\n        (spec_assert_le mem \u03ba range_check_ptr a b (mem (\u03c4.ap - 1)))) :=\nbegin\n  apply ensures_of_ensuresb, intro \u03bdbound,\n  have h_mem_rec := h_mem,\n  unpack_memory code_assert_le at h_mem with \u27e8hpc0, hpc1, hpc2, hpc3, hpc4\u27e9,\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 \u03ba_call4 ap4 h_call4,\n  rcases h_call4 with \u27e8h_call4_ap_offset, h_call4\u27e9,\n  rcases h_call4 with \u27e8rc_m4, rc_mle4, hl_range_check_ptr\u2081, h_call4\u27e9,\n  generalize' hr_rev_range_check_ptr\u2081: mem (ap4 - 1) = range_check_ptr\u2081,\n  have htv_range_check_ptr\u2081 := hr_rev_range_check_ptr\u2081.symm, clear hr_rev_range_check_ptr\u2081,\n  try { simp only [arg0 ,arg1] at hl_range_check_ptr\u2081 },\n  rw [\u2190htv_range_check_ptr\u2081, \u2190hin_range_check_ptr] at hl_range_check_ptr\u2081,\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 [\u2190htv_range_check_ptr\u2081, hl_range_check_ptr\u2081, 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 [\u03ba_call4],\n  use_only [range_check_ptr\u2081],\n  have rc_h_range_check_ptr\u2081 := range_checked_offset' rc_h_range_check_ptr,\n  have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n  have spec4 := h_call4 rc_h_range_check_ptr',\n  rw [\u2190hin_range_check_ptr, \u2190htv_range_check_ptr\u2081] 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\u2081] }, },\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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i1 (v2)).write i3 (v2)).read i1) \u2260 (v2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test46.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.4532618480153861, "lm_q1q2_score": 0.23901246187607114}}
{"text": "import AutograderTests.Util\n\nin_exercise\n\n  theorem exercise : \u2200 m n : Nat, m + n = n + m :=\n    sorry\n\nin_solution\n\n  theorem exercise : True :=\n    \u27e8\u27e9\n", "meta": {"author": "gebner", "repo": "autograder", "sha": "9d23bfc346c672e93d0b4ee11453925ed15cd091", "save_path": "github-repos/lean/gebner-autograder", "path": "github-repos/lean/gebner-autograder/autograder-9d23bfc346c672e93d0b4ee11453925ed15cd091/AutograderTests/TodoFail/ChangedExercise.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.320821300824607, "lm_q1q2_score": 0.23842412725428894}}
{"text": "import DijkstraMonad.Basic\nopen EffectObservation\nopen OrderedMonad\n\nuniverse u v w\n#print ExceptT\n\ninstance\n  {\u03b5 : Type u}\n  {W:Type u \u2192 Type v}\n  [Monad W] [OrderedMonad W]\n  : OrderedMonad (ExceptT \u03b5 W) where\n\n  leW := by\n    simp [ExceptT]\n    intro \u03b1 e1 e2\n    apply leW e1 e2\n\n  trans := by\n    intro \u03b1 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 \u03b1 a\n    simp [ExceptT] at a\n    apply refl a\n\n  bindW := by\n    intro \u03b1 \u03b2 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 \u03b8\n#check bind\u03b8\n\ntheorem fun_apply_same_args {\u03b1:Type u} {\u03b2:Type v} : (f:\u03b1\u2192\u03b2) \u2192 (x y:\u03b1) \u2192 x = y \u2192 f x = f y := by\n  intro f x y h\n  induction h\n  rfl\n\ninstance\n  {\u03b5:Type u}\n  {M:Type u \u2192 Type v}\n  {W:Type u \u2192 Type w}\n  [Monad M] [Monad W]\n  [OrderedMonad W]\n  [EffectObservation M W]\n  : EffectObservation (ExceptT \u03b5 M) (ExceptT \u03b5 W) where\n\n  \u03b8 {\u03b1:Type u} (x:ExceptT \u03b5 M \u03b1) : ExceptT \u03b5 W \u03b1 :=\n    @\u03b8 M _ _ _ _ _ (Except \u03b5 \u03b1) x\n\n  bind\u03b8 := by\n    intro \u03b1 \u03b2 m f\n    simp [ExceptT] at m f\n    simp [bind, ExceptT.bind, ExceptT.bindCont, ExceptT.mk]\n    simp [bind\u03b8]\n    apply fun_apply_same_args\n    simp [Function.comp]\n    apply funext\n    intro x\n    cases x\n    . simp [pure\u03b8]\n    . simp\n\n  pure\u03b8 := by\n    intro \u03b1 x\n    simp\n    apply pure\u03b8\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": "\nimport test.slim_check.arbitrary\n\nuniverses u v\n\nvariable \u03b1 : Type u\nvariable \u03b2 : \u03b1 \u2192 Prop\nvariable f : Type \u2192 Prop\n\nnamespace slim_check\n\ninductive test_result (p : Prop)\n| success : (psum unit p) \u2192 test_result\n| gave_up {} : \u2115 \u2192 test_result\n| failure : \u00ac p \u2192 (list string) \u2192 test_result\n\nclass testable (p : Prop) :=\n  (run : gen (test_result p))\n\nopen list\n\nopen test_result\n\ndef combine {p q : Prop} : psum unit (p \u2192 q) \u2192 psum unit p \u2192 psum unit q\n | (psum.inr f) (psum.inr x) := psum.inr (f x)\n | _ _ := psum.inl ()\n\ndef convert_counter_example {p q : Prop}\n  (h : q \u2192 p)\n: test_result p \u2192\n  opt_param (psum unit (p \u2192 q)) (psum.inl ()) \u2192\n  test_result q\n | (failure Hce xs) _ := failure (mt h Hce) xs\n | (success Hp) Hpq := success (combine Hpq Hp)\n | (gave_up n) _ := gave_up n\n\ndef add_to_counter_example (x : string) {p q : Prop}\n  (h : q \u2192 p)\n: test_result p \u2192\n  opt_param (psum unit (p \u2192 q)) (psum.inl ()) \u2192\n  test_result q\n | (failure Hce xs) _ := failure (mt h Hce) $ x :: xs\n | r hpq := convert_counter_example h r hpq\n\ndef add_var_to_counter_example {\u03b3 : Type v} [has_to_string \u03b3]\n  (var : string) (x : \u03b3) {p q : Prop}\n  (h : q \u2192 p)\n: test_result p \u2192\n  opt_param (psum unit (p \u2192 q)) (psum.inl ()) \u2192\n  test_result q :=\n@add_to_counter_example (var ++ \" := \" ++ to_string x) _ _ h\n\ninstance imp_dec_testable (p : Prop) [decidable p] (\u03b2 : p \u2192 Prop)\n  [\u2200 h, testable (\u03b2 h)]\n: testable (\u03a0 h, \u03b2 h) :=\n\u27e8 do\n    if h : p\n    then (\u03bb r, convert_counter_example ($ h) r (psum.inr $ \u03bb q _, q)) <$> testable.run (\u03b2 h)\n    else return $ gave_up 1 \u27e9\n\ninstance all_types_testable [testable (f \u2124)]\n: testable (\u03a0 x, f x) :=\n\u27e8 do\n    r \u2190 testable.run (f \u2124),\n    return $ add_to_counter_example \"\u2124\" ($ \u2124) r \u27e9\n\ndef test_one (x : \u03b1) [testable (\u03b2 x)] (var : option (string \u00d7 string) := none)\n: testable (\u03a0 x, \u03b2 x) :=\n\u27e8 do\n    r \u2190 testable.run (\u03b2 x),\n    return $ match var with\n     | none := convert_counter_example ($ x) r\n     | (some (v,x_str)) := add_var_to_counter_example v x_str ($ x) r\n    end \u27e9\n\ndef test_forall_in_list (var : string) [\u2200 x, testable (\u03b2 x)] [has_to_string \u03b1]\n: \u03a0 xs : list \u03b1, testable (\u2200 x, x \u2208 xs \u2192 \u03b2 x)\n | [] := \u27e8 return $ success $ psum.inr (by { introv h, cases h} ) \u27e9\n | (x :: xs) :=\n\u27e8 do\n    r \u2190 testable.run (\u03b2 x),\n    match r with\n     | failure _ _ := return $ add_var_to_counter_example var x\n                               (by { intro h, apply h, left, refl }) r\n     | success hp := do\n       rs \u2190 (test_forall_in_list xs).run,\n       return $ convert_counter_example\n                               (by { intros h i h',\n                                     apply h,\n                                     right, apply h' })\n                               rs\n                               (combine (psum.inr\n                                $ by { intros j h, simp only [ball_cons],\n                                       split ; assumption, } ) hp)\n     | gave_up n := do\n       rs \u2190 (test_forall_in_list xs).run,\n       match rs with\n        | (success _) := return $ gave_up n\n        | (failure Hce xs) := return $ failure\n                    (by { simp only [ball_cons],\n                          apply not_and_of_not_right _ Hce, }) xs\n        | (gave_up n') := return $ gave_up (n + n')\n       end\n    end \u27e9\n\ndef combine_testable (p : Prop)\n  (t : list $ testable p) (h : 0 < t.length)\n: testable p :=\n\u27e8 have 0 < length (map (@testable.run p) t),\n    by { rw [length_map], apply h },\n  one_of (list.map (@testable.run _) t) this \u27e9\n\ndef var_testable [has_to_string \u03b1] [arbitrary \u03b1] [\u2200 x, testable (\u03b2 x)]\n  (var : option string := none)\n: testable (\u03a0 x : \u03b1, \u03b2 x) :=\n\u27e8 liftable.down' $ do\n  x \u2190 arby \u03b1,\n  liftable.up' (do\n    r \u2190 testable.run (\u03b2 x),\n    return $ match var with\n     | none := add_to_counter_example (to_string x) ($ x) r\n     | (some v) := add_var_to_counter_example v x ($ x) r\n    end) \u27e9\n\ninstance pi_testable [has_to_string \u03b1] [arbitrary \u03b1] [\u2200 x, testable (\u03b2 x)]\n: testable (\u03a0 x : \u03b1, \u03b2 x) :=\nvar_testable \u03b1 \u03b2\n\ninstance de_testable {p : Prop} [decidable p] : testable p :=\n\u27e8 return $ if h : p then success (psum.inr h) else failure h [] \u27e9\n\nsection io\n\nvariable (p : Prop)\nvariable [testable p]\n\nopen nat\n\nvariable {p}\n\ndef retry (cmd : rand (test_result p)) : \u2115 \u2192 rand (test_result p)\n | 0 := return $ gave_up 1\n | (succ n) := do\nr \u2190 cmd,\nmatch r with\n | success hp := return $ success hp\n | (failure Hce xs) := return (failure Hce xs)\n | (gave_up _) := retry n\nend\n\ndef give_up_once (x : \u2115) : test_result p \u2192 test_result p\n | (success (psum.inl ())) := gave_up x\n | (success (psum.inr p))  := success (psum.inr p)\n | (gave_up n) := gave_up (n+x)\n | (failure Hce xs) := failure Hce xs\n\nvariable (p)\n\ndef testable.run_suite_aux : test_result p \u2192 \u2115 \u2192 rand (test_result p)\n | r 0 := return r\n | r (succ n) :=\ndo x \u2190 retry ( (testable.run p).run \u27e8 99 - n \u27e9) 10,\n   match x with\n    | (success (psum.inl ())) := testable.run_suite_aux r n\n    | (success (psum.inr Hp)) := return $ success (psum.inr Hp)\n    | (failure Hce xs) := return (failure Hce xs)\n    | (gave_up g) := testable.run_suite_aux (give_up_once g r) n\n   end\n\ndef testable.run_suite (bound : \u2115 := 100) :=\ntestable.run_suite_aux p (success $ psum.inl ()) bound\n\ndef testable.check (bound : \u2115 := 100) : io (test_result p) :=\nio.run_rand (testable.run_suite p bound)\n\ndef testable.check' (bound : \u2115 := 100) : io bool := do\nx \u2190 io.run_rand (testable.run_suite p bound),\nmatch x with\n | (success _) := return tt\n | (gave_up n) := io.put_str_ln (\"Gave up \" ++ repr n ++ \" times\") >> return ff\n | (failure _ xs) := do\n   io.put_str_ln \"\\n===================\",\n   io.put_str_ln \"Found problems!\",\n   io.put_str_ln \"\",\n   list.mmap' io.put_str_ln xs,\n   io.put_str_ln \"-------------------\",\n   return ff\nend\n\nend io\n\nend slim_check\n", "meta": {"author": "cipher1024", "repo": "slim_check", "sha": "5969b7f72e01fdd46f2502ed0cbf69c0699061d4", "save_path": "github-repos/lean/cipher1024-slim_check", "path": "github-repos/lean/cipher1024-slim_check/slim_check-5969b7f72e01fdd46f2502ed0cbf69c0699061d4/src/test/slim_check/testable.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.538983220687684, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.2380543390839296}}
{"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 {\u03b1 : Type w} [partial_order \u03b1] {a b : \u03b1}\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 : \u03b1) (h : a \u2264 b) : is_bot a :=\n\u03bb 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) \u2227\n  \u2200 (c : \u03b1) (hc\u2081 : a \u2264 c) (hc\u2082 : c < b), c = a\n\ndef order.is_succ : Prop :=\n  \u2203 (a : \u03b1), order.are_succ a b\n\ndef order.is_limit : Prop :=\n  (\u00acis_bot a) \u2227 (\u00acorder.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 \u2264 b := h.1.le\n\ndef order.are_succ.hom (h : order.are_succ a b) :\n  a \u27f6 b := hom_of_le h.1.le\n\nlemma order.are_succ.of_le_iff {m : \u03b1} (a b : { x : \u03b1 // x \u2264 m}) :\n  order.are_succ a b \u2194 order.are_succ a.1 b.1 :=\nbegin\n  split,\n  { intro h,\n    exact \u27e8h.1, \u03bb c hc\u2081 hc\u2082, subtype.ext_iff.1 (h.2 \u27e8c, hc\u2082.le.trans b.2\u27e9 hc\u2081 hc\u2082)\u27e9, },\n  { intro h,\n    exact \u27e8h.1, \u03bb c hc\u2081 hc\u2082, by { ext, exact h.2 c.1 hc\u2081 hc\u2082}\u27e9, },\nend\n\nlemma order.is_succ.of_le_iff {m : \u03b1} (b : { x : \u03b1 // x \u2264 m}) :\n  order.is_succ b \u2194 order.is_succ b.1 :=\nbegin\n  split,\n  { rintro \u27e8a, ha\u27e9,\n    rw order.are_succ.of_le_iff at ha,\n    exact \u27e8_, ha\u27e9, },\n  { rintro \u27e8a, ha\u27e9,\n    let a' : { x // x \u2264 m} := \u27e8a, ha.1.le.trans b.2\u27e9,\n    exact \u27e8_, (order.are_succ.of_le_iff a' b).2 ha\u27e9, },\nend\n\n@[simps, nolint unused_arguments]\ndef order.lt_inclusion_functor (m : \u03b1) :\n  { a : \u03b1 // a < m } \u2964 \u03b1 :=\nmonotone.functor (subtype.mono_coe _)\n\n@[simps]\ndef order.lt_cocone (m : \u03b1) {C : Type*} [category C] (F : \u03b1 \u2964 C) :\n  cocone (order.lt_inclusion_functor m \u22d9 F) :=\n{ X := F.obj m,\n  \u03b9 :=\n  { app := \u03bb a, F.map (hom_of_le a.2.le),\n    naturality' := \u03bb a b f, begin\n      dsimp,\n      simp only [comp_id, \u2190 F.map_comp],\n      congr,\n    end, }, }\n\n@[simps]\ndef order.le_inclusion_functor_of_le (m\u2081 m\u2082 : \u03b1) (h : m\u2081 \u2264 m\u2082) :\n  { a : \u03b1 // a \u2264 m\u2081 } \u2964 { a : \u03b1 // a \u2264 m\u2082 } :=\nbegin\n  let \u03c6 : { a : \u03b1 // a \u2264 m\u2081 } \u2192 { a : \u03b1 // a \u2264 m\u2082 } := \u03bb a, \u27e8a.1, a.2.trans h\u27e9,\n  have h\u03c6 : monotone \u03c6 := \u03bb a b hab, hab,\n  exact monotone.functor h\u03c6,\nend\n\n@[simps]\ndef order.order_iso_lt_le (m\u2081 m\u2082 : \u03b1) (h : m\u2081 \u2264 m\u2082) (b : { x // x \u2264 m\u2081}) :\n  order_iso { y : { x // x \u2264 m\u2081 } // y < b } { y : { x // x \u2264 m\u2082 } // y < \u27e8b.1, b.2.trans h\u27e9 } :=\n{ to_fun := \u03bb y, \u27e8\u27e8y.1.1, y.1.2.trans h\u27e9, y.2\u27e9,\n  inv_fun := \u03bb y, \u27e8\u27e8y.1, (show y.1.1 \u2264 b.1, by exact y.2.le).trans (b.2 : b.1 \u2264 m\u2081)\u27e9, y.2\u27e9,\n  left_inv := \u03bb y, by { ext, refl, },\n  right_inv := \u03bb y, by { ext, refl, },\n  map_rel_iff' := \u03bb x y, \u27e8\u03bb h, h, \u03bb h, h\u27e9, }\n\n@[simps]\ndef order_iso.to_equivalence {\u03b1 : Type u } {\u03b2 : Type v} [preorder \u03b1] [preorder \u03b2]\n  (e : order_iso \u03b1 \u03b2) : \u03b1 \u224c \u03b2 :=\n{ functor := monotone.functor e.monotone,\n  inverse := monotone.functor e.symm.monotone,\n  unit_iso := eq_to_iso (category_theory.functor.ext (\u03bb a, (e.left_inv a).symm)\n    (\u03bb a\u2081 a\u2082 f, subsingleton.elim _ _)),\n  counit_iso := eq_to_iso (category_theory.functor.ext (\u03bb b, (e.right_inv b))\n    (\u03bb b\u2081 b\u2082 f, subsingleton.elim _ _)),\n  functor_unit_iso_comp' := \u03bb X, subsingleton.elim _ _, }\n\n@[simps]\ndef order.lt_inclusion_functor_iso_of_le (m\u2081 m\u2082 : \u03b1) (h : m\u2081 \u2264 m\u2082) (b : { x // x \u2264 m\u2081}) :\n  order.lt_inclusion_functor b \u22d9 order.le_inclusion_functor_of_le m\u2081 m\u2082 h \u2245\n    (order.order_iso_lt_le m\u2081 m\u2082 h b).to_equivalence.functor \u22d9\n      order.lt_inclusion_functor (\u27e8b, b.2.trans h\u27e9 : { x // x \u2264 m\u2082 }) := iso.refl _\n\n@[simps]\ndef order.lt_inclusion_functor_iso_of_le' (m\u2081 m\u2082 : \u03b1) (h : m\u2081 \u2264 m\u2082) (b : { x // x \u2264 m\u2081}) :\n  (order.order_iso_lt_le m\u2081 m\u2082 h b).to_equivalence.inverse \u22d9\n    order.lt_inclusion_functor b \u22d9 order.le_inclusion_functor_of_le m\u2081 m\u2082 h \u2245\n      order.lt_inclusion_functor (\u27e8b, b.2.trans h\u27e9 : { x // x \u2264 m\u2082 }) :=\niso_whisker_left (order.order_iso_lt_le m\u2081 m\u2082 h b).to_equivalence.inverse\n  (order.lt_inclusion_functor_iso_of_le m\u2081 m\u2082 h b) \u226a\u226b (functor.associator _ _ _).symm \u226a\u226b\n  iso_whisker_right (order.order_iso_lt_le m\u2081 m\u2082 h b).to_equivalence.counit_iso _ \u226a\u226b\n  functor.left_unitor _\n\nlemma is_bot.subsingleton_le {m : \u03b1} (hm : is_bot m) :\n  subsingleton {a // a \u2264 m} :=\n\u27e8\u03bb x\u2081 x\u2082, begin\n  have eq : \u2200 (x : {x // x \u2264 m}), x = \u27e8m, hm m\u27e9 := \u03bb x, le_antisymm x.2 (hm _),\n  rw [eq x\u2081, eq x\u2082],\nend\u27e9\n\nend\n\nsection\n\nvariables {\u03b1 : Type*} [linear_order \u03b1]\n\n@[simp]\nlemma is_bot.of_le_iff {m : \u03b1} (a : { x : \u03b1 // x \u2264 m}) :\n  is_bot a \u2194 is_bot a.1 :=\nbegin\n  split,\n  { intros h b,\n    by_cases hb : b \u2264 m,\n    { exact h \u27e8b, hb\u27e9, },\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 : \u03b1} (a : { x : \u03b1 // x \u2264 m}) :\n  order.is_limit a \u2194 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 : \u03b1} (h : order.are_succ a b) (c : \u03b1) : c < b \u2194 c \u2264 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 : \u03b1} (h\u2081 : order.are_succ a b) (h\u2082 : order.are_succ a' b) :\n  a = a' :=\nle_antisymm (by simpa only [\u2190 h\u2082.lt_iff_le] using h\u2081.lt)\n  (by simpa only [\u2190 h\u2081.lt_iff_le] using h\u2082.lt)\n\nsection\n\nvariables {C : Type*} [category C] {m : \u03b1} (hm : is_top m)\n  (F G : \u03b1 \u2964 C) (\u03c6 : order.lt_inclusion_functor m \u22d9 F \u27f6 order.lt_inclusion_functor m \u22d9 G)\n  (\u03c6m : F.obj m \u27f6 G.obj m)\n  (comm : \u2200 (a : { x // x < m }), F.map (hom_of_le (hm a.1)) \u226b \u03c6m =\n    \u03c6.app a \u226b G.map (hom_of_le (hm a.1)))\n\ninclude comm\n\ndef is_top.mk_nat_trans : F \u27f6 G :=\n{ app := \u03bb a, begin\n    by_cases a < m,\n    { exact \u03c6.app \u27e8a, h\u27e9, },\n    { refine eq_to_hom _ \u226b \u03c6m \u226b eq_to_hom _,\n      all_goals\n      { rw le_antisymm (hm _) (not_lt.1 h), }, },\n  end,\n  naturality' := \u03bb a\u2081 a\u2082 \u03c8, begin\n    by_cases h\u2082 : a\u2082 < m,\n    { have h\u2081 := lt_of_le_of_lt (le_of_hom \u03c8) h\u2082,\n      rw [dif_pos h\u2081, dif_pos h\u2082],\n      let b\u2081 : { x // x < m} := \u27e8a\u2081, h\u2081\u27e9,\n      let b\u2082 : { x // x < m} := \u27e8a\u2082, h\u2082\u27e9,\n      have \u03c8' : b\u2081 \u2264 b\u2082 := le_of_hom \u03c8,\n      convert \u03c6.naturality (hom_of_le \u03c8'), },\n    { have h\u2082' := le_antisymm (not_lt.1 h\u2082) (hm a\u2082),\n      subst h\u2082',\n      rw dif_neg (lt_irrefl m),\n      by_cases h\u2081 : a\u2081 < m,\n      { simp only [dif_pos h\u2081, eq_to_hom_refl, id_comp, comp_id],\n        convert comm \u27e8a\u2081 ,h\u2081\u27e9, },\n      { have h\u2081' := le_antisymm (not_lt.1 h\u2081) (hm a\u2081),\n        subst h\u2081',\n        simp only [dif_neg (lt_irrefl m), subsingleton.elim \u03c8 (\ud835\udfd9 _),\n          category_theory.functor.map_id, comp_id, id_comp], }, },\n  end, }\n\nlemma is_top.mk_nat_trans_eq (a : \u03b1) (ha : a < m) :\n  (is_top.mk_nat_trans hm F G \u03c6 \u03c6m comm).app a = \u03c6.app \u27e8a, ha\u27e9 :=\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 \u03c6 \u03c6m comm).app m = \u03c6m :=\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\u2081 m\u2082 : \u03b1} (hm\u2081\u2082 : order.are_succ m\u2081 m\u2082)\n  (hm\u2082 : is_top m\u2082)\n  (F G : \u03b1 \u2964 C) (\u03c6 : order.lt_inclusion_functor m\u2082 \u22d9 F \u27f6 order.lt_inclusion_functor m\u2082 \u22d9 G)\n  (\u03c6m : F.obj m\u2082 \u27f6 G.obj m\u2082)\n  (comm : F.map hm\u2081\u2082.hom \u226b \u03c6m = \u03c6.app \u27e8m\u2081, hm\u2081\u2082.lt\u27e9 \u226b G.map hm\u2081\u2082.hom)\n\ninclude comm\n\ndef order.are_succ.mk_nat_trans : F \u27f6 G :=\nhm\u2082.mk_nat_trans F G \u03c6 \u03c6m (\u03bb a, begin\n  have r : a.1 \u2264 m\u2081 := (hm\u2081\u2082.lt_iff_le _).1 a.2,\n  have r' : a \u2264 \u27e8m\u2081, hm\u2081\u2082.lt\u27e9 := r,\n  simp only [subsingleton.elim (hom_of_le (r.trans hm\u2081\u2082.le)) (hom_of_le r \u226b hom_of_le hm\u2081\u2082.le),\n    functor.map_comp, assoc],\n  erw comm,\n  apply \u03c6.naturality_assoc (hom_of_le r'),\nend)\n\nlemma order.are_succ.mk_nat_trans_eq (a : \u03b1) (ha : a < m\u2082) :\n  (order.are_succ.mk_nat_trans hm\u2081\u2082 hm\u2082 F G \u03c6 \u03c6m comm).app a = \u03c6.app \u27e8a, ha\u27e9 :=\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\u2081\u2082 hm\u2082 F G \u03c6 \u03c6m comm).app m\u2082 = \u03c6m :=\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 {\u03b1 : Type*} [linear_order \u03b1] [is_well_order \u03b1 (<)]\n  (a : \u03b1) : is_bot a \u2228 order.is_succ a \u2228 order.is_limit a :=\nbegin\n  by_cases h\u2081 : is_bot a,\n  { exact or.inl h\u2081, },\n  { by_cases h\u2082 : order.is_succ a,\n    { exact or.inr (or.inl h\u2082), },\n    { exact or.inr (or.inr \u27e8h\u2081, h\u2082\u27e9), }, },\nend\n\nlemma is_well_order.two_cases {\u03b1 : Type*} [linear_order \u03b1] [is_well_order \u03b1 (<)]\n  (a : \u03b1) (ha : \u00acis_bot a) : order.is_succ a \u2228 order.is_limit a :=\nbegin\n  by_cases order.is_succ a,\n  { exact or.inl h, },\n  { exact or.inr \u27e8ha, h\u27e9, },\nend\n\ninstance is_well_order_subtype {\u03b1 : Type*} [linear_order \u03b1] [is_well_order \u03b1 (<)]\n  (P : \u03b1 \u2192 Prop) : is_well_order { a : \u03b1 // P a } (<) :=\nbegin\n  haveI : is_trichotomous { a : \u03b1 // P a } (<) := \u27e8\u03bb a b, begin\n    rcases @is_trichotomous.trichotomous \u03b1 (<) _ a.1 b.1 with h\u2081 | (h\u2082 | h\u2083),\n    { exact or.inl h\u2081, },\n    { exact or.inr (or.inl (by { ext, exact h\u2082, })), },\n    { exact or.inr (or.inr h\u2083), },\n  end\u27e9,\n  haveI : is_trans { a : \u03b1 // P a } (<) := \u27e8\u03bb a b c hab hbc, hab.trans hbc\u27e9,\n  haveI : is_well_founded { a : \u03b1 // P a } (<) := \u27e8\u27e8begin\n    rintro \u27e8a, ha\u27e9,\n    apply @well_founded.induction \u03b1 (<) is_well_founded.wf (\u03bb (a : \u03b1),\n      \u2200 (ha : P a), acc (<) (\u27e8a, ha\u27e9 : { b : \u03b1 // P b})),\n    refine \u03bb b H hb, acc.intro _ _,\n    rintro \u27e8a, ha\u27e9 hab,\n    exact H a hab ha,\n  end\u27e9\u27e9,\n  constructor,\nend\n\nnamespace category_theory\n\nnamespace functor\n\nvariables {C : Type u} [category.{v} C] {\u03b1 : Type*}\n  {\u03a6 : C \u2964 C} (\u03c4 : \ud835\udfed C \u27f6 \u03a6)\n\nstructure transfinite_iteration [partial_order \u03b1] (m : \u03b1) :=\n(F : { a : \u03b1 // a \u2264 m } \u2964 C)\n(hF : \u2200 (b : { a : \u03b1 // a \u2264 m }) (hb : order.is_limit b),\n  is_colimit (order.lt_cocone b F))\n(iso : \u03a0 (a b : { a : \u03b1 // a \u2264 m }) (hab : order.are_succ a b),\n  under.mk (F.map hab.hom) \u2245 under.mk (\u03c4.app (F.obj a)))\n\nnamespace transfinite_iteration\n\nvariables {\u03c4} {\u03b1}\n\nsection\n\nvariables [partial_order \u03b1] {m : \u03b1}\n\n@[ext]\nstructure hom (I\u2081 I\u2082 : transfinite_iteration \u03c4 m) :=\n(f : I\u2081.F \u27f6 I\u2082.F)\n(comm\u03c4 : \u03a0 (a b : { a : \u03b1 // a \u2264 m}) (hab : order.are_succ a b),\n  (I\u2081.iso a b hab).hom.right \u226b \u03a6.map (f.app a) =\n    f.app b \u226b (I\u2082.iso a b hab).hom.right)\n\n@[simps]\ndef hom.id (I : transfinite_iteration \u03c4 m) :\n  hom I I :=\n{ f := \ud835\udfd9 _,\n  comm\u03c4 := by tidy, }\n\n@[simps]\ndef hom.comp {I\u2081 I\u2082 I\u2083 : transfinite_iteration \u03c4 m} (f : hom I\u2081 I\u2082) (g : hom I\u2082 I\u2083) :\n  hom I\u2081 I\u2083 :=\n{ f := f.f \u226b g.f,\n  comm\u03c4 := \u03bb a b hab, by simp only [nat_trans.comp_app, map_comp, assoc,\n      reassoc_of (f.comm\u03c4 a b hab), g.comm\u03c4 a b hab], }\n\ninstance : category (transfinite_iteration \u03c4 m) :=\n{ hom := hom,\n  id := hom.id,\n  comp := \u03bb I\u2081 I\u2082 I\u2083, hom.comp, }\n\nvariables (\u03c4 m)\n\n@[simps]\ndef eval (a : { b : \u03b1 // b \u2264 m}) : transfinite_iteration \u03c4 m \u2964 C :=\n{ obj := \u03bb I, I.F.obj a,\n  map := \u03bb I\u2081 I\u2082 f, f.f.app a, }\n\nend\n\nsection\n\nvariables [linear_order \u03b1] {m : \u03b1}\n\ndef restriction (m\u2081 m\u2082 : \u03b1) (h : m\u2081 \u2264 m\u2082) :\n  transfinite_iteration \u03c4 m\u2082 \u2964 transfinite_iteration \u03c4 m\u2081 :=\n{ obj := \u03bb I,\n  { F := order.le_inclusion_functor_of_le _ _ h \u22d9 I.F,\n    hF := begin\n      rintro \u27e8b, hb\u27e9 hb',\n      have hc := I.hF \u27e8b, hb.trans h\u27e9 (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\u2081 m\u2082 h \u27e8b, hb\u27e9).to_equivalence.symm,\n      let e := order.lt_inclusion_functor_iso_of_le' m\u2081 m\u2082 h \u27e8b, hb\u27e9,\n      let e' := iso_whisker_right e I.F,\n      let e'' : (order.order_iso_lt_le m\u2081 m\u2082 h \u27e8b, hb\u27e9).to_equivalence.inverse \u22d9\n        order.lt_inclusion_functor \u27e8b, hb\u27e9 \u22d9 order.le_inclusion_functor_of_le m\u2081 m\u2082 h \u22d9\n        I.F \u2245 _ := 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 _) (\u03bb a, _)),\n      dsimp,\n      simpa only [comp_id, \u2190 I.F.map_comp],\n    end,\n    iso := \u03bb a b hab, I.iso \u27e8a.1, a.2.trans h\u27e9 \u27e8b.1, b.2.trans h\u27e9\n      (by simpa only [order.are_succ.of_le_iff] using hab), },\n  map := \u03bb I\u2081 I\u2082 f,\n  { f := whisker_left (order.le_inclusion_functor_of_le _ _ h) f.f,\n    comm\u03c4 := \u03bb a b hab, f.comm\u03c4 \u27e8a.1, a.2.trans h\u27e9 \u27e8b.1, b.2.trans h\u27e9\n      (by simpa only [order.are_succ.of_le_iff] using hab), }, }\n\nend\n\nvariables (\u03c4) [linear_order \u03b1] [is_well_order \u03b1 (<)] (m : \u03b1) (a\u2080 : { b : \u03b1 // b \u2264 m})\n  (ha\u2080 : is_bot a\u2080)\n\ninclude ha\u2080\n\nlemma faithful_eval_zero : faithful (eval \u03c4 m a\u2080) :=\n\u27e8\u03bb I\u2081 I\u2082 f g h, begin\n  ext b,\n  apply @well_founded.induction { b : \u03b1 // b \u2264 m } (<) is_well_founded.wf\n    (\u03bb b, f.f.app b = g.f.app b),\n  intros b H,\n  rcases is_well_order.three_cases b with h\u2081 | (h\u2082 | h\u2083),\n  { have eq := is_bot.unique ha\u2080 h\u2081,\n    subst eq,\n    exact h, },\n  { obtain \u27e8a, hab\u27e9 := h\u2082,\n    simp only [\u2190 cancel_mono ((under.forget _).map (I\u2082.iso a b hab).hom),\n      under.forget_map, \u2190 f.comm\u03c4 a b hab, H a hab.lt, g.comm\u03c4 a b hab], },\n  { apply (I\u2081.hF b h\u2083).hom_ext,\n    intro a,\n    simp only [order.lt_cocone_\u03b9_app, nat_trans.naturality],\n    congr' 1,\n    exact H a a.2, },\nend\u27e9\n\nvariable {m}\n\nlemma eval_injective (I\u2081 I\u2082 : transfinite_iteration \u03c4 m) (m\u2081 m\u2082 : { x // x \u2264 m})\n  (f\u2081 : (restriction m\u2081.1 m m\u2081.2).obj I\u2081 \u27f6 (restriction m\u2081.1 m m\u2081.2).obj I\u2082)\n  (f\u2082 : (restriction m\u2082.1 m m\u2082.2).obj I\u2081 \u27f6 (restriction m\u2082.1 m m\u2082.2).obj I\u2082)\n  (eq : f\u2081.f.app \u27e8a\u2080.1, ha\u2080 _\u27e9 = f\u2082.f.app \u27e8a\u2080.1, ha\u2080 _\u27e9)\n  (a : { x // x \u2264 m}) (ha\u2081 : a \u2264 m\u2081) (ha\u2082 : a \u2264 m\u2082) :\n  f\u2081.f.app \u27e8a.1, ha\u2081\u27e9 = f\u2082.f.app \u27e8a.1, ha\u2082\u27e9 :=\nbegin\n  suffices : (restriction a.1 m\u2081.1 ha\u2081).map f\u2081 = (restriction a.1 m\u2082.1 ha\u2082).map f\u2082,\n  { exact congr_app (congr_arg transfinite_iteration.hom.f this) \u27e8a.1, le_refl _\u27e9, },\n  haveI := faithful_eval_zero \u03c4 a.1 \u27e8a\u2080, ha\u2080 _\u27e9\n    (by simpa only [is_bot.of_le_iff] using ha\u2080),\n  exact (eval \u03c4 a.1 \u27e8a\u2080, ha\u2080 _\u27e9).map_injective eq,\nend\n\nvariable (m)\n\nlemma full_eval_zero : full (eval \u03c4 m a\u2080) :=\nnonempty.some begin\n  rcases a\u2080 with \u27e8a\u2080, ha\u2081\u27e9,\n  rw is_bot.of_le_iff at ha\u2080,\n  dsimp at ha\u2080,\n  apply @well_founded.induction \u03b1 (<) is_well_founded.wf (\u03bb (m' : \u03b1), nonempty\n    (full (eval \u03c4 m' \u27e8a\u2080, ha\u2080 _\u27e9))),\n  clear ha\u2081 m,\n  intros m H,\n  refine \u27e8full_of_surjective _ (\u03bb I\u2081 I\u2082 f, _)\u27e9,\n  dsimp at f,\n  by_cases hm : is_bot m,\n  { haveI : subsingleton { x // x \u2264 m},\n    { have hm : \u2200 (a : { x // x \u2264 m}), a = \u27e8a\u2080, ha\u2080 _\u27e9 :=\n        \u03bb a, le_antisymm (a.2.trans (hm _)) (ha\u2080 _),\n      exact \u27e8\u03bb x y, by rw [hm x, hm y]\u27e9, },\n    refine\n    \u27e8{ f :=\n      { app := \u03bb a, eq_to_hom (by congr) \u226b f \u226b eq_to_hom (by congr),\n        naturality' := \u03bb a\u2081 a\u2082 \u03c6, begin\n          have h\u2081\u2082 := subsingleton.elim a\u2081 a\u2082,\n          subst h\u2081\u2082,\n          simp only [subsingleton.elim \u03c6 (\ud835\udfd9 _), map_id, id_comp, comp_id],\n        end, },\n      comm\u03c4 := \u03bb 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, }, _\u27e9,\n    dsimp,\n    simp only [comp_id, id_comp], },\n  { let X := { x // x < m},\n    let R\u2081 := \u03bb (a : X), (restriction a.1 m a.2.le).obj I\u2081,\n    let R\u2082 := \u03bb (a : X), (restriction a.1 m a.2.le).obj I\u2082,\n    have h : \u2200 (a : X), \u2203 (\u03a6 : R\u2081 a \u27f6 R\u2082 a),\n      (eval \u03c4 a.1 \u27e8a\u2080, ha\u2080 _\u27e9).map \u03a6 = f,\n    { intros a,\n      haveI := (H a.1 a.2).some,\n      apply (eval \u03c4 a.1 \u27e8a\u2080, ha\u2080 _\u27e9).map_surjective, },\n    let \u03a8 := \u03bb (a : X), (h a).some,\n    have h\u03a8 : \u2200 (a : X), (\u03a8 a).f.app \u27e8a\u2080, ha\u2080 _\u27e9 = f := \u03bb a, (h a).some_spec,\n    have h\u03a8' : \u2200 (a\u2081 a\u2082 : X) (ha\u2081\u2082 : a\u2081 \u2264 a\u2082) (b : \u03b1) (hb : b \u2264 a\u2081.1),\n      (\u03a8 a\u2081).f.app \u27e8b, hb\u27e9 = (\u03a8 a\u2082).f.app \u27e8b, hb.trans ha\u2081\u2082\u27e9,\n    { intros a\u2081 a\u2082 ha\u2081\u2082 b hb,\n      exact eval_injective \u03c4 \u27e8a\u2080, ha\u2080 _\u27e9 (by simpa only [is_bot.of_le_iff] using ha\u2080)\n        I\u2081 I\u2082 \u27e8a\u2081.1, a\u2081.2.le\u27e9 \u27e8a\u2082.1, a\u2082.2.le\u27e9 (\u03a8 a\u2081) (\u03a8 a\u2082) (by erw [h\u03a8 a\u2081, h\u03a8 a\u2082])\n        \u27e8b, hb.trans a\u2081.2.le\u27e9 hb (hb.trans ha\u2081\u2082), },\n    let m' : { x // x \u2264 m} := \u27e8m, le_refl m\u27e9,\n    have hm' : is_top m' := \u03bb a, a.2,\n    let \u03c6' : order.lt_inclusion_functor m' \u22d9 I\u2081.F \u27f6 order.lt_inclusion_functor m' \u22d9 I\u2082.F :=\n    { app := by { rintro \u27e8\u27e8a, ha\u27e9, ha'\u27e9, exact (\u03a8 \u27e8a, ha'\u27e9).f.app \u27e8a, le_refl _\u27e9, },\n      naturality' := begin\n        rintro \u27e8\u27e8a\u2081, ha\u2081\u27e9, ha\u2081'\u27e9 \u27e8\u27e8a\u2082, ha\u2082\u27e9, ha\u2082'\u27e9 g,\n        dsimp,\n        rw h\u03a8' \u27e8a\u2081, ha\u2081'\u27e9 \u27e8a\u2082, ha\u2082'\u27e9 (le_of_hom g),\n        let a\u2081' : {x // x \u2264 a\u2082} := \u27e8a\u2081, le_of_hom g\u27e9,\n        let a\u2082' : {x // x \u2264 a\u2082} := \u27e8a\u2082, le_refl _\u27e9,\n        let g' : a\u2081' \u27f6 a\u2082' := hom_of_le (le_of_hom g),\n        exact (\u03a8 \u27e8a\u2082, ha\u2082'\u27e9).f.naturality g',\n      end },\n    cases is_well_order.two_cases _ hm with hm'' hm'',\n    { obtain \u27e8m\u2081, hm\u2081\u27e9 := hm'',\n      have hm\u2081' := (order.are_succ.of_le_iff \u27e8m\u2081, hm\u2081.le\u27e9 m').2 hm\u2081,\n      let m\u2081' : { x // x < m'} := \u27e8\u27e8m\u2081, hm\u2081.le\u27e9, hm\u2081.lt\u27e9,\n      let \u03c6m : I\u2081.F.obj m' \u27f6 I\u2082.F.obj m' := (under.forget _).map (I\u2081.iso _ _ hm\u2081').hom \u226b\n        \u03a6.map (\u03c6'.app m\u2081') \u226b (under.forget _).map (I\u2082.iso _ _ hm\u2081').inv,\n      refine \u27e8{ f := hm\u2081'.mk_nat_trans hm' _ _ \u03c6' \u03c6m _, comm\u03c4 := _, }, _\u27e9,\n      { have eq := \u03c4.naturality (\u03c6'.app m\u2081'),\n        have eq\u2081 := under.w (I\u2081.iso _ _ hm\u2081').hom,\n        have eq\u2082 := under.w (I\u2082.iso _ _ hm\u2081').hom,\n        have eq\u2083 := ((under.forget _).map_iso (I\u2082.iso _ _ hm\u2081')).hom_inv_id,\n        dsimp [\u03c6m] at \u22a2 eq eq\u2081 eq\u2082 eq\u2083,\n        rw [\u2190 eq\u2081, \u2190 eq\u2082, assoc] at eq,\n        slice_lhs 1 3 { rw \u2190 eq, },\n        simp only [assoc, eq\u2083, comp_id], },\n      { rintro \u27e8a, ha\u27e9 \u27e8b, hb\u27e9 hab,\n        by_cases hb' : b < m,\n        { have ha' : a < m := lt_of_le_of_lt hab.le hb',\n          rw [hm\u2081'.mk_nat_trans_eq hm' _ _ _ _ _ \u27e8b, hb\u27e9 hb',\n            hm\u2081'.mk_nat_trans_eq hm' _ _ _ _ _ \u27e8a, ha\u27e9 ha'],\n          dsimp [\u03c6'],\n          rw [h\u03a8' \u27e8a, ha'\u27e9 \u27e8b, hb'\u27e9 hab.le a (le_refl _)],\n          exact (\u03a8 \u27e8b, hb'\u27e9).comm\u03c4 \u27e8a, hab.le\u27e9 \u27e8b, le_refl _\u27e9\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\u2081 = a := order.are_succ.pred_uniq hm\u2081 ((order.are_succ.of_le_iff _ _).1 hab),\n          subst ha',\n          rw [hm\u2081'.mk_nat_trans_eq' hm', hm\u2081'.mk_nat_trans_eq hm' _ _ _ _ _ \u27e8m\u2081, ha\u27e9 hm\u2081.lt],\n          dsimp [\u03c6m],\n          have eq := ((under.forget _).map_iso (I\u2082.iso \u27e8m\u2081, ha\u27e9 \u27e8m, hb\u27e9 hab)).inv_hom_id,\n          dsimp at eq,\n          simp only [assoc, eq, comp_id], }, },\n      { dsimp,\n        let a\u2080' : { x // x \u2264 m} := \u27e8a\u2080, ha\u2080 _\u27e9,\n        have ha\u2080' : a\u2080' < m',\n        { rw hm\u2081'.lt_iff_le,\n          apply ha\u2080, },\n        rw hm\u2081'.mk_nat_trans_eq hm' _ _ _ _ _ a\u2080' ha\u2080',\n        dsimp [\u03c6'],\n        rw h\u03a8, }, },\n    { let \u03c6m : I\u2081.F.obj m' \u27f6 I\u2082.F.obj m' := (I\u2081.hF m'\n        ((order.is_limit.of_le_iff m').2 hm'')).desc (cocone.mk (I\u2082.F.obj m')\n          { app := begin\n              rintro \u27e8\u27e8a, ha\u27e9, ha'\u27e9,\n              exact (\u03a8 \u27e8a, ha'\u27e9).f.app \u27e8a, le_refl _\u27e9 \u226b I\u2082.F.map (hom_of_le ha),\n            end,\n            naturality' := begin\n              rintro \u27e8\u27e8a, ha\u27e9, ha'\u27e9 \u27e8\u27e8b, hb\u27e9, hb'\u27e9 hab,\n              dsimp,\n              rw [comp_id, h\u03a8' \u27e8a, ha'\u27e9 \u27e8b, hb'\u27e9 (le_of_hom hab) a (le_refl _)],\n              let a' : { x // x \u2264 b} := \u27e8a, le_of_hom hab\u27e9,\n              let b' : { x // x \u2264 b} := \u27e8b, le_refl _\u27e9,\n              let hab' : a' \u27f6 b' := hom_of_le a'.2,\n              let a'' : {x // x \u2264 m} := \u27e8a, ha\u27e9,\n              let b'' : {x // x \u2264 m} := \u27e8b, hb\u27e9,\n              let g : b'' \u27f6 m' := hom_of_le hb,\n              let hab'' : a'' \u27f6 b'' := hab,\n              have eq' := subsingleton.elim (hom_of_le ha : a'' \u27f6 m') (hab'' \u226b hom_of_le hb),\n              rw [eq', I\u2082.F.map_comp],\n              have eq := (\u03a8 \u27e8b, hb'\u27e9).f.naturality hab' =\u226b I\u2082.F.map g,\n              simp only [assoc] at eq,\n              convert eq,\n            end }),\n      refine \u27e8{ f := hm'.mk_nat_trans _ _ \u03c6' \u03c6m _, comm\u03c4 := _, }, _\u27e9,\n      { rintro \u27e8\u27e8a, ha\u27e9, ha'\u27e9,\n        apply (I\u2081.hF m' ((order.is_limit.of_le_iff m').2 hm'')).fac, },\n      { rintro \u27e8a, ha\u27e9 \u27e8b, hb\u27e9 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 \u27e8_, hab\u27e9, },\n        have ha' : a < m := lt_of_lt_of_le hab.lt hb,\n        rw [hm'.mk_nat_trans_eq _ _ _ _ _ \u27e8a, ha\u27e9 ha',\n          hm'.mk_nat_trans_eq _ _ _ _ _ \u27e8b, hb\u27e9 hb'],\n        dsimp [\u03c6'],\n        rw h\u03a8' \u27e8a, ha'\u27e9 \u27e8b, hb'\u27e9 hab.le a (le_refl _),\n        exact (\u03a8 \u27e8b, hb'\u27e9).comm\u03c4 \u27e8a, _\u27e9 \u27e8b, _\u27e9\n          (by simpa only [order.are_succ.of_le_iff] using hab), },\n      { dsimp,\n        let a\u2080' : { x // x \u2264 m} := \u27e8a\u2080, ha\u2080 _\u27e9,\n        have ha\u2080' : a\u2080' < m',\n        { by_contra',\n          apply hm''.1,\n          rw \u2190 le_antisymm a\u2080'.2 this,\n          exact ha\u2080, },\n        rw hm'.mk_nat_trans_eq _ _ _ _ _ a\u2080' ha\u2080',\n        apply h\u03a8, }, }, },\nend\n\nend transfinite_iteration\n\nsection\n\ndef to_sections_lt_inclusion_functor [partial_order \u03b1] (F : \u03b1\u1d52\u1d56 \u2964 Type v) (a : \u03b1) (x : F.obj (opposite.op a)) :\n  ((order.lt_inclusion_functor a).op \u22d9 F).sections :=\n\u27e8\u03bb b, F.map (hom_of_le b.unop.2.le).op x, begin\n  rintro b c f,\n  dsimp,\n  simpa only [\u2190 functor_to_types.map_comp_apply F],\nend\u27e9\n\nvariables [linear_order \u03b1] [is_well_order \u03b1 (<)]\n  (F : \u03b1\u1d52\u1d56 \u2964 Type v)\n  (hF\u2081 : \u2200 (a b : \u03b1) (hab : order.are_succ a b), function.surjective (F.map (hom_of_le hab.le).op))\n  (hF\u2082 : \u2200 (a : \u03b1) (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(\u03b2 : set \u03b1)\n(h\u03b2 : \u2200 (x y : \u03b1) (hxy : x \u2264 y) (hy : y \u2208 \u03b2), x \u2208 \u03b2)\n(s : \u03a0 (b : \u03b2), F.obj (opposite.op b.1))\n(hs : \u2200 (b c : \u03b2) (h : b \u2264 c), s b = F.map (hom_of_le h : b.1 \u27f6 c.1).op (s c))\n\ninstance : partial_order (X F) :=\n{ le := \u03bb \u03c3\u2081 \u03c3\u2082, (\u03c3\u2081.\u03b2 \u2286 \u03c3\u2082.\u03b2) \u2227\n    \u2200 (b : \u03b1) (hb\u2081 : b \u2208 \u03c3\u2081.\u03b2) (hb\u2082 : b \u2208 \u03c3\u2082.\u03b2), \u03c3\u2081.s \u27e8b, hb\u2081\u27e9 = \u03c3\u2082.s \u27e8b, hb\u2082\u27e9,\n  le_refl := by tauto,\n  le_trans := \u03bb \u03c3\u2081 \u03c3\u2082 \u03c3\u2083 h\u2081\u2082 h\u2082\u2083,\n    \u27e8h\u2081\u2082.1.trans h\u2082\u2083.1, \u03bb b hb\u2081 hb\u2083, (h\u2081\u2082.2 b hb\u2081 (h\u2081\u2082.1 hb\u2081)).trans (h\u2082\u2083.2 b (h\u2081\u2082.1 hb\u2081) hb\u2083)\u27e9,\n  le_antisymm := \u03bb \u03c3\u2081 \u03c3\u2082 h\u2081\u2082 h\u2082\u2081, begin\n    rcases \u03c3\u2081 with \u27e8\u03b2, h\u03b2, s, hs\u27e9,\n    rcases \u03c3\u2082 with \u27e8\u03b2', h\u03b2', s', hs'\u27e9,\n    have eq\u03b2 : \u03b2 = \u03b2',\n    { ext,\n      exact \u27e8\u03bb h, h\u2081\u2082.1 h, \u03bb h, h\u2082\u2081.1 h\u27e9, },\n    subst eq\u03b2,\n    simp only [eq_self_iff_true, heq_iff_eq, true_and],\n    ext \u27e8b, hb\u27e9,\n    exact h\u2081\u2082.2 b hb hb,\n  end, }\n\n@[simps]\ndef X.of_is_bot (a\u2080 : \u03b1) (ha\u2080 : is_bot a\u2080) (x : F.obj (opposite.op a\u2080)) :\n  X F :=\n{ \u03b2 := { a\u2080 },\n  h\u03b2 := \u03bb x y hxy hy, begin\n    simp only [set.mem_singleton_iff] at hy \u22a2,\n    exact le_antisymm (hxy.trans (by rw hy)) (ha\u2080 _),\n  end,\n  s := begin\n    rintro \u27e8b, hb\u27e9,\n    simp only [set.mem_singleton_iff] at hb,\n    subst hb,\n    exact x,\n  end,\n  hs := begin\n    rintro \u27e8b, hb\u27e9 \u27e8c, hc\u27e9 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) (\ud835\udfd9 _), op_id, F.map_id, types_id_apply],\n  end, }\n\n@[simp]\nlemma X.of_is_bot_s\u2080 (a\u2080 : \u03b1) (ha\u2080 : is_bot a\u2080) (x : F.obj (opposite.op a\u2080)) :\n  (X.of_is_bot F a\u2080 ha\u2080 x).s \u27e8a\u2080, rfl\u27e9 = x := rfl\n\ndef X_set (a\u2080 : \u03b1) (ha\u2080 : is_bot a\u2080) (x\u2080 : F.obj (opposite.op a\u2080)) :=\n  { \u03c3 : X F | X.of_is_bot F a\u2080 ha\u2080 x\u2080 \u2264 \u03c3 }\n\nvariable {F}\n\nlemma X_set_chain_condition {a\u2080 : \u03b1} {ha\u2080 : is_bot a\u2080} {x\u2080 : F.obj (opposite.op a\u2080)}\n  (C : set (X F)) (hC\u2081 : C \u2286 X_set F a\u2080 ha\u2080 x\u2080) (hC\u2082 : is_chain (\u2264) C) :\n  \u2203 (m : X F) (hm : m \u2208 X_set F a\u2080 ha\u2080 x\u2080), \u2200 (z : X F) (hz : z \u2208 C), z \u2264 m :=\nbegin\n  by_cases hC\u2080 : nonempty C,\n  { let \u03b2 : set \u03b1 := \u03bb b, \u2203 (c : C), b \u2208 c.1.\u03b2,\n    let \u03b3 : \u03b2 \u2192 C := \u03bb b, b.2.some,\n    have h\u03b3 : \u2200 (b : \u03b2), b.1 \u2208 (\u03b3 b).1.\u03b2 := \u03bb b, b.2.some_spec,\n    let s : \u03a0 (b : \u03b2), F.obj (opposite.op b.val) := \u03bb b, (\u03b3 b).1.s \u27e8b.1, h\u03b3 b\u27e9,\n    have hC\u2082' : \u2200 (z\u2081 z\u2082 : C) (b : \u03b1) (hb\u2081 : b \u2208 z\u2081.1.\u03b2) (hb\u2082 : b \u2208 z\u2082.1.\u03b2),\n      z\u2081.1.s \u27e8b, hb\u2081\u27e9 = z\u2082.1.s \u27e8b, hb\u2082\u27e9,\n    { intros z\u2081 z\u2082 b hb\u2081 hb\u2082,\n      by_cases hz\u2081\u2082 : z\u2081.1 = z\u2082.1,\n      { have hz\u2081\u2082' : z\u2081 = z\u2082 := by { ext, exact hz\u2081\u2082, },\n        subst hz\u2081\u2082', },\n      { cases hC\u2082 z\u2081.2 z\u2082.2 hz\u2081\u2082,\n        { apply h.2, },\n        { symmetry, apply h.2, }, }, },\n    have hs : \u2200 (z : C) (b : \u03b1) (hb : b \u2208 z.1.\u03b2), s \u27e8b, \u27e8z, hb\u27e9\u27e9 = z.1.s \u27e8b, hb\u27e9,\n    { intros s b hb,\n      apply hC\u2082', },\n    refine\n    \u27e8{ \u03b2 := \u03b2,\n      h\u03b2 := \u03bb b\u2081 b\u2082 h\u2081\u2082 h\u2082, begin\n        obtain \u27e8c, hc\u27e9 := h\u2082,\n        exact \u27e8c, c.1.h\u03b2 b\u2081 _ h\u2081\u2082 hc\u27e9,\n      end,\n      s := s,\n      hs := begin\n        rintro \u27e8b, hb\u27e9 \u27e8c, hc\u27e9 hbc,\n        let g := \u03b3 \u27e8c, hc\u27e9,\n        erw [hs g c (h\u03b3 _), hs g b (g.1.h\u03b2 _ _ hbc (h\u03b3 _))],\n        exact g.1.hs \u27e8b, _\u27e9 \u27e8c, _\u27e9 hbc,\n      end, }, _, _\u27e9,\n    { split,\n      { dsimp,\n        simp only [set.singleton_subset_iff],\n        exact \u27e8_, (hC\u2081 hC\u2080.some.2).1 rfl\u27e9, },\n      { intros b hb\u2081 hb\u2082,\n        apply (hC\u2081 (\u03b3 \u27e8b, hb\u2082\u27e9).2).2, }, },\n    { intros z hz,\n      split,\n      { intros a ha,\n        exact \u27e8\u27e8z, hz\u27e9, ha\u27e9, },\n      { intros b hb\u2081 hb\u2082,\n        exact (hs \u27e8z, hz\u27e9 b hb\u2081).symm, }, }, },\n  { refine \u27e8X.of_is_bot F a\u2080 ha\u2080 x\u2080, le_refl _, _\u27e9,\n    intros z hz,\n    exfalso,\n    exact hC\u2080 \u27e8\u27e8z, hz\u27e9\u27e9, },\nend\n\nsection\n\nvariables (x : X F) {m : \u03b1} (hx : x.\u03b2 = {a | a < m}) (t : F.obj (opposite.op m))\n  (ht : \u2200 (b : \u03b1) (hb : b < m),\n    x.s \u27e8b, by simpa only [hx] using hb\u27e9 = (F.map (hom_of_le hb.le).op) t)\n\ninclude ht\n\n@[simps]\ndef X.extension : X F :=\n{ \u03b2 := {a | a \u2264 m},\n  h\u03b2 := \u03bb x y hxy hy, hxy.trans hy,\n  s := begin\n    rintro \u27e8b, hb\u27e9,\n    by_cases b < m,\n    { exact x.s \u27e8b, by simpa only [hx] using h\u27e9, },\n    { have hb' := le_antisymm (not_lt.1 h) hb,\n      subst hb',\n      exact t, },\n  end,\n  hs := begin\n    rintro \u27e8b, hb\u27e9 \u27e8c, hc\u27e9 (hbc : b \u2264 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 \u27e8b, by simpa only [hx] using hb'\u27e9 \u27e8c, by simpa only [hx] using hc'\u27e9 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) (\ud835\udfd9 _), 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 \u2260 X.extension x hx t ht,\n  { intro h,\n    rw \u2190 lt_self_iff_false m,\n    change m \u2208 { x | x < m},\n    rw [\u2190 hx, h],\n    apply le_refl, },\n  suffices : x \u2264 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\u2081 hb\u2082,\n    have hb\u2081' : b < m := by simpa only [hx] using hb\u2081,\n    dsimp,\n    rw dif_pos hb\u2081', },\nend\n\nend\n\nend surjective_of_is_well_order_of_surjective\n\ninclude hF\u2081 hF\u2082\n\nopen surjective_of_is_well_order_of_surjective\n\nlemma surjective_of_is_well_order_of_surjective' (a\u2080 : \u03b1) (ha\u2080 : is_bot a\u2080):\n  function.surjective (\u03bb (s : F.sections), s.1 (opposite.op a\u2080)) :=\n\u03bb x\u2080, begin\n  obtain \u27e8m, hm\u2080 : X.of_is_bot F a\u2080 ha\u2080 x\u2080 \u2264 m, hm\u27e9 :=\n    zorn_partial_order\u2080 (X_set F a\u2080 ha\u2080 x\u2080) (by apply X_set_chain_condition),\n  suffices : m.\u03b2 = \u22a4,\n  { have hm' : \u2200 (b : \u03b1), b \u2208 m.\u03b2 := \u03bb b, by simp only [this, set.top_eq_univ],\n    refine \u27e8\u27e8\u03bb b, m.s \u27e8b.unop, hm' _\u27e9, _\u27e9, _\u27e9,\n    { intros b c f,\n      have eq := m.hs \u27e8c.unop, hm' _\u27e9 \u27e8b.unop, hm' _\u27e9 (le_of_hom f.unop),\n      convert eq.symm, },\n    { dsimp,\n      simp only [\u2190 hm\u2080.2 a\u2080 (by simp) (hm' _), X.of_is_bot_s], }, },\n  replace hm : \u2200 (z : X F) (hz : m \u2264 z), z = m := \u03bb z hz, hm z (hm\u2080.trans hz) hz,\n  by_contra' hm',\n  replace hm' : (m.\u03b2\u1d9c : set \u03b1).nonempty,\n  { simp only [set.nonempty_iff_ne_empty],\n    intro h,\n    apply hm',\n    rw [\u2190 compl_compl m.\u03b2, h, set.compl_empty, set.top_eq_univ], },\n  let b := @well_founded.min \u03b1 (<) is_well_founded.wf _ hm',\n  have hb : m.\u03b2 = { x | x < b},\n  { have hb' : b \u2208 m.\u03b2\u1d9c := well_founded.min_mem _ _ _,\n    ext a,\n    split,\n    { intro ha,\n      dsimp,\n      by_contra',\n      exact hb' (m.h\u03b2 _ _ this ha), },\n    { intro ha,\n      dsimp at ha,\n      by_contra ha',\n      have ha'' : \u00ac (a < b):= well_founded.not_lt_min _ _ _ ha',\n      exact ha'' ha, }, },\n  rcases is_well_order.three_cases b with h\u2081 | (h\u2082 | h\u2083),\n  { rw is_bot.unique h\u2081 ha\u2080 at hb,\n    have ha\u2080' : a\u2080 \u2209 m.\u03b2,\n    { simp only [hb, set.mem_set_of_eq, lt_self_iff_false, not_false_iff], },\n    apply ha\u2080',\n    apply hm\u2080.1,\n    simp only [X.of_is_bot_\u03b2, set.mem_singleton], },\n  { obtain \u27e8a, hab\u27e9 := h\u2082,\n    have ha' : a \u2208 m.\u03b2 := by simpa only [hb] using hab.lt,\n    obtain \u27e8t, ht\u27e9 := hF\u2081 _ _ hab (m.s \u27e8a, ha'\u27e9),\n    let M := X.extension m hb t (\u03bb c hc, begin\n      rw hab.lt_iff_le at hc,\n      rw m.hs \u27e8c, m.h\u03b2 _ _ hc ha'\u27e9 \u27e8a, ha'\u27e9 hc,\n      have eq := congr_arg (F.map (hom_of_le hc).op) ht,\n      simp only [\u2190 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 \u27e8t, ht\u27e9 := hF\u2082 _ h\u2083 \u27e8\u03bb c, m.s \u27e8c.unop.1, by simpa only [hb] using c.unop.2\u27e9,\n      (\u03bb c d hcd, (m.hs \u27e8d.unop.1, _\u27e9 \u27e8c.unop.1, _\u27e9 _).symm)\u27e9,\n    let M := X.extension m hb t (\u03bb c hc,\n      congr_fun (congr_arg subtype.val ht.symm) (opposite.op \u27e8c, hc\u27e9)),\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 \u03b1] :\n  function.surjective (\u03bb (s : F.sections), s.1 (opposite.op \u22a5)) :=\nsurjective_of_is_well_order_of_surjective' F hF\u2081 hF\u2082 \u22a5 (order_bot.bot_le)\n\nend\n\nsection\n\nvariables {m : \u03b1} [linear_order \u03b1] (F : { x // x < m } \u2964 C) (X : C)\n  (\u03c6 : F \u27f6 (functor.const _).obj X)\n\nnamespace order_extension_from_lt_to_le\n\ninclude F X\n\ndef obj (a : { x // x \u2264 m}) : C :=\nbegin\n  by_cases a.1 < m,\n  { exact F.obj \u27e8a.1, h\u27e9, },\n  { exact X, },\nend\n\ndef obj_iso_of_lt (a : { x // x \u2264 m}) (ha : a.1 < m) :\n  obj F X a \u2245 F.obj \u27e8a.1, ha\u27e9 :=\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 \u2264 m}) (ha : \u00ac a.1 < m) :\n  obj F X a \u2245 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 \u03c6\n\ndef order_extension_from_lt_to_le : { x // x \u2264 m } \u2964 C :=\n{ obj := order_extension_from_lt_to_le.obj F X,\n  map := \u03bb 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 \u226b F.map (hom_of_le (by exact le_of_hom f)) \u226b\n          (obj_iso_of_lt F X b hb).inv, },\n      { exact (obj_iso_of_lt F X a ha).hom \u226b \u03c6.app \u27e8a, ha\u27e9 \u226b (obj_iso_of_not_lt F X b hb).inv, }, },\n    { exact (obj_iso_of_not_lt F X a ha).hom \u226b (obj_iso_of_not_lt F X b\n        (by { simp only [not_lt] at \u22a2 ha, exact ha.trans (le_of_hom f), })).inv, },\n  end,\n  map_id' := \u03bb a, begin\n    by_cases ha : a.1 < m,\n    { simp only [dif_pos ha],\n      have h := le_refl (\u27e8a.1, ha\u27e9 : { x // x < m}),\n      rw [subsingleton.elim (hom_of_le h) (\ud835\udfd9 _), functor.map_id, id_comp, iso.hom_inv_id], },\n    { simp only [dif_neg ha, iso.hom_inv_id], },\n  end,\n  map_comp' := \u03bb 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, \u2190 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' : (\u27e8a, ha\u27e9 : { x // x < m}) \u27f6 \u27e8b, hb\u27e9 := f,\n          have eq := \u03c6.naturality f',\n          dsimp at eq,\n          rw comp_id at eq,\n          simp only [\u2190 eq, assoc],\n          congr, }, },\n      { have hc : \u00acc.1 < m := \u03bb 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 : \u00acb.1 < m := \u03bb h, ha (lt_of_le_of_lt (le_of_hom f) h),\n      have hc : \u00acc.1 < m := \u03bb 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 \u03b1] (F : \u03b1 \u2964 C) (m : \u03b1) (hm : is_top m) :\n  F \u27f6 (functor.const _).obj (F.obj m) :=\n{ app := \u03bb a, F.map (hom_of_le (hm a)),\n  naturality' := \u03bb a b hab, begin\n    dsimp,\n    simpa only [comp_id, \u2190 F.map_comp],\n  end, }\n\nnamespace transfinite_iteration\n\nvariables (\u03c4) [linear_order \u03b1] [is_well_order \u03b1 (<)] {m : \u03b1} (a\u2080 : { b : \u03b1 // b \u2264 m})\n  (ha\u2080 : is_bot a\u2080)\n\ndef mk_of_is_bot (hm : is_bot m) (X : C) : transfinite_iteration \u03c4 m :=\n{ F := (functor.const _).obj X,\n  hF := \u03bb 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 \u27e8a, ha\u27e9 \u27e8b, hb\u27e9 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 : \u03b1} (hab : order.are_succ a b) (I : transfinite_iteration \u03c4 a) :\n  transfinite_iteration \u03c4 b :=\nbegin\n  let a' : { x // x < b} := \u27e8a, hab.lt\u27e9,\n  have ha' : is_top a' := \u03bb c, (hab.lt_iff_le c.1).1 c.2,\n  let i : { x // x < b } \u2192 { x // x \u2264 a } := \u03bb x, \u27e8x.1, ha' _\u27e9,\n  have hi : _root_.monotone i := \u03bb x y hxy, hxy,\n  exact\n  { F := order_extension_from_lt_to_le (monotone.functor hi \u22d9 I.F)\n      (\u03a6.obj (I.F.obj \u27e8a, le_refl a\u27e9))\n      (functor.nat_trans_to_functor_const _ a' ha' \u226b (functor.const _).map (\u03c4.app _)),\n    hF := sorry,\n    iso := sorry, }\nend\n\nvariable (m)\n\ninclude ha\u2080\n\nlemma ess_surj_eval_zero : ess_surj (eval \u03c4 m a\u2080) :=\nbegin\n  rcases a\u2080 with \u27e8a\u2080, ha\u2081\u27e9,\n  rw is_bot.of_le_iff at ha\u2080,\n  apply @well_founded.induction \u03b1 (<) is_well_founded.wf\n    (\u03bb b, ess_surj (eval \u03c4 b \u27e8a\u2080, ha\u2080 _\u27e9)) m,\n  intros b H,\n  rcases is_well_order.three_cases b with h\u2081 | (h\u2082 | h\u2083),\n  { have hb := is_bot.unique h\u2081 ha\u2080,\n    subst hb,\n    exact \u27e8\u03bb X\u2080, \u27e8mk_of_is_bot \u03c4 ha\u2080 X\u2080, \u27e8iso.refl _\u27e9\u27e9\u27e9, },\n  { obtain \u27e8a, hab\u27e9 := h\u2082,\n    haveI := H a hab.lt,\n    exact \u27e8\u03bb X\u2080, \u27e8mk_of_are_succ \u03c4 hab ((eval \u03c4 a \u27e8a\u2080, ha\u2080 _\u27e9).obj_preimage X\u2080),\n      \u27e8order_extension_from_lt_to_le.obj_iso_of_lt _ _ _ (lt_of_le_of_lt (ha\u2080 _) hab.lt) \u226a\u226b\n      ((eval \u03c4 a \u27e8a\u2080, ha\u2080 _\u27e9).obj_obj_preimage_iso _)\u27e9\u27e9\u27e9, },\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\u00f6lich, *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\u2200 p \u2260 (\u22a5 : ideal R), p.is_prime \u2192 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\u03bb 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 : \u00ac 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) = \u22a5)\n\n/-- An integral domain is a Dedekind domain iff and only if it is not a field, is\nNoetherian, has dimension \u2264 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 \u2194\n    (\u00ac is_field A) \u2227 is_noetherian_ring A \u2227 dimension_le_one A \u2227\n    integral_closure A f.codomain = \u22a5 :=\n\u27e8\u03bb \u27e8hf, hr, hd, hi\u27e9, \u27e8hf, hr, hd,\n  by rw [\u2190integral_closure_map_alg_equiv (fraction_ring.alg_equiv_of_quotient f),\n         hi, algebra.map_bot]\u27e9,\n \u03bb \u27e8hf, hr, hd, hi\u27e9, \u27e8hf, hr, hd,\n  by rw [\u2190integral_closure_map_alg_equiv (fraction_ring.alg_equiv_of_quotient f).symm,\n         hi, algebra.map_bot]\u27e9\u27e9\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 : \u00ac is_field A)\n(is_noetherian_ring : is_noetherian_ring A)\n(is_dvr_at_nonzero_prime : \u2200 P \u2260 (\u22a5 : ideal A), P.is_prime \u2192\n  discrete_valuation_ring (localization.at_prime P))\n\nsection inverse\n\nopen_locale classical\n\nvariables {R\u2081 : Type*} [integral_domain R\u2081] {g : fraction_map R\u2081 K}\nvariables {I J : fractional_ideal g}\n\nnoncomputable instance : has_inv (fractional_ideal g) := \u27e8\u03bb I, 1 / I\u27e9\n\nlemma inv_eq : I\u207b\u00b9 = 1 / I := rfl\n\nlemma inv_zero' : (0 : fractional_ideal g)\u207b\u00b9 = 0 := fractional_ideal.div_zero\n\nlemma inv_nonzero {J : fractional_ideal g} (h : J \u2260 0) :\nJ\u207b\u00b9 = \u27e8(1 : fractional_ideal g) / J, fractional_ideal.fractional_div_of_nonzero h\u27e9 :=\nfractional_ideal.div_nonzero _\n\nlemma coe_inv_of_nonzero {J : fractional_ideal g} (h : J \u2260 0) :\n  (\u2191J\u207b\u00b9 : submodule R\u2081 g.codomain) = g.coe_submodule 1 / J :=\nby { rwa inv_nonzero _, refl, assumption}\n\n/-- `I\u207b\u00b9` 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\u207b\u00b9 :=\nbegin\n  have hI : I \u2260 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 \u2190 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\u207b\u00b9 = 1 \u2194 \u2203 J, I * J = 1 :=\n\u27e8\u03bb h, \u27e8I\u207b\u00b9, h\u27e9, \u03bb \u27e8J, hJ\u27e9, by rwa [\u2190 @right_inverse_eq _ _ _ _ _ I J hJ]\u27e9\n\nvariables {K' : Type*} [field K'] {g' : fraction_map R\u2081 K'}\n\n@[simp] lemma map_inv (I : fractional_ideal g) (h : g.codomain \u2243\u2090[R\u2081] g'.codomain) :\n  (I\u207b\u00b9).map (h : g.codomain \u2192\u2090[R\u2081] g'.codomain) = (I.map h)\u207b\u00b9 :=\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)\u207b\u00b9 = fractional_ideal.span_singleton (x\u207b\u00b9) :=\nfractional_ideal.one_div_span_singleton x\n\nlemma mul_generator_self_inv (I : fractional_ideal g)\n  [submodule.is_principal (I : submodule R\u2081 g.codomain)] (h : I \u2260 0) :\n  I * fractional_ideal.span_singleton (generator (I : submodule R\u2081 g.codomain))\u207b\u00b9 = 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\u2081 g.codomain)] (h : I \u2260 0) :\n  I * I\u207b\u00b9 = 1 :=\n(fractional_ideal.mul_div_self_cancel_iff).mpr\n  \u27e8fractional_ideal.span_singleton (generator (I : submodule R\u2081 g.codomain))\u207b\u00b9,\n    @mul_generator_self_inv _ _ _ _ _ I _ h\u27e9\n\nlemma invertible_iff_generator_nonzero (I : fractional_ideal g)\n  [submodule.is_principal (I : submodule R\u2081 g.codomain)] :\n  I * I\u207b\u00b9 = 1 \u2194 generator (I : submodule R\u2081 g.codomain) \u2260 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\u2081 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\u2081 g.codomain)] (h : I \u2260 0) :\n  submodule.is_principal (I\u207b\u00b9).1 :=\nbegin\n  rw [fractional_ideal.val_eq_coe, fractional_ideal.is_principal_iff],\n  use (generator (I : submodule R\u2081 g.codomain))\u207b\u00b9,\n  have hI : I  * fractional_ideal.span_singleton ((generator (I : submodule R\u2081 g.codomain))\u207b\u00b9)  = 1,\n  apply @mul_generator_self_inv _ _ _ _ _ I _ h,\n  apply (@right_inverse_eq _ _ _ _ _ I (fractional_ideal.span_singleton\n    ( (generator (I : submodule R\u2081 g.codomain))\u207b\u00b9)) 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 : \u00ac is_field A)\n(mul_inv_cancel : \u2200 I \u2260 (\u22a5 : 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 \u2194\n    (\u00ac is_field A) \u2227 (\u2200 I \u2260 (\u22a5 : fractional_ideal f), I * I\u207b\u00b9 = 1) :=\nbegin\n  set h : (fraction_ring.of A).codomain \u2243\u2090[A] f.codomain := fraction_ring.alg_equiv_of_quotient f,\n  split; rintros \u27e8hf, hi\u27e9; use hf; intros I hI,\n  { have := hi (map \u2191h.symm I) (map_ne_zero _ hI),\n    convert congr_arg (map (h : (fraction_ring.of A).codomain \u2192\u2090[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 \u2191h I) (map_ne_zero _ hI),\n    convert congr_arg (map (h.symm : f.codomain \u2192\u2090[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 {\u03b1 : Type u}\n\ntheorem length_sub_lt_of_nodup_subperm [decidable_eq \u03b1] {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} \n(h\u2081 : l\u2081 <+~ l\u2082) (h\u2082 : a \u2208 l\u2082) (h\u2083 : a \u2209 l\u2081) (h\u2084 : nodup l\u2081):\nlength l\u2082 - length (a :: l\u2081) < length l\u2082 - length l\u2081\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 : \u03a0 (s : sig) (h : s \u2260 none), nnf\n| none h := by contradiction\n| (some \u27e8d, b\u27e9) h := d\n\ndef bsig : \u03a0 (s : sig) (h : s \u2260 none), list nnf\n| none h := by contradiction\n| (some \u27e8d, b\u27e9) h := b\n\ninstance (\u0393) : decidable_eq (no_literals \u0393) := by tactic.mk_dec_eq_instance\n\ninstance (\u0393) : decidable_eq (saturated \u0393) := by tactic.mk_dec_eq_instance\n\ninstance (\u0393) : decidable_eq (box_only \u0393) := 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 \u2286 closure goal)\n(ha : \u2200 \u03c6 \u2208 h, (\u27e8\u03c6, b\u27e9 : psig) \u2208 a)\n(hb : box_only b)\n-- dsig takes a signature (d, b) and a proof h, and returns d\n(ps\u2081 : \u03a0 (h : s \u2260 none), dsig s h \u2208 m)\n-- bsig takes a signature (d, b) and a proof h, and returns b\n(ps\u2082 : \u03a0 (h : s \u2260 none), bsig s h \u2286 m)\n\ninstance : decidable_eq sseqt := by tactic.mk_dec_eq_instance\n\nclass val_constructible (\u0393 : sseqt) :=\n(satu : saturated \u0393.m)\n(no_box_main : \u2200 {\u03c6}, box \u03c6 \u2209 \u0393.m)\n(no_contra_main : \u2200 {n}, var n \u2208 \u0393.m \u2192 neg n \u2209 \u0393.m)\n\nclass modal_applicable (\u0393 : sseqt) extends val_constructible \u0393 :=\n(\u03c6 : nnf)\n(ex : dia \u03c6 \u2208 \u0393.m)\n\nclass model_constructible (\u0393 : sseqt) extends val_constructible \u0393 :=\n(no_dia : \u2200 {\u03c6}, nnf.dia \u03c6 \u2209 \u0393.m)\n\ndef and_child {\u03c6 \u03c8} (\u0393 : sseqt) (h : nnf.and \u03c6 \u03c8 \u2208 \u0393.m) : sseqt :=\n{ goal := \u0393.goal, \n  s := none,\n  m := \u03c6 :: \u03c8 :: \u0393.m.erase (and \u03c6 \u03c8),\n  sbm := begin \n          intros x hx, cases hx, \n          {rw hx, apply (mem_closure_and _ (\u0393.sbm h)).1}, \n          {cases hx, \n           {rw hx, apply (mem_closure_and _ (\u0393.sbm h)).2},\n           {apply \u0393.sbm, apply list.erase_subset, exact hx}}\n         end,\n  ps\u2081 := by intro; contradiction,\n  ps\u2082 := by intro; contradiction,\n  .. \u0393}\n\ninductive and_instance_seqt (\u0393 : sseqt) : sseqt \u2192 Type\n| cons : \u03a0 {\u03c6 \u03c8} (h : nnf.and \u03c6 \u03c8 \u2208 \u0393.m), \n         and_instance_seqt $ and_child \u0393 h\n\ndef or_child_left {\u03c6 \u03c8} (\u0393 : sseqt) (h : nnf.or \u03c6 \u03c8 \u2208 \u0393.m) : sseqt :=\n{ goal := \u0393.goal, \n  s := none,\n  m := \u03c6 :: \u0393.m.erase (or \u03c6 \u03c8),\n  sbm := begin \n          intros x hx, cases hx, \n          {rw hx, apply (mem_closure_or _ (\u0393.sbm h)).1}, \n          {apply \u0393.sbm, apply list.erase_subset, exact hx}\n         end,\n  ps\u2081 := by intro; contradiction,\n  ps\u2082 := by intro; contradiction,\n  .. \u0393}\n\ndef or_child_right {\u03c6 \u03c8} (\u0393 : sseqt) (h : nnf.or \u03c6 \u03c8 \u2208 \u0393.m) : sseqt :=\n{ goal := \u0393.goal, \n  s := none,\n  m := \u03c8 :: \u0393.m.erase (or \u03c6 \u03c8),\n  sbm := begin \n           intros x hx, cases hx, \n           {rw hx, apply (mem_closure_or _ (\u0393.sbm h)).2}, \n           {apply \u0393.sbm, apply list.erase_subset, exact hx}\n         end,\n  ps\u2081 := by intro; contradiction,\n  ps\u2082 := by intro; contradiction,\n  .. \u0393}\n\ninductive or_instance_seqt (\u0393 : sseqt) : sseqt \u2192 sseqt \u2192 Type\n| cons : \u03a0 {\u03c6 \u03c8} (h : nnf.or \u03c6 \u03c8 \u2208 \u0393.m),\n         or_instance_seqt (or_child_left \u0393 h) (or_child_right \u0393 h)\n\ndef box_child_new {\u03c6} (\u0393 : sseqt) (h\u2081 : nnf.box \u03c6 \u2208 \u0393.m) (h\u2082 : nnf.box \u03c6 \u2209 \u0393.b) : sseqt :=\n{ goal := \u0393.goal, \n  s := none,\n  h := [], \n  b := box \u03c6 :: \u0393.b, \n  m := \u03c6 :: \u0393.m.erase (box \u03c6),\n  ndh := by simp,\n  ndb := begin rw list.nodup_cons, split, exact h\u2082, exact \u0393.ndb end,\n  sph := begin apply list.nil_subperm end,\n  spb := begin \n           apply list.cons_subperm_of_mem \u0393.ndb h\u2082, \n           apply \u0393.sbm h\u2081, apply \u0393.spb\n         end,\n  sbm := begin \n           intros x hx, cases hx, \n           {rw hx, apply mem_closure_box _ (\u0393.sbm h\u2081)}, \n           {apply \u0393.sbm, apply list.erase_subset, exact hx}\n         end,\n  ha := \u03bb \u03c6 h, absurd h $ list.not_mem_nil _,\n  hb := cons_box_only \u0393.hb,\n  ps\u2081 := by intro; contradiction,\n  ps\u2082 := by intro; contradiction,\n  .. \u0393}\n\ninductive box_new_instance_seqt (\u0393 : sseqt) : sseqt \u2192 Type\n| cons : \u03a0 {\u03c6} (h\u2081 : nnf.box \u03c6 \u2208 \u0393.m) (h\u2082 : nnf.box \u03c6 \u2209 \u0393.b), \n         box_new_instance_seqt $ box_child_new \u0393 h\u2081 h\u2082\n\ndef box_child {\u03c6} (\u0393 : sseqt) (h\u2081 : nnf.box \u03c6 \u2208 \u0393.m) : sseqt :=\n{ goal := \u0393.goal, \n  s := none,\n  a := \u0393.a, \n  h := \u0393.h, \n  b := \u0393.b, \n  m := \u03c6 :: \u0393.m.erase (box \u03c6),\n  ndh := \u0393.ndh,\n  ndb := \u0393.ndb,\n  sph := \u0393.sph,\n  spb := \u0393.spb,\n  sbm := begin \n           intros x hx, cases hx, \n           {rw hx, apply mem_closure_box _ (\u0393.sbm h\u2081)}, \n           {apply \u0393.sbm, apply list.erase_subset, exact hx}\n         end,\n  ha := \u0393.ha,\n  hb := \u0393.hb,\n  ps\u2081 := by intro; contradiction,\n  ps\u2082 := by intro; contradiction}\n\ninductive box_dup_instance_seqt (\u0393 : sseqt) : sseqt \u2192 Type\n| cons : \u03a0 {\u03c6} (h\u2081 : nnf.box \u03c6 \u2208 \u0393.m) (h\u2082 : nnf.box \u03c6 \u2208 \u0393.b), \n         box_dup_instance_seqt $ box_child \u0393 h\u2081\n\n\ntheorem hintikka_vc {\u0393} (h : val_constructible \u0393) : hintikka \u0393.m :=\n{hno_contra := h.no_contra_main,\n hand_left := begin intros \u03c6 \u03c8 h\u2081, exfalso, apply h.satu.no_and, exact h\u2081 end,\n hand_right := begin intros \u03c6 \u03c8 h\u2081, exfalso, apply h.satu.no_and, exact h\u2081 end,\n hor := begin intros \u03c6 \u03c8 h\u2081, exfalso, apply h.satu.no_or, exact h\u2081 end,\n hbox := begin intros \u03c6 h\u2081, exfalso, apply h.no_box_main, exact h\u2081 end}\n\ntheorem hintikka_ma {\u0393} (h : modal_applicable \u0393) : hintikka \u0393.m :=\nhintikka_vc h.to_val_constructible\n\ntheorem hintikka_mc {\u0393} (h : model_constructible \u0393) : hintikka \u0393.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 \u2286 htk)\n\ninstance : decidable_eq info := by tactic.mk_dec_eq_instance\n\ninductive tmodel\n| cons : info \u2192 list tmodel \u2192 list psig \u2192 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 {\u210d : Type} {\u03c9 : 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 (\u210d : Type) : context \u2192 kind \u2192 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 {} {\u0393} (a : name \u0393) : label \u0393 kind.concretion\n\n/- Evolution from one species to another species without any other interaction,\n   at a specific rate. -/\n| spontaneous {\u0393} (rate : \u210d) : label \u0393 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 {} {\u0393} (k : upair (name \u0393)) : label \u0393 kind.species\n\nnotation `#`:max a:max := label.apply a\nnotation `\u03c4@'`:max k:max  := label.spontaneous k\nnotation `\u03c4\u27e8 `:max a `, ` b ` \u27e9`:max := label.of_affinity (upair.mk a b)\nnotation `\u03c4\u27e8 `:max p ` \u27e9`:max := label.of_affinity p\n\n/-- Convert a label to a string. Can use `repr` normally. -/\nprotected def label.to_string [has_repr \u210d] : \u2200 {k}, label \u210d \u03c9 k \u2192 string\n| ._ (# a) := \"#\" ++ repr a\n| ._ (\u03c4@' k) := \"\u03c4@\" ++ repr k\n| ._ (\u03c4\u27e8 p \u27e9) := \"\u03c4\u27e8 \" ++ repr p ++ \" \u27e9\"\n\ninstance label.has_repr [has_repr \u210d] {k} : has_repr (label \u210d \u03c9 k) := \u27e8 label.to_string \u27e9\n\n/-- Rename all names within a label. -/\ndef label.rename {\u0393 \u0394} (\u03c1 : name \u0393 \u2192 name \u0394) : \u2200 {k}, label \u210d \u0393 k \u2192 label \u210d \u0394 k\n| ._ #a := # (\u03c1 a)\n| ._ \u03c4@'k := \u03c4@'k\n| ._ \u03c4\u27e8 ab \u27e9 := \u03c4\u27e8 upair.map \u03c1 ab \u27e9\n\nlemma label.rename.inj {\u0393 \u0394} {\u03c1 : name \u0393 \u2192 name \u0394} (inj : function.injective \u03c1)\n  : \u2200 {k}, function.injective (@label.rename \u210d \u0393 \u0394 \u03c1 k)\n  | ._ #a #b eq := by { cases inj (label.apply.inj eq), from rfl }\n  | ._ \u03c4@'k \u03c4@'j rfl := rfl\n  | ._ \u03c4\u27e8 a \u27e9 \u03c4\u27e8 b \u27e9 eq := begin\n      cases upair.map.inj inj (label.of_affinity.inj eq),\n      from rfl\n    end\n  | ._ \u03c4@'k \u03c4\u27e8 _ \u27e9 eq := by contradiction\n  | ._ \u03c4\u27e8 _ \u27e9 \u03c4@'k eq := by contradiction\n\nlemma label.rename_compose {\u0393 \u0394 \u03b7} (\u03c1 : name \u0393 \u2192 name \u0394) (\u03c3 : name \u0394 \u2192 name \u03b7)\n  : \u2200 {k} (l : label \u210d \u0393 k)\n  , label.rename \u03c3 (label.rename \u03c1 l) = label.rename (\u03c3 \u2218 \u03c1) l\n| ._ #a := rfl\n| ._ \u03c4@'k := rfl\n| ._ \u03c4\u27e8 ab \u27e9 := by simp only [label.rename, upair.map_compose]\n\nlemma label.rename_id {\u0393} : \u2200 {k} (l : label \u210d \u0393 k), label.rename id l = l\n| ._ #a := rfl\n| ._ \u03c4@'k := rfl\n| ._ \u03c4\u27e8 p \u27e9 := 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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v3) \u2260 ((((a3).write i1 (v3)).write i3 (v3)).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test75.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5195213219520929, "lm_q2_score": 0.4571367168274948, "lm_q1q2_score": 0.23749227143905963}}
{"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}] {\u03b1 : \u039b} [position_data.{}] [phase_2_assumptions \u03b1]\n  {\u03b2 : Iic \u03b1} [freedom_of_action_hypothesis \u03b2]\n\ndef near_litter_hypothesis (N : near_litter) (A : extended_index \u03b2) (H : hypothesis \u27e8inr N, A\u27e9) :\n  hypothesis \u27e8inr N.1.to_near_litter, A\u27e9 := {\n  atom_image := \u03bb 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 := \u03bb 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 (\u03c0 : struct_approx \u03b2) (h\u03c0 : \u03c0.free)\n  (N : near_litter) (A : extended_index \u03b2) (H : hypothesis \u27e8inr N, A\u27e9) : set atom :=\n(near_litter_approx.largest_sublitter (\u03c0 A)\n  (litter_completion \u03c0 h\u03c0 N.1 A (near_litter_hypothesis N A H)) \u222a\n  \u03c0 A \u2022 (N \u2229 (\u03c0 A).atom_perm.domain)) \u2206\n  \u22c3 (a : atom) (ha : a \u2208 (litter_set N.1 \u2206 N) \\ (\u03c0 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 (\u03c0 : near_litter_approx) (N : near_litter) :\n  small ((N : set atom) \u2229 \u03c0.atom_perm.domain) :=\nbegin\n  rw [\u2190 symm_diff_symm_diff_cancel_left (litter_set N.fst) N, inter_symm_diff_distrib_right],\n  exact small.symm_diff (\u03c0.domain_small N.fst) (small.mono (inter_subset_left _ _) N.2.prop),\nend\n\n/-\nlemma largest_sublitter_symm_diff_small (\u03c0 : near_litter_approx) (N : near_litter) :\n  small ((\u03c0.largest_sublitter N.fst : set atom) \u2206 N) :=\nbegin\n  refine is_near_litter.near _ _,\n  exact N.fst,\n  exact (near_litter.is_near_litter (\u03c0.largest_sublitter N.fst).to_near_litter _).mpr rfl,\n  rw near_litter.is_near_litter,\nend\n\nlemma largest_sublitter_diff_small (\u03c0 : near_litter_approx) (N : near_litter) :\n  small ((\u03c0.largest_sublitter N.fst : set atom) \\ N) :=\nsmall.mono (subset_union_left _ _) (largest_sublitter_symm_diff_small \u03c0 N)\n-/\n\nlemma near_litter_completion_map_is_near_litter (\u03c0 : struct_approx \u03b2)\n  (h\u03c0 : \u03c0.free) (N : near_litter) (A : extended_index \u03b2) (H : hypothesis \u27e8inr N, A\u27e9) :\n  is_near_litter (\u03c0.litter_completion h\u03c0 N.fst A (near_litter_hypothesis N A H))\n    (\u03c0.near_litter_completion_map h\u03c0 N A H) :=\nbegin\n  rw [near_litter_completion_map, is_near_litter, is_near, near_litter_approx.coe_largest_sublitter,\n    \u2190 symm_diff_assoc, symm_diff_comm, \u2190 small.symm_diff_iff _],\n  { rw [set.symm_diff_def, \u2190 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 _ _) ((\u03c0 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) (\u03bb _ _, small_singleton _), },\nend\n\nnoncomputable def near_litter_completion (\u03c0 : struct_approx \u03b2) (h\u03c0 : \u03c0.free)\n  (N : near_litter) (A : extended_index \u03b2) (H : hypothesis \u27e8inr N, A\u27e9) : near_litter :=\n\u27e8litter_completion \u03c0 h\u03c0 N.1 A (near_litter_hypothesis N A H),\n  near_litter_completion_map \u03c0 h\u03c0 N A H,\n  near_litter_completion_map_is_near_litter \u03c0 h\u03c0 N A H\u27e9\n\n@[simp] lemma near_litter_completion_fst_eq (\u03c0 : struct_approx \u03b2) (h\u03c0 : \u03c0.free)\n  (N : near_litter) (A : extended_index \u03b2) (H : hypothesis \u27e8inr N, A\u27e9) :\n  (\u03c0.near_litter_completion h\u03c0 N A H).1 =\n  litter_completion \u03c0 h\u03c0 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 \u2192 prod_coprod\n| prod : prod_coprod \u2192 prod_coprod \u2192 prod_coprod\n| coprod : prod_coprod \u2192 prod_coprod \u2192 prod_coprod\n\nvariable {C}\n\nnamespace prod_coprod\n\ninductive syntax : \u03a0 (X Y : prod_coprod C), Type\n| of_cat {X Y : C} : (X \u27f6 Y) \u2192 syntax (of_cat' X) (of_cat' Y)\n| prod_mk {X Y Z : prod_coprod C} : syntax X Y \u2192 syntax X Z \u2192 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 \u2192 syntax Y Z \u2192 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 \u2192 syntax Y Z \u2192 syntax X Z\n\nnamespace syntax\n\ninductive rel : \u03a0 {X Y : prod_coprod C}, syntax X Y \u2192 syntax X Y \u2192 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 \u2192 rel g f\n| trans {X Y : prod_coprod C} {f g h : syntax X Y} : rel f g \u2192 rel g h \u2192 rel f h\n| comp_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : syntax X Y} {g\u2081 g\u2082 : syntax Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (f\u2081.comp g\u2081) (f\u2082.comp g\u2082)\n| prod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : syntax X Y} {g\u2081 g\u2082 : syntax X Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (f\u2081.prod_mk g\u2081) (f\u2082.prod_mk g\u2082)\n| coprod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : syntax X Z} {g\u2081 g\u2082 : syntax Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (f\u2081.coprod_mk g\u2081) (f\u2082.coprod_mk g\u2082)\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 (\ud835\udfd9 X)) (syntax.id (of_cat' X))\n| of_cat_comp {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  rel (syntax.of_cat (f \u226b 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 ` \u2665 `: 50 := rel\n\nlemma rel_prod {X Y Z : prod_coprod C} {f g : syntax X (Y.prod Z)}\n  (h\u2081 : rel (f.comp syntax.fst) (g.comp syntax.fst))\n  (h\u2082 : rel (f.comp syntax.snd) (g.comp syntax.snd)) :\n  rel f g :=\ncalc f \u2665 syntax.prod_mk (f.comp syntax.fst) (f.comp syntax.snd) : rel.symm (rel.prod_eta f)\n   ... \u2665 syntax.prod_mk (g.comp syntax.fst) (g.comp syntax.snd) : rel.prod_mk_congr h\u2081 h\u2082\n   ... \u2665 g : rel.prod_eta g\n\nlemma rel_coprod {X Y Z : prod_coprod C} {f g : syntax (X.coprod Y) Z}\n  (h\u2081 : rel (syntax.inl.comp f) (syntax.inl.comp g))\n  (h\u2082 : rel (syntax.inr.comp f) (syntax.inr.comp g)) :\n  rel f g :=\ncalc f \u2665 syntax.coprod_mk (syntax.inl.comp f) (syntax.inr.comp f) : rel.symm (rel.coprod_eta f)\n   ... \u2665 syntax.coprod_mk (syntax.inl.comp g) (syntax.inr.comp g) : rel.coprod_mk_congr h\u2081 h\u2082\n   ... \u2665 g : rel.coprod_eta g\n\ninstance rel_setoid (X Y : prod_coprod C) : setoid (syntax X Y) :=\n{ r := rel,\n  iseqv := \u27e8rel.refl, \u03bb _ _, rel.symm, \u03bb _ _ _, rel.trans\u27e9 }\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 := \u03bb X, quotient.mk' (syntax.id X),\n  comp := \u03bb X Y Z f g, quotient.lift_on\u2082 f g (\u03bb f g, quotient.mk' (syntax.comp f g))\n    (\u03bb f\u2081 g\u2081 f\u2082 g\u2082 hf hg, quotient.sound (rel.comp_congr hf hg)) }\n\ninstance : category (prod_coprod C) :=\n{ id_comp' := \u03bb X Y f, quotient.induction_on f (\u03bb f, quotient.sound (rel.id_comp f)),\n  comp_id' := \u03bb X Y f, quotient.induction_on f (\u03bb f, quotient.sound (rel.comp_id f)),\n  assoc' := \u03bb W X Y Z f g h, quotient.induction_on\u2083 f g h\n    (\u03bb f g h, quotient.sound (rel.assoc f g h)) }\n\ndef of_syntax {X Y : prod_coprod C} : syntax X Y \u2192 (X \u27f6 Y) := quotient.mk\n\ndef of_cat : C \u2964 prod_coprod C :=\n{ obj := \u03bb X, of_cat' X,\n  map := \u03bb X Y f, of_syntax (syntax.of_cat f),\n  map_id' := \u03bb X, quotient.sound rel.of_cat_id,\n  map_comp' := \u03bb 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 \u27f6 Y) (g : X \u27f6 Z) : X \u27f6 (Y.prod Z) :=\nquotient.lift_on\u2082 f g (\u03bb 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) \u27f6 X :=\nof_syntax fst\n\ndef snd {X Y : prod_coprod C} : (X.prod Y) \u27f6 Y :=\nof_syntax snd\n\n@[simp] lemma prod_mk_fst_comp {X Y Z : prod_coprod C} (f : X \u27f6 Y) (g : X \u27f6 Z) :\n  prod_mk f g \u226b fst = f :=\nquotient.induction_on\u2082 f g (\u03bb 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 \u27f6 Y) (g : X \u27f6 Z) :\n  prod_mk f g \u226b snd = g :=\nquotient.induction_on\u2082 f g (\u03bb f g, quotient.sound (syntax.rel.mk_snd_comp _ _))\n\nlemma prod_mk_eta {X Y Z : prod_coprod C} (f : X \u27f6 Y.prod Z) :\n  prod_mk (f \u226b fst) (f \u226b snd) = f :=\nquotient.induction_on f (\u03bb f, quotient.sound (syntax.rel.prod_eta _))\n\n@[ext] lemma prod_hom_ext {X Y Z : prod_coprod C} {f g : X \u27f6 Y.prod Z}\n  (h\u2081 : f \u226b fst = g \u226b fst) (h\u2082 : f \u226b snd = g \u226b snd) : f = g :=\nbegin\n  conv_lhs { rw \u2190 prod_mk_eta f },\n  rw [h\u2081, h\u2082, prod_mk_eta]\nend\n\ndef coprod_mk {X Y Z : prod_coprod C} (f : X \u27f6 Z) (g : Y \u27f6 Z) : (X.coprod Y) \u27f6 Z :=\nquotient.lift_on\u2082 f g (\u03bb 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 \u27f6 (X.coprod Y) :=\nof_syntax inl\n\ndef inr {X Y : prod_coprod C} : Y \u27f6 (X.coprod Y) :=\nof_syntax inr\n\n@[elab_as_eliminator] lemma hom_induction\n  {motive : \u03a0 (X Y : prod_coprod C), (X \u27f6 Y) \u2192 Prop}\n  {X Y : prod_coprod C} (f : X \u27f6 Y)\n  (h\u2081 : \u03a0 {X Y : C} (f : X \u27f6 Y), motive _ _ (of_cat.map f))\n  (h\u2082 : \u03a0 {X Y Z : prod_coprod C} (f : X \u27f6 Y) (g : X \u27f6 Z),\n     motive X Y f \u2192 motive X Z g \u2192 motive _ _ (prod_mk f g))\n  (h\u2083 : \u03a0 {X Y : prod_coprod C}, motive (X.prod Y) X fst)\n  (h\u2084 : \u03a0 {X Y : prod_coprod C}, motive (X.prod Y) Y snd)\n  (h\u2085 : \u03a0 {X Y Z : prod_coprod C} (f : X \u27f6 Z) (g : Y \u27f6 Z),\n     motive X Z f \u2192 motive Y Z g \u2192 motive _ _ (coprod_mk f g))\n  (h\u2086 : \u03a0 {X Y : prod_coprod C}, motive X (X.coprod Y) inl)\n  (h\u2087 : \u03a0 {X Y : prod_coprod C}, motive Y (X.coprod Y) inr)\n  (h\u2088 : \u03a0 (X : prod_coprod C), motive X X (\ud835\udfd9 X))\n  (h\u2089 : \u03a0 {X Y Z : prod_coprod C} (f : X \u27f6 Y) (g : Y \u27f6 Z),\n     motive X Y f \u2192 motive Y Z g \u2192 motive X Z (f \u226b 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\u2082 (of_syntax f) (of_syntax g) },\n    { intros _ _ _ f g,\n      exact h\u2085 (of_syntax f) (of_syntax g) },\n    { intros _ _ _ f g,\n      exact h\u2089 (of_syntax f) (of_syntax g) }\n  end\n\n@[simp] lemma inl_comp_coprod_mk {X Y Z : prod_coprod C} (f : X \u27f6 Z) (g : Y \u27f6 Z) :\n  inl \u226b coprod_mk f g = f :=\nquotient.induction_on\u2082 f g (\u03bb 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 \u27f6 Z) (g : Y \u27f6 Z) :\n  inr \u226b coprod_mk f g = g :=\nquotient.induction_on\u2082 f g (\u03bb f g, quotient.sound (syntax.rel.inr_comp_mk _ _))\n\nlemma coprod_mk_eta {X Y Z : prod_coprod C} (f : X.coprod Y \u27f6 Z) :\n  coprod_mk (inl \u226b f) (inr \u226b f) = f :=\nquotient.induction_on f (\u03bb 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 \u27f6 Z}\n  (h\u2081 : inl \u226b f = inl \u226b g ) (h\u2082 : inr \u226b f = inr \u226b g) : f = g :=\nbegin\n  conv_lhs { rw \u2190 coprod_mk_eta f },\n  rw [h\u2081, h\u2082, coprod_mk_eta]\nend\n\n-- def wf_rel (x y : (prod_coprod C \u00d7 prod_coprod C) \u2295\n--   (prod_coprod C \u00d7 prod_coprod C \u00d7 prod_coprod C)) :Prop :=\n-- sum.lex (measure sizeof) (measure sizeof) x y\n\n\n\n-- @[simp] def sizeof2 : prod_coprod C \u2192 \u2115\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 \u00d7 prod_coprod C) \u2295\n--   (prod_coprod C \u00d7 prod_coprod C \u00d7 prod_coprod C)) :=\n-- \u27e8_, measure_wf (\u03bb x, sum.cases_on x\n--     (\u03bb x, sizeof x.1 + sizeof x.2)\n--     (\u03bb x, sizeof x.1 + sizeof x.2.1 + sizeof x.2.2))\u27e9\n\n-- @[simp] lemma hwf_rel_wf_simp :@has_well_founded.r _ (@hwf_rel_wf C _) =\n--   measure (\u03bb x, sum.cases_on x\n--     (\u03bb x, sizeof x.1 + sizeof x.2)\n--     (\u03bb 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 \u27f6 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) \u27f6 Z` that cannot be written\n    `fst \u226b f` or `snd \u226b f` for any `f`\n-/\n\n-- @[simp] def norm_type :\n--   ((prod_coprod C \u00d7 prod_coprod C) \u2295\n--   (prod_coprod C \u00d7 prod_coprod C \u00d7 prod_coprod C)) \u2192 Type\n-- | (sum.inl (coprod X Y, Z)) := norm_type (sum.inl (X, Z)) \u00d7 norm_type (sum.inl (Y, Z))\n-- | (sum.inl (prod X Y, Z)) :=\n--   norm_type (sum.inl (X, Z)) \u2295 norm_type (sum.inl (Y, Z))\n--   \u2295 norm_type (sum.inr (X, Y, Z))\n-- | (sum.inl (of_cat' X, of_cat' Y)) := X \u27f6 Y\n-- | (sum.inl (of_cat' X, prod Y Z)) :=\n--   norm_type (sum.inl (of_cat' X, Y)) \u00d7 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)) \u2295 norm_type (sum.inl (of_cat' X, Z))\n-- | (sum.inr (W, X, coprod Y Z)) :=\n--   norm_type (sum.inr (W, X, Y)) \u2295  -- (f : prod W X \u27f6 Y) \u226b inl\n--   norm_type (sum.inr (W, X, Z))  -- (f : prod W X \u27f6 Z) \u226b inr\n-- | (sum.inr (W, X, prod Y Z)) :=\n--   (norm_type (sum.inr (W, X, Y)) \u00d7 norm_type (sum.inr (W, X, Z))) \u2295 -- prod_mk _ _\n--   (norm_type (sum.inl (W, Y)) \u00d7 norm_type (sum.inl (X, Z))) \u2295\n--   (norm_type (sum.inl (W, Z)) \u00d7 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 := \u03bb _ _, `[exact hwf_rel_wf] }\n\ninductive norm_hom :\n  ((prod_coprod C \u00d7 prod_coprod C) \u2295\n  (prod_coprod C \u00d7 prod_coprod C \u00d7 prod_coprod C)) \u2192 Type\n| coprod_mk {X Y Z : prod_coprod C} :\n  norm_hom (sum.inl (X, Z)) \u2192 norm_hom (sum.inl (Y, Z)) \u2192\n  norm_hom (sum.inl (coprod X Y, Z))\n| fst_comp {X Y Z : prod_coprod C} : norm_hom (sum.inl (X, Z)) \u2192\n  norm_hom (sum.inl (prod X Y, Z))\n| snd_comp {X Y Z : prod_coprod C} : norm_hom (sum.inl (Y, Z)) \u2192\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)) \u2192\n  norm_hom (sum.inl (prod X Y, Z))\n| of_cat {X Y : C} : (X \u27f6 Y) \u2192 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)) \u2192\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)) \u2192\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)) \u2192\n  norm_hom (sum.inl (of_cat' X, Z)) \u2192 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)) \u2192\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)) \u2192\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)) \u2192\n  norm_hom (sum.inr (W, X, Z)) \u2192 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)) \u2192\n  norm_hom (sum.inl (W, Z)) \u2192 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)) \u2192\n  norm_hom (sum.inl (X, Z)) \u2192 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)) \u2192\n  norm_hom (sum.inr (W, X, Z)) \u2192 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)) \u2192\n  norm_hom (sum.inr (W, X, Z)) \u2192 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)) \u2192 norm_hom (sum.inl (X, Z)) \u2192\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)) \u2192 norm_hom (sum.inl (W, Z)) \u2192\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 : \u03a0 {X Y Z : prod_coprod C}, norm_hom (sum.inl (X, Y)) \u2192\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 : \u03a0 {X Y Z : prod_coprod C}, norm_hom (sum.inl (X, Z)) \u2192\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 : \u03a0 (X : prod_coprod C), norm_hom (sum.inl (X, X))\n| (of_cat' X) := norm_hom.of_cat (\ud835\udfd9 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 : \u03a0 {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 : \u03a0 (X Y : prod_coprod C), Type\n| of_cat {X Y : C} (f : X \u27f6 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 : \u03a0 {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 : \u03a0 {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 \u226b 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 : \u03a0 {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 : \u03a0 {X Y : prod_coprod C} (f : norm_hom2 X Y), (X \u27f6 Y)\n| _ _ (norm_hom2.of_cat f) := of_cat.map f\n| _ _ (norm_hom2.comp_inl f) := norm_hom2.to_hom f \u226b inl\n| _ _ (norm_hom2.comp_inr f) := norm_hom2.to_hom f \u226b inr\n| _ _ (norm_hom2.fst_comp f) := fst \u226b norm_hom2.to_hom f\n| _ _ (norm_hom2.snd_comp f) := snd \u226b 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 : \u03a0 {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 : \u03a0 {X Y : prod_coprod C} {f g : syntax X Y}, rel f g \u2192 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 : \u03a0 {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 \u226b 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    \u2190 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 : \u03a0 {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 \u226b 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    \u2190 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 : \u03a0 {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 : \u03a0 {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 \u226b g.to_hom\n| _ _ _ (norm_hom2.coprod_mk f g) h :=\n  by ext; simp [to_hom_comp f, to_hom_comp g, \u2190 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, \u2190 category.assoc]\n| _ _ _  (norm_hom2.prod_mk f g) (norm_hom2.snd_comp h) :=\n  by simp [to_hom_comp _ h, \u2190 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 \u226b 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 \u2964 (C\u1d52\u1d56 \u2964 Type) :=\n{ obj := to_presheaf_obj,\n  map := \u03bb X Y f, quotient.lift_on f (to_presheaf_syntax) to_presheaf_syntax_rel,\n  map_id' := \u03bb _, rfl,\n  map_comp' := \u03bb _ _ _ f g, quotient.induction_on\u2082 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 \u27f6 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 \u27f6 Y) (g : X \u27f6 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\u2082 f g _,\n  intros, refl\nend\n\n@[simp] lemma to_presheaf_coprod_mk {X Y Z : prod_coprod C}\n  (f : X \u27f6 Z) (g : Y \u27f6 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\u2082 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 \u27f6 X) = Pprod_fst := rfl\n\n@[simp] lemma to_presheaf_snd {X Y : prod_coprod C} :\n  to_presheaf.map (snd : X.prod Y \u27f6 Y) = Pprod_snd := rfl\n\n@[simp] lemma to_presheaf_inl {X Y : prod_coprod C} :\n  to_presheaf.map (inl : X \u27f6 X.coprod Y) = Pcoprod_inl := rfl\n\n@[simp] lemma to_presheaf_inr {X Y : prod_coprod C} :\n  to_presheaf.map (inr : Y \u27f6 X.coprod Y) = Pcoprod_inr := rfl\n\nend syntax\n\ndef transformation_syntax : \u03a0 {X : C} {Y : prod_coprod C}, (to_presheaf.obj Y).obj (opposite.op X) \u2192\n  syntax (of_cat' X) Y\n| X (of_cat' Y) := \u03bb f, syntax.of_cat f\n| X (prod Y Z) := \u03bb f, syntax.prod_mk (transformation_syntax f.1) (transformation_syntax f.2)\n| X (coprod Y Z) := \u03bb f, f.elim\n  (\u03bb f, (transformation_syntax f).comp syntax.inl)\n  (\u03bb f, (transformation_syntax f).comp syntax.inr)\n\n@[simp] def transformation : \u03a0 {X : C} {Y : prod_coprod C},\n  (to_presheaf.obj Y).obj (opposite.op X) \u2192\n  ((of_cat' X) \u27f6 Y)\n| X (of_cat' Y) := \u03bb f, of_cat.map f\n| X (prod Y Z) := \u03bb f, prod_mk (transformation f.1) (transformation f.2)\n| X (coprod Y Z) := \u03bb f, f.elim\n  (\u03bb f, (transformation f) \u226b inl)\n  (\u03bb f, (transformation f) \u226b 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 : \u03a0 {X Y : prod_coprod C}\n  (f : X \u27f6 Y) \u2983Z : C\u2984 (z : (to_presheaf.obj X).obj (op Z)),\n  transformation ((to_presheaf.map f).app (op Z) z) =\n  transformation z \u226b 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) \u27f6 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) \u27f6 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 := \u03bb X Y f, ((to_presheaf.map f).app (op X) (\ud835\udfd9 X)),\n  witness' := \u03bb X Y f, begin\n    have := transformation_left_naturality f (\ud835\udfd9 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' := \u03bb 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) \u27f6 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) \u27f6 Y) : of_syntax (normalize f) = f :=\nby rw [normalize, \u2190 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": "/-\nCopyright (c) 2020 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Lean.Util.ForEachExpr\nimport Lean.Meta.ForEachExpr\nimport Lean.Meta.RecursorInfo\nimport Lean.Meta.Match.Match\nimport Lean.Meta.Transform\nimport Lean.Elab.PreDefinition.Basic\nnamespace Lean.Elab\nnamespace Structural\nopen Meta\n\nprivate def getFixedPrefix (declName : Name) (xs : Array Expr) (value : Expr) : MetaM Nat := do\n  let numFixedRef \u2190 IO.mkRef xs.size\n  forEachExpr' value fun e => do\n    if e.isAppOf declName then\n      let args := e.getAppArgs\n      numFixedRef.modify fun numFixed => if args.size < numFixed then args.size else numFixed\n      for arg in args, x in xs do\n        /- We should not use structural equality here. For example, given the definition\n           ```\n           def V.map {\u03b1 \u03b2} f x x_1 :=\n             @V.map.match_1.{1} \u03b1 (fun x x_2 => V \u03b2 x) x x_1\n               (fun x x_2 => @V.mk\u2081 \u03b2 x (f Bool.true x_2))\n               (fun e => @V.mk\u2082 \u03b2 (V.map (fun b => \u03b1 b) (fun b => \u03b2 b) f Bool.false e))\n           ```\n           The first three arguments at `V.map (fun b => \u03b1 b) (fun b => \u03b2 b) f Bool.false e` are \"fixed\"\n           modulo definitional equality.\n        -/\n        if !(\u2190 withReducible <| isDefEq arg x) then\n          -- We continue searching if e's arguments are not a prefix of `xs`\n          return true\n      return false\n    else\n      return true\n  numFixedRef.get\n\nstructure RecArgInfo where\n  /- `fixedParams ++ ys` are the arguments of the function we are trying to justify termination using structural recursion. -/\n  fixedParams : Array Expr\n  ys          : Array Expr  -- recursion arguments\n  pos         : Nat         -- position in `ys` of the argument we are recursing on\n  indicesPos  : Array Nat   -- position in `ys` of the inductive datatype indices we are recursing on\n  indName     : Name        -- inductive datatype name of the argument we are recursing on\n  indLevels   : List Level  -- inductice datatype universe levels of the argument we are recursing on\n  indParams   : Array Expr  -- inductive datatype parameters of the argument we are recursing on\n  indIndices  : Array Expr  -- inductive datatype indices of the argument we are recursing on, it is equal to `indicesPos.map fun i => ys.get! i`\n  reflexive   : Bool        -- true if we are recursing over a reflexive inductive datatype\n\nprivate def getIndexMinPos (xs : Array Expr) (indices : Array Expr) : Nat := do\n  let mut minPos := xs.size\n  for index in indices do\n    match xs.indexOf? index with\n    | some pos => if pos.val < minPos then minPos := pos.val\n    | _        => pure ()\n  return minPos\n\n-- Indices can only depend on other indices\nprivate def hasBadIndexDep? (ys : Array Expr) (indices : Array Expr) : MetaM (Option (Expr \u00d7 Expr)) := do\n  for index in indices do\n    let indexType \u2190 inferType index\n    for y in ys do\n      if !indices.contains y && (\u2190 dependsOn indexType y.fvarId!) then\n        return some (index, y)\n  return none\n\n-- Inductive datatype parameters cannot depend on ys\nprivate def hasBadParamDep? (ys : Array Expr) (indParams : Array Expr) : MetaM (Option (Expr \u00d7 Expr)) := do\n  for p in indParams do\n    let pType \u2190 inferType p\n    for y in ys do\n      if \u2190 dependsOn pType y.fvarId! then\n        return some (p, y)\n  return none\n\nprivate def throwStructuralFailed {\u03b1} : MetaM \u03b1 :=\n  throwError \"structural recursion cannot be used\"\n\nstructure State where\n  /- When compiling structural recursion we use the `brecOn` recursor automatically built by\n     the `inductive` command. For an inductive datatype `C`, it has the form\n     `C.brecOn As motive is c F`\n     where `As` are the inductive datatype parameters, `is` are the inductive datatype indices,\n     `c : C As is`, and `F : (js) \u2192 (d : C As js) \u2192 C.below d \u2192 motive d`\n     The `C.below d` is used to eliminate recursive applications. We refine its type when we process\n     a nested dependent pattern matcher using `MatcherApp.addArg`. See `replaceRecApps` for additional details.\n     We store the names of the matcher where we used `MatcherApp.addArg` at `matcherBelowDep`.\n     We use this information to generate the auxiliary `_sunfold` definition needed by the smart unfolding\n     technique used at WHNF. -/\n  matcherBelowDep : NameSet := {}\n\nabbrev M := StateRefT State MetaM\n\ninstance {\u03b1} : Inhabited (M \u03b1) where\n  default := throwError \"failed\"\n\nprivate def run {\u03b1} (x : M \u03b1) (s : State := {}) : MetaM (\u03b1 \u00d7 State) :=\n  StateRefT'.run x s\n\nprivate def orelse' {\u03b1} (x y : M \u03b1) : M \u03b1 := do\n  let saveState \u2190 get\n  orelseMergeErrors x (do set saveState; y)\n\nprivate partial def findRecArg {\u03b1} (numFixed : Nat) (xs : Array Expr) (k : RecArgInfo \u2192 M \u03b1) : M \u03b1 :=\n  let rec loop (i : Nat) : M \u03b1 := do\n    if h : i < xs.size then\n      let x := xs.get \u27e8i, h\u27e9\n      let localDecl \u2190 getFVarLocalDecl x\n      if localDecl.isLet then\n        throwStructuralFailed\n      else\n        let xType \u2190 whnfD localDecl.type\n        matchConstInduct xType.getAppFn (fun _ => loop (i+1)) fun indInfo us => do\n        if !(\u2190 hasConst (mkBRecOnName indInfo.name)) then\n          loop (i+1)\n        else if indInfo.isReflexive && !(\u2190 hasConst (mkBInductionOnName indInfo.name)) then\n          loop (i+1)\n        else\n          let indArgs    := xType.getAppArgs\n          let indParams  := indArgs.extract 0 indInfo.numParams\n          let indIndices := indArgs.extract indInfo.numParams indArgs.size\n          if !indIndices.all Expr.isFVar then\n            orelse'\n              (throwError \"argument #{i+1} was not used because its type is an inductive family and indices are not variables{indentExpr xType}\")\n              (loop (i+1))\n          else if !indIndices.allDiff then\n            orelse'\n              (throwError \"argument #{i+1} was not used because its type is an inductive family and indices are not pairwise distinct{indentExpr xType}\")\n              (loop (i+1))\n          else\n            let indexMinPos := getIndexMinPos xs indIndices\n            let numFixed    := if indexMinPos < numFixed then indexMinPos else numFixed\n            let fixedParams := xs.extract 0 numFixed\n            let ys          := xs.extract numFixed xs.size\n            match \u2190 hasBadIndexDep? ys indIndices with\n            | some (index, y) =>\n              orelse'\n                (throwError \"argument #{i+1} was not used because its type is an inductive family{indentExpr xType}\\nand index{indentExpr index}\\ndepends on the non index{indentExpr y}\")\n                (loop (i+1))\n            | none =>\n              match \u2190 hasBadParamDep? ys indParams with\n              | some (indParam, y) =>\n                orelse'\n                  (throwError \"argument #{i+1} was not used because its type is an inductive datatype{indentExpr xType}\\nand parameter{indentExpr indParam}\\ndepends on{indentExpr y}\")\n                  (loop (i+1))\n              | none =>\n                let indicesPos := indIndices.map fun index => match ys.indexOf? index with | some i => i.val | none => unreachable!\n                orelse'\n                  (mapError\n                    (k { fixedParams := fixedParams\n                         ys          := ys\n                         pos         := i - fixedParams.size\n                         indicesPos  := indicesPos\n                         indName     := indInfo.name\n                         indLevels   := us\n                         indParams   := indParams\n                         indIndices  := indIndices\n                         reflexive := indInfo.isReflexive })\n                    (fun msg => m!\"argument #{i+1} was not used for structural recursion{indentD msg}\"))\n                  (loop (i+1))\n    else\n      throwStructuralFailed\n  loop numFixed\n\nprivate def containsRecFn (recFnName : Name) (e : Expr) : Bool :=\n  (e.find? fun e => e.isConstOf recFnName).isSome\n\nprivate def ensureNoRecFn (recFnName : Name) (e : Expr) : MetaM Expr := do\n  if containsRecFn recFnName e then\n    Meta.forEachExpr e fun e => do\n      if e.isAppOf recFnName then\n        throwError \"unexpected occurrence of recursive application{indentExpr e}\"\n    pure e\n  else\n    pure e\n\nprivate def throwToBelowFailed {\u03b1} : MetaM \u03b1 :=\n  throwError \"toBelow failed\"\n\n/- See toBelow -/\nprivate partial def toBelowAux (C : Expr) : Expr \u2192 Expr \u2192 Expr \u2192 MetaM Expr\n  | belowDict, arg, F => do\n    let belowDict \u2190 whnf belowDict\n    trace[Elab.definition.structural] \"belowDict: {belowDict}, arg: {arg}\"\n    match belowDict with\n    | Expr.app (Expr.app (Expr.const `PProd _ _) d1 _) d2 _ =>\n      (do toBelowAux C d1 arg (\u2190 mkAppM `PProd.fst #[F]))\n      <|>\n      (do toBelowAux C d2 arg (\u2190 mkAppM `PProd.snd #[F]))\n    | Expr.app (Expr.app (Expr.const `And _ _) d1 _) d2 _ =>\n      (do toBelowAux C d1 arg (\u2190 mkAppM `And.left #[F]))\n      <|>\n      (do toBelowAux C d2 arg (\u2190 mkAppM `And.right #[F]))\n    | _ => forallTelescopeReducing belowDict fun xs belowDict => do\n      let argArgs := arg.getAppArgs\n      unless argArgs.size >= xs.size do throwToBelowFailed\n      let n := argArgs.size\n      let argTailArgs := argArgs.extract (n - xs.size) n\n      let belowDict := belowDict.replaceFVars xs argTailArgs\n      match belowDict with\n      | Expr.app belowDictFun belowDictArg _ =>\n        unless belowDictFun.getAppFn == C do throwToBelowFailed\n        unless \u2190 isDefEq belowDictArg arg do throwToBelowFailed\n        pure (mkAppN F argTailArgs)\n      | _ => throwToBelowFailed\n\n/- See toBelow -/\nprivate def withBelowDict {\u03b1} (below : Expr) (numIndParams : Nat) (k : Expr \u2192 Expr \u2192 MetaM \u03b1) : MetaM \u03b1 := do\n  let belowType \u2190 inferType below\n  trace[Elab.definition.structural] \"belowType: {belowType}\"\n  belowType.withApp fun f args => do\n    let motivePos := numIndParams + 1\n    unless motivePos < args.size do throwError \"unexpected 'below' type{indentExpr belowType}\"\n    let pre := mkAppN f (args.extract 0 numIndParams)\n    let preType \u2190 inferType pre\n    forallBoundedTelescope preType (some 1) fun x _ => do\n      let motiveType \u2190 inferType x[0]\n      let C \u2190 mkFreshUserName `C\n      withLocalDeclD C motiveType fun C =>\n        let belowDict := mkApp pre C\n        let belowDict := mkAppN belowDict (args.extract (numIndParams + 1) args.size)\n        k C belowDict\n\n/-\n  `below` is a free variable with type of the form `I.below indParams motive indices major`,\n  where `I` is the name of an inductive datatype.\n\n  For example, when trying to show that the following function terminates using structural recursion\n  ```lean\n  def addAdjacent : List Nat \u2192 List Nat\n  | []       => []\n  | [a]      => [a]\n  | a::b::as => (a+b) :: addAdjacent as\n  ```\n  when we are visiting `addAdjacent as` at `replaceRecApps`, `below` has type\n  `@List.below Nat (fun (x : List Nat) => List Nat) (a::b::as)`\n  The motive `fun (x : List Nat) => List Nat` depends on the actual function we are trying to compute.\n  So, we first replace it with a fresh variable `C` at `withBelowDict`.\n  Recall that `brecOn` implements course-of-values recursion, and `below` can be viewed as a dictionary\n  of the \"previous values\".\n  We search this dictionary using the auxiliary function `toBelowAux`.\n  The dictionary is built using the `PProd` (`And` for inductive predicates).\n  We keep searching it until we find `C recArg`, where `C` is the auxiliary fresh variable created at `withBelowDict`.  -/\nprivate partial def toBelow (below : Expr) (numIndParams : Nat) (recArg : Expr) : MetaM Expr := do\n  withBelowDict below numIndParams fun C belowDict =>\n    toBelowAux C belowDict recArg below\n\n/--\n  Return true iff `e` contains an application `recFnName .. t ..` where the term `t` is\n  the argument we are trying to recurse on, and it contains loose bound variables.\n\n  We use this test to decide whether we should process a matcher-application as a regular\n  applicaton or not. That is, whether we should push the `below` argument should be affected by the matcher or not.\n  If `e` does not contain an application of the form `recFnName .. t ..`, then we know\n  the recursion doesn't depend on any pattern variable in this matcher.\n-/\nprivate def recArgHasLooseBVarsAt (recFnName : Name) (recArgInfo : RecArgInfo) (e : Expr) : Bool :=\n  let recArgPos := recArgInfo.fixedParams.size + recArgInfo.pos\n  let app?   := e.find? fun e =>\n     e.isAppOf recFnName && e.getAppNumArgs > recArgPos && (e.getArg! recArgPos).hasLooseBVars\n  app?.isSome\n\nprivate partial def replaceRecApps (recFnName : Name) (recArgInfo : RecArgInfo) (below : Expr) (e : Expr) : M Expr :=\n  let rec loop (below : Expr) (e : Expr) : M Expr := do\n    match e with\n    | Expr.lam n d b c =>\n      withLocalDecl n c.binderInfo (\u2190 loop below d) fun x => do\n        mkLambdaFVars #[x] (\u2190 loop below (b.instantiate1 x))\n    | Expr.forallE n d b c =>\n      withLocalDecl n c.binderInfo (\u2190 loop below d) fun x => do\n        mkForallFVars #[x] (\u2190 loop below (b.instantiate1 x))\n    | Expr.letE n type val body _ =>\n      withLetDecl n (\u2190 loop below type) (\u2190 loop below val) fun x => do\n        mkLetFVars #[x] (\u2190 loop below (body.instantiate1 x))\n    | Expr.mdata d e _   => return mkMData d (\u2190 loop below e)\n    | Expr.proj n i e _  => return mkProj n i (\u2190 loop below e)\n    | Expr.app _ _ _ =>\n      let processApp (e : Expr) : M Expr :=\n        e.withApp fun f args => do\n          if f.isConstOf recFnName then\n            let numFixed  := recArgInfo.fixedParams.size\n            let recArgPos := recArgInfo.fixedParams.size + recArgInfo.pos\n            if recArgPos >= args.size then\n              throwError \"insufficient number of parameters at recursive application {indentExpr e}\"\n            let recArg := args[recArgPos]\n            -- For reflexive type, we may have nested recursive applications in recArg\n            let recArg \u2190 loop below recArg\n            let f \u2190 try toBelow below recArgInfo.indParams.size recArg catch  _ => throwError \"failed to eliminate recursive application{indentExpr e}\"\n            -- Recall that the fixed parameters are not in the scope of the `brecOn`. So, we skip them.\n            let argsNonFixed := args.extract numFixed args.size\n            -- The function `f` does not explicitly take `recArg` and its indices as arguments. So, we skip them too.\n            let mut fArgs := #[]\n            for i in [:argsNonFixed.size] do\n              if recArgInfo.pos != i && !recArgInfo.indicesPos.contains i then\n                let arg := argsNonFixed[i]\n                let arg \u2190 replaceRecApps recFnName recArgInfo below arg\n                fArgs := fArgs.push arg\n            return mkAppN f fArgs\n          else\n            return mkAppN (\u2190 loop below f) (\u2190 args.mapM (loop below))\n      let matcherApp? \u2190 matchMatcherApp? e\n      match matcherApp? with\n      | some matcherApp =>\n        if !recArgHasLooseBVarsAt recFnName recArgInfo e then\n          processApp e\n        else\n          /- Here is an example we currently not handle\n             ```\n             def g (xs : List Nat) : Nat :=\n             match xs with\n             | [] => 0\n             | y::ys =>\n               match ys with\n               | []       => 1\n               | _::_::zs => g zs + 1\n               | zs       => g ys + 2\n             ```\n             We are matching on `ys`, but still using `ys` in the third alternative.\n             If we push the `below` argument over the dependent match it will be able to eliminate recursive call using `zs`.\n             To make it work, users have to write the third alternative as `| zs => g zs + 2`\n             If this is too annoying in practice, we may replace `ys` with the matching term, but\n             this may generate weird error messages, when it doesn't work. -/\n          trace[Elab.definition.structural] \"below before matcherApp.addArg: {below} : {\u2190 inferType below}\"\n          let matcherApp \u2190 mapError (matcherApp.addArg below) (fun msg => \"failed to add `below` argument to 'matcher' application\" ++ indentD msg)\n          modify fun s => { s with matcherBelowDep := s.matcherBelowDep.insert matcherApp.matcherName }\n          let altsNew \u2190 (Array.zip matcherApp.alts matcherApp.altNumParams).mapM fun (alt, numParams) =>\n            lambdaTelescope alt fun xs altBody => do\n              trace[Elab.definition.structural] \"altNumParams: {numParams}, xs: {xs}\"\n              unless xs.size >= numParams do\n                throwError \"unexpected matcher application alternative{indentExpr alt}\\nat application{indentExpr e}\"\n              let belowForAlt := xs[numParams - 1]\n              mkLambdaFVars xs (\u2190 loop belowForAlt altBody)\n          pure { matcherApp with alts := altsNew }.toExpr\n      | none => processApp e\n    | e => ensureNoRecFn recFnName e\n  loop below e\n\nprivate def mkBRecOn (recFnName : Name) (recArgInfo : RecArgInfo) (value : Expr) : M Expr := do\n  let type  := (\u2190 inferType value).headBeta\n  let major := recArgInfo.ys[recArgInfo.pos]\n  let otherArgs := recArgInfo.ys.filter fun y => y != major && !recArgInfo.indIndices.contains y\n  trace[Elab.definition.structural] \"fixedParams: {recArgInfo.fixedParams}, otherArgs: {otherArgs}\"\n  let motive \u2190 mkForallFVars otherArgs type\n  let mut brecOnUniv \u2190 getLevel motive\n  trace[Elab.definition.structural] \"brecOn univ: {brecOnUniv}\"\n  let useBInductionOn := recArgInfo.reflexive && brecOnUniv == levelZero\n  if recArgInfo.reflexive && brecOnUniv != levelZero then\n    brecOnUniv \u2190 decLevel brecOnUniv\n  let motive \u2190 mkLambdaFVars (recArgInfo.indIndices.push major) motive\n  trace[Elab.definition.structural] \"brecOn motive: {motive}\"\n  let brecOn :=\n    if useBInductionOn then\n      Lean.mkConst (mkBInductionOnName recArgInfo.indName) recArgInfo.indLevels\n    else\n      Lean.mkConst (mkBRecOnName recArgInfo.indName) (brecOnUniv :: recArgInfo.indLevels)\n  let brecOn := mkAppN brecOn recArgInfo.indParams\n  let brecOn := mkApp brecOn motive\n  let brecOn := mkAppN brecOn recArgInfo.indIndices\n  let brecOn := mkApp brecOn major\n  check brecOn\n  let brecOnType \u2190 inferType brecOn\n  trace[Elab.definition.structural] \"brecOn     {brecOn}\"\n  trace[Elab.definition.structural] \"brecOnType {brecOnType}\"\n  forallBoundedTelescope brecOnType (some 1) fun F _ => do\n    let F := F[0]\n    let FType \u2190 inferType F\n    trace[Elab.definition.structural] \"FType: {FType}\"\n    let FType \u2190 instantiateForall FType recArgInfo.indIndices\n    let FType \u2190 instantiateForall FType #[major]\n    forallBoundedTelescope FType (some 1) fun below _ => do\n      let below := below[0]\n      let valueNew     \u2190 replaceRecApps recFnName recArgInfo below value\n      let Farg         \u2190 mkLambdaFVars (recArgInfo.indIndices ++ #[major, below] ++ otherArgs) valueNew\n      let brecOn       := mkApp brecOn Farg\n      pure $ mkAppN brecOn otherArgs\n\nprivate def shouldBetaReduce (e : Expr) (recFnName : Name) : Bool :=\n  if e.isHeadBetaTarget then\n    e.getAppFn.find? (\u00b7.isConstOf recFnName) |>.isSome\n  else\n    false\n\n/--\n  Beta reduce terms where the recursive function occurs in the lambda term.\n  This is useful to improve the effectiveness of `elimRecursion`.\n  Example:\n  ```\n  def f : Nat \u2192 Nat\n    | 0 => 1\n    | i+1 => (fun x => f x) i\n  ```\n-/\nprivate def preprocess (e : Expr) (recFnName : Name) : CoreM Expr :=\n  Core.transform e\n   fun e => return TransformStep.visit <|\n     if shouldBetaReduce e recFnName then\n       e.headBeta\n     else\n       e\n\nprivate def elimRecursion (preDef : PreDefinition) : M PreDefinition :=\n  withoutModifyingEnv do lambdaTelescope preDef.value fun xs value => do\n    addAsAxiom preDef\n    let value \u2190 preprocess value preDef.declName\n    trace[Elab.definition.structural] \"{preDef.declName} {xs} :=\\n{value}\"\n    let numFixed \u2190 getFixedPrefix preDef.declName xs value\n    trace[Elab.definition.structural] \"numFixed: {numFixed}\"\n    findRecArg numFixed xs fun recArgInfo => do\n      -- when (recArgInfo.indName == `Nat) throwStructuralFailed -- HACK to skip Nat argument\n      let valueNew \u2190 mkBRecOn preDef.declName recArgInfo value\n      let valueNew \u2190 mkLambdaFVars xs valueNew\n      trace[Elab.definition.structural] \"result: {valueNew}\"\n      -- Recursive applications may still occur in expressions that were not visited by replaceRecApps (e.g., in types)\n      let valueNew \u2190 ensureNoRecFn preDef.declName valueNew\n      pure { preDef with value := valueNew }\n\npartial def addSmartUnfoldingDefAux (preDef : PreDefinition) (matcherBelowDep : NameSet) : MetaM PreDefinition := do\n  let recFnName := preDef.declName\n  let isMarkedMatcherName (n : Name) : Bool    := matcherBelowDep.contains n\n  let isMarkedMatcherConst (e : Expr) : Bool   := e.isConst && isMarkedMatcherName e.constName!\n  let isMarkedMatcherApp (e : Expr) : Bool     := isMarkedMatcherConst e.getAppFn\n  let containsMarkedMatcher (e : Expr) : Bool := e.find? isMarkedMatcherConst |>.isSome\n  let rec visit (e : Expr) : MetaM Expr := do\n    match e with\n    | Expr.lam ..     => lambdaTelescope e fun xs b => do mkLambdaFVars xs (\u2190 visit b)\n    | Expr.forallE .. => forallTelescope e fun xs b => do mkForallFVars xs (\u2190 visit b)\n    | Expr.letE n type val body _ =>\n      withLetDecl n type (\u2190 visit val) fun x => do\n        mkLetFVars #[x] (\u2190 visit (body.instantiate1 x))\n    | Expr.mdata d b _   => return mkMData d (\u2190 visit b)\n    | Expr.proj n i s _  => return mkProj n i (\u2190 visit s)\n    | Expr.app .. =>\n      let processApp (e : Expr) : MetaM Expr :=\n        e.withApp fun f args => do\n          return mkAppN (\u2190 visit f) (\u2190 args.mapM visit)\n      match isMarkedMatcherApp e, (\u2190 matchMatcherApp? e) with\n      | true, some matcherApp =>\n        let altsNew \u2190 (Array.zip matcherApp.alts matcherApp.altNumParams).mapM fun (alt, numParams) =>\n          lambdaTelescope alt fun xs altBody => do\n            unless xs.size >= numParams do\n              throwError \"unexpected matcher application alternative{indentExpr alt}\\nat application{indentExpr e}\"\n            if containsMarkedMatcher altBody then\n              -- continue\n              mkLambdaFVars xs (\u2190 visit altBody)\n            else\n              -- add idRhs marker\n              let altBody \u2190 mkLambdaFVars xs[numParams:xs.size] altBody\n              let altBody \u2190 mkIdRhs altBody\n              mkLambdaFVars xs[0:numParams] altBody\n        pure { matcherApp with alts := altsNew }.toExpr\n      | _, _ => processApp e\n    | _ => pure e\n  return { preDef with\n    declName  := mkSmartUnfoldingNameFor preDef.declName,\n    value     := (\u2190 visit preDef.value),\n    modifiers := {}\n  }\n\npartial def addSmartUnfoldingDef (preDef : PreDefinition) (state : State) : TermElabM Unit := do\n  if (\u2190 isProp preDef.type) then\n    return ()\n  else\n    let preDefSUnfold \u2190 addSmartUnfoldingDefAux preDef state.matcherBelowDep\n    addNonRec preDefSUnfold\n\ndef structuralRecursion (preDefs : Array PreDefinition) : TermElabM Unit :=\n  if preDefs.size != 1 then\n    throwError \"structural recursion does not handle mutually recursive functions\"\n  else do\n    let (preDefNonRec, state) \u2190 run $ elimRecursion preDefs[0]\n    mapError (addNonRec preDefNonRec) (fun msg => m!\"structural recursion failed, produced type incorrect term{indentD msg}\")\n    addAndCompilePartialRec preDefs\n    addSmartUnfoldingDef preDefs[0] state\n\nbuiltin_initialize\n  registerTraceClass `Elab.definition.structural\n\nend Structural\n\nexport Structural (structuralRecursion)\n\nend Lean.Elab\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/stage0/src/Lean/Elab/PreDefinition/Structural.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5234203638047913, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.23724648138704543}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i3 (v2)).write i1 (v2)).read i3) \u2260 (v2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test52.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.23724647464773652}}
{"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 ` \u2218 `:80 g:80 := g \u226b f\n\nnamespace homotopy_theory.cofibrations\nopen homotopy_theory.cylinder (renaming homotopic_rel \u2192 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 \u27e8jc, jw\u27e9,\nlet \u27e8\u27e8r, h, H\u27e9\u27e9 := (heq_iff_sdr_inclusion jc).mp jw in \u27e8r, h\u27e9\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 \u27e8fc, fw\u27e9,\n    \u27e8precofibration_category.pushout_is_cof po fc, pushout_is_acof po fc fw\u27e9)\n  (assume a, \u27e8I.obj a, ii @> a, p @> a, cof_ii a, heq_p, pii\u27e9)\n  (assume x, \u27e8x, \ud835\udfd9 x, \u27e8cof_id x, weq_id x\u27e9, all_objects_fibrant x\u27e9)\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\u27e8I.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 \u2294 b \u2192 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\u2080 po.map\u2081 :=\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 \u2294 b) po.ob := isomorphic_coprod_of_Is_coproduct c in\n have ii' \u2218 j.hom = ii @> b, begin\n   dsimp [j, isomorphic_coprod_of_Is_coproduct];\n   apply coprod.uniqueness; rw \u2190assoc; simp [ii]\n end,\n have ii' = ii @> b \u2218 j.inv, by rw \u2190this; 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 \u2190assoc, simp }\n end\u27e9\n\n/-\n         I a \u2192 a\n          \u2193 po \u2193\n b \u2294 b \u2192 I b \u2192 c \u2192 b\n   a\n-/\ndef canonical_relative_cylinder {a b : C} {j : a \u27f6 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\u27e8po.ob,\n (pushout_by_cof j j _).is_pushout.induced ((i 0).app b \u226b po.map\u2080) ((i 1).app b \u226b po.map\u2080)\n   begin\n     erw [\u2190assoc, \u2190assoc, (i 0).naturality, (i 1).naturality],\n     rw [assoc, assoc, po.is_pushout.commutes, \u2190assoc, \u2190assoc],\n     simp\n   end,\n po.is_pushout.induced (p.app b) j (p.naturality j),\n\n/-\n a \u2294 a \u2192 I a \u2192   a\n   \u2193  po\u2081 \u2193 po\u2082  \u2193\n b \u2294 b \u2192  \u2b1d  \u2192 b \u2294 b\n                 a\n          \u2193 po\u2083  \u2193\n         I b \u2192   c \u2192 b\n-/\n begin\n   let po\u2080 := pushout_by_cof j j hj,\n   let abb : a \u27f6 po\u2080.ob := po\u2080.map\u2080 \u2218 j,\n   let po\u2081 := pushout_by_cof _ (ii.app a) (cof_coprod hj hj),\n   let l := po\u2081.is_pushout.induced (coprod.induced po\u2080.map\u2080 po\u2080.map\u2081) (abb \u2218 p.app a)\n   begin\n     apply coprod.uniqueness,\n       { rw [\u2190assoc, coprod_of_maps_commutes\u2080, assoc, coprod.induced_commutes\u2080],\n         rw [iii\u2080_assoc, \u2190assoc, pi_components, id_comp] },\n       { rw [\u2190assoc, coprod_of_maps_commutes\u2081, assoc, coprod.induced_commutes\u2081],\n         rw [iii\u2081_assoc, \u2190assoc, pi_components, id_comp, \u2190po\u2080.is_pushout.commutes] }\n   end,\n   have po\u2081\u2082 : Is_pushout (coprod_of_maps j j) (coprod.fold a) _ _ :=\n     Is_pushout_fold po\u2080.is_pushout,\n   have po\u2082 : Is_pushout po\u2081.map\u2081 (p.app a) l abb,\n   { refine Is_pushout_of_Is_pushout_of_Is_pushout' po\u2081.is_pushout _ _,\n     { convert po\u2081\u2082,\n       { apply pii },\n       { simp } },\n     { simp } },\n   have po\u2082\u2083 : 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\u2083 : Is_pushout m l po.map\u2080 n,\n   { refine Is_pushout_of_Is_pushout_of_Is_pushout_vert' po\u2082 _ _,\n     convert po\u2082\u2083,\n     { simp, refl },\n     { have : po.map\u2080 \u2218 (i 0).app b \u2218 j = po.map\u2081,\n       { rw \u2190assoc,\n         erw (i 0).naturality,\n         rw [assoc, po.is_pushout.commutes, \u2190assoc, pi_components, id_comp] },\n       simpa using this },\n     { apply po\u2081.is_pushout.uniqueness; rw [\u2190assoc, \u2190assoc],\n       { simp only [Is_pushout.induced_commutes\u2080, Is_pushout.induced_commutes\u2081],\n         apply coprod.uniqueness; rw [\u2190assoc, \u2190assoc]; simp },\n       { simp only [assoc, Is_pushout.induced_commutes\u2080, Is_pushout.induced_commutes\u2081],\n         slice_rhs 2 3 { change (i 0).app b \u2218 ((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\u2083 this\n end,\n begin\n   have : is_weq po.map\u2080 :=\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 \u2190assoc; simp\n end\u27e9\n\nsection homotopy\nvariables {a b x : C} {j : a \u27f6 b} (hj : is_cof j) (f\u2080 f\u2081 : b \u27f6 x)\n\nlemma homotopic_rel_iff_cylinder :\n  homotopic_rel hj f\u2080 f\u2081 \u2194 homotopic_rel_cylinder j f\u2080 f\u2081 :=\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\u2080 f\u2081 H\n      with \u27e8H, Hi\u2080, Hi\u2081\u27e9,\n    dsimp [canonical_relative_cylinder, relative_cylinder.i\u2080, relative_cylinder.i\u2081] at Hi\u2080 Hi\u2081,\n    simp at Hi\u2080 Hi\u2081,\n    refine \u27e8\u27e8po.map\u2080 \u226b H, _, _\u27e9, _\u27e9,\n    { rw [\u2190Hi\u2080, \u2190assoc, \u2190assoc], refl },\n    { rw [\u2190Hi\u2081, \u2190assoc, \u2190assoc], refl },\n    { dsimp [homotopy.is_rel],\n      rw [\u2190Hi\u2080],\n      slice_rhs 2 3 { change (functor.id _).map j \u226b (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 \u226b po.map\u2080, rw po.is_pushout.commutes },\n      slice_rhs 2 3 { rw pi_components },\n      simp } },\n  { rcases H with \u27e8\u27e8H, Hi\u2080, Hi\u2081\u27e9, r\u27e9,\n    refine \u27e8canonical_relative_cylinder hj, \u27e8\u27e8_, _, _\u27e9\u27e9\u27e9,\n    refine po.is_pushout.induced H (j \u226b f\u2080) r,\n    { convert Hi\u2080 using 1,\n      dsimp [relative_cylinder.i\u2080, canonical_relative_cylinder], simp },\n    { convert Hi\u2081 using 1,\n      dsimp [relative_cylinder.i\u2081, 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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a1).write i3 (v1)).write i2 (v1)).read i3) \u2260 (v1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test21.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.2369721616383417}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a1).write i2 (v1)).write i1 (v1)).read i2) \u2260 (v1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test57.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.2369721616383417}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i2 (v1)).write i1 (v1)).read i2) \u2260 (v1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test66.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.527316523379567, "lm_q2_score": 0.4493926344647597, "lm_q1q2_score": 0.23697216163834167}}
{"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\u2081 C\u2082 : Type*} [category C\u2081] [category C\u2082]\n  {X Y : C\u2081 \u00d7 C\u2082} (eq : X = Y) : (eq_to_hom eq : X \u27f6 Y).fst = eq_to_hom (by rw eq) :=\nby { subst eq, refl, }\n\n@[simp]\nlemma prod.eq_to_hom_snd {C\u2081 C\u2082 : Type*} [category C\u2081] [category C\u2082]\n  {X Y : C\u2081 \u00d7 C\u2082} (eq : X = Y) : (eq_to_hom eq : X \u27f6 Y).snd = eq_to_hom (by rw eq) :=\nby { subst eq, refl, }\n\nlemma functor.prod.ext {C\u2081 C\u2082 E : Type*} [category C\u2081] [category C\u2082] [category E]\n  {F\u2081 F\u2082 : E \u2964 C\u2081 \u00d7 C\u2082} (h\u2081 : F\u2081 \u22d9 prod.fst _ _ = F\u2082 \u22d9 prod.fst _ _)\n  (h\u2082 : F\u2081 \u22d9 prod.snd _ _ = F\u2082 \u22d9 prod.snd _ _) : F\u2081 = F\u2082 :=\nbegin\n  refine functor.ext (\u03bb X, _) (\u03bb X Y f, _),\n  { ext,\n    exacts [functor.congr_obj h\u2081 X, functor.congr_obj h\u2082 X], },\n  { ext,\n    { simpa only [prod_comp_fst, prod.eq_to_hom_fst] using functor.congr_map_conjugate h\u2081 f, },\n    { simpa only [prod_comp_snd, prod.eq_to_hom_snd] using functor.congr_map_conjugate h\u2082 f, }, },\nend\n\nlemma functor.is_localization.of_is_equivalence {C D : Type*} [category C] [category D]\n  (F : C \u2964 D) [is_equivalence F] (W : morphism_property C)\n  (hF : W \u2286 morphism_property.isomorphisms C) : F.is_localization W :=\nbegin\n  haveI := localization.id_is_localization W hF,\n  exact functor.is_localization.of_equivalence (\ud835\udfed 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\u2081 f\u2082 : arrow C) (hf\u2082 : W f\u2082.hom) (eq : f\u2081 = f\u2082) : W f\u2081.hom := by { subst eq, exact hf\u2082, }\n\nlemma morphism_property.of_arrow_mk_eq {C : Type*} [category C] (W : morphism_property C)\n  {X\u2081 Y\u2081 X\u2082 Y\u2082 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (hf\u2082 : W f\u2082) (eq : arrow.mk f\u2081 = arrow.mk f\u2082) :\n  W f\u2081 :=\nW.of_arrow_eq (arrow.mk f\u2081) (arrow.mk f\u2082) hf\u2082 eq\n\nlemma functor.congr_map_arrow_obj_arrow_mk {C D : Type*} [category C] [category D]\n  {F\u2081 F\u2082 : C \u2964 D} (eq : F\u2081 = F\u2082) {X Y : C} (f : X \u27f6 Y) :\n  F\u2081.map_arrow.obj (arrow.mk f) = F\u2082.map_arrow.obj (arrow.mk f) := by subst eq\n\nsection\n\nvariables {C\u2081 D\u2081 C\u2082 D\u2082 : Type*} [category C\u2081] [category C\u2082] [category D\u2081] [category D\u2082]\n  (W\u2081 : morphism_property C\u2081) (W\u2082 : morphism_property C\u2082) {E : Type*} [category E]\n\n@[simps]\ndef nat_iso.prod {F F' : C\u2081 \u2964 D\u2081} {G G' : C\u2082 \u2964 D\u2082} (\u03b1 : F \u2245 F') (\u03b2 : G \u2245 G') :\n  F.prod G \u2245 F'.prod G' :=\n{ hom := \u03b1.hom.prod \u03b2.hom,\n  inv := \u03b1.inv.prod \u03b2.inv, }\n\nnamespace equivalence\n\ndef prod (E\u2081 : C\u2081 \u224c D\u2081) (E\u2082 : C\u2082 \u224c D\u2082) : C\u2081 \u00d7 C\u2082 \u224c D\u2081 \u00d7 D\u2082 :=\n{ functor := E\u2081.functor.prod E\u2082.functor,\n  inverse := E\u2081.inverse.prod E\u2082.inverse,\n  unit_iso := ((functor_prod_functor_equiv (C\u2081 \u00d7 C\u2082) C\u2081 C\u2082).counit_iso.app (\ud835\udfed _)).symm\n      \u226a\u226b nat_iso.prod E\u2081.unit_iso E\u2082.unit_iso,\n  counit_iso := nat_iso.prod E\u2081.counit_iso E\u2082.counit_iso \u226a\u226b\n      ((functor_prod_functor_equiv (D\u2081 \u00d7 D\u2082) D\u2081 D\u2082).counit_iso.app (\ud835\udfed _)), }\n\nend equivalence\n\nnamespace functor\n\n@[simps]\ndef prod_functor : (C\u2081 \u2964 D\u2081) \u00d7 (C\u2082 \u2964 D\u2082) \u2964 (C\u2081 \u00d7 C\u2082) \u2964 (D\u2081 \u00d7 D\u2082) :=\n{ obj := \u03bb F, F.1.prod F.2,\n  map := \u03bb F G \u03c6, \u03c6.1.prod \u03c6.2, }\n\nlemma flip_flip (H : D\u2081 \u2964 D\u2082 \u2964 E) : H.flip.flip = H :=\nfunctor.ext (\u03bb X\u2081, (functor.ext (\u03bb X\u2082, rfl) (by tidy))) (by tidy)\n\nlemma comp_comp_curry_flip_flip_eq_curry (H : D\u2081 \u00d7 D\u2082 \u2964 E) (F\u2081 : C\u2081 \u2964 D\u2081) (F\u2082 : C\u2082 \u2964 D\u2082) :\n  F\u2081 \u22d9 (F\u2082 \u22d9 (curry.obj H).flip).flip = curry.obj (F\u2081.prod F\u2082 \u22d9 H) :=\nfunctor.ext (\u03bb X\u2081, (functor.ext (\u03bb Y\u2081, rfl) (by tidy))) (by tidy)\n\nlemma uncurry_curry (H : D\u2081 \u00d7 D\u2082 \u2964 E) : uncurry.obj (curry.obj H) = H :=\nfunctor.ext (\u03bb 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 [] : \u2200 (X : C), W (\ud835\udfd9 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\u27e8\u03bb X, h.id X.unop\u27e9\n\nlemma unop {C : Type*} [category C] {W : morphism_property C\u1d52\u1d56}\n  (h : W.contains_identities) : W.unop.contains_identities :=\n\u27e8\u03bb X, h.id (opposite.op X)\u27e9\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\u2081 \u00d7 C\u2082) := \u03bb X Y f, W\u2081 f.fst \u2227 W\u2082 f.snd\n\nvariables {W\u2081 W\u2082}\n\nlemma is_inverted_by.prod {F\u2081 : C\u2081 \u2964 D\u2081} {F\u2082 : C\u2082 \u2964 D\u2082} (h\u2081 : W\u2081.is_inverted_by F\u2081)\n  (h\u2082 : W\u2082.is_inverted_by F\u2082) : (W\u2081.prod W\u2082).is_inverted_by (F\u2081.prod F\u2082) :=\n\u03bb X Y f hf, by { rw is_iso_prod_iff, exact \u27e8h\u2081 f.1 hf.1,h\u2082 f.2 hf.2\u27e9, }\n\nend morphism_property\n\nnamespace localization\n\nvariables [hW\u2081 : W\u2081.contains_identities] [hW\u2082 : W\u2082.contains_identities]\n\nnamespace strict_universal_property_fixed_target\n\nvariables  (F : C\u2081 \u00d7 C\u2082 \u2964 E) (hF : (W\u2081.prod W\u2082).is_inverted_by F)\n\n@[simps]\ndef prod.hom_mk {X\u2081 Y\u2081 : C\u2081} {X\u2082 Y\u2082 : C\u2082} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) :\n  (\u27e8X\u2081, X\u2082\u27e9 : C\u2081 \u00d7 C\u2082) \u27f6 \u27e8Y\u2081, Y\u2082\u27e9 := \u27e8f\u2081, f\u2082\u27e9\n\nnamespace prod\n\ninclude hF hW\u2082\ndef lift\u2081 : W\u2081.localization \u2964 C\u2082 \u2964 E :=\nlocalization.construction.lift (curry.obj F) (\u03bb X\u2081 Y\u2081 f\u2081 hf\u2081, begin\n  haveI : \u03a0 (Z\u2082 : C\u2082), is_iso (((curry.obj F).map f\u2081).app Z\u2082),\n  { intro Z\u2082,\n    apply hF,\n    exact \u27e8hf\u2081, morphism_property.contains_identities.id _ _\u27e9, },\n    apply nat_iso.is_iso_of_is_iso_app,\nend)\n\nlemma fac\u2081 : W\u2081.Q \u22d9 (lift\u2081 W\u2081 W\u2082 F hF) = curry.obj F := localization.construction.fac _ _\n\nlemma lift\u2081_obj_map (X\u2081 : C\u2081) {X\u2082 Y\u2082 : C\u2082} (f\u2082 : X\u2082 \u27f6 Y\u2082) :\n  ((lift\u2081 W\u2081 W\u2082 F hF).obj (W\u2081.Q.obj X\u2081)).map f\u2082 =\n    F.map (prod.hom_mk (\ud835\udfd9 X\u2081) f\u2082) := rfl\n\nlemma lift\u2081_map_app {X\u2081 Y\u2081 : C\u2081} (f\u2081 : X\u2081 \u27f6 Y\u2081) (X\u2082 : C\u2082) :\n  ((lift\u2081 W\u2081 W\u2082 F hF).map (W\u2081.Q.map f\u2081)).app X\u2082 =\n    F.map (prod.hom_mk f\u2081 (\ud835\udfd9 X\u2082)) :=\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\u2081 W\u2081 W\u2082 F hF) f\u2081) X\u2082\n\ninclude hW\u2081\n\ndef lift\u2082 : W\u2082.localization \u2964 W\u2081.localization \u2964 E :=\nlocalization.construction.lift (lift\u2081 W\u2081 W\u2082 F hF).flip (\u03bb X\u2082 Y\u2082 f\u2082 hf\u2082, begin\n  haveI : \u2200 (X\u2081 : W\u2081.localization), is_iso (((lift\u2081 W\u2081 W\u2082 F hF).flip.map f\u2082).app X\u2081),\n  { intro X\u2081,\n    have hF\u2081 : \u2203 (A\u2081 : C\u2081), W\u2081.Q.obj A\u2081 = X\u2081 := (construction.obj_equiv W\u2081).surjective X\u2081,\n    cases hF\u2081 with A\u2081 hA\u2081,\n    subst hA\u2081,\n    simp only [functor.flip_map_app, lift\u2081_obj_map],\n    haveI := hF (prod.hom_mk (\ud835\udfd9 A\u2081) f\u2082) \u27e8morphism_property.contains_identities.id _ _, hf\u2082\u27e9,\n    apply_instance, },\n  apply nat_iso.is_iso_of_is_iso_app,\nend)\n\nlemma fac\u2082 : W\u2082.Q \u22d9 (lift\u2082 W\u2081 W\u2082 F hF) = (lift\u2081 W\u2081 W\u2082 F hF).flip :=\nlocalization.construction.fac _ _\n\nlemma lift\u2082_obj_map {X\u2081 Y\u2081 : C\u2081} (f\u2081 : X\u2081 \u27f6 Y\u2081) (X\u2082 : C\u2082) :\n  ((lift\u2082 W\u2081 W\u2082 F hF).obj (W\u2082.Q.obj X\u2082)).map (W\u2081.Q.map f\u2081) = F.map (prod.hom_mk f\u2081 (\ud835\udfd9 X\u2082)) :=\nby simpa only [eq_to_hom_refl, functor.flip_obj_map, category.comp_id,\n  category.id_comp, lift\u2081_map_app] using functor.congr_map_conjugate\n    (functor.congr_obj (fac\u2082 W\u2081 W\u2082 F hF) X\u2082) (W\u2081.Q.map f\u2081)\n\nlemma lift\u2082_map_app (X\u2081 : C\u2081) {X\u2082 Y\u2082 : C\u2082} (f\u2082 : X\u2082 \u27f6 Y\u2082) :\n  ((lift\u2082 W\u2081 W\u2082 F hF).map (W\u2082.Q.map f\u2082)).app (W\u2081.Q.obj X\u2081) = F.map (prod.hom_mk (\ud835\udfd9 X\u2081) f\u2082) :=\nby simpa only [eq_to_hom_refl, category.comp_id, category.id_comp]\n  using congr_app (functor.congr_map_conjugate (fac\u2082 W\u2081 W\u2082 F hF) f\u2082) (W\u2081.Q.obj X\u2081)\n\ndef lift\u2083 : W\u2081.localization \u00d7 W\u2082.localization \u2964 E := uncurry.obj (lift\u2082 W\u2081 W\u2082 F hF).flip\n\nlemma fac : W\u2081.Q.prod W\u2082.Q \u22d9 prod.lift\u2083 W\u2081 W\u2082 F hF = F :=\nbegin\n  refine functor.ext (\u03bb X, by { cases X, refl, }) (\u03bb X Y f, _),\n  { rcases X with \u27e8X\u2081, X\u2082\u27e9,\n    rcases Y with \u27e8Y\u2081, Y\u2082\u27e9,\n    have eq : f = prod.hom_mk (\ud835\udfd9 X\u2081) f.2 \u226b prod.hom_mk f.1 (\ud835\udfd9 Y\u2082) :=\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\u2083],\n    simp only [category.id_comp, category.comp_id, nat_trans.naturality,\n      lift\u2082_obj_map, lift\u2082_map_app, \u2190 F.map_comp],\n    congr' 1,\n    ext,\n    { apply category.comp_id, },\n    { apply category.id_comp, }, },\nend\n\nomit hF hW\u2081 hW\u2082\n\nlemma uniq (H H' : W\u2081.localization \u00d7 W\u2082.localization \u2964 E)\n  (eq : W\u2081.Q.prod W\u2082.Q \u22d9 H = W\u2081.Q.prod W\u2082.Q \u22d9 H') : H = H' :=\nbegin\n  let G := (curry.obj H).flip,\n  let G' := (curry.obj H').flip,\n  suffices : G = G',\n  { rw [\u2190 functor.uncurry_curry H, \u2190 functor.uncurry_curry H'],\n    congr' 1,\n    rw [\u2190 functor.flip_flip (curry.obj H), \u2190 functor.flip_flip (curry.obj H')],\n    congr', },\n  apply construction.uniq,\n  suffices : (W\u2082.Q \u22d9 G).flip = (W\u2082.Q \u22d9 G').flip,\n  { rw [\u2190 functor.flip_flip (W\u2082.Q \u22d9 G), \u2190 functor.flip_flip (W\u2082.Q \u22d9 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\u2081 hW\u2082\n\nvariable (E)\n\ndef prod : strict_universal_property_fixed_target (W\u2081.Q.prod W\u2082.Q) (W\u2081.prod W\u2082) E :=\n{ inverts := (localization.inverts _ _).prod (localization.inverts _ _),\n  lift := \u03bb F hF, prod.lift\u2083 W\u2081 W\u2082 F hF,\n  fac := \u03bb F hF, prod.fac W\u2081 W\u2082 F hF,\n  uniq := \u03bb H H' eq, begin\n    let G := (curry.obj H).flip,\n    let G' := (curry.obj H').flip,\n    suffices : G = G',\n    { rw [\u2190 functor.uncurry_curry H, \u2190 functor.uncurry_curry H'],\n      congr' 1,\n      rw [\u2190 functor.flip_flip (curry.obj H), \u2190 functor.flip_flip (curry.obj H')],\n      congr', },\n    apply construction.uniq,\n    suffices : (W\u2082.Q \u22d9 G).flip = (W\u2082.Q \u22d9 G').flip,\n    { rw [\u2190 functor.flip_flip (W\u2082.Q \u22d9 G), \u2190 functor.flip_flip (W\u2082.Q \u22d9 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\u2081 hW\u2082\n\ninstance prod_construction_is_localization : (W\u2081.Q.prod W\u2082.Q).is_localization (W\u2081.prod W\u2082) :=\nfunctor.is_localization.mk' _ _\n  (strict_universal_property_fixed_target.prod W\u2081 W\u2082 _)\n  (strict_universal_property_fixed_target.prod W\u2081 W\u2082 _)\n\ninstance prod_is_localization (L\u2081 : C\u2081 \u2964 D\u2081) (L\u2082 : C\u2082 \u2964 D\u2082)\n  [L\u2081.is_localization W\u2081] [L\u2082.is_localization W\u2082] :\n  (L\u2081.prod L\u2082).is_localization (W\u2081.prod W\u2082) :=\nbegin\n  let E\u2081 := equivalence_from_model L\u2081 W\u2081,\n  let E\u2082 := equivalence_from_model L\u2082 W\u2082,\n  let e\u2081 : W\u2081.Q \u22d9 E\u2081.functor \u2245 L\u2081 := Q_comp_equivalence_from_model_functor_iso _ _,\n  let e\u2082 : W\u2082.Q \u22d9 E\u2082.functor \u2245 L\u2082 := Q_comp_equivalence_from_model_functor_iso _ _,\n  exact functor.is_localization.of_equivalence (W\u2081.Q.prod W\u2082.Q) (W\u2081.prod W\u2082) (L\u2081.prod L\u2082)\n    (E\u2081.prod E\u2082) (functor.prod_functor.map_iso (e\u2081.prod e\u2082)),\nend\n\nend localization\n\nvariables {J : Type*} (C : J \u2192 Type u) [\u03a0 j, category (C j)]\n\ndef equivalence.pi' {J' : Type*} (\u03b1 : J' \u2243 J) :\n  (\u03a0 j, C (\u03b1 j)) \u224c (\u03a0 j', C j'):=\n{ functor := functor.pi'_ (\u03bb j, functor.pi_.eval _ (\u03b1.symm j) \u22d9\n    (pi.equivalence_of_eq C (show \u03b1 (\u03b1.symm j) = j, by simp)).functor),\n  inverse := functor.pi'_ (\u03bb j', functor.pi_.eval _ (\u03b1 j')),\n  unit_iso := functor.pi_.mk_nat_iso (\u03bb j', begin\n    calc \ud835\udfed (\u03a0 (j : J'), C (\u03b1 j)) \u22d9 functor.pi_.eval (\u03bb (j : J'), C (\u03b1 j)) j' \u2245 _ :\n      functor.left_unitor _\n    ... \u2245 _ : (functor.pi_.eval_iso_of_eq (\u03bb j, C (\u03b1 j)) (show \u03b1.symm (\u03b1 j') = j', by simp)).symm\n    ... \u2245 _ : _\n    ... \u2245 _ \u22d9 functor.pi_.eval _ _ : (functor.pi'__eval_iso _ _).symm\n    ... \u2245 _ \u22d9 _ \u22d9 _ : iso_whisker_left _ ((functor.pi'__eval_iso _ _).symm)\n    ... \u2245 (_ \u22d9 _) \u22d9 _ : (functor.associator _ _ _).symm,\n    { exact iso_whisker_left _ (pi.equivalence_of_eq_functor_iso C \u03b1 (by simp)), },\n  end),\n  counit_iso := functor.pi_.mk_nat_iso\n    (\u03bb j, functor.associator _ _ _ \u226a\u226b iso_whisker_left _ (functor.pi'__eval_iso _ _) \u226a\u226b\n    (functor.associator _ _ _).symm \u226a\u226b iso_whisker_right (functor.pi'__eval_iso _ _) _ \u226a\u226b\n    functor.pi_.eval_iso_of_eq _ _ \u226a\u226b (functor.left_unitor _).symm),\n  functor_unit_iso_comp' := \u03bb 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*} (\u03b1 : J' \u2243 J) (j' : J') :\n  (equivalence.pi' C \u03b1).inverse \u22d9 functor.pi_.eval _ j' = functor.pi_.eval _ (\u03b1 j') := rfl\n\nlemma equivalence.pi'_functor_comp_eval {J' : Type*} (\u03b1 : J' \u2243 J) (j' : J') :\n  (equivalence.pi' C \u03b1).functor \u22d9 functor.pi_.eval _ (\u03b1 j') = functor.pi_.eval _ j' :=\nbegin\n  dsimp only [equivalence.pi'],\n  rw functor.pi'__eval,\n  rw \u2190 functor.pi_.eval_eq_of_eq (\u03bb j', C (\u03b1 j')) (show \u03b1.symm (\u03b1 j') = j', by simp),\n  rw pi.equivalence_of_eq_functor_eq C \u03b1,\nend\n\nvariable {C}\n\n@[simps]\ndef equivalence.pi'' {J' : Type*} (\u03b1 : J \u2243 J') {D : J' \u2192 Type*}\n  [\u03a0 j', category (D j')] (e : \u03a0 j, C j \u224c D (\u03b1 j)) :\n  (\u03a0 j, C j) \u224c (\u03a0 j', D j') :=\n(equivalence.pi e).trans (equivalence.pi' D \u03b1)\n\nlemma equivalence.pi''_inverse_comp_eval {J' : Type*} (\u03b1 : J \u2243 J') {D : J' \u2192 Type*}\n  [\u03a0 j', category (D j')] (e : \u03a0 j, C j \u224c D (\u03b1 j)) (j : J) :\n  (equivalence.pi'' \u03b1 e).inverse \u22d9 functor.pi_.eval _ j =\n    functor.pi_.eval _ (\u03b1 j) \u22d9 (e j).inverse := rfl\n\nlemma equivalence.pi''_functor_comp_eval {J' : Type*} (\u03b1 : J \u2243 J') {D : J' \u2192 Type*}\n  [\u03a0 j', category (D j')] (e : \u03a0 j, C j \u224c D (\u03b1 j)) (j : J) :\n  (equivalence.pi'' \u03b1 e).functor \u22d9 functor.pi_.eval _ (\u03b1 j) =\n    functor.pi_.eval _ j \u22d9 (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 : \u03a0 j, C j} (f : X \u27f6 Y) :\n  is_iso f \u2194 \u2200 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 \u27e8\u27e8\u03bb j, inv (f j), by tidy\u27e9\u27e9, },\nend\n\ndef morphism_property.pi (W : \u03a0 j, morphism_property (C j)) :\n  morphism_property (\u03a0 j, C j) := \u03bb X Y f, \u2200 j, (W j) (f j)\n\nend\n\nsection\n\nvariables {J\u2081 J\u2082 : Type*} (C\u2081 : J\u2081 \u2192 Type u) (C\u2082 : J\u2082 \u2192 Type u)\n\n@[simp]\ndef sum.desc : sum J\u2081 J\u2082 \u2192 Type u\n|(sum.inl j\u2081) := C\u2081 j\u2081\n|(sum.inr j\u2082) := C\u2082 j\u2082\n\nvariables [\u03a0 j\u2081, category.{v} (C\u2081 j\u2081)] [\u03a0 j\u2082, category.{v} (C\u2082 j\u2082)]\n\ninstance : \u03a0 j, category.{v} (sum.desc C\u2081 C\u2082 j) :=\n\u03bb j, by { cases j; dsimp only [sum.desc]; apply_instance, }\n\ndef equivalence_pi_prod :\n  (\u03a0 j\u2081, C\u2081 j\u2081) \u00d7 (\u03a0 j\u2082, C\u2082 j\u2082) \u224c (\u03a0 j, sum.desc C\u2081 C\u2082 j) :=\n{ functor := functor.pi'_ (\u03bb j, match j with\n    | sum.inl j\u2081 := category_theory.prod.fst _ _ \u22d9 functor.pi_.eval _ j\u2081\n    | sum.inr j\u2082 := category_theory.prod.snd _ _ \u22d9 functor.pi_.eval _ j\u2082\n  end),\n  inverse := functor.prod'\n    (functor.pi'_ (\u03bb j\u2081, functor.pi_.eval _ (sum.inl j\u2081)))\n    (functor.pi'_ (\u03bb j\u2082, functor.pi_.eval _ (sum.inr j\u2082))),\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 \u2192 T) (C\u2080 : T)\n\n@[simp]\ndef option.desc : option J \u2192 T\n| none := C\u2080\n| (some j) := C j\n\nlemma option.is_desc (f : option J \u2192 T) : \u2203 (C : J \u2192 T) (C\u2080 : T), f = option.desc C C\u2080 :=\n\u27e8\u03bb j, f (some j), f none, by { ext j, cases j; refl, }\u27e9\n\ndef option.desc' {C : J \u2192 Type u} {C\u2080 : Type u}\n  (f : \u03a0 j, C j) (f\u2080 : C\u2080) : \u03a0 (j : option J), option.desc C C\u2080 j\n| none := f\u2080\n| (some j) := f j\n\nlemma option.is_desc'\n  {C : J \u2192 Type u} {C\u2080 : Type u} (g : \u03a0 (j : option J), option.desc C C\u2080 j) :\n  \u2203 (f : \u03a0 j, C j) (f\u2080 : C\u2080), g = option.desc' f f\u2080 :=\n\u27e8\u03bb j, g (some j), g none, by { ext j, cases j; refl,}\u27e9\n\nend\n\nsection\n\nvariables {J : Type*} (j : J) [subsingleton J] (C : J \u2192 Type*) [\u03a0 t, category (C t)]\n\ndef equivalence_pi_single :\n  (\u03a0 t, C t) \u224c C j :=\n{ functor := functor.pi_.eval _ j,\n  inverse := functor.pi'_ (\u03bb t, begin\n    have eq := subsingleton.elim j t,\n    subst eq,\n    exact \ud835\udfed _,\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 \u2192 Type u) [\u03a0 j', category.{v} (C j')]\n\ndef equivalence_pi_option : (\u03a0 j', C j') \u224c (\u03a0 j, C (some j)) \u00d7 C none :=\n{ functor := functor.prod' (functor.pi'_ (\u03bb j, functor.pi_.eval _ (some j))) (functor.pi_.eval _ none),\n  inverse := functor.pi'_ (\u03bb j, match j with\n    | none := prod.snd _ _\n    | (some j) := prod.fst _ _ \u22d9 functor.pi_.eval _ j\n  end),\n  unit_iso := eq_to_iso (functor.pi_.ext (\u03bb 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 \u2192 Type*} {D : J \u2192 Type*}\n  [\u03a0 j, category (C j)] [\u03a0 j, category (D j)]\n  (W : \u03a0 j, morphism_property (C j))\n  (L : \u03a0 j, C j \u2964 D j)\n\nlemma morphism_property.is_inverted_by.pi (h : \u2200 j, (W j).is_inverted_by (L j)):\n  (morphism_property.pi W).is_inverted_by (functor.pi_ (\u03bb j, L j)) :=\n\u03bb X Y f hf, by { rw is_iso_pi_iff, exact \u03bb j, h _ _ (hf j), }\n\ninstance [\u03a0 j, (W j).contains_identities] :\n  morphism_property.contains_identities (morphism_property.pi W) :=\n\u27e8\u03bb X j, morphism_property.contains_identities.id (W j) (X j)\u27e9\n\nend\n\nnamespace localization\n\nvariables (J : Type) [finite J] {C : J \u2192 Type*} {D : J \u2192 Type*}\n  [\u03a0 j, category (C j)] [\u03a0 j, category (D j)]\n  (W : \u03a0 j, morphism_property (C j))\n  [hW : \u2200 j, (W j).contains_identities]\n  (L : \u03a0 j, C j \u2964 D j) [\u03a0 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\u2081 J\u2082 e h\u2081 C\u2082 D\u2082, introI, introI, intros W\u2082, introI, intro L\u2082, introI,\n    let C\u2081 := \u03bb j\u2081, C\u2082 (e j\u2081),\n    let D\u2081 := \u03bb j\u2081, D\u2082 (e j\u2081),\n    let L\u2081 : \u03a0 j\u2081, C\u2081 j\u2081 \u2964 D\u2081 j\u2081 := \u03bb j\u2081, L\u2082 (e j\u2081),\n    let W\u2081 : \u03a0 j\u2081, morphism_property (C\u2081 j\u2081) := \u03bb j\u2081, W\u2082 (e j\u2081),\n    haveI := h\u2081 W\u2081 L\u2081,\n    let E : (\u03a0 j\u2081, C\u2081 j\u2081) \u224c (\u03a0 j\u2082, C\u2082 j\u2082) := equivalence.pi'' e (\u03bb j\u2081, by refl),\n    let E' : (\u03a0 j\u2081, D\u2081 j\u2081) \u224c (\u03a0 j\u2082, D\u2082 j\u2082) := equivalence.pi'' e (\u03bb j\u2081, by refl),\n    let Sq : Comm_sq E.symm.functor (functor.pi_ L\u2082) (functor.pi_ L\u2081) E'.symm.functor :=\n      \u27e8eq_to_iso (functor.pi_.ext (\u03bb j\u2081, begin\n        simp only [functor.assoc, functor.pi_eval],\n        erw equivalence.pi''_inverse_comp_eval,\n        simp only [\u2190 functor.assoc],\n        erw equivalence.pi''_inverse_comp_eval,\n        refl,\n    end))\u27e9,\n    have hW\u2081 : morphism_property.pi W\u2081 \u2286 (morphism_property.pi W\u2082).inverse_image' E.symm.inverse,\n    { intros X\u2081 Y\u2081 f hf,\n      refine \u27e8X\u2081, Y\u2081, iso.refl _, iso.refl _, f, \u03bb j\u2082, _, by tidy\u27e9,\n      rcases e.surjective j\u2082 with \u27e8j\u2081, hj\u2081\u27e9,\n      subst hj\u2081,\n      refine (W\u2082 (e j\u2081)).of_arrow_mk_eq _ _ (hf j\u2081) _,\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\u2082) (morphism_property.pi W\u2081)\n      (morphism_property.is_inverted_by.pi W\u2082 L\u2082 (\u03bb j\u2082, localization.inverts _ _)) hW\u2081), },\n  { intros C D, introI, introI, intros W, introI, intro L, introI,\n    haveI : is_equivalence (functor.pi_ L) :=\n    { inverse :=\n      { obj := \u03bb Y j, by induction j,\n        map := \u03bb 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 := \u03bb j, W' (some j),\n    let W\u2080 := W' none,\n    let L := \u03bb j, L' (some j),\n    let L\u2080 := L' none,\n    let E := equivalence_pi_option C',\n    let E' := equivalence_pi_option D',\n    haveI : L\u2080.is_localization W\u2080 := hL' none,\n    let H : Comm_sq (equivalence_pi_option C').functor (functor.pi_ L') (functor.prod (functor.pi_ L) L\u2080) (equivalence_pi_option D').functor := \u27e8eq_to_iso rfl\u27e9,\n    have hW\u2081 := morphism_property.is_inverted_by.pi W' L' (\u03bb j, localization.inverts _ _),\n    have hW\u2082 : (morphism_property.pi W).prod W\u2080 \u2286 (morphism_property.pi W').inverse_image' E.inverse,\n    { intros X Y f hf,\n      refine \u27e8X, Y, iso.refl X, iso.refl Y, f, _, comm_sq.mk (by simp)\u27e9,\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\u2080) hW\u2081 hW\u2082, },\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 \u2964 C) := \u03bb X Y f, \u2200 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 \u2964 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\u2081 := (whiskering_right (discrete J) C D).obj L,\n  let L\u2082 := functor.pi_ (\u03bb (j : J), L),\n  let H : Comm_sq E.symm.functor L\u2081 L\u2082 E'.symm.functor := \u27e8iso.refl _\u27e9,\n  refine functor.is_localization.of_equivalence'' E.symm E'.symm H (W.functor_category _)\n    (morphism_property.pi (\u03bb j, W)) _ _,\n  { intros X Y f hf,\n    haveI : \u2200 (j : discrete J), is_iso ((((whiskering_right\n      (discrete J) C D).obj L).map f).app j),\n    { rintro \u27e8j\u27e9,\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 \u27e8j\u27e9,\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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (((a2).write i2 ((a2).read i1)).read i1) \u2260 ((a2).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test20.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.23633853129793364}}
{"text": "/-\nCopyright (c) 2022 Jo\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u2124} {n : \u2124} (z : cocycle F G n) {m : \u2124} [\u2200 p, has_binary_biproduct (F.X (p+1-n)) (G.X p)]\ninclude z\n\nnamespace twist\n\n@[protected, simp]\ndef \u03b4 (p q : \u2124) :\n  biprod (F.X (p+1-n)) (G.X p) \u27f6 biprod (F.X (q+1-n)) (G.X q) :=\nbegin\n  refine biprod.desc (biprod.lift (\u03b5 (n+1) \u2022 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 \u2124 :=\n{ X := \u03bb p, biprod (F.X (p+1-n)) (G.X p),\n  d := \u03bb p q, twist.\u03b4 z p q,\n  shape' := \u03bb p q hpq, begin\n    dsimp [twist.\u03b4],\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' := \u03bb 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.\u03b4, 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\u2081 := z.2,\n      rw cocycle.mem_iff n (n+1) rfl at hz\u2081,\n      have hz\u2082 := cochain.congr_v hz\u2081 (i+1-n) (i+2) (by linarith),\n      simp only [\u03b4_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\u2082,\n      rw \u2190 hz\u2082,\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\u2080 : \u2124} (hn\u2080 : n\u2080+1=n) : cochain F (twist z) n\u2080 :=\ncochain.mk (\u03bb p q hpq, (cochain.of_hom (\ud835\udfd9 F)).v p (q+1-n) (by linarith) \u226b biprod.inl)\n\ndef inr : G \u27f6 twist z := { f := \u03bb p, biprod.inr, }\n\ndef fst {n\u2081 : \u2124} (hn\u2081 : n+n\u2081=1) : cocycle (twist z) F n\u2081 :=\ncocycle.mk (cochain.mk (\u03bb p q hpq, biprod.fst \u226b\n  (cochain.of_hom (\ud835\udfd9 F)).v (p+1-n) q (show q=p+1-n+0, by linarith))) (n\u2081+1) rfl\nbegin\n  have hn\u2081' : n\u2081 = 1-n := by linarith,\n  subst hn\u2081',\n  ext1,\n  simp only [\u03b4_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.\u03b4, dif_pos,\n      cochain.zero_v],\n  ext,\n  { have hq : q = p+1+1-n := by linarith,\n    subst hq,\n    have eq : \u03b5 (1-n+1) * \u03b5 (n+1) = \u03b5 ((1 : \u2124) + 1 + 1) := by { rw \u2190 \u03b5_add, congr' 1, linarith, },\n    have eq' : \u03b5 ((1 : \u2124)+1+1) = -1 := by { simp only [\u03b5_succ, \u03b5_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 (\u03bb p q hpq, biprod.snd \u226b (cochain.of_hom (\ud835\udfd9 G)).v p q hpq)\n\n@[simp]\nlemma inl_comp_fst {n\u2080 n\u2081 : \u2124} (hn\u2080 : n\u2080+1=n) (hn\u2081 : n+n\u2081=1) :\n  (inl z hn\u2080).comp \u2191(fst z hn\u2081) (show 0=n\u2080+n\u2081, by linarith) = cochain.of_hom (\ud835\udfd9 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\u2080 : \u2124} (hn\u2080 : n\u2080+1=n) :\n  (inl z hn\u2080).comp (snd z) (add_zero n\u2080).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\u2081 : \u2124} (hn\u2081 : n+n\u2081=1) :\n  (cochain.of_hom (inr z)).comp (fst z hn\u2081 : cochain (twist z) F n\u2081) (zero_add n\u2081).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 (\ud835\udfd9 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 \u03b4_inl {n\u2080 : \u2124} (hn\u2080 : n\u2080+1=n) :\n  \u03b4 n\u2080 n (inl z hn\u2080) = cochain.comp \u2191z (cochain.of_hom (inr z)) (add_zero n).symm :=\nbegin\n  ext1,\n  simp only [\u03b4_v n\u2080 n hn\u2080 (inl z hn\u2080) p q hpq _ _ rfl rfl, twist_d, twist.\u03b4],\n  ext,\n  { simp only [\u2190 hn\u2080, inl, cochain.mk_v, \u03b5_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 \u03b4_snd {n\u2081 : \u2124} (hn\u2081 : n+n\u2081=1) :\n  \u03b4 0 1 (snd z) = -cochain.comp (fst z hn\u2081 : cochain (twist z) F n\u2081) (\u2191z) (show 1 = n\u2081+n, by rw [\u2190 hn\u2081, add_comm]) :=\nbegin\n  ext1,\n  simp only [\u03b4_v 0 1 (zero_add 1) _ p q hpq p q (by linarith) hpq, fst, snd, zero_add, \u03b5_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.\u03b4,\n    cochain.comp_v _ _ (show 1=n\u2081+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\u2080 n\u2081 : \u2124} (hn\u2080 : n\u2080+1=n)  (hn\u2081 : n+n\u2081=1) : cochain.of_hom (\ud835\udfd9 (twist z)) =\ncochain.comp \u2191(fst z hn\u2081) (inl z hn\u2080) (show 0=n\u2081+n\u2080, 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\u2081+n\u2080, 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\u2081 y\u2082 : cochain (twist z) K m) {n\u2080 n\u2081 : \u2124} (hn\u2080 : n\u2080+1=n)\n  (hn\u2081 : n\u2081 = n\u2080+m) :\n  y\u2081 = y\u2082 \u2194 cochain.comp (inl z hn\u2080) y\u2081 hn\u2081 = cochain.comp (inl z hn\u2080) y\u2082 hn\u2081 \u2227\n    cochain.comp (cochain.of_hom (inr z)) y\u2081 (zero_add m).symm =\n      cochain.comp (cochain.of_hom (inr z)) y\u2082 (zero_add m).symm :=\nbegin\n  split,\n  { intro h, rw h, tauto, },\n  { rintro \u27e8hl, hr\u27e9,\n    suffices : cochain.comp (cochain.of_hom (\ud835\udfd9 _)) y\u2081 (zero_add m).symm =\n      cochain.comp (cochain.of_hom (\ud835\udfd9 _)) y\u2082 (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\u2080 (show n+(-n\u2080)=1, by linarith), cochain.add_comp,\n      cochain.comp_assoc_of_second_is_zero_cochain,\n      cochain.comp_assoc _ _ _ (show 0=-n\u2080+n\u2080, by linarith) (show n\u2081=n\u2080+m, by linarith)\n      (show m=-n\u2080+n\u2080+m, by linarith), hl, hr], }\nend\n\ndef desc_cochain {m m\u2081 : \u2124} (y\u2081 : cochain F K m\u2081) (y\u2082 : cochain G K m)\n  (hm\u2081 : m\u2081+1=n+m) : cochain (twist z) K m :=\ncochain.comp \u2191(fst z (show n+(m-m\u2081) = 1, by linarith)) y\u2081 (eq_add_of_sub_eq rfl : m=(m-m\u2081)+m\u2081) +\n  cochain.comp (snd z) y\u2082 (zero_add m).symm\n\nlemma desc_cochain_eq {m m\u2081 n\u2081 : \u2124} (y\u2081 : cochain F K m\u2081) (y\u2082 : cochain G K m)\n  (hm\u2081 : m\u2081+1=n+m) (hn\u2081 : n+n\u2081=1) : desc_cochain z y\u2081 y\u2082 hm\u2081 =\ncochain.comp \u2191(fst z hn\u2081) y\u2081 (show m = n\u2081+m\u2081, begin\n  suffices : m+1=n\u2081+m\u2081+1,\n  { simpa only [add_left_inj] using this, },\n  rw [add_assoc, hm\u2081, \u2190 hn\u2081, add_comm n\u2081, add_comm n m, add_assoc],\nend) + cochain.comp (snd z) y\u2082 (zero_add m).symm :=\nbegin\n  have h : n\u2081 = m-m\u2081 := by linarith,\n  subst h,\n  refl,\nend\n\nlemma inl_comp_desc_cochain {m m\u2081 n\u2080 : \u2124} (y\u2081 : cochain F K m\u2081)\n  (y\u2082 : cochain G K m) (hm\u2081 : m\u2081+1=n+m) (hn\u2080 : n\u2080+1=n) :\n  cochain.comp (inl z hn\u2080) (desc_cochain z y\u2081 y\u2082 hm\u2081) begin\n    suffices : m\u2081+1 = n\u2080+m+1,\n    { simpa only [add_left_inj] using this, },\n    rw [add_assoc, hm\u2081, \u2190 hn\u2080, add_assoc, add_comm 1 m],\n  end = y\u2081 :=\nbegin\n  simp only [desc_cochain_eq z y\u2081 y\u2082 hm\u2081 (show n+(-n\u2080)=1, by linarith), cochain.comp_add,\n    \u2190 cochain.comp_assoc (inl z hn\u2080) _ y\u2081 (show 0=n\u2080+(-n\u2080), by linarith)\n      (show m= _, by linarith) (show m\u2081=_, by linarith),\n    \u2190 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\u2081 : \u2124} (y\u2081 : cochain F K m\u2081)\n  (y\u2082 : cochain G K m) (hm\u2081 : m\u2081+1=n+m) :\n  cochain.comp (cochain.of_hom (inr z)) (desc_cochain z y\u2081 y\u2082 hm\u2081) (zero_add m).symm = y\u2082 :=\nbegin\n  simp only [desc_cochain_eq z y\u2081 y\u2082 hm\u2081 (show n+(1-n)=1, by linarith), cochain.comp_add,\n    \u2190 cochain.comp_assoc_of_second_is_zero_cochain, inr_comp_snd, cochain.id_comp,\n    \u2190 cochain.comp_assoc_of_first_is_zero_cochain, inr_comp_fst, cochain.zero_comp, zero_add],\nend\n\nlemma \u03b4_desc_cochain {m m\u2081 m\u2082 n\u2081 : \u2124} (y\u2081 : cochain F K m\u2081) (y\u2082 : cochain G K m)\n  (hm\u2081 : m\u2081+1=n+m) (hn\u2081 : n+n\u2081=1) (hm\u2082 : m\u2081+1=m\u2082)\n  (m' : \u2124) (hm' : m+1=m') :\n  \u03b4 m m' (desc_cochain z y\u2081 y\u2082 hm\u2081) =\n  cochain.comp (fst z hn\u2081 : cochain (twist z) F n\u2081) (\u03b4 m\u2081 m\u2082 y\u2081 +\n    \u03b5 (m+1) \u2022 cochain.comp \u2191z y\u2082 (show m\u2082 = n+m, by linarith)) (show m' = n\u2081+m\u2082, by linarith) +\n  cochain.comp (snd z) (\u03b4 m m' y\u2082) (zero_add m').symm :=\nbegin\n  simp only [desc_cochain_eq z y\u2081 y\u2082 hm\u2081 hn\u2081, \u03b4_add, cochain.comp_add,\n    \u03b4_comp_of_first_is_zero_cochain _ _ _ hm', \u03b4_snd z hn\u2081,\n    \u03b4_comp \u2191(fst z hn\u2081) y\u2081 (show m = n\u2081+m\u2081, by linarith) _ m\u2082 m' hm' rfl hm\u2082,\n    cochain.comp_zsmul, cochain.neg_comp, zsmul_neg, \u03b5_add, \u03b5_1, mul_neg, mul_one,\n    neg_zsmul, cochain.comp_neg, cocycle.\u03b4_eq_zero, cochain.zero_comp, zsmul_zero, add_zero,\n    add_assoc],\n  rw cochain.comp_assoc _ _ _ (show 1=n\u2081+n, by linarith) (show m\u2082=n+m, by linarith)\n    (show m' = n\u2081+n+m, by linarith),\n  conv_rhs { congr, skip, rw add_comm, },\nend\n\n@[simps]\ndef desc_cocycle {m m\u2081 n\u2082 : \u2124} (y\u2081 : cochain F K m\u2081) (y\u2082 : cocycle G K m)\n  (hm\u2081 : m\u2081+1=n+m) (hn\u2082 : n\u2082 = n+m)\n  (hy : \u03b4 m\u2081 n\u2082 y\u2081 = \u03b5 m \u2022 cochain.comp (z : cochain F G n) (y\u2082 : cochain G K m) hn\u2082) :\n  cocycle (twist z) K m :=\ncocycle.mk (desc_cochain z y\u2081 \u2191y\u2082 hm\u2081) _ rfl\nbegin\n  simp only [\u03b4_desc_cochain z y\u2081 \u2191y\u2082 hm\u2081 (show n+(1-n)=1, by linarith) (show m\u2081+1=n\u2082, by linarith) _ rfl,\n    cocycle.\u03b4_eq_zero, cochain.comp_zero, add_zero, hy, \u03b5_add, \u03b5_1, mul_neg, mul_one, neg_zsmul,\n    add_right_neg, cochain.comp_zero],\nend\n\nlemma inr_comp_desc_cocycle {m m\u2081 n\u2082 : \u2124} (y\u2081 : cochain F K m\u2081) (y\u2082 : cocycle G K m)\n  (hm\u2081 : m\u2081+1=n+m) (hn\u2082 : n\u2082 = n+m)\n  (hy : \u03b4 m\u2081 n\u2082 y\u2081 = \u03b5 m \u2022 cochain.comp (z : cochain F G n) (y\u2082 : cochain G K m) hn\u2082) :\n  cochain.comp (cochain.of_hom (inr z)) (desc_cocycle z y\u2081 y\u2082 hm\u2081 hn\u2082 hy : cochain (twist z) K m)\n    (zero_add m).symm = y\u2082 :=\nby simp only [desc_cocycle, cocycle.mk_coe, inr_comp_desc_cochain]\n\n@[simps]\ndef desc_hom_as_cocycle {m\u2081 : \u2124} (y\u2081 : cochain F K m\u2081) (y\u2082 : G \u27f6 K)(hm\u2081 : m\u2081+1=n)\n  (hy : \u03b4 m\u2081 n y\u2081 = cochain.comp (z : cochain F G n) (cochain.of_hom y\u2082) (add_zero n).symm) :\n  cocycle (twist z) K 0 :=\nbegin\n  apply desc_cocycle z y\u2081 (cocycle.of_hom y\u2082) (by linarith) (add_zero n).symm,\n  simpa only [hy, \u03b5_0, one_zsmul],\nend\n\n@[simps]\ndef desc {m\u2081 : \u2124} (y\u2081 : cochain F K m\u2081) (y\u2082 : G \u27f6 K)\n  (hm\u2081 : m\u2081+1=n)\n  (hy : \u03b4 m\u2081 n y\u2081 = cochain.comp (z : cochain F G n) (cochain.of_hom y\u2082) (add_zero n).symm) :\n  twist z \u27f6 K :=\ncocycle.hom_of (desc_hom_as_cocycle z y\u2081 y\u2082 hm\u2081 hy)\n\n@[simp]\nlemma inr_comp_desc {m\u2081 : \u2124} (y\u2081 : cochain F K m\u2081) (y\u2082 : G \u27f6 K)\n  (hm\u2081 : m\u2081+1=n)\n  (hy : \u03b4 m\u2081 n y\u2081 = cochain.comp (z : cochain F G n) (cochain.of_hom y\u2082) (add_zero n).symm) :\n  inr z \u226b desc z y\u2081 y\u2082 hm\u2081 hy = y\u2082 :=\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\u2081 : \u2124} (y\u2081 : cochain K F m\u2081) (y\u2082 : cochain K G m)\n  (hm : m+1=m\u2081+n) : cochain K (twist z) m :=\ncochain.comp y\u2081 (inl z (show (n-1)+1=n, by linarith)) (show m=m\u2081+(n-1), by linarith) +\n  cochain.comp y\u2082 (cochain.of_hom (inr z)) (add_zero m).symm\n\nlemma lift_cochain_eq {m\u2081 n\u2080 : \u2124} (y\u2081 : cochain K F m\u2081) (y\u2082 : cochain K G m) (hm : m+1=m\u2081+n)\n  (hn\u2080 : n\u2080+1=n) : lift_cochain z y\u2081 y\u2082 hm =\ncochain.comp y\u2081 (inl z hn\u2080) (begin\n  suffices : m+1=m\u2081+n\u2080+1,\n  { simpa only [add_left_inj] using this, },\n  rw [hm, \u2190 hn\u2080, add_assoc],\nend) + cochain.comp y\u2082 (cochain.of_hom (inr z)) (add_zero m).symm :=\nbegin\n  have eq : n\u2080 = n-1 := by linarith,\n  subst eq,\n  refl,\nend\n\nlemma lift_cochain_v {m\u2081 n\u2080 : \u2124} (y\u2081 : cochain K F m\u2081) (y\u2082 : cochain K G m)\n  (hm : m+1=m\u2081+n) (hn\u2080 : n\u2080+1 = n) (p q : \u2124) (hpq : q = p + m) (p' : \u2124) (hp' : p' = p + m\u2081):\n  (lift_cochain z y\u2081 y\u2082 hm).v p q hpq =\n    y\u2081.v p p' hp' \u226b (inl z hn\u2080).v p' q (by rw [hpq, hp', add_assoc, add_right_inj,\n      \u2190 add_left_inj (1 : \u2124), hm, \u2190 hn\u2080, add_assoc]) +\n    y\u2082.v p q hpq \u226b (inr z).f q :=\nbegin\n  have hn\u2080' : n\u2080 = n-1 := by linarith,\n  substs hn\u2080' 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\u2081 n\u2081 : \u2124} (y\u2081 : cochain K F m\u2081) (y\u2082 : cochain K G m) (hm : m+1=m\u2081+n)\n  (hn\u2081 : n+n\u2081=1) : cochain.comp (lift_cochain z y\u2081 y\u2082 hm) \u2191(fst z hn\u2081)\n    (show m\u2081=m+n\u2081, by { suffices : m\u2081+n = m+n\u2081+n,\n    { simpa only [add_left_inj] using this,},\n    rw [\u2190 hm, \u2190 hn\u2081, add_comm n, add_assoc]}) = y\u2081 :=\nbegin\n  simp only [lift_cochain, cochain.add_comp,\n    cochain.comp_assoc _ _ _ (show m=m\u2081+(n-1), by linarith) (show 0=n-1+n\u2081, by linarith)\n    (show m\u2081=_, 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\u2081 : \u2124} (y\u2081 : cochain K F m\u2081) (y\u2082 : cochain K G m) (hm : m+1=m\u2081+n) :\n  cochain.comp (lift_cochain z y\u2081 y\u2082 hm) (snd z) (add_zero m).symm = y\u2082 :=\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 \u03b4_lift_cochain {m\u2081 n\u2080 m\u2082 : \u2124} (y\u2081 : cochain K F m\u2081) (y\u2082 : cochain K G m) (hm : m+1=m\u2081+n)\n  (hn\u2080 : n\u2080+1=n) (hm\u2082 : m\u2081+1=m\u2082) (m' : \u2124) (hm' : m+1=m') :\n  \u03b4 m m' (lift_cochain z y\u2081 y\u2082 hm) =\n    \u03b5 n\u2080 \u2022 cochain.comp (\u03b4 m\u2081 m\u2082 y\u2081) (inl z hn\u2080)\n    (by rw [\u2190 hm', \u2190 hm\u2082, hm, \u2190 hn\u2080, add_comm n\u2080 1, add_assoc]) +\n  cochain.comp (\u03b4 m m' y\u2082 + cochain.comp y\u2081 \u2191z (by rw [\u2190 hm', hm]))\n    (cochain.of_hom (inr z)) (add_zero m').symm :=\nbegin\n  simp only [lift_cochain_eq z y\u2081 y\u2082 hm hn\u2080, \u03b4_add,\n    \u03b4_comp y\u2081 (inl z hn\u2080) (show m = m\u2081+n\u2080, by linarith) m\u2082 n m' hm' hm\u2082 hn\u2080,\n    \u03b4_comp_of_second_is_zero_cochain _ _ _ hm', \u03b4_inl, cocycle.\u03b4_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\u2081 n\u2080 : \u2124} (y\u2081 : cocycle K F m\u2081) (y\u2082 : cochain K G m) (hm : m+1=m\u2081+n)\n  (hn\u2080 : n\u2080+1=n) (m' : \u2124) (hm' : m+1=m')\n  (hy : \u03b4 m m' y\u2082 + cochain.comp (y\u2081 : cochain K F m\u2081) \u2191z (show m'=m\u2081+n, by rw [\u2190 hm', hm]) = 0) :\n  cocycle K (twist z) m := cocycle.mk (lift_cochain z \u2191y\u2081 y\u2082 hm) m' hm'\n(by simp only [\u03b4_lift_cochain z \u2191y\u2081 y\u2082 hm hn\u2080 rfl m' hm', cocycle.\u03b4_eq_zero, cochain.zero_comp,\n    zsmul_zero, zero_add, hy])\n\n@[simps]\ndef lift_hom_as_cocycle {m\u2081 n\u2080 : \u2124} (y\u2081 : cocycle K F m\u2081) (y\u2082 : cochain K G 0) (hm : m\u2081+n=1)\n  (hn\u2080 : n\u2080+1=n)\n  (hy : \u03b4 0 1 y\u2082 + cochain.comp (y\u2081 : cochain K F m\u2081) \u2191z hm.symm = 0) : cocycle K (twist z) 0 :=\nlift_cocycle z y\u2081 y\u2082 (show 0+1 = m\u2081+n, by linarith) hn\u2080 1 (zero_add 1) hy\n\n@[simps]\ndef lift {m\u2081 n\u2080 : \u2124} (y\u2081 : cocycle K F m\u2081) (y\u2082 : cochain K G 0) (hm : m\u2081+n=1)\n  (hn\u2080 : n\u2080+1=n)\n  (hy : \u03b4 0 1 y\u2082 + cochain.comp (y\u2081 : cochain K F m\u2081) \u2191z hm.symm = 0) :\n  K \u27f6 twist z :=\ncocycle.hom_of (lift_hom_as_cocycle z y\u2081 y\u2082 hm hn\u2080 hy)\n\nlemma cochain_ext' (y\u2081 y\u2082 : cochain K (twist z) m) {n\u2081 m\u2081 : \u2124} (hn\u2081 : n+n\u2081=1) (hm\u2081 : m\u2081 = m+n\u2081) :\n  y\u2081 = y\u2082 \u2194 cochain.comp y\u2081 (fst z hn\u2081 : cochain (twist z) F n\u2081) hm\u2081\n      = cochain.comp y\u2082 (fst z hn\u2081 : cochain (twist z) F n\u2081) hm\u2081 \u2227\n  cochain.comp y\u2081 (snd z) (add_zero m).symm =\n  cochain.comp y\u2082 (snd z) (add_zero m).symm :=\nbegin\n  split,\n  { intro h, rw h, tauto, },\n  { rintro \u27e8hl, hr\u27e9,\n    suffices : cochain.comp y\u2081 (cochain.of_hom (\ud835\udfd9 _)) (add_zero m).symm =\n      cochain.comp y\u2082 (cochain.of_hom (\ud835\udfd9 _)) (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\u2081, cochain.add_comp,\n      cochain.comp_add],\n    simp only [\u2190 cochain.comp_assoc_of_second_is_zero_cochain,\n      \u2190 cochain.comp_assoc _ _ _ hm\u2081 (show 0=n\u2081+(n-1), by linarith)\n      (show m=m+n\u2081+(n-1), by linarith), hl, hr], },\nend\n\nlemma of_d_eq (n\u2081 n\u2082 n\u2083 : \u2124) (hn\u2081 : n + n\u2081 = 1) (hn\u2082 : n\u2082 = n\u2081+1) (hn\u2083 : n\u2083+1=n) : cochain.of_d (twist z) =\n  \u03b5 (n+1) \u2022 ((fst z hn\u2081 : cochain (twist z) F n\u2081).comp (cochain.of_d F) hn\u2082).comp (inl z hn\u2083)\n    (by rw [\u2190 hn\u2081, hn\u2082, \u2190 hn\u2083, add_comm n\u2083, add_assoc, add_comm n\u2083, \u2190 add_assoc, add_comm n\u2081]) +\n    ((fst z hn\u2081 : cochain (twist z) F n\u2081).comp (z : cochain F G n) (show 1 = n\u2081 + n, by rw [\u2190 hn\u2081, 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\u2083 hn\u2083.symm,\n  split,\n  { simp only [cochain.comp_add, cochain.comp_zsmul],\n    simp only [\u2190 cochain.comp_assoc_of_third_is_zero_cochain,\n      \u2190 cochain.comp_assoc_of_second_is_zero_cochain, inl_comp_snd, inl_comp_fst, cochain.id_comp,\n      \u2190 cochain.comp_assoc (inl z hn\u2083) _ _ (show 1 = n\u2083+n\u2082, by linarith) _ (show n = n\u2083+n\u2082+n\u2083, by linarith),\n      \u2190 cochain.comp_assoc (inl z hn\u2083) _ _ (show 0 = n\u2083 + n\u2081, by linarith) _ (show 1 = n\u2083 + n\u2081 + 1, by linarith),\n      \u2190 cochain.comp_assoc (inl z hn\u2083) _ _ (show 0 = n\u2083 + n\u2081, by linarith) (show 1 = n\u2081 + n, by linarith)\n      (show n = n\u2083+n\u2081+n, by linarith), cochain.zero_comp, add_zero,\n      cochain_ext' z _ _ hn\u2081 (show 1 = n+n\u2081, 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\u2083) _ (show n = 1+n\u2083, by linarith) (show 0 = n\u2083 + n\u2081, by linarith)\n        (show 1 = 1 + n\u2083 + n\u2081, by linarith), add_zero, cochain.comp_id],\n      ext p q hpq,\n      dsimp [inl, fst, cochain.comp],\n      simp only [twist.\u03b4, 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 : \u2203 (p' : \u2124), p = p' + 1 -n := \u27e8p+n-1, by linarith\u27e9,\n      obtain \u27e8p', hp'\u27e9 := hp,\n      subst hp',\n      rw cochain.comp_v _ _ hn\u2083.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.\u03b4, 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 [\u03b5_succ, neg_smul,\n      cochain.comp_add, cochain.comp_neg, cochain.comp_zsmul,\n      \u2190 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\u2081 (show n\u2082 = 1 + n\u2081, 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\u2082 = 1 + n\u2081, by linarith) p (p+1) q rfl (by linarith)],\n      dsimp [inr, fst],\n      simp only [twist.\u03b4, 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.\u03b4, 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 {\u03b1 : Type v} (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] : cofan X := cofan.mk\n{ val := (homotopy_category.colimit_cofan $ \u03bb a : \u03b1, (X a).val).X,\n  bdd := begin\n    obtain \u27e8n,hn\u27e9 := homotopy_category.is_uniformly_bounded_above.cond (val \u2218 X),\n      use n, intros i hi,\n    dsimp [homotopy_category.colimit_cofan],\n    let e : (\u2210 \u03bb (a : \u03b1), (X a).val.as).X i \u2245\n      (\u2210 \u03bb (a : \u03b1), (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(\u03bb a, (homotopy_category.colimit_cofan (\u03bb a : \u03b1, (X a).val)).\u03b9.app \u27e8a\u27e9)\n\nnoncomputable\ndef is_colimit_cofan {\u03b1 : Type v} (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] : is_colimit (cofan X) :=\n{ desc := \u03bb S, (homotopy_category.is_colimit_cofan\n    (\u03bb a : \u03b1, (X a).val)).desc ((forget A).map_cocone S),\n  fac' := begin\n    intros S j,\n    erw (homotopy_category.is_colimit_cofan (\u03bb a : \u03b1, (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 (\u03bb a : \u03b1, (X a).val)).hom_ext,\n    intros j,\n    specialize hm j,\n    erw hm,\n    erw (homotopy_category.is_colimit_cofan (\u03bb a : \u03b1, (X a).val)).fac,\n    refl,\n  end }\n\ninstance has_coproduct_of_uniform_bound {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] :\n  has_coproduct X :=\nbegin\n  constructor, apply nonempty.intro,\n  refine \u27e8cofan X, is_colimit_cofan X\u27e9,\nend\n\ninstance is_K_projective_sigma {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  [\u2200 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) \u2245 (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 {\u03b1 : Type v}\n  (X : \u03b1 \u2192 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) \u2245\n    homotopy_category.colimit_cofan (val \u2218 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  {\u03b1 : Type v}\n  (X P : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  [uniformly_bounded P]\n  (\u03c0 : \u03a0 a, P a \u27f6 X a)\n  [\u2200 a, homotopy_category.is_quasi_iso (\u03c0 a)] :\n  homotopy_category.is_quasi_iso\n    (sigma.desc $ \u03bb a : \u03b1, \u03c0 a \u226b sigma.\u03b9 X a : sigma_obj P \u27f6 sigma_obj X) :=\nbegin\n  let t := sigma.desc (\u03bb (a : \u03b1), \u03c0 a \u226b sigma.\u03b9 X a),\n  change homotopy_category.is_quasi_iso ((forget A).map t),\n  let eP : (forget A).obj (\u2210 P) \u2245 \u2210 (\u03bb a, (forget A).obj (P a)) :=\n    preserves_colimit_iso (forget A) _,\n  let eX : (forget A).obj (\u2210 X) \u2245 \u2210 (\u03bb a, (forget A).obj (X a)) :=\n    preserves_colimit_iso (forget A) _,\n  let s : \u2210 (\u03bb a, (forget A).obj (P a)) \u27f6 \u2210 (\u03bb a, (forget A).obj (X a)) :=\n    sigma.desc (\u03bb (a : \u03b1), \u03c0 a \u226b sigma.\u03b9 (val \u2218 X) a),\n  suffices : (forget A).map t = eP.hom \u226b s \u226b 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 [\u2190 (forget A).map_comp, colimit.\u03b9_desc],\n  slice_rhs 0 1\n  { erw (is_colimit_of_preserves (forget A) (colimit.is_colimit (discrete.functor P))).fac },\n  erw colimit.\u03b9_desc,\n  dsimp, simp only [category.assoc], erw colimit.\u03b9_desc,\n  dsimp, simp only [functor.map_comp], refl,\nend\n\nvariables [enough_projectives A]\n\nnoncomputable\ndef uniform_\u03c0 {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] : sigma_obj (replace_uniformly X) \u27f6 sigma_obj X :=\nsigma.desc $ \u03bb a, \u03c0_uniformly _ _ \u226b sigma.\u03b9 _ a\n\ninstance is_quasi_iso_sigma_map_\u03c0_uniformly\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] :\n  homotopy_category.is_quasi_iso (uniform_\u03c0 X) :=\nis_quasi_iso_sigma _ _ _\n\nopen opposite\n\nnoncomputable\ndef Ext_coproduct_iso\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  (i : \u2124) (Y) :\n  ((Ext i).obj (op (sigma_obj X))).obj Y \u2245\n  pi_obj (\u03bb a : \u03b1, ((Ext i).obj (op (X a))).obj Y) :=\nExt_iso i _ _ _ (uniform_\u03c0 X) \u226a\u226b\ncategory_theory.preadditive_yoneda_coproduct_iso (replace_uniformly X) (Y\u27e6i\u27e7) \u226a\u226b\ncategory_theory.pi_iso _ _ (\u03bb a, (Ext_iso i _ _ _ (\u03c0_uniformly X a)).symm)\n\nlemma \u03b9_Ext_coprodut_iso\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  (i : \u2124) (Y) (j) :\n  (Ext_coproduct_iso X i Y).inv \u226b\n  ((Ext i).map (sigma.\u03b9 X j : X j \u27f6 \u2210 X).op).app Y =\n  pi.\u03c0 _ _ :=\nbegin\n  rw iso.inv_comp_eq,\n  dsimp [Ext_coproduct_iso, pi_iso],\n  simp only [category.assoc, limit.lift_\u03c0, fan.mk_\u03c0_app],\n  simp only [\u2190 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_\u03c0],\n  ext t, simp only [comp_apply], dsimp,\n  simp only [\u2190 category.assoc], congr' 1,\n  apply lift_ext (\u2210 X).\u03c0, swap, apply_instance,\n  dsimp [uniform_\u03c0],\n  simp,\nend\n\nlemma \u03b9_Ext_coproduct_iso'\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  (i : \u2124) (Y) (j) :\n  (Ext_coproduct_iso X i Y).hom \u226b  pi.\u03c0 _ _ =\n  ((Ext i).map (sigma.\u03b9 X j : X j \u27f6 \u2210 X).op).app Y :=\nbegin\n  rw [\u2190 iso.eq_inv_comp, \u03b9_Ext_coprodut_iso],\nend\n\nlemma Ext_coproduct_iso_naturality\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X\u2081 X\u2082 : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X\u2081]\n  [uniformly_bounded X\u2082]\n  (g : X\u2081 \u27f6 X\u2082)\n  (i : \u2124) (Y) :\n  ((Ext i).map (sigma.desc (\u03bb b, g b \u226b sigma.\u03b9 X\u2082 b) : \u2210 X\u2081 \u27f6 \u2210 X\u2082).op).app Y \u226b\n  (Ext_coproduct_iso _ _ _).hom =\n  (Ext_coproduct_iso _ _ _).hom \u226b\n  pi.lift (\u03bb b, pi.\u03c0 _ b \u226b ((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_\u03c0, fan.mk_\u03c0_app, limit.lift_\u03c0_assoc],\n  simp only [\u2190 functor.map_comp, \u2190 op_comp],\n  congr' 2,\n  simp only [category.assoc],\n  apply lift_ext (\u2210 X\u2082).\u03c0, swap, apply_instance,\n  dsimp [quiver.hom.unop_op],\n  simp only [category.assoc, lift_lifts, lift_lifts_assoc],\n  dsimp [uniform_\u03c0],\n  simp only [colimit.\u03b9_desc_assoc, cofan.mk_\u03b9_app, category.assoc, colimit.\u03b9_desc,\n    lift_lifts_assoc],\nend\n\nlemma Ext_coproduct_iso_naturality'\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  (i : \u2124) (Y\u2081 Y\u2082) (f : Y\u2081 \u27f6 Y\u2082) :\n  ((Ext i).obj (op (sigma_obj X))).map f \u226b\n  (Ext_coproduct_iso _ _ _).hom =\n  (Ext_coproduct_iso _ _ _).hom \u226b\n  pi.lift (\u03bb a, pi.\u03c0 _ a \u226b ((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_\u03c0, fan.mk_\u03c0_app, limit.lift_\u03c0_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  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 chain_complex A \u2115) :\n  bounded_homotopy_category.uniformly_bounded\n  (\u03bb 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 {\u03b1 : Type v}\n  {C : Type u} {D : Type u'} [category.{v} C] [category.{v} D] (F : C \u2964 D)\n  (X : \u03b1 \u2192 C) : discrete.functor X \u22d9 F \u2245 discrete.functor (F.obj \u2218 X) :=\n  discrete.nat_iso (\u03bb i, iso.refl _)\n\nnoncomputable\nlemma preserves_coproducts_aux\n  {\u03b1 : Type v} {C : Type u} {D : Type u'}\n  [category.{v} C] [category.{v} D]\n  (F : C \u2964 D)\n  [has_coproducts_of_shape \u03b1 C]\n  [\u2200 (X : \u03b1 \u2192 C), has_coproduct (\u03bb a, F.obj (X a))]\n  (e : \u03a0 (X : \u03b1 \u2192 C), F.obj (\u2210 X) \u2245 \u2210 (\u03bb a, F.obj (X a)))\n  (he : \u2200 (X : \u03b1 \u2192 C) (a : \u03b1), F.map (sigma.\u03b9 X a) \u226b (e X).hom = sigma.\u03b9 _ a) :\n  preserves_colimits_of_shape (discrete \u03b1) F :=\nbegin\n  constructor, intros K,\n  let E : K \u2245 discrete.functor (K.obj \u2218 discrete.mk) := discrete.nat_iso (\u03bb \u27e8a\u27e9, 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 (\u03bb a : \u03b1, F.obj (K.obj \u27e8a\u27e9))),\n  apply_instance,\n  symmetry,\n  fapply cocones.ext,\n  apply e,\n  rintro \u27e8a\u27e9,\n  convert (he (\u03bb b, (K.obj \u27e8b\u27e9))) a,\n  dsimp [P', whisker_discrete_functor],\n  rw category.id_comp,\nend\n\nnoncomputable\ninstance homological_complex_embed_preserves_coproducts {\u03b1 : Type v}\n  {M N : Type} (c\u2081 : complex_shape M) (c\u2082 : complex_shape N) (e : c\u2081.embedding c\u2082) :\n  preserves_colimits_of_shape (discrete \u03b1)\n  (homological_complex.embed e : homological_complex A _ \u2964 _) :=\npreserves_coproducts_aux\n(homological_complex.embed e : homological_complex A _ \u2964 _)\n(\u03bb (X : \u03b1 \u2192 homological_complex A c\u2081), homological_complex.hom.iso_of_components\n(\u03bb i,\nbegin\n  rcases h : e.r i with _ | j,\n  { refine homological_complex.embed.X_iso_of_none _ h \u226a\u226b _,\n    refine _ \u226a\u226b (preserves_colimit_iso (homological_complex.eval A c\u2082 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 \u226a\u226b _,\n    refine (preserves_colimit_iso (homological_complex.eval _ _ _) _) \u226a\u226b _,\n    refine _ \u226a\u226b (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\u2081 : e.r i with _ | i';\n  rcases h\u2082 : 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\u2081, h\u2082], dsimp,\n    simp only [category.assoc],\n    rw \u2190 iso.eq_inv_comp,\n    dsimp [homological_complex.embed, homological_complex.embed.obj],\n    rw homological_complex.embed.d_of_some_of_some (\u2210 X) h\u2081 h\u2082,\n    simp only [category.assoc, iso.inv_hom_id_assoc],\n    apply (is_colimit_of_preserves (homological_complex.eval A c\u2081 i') _).hom_ext,\n    rintro \u27e8a\u27e9,\n    simp only [functor.map_cocone_\u03b9_app, colimit.cocone_\u03b9, homological_complex.eval_map],\n    slice_lhs 1 2 {\n      erw (is_colimit_of_preserves (homological_complex.eval A c\u2081 i') _).fac },\n    dsimp,\n    simp only [has_colimit.iso_of_nat_iso_\u03b9_hom, discrete.nat_iso_hom_app, iso.symm_hom,\n      category.assoc, \u03b9_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\u2081 j') _).fac },\n    dsimp,\n    simp only [has_colimit.iso_of_nat_iso_\u03b9_hom, discrete.nat_iso_hom_app, iso.symm_hom,\n      category.assoc, \u03b9_preserves_colimits_iso_inv, homological_complex.eval_map],\n    slice_rhs 1 3\n    { erw \u2190 homological_complex.embed.d_of_some_of_some (X a) h\u2081 h\u2082 },\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 [\u2190 category.assoc, iso.comp_inv_eq],\n  simp_rw [\u2190 iso.eq_comp_inv, category.assoc],\n  slice_rhs 1 2\n  { erw (is_colimit_of_preserves (homological_complex.eval A c\u2082 i) _).fac },\n  dsimp,\n  simp only [has_colimit.iso_of_nat_iso_\u03b9_inv, discrete.nat_iso_inv_app, iso.symm_inv,\n    category.assoc, \u03b9_preserves_colimits_iso_inv, homological_complex.eval_map],\n  apply homological_complex.embed.f_of_some,\nend\n\nnoncomputable\ndef embed_coproduct_iso\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 chain_complex A \u2115) :\n  (homological_complex.embed complex_shape.embedding.nat_down_int_up).obj (\u2210 X) \u2245\n  (\u2210 \u03bb (a : \u03b1), (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) _ \u226a\u226b\nhas_colimit.iso_of_nat_iso (whisker_discrete_functor _ _)\n\nnoncomputable\ndef chain_complex_embed_cofan_iso\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 chain_complex A \u2115) :\n  (bounded_homotopy_category.cofan\n    (\u03bb a, chain_complex.to_bounded_homotopy_category.obj (X a))) \u2245\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 \u27e8a\u27e9,\n  dsimp [bounded_homotopy_category.cofan,\n    homotopy_category.colimit_cofan, whisker_discrete_functor],\n  erw [category.id_comp, \u2190 functor.map_comp],\n  congr' 1,\n  dsimp [embed_coproduct_iso],\n  simp only [category.assoc],\n  erw colimit.\u03b9_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  {\u03b1 : Type v} :\n  preserves_colimits_of_shape (discrete \u03b1)\n  (chain_complex.to_bounded_homotopy_category : chain_complex A _ \u2964 _) :=\nbegin\n  constructor, intros K,\n  let E : K \u2245 discrete.functor (K.obj \u2218 discrete.mk) := discrete.nat_iso (\u03bb \u27e8a\u27e9, 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 : \u03b1 \u2192 bounded_homotopy_category A := \u03bb a,\n    chain_complex.to_bounded_homotopy_category.obj (K.obj \u27e8a\u27e9),\n  let P := _, change is_colimit P,\n  let T : discrete.functor (K.obj \u2218 discrete.mk) \u22d9 chain_complex.to_bounded_homotopy_category \u2245\n    discrete.functor Q := discrete.nat_iso (\u03bb _, 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}} {\u03bc : Type v}\n {I : Type u} (A : I \u2192 Type u) [(\u03b9 : I) \u2192 Inhabited (A \u03b9)] [s : (\u03b9 : I) \u2192 FirstOrder.Structure L (A \u03b9)] (\ud835\udce4 : Ultrafilter I)\n\nnamespace FirstOrder\n\nnamespace Structure\n\nstructure Uprod (\ud835\udce4 : Ultrafilter I) where\n  val : (i : I) \u2192 A i\n\ninstance UprodStruc : Structure.{u,u} L (Uprod A \ud835\udce4) where\n  func := fun f v => \u27e8fun \u03b9 => (s \u03b9).func f (fun i => (v i).val \u03b9)\u27e9\n  rel  := fun r v => {\u03b9 | (s \u03b9).rel r (fun i => (v i).val \u03b9)} \u2208 \ud835\udce4\n\ninstance [Inhabited I] [(\u03b9 : I) \u2192 Inhabited (A \u03b9)] : Inhabited (Uprod A \ud835\udce4) := \u27e8\u27e8default\u27e9\u27e9\n\n@[simp] lemma func_Uprod {k} (f : L.func k) (v : Fin k \u2192 Uprod A \ud835\udce4) :\n    func f v = \u27e8fun \u03b9 => (s \u03b9).func f (fun i => (v i).val \u03b9)\u27e9 := rfl\n\n@[simp] lemma rel_Uprod {k} (r : L.rel k) (v : Fin k \u2192 Uprod A \ud835\udce4) :\n    rel r v \u2194 {\u03b9 | (s \u03b9).rel r (fun i => (v i).val \u03b9)} \u2208 \ud835\udce4 := of_eq rfl\n\nend Structure\n\nend FirstOrder\n\nnamespace SubTerm\n\nopen FirstOrder Structure\n\nvariable (e : Fin n \u2192 Uprod A \ud835\udce4) (\u03b5 : \u03bc \u2192 Uprod A \ud835\udce4)\n\nlemma val_Uprod (t : SubTerm L \u03bc n) :\n    t.val! (Uprod A \ud835\udce4) e \u03b5 = \u27e8fun \u03b9 => t.val (s \u03b9) (fun i => (e i).val \u03b9) (fun i => (\u03b5 i).val \u03b9)\u27e9 :=\n  by induction t <;> simp[*, val_func]\n\nend SubTerm\n\nnamespace FirstOrder\n\nopen Structure\n\nvariable {A} {\ud835\udce4}\n\nnamespace SubFormula\nvariable {e : Fin n \u2192 Uprod A \ud835\udce4} {\u03b5 : \u03bc \u2192 Uprod A \ud835\udce4}\n\nlemma val_vecCons_val_eq {z : Uprod A \ud835\udce4} {\u03b9 : I} :\n    (z.val \u03b9 :> fun i => (e i).val \u03b9) = (fun i => ((z :> e) i).val \u03b9) :=\n  by simp[Matrix.comp_vecCons (Uprod.val \u00b7 \u03b9), Function.comp]\n\nlemma eval_Uprod {p : SubFormula L \u03bc n} :\n    Eval! (Uprod A \ud835\udce4) e \u03b5 p \u2194 {\u03b9 | Eval (s \u03b9) (fun i => (e i).val \u03b9) (fun i => (\u03b5 i).val \u03b9) p} \u2208 \ud835\udce4 := 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    \u00b7 intro h\n      let z : Uprod A \ud835\udce4 := \u27e8fun \u03b9 =>\n        Classical.epsilon (fun z => \u00acEval (s \u03b9) (z :> fun i => (e i).val \u03b9) (fun i => (\u03b5 i).val \u03b9) p)\u27e9\n      exact Filter.mem_of_superset (h z) (by \n        intro \u03b9 h\u03b9 a\n        have : Eval (s \u03b9) (z.val \u03b9 :> fun i => (e i).val \u03b9) (fun i => (\u03b5 i).val \u03b9) p :=\n          by rw [val_vecCons_val_eq]; exact h\u03b9\n        by_contra hc\n        have : \u00acEval! (A \u03b9) (z.val \u03b9 :> fun i => (e i).val \u03b9) (fun i => (\u03b5 i).val \u03b9) p :=\n          Classical.epsilon_spec (p := fun z => \u00ac(Eval (s \u03b9) (z :> fun i => (e i).val \u03b9) _ p)) \u27e8a, hc\u27e9\n        contradiction)\n    \u00b7 intro h x\n      exact Filter.mem_of_superset h (by intro \u03b9 h; simpa [val_vecCons_val_eq] using h (x.val \u03b9))\n  case hex p _ =>\n    constructor\n    \u00b7 rintro \u27e8x, hx\u27e9\n      exact Filter.mem_of_superset hx (by intro \u03b9 h; use x.val \u03b9; simpa[val_vecCons_val_eq] using h)\n    \u00b7 intro h\n      let z : Uprod A \ud835\udce4 := \u27e8fun \u03b9 =>\n        Classical.epsilon (fun z => Eval (s \u03b9) (z :> fun i => (e i).val \u03b9) (fun i => (\u03b5 i).val \u03b9) p)\u27e9\n      use z\n      exact Filter.mem_of_superset h (by\n        intro \u03b9; rintro \u27e8x, hx\u27e9\n        have : Eval (s \u03b9) (z.val \u03b9 :> fun i => (e i).val \u03b9) (fun i => (\u03b5 i).val \u03b9) p :=\n          Classical.epsilon_spec (p := fun z => Eval (s \u03b9) (z :> fun i => (e i).val \u03b9) _ p) \u27e8x, hx\u27e9\n        rw[val_vecCons_val_eq] at this; exact this)\n\nlemma val_Uprod {p : Formula L \u03bc} :\n    Val! (Uprod A \ud835\udce4) \u03b5 p \u2194 {\u03b9 | Val (s \u03b9) (fun i => (\u03b5 i).val \u03b9) p} \u2208 \ud835\udce4 :=\n  by simp[Val, eval_Uprod, Matrix.empty_eq]\n\nend SubFormula\n\nlemma realize_Uprod {\u03c3 : Sentence L} :\n    (Uprod A \ud835\udce4) \u22a7\u2081 \u03c3 \u2194 {\u03b9 | Semantics.realize (self := semantics) (s \u03b9) \u03c3} \u2208 \ud835\udce4 :=\n  by simp[realize_def, SubFormula.val_Uprod, Empty.eq_elim]\n\nvariable (A)\n\ndef SubFormula.domain (\u03c3 : Sentence L) := {\u03b9 | (A \u03b9) \u22a7\u2081 \u03c3}\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) // \u2191t \u2286 T}\n\nvariable (A : FinSubTheory T \u2192 Type u) [s : (\u03b9 : FinSubTheory T) \u2192 Structure L (A \u03b9)]\n\ninstance : Inhabited (FinSubTheory T) := \u27e8\u2205, by simp\u27e9\n\nattribute [instance] Classical.propDecidable in\nlemma ultrafilter_exists (H : \u2200 (\u03b9 : FinSubTheory T), (A \u03b9) \u22a7\u2081* (\u03b9.val : CTheory L)) :\n    \u2203 \ud835\udce4 : Ultrafilter (FinSubTheory T), Set.image (SubFormula.domain A) T \u2286 \ud835\udce4.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 \u03c3 h\u03c3\n    exact H \u27e8t, ht\u27e9 h\u03c3)\n\ntheorem compactness :\n    Semantics.Satisfiable\u209b T \u2194 \u2200 \u03b9 : FinSubTheory T, Semantics.Satisfiable\u209b (\u03b9.val : CTheory L) := by\n  constructor\n  \u00b7 rintro h \u27e8t, ht\u27e9; exact Semantics.satisfiable\u209b_of_subset h ht\n  \u00b7 intro h\n    have : \u2200 \u03b9 : FinSubTheory T, \u2203 (M : Type u) (_ : Inhabited M) (_ : Structure L M), M \u22a7\u2081* (\u03b9.val : CTheory L) := \n      by intro \u03b9; exact satisfiable\u209b_iff.mp (h \u03b9)\n    choose A si s hA using this\n    have : \u2203 \ud835\udce4 : Ultrafilter (FinSubTheory T), Set.image (SubFormula.domain A) T \u2286 \ud835\udce4.sets := ultrafilter_exists A hA\n    rcases this with \u27e8\ud835\udce4, h\ud835\udce4\u27e9\n    have : Structure.Uprod A \ud835\udce4 \u22a7\u2081* T := by intro \u03c3 h\u03c3; exact realize_Uprod.mpr (h\ud835\udce4 $ Set.mem_image_of_mem (SubFormula.domain A) h\u03c3)\n    exact satisfiable\u209b_intro (Structure.Uprod A \ud835\udce4) 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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (((a1).write i2 ((a1).read i1)).read i1) \u2260 ((a1).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test78.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.538983220687684, "lm_q2_score": 0.4378234991142019, "lm_q1q2_score": 0.2359795196453239}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v2) \u2260 ((((a1).write i1 (v2)).write i2 (v2)).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test7.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.45713671682749485, "lm_q1q2_score": 0.23570879540448897}}
{"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 := \u27e8@continuous_id, @continuous.comp\u27e9\n\n-- local attribute [class] continuous\n-- instance {R S : Top} (f : R \u27f6 S) : continuous (f : R \u2192 S) := f.2\nend Top\n\nstructure open_set (X : Top.{u}) : Type u :=\n(s : set X.\u03b1)\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.\u03b1) := { coe := \u03bb U, U.s }\n\ninstance : has_subset (open_set X) :=\n{ subset := \u03bb U V, U.s \u2286 V.s }\n\ninstance : preorder (open_set X) := by refine { le := (\u2287), .. } ; tidy\n\ninstance open_sets : small_category (open_set X) := by apply_instance\n\ninstance : has_mem X.\u03b1 (open_set X) :=\n{ mem := \u03bb a V, a \u2208 V.s }\n\ndef nbhd (x : X.\u03b1) := { U : open_set X // x \u2208 U }\ndef nbhds (x : X.\u03b1) : 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 \u27f6 Y) : open_set Y \u2964 open_set X :=\n{ obj := \u03bb U, \u27e8 f.val \u207b\u00b9' U.s, f.property _ U.is_open \u27e9,\n  map' := \u03bb U V i, \u27e8 \u27e8 \u03bb a b, i.down.down b \u27e9 \u27e9 }.\n\n@[simp] lemma map_id_obj (X : Top.{u}) (U : open_set X) : map (\ud835\udfd9 X) U = U :=\nbegin\n  cases U, tidy\nend\n\n@[simp] def map_id (X : Top.{u}) : map (\ud835\udfd9 X) \u2245 functor.id (open_set X) := \n{ hom := { app := \u03bb U, \ud835\udfd9 U },\n  inv := { app := \u03bb U, \ud835\udfd9 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 \u27f6 Y) (h : f = g) : map f \u2245 map g := \nnat_iso.of_components (\u03bb 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 (\ud835\udfd9 X) (\ud835\udfd9 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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i2 (v2)).write i1 (v2)).read i2) \u2260 (v2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test22.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.2354791944714021}}
{"text": "import Smt\n\ntheorem index : \"a\".get 0 = 'a' := by\n  smt\n  rfl\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/Test/String/GetOp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4532618480153861, "lm_q1q2_score": 0.23547919447140206}}
{"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\u2081 v\u2082 u\u2081 u\u2082\n\nnamespace category_theory.graphs\n\ndef paths (C : Type u\u2082) := C\n\ninstance paths_category (C : Type u\u2081) [graph.{v\u2081} C] : category.{(max u\u2081 v\u2081)+1} (paths C) :=\n{ hom     := \u03bb x y : C, path x y,\n  id      := \u03bb x, path.nil x,\n  comp    := \u03bb _ _ _ 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\u2081) [graph.{u\u2081 u\u2081} C] : small_category (paths C) := graphs.paths_category C\n\nvariables {C : Type u\u2082} [\ud835\udc9e : category.{v\u2082} C] {G : Type u\u2081} [\ud835\udca2 : graph.{v\u2081} G]\ninclude \ud835\udca2 \ud835\udc9e\n\n@[simp] def path_to_morphism\n  (H : graph_hom G C)\n  : \u03a0 {X Y : G}, path X Y \u2192 ((H.onVertices X) \u27f6 (H.onVertices Y))\n| ._ ._ (path.nil Z)              := \ud835\udfd9 (H.onVertices Z)\n| ._ ._ (@path.cons ._ _ _ _ _ e p) := (H.onEdges e) \u226b (path_to_morphism p)\n\n@[simp] lemma path_to_morphism.comp (H : graph_hom G C) {X Y Z : paths G} (f : X \u27f6 Y) (g : Y \u27f6 Z) : path_to_morphism H (f \u226b g) = path_to_morphism H f \u226b 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\u2082} [\ud835\udc9e : category.{v\u2082} C] {G : Type u\u2081} [\ud835\udca2 : graph.{v\u2081} G]\ninclude \ud835\udca2 \ud835\udc9e\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) \u2964 C :=\n{ obj := \u03bb X, (H.onVertices X),\n  map := \u03bb _ _ 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<u>\n-- -----------------------------\n-- C<\u22a4> \u2228 u = \u22a5     C<\u22a5> \u2228 u = \u22a4\n--\n-- where u is of type Prop, but neither \u22a5 nor \u22a4, 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 \u2192 Prop) (e : Prop) (H : f e) : f True \u2228 e = False :=\n  @Classical.byCases e _\n    (fun p => have h : e = True := by simp [p];\n              Or.inl (h \u25b8 H))\n    (fun np => by simp [np])\n\ntheorem bool_hoist_proof (f : Prop \u2192 Prop) (e : Prop) (H : f e) : f False \u2228 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 \u25b8 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) \u2190 instantiatePremises parents premises xs transferExprs\n    let parentLits := parentsLits[0]!\n    let appliedPremise := appliedPremises[0]!\n\n    let i := pos.lit\n    let \u27e8s, p\u27e9 := 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 := \u27e8s, p\u27e9\n        let f \u2190 Meta.withLocalDeclD `h (.sort .zero) fun h => do\n          let lit' \u2190 lit.replaceAtPos! lp h\n          let f := lit'.toExpr\n          Meta.mkLambdaFVars #[h] f\n        let e \u2190 lit.getAtPos! lp\n        let pr \u2190 Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let mut pr := h\n          if sgn then\n            pr \u2190 Meta.mkAppM ``loob_hoist_proof #[f, e, h]\n          else\n            pr \u2190 Meta.mkAppM ``bool_hoist_proof #[f, e, h]\n          Meta.mkLambdaFVars #[h] $ \u2190 orSubclause (cLits.map Lit.toExpr) 2 pr\n        caseProofs := caseProofs.push pr\n      else\n        -- need proof of `L_j \u2192 L_1 \u2228 ... \u2228 L_n`\n        let pr \u2190 Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let idx := if j \u2265 i then j - 1 else j\n          Meta.mkLambdaFVars #[h] $ \u2190 orIntro (cLits.map Lit.toExpr) idx h\n        caseProofs := caseProofs.push pr\n    \n    let r \u2190 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 \u00d7 Proof))) :=\n  withoutModifyingMCtx do\n    let ty \u2190 inferType e\n    if ty == .sort .zero then\n      let l := pos.lit\n      let \u27e8s, p\u27e9 := 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 \u2227 c.lits[l]!.sign\n      if is_true \u2228 is_false \u2228 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          #[\u2190 litl.replaceAtPos! \u27e8s, p\u27e9 (mkConst ``True), Lit.fromSingleExpr e false]\n        trace[Rule.identBoolHoist] s!\"New Clause: {nc.lits.map Lit.toExpr}\"\n        let cp1 \u2190 yieldClause nc \"identity loobHoist\" (some (mkBoolHoistProof pos true))\n        let nc := c_erased.appendLits\n          #[\u2190 litl.replaceAtPos! \u27e8s, p\u27e9 (mkConst ``False), Lit.fromSingleExpr e true]\n        trace[Rule.identBoolHoist] s!\"New Clause: {nc.lits.map Lit.toExpr}\"\n        let cp2 \u2190 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 \u2190 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 \u2964 D) {A\u2081 A\u2082 A\u2083 X : C} {f : A\u2081 \u27f6 A\u2082} {g : A\u2082 \u27f6 A\u2083}\nvariables [abelian C] [abelian D] [additive F] [preserves_finite_colimits F]\n\nsection les\n\ndef \u03b4\u2080 (A : short_exact_sequence C) := \u03b4 F 0 A \u226b (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    \u03b4\u2080 F A,\n    F.map A.f, F.map A.g, (0 : F.obj A.3 \u27f6 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) (\u03b4 F 0 A) _ _\n      (iso.refl _) (iso.refl _) ((left_derived_zero_iso_self F).app A.1) (by simp) _ _,\n    { dsimp [\u03b4\u2080], 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' (\u03b4 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 [\u03b4\u2080], 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 [\u2190 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 \u27e8U, R, \u27e8e\u27e9\u27e9 := X.local_affine x,\n  have hy := (h' _ U.1.2).mp U.2,\n  erw \u2190 subtype_indistinguishable_iff (\u27e8x, U.2\u27e9 : U.1.1) (\u27e8y, hy\u27e9 : U.1.1) at h',\n  let e' : U.1 \u2243\u209c prime_spectrum R :=\n    homeo_of_iso ((LocallyRingedSpace.forget_to_SheafedSpace \u22d9 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 \u27e8x, U.2\u27e9 \u27e8y, hy\u27e9 (by simpa using h) h'\nend\n\ninstance : quasi_sober X.carrier :=\nbegin\n  apply_with (quasi_sober_of_open_cover\n    (set.range (\u03bb x, set.range $ (X.affine_cover.map x).1.base)))\n    { instances := ff },\n  { rintro \u27e8_,i,rfl\u27e9, exact (X.affine_cover.is_open i).base_open.open_range },\n  { rintro \u27e8_,i,rfl\u27e9,\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 \u27e8_, \u27e8_, rfl\u27e9, X.affine_cover.covers x\u27e9 }\nend\n\n/-- A scheme `X` is reduced if all `\ud835\udcaa\u2093(U)` are reduced. -/\nclass is_reduced : Prop :=\n(component_reduced : \u2200 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 [\u2200 x : X.carrier, _root_.is_reduced (X.presheaf.stalk x)] :\n  is_reduced X :=\nbegin\n  refine \u27e8\u03bb U, \u27e8\u03bb s hs, _\u27e9\u27e9,\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 \u27e8n, e\u27e9,\n  obtain \u27e8U, hxU, s, rfl\u27e9 := X.presheaf.germ_exist x g,\n  rw [\u2190 map_pow, \u2190 map_zero (X.presheaf.germ \u27e8x, hxU\u27e9)] at e,\n  obtain \u27e8V, hxV, iU, iV, e'\u27e9 := 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 \u2190 concrete_category.congr_hom (X.presheaf.germ_res iU \u27e8x, hxV\u27e9) s,\n  rw [comp_apply, e', map_zero]\nend\n\nlemma is_reduced_of_open_immersion {X Y : Scheme} (f : X \u27f6 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 _ \u2245 _).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) \u2194 _root_.is_reduced R :=\nbegin\n  refine \u27e8_, \u03bb h, by exactI infer_instance\u27e9,\n  intro h,\n  resetI,\n  haveI : _root_.is_reduced (LocallyRingedSpace.\u0393.obj (op $ Spec.to_LocallyRingedSpace.obj $ op R)),\n  { change _root_.is_reduced ((Scheme.Spec.obj $ op R).presheaf.obj $ op \u22a4), apply_instance },\n  exact is_reduced_of_injective (to_Spec_\u0393 R)\n    ((as_iso $ to_Spec_\u0393 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 \u22a4))] : is_reduced X :=\nbegin\n  haveI : is_reduced (Scheme.Spec.obj (op (Scheme.\u0393.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 \u27f6 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 : \u2200 (X : Scheme) (U : opens X.carrier), Prop)\n  (h\u2081 : \u2200 (X : Scheme) (U : opens X.carrier),\n    (\u2200 (x : U), \u2203 {V} (h : x.1 \u2208 V) (i : V \u27f6 U), P X V) \u2192 P X U)\n  (h\u2082 : \u2200 {X Y} (f : X \u27f6 Y) [hf : is_open_immersion f], \u2203 {U : set X.carrier} {V : set Y.carrier}\n    (hU : U = \u22a4) (hV : V = set.range f.1.base), P X \u27e8U, hU.symm \u25b8 is_open_univ\u27e9 \u2192\n      P Y \u27e8V, hV.symm \u25b8 hf.base_open.open_range\u27e9)\n  (h\u2083 : \u2200 (R : CommRing), P (Scheme.Spec.obj $ op R) \u22a4) :\n  \u2200 (X : Scheme) (U : opens X.carrier), P X U :=\nbegin\n  intros X U,\n  apply h\u2081,\n  intro x,\n  obtain \u27e8_,\u27e8j,rfl\u27e9,hx,i\u27e9 := X.affine_basis_cover_is_basis.exists_subset_of_mem_open x.prop U.2,\n  let U' : opens _ := \u27e8_, (X.affine_basis_cover.is_open j).base_open.open_range\u27e9,\n  let i' : U' \u27f6 U :=\n    hom_of_le i,\n  refine \u27e8U', hx, i', _\u27e9,\n  obtain \u27e8_,_,rfl,rfl,h\u2082'\u27e9 := h\u2082 (X.affine_basis_cover.map j),\n  apply h\u2082',\n  apply h\u2083\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 = \u2205) :\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 \u27e8V, hx, i, H\u27e9 := hx x,\n    unfreezingI { specialize H (X.presheaf.map i.op s) },\n    erw Scheme.basic_open_res at H,\n    rw [hs, \u2190 subtype.coe_injective.eq_iff, opens.empty_eq, opens.inter_eq, inf_bot_eq] at H,\n    specialize H rfl \u27e8x, hx\u27e9,\n    erw Top.presheaf.germ_res_apply at H,\n    exact H },\n  { rintros X Y f hf,\n    have e : (f.val.base) \u207b\u00b9' set.range \u21d1(f.val.base) = \u22a4,\n    { rw [\u2190 set.image_univ, set.preimage_image_eq _ hf.base_open.inj, set.top_eq_univ] },\n    refine \u27e8_, _, e, rfl, _\u27e9,\n    rintros H hX s hs \u27e8_, x, rfl\u27e9,\n    unfreezingI { haveI := is_reduced_of_open_immersion f },\n    specialize H (f.1.c.app _ s) _ \u27e8x, by { change x \u2208 (f.val.base) \u207b\u00b9' _, rw e, trivial }\u27e9,\n    { rw [\u2190 Scheme.preimage_basic_open, hs], ext1, simp [opens.map] },\n    { erw \u2190 PresheafedSpace.stalk_map_germ_apply f.1 \u27e8_,_\u27e9 \u27e8x,_\u27e9 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_\u0393_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 \u22a4 }\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 = \u22a5 \u2194 s = 0 :=\nbegin\n  refine \u27e8eq_zero_of_basic_open_empty s, _\u27e9,\n  rintro rfl,\n  simp,\nend\n\n/-- A scheme `X` is integral if its carrier is nonempty,\nand `\ud835\udcaa\u2093(U)` is an integral domain for each `U \u2260 \u2205`. -/\nclass is_integral : Prop :=\n(nonempty : nonempty X.carrier . tactic.apply_instance)\n(component_integral : \u2200 (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 \u22a4)) :=\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 = \u2205 := 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 : \u00ac is_preirreducible (\u22a4 : set X.carrier) := \u03bb h,\n    H { to_preirreducible_space := \u27e8h\u27e9, to_nonempty := infer_instance },\n  simp_rw [is_preirreducible_iff_closed_union_closed, not_forall, not_or_distrib] at H,\n  rcases H with \u27e8S, T, hS, hT, h\u2081, h\u2082, h\u2083\u27e9,\n  erw not_forall at h\u2082 h\u2083,\n  simp_rw not_forall at h\u2082 h\u2083,\n  haveI : nonempty (\u27e8S\u1d9c, hS.1\u27e9 : opens X.carrier) := \u27e8\u27e8_, h\u2082.some_spec.some_spec\u27e9\u27e9,\n  haveI : nonempty (\u27e8T\u1d9c, hT.1\u27e9 : opens X.carrier) := \u27e8\u27e8_, h\u2083.some_spec.some_spec\u27e9\u27e9,\n  haveI : nonempty (\u27e8S\u1d9c, hS.1\u27e9 \u2294 \u27e8T\u1d9c, hT.1\u27e9 : opens X.carrier) :=\n    \u27e8\u27e8_, or.inl h\u2082.some_spec.some_spec\u27e9\u27e9,\n  let e : X.presheaf.obj _ \u2245 CommRing.of _ := (X.sheaf.is_product_of_disjoint \u27e8_, hS.1\u27e9 \u27e8_, hT.1\u27e9 _)\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 \u27e8hS,hT\u27e9,\n      cases h\u2081 (show x \u2208 \u22a4, 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 \u03bb U hU, \u27e8\u03bb a b e, _,\n    (@@LocallyRingedSpace.component_nontrivial X.to_LocallyRingedSpace U hU).1\u27e9,\n  simp_rw [\u2190 basic_open_eq_bot_iff, \u2190 opens.not_nonempty_iff_eq_bot],\n  by_contra' h,\n  obtain \u27e8_, \u27e8x, hx\u2081, rfl\u27e9, \u27e8x, hx\u2082, e'\u27e9\u27e9 := @@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\u2081.mul hx\u2082,\n  exact e.symm\nend\n\nlemma is_integral_iff_is_irreducible_and_is_reduced :\n  is_integral X \u2194 irreducible_space X.carrier \u2227 is_reduced X :=\n\u27e8\u03bb _, by exactI \u27e8infer_instance, infer_instance\u27e9,\n  \u03bb \u27e8_, _\u27e9, by exactI is_integral_of_is_irreducible_is_reduced X\u27e9\n\nlemma is_integral_of_open_immersion {X Y : Scheme} (f : X \u27f6 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 \u27e8\u27e8_, _, hU.some.prop, rfl\u27e9\u27e9 },\n  exact (as_iso $ f.1.c.app (op $ H.base_open.is_open_map.functor.obj U) :\n    Y.presheaf.obj _ \u2245 _).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) \u2194 is_domain R :=\n\u27e8\u03bb h, by exactI ring_equiv.is_domain ((Scheme.Spec.obj $ op R).presheaf.obj _)\n  (as_iso $ to_Spec_\u0393 R).CommRing_iso_to_ring_equiv, \u03bb h, by exactI infer_instance\u27e9\n\nlemma is_integral_of_is_affine_is_domain [is_affine X] [nonempty X.carrier]\n  [h : is_domain (X.presheaf.obj (op \u22a4))] : is_integral X :=\nbegin\n  haveI : is_integral (Scheme.Spec.obj (op (Scheme.\u0393.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 \u27f6 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 \u2190 basic_open_eq_bot_iff at \u22a2 hx,\n  rw Scheme.basic_open_res at hx,\n  revert hx,\n  contrapose!,\n  simp_rw [\u2190 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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i1 (v3)).write i2 (v3)).read i1) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test19.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.2352212495409584}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a1).write i3 (v2)).write i1 (v2)).read i3) \u2260 (v2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test61.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.4493926344647596, "lm_q1q2_score": 0.23522124954095838}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((a1).read i2) \u2260 (((a1).write i1 ((a1).read i2)).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test36.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.23493508547998251}}
{"text": "import analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  -- Let $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$.\n  assume A : set (euclidean_space \u211d (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 : \u2203 C : set (euclidean_space \u211d (fin n)), is_open_cover C \u2227 is_locally_finite C \u2227 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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  \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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 (\u03c3 : Type)\n@[reducible]\nprivate def pred := pred' \u03c3\nparameters {p : nondet.program \u03c3}\nparameters {term : pred}\nparameters {c : code p.lbl p.first term}\n\nparameter Hterm : \u2200 ae : p.lbl, term \u27f9 -p.coarse_sch_of ae\n\nstructure state :=\n  (pc : option (current c))\n  (intl : \u03c3)\n  (assertion : assert_of pc intl)\n\nparameter {\u03c3}\nparameter Hcorr : \u2200 pc, state_correctness p c pc\n\n-- include Hcorr\n\nsection event\n\nparameter (e : p.lbl)\nparameter (s : state)\nparameter (h\u2080 : selects s.pc e)\nparameter (h\u2081 : true)\n\nsection implicit\n\ninclude h\u2081\n\ntheorem evt_guard\n: p.guard e s.intl :=\n(Hcorr s.pc).enabled e h\u2080 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\u2227 match action_of e with\n   | (sum.inr \u27e8l,hl\u27e9) :=\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: \u2203 (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 \u2190 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 _ _ \u27e8CS,FS,H\u27e9,\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 := \u03bb s, some cur = s.pc\n  , fine_sch   := True\n  , step := \u03bb s hc _ s', machine.step cur s hc s'\n  , fis  := \u03bb 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 := \u03bb \u27e8s\u2080,s\u2081,_\u27e9, s\u2080 = first c \u2227 p.first s\u2081\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 \u27e8rfl,Hs\u27e9\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) = (\u03bb 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 = (\u03bb s', \u2203 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 \u2192 Prop\n  | (some e) := selects l e\n  | none     := is_control l \u2228 l = none\n\nlemma ref_sim (ec : option mch_of.lbl)\n: \u27e6mch_of.step_of ec\u27e7 \u27f9\n      \u2203\u2203 (ea : {ea // rel ec ea}), \u27e6p.step_of (ea.val) on state.intl\u27e7 :=\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 \u27e8Hen.left,Hen.right,H.right\u27e9, }, },\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 (\u03bb s : state, selects s.pc e) (leads_to mch_of)\n\n@[trans]\ndef lt_sched_trans\n  {\u03b1} (\u03b2) {\u03b3 : pred' state}\n  (h\u2080 : lt_sched \u03b1 \u03b2)\n  (h\u2081 : lt_sched \u03b2 \u03b3)\n: lt_sched \u03b1 \u03b3 :=\nh\u2081 <<< h\u2080\n\nlocal infix `  \u21a6.  `:60 := lt_sched\n\nlemma evt_leads_to_aux\n: (\u03bb s : state, within H s.pc)\n    \u21a6.\n  (\u03bb 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\u2080 H\u2081,\n      apply counter_action_of_within H\u2080 H\u2081, },\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\u2080 Hstep\u2081,\n      rw [Hstep\u2080,\u2190 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\u2080,\n      right,\n      unfold exits,\n      have Hp := counter_action_of_within Hp Hnq\u2080,\n      rw [\u2190 next_counter_action s.intl H, Hp],\n      symmetry,\n      apply Hstep.left, }, },\n  case code.seq p\u2080 q r c\u2080 c\u2081 ih_1 ih_2 H\n  { have Pright : lt_sched Hcorr e\n                  (\u03bb (s : state), within H.right (s.pc))\n                  (\u03bb (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                 (\u03bb (s : state), within H.left (s.pc))\n                 (\u03bb (s : state), exits H (s.pc)),\n    { apply lt_sched_trans Hcorr e (\u03bb (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 \u22c0 (p.event ea).fine_sch) \u2218 state.intl\n    \u21a6\n      -(p.coarse_sch_of ea \u2218 state.intl)\n      \u22c1 \u2203\u2203 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 \u2218 state.intl),\n    -- type_check entails_trans (term \u2218 state.intl),\n    refine entails_trans (term \u2218 state.intl) _ _,\n    { intro s, simp [exits],\n      intro H,\n      have Hasrt := s.assertion,\n      rw \u2190 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 \u22c0 p.fine_sch_of ea) \u2218 state.intl \u22c0 True\n  \u22c0 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 \u22c0 (p.event ea).fine_sch) \u2218 state.intl\n    >~>\n      -(p.coarse_sch_of ea \u2218 state.intl)\n      \u22c1 \u2203\u2203 ec : { ec // rel ec ea }, True \u22c0 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 \u22c0 mch_of.coarse_sch_of ec)\n      (-(p.coarse_sch_of ea \u2218 state.intl))\n      { e | \u2203 (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\u2080 H\u2081 H\u2082,\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\u2081 Hc,\n  cases ec with ec Hec,\n  specialize Hexcp ec Hec,\n  cases ec with ec,\n  { right, trivial, },\n  simp at H\u2081,\n  exfalso, apply Hexcp,\n  dsimp [program.event,code.semantics.mch_of,program.event,machine.event] at H\u2081 Hc,\n  rw \u2190 Hc at H\u2081,\n  rw H\u2081,\n  refl\nend\n\nlemma evt_sim\n:    \u27e6mch_of.step_of (ec.val)\u27e7\n \u27f9 \u27e6p.step_of ea on state.intl\u27e7 :=\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                \u2192 (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               \u2192 (p.event' ea).coarse_sch (s.intl),\n      { apply and.left \u2218 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\u2080 _, rw H\u2080,\n        cases pc with pc P, cases P with P\u2080 P\u2081,\n        cases not_selects_and_is_control Hec P\u2080, } } },\n  case none\n  { cases ec with ec ;\n    simp [program.event],\n    { have Hcs : nondet.skip.coarse_sch s \u2192 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\u2080,\n              cases ea with ea Hea\u2081,\n              cases not_selects_and_is_control Hea\u2081 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      (\u03bb (ec : {ec // rel ec ea}), mch_of.event (ec.val)) :=\n{ witness := \u03bb _, 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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (((a2).write i3 ((a2).read i1)).read i1) \u2260 ((a2).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test63.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.43782349911420193, "lm_q1q2_score": 0.23427866639181413}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (((a2).write i1 ((a2).read i3)).read i3) \u2260 ((a2).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test18.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.43782349911420193, "lm_q1q2_score": 0.23427866639181408}}
{"text": "import condensed.Qprime_isoms\n\n.\n\nnoncomputable theory\n\nuniverses v u u\u2081 u\u2082\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 \u27f6 N)\n\nlemma homology_functor_iso_natural'\n  (C\u2081 C\u2082 : cochain_complex (Profinite.{u}\u1d52\u1d56 \u2964 Ab.{u+1}) \u2124) (g : C\u2081 \u27f6 C\u2082)\n  (S : Profinite.{u}\u1d52\u1d56) (i : \u2124) :\n  (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj S).homology_functor_iso (complex_shape.up \u2124) i).inv.app C\u2081 \u226b\n  ((homology_functor (Profinite.{u}\u1d52\u1d56 \u2964 Ab.{u+1}) (complex_shape.up \u2124) i).map g).app S =\n  category_theory.functor.map _ g \u226b\n      (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj S).homology_functor_iso (complex_shape.up \u2124) i).inv.app C\u2082 :=\n((((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj S).homology_functor_iso _ i).inv.naturality g).symm\n\nlemma homology_functor_iso_natural (S : ExtrDisc\u1d52\u1d56) (i : \u2124) :\n  (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj\n      (op (unop S).val)).homology_functor_iso (complex_shape.up \u2124) i).inv.app\n    ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M)) \u226b\n  ((homology_functor (Profinite\u1d52\u1d56 \u2964 Ab) (complex_shape.up \u2124) 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)) \u226b\n      (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj\n        (op (unop S).val)).homology_functor_iso (complex_shape.up \u2124) 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\u1d52\u1d56) :\n  ((((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj (op (unop S).val)).map_homological_complex\n        (complex_shape.up \u2124)).map\n       ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))).f\n      (int.of_nat 0) \u226b\n    (eval_freeAb_iso.component_zero BD N (unop S)).hom =\n  (eval_freeAb_iso.component_zero BD M (unop S)).hom \u226b\n    ((BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free)).map\n       (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 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    \u2190 functor.map_comp], congr' 2,\n  apply biproduct.hom_ext, intro j,\n  simp only [category.assoc],\n  erw [biproduct.lift_\u03c0, biproduct.map_\u03c0, biproduct.lift_\u03c0_assoc],\n  simp only [functor.map_bicone_\u03c0, biproduct.bicone_\u03c0, evaluation_obj_map],\n  simp only [\u2190 nat_trans.comp_app], congr' 1,\n  rw [biproduct.map_\u03c0], refl,\nend\n\nlemma eval_freeAb_iso_component_natural_neg (S : ExtrDisc\u1d52\u1d56) (n : \u2115) :\n((((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj (op (unop S).val)).map_homological_complex\n        (complex_shape.up \u2124)).map\n       ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))).f\n      -[1+ n] \u226b\n    (eval_freeAb_iso.component_neg BD N (unop S) n).hom =\n  (eval_freeAb_iso.component_neg BD M (unop S) n).hom \u226b\n    ((BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free)).map\n       (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 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    \u2190 functor.map_comp], congr' 2,\n  apply biproduct.hom_ext, intro j,\n  simp only [category.assoc],\n  erw [biproduct.lift_\u03c0, biproduct.map_\u03c0, biproduct.lift_\u03c0_assoc],\n  simp only [functor.map_bicone_\u03c0, biproduct.bicone_\u03c0, evaluation_obj_map],\n  simp only [\u2190 nat_trans.comp_app], congr' 1,\n  rw [biproduct.map_\u03c0], refl,\nend\n\nlemma eval_freeAb_iso_component_natural (S : ExtrDisc\u1d52\u1d56) :\n(eval_freeAb_iso_component BD M (unop S)).inv \u226b\n    (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj (op (unop S).val)).map_homological_complex\n       (complex_shape.up \u2124)).map\n      ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f)) =\n  (BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free)).map\n      (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj (op (unop S).val)).map f.val) \u226b\n    (eval_freeAb_iso_component BD N (unop S)).inv :=\nbegin\n  rw [iso.inv_comp_eq, \u2190 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\u1d52\u1d56) (i : \u2124) :\n  (homology_functor AddCommGroup (complex_shape.up \u2124) i).map (eval_freeAb_iso_component BD M (unop S)).inv \u226b\n  (((category_theory.evaluation Profinite\u1d52\u1d56 Ab).obj (op (unop S).val)).map_homological_complex\n       (complex_shape.up \u2124) \u22d9\n     homology_functor Ab (complex_shape.up \u2124) 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}\u1d52\u1d56 Ab.{u+1}).obj\n      (op (unop S).val)).map f.val)) \u226b\n    (homology_functor AddCommGroup (complex_shape.up \u2124) i).map (eval_freeAb_iso_component BD N (unop S)).inv :=\nbegin\n  rw [functor.comp_map, \u2190 functor.map_comp, \u2190 functor.map_comp], congr' 1,\n  apply eval_freeAb_iso_component_natural,\nend\n\nlemma tensor_to_unsheafified_homology_natural'_aux (S : ExtrDisc\u1d52\u1d56) (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) \u226b\n    ((category_theory.evaluation Profinite\u1d52\u1d56 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 \u27e8\u27e9,\n  rw [free_abelian_group.lift.of, comp_apply, free_abelian_group.lift.of],\n  refl\nend\n\nlemma aaaahrg (i : \u2124) {A B : Ab} (f : A \u27f6 B) :\n  (homotopy_category.homology_functor AddCommGroup (complex_shape.up \u2124) i).map\n  ((BD.eval (forget AddCommGroup \u22d9 AddCommGroup.free)).map f) =\n  (homology_functor AddCommGroup (complex_shape.up \u2124) i).map\n  ((BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free)).map f) :=\nrfl\n\nlemma tensor_to_unsheafified_homology_natural' (i : \u2124) :\n  tensor_to_unsheafified_homology BD M i \u226b\n    whisker_left ExtrDisc_to_Profinite.op\n      ((homology_functor (Profinite\u1d52\u1d56 \u2964 Ab) (complex_shape.up \u2124) 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      (\ud835\udfd9 (((BD.eval (forget AddCommGroup \u22d9 AddCommGroup.free)).obj (AddCommGroup.free.obj punit)).val.as.homology i))).val \u226b\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 [\u2190 comp_apply, category.assoc], congr' 1,\n  rw homology_functor_iso_natural,\n  simp only [\u2190 category.assoc], congr' 1, simp only [category.assoc],\n  rw eval_freeAb_iso_component_natural_bis,\n  simp only [\u2190 category.assoc], congr' 1,\n  rw [tensor_to_unsheafified_homology_natural'_aux],\n  rw [aaaahrg, aaaahrg, \u2190 category_theory.functor.map_comp, \u2190 category_theory.functor.map_comp],\nend\n\nlemma tensor_to_homology_natural (i : \u2124) :\n  tensor_to_homology.{u} BD M i \u226b (homology_functor (Condensed.{u} Ab.{u+1}) _ i).map\n      ((BD.eval' freeCond').map f) =\n  map_tensor f (\ud835\udfd9 _) \u226b tensor_to_homology.{u} BD N i :=\nbegin\n  simp only [tensor_to_homology, category.assoc, \u2190 functor.map_comp,\n    eval_freeCond'_iso_component_natural],\n  simp only [functor.map_comp],\n  simp only [\u2190 category.assoc], refine congr_arg2 _ _ rfl, simp only [category.assoc],\n  have := (homology_functor_sheafification_iso (complex_shape.up \u2124) i).hom.naturality\n    ((Condensed_Ab_to_presheaf \u22d9 BD.eval' freeFunc).map f),\n  erw [\u2190 this], clear this,\n  simp only [\u2190 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}\u1d52\u1d56 \u2964 Ab.{u+1}) _ i \u22d9\n      presheaf_to_Condensed_Ab).map ((Condensed_Ab_to_presheaf \u22d9 BD.eval' freeFunc.{u u+1}).map f)),\n  erw [\u2190 this], clear this,\n  simp only [\u2190 category.assoc], refine congr_arg2 _ _ rfl, simp only [category.assoc],\n  dsimp only [map_tensor, functor.comp_map],\n  simp only [\u2190 functor.map_comp], congr' 1,\n  have := ExtrDisc_sheafification_iso.hom.naturality\n    ((homology_functor (Profinite.{u}\u1d52\u1d56 \u2964 Ab.{u+1}) _ i).map\n      ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))),\n  erw [\u2190 this], clear this,\n  simp only [\u2190 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, \u2190 grothendieck_topology.sheafify_map_comp],\n  rw [tensor_to_unsheafified_homology_natural'],\nend\n\nlemma homology_bd_eval_natural\n  [\u2200 S : ExtrDisc.{u}, no_zero_smul_divisors \u2124 (M.val.obj (op S.val))]\n  [\u2200 S : ExtrDisc.{u}, no_zero_smul_divisors \u2124 (N.val.obj (op S.val))] (i : \u2124) :\n  (homology_bd_eval BD M i).inv \u226b (homology_functor _ _ i).map ((BD.eval' freeCond').map f) =\n  map_tensor f (\ud835\udfd9 _) \u226b (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 Lean\nimport Duper.DUnif.UnifRules\nopen Lean\n\nnamespace DUnif\n\n-- Note: This is copied from standard library with some code\n--       removed to make it simpler and a few lines changed to\n--       allow for higher-order unification\n\nprivate def throwApplyError {\u03b1} (mvarId : MVarId) (eType : Expr) (targetType : Expr) : MetaM \u03b1 :=\n  Meta.throwTacticEx `apply mvarId m!\"failed to unify{indentExpr eType}\\nwith{indentExpr targetType}\"\n\n/--\nClose the given goal using `apply e`.\n-/\ndef execdapply (mvarId : MVarId) (e : Expr) (nAttempt : Nat) (nUnif : Nat) (cont : Nat) (cfg : Meta.ApplyConfig := {}) : MetaM (List MVarId) :=\n  mvarId.withContext do\n    mvarId.checkNotAssigned `apply\n    let targetType \u2190 mvarId.getType\n    let targetMVars \u2190 Meta.getMVarsNoDelayed targetType\n    let eType      \u2190 Meta.inferType e\n    let (numArgs, hasMVarHead) \u2190 Meta.getExpectedNumArgsAux eType\n    /-\n    The `apply` tactic adds `_`s to `e`, and some of these `_`s become new goals.\n    When `hasMVarHead` is `false` we try different numbers, until we find a type compatible with `targetType`.\n    We used to try only `numArgs-targetTypeNumArgs` when `hasMVarHead = false`, but this is not always correct.\n    For example, consider the following example\n    ```\n    example {\u03b1 \u03b2} [LE_trans \u03b2] (x y z : \u03b1 \u2192 \u03b2) (h\u2080 : x \u2264 y) (h\u2081 : y \u2264 z) : x \u2264 z := by\n      apply le_trans\n      assumption\n      assumption\n    ```\n    In this example, `targetTypeNumArgs = 1` because `LE` for functions is defined as\n    ```\n    instance {\u03b1 : Type u} {\u03b2 : Type v} [LE \u03b2] : LE (\u03b1 \u2192 \u03b2) where\n      le f g := \u2200 i, f i \u2264 g i\n    ```\n    -/\n    let rangeNumArgs \u2190 if hasMVarHead then\n      pure [numArgs : numArgs+1]\n    else\n      let targetTypeNumArgs \u2190 Meta.getExpectedNumArgs targetType\n      pure [numArgs - targetTypeNumArgs : numArgs+1]\n    /-\n    Auxiliary function for trying to add `n` underscores where `n \u2208 [i: rangeNumArgs.stop)`\n    See comment above\n    -/\n    let rec go (i : Nat) : MetaM (Array Expr \u00d7 Array BinderInfo) := do\n      if i < rangeNumArgs.stop then\n        let s \u2190 saveState\n        let (newMVars, binderInfos, eType) \u2190 Meta.forallMetaTelescopeReducing eType i\n        if (\u2190 hounif eType targetType nAttempt nUnif cont true) then\n          return (newMVars, binderInfos)\n        else\n          s.restore\n          go (i+1)\n      else\n        let (_, _, eType) \u2190 Meta.forallMetaTelescopeReducing eType (some rangeNumArgs.start)\n        throwApplyError mvarId eType targetType\n    let (newMVars, binderInfos) \u2190 go rangeNumArgs.start\n    Meta.postprocessAppMVars `apply mvarId newMVars binderInfos cfg.synthAssignedInstances\n    let e \u2190 instantiateMVars e\n    mvarId.assign (mkAppN e newMVars)\n    let newMVars \u2190 newMVars.filterM fun mvar => not <$> mvar.mvarId!.isAssigned\n    -- Collect other mvars\n    let mut otherMVarIds \u2190 Meta.getMVarsNoDelayed e\n    for m in targetMVars do\n      for mvarId in (\u2190 Meta.getMVarsNoDelayed (.mvar m)) do\n        if !otherMVarIds.contains mvarId then\n          otherMVarIds := otherMVarIds.push mvarId\n    let newMVarIds := (newMVars.map (\u00b7.mvarId!)).data\n    otherMVarIds := otherMVarIds.filter fun mvarId => !newMVarIds.contains mvarId\n    let result := newMVarIds ++ otherMVarIds.toList\n    trace[Meta.Tactic] \"{result}\"\n    result.forM (\u00b7.headBetaType)\n    return result\ntermination_by go i => rangeNumArgs.stop - i\n\nsyntax (name := dapply) \"dapply \" term \" attempt \" num \"unifier \" num \"contains\" num : tactic\n\n@[tactic dapply]\ndef evaldapply : Elab.Tactic.Tactic := fun stx =>\n  match stx with\n  | `(tactic| dapply $e attempt $nAttempt unifier $nunif contains $cont) => Elab.Tactic.withMainContext do\n    let mut val \u2190 instantiateMVars (\u2190 Elab.Tactic.elabTermForApply e)\n    if val.isMVar then\n      Elab.Term.synthesizeSyntheticMVarsNoPostponing\n      val \u2190 instantiateMVars val\n    let mvarIds' \u2190 execdapply (\u2190 Elab.Tactic.getMainGoal) val nAttempt.getNat nunif.getNat cont.getNat\n    Elab.Term.synthesizeSyntheticMVarsNoPostponing\n    Elab.Tactic.replaceMainGoal mvarIds'\n  | _ => Elab.throwUnsupportedSyntax", "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/DUnif/DApply.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.538983220687684, "lm_q2_score": 0.43398146480389854, "lm_q1q2_score": 0.23390872761876402}}
{"text": "import analysis.normed.group.SemiNormedGroup.kernels\nimport algebra.homology.additive\n\nnamespace SemiNormedGroup\n\nprotected class strict_iso {A B : SemiNormedGroup} (f : A \u2245 B) :=\n(strict_hom' : \u2200 a : A, \u2225f.hom a\u2225\u208a = \u2225a\u2225\u208a)\n\n@[simp]\nlemma strict_iso_hom {A B : SemiNormedGroup} (f : A \u2245 B) [strict_iso f] (a : A) :\n  \u2225f.hom a\u2225\u208a = \u2225a\u2225\u208a := strict_iso.strict_hom' _\n\n@[simp]\nlemma strict_iso_inv {A B : SemiNormedGroup} (f : A \u2245 B) [strict_iso f] (b : B) :\n  \u2225f.inv b\u2225\u208a = \u2225b\u2225\u208a :=\nbegin\n  have : b = f.hom (f.inv b),\n  { change b = (f.inv \u226b 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 \u2115) :=\n(iso : C \u2245 D)\n[is_strict : \u2200 i : \u2115, SemiNormedGroup.strict_iso $ (homological_complex.eval _ _ i).map_iso iso]\n\ninstance (C D : cochain_complex SemiNormedGroup \u2115) (f : strict_iso C D) (n : \u2115) :\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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (((a1).write i3 ((a1).read i2)).read i2) \u2260 ((a1).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test67.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5428632831725052, "lm_q2_score": 0.4301473485858429, "lm_q1q2_score": 0.23351120190125874}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i3 (v3)).write i2 (v3)).read i3) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test48.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4493926344647597, "lm_q1q2_score": 0.23346905553266567}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i1 (v2)).write i2 (v2)).read i1) \u2260 (v2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test38.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4493926344647597, "lm_q1q2_score": 0.23346905553266567}}
{"text": "variables x : Type \n\nconstant duh : \u2115\nconstant doh : \u2115 \nconstant dah : \u2115 \n\nlemma exercise : x = x := by sorry\n\nlemma exercise2 : 1 + 1 = 2 := by sorry\n\n", "meta": {"author": "gihanmarasingha", "repo": "lean_autograder_test", "sha": "a795df730fa6ca760be6d85b11b581b569682621", "save_path": "github-repos/lean/gihanmarasingha-lean_autograder_test", "path": "github-repos/lean/gihanmarasingha-lean_autograder_test/lean_autograder_test-a795df730fa6ca760be6d85b11b581b569682621/src/assignment.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": "\nlemma eq_mp_heq :\n  \u2200 {\u03b1 \u03b2 : Sort*} {a : \u03b1} {a' : \u03b2} (h\u2082 : a == a'), (eq.mp (type_eq_of_heq h\u2082) a) = a'\n| \u03b1 ._ 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 \u2192 F\nvariable  \u03c3 : 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 \u03c3.pc\n    (h_mem : mem_at mem code_get_point_from_x \u03c3.pc)\n    -- all dependencies are in memory\n    (h_mem_0 : mem_at mem code_assert_nn (\u03c3.pc  - 751))\n    (h_mem_1 : mem_at mem code_assert_le (\u03c3.pc  - 747))\n    (h_mem_2 : mem_at mem code_assert_nn_le (\u03c3.pc  - 742))\n    (h_mem_4 : mem_at mem code_nondet_bigint3 (\u03c3.pc  - 719))\n    (h_mem_5 : mem_at mem code_unreduced_mul (\u03c3.pc  - 707))\n    (h_mem_6 : mem_at mem code_unreduced_sqr (\u03c3.pc  - 687))\n    (h_mem_7 : mem_at mem code_verify_zero (\u03c3.pc  - 671))\n    (h_mem_9 : mem_at mem code_reduce (\u03c3.pc  - 612))\n    (h_mem_10 : mem_at mem code_validate_reduced_field_element (\u03c3.pc  - 599))\n    -- input arguments on the stack\n    (hin_range_check_ptr : range_check_ptr = mem (\u03c3.fp - 7))\n    (hin_x : x = cast_BigInt3 mem (\u03c3.fp - 6))\n    (hin_v : v = mem (\u03c3.fp - 3))\n    -- conclusion\n  : ensures_ret mem \u03c3 (\u03bb \u03ba \u03c4,\n      \u2203 \u03bc \u2264 \u03ba, rc_ensures mem (rc_bound F) \u03bc (mem (\u03c3.fp - 7)) (mem $ \u03c4.ap - 7)\n        (spec_get_point_from_x mem \u03ba range_check_ptr x v (mem (\u03c4.ap - 7)) (cast_EcPoint mem (\u03c4.ap - 6)))) :=\nbegin\n  apply ensures_of_ensuresb, intro \u03bdbound,\n  have h_mem_rec := h_mem,\n  unpack_memory code_get_point_from_x at h_mem with \u27e8hpc0, 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\u27e9,\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 \u03ba_call6 ap6 h_call6,\n  rcases h_call6 with \u27e8h_call6_ap_offset, h_call6\u27e9,\n  rcases h_call6 with \u27e8rc_m6, rc_mle6, hl_range_check_ptr\u2081, h_call6\u27e9,\n  generalize' hr_rev_range_check_ptr\u2081: mem (ap6 - 1) = range_check_ptr\u2081,\n  have htv_range_check_ptr\u2081 := hr_rev_range_check_ptr\u2081.symm, clear hr_rev_range_check_ptr\u2081,\n  try { simp only [arg0 ,arg1] at hl_range_check_ptr\u2081 },\n  rw [\u2190htv_range_check_ptr\u2081, \u2190hin_range_check_ptr] at hl_range_check_ptr\u2081,\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\u2081] },\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 \u03ba_call11 ap11 h_call11,\n  rcases h_call11 with \u27e8h_call11_ap_offset, h_call11\u27e9,\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\u2081 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\u2081, 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\u2081, 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 \u03ba_call17 ap17 h_call17,\n  rcases h_call17 with \u27e8h_call17_ap_offset, h_call17\u27e9,\n  rcases h_call17 with \u27e8rc_m17, rc_mle17, hl_range_check_ptr\u2082, h_call17\u27e9,\n  generalize' hr_rev_range_check_ptr\u2082: mem (ap17 - 4) = range_check_ptr\u2082,\n  have htv_range_check_ptr\u2082 := hr_rev_range_check_ptr\u2082.symm, clear hr_rev_range_check_ptr\u2082,\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\u2082 },\n  try { rw [h_call11_ap_offset] at hl_range_check_ptr\u2082 }, try { arith_simps at hl_range_check_ptr\u2082 },\n  rw [\u2190htv_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2081] at hl_range_check_ptr\u2082,\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 [\u2190htv_range_check_ptr\u2081, hl_range_check_ptr\u2081, 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\u2081, htv_x_square, htv_range_check_ptr\u2082, 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\u2081, htv_x_square, htv_range_check_ptr\u2082, 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 \u03ba_call25 ap25 h_call25,\n  rcases h_call25 with \u27e8h_call25_ap_offset, h_call25\u27e9,\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 \u03c3.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\u2082 _ _),\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\u2081, htv_x_square, htv_range_check_ptr\u2082, 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 \u03ba_call31 ap31 h_call31,\n  rcases h_call31 with \u27e8h_call31_ap_offset, h_call31\u27e9,\n  rcases h_call31 with \u27e8rc_m31, rc_mle31, hl_range_check_ptr\u2083, h_call31\u27e9,\n  generalize' hr_rev_range_check_ptr\u2083: mem (ap31 - 4) = range_check_ptr\u2083,\n  have htv_range_check_ptr\u2083 := hr_rev_range_check_ptr\u2083.symm, clear hr_rev_range_check_ptr\u2083,\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\u2083 },\n  try { rw [h_call25_ap_offset] at hl_range_check_ptr\u2083 }, try { arith_simps at hl_range_check_ptr\u2083 },\n  rw [\u2190htv_range_check_ptr\u2083, \u2190htv_range_check_ptr\u2082] at hl_range_check_ptr\u2083,\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 [\u2190htv_range_check_ptr\u2082, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 (\u03c3.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\u2083 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\u2081, htv_x_square, htv_range_check_ptr\u2082, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr\u2083, 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\u2081, htv_x_square, htv_range_check_ptr\u2082, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr\u2083, 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 \u03ba_call40 ap40 h_call40,\n  rcases h_call40 with \u27e8rc_m40, rc_mle40, hl_range_check_ptr\u2084, h_call40\u27e9,\n  generalize' hr_rev_range_check_ptr\u2084: mem (ap40 - 1) = range_check_ptr\u2084,\n  have htv_range_check_ptr\u2084 := hr_rev_range_check_ptr\u2084.symm, clear hr_rev_range_check_ptr\u2084,\n  try { simp only [arg0 ,arg1 ,arg2 ,arg3] at hl_range_check_ptr\u2084 },\n  rw [\u2190htv_range_check_ptr\u2084, \u2190htv_range_check_ptr\u2083] at hl_range_check_ptr\u2084,\n  try { simp only [arg0 ,arg1 ,arg2 ,arg3] at h_call40 },\n  rw [\u2190htv_range_check_ptr\u2083, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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_\u03b440_c0 : \u2200 x : F, x / (2 : \u2124) = x * (-1809251394333065606848661391547535052811553607665798349986546028067936010240 : \u2124),\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_\u03b440_c0_fz : \u2200 x : F, x / 2 = x / (2 : \u2124), { intro x, norm_cast }, \n  step_sub hpc44 (auto_sound_assert_nn mem _ range_check_ptr\u2084 ((y.d0 + v) / (2 : \u2124)) _ _ _),\n  { rw hpc45, norm_num2, exact h_mem_0 },\n  { try { simp only [h_\u03b440_c0_fz, h_\u03b440_c0] }, try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr\u2081, htv_x_square, htv_range_check_ptr\u2082, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr\u2083, htv_y, lc_y, htv_range_check_ptr\u2084] },\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_\u03b440_c0_fz, h_\u03b440_c0] }, try { simp only [add_neg_eq_sub, hin_range_check_ptr, hin_x, hin_v, htv_range_check_ptr\u2081, htv_x_square, htv_range_check_ptr\u2082, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr\u2083, htv_y, lc_y, htv_range_check_ptr\u2084] },\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 \u03ba_call46 ap46 h_call46,\n  rcases h_call46 with \u27e8h_call46_ap_offset, h_call46\u27e9,\n  rcases h_call46 with \u27e8rc_m46, rc_mle46, hl_range_check_ptr\u2085, h_call46\u27e9,\n  generalize' hr_rev_range_check_ptr\u2085: mem (ap46 - 1) = range_check_ptr\u2085,\n  have htv_range_check_ptr\u2085 := hr_rev_range_check_ptr\u2085.symm, clear hr_rev_range_check_ptr\u2085,\n  try { simp only [arg0 ,arg1 ,arg2] at hl_range_check_ptr\u2085 },\n  rw [\u2190htv_range_check_ptr\u2085, \u2190htv_range_check_ptr\u2084] at hl_range_check_ptr\u2085,\n  try { simp only [arg0 ,arg1 ,arg2] at h_call46 },\n  rw [\u2190htv_range_check_ptr\u2084, hl_range_check_ptr\u2084, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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\u2081, htv_x_square, htv_range_check_ptr\u2082, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr\u2083, htv_y, lc_y, htv_range_check_ptr\u2084, htv_range_check_ptr\u2085] },\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 \u03ba_call51 ap51 h_call51,\n  rcases h_call51 with \u27e8h_call51_ap_offset, h_call51\u27e9,\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\u2085 {\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\u2081, htv_x_square, htv_range_check_ptr\u2082, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr\u2083, htv_y, lc_y, htv_range_check_ptr\u2084, htv_range_check_ptr\u2085, 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\u2081, htv_x_square, htv_range_check_ptr\u2082, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr\u2083, htv_y, lc_y, htv_range_check_ptr\u2084, htv_range_check_ptr\u2085, 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 \u03ba_call59 ap59 h_call59,\n  rcases h_call59 with \u27e8h_call59_ap_offset, h_call59\u27e9,\n  rcases h_call59 with \u27e8rc_m59, rc_mle59, hl_range_check_ptr\u2086, h_call59\u27e9,\n  generalize' hr_rev_range_check_ptr\u2086: mem (ap59 - 1) = range_check_ptr\u2086,\n  have htv_range_check_ptr\u2086 := hr_rev_range_check_ptr\u2086.symm, clear hr_rev_range_check_ptr\u2086,\n  try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4] at hl_range_check_ptr\u2086 },\n  try { rw [h_call51_ap_offset] at hl_range_check_ptr\u2086 }, try { arith_simps at hl_range_check_ptr\u2086 },\n  rw [\u2190htv_range_check_ptr\u2086, \u2190htv_range_check_ptr\u2085] at hl_range_check_ptr\u2086,\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 [\u2190htv_range_check_ptr\u2085, hl_range_check_ptr\u2085, hl_range_check_ptr\u2084, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u2190htv_range_check_ptr\u2086, hl_range_check_ptr\u2086, hl_range_check_ptr\u2085, hl_range_check_ptr\u2084, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u03ba_call6],\n  use_only [range_check_ptr\u2081],\n  have rc_h_range_check_ptr\u2081 := range_checked_offset' rc_h_range_check_ptr,\n  have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n  have spec6 := h_call6 rc_h_range_check_ptr',\n  rw [\u2190hin_range_check_ptr, \u2190htv_range_check_ptr\u2081] at spec6,\n  try { dsimp at spec6, arith_simps at spec6 },\n  use_only [spec6],\n  use_only [\u03ba_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 [\u03ba_call17],\n  use_only [range_check_ptr\u2082],\n  use_only [x_square_reduced],\n  have rc_h_range_check_ptr\u2082 := range_checked_offset' rc_h_range_check_ptr\u2081,\n  have rc_h_range_check_ptr\u2082' := range_checked_add_right rc_h_range_check_ptr\u2082, try { norm_cast at rc_h_range_check_ptr\u2082' },\n  have spec17 := h_call17 rc_h_range_check_ptr\u2081',\n  rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190htv_range_check_ptr\u2082] at spec17,\n  try { dsimp at spec17, arith_simps at spec17 },\n  use_only [spec17],\n  use_only [\u03ba_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 [\u03ba_call31],\n  use_only [range_check_ptr\u2083],\n  use_only [y],\n  have rc_h_range_check_ptr\u2083 := range_checked_offset' rc_h_range_check_ptr\u2082,\n  have rc_h_range_check_ptr\u2083' := range_checked_add_right rc_h_range_check_ptr\u2083, try { norm_cast at rc_h_range_check_ptr\u2083' },\n  have spec31 := h_call31 rc_h_range_check_ptr\u2082',\n  rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2083] at spec31,\n  try { dsimp at spec31, arith_simps at spec31 },\n  use_only [spec31],\n  use_only [\u03ba_call40],\n  use_only [range_check_ptr\u2084],\n  have rc_h_range_check_ptr\u2084 := range_checked_offset' rc_h_range_check_ptr\u2083,\n  have rc_h_range_check_ptr\u2084' := range_checked_add_right rc_h_range_check_ptr\u2084, try { norm_cast at rc_h_range_check_ptr\u2084' },\n  have spec40 := h_call40 rc_h_range_check_ptr\u2083',\n  rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190hl_range_check_ptr\u2083, \u2190htv_range_check_ptr\u2084] at spec40,\n  try { dsimp at spec40, arith_simps at spec40 },\n  use_only [spec40],\n  use_only [\u03ba_call46],\n  use_only [range_check_ptr\u2085],\n  have rc_h_range_check_ptr\u2085 := range_checked_offset' rc_h_range_check_ptr\u2084,\n  have rc_h_range_check_ptr\u2085' := range_checked_add_right rc_h_range_check_ptr\u2085, try { norm_cast at rc_h_range_check_ptr\u2085' },\n  have spec46 := h_call46 rc_h_range_check_ptr\u2084',\n  rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190hl_range_check_ptr\u2083, \u2190hl_range_check_ptr\u2084, \u2190htv_range_check_ptr\u2085] at spec46,\n  try { dsimp at spec46, arith_simps at spec46 },\n  use_only [spec46],\n  use_only [\u03ba_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 [\u03ba_call59],\n  use_only [range_check_ptr\u2086],\n  have rc_h_range_check_ptr\u2086 := range_checked_offset' rc_h_range_check_ptr\u2085,\n  have rc_h_range_check_ptr\u2086' := range_checked_add_right rc_h_range_check_ptr\u2086, try { norm_cast at rc_h_range_check_ptr\u2086' },\n  have spec59 := h_call59 rc_h_range_check_ptr\u2085',\n  rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190hl_range_check_ptr\u2083, \u2190hl_range_check_ptr\u2084, \u2190hl_range_check_ptr\u2085, \u2190htv_range_check_ptr\u2086] 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\u2081, htv_x_square, htv_range_check_ptr\u2082, htv_x_square_reduced, htv_x_cube, lc_x_cube, htv_range_check_ptr\u2083, htv_y, lc_y, htv_range_check_ptr\u2084, htv_range_check_ptr\u2085, htv_y_square, htv_range_check_ptr\u2086] }, },\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 \u2964 D) {A\u2081 A\u2082 A\u2083 X : C} {f : A\u2081 \u27f6 A\u2082} {g : A\u2082 \u27f6 A\u2083}\nvariables [abelian C] [abelian D] [additive F] [preserves_finite_colimits F]\n\nsection les\n\ndef \u03b4\u2080 (A : short_exact_sequence C) := \u03b4 F 0 A \u226b (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    \u03b4\u2080 F A,\n    F.map A.f, F.map A.g, (0 : F.obj A.3 \u27f6 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) (\u03b4 F 0 A) _ _\n      (iso.refl _) (iso.refl _) ((left_derived_zero_iso_self F).app A.1) (by simp) _ _,\n    { dsimp [\u03b4\u2080], 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' (\u03b4 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 [\u03b4\u2080], 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 [\u2190 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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a1).write i1 (v2)).write i3 (v2)).read i1) \u2260 (v2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test60.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.44552953503957266, "lm_q1q2_score": 0.23319922469185134}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i3 (v2)).write i2 (v2)).read i3) \u2260 (v2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test29.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5234203489363239, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.2331992246918513}}
{"text": "import lib.tactic\nimport tactic.rewrite_all\n\nimport .data\n\nuniverse u\n\nmeta inductive how\n| rewrite (rule_index : \u2115) (location : \u2115) (addr : option (list side))\n| defeq\n| simp  -- TODO handle \"explaining\" me\nmeta def how.to_string : how \u2192 format\n| (how.rewrite idx loc addr) := format!\"rewrite {idx} {loc} {addr.iget.to_string}\"\n| how.defeq := \"(defeq)\"\n| how.simp := \"simp\"\nmeta instance how.has_to_format : has_to_format how := \u27e8how.to_string\u27e9\n\nmeta structure rewrite :=\n(e   : expr)\n(prf : tactic expr) -- we defer constructing the proofs until they are needed\n(how : how)\n\nnamespace tactic.rewrite_search\n\nstructure config :=\n(max_iterations  : \u2115 := 500)\n(max_discovers   : \u2115 := 0)\n(optimal         : bool := tt)\n(exhaustive      : bool := ff)\n(trace           : bool := ff)\n(trace_summary   : bool := ff)\n(trace_rules     : bool := ff)\n(trace_discovery : bool := tt)\n(explain         : bool := ff)\n(explain_using_conv : bool := tt)\n\nend tactic.rewrite_search\n\nopen tactic\n\nnamespace rw_equation\n\nmeta def split : expr \u2192 tactic (expr \u00d7 expr)\n| `(%%lhs = %%rhs) := return (lhs, rhs)\n| `(%%lhs \u2194 %%rhs) := return (lhs, rhs)\n| _                := fail \"target is not an equation or iff\"\n\nmeta def lhs (e : expr) : tactic expr := prod.fst <$> split e\n\nmeta def rhs (e : expr) : tactic expr := prod.snd <$> split e\n\nend rw_equation\n\nmeta def is_acceptable_rewrite (t : expr) : bool :=\nt.is_eq_or_iff_after_binders\n\nmeta def is_acceptable_lemma (r : expr) : tactic bool :=\n  is_acceptable_rewrite <$> (infer_type r >>= whnf)\n\nmeta def is_acceptable_hyp (r : expr) : tactic bool :=\n  do t \u2190 infer_type r >>= whnf, return $ is_acceptable_rewrite t \u2227 \u00act.has_meta_var\n", "meta": {"author": "semorrison", "repo": "lean-rewrite-search", "sha": "e804b8f2753366b8957be839908230ee73f9e89f", "save_path": "github-repos/lean/semorrison-lean-rewrite-search", "path": "github-repos/lean/semorrison-lean-rewrite-search/lean-rewrite-search-e804b8f2753366b8957be839908230ee73f9e89f/src/tactic/rewrite_search/core/common.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5774953651858118, "lm_q2_score": 0.40356685373537454, "lm_q1q2_score": 0.2330579875747992}}
{"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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a3).write i2 (v1)).write i1 (v1)).read i2) \u2260 (v1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test44.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5312093733737563, "lm_q2_score": 0.43782349911420193, "lm_q1q2_score": 0.23257594661276054}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v1) \u2260 ((((a1).write i1 (v1)).write i2 (v1)).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test58.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.4610167793123159, "lm_q1q2_score": 0.2323091998129193}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (((a2).write i3 ((a2).read i2)).read i2) \u2260 ((a2).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test68.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.43398146480389854, "lm_q1q2_score": 0.23222279986964123}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v3) \u2260 ((((a1).write i3 (v3)).write i1 (v3)).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test30.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.23194161390836884}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v1) \u2260 ((((a2).write i1 (v1)).write i3 (v1)).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test54.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041652, "lm_q2_score": 0.45326184801538616, "lm_q1q2_score": 0.2319416139083688}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a1).write i1 (v3)).write i2 (v3)).read i1) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test16.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.4493926344647597, "lm_q1q2_score": 0.23171579230926334}}
{"text": "import feather_model.basic\n\nopen_locale classical\n\nopen feather_model\n\n@[reducible] def \ud835\udd4b := 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 := \u03bb v, {v},\n  bound := id,\n  subst := \u03bb v e f, if v \u2208 f then f.erase v \u222a e else f,\n  is_type := \u03bb _ _, true,\n  runtime_ok := \u03bb _, true,\n  rir_ok := \u03bb _, true,\n  runtime_judgments := \u03bb _, true,\n  rir_judgments := \u03bb _, true,\n  defeq := \u03bb _ _ _ _, true,\n  sort := \u03bb _, \u2205,\n  representable := \u03bb s f, f,\n}\n\ninstance : type_data (finset V) := \u27e8\u03bb _ _, true, \u03bb _, true\u27e9\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 \ud835\udd4b := 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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i2 (v3)).write i1 (v3)).read i2) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test76.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.23146209301246015}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a3).write i1 (v3)).write i2 (v3)).read i1) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test41.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.23146209301246015}}
{"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 \u00d7 message_t))\n\ndef lookup_updatef {A : Type u} [decidable_eq A] {B : A \u2192 Type v}\n  (a : A) (f : B a \u2192 B a) (m : \u2200 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 \u2192 Type v}\n  (a : A) (b : B a) : (\u2200 a, B a) \u2192 (\u2200 a, B a)\n:= lookup_updatef a (\u03bb _, b)\n\nlemma lookup_update_refl {A : Type u} [decidable_eq A] {B : A \u2192 Type v}\n  {a : A} {b : B a} {f : \u2200 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 \u2192 Type v}\n  {a a' : A} {b : B a} {f : \u2200 a, B a} (H : a \u2260 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 \u2192 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 \u2192 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') \u2190 option.precondition (elapsed < bound \u2227 0 < elapsed),\n  idx \u2190 list.check_member_st (\u03bb p : socket \u00d7 message_t, p.snd = mess) incoming.messages,\n  sockidx \u2190 list.check_member idx.to_member.value.fst sockets, --any other checks necessary?\n  some (poll_result.message \u27e8 elapsed, H \u27e9 sockidx mess H')\n\ndef agent_label.to_dlabel\n  (incoming : incoming_items) {ag : agent}\n: \u2200 (a_next : act ag.state_type), agent_label \u2192 option (dlabel a_next)\n| (act.poll ports sockets bound cont) (agent_label.mk plabel ms) := do\n   r \u2190 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 \u2192 global_state_t :=\n  lookup_updatef a_ip (\u03bb i : incoming_items, {i with messages := (rn, m) :: i.messages })\n\ndef dlabel_to_label {A} : \u2200 {a_next : act A}, dlabel a_next \u2192 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 : \u2200 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 \u00d7 message_t))\n   (updatef : global_state_t \u2192 global_state_t)\n  : global_state_t \u2192 global_state_t\n  := let fs := (list.map (\u03bb p : socket \u00d7 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 \u2192 A)\n  : poll_result ports sockets bound\n  \u2192 option (global_state_t \u2192 global_state_t)\n| poll_result.timeout := some id\n| (poll_result.message elapsed_fin sock mess H) := do\n    midx \u2190 incoming.messages.check_member (sock.value, mess),\n    some (lookup_updatef a_ip (\u03bb inc, {inc with messages := list.remove_member _ midx}))\n\ndef next_agent_state_from_dlabel\n  : \u2200 {a_next : act ag.state_type} (la : dlabel a_next)\n  , option (ag.state_type \u00d7 (global_state_t \u2192 global_state_t))\n| (act.poll ports sockets bound cont) (dlabel.poll ._ ._ ._ ._ r) := do\n    updatef \u2190 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 \u2192 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     $ \u03bb 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 \u2192 B) (x : sigma (\u03bb _ : 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 \u2192 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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a3).write i3 (v1)).write i1 (v1)).read i3) \u2260 (v1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test17.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5234203489363239, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.2311806387407333}}
{"text": "import smt2\n\nlemma true_is_true : true :=\nbegin\n    z3 \"true.log\"\nend\n", "meta": {"author": "leanprover", "repo": "smt2_interface", "sha": "7ff0ce248b68ea4db2a2d4966a97b5786da05ed7", "save_path": "github-repos/lean/leanprover-smt2_interface", "path": "github-repos/lean/leanprover-smt2_interface/smt2_interface-7ff0ce248b68ea4db2a2d4966a97b5786da05ed7/test/true.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5621765008857982, "lm_q2_score": 0.41111086923216794, "lm_q1q2_score": 0.23111686994105912}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a3).write i2 (v1)).write i3 (v1)).read i2) \u2260 (v1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test24.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5273165233795671, "lm_q2_score": 0.43782349911420193, "lm_q1q2_score": 0.23087156540677795}}
{"text": "/-\nFor a given agent, we define a labeled transition system\nwhere everything else occuring on the network may be completely arbitrary\n-/\nimport .action\n       galois.option\n       galois.network.network_implementation\n       galois.temporal.LTS\n\nnamespace network\nnamespace loc\n\ndef next_agent_state_from_dlabel {A} {a_next : act A} (la : dlabel a_next)\n  : A\n  := la.cont_result.snd\n\ndef sends_message_st (P : socket \u2192 message_t \u2192 Prop) (l : agent_label) : Prop\n  := l.messages.Exists (\u03bb x, P x.fst x.snd)\n\ndef sends_message_std (P : socket \u2192 message_t \u2192 Prop) {ag : agent}\n  (a_next : act ag.state_type) (la : dlabel a_next) : Prop\n  := la.messages.Exists (\u03bb x, P x.fst x.snd)\n\nsection\nparameters {ag : agent}\n\ndef inLabeld (P : \u2200 (a_next : act ag.state_type), dlabel a_next \u2192 Prop)\n  (x : sigma (\u03bb s : ag.state_type, dlabel (ag.loop s))) : Prop\n:= begin\ninduction x, apply P; assumption\nend\n\ninstance sends_message_st_decidable (P : socket \u2192 message_t \u2192 Prop)\n  [decP : \u2200 x y, decidable (P x y)] : decidable_pred (sends_message_st P)\n:= begin\nintros x, unfold sends_message_st,\napply list.Exists_decidable,\nend\n\nend\n\ndef LTSd (ag : agent) (s l s') := @next_agent_state_from_dlabel ag.state_type (ag.loop s) l = s'\n\nend loc\n\nopen temporal\n\ndef sys_dlabel_to_local {agents : map ip agent}\n (ag : agents.member) (s : @system_state agents) :\n  sys_dlabel s \u2192 option (dlabel (ag.value.loop (s.local_state ag)))\n| (sys_dlabel.mk ag' aupdate) := do\n  plift.up H \u2190 option.precondition (ag' = ag),\n  some (eq.rec_on H aupdate)\n\nuniverses u\n\nlemma next_state_local\n  (agents : map ip agent)\n  (ag : mapd.member agents)\n  (incoming : incoming_items)\n  (a_next : act ag.value.state_type)\n  (label : dlabel a_next)\n  (new_state : (ag.value).state_type)\n  (updatef : global_state_t \u2192 global_state_t)\n  (Hx1 : next_agent_state_from_dlabel (ag.key) (ag.value) incoming label = some (new_state, updatef))\n: loc.next_agent_state_from_dlabel label = new_state\n:= begin\ninduction label, dsimp [loc.next_agent_state_from_dlabel, dlabel.cont_result],\ndsimp [next_agent_state_from_dlabel] at Hx1,\napply_in Hx1 option.bind_some',\ninduction Hx1 with updatef H,\ninduction H with H1 H2,\ndsimp [next_agent_state_from_dlabel] at H2,\ngeneralize Hx : cont r = x, rw Hx at H2,\nclear Hx, induction x, dsimp,\ndsimp [next_agent_state_from_dlabel] at H2,\ninjection H2 with H, clear H2, injection H with H1 H2\nend\n\ndef refinesd\n  {agents : map ip agent}\n  (ag : agents.member)\n : Refinement (@LTSd agents) (SkipLTS (loc.LTSd ag.value))\n:= { S_refine := \u03bb s, s.local_state ag\n   , L_refine := sys_dlabel_to_local ag\n   , refines := begin\n   intros s l s' H,\n   unfold LTSd at H, induction l,\n   simp only [next_state_from_dlabel] at H,\n   simp only [sys_dlabel_to_local],\n   rename ag_1 ag',\n   apply_in H option.bind_some',\n   induction H with Hx Hx', induction Hx' with Hx1 Hx2,\n   induction Hx with new_state updatef,\n   dsimp [next_state_from_dlabel] at Hx2,\n   injection Hx2 with Hx2', clear Hx2,\n   subst s', dsimp,\n   apply (if Hag : ag' = ag then _ else _),\n   { -- I go!\n     rw (option.precondition_true_bind Hag),\n     dsimp [sys_dlabel_to_local], induction Hag,\n     dsimp, unfold SkipLTS,\n     unfold loc.LTSd,\n     rw lookup_update_refl,\n     generalize Hls : (ag'.value).loop (s.local_state ag') = ls,\n     rw Hls at label, rename label label',\n     apply next_state_local, assumption,\n   },\n   { --Someone else goes\n   rw (option.precondition_false Hag),\n   dsimp [has_bind.bind, option.bind],\n   dsimp [SkipLTS],\n   rw (lookup_update_different Hag),\n   },\n   end\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_local_abs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5660185205547239, "lm_q2_score": 0.4073334000459302, "lm_q1q2_score": 0.23055824846652292}}
{"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 {\u03b1 : U} {\u03b2 : V} : (\u03b1 \u27f6' \u03b2) \u2192 (\u03b2 \u27f6' \u03b1) \u2192 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                             (\u03b1 : U) (\u03b2 : V) : Sort (max 1 u v) where\n(toFun   : \u03b1 \u27f6' \u03b2)\n(invFun  : \u03b2 \u27f6' \u03b1)\n(isEquiv : h.IsEquiv toFun invFun)\n\nnamespace BundledEquivalence\n\n  infix:20 \" \u27f7' \" => BundledEquivalence\n\n  variable {U V : Universe} [hUV : HasExternalFunctors U V] [hVU : HasExternalFunctors V U]\n           [h : HasExternalEquivalences U V]\n\n  def mkEquiv {\u03b1 : U} {\u03b2 : V} {to : \u03b1 \u27f6' \u03b2} {inv : \u03b2 \u27f6' \u03b1} (he : h.IsEquiv to inv) : \u03b1 \u27f7' \u03b2 :=\n  \u27e8to, inv, he\u27e9\n\nend BundledEquivalence\n\nclass HasInternalEquivalences (U : Universe.{u}) [h : HasInternalFunctors U] extends HasExternalEquivalences U U : Type u where\n(Equiv                          : U \u2192 U \u2192 U)\n(equivEquiv           (\u03b1 \u03b2 : U) : \u2308Equiv \u03b1 \u03b2\u2309 \u2243 (\u03b1 \u27f7' \u03b2))\n(equivElimToFunIsFun  (\u03b1 \u03b2 : U) : h.IsFun (\u03bb E : Equiv \u03b1 \u03b2 => HasInternalFunctors.fromBundled ((equivEquiv \u03b1 \u03b2).toFun E).toFun))\n(equivElimInvFunIsFun (\u03b1 \u03b2 : U) : h.IsFun (\u03bb E : Equiv \u03b1 \u03b2 => HasInternalFunctors.fromBundled ((equivEquiv \u03b1 \u03b2).toFun E).invFun))\n\nnamespace HasInternalEquivalences\n\n  infix:20 \" \u27f7 \" => HasInternalEquivalences.Equiv\n\n  variable {U : Universe} [HasInternalFunctors U] [h : HasInternalEquivalences U]\n\n  def toBundled   {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7  \u03b2) : \u03b1 \u27f7' \u03b2 := (h.equivEquiv \u03b1 \u03b2).toFun  E\n  def fromBundled {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) : \u03b1 \u27f7  \u03b2 := (h.equivEquiv \u03b1 \u03b2).invFun E\n\n  @[simp] theorem fromToBundled {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7  \u03b2) : fromBundled (toBundled E) = E :=\n  (h.equivEquiv \u03b1 \u03b2).leftInv  E\n  @[simp] theorem toFromBundled {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) : toBundled (fromBundled E) = E :=\n  (h.equivEquiv \u03b1 \u03b2).rightInv E\n\n  def to  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (a : \u03b1) : \u03b2 := (toBundled E).toFun  a\n  def inv {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (b : \u03b2) : \u03b1 := (toBundled E).invFun b\n\n  def toFun  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) : \u03b1 \u27f6 \u03b2 := HasInternalFunctors.fromBundled (toBundled E).toFun\n  def invFun {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) : \u03b2 \u27f6 \u03b1 := HasInternalFunctors.fromBundled (toBundled E).invFun\n\n  @[simp] theorem toFun.eff  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (a : \u03b1) : (toFun  E) a = to  E a :=\n  by apply HasInternalFunctors.fromBundled.eff\n  @[simp] theorem invFun.eff {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (b : \u03b2) : (invFun E) b = inv E b :=\n  by apply HasInternalFunctors.fromBundled.eff\n\n  def toFunFun'  (\u03b1 \u03b2 : U) : (\u03b1 \u27f7 \u03b2) \u27f6' (\u03b1 \u27f6 \u03b2) := BundledFunctor.mkFun (h.equivElimToFunIsFun  \u03b1 \u03b2)\n  def invFunFun' (\u03b1 \u03b2 : U) : (\u03b1 \u27f7 \u03b2) \u27f6' (\u03b2 \u27f6 \u03b1) := BundledFunctor.mkFun (h.equivElimInvFunIsFun \u03b1 \u03b2)\n  def toFunFun   (\u03b1 \u03b2 : U) : (\u03b1 \u27f7 \u03b2) \u27f6  (\u03b1 \u27f6 \u03b2) := HasInternalFunctors.fromBundled (toFunFun'  \u03b1 \u03b2)\n  def invFunFun  (\u03b1 \u03b2 : U) : (\u03b1 \u27f7 \u03b2) \u27f6  (\u03b2 \u27f6 \u03b1) := HasInternalFunctors.fromBundled (invFunFun' \u03b1 \u03b2)\n\n  @[simp] theorem toFunFun.eff  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) : (toFunFun  \u03b1 \u03b2) E = toFun  E :=\n  by apply HasInternalFunctors.fromBundled.eff\n  @[simp] theorem invFunFun.eff {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) : (invFunFun \u03b1 \u03b2) E = invFun E :=\n  by apply HasInternalFunctors.fromBundled.eff\n  @[simp] theorem toFunFun.effEff  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (a : \u03b1) : ((toFunFun  \u03b1 \u03b2) E) a = to  E a :=\n  by simp\n  @[simp] theorem invFunFun.effEff {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (b : \u03b2) : ((invFunFun \u03b1 \u03b2) E) b = inv E b :=\n  by simp\n\n  @[simp] theorem toFun.bundledEq  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) : HasInternalFunctors.toBundled (toFun E)  = (toBundled E).toFun :=\n  HasInternalFunctors.toFromBundled (toBundled E).toFun\n  @[simp] theorem invFun.bundledEq {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) : HasInternalFunctors.toBundled (invFun E) = (toBundled E).invFun :=\n  HasInternalFunctors.toFromBundled (toBundled E).invFun\n\n  def isEquiv {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) : h.IsEquiv (toBundled E).toFun (toBundled E).invFun :=\n  (toBundled E).isEquiv\n\n  def isEquiv' {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) :\n    h.IsEquiv (HasInternalFunctors.toBundled (toFun E)) (HasInternalFunctors.toBundled (invFun E)) :=\n  by simp; apply isEquiv\n\n  @[simp] theorem fromBundled.to.coe'  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) : (toBundled (fromBundled E)).toFun  = E.toFun  :=\n  congrArg BundledEquivalence.toFun  (toFromBundled E)\n  @[simp] theorem fromBundled.inv.coe' {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) : (toBundled (fromBundled E)).invFun = E.invFun :=\n  congrArg BundledEquivalence.invFun (toFromBundled E)\n  @[simp] theorem fromBundled.to.coe  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) : (toBundled (fromBundled E)).toFun.f  = E.toFun.f  :=\n  congrArg BundledFunctor.f (fromBundled.to.coe'  E)\n  @[simp] theorem fromBundled.inv.coe {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) : (toBundled (fromBundled E)).invFun.f = E.invFun.f :=\n  congrArg BundledFunctor.f (fromBundled.inv.coe' E)\n  @[simp] theorem fromBundled.to.eff  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) (a : \u03b1) : to  (fromBundled E) a = E.toFun  a :=\n  congrFun (fromBundled.to.coe  E) a\n  @[simp] theorem fromBundled.inv.eff {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) (b : \u03b2) : inv (fromBundled E) b = E.invFun b :=\n  congrFun (fromBundled.inv.coe E) b\n\n  def mkEquiv {\u03b1 \u03b2 : U} {to : \u03b1 \u27f6' \u03b2} {inv : \u03b2 \u27f6' \u03b1} (he : h.IsEquiv to inv) : \u03b1 \u27f7 \u03b2 :=\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 (\u03b1 : U) : h.IsEquiv (HasIdFun.idFun' \u03b1) (HasIdFun.idFun' \u03b1))\n\nnamespace HasIdEquiv\n\n  variable {U : Universe} [HasExternalFunctors U U] [HasIdFun U] [HasExternalEquivalences U U] [h : HasIdEquiv U]\n\n  def idEquiv' (\u03b1 : U) : \u03b1 \u27f7' \u03b1 := BundledEquivalence.mkEquiv (h.idIsEquiv \u03b1)\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 {\u03b1 : U} {\u03b2 : V} {\u03b3 : W} (E : \u03b1 \u27f7' \u03b2) (F : \u03b2 \u27f7' \u03b3) : h.IsEquiv (F.toFun \u2299' E.toFun) (E.invFun \u2299' 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' {\u03b1 : U} {\u03b2 : V} {\u03b3 : W} (E : \u03b1 \u27f7' \u03b2) (F : \u03b2 \u27f7' \u03b3) : \u03b1 \u27f7' \u03b3 := 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 {\u03b1 : U} {\u03b2 : V} (E : \u03b1 \u27f7' \u03b2) : 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' {\u03b1 : U} {\u03b2 : V} (E : \u03b1 \u27f7' \u03b2) : \u03b2 \u27f7' \u03b1 := 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    {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) (\u03b3 : U) : h.IsFun (\u03bb F : \u03b2 \u27f7 \u03b3 => HasInternalEquivalences.mkEquiv (compIsEquiv E (HasInternalEquivalences.toBundled F))))\n(compEquivFunIsFun (\u03b1 \u03b2 \u03b3 : U)                    : h.IsFun (\u03bb E : \u03b1 \u27f7 \u03b2 => HasInternalFunctors.mkFun (compEquivIsFun (HasInternalEquivalences.toBundled E) \u03b3)))\n(invEquivIsFun     (\u03b1 \u03b2 : U)                      : h.IsFun (\u03bb E : \u03b1 \u27f7 \u03b2 => HasInternalEquivalences.mkEquiv (invIsEquiv (HasInternalEquivalences.toBundled E))))\n(invEquivIsEquiv   (\u03b1 \u03b2 : U)                      : IsEquiv (BundledFunctor.mkFun (invEquivIsFun \u03b1 \u03b2)) (BundledFunctor.mkFun (invEquivIsFun \u03b2 \u03b1)))\n\nnamespace HasEquivOp\n\n  variable {U : Universe.{u}} [HasInternalFunctors U] [HasLinearFunOp U] [h : HasEquivOp U]\n\n  def idEquiv' (\u03b1 : U) : \u03b1 \u27f7' \u03b1 := HasIdEquiv.idEquiv' \u03b1\n  def idEquiv  (\u03b1 : U) : \u03b1 \u27f7  \u03b1 := HasInternalEquivalences.fromBundled (idEquiv' \u03b1)\n\n  @[simp] theorem idEquiv.to.eff  (\u03b1 : U) (a : \u03b1) : HasInternalEquivalences.to  (idEquiv \u03b1) a = a :=\n  by apply HasInternalEquivalences.fromBundled.to.eff\n  @[simp] theorem idEquiv.inv.eff (\u03b1 : U) (a : \u03b1) : HasInternalEquivalences.inv (idEquiv \u03b1) a = a :=\n  by apply HasInternalEquivalences.fromBundled.inv.eff\n\n  def compEquiv' {\u03b1 \u03b2 \u03b3 : U} (E : \u03b1 \u27f7' \u03b2) (F : \u03b2 \u27f7' \u03b3) : \u03b1 \u27f7' \u03b3 := HasCompEquiv.compEquiv' E F\n  def compEquiv  {\u03b1 \u03b2 \u03b3 : U} (E : \u03b1 \u27f7  \u03b2) (F : \u03b2 \u27f7  \u03b3) : \u03b1 \u27f7  \u03b3 :=\n  HasInternalEquivalences.fromBundled (compEquiv' (HasInternalEquivalences.toBundled E) (HasInternalEquivalences.toBundled F))\n\n  @[simp] theorem compEquiv.to.eff  {\u03b1 \u03b2 \u03b3 : U} (E : \u03b1 \u27f7 \u03b2) (F : \u03b2 \u27f7 \u03b3) (a : \u03b1) :\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 {\u03b1 \u03b2 \u03b3 : U} (E : \u03b1 \u27f7 \u03b2) (F : \u03b2 \u27f7 \u03b3) (c : \u03b3) :\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' {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) (\u03b3 : U) : (\u03b2 \u27f7 \u03b3) \u27f6' (\u03b1 \u27f7 \u03b3) := BundledFunctor.mkFun (h.compEquivIsFun E \u03b3)\n  def compEquivFun  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7  \u03b2) (\u03b3 : U) : (\u03b2 \u27f7 \u03b3) \u27f6  (\u03b1 \u27f7 \u03b3) :=\n  HasInternalFunctors.fromBundled (compEquivFun' (HasInternalEquivalences.toBundled E) \u03b3)\n\n  @[simp] theorem compEquivFun.eff {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (\u03b3 : U) (F : \u03b2 \u27f7 \u03b3) : (compEquivFun E \u03b3) F = compEquiv E F :=\n  by apply HasInternalFunctors.fromBundled.eff\n  @[simp] theorem compEquivFun.to.effEff  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (\u03b3 : U) (F : \u03b2 \u27f7 \u03b3) (a : \u03b1) :\n    HasInternalEquivalences.to  ((compEquivFun E \u03b3) F) a = HasInternalEquivalences.to  F (HasInternalEquivalences.to  E a) :=\n  by simp\n  @[simp] theorem compEquivFun.inv.effEff {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (\u03b3 : U) (F : \u03b2 \u27f7 \u03b3) (c : \u03b3) :\n    HasInternalEquivalences.inv ((compEquivFun E \u03b3) F) c = HasInternalEquivalences.inv E (HasInternalEquivalences.inv F c) :=\n  by simp\n\n  def compEquivFunFun' (\u03b1 \u03b2 \u03b3 : U) : (\u03b1 \u27f7 \u03b2) \u27f6' (\u03b2 \u27f7 \u03b3) \u27f6 (\u03b1 \u27f7 \u03b3) := BundledFunctor.mkFun (h.compEquivFunIsFun \u03b1 \u03b2 \u03b3)\n  def compEquivFunFun  (\u03b1 \u03b2 \u03b3 : U) : (\u03b1 \u27f7 \u03b2) \u27f6  (\u03b2 \u27f7 \u03b3) \u27f6 (\u03b1 \u27f7 \u03b3) := HasInternalFunctors.fromBundled (compEquivFunFun' \u03b1 \u03b2 \u03b3)\n  \n  @[simp] theorem compEquivFunFun.eff (\u03b1 \u03b2 \u03b3 : U) (E : \u03b1 \u27f7 \u03b2) : (compEquivFunFun \u03b1 \u03b2 \u03b3) E = compEquivFun E \u03b3 :=\n  by apply HasInternalFunctors.fromBundled.eff\n  @[simp] theorem compEquivFunFun.effEff (\u03b1 \u03b2 \u03b3 : U) (E : \u03b1 \u27f7 \u03b2) (F : \u03b2 \u27f7 \u03b3) : ((compEquivFunFun \u03b1 \u03b2 \u03b3) E) F = compEquiv E F :=\n  by simp\n  @[simp] theorem compEquivFunFun.to.effEffEff  (\u03b1 \u03b2 \u03b3 : U) (E : \u03b1 \u27f7 \u03b2) (F : \u03b2 \u27f7 \u03b3) (a : \u03b1) :\n    HasInternalEquivalences.to  (((compEquivFunFun \u03b1 \u03b2 \u03b3) E) F) a = HasInternalEquivalences.to  F (HasInternalEquivalences.to  E a) := by simp\n  @[simp] theorem compEquivFunFun.inv.effEffEff (\u03b1 \u03b2 \u03b3 : U) (E : \u03b1 \u27f7 \u03b2) (F : \u03b2 \u27f7 \u03b3) (c : \u03b3) :\n    HasInternalEquivalences.inv (((compEquivFunFun \u03b1 \u03b2 \u03b3) E) F) c = HasInternalEquivalences.inv E (HasInternalEquivalences.inv F c) := by simp\n\n  def invEquiv' {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7' \u03b2) : \u03b2 \u27f7' \u03b1 := HasInvEquiv.invEquiv' E\n  def invEquiv  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7  \u03b2) : \u03b2 \u27f7  \u03b1 :=\n  HasInternalEquivalences.fromBundled (invEquiv' (HasInternalEquivalences.toBundled E))\n\n  @[simp] theorem invEquiv.to.eff  {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (b : \u03b2) : HasInternalEquivalences.to  (invEquiv E) b = HasInternalEquivalences.inv E b :=\n  by apply HasInternalEquivalences.fromBundled.to.eff\n  @[simp] theorem invEquiv.inv.eff {\u03b1 \u03b2 : U} (E : \u03b1 \u27f7 \u03b2) (a : \u03b1) : HasInternalEquivalences.inv (invEquiv E) a = HasInternalEquivalences.to  E a :=\n  by apply HasInternalEquivalences.fromBundled.inv.eff\n\n  def invEquivFun' (\u03b1 \u03b2 : U) : (\u03b1 \u27f7 \u03b2) \u27f6' (\u03b2 \u27f7 \u03b1) := BundledFunctor.mkFun (h.invEquivIsFun \u03b1 \u03b2)\n  def invEquivFun  (\u03b1 \u03b2 : U) : (\u03b1 \u27f7 \u03b2) \u27f6  (\u03b2 \u27f7 \u03b1) := HasInternalFunctors.fromBundled (invEquivFun' \u03b1 \u03b2)\n\n  @[simp] theorem invEquivFun.eff (\u03b1 \u03b2 : U) (E : \u03b1 \u27f7 \u03b2) : (invEquivFun \u03b1 \u03b2) E = invEquiv E :=\n  by apply HasInternalFunctors.fromBundled.eff\n  @[simp] theorem invEquivFun.to.effEff  (\u03b1 \u03b2 : U) (E : \u03b1 \u27f7 \u03b2) (b : \u03b2) :\n    HasInternalEquivalences.to  ((invEquivFun \u03b1 \u03b2) E) b = HasInternalEquivalences.inv E b := by simp\n  @[simp] theorem invEquivFun.inv.effEff (\u03b1 \u03b2 : U) (E : \u03b1 \u27f7 \u03b2) (a : \u03b1) :\n    HasInternalEquivalences.inv ((invEquivFun \u03b1 \u03b2) E) a = HasInternalEquivalences.to  E a := by simp\n\n  def invEquivEquiv' (\u03b1 \u03b2 : U) : (\u03b1 \u27f7 \u03b2) \u27f7' (\u03b2 \u27f7 \u03b1) := BundledEquivalence.mkEquiv (h.invEquivIsEquiv \u03b1 \u03b2)\n  def invEquivEquiv  (\u03b1 \u03b2 : U) : (\u03b1 \u27f7 \u03b2) \u27f7  (\u03b2 \u27f7 \u03b1) := HasInternalEquivalences.fromBundled (invEquivEquiv' \u03b1 \u03b2)\n\n  @[simp] theorem invEquivEquiv.to.eff  (\u03b1 \u03b2 : U) (E : \u03b1 \u27f7 \u03b2) : HasInternalEquivalences.to  (invEquivEquiv \u03b1 \u03b2) E = invEquiv E :=\n  by apply HasInternalEquivalences.fromBundled.to.eff\n  @[simp] theorem invEquivEquiv.inv.eff (\u03b1 \u03b2 : U) (E : \u03b2 \u27f7 \u03b1) : HasInternalEquivalences.inv (invEquivEquiv \u03b1 \u03b2) E = invEquiv E :=\n  by apply HasInternalEquivalences.fromBundled.inv.eff\n  @[simp] theorem invEquivEquiv.to.to.effEff   (\u03b1 \u03b2 : U) (E : \u03b1 \u27f7 \u03b2) (b : \u03b2) :\n    HasInternalEquivalences.to  (HasInternalEquivalences.to  (invEquivEquiv \u03b1 \u03b2) E) b = HasInternalEquivalences.inv E b := by simp\n  @[simp] theorem invEquivEquiv.to.inv.effEff  (\u03b1 \u03b2 : U) (E : \u03b1 \u27f7 \u03b2) (a : \u03b1) :\n    HasInternalEquivalences.inv (HasInternalEquivalences.to  (invEquivEquiv \u03b1 \u03b2) E) a = HasInternalEquivalences.to  E a := by simp\n  @[simp] theorem invEquivEquiv.inv.to.effEff  (\u03b1 \u03b2 : U) (E : \u03b2 \u27f7 \u03b1) (a : \u03b1) :\n    HasInternalEquivalences.to  (HasInternalEquivalences.inv (invEquivEquiv \u03b1 \u03b2) E) a = HasInternalEquivalences.inv E a := by simp\n  @[simp] theorem invEquivEquiv.inv.inv.effEff (\u03b1 \u03b2 : U) (E : \u03b2 \u27f7 \u03b1) (b : \u03b2) :\n    HasInternalEquivalences.inv (HasInternalEquivalences.inv (invEquivEquiv \u03b1 \u03b2) 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 (\u03bb h, false.elim (iff.mp not_true h)) (\u03bb _, rfl)\n\n@[simp] lemma to_bool_false_eq_ff (h : decidable false) : @to_bool false h = ff :=\ndecidable.cases_on h (\u03bb h, rfl) (\u03bb 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 \u2192 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 \u2192 Type v} \n  (f : \u03a0a, B a \u2192 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 \u2192 \u03a0 (X : ?M_1.Obj), ?M_2.Hom (\u21d1?M_3 X) (\u21d1?M_4 X)\n\n-- \u03b1 === Type (max u v)\n-- a === (@NaturalTransformation (C \u00d7 C) C (@MonoidalStructure.tensor C m)\n--           (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C)\n--              (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))))\n-- T === (\u03bb (_x : Type (max u v)), _x)\n-- t : T a == a\n-- t === (@vertical_composition_of_NaturalTransformations (C \u00d7 C) C (@MonoidalStructure.tensor C m)\n--           (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n--           (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C)\n--              (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m)))\n--           (@isomorphism.Isomorphism.morphism (FunctorCategory (C \u00d7 C) C) (@MonoidalStructure.tensor C m)\n--              (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n--              (@braided_monoidal_category.Symmetry.braiding C m \u03b2))\n--           (@whisker_on_left (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m)\n--              (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n--              (@isomorphism.Isomorphism.morphism (FunctorCategory (C \u00d7 C) C) (@MonoidalStructure.tensor C m)\n--                 (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n--                 (@braided_monoidal_category.Symmetry.braiding C m \u03b2)))) \n-- b === (@NaturalTransformation (C \u00d7 C) C (@MonoidalStructure.tensor C m) (@MonoidalStructure.tensor C m))\n-- e : a = b\n\n-- @eq.rec \u03b1 a T t b e : T b\n-- T b == b\n\n-- now we want to apply\n--   f === @NaturalTransformation.components (C \u00d7 C) C (@MonoidalStructure.tensor C m) (@MonoidalStructure.tensor C m)\n-- to @eq.rec \u03b1 a T b e.\n-- actually, we're going to need to think of this as applying \n--   f' === @NaturalTransformation.components (C \u00d7 C) C (@MonoidalStructure.tensor C m)\n--      : \u03a0 (F : Functor (C \u00d7 C) C), NaturalTransformation m.tensor F \u2192 \u03a0 (x : (C \u00d7 C).Obj), C.Hom (m.tensor x) (F x)\n-- and here we may as well introduce S : Functor (C \u00d7 C) C \u2192 Type as S F = \u03a0 (x : (C \u00d7 C).Obj), C.Hom (m.tensor x) (F x),\n-- and then write f' : \u03a0 (F : Functor (C \u00d7 C) C), NaturalTransformation m.tensor F \u2192 S F \n--\n-- Thus we want to start with f' (@MonoidalStructure.tensor C m) (@eq.rec \u03b1 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 \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C)\n--              (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m)))\n--      a \n-- Now this thing is of type S (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C)\n--              (@FunctorComposition (C \u00d7 C) (C \u00d7 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 \u00d7 C) C\n--        (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n--        (@MonoidalStructure.tensor C m)\n--        (@eq.rec (Functor (C \u00d7 C) C)\n--           (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C)) (@MonoidalStructure.tensor C m))\n--           (@NaturalTransformation (C \u00d7 C) C\n--              (@FunctorComposition (C \u00d7 C) (C \u00d7 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 \u00d7 C) C (@MonoidalStructure.tensor C m)))\n--        X)\n\n-- S = (@NaturalTransformation (C \u00d7 C) C\n-- f = @NaturalTransformation.components (C \u00d7 C) C\n-- f : \u03a0 a a' : A, \u03a0 t : S a a', Z a a'\n\n-- Z a a' = \u03a0 X : (C \u00d7 C).Obj, C.Hom (a X) (a' X)\n\n-- a  = (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n-- a' = (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C)) (@MonoidalStructure.tensor C m))\n\n-- A = (Functor (C \u00d7 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 { \u03b1 : Type u1 } { \u03b2 : Type u2 } { S : \u03b1 \u2192 \u03b2 \u2192 Type u3 } { Z : \u03b1 \u2192 \u03b2 \u2192 Type u4 } { a : \u03b1 } { b : \u03b2 } { t : S a b } { b' : \u03b2 } { p : b = b' } ( f : \u03a0 ( c : \u03b1 ) ( d : \u03b2 ) , S c d \u2192 Z c d ): \n  f a b' (@eq.rec \u03b2 b (S a) t b' p) = (@eq.rec \u03b2 b (Z a) (f a b t) b' p) :=\nbegin\ninduction p, reflexivity\nend\n\nlemma {u1 u2 u3} v1 { \u03b2 : Type u1 } { S : \u03b2 \u2192 Type u2 } { Z : \u03b2 \u2192 Type u3 } { b : \u03b2 } { t : S b } { b' : \u03b2 } { p : b = b' } ( f : \u03a0 d : \u03b2, S d \u2192 Z d ) : \n  f b' (@eq.rec \u03b2 b S t b' p) = (@eq.rec \u03b2 b Z (f b t) b' p) :=\nbegin\ninduction p, reflexivity\nend\n\n\n      --  (@NaturalTransformation.components (C \u00d7 C) C\n      --     (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n      --     (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C)) (@MonoidalStructure.tensor C m))\n      --     (@eq.rec (Functor (C \u00d7 C) (C \u00d7 C))\n      --        (@FunctorComposition (C \u00d7 C) (C \u00d7 C) (C \u00d7 C) (SwitchProductCategory C C) (SwitchProductCategory C C))\n      --        (\u03bb (a : Functor (C \u00d7 C) (C \u00d7 C)),\n      --           @NaturalTransformation (C \u00d7 C) C\n      --             (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n      --             (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C a (@MonoidalStructure.tensor C m)))\n      --        (t : NaturalTransformation (switch tensor) (switch switch tensor))\n      --        (IdentityFunctor (C \u00d7 C))\n      --        (switch_twice_is_the_identity C C)))\n\n-- f  = @NaturalTransformation.components (C \u00d7 C) C\n-- \u03b1  = Functor (C \u00d7 C) C \n-- a  : \u03b1\n-- a  = (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (SwitchProductCategory C C) (@MonoidalStructure.tensor C m))\n-- \u03b2  = Functor (C \u00d7 C) C\n-- f  : \u03a0 (a : \u03b1) (b : \u03b2), S a b \u2192 Z a b\n-- \u03b3  = (Functor (C \u00d7 C) (C \u00d7 C)\n-- g  = switch switch\n-- g' = id\n-- p  : g = g'\n-- R  : \u03b3 \u2192 \u03b2\n--    = \u03bb g, (g tensor)\n-- S  = \u03bb a b, NaturalTransformation a b\n--\n-- f a (R g') (@eq.rec \u03b3 g (S a) t g' p)\n\n\n-- c' = (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C)) (@MonoidalStructure.tensor C m))\n-- c'' = (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (@FunctorComposition (C \u00d7 C) (C \u00d7 C) (C \u00d7 C) (SwitchProductCategory C C) (SwitchProductCategory C C)) (@MonoidalStructure.tensor C m))\n-- eq.rec ... : NaturalTransformation c c'\n-- \u03b3 = (Functor (C \u00d7 C) (C \u00d7 C)\n-- g = switch switch\n-- S = \u03a0 (a : \u03b1) (g : \u03b3), NaturalTransformation a (R g)\n-- t : NaturalTransformation a (R g)\n-- t : S a g\n-- g' = Identity (C \u00d7 C)\n-- p : g = g'\n\n-- c' = R g'\n-- c'' = R g\n-- R = \u03a0 g : \u03b3, (g tensor)\n-- R : \u03b3 \u2192 \u03b2\n\n-- f a c' t' : Z a c'\n\n-- f a (R g') (@eq.rec \u03b3 g S t g' p)\n-- f a (@eq.rec \u03b3 g R c'' g' p) (@eq.rec \u03b3 g S t g' p)\n-- @eq.rec \u03b3 g (Z a (R g)) (f a (R g) t) g' p\n-- @eq.rec \u03b3 g (Z a ???) (f a (@eq.rec \u03b3 g' R c' g (eq.symm p)) t) g' p\n\n\n\nlemma {u1 u2 u3 u4 u5} w\n  { \u03b1 : Type u1 } { \u03b2 : Type u2 } { \u03b3 : Type u3 }\n  { S : \u03b1 \u2192 \u03b2 \u2192 Type u4 }\n  { Z : \u03b1 \u2192 \u03b2 \u2192 Type u5 }\n  { a : \u03b1 } { g : \u03b3 } ( R : \u03b3 \u2192 \u03b2 ) { t : S a (R g) } { g' : \u03b3 } { p : g = g' } ( f : \u03a0 (a : \u03b1) (b : \u03b2), S a b \u2192 Z a b ):\n  f a (R g') (@eq.rec \u03b3 g (\u03bb g, S a (R g)) t g' p) \n    = \n  @eq.rec \u03b3 g (\u03bb 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 \u00d7 C) C)\n--                 (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C)) (@MonoidalStructure.tensor C m))\n--                 (\u03bb (G : Functor (C \u00d7 C) C),\n--                    \u03a0 (X : (C \u00d7 C).Obj),\n--                      C.Hom\n--                        (@Functor.onObjects (C \u00d7 C) C\n--                           (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C))\n--                              (@MonoidalStructure.tensor C m))\n--                           X)\n--                        (@Functor.onObjects (C \u00d7 C) C G X))\n--                 (\u03bb (X : (C \u00d7 C).Obj),\n--                    C.identity\n--                      (@Functor.onObjects (C \u00d7 C) C\n--                         (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 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 { \u03b1 : Type u1 } { a : \u03b1 } { \u03b2 : Type u2 } { Z : \u03b1 \u2192 \u03b2 \u2192 Type u3 } { t : \u03a0 (b : \u03b2), Z a b } { a' : \u03b1 } { p : a = a' } \n  : @eq.rec \u03b1 a _ t a' p = \u03bb b : \u03b2, @eq.rec \u03b1 a (\u03bb _a, Z _a b) (t b) a' p :=\nbegin\n  induction p,\n  reflexivity\nend\n\n--  (@eq.rec (Functor (C \u00d7 C) C)\n--                 (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C)) (@MonoidalStructure.tensor C m))\n--                 (\u03bb (_a : Functor (C \u00d7 C) C),\n--                    C.Hom\n--                      (@Functor.onObjects (C \u00d7 C) C\n--                         (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C))\n--                            (@MonoidalStructure.tensor C m))\n--                         (X_1, X_2))\n--                      (@Functor.onObjects (C \u00d7 C) C _a (X_1, X_2)))\n--                 (C.identity\n--                    (@Functor.onObjects (C \u00d7 C) C\n--                       (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C))\n--                          (@MonoidalStructure.tensor C m))\n--                       (X_1, X_2)))\n--                 (@MonoidalStructure.tensor C m)\n--                 (@squared_Braiding._proof_3 C m))\n-- \u03b1 = (Functor (C \u00d7 C) C)\n-- a = (@FunctorComposition (C \u00d7 C) (C \u00d7 C) C (IdentityFunctor (C \u00d7 C)) (@MonoidalStructure.tensor C m))\n-- f = C.identity\n--   : \u03a0 X : C.Obj, C.Hom X X\n-- r = @Functor.onObjects (C \u00d7 C) C\n-- x : (C \u00d7 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  { \u03b1 : Type u1 } { a : \u03b1 } { \u03b2 : Type u2 } { Z : \u03b2 \u2192 Type u3 } { \u03b3 : Type u4 } { r : \u03a0 a : \u03b1, \u03b3 \u2192 \u03b2 } { x : \u03b3 } { a' : \u03b1 } { p : a = a' } ( f : \u03a0 (b : \u03b2), Z b ) :\n  @eq.rec \u03b1 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 { \u03b1 : Type u } { a : \u03b1 } { b : \u03b1 } ( p : a = b ) : @eq.rec \u03b1 a (\u03bb b: \u03b1, b = a) (eq.refl a) b p = eq.symm p :=\nbegin\n  cases p,\n  reflexivity\nend\n\nlemma {u} foo { \u03b1 : Type u } { a b : \u03b1 } { p : a = b } : eq.symm (eq.symm p) = p := by reflexivity\n\n@[simp] lemma {u v w} function_of_eq.rec { \u03b1 : Type u } { a : \u03b1 } { T : \u03b1 \u2192 Type v } { S : \u03b1 \u2192 Type w } ( t : T a ) { b : \u03b1 } ( e : a = b ) ( f : \u03a0 { c : \u03b1 }, T c \u2192 S c ) :\n  @f b ( @eq.rec \u03b1 a T t b e ) = @eq.rec \u03b1 a S (@f a t) b e :=\nbegin\n  cases e,\n  reflexivity\nend\n@[simp] lemma {u v w} function_of_eq.drec { \u03b1 : Type u } { a : \u03b1 } { T : \u03a0 b : \u03b1, a = b \u2192 Type v } { S : \u03a0 b : \u03b1, a = b \u2192 Type v } ( t : T a (eq.refl a)) { b : \u03b1 } ( e : a = b ) ( f : \u03a0 { c : \u03b1 } { p : a = c }, T c p \u2192 S c p ) :\n  f ( @eq.drec \u03b1 a T t b e ) = @eq.drec \u03b1 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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (((a3).write i2 ((a3).read i3)).read i3) \u2260 ((a3).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test35.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.4301473485858429, "lm_q1q2_score": 0.23017117030618783}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v1) \u2260 ((((a2).write i3 (v1)).write i2 (v1)).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test27.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.22996167308736687}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v1) \u2260 ((((a2).write i2 (v1)).write i3 (v1)).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test33.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.22996167308736687}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v1) \u2260 ((((a3).write i1 (v1)).write i3 (v1)).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test6.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.22996167308736687}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v3) \u2260 ((((a2).write i3 (v3)).write i1 (v3)).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test73.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041652, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.22996167308736684}}
{"text": "import cfr\n\nexample (a b : rat) : (\u00ac a < b) \u2227 (\u00ac b < a) \u2192 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 // \u2203 v, claims.read i = v}\ninstance : has_lt AllowedClaim := \u27e8 fun a b, a.val < b.val \u27e9 \ninstance AllowedClaim_decidable_rel : decidable_rel ((<) : AllowedClaim \u2192 AllowedClaim \u2192 Prop) := infer_instance\n\ninductive Action\n| Claim (claim : AllowedClaim) : Action\n| Dudo : Action\n\ndef Action.show : Action \u2192 string\n| (Action.Claim \u27e8 i, _\u27e9 ) := \"Claim \" ++ has_repr.repr (claims.read i)\n| Action.Dudo := \"Dudo\"\n\ninstance : has_repr Action := \u27e8 Action.show \u27e9\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 \u2208 dice}\ninstance : has_lt Die := \u27e8 fun a b, a.val < b.val \u27e9\ninstance Die_decidable_rel : decidable_rel ((<) : Die \u2192 Die \u2192 Prop) := infer_instance\n\n@[derive has_lt] def History := Die \u00d7 list AllowedClaim\ninstance History_decidable_rel : decidable_rel ((<) : History \u2192 History \u2192 Prop) := infer_instance\n\ndef \u210d\ud835\udd38 : History \u2192 Type*\n    | (die, []) := AllowedClaim\n    | (die, _) := Action\n\ndef ha : HistoryToActions History \u210d\ud835\udd38\n    | (_, []) := \u27e8 actions.begin.1, actions.begin.read \u27e9\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 \u27e8 v.1, v.read \u27e9\n\nstructure Particle (\u03b1 : Type*) := mk ::\n    (state : \u03b1)\n    (probability : \u211a)\n    (is_updateable : bool)\n\nnamespace game\ndef state := state (Infosets ha)\ndef read_dice (i : fin dice.1) : Die := \u27e8 dice.read i, \u27e8 i, rfl \u27e9 \u27e9\n\ndef chance (one : Particle unit) (next : Particle Die \u2192 state rat) : state rat := \n    chance_uniform ha \u27e8 dice.1, read_dice \u27e9 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 : \u210d\ud835\udd38 \u27e8 one.state, h \u27e9 \u2192 Particle Die \u2192 state rat) \n        : state rat :=\n    response ha one.is_updateable one.probability two.probability \u27e8 one.state, h \u27e9\n        (fun action prob, next action {probability:=prob, ..one}) \n\ndef terminal := terminal ha\n\nmeta def dudo.main : Particle Die \u2192 Particle Die \u2192 list AllowedClaim \u2192 state rat\n    | one two [] := response one two [] (fun action one, dudo.main two one [action])\n    | one two h@(\u27e8i, _\u27e9 :: _) :=\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 \u2228 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 \u00d7 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 \u00d7 Infosets ha) \n        num_iterations (0, buffer.nil) \n        (fun i \u27e8 util, infosets \u27e9,\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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v2) \u2260 ((((a1).write i2 (v2)).write i3 (v2)).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test14.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.22972390130921885}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a1).write i1 (v3)).write i3 (v3)).read i1) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test72.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230156, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.2297239013092188}}
{"text": "import Mathlib.Data.Nat.Basic\nimport Mathlib.Data.Char\nimport Mathlib.Data.UInt\n\nnamespace Nat\n\n/- Up -/\n\n/-- A well-ordered relation for \"upwards\" induction on the natural numbers up to some bound `ub`. -/\ndef Up (ub a i : \u2115) := i < a \u2227 i < ub\n\nlemma Up.next {ub i} (h : i < ub) : Up ub (i+1) i := \u27e8Nat.lt_succ_self _, h\u27e9\n\nlemma Up.WF (ub) : WellFounded (Up ub) :=\n  Subrelation.wf (h\u2082 := (measure (ub - .)).wf) fun \u27e8ia, iu\u27e9 \u21a6 Nat.sub_lt_sub_left iu ia\n\n/-- A well-ordered relation for \"upwards\" induction on the natural numbers up to some bound `ub`. -/\ndef upRel (ub : \u2115) : WellFoundedRelation Nat := \u27e8Up ub, Up.WF ub\u27e9\n\nend Nat\n\n/-- A terminal byte slice, a suffix of a byte array. -/\nstructure ByteSliceT := (arr : ByteArray) (off : Nat)\n\nnamespace ByteSliceT\n\n/-- The number of elements in the byte slice. -/\n@[inline] def size (self : ByteSliceT) : Nat := self.arr.size - self.off\n\n/-- Index into a byte slice. The `getOp` function allows the use of the `buf[i]` notation. -/\n@[inline] def getOp (self : ByteSliceT) (idx : Nat) : UInt8 := self.arr.get! (self.off + idx)\n\nend ByteSliceT\n\n/-- Convert a byte array into a terminal slice. -/\ndef ByteArray.toSliceT (arr : ByteArray) : ByteSliceT := \u27e8arr, 0\u27e9\n\n/-- A byte slice, given by a backing byte array, and an offset and length. -/\nstructure ByteSlice := (arr : ByteArray) (off len : Nat)\n\nnamespace ByteSlice\n\n/-- Convert a byte slice into an array, by copying the data if necessary. -/\ndef toArray : ByteSlice \u2192 ByteArray\n| \u27e8arr, off, len\u27e9 => arr.extract off len\n\n/-- Index into a byte slice. The `getOp` function allows the use of the `buf[i]` notation. -/\n@[inline] def getOp (self : ByteSlice) (idx : Nat) : UInt8 := self.arr.get! (self.off + idx)\n\n\n/-- The inner loop of the `forIn` implementation for byte slices. -/\ndef forIn.loop [Monad m] (f : UInt8 \u2192 \u03b2 \u2192 m (ForInStep \u03b2))\n  (arr : ByteArray) (off _end : Nat) (i : Nat) (b : \u03b2) : m \u03b2 :=\n  if h : i < _end then do\n    match \u2190 f (arr.get! i) b with\n    | ForInStep.done b => pure b\n    | ForInStep.yield b => have := Nat.Up.next h; loop f arr off _end (i+1) b\n  else pure b\ntermination_by _ => _end - i\n\ninstance : ForIn m ByteSlice UInt8 :=\n  \u27e8fun \u27e8arr, off, len\u27e9 b f \u21a6 forIn.loop f arr off (off + len) off b\u27e9\n\nend ByteSlice\n\n/-- Convert a terminal byte slice into a regular byte slice. -/\ndef ByteSliceT.toSlice : ByteSliceT \u2192 ByteSlice\n| \u27e8arr, off\u27e9 => \u27e8arr, off, arr.size - off\u27e9\n\n/-- Convert a byte array into a byte slice. -/\ndef ByteArray.toSlice (arr : ByteArray) : ByteSlice := \u27e8arr, 0, arr.size\u27e9\n\n/-- Convert a string of assumed-ASCII characters into a byte array.\n(If any characters are non-ASCII they will be reduced modulo 256.) -/\ndef String.toAsciiByteArray (s : String) : ByteArray :=\n  let rec loop (p : Pos) (out : ByteArray) : ByteArray :=\n    if h : s.atEnd p then out else\n    let c := s.get p\n    have : utf8ByteSize s - (next s p).byteIdx < utf8ByteSize s - p.byteIdx :=\n      Nat.sub_lt_sub_left (Nat.lt_of_not_le <| mt decide_eq_true h)\n        (Nat.lt_add_of_pos_right (String.csize_pos _))\n    loop (s.next p) (out.push c.toUInt8)\n  loop 0 ByteArray.empty\ntermination_by _ => utf8ByteSize s - p.byteIdx\n\n/-- Convert a byte slice into a string. This does not handle non-ASCII characters correctly:\nevery byte will become a unicode character with codepoint < 256. -/\ndef ByteSlice.toString (bs : ByteSlice) : String := Id.run do\n  let mut s := \"\"\n  for c in bs do s := s.push c.toChar\n  s\n\ninstance : ToString ByteSlice where\n  toString bs := Id.run do\n    let mut s := \"\"\n    for c in bs do s := s.push c.toChar\n    s\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/ByteArray.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.672331699179286, "lm_q2_score": 0.3415825061409754, "lm_q1q2_score": 0.2296567467636809}}
{"text": "import model_theory.substructures\nimport model_theory.bundled\n\n\n--OUTPUT 1\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  sorry,\nend\n\n--OUTPUT 2\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let A := \u03bb n : \u2115, \u2203 (x1 : F.Model.sort 1) (x2 : F.Model.sort 1) (xs : fin n \u2192 F.Model.sort 1),\n      \u2200 (x : fin n), x1 \u2260 x2 \u2227 x1 \u2260 xs x \u2227 \u2200 (x y : fin n), x \u2260 y \u2192 xs x \u2260 xs y,\n  have hA : \u2200 (n : \u2115), A n, from sorry,\n  let Gamma := F.axioms \u222a { A n | n : \u2115},\n  have hGamma : \u2200 (n : \u2115), \u2203 (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 : \u2200 (n : \u2115), 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 \u2203 (M : F.Model), infinite M, from sorry,\nend\n\n--OUTPUT 3\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  assume L : first_order.language,\n  assume F : L.Theory,\n  assume h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin,\n\n  let \u0393 : set L.formula := sorry,\n  have h1 : \u2200 s : set L.formula, finite s \u2192 (\u2203 (m : F.Model), s \u2286 m) \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h2 : \u2200 s : set L.formula, finite s \u2192 (\u2203 (m : F.Model), s \u2286 m), from sorry,\n  have h3 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h4 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h5 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h6 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h7 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h8 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h9 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h10 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h11 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h12 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h13 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h14 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h15 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h16 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h17 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h18 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h19 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h20 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h21 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h22 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h23 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h24 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h25 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h26 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h27 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h28 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h29 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h30 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h31 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h32 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h33 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h34 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h35 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h36 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h37 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h38 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h39 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h40 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h41 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h42 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h43 : \u2200 s : set L.formula, finite s \u2192 s \u2286 \u0393 \u2192 \u2203 (m : F.Model), s \u2286 m, from sorry,\n  have h44 : \u2200 s : set L.formula, finite s \u2192 s \u2286\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  have h1 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h2 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h3 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h4 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h5 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h6 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h7 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h8 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h9 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h10 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h11 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h12 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h13 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h14 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h15 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h16 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h17 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h18 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h19 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h20 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h21 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h22 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h23 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h24 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h25 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h26 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h27 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h28 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h29 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h30 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h31 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h32 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h33 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h34 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h35 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h36 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h37 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h38 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h39 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h40 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h41 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h42 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h43 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h44 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h45 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h46 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h47 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h48 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h49 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h50 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h51 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h52 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h53 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @fintype.card m _, from sorry,\n  have h54 : \u2200 n : \u2115, \u2203 (m : F.Model), n \u2264 @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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  have h1 : \u2203 (x : \u2115) (m : F.Model) [mfin : fintype m], x = fintype.card m, from sorry,\n  have h2 : \u2203 (m : F.Model) [mfin : fintype m], 1 \u2264 @fintype.card m mfin, from sorry,\n  have h3 : \u2203 (m : F.Model) [mfin : fintype m], 2 \u2264 @fintype.card m mfin, from sorry,\n  have h4 : \u2203 (m : F.Model) [mfin : fintype m], 3 \u2264 @fintype.card m mfin, from sorry,\n\n  have h5 : \u2203 (m : F.Model) [mfin : fintype m], 4 \u2264 @fintype.card m mfin, from sorry,\n  have h6 : \u2203 (m : F.Model) [mfin : fintype m], 5 \u2264 @fintype.card m mfin, from sorry,\n  have h7 : \u2203 (m : F.Model) [mfin : fintype m], 6 \u2264 @fintype.card m mfin, from sorry,\n  have h8 : \u2203 (m : F.Model) [mfin : fintype m], 7 \u2264 @fintype.card m mfin, from sorry,\n  have h9 : \u2203 (m : F.Model) [mfin : fintype m], 8 \u2264 @fintype.card m mfin, from sorry,\n\n  have h10 : \u2203 (m : F.Model) [mfin : fintype m], 9 \u2264 @fintype.card m mfin, from sorry,\n  have h11 : \u2203 (m : F.Model) [mfin : fintype m], 10 \u2264 @fintype.card m mfin, from sorry,\n  have h12 : \u2203 (m : F.Model) [mfin : fintype m], 11 \u2264 @fintype.card m mfin, from sorry,\n  have h13 : \u2203 (m : F.Model) [mfin : fintype m], 12 \u2264 @fintype.card m mfin, from sorry,\n  have h14 : \u2203 (m : F.Model) [mfin : fintype m], 13 \u2264 @fintype.card m mfin, from sorry,\n\n  have h15 : \u2203 (m : F.Model) [mfin : fintype m], 14 \u2264 @fintype.card m mfin, from sorry,\n  have h16 : \u2203 (m : F.Model) [mfin : fintype m], 15 \u2264 @fintype.card m mfin, from sorry,\n  have h17 : \u2203 (m : F.Model) [mfin : fintype m], 16 \u2264 @fintype.card m mfin, from sorry,\n  have h18 : \u2203 (m : F.Model) [mfin : fintype m], 17 \u2264 @fintype.card m mfin, from sorry,\n  have h19 : \u2203 (m : F.Model) [mfin : fintype m], 18 \u2264 @fintype.card m mfin, from sorry,\n\n  have h20 : \u2203 (m : F.Model) [mfin : fintype m], 19 \u2264 @fintype.card m mfin, from sorry,\n  have h21 : \u2203 (m : F.Model) [mfin : fintype m], 20 \u2264 @fintype.card m mfin, from sorry,\n  have h22 : \u2203 (m : F.Model) [mfin : fintype m], 21 \u2264 @fintype.card m mfin, from sorry,\n  have h23 : \u2203 (m : F.Model) [mfin : fintype m], 22 \u2264 @fintype.card m mfin, from sorry,\n  have h24 : \u2203 (m : F.Model) [mfin : fintype m], 23 \u2264 @fintype.card m mfin, from sorry,\n\n  have h25 : \u2203 (m : F.Model) [mfin : fintype m], 24 \u2264 @fintype.card m mfin, from sorry,\n  have h26 : \u2203 (m : F.Model) [mfin : fintype m], 25 \u2264 @fintype.card m mfin, from sorry,\n  have h27 : \u2203 (m : F.Model) [mfin : fintype m], 26 \u2264 @fintype.card m mfin, from sorry,\n  have h28 : \u2203 (m : F.Model) [mfin : fintype m], 27 \u2264 @fintype.card m mfin, from sorry,\n  have h29 : \u2203 (m : F.Model) [mfin : fintype m], 28 \u2264 @fintype.card m mfin, from sorry,\n\n  have h30 : \u2203 (m : F.Model) [mfin : fintype m], 29 \u2264 @fintype.card m mfin, from sorry,\n  have h31 : \u2203 (m : F.Model) [mfin : fintype m], 30 \u2264 @fintype.card m mfin, from sorry,\n  have h32 : \u2203 (m : F.Model) [mfin : fintype m], 31 \u2264 @fintype.card m mfin, from sorry,\n  have h33 : \u2203 (m : F.Model) [mfin : fintype m], 32 \u2264 @fintype.card m mfin, from sorry,\n  have h34 : \u2203 (m : F.Model) [mfin : fintype m], 33 \u2264 @fintype.card m mfin, from sorry,\n\n  have h35 : \u2203 (m : F.Model) [mfin : fintype m], 34 \u2264 @fintype.card m mfin, from sorry,\n  have h36 : \u2203 (m : F.Model) [mfin : fintype m], 35 \u2264 @fintype.card m mfin, from sorry,\n  have h37 : \u2203 (m : F.Model) [mfin : fintype m], 36 \u2264 @fintype.card m mfin, from sorry,\n  have h38 : \u2203 (m : F.Model) [mfin : fintype m], 37 \u2264 @fintype.card m mfin, from sorry,\n  have h39 : \u2203 (m : F.Model) [mfin : fintype m], 38 \u2264 @fintype.card m mfin, from sorry,\n\n  have h40 : \u2203 (m : F.Model) [mfin : fintype m], 39 \u2264 @fintype.card m mfin, from sorry,\n  have h41 : \u2203 (m : F.Model) [mfin : fintype m], 40 \u2264 @fintype.card m mfin, from sorry,\n  have h42 : \u2203 (m : F.Model) [mfin : fintype m], 41 \u2264 @fintype.card m mfin, from sorry,\n  have h43 : \u2203 (m : F.Model) [mfin : fintype m], 42 \u2264 @fintype.card m mfin, from sorry,\n  have h44 : \u2203 (m : F.Model) [mfin : fintype m], 43 \u2264 @fintype.card m mfin, from sorry,\n\n  have h45 : \u2203 (m : F.Model) [mfin : fintype m], 44 \u2264 @fintype.card m mfin, from sorry,\n  have h46 : \u2203 (m : F.Model) [mfin : fintype m], 45 \u2264 @fintype.card m mfin, from sorry,\n  have h47 : \u2203 (m : F.Model) [mfin : fintype m], 46 \u2264 @fintype.card m mfin, from sorry,\n  have h48 : \u2203 (m : F.Model) [mfin : fintype m], 47 \u2264 @fintype.card m mfin, from sorry,\n  have h49 : \u2203 (m : F.Model) [mfin : fintype m], 48 \u2264 @fintype.card m mfin, from sorry,\n\n  have h50 : \u2203 (m : F.Model) [mfin : fintype m], 49 \u2264 @fintype.card m mfin, from sorry,\n  have h51 : \u2203 (m : F.Model) [mfin : fintype m], 50 \u2264 @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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  assume (n : \u2115),\n  let A : L.Theory := F.union (L.Theory.of (L.model_of_nat n)),\n  have h1 : \u2200 (s : finset F.Model), (\u2200 (m : F.Model) (H : m \u2208 s), m.satisfies A) \u2192 \u2203 (M : F.Model), M.satisfies A, from sorry,\n  have h2 : \u2200 (s : finset F.Model), (\u2200 (m : F.Model) (H : m \u2208 s), m.satisfies A) \u2192 \u2203 (M : F.Model), M.satisfies A \u2227 infinite M, from sorry,\n  have h3 : \u2203 (M : F.Model), M.satisfies A \u2227 infinite M, from sorry,\n  show \u2203 (M : F.Model), infinite M, from sorry,\nend\n\n--OUTPUT 7\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  sorry,\nend\n\n--OUTPUT 8\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  have h1 : \u2200 n : \u2115, \u2203 (A : F.Model), n \u2264 fintype.card A, from sorry,\n  have h2 : \u2200 n : \u2115, F.Formula.Existential n \u2208 F.Theory.satisfiable, from sorry,\n  have h3 : \u2200 n : \u2115, F.Formula.ForAll n \u2208 F.Theory.satisfiable, from sorry,\n  have h4 : \u2200 n : \u2115, \u2203 (A : F.Model), F.Formula.ForAll n \u2208 F.Model.satisfy A, from sorry,\n\n  have h5 : \u2200 n : \u2115,  F.Formula.ForAll (n + 1), from sorry,\n  have h6 : \u2200 n : \u2115,  F.Formula.ForAll (n + 2), from sorry,\n\n  have h7 : \u2200 n : \u2115,  F.Formula.ForAll (n + 3), from sorry,\n\n  have h8 : \u2200 n : \u2115,  F.Formula.ForAll (n + 4), from sorry,\n  have h9 : \u2200 n : \u2115,  F.Formula.ForAll (n + 5), from sorry,\n\n  have h10 : \u2200 n : \u2115,  F.Formula.ForAll (n + 6), from sorry,\n\n  have h11 : \u2200 n : \u2115,  F.Formula.ForAll (n + 7), from sorry,\n  have h12 : \u2200 n : \u2115,  F.Formula.ForAll (n + 8), from sorry,\n\n  have h13 : \u2200 n : \u2115,  F.Formula.ForAll (n + 9), from sorry,\n  have h14 : \u2200 n : \u2115,  F.Formula.ForAll (n + 10), from sorry,\n\n  have h15 : \u2200 n : \u2115,  F.Formula.ForAll (n + 11), from sorry,\n  have h16 : \u2200 n : \u2115,  F.Formula.ForAll (n + 12), from sorry,\n\n  have h17 : \u2200 n : \u2115,  F.Formula.ForAll (n + 13), from sorry,\n  have h18 : \u2200 n : \u2115,  F.Formula.ForAll (n + 14), from sorry,\n\n  have h19 : \u2200 n : \u2115,  F.Formula.ForAll (n + 15), from sorry,\n  have h20 : \u2200 n : \u2115,  F.Formula.ForAll (n + 16), from sorry,\n\n  have h21 : \u2200 n : \u2115,  F.Formula.ForAll (n + 17), from sorry,\n  have h22 : \u2200 n : \u2115,  F.Formula.ForAll (n + 18), from sorry,\n\n  have h23 : \u2200 n : \u2115,  F.Formula.ForAll (n + 19), from sorry,\n  have h24 : \u2200 n : \u2115,  F.Formula.ForAll (n + 20), from sorry,\n\n  have h25 : \u2200 n : \u2115,  F.Formula.ForAll (n + 21), from sorry,\n  have h26 : \u2200 n : \u2115,  F.Formula.ForAll (n + 22), from sorry,\n\n  have h27 : \u2200 n : \u2115,  F.Formula.ForAll (n + 23), from sorry,\n  have h28 : \u2200 n : \u2115,  F.Formula.ForAll (n + 24), from sorry,\n\n  have h29 : \u2200 n : \u2115,  F.Formula.ForAll (n + 25), from sorry,\n  have h30 : \u2200 n : \u2115,  F.Formula.ForAll (n + 26), from sorry,\n\n  have h31 : \u2200 n : \u2115,  F.Formula.ForAll (n + 27), from sorry,\n  have h32 : \u2200 n : \u2115,  F.Formula.ForAll (n + 28), from sorry,\n\n  have h33 : \u2200 n : \u2115,  F.Formula.ForAll (n + 29), from sorry,\n  have h34 : \u2200 n : \u2115,  F.Formula.ForAll (n + 30), from sorry,\n\n  have h35 : \u2200 n : \u2115,  F.Formula.ForAll (n + 31), from sorry,\n  have h36 : \u2200 n : \u2115,  F.Formula.ForAll (n + 32), from sorry,\n\n  have h37 : \u2200 n : \u2115,  F.Formula.ForAll (n + 33), from sorry,\n  have h38 : \u2200 n : \u2115,  F.Formula.ForAll (n + 34), from sorry,\n\n  have h39 : \u2200 n : \u2115,  F.Formula.ForAll (n + 35), from sorry,\n  have h40 : \u2200 n : \u2115,  F.Formula.ForAll (n + 36), from sorry,\n\n  have h41 : \u2200 n : \u2115,  F.Formula.ForAll (n + 37), from sorry,\n  have h42 : \u2200 n : \u2115,  F.Formula.ForAll (n + 38), from sorry,\n\n  have h43 : \u2200 n : \u2115,  F.Formula.ForAll (n + 39), from sorry,\n  have h44 : \u2200 n : \u2115,  F.Formula.ForAll (n + 40), from sorry,\n\n  have h45 : \u2200 n : \u2115,  F.Formula.ForAll (n + 41), from sorry,\n  have h46 : \u2200 n : \u2115,  F.Formula.ForAll (n + 42), from sorry,\n\n  have h47 : \u2200 n : \u2115,  F.Formula.ForAll (n + 43), from sorry,\n  have h48 : \u2200 n : \u2115,  F.Formula.ForAll (n + 44), from sorry,\n\n  have h49 : \u2200 n : \u2115,  F.Formula.ForAll (n + 45), from sorry,\n  have h50 : \u2200 n : \u2115,  F.Formula.ForAll (n + 46), from sorry,\n\n  have h51 : \u2200 n : \u2115,  F.Formula.ForAll (n + 47), from sorry,\n  have h52 : \u2200 n : \u2115,  F.Formula.ForAll (n + 48), from sorry,\n\n  have h53 : \u2200 n : \u2115,  F.Formula.ForAll (n + 49), from sorry,\n  have h54 : \u2200 n : \u2115,  F.Formula.ForAll (n + 50), from sorry,\n\n  have h55 : \u2200 n : \u2115,  F.Formula.ForAll (n + 51), from sorry,\n  have h56 : \u2200 n : \u2115,  F.Formula.ForAll (n + 52), from sorry,\n\n  have h57 : \u2200 n : \u2115,  F.Formula.ForAll (n + 53), from sorry,\n  have h58 : \u2200 n : \u2115,  F.Formula.ForAll (n + 54), from sorry,\n\n  have h59 : \u2200 n : \u2115,  F.Formula.ForAll (n + 55), from sorry,\n  have h60 : \u2200 n : \u2115,  F.Formula.ForAll (n + 56), from sorry,\n\n  have h61 : \u2200 n : \u2115,  F.Formula.ForAll (n + 57), from sorry,\n  have h62 : \u2200 n : \u2115,  F.Formula.ForAll (n + 58), from sorry,\n\n  have h63 : \u2200 n : \u2115,  F.Formula.ForAll (n + 59), from sorry,\n  have h64 : \u2200 n : \u2115,  F.Formula.ForAll (n + 60), from sorry,\n\n  have h65 : \u2200 n : \u2115,  F.Formula.ForAll (n + 61), from sorry,\n  have h66 : \u2200 n : \u2115, \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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (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 model_theory.substructures\nimport model_theory.bundled\n\n\n--OUTPUT 1\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  have h1 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h2 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 fintype.card m, from by auto,\n  have h3 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h4 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h5 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h6 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h7 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h8 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h9 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h10 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h11 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h12 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h13 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h14 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h15 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h16 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h17 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h18 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h19 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h20 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h21 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h22 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h23 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h24 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h25 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h26 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h27 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h28 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h29 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h30 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h31 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h32 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h33 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h34 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h35 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h36 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h37 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h38 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h39 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h40 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h41 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto,\n  have h42 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let A_i := \u03bb (n : \u2115), \u2203 (x_1 : M), \u2203 (x_2 : M), (\u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 x_i \u2260 x_n),\n  have h1 : \u2200 (n : \u2115), \u2203 (m : F.Model) [mfin : fintype m], @A_i n m, from by auto [h],\n  have h2 : \u2200 (n : \u2115), \u2203 (m : F.Model), @A_i n m, from by auto [h1],\n  have h3 : \u2200 (n : \u2115), \u2203 (m : F.Model), @A_i n m \u2227 (\u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), (\u2203 (x_n : M), x_i \u2260 x_n)), from by auto [h2],\n  have h4 : \u2200 (n : \u2115), @A_i n M, from by auto [h3],\n  have h5 : \u2200 (n : \u2115), \u2203 (x_1 : M), \u2203 (x_2 : M), (\u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 x_i \u2260 x_n), from by auto [h4],\n  have h6 : \u2200 (n : \u2115), \u2203 (x_1 : M), \u2203 (x_2 : M), (\u2203 (x_n : M), x_1 \u2260 x_2 \u2227 x_1 \u2260 x_n), from by auto [h5],\n  have h7 : \u2200 (n : \u2115), \u2203 (x_1 : M), \u2203 (x_2 : M), (\u2203 (x_n : M), x_1 \u2260 x_2 \u2227 x_2 \u2260 x_n), from by auto [h6],\n  have h8 : \u2200 (n : \u2115), \u2203 (x_1 : M), \u2203 (x_2 : M), (\u2203 (x_n : M), x_1 \u2260 x_2 \u2227 x_2 \u2260 x_n \u2227 x_1 \u2260 x_n), from by auto [h7],\n  have h9 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h8],\n  have h10 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n \u2227 \u2200 (j : \u2115), j \u2260 i \u2192 x_j \u2260 x_n, from by auto [h9],\n  have h11 : \u2200 (n : \u2115), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), \u2200 (j : \u2115), j \u2260 i \u2192 x_j \u2260 x_n, from by auto [h10],\n  have h12 : \u2200 (n : \u2115), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), \u2200 (j : \u2115), j \u2260 i \u2192 x_j \u2260 x_n, from by auto [h11],\n  have h13 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h12],\n  have h14 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h13],\n  have h15 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h14],\n  have h16 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h15],\n  have h17 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h16],\n  have h18 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h17],\n  have h19 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h18],\n  have h20 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h19],\n  have h21 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h20],\n  have h22 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h21],\n  have h23 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h22],\n  have h24 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h23],\n  have h25 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h24],\n  have h26 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h25],\n  have h27 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h26],\n  have h28 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h27],\n  have h29 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h28],\n  have h30 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260 x_n, from by auto [h29],\n  have h31 : \u2200 (n : \u2115), \u2203 (x_n : M), \u2200 (i : \u2115), i < n \u2192 \u2203 (x_i : M), x_i \u2260\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M := \nbegin\n  have h1 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h],\n  have h2 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h1],\n  have h3 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h2],\n  have h4 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h3],\n  have h5 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h4],\n  have h6 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h5],\n  have h7 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h6],\n\n  have h8 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h7],\n  have h9 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h8],\n  have h10 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h9],\n  have h11 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h10],\n  have h12 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h11],\n  have h13 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h12],\n\n  have h14 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h13],\n  have h15 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h14],\n  have h16 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h15],\n  have h17 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h16],\n  have h18 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h17],\n  have h19 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h18],\n\n  have h20 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h19],\n  have h21 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h20],\n  have h22 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h21],\n  have h23 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h22],\n  have h24 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h23],\n  have h25 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h24],\n\n  have h26 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h25],\n  have h27 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h26],\n  have h28 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h27],\n  have h29 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h28],\n  have h30 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h29],\n  have h31 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h30],\n\n  have h32 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h31],\n  have h33 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h32],\n  have h34 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h33],\n  have h35 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h34],\n  have h36 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h35],\n  have h37 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h36],\n\n  have h38 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h37],\n  have h39 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h38],\n  have h40 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin := by auto [h\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  have h1 : \u2200 n : \u2115, F.Theory.formula (\u2203 x y : M, x \u2260 y \u2227 x \u2260 y), from by auto, \n\n  have h2 : F.Theory.formula (\u2203 x : M, \u2203 y : M, x \u2260 y \u2227 x \u2260 y), from by auto, \n\n  have h3 : F.Theory.formula (\u2203 x : M, \u2203 y : M, x \u2260 y \u2227 x \u2260 y \u2227 \u2203 z : M, z \u2260 x \u2227 z \u2260 y), from by auto, \n\n  have h4 : \u2200 n : \u2115, F.Theory.formula (\u2203 x\u2081 x\u2082 x\u2083 : M, x\u2081 \u2260 x\u2082 \u2227 x\u2082 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2083), from by auto, \n\n  have h5 : \u2200 n : \u2115, F.Theory.formula (\u2203 x\u2081 x\u2082 x\u2083 x\u2084 : M, x\u2081 \u2260 x\u2082 \u2227 x\u2082 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2084 \u2227 x\u2082 \u2260 x\u2084 \u2227 x\u2083 \u2260 x\u2084), from by auto, \n\n  have h6 : \u2200 n : \u2115, F.Theory.formula (\u2203 x\u2081 x\u2082 x\u2083 x\u2084 x\u2085 : M, x\u2081 \u2260 x\u2082 \u2227 x\u2082 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2084 \u2227 x\u2082 \u2260 x\u2084 \u2227 x\u2083 \u2260 x\u2084 \u2227 x\u2081 \u2260 x\u2085 \u2227 x\u2082 \u2260 x\u2085 \u2227 x\u2083 \u2260 x\u2085 \u2227 x\u2084 \u2260 x\u2085), from by auto, \n\n  have h7 : \u2200 n : \u2115, F.Theory.formula (\u2203 x\u2081 x\u2082 x\u2083 x\u2084 x\u2085 x\u2086 : M, x\u2081 \u2260 x\u2082 \u2227 x\u2082 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2084 \u2227 x\u2082 \u2260 x\u2084 \u2227 x\u2083 \u2260 x\u2084 \u2227 x\u2081 \u2260 x\u2085 \u2227 x\u2082 \u2260 x\u2085 \u2227 x\u2083 \u2260 x\u2085 \u2227 x\u2084 \u2260 x\u2085 \u2227 x\u2081 \u2260 x\u2086 \u2227 x\u2082 \u2260 x\u2086 \u2227 x\u2083 \u2260 x\u2086 \u2227 x\u2084 \u2260 x\u2086 \u2227 x\u2085 \u2260 x\u2086), from by auto, \n\n  have h8 : \u2200 n : \u2115, F.Theory.formula (\u2203 x\u2081 x\u2082 x\u2083 x\u2084 x\u2085 x\u2086 x\u2087 : M, x\u2081 \u2260 x\u2082 \u2227 x\u2082 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2084 \u2227 x\u2082 \u2260 x\u2084 \u2227 x\u2083 \u2260 x\u2084 \u2227 x\u2081 \u2260 x\u2085 \u2227 x\u2082 \u2260 x\u2085 \u2227 x\u2083 \u2260 x\u2085 \u2227 x\u2084 \u2260 x\u2085 \u2227 x\u2081 \u2260 x\u2086 \u2227 x\u2082 \u2260 x\u2086 \u2227 x\u2083 \u2260 x\u2086 \u2227 x\u2084 \u2260 x\u2086 \u2227 x\u2085 \u2260 x\u2086 \u2227 x\u2081 \u2260 x\u2087 \u2227 x\u2082 \u2260 x\u2087 \u2227 x\u2083 \u2260 x\u2087 \u2227 x\u2084 \u2260 x\u2087 \u2227 x\u2085 \u2260 x\u2087 \u2227 x\u2086 \u2260 x\u2087), from by auto, \n\n  have h9 : \u2200 n : \u2115, F.Theory.formula (\u2203 x\u2081 x\u2082 x\u2083 x\u2084 x\u2085 x\u2086 x\u2087 x\u2088 : M, x\u2081 \u2260 x\u2082 \u2227 x\u2082 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2084 \u2227 x\u2082 \u2260 x\u2084 \u2227 x\u2083 \u2260 x\u2084 \u2227 x\u2081 \u2260 x\u2085 \u2227 x\u2082 \u2260 x\u2085 \u2227 x\u2083 \u2260 x\u2085 \u2227 x\u2084 \u2260 x\u2085 \u2227 x\u2081 \u2260 x\u2086 \u2227 x\u2082 \u2260 x\u2086 \u2227 x\u2083 \u2260 x\u2086 \u2227 x\u2084 \u2260 x\u2086 \u2227 x\u2085 \u2260 x\u2086 \u2227 x\u2081 \u2260 x\u2087 \u2227 x\u2082 \u2260 x\u2087 \u2227 x\u2083 \u2260 x\u2087 \u2227 x\u2084 \u2260 x\u2087 \u2227 x\u2085 \u2260 x\u2087 \u2227 x\u2086 \u2260 x\u2087 \u2227 x\u2081 \u2260 x\u2088 \u2227 x\u2082 \u2260 x\u2088 \u2227 x\u2083 \u2260 x\u2088 \u2227 x\u2084 \u2260 x\u2088 \u2227 x\u2085 \u2260 x\u2088 \u2227 x\u2086 \u2260 x\u2088 \u2227 x\u2087 \u2260 x\u2088), from by auto, \n\n  have h10 : \u2200 n : \u2115, F.Theory.formula (\u2203 x\u2081 x\u2082 x\u2083 x\u2084 x\u2085 x\u2086 x\u2087 x\u2088 x\u2089 : M, x\u2081 \u2260 x\u2082 \u2227 x\u2082 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2083 \u2227 x\u2081 \u2260 x\u2084 \u2227 x\u2082 \u2260 x\u2084 \u2227 x\u2083 \u2260 x\u2084 \u2227 x\u2081 \u2260 x\u2085 \u2227 x\u2082 \u2260 x\u2085 \u2227 x\u2083 \u2260 x\u2085 \u2227 x\u2084 \u2260 x\u2085 \u2227 x\u2081 \u2260 x\u2086 \u2227 x\u2082 \u2260 x\u2086 \u2227 x\u2083 \u2260 x\u2086 \u2227 x\u2084 \u2260 x\u2086 \u2227 x\u2085 \u2260 x\u2086 \u2227 x\u2081 \u2260 x\u2087 \u2227 x\u2082 \u2260 x\u2087 \u2227 x\u2083 \u2260 x\u2087 \u2227 x\u2084 \u2260 x\u2087 \u2227 x\u2085 \u2260 x\u2087 \u2227 x\u2086 \u2260 x\u2087 \u2227 x\u2081 \u2260 x\u2088 \u2227 x\u2082 \u2260 x\u2088 \u2227 x\u2083 \u2260 x\u2088 \u2227 x\u2084 \u2260 x\u2088 \u2227 x\u2085 \u2260 x\u2088 \u2227 x\u2086 \u2260 x\u2088 \u2227 x\u2087 \u2260 x\u2088 \u2227 x\u2081 \u2260 x\u2089 \u2227 x\u2082 \u2260 x\u2089 \u2227 x\u2083 \u2260 x\u2089 \u2227 x\u2084 \u2260 x\u2089 \u2227 x\u2085 \u2260 x\u2089 \u2227 x\u2086 \u2260 x\u2089 \u2227 x\u2087 \u2260 x\u2089 \u2227 x\u2088 \u2260 x\u2089), from by auto, \n\n  have h11 : \u2200 n : \u2115, F.Theory.formula (\u2203 x\u2081 x\u2082 x\u2083 x\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  have h1 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 F.Model, from by auto [h],\n  have h2 : \u2200 (a : \u2115) (b : \u2203 (m : F.Model) [mfin : fintype m], a \u2264 @fintype.card m mfin), F.Model, from by auto [h1],\n  have h3 : \u2200 (n : \u2115) (b : \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin), F.Model, from by auto [h2],\n  have h4 : \u2200 (n : \u2115), F.Model, from by auto [h3],\n  have h5 : \u2200 (n : \u2115), \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 F.Model, from by auto [h1, h4],\n  have h6 : \u2200 (a : \u2115) (b : \u2203 (m : F.Model) [mfin : fintype m], a \u2264 @fintype.card m mfin), F.Model, from by auto [h5],\n  have h7 : \u2200 (n : \u2115) (b : \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin), F.Model, from by auto [h6],\n  have h8 : \u2200 (n : \u2115), F.Model, from by auto [h7],\n  have h9 : \u2200 (m : F.Model) [mfin : fintype m], \u2203 (n : \u2115), n \u2264 @fintype.card m mfin, from by auto [fintype.card_pos, exists_nat_le],\n  have h10 : \u2203 (n : \u2115) (b : \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin), F.Model, from by auto [h9, h8],\n  have h11 : \u2203 (n : \u2115) (b : F.Model), n \u2264 fintype.card b, from by auto [h10, exists_prop],\n  have h12 : \u2203 (n : \u2115) (b : F.Model), n \u2264 fintype.card b \u2192 F.Model, from by auto [h11],\n  have h13 : \u2200 (a : \u2115) (b : F.Model), a \u2264 fintype.card b \u2192 F.Model, from by auto [h12],\n  have h14 : \u2200 (n : \u2115) (b : F.Model), n \u2264 fintype.card b \u2192 F.Model, from by auto [h13],\n  have h15 : \u2200 (n : \u2115), F.Model, from by auto [h14],\n  have h16 : \u2200 (n : \u2115), F.Model \u2192 F.Model, from by auto [h15],\n  have h17 : \u2200 (n : \u2115) (b : F.Model), F.Model, from by auto [h16],\n  have h18 : \u2200 (n : \u2115) (b : F.Model), F.Model \u2192 F.Model, from by auto [h17],\n  have h19 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model), F.Model, from by auto [h18],\n  have h20 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model), F.Model \u2192 F.Model, from by auto [h19],\n  have h21 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model), F.Model \u2192 F.Model \u2192 F.Model, from by auto [h20],\n  have h22 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model, from by auto [h21],\n  have h23 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model, from by auto [h22],\n  have h24 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model, from by auto [h23],\n  have h25 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h24],\n  have h26 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h25],\n  have h27 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h26],\n  have h28 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h27],\n  have h29 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h28],\n  have h30 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h29],\n  have h31 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h30],\n  have h32 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h31],\n  have h33 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h32],\n  have h34 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d : F.Model) (e : F.Model), F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model \u2192 F.Model, from by auto [h33],\n  have h35 : \u2200 (n : \u2115) (b : F.Model) (c : F.Model) (d :\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  assume L,\n  assume F,\n  assume h,\n\n  let A : \u2115 \u2192 L.Theory,\n  let A' : \u2115 \u2192 L.Theory,\n  let A'' : \u2115 \u2192 L.Theory,\n  let B : L.Theory,\n  let C : L.Theory,\n  let \u0393 : L.Theory,\n  let h1 : \u2200 n : \u2115, A' n = A'' n,\n  let h2 : \u2200 n : \u2115, A' n = A n,\n  let h3 : \u0393 = F \u222a C,\n  let h4 : C = \u22c3 n : \u2115, A' n,\n  let h5 : \u2200 n : \u2115, A n = A'' n,\n  let h6 : C = \u22c3 n : \u2115, A'' n,\n  have h1 : \u2200 n : \u2115, A' n = A'' n, from by auto [h2, h5],\n  have h3 : \u0393 = F \u222a C, from by auto [h4, h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n, from by auto [h4],\n  have h3 : \u0393 = F \u222a C, from by auto [h6],\n  have h4 : \u2200 n : \u2115, A n = A'' n, from by auto [h1, h2],\n  have h6 : C = \u22c3 n : \u2115, A'' n,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let \u0393 := F.set \u222a (\u22c3 (n : \u2115), F.model_has_n_elements n),\n  have h1 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by auto [h],\n  have h2 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2227 F.model_has_n_elements n m, from by auto [F.model_has_n_elements],\n  have h3 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2227 \u2203 (n : \u2115), F.model_has_n_elements n m, from by auto [F.model_has_n_elements],\n  have h4 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2227 \u2203 (n : \u2115), F.model_has_n_elements n m \u2227 F.set \u2286 F.Theory.set_of_formulas m, from by auto [F.sat_of_mem],\n  have h5 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2227 \u2203 (n : \u2115), F.model_has_n_elements n m \u2227 F.set \u2286 F.Theory.set_of_formulas m \u2227 F.Theory.set_of_formulas m \u2286 F.set, from by auto [F.set_of_formulas_subset_set],\n  have h6 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2227 \u2203 (n : \u2115), F.model_has_n_elements n m \u2227 F.set \u2286 F.Theory.set_of_formulas m \u2227 F.Theory.set_of_formulas m = F.set, from by auto [ext],\n  have h7 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2227 \u2203 (n : \u2115), F.model_has_n_elements n m \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.set], F.Theory.sat f m, from by auto [F.sat_of_mem],\n  have h8 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2227 \u2203 (n : \u2115), F.model_has_n_elements n m \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.set], F.Theory.sat f m \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.L.formula.set], F.Theory.sat f m, from by auto [F.sat, F.model_has_n_elements],\n  have h9 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2227 \u2203 (n : \u2115), F.model_has_n_elements n m \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.set], F.Theory.sat f m \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.L.formula.set], F.Theory.sat f m \u2227 \u2200 (f : F.L.formula), F.Theory.sat f m, from by auto [F.model_has_n_elements, F.sat],\n  have h10 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2192 \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin \u2227 \u2203 (n : \u2115), F.model_has_n_elements n m \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.set], F.Theory.sat f m \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.L.formula.set], F.Theory.sat f m \u2227 \u2200 (f : F.L.formula), F.Theory.sat f m \u2227 finite m, from by auto [F.sat, F.model_has_n_elements],\n  have h11 : \u2203 (M : F.Model), \u2200 (f : F.L.formula), F.Theory.sat f M \u2227 finite M, from by auto [fintype.complete, F.sat],\n  have h12 : \u2203 (M : F.Model), \u2200 (f : F.L.formula), F.Theory.sat f M \u2227 finite M \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.set], F.Theory.sat f M, from by auto [F.sat_of_mem],\n  have h13 : \u2203 (M : F.Model), \u2200 (f : F.L.formula), F.Theory.sat f M \u2227 finite M \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.set], F.Theory.sat f M \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.L.formula.set], F.Theory.sat f M, from by auto [F.sat, F.model_has_n_elements],\n  have h14 : \u2203 (M : F.Model), \u2200 (f : F.L.formula), F.Theory.sat f M \u2227 finite M \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.set], F.Theory.sat f M \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.L.formula.set], F.Theory.sat f M \u2227 \u2200 (f : F.L.formula), F.Theory.sat f M, from by auto [F.sat, F.model_has_n_elements],\n  have h15 : \u2203 (M : F.Model), \u2200 (f : F.L.formula), F.Theory.sat f M \u2227 finite M \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.set], F.Theory.sat f M \u2227 \u2200 (f : F.L.formula) [h : f \u2208 F.L.formula.set], F.Theory.sat f M \u2227 \u2200 (f\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let A_n : L.Formula := L.exists_list [L.var n],\n  have h1 : \u2200 (n : \u2115), A_n n \u2208 F, from by auto [L.exists_list_mem],\n  have h2 : \u2200 (n : \u2115), A_n n \u2208 F.set_of_formulas, from by auto [L.exists_list_mem, L.mem_set_of_formulas],\n  have h3 : \u2200 (n : \u2115), \u00ac (A_n n \u2208 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h4 : \u2200 (n : \u2115), (A_n n \u2209 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  let Gamma : set L.Formula := F.set_of_formulas \u222a (set.univ.image (\u03bb n : \u2115, A_n n)),\n  have h5 : \u2200 (n : \u2115), A_n n \u2208 Gamma, from by auto [set.mem_union_left, set.mem_univ, set.mem_image],\n  have h6 : Gamma \u2286 F.set_of_formulas, from by simp [set.subset_def],\n  have h7 : \u2200 (n : \u2115), A_n n \u2208 F, from by auto [L.exists_list_mem],\n  have h8 : \u2200 (n : \u2115), A_n n \u2208 F.set_of_formulas, from by auto [L.exists_list_mem, L.mem_set_of_formulas],\n  have h9 : \u2200 (n : \u2115), \u2200 (i : \u2115), i < n \u2192 (L.var i) \u2208 A_n n, from by auto [L.exists_list_mem],\n  have h10 : \u2200 (n : \u2115), \u2200 (i : \u2115), i < n \u2192 (L.var i) \u2208 F.set_of_formulas, from by auto [L.exists_list_mem, L.mem_set_of_formulas],\n  have h11 : \u2200 (n : \u2115), \u2200 (i j : \u2115), i < n \u2192 j < n \u2192 i \u2260 j \u2192 L.neq (L.var i) (L.var j) \u2208 A_n n, from by auto [L.exists_list_mem],\n  have h12 : \u2200 (n : \u2115), \u2200 (i j : \u2115), i < n \u2192 j < n \u2192 i \u2260 j \u2192 L.neq (L.var i) (L.var j) \u2208 F.set_of_formulas, from by auto [L.exists_list_mem, L.mem_set_of_formulas],\n  have h13 : \u2200 (n : \u2115), \u2200 (i : \u2115), i < n \u2192 (L.var i) \u2208 A_n n, from by auto [L.exists_list_mem],\n  have h14 : \u2200 (n : \u2115), \u2200 (i j : \u2115), i < n \u2192 j < n \u2192 i \u2260 j \u2192 L.neq (L.var i) (L.var j) \u2208 A_n n, from by auto [L.exists_list_mem],\n\n  have h15 : \u2200 (n : \u2115), \u2200 (s : F.Model_Structure), s.model_assignment \u22a8 (A_n n) \u2194 (s.model_assignment.domain.cardinal \u2265 n), from by auto [L.exists_list_satisfaction, L.not_satisfaction, set.card_ge_iff_exists],\n  have h16 : \u2200 (n : \u2115), \u00ac (A_n n \u2208 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h17 : \u2200 (n : \u2115), (A_n n \u2209 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h18 : \u2200 (n : \u2115), \u2200 (s : F.Model_Structure), s.model_assignment \u22a8 (A_n n) \u2194 (s.model_assignment.domain.cardinal \u2265 n), from by auto [L.exists_list_satisfaction, L.not_satisfaction, set.card_ge_iff_exists],\n  have h19 : \u2200 (n : \u2115), \u00ac (A_n n \u2208 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h20 : \u2200 (n : \u2115), (A_n n \u2209 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h21 : \u2200 (n : \u2115), \u2200 (s : F.Model_Structure), s.model_assignment \u22a8 (A_n n) \u2194 (s.model_assignment.domain.cardinal \u2265 n), from by auto [L.exists_list_satisfaction, L.not_satisfaction, set.card_ge_iff_exists],\n  have h22 : \u2200 (n : \u2115), \u00ac (A_n n \u2208 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h23 : \u2200 (n : \u2115), (A_n n \u2209 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h24 : \u2200 (n : \u2115), \u2200 (s : F.Model_Structure), s.model_assignment \u22a8 (A_n n) \u2194 (s.model_assignment.domain.cardinal \u2265 n), from by auto [L.exists_list_satisfaction, L.not_satisfaction, set.card_ge_iff_exists],\n  have h25 : \u2200 (n : \u2115), \u00ac (A_n n \u2208 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h26 : \u2200 (n : \u2115), (A_n n \u2209 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n\n  have h27 : \u2200 (n : \u2115), \u2200 (s : F.Model_Structure), s.model_assignment \u22a8 (A_n n) \u2194 (s.model_assignment.domain.cardinal \u2265 n), from by auto [L.exists_list_satisfaction, L.not_satisfaction, set.card_ge_iff_exists],\n  have h28 : \u2200 (n : \u2115), \u00ac (A_n n \u2208 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h29 : \u2200 (n : \u2115), (A_n n \u2209 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h30 : \u2200 (n : \u2115), \u2200 (s : F.Model_Structure), s.model_assignment \u22a8 (A_n n) \u2194 (s.model_assignment.domain.cardinal \u2265 n), from by auto [L.exists_list_satisfaction, L.not_satisfaction, set.card_ge_iff_exists],\n  have h31 : \u2200 (n : \u2115), \u00ac (A_n n \u2208 F), from by auto [L.exists_list_not_mem, L.not_mem_set_of_formulas],\n  have h32 : \u2200 (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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from by auto [h2],\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (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.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.5851011542032312, "lm_q2_score": 0.3923368301671084, "lm_q1q2_score": 0.2295567321672122}}
{"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\u2081 u\u2082\nopen_locale tensor_product\n\nopen category_theory category_theory.limits opposite\n\nsection\nvariables {\ud835\udcd0 : Type u\u2081} {\ud835\udcd1 : Type u\u2082} [category.{v} \ud835\udcd0] [category.{v} \ud835\udcd1] (F : \ud835\udcd0 \u2964 \ud835\udcd1)\nvariables [abelian \ud835\udcd0] [abelian \ud835\udcd1]\n\ndef preserves_limits_of_shape_pempty_of_preserves_terminal\n  [preserves_limit (functor.empty.{v} \ud835\udcd0) F] : preserves_limits_of_shape (discrete pempty) F :=\n{ preserves_limit := \u03bb K,\n    preserves_limit_of_iso_diagram.{v v} F (functor.empty_ext (functor.empty \ud835\udcd0) _) }\n\ndef preserves_terminal_object_of_preserves_zero_morphisms\n  [functor.preserves_zero_morphisms F] : preserves_limit (functor.empty \ud835\udcd0) 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_\u03b9 {X Y : \ud835\udcd0} (f g : X \u27f6 Y) (c : cone (parallel_pair f g)) :\n  c \u2245 fork.of_\u03b9 (fork.\u03b9 c) (fork.condition c) :=\nfork.ext (iso.refl _) (by tidy)\n\ndef preserves_equalizer_of_preserves_kernels [F.additive]\n  [\u2200 {X Y} (f : X \u27f6 Y), preserves_limit (parallel_pair f 0) F] {X Y : \ud835\udcd0}\n  (f g : X \u27f6 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_\u03b9 _ _ 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_\u03b9 _ _ 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 \u2245 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, \u2190 fork.app_zero_eq_\u03b9],\n  simp [- fork.app_zero_eq_\u03b9]\nend\n\ndef preserves_equalizers_of_preserves_kernels [F.additive]\n  [\u2200 {X Y} (f : X \u27f6 Y), preserves_limit (parallel_pair f 0) F] :\n  preserves_limits_of_shape walking_parallel_pair F :=\n{ preserves_limit := \u03bb 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 : \ud835\udcd0} (f : X \u27f6 Y) (g : Y \u27f6 Z) (h : Z \u27f6 A) [mono h]:\n  exact f (g \u226b h) \u2194 exact f g :=\nbegin\n  refine \u27e8\u03bb hfg, \u27e8zero_of_comp_mono h (by rw [category.assoc, hfg.1]), _\u27e9, \u03bb h, exact_comp_mono h\u27e9,\n  rw \u2190 (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  {\ud835\udcd0 : Type u\u2081} {\ud835\udcd1 : Type u\u2082} [category.{v} \ud835\udcd0] [category.{v} \ud835\udcd1] [abelian \ud835\udcd0] [abelian \ud835\udcd1]\n  (F : \ud835\udcd0 \u2964 \ud835\udcd1) (h1 : \u2200 \u2983X Y : \ud835\udcd0\u2984 (f : X \u27f6 Y), mono f \u2192 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 : \u2200 {X Y} (f : X \u27f6 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.\u03b9 c)) (F.map f),\n    { haveI : mono (F.map (fork.\u03b9 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 \u03b1 : parallel_pair f 0 \u22d9 F \u2245 parallel_pair (F.map f) 0,\n      { refine diagram_iso_parallel_pair _ \u226a\u226b _,\n        refine parallel_pair.ext (iso.refl _) (iso.refl _) (by simp) (by simp) },\n      refine is_limit.postcompose_hom_equiv \u03b1 _ _,\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_\u03b9 _ _ _),\n    have := abelian.exact_of_is_kernel _ _ (kernel_fork.condition c) hc',\n    simp_rw \u2190 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.\u03b9 f)),\n    { apply h1, apply_instance },\n    simp_rw \u2190 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 \ud835\udcd0) 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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a2).write i1 (v3)).write i3 (v3)).read i1) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test28.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.22945854377344055}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v2) \u2260 ((((a3).write i1 (v2)).write i3 (v2)).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.22945854377344055}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a3).write i2 (v3)).write i1 (v3)).read i2) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test32.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5195213219520929, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.2294585437734405}}
{"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}\u1d52\u1d56 \u2964 Ab.{u+1}) :=\ncategory_theory.functor_category_is_abelian.{(u+2) u (u+1)}\n\n-- ANNOYING!\ninstance ExtrDisc_presheaf_abelian : abelian (ExtrDisc.{u}\u1d52\u1d56 \u2964 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} \u2964 Profinite.{u}\u1d52\u1d56 \u2964 Ab.{u+1} :=\nyoneda \u22d9 (whiskering_right _ _ _).obj (ulift_functor.{u+1} \u22d9 AddCommGroup.free)\n\ndef Profinite_to_ExtrDisc_presheaf : Profinite.{u} \u2964 ExtrDisc.{u}\u1d52\u1d56 \u2964 Type (u+1) :=\nyoneda \u22d9 (whiskering_left _ _ _).obj ExtrDisc_to_Profinite.op \u22d9\n  (whiskering_right _ _ _).obj ulift_functor.{u+1}\n\ndef Profinite_to_ExtrDisc_presheaf_Ab : Profinite.{u} \u2964 ExtrDisc.{u}\u1d52\u1d56 \u2964 Ab.{u+1} :=\nyoneda \u22d9 (whiskering_left _ _ _).obj ExtrDisc_to_Profinite.op \u22d9\n  (whiskering_right _ _ _).obj (ulift_functor.{u+1} \u22d9 AddCommGroup.free)\n\ndef unsheafified_free_Cech' (F : arrow Profinite.{u}) :\n  chain_complex (Profinite.{u}\u1d52\u1d56 \u2964 Ab.{u+1}) \u2115 :=\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}\u1d52\u1d56 \u2964 Ab.{u+1}) \u2115 :=\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}) \u2115 :=\n(((simplicial_object.augmented.whiskering _ _).obj\n  (Profinite_to_Condensed \u22d9 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}) \u2115 :=\n(((simplicial_object.augmented.whiskering _ _).obj\n  (Profinite_to_ExtrDisc_presheaf_Ab \u22d9 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}) \u2124 :=\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] {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0] {\ud835\udcd1 : Type*} [category \ud835\udcd1] [abelian \ud835\udcd1]\n  (f : arrow C) [\u2200 (n : \u2115),\n    has_wide_pullback f.right (\u03bb (i : ulift (fin (n + 1))), f.left) (\u03bb (i : ulift (fin (n + 1))), f.hom)]\n  (F : C \u2964 \ud835\udcd0) (G : \ud835\udcd0 \u2964 \ud835\udcd1) (H : C \u2964 \ud835\udcd1) (E : F \u22d9 G \u2245 H) [G.additive] :\n  (G.map_homological_complex _).obj ((((simplicial_object.augmented.whiskering _ _).obj F).obj\n    f.augmented_cech_nerve).to_complex) \u2245\n  (((simplicial_object.augmented.whiskering _ _).obj H).obj f.augmented_cech_nerve).to_complex :=\nhomological_complex.hom.iso_of_components\n(\u03bb 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, \u2190 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 \u2190 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) \u2245\n  free_ExtrDisc_Cech' F :=\nlet e := ExtrDisc_sheafification_iso in\nwhiskering_Cech_comp_iso F\n  (Profinite_to_Condensed.{u} \u22d9 CondensedSet_to_Condensed_Ab.{u})\n  ((Condensed_ExtrSheaf_equiv.{u u+2} Ab.{u+1}).inverse)\n  (Profinite_to_ExtrDisc_presheaf_Ab.{u} \u22d9 presheaf_to_Sheaf.{u+2 u u+1} ExtrDisc.proetale_topology.{u} Ab.{u+1}) $\nnat_iso.of_components\n(\u03bb 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\u2082_aux\n  {C : Type*} [category C] {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0] {\ud835\udcd1 : Type*} [category \ud835\udcd1] [abelian \ud835\udcd1]\n  (f : arrow C) [\u2200 (n : \u2115),\n    has_wide_pullback f.right (\u03bb (i : ulift (fin (n + 1))), f.left) (\u03bb (i : ulift (fin (n + 1))), f.hom)]\n  (F : C \u2964 \ud835\udcd0) (G : \ud835\udcd0\u1d52\u1d56 \u2964 \ud835\udcd1) [G.additive] :\n  (G.map_homological_complex _).obj ((((simplicial_object.augmented.whiskering _ _).obj F).obj\n    f.augmented_cech_nerve).to_complex).op \u2245\n  (((cosimplicial_object.augmented.whiskering _ _).obj (F.op \u22d9 G)).obj\n    f.augmented_cech_nerve.right_op).to_cocomplex :=\nhomological_complex.hom.iso_of_components\n(\u03bb 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 \u2245\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(\u03bb 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 \u2245 (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(\u03bb 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}\u1d52\u1d56 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} \u2115 :=\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}\u1d52\u1d56 Ab.{u+1}).obj\n  (op X)).map_homological_complex\n  (complex_shape.down.{0} \u2115)).obj\n  (unsheafified_free_ExtrDiscr_Cech.{u} F) \u2245\n  evaluated_free_ExtrDisc_Cech F X :=\nhomological_complex.hom.iso_of_components\n(\u03bb 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) \u27e8rfl\u27e9,\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 : \u2115) = 0 + 1), erw category.id_comp,\n    rw if_pos (rfl : (1 : \u2115) = 0 + 1), erw category.id_comp,\n    apply free_abelian_group.lift.ext,\n    rintro \u27e8t\u27e9,\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} (\u03bb (_x : ulift.{u 0} (fin (0 + 0 + 1))), F.hom))).app\n        (op.{u+2} X.val))) (\u03bb (q : ulift.{u+1 0} (fin (0 + 0 + 1))), ulift_functor.{u+1 u}.map\n        ((yoneda.{u u+1}.map (wide_pullback.\u03c0.{u u+1} (\u03bb (_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} (\u03bb (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 \u2190 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.\u03b4],\n\n    apply free_abelian_group.lift.ext,\n    rintro \u27e8t\u27e9,\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} (\u03bb (i : ulift.{u+1 0}\n      (fin (j + 1 + 1))), (Profinite_to_ExtrDisc_presheaf.{u}.map F.hom).app (op.{u+2} X)))\n      (\u03bb (i_1 : ulift.{u+1 0} (fin (j + 1))), wide_pullback.\u03c0.{u+1 u+2} (\u03bb (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.\u03b4 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} (\u03bb (_x : ulift.{u 0} (fin (j.succ + 0 + 1))), F.hom))).app\n      (op.{u+2} X.val))) (\u03bb (q : ulift.{u+1 0} (fin (j.succ + 0 + 1))), ulift_functor.{u+1 u}.map\n      ((yoneda.{u u+1}.map (wide_pullback.\u03c0.{u u+1} (\u03bb (_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} (\u03bb (_x : ulift.{u 0} (fin (j + 0 + 1))), F.hom))).app\n      (op.{u+2} X.val))) (\u03bb (q : ulift.{u+1 0} (fin (j + 0 + 1))), ulift_functor.{u+1 u}.map\n      ((yoneda.{u u+1}.map (wide_pullback.\u03c0.{u u+1} (\u03bb (_x : ulift.{u 0} (fin (j + 0 + 1))),\n      F.hom) {down := q.down})).app (op.{u+2} X.val))) _,\n\n    change (f2 \u226b f1) _ = f3 _,\n\n    let f4 := wide_pullback.lift.{u u+1} (wide_pullback.base.{u u+1} (\u03bb (i : ulift.{u 0}\n      (fin (j + 1 + 1))), F.hom)) (\u03bb (i_1 : ulift.{u 0} (fin (j + 1))), wide_pullback.\u03c0.{u u+1}\n      (\u03bb (i : ulift.{u 0} (fin (j + 1 + 1))), F.hom) {down := (simplex_category.hom.to_order_hom\n      (simplex_category.\u03b4 i)) i_1.down}) _,\n\n    suffices : f2 \u226b f1 = ((yoneda'.map f4).app (op X.val) \u226b 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_\u03c0, wide_pullback.lift_\u03c0_assoc],\n      erw [wide_pullback.lift_\u03c0],\n      erw [\u2190 functor.map_comp, \u2190 nat_trans.comp_app, \u2190 functor.map_comp, wide_pullback.lift_\u03c0] },\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 [\u2190 functor.map_comp, \u2190 nat_trans.comp_app, \u2190 functor.map_comp,\n        wide_pullback.lift_base] } }\nend\n\nlemma free_Cech_exact (F : arrow Profinite.{u}) (hF : function.surjective F.hom) : \u2200 (n : \u2124),\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 \u27e8\u03bb i, (this i).some, _\u27e9,\n      ext1 i, exact (this i).some_spec },\n    dsimp [G, functor.map_arrow, Profinite_to_ExtrDisc_presheaf, ulift_functor, yoneda],\n    rintros \u27e8e\u27e9,\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) : \u2200 n,\n  short_exact (kernel.\u03b9 $ (free_Cech F).d (n+1+1) (n+1)) (delta_to_kernel _ (n+1+1) (n+1) n) :=\nbegin\n  erw \u2190 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 : \u2124) (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 : \u2124) : Prop := \u2200 S, \u2200 i > 0, i \u2264 n \u2192 is_zero (HH i S M)\n\n/-- Consider the following commutative diagram\n```\n     O\u2080\n     \u2193\nA\u2081 \u2192 B\u2081 \u2192 C\u2081 \u2192 O\u2081\n   \u2198 \u2193\n     B\u2082\n     \u2193  \u2198\nO\u2083 \u2192 B\u2083 \u2192 C\u2083\n```\nwhere `O\u2080`, `O\u2081`, and `O\u2083` are zero objects, and all sequence are exact.\n\nThen `C\u2081` is also a zero object.\n-/\nlemma acyclic_of_exact.induction_step_aux {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {O\u2080 O\u2081 O\u2083 A\u2081 B\u2081 C\u2081 B\u2082 B\u2083 C\u2083 : \ud835\udcd0}\n  {\u03b1\u2081 : A\u2081 \u27f6 B\u2081} {\u03b2\u2081 : B\u2081 \u27f6 C\u2081} {\u03b3\u2081 : C\u2081 \u27f6 O\u2081} (ex\u2081 : exact_seq \ud835\udcd0 [\u03b1\u2081, \u03b2\u2081, \u03b3\u2081])\n  {d\u2081 : A\u2081 \u27f6 B\u2082} {d\u2082 : B\u2082 \u27f6 C\u2083}                 (exd : exact d\u2081 d\u2082)\n  {b\u2080 : O\u2080 \u27f6 B\u2081} {b\u2081 : B\u2081 \u27f6 B\u2082} {b\u2082 : B\u2082 \u27f6 B\u2083} (exb : exact_seq \ud835\udcd0 [b\u2080, b\u2081, b\u2082])\n  {\u03b1\u2083 : O\u2083 \u27f6 B\u2083} {\u03b2\u2083 : B\u2083 \u27f6 C\u2083}                 (ex\u2083 : exact \u03b1\u2083 \u03b2\u2083)\n  (hO\u2080 : is_zero O\u2080) (hO\u2081 : is_zero O\u2081) (hO\u2083 : is_zero O\u2083)\n  (tr\u2081 : \u03b1\u2081 \u226b b\u2081 = d\u2081) (tr\u2082 : b\u2082 \u226b \u03b2\u2083 = d\u2082) :\n  is_zero C\u2081 :=\nbegin\n  refine (ex\u2081.drop 1).pair.is_zero_of_eq_zero_eq_zero\n    (ex\u2081.pair.eq_zero_of_epi _) (hO\u2081.eq_of_tgt _ _),\n  haveI : mono b\u2081 := exb.pair.mono_of_eq_zero (hO\u2080.eq_of_src _ _),\n  haveI : mono \u03b2\u2083 := ex\u2083.mono_of_eq_zero (hO\u2083.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' \u03b2\u2083 tr\u2082.symm,\n  obtain rfl :\n    \u03b1\u2081 = kernel.lift _ _ exd.w \u226b (is_limit.cone_point_unique_up_to_iso (limit.is_limit _) l).hom,\n  { erw [\u2190 cancel_mono b\u2081, category.assoc,\n      is_limit.cone_point_unique_up_to_iso_hom_comp _ _ walking_parallel_pair.zero, is_limit.fac,\n      fork.of_\u03b9_\u03c0_app, tr\u2081] },\n  apply epi_comp\nend\n\nlemma acyclic_of_exact.induction_step_ex\u2081\n  (F : arrow Profinite.{u})\n  (h : \u2200 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\u1d52\u1d56 Ab).obj\n    ((Profinite_to_Condensed \u22d9 CondensedSet_to_Condensed_Ab).op \u22d9 preadditive_yoneda.obj M)).obj\n    F.augmented_cech_nerve.right_op).to_cocomplex\n  in \u2200 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\u2082\n  (F : arrow Profinite.{u})\n  (h : let C := (((cosimplicial_object.augmented.whiskering Profinite\u1d52\u1d56 Ab).obj\n    ((Profinite_to_Condensed \u22d9 CondensedSet_to_Condensed_Ab).op \u22d9 preadditive_yoneda.obj M)).obj\n    F.augmented_cech_nerve.right_op).to_cocomplex\n    in \u2200 i, is_zero (C.homology i)) :\n  \u2200 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\u2082_aux,\nend\n\nlemma int.of_nat_add_one (i : \u2115) : 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 : \u2115) :\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  {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0]\n  (C : cochain_complex \ud835\udcd0 \u2115) (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 \u226a\u226b limits.cokernel_zero_iso_target,\n  simp_rw [C.d_from_eq (show (complex_shape.up \u2115).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 \u226a\u226b (kernel_comp_mono _ _)).symm) _ _)\nend\n\nlemma acyclic_of_exact.induction_step_ex\u2083\n  (F : arrow Profinite.{u}) (i : \u2124)\n  (h : \u2200 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 [\u2190 functor.map_comp, \u2190 op_comp, homological_complex.d_comp_d, op_zero, functor.map_zero] },\n    clear h,\n    refine _ \u226a\u226b (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, \u2190 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\u2084\n  (F : arrow Profinite.{u}) (i : \u2124)\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 : \u2200 i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n      F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n  (i : \u2124) :\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\u2084,\n  apply acyclic_of_exact.induction_step_ex\u2083,\n  apply acyclic_of_exact.induction_step_ex\u2082,\n  apply acyclic_of_exact.induction_step_ex\u2081 _ F h,\nend\n\nlemma acyclic_of_exact.induction_step\n  (h : \u2200 (F : arrow Profinite.{u}) (surj : function.surjective F.hom),\n    \u2200 i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n      F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n  (n : \u2124) (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 \u2190 Profinite.epi_iff_surjective, apply projective_presentation.epi },\n  let E := \u03bb i, (Ext' i).flip.obj M,\n  have ih' : \u2200 (i j : \u2124) (h0i : 0 < i) (hin : i \u2264 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 := \u03bb i, kernel ((free_Cech F).d (i + 1) i),\n  have LES := \u03bb i j, (free_Cech_kernel_SES F hF i).Ext'_five_term_exact_seq M j,\n  have H1 : \u2200 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 : \u2200 (i : \u2124) (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 : \u2200 (i j : \u2124) (h0i : 0 < i+1) (hi : i+1 \u2264 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 : \u2200 i j, 0 < i \u2192 -1 \u2264 j \u2192 i + j = n \u2192 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.\u03b9 _) _).op, refine is_zero_zero _, },\n    { refine this (n+1) (-1) h1 le_rfl _, rw [\u2190 sub_eq_add_neg, add_sub_cancel] } },\n  obtain \u27e8n, rfl\u27e9 : \u2203 k, k+1 = n := \u27e8n-1, sub_add_cancel _ _\u27e9,\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:\u2124), 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 := \u03bb 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 \u2228 1 \u2264 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 [\u2190 delta_to_kernel_\u03b9 _ _ _ (n+1), op_comp, functor.map_comp] }, refl },\n  { conv_rhs { rw [\u2190 delta_to_kernel_\u03b9 _ _ _ (n+1+1), op_comp, functor.map_comp] }, refl },\nend\n\nlemma acyclic_of_exact\n  (h : \u2200 (F : arrow Profinite.{u}) (surj : function.surjective F.hom),\n    \u2200 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  \u2200 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 {\u03b1 : Type u_1} [uniform_space \u03b1] [separated_space \u03b1] {s : set \u03b1}\n    (h : is_complete s) : is_closed s :=\n  sorry\n\nnamespace dense_inducing\n\n\ntheorem continuous_extend_of_cauchy {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b2 : Type u_2}\n    [topological_space \u03b2] {\u03b3 : Type u_3} [uniform_space \u03b3] [complete_space \u03b3] [separated_space \u03b3]\n    {e : \u03b1 \u2192 \u03b2} {f : \u03b1 \u2192 \u03b3} (de : dense_inducing e)\n    (h : \u2200 (b : \u03b2), cauchy (filter.map f (filter.comap e (nhds b)))) : continuous (extend de f) :=\n  continuous_extend de fun (b : \u03b2) => 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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) \u2208 s)\n(add_mem {a b} : a \u2208 s \u2192 b \u2208 s \u2192 a + b \u2208 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) \u2208 s)\n(mul_mem {a b} : a \u2208 s \u2192 b \u2208 s \u2192 a * b \u2208 s)\n\nlemma additive.is_add_submonoid\n  {s : set M} : \u2200 (is : is_submonoid s), @is_add_submonoid (additive M) _ s\n| \u27e8h\u2081, h\u2082\u27e9 := \u27e8h\u2081, @h\u2082\u27e9\n\ntheorem additive.is_add_submonoid_iff\n  {s : set M} : @is_add_submonoid (additive M) _ s \u2194 is_submonoid s :=\n\u27e8\u03bb \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081, @h\u2082\u27e9, additive.is_add_submonoid\u27e9\n\nlemma multiplicative.is_submonoid\n  {s : set A} : \u2200 (is : is_add_submonoid s), @is_submonoid (multiplicative A) _ s\n| \u27e8h\u2081, h\u2082\u27e9 := \u27e8h\u2081, @h\u2082\u27e9\n\ntheorem multiplicative.is_submonoid_iff\n  {s : set A} : @is_submonoid (multiplicative A) _ s \u2194 is_add_submonoid s :=\n\u27e8\u03bb \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081, @h\u2082\u27e9, multiplicative.is_submonoid\u27e9\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\u2081 s\u2082 : set M} (is\u2081 : is_submonoid s\u2081) (is\u2082 : is_submonoid s\u2082) :\n  is_submonoid (s\u2081 \u2229 s\u2082) :=\n{ one_mem := \u27e8is\u2081.one_mem, is\u2082.one_mem\u27e9,\n  mul_mem := \u03bb x y hx hy,\n    \u27e8is\u2081.mul_mem hx.1 hy.1, is\u2082.mul_mem hx.2 hy.2\u27e9 }\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 {\u03b9 : Sort*} {s : \u03b9 \u2192 set M} (h : \u2200 y : \u03b9, is_submonoid (s y)) :\n  is_submonoid (set.Inter s) :=\n{ one_mem := set.mem_Inter.2 $ \u03bb y, (h y).one_mem,\n  mul_mem := \u03bb x\u2081 x\u2082 h\u2081 h\u2082, set.mem_Inter.2 $\n    \u03bb y, (h y).mul_mem (set.mem_Inter.1 h\u2081 y) (set.mem_Inter.1 h\u2082 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 {\u03b9 : Type*} [h\u03b9 : nonempty \u03b9]\n  {s : \u03b9 \u2192 set M} (hs : \u2200 i, is_submonoid (s i))\n  (directed : \u2200 i j, \u2203 k, s i \u2286 s k \u2227 s j \u2286 s k) :\n  is_submonoid (\u22c3i, s i) :=\n{ one_mem := let \u27e8i\u27e9 := h\u03b9 in set.mem_Union.2 \u27e8i, (hs i).one_mem\u27e9,\n  mul_mem := \u03bb a b ha hb,\n    let \u27e8i, hi\u27e9 := set.mem_Union.1 ha in\n    let \u27e8j, hj\u27e9 := set.mem_Union.1 hb in\n    let \u27e8k, hk\u27e9 := directed i j in\n    set.mem_Union.2 \u27e8k, (hs k).mul_mem (hk.1 hi) (hk.2 hj)\u27e9 }\n\nsection powers\n\n/-- The set of natural number powers `1, x, x\u00b2, ...` 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 | \u2203 n:\u2115, 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) \u2208 powers x := \u27e80, pow_zero _\u27e9\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 \u2208 powers x := \u27e81, pow_one _\u27e9\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 \u2208 powers x) \u2192 (z \u2208 powers x) \u2192 (y * z \u2208 powers x) :=\n\u03bb \u27e8n\u2081, h\u2081\u27e9 \u27e8n\u2082, h\u2082\u27e9, \u27e8n\u2081 + n\u2082, by simp only [pow_add, *]\u27e9\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 := \u03bb 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 \u2192 N} (hf : is_monoid_hom f)\n  {s : set N} (hs : is_submonoid s) : is_submonoid (f \u207b\u00b9' s) :=\n{ one_mem := show f 1 \u2208 s, by rw is_monoid_hom.map_one hf; exact hs.one_mem,\n  mul_mem := \u03bb a b (ha : f a \u2208 s) (hb : f b \u2208 s),\n    show f (a * b) \u2208 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 {\u03b3 : Type*} [monoid \u03b3] {f : M \u2192 \u03b3} (hf : is_monoid_hom f)\n  {s : set M} (hs : is_submonoid s) : is_submonoid (f '' s) :=\n{ one_mem := \u27e81, hs.one_mem, hf.map_one\u27e9,\n  mul_mem := \u03bb a b \u27e8x, hx\u27e9 \u27e8y, hy\u27e9, \u27e8x * y, hs.mul_mem hx.1 hy.1,\n    by rw [hf.map_mul, hx.2, hy.2]\u27e9 }\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 {\u03b3 : Type*} [monoid \u03b3] {f : M \u2192 \u03b3} (hf : is_monoid_hom f) :\n  is_submonoid (set.range f) :=\nby { rw \u2190 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 \u2208 s) : \u2200 {n : \u2115}, a ^ n \u2208 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 \u2208 s) : powers a \u2286 s :=\nassume x \u27e8n, hx\u27e9, hx \u25b8 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) : \u2200{l : list M}, (\u2200x\u2208l, x \u2208 s) \u2192 l.prod \u2208 s\n| []     h := hs.one_mem\n| (a::l) h :=\n  suffices a * l.prod \u2208 s, by simpa,\n  have a \u2208 s \u2227 (\u2200x\u2208l, x \u2208 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  (\u2200a\u2208m, a \u2208 s) \u2192 m.prod \u2208 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 \u2192 M) :\n  \u2200(t : finset A), (\u2200b\u2208t, f b \u2208 s) \u2192 \u220f b in t, f b \u2208 s\n| \u27e8m, hm\u27e9 _ := 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 \u2192 Prop\n| basic {a : A} : a \u2208 s \u2192 in_closure a\n| zero : in_closure 0\n| add {a b : A} : in_closure a \u2192 in_closure b \u2192 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 \u2192 Prop\n| basic {a : M} : a \u2208 s \u2192 in_closure a\n| one : in_closure 1\n| mul {a b : M} : in_closure a \u2192 in_closure b \u2192 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 \u2286 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 \u2286 t) : closure s \u2286 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 \u2286 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 \u2286 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 \u2286 t) : closure s \u2286 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 \u2192 A} (hf : is_monoid_hom f) (s : set M) :\n  f '' closure s = closure (f '' s) :=\nle_antisymm\n  begin\n    rintros _ \u27e8x, hx, rfl\u27e9,\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 \u2208 closure s) :\n  (\u2203l:list M, (\u2200x\u2208l, x \u2208 s) \u2227 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 \u27e8la, ha, eqa\u27e9,\n    rcases hb with \u27e8lb, hb, eqb\u27e9,\n    existsi (la ++ lb),\n    simp [eqa.symm, eqb.symm, or_imp_distrib],\n    exact assume a, \u27e8ha a, hb a\u27e9 }\nend\n\n/-- Given sets `s, t` of a commutative monoid `M`, `x \u2208 M` is in the submonoid of `M` generated by\n    `s \u222a 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 \u2208 M` is in the `add_submonoid`\nof `M` generated by `s \u222a 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 \u2208 closure (s \u222a t) \u2194 \u2203 y \u2208 closure s, \u2203 z \u2208 closure t, y * z = x :=\n\u27e8\u03bb hx, let \u27e8L, HL1, HL2\u27e9 := exists_list_of_mem_closure hx in HL2 \u25b8\n  list.rec_on L (\u03bb _, \u27e81, (closure.is_submonoid _).one_mem, 1,\n    (closure.is_submonoid _).one_mem, mul_one _\u27e9)\n    (\u03bb hd tl ih HL1, let \u27e8y, hy, z, hz, hyzx\u27e9 := ih (list.forall_mem_of_forall_mem_cons HL1) in\n      or.cases_on (HL1 hd $ list.mem_cons_self _ _)\n        (\u03bb hs, \u27e8hd * y, (closure.is_submonoid _).mul_mem (subset_closure hs) hy, z, hz,\n          by rw [mul_assoc, list.prod_cons, \u2190 hyzx]; refl\u27e9)\n        (\u03bb ht, \u27e8y, hy, z * hd, (closure.is_submonoid _).mul_mem hz (subset_closure ht),\n          by rw [\u2190 mul_assoc, list.prod_cons, \u2190 hyzx, mul_comm hd]; refl\u27e9)) HL1,\n\u03bb \u27e8y, hy, z, hz, hyzx\u27e9, hyzx \u25b8 (closure.is_submonoid _).mul_mem\n  (closure_mono (set.subset_union_left _ _) hy)\n  (closure_mono (set.subset_union_right _ _) hz)\u27e9\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 := \u27e8s, h.2, h.1\u27e9\n\n@[to_additive]\nlemma submonoid.is_submonoid (S : submonoid M) : is_submonoid (S : set M) := \u27e8S.3, S.2\u27e9\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\u1d52\u1d56 \u2964 Type (max v u)) \u2964 SheafOfTypes J :=\n{ obj := \u03bb P,\n  { val := J.sheafify P,\n    cond := begin\n      rw \u2190 is_sheaf_iff_is_sheaf_of_type,\n      exact grothendieck_topology.plus.is_sheaf_plus_plus J P,\n    end },\n  map := \u03bb P Q \u03b7, \u27e8J.sheafify_map \u03b7\u27e9,\n  map_id' := \u03bb P, SheafOfTypes.hom.ext _ _ $ J.sheafify_map_id _,\n  map_comp' := \u03bb P Q R \u03b7 \u03b3, SheafOfTypes.hom.ext _ _ $ J.sheafify_map_comp _ _ }\n\n-- Sanity check\ndef presheaf_to_SheafOfTypes_iso : presheaf_to_SheafOfTypes J \u2245\n  presheaf_to_Sheaf J _ \u22d9 (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) \u22a3 SheafOfTypes_to_presheaf J :=\nshow presheaf_to_Sheaf J _ \u22d9 (Sheaf_equiv_SheafOfTypes J).functor \u22a3\n  (Sheaf_equiv_SheafOfTypes J).inverse \u22d9 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\u1d52\u1d56 \u2964 Type (max v u))\n  (Y : SheafOfTypes J) (e : (presheaf_to_SheafOfTypes _).obj X \u27f6 Y) :\n  (sheafification_adjunction_types J).hom_equiv _ _ e =\n  J.to_sheafify _ \u226b e.val := rfl\n\n@[simp]\nlemma sheafification_adjunction_types_hom_equiv_symm_apply (X : C\u1d52\u1d56 \u2964 Type (max v u))\n  (Y : SheafOfTypes J) (e : X \u27f6 (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\u1d52\u1d56 \u2964 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 (\ud835\udfd9 _) (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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v1) \u2260 ((((a1).write i3 (v1)).write i1 (v1)).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test31.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 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 \u2286 as.supboxes)\n(sup_avail : as.supboxes \u2286 avail)\n(sub_disj : as.subboxes.disjoint as.sk_comp)\n(sk_comp_avail : as.sk_comp \u2286 avail)\n(sk_comp_closed : \u2200 xy \u2208 as.sk_comp, \u2200 d : direction,\n  d.shift xy \u2208 avail \u2192\n  (d.shift xy \u2208 as.sk_comp \u2228 d.shift xy \u2208 as.subboxes))\n\ndef boxint.mem (s : sokostate) (as : boxint)\n  := s.storekeeper \u2208 as.sk_comp \u2227\n     as.subboxes \u2286 s.boxes \u2227 s.boxes \u2286 as.supboxes\ninstance : has_mem sokostate boxint\n:= \u27e8boxint.mem\u27e9\nlemma boxint.mem.unfold\n  {s : sokostate} {as : boxint}\n  : s \u2208 as = (s.storekeeper \u2208 as.sk_comp \u2227\n     as.subboxes \u2286 s.boxes \u2227 s.boxes \u2286 as.supboxes)\n:= rfl\ninstance boxint.mem.decidable\n  (s : sokostate) (as : boxint) : decidable (s \u2208 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  := \u00ac (as1.subboxes \u2286 as2.boxes \u2227 as2.boxes \u2286 as1.supboxes)\nlemma boxint.disjoint_correct\n  (as : boxint) (bs : boxes_only)\n  (s : sokostate)\n  : as.disjoint bs \u2192 s \u2208 as \u2192 s \u2208 bs \u2192 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 \u2286 as2.sk_comp \u2227 as2.subboxes \u2286 as1.subboxes\n  \u2227 as1.supboxes \u2286 as2.supboxes\ninstance : has_subset boxint := \u27e8boxint.subset\u27e9\n\nlemma boxint.subset_correct (as1 as2 : boxint)\n  : as1 \u2286 as2 \u2192 \u2200 s : sokostate, s \u2208 as1 \u2192 s \u2208 as2 :=\nbegin\n  intros H12 s H1,\n  rcases H12 with \u27e8H12sk,H12sub,H12sup\u27e9,\n  rcases H1 with \u27e8H1sk,H1sub,H1sup\u27e9,\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 \u2286 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 \u2286 as2.sk_comp \u2227 as2.subboxes \u2286 as1.subboxes\n  \u2227 ( as1.supboxes \u2286 as2.supboxes \u2228\n    goal.boxes.count \u2264 as1.subboxes.count \u2227 as1.subboxes \u2286 as2.supboxes )\nlemma boxint.subset_g_correct {avail : bset2d} {as1 as2 : boxint} {goal : boxes_only}\n: as1.subset_g as2 goal \u2192 \u2200 s sg : sokostate,\ns \u2208 as1 \u2192 sg \u2208 goal \u2192 sg.reachable avail s \u2192 s \u2208 as2\n:=\nbegin\n  intros H12 s sg H1 Hg Hr,\n  rcases H12 with \u27e8H12sk, H12sub, H12sup_cnt\u27e9,\n  rcases H1 with \u27e8H1sk,H1sub, H1sup\u27e9,\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 \u2264 s.boxes.count := bset2d.count_le_of_subset _ _ H1sub,\n    have : sg.boxes.count \u2264 goal.boxes.count := bset2d.count_le_of_subset _ _ Hg.1,\n    have : as1.subboxes.count = s.boxes.count, by omega,\n    have : s.boxes \u2286 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 : \u2115 \u00d7 \u2115) : 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 : \u2115 \u00d7 \u2115}\n  : subboxes \u2286 supboxes \u2192 supboxes \u2286 avail \u2192\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 \u2208 subboxes,\n    { right, exact C, }, left,\n    have Ha2 : d.shift xy \u2208 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 \u00d7 (\u2115 \u00d7 \u2115))\n  := do\n  box \u2190 s.subboxes.to_indexes,\n  d \u2190 direction.luniv,\n  if d.shift box \u2208 avail \u2227 d.shift box \u2209 s.subboxes\n    \u2227 d.opposite.shift box \u2208 s.sk_comp\n  then return (d, box)\n  else list.nil\n\ndef boxint.get_appearances (avail : bset2d) (s : boxint)\n  : list (direction \u00d7 (\u2115 \u00d7 \u2115))\n  := do\n  box \u2190 (avail \\ s.supboxes).to_indexes,\n  d \u2190 direction.luniv,\n  if d.shift box \u2208 s.supboxes \u2227 d.shift box \u2209 s.subboxes\n    \u2227 d.shift (d.shift box) \u2208 s.sk_comp\n    \u2227 d.shift (d.shift box) \u2260 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 \u00d7 (\u2115 \u00d7 \u2115))\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  : \u2200 (d : direction) (box : \u2115\u00d7\u2115),\n  (d,box) \u2208 boxint.get_moves avail s \u2194 (\n    d.opposite.shift box \u2208 s.sk_comp \u2227\n    d.opposite.shift box \u2260 box \u2227\n    d.shift box \u2208 avail \u2227 d.shift box \u2209 s.subboxes \u2227\n    box \u2208 s.supboxes \u2227 (d.shift box \u2208 s.supboxes \u2192 box \u2208 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 \u27e8box,Hbox,d,Huniv,H\u27e9, clear Huniv,\n      have Hbox := (bset2d.to_indexes_iff _ _).mp Hbox,\n      by_cases C : d.shift box \u2208 avail \u2227 d.shift box \u2209 s.subboxes\n          \u2227 d.opposite.shift box \u2208 s.sk_comp, {\n        simp [C] at H, rw [H.1, H.2], clear H,\n        rcases C with \u27e8Ha2, Hnb2, Hsk\u27e9,\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 \u27e8box,Hbox,d,Huniv,H\u27e9, clear Huniv,\n      have Hbox := (bset2d.to_indexes_iff _ box).mp Hbox,\n      have Hba: box \u2208 avail, from bset2d.mem_of_mem_sdiff Hbox,\n      have Hbnsup: box \u2209 s.supboxes, from bset2d.nmem_of_mem_sdiff Hbox,\n      by_cases C : d.shift box \u2208 s.supboxes \u2227 d.shift box \u2209 s.subboxes\n          \u2227 d.shift (d.shift box) \u2208 s.sk_comp \u2227 d.shift (d.shift box) \u2260 d.shift box, {\n        simp [C] at H, rw [H.1, H.2], clear H,\n        rcases C with \u27e8Hsup2, Hfree, Hcomp, Hnngen\u27e9,\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 \u27e8Hcomp, Hnngen, Hav, Hfree, Hsup, H\u27e9,\n    by_cases C : box \u2208 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 \u2208 (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 : \u2115\u00d7\u2115)\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 \u2192\n  \u2200 as2 : boxint, as2 \u2208 as1.next_states avail \u2192 as2.valid avail\n:=\nbegin\n  introv Hv H, simp [boxint.next_states, -prod.exists] at H,\n  rcases H with \u27e8\u27e8d, box\u27e9, H, Heq\u27e9,\n  simp at Heq, rw \u2190Heq, clear Heq as2,\n  rw (boxint.in_get_moves_iff avail as1 Hv) at H,\n  rcases H with \u27e8Hcomp, Hnng, Hav, Hnb, Hsp, Hextra\u27e9,\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 \u2192\n  \u2200 (s : sokostate) (d : direction), s \u2208 as1 \u2192 s.move avail d \u2208 as1 \u2228\n  (\u2203 as2 : boxint, as2 \u2208 as1.next_states avail \u2227 s.move avail d \u2208 as2)\n:=\nbegin\n  intros Hv s d Hin,\n  have := Hin,\n  rcases this with \u27e8Hsk,Hsub,Hsup\u27e9,\n  let box := d.shift s.storekeeper,\n  let box2 := d.shift box,\n  by_cases C : box \u2208 s.boxes \u2227 box2 \u2208 avail \u2227 box2 \u2209 s.boxes\n    \u2227 (box \u2208 as1.subboxes \u2228 box2 \u2209 as1.supboxes), {\n\n    right, -- we move to another abstract state\n\n    existsi as1.move avail d box,\n    rcases C with \u27e8Hbb, Hb2a, Hb2nb, Has\u27e9,\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 \u2260 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 \u2208 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 \u2208 avail, {\n    simp [Cba], by_cases Cbb : box \u2208 s.boxes, {\n      simp [Cbb], by_cases Cb2a : box2 \u2208 avail, {\n        simp [Cb2a], by_cases Cb2b : box2 \u2208 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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v1) \u2260 ((((a1).write i1 (v1)).write i3 (v1)).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test10.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.4532618480153861, "lm_q1q2_score": 0.2284014420803673}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v1) \u2260 ((((a1).write i2 (v1)).write i3 (v1)).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test13.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.4493926344647597, "lm_q1q2_score": 0.22820691150089267}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v3) \u2260 ((((a3).write i3 (v3)).write i2 (v3)).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test23.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.22820691150089265}}
{"text": "import model_theory.substructures\nimport model_theory.bundled\n\n\n--OUTPUT 1\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M := sorry\n\nend\n\n--OUTPUT 2\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let \u03c6 : set L.Formula,\n  let \u03c6 := F.sentences,\n\n  let \u03c61 : set L.Formula,\n  let \u03c61 := (\u03bb x : L.Formula, \u2203 (a b : x.carrier), a \u2260 b),\n\n  let \u03c62 : set L.Formula,\n  let \u03c62 := (\u03bb x : L.Formula, \u2203 (a b c : x.carrier), a \u2260 b \u2227 b \u2260 c \u2227 a \u2260 c),\n\n  let \u03c63 : set L.Formula,\n  let \u03c63 := (\u03bb x : L.Formula, \u2203 (a b c d : x.carrier), a \u2260 b \u2227 b \u2260 c \u2227 c \u2260 d \u2227 a \u2260 c \u2227 a \u2260 d \u2227 b \u2260 d),\n\n  let \u03c64 : set L.Formula,\n  let \u03c64 := (\u03bb x : L.Formula, \u2203 (a b c d e : x.carrier), a \u2260 b \u2227 b \u2260 c \u2227 c \u2260 d \u2227 d \u2260 e \u2227 a \u2260 c \u2227 a \u2260 d \u2227 a \u2260 e \u2227 b \u2260 d \u2227 b \u2260 e \u2227 c \u2260 e),\n\n  let \u03c65 : set L.Formula,\n  let \u03c65 := (\u03bb x : L.Formula, \u2203 (a b c d e f : x.carrier), a \u2260 b \u2227 b \u2260 c \u2227 c \u2260 d \u2227 d \u2260 e \u2227 e \u2260 f \u2227 a \u2260 c \u2227 a \u2260 d \u2227 a \u2260 e \u2227 a \u2260 f \u2227 b \u2260 d \u2227 b \u2260 e \u2227 b \u2260 f \u2227 c \u2260 e \u2227 c \u2260 f \u2227 d \u2260 f),\n\n  let \u03c66 : set L.Formula,\n  let \u03c66 := (\u03bb x : L.Formula, \u2203 (a b c d e f g : x.carrier), a \u2260 b \u2227 b \u2260 c \u2227 c \u2260 d \u2227 d \u2260 e \u2227 e \u2260 f \u2227 f \u2260 g \u2227 a \u2260 c \u2227 a \u2260 d \u2227 a \u2260 e \u2227 a \u2260 f \u2227 a \u2260 g \u2227 b \u2260 d \u2227 b \u2260 e \u2227 b \u2260 f \u2227 b \u2260 g \u2227 c \u2260 e \u2227 c \u2260 f \u2227 c \u2260 g \u2227 d \u2260 f \u2227 d \u2260 g \u2227 e \u2260 g),\n\n  let \u03c67 : set L.Formula,\n  let \u03c67 := (\u03bb x : L.Formula, \u2203 (a b c d e f g h : x.carrier), a \u2260 b \u2227 b \u2260 c \u2227 c \u2260 d \u2227 d \u2260 e \u2227 e \u2260 f \u2227 f \u2260 g \u2227 g \u2260 h \u2227 a \u2260 c \u2227 a \u2260 d \u2227 a \u2260 e \u2227 a \u2260 f \u2227 a \u2260 g \u2227 a \u2260 h \u2227 b \u2260 d \u2227 b \u2260 e \u2227 b \u2260 f \u2227 b \u2260 g \u2227 b \u2260 h \u2227 c \u2260 e \u2227 c \u2260 f \u2227 c \u2260 g \u2227 c \u2260 h \u2227 d \u2260 f \u2227 d \u2260 g \u2227 d \u2260 h \u2227 e \u2260 g \u2227 e \u2260 h \u2227 f \u2260 h),\n\n  let \u03c68 : set L.Formula,\n  let \u03c68 := (\u03bb x : L.Formula, \u2203 (a b c d e f g h i : x.carrier), a \u2260 b \u2227 b \u2260 c \u2227 c \u2260 d \u2227 d \u2260 e \u2227 e \u2260 f \u2227 f \u2260 g \u2227 g \u2260 h \u2227 h \u2260 i \u2227 a \u2260 c \u2227 a \u2260 d \u2227 a \u2260 e \u2227 a \u2260 f \u2227 a \u2260 g \u2227 a \u2260 h \u2227 a \u2260 i \u2227 b \u2260 d \u2227 b \u2260 e \u2227 b \u2260 f \u2227 b \u2260 g \u2227 b \u2260 h \u2227 b \u2260 i \u2227 c \u2260 e \u2227 c \u2260 f \u2227 c \u2260 g \u2227 c \u2260 h \u2227 c \u2260 i \u2227 d \u2260 f \u2227 d \u2260 g \u2227 d \u2260 h \u2227 d \u2260 i \u2227 e \u2260 g \u2227 e \u2260 h \u2227 e \u2260 i \u2227 f \u2260 h \u2227 f \u2260 i \u2227 g \u2260 i),\n\n  let \u03c69 : set L.Formula,\n  let \u03c69 := (\u03bb x : L.Formula, \u2203 (a b c d e f g h i j : x.carrier), a \u2260 b \u2227 b \u2260 c \u2227 c \u2260 d \u2227 d \u2260 e \u2227 e \u2260 f \u2227 f \u2260 g \u2227 g \u2260 h \u2227 h \u2260 i \u2227 i \u2260 j \u2227 a \u2260 c \u2227 a \u2260 d \u2227 a \u2260 e \u2227 a \u2260 f \u2227 a \u2260 g \u2227 a \u2260 h \u2227 a \u2260 i \u2227 a \u2260 j \u2227 b \u2260 d \u2227 b \u2260 e \u2227 b \u2260 f \u2227 b \u2260 g \u2227 b \u2260 h \u2227 b \u2260 i \u2227 b \u2260 j \u2227 c \u2260 e \u2227 c \u2260 f \u2227 c \u2260 g \u2227 c \u2260 h \u2227 c \u2260 i \u2227 c \u2260 j \u2227 d \u2260 f \u2227 d \u2260 g \u2227 d \u2260 h \u2227 d \u2260 i \u2227 d \u2260 j \u2227 e \u2260 g \u2227 e \u2260 h \u2227 e \u2260 i \u2227 e \u2260 j \u2227 f \u2260 h \u2227 f \u2260 i \u2227 f \u2260 j \u2227 g \u2260 i \u2227 g \u2260 j \u2227 h \u2260 j),\n\n  let \u03c610 : set L.Formula,\n  let \u03c610 := (\u03bb x : L.Formula, \u2203 (a b c d e f g h i j k : x.carrier), a \u2260 b \u2227 b \u2260 c \u2227 c \u2260 d \u2227 d \u2260 e \u2227 e \u2260 f \u2227 f \u2260 g \u2227 g \u2260 h \u2227 h \u2260 i \u2227 i \u2260 j \u2227 j \u2260 k \u2227 a \u2260 c \u2227 a \u2260 d \u2227 a \u2260 e \u2227 a \u2260 f \u2227 a \u2260 g \u2227 a \u2260 h \u2227 a \u2260 i \u2227 a \u2260 j \u2227 a \u2260 k \u2227 b \u2260 d \u2227 b \u2260 e \u2227 b \u2260 f \u2227 b \u2260 g \u2227 b \u2260 h \u2227 b \u2260 i \u2227 b \u2260 j \u2227 b \u2260 k \u2227 c \u2260 e \u2227 c \u2260 f \u2227 c \u2260 g \u2227 c \u2260 h \u2227 c \u2260 i \u2227 c \u2260 j \u2227 c \u2260 k \u2227 d \u2260 f \u2227 d \u2260 g \u2227 d \u2260 h \u2227 d \u2260 i \u2227 d \u2260 j \u2227 d \u2260 k \u2227 e \u2260 g \u2227 e \u2260 h \u2227 e \u2260 i \u2227 e \u2260 j \u2227 e \u2260 k \u2227 f \u2260 h \u2227 f \u2260 i \u2227 f \u2260 j \u2227 f \u2260 k \u2227 g \u2260 i \u2227 g \u2260 j \u2227 g \u2260 k \u2227 h \u2260 j \u2227 h \u2260 k \u2227 i \u2260 k),\n\n  let \u03c8 : set L.Formula,\n  let \u03c8 := (\u03c6 \u222a \u03c61 \u222a \u03c62 \u222a \u03c63 \u222a \u03c64 \u222a \u03c65 \u222a \u03c66 \u222a \u03c67 \u222a \u03c68 \u222a \u03c69 \u222a \u03c610),\n\n  have h1 : \u2200 \u0393 : set L.Formula, finite \u0393 \u2192 \u2203 m : F.Model, \u0393 \u2286 m.sentences, from by auto [F.sentences_finite_model],\n\n  have h2 : \u2200\ud835\udd39 \u0393 : set L.Formula, finite \u0393 \u2192 \u2203 m : F.Model, \u0393 \u2286 m.sentences \u2227 finite m.carrier \u2227 \ud835\udd39.size \u2264 m.size, from by intros \ud835\udd39 \u0393 h\u0393,\n  let h3 : \u2200\ud835\udd39 \u0393 : set L.Formula,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  have h1 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from h,\n  have h2 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from h,\n  have h3 : \u2203 (m : F.Model) [mfin : fintype m], 1 \u2264 @fintype.card m mfin, from h,\n  have h4 : \u2203 (m : F.Model) [mfin : fintype m], 2 \u2264 @fintype.card m mfin, from h,\n  have h5 : \u2203 (m : F.Model) [mfin : fintype m], 3 \u2264 @fintype.card m mfin, from h,\n  have h6 : \u2203 (m : F.Model) [mfin : fintype m], 4 \u2264 @fintype.card m mfin, from h,\n  have h7 : \u2203 (m : F.Model) [mfin : fintype m], 5 \u2264 @fintype.card m mfin, from h,\n  have h8 : \u2203 (m : F.Model) [mfin : fintype m], 6 \u2264 @fintype.card m mfin, from h,\n  have h9 : \u2203 (m : F.Model) [mfin : fintype m], 7 \u2264 @fintype.card m mfin, from h,\n  have h10 : \u2203 (m : F.Model) [mfin : fintype m], 8 \u2264 @fintype.card m mfin, from h,\n\n  have h11 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from h,\n  have h12 : \u2203 (m : F.Model) [mfin : fintype m], 1 \u2264 @fintype.card m mfin, from h3,\n  have h13 : \u2203 (m : F.Model) [mfin : fintype m], 2 \u2264 @fintype.card m mfin, from h4,\n  have h14 : \u2203 (m : F.Model) [mfin : fintype m], 3 \u2264 @fintype.card m mfin, from h5,\n  have h15 : \u2203 (m : F.Model) [mfin : fintype m], 4 \u2264 @fintype.card m mfin, from h6,\n  have h16 : \u2203 (m : F.Model) [mfin : fintype m], 5 \u2264 @fintype.card m mfin, from h7,\n  have h17 : \u2203 (m : F.Model) [mfin : fintype m], 6 \u2264 @fintype.card m mfin, from h8,\n  have h18 : \u2203 (m : F.Model) [mfin : fintype m], 7 \u2264 @fintype.card m mfin, from h9,\n  have h19 : \u2203 (m : F.Model) [mfin : fintype m], 8 \u2264 @fintype.card m mfin, from h10,\n  have h20 : \u2203 (m : F.Model) [mfin : fintype m], 9 \u2264 @fintype.card m mfin, from h,\n\n  show \u2203 (M : F.Model), infinite M, from sorry\nend\n\n--OUTPUT 4\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (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 : \u2115),\n  let F' := F'.add_binop_of_types (<) (2 : \u2115),\n  let F' := F'.add_binop_of_types (-) (2 : \u2115),\n  let F' := F'.add_binop_of_types (*) (2 : \u2115),\n  let F' := F'.add_binop_of_types (^) (2 : \u2115),\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 (\u2115) := \u2203 \u2191x \u2203 \u2191y \u2203 \u2191z, \u2200 \u2191f \u2200 \u2191g \u2200 \u2191h \u2200 \u2191i \u2200 \u2191j \u2200 \u2191k \u2200 \u2191l \u2200 \u2191m \u2200 \u2191n \u2200 \u2191o, x \u2260 f \u2227 x \u2260 g \u2227 x \u2260 h \u2227 x \u2260 i \u2227 x \u2260 j \u2227 x \u2260 k \u2227 x \u2260 l \u2227 x \u2260 m \u2227 x \u2260 n \u2227 x \u2260 o \u2227 y \u2260 f \u2227 y \u2260 g \u2227 y \u2260 h \u2227 y \u2260 i \u2227 y \u2260 j \u2227 y \u2260 k \u2227 y \u2260 l \u2227 y \u2260 m \u2227 y \u2260 n \u2227 y \u2260 o \u2227 z \u2260 f \u2227 z \u2260 g \u2227 z \u2260 h \u2227 z \u2260 i \u2227 z \u2260 j \u2227 z \u2260 k \u2227 z \u2260 l \u2227 z \u2260 m \u2227 z \u2260 n \u2227 z \u2260 o,\n\n\n  let add1 := (\u03bb n : \u2115, n + 1),\n  let add2 := (\u03bb n : \u2115, n + 2),\n  let add3 := (\u03bb n : \u2115, n + 3),\n  let add4 := (\u03bb n : \u2115, n + 4),\n  let add5 := (\u03bb n : \u2115, n + 5),\n  let add6 := (\u03bb n : \u2115, n + 6),\n  let add7 := (\u03bb n : \u2115, n + 7),\n  let add8 := (\u03bb n : \u2115, n + 8),\n  let add9 := (\u03bb n : \u2115, n + 9),\n\n  let sub0 := (\u03bb n : \u2115, 10 - n),\n  let sub1 := (\u03bb n : \u2115, 9 - n),\n  let sub2 := (\u03bb n : \u2115, 8 - n),\n  let sub3 := (\u03bb n : \u2115, 7 - n),\n  let sub4 := (\u03bb n : \u2115, 6 - n),\n  let sub5 := (\u03bb n : \u2115, 5 - n),\n  let sub6 := (\u03bb n : \u2115, 4 - n),\n  let sub7 := (\u03bb n : \u2115, 3 - n),\n  let sub8 := (\u03bb n : \u2115, 2 - n),\n  let sub9 := (\u03bb n : \u2115, 1 - n),\n\n  let A2 := (\u2200 \u2191f \u2200 \u2191g \u2200 \u2191h \u2200 \u2191i \u2200 \u2191j \u2200 \u2191k \u2200 \u2191l \u2200 \u2191m \u2200 \u2191n \u2200 \u2191o, f = 0 \u2228 f = 1 \u2228 f = 2 \u2228 f = 3 \u2228 f = 4 \u2228 f = 5 \u2228 f = 6 \u2228 f = 7 \u2228 f = 8 \u2228 f = 9 \u2192 g \u2260 f \u2227 g \u2260 h \u2227 g \u2260 i \u2227 g \u2260 j \u2227 g \u2260 k \u2227 g \u2260 l \u2227 g \u2260 m \u2227 g \u2260 n \u2227 g \u2260 o \u2227 h \u2260 g \u2227 h \u2260 i \u2227 h \u2260 j \u2227 h \u2260 k \u2227 h \u2260 l \u2227 h \u2260 m \u2227 h \u2260 n \u2227 h \u2260 o \u2227 i \u2260 g \u2227 i \u2260 h \u2227 i \u2260 j \u2227 i \u2260 k \u2227 i \u2260 l \u2227 i \u2260 m \u2227 i \u2260 n \u2227 i \u2260 o \u2227 j \u2260 f \u2227 j \u2260 h \u2227 j \u2260 i \u2227 j \u2260 k \u2227 j \u2260 l \u2227 j \u2260 m \u2227 j \u2260 n \u2227 j \u2260 o \u2227 k \u2260 f \u2227 k \u2260 g \u2227 k \u2260 i \u2227 k \u2260 j \u2227 k \u2260 l \u2227 k \u2260 m \u2227 k \u2260 n \u2227 k \u2260 o \u2227 l \u2260 f \u2227 l \u2260 g \u2227 l \u2260 h \u2227 l \u2260 j \u2227 l \u2260 k \u2227 l \u2260 m \u2227 l \u2260 n \u2227 l \u2260 o \u2227 m \u2260 f \u2227 m \u2260 g \u2227 m \u2260 h \u2227 m \u2260 i \u2227 m \u2260 k \u2227 m \u2260 l \u2227 m \u2260 n \u2227 m \u2260 o \u2227 n \u2260 f \u2227 n \u2260 g \u2227 n \u2260 h \u2227 n \u2260 i \u2227 n \u2260 j \u2227 n \u2260 l \u2227 n \u2260 m \u2227 n \u2260 o \u2227 o \u2260 f \u2227 o \u2260 g \u2227 o \u2260 h \u2227 o \u2260 i \u2227 o \u2260 j \u2227 o \u2260 k \u2227 o \u2260 m \u2227 o \u2260 n),\n\n  let \u0393_0 := \u2200 \u2191f \u2200 \u2191g \u2200 \u2191h \u2200 \u2191i \u2200 \u2191j \u2200 \u2191k \u2200 \u2191l \u2200 \u2191m \u2200 \u2191n \u2200 \u2191o, f = 0 \u2228 f = 1 \u2228 f = 2 \u2228 f = 3 \u2228 f = 4 \u2228 f = 5 \u2228 f = 6 \u2228 f = 7 \u2228 f = 8 \u2228 f = 9 \u2192 g \u2260 f \u2227 g \u2260 h \u2227 g \u2260 i \u2227 g \u2260 j \u2227 g \u2260 k \u2227 g \u2260 l \u2227 g \u2260 m \u2227 g \u2260 n \n  \u2227 g \u2260 o \u2227 h \u2260 g \u2227 h \u2260 i \u2227 h \u2260 j \u2227 h \u2260 k \u2227 h \u2260 l \u2227 h \u2260 m \u2227 h \u2260 n \u2227 h \u2260 o \u2227 i \u2260 g \u2227 i \u2260 h \u2227 i \u2260 j \u2227 i \u2260 k \u2227 i \u2260 l \u2227 i \u2260 m \u2227 i \u2260 n \u2227 i \u2260 o \u2227 j \u2260 f \u2227 j \u2260 h \u2227 j \u2260 i \u2227 j \u2260 k \u2227 j \u2260 l \u2227 j \u2260 m \u2227 j \u2260 n \u2227 j \u2260 o \u2227 k \u2260 f \u2227 k \u2260 g \u2227 k \u2260 i \u2227 k \u2260 j \u2227 k \u2260 l \u2227 k \u2260 m \u2227 k \u2260 n \u2227 k \u2260 o \u2227 l \u2260 f \u2227 l \u2260 g \u2227 l \u2260 h \u2227 l \u2260 j \u2227 l \u2260 k \u2227 l \u2260 m \u2227 l \u2260 n \u2227 l \u2260 o \u2227 m \u2260 f \u2227 m \u2260 g \u2227 m \u2260 h \u2227 m \u2260 i \u2227 m \u2260 k \u2227 m \u2260 l \u2227 m \u2260 n \u2227 m \u2260 o \u2227 n \u2260 f \u2227 n \u2260 g \u2227 n \u2260 h \u2227 n \u2260 i \u2227 n \u2260 j \u2227 n \u2260 l \u2227 n \u2260 m \u2227 n \u2260 o \u2227\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  -- The negation is used to avoid a contradiction when n = 0\n  have h1 : \u00ac(\u2200 n : \u2115, n \u2264 0 \u2192 \u2200 (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 : \u00ac(\u2200 n : \u2115, \u2200 (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 : \u2203 (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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let A n := \u2203 (l : fin n \u2192 L.Model.Atom), \u2200 (a : fin n \u2192 L.Model.Atom), \u2203! (m : fin n), l m = a m,\n  have h1 : \u2203 (M : F.Model) [mfin : fintype M], \u2200 (n : \u2115), \u00ac A n, from sorry,\n\n  obtain \u27e8M, mfin, h2\u27e9 := h1,\n\n  exact M,\nend\n\n--OUTPUT 7\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let \u0393 := \n    begin\n      exact (F \u222a (set.Union \u2115 (\u03bb n, {\u2203 (x\u2081 x\u2082 \u2026 x\u2099 : F.Var), \u00ac (x\u2081 = x\u2082 \u2227 \u2026 \u2227 x\u2099\u208b\u2081 = x\u2099)})))\n    end,\n\n  have h1 : \u2200 (n : \u2115), F.sat (set.to_finset \u0393.val.val.val) (list.repeat F.true n), from by auto,\n  have h2 : \u2200 (n : \u2115), F.sat (set.to_finset \u0393.val.val.val) (\u2191(\u0393.val.val.val.val.val.val) :: list.repeat F.true n), from by auto,\n\n  have h3 : F.T.sat \u0393.val.val.val \u2228 \u00acF.T.sat \u0393.val.val.val, from by blast,\n\n  let M := \u03a3 (M : F.Model), F.sat M \u0393.val.val.val,\n  have h4 : \u2203 (M : F.Model), finite M, from by auto [finite.of_fintype, h],\n  have h5 : \u2203 (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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M := \nbegin\n  have A1 : \u2200 n : \u2115, fintype.card (@fintype.card F.Model (fintype.of_univ) n) = n, from by auto [fintype.card_univ],\n  have A2 : \u2200 n : \u2115, \u2203 ( N : F.Model ) [mN : fintype N], \u2200 i : \u22c6, i.val < n \u2192 N.elems.val i \u2208 N.elems.val (fintype.ord_max (n)), from begin\n    assume n : \u2115,\n    have B1 : \u2200 i : \u22c6, i.val < n \u2192 \u2203 (m : F.Model) [mfin : fintype m], fintype.card m = n, from begin\n      assume i\u2080 : \u22c6,\n      assume h : i\u2080.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) \u2264 fintype.card (hgfp (@fintype.card F.Model (fintype.of_univ) n) (n+1)).val, from h1 (\u03bb a b, @nat.le_iff_lt_or_eq.2 b),\n      have h4 : (n+1) \u2264 (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 \u2203 (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 : \u2200 i : \u22c6, i.val < n \u2192 \u2203 (m : F.Model), fintype.card m = n, from begin\n      assume i\u2080 : \u22c6,\n      assume h : i\u2080.val < n,\n      have h1 : \u2203 (m : F.Model) [mfin : fintype m], fintype.card m = n, from B1 i\u2080 h,\n      show \u2203 (m : F.Model), fintype.card m = n, from exists.elim h1 (\u03bb a b, a),\n    end,\n    have B3 : \u2200 i : \u22c6, i.val < n \u2192 \u2203 (m : F.Model) [mfin : fintype m], fintype.card m = n, from by auto using B2,\n    have B4 : \u2200 i : \u22c6, i.val < n \u2192 \u2203 (m : F.Model), fintype.card m = n, from by auto using B3,\n    have C1 : \u2203 (m : F.Model) [mfin : fintype m], fintype.card m = n, from by auto [h, B4],\n    have C2 : \u2203 (m : F.Model), fintype.card m = n, from exists.elim C1 (\u03bb a b, a),\n    have C3 : \u2203 (N : F.Model) [mN : fintype N], fintype.card N = n, from C2,\n    have C4 : \u2203 (N : F.Model) [mN : fintype N], \u2200 i : \u22c6, i.val < n \u2192 N.elems.val i \u2208 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 : \u2200 i : \u22c6, i.val < n \u2192 N.elems.val i \u2208 N.elems.val (fintype.ord_max (n)), from begin\n        assume i\u2080 : \u22c6,\n        assume h : i\u2080.val < n,\n        have h1 : \u2203 (m : F.Model) [mfin : fintype m], fintype.card m = n, from B1 i\u2080 h,\n        have h2 : fintype.card N = n, from hN,\n        have h3 : \u2200 i : \u22c6, i.val < n \u2192 \u2203 (m : F.Model), fintype.card m = n, from B4,\n        have h4 : \u2203 (N : F.Model) [mN : fintype N], fintype.card N = n, from h3 i\u2080 h,\n        have h5 : \u2203 (N : F.Model), fintype.card N = n, from exists.elim h4 (\u03bb 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 : \u2203 (m : F.Model), fintype.card m = n, from h1,\n        have h9 : \u2203 (m : F.Model), fintype.card m = n, from h8,\n        have h10 : \u2203 (m : F.Model), fintype.card m = n, from h1,\n        have h11 : \u2203 (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 : \u2203 (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 : \u2203 (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 : \u2203 (m : F.Model), fintype.card m = n, from exists.intro (N : F.Model) (exists.intro hN h6),\n        have h19 : \u2203 (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) \u2208 N.elems, from by auto [fintype.subtype_val_range],\n        have h23 : (N : F.Model) \u2208 (N.elems), from h22,\n        show N.elems.val i\u2080 \u2208 N.elems.val (fintype.ord_max (n)), from h23,\n      end,\n      show \u2203 (N : F.Model) [mN : fintype N], \u2200 i : \u22c6, i.val < n \u2192 N.elems.val i \u2208 N.elems.val (fintype.ord_max (n)), from exists.intro (N : F.Model) (exists.intro mN D1),\n    end),\n    have C5 : \u2203 (N\nend --Needs more than 2000 tokens!\n\n--OUTPUT 9\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let \u0393 := F.add_axiom_of_infinite_models,\n  have h1 : F.has_finite_models, from by auto [h],\n  have h2 : \u2200 (n : \u2115), n < \u0393.card \u2192 \u2203 (m : F.Model), n \u2264 m.card, from by auto using [h1],\n  have h3 : \u2203 (M : F.Model), \u0393.card \u2264 M.card, from by auto using [compactness.compactness, h2],\n  have h4 : \u2203 (M : F.Model), infinite M, from by auto [h3],\n  show \u2203 (M : F.Model), infinite M, from h4,\nend\n\n--OUTPUT 10\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n\n  have h1 : \u2200 (n : \u2115), \u2203 (m : F.Model), n \u2264 fintype.card m, from by auto,\n\n  have h3 : \u2200 (n : \u2115), fintype.card \u2115 \u2265 n, from by linarith [fintype.card_nat],\n\n  have h4 : \u2200 (n : \u2115) (m : F.Model) [mfin : fintype m], n \u2264 fintype.card m, from by {assume n m mfin, assume h, cases h, exact h},\n\n  have h5 : \u2200 (n : \u2115), \u2203 (m : F.Model) [mfin : fintype m], fintype.card m \u2265 n, from by auto [h1, h3, h4, exists.intro],\n\n  have h6 : \u2200 (A : set (L.Formula \u2115)), @fintype.card (set (L.Formula \u2115)) (fintype.fintype_set (L.Formula \u2115)) (F.Theory.SAT_set A) \u2265 (fintype.card A), from by auto [fintype.card_SAT_set],\n\n  have h7 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 fintype.card B = fintype.card A, from by auto [fintype.exists_set_of_card_eq, exists.intro],\n  \n  have h8 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 F.Theory.SAT_rel B, from by auto [h6, h7],\n\n  have h9 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], fintype.card A < fintype.card (F.Theory.SAT_set A), from by auto,\n\n  have h10 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 F.Theory.SAT_rel B \u2227 fintype.card B \u2264 fintype.card A, from by auto [h8, h9],\n\n  have h11 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto,\n\n  have h12 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n\n  have h13 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n  \n  have h14 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n\n  have h15 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n\n  have h16 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n\n  have h17 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n\n  have h18 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n\n  have h19 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n\n  have h20 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n\n  have h21 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 m = F.Theory.SAT_set B \u2227 fintype.card B < fintype.card A, from by auto [h8, h9],\n\n  have h22 : \u2200 (A : set (L.Formula \u2115)) [Afin : fintype A], \u2203 (m : F.Model) [mfin : fintype m], \u2203 (B : set (L.Formula \u2115)) [Bfin : fintype B], B \u2286 A \u2227 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from by auto [h2],\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (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}\u1d52\u1d56 \u2964 Ab.{u+1}) :=\ncategory_theory.functor_category_is_abelian.{(u+2) u (u+1)}\n\n-- ANNOYING!\ninstance ExtrDisc_presheaf_abelian : abelian (ExtrDisc.{u}\u1d52\u1d56 \u2964 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} \u2964 Profinite.{u}\u1d52\u1d56 \u2964 Ab.{u+1} :=\nyoneda \u22d9 (whiskering_right _ _ _).obj (ulift_functor.{u+1} \u22d9 AddCommGroup.free)\n\ndef Profinite_to_ExtrDisc_presheaf : Profinite.{u} \u2964 ExtrDisc.{u}\u1d52\u1d56 \u2964 Type (u+1) :=\nyoneda \u22d9 (whiskering_left _ _ _).obj ExtrDisc_to_Profinite.op \u22d9\n  (whiskering_right _ _ _).obj ulift_functor.{u+1}\n\ndef Profinite_to_ExtrDisc_presheaf_Ab : Profinite.{u} \u2964 ExtrDisc.{u}\u1d52\u1d56 \u2964 Ab.{u+1} :=\nyoneda \u22d9 (whiskering_left _ _ _).obj ExtrDisc_to_Profinite.op \u22d9\n  (whiskering_right _ _ _).obj (ulift_functor.{u+1} \u22d9 AddCommGroup.free)\n\ndef unsheafified_free_Cech' (F : arrow Profinite.{u}) :\n  chain_complex (Profinite.{u}\u1d52\u1d56 \u2964 Ab.{u+1}) \u2115 :=\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}\u1d52\u1d56 \u2964 Ab.{u+1}) \u2115 :=\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}) \u2115 :=\n(((simplicial_object.augmented.whiskering _ _).obj\n  (Profinite_to_Condensed \u22d9 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}) \u2115 :=\n(((simplicial_object.augmented.whiskering _ _).obj\n  (Profinite_to_ExtrDisc_presheaf_Ab \u22d9 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}) \u2124 :=\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] {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0] {\ud835\udcd1 : Type*} [category \ud835\udcd1] [abelian \ud835\udcd1]\n  (f : arrow C)\n  [\u2200 (n : \u2115), has_wide_pullback f.right (\u03bb (i : fin (n + 1)), f.left) (\u03bb (i : fin (n + 1)), f.hom)]\n  (F : C \u2964 \ud835\udcd0) (G : \ud835\udcd0 \u2964 \ud835\udcd1) (H : C \u2964 \ud835\udcd1) (E : F \u22d9 G \u2245 H) [G.additive] :\n  (G.map_homological_complex _).obj ((((simplicial_object.augmented.whiskering _ _).obj F).obj\n    f.augmented_cech_nerve).to_complex) \u2245\n  (((simplicial_object.augmented.whiskering _ _).obj H).obj f.augmented_cech_nerve).to_complex :=\nhomological_complex.hom.iso_of_components\n(\u03bb 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, \u2190 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 \u2190 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) \u2245\n  free_ExtrDisc_Cech' F :=\nlet e := ExtrDisc_sheafification_iso in\nwhiskering_Cech_comp_iso F\n  (Profinite_to_Condensed.{u} \u22d9 CondensedSet_to_Condensed_Ab.{u})\n  ((Condensed_ExtrSheaf_equiv.{u u+2} Ab.{u+1}).inverse)\n  (Profinite_to_ExtrDisc_presheaf_Ab.{u} \u22d9 presheaf_to_Sheaf.{u+2 u u+1} ExtrDisc.proetale_topology.{u} Ab.{u+1}) $\nnat_iso.of_components\n(\u03bb 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\u2082_aux\n  {C : Type*} [category C] {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0] {\ud835\udcd1 : Type*} [category \ud835\udcd1] [abelian \ud835\udcd1]\n  (f : arrow C)\n  [\u2200 (n : \u2115), has_wide_pullback f.right (\u03bb (i : fin (n + 1)), f.left) (\u03bb (i : fin (n + 1)), f.hom)]\n  (F : C \u2964 \ud835\udcd0) (G : \ud835\udcd0\u1d52\u1d56 \u2964 \ud835\udcd1) [G.additive] :\n  (G.map_homological_complex _).obj ((((simplicial_object.augmented.whiskering _ _).obj F).obj\n    f.augmented_cech_nerve).to_complex).op \u2245\n  (((cosimplicial_object.augmented.whiskering _ _).obj (F.op \u22d9 G)).obj\n    f.augmented_cech_nerve.right_op).to_cocomplex :=\nhomological_complex.hom.iso_of_components\n(\u03bb 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 \u2245\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(\u03bb 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 \u2245 (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(\u03bb 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}\u1d52\u1d56 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} \u2115 :=\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}\u1d52\u1d56 Ab.{u+1}).obj\n  (op X)).map_homological_complex\n  (complex_shape.down.{0} \u2115)).obj\n  (unsheafified_free_ExtrDiscr_Cech.{u} F) \u2245\n  evaluated_free_ExtrDisc_Cech F X :=\nhomological_complex.hom.iso_of_components\n(\u03bb 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) \u27e8rfl\u27e9,\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 : \u2115) = 0 + 1), erw category.id_comp,\n    rw if_pos (rfl : (1 : \u2115) = 0 + 1), erw category.id_comp,\n    apply free_abelian_group.lift.ext,\n    rintro \u27e8t\u27e9,\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 (\u03bb (_x : fin (0 + 0 + 1)), F.hom))).app\n        (op.{u+2} X.val))) (\u03bb (q : fin (0 + 0 + 1)), ulift_functor.{u+1 u}.map\n        ((yoneda.{u u+1}.map (wide_pullback.\u03c0 (\u03bb (_x : fin (0 + 0 + 1)),\n        F.hom) q)).app (op.{u+2} X.val))) _)\n      (wide_pullback.base (\u03bb (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 \u2190 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.\u03b4],\n\n    apply free_abelian_group.lift.ext,\n    rintro \u27e8t\u27e9,\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      (\u03bb (i : fin (j + 1 + 1)), (Profinite_to_ExtrDisc_presheaf.{u}.map F.hom).app (op.{u+2} X)))\n      (\u03bb (k : fin (j + 1)), wide_pullback.\u03c0\n      (\u03bb (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.\u03b4 i)) k)) _,\n\n    let f2 := wide_pullback.lift (ulift_functor.{u+1 u}.map ((yoneda.{u u+1}.map\n      (wide_pullback.base (\u03bb (_x : fin (j.succ + 0 + 1)), F.hom))).app (op.{u+2} X.val)))\n      (\u03bb (q : fin (j.succ + 0 + 1)), ulift_functor.{u+1 u}.map\n      ((yoneda.{u u+1}.map (wide_pullback.\u03c0\n      (\u03bb (_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 (\u03bb (_x : fin (j + 0 + 1)), F.hom))).app (op.{u+2} X.val)))\n      (\u03bb (q : fin (j + 0 + 1)), ulift_functor.{u+1 u}.map\n      ((yoneda.{u u+1}.map (wide_pullback.\u03c0\n      (\u03bb (_x : fin (j + 0 + 1)), F.hom) q)).app (op.{u+2} X.val))) _,\n\n    change (f2 \u226b f1) _ = f3 _,\n\n    let f4 := wide_pullback.lift (wide_pullback.base (\u03bb (i : fin (j + 1 + 1)), F.hom))\n      (\u03bb (k : fin (j + 1)), wide_pullback.\u03c0\n      (\u03bb (i : fin (j + 1 + 1)), F.hom) ((simplex_category.hom.to_order_hom\n      (simplex_category.\u03b4 i)) k)) _,\n\n    suffices : f2 \u226b f1 = ((yoneda'.map f4).app (op X.val) \u226b 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_\u03c0, wide_pullback.lift_\u03c0_assoc],\n      erw [wide_pullback.lift_\u03c0],\n      erw [\u2190 functor.map_comp, \u2190 nat_trans.comp_app, \u2190 functor.map_comp, wide_pullback.lift_\u03c0] },\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 [\u2190 functor.map_comp, \u2190 nat_trans.comp_app, \u2190 functor.map_comp,\n        wide_pullback.lift_base] } }\nend\n\nlemma free_Cech_exact (F : arrow Profinite.{u}) (hF : function.surjective F.hom) : \u2200 (n : \u2124),\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 \u27e8\u03bb i, (this i).some, _\u27e9,\n      ext1 i, exact (this i).some_spec },\n    dsimp [G, functor.map_arrow, Profinite_to_ExtrDisc_presheaf, ulift_functor, yoneda],\n    rintros \u27e8e\u27e9,\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) : \u2200 n,\n  short_exact (kernel.\u03b9 $ (free_Cech F).d (n+1+1) (n+1)) (delta_to_kernel _ (n+1+1) (n+1) n) :=\nbegin\n  erw \u2190 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 : \u2124) (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 : \u2124) : Prop := \u2200 S, \u2200 i > 0, i \u2264 n \u2192 is_zero (HH i S M)\n\n/-- Consider the following commutative diagram\n```\n     O\u2080\n     \u2193\nA\u2081 \u2192 B\u2081 \u2192 C\u2081 \u2192 O\u2081\n   \u2198 \u2193\n     B\u2082\n     \u2193  \u2198\nO\u2083 \u2192 B\u2083 \u2192 C\u2083\n```\nwhere `O\u2080`, `O\u2081`, and `O\u2083` are zero objects, and all sequence are exact.\n\nThen `C\u2081` is also a zero object.\n-/\nlemma acyclic_of_exact.induction_step_aux {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {O\u2080 O\u2081 O\u2083 A\u2081 B\u2081 C\u2081 B\u2082 B\u2083 C\u2083 : \ud835\udcd0}\n  {\u03b1\u2081 : A\u2081 \u27f6 B\u2081} {\u03b2\u2081 : B\u2081 \u27f6 C\u2081} {\u03b3\u2081 : C\u2081 \u27f6 O\u2081} (ex\u2081 : exact_seq \ud835\udcd0 [\u03b1\u2081, \u03b2\u2081, \u03b3\u2081])\n  {d\u2081 : A\u2081 \u27f6 B\u2082} {d\u2082 : B\u2082 \u27f6 C\u2083}                 (exd : exact d\u2081 d\u2082)\n  {b\u2080 : O\u2080 \u27f6 B\u2081} {b\u2081 : B\u2081 \u27f6 B\u2082} {b\u2082 : B\u2082 \u27f6 B\u2083} (exb : exact_seq \ud835\udcd0 [b\u2080, b\u2081, b\u2082])\n  {\u03b1\u2083 : O\u2083 \u27f6 B\u2083} {\u03b2\u2083 : B\u2083 \u27f6 C\u2083}                 (ex\u2083 : exact \u03b1\u2083 \u03b2\u2083)\n  (hO\u2080 : is_zero O\u2080) (hO\u2081 : is_zero O\u2081) (hO\u2083 : is_zero O\u2083)\n  (tr\u2081 : \u03b1\u2081 \u226b b\u2081 = d\u2081) (tr\u2082 : b\u2082 \u226b \u03b2\u2083 = d\u2082) :\n  is_zero C\u2081 :=\nbegin\n  refine (ex\u2081.drop 1).pair.is_zero_of_eq_zero_eq_zero\n    (ex\u2081.pair.eq_zero_of_epi _) (hO\u2081.eq_of_tgt _ _),\n  haveI : mono b\u2081 := exb.pair.mono_of_eq_zero (hO\u2080.eq_of_src _ _),\n  haveI : mono \u03b2\u2083 := ex\u2083.mono_of_eq_zero (hO\u2083.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' \u03b2\u2083 tr\u2082.symm,\n  obtain rfl :\n    \u03b1\u2081 = kernel.lift _ _ exd.w \u226b (is_limit.cone_point_unique_up_to_iso (limit.is_limit _) l).hom,\n  { erw [\u2190 cancel_mono b\u2081, category.assoc,\n      is_limit.cone_point_unique_up_to_iso_hom_comp _ _ walking_parallel_pair.zero, is_limit.fac,\n      fork.of_\u03b9_\u03c0_app, tr\u2081] },\n  apply epi_comp\nend\n\nlemma acyclic_of_exact.induction_step_ex\u2081\n  (F : arrow Profinite.{u})\n  (h : \u2200 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\u1d52\u1d56 Ab).obj\n    ((Profinite_to_Condensed \u22d9 CondensedSet_to_Condensed_Ab).op \u22d9 preadditive_yoneda.obj M)).obj\n    F.augmented_cech_nerve.right_op).to_cocomplex\n  in \u2200 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\u2082\n  (F : arrow Profinite.{u})\n  (h : let C := (((cosimplicial_object.augmented.whiskering Profinite\u1d52\u1d56 Ab).obj\n    ((Profinite_to_Condensed \u22d9 CondensedSet_to_Condensed_Ab).op \u22d9 preadditive_yoneda.obj M)).obj\n    F.augmented_cech_nerve.right_op).to_cocomplex\n    in \u2200 i, is_zero (C.homology i)) :\n  \u2200 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\u2082_aux,\nend\n\nlemma int.of_nat_add_one (i : \u2115) : 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 : \u2115) :\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  {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0]\n  (C : cochain_complex \ud835\udcd0 \u2115) (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 \u2115).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\u2083\n  (F : arrow Profinite.{u}) (i : \u2124)\n  (h : \u2200 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 [\u2190 functor.map_comp, \u2190 op_comp, homological_complex.d_comp_d, op_zero, functor.map_zero] },\n    clear h,\n    refine _ \u226a\u226b (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, \u2190 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\u2084\n  (F : arrow Profinite.{u}) (i : \u2124)\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 : \u2200 i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n      F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n  (i : \u2124) :\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\u2084,\n  apply acyclic_of_exact.induction_step_ex\u2083,\n  apply acyclic_of_exact.induction_step_ex\u2082,\n  apply acyclic_of_exact.induction_step_ex\u2081 _ F h,\nend\n\nlemma acyclic_of_exact.induction_step\n  (h : \u2200 (F : arrow Profinite.{u}) (surj : function.surjective F.hom),\n    \u2200 i, is_zero (((((cosimplicial_object.augmented.whiskering _ _).obj M.val).obj\n      F.augmented_cech_nerve.right_op).to_cocomplex).homology i))\n  (n : \u2124) (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 \u2190 Profinite.epi_iff_surjective, apply projective_presentation.epi },\n  let E := \u03bb i, (Ext' i).flip.obj M,\n  have ih' : \u2200 (i j : \u2124) (h0i : 0 < i) (hin : i \u2264 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 := \u03bb i, kernel ((free_Cech F).d (i + 1) i),\n  have LES := \u03bb i j, (free_Cech_kernel_SES F hF i).Ext'_five_term_exact_seq M j,\n  have H1 : \u2200 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 : \u2200 (i : \u2124) (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 : \u2200 (i j : \u2124) (h0i : 0 < i+1) (hi : i+1 \u2264 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 : \u2200 i j, 0 < i \u2192 -1 \u2264 j \u2192 i + j = n \u2192 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.\u03b9 _) _).op, refine is_zero_zero _, },\n    { refine this (n+1) (-1) h1 le_rfl _, rw [\u2190 sub_eq_add_neg, add_sub_cancel] } },\n  obtain \u27e8n, rfl\u27e9 : \u2203 k, k+1 = n := \u27e8n-1, sub_add_cancel _ _\u27e9,\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:\u2124), 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 := \u03bb 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 \u2228 1 \u2264 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 [\u2190 delta_to_kernel_\u03b9 _ _ _ (n+1), op_comp, functor.map_comp] }, refl },\n  { conv_rhs { rw [\u2190 delta_to_kernel_\u03b9 _ _ _ (n+1+1), op_comp, functor.map_comp] }, refl },\nend\n\nlemma acyclic_of_exact\n  (h : \u2200 (F : arrow Profinite.{u}) (surj : function.surjective F.hom),\n    \u2200 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  \u2200 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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (((a3).write i3 ((a3).read i1)).read i1) \u2260 ((a3).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test80.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5350984286266115, "lm_q2_score": 0.4263215925474903, "lm_q1q2_score": 0.2281240142617566}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v2) \u2260 ((((a1).write i3 (v2)).write i2 (v2)).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test26.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.2279848609658756}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v3) \u2260 ((((a1).write i2 (v3)).write i3 (v3)).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test12.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.2279848609658756}}
{"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 (\u03b1 : Type w) (m : Type u \u2192 Type v) (\u03b2 : Type u) :=\n(apply : \u03b1 \u2192 m \u03b2)\n\ndef goto {\u03b1 \u03b2} {m : Type u \u2192 Type v} (f : label \u03b1 m \u03b2) (x : \u03b1) := f.apply x\n\nclass monad_cont (m : Type u \u2192 Type v)\nextends monad m :=\n(call_cc : \u03a0 {\u03b1 \u03b2}, ((label \u03b1 m \u03b2) \u2192 m \u03b1) \u2192 m \u03b1)\n\nopen monad_cont\nclass is_lawful_monad_cont (m : Type u \u2192 Type v) [monad_cont m]\nextends is_lawful_monad m :=\n(call_cc_bind_right {\u03b1 \u03c9 \u03b3} (cmd : m \u03b1) (next : (label \u03c9 m \u03b3) \u2192 \u03b1 \u2192 m \u03c9) :\n  call_cc (\u03bb f, cmd >>= next f) = cmd >>= \u03bb x, call_cc (\u03bb f, next f x))\n(call_cc_bind_left {\u03b1} (\u03b2) (x : \u03b1) (dead : label \u03b1 m \u03b2 \u2192 \u03b2 \u2192 m \u03b1) :\n  call_cc (\u03bb f : label \u03b1 m \u03b2, goto f x >>= dead f) = pure x)\n(call_cc_dummy {\u03b1 \u03b2} (dummy : m \u03b1) :\n  call_cc (\u03bb f : label \u03b1 m \u03b2, dummy) = dummy)\n\nexport is_lawful_monad_cont\n\ndef cont_t (r : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type w) := (\u03b1 \u2192 m r) \u2192 m r\n\nnamespace cont_t\n\nvariables {r : Type u} {m : Type u \u2192 Type v} {\u03b1 \u03b2 \u03b3 \u03c9 : Type w}\n\ndef run : cont_t r m \u03b1 \u2192 (\u03b1 \u2192 m r) \u2192 m r := id\n\ndef map (f : m r \u2192 m r) (x : cont_t r m \u03b1) : cont_t r m \u03b1 := f \u2218 x\n\nlemma run_cont_t_map_cont_t (f : m r \u2192 m r) (x : cont_t r m \u03b1) :\n  run (map f x) = f \u2218 run x := rfl\n\ndef with_cont_t (f : (\u03b2 \u2192 m r) \u2192 \u03b1 \u2192 m r) (x : cont_t r m \u03b1) : cont_t r m \u03b2 :=\n\u03bb g, x $ f g\n\nlemma run_with_cont_t (f : (\u03b2 \u2192 m r) \u2192 \u03b1 \u2192 m r) (x : cont_t r m \u03b1) :\n  run (with_cont_t f x) = run x \u2218 f := rfl\n\n-- def call_cc (f : (\u03b1 \u2192 cont_t r m \u03b2) \u2192 cont_t r m \u03b1) : cont_t r m \u03b1 :=\n-- \u03bb g, f (\u03bb x h, g x) g\n\ninstance : monad (cont_t r m) :=\n{ pure := \u03bb \u03b1 x f, f x,\n  bind := \u03bb \u03b1 \u03b2 x f g, x $ \u03bb 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 := \u03bb a x f, x >>= f }\n\nlemma monad_lift_bind [monad m] [is_lawful_monad m] {\u03b1 \u03b2} (x : m \u03b1) (f : \u03b1 \u2192 m \u03b2) :\n  (monad_lift (x >>= f) : cont_t r m \u03b2) = monad_lift x >>= monad_lift \u2218 f :=\nby { ext, simp only [monad_lift,has_monad_lift.monad_lift,(\u2218),(>>=),bind_assoc,id.def] }\n\ninstance : monad_cont (cont_t r m) :=\n{ call_cc := \u03bb \u03b1 \u03b2 f g, f \u27e8\u03bb x h, g x\u27e9 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 \u2192 Type v} {\u03b1 \u03b2 \u03b3 \u03c9 : Type w}\n\ndef take_while' [monad_cont m] {\u03b1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (xs : list \u03b1) : m (list \u03b1) :=\ncall_cc $ \u03bb leave,\ndo rs \u2190 mfoldl (\u03bb 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 : \u03b1 \u2192 Prop) [decidable_pred p] (xs : list \u03b1) : list \u03b1 :=\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] {\u03b1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (xs : list \u03b1) :\n  take_while' p xs = (pure $ list.take_while p xs : m (list \u03b1)) :=\nbegin\n  suffices : take_while' p xs = (pure $ [].reverse ++ list.take_while p xs : m (list \u03b1)),\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 : \u03b1 \u2192 Prop) [decidable_pred p] (xs : list \u03b1) :\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 \u2192 Type v} {\u03b1 \u03b2 \u03b3 \u03c9 : Type u}\nvariables (f : \u03b1 \u2192 m \u03b1)\n\nsection iter\nvariables [monad m]\ndef iterate' : \u2115 \u2192 \u03b1 \u2192 m \u03b1\n| 0 := pure\n| (succ n) := \u03bb x, f x >>= iterate' n\nopen list\n\nlemma iterate_eq_foldl (n : \u2115) (x : \u03b1) :\n  iterate' f n x = mfoldl (\u03bb 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 : \u2115) (x : \u03b1) :\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 [\u2190 bind_assoc,n_ih],\nend\n\nlemma iterate_succ'' (n : \u2115) :\n  iterate' f (succ n) = \u03bb x, iterate' f n x >>= f :=\nby ext; rw _root_.iterate_succ'\n\nlemma iterate_bind_iterate (x : \u03b1) (n k : \u2115) :\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 : \u2115) :\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' : \u03a0 n, (array n (label \u03b1 m \u03b1) \u2192 \u03b1 \u2192 m \u03b1) \u2192 \u03b1 \u2192 m \u03b1\n| 0 f x := f array.nil x\n| (succ n) g x :=\ncall_cc $ \u03bb goto_n,\ndo y \u2190 iterate_duff' n (\u03bb a, g $ a.push_back goto_n) x,\n   f y\n\ndef duff_idx {n} : fin n \u2192 fin n\n| \u27e8i,hi\u27e9 :=\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\u27e8n - (i+1), h\u27e9\n\ndef iterate_duff {n} (i : fin n) : \u03b1 \u2192 m \u03b1 :=\niterate_duff' f n $ \u03bb a,\ngoto (a.read (duff_idx i))\n\nvariables [is_lawful_monad_cont m]\n\n@[simp]\nlemma iterate_duff_dummy (n : \u2115) (goto_n : \u03b1 \u2192 m \u03b1) (x : \u03b1) :\n  iterate_duff' f n (\u03bb (a : array n (label \u03b1 m \u03b1)), 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 \u03b1) (x : \u03b1) (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 \u2190 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 \u2260 0) :\n  \u2191(i.pred h) = nat.pred i :=\nby cases i; refl\n\nlemma iterate_duff_def {n} (i : fin n) (x : \u03b1) :\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 : \u03a0 (l : list \u03b1) {n}, array n \u03b1 \u2192 array (n + l.length) \u03b1\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 : \u03b1) :\n  iterate' f i x =\n  call_cc (\u03bb goto_n_0 : label \u03b1 m \u03b1,\n  call_cc (\u03bb goto_n_1,\n  call_cc (\u03bb goto_n_2,\n  call_cc (\u03bb 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  \u03bb (y\u2084 : \u03b1), f y\u2084) >>=\n  \u03bb (y\u2083 : \u03b1), f y\u2083) >>=\n  \u03bb (y\u2082 : \u03b1), f y\u2082) >>=\n  \u03bb (y\u2081 : \u03b1), f y\u2081)\n :=\nbegin\n  rw \u2190 iterate_duff_def,\n  dsimp [iterate_duff,iterate_duff'], refl,\nend\n\nlemma unroll_iterate_def (n c : \u2115) (h : n > 0) (x : \u03b1) :\n  iterate' f c x =\n  iterate_duff f \u27e8c % n, mod_lt c h \u27e9 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 : \u2115) (x : \u03b1) :\n  iterate' f c x =\n  call_cc (\u03bb goto_n_0 : label \u03b1 m \u03b1,\n  call_cc (\u03bb goto_n_1,\n  call_cc (\u03bb goto_n_2,\n  call_cc (\u03bb 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 (\u27e8c % 4,mod_lt c dec_trivial\u27e9)) x >>=\n  \u03bb (y\u2084 : \u03b1), f y\u2084) >>=\n  \u03bb (y\u2083 : \u03b1), f y\u2083) >>=\n  \u03bb (y\u2082 : \u03b1), f y\u2082) >>=\n  \u03bb (y\u2081 : \u03b1), f y\u2081) >>=\n  iterate' (\u03bb 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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a1).write i2 (v3)).write i1 (v3)).read i2) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test9.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.22773539795792527}}
{"text": "/- Enumerable and the Decidable instance may already be in Mathlib -/\n\nclass Enumerable (\u03b1 : Type u) where\n  elems    : List \u03b1\n  complete : \u2200 a : \u03b1, a \u2208 elems\n\ndef List.allTrue (p : \u03b1 \u2192 Prop) [(a : \u03b1) \u2192 Decidable (p a)] : List \u03b1 \u2192 Bool\n  | [] => true\n  | a :: as => p a && allTrue p as\n\ntheorem List.of_allTrue [(a : \u03b1) \u2192 Decidable (p a)] (hc : allTrue p as) (hin : a \u2208 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 : \u03b1) \u2192 Decidable (p a)] (h : \u2200 a, p a) : allTrue p as := by\n  induction as <;> simp [allTrue, *]\n\ninstance [Enumerable \u03b1] (p : \u03b1 \u2192 Prop) [(a : \u03b1) \u2192 Decidable (p a)] : Decidable (\u2200 a, p a) :=\n  have : List.allTrue p Enumerable.elems \u2192 (a : \u03b1) \u2192 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 \u2192 States \u2192 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 : \u2200 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 Cube.Simple.Basic\nimport Cube.Simple.Infer\nimport Cube.Simple.Eval\n\nopen Lean\nnamespace Cube.Simple.Expr\n\nnamespace Unify\n\ninductive Head where\n| const (name : String)\n| bvar (idx : Nat)\n| fvar (fvarId : FVarId)\nderiving DecidableEq, Hashable, Inhabited, Repr\n\nstructure BetaEtaNormalExpr where\n  binder : Array Ty\n  head : Head\n  args : Array Expr\nderiving DecidableEq, Hashable, Inhabited, Repr\n\ndef BetaEtaNormalExpr.ofNormalExpr (expr : Expr) : BetaEtaNormalExpr :=\n  let (binder, body) := lambdaTelescope expr\n  let (args, head) := appTelescope body\n  let head := match head with\n    | .const name => .const name\n    | .bvar idx => .bvar idx\n    | .fvar fvarId => .fvar fvarId\n    | _ => panic! \"Not in correct normal form\"\n  { binder, head, args }\n\ndef BetaEtaNormalExpr.ofExpr (expr : Expr) (ty : Ty) : BetaEtaNormalExpr :=\n  .ofNormalExpr <| betaEtaNormalForm expr ty\n\ndef Head.toExpr (head : Head) : Expr :=\n  match head with\n  | .const name => .const name\n  | .bvar idx => .bvar idx\n  | .fvar fvarId => .fvar fvarId\n\ndef BetaEtaNormalExpr.toExpr (expr : BetaEtaNormalExpr) : Expr :=\n  let body := mkApp expr.head.toExpr expr.args\n  abstractArgs body expr.binder\n \ninductive Flexibility where\n| rigid\n| flexible\n\ndef BetaEtaNormalExpr.flexibility (expr : BetaEtaNormalExpr) : Flexibility :=\n  match expr.head with\n  | .fvar .. => .flexible\n  | _ => .rigid\n\ntheorem BetaEtaNormalExpr.False_of_rigid_fvar {expr : BetaEtaNormalExpr} (h1 : expr.flexibility = .rigid) (h2 : expr.head = .fvar fvarId) : False := by\n  unfold flexibility at h1\n  rw [h2] at h1\n  simp at h1\n\ndef BetaEtaNormalExpr.headType (expr : BetaEtaNormalExpr) : SimpleM Ty := do\n  match expr.head with\n  | .const name => return (\u2190 read).find! name\n  | .fvar fvarId => return (\u2190 get).find! fvarId\n  | .bvar idx => return expr.binder.get! (expr.binder.size - idx)\n\ndef inhabitant (ty : Ty) : Expr :=\n  match ty with\n  | .nat => .const \"0\"\n  | .fun t1 t2 => .lam t1 (inhabitant t2)\n\ndef BetaEtaNormalExpr.headFVarId (expr : BetaEtaNormalExpr) (h : expr.flexibility = .flexible) : FVarId :=\n  match h2:expr.head with\n  | .fvar fvarId => fvarId\n  | .bvar idx | .const name => by simp [flexibility, h2] at h\n\ndef BetaEtaNormalExpr.applySubst (normalExpr : BetaEtaNormalExpr) (subst : Substitution) : SimpleM BetaEtaNormalExpr := do\n  let expr := normalExpr.toExpr\n  let substExpr := expr.applySubst subst\n  let ty \u2190 infer substExpr\n  return BetaEtaNormalExpr.ofExpr substExpr ty \n \nabbrev DisagreementPair := BetaEtaNormalExpr \u00d7 BetaEtaNormalExpr\nabbrev DisagreementSet := HashSet DisagreementPair\nstructure UnifyNode where\n  disagreement : DisagreementSet\n  substitution : Substitution\n\ndef DisagreementPair.apply (pair : DisagreementPair) (subst : Substitution) : SimpleM DisagreementPair :=\n  return (\u2190 pair.fst.applySubst subst, \u2190 pair.snd.applySubst subst)\n\ndef DisagreementSet.apply (set : DisagreementSet) (subst : Substitution) : SimpleM DisagreementSet :=\n  set.foldM (init := HashSet.empty) (fun new pair => do return new.insert (\u2190 pair.apply subst))\n\ndef UnifyNode.apply (node : UnifyNode) (subst : Substitution) : SimpleM UnifyNode := do\n  return \u27e8\u2190 node.disagreement.apply subst, node.substitution.compose subst\u27e9\n\n-- https://www21.in.tum.de/teaching/sar/SS20/5.pdf\npartial def unify (e1 e2 : Expr) : SimpleM Substitution := do\n  let t1 \u2190 infer e1 \n  let t2 \u2190 infer e2\n  if t1 == t2 then\n    let e1Normal := BetaEtaNormalExpr.ofExpr e1 t1\n    let e2Normal := BetaEtaNormalExpr.ofExpr e2 t1\n    go [\u27e8HashSet.empty.insert (e1Normal, e2Normal), {}\u27e9]\n  else\n    throw \"Types don't match\"\nwhere\n  go (state : List UnifyNode) : SimpleM Substitution := do\n    match state with\n    | [] => throw \"Gave up after exhaustive search\"\n    | node :: rest =>\n      match \u2190 simplify node with\n      | none => go rest\n      | some (.inl subst) => return subst\n      | some (.inr node) =>\n        match findMatcherTarget node.disagreement with\n        | some (lhs, rhs) =>\n          let candidates \u2190 matcher lhs rhs\n          let newNodes \u2190 candidates.mapM node.apply\n          go <| rest.append newNodes\n        | none => go <| rest.append [node]\n\n  simplify (node : UnifyNode) : SimpleM (Option (Substitution \u2295 UnifyNode)) := do\n    let mut newSet := HashSet.empty\n    let mut newSubst := node.substitution\n    for pair in node.disagreement do\n      match \u2190 simplifyPair pair newSubst with\n      | none => return none\n      | some (.inl subst) => newSubst := subst\n      | some (.inr set) => newSet := newSet.merge set\n    if newSet.isEmpty then\n      return some <| .inl newSubst\n    else\n      return some <| .inr \u27e8newSet, newSubst\u27e9\n\n  simplifyPair (pair : DisagreementPair) (subst : Substitution) : SimpleM (Option (Substitution \u2295 DisagreementSet)) := do\n    let lhs := pair.fst\n    let rhs := pair.snd\n    match hlflex:lhs.flexibility, hrflex:rhs.flexibility with\n    | .rigid, .rigid =>\n      if lhs.binder != rhs.binder || lhs.head != rhs.head then\n        return none\n      else\n        let newProblems := lhs.args.zip rhs.args\n        let folder := fun set (newLhs, newRhs) =>\n          let newLhs := BetaEtaNormalExpr.ofNormalExpr newLhs\n          let newRhs := BetaEtaNormalExpr.ofNormalExpr newRhs\n          let newPair := \u27e8{newLhs with binder := lhs.binder.append newLhs.binder}, {newRhs with binder := rhs.binder.append newRhs.binder}\u27e9\n          set.insert newPair\n        let newDisagreements := newProblems.foldl (init := .empty) folder\n        return some <| .inr newDisagreements\n    | .flexible, .flexible =>\n      let lhsVal := inhabitant (\u2190 lhs.headType)\n      let rhsVal := inhabitant (\u2190 rhs.headType)\n      let subst := subst.insert (lhs.headFVarId hlflex) lhsVal\n        |>.insert (rhs.headFVarId hrflex) rhsVal\n      return some <| .inl subst\n    | .flexible, .rigid => return some <| .inr <| HashSet.empty.insert (lhs, rhs)\n    | .rigid, .flexible => return some <| .inr <| HashSet.empty.insert (rhs, lhs)\n\n  findMatcherTarget (set : DisagreementSet) : Option ({ e : BetaEtaNormalExpr // e.flexibility = .flexible} \u00d7 { e : BetaEtaNormalExpr // e.flexibility = .rigid}) := do\n    for (lhs, rhs) in set do\n      match hlflex:lhs.flexibility, hrflex:rhs.flexibility with\n      -- simplify already turned .rigid, .flexible this way around\n      | .flexible, .rigid => return (\u27e8lhs, hlflex\u27e9, \u27e8rhs, hrflex\u27e9)\n      | _, _ => pure ()\n    none\n\n  projection (binder : Array Ty) (targetFVar : FVarId) (z : Nat) (zTelescope : Array Ty) : SimpleM Substitution := do\n    let mut hs := #[]\n    -- TODO this opt should be possible below as well\n    let args := (zTelescope.size - 1).fold (init := #[]) (fun idx args => args.push (.bvar idx))\n    -- TODO Dedup with projection\n    for hResTy in zTelescope[:zTelescope.size - 1] do\n      let hTyTelescope := binder.push hResTy\n      let hTy := Ty.ofTelescope hTyTelescope\n      let hFVar \u2190 FVar.freshM hTy\n      let hTerm := mkApp (.fvar hFVar) args\n      hs := hs.push hTerm\n    let replacer := abstractArgs (mkApp (.bvar z) hs) zTelescope\n    let candidate := (Substitution.empty.insert targetFVar replacer)\n    return candidate\n\n  projections (e : BetaEtaNormalExpr) (targetFVar : FVarId) (targetFVarTyTelescope : Array Ty) (resultTy : Ty) : SimpleM (List Substitution) := do\n    let mut substs := []\n    for i in [0:targetFVarTyTelescope.size - 1] do\n      let iTy := targetFVarTyTelescope[i]!\n      let iTyTelescope := iTy.telescope\n      let iResultTy := iTyTelescope[iTyTelescope.size - 1]!\n      if resultTy == iResultTy then\n        substs := (\u2190 projection e.binder targetFVar i iTyTelescope) :: substs\n    return substs\n\n  matcher (flex : { e : BetaEtaNormalExpr // e.flexibility = .flexible}) (rig : { e : BetaEtaNormalExpr // e.flexibility = .rigid}) : SimpleM (List Substitution) := do\n    let targetFVar := flex.val.headFVarId flex.property\n    let targetFVarTyTelescope := (\u2190 getCtx).find! targetFVar |>.telescope\n    match hhead:rig.val.head with\n    | .bvar idx => projections flex.val targetFVar targetFVarTyTelescope (rig.val.binder.get! (rig.val.binder.size - idx))\n    | .const name =>\n      -- imitation\n      let mut hs := #[]\n      let constTy := (\u2190 getEnv).find! name\n      let constTyTelescope := constTy.telescope\n      for hResTy in constTyTelescope[:constTyTelescope.size - 1] do\n        let hTyTelescope := targetFVarTyTelescope.set! (targetFVarTyTelescope.size - 1) hResTy\n        let hTy := Ty.ofTelescope hTyTelescope\n        let args := (hTyTelescope.size - 1).fold (init := #[]) (fun idx args => args.push (.bvar idx))\n        let hFVar \u2190 FVar.freshM hTy\n        let hTerm := mkApp (.fvar hFVar) args\n        hs := hs.push hTerm\n      let replacer := abstractArgs (mkApp (.const name) hs) (targetFVarTyTelescope[:targetFVarTyTelescope.size - 1])\n      let candidates := (Substitution.empty.insert targetFVar replacer) :: (\u2190 projections flex.val targetFVar targetFVarTyTelescope (constTyTelescope.get! (constTyTelescope.size - 1)))\n      -- TODO: Projection\n      return candidates\n    | .fvar .. => nomatch BetaEtaNormalExpr.False_of_rigid_fvar rig.property hhead\n\n#eval show IO _ from do\n  let testPairs := #[\n    -- flexible, flexible\n    ([stlc| \u03bb a : \u2115 . f a], [stlc| \u03bb b : \u2115 . x], Env.empty, (Context.empty.insert \u27e8\"f\", 0\u27e9 (.fun .nat .nat) |>.insert \u27e8\"x\", 0\u27e9 .nat)),\n    -- rigid, rigid\n    ([stlc| \u03bb f : \u2115 \u2192 \u2115 . f x], [stlc| \u03bb g : \u2115 \u2192 \u2115 . g x], Env.empty, (Context.empty.insert \u27e8\"x\", 0\u27e9 .nat)),\n    -- flexible, rigid\n    ([stlc| \u03bb y : \u2115 . x], [stlc| \u03bb y : \u2115 . 0], (Env.empty.insert \"0\" .nat), (Context.empty.insert \u27e8\"x\", 0\u27e9 .nat)),\n    ([stlc| \u03bb x : \u2115 . f x], [stlc| \u03bb y : \u2115 . 0], (Env.empty.insert \"0\" .nat), (Context.empty.insert \u27e8\"f\", 0\u27e9 (.fun .nat .nat))),\n    ([stlc| \u03bb x : \u2115 . f x], [stlc| \u03bb y : \u2115 . C y], (Env.empty.insert \"C\" (.fun .nat .nat)), (Context.empty.insert \u27e8\"f\", 0\u27e9 (.fun .nat .nat))),\n    ([stlc| \u03bb x : \u2115 . f (C (f x))], [stlc| \u03bb x : \u2115 . C x], (Env.empty.insert \"C\" (.fun .nat .nat)), (Context.empty.insert \u27e8\"f\", 0\u27e9 (.fun .nat .nat)))\n  ]\n  for (expr1, expr2, env, ctx) in testPairs do\n    let subst := unify expr1 expr2 |>.run' env ctx\n    match subst with\n    | .ok subst => \n      let expr1' := expr1.applySubst subst |>.betaReduce\n      let expr2' := expr2.applySubst subst |>.betaReduce\n      IO.println s!\"{repr subst}\"\n      IO.println s!\"{repr expr1'}\"\n      IO.println s!\"{repr expr2'}\"\n      IO.println \"\"\n    | .error e => IO.println s!\"unification failure: {e} \\n\"\n\nend Cube.Simple.Expr.Unify\n", "meta": {"author": "hargoniX", "repo": "lean-cube", "sha": "eda872669e0d8a27d627b0e042eed5e37ce09342", "save_path": "github-repos/lean/hargoniX-lean-cube", "path": "github-repos/lean/hargoniX-lean-cube/lean-cube-eda872669e0d8a27d627b0e042eed5e37ce09342/Cube/Simple/Unify.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5389832206876841, "lm_q2_score": 0.4225046348141883, "lm_q1q2_score": 0.22772290882762505}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((((a3).write i2 (v3)).write i3 (v3)).read i2) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test55.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4378234991142019, "lm_q1q2_score": 0.22745864304150118}}
{"text": "import Contractome.EVM\n\nopen EVM\n\n\nvariable {C : Cfg} [DecidableEq C.Tw] [\u2200 n, OfNat C.Tw n] [Element C.Tw] [DecidableEq C.Tb] [\u2200 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 \u00d7 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) \u03b1) :=\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) \u03b1) :=\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) \u03b1) :\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) \u03b1) :\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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((a3).read i1) \u2260 (((a3).write i2 ((a3).read i1)).read i1) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test11.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5234203489363239, "lm_q2_score": 0.43398146480389854, "lm_q1q2_score": 0.22715472973955356}}
{"text": "import .rules\n\nopen psum nnf node\n\nset_option eqn_compiler.zeta true\n\ndef tableau : \u03a0 \u0393 : sseqt, node \u0393\n| \u0393 := \n  match get_contra_seqt \u0393 with \n  | inl w := contra_rule_seqt w.2\n  | inr no_contra :=\n    match get_and_seqt \u0393 with\n    | inl w := \n    let inst := and_instance_seqt.cons w.2 in\n    have h : prod.measure_lex' sseqt_size (and_child \u0393 w.2) \u0393,\n    begin apply split_lt_and_seqt end,\n    let d_delta := tableau (and_child \u0393 w.2) in\n    and_rule_seqt inst d_delta\n    | inr no_and := \n      match get_or_seqt \u0393 with\n      | inl w := \n      let inst := or_instance_seqt.cons w.2 in \n      have h\u2081 : prod.measure_lex' sseqt_size (or_child_left \u0393 w.2) \u0393,\n      begin apply split_lt_or_seqt_left end,\n      have h\u2082 : prod.measure_lex' sseqt_size (or_child_right \u0393 w.2) \u0393,\n      begin apply split_lt_or_seqt_right end,\n      let \u0393\u2081 := tableau (or_child_left \u0393 w.2) in\n      match \u0393\u2081 with\n      | closed p := or_rule_seqt inst (closed p) (tableau (or_child_right \u0393 w.2))\n      | open_ w := open_rule_seqt inst w.2\n      end\n      | inr no_or := \n        match get_box_seqt \u0393 with\n        | inl w := -- term mode here helps termination \n        if hb : box w.1 \u2208 \u0393.b then\n        let inst := box_dup_instance_seqt.cons w.2 hb in \n        have h : prod.measure_lex' sseqt_size (box_child \u0393 w.2) \u0393,\n        from copy_lt_seqt _ _,\n        let d_delta := tableau (box_child \u0393 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 \u0393 w.2 hb) \u0393,\n        from box_new_lt_seqt _ _ _,\n        let d_delta := tableau (box_child_new \u0393 w.2 hb) in\n        box_new_rule_seqt inst d_delta\n        | inr no_box := \n          match get_dia_seqt \u0393 with\n          | inl w := \n          let ma : modal_applicable \u0393 := \n              {satu := {no_and := no_and, no_or := no_or},\n               no_contra_main := no_contra, \n               no_box_main := no_box,\n               \u03c6 := w.1,\n               ex := w.2} in \n          let l := @dia_rule_seqt (\u03bb \u0394, prod.measure_lex' sseqt_size \u0394 \u0393) \n                   (\u03bb x h, tableau x) (unmodal_seqt \u0393) \n                   (unmodal_seqt_size \u0393) 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 \u0393.h \u0393.b \u0393.m,\n             let m\u0393 : sseqt := \u0393,\n             let mhtk := \u0393.m,\n             have mhhtk : hintikka \u0393.m, {apply hintikka_ma ma},\n             have mmhtk : \u0393.m \u2286 \u0393.m, {simp},\n             split, swap,\n             {let minfo : info := \u27e8m\u0393, mhtk, mhhtk, mmhtk\u27e9,\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 \u27e8i, hmem, hi\u27e9, intros \u03c6 h\u03c6, rw \u2190hi,\n                apply mem_be_box, exact w.2, exact hmem, exact h\u03c6},\n               {simp, intros s hs \u03c6 h\u03c6, exfalso, apply no_box, exact h\u03c6},\n               {simp, intros \u03c6 h\u03c6, \n                by_cases hc : \u03c6 \u2208 \u0393.h,\n                {left, have := mem_loop_left _ \u0393.b _  _ hc h\u03c6, split, split, exact this, simp},\n                {right, have := mem_be_dia _ _ w.2 _ h\u03c6 hc, \n                 rcases this with \u27e8i, hmem, hi\u27e9,\n                 have := list.mem_map_of_mem (\u03bb 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 \u27e8ms, pmsl, pmsr\u27e9, \n                 have hci := be_ex _ _ w.2 _ pmsl,\n                 rcases hci with \u27e8iw, imem, pi\u27e9,\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 \u27e8c, memc, pdc\u27e9, \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 \u27e8ms, pmsl, pmsr\u27e9, \n                  have hci := be_ex _ _ w.2 _ pmsl,\n                  rcases hci with \u27e8iw, imem, pi\u27e9,\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 \u27e8d, ddesc, hd\u27e9,\n                  split, swap, exact d, split,\n                  {apply desc_ex, split, split, exact memc, exact ddesc},\n                  {exact hd}}}},\n               {simp, intros rq hrq \u03c6 h\u03c6, cases h\u03c6, \n                {exfalso, apply ma.no_box_main, exact h\u03c6}, \n                {have := mem_loop_box _ _ _ _ hrq, rw this, exact h\u03c6}},\n               {simp, intros s hs, have := mem_loop_dia _ _ _ _ hs, \n                rcases this with \u27e8w, hmem, hw\u27e9,\n                have := \u0393.ha _ hmem,\n                have sb := mem_loop_box _ _ _ _ hs,\n                cases s, rw \u2190hw at this, rw \u2190sb 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 \u27e8m, memm, mdesc\u27e9, \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 \u0393 := \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 := \u03bb _ _, `[exact \u27e8_, prod.measure_lex_wf' sseqt_size\u27e9], dec_tac := `[assumption]}\n\n@[simp] def mk_sseqt (\u0393 : list nnf) : sseqt :=\n{ goal := \u0393,\n  s := none,\n  a := [],\n  h := [],\n  b := [],\n  m := \u0393,\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 := \u03bb x hx, absurd hx $ list.not_mem_nil _,\n  hb := box_only_nil,\n  ps\u2081 := \u03bb h, by contradiction,\n  ps\u2082 := \u03bb h, by contradiction }\n\ndef is_sat (\u0393 : list nnf) : bool :=\nmatch tableau (mk_sseqt \u0393) with\n| closed _ := ff\n| open_ _ := tt\nend\n\ntheorem model_existence (m : model) (hrt : manc m.1 = []) \n(\u0393 : list nnf) (h : \u0393 \u2286 htk m.1) : \u2203 (st : Type) (k : S4 st) s, sat k s \u0393 := \nbegin\nsplit, swap,\nexact {x : rmodel // x.1 = m.1 \u2228 desc x.1 m.1},\nsplit, swap,\nexact builder m.1,\nsplit, swap,\nsplit,\nleft, swap, exact \u27e8m.1, m.2.1\u27e9,\nsimp,\nintros \u03c6 h\u03c6, apply good_model,\nexact hrt, apply h, exact h\u03c6\nend\n\ntheorem correctness (\u0393 : list nnf) : is_sat \u0393 = tt \u2194 \u2203 (st : Type) (k : S4 st) s, sat k s \u0393 := \nbegin\n  cases h : is_sat \u0393,\n  constructor,\n  {intro, contradiction},\n  {intro hsat, cases eq : tableau (mk_sseqt \u0393), \n   rcases hsat with \u27e8w, k, s, hsat\u27e9,\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 \u0393),\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 \u03c6 : nnf := \nand (box $ or (neg 1) (var 2)) (and (box $ var 1) (dia $ neg 2))\n\n#eval is_sat [\u03c6] -- ff\n\n-- negation of S4\ndef \u03c8 : nnf := and (box (var 1)) (dia (dia (neg 1)))\n\n#eval is_sat [\u03c8] -- ff\n\ndef \u03b3 : nnf := and (and (dia (var 1)) (dia (var 2))) (box (or (neg 1) (neg 2)))\n\n#eval is_sat [\u03b3] -- 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\u2080 u\u2081 u\u2082 u\u2083\nopen predicate nat\n\nlocal infix ` \u2243 `:75 := v_eq\n\nnamespace temporal\n\nnamespace many_to_many\nsection\nopen fairness\nparameters {\u03b1 : Type u} {\u03b2 : Type u\u2080} {\u03b3 : Type u\u2081 }\nparameters {m\u2080 : mch (\u03b3\u00d7\u03b1)} {m\u2081 : mch (\u03b3\u00d7\u03b2)}\nlocal notation `p` := m\u2080.init\nlocal notation `q` := m\u2081.init\nlocal notation `aevt` := m\u2080.evt\nlocal notation `cevt` := m\u2081.evt\nlocal notation `cs\u2080` := m\u2080.cs\nlocal notation `fs\u2080` := m\u2080.fs\nlocal notation `cs\u2081` := m\u2081.cs\nlocal notation `fs\u2081` := m\u2081.fs\nlocal notation `A` := m\u2080.A\nlocal notation `C` := m\u2081.A\nlocal notation `ae`  := m\u2080.event\nlocal notation `ce`  := m\u2081.event\nlocal notation `ce'` := m\u2081.event' (option aevt)\n-- local notation `Next\u2080` := m\u2080.effect\n-- local notation `Next\u2081` := m\u2081.effect\n\n\nparameters (J : pred' (\u03b3\u00d7\u03b1\u00d7\u03b2))\nparameter ref : option aevt \u2192 option cevt \u2192 Prop\nparameter wit : \u03a0 a : aevt, subtype (\u03bb c : cevt, ref a c) \u2192 cpred\n\nopen prod\n\ndef C' (e : cevt) : act (cevt\u00d7\u03b3\u00d7\u03b2) :=\n\u03bb \u27e8sch,s\u27e9 \u27e8_,s'\u27e9, sch = e \u2227 C e s s'\n\n\n-- #check (_ \u00d7 _) \u00d7 _\n-- abbreviation ae' (i : aevt) : event (\u03b3\u00d7\u03b1\u00d7aevt) :=\n-- { p := cs\u2080 i!\u27e8prod.map_right fst\u27e9\n-- , q := fs\u2080 i!\u27e8prod.map_right fst\u27e9\n-- , A := \u03bb s s', s.2.2 = i \u2227 (A i on prod.map_right fst) s s' }\n-- abbreviation ce' (i : cevt) (j : aevt) : event (\u03b3\u00d7\u03b2\u00d7(cevt\u00d7aevt)) :=\n-- { p := cs\u2081 i!\u27e8prod.map_right fst\u27e9\n-- , q := fs\u2081 i!\u27e8prod.map_right fst\u27e9\n-- , A := \u03bb \u27e8o,v,ce,_\u27e9 \u27e8o',v',_,ae'\u27e9, ae' = j \u2227 ce = i \u2227 C i (o,v) (o',v') }\n\nsection specs\n\n-- parameters p q cs\u2080 fs\u2080 cs\u2081 fs\u2081\n\ndef SPEC\u2080.saf' (v : tvar \u03b1) (o : tvar \u03b3) (sch : tvar (option aevt)) : cpred :=\nm\u2080.spec_saf_sch \u2983o,v\u2984 (\u2299sch)\n\ndef SPEC\u2080 (v : tvar \u03b1) (o : tvar \u03b3) : cpred :=\nm\u2080.spec \u2983 o,v \u2984\n\ndef SPEC\u2081 (v : tvar \u03b2) (o : tvar \u03b3) : cpred :=\nm\u2081.spec \u2983 o,v \u2984\n\ndef SPEC\u2082 (v : tvar \u03b2) (o : tvar \u03b3) (s : tvar (option cevt)) : cpred :=\nm\u2081.spec_sch \u2983o,v\u2984 s\n\nend specs\n\nparameters [inh_cevt : inhabited cevt]\n           [inh_aevt : inhabited aevt]\n\n-- parameter Hc2a : \u2200 ce : cevt, \u2203 ae : aevt, ref ae ce\n\n-- parameter init_J\u2090 : \u2200 w o, (o,w) \u22a8 p \u2192 (o,w) \u22a8 J\u2090\n-- parameter evt_J\u2090  : \u2200 w o w' o' e,\n--                           (o,w) \u22a8 J\u2090 \u2192\n--                           (o,w) \u22a8 cs\u2080 e \u2192\n--                           (o,w) \u22a8 fs\u2080 e \u2192\n--                           A e (o,w) (o',w') \u2192\n--                           (o',w') \u22a8 J\u2090\n\nstructure refinement :=\n  (SIM\u2080 : \u2200 v o, (o,v) \u22a8 q \u2192 \u2203 w, (o,w) \u22a8 p \u2227 (o,w,v) \u22a8 J)\n  (SIM : \u2200 cev w v o v' o',\n    (o,w,v) \u22a8 J \u2192\n    m\u2081.effect cev (o,v) (o',v') \u2192\n    \u2203 aev w', ref aev cev \u2227\n             m\u2080.effect aev (o,w) (o',w') \u2227\n             (o',w',v') \u22a8 J )\n  (ANIM : \u2200 (e : aevt) (sch : tvar (option aevt)) (o v w),\n    many_to_many_po'\n      (subtype _)\n      (SPEC\u2081 v o \u22c0 SPEC\u2080.saf' w o sch \u22c0 \u25fb(J ! \u2983o,w,v\u2984))\n      (wit e)\n      (\u03bb e', ce e') (ae e)\n      \u2983o,v\u2984 \u2983o,w\u2984)\n\nsection obligations\n\nparameters (v : tvar \u03b2) (o : tvar \u03b3)\nparameters (\u0393 : cpred)\n\nparameter Href : refinement\n\nparameters \u03b2 \u03b3\nparameters {\u03b2 \u03b3}\n\nsection conc_sch\n\nparameters (sch_c : tvar (option cevt))\n\nvariable (sch_a : tvar (option aevt))\n\nsection SPEC\u2082\nvariable H : \u0393 \u22a2 SPEC\u2082 v o sch_c\n\nopen prod temporal.prod\n\n-- def Next_a : act $ \u03b3 \u00d7 aevt \u00d7 \u03b1 :=\n-- \u03bb \u03c3 \u03c3',\n-- \u2203 e, \u03c3.2.1 = e \u2227\n--       map_right snd \u03c3 \u22a8 cs\u2080 e \u2227\n--       map_right snd \u03c3 \u22a8 fs\u2080 e \u2227\n--       (A e on map_right snd) \u03c3 \u03c3'\n\n-- def Next_c : act $ \u03b3 \u00d7 cevt \u00d7 \u03b2 :=\n-- \u03bb \u03c3 \u03c3',\n-- \u2203 e, \u03c3.2.1 = e \u2227\n--       map_right snd \u03c3 \u22a8 cs\u2081 e \u2227\n--       map_right snd \u03c3 \u22a8 fs\u2081 e \u2227\n--       (C e on map_right snd) \u03c3 \u03c3'\n\nsection J\ndef J' : pred' (\u03b3 \u00d7 (aevt \u00d7 \u03b1) \u00d7 (cevt \u00d7 \u03b2)) :=\nJ ! \u27e8 prod.map_right $ prod.map prod.snd prod.snd \u27e9 \u22c0\n\u27e8 \u03bb \u27e8_, a, c\u27e9, ref a.1 c.1 \u27e9\n\n-- def JJ\u2090 : pred' (\u03b3 \u00d7 aevt \u00d7 \u03b1) :=\n-- J\u2090 ! \u27e8 prod.map_right snd \u27e9\n\ndef p' : pred' (\u03b3 \u00d7 aevt \u00d7 \u03b1) :=\np ! \u27e8prod.map_right prod.snd\u27e9\n\ndef q' : pred' (\u03b3 \u00d7 cevt \u00d7 \u03b2) :=\nq ! \u27e8prod.map_right prod.snd\u27e9\n\nend J\nvariable w : tvar \u03b1\nopen function\ninclude inh_aevt\n-- def Wx\u2080_f : tvar (\u03b2 \u2192 \u03b3 \u2192 aevt \u00d7 \u03b1 \u2192 Prop) :=\n-- \u03bb v o (w : aevt \u00d7 _), (o,w.2) \u22a8 p \u2227 (o,w.2,v) \u22a8 J\n\n-- @[simp]\n-- def Wx\u2080 : tvar (option aevt \u00d7 \u03b1 \u2192 Prop) :=\n-- [| v o , \u03bb (w : option aevt \u00d7 _), (o,w.2) \u22a8 p |]\n\n-- def Wf_f : tvar (option cevt \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b3 \u2192 option aevt \u00d7 \u03b1 \u2192 option aevt \u00d7 \u03b1 \u2192 Prop) :=\n-- \u27ea\u2115, \u03bb ce v' o o' (w : _ \u00d7 _) (w' : option aevt \u00d7 \u03b1),\n--              (o',w'.2,v') \u22a8 J \u2227\n--              ref w'.1 ce \u2227\n--              -- (o,w.2) \u22a8 cs\u2080 w'.1 \u2227\n--              -- (o,w.2) \u22a8 fs\u2080 w'.1 \u2227\n--              m\u2080.effect w'.1 (o,w.2) (o',w'.2) \u27eb\n--              -- A w'.1 (o,w.2) (o',w'.2) \u27eb\n\n-- @[simp]\n-- def Wf : tvar (option aevt \u00d7 \u03b1 \u2192 option aevt \u00d7 \u03b1 \u2192 Prop) :=\n-- \u27ea\u2115, \u03bb (cev : option cevt) o o' (w w' : option aevt \u00d7 \u03b1),\n--              ref w'.1 cev \u2227\n--              -- (o,w.2) \u22a8 cs\u2080 w'.1 \u2227\n--              -- (o,w.2) \u22a8 fs\u2080 w'.1 \u2227\n--              m\u2080.effect w'.1 (o,w.2) (o',w'.2) \u27eb\n--  sch_c o (\u2299o)\n\n-- lemma Wx\u2080_def' (\u03c3 : \u2115)\n-- : \u03c3 \u22a8 Wx\u2080 =\n--   \u03b5 w : _ \u00d7 \u03b1, (\u03c3 \u22a8 o,w.2) \u22a8 p \u2227 (\u03c3 \u22a8 o,w.2,\u03c3 \u22a8 v) \u22a8 J :=\n-- by repeat { unfold_coes <|> simp [Wx\u2080,Wx\u2080_f] }\n\n-- @[simp,predicate]\n-- lemma Wx\u2080_def (\u03c3 : \u2115) (a b)\n-- : (a,b) = \u03c3 \u22a8 Wx\u2080 \u2194\n--   a = (\u03b5 w : _ \u00d7 \u03b1,    (\u03c3 \u22a8 o,w.2) \u22a8 p \u2227 (\u03c3 \u22a8 o,w.2,\u03c3 \u22a8 v) \u22a8 J).fst \u2227\n--   b = (\u03b5 w : aevt \u00d7 \u03b1, (\u03c3 \u22a8 o,w.2) \u22a8 p \u2227 (\u03c3 \u22a8 o,w.2,\u03c3 \u22a8 v) \u22a8 J).snd :=\n-- by repeat { unfold_coes <|> simp [Wx\u2080,Wx\u2080_f,ext] }\n\n-- lemma Wf_def' (\u03c3 : \u2115) (w)\n-- : \u03c3 \u22a8 Wf \u2983sch_a,w\u2984 =\n--   \u03b5 w' : _ \u00d7 \u03b1,\n--          (succ \u03c3 \u22a8 o,w'.2,succ \u03c3 \u22a8 v) \u22a8 J \u2227\n--                ref w'.1 (\u03c3 \u22a8 sch_c) \u2227\n--                (\u03c3 \u22a8 o,\u03c3 \u22a8 w) \u22a8 cs\u2080 w'.1 \u2227\n--                (\u03c3 \u22a8 o,\u03c3 \u22a8 w) \u22a8 fs\u2080 w'.1 \u2227\n--                A w'.1 (\u03c3 \u22a8 o,\u03c3 \u22a8 w) (succ \u03c3 \u22a8 o,w'.2) :=\n-- by repeat { unfold_coes <|> simp [Wf,Wf_f] }\n\n\n-- @[simp,predicate]\n-- lemma Wf_def (\u03c3 : \u2115) (sch_a w) (a b)\n-- : (a,b) = (\u03c3 \u22a8 Wf) (sch_a,w) \u2194\n--   a = (\u03b5 w' : _ \u00d7 \u03b1,\n--          (succ \u03c3 \u22a8 o,w'.2,succ \u03c3 \u22a8 v) \u22a8 J \u2227\n--                ref w'.1 (\u03c3 \u22a8 sch_c) \u2227\n--                (\u03c3 \u22a8 o,w) \u22a8 cs\u2080 w'.1 \u2227\n--                (\u03c3 \u22a8 o,w) \u22a8 fs\u2080 w'.1 \u2227\n--                A w'.1 (\u03c3 \u22a8 o,w) (succ \u03c3 \u22a8 o,w'.2)).1 \u2227\n--   b = (\u03b5 w' : aevt \u00d7 \u03b1,\n--          (succ \u03c3 \u22a8 o,w'.2,succ \u03c3 \u22a8 v) \u22a8 J \u2227\n--                ref w'.1 (\u03c3 \u22a8 sch_c) \u2227\n--                (\u03c3 \u22a8 o,w) \u22a8 cs\u2080 w'.1 \u2227\n--                (\u03c3 \u22a8 o,w) \u22a8 fs\u2080 w'.1 \u2227\n--                A w'.1 (\u03c3 \u22a8 o,w) (succ \u03c3 \u22a8 o,w'.2)).2 :=\n-- by repeat { unfold_coes <|> simp [Wf,Wf_f,ext] }\n\n-- variable valid_witness\n-- : \u0393 \u22a2 Wtn \u2983sch_a,w\u2984\n\n-- lemma abstract_sch (e : aevt)\n-- : \u0393 \u22a2 sch_a \u2243 e \u22c0 cs\u2080 e ! \u2983o,w\u2984 \u22c0 fs\u2080 e ! \u2983o,w\u2984 \u22c0 \u27e6 o,w | A e \u27e7 \u2261\n--       sch_a \u2243 e \u22c0 \u27e6 o,sch_a,w | Next_a \u27e7 :=\n-- begin\n--   lifted_pred [Next_a,on_fun],\n--   split ; intro h ; split\n--   ; casesm* _ \u2227 _ ; subst e ; tauto,\n-- end\n\nsection Simulation_POs\n-- include SIM\u2080 Hc2a\n-- lemma SIM\u2080' (v : cevt \u00d7 \u03b2) (o : \u03b3)\n--   (h : (o, v) \u22a8 q')\n-- : (\u2203 (w : aevt \u00d7 \u03b1), (o, w) \u22a8 p' \u2227 (o, w, v) \u22a8 J') :=\n-- begin\n--   simp [q',prod.map_left] at h,\n--   specialize SIM\u2080 v.2 o h,\n--   specialize Hc2a v.1,\n--   revert SIM\u2080, intros_mono,\n--   simp [J',p',map], intros,\n--   cases Hc2a,\n--   constructor_matching* [Exists _, _ \u2227 _] ;\n--   tauto,\n-- end\n\n-- omit SIM\u2080\n-- include SIM\n-- lemma SIM' (w : aevt \u00d7 \u03b1) (v : cevt \u00d7 \u03b2) (o : \u03b3) (v' : cevt \u00d7 \u03b2) (o' : \u03b3)\n--   (h\u2080 : (o, w, v) \u22a8 J')\n--   (h\u2081 : Next_c (o, v) (o', v'))\n-- : (\u2203 w', Next_a (o,w) (o',w') \u2227 (o', w', v') \u22a8 J') :=\n-- begin\n--   simp [J',map] at h\u2080,\n--   simp [Next_c,on_fun] at h\u2081,\n--   cases h\u2080,\n--   specialize SIM w.2 v.2 o v'.2 o' v.1 w.1 h\u2080_right h\u2080_left h\u2081,\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\u2080_right],\n--   tauto,\n-- end\n\n-- include H\n-- omit SIM\n-- lemma H'\n-- : \u0393 \u22a2 simulation.SPEC\u2081 q' Next_c \u2983v,sch_c\u2984 o :=\n-- begin [temporal]\n--   simp [SPEC\u2082,simulation.SPEC\u2081,q'] at H \u22a2,\n--   split, tauto,\n--   casesm* _ \u22c0 _,\n--   persistent,\n--   select h : \u25fbp_exists _,\n--   henceforth at h \u22a2,\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 \u2192 option cevt \u2192 Prop) :=\nref\n\n@[simp]\ndef Next\u2080 : act (\u03b3 \u00d7 \u03b1 \u00d7 option aevt) :=\n\u03bb \u27e8o,w,sch_a\u27e9 \u27e8o',w',_\u27e9, \u2203 e, sch_a = e \u2227 m\u2080.effect e (o,w) (o',w')\n\n-- include valid_witness -- init_J\u2090 evt_J\u2090\ninclude H Href\n-- set_option pp.implicit true\n\nlemma J_inv_in_w'\n: \u0393 \u22a2 \u2203\u2203 w, \u25fb(J ! \u2983o,w,v\u2984) \u22c0 SPEC\u2080.saf' w o sch_a :=\nbegin [temporal]\n  -- select_witness w : temporal.many_to_many.Wtn w\n  --   with Hw using J ! \u2983o,w.snd,v\u2984,\n  unfold SPEC\u2082 mch.spec_sch at H, casesm* _ \u22c0 _,\n\n  select_witness w : m\u2080.init ! \u2983o,w\u2984 \u22c0 \u25fb \u27e6 o,w,sch_a | temporal.many_to_many.Next\u2080 \u27e7\n    -- with h\u2080 h\u2081\n    using (J ! \u2983o,w,v\u2984)\n  { ext, admit, -- simp_coe [to_fun_var'],\n    -- simp only with lifted_fn,\n    -- congr, funext, transitivity, apply to_fun_var'_lift\u2082,\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\u2080, assumption },\n  -- simp [SPEC\u2082] at H,\n  -- rw henceforth_next_intro,\n  -- dsimp [SPEC\u2080.saf'],\n  -- -- cases valid_witness with h\u2080 h\u2080,\n  -- casesm* _ \u22c0 _,\n  -- intros,\n  -- t_induction,\n  -- { -- select Hw : _ \u2243 temporal.many_to_many.Wx\u2080,\n  --   select Hq : q ! _,\n  --   have SIM\u2080 := Href.SIM\u2080,\n  --   explicit' with SIM\u2080 Hq\n  --   { {  },\n  --     simp, tauto, } },\n  { select H\u2080 : p_exists _,\n    -- henceforth! at h\u2080_1 H\u2080 \u22a2,\n    explicit' [Next\u2080] with H\u2080\n    { intros h hJ,\n      -- casesm* [_ \u2227 _,Exists _],\n      -- type_check cs\u2080,\n      -- have : (o', h', v') \u22a8 J \u2227\n      --        (o,w) \u22a8 cs\u2080 sch_a' \u2227 (o,w) \u22a8 fs\u2080 sch_a' \u2227\n      --        A sch_a' (o, w) (o', w'),\n      -- { subst H\u2080_w, subst w', subst sch_a',\n      --   apply_epsilon_spec,\n      --   simp,\n      --   apply SIM ; solve_by_elim },\n      -- split, tauto,\n      -- casesm* _ \u2227 _,\n      -- apply evt_J\u2090 ; apply hJ\u2090 <|> solve_by_elim\n      } },\nend\n\n-- lemma J_inv_in_w\n-- : \u0393 \u22a2 \u25fb(J ! \u2983o,w,v\u2984) :=\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-- : \u0393 \u22a2 \u25fb(J\u2090 ! \u2983o,w\u2984) :=\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\u2080_saf\n: \u0393 \u22a2 SPEC\u2080.saf' w o sch_a :=\nbegin [temporal]\n  simp [SPEC\u2080.saf',Wtn] at \u22a2 valid_witness,\n  cases valid_witness with H\u2080 H\u2081,\n  split,\n  explicit' with H\u2080\n  { tauto, },\n  henceforth!,\n  explicit' with H\u2081\n  { tauto, },\nend\n\nomit H\nparameters m\u2080 m\u2081\ninclude Href\nomit valid_witness\n\nlemma SPEC\u2082_imp_SPEC\u2081\n: (SPEC\u2082 v o sch_c) \u27f9 (SPEC\u2081 v o) :=\nbegin [temporal]\n  simp only [SPEC\u2081,SPEC\u2082,temporal.many_to_many.SPEC\u2081,temporal.many_to_many.SPEC\u2082],\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\u2080 h\u2081,\n    replace h := h _ h\u2080 h\u2081,\n    revert h, monotonicity, simp, }\nend\n\nsection\nomit Href\ninclude valid_witness \u0393 H\n-- #check w\n-- noncomputable def sch_w : tvar aevt :=\n-- \u27ea \u2115, \u03bb (w w' : \u03b1), \u03b5 ae, A ae w w' \u27eb w (\u2299w)\n\n-- lemma sch_w_spec\n-- : \u0393 \u22a2 \u25fb(ref' (\u2299sch_a) sch_c) :=\n-- begin [temporal]\n--   have hJ  := temporal.many_to_many.J_inv_in_w _ H _ valid_witness,\n--   have hJ\u2090 := temporal.many_to_many.abs_J_inv_in_w _ H _ valid_witness,\n--   simp [Wtn,SPEC\u2082] at valid_witness H,\n--   cases valid_witness with Hw' Hw,\n--   cases H with H H\u2080,\n--   cases H with H\u2081 H\u2082,\n--   henceforth! at Hw \u22a2 hJ hJ\u2090 H\u2082,\n--   explicit' with Hw hJ hJ\u2090 H\u2082\n--   { cases Hw, subst sch_a', casesm* [_\u2227_,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: \u0393 \u22a2 \u25fb(sch_c \u2243 \u2191e \u27f6 \u2299sch_a \u2243 \u2191e' \u27f6\n        \u27e6 o,v | Next\u2081 e \u27e7 \u27f6\n        \u27e6 o,w | Next\u2080 e' \u27e7) :=\nbegin [temporal]\n  have hJ := temporal.many_to_many.J_inv_in_w sch_a H w valid_witness,\n  have hJ\u2090 := 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\u2080 h\u2081,\n  cases H with H H\u2080,\n  cases H with H\u2081 H\u2082,\n  clear_except hJ hJ\u2090 SIM h\u2081 H\u2082,\n  henceforth! at *,\n  explicit' with hJ hJ\u2090 SIM h\u2081 H\u2082\n  { intros, cases h\u2081, subst w', subst sch_c,\n    subst sch_a', substs e',\n    casesm* [_ \u2227 _, 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\u2082 v o sch_c \u22c0 Wtn \u2983sch_a,w\u2984 \u22c0 \u25fb(J ! \u2983o,w,v\u2984))\n     (wit e)\n     (\u03bb i, ce' i e) (ae e)\n     \u2983\u2983o,v\u2984,sch_c,sch_a\u2984 \u2983o,w\u2984\n:=\nbegin\n  have\n  : temporal.many_to_many.SPEC\u2082 v o sch_c \u22c0 temporal.many_to_many.Wtn \u2983sch_a,w\u2984 \u22c0\n      \u25fb(J ! \u2983o,w,v\u2984) \u27f9\n    temporal.many_to_many.SPEC\u2081 v o \u22c0 temporal.many_to_many.SPEC\u2080.saf' w o sch_a \u22c0\n      \u25fb(J ! \u2983o,w,v\u2984),\n  begin [temporal]\n    simp, intros h\u2080 h\u2081 h\u2082, split*,\n    { apply temporal.many_to_many.SPEC\u2082_imp_SPEC\u2081 _ _ ; try { solve_by_elim }, },\n    { apply temporal.many_to_many.witness_imp_SPEC\u2080_saf _ h\u2080 _ h\u2081, },\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* _ \u22c0 _,\n    select Hw : temporal.many_to_many.Wtn _,\n    select hJ : \u25fb(J ! _),\n    select H  : temporal.many_to_many.SPEC\u2082 _ _ _,\n    have := temporal.many_to_many.H_C_imp_A _ H w Hw _ e x.2,\n    cases H with H H\u2080,\n    cases H with H\u2081 H\u2082,\n    clear_except this Href SIM\u2080 SIM Hw hJ H\u2082,\n    simp [Wtn] at Hw, cases Hw with Hw' Hw,\n    henceforth! at \u22a2 Hw hJ H\u2082 this,\n    explicit' [mch.event'] with this Hw hJ H\u2082\n    { dsimp [ce',mch.event'], cases Hw,\n      intros,\n      casesm* [_ \u2227 _, 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 \u00d7 \u03b1))\n (hJ : \u0393 \u22a2 \u25fb(J ! \u2983o,w,v\u2984))\n (Hw : \u0393 \u22a2 Wtn \u2983sch_a,w\u2984)\n (h : \u0393 \u22a2 \u2200\u2200 j : cevt, ref \u2191i \u2191j \u27f6 sched (cs\u2081 j ! \u2983o,v\u2984) (fs\u2081 j ! \u2983o,v\u2984) (sch_c \u2243 some j \u22c0 \u27e6 o,v | C j \u27e7))\n: \u0393 \u22a2 sched (cs\u2080 i ! \u2983o,w\u2984) (fs\u2080 i ! \u2983o,w\u2984) \u27e6 o,w | A i \u27e7 :=\nbegin [temporal]\n  -- have hJ : \u25fb(J ! \u2983o,w,v\u2984),\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\u2082_imp_SPEC\u2081 _ ; assumption,\n    apply temporal.many_to_many.witness_imp_SPEC\u2080_saf ; assumption,\n    assumption },\n  intro cev, cases cev with cev Hce,\n  simp only, intros H\u2080 H\u2081,\n  replace h := h cev Hce H\u2080 H\u2081,\n  revert h,\n  monotonicity!,\n  explicit'\n  { intros, tauto },\nend\n\n/-\n  This proof works as:\n  Init\u2082 \u21d2 Init\u2080\n  Saf\u2082  \u21d2 Saf\u2080\n  Spec\u2082 \u21d2 Live\u2080\n -/\nlemma many_to_many\n: \u0393 \u22a2 \u2203\u2203 w, SPEC\u2080 w o :=\nbegin [temporal]\n  apply p_exists_partial_intro _ (proj $ @pair.snd (option aevt) \u03b1) _ _,\n  -- replace H := H.left,\n  cases H.left with H\u2080 H\u2081,\n  select_witness w : temporal.many_to_many.Wtn w\n    with Hw using J ! \u2983o,w.snd,v\u2984,\n  explicit' [Wx\u2080] with H\u2080\n  { apply Href.SIM\u2080 _ _ H\u2080, },\n  explicit' [Wf] with H\u2081\n  { simp_intros b hJ [and_assoc],\n    have := Href.SIM _ _ _ _ _ _ hJ H\u2081,\n    tauto, }, -- a \u2227 a \u2194 a\n  existsi w,\n  { apply m\u2080.spec_of_spec_saf_sch _ (\u2299w.fst),\n    apply temporal.many_to_many.witness_imp_SPEC\u2080_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\u2082\nend conc_sch\n\nsection refinement_SPEC\u2082\ninclude Href wit inh_aevt\nparameters m\u2080 m\u2081\n\nlemma refinement_SPEC\u2082\n: \u0393 \u22a2 (\u2203\u2203 sch_c, SPEC\u2082 v o sch_c) \u27f6 (\u2203\u2203 a, SPEC\u2080 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\u2082\n\nopen nat function set scheduling\ninclude inh_cevt\n\nvariables [encodable cevt]\n\nlemma refinement_SPEC\u2081\n: SPEC\u2081 v o \u27f9 (\u2203\u2203 sch, SPEC\u2082 v o sch) :=\nassume \u0393,\nsch_intro _ _ _\n\nend obligations\nopen function\ninclude J wit inh_cevt inh_aevt\n\nlemma refinement' {o : tvar \u03b3} [encodable cevt]\n  (h : refinement)\n: (\u2203\u2203 c, SPEC\u2081 c o) \u27f9 (\u2203\u2203 a, SPEC\u2080 a o) :=\nbegin [temporal]\n  transitivity (\u2203\u2203 c (sch : tvar (option cevt)), SPEC\u2082 c o sch),\n  { apply p_exists_p_imp_p_exists ,\n    intro v,\n    apply temporal.many_to_many.refinement_SPEC\u2081, },\n  { simp, intros c sch Hspec,\n    apply temporal.many_to_many.refinement_SPEC\u2082 c o \u0393 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 \u2192 Type v) : Type (max (u+1) v) where\n    fmap : (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2\n    map_const : \u03b1 \u2192 f \u03b2 \u2192 f \u03b1 := fmap \u2218 (Function.const \u03b2)\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 {\u03b1 \u03b2 : Type u} {f : Type u \u2192 Type v} [Functor f] : f \u03b2 \u2192 \u03b1 \u2192 f \u03b1 := flip map_const\n    infixr:90 \" $> \" => Monads.Functor.const_map\n    def void {\u03b1 : Type} {f : Type \u2192 Type} [Functor f] : f \u03b1 \u2192 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 \u2192 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 : \u2200 (x : f \u03b1), 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 : \u2200 (g : \u03b1 \u2192 \u03b2) (h : \u03b2 \u2192 \u03b3) (x : f \u03b1), (h \u2218 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: \u2200 (x : \u03b1) (y : f \u03b2), x <$ y = (fmap \u2218 (Function.const \u03b2)) x y\n\n  namespace LawfulFunctor\n    variable {f : Type u \u2192 Type v} [Functor f] [LawfulFunctor f]\n\n    example {g : \u03b1 \u2192 \u03b2} {x : f \u03b1} : g <$> (id <$> x) = g <$> x := by\n      rw [fmap_id]\n\n    example {g : \u03b1 \u2192 \u03b2} {x : f \u03b1} : 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": "example (n : \u2115) : \u2115 := \u2039\u2115\u203a\n", "meta": {"author": "Ailrun", "repo": "Theorem_Proving_in_Lean", "sha": "2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68", "save_path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean", "path": "github-repos/lean/Ailrun-Theorem_Proving_in_Lean/Theorem_Proving_in_Lean-2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68/src/ch4/ex0505.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": "-- 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 \u2192 \n      \u2203 (f x: var) (R S: spec) (e: exp) (\u03c3: env), v = value.func f x R S e \u03c3 :=\n  assume isFunc_is_true: unop.apply unop.isFunc v = value.true,\n  begin\n    cases v with n f x R S e \u03c3,\n\n    show \u2203 (f x: var) (R S: spec) (e: exp) (\u03c3: env), value.true = value.func f x R S e \u03c3, 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 \u2203 (f x: var) (R S: spec) (e: exp) (\u03c3: env), value.false = value.func f x R S e \u03c3, 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 \u2203 (f x: var) (R S: spec) (e: exp) (\u03c3: env), value.num n = value.func f x R S e \u03c3, 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 \u2203 (f_1 x_1: var) (R_1 S_1: spec) (e_1: exp) (\u03c3_1: env),\n        value.func f x R S e \u03c3 = value.func f_1 x_1 R_1 S_1 e_1 \u03c3_1, from (\n      exists.intro f (exists.intro x (exists.intro R (exists.intro S\n                     (exists.intro e (exists.intro \u03c3 rfl)))))\n    )\n  end\n\nlemma unop.isBool.inv {v: value}: unop.apply unop.isBool v = value.true \u2192 (v = value.true) \u2228 (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 \u03c3,\n\n    show ((value.true = value.true) \u2228 (value.true = value.false)), from (\n      or.inl rfl\n    ),\n\n    show ((value.false = value.true) \u2228 (value.false = value.false)), from (\n      or.inr rfl\n    ),\n\n    show (value.num n = value.true \u2228 (value.num n = value.false)), from (\n      have h1: unop.apply unop.isBool (value.num n) = \u2191value.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 \u03c3 = value.true \u2228 (value.func f x R S e \u03c3 = value.false)), from (\n      have h1: unop.apply unop.isBool (value.func f x R S e \u03c3) = \u2191value.true, from isBool_is_true,\n      have h2: (unop.apply unop.isBool (value.func f x R S e \u03c3) = 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\u2081 v\u2082: value}: binop.apply binop.eq v\u2081 v\u2082 = value.true \u2192 (v\u2081 = v\u2082) :=\n  assume eq_is_true: binop.apply binop.eq v\u2081 v\u2082 = value.true,\n  begin\n    by_cases (v\u2081 = v\u2082),\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 \u27f9* s' \u2192 (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\u2081 s\u2082 s\u2083 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) \u2192 (vy = value.true) \u2228 (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) \u2192 ((vz = value.true) \u2228 (vz = value.false) \u2228 (\u2203n, 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 \u27f6 s') \u2192 \u2200d, stack_equiv_dstack s d \u2192 \u2203d', (d \u27f9 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 (\u03c3[x\u21a6value.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 (\u03c3[x\u21a6value.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 (\u03c3[x\u21a6value.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 (\u03c3[f\u21a6value.func f x R S e\u2081 \u03c3]) e\u2082),\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 (\u03c3[y\u21a6v]) 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 (\u03c3[z\u21a6v]) 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, (\u03c3'[g\u21a6value.func g z R S e \u03c3'][z\u21a6v]), e) R_1 \u03c3 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 \u03c3 e\u2081),\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 \u03c3 e\u2082),\n      apply dstep.ite_false a\n    },\n\n    case step.ctx s\u2081 s\u2082 \u03c3\u2081 f x y e\u2081 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 \u03c3\u2081 y f x e\u2081),\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 (\u03c3\u2082[y\u21a6v]) 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 \u27f9 d') \u2192 \u2200s, stack_equiv_dstack s d \u2192 \u2203s', (s \u27f6 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 (\u03c3[x\u21a6value.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 (\u03c3[x\u21a6value.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 (\u03c3[x\u21a6value.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 (\u03c3[f\u21a6value.func f x R S e\u2081 \u03c3]) e\u2082),\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 (\u03c3[y\u21a6v]) 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 (\u03c3[z\u21a6v]) 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 ((\u03c3'[g\u21a6value.func g z R S e \u03c3'][z\u21a6v]), e) \u03c3 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 \u03c3 e\u2081),\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 \u03c3 e\u2082),\n      apply step.ite_false a\n    },\n\n    case dstep.ctx d\u2081 d\u2082 R \u03c3\u2081 f x y e\u2081 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'' \u03c3\u2081 y f x e\u2081),\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 (\u03c3\u2082[y\u21a6v]) 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      \u2200{s': stack} {d d': dstack},\n      stack_equiv_dstack s d \u2192 (s \u27f6 s') \u2192 (d \u27f9 d') \u2192 stack_equiv_dstack s' d' :=\n  begin\n    induction s,\n\n    case stack.top \u03c3 e {\n      assume s' d d',\n      assume h1,\n      assume h2,\n      assume h3,\n      cases h1,\n      have h4: (dstack.top R \u03c3 e \u27f9 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\u2081 = v\u2081_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\u2081 = v\u2081_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\u2082 = v\u2082_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 \u03c3') = (value.func g_1 z_1 R_2 S_1 e \u03c3'_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'' \u03c3'' 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 \u27f9* d') \u2192 \u2200s, stack_equiv_dstack s d \u2192 \u2203s', (s \u27f6* s') \u2227 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 \u27f6* s') \u2192 \u2200d, stack_equiv_dstack s d \u2192 \u2203d', (d \u27f9* d') \u2227 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: \u2203 (d' : dstack), s_2\u27f9d', 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\u2081 R\u2082: spec} {\u03c3\u2081 \u03c3\u2082: env} {e\u2081 e\u2082: exp}: (R\u2081, \u03c3\u2081, e\u2081) \u27f9* (R\u2082, \u03c3\u2082, e\u2082) \u2192 ((\u03c3\u2081, e\u2081) \u27f6* (\u03c3\u2082, e\u2082)) :=\n  begin\n    assume h1,\n    have h2: stack_equiv_dstack (\u03c3\u2081, e\u2081) (R\u2081, \u03c3\u2081, e\u2081), from stack_equiv_dstack.top,\n    have h3, from step_of_dstep_trans h1 (\u03c3\u2081, e\u2081) 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 \u2192 (is_dvalue d \u2228 \u2203d', d \u27f9 d') \u2192 (is_value s \u2228 \u2203s', s \u27f6 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 \u03c3 h5,\n    cases h5 with x h6,\n    cases h6 with v h7,\n    left,\n    unfold is_value,\n    existsi \u03c3,\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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((a3).write i1 (((a3).write i2 ((a3).read i1)).read i1)) \u2260 (a3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test79.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.44939263446475963, "lm_q1q2_score": 0.2264517214971119}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v2) \u2260 ((((a2).write i2 (v2)).write i3 (v2)).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test65.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.22624518377989256}}
{"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 \u2190\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 \u2192 Waiter\n  | root         : Waiter\n\ndef Waiter.isRoot : Waiter \u2192 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.<idx>`. 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 (\u2190 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! (\u2190 normLevel v)\n    | Level.max v w     => return u.updateMax! (\u2190 normLevel v) (\u2190 normLevel w)\n    | Level.imax v w    => return u.updateIMax! (\u2190 normLevel v) (\u2190 normLevel w)\n    | Level.mvar mvarId =>\n      if (\u2190 getMCtx).getLevelDepth mvarId != (\u2190 getMCtx).depth then\n        return u\n      else\n        let s \u2190 get\n        match (\u2190 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! (\u2190 us.mapM normLevel)\n    | Expr.sort u          => return e.updateSort! (\u2190 normLevel u)\n    | Expr.app f a         => return e.updateApp! (\u2190 normExpr f) (\u2190 normExpr a)\n    | Expr.letE _ t v b _  => return e.updateLet! (\u2190 normExpr t) (\u2190 normExpr v) (\u2190 normExpr b)\n    | Expr.forallE _ d b _ => return e.updateForallE! (\u2190 normExpr d) (\u2190 normExpr b)\n    | Expr.lam _ d b _     => return e.updateLambdaE! (\u2190 normExpr d) (\u2190 normExpr b)\n    | Expr.mdata _ b       => return e.updateMData! (\u2190 normExpr b)\n    | Expr.proj _ _ b      => return e.updateProj! (\u2190 normExpr b)\n    | Expr.mvar mvarId     =>\n      if !(\u2190 mvarId.isAssignable) then\n        return e\n      else\n        let s \u2190 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 := (\u2190 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 \u00d7 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 (\u2190 read).maxHeartbeats\n\n@[inline] def mapMetaM (f : forall {\u03b1}, MetaM \u03b1 \u2192 MetaM \u03b1) {\u03b1} : SynthM \u03b1 \u2192 SynthM \u03b1 :=\n  monadMap @f\n\ninstance : Inhabited (SynthM \u03b1) 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 \u2190 getLocalInstances\n  forallTelescopeReducing type fun _ type => do\n    let className? \u2190 isClass? type\n    match className? with\n    | none   => throwError \"type class instance expected{indentExpr type}\"\n    | some className =>\n      let globalInstances \u2190 getGlobalInstancesIndex\n      let result \u2190 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\u2081 e\u2082 => e\u2081.priority < e\u2082.priority\n      let erasedInstances \u2190 getErasedInstances\n      let result \u2190 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! (\u2190 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  \u2190 inferType mvar\n  let mvarType  \u2190 instantiateMVars mvarType\n  let instances \u2190 getInstances mvarType\n  if instances.isEmpty then\n    return none\n  else\n    let mctx \u2190 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 (\u2190 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 (\u2190 get).tableEntries.find? key\n\ndef getEntry (key : Expr) : SynthM TableEntry := do\n  match (\u2190 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 \u2190 inferType mvar\n    let mvarType \u2190 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 \u2192 Nat \u2192 List Expr \u2192 Expr \u2192 Expr \u2192 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 \u2190 mkForallFVars xs d\n    let mvar     \u2190 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 \u2190 whnf type\n    if type.isForall then\n      getSubgoalsAux lctx localInsts xs args args.size subgoals instVal type\n    else\n      return \u27e8subgoals, instVal, type\u27e9\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 \u2190 inferType inst\n  let result \u2190 getSubgoalsAux lctx localInsts xs #[] 0 [] inst instType\n  if let .const constName _ := inst.getAppFn then\n    let env \u2190 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 \u00d7 List Expr)) := do\n  let mvarType   \u2190 inferType mvar\n  let lctx       \u2190 getLCtx\n  let localInsts \u2190 getLocalInstances\n  forallTelescopeReducing mvarType fun xs mvarTypeBody => do\n    let \u27e8subgoals, instVal, instTypeBody\u27e9 \u2190 getSubgoals lctx localInsts xs inst\n    withTraceNode `Meta.synthInstance.tryResolve (withMCtx (\u2190 getMCtx) do\n        return m!\"{exceptOptionEmoji \u00b7} {\u2190 instantiateMVars mvarTypeBody} \u225f {\u2190 instantiateMVars instTypeBody}\") do\n    if (\u2190 isDefEq mvarTypeBody instTypeBody) then\n      let instVal \u2190 mkLambdaFVars xs instVal\n      if (\u2190 isDefEq mvar instVal) then\n        return some ((\u2190 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) \u2190 openAbstractMVarsResult answer.result\n    if (\u2190 isDefEq mvar val) then\n      return some (\u2190 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 \u2192 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) \u2190 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 \u2190 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 \u2190 instantiateMVars cNode.mvar\n    trace[Meta.synthInstance.newAnswer] \"size: {cNode.size}, val: {val}\"\n    let result \u2190 abstractMVars val -- assignable metavariables become parameters\n    let resultType \u2190 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 \u2265 (\u2190 read).maxResultSize then\n      trace[Meta.synthInstance.answer] \"{crossEmoji} {\u2190 instantiateMVars (\u2190 inferType cNode.mvar)}{Format.line}(size: {cNode.size} \u2265 {(\u2190 read).maxResultSize})\"\n  else\n    withTraceNode `Meta.synthInstance.answer\n      (fun _ => return m!\"{checkEmoji} {\u2190 instantiateMVars (\u2190 inferType cNode.mvar)}\") do\n    let answer \u2190 mkAnswer cNode\n    -- Remark: `answer` does not contain assignable or assigned metavariables.\n    let key := cNode.key\n    let entry \u2190 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) \u2192 ... \u2192 (a_n : A_n) \u2192 B` has an unused argument `a_i`.\n\n  Remark: This is syntactic check and no reduction is performed.\n-/\nprivate def hasUnusedArguments : Expr \u2192 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 `(\u03b1, transformer)`\n  where `\u03b1` is a new type without the unused arguments and the `transformer` is a function for coverting a\n  solution with type `\u03b1` into a value that can be assigned to `mvar`.\n  Example: suppose `mvar` has type `(a : A) \u2192 (b : B a) \u2192 (c : C a) \u2192 D a c`, the result is the pair\n  ```\n  ((a : A) \u2192 (c : C a) \u2192 D a c,\n   fun (f : (a : A) \u2192 (c : C a) \u2192 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 \u2192 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 \u2192 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 \u00d7 Expr)) :=\n  withMCtx mctx do\n    let mvarType \u2190 instantiateMVars (\u2190 inferType mvar)\n    if !hasUnusedArguments mvarType then\n      return none\n    else\n      forallTelescope mvarType fun xs body => do\n        let ys \u2190 xs.foldrM (init := []) fun x ys => do\n          if body.containsFVar x.fvarId! then\n            return x :: ys\n          else if (\u2190 ys.anyM fun y => return (\u2190 inferType y).containsFVar x.fvarId!) then\n            return x :: ys\n          else\n            return ys\n        let ys := ys.toArray\n        let mvarType' \u2190 mkForallFVars ys body\n        withLocalDeclD `redf mvarType' fun f => do\n          let transformer \u2190 mkLambdaFVars #[f] (\u2190 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} \u2192 {M : Type u_2} \u2192\n      [_inst_1 : Semiring R] \u2192\n      [_inst_2 : AddCommMonoid M] \u2192\n      [_inst_3 : @ModuleS R M _inst_1 _inst_2] \u2192\n      SetLike (@Submodule R M _inst_1 _inst_2 _inst_3) M\n    ```\n  -/\n  let cNode := { cNode with\n    subgoals := \u2190 withMCtx cNode.mctx do\n      cNode.subgoals.filterM (not <$> \u00b7.mvarId!.isAssigned)\n  }\n  match cNode.subgoals with\n  | []      => addAnswer cNode\n  | mvar::_ =>\n     let waiter := Waiter.consumerNode cNode\n     let key \u2190 mkTableKeyFor cNode.mctx mvar\n     let entry? \u2190 findEntry? key\n     match entry? with\n     | none       =>\n       -- Remove unused arguments and try again, see comment at `removeUnusedArguments?`\n       match (\u2190 removeUnusedArguments? cNode.mctx mvar) with\n       | none => newSubgoal cNode.mctx key mvar waiter\n       | some (mvarType', transformer) =>\n         let key' \u2190 withMCtx cNode.mctx <| mkTableKey mvarType'\n         match (\u2190 findEntry? key') with\n         | none =>\n           let (mctx', mvar') \u2190 withMCtx cNode.mctx do\n             let mvar' \u2190 mkFreshExprMVar mvarType'\n             return (\u2190 getMCtx, mvar')\n           newSubgoal mctx' key' mvar' (Waiter.consumerNode { cNode with mctx := mctx', subgoals := mvar'::cNode.subgoals })\n         | some entry' =>\n           let answers' \u2190 entry'.answers.mapM fun a => withMCtx cNode.mctx do\n             let trAnswr := Expr.betaRev transformer #[\u2190 instantiateMVars a.result.expr]\n             let trAnswrType \u2190 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 (\u2190 get).generatorStack.back\n\n@[inline] def modifyTop (f : GeneratorNode \u2192 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 \u2190 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 \u00b7} apply {inst} to {\u2190 instantiateMVars (\u2190 inferType mvar)}\") do\n      modifyTop fun gNode => { gNode with currInstanceIdx := idx }\n      if let some (mctx, subgoals) \u2190 tryResolve mvar inst then\n        consume { key, mvar, subgoals, mctx, size := 0 }\n        return some ()\n      return none\n\ndef getNextToResume : SynthM (ConsumerNode \u00d7 Answer) := do\n  let r := (\u2190 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) \u2190 getNextToResume\n  match cNode.subgoals with\n  | []         => panic! \"resume found no remaining subgoals\"\n  | mvar::rest =>\n    match (\u2190 tryAnswer cNode.mctx mvar answer) with\n    | none      => return ()\n    | some mctx =>\n      withMCtx mctx do\n      let goal    \u2190 inferType cNode.mvar\n      let subgoal \u2190 inferType mvar\n      withTraceNode `Meta.synthInstance.resume\n        (fun _ => withMCtx cNode.mctx do\n          return m!\"propagating {\u2190 instantiateMVars answer.resultType} to subgoal {\u2190 instantiateMVars subgoal} of {\u2190 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 \u2190 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 (\u2190 get).result?\n\npartial def synth : SynthM (Option AbstractMVarsResult) := do\n  if (\u2190 step) then\n    match (\u2190 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 \u2190 mkFreshExprMVar type\n     let key  \u2190 mkTableKey type\n     let action : SynthM (Option AbstractMVarsResult) := do\n       newSubgoal (\u2190 getMCtx) key mvar Waiter.root\n       synth\n     try\n       action.run { maxResultSize := maxResultSize, maxHeartbeats := getMaxHeartbeats (\u2190 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 \u2190 whnf type\n    mkForallFVars xs type\n\nprivate def preprocessLevels (us : List Level) : MetaM (List Level \u00d7 Bool) := do\n  let mut r := #[]\n  let mut modified := false\n  for u in us do\n    let u \u2190 instantiateLevelMVars u\n    if u.hasMVar then\n      r := r.push (\u2190 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 \u2190 whnf type\n    match type with\n    | .forallE _ d b _ => do\n      let arg := args.get \u27e8i, h\u27e9\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 \u2190 if outParamsPos.contains i then mkFreshExprMVar d else pure arg\n      let args := args.set \u27e8i, h\u27e9 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 \u2190 getEnv\n      if let some outParamsPos := getOutParamPositions? env declName then\n        unless outParamsPos.isEmpty do\n          let args := typeBody.getAppArgs\n          let cType \u2190 inferType c\n          let args \u2190 preprocessArgs cType 0 args outParamsPos\n          return (\u2190 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\" (\u2190 getOptions) (decl := type.getAppFn.constName?.getD .anonymous) do\n  let opts \u2190 getOptions\n  let maxResultSize := maxResultSize?.getD (synthInstance.maxSize.get opts)\n  withTraceNode `Meta.synthInstance\n    (return m!\"{exceptOptionEmoji \u00b7} {\u2190 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 (\u2190 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 \u2190 getLocalInstances\n    let type \u2190 instantiateMVars type\n    let type \u2190 preprocess type\n    let s \u2190 get\n    let rec assignOutParams (result : Expr) : MetaM Bool := do\n      let resultType \u2190 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 \u2190 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 (\u2190 assignOutParams inst) do\n          return none\n      pure result\n    | none        =>\n      let result? \u2190 withNewMCtxDepth (allowLevelAssignments := true) do\n        let normType \u2190 preprocessOutParam type\n        SynthInstance.main normType maxResultSize\n      let result? \u2190 match result? with\n        | none        => pure none\n        | some result => do\n          let (_, _, result) \u2190 openAbstractMVarsResult result\n          trace[Meta.synthInstance] \"result {result}\"\n          if (\u2190 assignOutParams result) then\n            let result \u2190 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) (\u03b1 : Sort u)\n                class C {a : A} (\u03b1 : Sort u) [B a \u03b1]\n                class D {a : A} (\u03b1 : Sort u) [B a \u03b1] [c : C \u03b1]\n                class E (a : A) where [c (\u03b1 : Sort u) [B a \u03b1] : C \u03b1]\n                instance c {a : A} [e : E a] (\u03b1 : Sort u) [B a \u03b1] : C \u03b1 := e.c \u03b1\n\n                def d {a : A} [e : E a] (\u03b1 : Sort u) [b : B a \u03b1] : D \u03b1 := \u27e8\u27e9\n               ```\n               The term `D \u03b1` has two instance implicit arguments. The second one has type `C \u03b1`, and TC\n               resolution produces the result `@c.{u} a e \u03b1 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 \u03b1 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? \u2190 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 \u2190 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 (\u2190 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 (\u2190 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? \u2190 catchInternalId isDefEqStuckExceptionId (synthInstance? mvarDecl.type (maxResultSize? := none)) (fun _ => pure none)\n          match val? with\n          | none     =>\n            return false\n          | some val =>\n            if (\u2190 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 \u2964 K \u2964 C) : limit (F.flip \u22d9 lim) \u2245 limit (F \u22d9 lim) :=\n{ hom := limit.lift (F \u22d9 lim) \u27e8limit (F.flip \u22d9 lim),\n  { app := \u03bb j, limit.lift (F.obj j) \u27e8limit (F.flip \u22d9 lim),\n    { app := \u03bb k, limit.\u03c0 _ k \u226b limit.\u03c0 _ j,\n      naturality' := begin\n        intros k1 k2 f,\n        dsimp, simp only [category.id_comp, category.assoc],\n        rw \u2190 limit.w _ f,\n        simp,\n      end }\u27e9,\n    naturality' := begin\n      intros j1 j2 f,\n      ext,\n      dsimp,\n      simp only [category.id_comp, category.assoc, limit.lift_\u03c0, limit.lift_map,\n        cones.postcompose_obj_\u03c0, nat_trans.comp_app],\n      rw \u2190 limit.w _ f,\n      refl,\n    end }\u27e9,\n  inv := limit.lift (F.flip \u22d9 lim) \u27e8limit (F \u22d9 lim),\n  { app := \u03bb k, limit.lift (F.flip.obj k) \u27e8limit (F \u22d9 lim),\n    { app := \u03bb j, limit.\u03c0 _ j \u226b limit.\u03c0 _ k,\n      naturality' := begin\n        intros j1 j2 f,\n        dsimp, simp only [category.id_comp, category.assoc],\n        rw \u2190 limit.w _ f,\n        simp,\n      end }\u27e9,\n    naturality' := begin\n      intros k1 k2 f,\n      ext,\n      dsimp,\n      simp only [category.id_comp, category.assoc, limit.lift_\u03c0, limit.lift_map,\n        cones.postcompose_obj_\u03c0, nat_trans.comp_app],\n      rw \u2190 limit.w _ f,\n      refl,\n    end }\u27e9,\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_\u03c0_\u03c0 {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 \u2964 K \u2964 C) (j) (k) :\n  (limit_flip_comp_lim_iso_limit_comp_lim' F).hom \u226b limit.\u03c0 _ j \u226b limit.\u03c0 _ k =\n  limit.\u03c0 _ k \u226b limit.\u03c0 _ 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_\u03c0_\u03c0 {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 \u2964 K \u2964 C) (j) (k) :\n  (limit_flip_comp_lim_iso_limit_comp_lim' F).inv \u226b limit.\u03c0 _ j \u226b limit.\u03c0 _ k =\n  limit.\u03c0 _ k \u226b limit.\u03c0 _ 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 \u27f6 B} {p : X \u27f6 Y} {f : A \u27f6 X} {g : B \u27f6 Y}\n  (sq : comm_sq f i p g)\n\nnamespace comm_sq\n\ndef lift_struct.map {D : Type*} [category D] (F : C \u2964 D)\n  {A B X Y : C} {i : A \u27f6 B} {p : X \u27f6 Y} {f : A \u27f6 X} {g : B \u27f6 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 [\u2190 F.map_comp, l.fac_left], },\n  fac_right' := by { rw [\u2190 F.map_comp, l.fac_right], }, }\n\nvariable (sq)\n\ndef under_forget_equiv_lift_struct :\n  sq.lift_struct \u2243 ((under.forget M).map_comm_sq sq).lift_struct :=\n{ to_fun := lift_struct.map (under.forget M),\n  inv_fun := \u03bb l,\n  { l := structured_arrow.hom_mk l.l begin\n      simp only [functor.id_map],\n      have w\u2081 := f.w,\n      have w\u2082 := i.w,\n      dsimp at w\u2081 w\u2082,\n      rw [id_comp] at w\u2081 w\u2082,\n      have h := l.fac_left,\n      dsimp at h,\n      rw [w\u2082, assoc, h, w\u2081],\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 \u2194 ((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\u27e8\u03bb f g sq, by { rw comm_sq.under_sq_has_lift_iff, apply_instance, }\u27e9\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 for_mathlib.algebraic_topology.skeleton.split\nimport for_mathlib.algebraic_topology.skeleton.misc\nimport category_theory.limits.mono_coprod\n\nopen category_theory category_theory.limits opposite\nopen_locale simplicial\n\nnamespace simplicial_object\n\nnamespace splitting\n\nvariables {C : Type*} [category C] [has_finite_coproducts C]\n  {X : simplicial_object C} (s : splitting X) [mono_coprod C]\n\nlemma sk_succ_comm_sq (d : \u2115) :\n  comm_sq (sSet.tensor_map\u2081 (sSet.boundary_inclusion (d+1)) (s.N (d+1)))\n    sorry\n    ((sSet.tensor_yoneda_adjunction (d+1) (s.N (d+1)) (s.sk (d+1))).symm\n    (s.\u03b9_summand_sk (d+1) (index_set.truncated.id (op [d+1]))))\n    (s.sk_inclusion (show d \u2264 d+1, by exact nat.le_succ _)) :=\nbegin\n  sorry,\nend\n\n\nend splitting\n\nend simplicial_object\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/skeleton/filtration.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.7431680086124812, "lm_q2_score": 0.30404167496654744, "lm_q1q2_score": 0.22595404612009234}}
{"text": "import analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open A) (hA' : is_covering A),\n  have h1 : \u2200 m : \u2115, \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open Cm \u2227 \u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2194 \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n    assume (m : \u2115),\n    have h1 : \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open Cm \u2227 \u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2194 \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n      have h1 : \u2200 (x : euclidean_space \u211d (fin n)), \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n        assume (x : euclidean_space \u211d (fin n)),\n        have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n          have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n            have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n              have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                  have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                    have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                      have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                        have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                          have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                            have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                              have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                                have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                                  have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                                    have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                                      have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space \u211d (fin n)) \u27e8m, by auto [nat.lt_succ_self]\u27e9) \u2286 A, from begin\n                                        have h1 : \u2203 (U : set (euclidean_space \u211d (fin n))), is_open U \u2227 x \u2208 U \u2227 U \u2229 (set.Icc (0 : euclidean_space\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume A : set (euclidean_space \u211d (fin n)),\n  assume hA : is_open A,\n  assume hA2 : is_cover A,\n\n  have h1 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h2 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h3 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n\n  have h4 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h5 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h6 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h7 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h8 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h9 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h10 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h11 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h12 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h13 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h14 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h15 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h16 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h17 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h18 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h19 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h20 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h21 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h22 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h23 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h24 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h25 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h26 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h27 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h28 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h29 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h30 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h31 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h32 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h33 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h34 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h35 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h36 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h37 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h38 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h39 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h40 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h41 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h42 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h43 : \u2200 m : \u2115, \u2203! x : \u211d, x = m, from by auto [exists_unique.exists, exists_unique.unique],\n  have h44 : \u2200 m : \u2115, \u2203! x :\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume A : set (euclidean_space \u211d (fin n)),\n  assume hA : is_open A,\n  assume hA2 : is_covering A,\n  have h1 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [set.image_inter_open, set.inter_open_left, set.inter_open_right, set.Icc_is_open],\n  have h2 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [set.image_inter_covering, set.inter_covering_left, set.inter_covering_right, set.Icc_is_covering],\n  have h3 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h1],\n  have h4 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h2],\n  have h5 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h3],\n  have h6 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h4],\n  have h7 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h5],\n  have h8 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h6],\n  have h9 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h7],\n  have h10 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h8],\n  have h11 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h9],\n  have h12 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h10],\n  have h13 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h11],\n  have h14 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h12],\n  have h15 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h13],\n  have h16 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h14],\n  have h17 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h15],\n  have h18 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h16],\n  have h19 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h17],\n  have h20 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h18],\n  have h21 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h19],\n  have h22 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h20],\n  have h23 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h21],\n  have h24 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h22],\n  have h25 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h23],\n  have h26 : \u2200 (m : \u2115), is_covering (set.image (\u03bb (x : euclidean_space \u211d (fin n)), x \u2229 (set.Icc (0 : \u211d) (m : \u211d))) A), from by auto [h24],\n  have h27 : \u2200 (m : \u2115), is_open (set.image (\u03bb (x : euclidean\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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from by auto [h2],\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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  \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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-Natural-Language-Proof-Translation/Correct_statement-lean_proof_auto-3_few_shot_temperature_0.2_max_tokens_2000_n_3/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6893056167854461, "lm_q2_score": 0.3276683008207139, "lm_q1q2_score": 0.2258636001982613}}
{"text": "/-\nCopyright (c) 2019 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Simon Hudon\n\nThe writer monad transformer for passing immutable state.\n-/\nimport control.monad.basic\nimport algebra.group.basic\n\nuniverses u v w u\u2080 u\u2081 v\u2080 v\u2081\n\nstructure writer_t (\u03c9 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) : Type (max u v) :=\n(run : m (\u03b1 \u00d7 \u03c9))\n\n@[reducible] def writer (\u03c9 : Type u) := writer_t \u03c9 id\n\nattribute [pp_using_anonymous_constructor] writer_t\n\nnamespace writer_t\nsection\n  variable  {\u03c9 : Type u}\n  variable  {m : Type u \u2192 Type v}\n  variable  [monad m]\n  variables {\u03b1 \u03b2 : Type u}\n  open function\n\n  @[ext]\n  protected \n\n  @[inline] protected def tell (w : \u03c9) : writer_t \u03c9 m punit :=\n  \u27e8pure (punit.star, w)\u27e9\n\n  @[inline] protected def listen : writer_t \u03c9 m \u03b1 \u2192 writer_t \u03c9 m (\u03b1 \u00d7 \u03c9)\n  | \u27e8 cmd \u27e9 := \u27e8 (\u03bb x : \u03b1 \u00d7 \u03c9, ((x.1,x.2),x.2)) <$> cmd \u27e9\n\n  @[inline] protected def pass : writer_t \u03c9 m (\u03b1 \u00d7 (\u03c9 \u2192 \u03c9)) \u2192 writer_t \u03c9 m \u03b1\n  | \u27e8 cmd \u27e9 := \u27e8 uncurry (uncurry $ \u03bb x (f : \u03c9 \u2192 \u03c9) w, (x,f w)) <$> cmd \u27e9\n\n  @[inline] protected def pure [has_one \u03c9] (a : \u03b1) : writer_t \u03c9 m \u03b1 :=\n  \u27e8 pure (a,1) \u27e9\n\n  @[inline] protected def bind [has_mul \u03c9] (x : writer_t \u03c9 m \u03b1) (f : \u03b1 \u2192 writer_t \u03c9 m \u03b2) :\n    writer_t \u03c9 m \u03b2 :=\n  \u27e8 do x  \u2190 x.run,\n       x' \u2190 (f x.1).run,\n       pure (x'.1,x.2 * x'.2) \u27e9\n\n  instance [has_one \u03c9] [has_mul \u03c9] : monad (writer_t \u03c9 m) :=\n  { pure := \u03bb \u03b1, writer_t.pure, bind := \u03bb \u03b1 \u03b2, writer_t.bind }\n\n  instance [monoid \u03c9] [is_lawful_monad m] : is_lawful_monad (writer_t \u03c9 m) :=\n  { id_map := by { intros, cases x, simp [(<$>),writer_t.bind,writer_t.pure] },\n    pure_bind := by { intros, simp [has_pure.pure,writer_t.pure,(>>=),writer_t.bind], ext; refl },\n    bind_assoc := by { intros, simp [(>>=),writer_t.bind,mul_assoc] with functor_norm } }\n\n  @[inline] protected def lift [has_one \u03c9] (a : m \u03b1) : writer_t \u03c9 m \u03b1 :=\n  \u27e8 flip prod.mk 1 <$> a \u27e9\n\n  instance (m) [monad m] [has_one \u03c9] : has_monad_lift m (writer_t \u03c9 m) :=\n  \u27e8 \u03bb \u03b1, writer_t.lift  \u27e9\n\n  @[inline] protected def monad_map {m m'} [monad m] [monad m'] {\u03b1} (f : \u03a0 {\u03b1}, m \u03b1 \u2192 m' \u03b1) :\n    writer_t \u03c9 m \u03b1 \u2192 writer_t \u03c9 m' \u03b1 :=\n  \u03bb x, \u27e8 f x.run \u27e9\n\n  instance (m m') [monad m] [monad m'] : monad_functor m m' (writer_t \u03c9 m) (writer_t \u03c9 m') :=\n  \u27e8@writer_t.monad_map \u03c9 m m' _ _\u27e9\n\n  @[inline] protected def adapt {\u03c9' : Type u} {\u03b1 : Type u} (f : \u03c9 \u2192 \u03c9') :\n    writer_t \u03c9 m \u03b1 \u2192 writer_t \u03c9' m \u03b1 :=\n  \u03bb x, \u27e8prod.map id f <$> x.run\u27e9\n\n  instance (\u03b5) [has_one \u03c9] [monad m] [monad_except \u03b5 m] : monad_except \u03b5 (writer_t \u03c9 m) :=\n  { throw := \u03bb \u03b1, writer_t.lift \u2218 throw,\n    catch := \u03bb \u03b1 x c, \u27e8catch x.run (\u03bb e, (c e).run)\u27e9 }\nend\nend writer_t\n\n\n/--\nAn implementation of [MonadReader](\nhttps://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Reader-Class.html#t:MonadReader).\nIt does not contain `local` because this function cannot be lifted using `monad_lift`.\nInstead, the `monad_reader_adapter` class provides the more general `adapt_reader` function.\n\nNote: This class can be seen as a simplification of the more \"principled\" definition\n```\nclass monad_reader (\u03c1 : out_param (Type u)) (n : Type u \u2192 Type u) :=\n(lift {\u03b1 : Type u} : (\u2200 {m : Type u \u2192 Type u} [monad m], reader_t \u03c1 m \u03b1) \u2192 n \u03b1)\n```\n-/\nclass monad_writer (\u03c9 : out_param (Type u)) (m : Type u \u2192 Type v) :=\n(tell (w : \u03c9) : m punit)\n(listen {\u03b1} : m \u03b1 \u2192 m (\u03b1 \u00d7 \u03c9))\n(pass {\u03b1 : Type u} : m (\u03b1 \u00d7 (\u03c9 \u2192 \u03c9)) \u2192 m \u03b1)\n\nexport monad_writer\n\ninstance {\u03c9 : Type u} {m : Type u \u2192 Type v} [monad m] : monad_writer \u03c9 (writer_t \u03c9 m) :=\n{ tell := writer_t.tell,\n  listen := \u03bb \u03b1, writer_t.listen,\n  pass := \u03bb \u03b1, writer_t.pass }\n\ninstance {\u03c9 \u03c1 : Type u} {m : Type u \u2192 Type v} [monad m] [monad_writer \u03c9 m] :\n  monad_writer \u03c9 (reader_t \u03c1 m) :=\n{ tell := \u03bb x, monad_lift (tell x : m punit),\n  listen := \u03bb \u03b1 \u27e8 cmd \u27e9, \u27e8 \u03bb r, listen (cmd r) \u27e9,\n  pass := \u03bb \u03b1 \u27e8 cmd \u27e9, \u27e8 \u03bb r, pass (cmd r) \u27e9 }\n\ndef swap_right {\u03b1 \u03b2 \u03b3} : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2192 (\u03b1 \u00d7 \u03b3) \u00d7 \u03b2\n| \u27e8\u27e8x,y\u27e9,z\u27e9 := ((x,z),y)\n\ninstance {\u03c9 \u03c3 : Type u} {m : Type u \u2192 Type v} [monad m] [monad_writer \u03c9 m] :\n  monad_writer \u03c9 (state_t \u03c3 m) :=\n{ tell := \u03bb x, monad_lift (tell x : m punit),\n  listen := \u03bb \u03b1 \u27e8 cmd \u27e9, \u27e8 \u03bb r, swap_right <$> listen (cmd r) \u27e9,\n  pass := \u03bb \u03b1 \u27e8 cmd \u27e9, \u27e8 \u03bb r, pass (swap_right <$> cmd r) \u27e9 }\nopen function\n\ndef except_t.pass_aux {\u03b5 \u03b1 \u03c9} : except \u03b5 (\u03b1 \u00d7 (\u03c9 \u2192 \u03c9)) \u2192 except \u03b5 \u03b1 \u00d7 (\u03c9 \u2192 \u03c9)\n| (except.error a) := (except.error a,id)\n| (except.ok (x,y)) := (except.ok x,y)\n\ninstance {\u03c9 \u03b5 : Type u} {m : Type u \u2192 Type v} [monad m] [monad_writer \u03c9 m] :\n  monad_writer \u03c9 (except_t \u03b5 m) :=\n{ tell := \u03bb x, monad_lift (tell x : m punit),\n  listen := \u03bb \u03b1 \u27e8 cmd \u27e9, \u27e8 uncurry (\u03bb x y, flip prod.mk y <$> x) <$> listen cmd \u27e9,\n  pass := \u03bb \u03b1 \u27e8 cmd \u27e9, \u27e8 pass (except_t.pass_aux <$> cmd) \u27e9 }\n\ndef option_t.pass_aux {\u03b1 \u03c9} : option (\u03b1 \u00d7 (\u03c9 \u2192 \u03c9)) \u2192 option \u03b1 \u00d7 (\u03c9 \u2192 \u03c9)\n| none := (none ,id)\n| (some (x,y)) := (some x,y)\n\ninstance {\u03c9 : Type u} {m : Type u \u2192 Type v} [monad m] [monad_writer \u03c9 m] :\n  monad_writer \u03c9 (option_t m) :=\n{ tell := \u03bb x, monad_lift (tell x : m punit),\n  listen := \u03bb \u03b1 \u27e8 cmd \u27e9, \u27e8 uncurry (\u03bb x y, flip prod.mk y <$> x) <$> listen cmd \u27e9,\n  pass := \u03bb \u03b1 \u27e8 cmd \u27e9, \u27e8 pass (option_t.pass_aux <$> cmd) \u27e9 }\n\n/-- Adapt a monad stack, changing the type of its top-most environment.\n\nThis class is comparable to\n[Control.Lens.Magnify](https://hackage.haskell.org/package/lens-4.15.4/docs/Control-Lens-Zoom.html#t:Magnify),\nbut does not use lenses (why would it), and is derived automatically for any transformer\nimplementing `monad_functor`.\n\nNote: This class can be seen as a simplification of the more \"principled\" definition\n```\nclass monad_reader_functor (\u03c1 \u03c1' : out_param (Type u)) (n n' : Type u \u2192 Type u) :=\n(map {\u03b1 : Type u} :\n  (\u2200 {m : Type u \u2192 Type u} [monad m], reader_t \u03c1 m \u03b1 \u2192 reader_t \u03c1' m \u03b1) \u2192 n \u03b1 \u2192 n' \u03b1)\n```\n-/\nclass monad_writer_adapter (\u03c9 \u03c9' : out_param (Type u)) (m m' : Type u \u2192 Type v) :=\n(adapt_writer {\u03b1 : Type u} : (\u03c9 \u2192 \u03c9') \u2192 m \u03b1 \u2192 m' \u03b1)\nexport monad_writer_adapter (adapt_writer)\n\nsection\nvariables {\u03c9 \u03c9' : Type u} {m m' : Type u \u2192 Type v}\n\n/-- Transitivity.\n\nThis instance generates the type-class problem with a metavariable argument (which is why this\nis marked as `[nolint dangerous_instance]`).\nCurrently that is not a problem, as there are almost no instances of `monad_functor` or\n`monad_writer_adapter`.\n\nsee Note [lower instance priority] -/\n@[nolint dangerous_instance, priority 100]\ninstance monad_writer_adapter_trans {n n' : Type u \u2192 Type v} [monad_writer_adapter \u03c9 \u03c9' m m']\n  [monad_functor m m' n n'] : monad_writer_adapter \u03c9 \u03c9' n n' :=\n\u27e8\u03bb \u03b1 f, monad_map (\u03bb \u03b1, (adapt_writer f : m \u03b1 \u2192 m' \u03b1))\u27e9\n\ninstance [monad m] : monad_writer_adapter \u03c9 \u03c9' (writer_t \u03c9 m) (writer_t \u03c9' m) :=\n\u27e8\u03bb \u03b1, writer_t.adapt\u27e9\nend\n\ninstance (\u03c9 : Type u) (m out) [monad_run out m] : monad_run (\u03bb \u03b1, out (\u03b1 \u00d7 \u03c9)) (writer_t \u03c9 m) :=\n\u27e8\u03bb \u03b1 x, run $ x.run \u27e9\n\n/-- reduce the equivalence between two writer monads to the equivalence between\ntheir underlying monad -/\ndef writer_t.equiv {m\u2081 : Type u\u2080 \u2192 Type v\u2080} {m\u2082 : Type u\u2081 \u2192 Type v\u2081}\n  {\u03b1\u2081 \u03c9\u2081 : Type u\u2080} {\u03b1\u2082 \u03c9\u2082 : Type u\u2081} (F : (m\u2081 (\u03b1\u2081 \u00d7 \u03c9\u2081)) \u2243 (m\u2082 (\u03b1\u2082 \u00d7 \u03c9\u2082))) :\n  writer_t \u03c9\u2081 m\u2081 \u03b1\u2081 \u2243 writer_t \u03c9\u2082 m\u2082 \u03b1\u2082 :=\n{ to_fun := \u03bb \u27e8f\u27e9, \u27e8F f\u27e9,\n  inv_fun := \u03bb \u27e8f\u27e9, \u27e8F.symm f\u27e9,\n  left_inv := \u03bb \u27e8f\u27e9, congr_arg writer_t.mk $ F.left_inv _,\n  right_inv := \u03bb \u27e8f\u27e9, congr_arg writer_t.mk $ F.right_inv _ }\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/src/control/monad/writer.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.43782349911420193, "lm_q1q2_score": 0.22575051571482063}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((a2).read i2) \u2260 (((a2).write i1 ((a2).read i2)).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test42.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.4378234991142019, "lm_q1q2_score": 0.2257505157148206}}
{"text": "import ReactorModel.Objects.Reactor.Updatable\n\nopen Classical\n\nnamespace Reactor\n\nprotected inductive Core \n  | mk \n    (ports : Kind \u2192 ID \u21c0 Value)\n    (acts :  ID \u21c0 Action)\n    (state : ID \u21c0 Value)\n    (rcns :  ID \u21c0 Reaction)\n    (nest :  ID \u2192 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 \u27e8i, hn\u27e9\n    simp [ReactorType.nest] at hn \n    have := hn \u25b8 hi i\n    simp_all\n    \nnoncomputable section Update\nopen ReactorType\n\nabbrev \u00abwith\u00bb \n    (rtr : Reactor.Core) (ports : Kind \u2192 ID \u21c0 Value := ports rtr) (acts : ID \u21c0 Action := acts rtr) \n    (state : ID \u21c0 Value := state rtr) (rcns : ID \u21c0 Reaction := rcns rtr) \n    (nest : ID \u21c0 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 \u2039Component.Valued\u203a \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 \u2260 cpt \u2228 j \u2260 i) :\n    cpt? c rtr j = cpt? c (rtr.insert cpt i v) j := by\n  cases cpt <;> try cases \u2039Component.Valued\u203a <;> try cases \u2039Kind\u203a\n  all_goals cases c <;> try cases \u2039Component.Valued\u203a <;> try cases \u2039Kind\u203a\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 \u2192 cpt.type) : \n    Member cpt i rtr \u2192 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 \u2192 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 \u2192 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 abstraction.concepts\nuniverse u\nopen set topological_space classical\nlocal attribute [instance] prop_decidable\n\n-- THIS FILE IS A WORK IN PROGRESS\n-- TERMINOLOGY HERE DIFFERS FROM THE REST OF THE PROJECT\n\nnamespace ontology\n  variables (\u03c9 : ontology)\n  section matter\n\n \n    -- We call any composite substance `physical`,\n    -- or a `body`.\n    \n    @[reducible]\n    def substance.physical {\u03c9 : ontology} (s : \u03c9.substance) := s.composite\n    def cosmos_set := {s : \u03c9.substance | s.physical}\n    def body := subtype \u03c9.cosmos_set\n    \n    -- The cosmos is the integral whole of all\n    -- composite (physical) substances.\n    def cosmos := integral_whole \u03c9.cosmos_set\n  \n    -- Prime matter is the abstract whole of all\n    -- composite (physical) substances.\n    def prime_matter := abstract_whole \u03c9.cosmos_set\n    \n    -- There are specifically two dual notions of `matter` that are obtained \n    -- by considering virtual substances (concepts) \n    -- as the totalities of both kinds of matter:\n    \n    -- (1) From the point of view of the whole, \n    -- matter can be thought of as that which \n    -- actively composes a thing, its substratum.\n    -- This sense we will only cover in the next\n    -- section, which is mereology.\n    \n    -- (2) From the point of view of matter itself,\n    -- matter can be thought of as that which is in potency\n    -- to a multiplicty of forms, in the sense of prime matter.\n    -- Mathematically these two notions are dual, \n    -- with the duality of \u03a0 and \u03a3 types, respectively.\n  \n    -- Notice, in the first notion matter is actual, \n    -- and in the second potential.\n    \n    -- Transcendent matter is the abstract whole of all\n    -- substances.\n    -- This is the virtual substance that is \"in potency\"\n    -- for becoming any other substance.\n    def transcendent_matter : \u03c9.concept := abstract_whole univ\n  \n    -- The state space of a virtual, likely possible, substance\n    -- corresponding to a concrete and immanent notion of matter.\n    -- This virtual is the mereological sum of the set of all substances.\n    -- It is the whole of reality.\n    def reality : \u03c9.concept := integral_whole univ\n  \n    -- Of course nothing in reality is an instance of\n    -- prime or transcendent matter.\n \n  end matter\n  \n  section mereology\n \n    -- A substance s\u2081 is an integral part of another\n    -- substance s\u2082 if there is a \n    -- (necessarilly nonempty) set S of substances \n    -- such that the integral whole of {s\u2081} \u222a S is\n    -- homeomorphic to the state space of s\u2082 by\n    -- means of a state-preserving homeomorphism\n    def substance.part_of {\u03c9 : ontology} (s\u2081 s\u2082 : \u03c9.substance) :=\n      -- s\u2081 \u2260 s\u2082 \u2227\n      \u2203 S : set \u03c9.substance, \n      S.nonempty \u2227\n      s\u2081 \u2209 S \u2227\n      -- (\u2200 x \u2208 S, x \u2260 s\u2082) \u2227\n      \u2203 hom :\n          s\u2082.concept.state \u2243\u209c\n          (integral_whole $ S \u222a {s\u2081}).state,\n      state_preserving hom.to_fun\n  \n    -- This is to say that if we know the state of the\n    -- substance s\u2082 in a possible world w, then we\n    -- already know the state of each of its parts,\n    -- since there is a functional dependence between them.\n    \n    --  @[trans]\n    --  lemma part_of_trans : \u2200 s\u2081 s\u2082 s\u2083 : \u03c9.substance, \n    --                        s\u2081.part_of s\u2082 \u2192\n    --                        s\u2082.part_of s\u2083 \u2192\n    --                        s\u2081.part_of s\u2083 :=\n    --     begin\n    --         intros s\u2081 s\u2082 s\u2083 h\u2081 h\u2082,\n    --         -- simp [substance.part_of] at *,\n    --         obtain \u27e8S\u2081, ne\u2081, notin\u2081, hom\u2081, h\u2081\u27e9 := h\u2081,\n    --         obtain \u27e8S\u2082, ne\u2082, notin\u2082, hom\u2082, h\u2082\u27e9 := h\u2082,\n    --         use S\u2081 \u222a S\u2082 \u222a {s\u2082},\n    --         simp,\n              -- TODO\n    --     end\n  \n  end mereology\nend ontology", "meta": {"author": "maxd13", "repo": "topological_ontology", "sha": "68d21c9a00024fba3aed301e16c31e05733c1786", "save_path": "github-repos/lean/maxd13-topological_ontology", "path": "github-repos/lean/maxd13-topological_ontology/topological_ontology-68d21c9a00024fba3aed301e16c31e05733c1786/src/metaphysics/mereology.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6076631698328916, "lm_q2_score": 0.3702253856469203, "lm_q1q2_score": 0.22497233139481232}}
{"text": "import Std.Data.PersistentHashMap\n\nopen Std\ndef m : PersistentHashMap Nat Nat :=\nlet m : PersistentHashMap Nat Nat := {};\nm.insert 1 1\n\ndef natDiffHash : Hashable Nat :=\n\u27e8fun n => UInt64.ofNat $ n+10\u27e9\n\n-- The following example should fail since the `Hashable` instance used to create `m` is not `natDiffHash`\n#eval @PersistentHashMap.find? Nat Nat _ natDiffHash m 1\n", "meta": {"author": "Kha", "repo": "lean4-nightly", "sha": "b4c92de57090e6c47b29d3575df53d86fce52752", "save_path": "github-repos/lean/Kha-lean4-nightly", "path": "github-repos/lean/Kha-lean4-nightly/lean4-nightly-b4c92de57090e6c47b29d3575df53d86fce52752/tests/lean/phashmap_inst_coherence.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.22450508185939286}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v1) \u2260 ((((a2).write i3 (v1)).write i1 (v1)).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test15.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5039061705290805, "lm_q2_score": 0.4455295350395727, "lm_q1q2_score": 0.22450508185939286}}
{"text": "import vc0.basic\n\nnamespace c0\n\nopen ast ast.gdecl\n\ntheorem start_ok (\u0393 : ast) (ok : \u0393.ok) : \u2200 s, start \u0393 s \u2192 state.ok \u0393 s\n| _ (@start.mk _ s h) := begin\n  rcases get_body_ok' ok.ind h with \u27e8h\u2081, h\u2082|\u27e8\u27e8\u27e9\u27e9\u27e9,\n  rcases ok.ok_init h with \u27e8\u03b4, h\u2083\u27e9,\n  exact state.ok.stmt (some type.int) env.ok.empty vtype.of_ty.int h\u2081 h\u2083 (or.inl h\u2082)\nend\n\nnamespace value\n\ntheorem default.ok {\u0393 : ast} {ts v} (\u0393ok : \u0393.ok)\n  (h : default \u0393 ts v) (E) : ok_type_or_sdef \u0393 E v ts :=\nbegin\n  induction h,\n  { exact \u27e8_, vtype.of_ty.int, ok.int\u27e9 },\n  { exact \u27e8_, vtype.of_ty.bool, ok.bool\u27e9 },\n  { exact \u27e8_, vtype.of_ty.ref (vtype.of_ty_fn _).2, ok.null\u27e9 },\n  { exact \u27e8_, vtype.of_ty.arr (vtype.of_ty_fn _).2, ok.null_arr\u27e9 },\n  { rcases h_ih with \u27e8vs, vm, al'\u27e9,\n    refine \u27e8_, vtype.of_ty.struct, ok.struct\n      (\u03bb sd' \u03c4s hd al, value.of_map_ok.2 \u27e8_, rfl, _\u27e9) vm\u27e9,\n    cases get_sdef_determ \u0393ok.ind h_a hd,\n    refine list.forall\u2082.mp_trans _ al'.flip al,\n    rintro _ _ _ \u27e8i, v, t, \u03c4, t\u03c4, vok\u27e9 \u27e8_, _, \u03c4', t\u03c4'\u27e9,\n    cases vtype.of_ty_determ t\u03c4 t\u03c4',\n    exact \u27e8vok\u27e9 },\n  { exact \u27e8\u2205, rfl, list.forall\u2082.nil\u27e9 },\n  case c0.value.default.cons : \u0394 x \u03c4 h v vs h\u2081 h\u2082 IH\u2081 IH\u2082 {\n    rcases IH\u2081 with \u27e8\u03c4', t\u03c4\u2081, vok\u27e9,\n    rcases IH\u2082 with \u27e8\u03c4s', rfl, al\u27e9,\n    exact \u27e8_, (of_map_cons (mt al.mem_iff.2 h)).symm,\n      alist.forall\u2082_cons.2 \u27e8\u27e8_, t\u03c4\u2081, vok\u27e9, al\u27e9\u27e9 },\nend\n\ntheorem default.ok' {\u0393 : ast} {t \u03c4 v} (ok : \u0393.ok)\n  (h : default \u0393 (sum.inl t) v) (E)\n  (t\u03c4 : vtype.of_ty (exp.type.reg t) \u03c4) : value.ok \u0393 E v \u03c4 :=\nlet \u27e8\u03c4', h\u2081, h\u2082\u27e9 := h.ok ok E in vtype.of_ty_determ h\u2081 t\u03c4 \u25b8 h\u2082\n\ntheorem ok.repeat {\u0393 E v \u03c4} (h : value.ok \u0393 E v \u03c4) :\n  \u2200 {n}, value.ok \u0393 E (value.repeat v n) (vtype.arr' \u03c4 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 {\u0393 E \u0394 H \u03c3 \u03b7} (ok : ast.okind \u0393)\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3)\n  (Hok : heap.ok \u0393 H E) (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3)\n  {R a H' \u03b7' \u03c4} (aok : addr.ok \u0393 E \u03c3 a \u03c4)\n  (h : update H \u03b7 R a H' \u03b7')\n  (Rok : \u2200 x, value.ok \u0393 E x \u03c4 \u2192 \u2200 y, R x y \u2192 value.ok \u0393 E y \u03c4) :\n  heap.ok \u0393 H' E \u2227 vars.ok \u0393 E \u03b7' \u03c3 :=\nbegin\n  induction h generalizing \u03c4,\n  case c0.addr.update.ref : R n H' {\n    rcases aok with \u27e8_, _, m\u27e9,\n    suffices : \u2200 E', list.forall\u2082 (value.ok \u0393 E) H E' \u2192 \u03c4 \u2208 list.nth E' n \u2192\n      list.forall\u2082 (value.ok \u0393 E) H' E', from \u27e8this _ Hok m, \u03b7ok\u27e9,\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 _ \u03c4' _ E' v'ok vsok,\n    { cases m,\n      exact list.forall\u2082.cons (Rok _ v'ok _ r) vsok },\n    { exact list.forall\u2082.cons v'ok (IH _ vsok m) } },\n  case c0.addr.update.var : R i v v' e m\u03b7 r {\n    refine \u27e8Hok, \u03bb j \u03c4' \u03c4\u03c3, _\u27e9, subst e,\n    rcases \u03b7ok _ _ \u03c4\u03c3 with \u27e8x, x\u03b7, xok\u27e9,\n    rcases aok with _|\u27e8_, _, m\u03c3\u27e9,\n    revert \u03b7, refine \u03bb \u03b7, finmap.induction_on \u03b7 (\u03bb \u03b7, _), intros,\n    have := alist.replace_forall\u2082 i v' \u03b7,\n    rcases this.rel_of_lookup_right x\u03b7 with \u27e8v', m', h\u27e9,\n    refine \u27e8v', m', _\u27e9,\n    cases h,\n    { cases option.mem_unique m\u03b7 x\u03b7,\n      cases option.mem_unique m\u03c3 \u03c4\u03c3,\n      exact Rok _ xok _ r },\n    { exact xok } },\n  case c0.addr.update.head : R a H' \u03b7' h IH {\n    rcases aok with _|_|\u27e8_, _, \u03c4s, aok\u27e9,\n    exact IH aok (at_head.ok Rok) },\n  case c0.addr.update.tail : R a H' \u03b7' h IH {\n    rcases aok with _|_|_|\u27e8_, \u03c4\u2081, _, aok\u27e9,\n    exact IH aok (at_tail.ok Rok) },\n  case c0.addr.update.nth : R a i H' \u03b7' h IH {\n    rcases aok with _|_|_|_|\u27e8_, \u03c4\u2081, _, aok\u27e9,\n    exact IH aok_a_2 (at_nth.ok Rok aok_a_1) },\n  case c0.addr.update.field : R a f H' \u03b7' h IH {\n    rcases aok with _|_|_|_|\u27e8_, \u03c4\u2081, _, aok\u27e9,\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 {\u0393 E \u0394 \u03c3 \u03b7 x v t \u03c4}\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3) (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3)\n  (xok : t \u2208 \u0394.lookup x)\n  (t\u03c4 : vtype.of_ty (exp.type.reg t) \u03c4)\n  (vok : value.ok \u0393 E v \u03c4) :\n\u2203 \u03c3', vars_ty.ok \u0394 \u03c3' \u2227\n  \u03c3'.keys = insert x \u03c3.keys \u2227\n  vars.ok \u0393 E (vars.assign \u03b7 x v) \u03c3' :=\nbegin\n  by_cases x\u03c3 : x \u2208 \u03c3,\n  { refine \u27e8\u03c3, \u03c3ok, (finset.insert_eq_of_mem (finmap.mem_keys.2 x\u03c3)).symm, _\u27e9,\n    rw [vars.assign, if_pos (\u03b7ok.mem x\u03c3)],\n    intros y \u03c4' hy,\n    by_cases x = y,\n    { subst y,\n      rcases \u03c3ok _ _ hy with \u27e8t', h\u2081, h\u2082\u27e9,\n      cases option.mem_unique xok h\u2081,\n      cases vtype.of_ty_determ t\u03c4 h\u2082,\n      exact \u27e8v, finmap.lookup_replace_self (\u03b7ok.mem x\u03c3), vok\u27e9 },\n    { rcases \u03b7ok _ _ hy with \u27e8v', h\u2081, h\u2082\u27e9,\n      refine \u27e8v', _, h\u2082\u27e9,\n      convert h\u2081 using 1,\n      exact finmap.lookup_replace_of_ne h } },\n  { refine \u27e8\u03c3.insert x \u03c4, \u03bb y \u03c4' hy, _, finmap.keys_insert _ _ _, \u03bb y \u03c4' hy, _\u27e9;\n      rw finmap.lookup_insert_of_neg x\u03c3 at hy;\n      rcases hy with \u27e8\u27e8\u27e9\u27e9 | hy,\n    { exact \u27e8_, xok, t\u03c4\u27e9 },\n    { exact \u03c3ok _ _ hy },\n    { refine \u27e8v, _, vok\u27e9,\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 \u03b7ok _ _ hy with \u27e8v', h\u2081, h\u2082\u27e9,\n      refine \u27e8v', _, h\u2082\u27e9,\n      rw vars.assign, split_ifs,\n      { rwa finmap.lookup_replace_of_ne,\n        rintro rfl,\n        cases x\u03c3 (finmap.exists_mem_lookup_iff.1 \u27e8_, hy\u27e9) },\n      { exact (finmap.lookup_insert_of_neg h).2 (or.inr h\u2081) } } }\nend\n\ntheorem value.step_binop.ok {\u0393 E op t\u2081 t\u2082 \u03c4\u2081 \u03c4\u2082 v\u2081 v\u2082 v}\n  (sok : value.step_binop op v\u2081 v\u2082 (sum.inl v))\n  (opok : binop.ok op t\u2081 t\u2082)\n  (t\u03c4\u2081 : vtype.of_ty (exp.type.reg t\u2081) \u03c4\u2081)\n  (t\u03c4\u2082 : vtype.of_ty (exp.type.reg t\u2082) \u03c4\u2082)\n  (vok\u2081 : value.ok \u0393 E v\u2081 \u03c4\u2081) (vok\u2082 : value.ok \u0393 E v\u2082 \u03c4\u2081) :\n  value.ok \u0393 E v \u03c4\u2082 :=\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\u03c4\u2081; cases t\u03c4\u2082; try {constructor},\n  all_goals {\n    rcases (\u27e8_, e\u27e9 : \u2203 x, sum.inl v = value.to_err x) with \u27e8_|_, \u27e8\u27e9\u27e9,\n    constructor }\nend\n\ntheorem value.step_unop.ok {\u0393 E op t\u2081 t\u2082 \u03c4\u2081 \u03c4\u2082 v v'}\n  (sok : value.step_unop op v v')\n  (opok : unop.ok op t\u2081 t\u2082)\n  (t\u03c4\u2081 : vtype.of_ty (exp.type.reg t\u2081) \u03c4\u2081)\n  (t\u03c4\u2082 : vtype.of_ty (exp.type.reg t\u2082) \u03c4\u2082)\n  (vok\u2081 : value.ok \u0393 E v \u03c4\u2081) : value.ok \u0393 E v' \u03c4\u2082 :=\nby cases sok; cases opok; cases t\u03c4\u2081; cases t\u03c4\u2082; constructor\n\ntheorem stmt_list.ok.mono {\u0393 \u0394 \u03b4\u2081 \u03b4\u2082 ret K}\n  (ss : \u03b4\u2081 \u2286 \u03b4\u2082) (Kok : stmt_list.ok \u0393 ret \u0394 \u03b4\u2081 K) :\n  stmt_list.ok \u0393 ret \u0394 \u03b4\u2082 K :=\nbegin\n  induction Kok generalizing \u03b4\u2082,\n  { exact stmt_list.ok.nil Kok_a },\n  { rcases Kok_a_2.mono ss with \u27e8\u03b4', ss', i\u27e9,\n    exact stmt_list.ok.one Kok_a Kok_a_1 i },\n  { rcases Kok_a_1.mono ss with \u27e8\u03b4', ss', i\u27e9,\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 {\u0393 E \u0394 \u03c3 \u03b7 ret s K}\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3)\n  (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3) : stmt_list.ok \u0393 ret \u0394 \u03c3.keys (s :: K) \u2192\n  \u2203 \u0394' \u03c3' \u03b4', vars_ty.ok \u0394' \u03c3' \u2227 vars.ok \u0393 E \u03b7 \u03c3' \u2227\n    stmt.ok \u0393 ret \u0394' s \u2227\n    stmt.init' \u0393 \u0394'.keys.to_finset \u03c3'.keys s \u03b4' \u2227\n    (stmt.returns s \u2228 stmt_list.ok \u0393 ret \u0394' \u03b4' K) :=\nbegin\n  generalize e : (s :: K : list stmt) = K',\n  generalize e' : \u03c3.keys = \u03b4,\n  intro Kok, induction Kok generalizing \u03c3; cases e; subst Kok_\u03b4,\n  { exact \u27e8_, _, _, \u03c3ok, \u03b7ok, Kok_a, Kok_a_2, or.inl Kok_a_1\u27e9 },\n  { rcases Kok_a_1.subset Kok_a rfl \u03c3ok.subset with \u27e8ss\u2081', ss\u2082'\u27e9,\n    exact \u27e8_, _, _, \u03c3ok, \u03b7ok, Kok_a, Kok_a_1, or.inr Kok_a_2\u27e9 },\n  { exact Kok_ih rfl \u03c3ok.erase \u03b7ok.erase (finmap.keys_erase _ _) }\nend\n\ntheorem step_deref.ok {\u0393 E \u03c3s \u0394 \u03c3 H S \u03b7 ret a \u03c4 K s'}\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3) (Eok : heap.ok \u0393 H E)\n  (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3) (Sok : stack.ok \u0393 E \u03c3s S ret)\n  (aok : addr_opt.ok \u0393 E \u03c3 a \u03c4)\n  (Kok : cont.ok' \u0393 E \u03c3 \u0394 ret K \u03c4)\n  (h : step_deref \u27e8H, S, \u03b7\u27e9 a K s') : state.ok \u0393 s' :=\nbegin\n  cases h,\n  { apply state.ok.err },\n  { exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9\n      (h_a_1.ok \u03c3ok Eok \u03b7ok aok) Kok }\nend\n\ntheorem step_ret.ok {\u0393 E \u03c3s \u0394 \u03c3 H S \u03b7 \u03c4 v s'}\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3) (Eok : heap.ok \u0393 H E)\n  (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3) (Sok : stack.ok \u0393 E \u03c3s S \u03c4)\n  (vok : value.ok \u0393 E v \u03c4)\n  (h : step_ret \u27e8H, S, \u03b7\u27e9 v s') : state.ok \u0393 s' :=\nbegin\n  cases h,\n  { cases Sok with \u0394' \u03b7 K' S' \u03c3 \u03c3s \u03c4\u2081 \u03c4' \u03c3ok' \u03b7ok' Kok' Sok',\n    exact state.ok.ret \u27e8\u03c3ok', Eok, \u03b7ok', Sok'\u27e9 vok Kok' },\n  { apply state.ok.done }\nend\n\ntheorem step_call.ok {\u0393 : ast} {\u0394 : ctx} {E vs \u03c4s \u03b7}\n  (\u03c4ok : vtype.of_ty (exp.type.ls \u0394.values) \u03c4s)\n  (sc : step_call \u0394 vs \u03b7) (vok : value.ok \u0393 E vs \u03c4s) :\n  \u2203 \u03c3, vars_ty.ok \u0394 \u03c3 \u2227 vars.ok \u0393 E \u03b7 \u03c3 \u2227 \u0394.keys.to_finset \u2286 \u03c3.keys \u2227 \u2200 x \u2208 \u03b7, x \u2208 \u03c3 :=\nbegin\n  induction sc with \u0394 x \u03c4 v vs \u03b7 h a IH generalizing \u03c4s; cases \u03c4ok; cases vok,\n  { exact \u27e8\u2205, by rintro _ _ \u27e8\u27e9, by rintro _ _ \u27e8\u27e9, \u03bb _, id, by rintro _ \u27e8_, \u27e8\u27e9\u27e9\u27e9 },\n  { rcases IH \u03c4ok_a_1 vok_a_1 with \u27e8\u03c3, \u03c3ok, \u03b7ok, ss, \u03b7\u03c3\u27e9,\n    have \u03b7ok' := \u03b7ok.insert (mt (\u03c3ok.mem \u2218 \u03b7\u03c3 _) h) vok_a,\n    refine \u27e8_, (\u03c3ok.weak _).insert (mt \u03c3ok.mem h) alist.lookup_cons_self \u03c4ok_a,\n      \u03b7ok', _, \u03bb y h, _\u27e9,\n    { rw [alist.cons_keys, list.cons_to_finset, finmap.keys_insert],\n      exact finset.insert_subset_insert _ ss },\n    { rw [\u2190 finmap.mem_keys, finmap.keys_insert, finset.mem_insert, finmap.mem_keys] at h \u22a2,\n      exact h.imp_right (\u03b7\u03c3 _) } }\nend\n\ntheorem step_alloc.ok {\u0393 E \u03c3s \u0394 \u03c3 H S ret \u03b7 \u03c4 v K s}\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3) (Eok : heap.ok \u0393 H E)\n  (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3) (Sok : stack.ok \u0393 E \u03c3s S ret)\n  (vok : value.ok \u0393 E v \u03c4) (Kok : cont.ok' \u0393 E \u03c3 \u0394 ret K (vtype.ref \u03c4))\n  (h : step_alloc \u27e8H, S, \u03b7\u27e9 v K s) : state.ok \u0393 s :=\nbegin\n  cases h,\n  have EE : E \u2264 E.add \u03c4 := E.le_add \u03c4,\n  refine state.ok.ret\n    \u27e8\u03c3ok, Eok.add (vok.mono EE), \u03b7ok.mono EE, Sok.mono EE\u27e9\n    (value.ok.ref _) (Kok.mono EE),\n  rintro _ \u27e8\u27e9,\n  rw list.forall\u2082_length_eq Eok,\n  apply list.nth_concat_length\nend\n\ntheorem step_alloc_arr.ok {\u0393 E \u03c3s \u0394 \u03c3 H S ret \u03b7 \u03c4 n v K s}\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3) (Eok : heap.ok \u0393 H E)\n  (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3) (Sok : stack.ok \u0393 E \u03c3s S ret)\n  (vok : value.ok \u0393 E v (vtype.arr \u03c4 n))\n  (Kok : cont.ok' \u0393 E \u03c3 \u0394 ret K (vtype.refarr \u03c4))\n  (h : step_alloc \u27e8H, S, \u03b7\u27e9 v K s) : state.ok \u0393 s :=\nbegin\n  cases h,\n  have EE : E \u2264 E.add (vtype.arr \u03c4 n) := E.le_add (vtype.arr \u03c4 n),\n  refine state.ok.ret\n    \u27e8\u03c3ok, Eok.add (vok.mono EE), \u03b7ok.mono EE, Sok.mono EE\u27e9\n    (value.ok.refarr _) (Kok.mono EE),\n  rintro _ \u27e8\u27e9, existsi n,\n  rw list.forall\u2082_length_eq Eok,\n  apply list.nth_concat_length\nend\n\ntheorem preservation {\u0393 : ast} (ok : \u0393.ok)\n  {s} (sok : state.ok \u0393 s) {o} (iok : io.ok \u0393 o)\n  {s'} (H : step \u0393 s o s') : state.ok \u0393 s' :=\nbegin\n  cases H,\n  case c0.step.decl : H S \u03b7 v \u03c4 \u03c4' s K H\u2081 {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, \u27e8_, _, _, \u03c4', _, hn, \u03c4\u03c4', \u03c4sm, sok\u27e9, si, Kok\u27e9,\n    cases si,\n    refine state.ok.stmt t \u27e8\u03c3ok.weak _, Eok, \u03b7ok, Sok\u27e9 t\u03c4 sok\n      (by simpa using si_a) _,\n    rcases Kok with \u27e8\u27e8_, _, _, r\u27e9\u27e9|Kok,\n    { exact or.inl r },\n    { exact or.inr Kok.weak } },\n  case c0.step.decl_asgn : H S \u03b7 v \u03c4 \u03c4' e s K H\u2081 {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, Kok\u27e9, cases si, cases sok,\n    refine state.ok.stmt t \u27e8\u03c3ok.weak sok_h, Eok, \u03b7ok, Sok\u27e9 t\u03c4\n      (stmt.ok.asgn (exp.ok.var alist.lookup_cons_self) sok_a_2.weak' sok_a_1)\n      (ast.stmt.init.asgn \u27e8\u27e9 si_a) (or.inr _),\n    change stmt.init' \u0393 (insert v sok_\u0394.keys.to_finset)\n      (insert v sok_\u03c3.keys) s si_\u03b4' at si_a_1,\n    rw [\u2190 list.cons_to_finset, \u2190 alist.cons_keys] at si_a_1,\n    rcases Kok with \u27e8\u27e8\u27e9\u27e9|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\u2081 : C c s\u2081 s\u2082 K {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, Kok\u27e9, cases si, cases sok,\n    refine state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 si_a \u27e8\u27e9\n      \u27e8_, sok_a_1, vtype.of_ty.bool\u27e9\n      (cont.ok.If t\u03c4 sok_a_2 si_a_1 sok_a_3 si_a_2 _),\n    rcases Kok with \u27e8\u27e8\u27e9\u27e9|Kok,\n    { exact or.inl \u27e8Kok_a, Kok_a_1\u27e9 },\n    { exact or.inr Kok } },\n  case c0.step.If\u2082 : C b s\u2081 s\u2082 K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      _, _, _, _, \u03b4\u2081, \u03b4\u2082, _, t, t\u03c4, s\u2081ok, i\u2081, s\u2082ok, i\u2082, Kok\u27e9,\n    cases b,\n    exact state.ok.stmt t \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 t\u03c4 s\u2082ok i\u2082\n      (Kok.imp and.right $ stmt_list.ok.mono (finset.inter_subset_right _ _)),\n    exact state.ok.stmt t \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 t\u03c4 s\u2081ok i\u2081\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 \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, \u27e8\u27e8\u27e9\u27e9|Kok\u27e9, cases si, cases id sok,\n    have := si_a_1.subset a_1 rfl \u03c3ok.subset,\n    rcases si.mono this.1 with \u27e8\u03b4'', ss', i'\u27e9,\n    exact (state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 si_a \u27e8\u27e9 \u27e8_, a, vtype.of_ty.bool\u27e9 $\n      cont.ok.If t\u03c4 (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\u2081 : C lv e K eq {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, \u27e8\u27e8\u27e9\u27e9|Kok\u27e9, cases si, cases sok,\n    rcases vtype.of_ty_fn sok_\u03c4 with \u27e8v\u03c4, hv\u27e9,\n    rw [lval.uses, eq] at si_a, rw eq at Kok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 si_a lv.ok \u27e8_, sok_a_1, hv\u27e9\n      (cont.ok.asgn\u2081 \u27e8_, sok_a_2, hv\u27e9 si_a_1 \u27e8t, t\u03c4, Kok\u27e9) },\n  case c0.step.asgn\u2082 : C a e K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      aok, _|\u27e8_, _, _, _, \u27e8t, eok, t\u03c4\u27e9, eu, t', t\u03c4', Kok\u27e9\u27e9,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu \u27e8\u27e9\n      \u27e8_, eok, t\u03c4\u27e9 (cont.ok.asgn\u2082 aok \u27e8_, t\u03c4', Kok\u27e9) },\n  case c0.step.asgn\u2083 : H H' S \u03b7 \u03b7' a v K h {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, _|_|\u27e8_, _, _, _, aok, t, t\u03c4, Kok\u27e9\u27e9,\n    rcases h.ok ok.ind \u03c3ok Eok \u03b7ok aok (addr.eq.ok vok) with \u27e8Eok', \u03b7ok'\u27e9,\n    exact state.ok.stmt t \u27e8\u03c3ok, Eok', \u03b7ok', Sok\u27e9 t\u03c4\n      stmt.ok.nop stmt.init.nop (or.inr Kok) },\n  case c0.step.asgn_var\u2081 : C lv x e K eq {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, \u27e8\u27e8\u27e9\u27e9|Kok\u27e9, cases si, cases sok,\n    cases lv; cases eq,\n    rcases vtype.of_ty_fn sok_\u03c4 with \u27e8v\u03c4, hv\u27e9,\n    rcases sok_a_1 with _|_|_|\u27e8_, t', t\u0394\u27e9,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 si_a_1 \u27e8\u27e9\n      \u27e8_, sok_a_2, hv\u27e9 (cont.ok.asgn_var t\u0394 hv \u27e8_, t\u03c4, Kok\u27e9) },\n  case c0.step.asgn_var\u2082 : H S \u03b7 x v K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok, rcases Kok_a_2 with \u27e8t, t\u03c4, Kok\u27e9,\n    rcases assign.ok \u03c3ok \u03b7ok Kok_a Kok_a_1 vok with \u27e8\u03c3', \u03c3ok', e, \u03b7ok'\u27e9,\n    exact state.ok.stmt _ \u27e8\u03c3ok', Eok, \u03b7ok', Sok\u27e9 t\u03c4\n      stmt.ok.nop stmt.init.nop (or.inr (by rwa e)) },\n  case c0.step.asgn_err : H S \u03b7 v K { apply state.ok.err },\n  case c0.step.asnop\u2081 : C lv op e K {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, \u27e8\u27e8\u27e9\u27e9|Kok\u27e9, cases si, cases id sok,\n    rcases vtype.of_ty_fn (exp.type.reg \u03c4_1) with \u27e8v\u03c4, hv\u27e9,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 si_a lv.ok\n      \u27e8_, a, hv\u27e9 (cont.ok.asnop a_2 hv a_1 si_a_1 \u27e8_, t\u03c4, Kok\u27e9) },\n  case c0.step.asnop\u2082 : _ C a op e K h {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      aok, Kok\u27e9, cases Kok, cases Kok_a with _ opok,\n    exact step_deref.ok \u03c3ok Eok \u03b7ok Sok aok\n      (cont.ok.binop\u2081 opok Kok_a_1 Kok_a_1 Kok_a_2 Kok_a_3 $\n       cont.ok.asgn\u2082 aok Kok_a_4) h },\n  case c0.step.eval\u2081 : C e K {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, \u27e8\u27e8\u27e9\u27e9|Kok\u27e9, cases si, cases id sok,\n    rcases vtype.of_ty_fn \u03c4_1 with \u27e8v\u03c4, hv\u27e9,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 si_a \u27e8\u27e9\n      \u27e8_, a, hv\u27e9 (cont.ok.eval \u27e8t, t\u03c4, Kok\u27e9) },\n  case c0.step.eval\u2082 : C e K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      aok, Kok\u27e9, cases Kok, rcases Kok_a with \u27e8t, t\u03c4, Kok\u27e9,\n    exact state.ok.stmt t \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 t\u03c4\n      stmt.ok.nop stmt.init.nop (or.inr Kok) },\n  case c0.step.assert\u2081 : C e K {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, \u27e8\u27e8\u27e9\u27e9|Kok\u27e9, cases si, cases id sok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 si_a \u27e8\u27e9\n      \u27e8_, a, vtype.of_ty.bool\u27e9 (cont.ok.assert \u27e8t, t\u03c4, Kok\u27e9) },\n  case c0.step.assert\u2082 : C b K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      aok, Kok\u27e9,\n    cases b, {apply state.ok.err},\n    cases Kok, rcases Kok_a with \u27e8t, t\u03c4, Kok\u27e9,\n    exact state.ok.stmt t \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 t\u03c4\n      stmt.ok.nop stmt.init.nop (or.inr Kok) },\n  case c0.step.ret\u2081 : C e K {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, Kok\u27e9, cases si, cases id sok, cases a,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 (si_a _ rfl) \u27e8\u27e9\n      \u27e8_, a_a_1, t\u03c4\u27e9 cont.ok.ret },\n  case c0.step.ret\u2082 : _ C v h {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, \u27e8\u27e9\u27e9,\n    exact h.ok \u03c3ok Eok \u03b7ok Sok vok },\n  case c0.step.ret_none : _ C v h {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, Kok\u27e9, cases id sok, cases a, cases t\u03c4,\n    exact h.ok \u03c3ok Eok \u03b7ok Sok value.ok.nil },\n  case c0.step.nop\u2081 : _ C h {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, _, si, \u27e8\u27e8\u27e9\u27e9|Kok\u27e9, cases si, cases Kok.eq_none, cases t\u03c4,\n    exact h.ok \u03c3ok Eok \u03b7ok Sok value.ok.nil },\n  case c0.step.nop\u2082 : C s K {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, _, si, \u27e8\u27e8\u27e9\u27e9|Kok\u27e9, cases si,\n    rcases Kok.cons_inv \u03c3ok \u03b7ok with \u27e8\u0394', \u03c3', \u03b4', \u03c3ok', \u03b7ok', sok, si', Kok\u27e9,\n    exact state.ok.stmt t \u27e8\u03c3ok', Eok, \u03b7ok', Sok\u27e9 t\u03c4 sok si' Kok },\n  case c0.step.seq : C s\u2081 s\u2082 K {\n    rcases sok with \u27e8_, _, _, _, _, \u03c4, _, _, _, t,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      t\u03c4, sok, si, Kok\u27e9, cases si, cases id sok, rcases Kok with \u27e8\u27e8\u27e9\u27e9|Kok,\n    { exact state.ok.stmt t \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 t\u03c4 a si_a (or.inl Kok_a) },\n    { exact state.ok.stmt t \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 t\u03c4 a si_a\n        (or.inr $ stmt_list.ok.one a_1 Kok_a si_a_1) },\n    { exact state.ok.stmt t \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 t\u03c4 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 _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, \u27e8\u27e9, t\u03c4\u27e9, Kok\u27e9, cases t\u03c4,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 value.ok.int Kok },\n  case c0.step.bool : C b K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, \u27e8\u27e9, t\u03c4\u27e9, Kok\u27e9, cases t\u03c4,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 value.ok.bool Kok },\n  case c0.step.null : C K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, \u27e8\u27e9, t\u03c4\u27e9, Kok\u27e9, cases t\u03c4,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 value.ok.null Kok },\n  case c0.step.var : C i v K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8_, _|_|_|\u27e8_, t, i\u0394\u27e9, t\u03c4\u27e9, Kok\u27e9,\n    rcases finmap.exists_mem_lookup_iff.2 (finmap.mem_keys.1 eu) with \u27e8\u03c4', i\u03c4'\u27e9,\n    cases vtype.of_ty_determ t\u03c4 (\u03c3ok.ok_of_mem i\u03c4' i\u0394),\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 (\u03b7ok.ok_of_mem i\u03c4' H_a) Kok },\n  case c0.step.binop\u2081 : C op e\u2081 e\u2082 K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      \u27e8eu\u2081, eu\u2082\u27e9, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    rcases vtype.of_ty_fn (exp.type.reg eok_\u03c4\u2081) with \u27e8v\u03c4\u2081, hv\u2081\u27e9,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu\u2081 \u27e8\u27e9\n      \u27e8_, eok_a, hv\u2081\u27e9 (cont.ok.binop\u2081 eok_a_2 hv\u2081 t\u03c4 eok_a_1 eu\u2082 Kok) },\n  case c0.step.binop\u2082 : C op v\u2081 e\u2082 K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 Kok_a_4 \u27e8\u27e9 \u27e8_, Kok_a_3, Kok_a_1\u27e9\n      (cont.ok.binop\u2082 Kok_a Kok_a_1 Kok_a_2 vok Kok_a_5) },\n  case c0.step.binop\u2083 : C op v\u2081 v\u2082 v K sb {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok\u2082, Kok\u27e9, cases Kok,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9\n      (sb.ok Kok_a Kok_a_1 Kok_a_2 Kok_a_3 vok\u2082) Kok_a_4 },\n  case c0.step.binop_err : C op v\u2081 v\u2082 err K sb { apply state.ok.err },\n  case c0.step.unop\u2081 : C op e K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    rcases vtype.of_ty_fn (exp.type.reg eok_\u03c4\u2081) with \u27e8v\u03c4\u2081, hv\u2081\u27e9,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu \u27e8\u27e9\n      \u27e8_, eok_a, hv\u2081\u27e9 (cont.ok.unop eok_a_1 hv\u2081 t\u03c4 Kok) },\n  case c0.step.unop\u2082 : C op v v' K su {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9\n      (su.ok Kok_a Kok_a_1 Kok_a_2 vok) Kok_a_3 },\n  case c0.step.cond\u2081 : C c e\u2081 e\u2082 K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      \u27e8euc, eu\u2081, eu\u2082\u27e9, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 euc \u27e8\u27e9 \u27e8_, eok_a, vtype.of_ty.bool\u27e9\n      (cont.ok.cond \u27e8_, eok_a_1, t\u03c4\u27e9 eu\u2081 \u27e8_, eok_a_2, t\u03c4\u27e9 eu\u2082 Kok) },\n  case c0.step.cond\u2082 : C b e\u2081 e\u2082 K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok,\n    cases b,\n    { exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 Kok_a_3 \u27e8\u27e9 Kok_a_2 Kok_a_4 },\n    { exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 Kok_a_1 \u27e8\u27e9 Kok_a Kok_a_4 } },\n  case c0.step.nil : C K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, \u27e8\u27e9, t\u03c4\u27e9, Kok\u27e9, cases t\u03c4,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 value.ok.nil Kok },\n  case c0.step.cons\u2081 : C e es K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      \u27e8eu\u2081, eu\u2082\u27e9, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok, cases t\u03c4,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu\u2081 \u27e8\u27e9 \u27e8_, eok_a, t\u03c4_a\u27e9\n      (cont.ok.cons\u2081 \u27e8_, eok_a_1, t\u03c4_a_1\u27e9 eu\u2082 Kok) },\n  case c0.step.cons\u2082 : C v es K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 Kok_a_1 \u27e8\u27e9 Kok_a\n      (cont.ok.cons\u2082 vok Kok_a_2) },\n  case c0.step.cons\u2083 : C v\u2081 v\u2082 K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok\u2082, Kok\u27e9, cases Kok,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9\n      (value.ok.cons Kok_a vok\u2082) Kok_a_1 },\n  case c0.step.call\u2081 : C op e K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      \u27e8fok, eu\u27e9, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    rcases vtype.of_ty_fn (exp.type.ls eok_\u03c4s) with \u27e8v\u03c4s, t\u03c4s\u27e9,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu \u27e8\u27e9\n      \u27e8_, eok_a_1, t\u03c4s\u27e9 (cont.ok.call eok_a fok t\u03c4 t\u03c4s Kok) },\n  case c0.step.call\u2082 : H S \u03b7 \u03b7' f \u03c4 \u0394' s vs K bok sc {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok,\n    cases ok.fdef_uniq bok.get_fdef Kok_a,\n    rcases sc.ok Kok_a_3 vok with \u27e8\u03c3', \u03c3ok', \u03b7ok', ss, _\u27e9,\n    rcases get_body_ok' ok.ind bok with \u27e8sok, r\u27e9,\n    rcases ok.ok_init bok with \u27e8\u03b4, si\u27e9,\n    rcases si.mono ss with \u27e8\u03b4', ss', si'\u27e9,\n    exact state.ok.stmt _ \u27e8\u03c3ok', Eok, \u03b7ok', Sok.cons \u03c3ok \u03b7ok Kok_a_4\u27e9\n      Kok_a_2 sok si' (r.imp_right stmt_list.ok.nil) },\n  case c0.step.call_extern : H S \u03b7 f vs H' v K ext {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok,\n    rcases iok ext Kok_a Kok_a_2 Kok_a_3 Eok vok with \u27e8E', EE, Eok', vok'\u27e9,\n    exact state.ok.ret \u27e8\u03c3ok, Eok', \u03b7ok.mono EE, Sok.mono EE\u27e9\n       vok' (Kok_a_4.mono EE) },\n  case c0.step.deref : C e K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu \u27e8\u27e9 \u27e8_, eok_a, t\u03c4.ref\u27e9\n      (cont.ok.addr_deref $ cont.ok.deref Kok) },\n  case c0.step.index : C e n K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      \u27e8eu\u2081, eu\u2082\u27e9, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu\u2081 \u27e8\u27e9 \u27e8_, eok_a, t\u03c4.arr\u27e9\n      (cont.ok.addr_index\u2081 eok_a_1 eu\u2082 $ cont.ok.deref Kok) },\n  case c0.step.field : C e n K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu\n      (lv_ok_of_struct ok.ind eok_a) \u27e8_, eok_a, vtype.of_ty.struct\u27e9\n      (cont.ok.addr_field eok_a_1 eok_a_2 t\u03c4 $ cont.ok.deref Kok) },\n  case c0.step.deref' : _ C a K sd {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      aok, Kok\u27e9, cases Kok,\n    exact sd.ok \u03c3ok Eok \u03b7ok Sok aok Kok_a },\n  case c0.step.alloc_ref : _ C \u03c4 \u03c4' v K \u03c4\u03c4' v0 sa {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    cases ast.eval_ty.determ ok.ind \u03c4\u03c4' eok_a, cases t\u03c4,\n    refine sa.ok \u03c3ok Eok \u03b7ok Sok (v0.ok' ok _ t\u03c4_a) Kok },\n  case c0.step.alloc_arr\u2081 : C \u03c4 \u03c4' e K \u03c4\u03c4' {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    cases ast.eval_ty.determ ok.ind \u03c4\u03c4' eok_a, cases t\u03c4,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu \u27e8\u27e9 \u27e8_, eok_a_2, vtype.of_ty.int\u27e9\n      (cont.ok.alloc_arr t\u03c4 eok_a_1 Kok) },\n  case c0.step.alloc_arr\u2082 : _ C \u03c4 v K i n e v0 sa {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok, cases Kok_a,\n    exact step_alloc_arr.ok \u03c3ok Eok \u03b7ok Sok\n      (v0.ok' ok _ Kok_a_a).repeat.arr Kok_a_2 sa },\n  case c0.step.alloc_arr_err : C \u03c4 i K i0 { apply state.ok.err },\n  case c0.step.addr_var : C v K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    rcases finmap.exists_mem_lookup_iff.2 (finmap.mem_keys.1 eu) with \u27e8\u03c4', v\u03c4'\u27e9,\n    cases vtype.of_ty_determ (\u03c3ok.ok_of_mem v\u03c4' eok_a) t\u03c4,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 (addr.ok.var v\u03c4') Kok },\n  case c0.step.addr_deref\u2081 : C e K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu \u27e8\u27e9 \u27e8_, eok_a, t\u03c4.ref\u27e9\n      (cont.ok.addr_deref Kok) },\n  case c0.step.addr_deref\u2082 : C v K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok,\n    refine state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 (addr.ok.ref_opt vok) Kok_a },\n  case c0.step.addr_index\u2081 : C e n K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      \u27e8eu\u2081, eu\u2082\u27e9, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu\u2081 \u27e8\u27e9 \u27e8_, eok_a, t\u03c4.arr\u27e9\n      (cont.ok.addr_index\u2081 eok_a_1 eu\u2082 Kok) },\n  case c0.step.addr_index\u2082 : C a n K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      vok, Kok\u27e9, cases Kok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 Kok_a_1 \u27e8\u27e9\n      \u27e8_, Kok_a, vtype.of_ty.int\u27e9\n      (cont.ok.addr_index\u2082 (addr.ok.refarr_opt vok) Kok_a_2) },\n  case c0.step.addr_index\u2083 : C a n K i j len e lt {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      _, Kok\u27e9, cases Kok,\n    cases len with _ _ v aok,\n    cases Kok_a _ rfl with n h,\n    cases addr.get.ok \u03c3ok Eok \u03b7ok h aok,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 (h.nth lt) Kok_a_1 },\n  case c0.step.addr_index_err\u2081 : C i K { apply state.ok.err },\n  case c0.step.addr_index_err\u2082 : C a n K i { apply state.ok.err },\n  case c0.step.addr_field\u2081 : C e f K {\n    rcases sok with _|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      eu, _, \u27e8t, eok, t\u03c4\u27e9, Kok\u27e9, cases eok,\n    exact state.ok.exp \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9 eu\n      (lv_ok_of_struct ok.ind eok_a) \u27e8_, eok_a, vtype.of_ty.struct\u27e9\n      (cont.ok.addr_field eok_a_1 eok_a_2 t\u03c4 Kok) },\n  case c0.step.addr_field\u2082 : C a f K {\n    rcases sok with _|_|\u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, ret, \u03c4, \u03b1, v, K,\n      \u27e8E, \u03c3s, \u03c3, H, \u03b7, S, \u0394, _, \u03c3ok, Eok, \u03b7ok, Sok\u27e9,\n      aok, Kok\u27e9, cases Kok,\n    exact state.ok.ret \u27e8\u03c3ok, Eok, \u03b7ok, Sok\u27e9\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 LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((a3).write i1 (v3)) = (a3) \u2192 ((a3).read i1) \u2260 (v3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test64.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.22428679240835314}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v2) \u2260 ((((a3).write i3 (v2)).write i2 (v2)).read i3) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test34.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5078118642792044, "lm_q2_score": 0.4416730056646256, "lm_q1q2_score": 0.22428679240835314}}
{"text": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        (v2) \u2260 ((((a3).write i2 (v2)).write i3 (v2)).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.4378234991142019, "lm_q1q2_score": 0.22404155442641654}}
{"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 {\u03b9 : Type} (impl : \u03b9 \u2192 bitstring \u2192 bitstring) : code \u03b9 \u2192 bitstring \u2192. \u2115\n| (code.oracle i) := \u03bb b, pure 1\n| (code.pair c\u2081 c\u2082) := \u03bb v, (+1) <$> (time c\u2081 v) + (time c\u2082 v)\n| (code.comp c\u2081 c\u2082) := \u03bb v, (+1) <$> (time c\u2082 v) + (c\u2082.eval impl v >>= time c\u2081)\n| (code.case c\u2081 c\u2082) := \u03bb v, (+1) <$> (if v.head = ff then time c\u2081 v.tail else time c\u2082 v.tail)\n| (code.fix f) := \u03bb v\u2080, (@pfun.fix (bitstring \u00d7 \u2115) \u2115 $ \n  \u03bb vt, (time f vt.1) >>= \u03bb t',\n    (f.eval impl vt.1).map (\u03bb v' : bitstring,\n      if v'.head = ff then sum.inl (vt.2+t')\n      else sum.inr (v'.tail, vt.2+t'))\n  ) (v\u2080, 0)\n\nvariables {\u03b9 : Type} (impl : \u03b9 \u2192 bitstring \u2192 bitstring)\n\nlemma time_dom_iff_eval_dom (c : code \u03b9) (b : bitstring) : (time impl c b).dom \u2194 (c.eval impl b).dom :=\nbegin\n  induction c generalizing b,\n  case code.oracle { simp [time], refl, },\n  case code.pair : c\u2081 c\u2082 c\u2081ih c\u2082ih { simp only [time, code.eval, (+), (<*>)], simp [c\u2081ih, c\u2082ih], },\n  case code.comp : c\u2081 c\u2082 c\u2081ih c\u2082ih { simp only [time, code.eval, (+), (<*>)], simp [c\u2081ih, c\u2082ih], tauto, },\n  case code.case : c\u2081 c\u2082 c\u2081ih c\u2082ih { simp only [time, code.eval], split_ifs; simp [c\u2081ih, c\u2082ih], },\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 \u27e8he, _\u27e9,\n      split_ifs at h, { contradiction, },\n      rw \u2190 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\u2081 n\u2082 hn\u2082 b hb h,\n    refine \u27e8b.tail, b, hb, _\u27e9,\n    split_ifs at h \u22a2, { refl, }, { contradiction, }, }\nend\n\nvariables (c : code \u03b9) (bound : \u2115 \u2192 \u2115)\ndef time_bound : Prop :=\n\u2200 (b : bitstring) (l : \u2115), b.sizeof \u2264 l \u2192 \u2203 t \u2208 time impl c b, t \u2264 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 \u2190 time_dom_iff_eval_dom,\n  obtain \u27e8n, t, _\u27e9 := H b b.sizeof (by refl),\n  rw part.dom_iff_mem, use n, assumption,\nend\n\nlemma time_bound_oracle (i : \u03b9) :\n  time_bound impl (code.oracle i) 1 :=\nby { intros _ _ _, refine \u27e81, _, (by refl)\u27e9, simp [time], }\n\n\nlemma time_bound_pair (c\u2081 c\u2082 : code \u03b9) {b\u2081 b\u2082 : \u2115 \u2192 \u2115} (hb\u2081 : time_bound impl c\u2081 b\u2081) (hb\u2082 : time_bound impl c\u2082 b\u2082) :\n  time_bound impl (code.pair c\u2081 c\u2082) (\u03bb n, b\u2081 n + b\u2082 n + 1) :=\nbegin\n  intros b l hb, simp only [time],\n  obtain \u27e8t\u2081, ht\u2081, t\u2081_le\u27e9 := hb\u2081 b l hb,\n  obtain \u27e8t\u2082, ht\u2082, t\u2082_le\u27e9 := hb\u2082 b l hb,\n  use t\u2081 + t\u2082 + 1, split, swap, { linarith, },\n  simp only [part.eq_some_iff.mpr ht\u2081, part.eq_some_iff.mpr ht\u2082, (+), (<*>)], 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": "import LMT\n\nvariable {I} [Nonempty I] {E} [Nonempty E] [Nonempty (A I E)]\n\nexample {a1 a2 a3 : A I E} :\n        ((a3).read i2) \u2260 (((a3).write i1 ((a3).read i2)).read i2) \u2192 False := by\n  arr\n", "meta": {"author": "abdoo8080", "repo": "ar-project", "sha": "303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8", "save_path": "github-repos/lean/abdoo8080-ar-project", "path": "github-repos/lean/abdoo8080-ar-project/ar-project-303af2d62cf8c8fe996c9670f9fe5a0cc90e5bb8/Test/Lean/Test8.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.4301473485858429, "lm_q1q2_score": 0.22347071917150488}}
{"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 \u2192 F\nvariable  \u03c3 : 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 \u03c3.pc\n    (h_mem : mem_at mem code_ec_double \u03c3.pc)\n    -- all dependencies are in memory\n    (h_mem_4 : mem_at mem code_nondet_bigint3 (\u03c3.pc  - 244))\n    (h_mem_5 : mem_at mem code_unreduced_mul (\u03c3.pc  - 232))\n    (h_mem_6 : mem_at mem code_unreduced_sqr (\u03c3.pc  - 212))\n    (h_mem_7 : mem_at mem code_verify_zero (\u03c3.pc  - 196))\n    (h_mem_12 : mem_at mem code_compute_doubling_slope (\u03c3.pc  - 68))\n    -- input arguments on the stack\n    (hin_range_check_ptr : range_check_ptr = mem (\u03c3.fp - 9))\n    (hin_point : point = cast_EcPoint mem (\u03c3.fp - 8))\n    (\u03bdbound : \u2115)\n    -- conclusion\n  : ensuresb_ret \u03bdbound mem\n    {pc := \u03c3.pc + 14, ap := ap, fp := \u03c3.fp}\n    (\u03bb \u03ba \u03c4,\n      \u2203 \u03bc \u2264 \u03ba, rc_ensures mem (rc_bound F) \u03bc (mem (\u03c3.fp - 9)) (mem $ \u03c4.ap - 7)\n        (auto_spec_ec_double_block5 mem \u03ba range_check_ptr point (mem (\u03c4.ap - 7)) (cast_EcPoint mem (\u03c4.ap - 6)))) :=\nbegin\n  have h_mem_rec := h_mem,\n  unpack_memory code_ec_double at h_mem with \u27e8hpc0, 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\u27e9,\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 \u03ba_call23 ap23 h_call23,\n  rcases h_call23 with \u27e8h_call23_ap_offset, h_call23\u27e9,\n  rcases h_call23 with \u27e8rc_m23, rc_mle23, hl_range_check_ptr\u2081, h_call23\u27e9,\n  generalize' hr_rev_range_check_ptr\u2081: mem (ap23 - 4) = range_check_ptr\u2081,\n  have htv_range_check_ptr\u2081 := hr_rev_range_check_ptr\u2081.symm, clear hr_rev_range_check_ptr\u2081,\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\u2081 },\n  rw [\u2190htv_range_check_ptr\u2081, \u2190hin_range_check_ptr] at hl_range_check_ptr\u2081,\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\u2081, 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 \u03ba_call25 ap25 h_call25,\n  rcases h_call25 with \u27e8h_call25_ap_offset, h_call25\u27e9,\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\u2081 _ _),\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\u2081, 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 \u03ba_call28 ap28 h_call28,\n  rcases h_call28 with \u27e8h_call28_ap_offset, h_call28\u27e9,\n  rcases h_call28 with \u27e8rc_m28, rc_mle28, hl_range_check_ptr\u2082, h_call28\u27e9,\n  generalize' hr_rev_range_check_ptr\u2082: mem (ap28 - 4) = range_check_ptr\u2082,\n  have htv_range_check_ptr\u2082 := hr_rev_range_check_ptr\u2082.symm, clear hr_rev_range_check_ptr\u2082,\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\u2082 },\n  try { rw [h_call25_ap_offset] at hl_range_check_ptr\u2082 }, try { arith_simps at hl_range_check_ptr\u2082 },\n  rw [\u2190htv_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2081] at hl_range_check_ptr\u2082,\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 [\u2190htv_range_check_ptr\u2081, hl_range_check_ptr\u2081, 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\u2082 _ _),\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\u2081, htv_slope, htv_slope_sqr, htv_range_check_ptr\u2082, 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 \u03ba_call31 ap31 h_call31,\n  rcases h_call31 with \u27e8h_call31_ap_offset, h_call31\u27e9,\n  rcases h_call31 with \u27e8rc_m31, rc_mle31, hl_range_check_ptr\u2083, h_call31\u27e9,\n  generalize' hr_rev_range_check_ptr\u2083: mem (ap31 - 4) = range_check_ptr\u2083,\n  have htv_range_check_ptr\u2083 := hr_rev_range_check_ptr\u2083.symm, clear hr_rev_range_check_ptr\u2083,\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\u2083 },\n  rw [\u2190htv_range_check_ptr\u2083, \u2190htv_range_check_ptr\u2082] at hl_range_check_ptr\u2083,\n  try { simp only [arg0] at h_call31 },\n  rw [\u2190htv_range_check_ptr\u2082, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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\u2083 {\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\u2081, htv_slope, htv_slope_sqr, htv_range_check_ptr\u2082, htv_new_x, htv_range_check_ptr\u2083, 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\u2081, htv_slope, htv_slope_sqr, htv_range_check_ptr\u2082, htv_new_x, htv_range_check_ptr\u2083, 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 \u03ba_call49 ap49 h_call49,\n  rcases h_call49 with \u27e8h_call49_ap_offset, h_call49\u27e9,\n  rcases h_call49 with \u27e8rc_m49, rc_mle49, hl_range_check_ptr\u2084, h_call49\u27e9,\n  generalize' hr_rev_range_check_ptr\u2084: mem (ap49 - 1) = range_check_ptr\u2084,\n  have htv_range_check_ptr\u2084 := hr_rev_range_check_ptr\u2084.symm, clear hr_rev_range_check_ptr\u2084,\n  try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at hl_range_check_ptr\u2084 },\n  rw [\u2190htv_range_check_ptr\u2084, \u2190htv_range_check_ptr\u2083] at hl_range_check_ptr\u2084,\n  try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at h_call49 },\n  rw [\u2190htv_range_check_ptr\u2083, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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\u2081, htv_slope, htv_slope_sqr, htv_range_check_ptr\u2082, htv_new_x, htv_range_check_ptr\u2083, htv_new_y, htv_range_check_ptr\u2084] },\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\u2081, htv_slope, htv_slope_sqr, htv_range_check_ptr\u2082, htv_new_x, htv_range_check_ptr\u2083, htv_new_y, htv_range_check_ptr\u2084] },\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 \u03ba_call57 ap57 h_call57,\n  rcases h_call57 with \u27e8h_call57_ap_offset, h_call57\u27e9,\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\u2084 {\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\u2081, htv_slope, htv_slope_sqr, htv_range_check_ptr\u2082, htv_new_x, htv_range_check_ptr\u2083, htv_new_y, htv_range_check_ptr\u2084, 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\u2081, htv_slope, htv_slope_sqr, htv_range_check_ptr\u2082, htv_new_x, htv_range_check_ptr\u2083, htv_new_y, htv_range_check_ptr\u2084, 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 \u03ba_call66 ap66 h_call66,\n  rcases h_call66 with \u27e8h_call66_ap_offset, h_call66\u27e9,\n  rcases h_call66 with \u27e8rc_m66, rc_mle66, hl_range_check_ptr\u2085, h_call66\u27e9,\n  generalize' hr_rev_range_check_ptr\u2085: mem (ap66 - 1) = range_check_ptr\u2085,\n  have htv_range_check_ptr\u2085 := hr_rev_range_check_ptr\u2085.symm, clear hr_rev_range_check_ptr\u2085,\n  try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6] at hl_range_check_ptr\u2085 },\n  try { rw [h_call57_ap_offset] at hl_range_check_ptr\u2085 }, try { arith_simps at hl_range_check_ptr\u2085 },\n  rw [\u2190htv_range_check_ptr\u2085, \u2190htv_range_check_ptr\u2084] at hl_range_check_ptr\u2085,\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 [\u2190htv_range_check_ptr\u2084, hl_range_check_ptr\u2084, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u2190htv_range_check_ptr\u2085, hl_range_check_ptr\u2085, hl_range_check_ptr\u2084, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u03ba_call23],\n  use_only [range_check_ptr\u2081],\n  use_only [slope],\n  have rc_h_range_check_ptr\u2081 := range_checked_offset' rc_h_range_check_ptr,\n  have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n  have spec23 := h_call23 rc_h_range_check_ptr',\n  rw [\u2190hin_range_check_ptr, \u2190htv_range_check_ptr\u2081] at spec23,\n  try { dsimp at spec23, arith_simps at spec23 },\n  use_only [spec23],\n  use_only [\u03ba_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 [\u03ba_call28],\n  use_only [range_check_ptr\u2082],\n  use_only [new_x],\n  have rc_h_range_check_ptr\u2082 := range_checked_offset' rc_h_range_check_ptr\u2081,\n  have rc_h_range_check_ptr\u2082' := range_checked_add_right rc_h_range_check_ptr\u2082, try { norm_cast at rc_h_range_check_ptr\u2082' },\n  have spec28 := h_call28 rc_h_range_check_ptr\u2081',\n  rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190htv_range_check_ptr\u2082] at spec28,\n  try { dsimp at spec28, arith_simps at spec28 },\n  use_only [spec28],\n  use_only [\u03ba_call31],\n  use_only [range_check_ptr\u2083],\n  use_only [new_y],\n  have rc_h_range_check_ptr\u2083 := range_checked_offset' rc_h_range_check_ptr\u2082,\n  have rc_h_range_check_ptr\u2083' := range_checked_add_right rc_h_range_check_ptr\u2083, try { norm_cast at rc_h_range_check_ptr\u2083' },\n  have spec31 := h_call31 rc_h_range_check_ptr\u2082',\n  rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2083] at spec31,\n  try { dsimp at spec31, arith_simps at spec31 },\n  use_only [spec31],\n  use_only [\u03ba_call49],\n  use_only [range_check_ptr\u2084],\n  have rc_h_range_check_ptr\u2084 := range_checked_offset' rc_h_range_check_ptr\u2083,\n  have rc_h_range_check_ptr\u2084' := range_checked_add_right rc_h_range_check_ptr\u2084, try { norm_cast at rc_h_range_check_ptr\u2084' },\n  have spec49 := h_call49 rc_h_range_check_ptr\u2083',\n  rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190hl_range_check_ptr\u2083, \u2190htv_range_check_ptr\u2084] at spec49,\n  try { dsimp at spec49, arith_simps at spec49 },\n  use_only [spec49],\n  use_only [\u03ba_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 [\u03ba_call66],\n  use_only [range_check_ptr\u2085],\n  have rc_h_range_check_ptr\u2085 := range_checked_offset' rc_h_range_check_ptr\u2084,\n  have rc_h_range_check_ptr\u2085' := range_checked_add_right rc_h_range_check_ptr\u2085, try { norm_cast at rc_h_range_check_ptr\u2085' },\n  have spec66 := h_call66 rc_h_range_check_ptr\u2084',\n  rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082, \u2190hl_range_check_ptr\u2083, \u2190hl_range_check_ptr\u2084, \u2190htv_range_check_ptr\u2085] 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\u2081, htv_slope, htv_slope_sqr, htv_range_check_ptr\u2082, htv_new_x, htv_range_check_ptr\u2083, htv_new_y, htv_range_check_ptr\u2084, htv_x_diff_slope, htv_range_check_ptr\u2085] }, },\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 \u03c3.pc\n    (h_mem : mem_at mem code_ec_double \u03c3.pc)\n    -- all dependencies are in memory\n    (h_mem_4 : mem_at mem code_nondet_bigint3 (\u03c3.pc  - 244))\n    (h_mem_5 : mem_at mem code_unreduced_mul (\u03c3.pc  - 232))\n    (h_mem_6 : mem_at mem code_unreduced_sqr (\u03c3.pc  - 212))\n    (h_mem_7 : mem_at mem code_verify_zero (\u03c3.pc  - 196))\n    (h_mem_12 : mem_at mem code_compute_doubling_slope (\u03c3.pc  - 68))\n    -- input arguments on the stack\n    (hin_range_check_ptr : range_check_ptr = mem (\u03c3.fp - 9))\n    (hin_point : point = cast_EcPoint mem (\u03c3.fp - 8))\n    -- conclusion\n  : ensures_ret mem \u03c3 (\u03bb \u03ba \u03c4,\n      \u2203 \u03bc \u2264 \u03ba, rc_ensures mem (rc_bound F) \u03bc (mem (\u03c3.fp - 9)) (mem $ \u03c4.ap - 7)\n        (spec_ec_double mem \u03ba range_check_ptr point (mem (\u03c4.ap - 7)) (cast_EcPoint mem (\u03c4.ap - 6)))) :=\nbegin\n  apply ensures_of_ensuresb, intro \u03bdbound,\n  have h_mem_rec := h_mem,\n  unpack_memory code_ec_double at h_mem with \u27e8hpc0, 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\u27e9,\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 \u2260 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 \u03c3 _ 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 \u03bdbound),\n        intros \u03ba_block5 \u03c4, try { arith_simps },\n        intro h_block5,\n        rcases h_block5 with \u27e8rc_m_block5, rc_m_le_block5, hblk_range_check_ptr\u2081, h_block5\u27e9,\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\u2081] },\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\u2081 := range_checked_offset' rc_h_range_check_ptr,\n        have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n        have h_block5' := h_block5 rc_h_range_check_ptr',\n        try { rw [\u2190hin_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[\u03ba_block5],\n        use [h_block5],\n        try { linarith }\n      }\n    },\n    {\n      -- if: negative branch\n      have a2 : point.x.d1 \u2260 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 \u03c3 _ 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 \u03bdbound),\n      intros \u03ba_block5 \u03c4, try { arith_simps },\n      intro h_block5,\n      rcases h_block5 with \u27e8rc_m_block5, rc_m_le_block5, hblk_range_check_ptr\u2081, h_block5\u27e9,\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\u2081] },\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\u2081 := range_checked_offset' rc_h_range_check_ptr,\n      have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n      have h_block5' := h_block5 rc_h_range_check_ptr',\n      try { rw [\u2190hin_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[\u03ba_block5],\n      use [h_block5],\n      try { linarith }\n    }\n  },\n  {\n    -- if: negative branch\n    have a0 : point.x.d0 \u2260 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 \u03c3 _ 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 \u03bdbound),\n    intros \u03ba_block5 \u03c4, try { arith_simps },\n    intro h_block5,\n    rcases h_block5 with \u27e8rc_m_block5, rc_m_le_block5, hblk_range_check_ptr\u2081, h_block5\u27e9,\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\u2081] },\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\u2081 := range_checked_offset' rc_h_range_check_ptr,\n    have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n    have h_block5' := h_block5 rc_h_range_check_ptr',\n    try { rw [\u2190hin_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[\u03ba_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 \u27f6 Y) (g : Y \u27f6 Z) (w : f \u226b 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} \u2964 _) :=\n\u27e8\u03bb X Y f g, rfl\u27e9\n\nlemma evaluation_exact (S : ExtrDisc.{u}) :\n  functor.exact (Condensed.evaluation _ S.val : Condensed.{u} Ab.{u+1} \u2964 _) :=\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) \u2245\n  homology (f.val.app (op S.val)) (g.val.app (op S.val))\n    (by { rw [\u2190 f.val.comp_app, \u2190 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 \u22d9 Condensed.evaluation _ S.val \u2245\n  (Condensed.evaluation _ S.val).map_homological_complex _ \u22d9 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": "-- import ..src.struct_tact\n\n-- lemma test :\n--     forall (o1 : option nat) (o2 : nat \u2192 option nat) n\n--         o1 >>= o2 = some n ->\n\n", "meta": {"author": "uwplse", "repo": "struct_tact", "sha": "22188ea2e97705d1185f75dde24e6bab88054ab0", "save_path": "github-repos/lean/uwplse-struct_tact", "path": "github-repos/lean/uwplse-struct_tact/struct_tact-22188ea2e97705d1185f75dde24e6bab88054ab0/test/simp_option.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.2226602158281952}}
{"text": "/- Enumerable and the Decidable instance may already be in Mathlib -/\n\nclass Enumerable (\u03b1 : Type u) where\n  elems    : List \u03b1\n  complete : \u2200 a : \u03b1, a \u2208 elems\n\ndef List.allTrue (p : \u03b1 \u2192 Prop) [(a : \u03b1) \u2192 Decidable (p a)] : List \u03b1 \u2192 Bool\n  | [] => true\n  | a :: as => p a && allTrue p as\n\ntheorem List.of_allTrue [(a : \u03b1) \u2192 Decidable (p a)] (hc : allTrue p as) (hin : a \u2208 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 : \u03b1) \u2192 Decidable (p a)] (h : \u2200 a, p a) : allTrue p as := by\n  induction as <;> simp [allTrue, *]\n\ninstance [Enumerable \u03b1] (p : \u03b1 \u2192 Prop) [(a : \u03b1) \u2192 Decidable (p a)] : Decidable (\u2200 a, p a) :=\n  have : List.allTrue p Enumerable.elems \u2192 (a : \u03b1) \u2192 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 \u2192 States \u2192 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 : \u2200 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 \u2192 F\nvariable  \u03c3 : 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 \u03c3.pc\n    (h_mem : mem_at mem code_unreduced_sqr \u03c3.pc)\n    -- input arguments on the stack\n    (hin_a : a = cast_BigInt3 mem (\u03c3.fp - 5))\n    -- conclusion\n  : ensures_ret mem \u03c3 (\u03bb \u03ba \u03c4, \u03c4.ap = \u03c3.ap + 12 \u2227 spec_unreduced_sqr mem \u03ba a (cast_UnreducedBigInt3 mem (\u03c4.ap - 3))) :=\nbegin\n  apply ensures_of_ensuresb, intro \u03bdbound,\n  have h_mem_rec := h_mem,\n  unpack_memory code_unreduced_sqr at h_mem with \u27e8hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15\u27e9,\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 : \u211d\u22650) :\n  X.Radon_LC p c \u2192 locally_constant X \u211d \u2192 \u211d :=\n\u03bb \u03bc, \u03bc.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 : \u211d\u22650) :\n  X.Radon p c \u2192 C(X,\u211d) \u2192 \u211d :=\n\u03bb \u03bc, \u03bc.1\n\nlemma Radon_LC_to_fun_injective (X : Profinite.{0}) (p c : \u211d\u22650) :\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 : \u211d\u22650) :\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 : \u211d\u22650) :\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 : \u211d\u22650) :\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 \u2192 \u211d) :=\n@Pi.t2_space X (\u03bb _, \u211d) infer_instance\nbegin\n  intros a, dsimp,\n  apply_instance\nend\n\ninstance t2_space_Radon_LC (X : Profinite.{0}) (p c : \u211d\u22650) :\n  t2_space (X.Radon_LC p c) :=\n\u27e8\u03bb 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\u27e9\n\ninstance t2_space_Radon (X : Profinite.{0}) (p c : \u211d\u22650) :\n  t2_space (X.Radon p c) :=\n\u27e8\u03bb f g h, separated_by_continuous (X.Radon_to_fun_continuous p c)\n  $ (X.Radon_to_fun_injective p c).ne h\u27e9\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_comparison_component_equiv_aux (X : Profinite.{0}) (p : \u211d\u22650)\n  (T : discrete_quotient X) :\n  weak_dual \u211d (locally_constant (X.diagram.obj T) \u211d) \u2243\n  real_measures p (X.fintype_diagram.obj T) :=\n{ to_fun := \u03bb \u03bc t,\n    \u03bc (clopens.indicator_LC $\n      discrete_quotient.fibre \u22a5 (discrete_quotient.equiv_bot t)),\n  inv_fun := \u03bb \u03bc,\n  { to_fun := \u03bb e, \u2211 t : T, \u03bc 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 [\u2190 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 (\u03bc t)) _,\n      apply locally_constant.continuous_eval,\n    end },\n  left_inv := begin\n    intros \u03bc, 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 \u03bc.map_sum,\n    apply finset.sum_congr, convert rfl,\n    intros t ht,\n    rw [\u03bc.map_smul, mul_comm], change _ = _ * _,\n    congr' 3, ext w, change _ = _ \u2194 _ = _,\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 \u03bc, 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 _ \u2260 _, 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)]\n  (f : weak_dual \u211d (locally_constant (X.diagram.obj T) \u211d)) :\n  f.bdd_LC p c \u2194\n  X.Radon_LC_comparison_component_equiv_aux p T f \u2208\n    pseudo_normed_group.filtration (real_measures p (X.fintype_diagram.obj T)) c :=\nbegin\n  split,\n  { intros h, change \u2211 (t : T), _ \u2264 _, specialize h \u22a5,\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 \u2211 (e : E), _ \u2264 _,\n    change \u2211 (t : T), _ \u2264 _ at h,\n    dsimp [Radon_LC_comparison_component_equiv_aux] at h,\n    refine le_trans _ h,\n    have : \u2200 e : E,\n      (E.fibre e).indicator_LC =\n      \u2211 t in finset.univ.filter (\u03bb t : T, E.proj t = e),\n        ((\u22a5 : 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 : \u211d) 0 = _, split_ifs with hh hh,\n      { rw finset.sum_eq_single q,\n        change _ = ite (_ = _) (1 : \u211d) _, erw if_pos rfl,\n        { intros t ht hh,\n          change ite (_ = _) _ (0 : \u211d) = 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 \u27e8finset.mem_univ _, hh\u27e9 } },\n      { symmetry, apply finset.sum_eq_zero,\n        intros t ht, rw finset.mem_filter at ht,\n        change ite (_ = _) _ (0 : \u211d) = 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 : \u2211 (x : \u21a5E),\n      \u2225\u2211 (i : \u21a5T) in\n        finset.filter (\u03bb (t : \u21a5T), E.proj t = x) finset.univ,\n        f ((\u22a5 : discrete_quotient T).fibre\n          (discrete_quotient.equiv_bot i)).indicator_LC\u2225\u208a^(p : \u211d) \u2264\n      \u2211 (x : E), \u2211 (i : T) in finset.filter (\u03bb (t : \u21a5T), E.proj t = x) finset.univ,\n        \u2225 f ((\u22a5 : discrete_quotient T).fibre\n          (discrete_quotient.equiv_bot i)).indicator_LC\u2225\u208a^(p : \u211d),\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 \u2190 finset.sum_bUnion,\n    have : finset.univ.bUnion (\u03bb (x : \u21a5E), finset.filter (\u03bb (t : \u21a5T), 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 \u27e8E.proj t, finset.mem_univ _, _\u27e9,\n      rw finset.mem_filter,\n      refine \u27e8finset.mem_univ _, rfl\u27e9 },\n    rw this,\n    intros a ha b hb hh q, dsimp, rw finset.mem_inter, rintros \u27e8h1,h2\u27e9,\n    simp only [finset.not_mem_empty], apply hh,\n    rw finset.mem_filter at h1 h2,\n    rw [\u2190 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  Radon_LC (X.diagram.obj T) p c \u2243\n  pseudo_normed_group.filtration (real_measures p (X.fintype_diagram.obj T)) c :=\n{ to_fun := \u03bb \u03bc, \u27e8X.Radon_LC_comparison_component_equiv_aux p T \u03bc.1,\n    begin\n      rw \u2190 bdd_LC_iff_comparison, exact \u03bc.2,\n    end\u27e9,\n  inv_fun := \u03bb \u03bc, \u27e8(X.Radon_LC_comparison_component_equiv_aux p T).symm \u03bc.1,\n    begin\n      have := \u03bc.2,\n      rw \u2190 (X.Radon_LC_comparison_component_equiv_aux p T).apply_symm_apply \u03bc.val at this,\n      rw \u2190 bdd_LC_iff_comparison at this,\n      exact this,\n    end\u27e9,\n  left_inv := begin\n    intros \u03bc, ext1,\n    apply (X.Radon_LC_comparison_component_equiv_aux p T).symm_apply_apply,\n  end,\n  right_inv := begin\n    intros \u03bc, 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  Radon_LC (X.diagram.obj T) p c \u2243\u209c\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 \u2190 (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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  Radon_LC (X.diagram.obj T) p c \u2245\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 \u27f6 T) (t : T) (q : S) :\n  ((\u22a5 : discrete_quotient T).fibre (discrete_quotient.equiv_bot t)).indicator_LC\n    (X.fintype_diagram.map f q) =\n  \u2211 i : S in finset.univ.filter (\u03bb j, X.fintype_diagram.map f j = t),\n    ((\u22a5 : 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 \u211d S _\n      (finset.filter (\u03bb (j : (X.fintype_diagram.obj S).\u03b1),\n        X.fintype_diagram.map f j = t) finset.univ)\n      (\u03bb i, ((\u22a5 : 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 `\u2133_p`.\n -/\ndef Radon_LC_comparison (X : Profinite.{0}) (p c : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  X.diagram \u22d9 Radon_LC_functor p c \u2245\n  X.fintype_diagram \u22d9 real_measures.functor p \u22d9 CompHausFiltPseuNormGrp\u2081.level.obj c \u22d9\n  CompHaus_to_Top :=\nnat_iso.of_components\n(\u03bb 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\u2081.level,\n    map_Radon_LC, weak_dual.comap\n    ],\n  let aa : weak_dual \u211d (locally_constant S \u211d) := a.1,\n  erw \u2190 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 {\u03b1 : Type*} [setoid \u03b1] (p : \u03b1 \u2192 Prop) [dec : decidable_pred p] (h : \u2200 a b, a \u2248 b \u2192 p a = p b)\n  : decidable_pred (quot.lift p h)\n| x := quot.hrec_on x dec (\u03bb x y r, subsingleton.helim (congr_arg decidable (h x y r)) (dec x) (dec y))\n\nnamespace cpi\nnamespace transition\n\nvariables {\u210d : Type} {\u03c9 : context}\n\n/-- The set of all transitions from a nil species. -/\ndef enumerate_nil {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393}\n  : fintype (transition.transition_from \u2113 species.nil)\n  := \u27e8 finset.empty, (\u03bb \u27e8 k, \u03b1, E, t \u27e9, by cases t) \u27e9\n\n/-- \u03be_choice acts as an embedding. This is effectively \u03be_choice.inj but lifted\n    to transitions. -/\ndef \u03be_choice.embed\n    {\u0393 f} (\u2113 : lookup \u210d \u03c9 \u0393)\n    (\u03c0 : prefix_expr \u210d \u0393 f) (A : species \u210d \u03c9 (f.apply \u0393)) (As : species.choices \u210d \u03c9 \u0393)\n  : transition_from \u2113 (\u03a3# As) \u21aa transition_from \u2113 (\u03a3# (whole.cons \u03c0 A As))\n  := { to_fun := \u03bb t, transition_from.mk (\u03be_choice t.2.2.2),\n       inj := \u03bb \u27e8 k, \u03b1, E, t \u27e9 \u27e8 k', \u03b1', E', t' \u27e9 eq, by { cases eq, from rfl} }\n\nprivate def enumerate_choice_communicate_ts {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) :\n  \u2200 (a :  name \u0393) (b : list (name \u0393)) (y : \u2115)\n    (A : species \u210d \u03c9 (context.extend y \u0393))\n    {As : species.choices \u210d \u03c9 \u0393}\n  , fintype (transition_from \u2113 (\u03a3# As))\n  \u2192 finset (transition_from \u2113 (\u03a3# (whole.cons (a#(b;y)) A As)))\n| a b y A As child :=\n  finset.insert_nmem'\n    (transition_from.mk (choice\u2081 a b rfl y A As))\n    (finset.map (\u03be_choice.embed \u2113 _ A As) child.elems)\n    (\u03bb mem, begin\n      rcases finset.mem_map.mp mem with \u27e8 \u27e8 k, \u03b1, E, t \u27e9, mem, eql \u27e9,\n\n      unfold_coes at eql,\n      simp only [\u03be_choice.embed, transition_from.mk] at eql,\n      unfold_projs at eql,\n      cases eql,\n    end)\n\nprivate def enumerate_choice_communicate {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) :\n  \u2200 (a :  name \u0393) (b : list (name \u0393)) (y : \u2115)\n    (A : species \u210d \u03c9 (context.extend y \u0393))\n    {As : species.choices \u210d \u03c9 \u0393}\n  , fintype (transition_from \u2113 (\u03a3# As))\n  \u2192 fintype (transition_from \u2113 (\u03a3# (whole.cons (a#(b;y)) A As)))\n| a b y A As child :=\n  { elems := enumerate_choice_communicate_ts \u2113 a b y A child,\n    complete := \u03bb x, begin\n      rcases x with \u27e8 k, \u03b1, E, t \u27e9,\n      cases t,\n      case \u03be_choice {\n        have : transition_from.mk t_a \u2208 child.elems := @fintype.complete _ child _,\n        have this := finset.mem_map_of_mem (\u03be_choice.embed \u2113 (a#(b;y)) A As) this,\n        from finset.mem_insert_nmem_of_mem this _,\n      },\n      case choice\u2081 {\n        subst t_b_len,\n        from finset.mem_insert_nmem_self _\n      },\n    end }\n\nprivate def enumerate_choice_spontaneous_ts {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) :\n  \u2200 (k : \u210d) (A : species \u210d \u03c9 \u0393) {As : species.choices \u210d \u03c9 \u0393}\n  , fintype (transition_from \u2113 (\u03a3# As))\n  \u2192 finset (transition_from \u2113 (\u03a3# (whole.cons (\u03c4@k) A As)))\n| k A As child :=\n  finset.insert_nmem'\n    (transition_from.mk (choice\u2082 k A As))\n    (finset.map (\u03be_choice.embed \u2113 _ A As) child.elems)\n    (\u03bb mem, begin\n      rcases finset.mem_map.mp mem with \u27e8 \u27e8 k, \u03b1, E, t \u27e9, mem, eql \u27e9,\n\n      unfold_coes at eql,\n      simp only [\u03be_choice.embed, transition_from.mk] at eql,\n      unfold_projs at eql,\n      cases eql,\n    end)\n\nprivate def enumerate_choice_spontaneous {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) :\n  \u2200 (k : \u210d) (A : species \u210d \u03c9 \u0393) {As : species.choices \u210d \u03c9 \u0393}\n  , fintype (transition_from \u2113 (\u03a3# As))\n  \u2192 fintype (transition_from \u2113 (\u03a3# (whole.cons (\u03c4@k) A As)))\n| k A As child :=\n  { elems := enumerate_choice_spontaneous_ts \u2113 k A child,\n    complete := \u03bb x, begin\n      rcases x with \u27e8 k', \u03b1, E, t \u27e9,\n      cases t,\n      case \u03be_choice {\n        have : transition_from.mk t_a \u2208 child.elems := @fintype.complete _ child _,\n        have this := finset.mem_map_of_mem (\u03be_choice.embed \u2113 (\u03c4@k) A As) this,\n        from finset.mem_insert_nmem_of_mem this _,\n      },\n      case choice\u2082 { from finset.mem_insert_nmem_self _ },\n    end }\n\n/-- The set of all transitions from a guarded choice species. -/\ndef enumerate_choices {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) :\n  \u2200 (As : species.choices \u210d \u03c9 \u0393), fintype (transition_from \u2113 (\u03a3# As))\n| species.whole.empty :=\n  { elems := finset.empty,\n    complete := \u03bb \u27e8 k, \u03b1, E, t \u27e9, by cases t }\n| (species.whole.cons (a#(b; y)) A As) := enumerate_choice_communicate \u2113 a b y A (enumerate_choices As)\n| (species.whole.cons (\u03c4@k) A As) := enumerate_choice_spontaneous \u2113 k A (enumerate_choices As)\n\nprivate def defn.from {\u0393 n} (\u2113 : lookup \u210d \u03c9 \u0393) (D : reference n \u03c9) (as : vector (name \u0393) n)\n  : transition_from \u2113 (\u03a3# (species.rename (name.mk_apply as) (\u2113 _ D)))\n  \u2192 transition_from \u2113 (apply D as)\n| \u27e8 k, \u03b1, E, t \u27e9 := \u27e8 k, \u03b1, E, defn _ _ _ _ rfl t \u27e9\n\nprivate def defn.embed {\u0393 n} (\u2113 : lookup \u210d \u03c9 \u0393) (D : reference n \u03c9) (as : vector (name \u0393) n)\n  : transition_from \u2113 (\u03a3# (species.rename (name.mk_apply as) (\u2113 _ D)))\n  \u21aa transition_from \u2113 (apply D as)\n  := \u27e8 defn.from \u2113 D as, \u03bb t t' eql, begin\n    rcases t with \u27e8 k, \u03b1, E, t \u27e9, rcases t' with \u27e8 k', \u03b1', E', t' \u27e9,\n    simp only [defn.from] at eql,\n\n    rcases sigma.mk.inj eql with \u27e8 \u27e8 _ \u27e9, eql\u2081 \u27e9, clear eql,\n    rcases sigma.mk.inj (eq_of_heq eql\u2081) with \u27e8 \u27e8 _ \u27e9, eql\u2082 \u27e9, clear eql\u2081,\n    rcases sigma.mk.inj (eq_of_heq eql\u2082) with \u27e8 \u27e8 _ \u27e9, eql\u2083 \u27e9, clear eql\u2082,\n    have eql := eq_of_heq (defn.inj (eq_of_heq eql\u2083)).2, clear eql\u2083, subst eql,\n  end \u27e9\n\nprivate def enumerate_apply_ts {\u0393 n} (\u2113 : lookup \u210d \u03c9 \u0393) (D : reference n \u03c9) (as : vector (name \u0393) n)\n  : finset (transition_from \u2113 (apply D as))\n  := finset.map (defn.embed \u2113 D as)\n      (enumerate_choices \u2113 (species.rename (name.mk_apply as) (\u2113 _ D))).elems\n\nprivate lemma enumerate_apply_complete {\u0393 n} (\u2113 : lookup \u210d \u03c9 \u0393) (D : reference n \u03c9) (as : vector (name \u0393) n)\n  : \u2200 x, x \u2208 enumerate_apply_ts \u2113 D as\n| \u27e8 k, \u03b1, E, defn \u2113' D as B eql t \u27e9 := begin\n  subst eql,\n  have h :=\n    @fintype.complete _\n      (enumerate_choices \u2113 (species.rename (name.mk_apply as) (\u2113 _ D)))\n      (transition_from.mk t),\n  from finset.mem_map_of_mem (defn.embed \u2113 D as) h,\nend\n\n/-- The set of all transitions from a species invocation. -/\ndef enumerate_apply {\u0393 n} (\u2113 : lookup \u210d \u03c9 \u0393) (D : reference n \u03c9) (as : vector (name \u0393) n)\n  : fintype (transition_from \u2113 (apply D as)) :=\n  \u27e8 enumerate_apply_ts \u2113 D as, enumerate_apply_complete \u2113 D as \u27e9\n\n/-- Wrap a transition in parL. -/\ndef parL {\u0393 : context} {\u2113 : lookup \u210d \u03c9 \u0393} (A B : species \u210d \u03c9 \u0393)\n  : transition.transition_from \u2113 A \u2192 transition.transition_from \u2113 (A |\u209b B)\n| \u27e8 _, \u03b1, production.species E, t \u27e9 := \u27e8 _, \u03b1, _, transition.parL_species B t \u27e9\n| \u27e8 _, \u03b1, production.concretion E, t \u27e9 := \u27e8 _, \u03b1, _, transition.parL_concretion B t \u27e9\n\n/-- Wrap a transition in parL, as a function embedding. -/\ndef parL.embed {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (A B : species \u210d \u03c9 \u0393)\n  : transition.transition_from \u2113 A \u21aa transition.transition_from \u2113 (A |\u209b B)\n  := \u27e8 parL A B, \u03bb t t' eq, begin\n        rcases t with \u27e8 k, \u03b1, E, t \u27e9, rcases t' with \u27e8 k', \u03b1', E', t' \u27e9,\n          cases E; cases E'; cases eq; from rfl,\n        end \u27e9\n\n/-- Wrap a transition in parR. -/\ndef parR {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (A B : species \u210d \u03c9 \u0393)\n  : transition.transition_from \u2113 B \u2192 transition.transition_from \u2113 (A |\u209b B)\n| \u27e8 _, \u03b1, production.species E, t \u27e9 := \u27e8 _, \u03b1, _, transition.parR_species A t \u27e9\n| \u27e8 _, \u03b1, production.concretion E, t \u27e9 := \u27e8 _, \u03b1, _, transition.parR_concretion A t \u27e9\n\n/-- Wrap a transition in parL, as a function embedding. -/\ndef parR.embed {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (A B : species \u210d \u03c9 \u0393)\n  : transition.transition_from \u2113 B \u21aa transition.transition_from \u2113 (A |\u209b B)\n  := \u27e8 parR A B, \u03bb t t' eq, begin\n        rcases t with \u27e8 k, \u03b1, E, t \u27e9, rcases t' with \u27e8 k', \u03b1', E', t' \u27e9,\n          cases E; cases E'; cases eq; from rfl,\n        end \u27e9\n\n/-- Determine if two transitions result have products with compatible\n    concretions. -/\nprivate def com\u2081.is_compatible {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A B : species \u210d \u03c9 \u0393)\n  : transition.transition_from \u2113 A \u00d7 transition.transition_from \u2113 B\n  \u2192 Prop\n| \u27e8 \u27e8 _, l, @production.concretion _ _ _ a x F, t \u27e9,\n    \u27e8 _, l', @production.concretion _ _ _ b y G, t' \u27e9 \u27e9 := a = y \u2227 b = x\n| \u27e8 \u27e8 _, l, production.concretion F, t \u27e9, \u27e8 _, l', production.species G, t' \u27e9 \u27e9 := false\n| \u27e8 \u27e8 _, l, production.species F, t \u27e9, \u27e8 _, l', production.concretion G, t' \u27e9 \u27e9 := false\n| \u27e8 \u27e8 _, l, production.species F, t \u27e9, \u27e8 _, l', production.species G, t' \u27e9 \u27e9 := false\n\ninstance com\u2081.is_compatible.decide {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A B : species \u210d \u03c9 \u0393)\n  : decidable_pred (com\u2081.is_compatible \u2113 A B)\n| \u27e8 \u27e8 _, l, @production.concretion _ _ _ a x F, t \u27e9,\n    \u27e8 _, l', @production.concretion _ _ _ b y G, t' \u27e9 \u27e9\n    := by { unfold com\u2081.is_compatible, by apply_instance }\n| \u27e8 \u27e8 _, l, production.concretion F, t \u27e9, \u27e8 _, l', production.species G, t' \u27e9 \u27e9 := decidable.false\n| \u27e8 \u27e8 _, l, production.species F, t \u27e9, \u27e8 _, l', production.concretion G, t' \u27e9 \u27e9 := decidable.false\n| \u27e8 \u27e8 _, l, production.species F, t \u27e9, \u27e8 _, l', production.species G, t' \u27e9 \u27e9 := decidable.false\n\n/-- The subtype of all transition pairs which are compatible. -/\n@[nolint has_inhabited_instance]\ndef com\u2081.compatible {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A B : species \u210d \u03c9 \u0393) : Type\n  := { p : transition.transition_from \u2113 A \u00d7 transition.transition_from \u2113 B\n     // com\u2081.is_compatible \u2113 A B p }\n\n/-- Convert a compatible pair of transitions to a com\u2081 transition. -/\ndef com\u2081.of_compatible {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A B : species \u210d \u03c9 \u0393)\n  : com\u2081.compatible \u2113 A B \u2192 transition.transition_from \u2113 (A |\u209b B)\n| \u27e8 \u27e8 \u27e8 _, l, @production.concretion _ _ _ a x F, t \u27e9,\n     \u27e8 _, l', @production.concretion _ _ _ b y G, t' \u27e9 \u27e9, p \u27e9 := begin\n  cases l with _ a, cases l' with _ b, rcases p with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n  refine \u27e8 _, _, _, com\u2081 rfl rfl t t' \u27e9,\nend\n| \u27e8 \u27e8 \u27e8 _, l, production.concretion F, t \u27e9, \u27e8 _, l', production.species G, t' \u27e9 \u27e9, p \u27e9 := false.elim p\n| \u27e8 \u27e8 \u27e8 _, l, production.species F, t \u27e9, \u27e8 _, l', production.concretion G, t' \u27e9 \u27e9, p \u27e9 := false.elim p\n| \u27e8 \u27e8 \u27e8 _, l, production.species F, t \u27e9, \u27e8 _, l', production.species G, t' \u27e9 \u27e9, p \u27e9 := false.elim p\n\n/-- We need a separate lemma to show com\u2081.of_compatible - we need to\n    generalise several variables, otherwise the case splits do not go through.\n-/\nprivate lemma com\u2081.of_compatible.inj_help {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (A B : species \u210d \u03c9 \u0393) :\n  \u2200 {a x} {a\u2081 b\u2081} {F\u2081 : concretion \u210d \u03c9 \u0393 a x} {G\u2081 : concretion \u210d \u03c9 \u0393 x a}\n    {b y} {a\u2082 b\u2082} {F\u2082 : concretion \u210d \u03c9 \u0393 b y} {G\u2082 : concretion \u210d \u03c9 \u0393 y b}\n    {FG\u2081 FG\u2082 : species \u210d \u03c9 \u0393} {\u03b1\u2081 \u03b1\u2082 : label \u210d \u0393 kind.species}\n    (eFG\u2081 : FG\u2081 = concretion.pseudo_apply F\u2081 G\u2081)\n    (eFG\u2082 : FG\u2082 = concretion.pseudo_apply F\u2082 G\u2082)\n    (e\u03b1\u2081 : \u03b1\u2081 = \u03c4\u27e8 a\u2081, b\u2081 \u27e9) (e\u03b1\u2082 : \u03b1\u2082 = \u03c4\u27e8 a\u2082, b\u2082 \u27e9)\n    (tf\u2081 : A [\u2113, #a\u2081]\u27f6 (production.concretion F\u2081)) (tg\u2081 : B [\u2113, #b\u2081]\u27f6 (production.concretion G\u2081))\n    (tf\u2082 : A [\u2113, #a\u2082]\u27f6 (production.concretion F\u2082)) (tg\u2082 : B [\u2113, #b\u2082]\u27f6 (production.concretion G\u2082))\n  , (\u03c4\u27e8 a\u2081, b\u2081 \u27e9 = (\u03c4\u27e8 a\u2082, b\u2082 \u27e9 : label \u210d \u0393 _))\n  \u2192 sigma.mk (production.species FG\u2081) (com\u2081 eFG\u2081 e\u03b1\u2081 tf\u2081 tg\u2081)\n  == sigma.mk (production.species FG\u2082) (com\u2081 eFG\u2082 e\u03b1\u2082 tf\u2082 tg\u2082)\n  \u2192 a = b \u2227 x = y \u2227 a\u2081 = a\u2082 \u2227 b\u2081 = b\u2082 \u2227 F\u2081 == F\u2082 \u2227 G\u2081 == G\u2082 \u2227 tf\u2081 == tf\u2082 \u2227 tg\u2081 == tg\u2082\n| a x a\u2081 b\u2081 F\u2081 G\u2081 b y a\u2082 b\u2082 F\u2082 G\u2082 FG\u2081 FG\u2082 \u03b1\u2081 \u03b1\u2082 eFG\u2081 eFG\u2082 e\u03b1\u2081 e\u03b1\u2082\n  tf\u2081 tg\u2081 tf\u2082 tg\u2082 eq\u03b1 eqT := begin\n  have : \u03b1\u2081 = \u03b1\u2082 := trans e\u03b1\u2081 (trans eq\u03b1 e\u03b1\u2082.symm), subst this,\n  rcases sigma.mk.inj (eq_of_heq eqT) with \u27e8 eqFG, eqT \u27e9,\n  have : FG\u2081 = FG\u2082 := production.species.inj eqFG, subst this,\n\n  rcases com\u2081.inj (eq_of_heq eqT) with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9, F, G, tf, tg \u27e9,\n  from \u27e8 rfl, rfl, rfl, rfl, F, G, tf, tg \u27e9,\nend\n\nprivate lemma com\u2081.of_compatible.inj {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (A B : species \u210d \u03c9 \u0393)\n  : function.injective (com\u2081.of_compatible \u2113 A B)\n| \u27e8 \u27e8 \u27e8 k\u2081, \u03b1\u2081, E\u2081, t\u2081 \u27e9, \u27e8 k\u2081', \u03b1\u2081', E\u2081', t\u2081' \u27e9 \u27e9, is\u2081 \u27e9\n  \u27e8 \u27e8 \u27e8 k\u2082, \u03b1\u2082, E\u2082, t\u2082 \u27e9, \u27e8 k\u2082', \u03b1\u2082', E\u2082', t\u2082' \u27e9 \u27e9, is\u2082 \u27e9 eql := begin\n  cases E\u2081; cases E\u2081'; try { unfold com\u2081.is_compatible at is\u2081, contradiction },\n  rcases is\u2081 with \u27e8 l, r \u27e9, subst l, subst r, cases \u03b1\u2081, cases \u03b1\u2081',\n\n  cases E\u2082; cases E\u2082'; try { unfold com\u2081.is_compatible at is\u2082, contradiction },\n  rcases is\u2082 with \u27e8 l, r \u27e9, subst l, subst r, cases \u03b1\u2082, cases \u03b1\u2082',\n\n  simp only [com\u2081.of_compatible] at eql,\n\n  rcases sigma.mk.inj (eq_of_heq (sigma.mk.inj eql).2) with \u27e8 eq\u03b1, eqT \u27e9,\n  rcases com\u2081.of_compatible.inj_help A B rfl rfl rfl rfl t\u2081 t\u2081' t\u2082 t\u2082' eq\u03b1 eqT\n    with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n  from rfl,\nend\n\n/-- Convert a compatible pair of transitions to a com\u2081 transition. -/\ndef com\u2081.embed {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A B : species \u210d \u03c9 \u0393)\n  : com\u2081.compatible \u2113 A B \u21aa transition.transition_from \u2113 (A |\u209b B)\n  := \u27e8 com\u2081.of_compatible \u2113 A B, com\u2081.of_compatible.inj A B \u27e9\n\nprivate lemma com\u2081.impossible_l {\u0393}\n    (\u2113 : lookup \u210d \u03c9 \u0393) (A B : species \u210d \u03c9 \u0393) {b y}\n    {F : concretion \u210d \u03c9 \u0393 b y} {G : concretion \u210d \u03c9 \u0393 y b}\n  : \u2200 {a\u2081 a\u2082} {C FG : species \u210d \u03c9 \u0393}\n      (t : A [\u2113, \u03c4\u27e8 a\u2081, a\u2082 \u27e9]\u27f6 (production.species C))\n      (t\u2081 : A [\u2113, #a\u2081]\u27f6 (production.concretion F))\n      (t\u2082 : B [\u2113, #a\u2082]\u27f6 (production.concretion G))\n      (h : FG = concretion.pseudo_apply F G)\n    , (C |\u209b B) = FG\n    \u2192 \u00ac (parL_species B t == com\u2081 h rfl t\u2081 t\u2082)\n| a\u2081 a\u2082 C FG t t\u2081 t\u2082 h cfg eql := by { subst cfg, cases (eq_of_heq eql) }\n\nprivate lemma com\u2081.impossible_r {\u0393}\n    (\u2113 : lookup \u210d \u03c9 \u0393) (A B : species \u210d \u03c9 \u0393) {b y}\n    {F : concretion \u210d \u03c9 \u0393 b y} {G : concretion \u210d \u03c9 \u0393 y b}\n  : \u2200 {a\u2081 a\u2082} {C FG : species \u210d \u03c9 \u0393}\n      (t : B [\u2113, \u03c4\u27e8 a\u2081, a\u2082 \u27e9]\u27f6 (production.species C))\n      (t\u2081 : A [\u2113, #a\u2081]\u27f6 (production.concretion F))\n      (t\u2082 : B [\u2113, #a\u2082]\u27f6 (production.concretion G))\n      (h : FG = concretion.pseudo_apply F G)\n    , (A |\u209b C) = FG\n    \u2192 \u00ac (parR_species A t == com\u2081 h rfl t\u2081 t\u2082)\n| a\u2081 a\u2082 C FG t t\u2081 t\u2082 h cfg eql := by { subst cfg, cases (eq_of_heq eql) }\n\nprivate def enumerate_parallel_ts {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (A B : species \u210d \u03c9 \u0393)\n  : fintype (transition.transition_from \u2113 A)\n  \u2192 fintype (transition.transition_from \u2113 B)\n  \u2192 finset (transition.transition_from \u2113 (A |\u209b B))\n| As Bs :=\n  finset.union_disjoint\n    (finset.map\n      (com\u2081.embed \u2113 A B)\n      ((finset.product As.elems Bs.elems).subtype (com\u2081.is_compatible \u2113 A B)))\n    (finset.union_disjoint\n      (As.elems.map (parL.embed A B))\n      (Bs.elems.map (parR.embed A B))\n      (\u03bb x memL memR, begin\n        rcases finset.mem_map.mp memL with \u27e8 \u27e8 k, \u03b1, E, t \u27e9, mem, eql \u27e9, clear mem,\n        unfold_coes at eql, simp only [parL.embed] at eql, subst eql,\n\n        rcases finset.mem_map.mp memR with \u27e8 \u27e8 k', \u03b1', E', t' \u27e9, mem, eql \u27e9, 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    (\u03bb x memL memR, begin\n      rcases finset.mem_map.mp memL with \u27e8 \u27e8 \u27e8 \u27e8 k\u2081, \u03b1\u2081, E\u2081, t\u2081 \u27e9, \u27e8 k\u2082, \u03b1\u2082, E\u2082, t\u2082 \u27e9 \u27e9, d \u27e9, mem, eql \u27e9, clear memL mem,\n      unfold_coes at eql, simp only [com\u2081.embed] at eql,\n      cases E\u2081; cases E\u2082; try { simpa only [com\u2081.is_compatible] using d },\n      rcases d with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9, cases \u03b1\u2081, cases \u03b1\u2082,\n      simp only [com\u2081.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 \u27e8 \u27e8 k, \u03b1, E, t \u27e9, mem, eql \u27e9, 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 \u27e8 \u27e8 _ \u27e9, eql\u2081 \u27e9, clear eql,\n          rcases sigma.mk.inj (eq_of_heq eql\u2081) with \u27e8 \u27e8 _ \u27e9, eql\u2082 \u27e9, clear eql\u2081,\n          rcases sigma.mk.inj (eq_of_heq eql\u2082) with \u27e8 eqlE, eqlT \u27e9,\n\n          from com\u2081.impossible_l \u2113 A B t t\u2081 t\u2082 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 \u27e8 \u27e8 k, \u03b1, E, t \u27e9, mem, eql \u27e9, 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 \u27e8 \u27e8 _ \u27e9, eql\u2081 \u27e9, clear eql,\n          rcases sigma.mk.inj (eq_of_heq eql\u2081) with \u27e8 \u27e8 _ \u27e9, eql\u2082 \u27e9, clear eql\u2081,\n          rcases sigma.mk.inj (eq_of_heq eql\u2082) with \u27e8 eqlE, eqlT \u27e9,\n\n          from com\u2081.impossible_r \u2113 A B t t\u2081 t\u2082 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    {\u0393 \u2113} {A B : species \u210d \u03c9 \u0393} {l : label \u210d \u0393 kind.species} {E}\n    (As : fintype (transition_from \u2113 A)) (Bs : fintype (transition_from \u2113 B))\n    (t : transition A \u2113 l (production.species E))\n  : transition_from.mk (parL_species B t) \u2208 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    {\u0393 \u2113} {A B} {l : label \u210d \u0393 kind.concretion} {b y} {E : concretion \u210d \u03c9 \u0393 b y}\n    (As : fintype (transition_from \u2113 A)) (Bs : fintype (transition_from \u2113 B))\n    (t : transition A \u2113 l (production.concretion E))\n  : transition_from.mk (parL_concretion B t) \u2208 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    {\u0393 \u2113} {A B : species \u210d \u03c9 \u0393} {l : label \u210d \u0393 kind.species} {E}\n    (As : fintype (transition_from \u2113 A)) (Bs : fintype (transition_from \u2113 B))\n    (t : transition B \u2113 l (production.species E))\n  : transition_from.mk (parR_species A t) \u2208 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 {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (A B : species \u210d \u03c9 \u0393)\n    (As : fintype (transition.transition_from \u2113 A)) (Bs : fintype (transition.transition_from \u2113 B))\n  : \u2200 x, x \u2208 enumerate_parallel_ts A B As Bs\n| \u27e8 k, \u03b1, E, parL_species _ t \u27e9 := enumate_parallel_compute_l_species As Bs t\n| \u27e8 k, \u03b1, E, parL_concretion _ t \u27e9 := enumate_parallel_compute_l_concretion As Bs t\n| \u27e8 k, \u03b1, E, parR_species _ t \u27e9 := enumate_parallel_compute_r_species As Bs t\n| \u27e8 k, \u03b1, E, parR_concretion _ t \u27e9 :=\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| \u27e8 k, \u03b1, E, com\u2081 eqFG eq\u03b1 tf tg \u27e9 := begin\n  subst eqFG, subst eq\u03b1,\n  let t : com\u2081.compatible \u2113 A B\n    := \u27e8 ( transition_from.mk tf, transition_from.mk tg ), \u27e8 rfl, rfl \u27e9 \u27e9,\n  have h\n    := finset.mem_subtype.mpr\n      (finset.mem_product.mpr \u27e8 @fintype.complete _ As t.val.1, @fintype.complete _ Bs t.val.2 \u27e9),\n  from finset.mem_union_disjoint.mpr (or.inl (finset.mem_map_of_mem (com\u2081.embed \u2113 A B) h)),\nend\n\n/-- The set of all transitions from a parallel composition of species -/\ndef enumerate_parallel {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} {A B : species \u210d \u03c9 \u0393}\n  : fintype (transition.transition_from \u2113 A)\n  \u2192 fintype (transition.transition_from \u2113 B)\n  \u2192 fintype (transition.transition_from \u2113 (A |\u209b B))\n| As Bs := \u27e8 enumerate_parallel_ts A B As Bs, enumerate_parallel_complete A B As Bs \u27e9\n\nprivate def is_restriction_name {\u0393} (M : affinity \u210d)\n  : name (context.extend M.arity \u0393) \u2192 name (context.extend M.arity \u0393)\n  \u2192 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 {\u0393} (M : affinity \u210d)\n  : \u2200 (a b : name (context.extend M.arity \u0393))\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 {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d) (A : species \u210d \u03c9 (context.extend M.arity \u0393))\n  : transition.transition_from (lookup.rename name.extend \u2113) A\n  \u2192 Prop\n| \u27e8 _, \u03c4\u27e8 p \u27e9, E, t \u27e9 := upair.lift_on p (is_restriction_name M) (is_restriction_name.comm M)\n| \u27e8 _, \u03c4@' k, E, t \u27e9 := true\n| \u27e8 _, # (name.zero n), E, t \u27e9 := false\n| \u27e8 _, # (name.extend n), E, t \u27e9 := true\n\nprivate def is_restriction {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d) (A : species \u210d \u03c9 (context.extend M.arity \u0393))\n  := { t : transition_from (lookup.rename name.extend \u2113) A // is_restriction_like \u2113 M A t }\n\nprivate def is_restriction.name_lift {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d)\n  (A : species \u210d \u03c9 (context.extend M.arity \u0393))\n  (B : species \u210d \u03c9 (context.extend M.arity \u0393)) :\n  \u2200 (a b : name (context.extend M.arity \u0393))\n  , is_restriction_name M a b\n  \u2192 A [lookup.rename name.extend \u2113, \u03c4\u27e8 a, b \u27e9]\u27f6 (production.species B)\n  \u2192 transition.transition_from \u2113 (\u03bd(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  \u27e8 _, _, _, com\u2082 M (option.get' is_some) this rfl t \u27e9\n| (name.extend a) (name.extend b) fls t := begin\n  have : \u03c4\u27e8 name.extend a, name.extend b \u27e9 = label.rename (@name.extend \u0393 M.arity) (\u03c4\u27e8 a, b \u27e9),\n  { simpa only [label.rename] },\n  from \u27e8 _, _, _, \u03bd\u2081_species M this t \u27e9,\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 {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (M : affinity \u210d) (A B : species \u210d \u03c9 (context.extend M.arity \u0393))\n    {x y : fin M.arity}\n    {tL : A [lookup.rename name.extend \u2113, \u03c4\u27e8 (upair.mk (name.zero x) (name.zero y)) \u27e9]\u27f6 (production.species B)}\n    {tR : A [lookup.rename name.extend \u2113, \u03c4\u27e8 (upair.mk (name.zero y) (name.zero x)) \u27e9]\u27f6 (production.species B)}\n    (eT : tL == tR)\n    (k\u2081 k\u2082 : \u210d)\n    (e\u2081 : M.get (upair.mk x y) = some k\u2081)\n    (e\u2082 : M.get (upair.mk y x) = some k\u2082)\n  : transition.transition_from.mk (com\u2082 M k\u2081 e\u2081 rfl tL)  = transition.transition_from.mk (com\u2082 M k\u2082 e\u2082 rfl tR) := begin\n  have : k\u2081 = k\u2082,\n  {\n    rw upair.mk.comm at e\u2081,\n    from option.some.inj (trans e\u2081.symm e\u2082),\n  }, subst this,\n\n  refine sigma.mk.inj_iff.mpr \u27e8 rfl, heq_of_eq _ \u27e9, simp only [heq_iff_eq],\n  from \u27e8 rfl, \u27e8 rfl, rfl \u27e9, quot.sound (or.inr \u27e8 rfl, rfl \u27e9), quot.sound (or.inr \u27e8 rfl, rfl \u27e9), eT \u27e9,\nend\n\nprivate lemma is_restriction_name_lift.comm_extend {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (M : affinity \u210d) (A B : species \u210d \u03c9 (context.extend M.arity \u0393))\n    {x y : name \u0393}\n    {tL : A [lookup.rename name.extend \u2113, \u03c4\u27e8 (upair.mk (name.extend x) (name.extend y)) \u27e9]\u27f6 (production.species B)}\n    {tR : A [lookup.rename name.extend \u2113, \u03c4\u27e8 (upair.mk (name.extend y) (name.extend x)) \u27e9]\u27f6 (production.species B)}\n    (eT : tL == tR)\n    (l\u2081 l\u2082 : label \u210d \u0393 kind.species)\n    (e\u2081 : \u03c4\u27e8 (upair.mk (name.extend x) (name.extend y)) \u27e9 = label.rename name.extend l\u2081)\n    (e\u2082 : \u03c4\u27e8 (upair.mk (name.extend y) (name.extend x)) \u27e9 = label.rename name.extend l\u2082)\n  : transition.transition_from.mk (\u03bd\u2081_species M e\u2081 tL) = transition.transition_from.mk (\u03bd\u2081_species M e\u2082 tR) := begin\n  have : l\u2081 = l\u2082,\n  {\n    rw [upair.mk.comm] at e\u2081,\n    from label.rename.inj (@name.extend.inj _ _) (trans e\u2081.symm e\u2082),\n  }, subst this,\n\n  refine sigma.mk.inj_iff.mpr \u27e8 rfl, heq_of_eq _ \u27e9, simp only [heq_iff_eq],\n  from \u27e8 rfl, \u27e8 rfl, rfl \u27e9, quot.sound (or.inr \u27e8 rfl, rfl \u27e9), eT \u27e9,\nend\n\nprivate lemma is_restriction.name_lift.comm {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d) (A B : species \u210d \u03c9 (context.extend M.arity \u0393)) :\n  \u2200 (a b : name (context.extend M.arity \u0393))\n  ,  is_restriction.name_lift \u2113 M A B a b\n  == is_restriction.name_lift \u2113 M A B b a\n| (name.zero x) (name.zero y) := function.hfunext\n  (by { unfold is_restriction_name, rw M.symm })\n  (\u03bb irlL irlR eIRL, function.hfunext\n    (by rw upair.mk.comm)\n    (\u03bb 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  (\u03bb irlL irlR eIRL, function.hfunext\n    (by rw upair.mk.comm)\n    (\u03bb 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    (\u03bb irlL irlR eIRL, function.hfunext (by rw upair.mk.comm) (\u03bb x b z, heq.rfl))\n| (name.extend x) (name.zero y) := function.hfunext rfl\n    (\u03bb irlL irlR eIRL, function.hfunext (by rw upair.mk.comm) (\u03bb x b z, heq.rfl))\n\nlemma \u03bd\u2081_species.inj' {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (M : affinity \u210d) {A} :\n  \u2200 {E\u2081 E\u2082}\n    {l\u2081 : label \u210d \u0393 kind.species} {l'\u2081 : label \u210d (context.extend M.arity \u0393) kind.species}\n    {l\u2082 : label \u210d \u0393 kind.species} {l'\u2082 : label \u210d (context.extend M.arity \u0393) kind.species}\n    {e\u2081 : l'\u2081 = label.rename name.extend l\u2081}\n    {e\u2082 : l'\u2082 = label.rename name.extend l\u2082}\n    {t\u2081 : A [lookup.rename name.extend \u2113, l'\u2081]\u27f6 (production.species E\u2081)}\n    {t\u2082 : A [lookup.rename name.extend \u2113, l'\u2082]\u27f6 (production.species E\u2082)}\n  , transition_from.mk (\u03bd\u2081_species M e\u2081 t\u2081) = transition_from.mk (\u03bd\u2081_species M e\u2082 t\u2082)\n  \u2192 transition_from.mk t\u2081 = transition_from.mk t\u2082\n| E\u2081 E\u2082 l\u2081 l'\u2081 l\u2082 l'\u2082 e\u2081 e\u2082 t\u2081 t\u2082 eql := begin\n  rcases sigma.mk.inj (eq_of_heq (sigma.mk.inj eql).2) with \u27e8 this, eqR \u27e9, subst \u2039l\u2081 = l\u2082\u203a,\n  have : l'\u2081 = l'\u2082 := trans e\u2081 e\u2082.symm, subst \u2039l'\u2081 = l'\u2082\u203a,\n\n  rcases sigma.mk.inj (eq_of_heq eqR) with \u27e8 \u27e8 _ \u27e9, eqT \u27e9,\n  rcases \u03bd\u2081_species.inj (eq_of_heq eqT) with \u27e8 _, \u27e8 _ \u27e9 \u27e9,\n  from rfl,\nend\n\nlemma \u03bd\u2081_concretion.inj' {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (M : affinity \u210d) {A} :\n  \u2200 {a x b y} {E\u2081 : concretion \u210d \u03c9 _ a x} {E\u2082 : concretion \u210d \u03c9 _ b y}\n    {l\u2081 : label \u210d \u0393 kind.concretion} {l'\u2081 : label \u210d (context.extend M.arity \u0393) kind.concretion}\n    {l\u2082 : label \u210d \u0393 kind.concretion} {l'\u2082 : label \u210d (context.extend M.arity \u0393) kind.concretion}\n    {e\u2081 : l'\u2081 = label.rename name.extend l\u2081}\n    {e\u2082 : l'\u2082 = label.rename name.extend l\u2082}\n    {t\u2081 : A [lookup.rename name.extend \u2113, l'\u2081]\u27f6 (production.concretion E\u2081)}\n    {t\u2082 : A [lookup.rename name.extend \u2113, l'\u2082]\u27f6 (production.concretion E\u2082)}\n  , transition_from.mk (\u03bd\u2081_concretion M e\u2081 t\u2081) = transition_from.mk (\u03bd\u2081_concretion M e\u2082 t\u2082)\n  \u2192 transition_from.mk t\u2081 = transition_from.mk t\u2082\n| a x b y E\u2081 E\u2082 l\u2081 l'\u2081 l\u2082 l'\u2082 e\u2081 e\u2082 t\u2081 t\u2082 eql := begin\n  rcases sigma.mk.inj (eq_of_heq (sigma.mk.inj eql).2) with \u27e8 this, eqR \u27e9, subst \u2039l\u2081 = l\u2082\u203a,\n  have : l'\u2081 = l'\u2082 := trans e\u2081 e\u2082.symm, subst \u2039l'\u2081 = l'\u2082\u203a,\n\n  rcases sigma.mk.inj (eq_of_heq eqR) with \u27e8 \u27e8 _ \u27e9, eqT \u27e9,\n  rcases \u03bd\u2081_concretion.inj (eq_of_heq eqT) with \u27e8 _, \u27e8 _ \u27e9 \u27e9,\n  from rfl,\nend\n\nprivate lemma is_restriction.name_lift.inj_zero {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d)\n    (A : species \u210d \u03c9 (context.extend M.arity \u0393)) :\n  \u2200 {B\u2081 B\u2082 : species \u210d \u03c9 (context.extend M.arity \u0393)}\n    {p q : upair (fin M.arity)}\n    {t\u2081 : A [lookup.rename name.extend \u2113, \u03c4\u27e8 (upair.map name.zero p) \u27e9]\u27f6 (production.species B\u2081)}\n    {t\u2082 : A [lookup.rename name.extend \u2113, \u03c4\u27e8 (upair.map name.zero q) \u27e9]\u27f6 (production.species B\u2082)}\n    {k\u2081 k\u2082 : \u210d} {e\u2081 : M.get p = some k\u2081} {e\u2082 : M.get q = some k\u2082}\n  , transition_from.mk (com\u2082 M k\u2081 e\u2081 rfl t\u2081) = transition_from.mk (com\u2082 M k\u2082 e\u2082 rfl t\u2082)\n  \u2192 transition_from.mk t\u2081 = transition_from.mk t\u2082\n| B\u2081 B\u2082 p q t\u2081 t\u2082 k\u2081 k\u2082 e\u2081 e\u2082 eql := begin\n  rcases sigma.mk.inj (eq_of_heq (sigma.mk.inj eql).2) with \u27e8 \u27e8 _ \u27e9, eqR \u27e9,\n  rcases sigma.mk.inj (eq_of_heq eqR) with \u27e8 \u27e8 _ \u27e9, eqT \u27e9,\n  rcases com\u2082.inj (eq_of_heq eqT) with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n  from rfl,\nend\n\nprivate lemma is_restriction.name_lift.inj {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d)\n    (A : species \u210d \u03c9 (context.extend M.arity \u0393)) {B\u2081 B\u2082 : species \u210d \u03c9 (context.extend M.arity \u0393)} :\n  \u2200 {a\u2081 b\u2081 a\u2082 b\u2082 : name (context.extend M.arity \u0393)}\n    (t\u2081 : A [lookup.rename name.extend \u2113, \u03c4\u27e8 a\u2081, b\u2081 \u27e9]\u27f6 (production.species B\u2081))\n    (t\u2082 : A [lookup.rename name.extend \u2113, \u03c4\u27e8 a\u2082, b\u2082 \u27e9]\u27f6 (production.species B\u2082))\n    (irl\u2081 : is_restriction_name M a\u2081 b\u2081)\n    (irl\u2082 : is_restriction_name M a\u2082 b\u2082)\n  , is_restriction.name_lift \u2113 M A B\u2081 a\u2081 b\u2081 irl\u2081 t\u2081 = is_restriction.name_lift \u2113 M A B\u2082 a\u2082 b\u2082 irl\u2082 t\u2082\n  \u2192 transition_from.mk t\u2081 = transition_from.mk t\u2082\n| a\u2081 b\u2081 a\u2082 b\u2082 t\u2081 t\u2082 irl\u2081 irl\u2082 eql := begin\n  cases a\u2081; cases b\u2081; try { from false.elim irl\u2081 };\n  cases a\u2082; cases b\u2082; try { from false.elim irl\u2082 <|> cases eql };\n  simp only [is_restriction.name_lift] at eql,\n\n  case name.extend { from \u03bd\u2081_species.inj' M eql },\n  case name.zero { from is_restriction.name_lift.inj_zero \u2113 M A eql },\nend\n\nprivate def is_restriction.lift {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d) (A : species \u210d \u03c9 (context.extend M.arity \u0393))\n  : is_restriction \u2113 M A\n  \u2192 transition.transition_from \u2113 (\u03bd(M) A)\n| \u27e8 \u27e8 _, \u03c4@' k, production.species B, t \u27e9, _ \u27e9 := begin\n  have : \u03c4@' k = label.rename (@name.extend \u0393 M.arity) (\u03c4@' k), { simp only [label.rename] },\n  from \u27e8 _, _, _, \u03bd\u2081_species M this t \u27e9,\nend\n| \u27e8 \u27e8 _, \u03c4\u27e8 p \u27e9, production.species B, t \u27e9, irl \u27e9 := begin\n  unfold is_restriction_like at irl,\n  from upair.rec_on p\n    (\u03bb a b irl t, is_restriction.name_lift \u2113 M A B a b irl t)\n    (is_restriction.name_lift.comm \u2113 M A B)\n    irl t,\nend\n| \u27e8 \u27e8 _, # (name.zero n), E, t \u27e9, irl \u27e9 := false.elim irl\n| \u27e8 \u27e8 _, # (name.extend n), production.concretion F, t \u27e9, _ \u27e9 := begin\n  have : # (name.extend n) = label.rename (@name.extend \u0393 M.arity) (# n), { simp only [label.rename] },\n  from \u27e8 _, # n, production.concretion (\u03bd'(M) F), \u03bd\u2081_concretion M this t \u27e9,\nend\n\nprivate def is_restriction.lift.inj_both {\u0393 : context} {\u2113 : lookup \u210d \u03c9 \u0393}\n    (M : affinity \u210d) (A B : species \u210d \u03c9 (context.extend M.arity \u0393)) :\n  \u2200 {B B' : species \u210d \u03c9 (context.extend M.arity \u0393)}\n    {p q : upair (name (context.extend M.arity \u0393))}\n\n    (t : A [lookup.rename name.extend \u2113, \u03c4\u27e8 p \u27e9]\u27f6 (production.species B))\n    (irl : is_restriction_like \u2113 M A \u27e8kind.species, \u27e8\u03c4\u27e8 p \u27e9, \u27e8production.species B, t\u27e9\u27e9\u27e9)\n\n    (t' : A [lookup.rename name.extend \u2113, \u03c4\u27e8 q \u27e9]\u27f6 (production.species B'))\n    (irl' : is_restriction_like \u2113 M A \u27e8kind.species, \u27e8\u03c4\u27e8 q \u27e9, \u27e8production.species B', t'\u27e9\u27e9\u27e9)\n\n  , is_restriction.lift \u2113 M A \u27e8\u27e8kind.species, \u27e8\u03c4\u27e8 p \u27e9, \u27e8production.species B, t\u27e9\u27e9\u27e9, irl\u27e9\n  = is_restriction.lift \u2113 M A \u27e8\u27e8kind.species, \u27e8\u03c4\u27e8 q \u27e9, \u27e8production.species B', t'\u27e9\u27e9\u27e9, irl'\u27e9\n  \u2192 (\u27e8\u27e8kind.species, \u27e8\u03c4\u27e8 p \u27e9, \u27e8production.species B, t\u27e9\u27e9\u27e9, irl\u27e9 : is_restriction \u2113 M A)\n  = \u27e8\u27e8kind.species, \u27e8\u03c4\u27e8 q \u27e9, \u27e8production.species B', t'\u27e9\u27e9\u27e9, irl'\u27e9\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 \u27e8 a, b, \u27e8 _ \u27e9 \u27e9,\n  rcases upair.exists_rep q with \u27e8 a', b', \u27e8 _ \u27e9 \u27e9,\n\n  simp only [],\n  from is_restriction.name_lift.inj \u2113 M A t t' irl irl' eql,\nend\n\nprivate def is_restriction.lift.inj {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d) (A : species \u210d \u03c9 (context.extend M.arity \u0393))\n  : function.injective (is_restriction.lift \u2113 M A)\n| \u27e8 \u27e8 _, # (name.zero n), E, t \u27e9, irl \u27e9 _ eql := false.elim irl\n\n| \u27e8 \u27e8 _, \u03c4@' k, production.species B, t \u27e9, _ \u27e9 \u27e8 \u27e8 _, # (name.zero n), E, t' \u27e9, irl \u27e9 eql := false.elim irl\n| \u27e8 \u27e8 _, \u03c4@' k, production.species B, t \u27e9, _ \u27e9 \u27e8 \u27e8 _, \u03c4@' k', production.species B', t' \u27e9, _ \u27e9 eql\n  := by { cases \u03bd\u2081_species.inj' M eql, from rfl }\n| \u27e8 \u27e8 _, \u03c4@' k, production.species B, t \u27e9, _ \u27e9 \u27e8 \u27e8 _, \u03c4\u27e8 p \u27e9, production.species B', t' \u27e9, irl \u27e9 eql := begin\n  rcases upair.exists_rep p with \u27e8 a, b, \u27e8 _ \u27e9 \u27e9,\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| \u27e8 \u27e8 _, \u03c4@' k, production.species B, t \u27e9, _ \u27e9 \u27e8 \u27e8 _, # (name.extend n), production.concretion F, t' \u27e9, _ \u27e9 eql := by cases eql\n\n| \u27e8 \u27e8 _, \u03c4\u27e8 p \u27e9, production.species B, t \u27e9, _ \u27e9 \u27e8 \u27e8 _, # (name.zero n'), E, t' \u27e9, irl \u27e9 eql := false.elim irl\n| \u27e8 \u27e8 _, \u03c4\u27e8 p \u27e9, production.species B, t \u27e9, irl \u27e9 \u27e8 \u27e8 _, # (name.extend n'), production.concretion F', t' \u27e9, _ \u27e9 eql := begin\n  rcases upair.exists_rep p with \u27e8 a, b, \u27e8 _ \u27e9 \u27e9,\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| \u27e8 \u27e8 _, \u03c4\u27e8 p \u27e9, production.species B, t \u27e9, irl \u27e9 \u27e8 \u27e8 _, \u03c4@' k', production.species B', t' \u27e9, _ \u27e9 eql := begin\n  rcases upair.exists_rep p with \u27e8 a, b, \u27e8 _ \u27e9 \u27e9,\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| \u27e8 \u27e8 _, \u03c4\u27e8 p \u27e9, production.species B, t \u27e9, irl \u27e9 \u27e8 \u27e8 _, \u03c4\u27e8 q \u27e9, production.species B', t' \u27e9, irl' \u27e9 eql\n  := is_restriction.lift.inj_both M A B t irl t' irl' eql\n\n| \u27e8 \u27e8 _, # (name.extend n), production.concretion F, t \u27e9, _ \u27e9 \u27e8 \u27e8 _, # (name.extend n'), production.concretion F', t' \u27e9, _ \u27e9 eql\n  := by { cases \u03bd\u2081_concretion.inj' M eql, from rfl }\n| \u27e8 \u27e8 _, # (name.extend n), production.concretion F, t \u27e9, _ \u27e9 \u27e8 \u27e8 _, # (name.zero n'), E, t' \u27e9, irl \u27e9 eql := false.elim irl\n| \u27e8 \u27e8 _, # (name.extend n), production.concretion F, t \u27e9, _ \u27e9 \u27e8 \u27e8 _, \u03c4@' k', production.species B', t' \u27e9, _ \u27e9 eql := by cases eql\n| \u27e8 \u27e8 _, # (name.extend n), production.concretion F, t \u27e9, _ \u27e9 \u27e8 \u27e8 _, \u03c4\u27e8 p \u27e9, production.species B', t' \u27e9, irl \u27e9 eql := begin\n  rcases upair.exists_rep p with \u27e8 a, b, \u27e8 _ \u27e9 \u27e9,\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 {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d) (A : species \u210d \u03c9 (context.extend M.arity \u0393))\n  : is_restriction \u2113 M A\n  \u21aa transition.transition_from \u2113 (\u03bd(M) A)\n  := \u27e8 is_restriction.lift \u2113 M A, is_restriction.lift.inj \u2113 M A \u27e9\n\ninstance is_restriction_name.decide {\u0393} (M : affinity \u210d)\n  : decidable_pred (\u03bb (p : upair.pair (name (context.extend M.arity \u0393))), is_restriction_name M p.fst p.snd)\n| \u27e8 name.zero a, name.zero b \u27e9 := by { unfold is_restriction_name, apply_instance }\n| \u27e8 name.extend _, name.extend _ \u27e9 := decidable.true\n| \u27e8 name.extend _, name.zero _ \u27e9 := decidable.false\n| \u27e8 name.zero _, name.extend _ \u27e9 := decidable.false\n\ninstance is_restriction_like.decide {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d) (A : species \u210d \u03c9 (context.extend M.arity \u0393))\n  : decidable_pred (is_restriction_like \u2113 M A)\n| \u27e8 _, \u03c4\u27e8 p \u27e9, E, t \u27e9 := quot.lift.decidable_pred _ _ _\n| \u27e8 _, \u03c4@' k, E, t \u27e9 := decidable.true\n| \u27e8 _, # (name.zero n), E, t \u27e9 := decidable.false\n| \u27e8 _, # (name.extend n), E, t \u27e9 := decidable.true\n\nprivate def enumerate_restriction {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (M : affinity \u210d) (A : species \u210d \u03c9 (context.extend M.arity \u0393))\n  : fintype (transition.transition_from (lookup.rename name.extend \u2113) A)\n  \u2192 fintype (transition.transition_from \u2113 (\u03bd(M) A))\n| As :=\n  \u27e8 finset.map (is_restriction.embed \u2113 M A)\n      (finset.subtype (is_restriction_like \u2113 M A) As.elems)\n  , \u03bb t, begin\n    rcases t with \u27e8 k, \u03b1, E, t \u27e9,\n    cases t,\n    case com\u2082 : p p' B k eql eqp t {\n      rcases upair.exists_rep p with \u27e8 a, b, ep' \u27e9, subst ep',\n\n      simp only [upair.map_beta] at eqp, subst eqp, cases eqp,\n\n      have : is_restriction_like \u2113 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 \u2113 M A := \u27e8 \u27e8 _, _, _, t \u27e9, this \u27e9,\n      have this := finset.mem_map_of_mem (is_restriction.embed \u2113 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 \u03bd\u2081_species : l l' B eql t {\n      have : is_restriction_like \u2113 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 \u27e8 a, b, \u27e8 _ \u27e9 \u27e9,\n        from true.intro,\n      },\n      let t' : is_restriction \u2113 M A := \u27e8 \u27e8 _, _, _, t \u27e9, this \u27e9,\n      have this := finset.mem_map_of_mem (is_restriction.embed \u2113 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 : \u2200 (a b : name \u0393), (quot.mk setoid.r (upair.pair.mk a b)) = upair.mk a b := \u03bb a b, rfl,\n      rcases quot.exists_rep l_k with \u27e8 \u27e8 a, b \u27e9, h \u27e9, 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 \u03bd\u2081_concretion : l l' b y B eql t {\n      cases l, simp only [label.rename] at eql, subst eql,\n      let t' : is_restriction \u2113 M A := \u27e8 \u27e8 _, _, _, t \u27e9, true.intro \u27e9,\n      from finset.mem_map_of_mem (is_restriction.embed \u2113 M A)\n        (finset.mem_subtype.mpr (@fintype.complete _ As t'.val)),\n    }\n  end \u27e9\n\n/-- Show that the available transitions from a species is finite and thus\n    enumerable.-/\ndef enumerate :\n  \u2200 {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A : species \u210d \u03c9 \u0393)\n  , fintype (transition_from \u2113 A)\n| \u0393 \u2113 nil := enumerate_nil\n| \u0393 \u2113 (apply D as) := enumerate_apply \u2113 D as\n| \u0393 \u2113 (A |\u209b B) := enumerate_parallel (enumerate \u2113 A) (enumerate \u2113 B)\n| \u0393 \u2113 (\u03a3# As) := enumerate_choices \u2113 As\n| \u0393 \u2113 (\u03bd(M) A) := enumerate_restriction \u2113 M A (enumerate (lookup.rename name.extend \u2113) A)\nusing_well_founded {\n  rel_tac := \u03bb _ _,\n    `[exact \u27e8_, measure_wf (\u03bb x, whole.sizeof _ _ _ _ x.2.2 ) \u27e9 ],\n  dec_tac := tactic.fst_dec_tac,\n}\n\ninstance {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A : species \u210d \u03c9 \u0393)\n  : fintype (transition_from \u2113 A) := enumerate \u2113 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 : \u2200 {t\u2081 t\u2082 : term},\n  followsFrom (not $ implies t\u2081 t\u2082) t\u2081 :=\n  by intros t\u2081 t\u2082 \u0393 \u0394 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\u2081 k\u2082 rt\u2081 rt\u2082 =>\n           simp\n           rewrite [rt\u2081]\n           have ek : (fun \u0393 \u0394 => \u00ac k' \u0393 \u0394) = k :=\n             by injection h' with h'; injection h' with _ h'; exact h';\n           have fe : (fun \u0393 \u0394 => k\u2081 \u0393 \u0394 \u2192 k\u2082 \u0393 \u0394) = k' :=\n             by injection h'' with h''; injection h'' with _ h''; exact h''\n           rewrite [\u2190 ek, \u2190 fe] at h\n           apply byContradiction\n           exact (\u03bb hf => h (\u03bb k\u2081w => False.elim (hf k\u2081w)))\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 : \u2200 {t\u2081 t\u2082 : term},\n  followsFrom (not $ implies t\u2081 t\u2082) (not t\u2082) :=\n    by intros t\u2081 t\u2082 \u0393 \u0394 h\n       simp at h\n       match r\u2081: interpTerm t\u2081, r\u2082: interpTerm t\u2082 with\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 atom 1, k\u2082 \u27e9 =>\n           simp\n           rewrite [r\u2082]\n           show \u00ac k\u2082 \u0393 \u0394\n           rewrite [r\u2081, r\u2082] at h\n           have h\u2082 : \u00ac ((k\u2081 \u0393 \u0394) \u2192 (k\u2082 \u0393 \u0394)) := h\n           match em (k\u2082 \u0393 \u0394) with\n           | Or.inl r  => exact False.elim (h\u2082 (\u03bb _ => r))\n           | Or.inr r  => exact r\n       | some \u27e8 atom 0, _ \u27e9, _  => rewrite [r\u2081] at h; simp at h\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 atom 0, _ \u27e9  => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 atom (succ (succ _)), _ \u27e9 => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.undef, _ \u27e9           => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.array _ _, _ \u27e9       => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.bv _, _ \u27e9            => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.arrow _ _, _ \u27e9       => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.dep, _ \u27e9             => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, none                             => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom (succ (succ _)), _ \u27e9, _ => absurdHyp h (r\u2081) \n       | some \u27e8 sort.undef, _ \u27e9, _           => absurdHyp h (r\u2081) \n       | some \u27e8 sort.array _ _, _ \u27e9, _       => absurdHyp h (r\u2081) \n       | some \u27e8 sort.bv _, _ \u27e9, _            => absurdHyp h (r\u2081) \n       | some \u27e8 sort.arrow _ _, _ \u27e9, _       => absurdHyp h (r\u2081) \n       | some \u27e8 sort.dep, _ \u27e9, _             => absurdHyp h (r\u2081)\n       | none, _                             => absurdHyp h (r\u2081)\n\ntheorem impliesElim : \u2200 {t\u2081 t\u2082 : term},\n  followsFrom (implies t\u2081 t\u2082) (or (not t\u2081) t\u2082)\n  | t\u2081, t\u2082, \u0393, \u0394, h =>\n    by simp at h\n       match r\u2081: interpTerm t\u2081, r\u2082: interpTerm t\u2082 with\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 atom 1, k\u2082 \u27e9 =>\n           simp\n           rewrite [r\u2081, r\u2082]\n           rewrite [r\u2081, r\u2082] at h\n           show (\u00ac k\u2081 \u0393 \u0394) \u2228 (k\u2082 \u0393 \u0394)\n           have h\u2082 : k\u2081 \u0393 \u0394 \u2192 k\u2082 \u0393 \u0394 := h\n           match em (k\u2081 \u0393 \u0394), em (k\u2082 \u0393 \u0394) with\n           | Or.inl _, Or.inl k\u2082W => exact Or.inr k\u2082W\n           | Or.inl k\u2081W, Or.inr nk\u2082W => have k\u2082W := h\u2082 k\u2081W\n                                        exact (False.elim (nk\u2082W k\u2082W))\n           | Or.inr _, Or.inl k\u2082W => exact Or.inr k\u2082W\n           | Or.inr nk\u2081W, Or.inr _ => exact Or.inl nk\u2081W\n       | some \u27e8 atom 0, _ \u27e9, _  => absurdHyp h (r\u2081)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 atom 0, _ \u27e9  => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 atom (succ (succ _)), _ \u27e9 => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.undef, _ \u27e9           => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.array _ _, _ \u27e9       => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.bv _, _ \u27e9            => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.arrow _ _, _ \u27e9       => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 sort.dep, _ \u27e9             => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom 1, k\u2081 \u27e9, none                             => absurdHyp h (r\u2081, r\u2082)\n       | some \u27e8 atom (succ (succ _)), _ \u27e9, _ => absurdHyp h (r\u2081) \n       | some \u27e8 sort.undef, _ \u27e9, _           => absurdHyp h (r\u2081) \n       | some \u27e8 sort.array _ _, _ \u27e9, _       => absurdHyp h (r\u2081)\n       | some \u27e8 sort.bv _, _ \u27e9, _            => absurdHyp h (r\u2081)\n       | some \u27e8 sort.arrow _ _, _ \u27e9, _       => absurdHyp h (r\u2081)\n       | some \u27e8 sort.dep, _ \u27e9, _             => absurdHyp h (r\u2081)\n       | none, _                             => absurdHyp h (r\u2081)\n\ntheorem contradiction: \u2200 {t: term},\n  followsFrom (and (not t) t) bot\n  | t, \u0393, \u0394, h => by\n    simp at h\n    match r: interpTerm t with\n    | some \u27e8 atom 1, k \u27e9 =>\n        rewrite [r] at h;\n        simp at h\n        have \u27e8nkW, kW\u27e9 : \u00ac (k \u0393 \u0394) \u2227 k \u0393 \u0394 := h\n        exact False.elim (nkW kW)\n    | some \u27e8 atom 0, _ \u27e9               => absurdHyp h (r)\n    | some \u27e8 atom (succ (succ _)), _ \u27e9 => absurdHyp h (r)\n    | some \u27e8 sort.undef, _ \u27e9           => absurdHyp h (r)\n    | some \u27e8 sort.array _ _, _ \u27e9       => absurdHyp h (r)\n    | some \u27e8 sort.bv _, _ \u27e9            => absurdHyp h (r)\n    | some \u27e8 sort.arrow _ _, _ \u27e9       => absurdHyp h (r)\n    | some \u27e8 sort.dep, _ \u27e9             => absurdHyp h (r)\n    | none                             => absurdHyp h (r)\n       \ntheorem R1 : \u2200 {t\u2081 t\u2082 : term},\n  followsFrom (and (or (not t\u2081) t\u2082) t\u2081) t\u2082\n  | t\u2081, t\u2082, \u0393, \u0394, h => by\n    simp at h\n    match r\u2081: interpTerm t\u2081, r\u2082: interpTerm t\u2082 with\n    | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 atom 1, k\u2082 \u27e9 =>\n        simp at *\n        rewrite [r\u2081, r\u2082] at h\n        rewrite [r\u2082]\n        have \u27e8 H, k\u2081W \u27e9: ((\u00ac (k\u2081 \u0393 \u0394)) \u2228 (k\u2082 \u0393 \u0394)) \u2227 (k\u2081 \u0393 \u0394) := h\n        match em (k\u2082 \u0393 \u0394) with\n        | Or.inl k\u2082W  => exact k\u2082W\n        | Or.inr _    => match em (k\u2081 \u0393 \u0394) with\n                         | Or.inl k\u2081W  => match H with\n                                          | Or.inl nk\u2081W => exact (False.elim (nk\u2081W k\u2081W))\n                                          | Or.inr k\u2082W  => exact k\u2082W\n                         | Or.inr nk\u2081W => exact (False.elim (nk\u2081W k\u2081W))\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 atom 0, _ \u27e9               => absurdHyp h (r\u2081, r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 atom (succ (succ _)), _ \u27e9 => absurdHyp h (r\u2081, r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.undef, _ \u27e9           => absurdHyp h (r\u2081, r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.array _ _, _ \u27e9       => absurdHyp h (r\u2081, r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.bv _, _ \u27e9            => absurdHyp h (r\u2081, r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.arrow _ _, _ \u27e9       => absurdHyp h (r\u2081, r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.dep, _ \u27e9             => absurdHyp h (r\u2081, r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, none                             => absurdHyp h (r\u2081, r\u2082)\n    | some \u27e8 atom 0, _ \u27e9, _               => absurdHyp h (r\u2081) \n    | some \u27e8 atom (succ (succ _)), _ \u27e9, _ => absurdHyp h (r\u2081)\n    | some \u27e8 sort.undef, _ \u27e9, _           => absurdHyp h (r\u2081)\n    | some \u27e8 sort.array _ _, _ \u27e9, _       => absurdHyp h (r\u2081)\n    | some \u27e8 sort.bv _, _ \u27e9, _            => absurdHyp h (r\u2081)\n    | some \u27e8 sort.arrow _ _, _ \u27e9, _       => absurdHyp h (r\u2081)\n    | some \u27e8 sort.dep, _ \u27e9, _             => absurdHyp h (r\u2081)\n    | none, _                             => absurdHyp h (r\u2081)\n\ntheorem conjunction: \u2200 {t\u2081 t\u2082: term} {\u0393: Environment} {\u0394 : SEnvironment},\n  validWith \u0393 \u0394 t\u2081 \u2192 validWith \u0393 \u0394 t\u2082 \u2192 validWith \u0393 \u0394 (and t\u2081 t\u2082)\n  | t\u2081, t\u2082, \u0393, \u0394, h\u2081, h\u2082 => by\n    simp at *\n    match r\u2081: interpTerm t\u2081, r\u2082: interpTerm t\u2082 with\n    | some \u27e8 atom 1, k\u2081 \u27e9, some \u27e8 atom 1, k\u2082 \u27e9 =>\n        show (k\u2081 \u0393 \u0394) \u2227 (k\u2082 \u0393 \u0394)\n        simp\n        rewrite [r\u2081] at h\u2081\n        rewrite [r\u2082] at h\u2082\n        have k\u2081W: (k\u2081 \u0393 \u0394) := h\u2081\n        have k\u2082W: (k\u2082 \u0393 \u0394) := h\u2082\n        exact And.intro k\u2081W k\u2082W\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 atom 0, _ \u27e9               => absurdHyp h\u2082 (r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 atom (succ (succ _)), _ \u27e9 => absurdHyp h\u2082 (r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.undef, _ \u27e9           => absurdHyp h\u2082 (r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.array _ _, _ \u27e9       => absurdHyp h\u2082 (r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.bv _, _ \u27e9            => absurdHyp h\u2082 (r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.arrow _ _, _ \u27e9       => absurdHyp h\u2082 (r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, some \u27e8 sort.dep, _ \u27e9             => absurdHyp h\u2082 (r\u2082)\n    | some \u27e8 atom 1, _ \u27e9, none                             => absurdHyp h\u2082 (r\u2082)\n    | some \u27e8 atom 0, _ \u27e9, _                                => absurdHyp h\u2081 (r\u2081)\n    | some \u27e8 atom (succ (succ _)), _ \u27e9 , _ => absurdHyp h\u2081 (r\u2081)\n    | some \u27e8 sort.undef, _ \u27e9, _            => absurdHyp h\u2081 (r\u2081)\n    | some \u27e8 sort.array _ _, _ \u27e9, _        => absurdHyp h\u2081 (r\u2081)\n    | some \u27e8 sort.bv _, _ \u27e9, _             => absurdHyp h\u2081 (r\u2081)\n    | some \u27e8 sort.arrow _ _, _ \u27e9, _        => absurdHyp h\u2081 (r\u2081)\n    | some \u27e8 sort.dep, _ \u27e9, _              => absurdHyp h\u2081 (r\u2081)\n    | none, _                              => absurdHyp h\u2081 (r\u2081)\n\ntheorem followsBot: \u2200 {t: term},\n  followsFrom t bot \u2192 \u2200 {\u0393 : Environment} {\u0394 : SEnvironment}, \u00ac validWith \u0393 \u0394 t\n  | t, h, \u0393, \u0394 => by\n    intro validT\n    have validBot := @h \u0393 \u0394 validT\n    simp at validBot\n    cases validBot\n\n@[simp] def isBool : term \u2192 Bool\n  | t => match interpTerm t with\n         | some \u27e8 atom 1, _ \u27e9 => true\n         | _ => false\n\ntheorem interpNotTerm: \u2200 {\u0393: Environment} {\u0394: SEnvironment} {t: term},\n  isBool t \u2192 \u00ac validWith \u0393 \u0394 (not t) \u2192 validWith \u0393 \u0394 t\n  | \u0393, \u0394, t, bt, h => by\n    simp\n    match r: interpTerm t with\n    | some \u27e8 atom 1, k \u27e9 => match em (k \u0393 \u0394) with\n                            | Or.inl kW  => exact kW\n                            | Or.inr nkW => simp at h\n                                            rewrite [r] at h\n                                            have nnkW : \u00ac (\u00ac (k \u0393 \u0394)) := h\n                                            exact (False.elim (nnkW nkW))\n    | some \u27e8 atom 0, _ \u27e9               => simp at bt; rewrite [r] at bt; cases bt\n    | some \u27e8 atom (succ (succ _)), _ \u27e9 => simp at bt; rewrite [r] at bt; cases bt\n    | some \u27e8 sort.undef, _ \u27e9           => simp at bt; rewrite [r] at bt; cases bt\n    | some \u27e8 sort.array _ _, _ \u27e9       => simp at bt; rewrite [r] at bt; cases bt\n    | some \u27e8 sort.bv _, _ \u27e9            => simp at bt; rewrite [r] at bt; cases bt\n    | some \u27e8 sort.arrow _ _, _ \u27e9       => simp at bt; rewrite [r] at bt; cases bt\n    | some \u27e8 sort.dep, _ \u27e9             => 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": "/-\nCopyright (c) 2021 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Lean.Meta.AppBuilder\nimport Lean.Class\n\nnamespace Lean.Meta\n\ninductive CongrArgKind where\n  /-- It is a parameter for the congruence theorem, the parameter occurs in the left and right hand sides. -/\n  | fixed\n  /--\n  It is not a parameter for the congruence theorem, the theorem was specialized for this parameter.\n  This only happens if the parameter is a subsingleton/proposition, and other parameters depend on it. -/\n  | fixedNoParam\n  /--\n  The lemma contains three parameters for this kind of argument `a_i`, `b_i` and `eq_i : a_i = b_i`.\n  `a_i` and `b_i` represent the left and right hand sides, and `eq_i` is a proof for their equality. -/\n  | eq\n  /--\n  The congr-simp theorems contains only one parameter for this kind of argument, and congr theorems contains two.\n  They correspond to arguments that are subsingletons/propositions. -/\n  | cast\n  /--\n  The lemma contains three parameters for this kind of argument `a_i`, `b_i` and `eq_i : HEq a_i b_i`.\n  `a_i` and `b_i` represent the left and right hand sides, and `eq_i` is a proof for their heterogeneous equality. -/\n  | heq\n  /--\n  For congr-simp theorems only.  Indicates a decidable instance argument.\n  The lemma contains two arguments [a_i : Decidable ...] [b_i : Decidable ...] -/\n  | subsingletonInst\n  deriving Inhabited, Repr\n\nstructure CongrTheorem where\n  type     : Expr\n  proof    : Expr\n  argKinds : Array CongrArgKind\n\nprivate def addPrimeToFVarUserNames (ys : Array Expr) (lctx : LocalContext) : LocalContext := Id.run do\n  let mut lctx := lctx\n  for y in ys do\n    let decl := lctx.getFVar! y\n    lctx := lctx.setUserName decl.fvarId (decl.userName.appendAfter \"'\")\n  return lctx\n\nprivate def setBinderInfosD (ys : Array Expr) (lctx : LocalContext) : LocalContext := Id.run do\n  let mut lctx := lctx\n  for y in ys do\n    let decl := lctx.getFVar! y\n    lctx := lctx.setBinderInfo decl.fvarId BinderInfo.default\n  return lctx\n\npartial def mkHCongrWithArity (f : Expr) (numArgs : Nat) : MetaM CongrTheorem := do\n  let fType \u2190 inferType f\n  forallBoundedTelescope fType numArgs fun xs _ =>\n  forallBoundedTelescope fType numArgs fun ys _ => do\n    if xs.size != numArgs then\n      throwError \"failed to generate hcongr theorem, insufficient number of arguments\"\n    else\n      let lctx := addPrimeToFVarUserNames ys (\u2190 getLCtx) |> setBinderInfosD ys |> setBinderInfosD xs\n      withLCtx lctx (\u2190 getLocalInstances) do\n      withNewEqs xs ys fun eqs argKinds => do\n        let mut hs := #[]\n        for x in xs, y in ys, eq in eqs do\n          hs := hs.push x |>.push y |>.push eq\n        let lhs := mkAppN f xs\n        let rhs := mkAppN f ys\n        let congrType \u2190 mkForallFVars hs (\u2190 mkHEq lhs rhs)\n        return {\n          type  := congrType\n          proof := (\u2190 mkProof congrType)\n          argKinds\n        }\nwhere\n  withNewEqs {\u03b1} (xs ys : Array Expr) (k : Array Expr \u2192 Array CongrArgKind \u2192 MetaM \u03b1) : MetaM \u03b1 :=\n    let rec loop (i : Nat) (eqs : Array Expr) (kinds : Array CongrArgKind) := do\n      if  i < xs.size then\n        let x := xs[i]!\n        let y := ys[i]!\n        let xType := (\u2190 inferType x).consumeTypeAnnotations\n        let yType := (\u2190 inferType y).consumeTypeAnnotations\n        if xType == yType then\n          withLocalDeclD ((`e).appendIndexAfter (i+1)) (\u2190 mkEq x y) fun h =>\n            loop (i+1) (eqs.push h) (kinds.push CongrArgKind.eq)\n        else\n          withLocalDeclD ((`e).appendIndexAfter (i+1)) (\u2190 mkHEq x y) fun h =>\n            loop (i+1) (eqs.push h) (kinds.push CongrArgKind.heq)\n      else\n        k eqs kinds\n    loop 0 #[] #[]\n\n  mkProof (type : Expr) : MetaM Expr := do\n    if let some (_, lhs, _) := type.eq? then\n      mkEqRefl lhs\n    else if let some (_, lhs, _, _) := type.heq? then\n      mkHEqRefl lhs\n    else\n      forallBoundedTelescope type (some 1) fun a type =>\n      let a := a[0]!\n      forallBoundedTelescope type (some 1) fun b motive =>\n      let b := b[0]!\n      let type := type.bindingBody!.instantiate1 a\n      withLocalDeclD motive.bindingName! motive.bindingDomain! fun eqPr => do\n      let type := type.bindingBody!\n      let motive := motive.bindingBody!\n      let minor \u2190 mkProof type\n      let mut major := eqPr\n      if (\u2190 whnf (\u2190 inferType eqPr)).isHEq then\n        major \u2190 mkEqOfHEq major\n      let motive \u2190 mkLambdaFVars #[b] motive\n      mkLambdaFVars #[a, b, eqPr] (\u2190 mkEqNDRec motive minor major)\n\ndef mkHCongr (f : Expr) : MetaM CongrTheorem := do\n  mkHCongrWithArity f (\u2190 getFunInfo f).getArity\n\n/--\n  Ensure that all dependencies for `congr_arg_kind::Eq` are `congr_arg_kind::Fixed`.\n-/\nprivate def fixKindsForDependencies (info : FunInfo) (kinds : Array CongrArgKind) : Array CongrArgKind := Id.run do\n  let mut kinds := kinds\n  for i in [:info.paramInfo.size] do\n    for j in [i+1:info.paramInfo.size] do\n      if info.paramInfo[j]!.backDeps.contains i then\n        if kinds[j]! matches CongrArgKind.eq || kinds[j]! matches CongrArgKind.fixed then\n          -- We must fix `i` because there is a `j` that depends on `i` and `j` is not cast-fixed.\n          kinds := kinds.set! i CongrArgKind.fixed\n          break\n  return kinds\n\n/--\n  (Try to) cast expression `e` to the given type using the equations `eqs`.\n  `deps` contains the indices of the relevant equalities.\n  Remark: deps is sorted. -/\nprivate partial def mkCast (e : Expr) (type : Expr) (deps : Array Nat) (eqs : Array (Option Expr)) : MetaM Expr := do\n  let rec go (i : Nat) (type : Expr) : MetaM Expr := do\n     if i < deps.size then\n       match eqs[deps[i]!]! with\n       | none => go (i+1) type\n       | some major =>\n         let some (_, lhs, rhs) := (\u2190 inferType major).eq? | unreachable!\n         if (\u2190 dependsOn type major.fvarId!) then\n           let motive \u2190 mkLambdaFVars #[rhs, major] type\n           let typeNew := type.replaceFVar rhs lhs |>.replaceFVar major (\u2190 mkEqRefl lhs)\n           let minor \u2190 go (i+1) typeNew\n           mkEqRec motive minor major\n         else\n           let motive \u2190 mkLambdaFVars #[rhs] type\n           let typeNew := type.replaceFVar rhs lhs\n           let minor \u2190 go (i+1) typeNew\n           mkEqNDRec motive minor major\n     else\n       return e\n  go 0 type\n\nprivate def hasCastLike (kinds : Array CongrArgKind) : Bool :=\n  kinds.any fun kind => kind matches CongrArgKind.cast || kind matches CongrArgKind.subsingletonInst\n\nprivate def withNext (type : Expr) (k : Expr \u2192 Expr \u2192 MetaM \u03b1) : MetaM \u03b1 := do\n  forallBoundedTelescope type (some 1) fun xs type => k xs[0]! type\n\n/--\n  Test whether we should use `subsingletonInst` kind for instances which depend on `eq`.\n  (Otherwise `fixKindsForDependencies`will downgrade them to Fixed -/\nprivate def shouldUseSubsingletonInst (info : FunInfo) (kinds : Array CongrArgKind) (i : Nat) : Bool := Id.run do\n  if info.paramInfo[i]!.isDecInst then\n    for j in info.paramInfo[i]!.backDeps do\n      if kinds[j]! matches CongrArgKind.eq then\n        return true\n  return false\n\n/--\nIf `f` is a class constructor, return a bitmask `m` s.t. `m[i]` is true if the `i`-th parameter\ncorresponds to a subobject field.\n\nWe use this function to implement the special support for class constructors at `getCongrSimpKinds`.\nSee issue #1808\n-/\nprivate def getClassSubobjectMask? (f : Expr) : MetaM (Option (Array Bool)) := do\n  let .const declName _ := f | return none\n  let .ctorInfo val \u2190 getConstInfo declName | return none\n  unless isClass (\u2190 getEnv) val.induct do return none\n  forallTelescopeReducing val.type fun xs _ => do\n    let env \u2190 getEnv\n    let mut mask := #[]\n    for i in [:xs.size] do\n      if i < val.numParams then\n        mask := mask.push false\n      else\n        let localDecl \u2190 xs[i]!.fvarId!.getDecl\n        mask := mask.push (isSubobjectField? env val.induct localDecl.userName).isSome\n    return some mask\n\n/-- Compute `CongrArgKind`s for a simp congruence theorem. -/\ndef getCongrSimpKinds (f : Expr) (info : FunInfo) : MetaM (Array CongrArgKind) := do\n  /-\n  The default `CongrArgKind` is `eq`, which allows `simp` to rewrite this\n  argument. However, if there are references from `i` to `j`, we cannot\n  rewrite both `i` and `j`. So we must change the `CongrArgKind` at\n  either `i` or `j`. In principle, if there is a dependency with `i`\n  appearing after `j`, then we set `j` to `fixed` (or `cast`). But there is\n  an optimization: if `i` is a subsingleton, we can fix it instead of\n  `j`, since all subsingletons are equal anyway. The fixing happens in\n  two loops: one for the special cases, and one for the general case.\n\n  This method has special support for class constructors.\n  For this kind of function, we treat subobject fields as regular parameters instead of instance implicit ones.\n  We added this feature because of issue #1808\n  -/\n  let mut result := #[]\n  let mask? \u2190 getClassSubobjectMask? f\n  for i in [:info.paramInfo.size] do\n    if info.resultDeps.contains i then\n      result := result.push .fixed\n    else if info.paramInfo[i]!.isProp then\n      result := result.push .cast\n    else if info.paramInfo[i]!.isInstImplicit then\n      if let some mask := mask? then\n        if h : i < mask.size then\n          if mask[i] then\n            -- Parameter is a subobect field of a class constructor. See comment above.\n            result := result.push .eq\n            continue\n      if shouldUseSubsingletonInst info result i then\n        result := result.push .subsingletonInst\n      else\n        result := result.push .fixed\n    else\n      result := result.push .eq\n  return fixKindsForDependencies info result\n\n/--\n  Create a congruence theorem that is useful for the simplifier and `congr` tactic.\n-/\npartial def mkCongrSimpCore? (f : Expr) (info : FunInfo) (kinds : Array CongrArgKind) (subsingletonInstImplicitRhs : Bool := true) : MetaM (Option CongrTheorem) := do\n  if let some result \u2190 mk? f info kinds then\n    return some result\n  else if hasCastLike kinds then\n    -- Simplify kinds and try again\n    let kinds := kinds.map fun kind =>\n      if kind matches CongrArgKind.cast || kind matches CongrArgKind.subsingletonInst then CongrArgKind.fixed else kind\n    mk? f info kinds\n  else\n    return none\nwhere\n  /--\n    Create a congruence theorem that is useful for the simplifier.\n    In this kind of theorem, if the i-th argument is a `cast` argument, then the theorem\n    contains an input `a_i` representing the i-th argument in the left-hand-side, and\n    it appears with a cast (e.g., `Eq.drec ... a_i ...`) in the right-hand-side.\n    The idea is that the right-hand-side of this theorem \"tells\" the simplifier\n    how the resulting term looks like. -/\n  mk? (f : Expr) (info : FunInfo) (kinds : Array CongrArgKind) : MetaM (Option CongrTheorem) := do\n    try\n      let fType \u2190 inferType f\n      forallBoundedTelescope fType kinds.size fun lhss _ => do\n        if lhss.size != kinds.size then return none\n        let rec go (i : Nat) (rhss : Array Expr) (eqs : Array (Option Expr)) (hyps : Array Expr) : MetaM CongrTheorem := do\n          if i == kinds.size then\n            let lhs := mkAppN f lhss\n            let rhs := mkAppN f rhss\n            let type \u2190 mkForallFVars hyps (\u2190 mkEq lhs rhs)\n            let proof \u2190 mkProof type kinds\n            return { type, proof, argKinds := kinds }\n          else\n            let hyps := hyps.push lhss[i]!\n            match kinds[i]! with\n            | .heq | .fixedNoParam => unreachable!\n            | .eq =>\n              let localDecl \u2190 lhss[i]!.fvarId!.getDecl\n              withLocalDecl localDecl.userName localDecl.binderInfo localDecl.type fun rhs => do\n              withLocalDeclD (localDecl.userName.appendBefore \"e_\") (\u2190 mkEq lhss[i]! rhs) fun eq => do\n                go (i+1) (rhss.push rhs) (eqs.push eq) (hyps.push rhs |>.push eq)\n            | .fixed => go (i+1) (rhss.push lhss[i]!) (eqs.push none) hyps\n            | .cast =>\n              let rhsType := (\u2190 inferType lhss[i]!).replaceFVars (lhss[:rhss.size]) rhss\n              let rhs \u2190 mkCast lhss[i]! rhsType info.paramInfo[i]!.backDeps eqs\n              go (i+1) (rhss.push rhs) (eqs.push none) hyps\n            | .subsingletonInst =>\n              -- The `lhs` does not need to instance implicit since it can be inferred from the LHS\n              withNewBinderInfos #[(lhss[i]!.fvarId!, .implicit)] do\n                let rhsType := (\u2190 inferType lhss[i]!).replaceFVars (lhss[:rhss.size]) rhss\n                let rhsBi   := if subsingletonInstImplicitRhs then .instImplicit else .implicit\n                withLocalDecl (\u2190 lhss[i]!.fvarId!.getDecl).userName rhsBi rhsType fun rhs =>\n                  go (i+1) (rhss.push rhs) (eqs.push none) (hyps.push rhs)\n        return some (\u2190 go 0 #[] #[] #[])\n    catch _ =>\n      return none\n\n  mkProof (type : Expr) (kinds : Array CongrArgKind) : MetaM Expr := do\n    let rec go (i : Nat) (type : Expr) : MetaM Expr := do\n      if i == kinds.size then\n        let some (_, lhs, _) := type.eq? | unreachable!\n        mkEqRefl lhs\n      else\n        withNext type fun lhs type => do\n        match kinds[i]! with\n        | .heq | .fixedNoParam => unreachable!\n        | .fixed => mkLambdaFVars #[lhs] (\u2190 go (i+1) type)\n        | .cast => mkLambdaFVars #[lhs] (\u2190 go (i+1) type)\n        | .eq =>\n          let typeSub := type.bindingBody!.bindingBody!.instantiate #[(\u2190 mkEqRefl lhs), lhs]\n          withNext type fun rhs type =>\n          withNext type fun heq type => do\n            let motive \u2190 mkLambdaFVars #[rhs, heq] type\n            let proofSub \u2190 go (i+1) typeSub\n            mkLambdaFVars #[lhs, rhs, heq] (\u2190 mkEqRec motive proofSub heq)\n        | .subsingletonInst =>\n          let typeSub := type.bindingBody!.instantiate #[lhs]\n          withNext type fun rhs type => do\n            let motive \u2190 mkLambdaFVars #[rhs] type\n            let proofSub \u2190 go (i+1) typeSub\n            let heq \u2190 mkAppM ``Subsingleton.elim #[lhs, rhs]\n            mkLambdaFVars #[lhs, rhs] (\u2190 mkEqNDRec motive proofSub heq)\n     go 0 type\n\n/--\nCreate a congruence theorem for `f`. The theorem is used in the simplifier.\n\nIf `subsingletonInstImplicitRhs = true`, the the `rhs` corresponding to `[Decidable p]` parameters\nis marked as instance implicit. It forces the simplifier to compute the new instance when applying\nthe congruence theorem.\nFor the `congr` tactic we set it to `false`.\n-/\ndef mkCongrSimp? (f : Expr) (subsingletonInstImplicitRhs : Bool := true) : MetaM (Option CongrTheorem) := do\n  let f := (\u2190 instantiateMVars f).cleanupAnnotations\n  let info \u2190 getFunInfo f\n  mkCongrSimpCore? f info (\u2190 getCongrSimpKinds f info) (subsingletonInstImplicitRhs := subsingletonInstImplicitRhs)\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/CongrTheorems.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.43398146480389854, "lm_q1q2_score": 0.2220755216739912}}
{"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\u2081 shape\u2082 : S} (\u03bc \u03c3 : T shape\u2081) (f : T shape\u2081 \u2192 T shape\u2082) :\n  is_btw_exp\u2082 f \u2192 is_integrable (\u03bb x, mvn_pdf \u03bc \u03c3 x \u2b1d f x)\n\naxiom is_uintegrable_mvn_of_bounded_exp\u2082_around {shape\u2081 shape\u2082 shape\u2083 : S} (pdf : T shape\u2081 \u2192 \u211d) (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, pdf x \u2b1d f x \u03b8\u2080) \u03b8\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\u2081\n     , applyc `certigrad.T.is_sub_quadratic_mul\u2082\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\u2082_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} (\u03bc \u03c3 : T shape) : \u03c3 > 0 \u2192 \u2200 (y : T oshape), is_integrable (\u03bb (x : T shape), mvn_pdf \u03bc \u03c3 x \u2b1d y)\naxiom mvn_moment\u2081_int {shape : S} (\u03bc \u03c3 : T shape) : \u03c3 > 0 \u2192 is_integrable (\u03bb (x : T shape), mvn_pdf \u03bc \u03c3 x \u2b1d x)\naxiom mvn_moment\u2082_int {shape : S} (\u03bc \u03c3 : T shape) : \u03c3 > 0 \u2192 is_integrable (\u03bb (x : T shape), mvn_pdf \u03bc \u03c3 x \u2b1d square x)\naxiom mvn_cmoment\u2082_int {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) : is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d square (x - \u03bc))\n\naxiom mvn_logpdf_int {shape : S} (\u03bc \u03bc' \u03c3 \u03c3' : T shape) (H_\u03c3 : \u03c3 > 0) (H_\u03c3' : \u03c3' > 0) : is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d mvn_logpdf \u03bc' \u03c3' x)\n\n-- TODO(dhs): prove in terms of primitives (possibly for concrete p)\naxiom mvn_bernoulli_neglogpdf_int {shape\u2081 shape\u2082 : S} (\u03bc \u03c3 : T shape\u2081) (H_\u03c3 : \u03c3 > 0) (p : T shape\u2081 \u2192 T shape\u2082)\n                                      (H_p_cont : \u2200 x, is_continuous p x) (H_p : \u2200 x, p x > 0 \u2227 p x < 1) (z : T shape\u2082) :\n  is_integrable (\u03bb (x : T shape\u2081), T.mvn_pdf \u03bc \u03c3 x \u2b1d bernoulli_neglogpdf (p x) z)\n\naxiom mvn_mvn_empirical_kl_int {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) (\u03bc' \u03c3' : T shape) :\n  is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d mvn_empirical_kl \u03bc' \u03c3' x)\n\naxiom mvn_mvn_kl_int {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) (\u03bc' \u03c3' : T shape) :\n  is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d mvn_kl \u03bc' \u03c3')\n\n-- mvn is a distribution (provable from first principles)\naxiom mvn_pdf_pos {shape : S} (\u03bc \u03c3 : T shape) : \u03c3 > 0 \u2192 \u2200 (x : T shape), mvn_pdf \u03bc \u03c3 x > 0\naxiom mvn_pdf_int1 {shape : S} (\u03bc \u03c3 : T shape) : \u03c3 > 0 \u2192 \u222b (\u03bb (x : T shape), mvn_pdf \u03bc \u03c3 x) = 1\n\nlemma mvn_expected {shape oshape : S} (\u03bc \u03c3 : T shape) : \u03c3 > 0 \u2192 \u2200 (y : T oshape), \u222b (\u03bb (x : T shape), mvn_pdf \u03bc \u03c3 x \u2b1d y) = y :=\nby { intros H_\u03c3 y, rw [integral_fscale, (mvn_pdf_int1 _ _ H_\u03c3), one_smul] }\n\n-- moments (provable from first principles)\naxiom mvn_moment\u2081 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) : \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d x) = \u03bc\naxiom mvn_moment\u2082 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) : \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d square x) = square \u03bc + square \u03c3\n\n-- central moments (provable in terms of moments)\nlemma mvn_cmoment\u2081 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) : \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (x - \u03bc)) = 0 :=\nhave H_int_x : is_integrable (\u03bb x, mvn_pdf \u03bc \u03c3 x \u2b1d x), from mvn_moment\u2081_int \u03bc \u03c3 H_\u03c3,\nhave H_int_\u03bc : is_integrable (\u03bb x, - (mvn_pdf \u03bc \u03c3 x \u2b1d \u03bc)), from iff.mp (is_integrable_neg _) (mvn_const_int \u03bc \u03c3 H_\u03c3 \u03bc),\ncalc  \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (x - \u03bc))\n    = \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d x + - (T.mvn_pdf \u03bc \u03c3 x \u2b1d \u03bc)) : begin simp [smul_addr, smul_neg], end\n... = \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d x) - \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d \u03bc)\n        : begin simp [integral_add, H_int_x, H_int_\u03bc, integral_neg] end\n... = \u03bc - \u03bc : by { rw [mvn_expected _ _ H_\u03c3, mvn_moment\u2081 _ _ H_\u03c3],  }\n... = 0 : by simp\n\n-- Exercise for the reader: prove\naxiom mvn_cmoment\u2082 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) : \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d square (x - \u03bc)) = square \u03c3\n\n-- central scaled moments (provable in terms of central moments)\nlemma mvn_csmoment\u2081 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) : \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d ((x - \u03bc) / \u03c3)) = 0 :=\nhave H_int_x\u03c3 : is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (x / \u03c3)),\n  by { simp [smul_div], exact iff.mp (is_integrable_div _ _ H_\u03c3) (mvn_moment\u2081_int _ _ H_\u03c3) },\n\nhave H_int_\u03bc\u03c3 : is_integrable (\u03bb (x : T shape), -(T.mvn_pdf \u03bc \u03c3 x \u2b1d (\u03bc / \u03c3))),\n by { apply iff.mp (is_integrable_neg _), simp [smul_div], exact iff.mp (is_integrable_div _ _ H_\u03c3) (mvn_const_int _ _ H_\u03c3 _) },\n\ncalc  \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d ((x - \u03bc) / \u03c3))\n    = \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (x / \u03c3) - (T.mvn_pdf \u03bc \u03c3 x \u2b1d (\u03bc / \u03c3)))\n        : by simp [T.div_add_div_same_symm, smul_addr, sum_add, neg_div, smul_neg, integral_neg]\n... = \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (x / \u03c3)) - \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (\u03bc / \u03c3))\n        : begin simp [integral_add, H_int_x\u03c3, H_int_\u03bc\u03c3, integral_neg] end\n... = \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d x) / \u03c3 - \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (\u03bc / \u03c3))\n        : by simp [smul_div, integral_div]\n... = \u03bc / \u03c3 - \u03bc / \u03c3 : by rw [mvn_moment\u2081 _ _ H_\u03c3, mvn_expected _ _ H_\u03c3]\n... = 0 : by simp\n\n-- Exercise for the reader: prove\naxiom mvn_csmoment\u2082 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) : \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d square ((x - \u03bc) / \u03c3)) = (1 : T shape)\n\nlemma mvn_logpdf_correct {shape : S} (\u03bc \u03c3 x : T shape) (H_\u03c3 : \u03c3 > 0) : log (mvn_pdf \u03bc \u03c3 x) = mvn_logpdf \u03bc \u03c3 x :=\nhave H_\u03c3\u2082 : square \u03c3 > 0, from square_pos_of_pos H_\u03c3,\nhave H_mul : (2 * pi shape) * square \u03c3 > 0, from mul_pos_of_pos_pos two_pi_pos H_\u03c3\u2082,\nhave H_sqrt : (sqrt ((2 * pi shape) * square \u03c3))\u207b\u00b9 > 0, from inv_pos (sqrt_pos H_mul),\nhave H_exp : exp ((- 2\u207b\u00b9) * (square $ (x - \u03bc) / \u03c3)) > 0, from exp_pos,\nhave H_mul\u2082 : (sqrt ((2 * pi shape) * square \u03c3))\u207b\u00b9 * exp ((- 2\u207b\u00b9) * (square $ (x - \u03bc) / \u03c3)) > 0,\nfrom mul_pos_of_pos_pos H_sqrt H_exp,\ncalc  log (mvn_pdf \u03bc \u03c3 x)\n    = log (prod ((sqrt ((2 * pi shape) * square \u03c3))\u207b\u00b9 * exp ((- 2\u207b\u00b9) * (square $ (x - \u03bc) / \u03c3)))) : rfl\n... = sum (log ((sqrt ((2 * pi shape) * square \u03c3))\u207b\u00b9) + ((- 2\u207b\u00b9) * (square $ (x - \u03bc) / \u03c3))) : by simp only [log_prod H_mul\u2082, log_mul H_sqrt H_exp, log_exp]\n... = sum ((- 2\u207b\u00b9) * log ((2 * pi shape) * square \u03c3) + ((- 2\u207b\u00b9) * (square $ (x - \u03bc) / \u03c3))) : by simp [log_inv, log_sqrt]\n... = sum ((- 2\u207b\u00b9) * (log (2 * pi shape) + log (square \u03c3)) + (- 2\u207b\u00b9) * (square $ (x - \u03bc) / \u03c3)) : by simp only [log_mul two_pi_pos H_\u03c3\u2082]\n... = sum ((- 2\u207b\u00b9) * (log (2 * pi shape) + log (square \u03c3) + (square $ (x - \u03bc) / \u03c3))) : by simp only [left_distrib]\n... = sum ((- (2 : \u211d)\u207b\u00b9) \u2b1d (log (2 * pi shape) + log (square \u03c3) + (square $ (x - \u03bc) / \u03c3))) : by simp only [smul.def, const_neg, const_inv, const_bit0, const_one]\n... = (- 2\u207b\u00b9) * sum (square ((x - \u03bc) / \u03c3) + log (2 * pi shape) + log (square \u03c3)) : by simp [sum_smul]\n... = mvn_logpdf \u03bc \u03c3 x : rfl\n\nlemma mvn_int_const {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) (y : \u211d) :\n  \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d y) = y :=\nby { rw [integral_fscale, (mvn_pdf_int1 _ _ H_\u03c3), one_smul] }\n\nlemma mvn_integral\u2081 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) :\n\u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d T.mvn_logpdf 0 1 x)\n=\n(- 2\u207b\u00b9) * sum (square \u03bc + square \u03c3) + (- 2\u207b\u00b9) * sum (log (2 * pi shape)) :=\nhave H_sq_x_int : is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d square x), from mvn_moment\u2082_int _ _ H_\u03c3,\nhave H_log_pi_int : is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d log (2 * pi shape)), from mvn_const_int _ _ H_\u03c3 _,\nhave H_sum_int : is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (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  \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d ((- 2\u207b\u00b9) * sum (square ((x - 0) / 1) + log (2 * pi shape) + log (square 1))))\n    = \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d ((- 2\u207b\u00b9) * sum (square x + log (2 * pi shape)))) : by simp [log_one, square, T.div_one]\n... = \u222b (\u03bb (x : T shape), (- (2 : \u211d)\u207b\u00b9) \u2b1d (T.mvn_pdf \u03bc \u03c3 x \u2b1d sum (square x + log (2 * pi shape)))) : by simp only [smul_mul_scalar_right]\n... = (- 2\u207b\u00b9) * \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d sum (square x + log (2 * pi shape))) : by { simp only [integral_scale], simp [smul.def] }\n... = (- 2\u207b\u00b9) * sum (\u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (square x + log (2 * pi shape)))) : by { simp only [integral_sum, H_sum_int, smul_sum] }\n... = (- 2\u207b\u00b9) * sum (\u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d square x + T.mvn_pdf \u03bc \u03c3 x \u2b1d log (2 * pi shape))) : by { simp only [smul_addr] }\n... = (- 2\u207b\u00b9) * sum (\u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d square x) + \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d log (2 * pi shape)))\n       : by { simp only [integral_add, H_sq_x_int, H_log_pi_int] }\n... = (- 2\u207b\u00b9) * (sum (square \u03bc + square \u03c3) + sum (log (2 * pi shape))) : by rw [mvn_moment\u2082 _ _ H_\u03c3, mvn_expected _ _ H_\u03c3, sum_add]\n... = (- 2\u207b\u00b9) * sum (square \u03bc + square \u03c3) + (- 2\u207b\u00b9) * sum (log (2 * pi shape)) : by rw left_distrib\n\nlemma mvn_integral\u2082 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) :\n\u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d T.mvn_logpdf \u03bc \u03c3 x)\n=\n(- 2\u207b\u00b9) * sum (1 : T shape) + (- 2\u207b\u00b9) * sum (log (2 * pi shape)) + (- 2\u207b\u00b9) * sum (log (square \u03c3)) :=\nhave H_int\u2081 : is_integrable (\u03bb (x : T shape), mvn_pdf \u03bc \u03c3 x \u2b1d (-2\u207b\u00b9 * sum (square ((x - \u03bc) / \u03c3)))),\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_\u03c3)),\nexact mvn_cmoment\u2082_int _ _ H_\u03c3,\nend,\n\nhave H_int\u2082 : is_integrable (\u03bb (x : T shape), mvn_pdf \u03bc \u03c3 x \u2b1d (-2\u207b\u00b9 * 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_\u03c3 _\nend,\n\nhave H_int\u2081\u2082 : is_integrable (\u03bb (x : T shape), mvn_pdf \u03bc \u03c3 x \u2b1d (-2\u207b\u00b9 * sum (square ((x - \u03bc) / \u03c3))) + mvn_pdf \u03bc \u03c3 x \u2b1d (-2\u207b\u00b9 * sum (log (2 * pi shape)))),\nfrom iff.mp (is_integrable_add _ _) (and.intro H_int\u2081 H_int\u2082),\n\nhave H_int\u2083 : is_integrable (\u03bb (x : T shape), mvn_pdf \u03bc \u03c3 x \u2b1d (-2\u207b\u00b9 * sum (log (square \u03c3)))),\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_\u03c3 _\nend,\n\nhave H_int\u2084 : is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d square ((x - \u03bc) / \u03c3)),\nbegin\nsimp only [square_div, smul_div],\napply iff.mp (is_integrable_div _ _ (square_pos_of_pos H_\u03c3)),\nexact mvn_cmoment\u2082_int _ _ H_\u03c3,\nend,\n\nhave H\u2081 : \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d ((- 2\u207b\u00b9) * sum (square ((x - \u03bc) / \u03c3)))) = (- 2\u207b\u00b9) * sum (1 : T shape), from\ncalc  \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d ((- 2\u207b\u00b9) * sum (square ((x - \u03bc) / \u03c3))))\n    = \u222b (\u03bb (x : T shape), (- (2 : \u211d)\u207b\u00b9) \u2b1d (T.mvn_pdf \u03bc \u03c3 x \u2b1d sum (square ((x - \u03bc) / \u03c3)))) : by simp only [smul_mul_scalar_right]\n... = (- 2\u207b\u00b9) * \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d sum (square ((x - \u03bc) / \u03c3))) : by { simp only [integral_scale], simp [smul.def] }\n... = (- 2\u207b\u00b9) * sum (\u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d square ((x - \u03bc) / \u03c3))) : by simp only [smul_sum, integral_sum, H_int\u2084]\n... = (- 2\u207b\u00b9) * sum (1 : T shape) : by rw (mvn_csmoment\u2082 _ _ H_\u03c3),\n\nhave H\u2082 : \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d ((- 2\u207b\u00b9) * sum (log (2 * pi shape)))) = (- 2\u207b\u00b9) * sum (log (2 * pi shape)), by rw (mvn_int_const \u03bc _ H_\u03c3),\n\nhave H\u2083 : \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d ((- 2\u207b\u00b9) * sum (log (square \u03c3)))) = (- 2\u207b\u00b9) * sum (log (square \u03c3)), by rw mvn_int_const \u03bc _ H_\u03c3,\nbegin\ndunfold mvn_logpdf,\nsimp only [sum_add, left_distrib, smul_addr, integral_add, H\u2081, H\u2082, H\u2083, H_int\u2081\u2082, H_int\u2081, H_int\u2082, H_int\u2083],\nend\n\nlemma mvn_kl_identity {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) :\n\u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d T.mvn_empirical_kl \u03bc \u03c3 x)\n=\nT.mvn_kl \u03bc \u03c3 :=\nhave H_logpdf_int : is_integrable (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d mvn_logpdf \u03bc \u03c3 x),\nfrom mvn_logpdf_int \u03bc \u03bc \u03c3 \u03c3 H_\u03c3 H_\u03c3,\n\nhave H_std_logpdf_int : is_integrable (\u03bb (x : T shape), - (T.mvn_pdf \u03bc \u03c3 x \u2b1d mvn_logpdf 0 1 x)),\nfrom iff.mp (is_integrable_neg _) (mvn_logpdf_int \u03bc 0 \u03c3 1 H_\u03c3 one_pos),\n\ncalc  \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d T.mvn_empirical_kl \u03bc \u03c3 x)\n    = \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d (mvn_logpdf \u03bc \u03c3 x - mvn_logpdf 0 1 x)) : rfl\n... = \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d mvn_logpdf \u03bc \u03c3 x + - (T.mvn_pdf \u03bc \u03c3 x \u2b1d mvn_logpdf 0 1 x)) : by simp [smul_addr, smul_neg]\n... = \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d mvn_logpdf \u03bc \u03c3 x) - \u222b (\u03bb (x : T shape), T.mvn_pdf \u03bc \u03c3 x \u2b1d mvn_logpdf 0 1 x)\n      : by simp [integral_add, H_logpdf_int, H_std_logpdf_int, integral_neg]\n... = ((- 2\u207b\u00b9) * sum (1 : T shape) + (- 2\u207b\u00b9) * sum (log (2 * pi shape)) + (- 2\u207b\u00b9) * sum (log (square \u03c3))) - ((- 2\u207b\u00b9) * sum (square \u03bc + square \u03c3) + (- 2\u207b\u00b9) * sum (log (2 * pi shape))) : by rw [mvn_integral\u2081 \u03bc \u03c3 H_\u03c3, mvn_integral\u2082 \u03bc \u03c3 H_\u03c3]\n... = (- 2\u207b\u00b9) * sum ((1 : T shape) + log (2 * pi shape) + log (square \u03c3) - square \u03bc - square \u03c3 - log (2 * pi shape)) : by simp [sum_add, left_distrib, sum_neg]\n... = (- 2\u207b\u00b9) * sum ((1 : T shape) + log (square \u03c3) - square \u03bc - square \u03c3 + (log (2 * pi shape) - log (2 * pi shape))) : by simp\n... = (- 2\u207b\u00b9) * sum ((1 : T shape) + log (square \u03c3) - square \u03bc - square \u03c3) : by simp\n... = T.mvn_kl \u03bc \u03c3 : 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 {\u03c3 : Type} {\u03b9 : Type} {\u03c4 : \u03b9 \u2192 Type} [decidable_eq \u03b9]\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 \u03c3 \u03c4 \u2192 Prop) (k : kernel \u03c3 \u03c4) (Q : thread_state \u03c3 \u03c4 \u2192 Prop) : Prop :=\n\u2200 {n} {s u : state n \u03c3 \u03c4} {ac : vector bool n}, (\u2200i : fin n, ac.nth i \u2192 P (s.threads.nth i)) \u2192 exec_state k ac s u \u2192 (\u2200i : fin n, ac.nth i \u2192 Q (u.threads.nth i))\n\nnotation `{* ` P : 1 ` *} ` k : 1 ` {* ` Q : 1 ` *}` := hoare P k Q\n\nexample (P Q : thread_state \u03c3 \u03c4 \u2192 Prop) (k\u2081 k\u2082 : kernel \u03c3 \u03c4) (c : \u03c3 \u2192 bool) : \n    {* \u03bb (t : thread_state \u03c3 \u03c4), P t \u2227 c t.tlocal *} k\u2081 {* Q *} \u2192 -- how is it possible that by loosening up the assumptions (i. e. and something to P) the proof gets possible?\n    {* \u03bb (t : thread_state \u03c3 \u03c4), P t \u2227 \u00acc t.tlocal *} k\u2082 {* Q *} \u2192 \n    {* P *} kernel.ite c k\u2081 k\u2082 {* 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 \u2190 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 \u2190 heqst',\n        apply and.intro,\n        {\n            exact hp i' hh',\n        }, {\n            exact deactivate_threads_condition' hh,\n        }, {\n            rw \u2190 bool.eq_tt_coe at hc,\n            apply active_map_deactivate_threads' hac hc,\n        }\n    }, {\n        sorry,\n    }\nend\n\nexample : \n    {* \u03bb (t : thread_state (\u2115 \u00d7 \u2115) \u03c4), t.tlocal.1 = 0 \u2227 t.tlocal.1 = 0 *} kernel.compute (\u03bb l, (l.1, 1)) {* \u03bb (t : thread_state (\u2115 \u00d7 \u2115) \u03c4), t.tlocal.2 = 1 *} \u2192\n    {* \u03bb (t : thread_state (\u2115 \u00d7 \u2115) \u03c4), t.tlocal.1 = 0 \u2227 \u00act.tlocal.1 = 0 *} kernel.compute (\u03bb l, (l.1, 2)) {* \u03bb (t : thread_state (\u2115 \u00d7 \u2115) \u03c4), t.tlocal.2 = 1 *} \u2192\n    {* \u03bb (t : thread_state (\u2115 \u00d7 \u2115) \u03c4), t.tlocal.1 = 0 *} kernel.ite (\u03bbt, t.1 = 0) (kernel.compute (\u03bb l, (l.1, 1))) (kernel.compute (\u03bb l, (l.1, 2))) {* \u03bb (t : thread_state (\u2115 \u00d7 \u2115) \u03c4), 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": "example : mynat \u2192 mynat :=\nbegin\nintro n, exact 3*n+2,\nend", "meta": {"author": "nicholaspun", "repo": "natural-number-game-solutions", "sha": "1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0", "save_path": "github-repos/lean/nicholaspun-natural-number-game-solutions", "path": "github-repos/lean/nicholaspun-natural-number-game-solutions/natural-number-game-solutions-1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0/3-function-world/l2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5813030906443134, "lm_q2_score": 0.38121956625614994, "lm_q1q2_score": 0.22160411207878458}}
{"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 \u27f6 Y)\n\nlemma is_iso_iff_ExtrDisc :\n  is_iso f \u2194 (\u2200 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 \u27f6 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 \u27f6 obj (cofibrant_object.mk X.obj) :=\napp (cofibrant_object.mk X.obj)\n\ndef map' {X Y : cofibrant_object C} (f : X \u27f6 Y) : obj X \u27f6 obj Y :=\nbegin\n  have sq : comm_sq ((cofibrant_object.forget C).map (f \u226b 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 \u27f6 Y) :\n  app X \u226b (bifibrant_object.forget_fib C).map (map' f) = f \u226b app Y :=\nby apply comm_sq.fac_left\n\nlemma fac' {X Y : bifibrant_object C} (f : X \u27f6 Y) :\n  app' X \u226b map' ((bifibrant_object.forget_fib C).map f) = f \u226b app' Y :=\nby apply fac\n\ndef map {X Y : cofibrant_object C} (f : X \u27f6 Y) :\n  bifibrant_object.homotopy_category.Q.obj (obj X) \u27f6\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 \u27f6 Y) (f' : obj X \u27f6 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 \u226b app Y) \u226b P.\u03c3)\n    ((cofibrant_object.forget C).map (app X)) P.\u03c0\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.\u03c0, cofibrant_object.forget_map, assoc, pre_path_object.d\u2080\u03c3,\n        comp_id, prod.lift_fst, bifibrant_object.forget_map] using (fac f).symm, },\n    { simpa only [pre_path_object.\u03c0, cofibrant_object.forget_map, assoc, comp_id,\n        pre_path_object.d\u2081\u03c3, prod.lift_snd, bifibrant_object.forget_map] using sq.w.symm, }, },\n  exact nonempty.intro\n  { h := sq.lift,\n    h\u2080' := by simpa using congr_arg (\u03bb f, f \u226b limits.prod.fst) sq.fac_right,\n    h\u2081' := by simpa using congr_arg (\u03bb f, f \u226b limits.prod.snd) sq.fac_right, },\nend\n\nend bifibrant_replacement\n\nvariable (C)\n\n@[simps]\ndef bifibrant_replacement : cofibrant_object C \u2964 bifibrant_object.homotopy_category C :=\n{ obj := \u03bb X, bifibrant_object.homotopy_category.Q.obj (bifibrant_replacement.obj X),\n  map := \u03bb X Y f, bifibrant_replacement.map f,\n  map_id' := \u03bb X, begin\n    rw [bifibrant_replacement.map_eq _ (\ud835\udfd9 _), 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' := \u03bb X Y Z f g, begin\n    rw [bifibrant_replacement.map_eq (f \u226b g)\n      (bifibrant_replacement.map' f \u226b 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 \u2964 Hocof)\n  [Lcof.is_localization cofibrant_object.weq]\n  {Hobif : Type*} [category Hobif] (Lbif : bifibrant_object C \u2964 Hobif)\n  [Lbif.is_localization bifibrant_object.weq]\n\nnamespace bifibrant_replacement\n\n@[simps]\ndef \u03c0 : bifibrant_object.homotopy_category C \u2964 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 \u22d9 Lcof) :=\n\u03bb X Y f hf, by convert localization.inverts Lcof cofibrant_object.weq f hf\n\ndef R : cofibrant_object C \u2964 Hobif := bifibrant_replacement C \u22d9 \u03c0 Lbif\n\nlemma R_inverts_weq : cofibrant_object.weq.is_inverted_by (R Lbif) := \u03bb 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 \u226b (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 \u2190 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 \u22d9 R Lbif \u2245 Lbif :=\nbegin\n  symmetry,\n  exact nat_iso.of_components\n    (\u03bb X, localization.iso_of_hom' Lbif bifibrant_object.weq (app' X) weak_eq.property)\n    (\u03bb X Y f, by { rw [localization.iso_of_hom'_hom, \u2190 Lbif.map_comp, \u2190 fac', Lbif.map_comp], refl, }),\nend\n\ndef R_comp_I'_iso {I' : Hobif \u2964 Hocof} (sq : Comm_sq (bifibrant_object.forget_fib C) Lbif Lcof I') :\n  R Lbif \u22d9 I' \u2245 Lcof :=\nbegin\n  symmetry,\n  exact nat_iso.of_components (\u03bb X, localization.iso_of_hom' Lcof cofibrant_object.weq\n    (app X) weak_eq.property \u226a\u226b sq.iso.symm.app _) (\u03bb 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, \u2190 Lcof.map_comp_assoc],\n    simp only [\u2190 fac, functor.map_comp, assoc],\n    congr' 1,\n    apply sq.iso.inv.naturality,\n  end),\nend\n\ndef is_equivalence (I' : Hobif \u2964 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 \u2964 Hocof :=\nlocalization.lift ((bifibrant_object.forget_fib C) \u22d9 Lcof)\n  (bifibrant_replacement.forget_comp_Lcof_inverts_weq Lcof) Lbif\n\ndef Lbif_comp_Hobif_to_Hocof_iso : Lbif \u22d9 Hobif_to_Hocof Lcof Lbif \u2245\n  bifibrant_object.forget_fib C \u22d9 Lcof := localization.fac _ _ _\n\ninstance : is_equivalence (Hobif_to_Hocof Lcof Lbif) :=\nbifibrant_replacement.is_equivalence Lcof Lbif (Hobif_to_Hocof Lcof Lbif)\n  \u27e8Lbif_comp_Hobif_to_Hocof_iso Lcof Lbif\u27e9\n\ninstance : full (bifibrant_object.forget_fib C \u22d9 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 : \u2115} {s : State}\n  (h : D_hws_at pw s) : \u00acA_hws_at pw s :=\nbegin\n  cases h with d h, change \u00ac\u2203 _, _, push_neg,\n  intro a, use d, rw not_A_wins_at, apply h,\nend\n\nlemma not_D_hws_at_of {pw : \u2115} {s : State}\n  (h : A_hws_at pw s) : \u00acD_hws_at pw s :=\nbegin\n  cases h with d h, change \u00ac\u2203 _, _, 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 : \u2115} {s : State}\n  (h : \u00acD_hws_at pw s) : s.act :=\nby { contrapose! h, use default, intro a, use 0 }\n\nlemma A_hvm_of_not_D_hws {pw : \u2115} {s : State}\n  (h : \u00acD_hws_at pw s) :\n  \u2200 (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\u2081, swap, { contradiction }, \n  rw play_A_move_at at h, split_ifs at h with h\u2082, swap, { cases h },\n  cases h\u2082 with h\u2082 h\u2083, convert h\u2083, change _ = dite _ _ _, rw dif_pos; refl,\nend\n\nlemma exi_moves_hws_of_not_D_hws {pw : \u2115} {s : State}\n  (h : \u00acD_hws_at pw s) :\n  \u2200 (md : Valid_D_move s.board) (d : D),\n  \u2203 (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\u2081 : \u00ac\u2203 _, _ := h, push_neg at h\u2081,\n  simp_rw not_D_wins_at at h\u2081, rintro md d\u2080, let md\u2080 := d\u2080.f s hs,\n  let d := d\u2080.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\u2082 : A_has_valid_move pw s'.board,\n  { apply A_hvm_of_not_D_hws h },\n  specialize h\u2081 d, cases h\u2081 with a h\u2081, let ma := a.f s' hs h\u2082, use [ma, a],\n  have hh : d\u2080 = d.set_move s md\u2080,\n  { change d\u2080 = (d\u2080.set_move s md).set_move s md\u2080,\n    rw [D_set_move_set_move_eq, D_set_move_self] },\n  rw hh, have h\u2083 : (init_game a d (apply_A_move s' ma.m)).A_wins,\n  { convert A_wins_at_play_move_of h\u2081,\n    rw init_game_play_move hs, change _ = dite _ _ _,\n    have h\u2083 : (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\u2083, rw dif_pos, swap, { split; assumption },\n    ext; try {refl}, rw play_A_move_at', dsimp,\n\n    sorry\n    -- simp_rw h\u2083, change (play_D_move_at (init_game a d s) hs).a with a,\n    -- generalize_proofs h\u2084, convert_to _ = apply_A_move s' (a.f s' hs h\u2082).m,\n    -- { congr; try {exact h\u2083}, convert_to trivial == trivial,\n    --   { exact eq_true_intro h\u2084 }, { exact eq_true_intro h\u2082 }, refl\n  },\n  let g : Game pw := _, change g.A_wins at h\u2083,\n  let g\u2081 : Game pw := _, change g\u2081.A_wins,\n  have h\u2084 : g\u2081 = g.set_D (d.set_move s md\u2080) := rfl, rw h\u2084, clear h\u2084,\n  have h\u2084 : s.len < (g.set_D d).s.len,\n  { exact length_lt_length_snoc\u2082 },\n  apply (D_set_move_A_wins_iff h\u2084).mpr, exact h\u2083,\nend\n\ndef mk_D_st_for_ma_exi_D_st {pw : \u2115} {s' : State}\n  (h : \u2200 (ma : Valid_A_move pw s'.board),\n    \u2203 (d : D), \u2200 (a : A pw),\n    (init_game a d (apply_A_move s' ma.m)).D_wins) :\n  D :=\nbegin\n  refine \u27e8\u03bb sx, _\u27e9,\n  apply dite (\u2203 (ma : Valid_A_move pw s'.board),\n    A_played_move_at sx s' ma); rintro h\u2081,\n  { exact (h h\u2081.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 : \u2115} {s : State}\n  (h : \u00acD_hws_at pw s) :\n  \u2200 (md : Valid_D_move s.board),\n  \u2203 (ma : Valid_A_move pw (apply_D_move s md.m).board),\n  \u00acD_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\u2081 := exi_moves_hws_of_not_D_hws h,\n  intro md, specialize h\u2081 md, simp_rw D_hws_at, contrapose! h\u2081,\n  simp_rw not_A_wins_at at h\u2081 \u22a2,\n  let D := mk_D_st_for_ma_exi_D_st h\u2081, use D,\n  rintro ma a, have h\u2082 := h\u2081 ma, let s' := apply_D_move s md.m,\n  change apply_D_move s md.m with s' at ma h\u2081 h\u2082 \u22a2,\n  let s\u2081 := apply_A_move s' ma.m,\n  change apply_A_move s' ma.m with s\u2081 at h\u2081 h\u2082 \u22a2,\n  let d := h\u2082.some, have h\u2083 := h\u2082.some_spec,\n  change \u2200 (a : A pw), (init_game a d s\u2081).D_wins at h\u2083,\n  specialize h\u2083 a, contrapose! h\u2083, rw not_D_wins_at at h\u2083 \u22a2,\n  intro n, specialize h\u2083 n, suffices h\u2084 : (init_game a D s\u2081).play n =\n    ((init_game a d s\u2081).play n).set_D D, { rwa h\u2084 at h\u2083 }, clear h\u2083,\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\u2081).play n with g,\n  simp_rw Game.play_move, change (g.set_D D).act with g.act,\n  split_ifs with h\u2083, swap, { refl }, have h\u2085 : 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\u2085,\n  suffices h\u2086 : apply_D_move g.s (D.f g.s h\u2083).m =\n    apply_D_move g.s (d.f g.s h\u2083).m,\n  { rw [h\u2086, \u2190play_A_move_at_set_D], refl },\n  simp_rw apply_D_move, congr' 3,\n  have h\u2086 : \u2203 (ma : Valid_A_move pw s'.board),\n    A_played_move_at g.s s' ma,\n  { exact \u27e8_, A_played_move_at_play\n    (A_played_move_at_apply_move hs rfl)\u27e9 },\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\u2087, change apply_D_move s md.m with s' at h\u2087,\n  have h\u2088 := h\u2087.some_spec, change d with h\u2082.some, congr,\n  suffices h\u2089 : apply_A_move (apply_D_move s md.m) h\u2086.some.m = s\u2081,\n  { rw h\u2089 }, change apply_A_move s' _ = apply_A_move _ _, congr,\n  apply A_played_move_at_eq h\u2086.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 : \u2115) : A pw :=\nbegin\n  refine \u27e8\u03bb s' h, _\u27e9,\n  apply dite (\u2203 (s : State) (md : Valid_D_move s.board),\n    \u00acD_hws_at pw s \u2227 s' = apply_D_move s md.m); rintro h\u2081 h\u2082,\n  { refine (_ : \u2203 (ma : Valid_A_move pw s'.board),\n      \u00acD_hws_at pw (apply_A_move s' ma.m)).some,\n    rcases h\u2081 with \u27e8s, md, h\u2081, rfl\u27e9,\n    use (exi_A_move_hws_of_not_D_hws h\u2081 _).some,\n    generalize_proofs h\u2082, exact h\u2082.some_spec },\n  { exact \u27e8_, h\u2082.some_spec\u27e9 },\nend\n\nlemma not_D_hws_at_play_of_not_D_hws {pw n : \u2115} {g : Game pw}\n  (h\u2081 : g.a = mk_A_st_for_not_D_hws pw)\n  (h\u2082 : \u00acD_hws_at pw g.s) :\n  \u00acD_hws_at pw (g.play n).s :=\nbegin\n  rename g g\u2080, induction n with n ih, { exact h\u2082 }, clear h\u2082,\n  rw play_at_succ', let g : Game pw := _,\n  change \u00acD_hws_at pw g.s at ih,\n  change \u00acD_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\u2083 : \u2203 (ma : Valid_A_move pw s'.board),\n    \u00acD_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\u2083.some, have h\u2084 := h\u2083.some_spec,\n  convert h\u2084, change Game.s (dite _ _ _) = _,\n  have h\u2085 : A_has_valid_move pw s'.board := \u27e8_, ma.h\u27e9,\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\u2085 = _, let A : A pw := _, change g\u2080.a = A at h\u2081,\n  have h\u2086 : g.a = A := by { rw \u2190h\u2081, exact play_at_players_eq.1 },\n  rw h\u2086, change (mk_A_st_for_not_D_hws pw).f _ _ _ = _,\n  rw mk_A_st_for_not_D_hws, dsimp, rw dif_pos, exact \u27e8s, md, ih, rfl\u27e9,\nend\n\nlemma A_hws_at_of {pw : \u2115} {s : State}\n  (h : \u00acD_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\u2081 : 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\u2081, clear h\u2081, have h\u2081 : A_has_valid_move pw s'.board,\n  { have h\u2081 : \u00acD_hws_at pw s := not_D_hws_at_play_of_not_D_hws rfl h,\n    exact \u27e8_, (exi_A_move_hws_of_not_D_hws h\u2081 md).some.h\u27e9 },\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 : \u2115} {s : State}\n  (h : \u00acA_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 : \u2115} {s : State} :\n  \u00acA_hws_at pw s \u2194 D_hws_at pw s :=\n\u27e8D_hws_at_of, not_A_hws_at_of\u27e9\n\nlemma not_D_hws_at_iff {pw : \u2115} {s : State} :\n  \u00acD_hws_at pw s \u2194 A_hws_at pw s :=\n\u27e8A_hws_at_of, not_D_hws_at_of\u27e9", "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 \u2964 D} {F : D \u2964 C} (adj : G \u22a3 F) {X : C} {Y : D}\n  (f : G.obj X \u27f6 Y) : G.map (adj.unit.app X) \u226b (F \u22d9 G).map f \u226b adj.counit.app Y = f :=\nby simp only [functor.comp_map, adjunction.counit_naturality, adjunction.left_triangle_components_assoc]\n\nsection\n\nvariables {C\u2081 C\u2082 D\u2081 D\u2082 : Type*} [category C\u2081] [category C\u2082]\n  [category D\u2081] [category D\u2082] {G\u2081 : C\u2081 \u2964 D\u2081} {F\u2081 : D\u2081 \u2964 C\u2081}\n  {G\u2082 : C\u2082 \u2964 D\u2082} {F\u2082 : D\u2082 \u2964 C\u2082}\n  (adj\u2081 : G\u2081 \u22a3 F\u2081) (adj\u2082 : G\u2082 \u22a3 F\u2082)\n  {L : C\u2081 \u2964 C\u2082} {L' : D\u2081 \u2964 D\u2082}\n\ninclude adj\u2081 adj\u2082\n\ndef adjunction.adjoint_nat_trans_equiv :\n  (L \u22d9 G\u2082 \u27f6 G\u2081 \u22d9 L') \u2243 (F\u2081 \u22d9 L \u27f6 L' \u22d9 F\u2082) :=\n{ to_fun := \u03bb \u03c4, begin\n    let \u03b1 := \ud835\udfd9 (F\u2081 \u22d9 L) \u25eb adj\u2082.unit,\n    let \u03b2 := (\ud835\udfd9 F\u2081) \u25eb \u03c4 \u25eb (\ud835\udfd9 F\u2082),\n    let \u03b3 := adj\u2081.counit \u25eb \ud835\udfd9 (L' \u22d9 F\u2082),\n    exact \u03b1 \u226b \u03b2 \u226b \u03b3,\n  end,\n  inv_fun := \u03bb \u03c4', begin\n    let \u03b1 := adj\u2081.unit \u25eb (\ud835\udfd9 (L \u22d9 G\u2082)),\n    let \u03b2 := (\ud835\udfd9 G\u2081) \u25eb \u03c4' \u25eb (\ud835\udfd9 G\u2082),\n    let \u03b3 := \ud835\udfd9 (G\u2081 \u22d9 L') \u25eb adj\u2082.counit,\n    exact \u03b1 \u226b \u03b2 \u226b \u03b3,\n  end,\n  left_inv := \u03bb \u03c4, 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 \u03c4.naturality_assoc,\n    dsimp,\n    rw [\u2190 L'.map_comp, adj\u2081.left_triangle_components, L'.map_id,\n      comp_id],\n  end,\n  right_inv := \u03bb \u03c4', 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 \u2190 \u03c4'.naturality,\n    dsimp,\n    rw [\u2190 L.map_comp_assoc, adj\u2081.right_triangle_components, L.map_id, id_comp],\n  end, }\n\n@[simp]\nlemma adjunction.adjoint_nat_trans_equiv_app (\u03c4 : L \u22d9 G\u2082 \u27f6 G\u2081 \u22d9 L') (Y\u2081 : D\u2081) :\n  (adjunction.adjoint_nat_trans_equiv adj\u2081 adj\u2082 \u03c4).app Y\u2081 =\n    adj\u2082.unit.app (L.obj (F\u2081.obj Y\u2081)) \u226b\n      F\u2082.map (\u03c4.app (F\u2081.obj Y\u2081)) \u226b\n      F\u2082.map (L'.map (adj\u2081.counit.app Y\u2081)) :=\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 (\u03c4 : F\u2081 \u22d9 L \u27f6 L' \u22d9 F\u2082) (X\u2081 : C\u2081) :\n  ((adjunction.adjoint_nat_trans_equiv adj\u2081 adj\u2082).symm \u03c4).app X\u2081 =\n  G\u2082.map (L.map (adj\u2081.unit.app X\u2081)) \u226b\n      G\u2082.map (\u03c4.app (G\u2081.obj X\u2081)) \u226b adj\u2082.counit.app (L'.obj (G\u2081.obj X\u2081)) :=\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 \u2964 D) (J : Type*) [category J] :\n  F \u22d9 (functor.const J) \u2245 (functor.const J) \u22d9 (whiskering_right J C D).obj F :=\nnat_iso.of_components (\u03bb X, nat_iso.of_components (\u03bb 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 \u2964 C) \u2964 C} (adj : functor.const J \u22a3 F)\n\ninclude adj\n\nlemma is_limit_of_is_iso_adj {X : J \u2964 C} (c : cone X)\n  (h : is_iso ((adj.hom_equiv _ _) c.\u03c0)) : is_limit c :=\nbegin\n  haveI := h,\n  exact\n  { lift := \u03bb s, (adj.hom_equiv _ _) s.\u03c0 \u226b inv ((adj.hom_equiv _ _) c.\u03c0),\n    fac' := \u03bb s, begin\n      suffices : (functor.const J).map ((adj.hom_equiv s.X X) s.\u03c0 \u226b inv ((adj.hom_equiv c.X X) c.\u03c0)) \u226b c.\u03c0 = s.\u03c0,\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' := \u03bb s m hm, begin\n      rw [\u2190 cancel_mono ((adj.hom_equiv c.X X) c.\u03c0), 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 \u2964 C} {c : cone X} (hc : is_limit c) :\n  is_iso ((adj.hom_equiv _ _) c.\u03c0) :=\nbegin\n  refine is_iso.mk \u27e8hc.lift (cone.mk (F.obj X) (adj.counit.app X)), _, _\u27e9,\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.\u03c0) 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 \u2964 C) : limit_cone X :=\n\u27e8cone.mk (F.obj X) (adj.counit.app X), is_limit_of_is_iso_adj adj _ (by tidy)\u27e9\n\nlemma has_limits_of_shape_of_adj : has_limits_of_shape J C :=\n\u27e8\u03bb X, \u27e8nonempty.intro (limit_cone_of_adj adj X)\u27e9\u27e9\n\nend\n\nsection\n\nvariables {C\u2081 C\u2082 J : Type*} [category C\u2081] [category C\u2082] [category J]\n  {F\u2081 : (J \u2964 C\u2081) \u2964 C\u2081} {F\u2082 : (J \u2964 C\u2082) \u2964 C\u2082} (adj\u2081 : functor.const J \u22a3 F\u2081)\n  (adj\u2082 : functor.const J \u22a3 F\u2082) (L : C\u2081 \u2964 C\u2082)\n\ninclude adj\u2081 adj\u2082\n\n@[simp]\ndef limit_comparison_of_adj : F\u2081 \u22d9 L \u27f6 (whiskering_right J _ _).obj L \u22d9 F\u2082 :=\n(adjunction.adjoint_nat_trans_equiv adj\u2081 adj\u2082)(L.comp_const J).hom\n\nlemma preserves_limit_of_adj (X : J \u2964 C\u2081)\n  (hX : is_iso ((limit_comparison_of_adj adj\u2081 adj\u2082 L).app X)) : preserves_limit X L :=\nbegin\n  refine preserves_limit_of_preserves_limit_cone (limit_cone_of_adj adj\u2081 X).is_limit _,\n  refine is_limit_of_is_iso_adj adj\u2082 _ _,\n  convert hX,\n  apply (adj\u2082.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_\u03c0_app,\n    adjunction.adjoint_nat_trans_equiv_app, whiskering_right_obj_map, \u2190 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\u2081 adj\u2082 L)] : preserves_limits_of_shape J L :=\n\u27e8\u03bb X, preserves_limit_of_adj adj\u2081 adj\u2082 L X infer_instance\u27e9\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 \u2964 A) \u2964 A)) := \u27e8\u27e9 .\n\n/-\nTODO: Change `AB5` from this definition to saying that `colim : (J \u2964 A) \u2964 A`\npreserves finite limits and colimits whenever `J` is filtered.\n-/\nclass AB5 : Prop :=\n(cond [] : \u2200 (J : Type v) [small_category J] [is_filtered J],\n  functor.exact (limits.colim : (J \u2964 A) \u2964 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 \u2964 A) \u2964 A) :=\nAB5.cond A J\n\nvariables\n  [preserves_finite_limits (limits.colim : (J \u2964 A) \u2964 A)]\n  [preserves_finite_colimits (limits.colim : (J \u2964 A) \u2964 A)]\n\nnoncomputable\ndef colimit_homology_functor_iso\n  {M : Type} (c : complex_shape M) (i : M) :\n  homology_functor (J \u2964 A) c i \u22d9 limits.colim \u2245\n  (limits.colim.map_homological_complex _) \u22d9 homology_functor _ _ i :=\nfunctor.homology_functor_iso _ _ _\n\nnoncomputable\ndef eval_functor_colimit_iso\n  {M : Type} (c : complex_shape M)\n  (F : J \u2964 homological_complex A c) :\n  colimit F \u2245 (limits.colim.map_homological_complex c).obj\n  (homological_complex.eval_functor.obj F) :=\nhomological_complex.hom.iso_of_components\n(\u03bb i, preserves_colimit_iso (homological_complex.eval A c i) _)\nbegin\n  intros i j hij,\n  rw \u2190iso.eq_inv_comp,\n  apply colimit.hom_ext,\n  intro k,\n  dsimp,\n  simp only [colimit.\u03b9_map, whisker_left_app, \u03b9_preserves_colimits_iso_inv_assoc,\n    homological_complex.eval_map, homological_complex.hom.comm_assoc],\n  congr,\n  rw [preserves_colimit_iso, \u2190 limits.colimit.iso_colimit_cocone_\u03b9_inv\n    \u27e8_, preserves_colimit.preserves (colimit.is_colimit F)\u27e9],\n  refl\nend\n\nnoncomputable\ninstance homology_functor_preserves_filtered_colimit\n  {M : Type} (c : complex_shape M) (i : M)\n  (F : J \u2964 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  [\u2200 (J : Type v) [hJ : small_category J]\n    [@is_filtered J hJ],\n    by exactI preserves_finite_limits (limits.colim : (J \u2964 A) \u2964 A)]\n  [\u2200 (J : Type v) [hJ : small_category J]\n    [@is_filtered J hJ],\n    by exactI preserves_finite_colimits (limits.colim : (J \u2964 A) \u2964 A)] :\n  preserves_filtered_colimits\n  (homology_functor A c i : homological_complex A c \u2964 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 Lean\n\nnamespace Lean.Meta.Match\n\nprivate def isMatchValue (e : Expr) : Bool :=\n  e.isNatLit || e.isCharLit || e.isStringLit\n\npartial def mkEquationsFor (matchDeclName : Name) :  MetaM Unit := do\n  let constInfo \u2190 getConstInfo matchDeclName\n  let us := constInfo.levelParams.map mkLevelParam\n  let some matchInfo \u2190 getMatcherInfo? matchDeclName | throwError \"'{matchDeclName}' is not a matcher function\"\n  forallTelescopeReducing constInfo.type fun xs _ => do\n    let params := xs[:matchInfo.numParams]\n    let motive := xs[matchInfo.getMotivePos]\n    let alts   := xs[xs.size - matchInfo.numAlts:]\n    let firstDiscrIdx := matchInfo.numParams + 1\n    let discrs := xs[firstDiscrIdx : firstDiscrIdx + matchInfo.numDiscrs]\n    let mut notAlts := #[]\n    for alt in alts do\n      let altType \u2190 inferType alt\n      trace[Meta.debug] \">> {altType}\"\n      notAlts \u2190 forallTelescopeReducing altType fun ys altResultType => do\n        let (ys, rhsArgs) \u2190 toFVarsRHSArgs ys\n        let patterns := altResultType.getAppArgs\n        let mut hs := #[]\n        for notAlt in notAlts do\n          hs := hs.push (\u2190 instantiateForall notAlt patterns)\n        hs \u2190 simpHs hs patterns.size\n        trace[Meta.debug] \"hs: {hs}\"\n        -- Create a proposition for representing terms that do not match `patterns`\n        let mut notAlt := mkConst ``False\n        for discr in discrs.toArray.reverse, pattern in patterns.reverse do\n          notAlt \u2190 mkArrow (\u2190 mkEq discr pattern) notAlt\n        notAlt \u2190 mkForallFVars (discrs ++ ys) notAlt\n        trace[Meta.debug] \"notAlt: {notAlt}\"\n        let lhs := mkAppN (mkConst constInfo.name us) (params ++ #[motive] ++ patterns ++ alts)\n        let rhs := mkAppN alt rhsArgs\n        let thmType \u2190 mkEq lhs rhs\n        let thmType \u2190 hs.foldrM (init := thmType) mkArrow\n        let thmType \u2190 mkForallFVars (params ++ #[motive] ++ alts ++ ys) thmType\n        let thmVal \u2190 prove thmType\n        trace[Meta.debug] \">> {thmType}\"\n        return notAlts.push notAlt\nwhere\n  toFVarsRHSArgs (ys : Array Expr) : MetaM (Array Expr \u00d7 Array Expr) := do\n    if ys.size == 1 && (\u2190 inferType ys[0]).isConstOf ``Unit then\n      return (#[], #[mkConst ``Unit.unit])\n    else\n      return (ys, ys)\n\n  simpEq (lhs : Expr) (rhs : Expr) : OptionT (StateRefT (Array Expr) MetaM) Unit := do\n    if isMatchValue lhs && isMatchValue rhs then\n      unless (\u2190 isDefEq lhs rhs) do\n        failure\n    else if rhs.isFVar then\n      -- Ignore case since it matches anything\n      pure ()\n    else match lhs.arrayLit?, rhs.arrayLit? with\n      | some (_, lhsArgs), some (_, rhsArgs) =>\n        if lhsArgs.length != rhsArgs.length then\n          failure\n        else\n          for lhsArg in lhsArgs, rhsArg in rhsArgs do\n            simpEq lhsArg rhsArg\n      | _, _ =>\n        match toCtorIfLit lhs |>.constructorApp? (\u2190 getEnv), toCtorIfLit rhs |>.constructorApp? (\u2190 getEnv) with\n        | some (lhsCtor, lhsArgs), some (rhsCtor, rhsArgs) =>\n          if lhsCtor.name == rhsCtor.name then\n            for lhsArg in lhsArgs[lhsCtor.numParams:], rhsArg in rhsArgs[lhsCtor.numParams:] do\n              simpEq lhsArg rhsArg\n          else\n            failure\n        | _, _ =>\n          let newEq \u2190 mkEq lhs rhs\n          modify fun eqs => eqs.push newEq\n\n  simpEqs (eqs : Array Expr) : OptionT (StateRefT (Array Expr) MetaM) Unit := do\n    eqs.forM fun eq =>\n      match eq.eq? with\n      | some (_, lhs, rhs) => simpEq lhs rhs\n      | _ => throwError \"failed to generate equality theorems for 'match', equality expected{indentExpr eq}\"\n\n  simpHs (hs : Array Expr) (numPatterns : Nat) : MetaM (Array Expr) :=\n    hs.filterMapM fun h => forallTelescope h fun ys _ => do\n      trace[Meta.debug] \"ys: {ys}\"\n      let xs  := ys[:ys.size - numPatterns].toArray\n      let eqs \u2190 ys[ys.size - numPatterns : ys.size].toArray.mapM inferType\n      if let some eqsNew \u2190 simpEqs eqs *> get |>.run |>.run' #[] then\n        let newH \u2190 eqsNew.foldrM (init := mkConst ``False) mkArrow\n        let xs \u2190 xs.filterM fun x => dependsOn newH x.fvarId!\n        return some (\u2190 mkForallFVars xs newH)\n      else\n        none\n\n  proveLoop (mvarId : MVarId) : MetaM Unit := do\n    let mvarId \u2190 modifyTargetEqLHS mvarId whnfCore\n    (applyRefl mvarId)\n    <|>\n    (do trace[Meta.debug] \"TODO{indentD <| MessageData.ofGoal mvarId}\"\n        -- TODO\n        admit mvarId)\n\n  prove (type : Expr) : MetaM Expr :=\n    withLCtx {} {} <| forallTelescope type fun ys target => do\n      let mvar0  \u2190 mkFreshExprSyntheticOpaqueMVar target\n      let mvarId \u2190 deltaTarget mvar0.mvarId! (. == matchDeclName)\n      proveLoop mvarId\n      mkLambdaFVars ys (\u2190 instantiateMVars mvar0)\n\nend Lean.Meta.Match\n\ndef f (xs ys : List String) : Nat :=\n  match xs, ys with\n  | [], []      => 0\n  | _,  [\"abc\"] => 1\n  | _, x::xs    => xs.length\n  | _,  _       => 2\n\ndef h (x y : Nat) : Nat :=\n  match x, y with\n  | 10000, _ => 0\n  | 10001, _ => 5\n  | _, 20000 => 4\n  | x+1, _   => 3\n  | Nat.zero, y+1 => 44\n  | _, _     => 1\n\ntheorem ex1 : h 10000 1 = 0 :=\n  rfl\n\ntheorem ex2 : h 10002 1 = 3 :=\n  rfl\n\ndef g (xs ys : Array Nat) : Nat :=\n  match xs, ys with\n  | #[], #[]     => 0\n  | _, #[0, y+1] => 1\n  | _, #[x, y]   => 2\n  | _,  _        => 3\n\n-- #print f.match_1\n\nset_option trace.Meta.debug true\n#eval Lean.Meta.Match.mkEquationsFor ``f.match_1\n#eval Lean.Meta.Match.mkEquationsFor ``h.match_1\n#eval Lean.Meta.Match.mkEquationsFor ``g.match_1\n", "meta": {"author": "JLimperg", "repo": "lean4-aesop", "sha": "5c4b9a3e05c32f69a4357c3047c274f4b94f9c71", "save_path": "github-repos/lean/JLimperg-lean4-aesop", "path": "github-repos/lean/JLimperg-lean4-aesop/lean4-aesop-5c4b9a3e05c32f69a4357c3047c274f4b94f9c71/tests/playground/matchEqs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5583269943353744, "lm_q2_score": 0.39606816627404173, "lm_q1q2_score": 0.221135548827709}}
{"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h\u03b1 : \u00ac is_rat \u03b1) : \u2200 y \u2208 Icc 0 1, \u2203 x \u2208 Icc 0 1, x \u2260 y \u2227 x \u2208 {n : \u2124 // n * \u03b1} :=\nbegin\n  assume y h,\n  have h1 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from by {\n    assume i j h2,\n    assume h3,\n    have h4 : i * \u03b1 - (i * \u03b1).floor = {i * \u03b1}, from by {\n      rw \u2190 h3,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw \u2190 floor_eq_of_mem_Icc,\n      rw\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h\u03b1 : \u00ac is_rat \u03b1) : \n\u2200 y \u2208 Icc 0 1, \u2203 x \u2208 set.range (\u03bb n : \u2124, n \u2022 \u03b1 % 1), abs (x - y) < 1 :=\nbegin\n  assume y h1,\n  have h2 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1 % 1) \u2260 (j \u2022 \u03b1 % 1), from\n    assume i j h2,\n    have h3 : i \u2022 \u03b1 - (i \u2022 \u03b1 % 1) = (i \u2022 \u03b1 % 1), from by {rw \u2190 sub_eq_add_neg, rw \u2190 floor_add, rw floor_eq_self, rw add_comm, rw add_neg_self, rw zero_add,},\n    have h4 : j \u2022 \u03b1 - (j \u2022 \u03b1 % 1) = (j \u2022 \u03b1 % 1), from by {rw \u2190 sub_eq_add_neg, rw \u2190 floor_add, rw floor_eq_self, rw add_comm, rw add_neg_self, rw zero_add,},\n    have h5 : i \u2022 \u03b1 = j \u2022 \u03b1, from by {rw [h3,h4], rw sub_eq_zero, rw h2,},\n    have h6 : \u03b1 = (j - i)\u207b\u00b9 \u2022 (j \u2022 \u03b1 - i \u2022 \u03b1), 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h\u03b1 : \u00ac is_rat \u03b1) : \u2200 y \u2208 Icc 0 1, \u2203 x \u2208 Icc 0 1, x \u2260 y :=\nbegin\n  assume y h,\n  have h1 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n    have h2 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n      have h3 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n        have h4 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n          have h5 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n            have h6 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n              have h7 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                have h8 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                  have h9 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                    have h10 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                      have h11 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                        have h12 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                          have h13 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                            have h14 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                              have h15 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                have h16 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                  have h17 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                    have h18 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                      have h19 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                        have h20 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                          have h21 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                            have h22 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                              have h23 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                have h24 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                  have h25 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                    have h26 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                      have h27 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                        have h28 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                          have h29 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                            have h30 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                              have h31 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                have h32 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                  have h33 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                    have h34 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                      have h35 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                        have h36 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                          have h37 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                            have h38 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                              have h39 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                have h40 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                  have h41 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                    have h42 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                      have h43 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                        have h44 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                          have h45 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                            have h46 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                              have h47 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                have h48 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                  have h49 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                    have h50 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                      have h51 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                        have h52 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                          have h53 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                            have h54 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                              have h55 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                have h56 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                  have h57 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                    have h58 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                      have h59 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                        have h60 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                          have h61 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                            have h62 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                              have h63 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                                have h64 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                                  have h65 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                                    have h66 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                                      have h67 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                                        have h68 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                                          have h69 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                                            have h70 : \u2203 x \u2208 Icc 0 1, x \u2260 y, from by {\n                                                                                                                                              have h71 : \u2203 x \u2208 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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 : \u2115 \u2192 \u211d) (l : \u211d) : \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in\n seq_limit y l \u2192 seq_limit z l \u2192  (\u2200 n : \u2115, (y n) \u2264 (x n) \u2227 (x n) \u2264 (z n)) \u2192 seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : \u2200 (n : \u2115), y n \u2264 x n \u2227 x n \u2264 z n) (\u03b5), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : \u2200 x, |x - l| < \u03b5 \u2194 (((l - \u03b5) < x) \u2227 (x < (l + \u03b5))), \n  from by \n  {\n    intro x0,\n    have h6 : |x0 - l| < \u03b5 \u2194 ((x0 - l) < \u03b5) \u2227 ((l - x0) < \u03b5), \n    from abs_sub_lt_iff, rw h6,\n    split, \n    rintro \u27e8 S_1, S_2 \u27e9, \n    split; linarith, \n    rintro \u27e8 S_3, S_4 \u27e9, \n    split; linarith,\n    },\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : \u03b5 > 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 \u03b5 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 \u03b5 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 : \u2200 n > N, n > N1 \u2227 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 : \u2200 n > N, (((l - \u03b5) < (y n)) \u2227 ((y n) \u2264 (x n))) \u2227 (((x n) \u2264 (z n)) \u2227 ((z n) < l+\u03b5)), \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 : \u2200 n > N, ((l - \u03b5) < (x n)) \u2227 ((x n) < (l+\u03b5)), \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  \u2200 (n : \u2115), n > N \u2192 |x n - l| < \u03b5, \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\u1d52\u1d56 \u2964 Type (max v u)) \u2964 SheafOfTypes J :=\n{ obj := \u03bb P,\n  { val := J.sheafify P,\n    cond := begin\n      rw \u2190 is_sheaf_iff_is_sheaf_of_type,\n      exact grothendieck_topology.plus.is_sheaf_plus_plus J P,\n    end },\n  map := \u03bb P Q \u03b7, \u27e8J.sheafify_map \u03b7\u27e9,\n  map_id' := \u03bb P, SheafOfTypes.hom.ext _ _ $ J.sheafify_map_id _,\n  map_comp' := \u03bb P Q R \u03b7 \u03b3, SheafOfTypes.hom.ext _ _ $ J.sheafify_map_comp _ _ }\n\n-- Sanity check\ndef presheaf_to_SheafOfTypes_iso : presheaf_to_SheafOfTypes J \u2245\n  presheaf_to_Sheaf J _ \u22d9 (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) \u22a3 SheafOfTypes_to_presheaf J :=\nshow presheaf_to_Sheaf J _ \u22d9 (Sheaf_equiv_SheafOfTypes J).functor \u22a3\n  (Sheaf_equiv_SheafOfTypes J).inverse \u22d9 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\u1d52\u1d56 \u2964 Type (max v u))\n  (Y : SheafOfTypes J) (e : (presheaf_to_SheafOfTypes _).obj X \u27f6 Y) :\n  (sheafification_adjunction_types J).hom_equiv _ _ e =\n  J.to_sheafify _ \u226b e.val := rfl\n\n@[simp]\nlemma sheafification_adjunction_types_hom_equiv_symm_apply (X : C\u1d52\u1d56 \u2964 Type (max v u))\n  (Y : SheafOfTypes J) (e : X \u27f6 (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\u1d52\u1d56 \u2964 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 (\ud835\udfd9 _) (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 {\u210d : Type} {\u03c9 : 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 (\u210d : Type) (\u03c9 : context) (\u0393 : context) : kind \u2192 Type\n| species (A : species \u210d \u03c9 \u0393) : production kind.species\n| concretion {b y} (F : concretion \u210d \u03c9 \u0393 b y) : production kind.concretion\n\ninstance production.has_repr [has_repr \u210d] {\u0393 k} : has_repr (production \u210d \u03c9 \u0393 k) :=\n  \u27e8 \u03bb x, by from production.rec_on x repr (\u03bb _ _ x, repr x), \u27e9\n\n/-- Rename a production. This just wraps renaming for species and concretions. -/\ndef production.rename\n  {\u0393 \u0394} (\u03c1 : name \u0393 \u2192 name \u0394)\n  : \u2200 {k}, production \u210d \u03c9 \u0393 k \u2192 production \u210d \u03c9 \u0394 k\n| ._ (production.species A) := production.species (species.rename \u03c1 A)\n| ._ (production.concretion A) := production.concretion (concretion.rename \u03c1 A)\n\nlemma production.rename_compose {\u0393 \u0394 \u03b7} (\u03c1 : name \u0393 \u2192 name \u0394) (\u03c3 : name \u0394 \u2192 name \u03b7)\n  : \u2200 {k} (E : production \u210d \u03c9 \u0393 k)\n  , production.rename \u03c3 (production.rename \u03c1 E)\n  = production.rename (\u03c3 \u2218 \u03c1) E\n| ._ (production.species A) := congr_arg _ (species.rename_compose \u03c1 \u03c3 A)\n| ._ (production.concretion F) := congr_arg _ (concretion.rename_compose \u03c1 \u03c3 F)\n\nlemma production.rename_id\n  {\u0393} : \u2200 {k} (E : production \u210d \u03c9 \u0393 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 [\u2200 \u0393, setoid (species \u210d \u03c9 \u0393)] [\u2200 \u0393 b y, setoid (concretion \u210d \u03c9 \u0393 b y)] {\u0393} :\n  \u2200 {k : kind}, production \u210d \u03c9 \u0393 k \u2192 production \u210d \u03c9 \u0393 k \u2192 Prop\n| species {A B : species \u210d \u03c9 \u0393}\n  : A \u2248 B \u2192 production.equiv (production.species A) (production.species B)\n| concretion {b y} {F G : concretion \u210d \u03c9 \u0393 b y}\n  : F \u2248 G \u2192 production.equiv (production.concretion F) (production.concretion G)\n\nnamespace production\n  variables [\u2200 \u0393, setoid (cpi.species \u210d \u03c9 \u0393)] [\u2200 \u0393 b y, setoid (cpi.concretion \u210d \u03c9 \u0393 b y)]\n\n  lemma equiv.refl {\u0393} : \u2200 {k : kind} (E : production \u210d \u03c9 \u0393 k), equiv E E\n  | ._ (species A) := equiv.species (refl A)\n  | ._ (concretion F) := equiv.concretion (refl F)\n\n  lemma equiv.symm {\u0393} : \u2200 {k : kind} (E F : production \u210d \u03c9 \u0393 k), equiv E F \u2192 equiv F E\n  | ._ ._ ._ (equiv.species eq) := equiv.species (symm eq)\n  | ._ ._ ._ (equiv.concretion eq) := equiv.concretion (symm eq)\n\n  lemma equiv.trans {\u0393} : \u2200 {k : kind} (E F G : production \u210d \u03c9 \u0393 k), equiv E F \u2192 equiv F G \u2192 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 {\u0393} {k} : is_equiv (production \u210d \u03c9 \u0393 k) equiv :=\n    { refl := equiv.refl, symm := equiv.symm, trans := equiv.trans }\n  instance {\u0393} {k} : is_refl (production \u210d \u03c9 \u0393 k) equiv := \u27e8 equiv.refl \u27e9\n  instance {\u0393} {k} : setoid (production \u210d \u03c9 \u0393 k) :=\n    \u27e8 equiv, \u27e8 equiv.refl, equiv.symm, equiv.trans \u27e9 \u27e9\n  instance setoid.is_equiv {\u0393} {k} : is_equiv (production \u210d \u03c9 \u0393 k) has_equiv.equiv :=\n    production.is_equiv\nend production\n\nsection equivalence\nvariables [\u2200 \u0393, setoid (cpi.species \u210d \u03c9 \u0393)] [\u2200 \u0393 b y, setoid (cpi.concretion \u210d \u03c9 \u0393 b y)]\n\nlemma production.equiv.unwrap_s :\n  \u2200 {\u0393} {A B : species \u210d \u03c9 \u0393}, production.species A \u2248 production.species B \u2192 A \u2248 B\n| \u0393 A B (production.equiv.species eq) := eq\n\nlemma production.equiv.arity :\n  \u2200 {\u0393} {a b x y} {F : concretion \u210d \u03c9 \u0393 a x} {G : concretion \u210d \u03c9 \u0393 b y}\n  , production.concretion F \u2248 production.concretion G\n  \u2192 a = b \u2227 x = y\n| \u0393 a b x y F G (production.equiv.concretion eq) := \u27e8 rfl, rfl \u27e9\n\nlemma production.equiv.unwrap_c :\n  \u2200 {\u0393} {b y} {F : concretion \u210d \u03c9 \u0393 b y} {G : concretion \u210d \u03c9 \u0393 b y}\n  , production.concretion F \u2248 production.concretion G\n  \u2192 F \u2248 G\n| \u0393 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.\u03b9_comp_mono {C : Type u} [category.{v} C] [abelian C] {X Y Z W : C}\n  (g : Y \u27f6 Z) (h : Z \u27f6 W) (f : X \u27f6 kernel g) (i : kernel g \u27f6 Y) (hf : epi f) (hh : mono h)\n  (hi : i = kernel.\u03b9 g) : exact (f \u226b i) (g \u226b 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_\u03b9\nend\n\n-- move this\nlemma biprod_factors (A B : C) [projective A] [projective B]\n  (E X : C) (f : A \u229e B \u27f6 X) (e : E \u27f6 X) [epi e] :\n  \u2203 f' : A \u229e B \u27f6 E, f' \u226b e = f :=\n\u27e8biprod.desc\n  (projective.factor_thru (biprod.inl \u226b f) e)\n  (projective.factor_thru (biprod.inr \u226b f) e),\n  by ext; simp only [projective.factor_thru_comp, biprod.inl_desc_assoc, biprod.inr_desc_assoc]\u27e9\n\nvariables (A B : short_exact_sequence C) (f : A \u27f6 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_\u03c0 : horseshoe_base A \u27f6 A :=\n{ fst := projective.\u03c0 _,\n  snd := biprod.desc (projective.\u03c0 _ \u226b A.f) (projective.factor_thru (projective.\u03c0 _) A.g),\n  trd := projective.\u03c0 _,\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_\u03c0_1 : epi (horseshoe_base_\u03c0 A).1 :=\nshow epi (projective.\u03c0 _), by apply_instance\n\ninstance epi_horseshoe_base_\u03c0_3 : epi (horseshoe_base_\u03c0 A).3 :=\nshow epi (projective.\u03c0 _), by apply_instance\n\nlocal attribute [instance] limits.has_zero_object.has_zero\n\ninstance epi_horseshoe_base_\u03c0_2 : epi (horseshoe_base_\u03c0 A).2 :=\nbegin\n  let \u03c6 := horseshoe_base_\u03c0 A,\n  have h : \u03c6.3 \u226b (0 : A.3 \u27f6 0) = (0 : _ \u27f6 0) \u226b (0 : 0 \u27f6 0) := by simp,\n  refine category_theory.abelian.epi_of_epi_of_epi_of_mono \u03c6.sq1' \u03c6.sq2' h _ _ _ _ _ _;\n  try { rw \u2190 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_\u03b9 [epi f.1] : horseshoe_ker f \u27f6 A :=\n{ fst := kernel.\u03b9 _,\n  snd := kernel.\u03b9 _,\n  trd := kernel.\u03b9 _,\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_\u03b9],\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_\u03b9],\n  end }\n.\n\nlemma horseshoe_ker_\u03b9_fst [epi f.1] : (horseshoe_ker_\u03b9 f).1 = kernel.\u03b9 f.1 := rfl\n\nlemma horseshoe_ker_\u03b9_snd [epi f.1] : (horseshoe_ker_\u03b9 f).2 = kernel.\u03b9 f.2 := rfl\n\nlemma horseshoe_ker_\u03b9_trd [epi f.1] : (horseshoe_ker_\u03b9 f).3 = kernel.\u03b9 f.3 := rfl\n\nvariables (A)\n\nlemma horseshoe_ker_\u03b9_comp_base_\u03c0 :\n  (horseshoe_ker_\u03b9 (horseshoe_base_\u03c0 A)) \u226b horseshoe_base_\u03c0 A = 0 :=\nbegin\n  dsimp [horseshoe_ker_\u03b9, horseshoe_base_\u03c0],\n  ext1; show kernel.\u03b9 _ \u226b _ = 0; exact exact.w exact_kernel_\u03b9,\nend\n\nnoncomputable\ndef horseshoe_step (A : short_exact_sequence C) :\n  \u2115 \u2192 \u03a3 (X Y Z : short_exact_sequence C) (\u03b9 : X \u27f6 Y), Y \u27f6 Z\n| 0     := \u27e8horseshoe_ker (horseshoe_base_\u03c0 A), _, _, horseshoe_ker_\u03b9 _, horseshoe_base_\u03c0 _\u27e9\n| (n+1) :=\n\u27e8horseshoe_ker (horseshoe_base_\u03c0 (horseshoe_step n).1), _, _, horseshoe_ker_\u03b9 _, horseshoe_base_\u03c0 _\u27e9\n\n@[reassoc] lemma horseshoe_step_comp_eq_zero :\n  \u2200 n, (horseshoe_step A n).2.2.2.1 \u226b (horseshoe_step A n).2.2.2.2 = 0\n| 0     := horseshoe_ker_\u03b9_comp_base_\u03c0 _\n| (n+1) := horseshoe_ker_\u03b9_comp_base_\u03c0 _\n\nlemma step_fst_mono (n : \u2115) : mono (horseshoe_step A n).2.2.2.1.1 :=\nbegin\n  cases n,\n  { dsimp [horseshoe_step, horseshoe_ker_\u03b9],\n    apply_instance },\n  { dsimp [horseshoe_step],\n    cases n, --Why do I have to do this again?!\n    { rw [horseshoe_ker_\u03b9_fst],\n      apply_instance },\n    { rw [horseshoe_ker_\u03b9_fst],\n      apply_instance }  }\nend\n\nlemma step_snd_mono (n : \u2115) : mono (horseshoe_step A n).2.2.2.1.2 :=\nbegin\n  cases n,\n  { dsimp [horseshoe_step, horseshoe_ker_\u03b9],\n    apply_instance },\n  { dsimp [horseshoe_step],\n    cases n, --Why do I have to do this again?!\n    { rw [horseshoe_ker_\u03b9_snd],\n      apply_instance },\n    { rw [horseshoe_ker_\u03b9_snd],\n      apply_instance }  }\nend\n\nlemma step_trd_mono (n : \u2115) : mono (horseshoe_step A n).2.2.2.1.3 :=\nbegin\n  cases n,\n  { dsimp [horseshoe_step, horseshoe_ker_\u03b9],\n    apply_instance },\n  { dsimp [horseshoe_step],\n    cases n, --Why do I have to do this again?!\n    { rw [horseshoe_ker_\u03b9_trd],\n      apply_instance },\n    { rw [horseshoe_ker_\u03b9_trd],\n      apply_instance }  }\nend\n\ndef horseshoe_obj (n : \u2115) := (horseshoe_step A n).2.1\n\ndef horseshoe_d (n : \u2115) : horseshoe_obj A (n+1) \u27f6 horseshoe_obj A n :=\n(horseshoe_step A (n+1)).2.2.2.2 \u226b eq_to_hom (by { dsimp [horseshoe_step], refl })\n  \u226b (horseshoe_step A n).2.2.2.1\n\nlemma horseshoe_d_d (n : \u2115) : horseshoe_d A (n+1) \u226b horseshoe_d A n = 0 :=\nbegin\n  dsimp [horseshoe_d, horseshoe_ker_\u03b9],\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) \u2115 :=\nchain_complex.of (horseshoe_obj A) (horseshoe_d A) (horseshoe_d_d A)\n\nvariables (A)\n\ndef horseshoe_\u03c0 : (horseshoe A).X 0 \u27f6 A := horseshoe_base_\u03c0 _\n\nlemma horseshoe_d_\u03c0 : (horseshoe A).d 1 0 \u226b horseshoe_\u03c0 A = 0 :=\nbegin\n  dsimp [horseshoe],\n  erw [chain_complex.of_d],\n  dsimp [horseshoe_d, horseshoe_\u03c0, horseshoe_step],\n  simp only [category.id_comp, category.assoc, comp_zero, zero_comp,\n    horseshoe_step_comp_eq_zero_assoc, horseshoe_ker_\u03b9_comp_base_\u03c0],\nend\n\ndef horseshoe_to_single\u2081 :=\n(chain_complex.to_single\u2080_equiv ((homological_complex.Fst C).obj (horseshoe A)) A.1).symm\n\u27e8(short_exact_sequence.Fst C).map (horseshoe_\u03c0 A),\nbegin\n  have := horseshoe_d_\u03c0 A, apply_fun (\u03bb f, (short_exact_sequence.Fst C).map f) at this,\n  rwa [functor.map_comp, functor.map_zero] at this,\nend\u27e9\n\ndef horseshoe_to_single\u2082 :=\n(chain_complex.to_single\u2080_equiv ((homological_complex.Snd C).obj (horseshoe A)) A.2).symm\n\u27e8(short_exact_sequence.Snd C).map (horseshoe_\u03c0 A),\nbegin\n  have := horseshoe_d_\u03c0 A, apply_fun (\u03bb f, (short_exact_sequence.Snd C).map f) at this,\n  rwa [functor.map_comp, functor.map_zero] at this,\nend\u27e9\n\ndef horseshoe_to_single\u2083 :=\n(chain_complex.to_single\u2080_equiv ((homological_complex.Trd C).obj (horseshoe A)) A.3).symm\n\u27e8(short_exact_sequence.Trd C).map (horseshoe_\u03c0 A),\nbegin\n  have := horseshoe_d_\u03c0 A, apply_fun (\u03bb f, (short_exact_sequence.Trd C).map f) at this,\n  rwa [functor.map_comp, functor.map_zero] at this,\nend\u27e9\n\nlemma horseshoe_exact\u2081 (A : short_exact_sequence C) (n : \u2115) :\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\u2081],\n  erw [chain_complex.of_d, chain_complex.of_d],\n  dsimp [horseshoe_d, horseshoe_step],\n\n  set f := horseshoe_base_\u03c0 (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.\u03b9_comp_mono f.1 _ (horseshoe_base_\u03c0 (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\u2082 (A : short_exact_sequence C) (n : \u2115) :\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\u2082],\n  erw [chain_complex.of_d, chain_complex.of_d],\n  dsimp [horseshoe_d, horseshoe_step],\n\n  set f := horseshoe_base_\u03c0 (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.\u03b9_comp_mono f.2 _ (horseshoe_base_\u03c0 (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\u2083 (A : short_exact_sequence C) (n : \u2115) :\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\u2083],\n  erw [chain_complex.of_d, chain_complex.of_d],\n  dsimp [horseshoe_d, horseshoe_step],\n\n  set f := horseshoe_base_\u03c0 (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.\u03b9_comp_mono f.3 _ (horseshoe_base_\u03c0 (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\u2081 (A : short_exact_sequence C) :\n  chain_complex.is_projective_resolution\n    ((homological_complex.Fst C).obj (horseshoe A)) A.1 (horseshoe_to_single\u2081 A) :=\n{ projective := by rintro (_|n); { show projective (projective.over _), apply_instance },\n  exact\u2080 :=\n  begin\n    dsimp [horseshoe_to_single\u2081, chain_complex.to_single\u2080_equiv, horseshoe_\u03c0],\n    erw [chain_complex.of_d],\n    dsimp [horseshoe_d, horseshoe_step],\n    rw [category.id_comp, \u2190 short_exact_sequence.comp_fst],\n    refine abelian.pseudoelement.exact_of_pseudo_exact _ _ \u27e8\u03bb a , _, \u03bb a ha, _\u27e9,\n    { rw [\u2190 abelian.pseudoelement.comp_apply, \u2190 short_exact_sequence.comp_fst, category.assoc,\n        horseshoe_ker_\u03b9_comp_base_\u03c0, comp_zero, short_exact_sequence.hom_zero_fst,\n        abelian.pseudoelement.zero_apply] },\n    { obtain \u27e8b, hb\u27e9 := is_snake_input.exists_of_exact exact_kernel_\u03b9 _ ha,\n      obtain \u27e8c, hc\u27e9 := abelian.pseudoelement.pseudo_surjective_of_epi\n        (horseshoe_base_\u03c0 (horseshoe_ker _)).1 b,\n      refine \u27e8c, _\u27e9,\n      rw [short_exact_sequence.comp_fst, abelian.pseudoelement.comp_apply, hc, \u2190 hb],\n      refl }\n  end,\n  exact := \u03bb n, horseshoe_exact\u2081 A n,\n  epi := show epi (projective.\u03c0 _), from infer_instance }\n\nlemma horseshoe_is_projective_resolution\u2082 (A : short_exact_sequence C) :\n  chain_complex.is_projective_resolution\n    ((homological_complex.Snd C).obj (horseshoe A)) A.2 (horseshoe_to_single\u2082 A) :=\n{ projective := by rintro (_|n); { show projective (projective.over _ \u229e projective.over _),\n    apply_instance },\n  exact\u2080 :=\n  begin\n    dsimp [horseshoe_to_single\u2082, chain_complex.to_single\u2080_equiv, horseshoe_\u03c0],\n    erw [chain_complex.of_d],\n    dsimp [horseshoe_d, horseshoe_step],\n    rw [category.id_comp, \u2190 short_exact_sequence.comp_snd],\n    refine abelian.pseudoelement.exact_of_pseudo_exact _ _ \u27e8\u03bb a , _, \u03bb a ha, _\u27e9,\n    { rw [\u2190 abelian.pseudoelement.comp_apply, \u2190 short_exact_sequence.comp_snd, category.assoc,\n        horseshoe_ker_\u03b9_comp_base_\u03c0, comp_zero, short_exact_sequence.hom_zero_snd,\n        abelian.pseudoelement.zero_apply] },\n    { obtain \u27e8b, hb\u27e9 := is_snake_input.exists_of_exact exact_kernel_\u03b9 _ ha,\n      obtain \u27e8c, hc\u27e9 := abelian.pseudoelement.pseudo_surjective_of_epi\n        (horseshoe_base_\u03c0 (horseshoe_ker _)).2 b,\n      refine \u27e8c, _\u27e9,\n      rw [short_exact_sequence.comp_snd, abelian.pseudoelement.comp_apply, hc, \u2190 hb],\n      refl }\n  end,\n  exact := \u03bb n, horseshoe_exact\u2082 A n,\n  epi := show epi (horseshoe_base_\u03c0 _).2, from infer_instance }\n\nlemma horseshoe_is_projective_resolution\u2083 (A : short_exact_sequence C) :\n  chain_complex.is_projective_resolution\n    ((homological_complex.Trd C).obj (horseshoe A)) A.3 (horseshoe_to_single\u2083 A) :=\n{ projective := by rintro (_|n); { show projective (projective.over _), apply_instance },\n  exact\u2080 :=\n  begin\n    dsimp [horseshoe_to_single\u2083, chain_complex.to_single\u2080_equiv, horseshoe_\u03c0],\n    erw [chain_complex.of_d],\n    dsimp [horseshoe_d, horseshoe_step],\n    rw [category.id_comp, \u2190 short_exact_sequence.comp_trd],\n    refine abelian.pseudoelement.exact_of_pseudo_exact _ _ \u27e8\u03bb a , _, \u03bb a ha, _\u27e9,\n    { rw [\u2190 abelian.pseudoelement.comp_apply, \u2190 short_exact_sequence.comp_trd, category.assoc,\n        horseshoe_ker_\u03b9_comp_base_\u03c0, comp_zero, short_exact_sequence.hom_zero_trd,\n        abelian.pseudoelement.zero_apply] },\n    { obtain \u27e8b, hb\u27e9 := is_snake_input.exists_of_exact exact_kernel_\u03b9 _ ha,\n      obtain \u27e8c, hc\u27e9 := abelian.pseudoelement.pseudo_surjective_of_epi\n        (horseshoe_base_\u03c0 (horseshoe_ker _)).3 b,\n      refine \u27e8c, _\u27e9,\n      rw [short_exact_sequence.comp_trd, abelian.pseudoelement.comp_apply, hc, \u2190 hb],\n      refl }\n  end,\n  exact := \u03bb n, horseshoe_exact\u2083 A n,\n  epi := show epi (projective.\u03c0 _), from infer_instance }\n.\n\nlemma horseshoe_split (A : short_exact_sequence C) (n : \u2115) :\n  ((horseshoe A).X n).split :=\nbegin\n  cases n;\n  exact \u27e8biprod.fst, biprod.inr, biprod.inl_fst, biprod.inr_snd, biprod.inr_fst, biprod.total\u27e9\nend\n\nlemma horseshoe_f_comp_to_single\u2082_f (A : short_exact_sequence C) (i : \u2115) :\n  ((horseshoe A).X i).f \u226b (horseshoe_to_single\u2082 A).f i =\n  (horseshoe_to_single\u2081 A).f i \u226b ((chain_complex.single\u2080 C).map A.f).f i :=\nbegin\n  cases i,\n  { dsimp [horseshoe_to_single\u2082, horseshoe_to_single\u2081, horseshoe, horseshoe_obj, horseshoe_step,\n      horseshoe_base, horseshoe_\u03c0, horseshoe_base_\u03c0, chain_complex.to_single\u2080_equiv],\n    simp },\n  { dsimp [horseshoe_to_single\u2082, horseshoe_to_single\u2081, horseshoe, horseshoe_obj, horseshoe_step,\n      horseshoe_base, horseshoe_\u03c0, horseshoe_base_\u03c0, chain_complex.to_single\u2080_equiv],\n    simp }\nend\n\nlemma horseshoe_g_comp_to_single\u2083_f (A : short_exact_sequence C) (i : \u2115) :\n  ((horseshoe A).X i).g \u226b (horseshoe_to_single\u2083 A).f i =\n  (horseshoe_to_single\u2082 A).f i \u226b ((chain_complex.single\u2080 C).map A.g).f i :=\nbegin\n  cases i,\n  { dsimp [horseshoe_to_single\u2082, horseshoe_to_single\u2083, chain_complex.to_single\u2080_equiv, horseshoe,\n      horseshoe_obj, horseshoe_\u03c0, horseshoe_step, horseshoe_base, horseshoe_base_\u03c0],\n    ext,\n    { simp },\n    { simp  } },\n  { dsimp [horseshoe_to_single\u2082, horseshoe_to_single\u2083, horseshoe, horseshoe_obj, horseshoe_step,\n      horseshoe_base, horseshoe_\u03c0, horseshoe_base_\u03c0, chain_complex.to_single\u2080_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  \u2200 (\u03b1 : Type) (r : \u03b1 \u2192 \u03b1 \u2192 Prop), symmetric r \u2192 transitive r \u2192 reflexive r\n\ndef fail (a b : unit): Prop := false\ntheorem fail_symm : symmetric fail := \u03bb x y h, h\ntheorem fail_trans : transitive fail := \u03bb x y z h1 _, false.rec (fail x z) h1\n-- theorem not_refl_fail : \u00ac reflexive fail := \u03bb a, a ()\n\ntheorem correct_version : \u00ac bad_theorem := \u03bb 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 : \u2124) :\n  (n<a \u2228 a<n) \u2228 n = a :=\nbegin\n  by_cases h\u2081 : n < a,\n  { exact or.inl (or.inl h\u2081), },\n  { cases (not_lt.1 h\u2081).lt_or_eq; tauto, },\nend\n\nlemma category_theory.nat_iso.map_eq_iff {C D : Type*} [category C] [category D] {F G : C \u2964 D}\n  (e : F \u2245 G) {X Y : C} (f\u2081 f\u2082 : X \u27f6 Y) : F.map f\u2081 = F.map f\u2082 \u2194 G.map f\u2081 = G.map f\u2082 :=\nbegin\n  suffices : \u2200 \u2983F G : C \u2964 D\u2984 (e : F \u2245 G) \u2983X Y : C\u2984 (f\u2081 f\u2082 : X \u27f6 Y)\n    (h : F.map f\u2081 = F.map f\u2082), G.map f\u2081 = G.map f\u2082,\n  { exact \u27e8this e f\u2081 f\u2082, this e.symm f\u2081 f\u2082\u27e9, },\n  intros F G e X Y f\u2081 f\u2082 eq,\n  have : \u2200 (f : X \u27f6 Y), G.map f = e.inv.app X \u226b F.map f \u226b e.hom.app Y := \u03bb f, by tidy,\n  simp only [this, eq],\nend\n\nopen category_theory category_theory.limits category_theory.category\n\nvariables {C : Type*} [category C] [abelian C]\n\nnamespace homological_complex\n\nlemma single_obj_X_self_naturality {\u03b9 : Type*} (c : complex_shape \u03b9) (n : \u03b9)\n  [decidable_eq \u03b9] {A B : C} (\u03c6 : A \u27f6 B) :\n    ((single C c n).map \u03c6).f n \u226b (single_obj_X_self C c n B).hom =\n      (single_obj_X_self C c n A).hom \u226b \u03c6 :=\nbegin\n  dsimp [single],\n  simpa only [dif_pos rfl, assoc, eq_to_hom_trans, eq_to_hom_refl, comp_id],\nend\n\nvariable (C)\n\ndef single_homology_functor_iso {\u03b9 : Type*} (c : complex_shape \u03b9) (n : \u03b9)\n  [decidable_eq \u03b9] :\n  homological_complex.single C c n \u22d9 homology_functor C c n \u2245 \ud835\udfed C :=\nnat_iso.of_components\n  (\u03bb A, homology_single_self C c A n)\n  (\u03bb A B \u03c6, begin\n    let h\u2081 := short_complex.homology_data.of_zeros (((single C c n).obj A).sc' n) rfl rfl,\n    let h\u2082 := short_complex.homology_data.of_zeros (((single C c n).obj B).sc' n) rfl rfl,\n    let h : short_complex.homology_map_data ((short_complex_functor _ _ n).map\n      ((single C c n).map \u03c6)) h\u2081 h\u2082 := short_complex.homology_map_data.of_zeros _ rfl rfl rfl rfl,\n    have eq := short_complex.homology_map_data.homology_map_comm h,\n    dsimp only [homology_single_self, iso.trans],\n    simp only [assoc],\n    erw [\u2190 single_obj_X_self_naturality c n \u03c6, reassoc_of eq],\n    refl,\n  end)\n\nend homological_complex\n\nvariable {C}\n\nnamespace cochain_complex\n\ninstance is_strictly_le_trunc_ge (K : cochain_complex C \u2124) (p q : \u2124) [K.is_strictly_le q] :\n  (K.trunc_ge p).is_strictly_le q :=\n\u27e8\u03bb i hi, begin\n  rw [is_zero.iff_id_eq_zero, \u2190 cancel_epi (trunc_ge.\u03c0_f K p i)],\n  apply (is_strictly_le.is_zero K q i hi).eq_of_src,\nend\u27e9\n\ninstance is_strictly_ge_trunc_le (K : cochain_complex C \u2124) (p q : \u2124) [K.is_strictly_ge p] :\n  (K.trunc_le q).is_strictly_ge p :=\n\u27e8\u03bb i hi, begin\n  rw [is_zero.iff_id_eq_zero, \u2190 cancel_mono (trunc_le.\u03b9_f K q i)],\n  apply (is_strictly_ge.is_zero K p i hi).eq_of_tgt,\nend\u27e9\n\nlemma is_le_iff_of_is_le_next (K : cochain_complex C \u2124) {a b : \u2124} (h : a+1=b)\n  [K.is_le b] : K.is_le a \u2194 is_zero (K.homology b) :=\nbegin\n  split,\n  { introI,\n    exact is_le.is_zero K a b (by linarith), },\n  { refine \u03bb hb, \u27e8\u03bb n hn, _\u27e9,\n    unfreezingI { subst h, },\n    rw \u2190 int.add_one_le_iff at hn,\n    cases hn.lt_or_eq,\n    { exact is_le.is_zero K (a+1) n h, },\n    { subst h,\n      exact hb, }, },\nend\n\nlemma is_ge_iff_of_is_ge_prev (K : cochain_complex C \u2124) {a b : \u2124} (h : a+1=b)\n  [K.is_ge a] : K.is_ge b \u2194 is_zero (K.homology a) :=\nbegin\n  split,\n  { introI,\n    exact is_ge.is_zero K b a (by linarith), },\n  { refine \u03bb ha, \u27e8\u03bb n hn, _\u27e9,\n    subst h,\n    rw [\u2190 int.add_one_le_iff, add_le_add_iff_right] at hn,\n    cases hn.lt_or_eq,\n    { exact is_ge.is_zero K a n h, },\n    { unfreezingI { subst h, },\n      exact ha, }, },\nend\n\nlemma shift_is_strict_le (K : cochain_complex C \u2124) (a b c : \u2124) (h : a = c + b)\n  [K.is_strictly_le a] : (K\u27e6b\u27e7).is_strictly_le c :=\n\u27e8\u03bb n hn, begin\n  change is_zero (K.X (n+b)),\n  exact is_strictly_le.is_zero K a (n+b) (by linarith),\nend\u27e9\n\nlemma shift_is_strict_ge (K : cochain_complex C \u2124) (a b c : \u2124) (h : a = c + b)\n  [K.is_strictly_ge a] : (K\u27e6b\u27e7).is_strictly_ge c :=\n\u27e8\u03bb n hn, begin\n  change is_zero (K.X (n+b)),\n  exact is_strictly_ge.is_zero K a (n+b) (by linarith),\nend\u27e9\n\nend cochain_complex\n\nnamespace derived_category\n\nlemma orthogonality {K L : derived_category C} (\u03c6 : K \u27f6 L) (p q : \u2124) (hpq : p < q)\n  [K.is_le p] [L.is_ge q] : \u03c6 = 0 :=\nbegin\n  obtain \u27e8K', hK', \u27e8eK\u27e9\u27e9 := exists_iso_Q_obj_of_le K p,\n  obtain \u27e8L', hL', \u27e8eL\u27e9\u27e9 := exists_iso_Q_obj_of_ge L q,\n  haveI := hK',\n  have h\u03c6 : \u2203 (\u03c6' : Q.obj K' \u27f6 Q.obj L'), \u03c6 = eK.hom \u226b \u03c6' \u226b eL.inv :=\n    \u27e8eK.inv \u226b \u03c6 \u226b eL.hom, by simp only [assoc, iso.hom_inv_id, comp_id, iso.hom_inv_id_assoc]\u27e9,\n  obtain \u27e8\u03c6, rfl\u27e9 := h\u03c6,\n  obtain \u27e8M, hM, s, f, hs, eq\u27e9 := right_factorisation_of_is_le \u03c6 p,\n  haveI := hM,\n  have hf : f = 0,\n  { ext n,\n    by_cases p < n,\n    { apply (cochain_complex.is_strictly_le.is_zero M p n h).eq_of_src, },\n    { apply (cochain_complex.is_strictly_ge.is_zero L' q n (by linarith)).eq_of_tgt, }, },\n  simp only [eq, preadditive.is_iso.comp_left_eq_zero, preadditive.is_iso.comp_right_eq_zero, hf,\n    functor.map_zero],\nend\n\nlemma right_factorisation_of_is_strictly_le_of_is_strictly_ge {K L : cochain_complex C \u2124}\n  (\u03c6 : Q.obj K \u27f6 Q.obj L) (p q : \u2124) [K.is_strictly_le p]\n  [K.is_strictly_ge q] [L.is_strictly_ge q] :\n  \u2203 (K' : cochain_complex C \u2124) (K'_le : K'.is_strictly_le p)\n    (K'_ge : K'.is_strictly_ge q) (s : K' \u27f6 K) (f : K' \u27f6 L) (hs : quasi_iso s),\n    \u03c6 = (by { haveI := hs, exact inv (Q.map s), }) \u226b Q.map f :=\nbegin\n  obtain \u27e8K', hK', s, f, hs, eq\u27e9 := right_factorisation_of_is_strictly_ge \u03c6 q,\n  haveI := hK',\n  haveI : K'.is_le p,\n  { rw cochain_complex.is_le_iff_of_quasi_iso s,\n    apply_instance, },\n  exact \u27e8(cochain_complex.trunc_le K' p), infer_instance, infer_instance,\n    cochain_complex.trunc_le.\u03b9 K' p \u226b s, cochain_complex.trunc_le.\u03b9 K' p \u226b f, infer_instance,\n    by simp only [eq, functor.map_comp, assoc, is_iso.eq_inv_comp, is_iso.hom_inv_id_assoc]\u27e9,\nend\n\nlemma left_factorisation_of_is_strictly_le_of_is_strictly_ge {K L : cochain_complex C \u2124}\n  (\u03c6 : Q.obj K \u27f6 Q.obj L) (p q : \u2124) [K.is_strictly_le p] [L.is_strictly_le p]\n  [L.is_strictly_ge q] :\n  \u2203 (L' : cochain_complex C \u2124) (L'_le : L'.is_strictly_le p)\n    (L'_ge : L'.is_strictly_ge q) (f : K \u27f6 L') (s : L \u27f6 L') (hs : quasi_iso s),\n    \u03c6 = Q.map f \u226b (by { haveI := hs, exact inv (Q.map s), }) :=\nbegin\n  obtain \u27e8L', hL', f, s, hs, eq\u27e9 := left_factorisation_of_is_strictly_le \u03c6 p,\n  haveI := hL',\n  haveI : L'.is_ge q,\n  { rw \u2190 cochain_complex.is_ge_iff_of_quasi_iso s,\n    apply_instance, },\n  exact \u27e8(cochain_complex.trunc_ge L' q), infer_instance, infer_instance,\n    f \u226b cochain_complex.trunc_ge.\u03c0 L' q, s \u226b cochain_complex.trunc_ge.\u03c0 L' q, infer_instance,\n    by simp only [eq, functor.map_comp, is_iso.inv_comp, assoc, is_iso.hom_inv_id_assoc]\u27e9,\nend\n\nlemma shift_is_le (K : derived_category C) (a b c : \u2124) (h : a = c + b)\n  [K.is_le a] : (K\u27e6b\u27e7).is_le c :=\n\u27e8\u03bb n hn, is_zero.of_iso (is_le.is_zero _ a _ (by linarith))\n  ((derived_category.shift_homology_functor_iso C b n _ rfl).app K)\u27e9\n\nlemma shift_is_ge (K : derived_category C) (a b c : \u2124) (h : a = c + b)\n  [K.is_ge a] : (K\u27e6b\u27e7).is_ge c :=\n\u27e8\u03bb n hn, is_zero.of_iso (is_ge.is_zero _ a _ (by linarith))\n  ((derived_category.shift_homology_functor_iso C b n _ rfl).app K)\u27e9\n\nend derived_category\n\nnamespace cochain_complex\n\ninstance single_is_strictly_le (A : C) (n : \u2124) :\n  is_strictly_le ((homological_complex.single C (complex_shape.up \u2124) n).obj A) n :=\n\u27e8\u03bb i hi, begin\n  dsimp,\n  rw if_neg (show \u00ac i = n, by linarith),\n  exact is_zero_zero C,\nend\u27e9\n\ninstance single_is_strictly_ge (A : C) (n : \u2124) :\n  is_strictly_ge ((homological_complex.single C (complex_shape.up \u2124) n).obj A) n :=\n\u27e8\u03bb i hi, begin\n  dsimp,\n  rw if_neg (show \u00ac i = n, by linarith),\n  exact is_zero_zero C,\nend\u27e9\n\n\nlemma from_single_ext {K L : cochain_complex C \u2124} (f\u2081 f\u2082 : K \u27f6 L) (p : \u2124)\n  [K.is_strictly_le p] [K.is_strictly_ge p] (h : f\u2081.f p = f\u2082.f p) : f\u2081 = f\u2082 :=\nbegin\n  ext i,\n  by_cases hi : i < p,\n  { apply (is_strictly_ge.is_zero K p i hi).eq_of_src, },\n  { cases (not_lt.1 hi).lt_or_eq with hi' hi',\n    { apply (is_strictly_le.is_zero K p i hi').eq_of_src, },\n    { subst hi',\n      exact h, }, },\nend\n\nlemma to_single_ext {K L : cochain_complex C \u2124} (f\u2081 f\u2082 : K \u27f6 L) (p : \u2124)\n  [L.is_strictly_le p] [L.is_strictly_ge p] (h : f\u2081.f p = f\u2082.f p) : f\u2081 = f\u2082 :=\nbegin\n  ext i,\n  by_cases hi : i < p,\n  { apply (is_strictly_ge.is_zero L p i hi).eq_of_tgt, },\n  { cases (not_lt.1 hi).lt_or_eq with hi' hi',\n    { apply (is_strictly_le.is_zero L p i hi').eq_of_tgt, },\n    { subst hi',\n      exact h, }, },\nend\n\ndef desc_single (K L : cochain_complex C \u2124) {p : \u2124} (f : K.X p \u27f6 L.X p) (q : \u2124)\n  [K.is_strictly_le p] [K.is_strictly_ge p]\n  (hpq : p+1=q) (hf : f \u226b L.d p q = 0) : K \u27f6 L :=\n{ f := \u03bb i, begin\n    by_cases i = p,\n    { unfreezingI { subst h, }, exact f, },\n    { exact 0, },\n  end,\n  comm' := \u03bb i j (hij : i+1 = j), begin\n    by_cases i = p,\n    { have hj : j = q := by linarith,\n      unfreezingI { substs h hj, },\n      dsimp,\n      simp only [if_pos rfl, hf,\n        (is_strictly_le.is_zero K i j (by linarith)).eq_of_tgt (K.d i j) 0, zero_comp], },\n    { apply is_zero.eq_of_src,\n      by_cases hi : i < p,\n      { exact is_strictly_ge.is_zero K p i hi, },\n      { apply is_strictly_le.is_zero K p i,\n        cases (not_lt.1 hi).lt_or_eq with hi' hi',\n        { exact hi', },\n        { exfalso, exact h hi'.symm, }, }, },\n  end, }\n\n@[simp]\nlemma desc_single_f (K L : cochain_complex C \u2124) {p : \u2124} (f : K.X p \u27f6 L.X p) (q : \u2124)\n  [K.is_strictly_le p] [K.is_strictly_ge p]\n  (hpq : p+1=q) (hf : f \u226b L.d p q = 0) :\n  (desc_single K L f q hpq hf).f p = f :=\nbegin\n  dsimp [desc_single],\n  rw if_pos rfl,\nend\n\ndef lift_single (K L : cochain_complex C \u2124) {q : \u2124} (f : K.X q \u27f6 L.X q) (p : \u2124)\n  [L.is_strictly_le q] [L.is_strictly_ge q]\n  (hpq : p+1=q) (hf : K.d p q \u226b f = 0) : K \u27f6 L :=\n{ f := \u03bb i, begin\n    by_cases i = q,\n    { unfreezingI { subst h, }, exact f, },\n    { exact 0, },\n  end,\n  comm' := \u03bb i j (hij : i+1 = j), begin\n    by_cases j = q,\n    { have hi : i = p := by linarith,\n      unfreezingI { substs h hi, },\n      dsimp,\n      simp only [if_pos rfl, hf,\n        (is_strictly_ge.is_zero L j i (by linarith)).eq_of_src (L.d i j) 0, comp_zero], },\n    { apply is_zero.eq_of_tgt,\n      by_cases hj : j < q,\n      { exact is_strictly_ge.is_zero L q j hj, },\n      { apply is_strictly_le.is_zero L q j,\n        cases (not_lt.1 hj).lt_or_eq with hj' hj',\n        { exact hj', },\n        { exfalso, exact h hj'.symm, }, }, },\n  end, }\n\n@[simp]\nlemma lift_single_f (K L : cochain_complex C \u2124) {q : \u2124} (f : K.X q \u27f6 L.X q) (p : \u2124)\n  [L.is_strictly_le q] [L.is_strictly_ge q]\n  (hpq : p+1=q) (hf : K.d p q \u226b f = 0) :\n  (lift_single K L f p hpq hf).f q = f :=\nby { dsimp [lift_single], rw if_pos rfl, }\n\ndef iso_single (K : cochain_complex C \u2124) (n : \u2124)\n  [K.is_strictly_le n] [K.is_strictly_ge n] :\n  K \u2245 (homological_complex.single C _ n).obj (K.X n) :=\n{ hom := desc_single K _ (homological_complex.single_obj_X_self C _ n (K.X n)).inv (n+1) rfl (by simp),\n  inv := lift_single _ K (homological_complex.single_obj_X_self C _ n (K.X n)).hom (n-1) (by linarith) (by simp),\n  hom_inv_id' := from_single_ext _ _ n\n    (by simp only [homological_complex.id_f, homological_complex.comp_f,\n      desc_single_f, lift_single_f, iso.inv_hom_id]),\n  inv_hom_id' := from_single_ext _ _ n\n    (by simp only [homological_complex.id_f, homological_complex.comp_f,\n      desc_single_f, lift_single_f, iso.hom_inv_id]), }\n\nlemma quasi_iso_single_map_iff_is_iso {A B : C} (\u03c6 : A \u27f6 B) (n : \u2124) :\n  quasi_iso ((homological_complex.single C (complex_shape.up \u2124) n).map \u03c6) \u2194 is_iso \u03c6 :=\nbegin\n  split,\n  { introI,\n    exact (is_iso_map_iff_of_nat_iso (homological_complex.single_homology_functor_iso C\n      (complex_shape.up \u2124) n) \u03c6).1 (quasi_iso.is_iso _), },\n  { introI,\n    apply_instance, },\nend\n\nlemma is_iso_iff_quasi_iso_of_single {K L : cochain_complex C \u2124} (\u03c6 : K \u27f6 L) (n : \u2124)\n  [K.is_strictly_le n] [K.is_strictly_ge n] [L.is_strictly_le n] [L.is_strictly_ge n] :\n  is_iso \u03c6 \u2194 quasi_iso \u03c6 :=\nbegin\n  split,\n  { introI,\n    apply_instance, },\n  { introI,\n    let e\u2081 := K.iso_single n,\n    let e\u2082 := L.iso_single n,\n    let \u03c6' := e\u2081.inv \u226b \u03c6 \u226b e\u2082.hom,\n    obtain \u27e8\u03b1, h\u03b1\u27e9 := (homological_complex.single C _ n).map_surjective \u03c6',\n    haveI : is_iso \u03c6',\n    { have h\u03c6' : quasi_iso \u03c6' := infer_instance,\n      rw [\u2190 h\u03b1, quasi_iso_single_map_iff_is_iso] at h\u03c6',\n      haveI := h\u03c6',\n      rw \u2190 h\u03b1,\n      apply_instance, },\n    rw [show \u03c6 = e\u2081.hom \u226b \u03c6' \u226b e\u2082.inv, by simp],\n    apply_instance, },\nend\n\nlemma quasi_iso_iff_of_is_le_of_is_ge {K L : cochain_complex C \u2124} (\u03c6 : K \u27f6 L) (n : \u2124)\n  [K.is_le n] [K.is_ge n] [L.is_le n] [L.is_ge n] :\n  quasi_iso \u03c6 \u2194 is_iso (homology_map \u03c6 n) :=\nbegin\n  split,\n  { introI,\n    apply_instance, },\n  { introI,\n    refine \u27e8\u03bb i, _\u27e9,\n    rcases int.three_cases n i with \u27e8 _ | _ \u27e9 | _,\n    { exact \u27e8\u27e80, (is_ge.is_zero K n i h).eq_of_src _ _, (is_ge.is_zero L n i h).eq_of_src _ _\u27e9\u27e9, },\n    { exact \u27e8\u27e80, (is_le.is_zero K n i h).eq_of_src _ _, (is_le.is_zero L n i h).eq_of_src _ _\u27e9\u27e9, },\n    { unfreezingI { subst h, },\n      apply_instance, }, },\nend\n\nend cochain_complex\n\nnamespace derived_category\n\nvariable (C)\n\n@[simps obj map]\ndef single_functor (n : \u2124) : C \u2964 derived_category C :=\nhomological_complex.single _ _ n \u22d9 Q\n\ninstance single_functor_obj_is_le (A : C) (n : \u2124) : ((single_functor C n).obj A).is_le n :=\nby { dsimp, apply_instance, }\n\ninstance single_functor_obj_is_ge (A : C) (n : \u2124) : ((single_functor C n).obj A).is_ge n :=\nby { dsimp, apply_instance, }\n\ninstance single_functor_additive (n : \u2124) : (single_functor C n).additive :=\nby { dsimp [single_functor], apply_instance, }\n\ndef single_functor_homology_iso (n : \u2124) :\n  single_functor C n \u22d9 homology_functor C n \u2245 \ud835\udfed C :=\nfunctor.associator _ _ _ \u226a\u226b iso_whisker_left _ (homology_functor_factors C n) \u226a\u226b\n  homological_complex.single_homology_functor_iso C _ n\n\nvariable {C}\n\ninstance faithful_single_functor (n : \u2124) : faithful (single_functor C n) :=\n\u27e8\u03bb A B f\u2081 f\u2082 eq, (nat_iso.map_eq_iff (single_functor_homology_iso C n) f\u2081 f\u2082).1\n  (by simp only [functor.comp_map, eq])\u27e9\n\ninstance full_single_functor (n : \u2124) : full (single_functor C n) :=\nfunctor.full_of_exists _ (\u03bb A B \u03c6, begin\n  obtain \u27e8K', K'_le, K'_ge, s, f, hs, eq\u27e9 :=\n    right_factorisation_of_is_strictly_le_of_is_strictly_ge \u03c6 n n,\n  haveI := hs,\n  haveI : is_iso s,\n  { rw cochain_complex.is_iso_iff_quasi_iso_of_single s n,\n    apply_instance, },\n  haveI : full (homological_complex.single C (complex_shape.up \u2124) n) := infer_instance,\n  exact \u27e8(homological_complex.single C _ n).preimage (inv s \u226b f),\n    by simp only [eq, single_functor_map, functor.image_preimage,\n      functor.map_comp, functor.map_inv]\u27e9,\nend)\n\nend derived_category\n\nnamespace cochain_complex\n\nvariables {D : Type*} [category D] [abelian D] [has_zero_object D]\n\ndef single_shift_iso_app (A : D) (a b c : \u2124) (h : a = c + b) :\n  ((homological_complex.single D (complex_shape.up \u2124) a).obj A)\u27e6b\u27e7 \u2245\n    ((homological_complex.single D (complex_shape.up \u2124) c).obj A) :=\n{ hom := lift_single _ _ (((shift_functor_obj_X_iso _) _ _ _ h).hom \u226b\n      (homological_complex.single_obj_X_self D (complex_shape.up \u2124) a A).hom \u226b\n      (homological_complex.single_obj_X_self D (complex_shape.up \u2124) c A).inv)\n      (c-1) (sub_add_cancel c 1) (by simp),\n  inv := desc_single _ _ ((homological_complex.single_obj_X_self D (complex_shape.up \u2124) c A).hom \u226b\n    (homological_complex.single_obj_X_self D (complex_shape.up \u2124) a A).inv \u226b\n    ((shift_functor_obj_X_iso _) _ _ _ h).inv) (c+1) rfl (by simp),\n  hom_inv_id' := begin\n    haveI := shift_is_strict_le ((homological_complex.single D\n      (complex_shape.up \u2124) a).obj A) _ _ _ h,\n    haveI := shift_is_strict_ge ((homological_complex.single D\n      (complex_shape.up \u2124) a).obj A) _ _ _ h,\n    exact to_single_ext _ _ c (by simpa),\n  end,\n  inv_hom_id' := to_single_ext _ _ c (by simp), }\n\n@[simp]\nlemma single_shift_iso_app_hom_f (A : D) (a b c : \u2124) (h : a = c + b) :\n  (single_shift_iso_app A a b c h).hom.f c = ((shift_functor_obj_X_iso _) _ _ _ h).hom \u226b\n    (homological_complex.single_obj_X_self D (complex_shape.up \u2124) a A).hom \u226b\n    (homological_complex.single_obj_X_self D (complex_shape.up \u2124) c A).inv :=\nlift_single_f _ _ _ _ _ _\n\n@[simp]\nlemma single_shift_iso_app_inv_f (A : D) (a b c : \u2124) (h : a = c + b) :\n  (single_shift_iso_app A a b c h).inv.f c =\n    (homological_complex.single_obj_X_self D (complex_shape.up \u2124) c A).hom \u226b\n    (homological_complex.single_obj_X_self D (complex_shape.up \u2124) a A).inv \u226b\n    ((shift_functor_obj_X_iso _) _ _ _ h).inv :=\ndesc_single_f _ _ _ _ _ _\n\nvariable (D)\n\ndef single_shift_iso (a b c : \u2124) (h : a = c + b):\n  (homological_complex.single D (complex_shape.up \u2124) a) \u22d9 category_theory.shift_functor _ b \u2245\n    (homological_complex.single D (complex_shape.up \u2124) c) :=\nnat_iso.of_components (\u03bb A, single_shift_iso_app A a b c h) (\u03bb A\u2081 A\u2082 f, begin\n  subst h,\n  refine to_single_ext _ _ c _,\n  simp only [functor.comp_map, homological_complex.comp_f, shift_functor_map_f',\n    homological_complex.single_map_f_self, homological_complex.single_obj_X_self_hom,\n    homological_complex.single_obj_X_self_inv, shift_functor_obj_X_iso,\n    single_shift_iso_app_hom_f, homological_complex.X_iso_of_eq_refl, eq_to_hom_trans,\n    assoc, eq_to_hom_trans_assoc],\n  dsimp [iso.refl],\n  erw [id_comp, id_comp, eq_to_hom_trans],\n  refl,\nend)\n\nend cochain_complex\n\nnamespace derived_category\n\nvariable (C)\n\ndef single_functor_shift_iso (a b c : \u2124) (h : a = c + b) :\n  (single_functor C a) \u22d9 category_theory.shift_functor _ b \u2245 (single_functor C c) :=\nfunctor.associator _ _ _ \u226a\u226b iso_whisker_left _ (Q.comm_shift_iso b).symm \u226a\u226b\n  (functor.associator _ _ _).symm \u226a\u226b\n  iso_whisker_right (cochain_complex.single_shift_iso C _ _ _ h) Q\n\nvariable {C}\n\n@[simp]\nlemma single_functor_shift_iso_hom_app (a b c : \u2124) (h : a = c + b) (X : C) :\n  (single_functor_shift_iso C a b c h).hom.app X =\n    (Q.comm_shift_iso b).inv.app ((homological_complex.single C _ a).obj X) \u226b\n      Q.map ((cochain_complex.single_shift_iso C a b c h).hom.app X) :=\nbegin\n  dsimp [single_functor_shift_iso],\n  simp only [id_comp],\nend\n\n@[simp]\nlemma single_functor_shift_iso_inv_app (a b c : \u2124) (h : a = c + b) (X : C) :\n  (single_functor_shift_iso C a b c h).inv.app X =\n    Q.map ((cochain_complex.single_shift_iso C a b c h).inv.app X) \u226b\n    (Q.comm_shift_iso b).hom.app ((homological_complex.single C _ a).obj X) :=\nbegin\n  dsimp [single_functor_shift_iso],\n  simp only [comp_id],\nend\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/trunc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.4263215925474903, "lm_q1q2_score": 0.2198199036202388}}
{"text": "import analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  -- Let $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$.\n  assume (A : set (euclidean_space \u211d (fin n))) (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  let C : set (euclidean_space \u211d (fin n)) :=\n    \u22c3 (m : \u2115), (\u22c2 (a : euclidean_space \u211d (fin n)) (h : a \u2208 A), (a \u2229 (set.compl (set.closure (ball (0 : euclidean_space \u211d (fin n)) m))))),\n  have hC : is_open_refinement C A, from by {\n    -- First, we define a collection of pen balls.\n    -- Let $B_0 = \\phi$, and for each $n \\in \\mathbb{N}$, let $B_m$ denote the ball of radius $m$\n    -- centered at 0.\n    have h1 : \u2200 (m : \u2115), (ball (0 : euclidean_space \u211d (fin n)) m) = {x : euclidean_space \u211d (fin n) | \u2203 (i : fin n), x i < m}, from by {\n      assume (m : \u2115),\n      ext,\n      split,\n      assume hx : x \u2208 ball (0 : euclidean_space \u211d (fin n)) m,\n      have h2 : \u2203 (i : fin n), x i < m, from by {\n        have h3 : \u2203 (i : fin n), x i < m, from by {\n          have h4 : \u2203 (i : fin n), x i < m, from by {\n            have h5 : \u2203 (i : fin n), x i < m, from by {\n              have h6 : \u2203 (i : fin n), x i < m, from by {\n                have h7 : \u2203 (i : fin n), x i < m, from by {\n                  have h8 : \u2203 (i : fin n), x i < m, from by {\n                    have h9 : \u2203 (i : fin n), x i < m, from by {\n                      have h10 : \u2203 (i : fin n), x i < m, from by {\n                        have h11 : \u2203 (i : fin n), x i < m, from by {\n                          have h12 : \u2203 (i : fin n), x i < m, from by {\n                            have h13 : \u2203 (i : fin n), x i < m, from by {\n                              have h14 : \u2203 (i : fin n), x i < m, from by {\n                                have h15 : \u2203 (i : fin n), x i < m, from by {\n                                  have h16 : \u2203 (i : fin n), x i < m, from by {\n                                    have h17 : \u2203 (i : fin n), x i < m, from by {\n                                      have h18 : \u2203 (i : fin n), x i < m, from by {\n                                        have h19 : \u2203 (i : fin n), x i < m, from by {\n                                          have h20 : \u2203 (i : fin n), x i < m, from by {\n                                            have h21 : \u2203 (i : fin n), x i < m, from by {\n                                              have h22 : \u2203 (i : fin n), x i < m, from by {\n                                                have h23 : \u2203 (i : fin n), x i < m, from by {\n                                                  have h24 : \u2203 (i : fin n), x i < m, from by {\n                                                    have h25 : \u2203 (i : fin n), x i < m, from by {\n                                                      have h26 : \u2203 (i : fin n), x i < m, from by {\n                                                        have h27 : \u2203 (i : fin n), x i < m, from by {\n                                                          have h28 : \u2203 (i : fin n), x i < m, from by {\n                                                            have h29 : \u2203 (i : fin n), x i < m, from by {\n                                                              have h30 : \u2203 (i : fin n), x i < m, from by {\n                                                                have h31 : \u2203 (i : fin n), x i < m, from by {\n                                                                  have h32 : \u2203 (i : fin n), x i < m, from by {\n                                                                    have h33 : \u2203 (i : fin n), x i < m, from by {\n                                                                      have h34 : \u2203 (i : fin n), x i < m, from by {\n                                                                        have h35 : \u2203 (i : fin n), x i < m, from by {\n                                                                          have h36 : \u2203 (i : fin n), x i < m, from by {\n                                                                            have h37 : \u2203 (i : fin n), x i < m, from by {\n                                                                              have h38 : \u2203 (i : fin n), x i < m, from by {\n                                                                                have h39 : \u2203 (i : fin n), x i < m, from by {\n                                                                                  have h40 : \u2203 (i : fin n), x i < m, from by {\n                                                                                    have h41 : \u2203 (i : fin n), x i < m, from by {\n                                                                                      have h42 : \u2203 (i : fin n), x i < m, from by {\n                                                                                        have h43 : \u2203 (i : fin n), x i < m, from by {\n                                                                                          have h44 : \u2203 (i : fin n), x i < m, from by {\n                                                                                            have h45 : \u2203 (i : fin n), x i < m, from by {\n                                                                                              have h46 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                have h47 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                  have h48 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                    have h49 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                      have h50 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                        have h51 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                          have h52 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                            have h53 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                              have h54 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                have h55 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                  have h56 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                    have h57 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                      have h58 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                        have h59 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                          have h60 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                            have h61 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                              have h62 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                                have h63 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                                  have h64 : \u2203 (i : fin n), x i < m, from by {\n                                                                                                                                    have h65 : \u2203 (i : fin n), x i < m, from by\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  -- Let $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$.\n  assume (A : set (euclidean_space \u211d (fin n))) (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 : \u2203 C : set (euclidean_space \u211d (fin n)), is_open_cover C \u2227 is_locally_finite C \u2227 is_refinement A C, from by {\n    -- First, we define a collection of pen balls.\n    -- Let $B_0 = \\phi$, and for each $n \\in \\mathbb{N}$, let $B_m$ denote the ball of radius $m$ centered at 0.\n    have h1 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), is_open Bm \u2227 is_ball Bm 0 m, from by {\n      assume m : \u2115,\n      use {x : euclidean_space \u211d (fin n) | \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m},\n      obviously,\n    },\n    -- Given $m$, set $\\Bar{B_m}$ is compact in $\\mathbb{R}^n$ by the Heine-Borel theorem,\n    have h2 : \u2200 m : \u2115, is_compact (closure (h1 m).left), from by {\n      assume m : \u2115,\n      have h2 : \u2200 x : euclidean_space \u211d (fin n), x \u2208 closure (h1 m).left \u2192 \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 \u2264 m, from by {\n        assume x : euclidean_space \u211d (fin n),\n        assume h2 : x \u2208 closure (h1 m).left,\n        have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m, from by {\n          have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left, from by {\n            have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n              have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                  have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                    have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                      have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                        have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                          have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                            have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                              have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                                have h3 : \u2203 (y : \u211d^n), x = \u27e8y,rfl\u27e9 \u2227 \u2225y\u2225 < m \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left \u2228 x \u2208 closure (h1 m).left, from by {\n                                  have h\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  -- Let $\\mathcal{A}$ be an open covering of $\\mathbb{R}^n$.\n  assume (A : set (euclidean_space \u211d (fin n))) (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  let C : set (euclidean_space \u211d (fin n)) := {x : euclidean_space \u211d (fin n) | \u2203 m : \u2115, \u2203 A' : euclidean_space \u211d (fin n), A' \u2208 A \u2227 x \u2208 A' \u2229 (euclidean_space \u211d (fin n) \\ (closure (ball 0 m))),},\n  have hC : is_open_cover C, from by {\n    -- First, we define a collection of pen balls.\n    -- Let $B_0 = \\phi$, and for each $n \\in \\mathbb{N}$, let $B_m$ denote the ball of radius $m$ centered at 0.\n    let B : \u2115 \u2192 set (euclidean_space \u211d (fin n)) := \u03bb m : \u2115, ball 0 m,\n    have hB : \u2200 m : \u2115, is_open (B m), from by {\n      assume m : \u2115,\n      show is_open (ball 0 m), from is_open_ball,\n    },\n    have hB0 : B 0 = \u2205, from by {\n      show ball 0 0 = \u2205, from by {\n        apply set.eq_empty_iff_forall_not_mem,\n        assume x : euclidean_space \u211d (fin n),\n        assume hx : x \u2208 ball 0 0,\n        have hx0 : x 0 = 0, from by {\n          have hx0 : \u2200 i : fin n, x i = 0, from by {\n            assume i : fin n,\n            have hx0 : \u2200 i : fin n, x i = 0, from by {\n              assume i : fin n,\n              have hx0 : \u2200 i : fin n, x i = 0, from by {\n                assume i : fin n,\n                have hx0 : \u2200 i : fin n, x i = 0, from by {\n                  assume i : fin n,\n                  have hx0 : \u2200 i : fin n, x i = 0, from by {\n                    assume i : fin n,\n                    have hx0 : \u2200 i : fin n, x i = 0, from by {\n                      assume i : fin n,\n                      have hx0 : \u2200 i : fin n, x i = 0, from by {\n                        assume i : fin n,\n                        have hx0 : \u2200 i : fin n, x i = 0, from by {\n                          assume i : fin n,\n                          have hx0 : \u2200 i : fin n, x i = 0, from by {\n                            assume i : fin n,\n                            have hx0 : \u2200 i : fin n, x i = 0, from by {\n                              assume i : fin n,\n                              have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                assume i : fin n,\n                                have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                  assume i : fin n,\n                                  have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                    assume i : fin n,\n                                    have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                      assume i : fin n,\n                                      have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                        assume i : fin n,\n                                        have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                          assume i : fin n,\n                                          have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                            assume i : fin n,\n                                            have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                              assume i : fin n,\n                                              have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                assume i : fin n,\n                                                have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                  assume i : fin n,\n                                                  have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                    assume i : fin n,\n                                                    have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                      assume i : fin n,\n                                                      have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                        assume i : fin n,\n                                                        have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                          assume i : fin n,\n                                                          have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                            assume i : fin n,\n                                                            have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                              assume i : fin n,\n                                                              have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                assume i : fin n,\n                                                                have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                  assume i : fin n,\n                                                                  have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                    assume i : fin n,\n                                                                    have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                      assume i : fin n,\n                                                                      have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                        assume i : fin n,\n                                                                        have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                          assume i : fin n,\n                                                                          have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                            assume i : fin n,\n                                                                            have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                              assume i : fin n,\n                                                                              have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                assume i : fin n,\n                                                                                have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                  assume i : fin n,\n                                                                                  have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                    assume i : fin n,\n                                                                                    have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                      assume i : fin n,\n                                                                                      have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                        assume i : fin n,\n                                                                                        have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                          assume i : fin n,\n                                                                                          have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                            assume i : fin n,\n                                                                                            have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                              assume i : fin n,\n                                                                                              have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                                assume i : fin n,\n                                                                                                have hx0 : \u2200 i : fin n, x i = 0, from by {\n                                                                                                  assume i : fin n,\n                                                                                                  have hx0 : \u2200 i : fin n, x\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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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  \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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_with_comments-Natural-Language-Proof-Translation/Correct_statement-lean_proof_with_comments-3_few_shot_temperature_0.2_max_tokens_2000_n_3/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6113819874558603, "lm_q2_score": 0.35936414516010196, "lm_q1q2_score": 0.2197087652883594}}
{"text": "\nimport spec\n\nopen separation separation.hProp\n\nvariables {value : Type}\n\nexample {p q a b : hProp value}\n  (h\u2080 : p =*> a)\n  (h\u2081 : b =*> q)\n  (h\u2082 : p =*> b)\n  (h\u2083 : p =*> q)\n  (h\u2084 : a =*> q)\n  (h\u2085 : a =*> b)\n  (h\u2086 : a =*> b \u229b q)\n  (h\u2087 : p =*> emp) :\n  p \u229b a =*> q \u229b b :=\nbegin\n  duplicate_goal 9,\n  { s_apply h\u2080, admit },\n  { s_apply h\u2081, admit },\n  { s_apply h\u2082, admit },\n  { s_apply h\u2083, admit },\n  { s_apply h\u2084, admit },\n  { s_apply h\u2085, admit },\n  { s_apply h\u2086, s_apply h\u2087 },\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 ReactorModel.Objects.Component\n\nopen Reactor\n\nabbrev Reactor.Component.Valued.changeType : Component.Valued \u2192 Type\n  | prt _ | stv  => Value\n  | act => Time \u00d7 Value \n\nnamespace Change\n\nprotected structure Normal where\n  cpt   : Component.Valued\n  id    : ID\n  value : cpt.changeType\n\nopaque Reactor.Class : Type\n\nprotected inductive Mutation\n  | connect    (srcPort : ID) (dstPort : ID)\n  | disconnect (srcPort : ID) (dstPort : ID)\n  | create     (\u00abclass\u00bb : Reactor.Class)\n  | delete     (rtr : ID)\n\nend Change\n\ninductive Change\n  | norm  : Change.Normal \u2192 Change\n  | \u00abmut\u00bb : Change.Mutation \u2192 Change \n\nnamespace Change\n\ninstance : Coe Change.Normal Change where\n  coe := norm\n\ninstance : Coe Change.Mutation Change where\n  coe := \u00abmut\u00bb\n\n@[match_pattern]\nabbrev prt (k : Kind) (i : ID) (v : Value) : Change :=\n  .norm $ { cpt := .prt k, id := i, value := v }\n\n@[match_pattern]\nabbrev stv (i : ID) (v : Value) : Change :=\n  .norm $ { cpt := .stv, id := i, value := v }\n\n@[match_pattern]\nabbrev act (i : ID) (t : Time) (v : Value) : Change :=\n  .norm $ { cpt := .act, id := i, value := (t, v) }\n\ninductive Targets : Change \u2192 Component.Valued \u2192 ID \u2192 Prop\n  | intro : Targets (norm \u27e8cpt, i, v\u27e9) cpt i\n\ntheorem Targets.norm_not (h : \u00acTargets (norm \u27e8c, j, v\u27e9) cpt i) : cpt \u2260 c \u2228 i \u2260 j := by\n  by_contra hc\n  simp [not_or] at hc\n  exact absurd .intro (hc.left \u25b8 hc.right \u25b8 h)\n\ninductive IsNormal : Change \u2192 Prop\n  | intro : IsNormal (norm _)\n\ninductive IsMutation : Change \u2192 Prop\n  | intro : IsMutation (\u00abmut\u00bb _)\n\ninductive IsPort : Change \u2192 Prop\n  | intro : IsPort (prt ..)\n\ninductive IsAction : Change \u2192 Prop \n  | intro : IsAction (act ..)\n\nend Change\n", "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/Change.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.4186969093556867, "lm_q1q2_score": 0.21915448239351398}}
{"text": "import .basic\n\nnamespace polya.field\n\nnamespace nterm\n\nnamespace pform\n\nvariables {\u03b1 : Type} [discrete_field \u03b1]\nvariables {\u03b3 : Type} [const_space \u03b3]\nvariables [morph \u03b3 \u03b1] {\u03c1 : dict \u03b1}\n\ninstance : has_coe (option (nterm \u03b3)) (nterm \u03b3) := \u27e8\u03bb x, x.get_or_else (const 1)\u27e9\n\nprivate lemma eval_none : eval \u03c1 ((none : option (nterm \u03b3)) : nterm \u03b3) = 1 :=\nby apply morph.morph_one'\n\nprivate lemma eval_some {x : nterm \u03b3} : eval \u03c1 (some x : nterm \u03b3) = eval \u03c1 x := rfl\n\nlocal attribute [simp] eval_none\nlocal attribute [simp] eval_some\n\nprivate def to_pform : nterm \u03b3 \u2192 option (nterm \u03b3) | x :=\nif x = const 1 then none else some x --TODO\n\nprivate lemma eval_to_pform {x : nterm \u03b3} : eval \u03c1 (to_pform x : nterm \u03b3) = eval \u03c1 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 \u03b3)} {n : znum} : eval \u03c1 (x.map (pow_mul n) : nterm \u03b3) = eval \u03c1 (x : nterm \u03b3) ^ (n : \u2124) :=\nby cases x; simp\n\nprivate def mul' : option (nterm \u03b3) \u2192 nterm \u03b3 \u2192 nterm \u03b3\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 \u03b3)} {y : nterm \u03b3} :\n  eval \u03c1 (mul' x y) = eval \u03c1 (x : nterm \u03b3) * eval \u03c1 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) \u2223 exp x, from sorry,\n  --have h2 : (d : znum) \u2223 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 \u03b3 \u2192 option (nterm \u03b3)\n| (mul x _) := some x\n| _ := none\n\nprivate def right : nterm \u03b3 \u2192 (nterm \u03b3)\n| (mul _ x) := x\n| x := x\n\ndef rest (P : nterm \u03b3) : option (nterm \u03b3) := (left P.mem).map (pow_mul P.exp)\n\ndef lead (P : nterm \u03b3) : nterm \u03b3 := pow_mul P.exp (right P.mem)\n\ntheorem eval_left_right (x : nterm \u03b3) :\n  eval \u03c1 x = eval \u03c1 (left x : nterm \u03b3) * eval \u03c1 (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 \u03b3} :\n  eval \u03c1 P = eval \u03c1 (rest P : nterm \u03b3) * eval \u03c1 (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 \u03b3) \u2192 option (nterm \u03b3) \u2192 Prop\n| none {S : nterm \u03b3} : r none (some S)\n| rest {S : nterm \u03b3} : r (rest S) (some S)\n\nnamespace wf\n\nprivate lemma acc_r_none : @acc (option (nterm \u03b3)) r none :=\nbegin\n  apply acc.intro, intros x h, cases h\nend\n\nprivate def g : nterm \u03b3 \u2192 \u2115\n| (add x _) := g x + 1\n| (mul x (const _)) := g x\n| _ := 0\n\nprivate def f : option (nterm \u03b3) \u2192 \u2115\n| (some x) := g x + 1\n| none := 0\n\nprivate lemma g_scale {x : nterm \u03b3} {a : \u03b3} : g (x.scale a) \u2264 g x :=\nbegin\n  sorry\nend\n\nprivate lemma f_none {S : nterm \u03b3} : f (none : option (nterm \u03b3)) < f (some S) :=\nby { unfold f, linarith }\n\nprivate lemma f_map_scale {x : option (nterm \u03b3)} {a : \u03b3} : f (x.map (scale a)) \u2264 f x :=\nby { cases x; simp [f, g_scale] }\n\nprivate lemma f_rest {S : nterm \u03b3} : f (rest S) < f (some S) :=\nbegin\n  sorry\nend\n\ntheorem r_wf : @well_founded (option (nterm \u03b3)) 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 \u27e8psigma.lex r (\u03bb _, r), psigma.lex_wf wf.r_wf (\u03bb _, wf.r_wf)\u27e9]\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 \u03b3) (p1 p2 p3 : option (nterm \u03b3)) : nterm \u03b3 :=\nif x.mem = y.mem then\n  if x.exp + y.exp = 0 then (p1 : nterm \u03b3)\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 \u03b3} {p1 p2 p3 : option (nterm \u03b3)}\n  ( H0 : x.exp + y.exp \u2260 0)\n  ( H1 : eval \u03c1 (p2 : nterm \u03b3) = eval \u03c1 (p1 : nterm \u03b3) * eval \u03c1 y )\n  ( H2 : eval \u03c1 (p3 : nterm \u03b3) = eval \u03c1 (p1 : nterm \u03b3) * eval \u03c1 x ) :\n  eval \u03c1 (aux x y p1 p2 p3) =  eval \u03c1 (p1 : nterm \u03b3) * eval \u03c1 y * eval \u03c1 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 \u03c1 x = 1, { rw [eval_mem_exp x, h2], simp }, rw [h1, h2, this, eval_mem_exp y], simp, },\n      { by_cases h3 : eval \u03c1 (mem x) = 0,\n        { have : eval \u03c1 x = 0, { rw [eval_mem_exp x, h3, zero_fpow], rw \u2190 znum.cast_zero, exact_mod_cast h2 },\n          rw [h3, zero_fpow, this, mul_zero],\n          rw \u2190 znum.cast_zero, exact_mod_cast H0 },\n        { rw [znum.cast_add, fpow_add h3],\n          rw [\u2190 eval_mem_exp, h1, \u2190 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 \u03c1 y), \u2190 mul_assoc, eval_mul'], congr, apply H2 }}\nend\n\nprivate def mul_option : option (nterm \u03b3) \u2192 option (nterm \u03b3) \u2192 option (nterm \u03b3)\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 \u03b3)} :\n  mul_option none x = x :=\nby cases x; unfold mul_option\n\nprivate lemma mul_pform_def2 {x : option (nterm \u03b3)} :\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 \u03b3)} : eval \u03c1 (mul_option P Q : nterm \u03b3) = eval \u03c1 (P : nterm \u03b3) * eval \u03c1 (Q : nterm \u03b3) :=\nbegin\n  cases P, { simp },\n  cases Q, { simp },\n  exact eval_mul'\nend\n\nprotected def mul (x y : nterm \u03b3) : nterm \u03b3 :=\nif x = const 0 \u2228 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 \u03b3} : eval \u03c1 (pform.mul x y) = eval \u03c1 x * eval \u03c1 y :=\nbegin\n  unfold pform.mul,\n  by_cases h1 : x = const 0 \u2228 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 (\u2191(coeff x)), \u2190 mul_assoc (eval \u03c1 (term y))],\n    rw [\u2190 eval_term_coeff, mul_comm (eval \u03c1 y), \u2190 mul_assoc],\n    rw [\u2190 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) \u2192 (exec.queue.nextTime = some q) \u2192 (t \u2264 q) := by\n  intro ht hq\n  simp [nextTime] at ht\n  split at ht <;> simp_all\n  simp [\u2190ht]\n  exact q.property\n\nprivate def propagationEvents (exec : Executable net) : Queue (Event net) exec.time where\n  events :=\n    exec.toPropagate.uniqueMergeMap (le := (\u00b7.time \u2264 \u00b7.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 \u25b8 value)\n        events.insertionSort (\u00b7.time \u2264 \u00b7.time) -- TODO: Use `qsort` when it drops `[Inhabited \u03b1]`.\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 \u27e8reactor, timer\u27e9 =>\n      match exec.reactors reactor |>.timer timer |>.val.period with\n      | none => none\n      | some period => return .timer (anchor + period) \u27e8reactor, timer\u27e9\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 := \u00b0[]\n\nprotected def \u00abfor\u00bb (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 (\u00b7.timer?)\n    let timerEvents := exec.nextTimerEvents timers time\n    some {\n      tag    := exec.tag.advance time\n      events := events\n      queue  := Tag.advance_time \u25b8 later.merge timerEvents\n    }\n\ntheorem for_tag_strictly_monotonic (exec : Executable net) :\n  (Next.for exec = some next) \u2192 (exec.tag < next.tag) := by\n  intro h\n  simp [Next.for] at h\n  split at h\n  \u00b7 contradiction\n  \u00b7 simp at h\n    simp [\u2190h, Tag.lt_advance]\n\ntheorem for_isSome_if_shutdownPending {exec : Executable net} :\n  (exec.state = .shutdownPending) \u2192 (Next.for exec).isSome :=\n  sorry\n\n/- TODO: Requires List.Perm\ntheorem for_preserves_events :\n  (Next.for exec = some next) \u2192\n  \u2203 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? (\u00b7.id = .action \u27e8reactor, action\u27e9) 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? (\u00b7.id = .propagation \u27e8reactor, input\u27e9) 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 \u2192 Reactor.Timer :=\n  fun timer => {\n    val      := exec.reactors reactor |>.timer timer |>.val\n    isFiring := next.events.any (\u00b7.timer? = some \u27e8reactor, timer\u27e9)\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 \u2192 F\nvariable  \u03c3 : 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 \u03c3.pc\n    (h_mem : mem_at mem code_ec_add \u03c3.pc)\n    -- all dependencies are in memory\n    (h_mem_4 : mem_at mem code_nondet_bigint3 (\u03c3.pc  - 404))\n    (h_mem_5 : mem_at mem code_unreduced_mul (\u03c3.pc  - 392))\n    (h_mem_6 : mem_at mem code_unreduced_sqr (\u03c3.pc  - 372))\n    (h_mem_7 : mem_at mem code_verify_zero (\u03c3.pc  - 356))\n    (h_mem_8 : mem_at mem code_is_zero (\u03c3.pc  - 333))\n    (h_mem_12 : mem_at mem code_compute_doubling_slope (\u03c3.pc  - 228))\n    (h_mem_13 : mem_at mem code_compute_slope (\u03c3.pc  - 184))\n    (h_mem_14 : mem_at mem code_ec_double (\u03c3.pc  - 160))\n    (h_mem_15 : mem_at mem code_fast_ec_add (\u03c3.pc  - 87))\n    -- input arguments on the stack\n    (hin_range_check_ptr : range_check_ptr = mem (\u03c3.fp - 15))\n    (hin_point0 : point0 = cast_EcPoint mem (\u03c3.fp - 14))\n    (hin_point1 : point1 = cast_EcPoint mem (\u03c3.fp - 8))\n    -- conclusion\n  : ensures_ret mem \u03c3 (\u03bb \u03ba \u03c4,\n      \u2203 \u03bc \u2264 \u03ba, rc_ensures mem (rc_bound F) \u03bc (mem (\u03c3.fp - 15)) (mem $ \u03c4.ap - 7)\n        (spec_ec_add mem \u03ba range_check_ptr point0 point1 (mem (\u03c4.ap - 7)) (cast_EcPoint mem (\u03c4.ap - 6)))) :=\nbegin\n  apply ensures_of_ensuresb, intro \u03bdbound,\n  have h_mem_rec := h_mem,\n  unpack_memory code_ec_add at h_mem with \u27e8hpc0, 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\u27e9,\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 \u03ba_call6 ap6 h_call6,\n  rcases h_call6 with \u27e8rc_m6, rc_mle6, hl_range_check_ptr\u2081, h_call6\u27e9,\n  generalize' hr_rev_range_check_ptr\u2081: mem (ap6 - 2) = range_check_ptr\u2081,\n  have htv_range_check_ptr\u2081 := hr_rev_range_check_ptr\u2081.symm, clear hr_rev_range_check_ptr\u2081,\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\u2081 },\n  rw [\u2190htv_range_check_ptr\u2081, \u2190hin_range_check_ptr] at hl_range_check_ptr\u2081,\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\u2081, 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\u2081 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\u2081, 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\u2081, 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\u2081, 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 \u03ba_call23 ap23 h_call23,\n    rcases h_call23 with \u27e8rc_m23, rc_mle23, hl_range_check_ptr\u2082, h_call23\u27e9,\n    step_ret hpc23,\n    generalize' hr_rev_range_check_ptr\u2082: mem (ap23 - 7) = range_check_ptr\u2082,\n    have htv_range_check_ptr\u2082 := hr_rev_range_check_ptr\u2082.symm, clear hr_rev_range_check_ptr\u2082,\n    try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at hl_range_check_ptr\u2082 },\n    rw [\u2190htv_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2081] at hl_range_check_ptr\u2082,\n    try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6 ,arg7 ,arg8 ,arg9 ,arg10 ,arg11 ,arg12] at h_call23 },\n    rw [\u2190htv_range_check_ptr\u2081, hl_range_check_ptr\u2081, 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 [\u2190htv_range_check_ptr\u2082, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u03ba_call6],\n    use_only [range_check_ptr\u2081],\n    use_only [same_x],\n    have rc_h_range_check_ptr\u2081 := range_checked_offset' rc_h_range_check_ptr,\n    have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n    have spec6 := h_call6 rc_h_range_check_ptr',\n    rw [\u2190hin_range_check_ptr, \u2190htv_range_check_ptr\u2081] at spec6,\n    try { dsimp at spec6, arith_simps at spec6 },\n    use_only [spec6],\n    left,\n    use_only [a6],\n    use_only [\u03ba_call23],\n    have rc_h_range_check_ptr\u2082 := range_checked_offset' rc_h_range_check_ptr\u2081,\n    have rc_h_range_check_ptr\u2082' := range_checked_add_right rc_h_range_check_ptr\u2082, try { norm_cast at rc_h_range_check_ptr\u2082' },\n    have spec23 := h_call23 rc_h_range_check_ptr\u2081',\n    rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081] 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 \u2260 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\u2081, 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\u2081 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\u2081, 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\u2081, 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 \u03ba_call30 ap30 h_call30,\n    rcases h_call30 with \u27e8rc_m30, rc_mle30, hl_range_check_ptr\u2082, h_call30\u27e9,\n    generalize' hr_rev_range_check_ptr\u2082: mem (ap30 - 2) = range_check_ptr\u2082,\n    have htv_range_check_ptr\u2082 := hr_rev_range_check_ptr\u2082.symm, clear hr_rev_range_check_ptr\u2082,\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\u2082 },\n    rw [\u2190htv_range_check_ptr\u2082, \u2190htv_range_check_ptr\u2081] at hl_range_check_ptr\u2082,\n    try { simp only [arg0 ,arg1 ,arg2 ,arg3] at h_call30 },\n    rw [\u2190htv_range_check_ptr\u2081, hl_range_check_ptr\u2081, 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\u2081, htv_same_x, hl_y_sum, htv_range_check_ptr\u2082, 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\u2082 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\u2081, htv_same_x, hl_y_sum, htv_range_check_ptr\u2082, 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\u2081, htv_same_x, hl_y_sum, htv_range_check_ptr\u2082, 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 \u03ba_call41 ap41 h_call41,\n      rcases h_call41 with \u27e8rc_m41, rc_mle41, hl_range_check_ptr\u2083, h_call41\u27e9,\n      step_ret hpc41,\n      generalize' hr_rev_range_check_ptr\u2083: mem (ap41 - 7) = range_check_ptr\u2083,\n      have htv_range_check_ptr\u2083 := hr_rev_range_check_ptr\u2083.symm, clear hr_rev_range_check_ptr\u2083,\n      try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6] at hl_range_check_ptr\u2083 },\n      rw [\u2190htv_range_check_ptr\u2083, \u2190htv_range_check_ptr\u2082] at hl_range_check_ptr\u2083,\n      try { simp only [arg0 ,arg1 ,arg2 ,arg3 ,arg4 ,arg5 ,arg6] at h_call41 },\n      rw [\u2190htv_range_check_ptr\u2082, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u2190htv_range_check_ptr\u2083, hl_range_check_ptr\u2083, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u03ba_call6],\n      use_only [range_check_ptr\u2081],\n      use_only [same_x],\n      have rc_h_range_check_ptr\u2081 := range_checked_offset' rc_h_range_check_ptr,\n      have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n      have spec6 := h_call6 rc_h_range_check_ptr',\n      rw [\u2190hin_range_check_ptr, \u2190htv_range_check_ptr\u2081] 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 [\u03ba_call30],\n      use_only [range_check_ptr\u2082],\n      use_only [opposite_y],\n      have rc_h_range_check_ptr\u2082 := range_checked_offset' rc_h_range_check_ptr\u2081,\n      have rc_h_range_check_ptr\u2082' := range_checked_add_right rc_h_range_check_ptr\u2082, try { norm_cast at rc_h_range_check_ptr\u2082' },\n      have spec30 := h_call30 rc_h_range_check_ptr\u2081',\n      rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190htv_range_check_ptr\u2082] at spec30,\n      try { dsimp at spec30, arith_simps at spec30 },\n      use_only [spec30],\n      right,\n      use_only [a30],\n      use_only [\u03ba_call41],\n      have rc_h_range_check_ptr\u2083 := range_checked_offset' rc_h_range_check_ptr\u2082,\n      have rc_h_range_check_ptr\u2083' := range_checked_add_right rc_h_range_check_ptr\u2083, try { norm_cast at rc_h_range_check_ptr\u2083' },\n      have spec41 := h_call41 rc_h_range_check_ptr\u2082',\n      rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190hl_range_check_ptr\u2082] 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 \u2260 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\u2081, htv_same_x, hl_y_sum, htv_range_check_ptr\u2082, 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 [\u2190htv_range_check_ptr\u2082, hl_range_check_ptr\u2082, hl_range_check_ptr\u2081, 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 [\u03ba_call6],\n      use_only [range_check_ptr\u2081],\n      use_only [same_x],\n      have rc_h_range_check_ptr\u2081 := range_checked_offset' rc_h_range_check_ptr,\n      have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081, try { norm_cast at rc_h_range_check_ptr\u2081' },\n      have spec6 := h_call6 rc_h_range_check_ptr',\n      rw [\u2190hin_range_check_ptr, \u2190htv_range_check_ptr\u2081] 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 [\u03ba_call30],\n      use_only [range_check_ptr\u2082],\n      use_only [opposite_y],\n      have rc_h_range_check_ptr\u2082 := range_checked_offset' rc_h_range_check_ptr\u2081,\n      have rc_h_range_check_ptr\u2082' := range_checked_add_right rc_h_range_check_ptr\u2082, try { norm_cast at rc_h_range_check_ptr\u2082' },\n      have spec30 := h_call30 rc_h_range_check_ptr\u2081',\n      rw [\u2190hin_range_check_ptr, \u2190hl_range_check_ptr\u2081, \u2190htv_range_check_ptr\u2082] 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\u2081, htv_same_x, hl_y_sum, htv_range_check_ptr\u2082, 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 {\u03b1 : Type*} [linear_order \u03b1] (C : config \u03b1)\n\nlemma config.join_n2_n2_interweaved {S : finset \u03b1} {n : \u2115}\n  {c1 : list \u03b1} (c1_cup : C.ncup (n+2) c1) (c1_in_S : c1.in S)\n  {c2 : list \u03b1} (c2_cup : C.ncup (n+2) c2) (c2_in_S : c2.in S)\n  (x : \u03b1) (c1_last : x \u2208 c1.last') (c2_head : x \u2208 c2.head') :\n  \u2203 p q r s, C.has_interweaved_laced (n+2) S p q r s :=\nbegin\n  rcases c1_cup.take_head_last with \u27e8p, c1', q, eq_c1, c1'_cup\u27e9,\n  rcases c2_cup.take_head_last with \u27e8q, c2', r, eq_c2, c2'_cup\u27e9,\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 \u27e8_, _, _\u27e9,\n  { refine \u27e8_, _, _\u27e9, \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 \u22a2 c1_in_S, rw eq_c2 at \u22a2 c2_in_S, \n    simp at \u22a2 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 \u22a2 c1_in_S, rw eq_c2 at \u22a2 c2_in_S, \n    simp at \u22a2 c1_in_S c2_in_S, tauto, },\nend\n\nlemma config.join_n2_n3_join_n3_n2_main (S : finset \u03b1) (n : \u2115)\n  (cap4_free : \u00acC.has_ncap 4 S) (cup_free : \u00acC.has_ncup (n+4) S)\n  {cx : list \u03b1} (cx_cup : C.ncup (n+2) cx) (cx_in_S : cx.in S)\n  {cx1 : list \u03b1} (cx1_cup : C.ncup (n+3) cx1) (cx1_in_S : cx1.in S)\n  {cy1 : list \u03b1} (cy1_cup : C.ncup (n+3) cy1) (cy1_in_S : cy1.in S)\n  {cy : list \u03b1} (cy_cup : C.ncup (n+2) cy) (cy_in_S : cy.in S)\n  (x : \u03b1) (cx_last : x \u2208 cx.last') (cx1_head : x \u2208 cx1.head')\n  (y : \u03b1) (cy1_last : y \u2208 cy1.last') (cy_head : y \u2208 cy.head') : \n  \u2203 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 \u2264 y\n  rcases cx1_cup.take_head_last with \u27e8x, cx1', z, eq_cx1, cx1'_cup\u27e9,\n  rw eq_cx1 at cx1_head, simp at cx1_head, subst cx1_head,\n  rcases cy1_cup.take_head_last with \u27e8w, cy1', y, eq_cy1, cy1'_cup\u27e9,\n  rw eq_cy1 at cy1_last, simp at cy1_last, subst cy1_last,\n  have z_in_S : z \u2208 S := by rw eq_cx1 at cx1_in_S; simp at cx1_in_S; tauto,\n  have w_in_S : w \u2208 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 \u27e8_, _, _\u27e9, 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 \u03b1) (n : \u2115)\n  (cap4_free : \u00acC.has_ncap 4 S) (cup_free : \u00acC.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  \u2203 p q r s, C.has_interweaved_laced (n+3) S p q r s := \nbegin\n  rcases hx with \u27e8x, cx, cx1, \n    \u27e8cx_cup, cx_in_S, cx_last\u27e9, \u27e8cx1_cup, cx1_in_S, cx1_head\u27e9\u27e9,\n  rcases hy with \u27e8y, cy1, cy, \n    \u27e8cy1_cup, cy1_in_S, cy1_last\u27e9, \u27e8cy_cup, cy_in_S, cy_head\u27e9\u27e9,\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: \u2200 (a b: Type) [add_comm_group a] [add_comm_group b], Type).\nparameter (Func_denote: \u2200 {a b: Type} [add_comm_group a] [add_comm_group b], Func a b \u2192 (a \u2192 b)).\n\ninductive ckt : \u2200 (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\u2081 b\u2081 a\u2082 b\u2082: Type}\n  [add_comm_group a\u2081] [add_comm_group a\u2082] [add_comm_group b\u2081] [add_comm_group b\u2082]\n  (f1: ckt a\u2081 b\u2081) (f2: ckt a\u2082 b\u2082) : ckt (a\u2081 \u00d7 a\u2082) (b\u2081 \u00d7 b\u2082)\n| feedback {a b: Type} [add_comm_group a] [add_comm_group b]\n  (F: ckt (a \u00d7 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 \u2192 stream b) :=\nbegin\n  -- unfreezingI { revert_deps a b, revert a b, },\n  -- apply (@ckt.rec (\u03bb {a b: Type} [_i1: add_comm_group a] [_i2: add_comm_group b] (f: @ckt a b _i1 _i2), (stream a \u2192 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^\u0394, },\n  { resetI, apply \u2191\u2191(Func_denote c_f), },\n  { -- seq\n    exact (\u03bb a, c_ih_f2 (c_ih_f1 a)), },\n  { -- par\n     resetI,\n     apply (uncurry_op (\u03bb x1 x2, sprod (c_ih_f1 x1, c_ih_f2 x2))), },\n  { -- feedback\n    resetI,\n    intros s,\n    apply fix (\u03bb \u03b1, c_ih (sprod (s, z\u207b\u00b9 \u03b1))),\n  },\n  -- { resetI, exact \u2191\u2191\u03b40, },\n  -- { resetI, exact \u2191\u2191stream_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 \u2192 f2 === f1 :=\n  by { unfold equiv, cc, }.\n\n@[trans]\nlemma equiv_trans (f1 f2 f3: ckt a b) : f1 === f2 \u2192 f2 === f3 \u2192 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) = \u03bb 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 (\u03bb 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)^\u0394 := 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) = \u2191\u2191(Func_denote f) := rfl.\n\n-- @[simp]\n-- lemma denote_ckt_lift (f: ckt a b) :\n--   denote (ckt.ckt_lift f) = \u2191\u2191(denote f) := rfl.\n\n@[simp]\nlemma denote_feedback (F: ckt (a \u00d7 b) b) :\n  denote (ckt.feedback F) = \u03bb s, fix (\u03bb \u03b1, denote F (sprod (s, z\u207b\u00b9 \u03b1))) := rfl.\n\n-- @[simp]\n-- lemma denote_intro :\n--   denote (@ckt.intro a _) = \u2191\u2191\u03b40 := rfl.\n--\n-- @[simp]\n-- lemma stream_elim_intro :\n--   denote (@ckt.elim a _) = \u2191\u2191\u222b := 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 \u2192 b \u2192 c) : ckt (a \u00d7 b) c :=\n  ckt.lifting (\u03bb xy, f xy.1 xy.2).\n\ndef derivative : ckt a a :=\n  ckt.lifting (\u03bb a, (a, a)) >>> ckt.par (ckt.lifting id) ckt.delay >>>\n  ckt.lifting2 (\u03bb 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 (\u03bb 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 _ (\u03bb (s: stream f_a) (\u03b1: stream f_b), ckt.denote f_F (sprod (s, \u03b1)))),\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 \u2192 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)^\u0394 :=\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: \u03a0 {a b: Type} [inst1: add_comm_group a] [inst2: add_comm_group b],\n      @ckt a b inst1 inst2 \u2192 option (@ckt a b inst1 inst2)).\n\ninclude opt\ndef recursive_opt : ckt a b \u2192 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 \u00d7 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: \u2200 {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 \u2192\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  \u2200 (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: \u2200 {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: \u2200 {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 \u2192\n            \u2200 (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^\u0394\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 \u00d7 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)^\u0394 :=\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 (\u03bb s \u03b1, denote _ @Func_denote f_F (sprod (s, \u03b1))),\n    { dsimp,\n      rw f_ih,\n      funext s,\n      congr' 1, funext \u03b1,\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 \u27f6 Y.X)\n(comm : X.e \u226b f = f \u226b Y.e)\n\nattribute [reassoc, simp] hom.comm\n\ninstance (C : Type u) [category.{v} C] : quiver (endomorphisms C) :=\n{ hom := \u03bb X Y, hom X Y }\n\nlemma f_injective (X Y : endomorphisms C) : function.injective (hom.f : (X \u27f6 Y) \u2192 (X.X \u27f6 Y.X)) :=\nby { intros f g h, ext, exact h }\n\nprotected def id (X : endomorphisms C) : X \u27f6 X :=\n{ f := \ud835\udfd9 _,\n  comm := by rw [category.comp_id, category.id_comp] }\n\nprotected def comp {X Y Z : endomorphisms C} (f : X \u27f6 Y) (g : Y \u27f6 Z) : X \u27f6 Z :=\n{ f := f.f \u226b 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 := \u03bb X, X.id,\n  comp := \u03bb X Y Z f g, endomorphisms.comp f g }\n\n@[simp] lemma id_f (X : endomorphisms C) : hom.f (\ud835\udfd9 X) = \ud835\udfd9 X.X := rfl\n\n@[simps]\ndef end_of_e (X : endomorphisms C) : X \u27f6 X := \u27e8X.e, rfl\u27e9\n\nlemma end_of_e_comm {X Y : endomorphisms C} (g : X \u27f6 Y) : X.end_of_e \u226b g =\n  g \u226b Y.end_of_e :=\nby { ext, apply endomorphisms.hom.comm, }\n\n@[simp, reassoc] lemma comp_f {X Y Z : endomorphisms C} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  hom.f (f \u226b g) = f.f \u226b g.f := rfl\n\ninstance (C : Type u) [category.{v} C] : category (endomorphisms C) :=\n{ id_comp' := \u03bb X Y f, by { ext1, simp only [comp_f, id_f, category.id_comp] },\n  comp_id' := \u03bb X Y f, by { ext1, simp only [comp_f, id_f, category.comp_id] },\n  assoc' := \u03bb X Y Z W f g h, by { ext1, simp only [comp_f, category.assoc] } }\n\nlemma congr_f {X Y : endomorphisms C} (f\u2081 f\u2082 : X \u27f6 Y) (h : f\u2081 = f\u2082) : f\u2081.f = f\u2082.f := by rw h\n\n@[simp, reassoc] lemma pow_comm {X Y : endomorphisms C} (f : X \u27f6 Y) (n : \u2115) :\n  (X.e ^ n : End X.X) \u226b f.f = f.f \u226b (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 \u2964 C :=\n{ obj := \u03bb X, X.X,\n  map := \u03bb X Y f, f.f,\n  map_id' := \u03bb X, rfl,\n  map_comp' := \u03bb 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 \u27f6 Y) [epi f.f] : epi f :=\n{ left_cancellation := \u03bb Z g h w, begin\n    ext, rw [\u2190 cancel_epi f.f, \u2190 comp_f, w, comp_f],\n  end }\n\ndef mk_iso {X Y : endomorphisms C} (e : X.X \u2245 Y.X) (h : X.e \u226b e.hom = e.hom \u226b Y.e) : X \u2245 Y :=\n{ hom := \u27e8e.hom, h\u27e9,\n  inv := \u27e8e.inv, by rw [e.comp_inv_eq, category.assoc, e.eq_inv_comp, h]\u27e9,\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 \u2964 endomorphisms C}\n  (S : cone (K \u22d9 endomorphisms.forget C)) :\n  cone (K \u22d9 endomorphisms.forget C) :=\n{ X := S.X,\n  \u03c0 :=\n  { app := \u03bb j, S.\u03c0.app j \u226b (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 \u2964 endomorphisms C}\n  (S : cone (K \u22d9 endomorphisms.forget C)) (hS : is_limit S) :\n  S.X \u27f6 S.X :=\n@is_limit.lift J _ C _ (K \u22d9 endomorphisms.forget C) S hS (twist_cone S)\n\n@[simps]\nprotected def cone {K : J \u2964 endomorphisms C}\n  (S : cone (K \u22d9 endomorphisms.forget C)) (hS : is_limit S) :\n  cone K :=\n{ X :=\n  { X := S.X,\n    e := cone_e S hS },\n  \u03c0 :=\n  { app := \u03bb j,\n    { f := S.\u03c0.app _,\n      comm := by { dsimp, simp } },\n    naturality' := \u03bb i j f, begin\n      ext, dsimp, simp, erw S.w,\n    end } }\n\n@[simps]\nprotected def is_limit_cone {K : J \u2964 endomorphisms C}\n  (S : cone (K \u22d9 endomorphisms.forget C)) (hS : is_limit S) :\n  is_limit (endomorphisms.cone S hS) :=\n{ lift := \u03bb S,\n  { f := hS.lift \u27e8S.X.X,\n    { app := \u03bb j, (S.\u03c0.app _).f,\n      naturality' := begin\n        intros i j f,\n        dsimp,\n        simp [\u2190 comp_f],\n      end }\u27e9,\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 (\u03bb e, e.f) at hm,\n    dsimp at *, simp [hm],\n  end }\n\n.\n\nprotected def cone_iso {K : J \u2964 endomorphisms C} (S : cone K)\n  (hS : is_limit ((endomorphisms.forget C).map_cone S)) :\n  endomorphisms.cone _ hS \u2245 S :=\ncones.ext\n({ hom :=\n  { f := \ud835\udfd9 _,\n    comm := by { apply hS.hom_ext, intros j, dsimp, simp, erw hS.fac, dsimp, simp, } },\n  inv :=\n  { f := \ud835\udfd9 _,\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 \u2964 endomorphisms C}\n  (S : cone (K \u22d9 endomorphisms.forget C)) (hS : is_limit S) :\n  (endomorphisms.forget C).map_cone (endomorphisms.cone S hS) \u2245 S :=\ncones.ext\n(iso.refl _)\nbegin\n  intros j,\n  dsimp,\n  simp,\nend\n\ninstance has_limit (K : J \u2964 endomorphisms C) [has_limit (K \u22d9 endomorphisms.forget C)] :\n  has_limit K :=\n\u27e8\u27e8\u27e8_, endomorphisms.is_limit_cone _ (limit.is_limit _)\u27e9\u27e9\u27e9\n\ninstance has_limits_of_shape [has_limits_of_shape J C] :\n  has_limits_of_shape J (endomorphisms C) := \u27e8\u27e9\n\ninstance has_limits [has_limits C] : has_limits (endomorphisms C) := \u27e8\u27e9\n\ninstance creates_limit (K : J \u2964 endomorphisms C) : creates_limit K (endomorphisms.forget _) :=\n{ reflects := \u03bb S hS, is_limit.of_iso_limit (endomorphisms.is_limit_cone _ _)\n    (endomorphisms.cone_iso _ hS),\n  lifts := \u03bb S hS,\n  { lifted_cone := endomorphisms.cone _ hS,\n    valid_lift := endomorphisms.cone_iso' _ _ } }\n\ninstance preserves_limit (K : J \u2964 endomorphisms C) [has_limit (K \u22d9 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) := \u27e8\u27e9\n\ninstance preserves_limits [has_limits C] : preserves_limits (endomorphisms.forget C) := \u27e8\u27e9\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 \u2964 endomorphisms C}\n  (S : cocone (K \u22d9 endomorphisms.forget C)) :\n  cocone (K \u22d9 endomorphisms.forget C) :=\n{ X := S.X,\n  \u03b9 :=\n  { app := \u03bb j, (K.obj j).e \u226b S.\u03b9.app j,\n    naturality' := begin\n      intros i j f,\n      dsimp,\n      simp only [category.comp_id, \u2190 hom.comm_assoc],\n      erw S.w,\n    end } }\n\nabbreviation cocone_e {K : J \u2964 endomorphisms C}\n  (S : cocone (K \u22d9 endomorphisms.forget C)) (hS : is_colimit S) :\n  S.X \u27f6 S.X :=\n@is_colimit.desc J _ C _ (K \u22d9 endomorphisms.forget C) S hS (twist_cocone S)\n\n@[simps]\nprotected def cocone {K : J \u2964 endomorphisms C}\n  (S : cocone (K \u22d9 endomorphisms.forget C)) (hS : is_colimit S) :\n  cocone K :=\n{ X :=\n  { X := S.X,\n    e := cocone_e S hS },\n  \u03b9 :=\n  { app := \u03bb j,\n    { f := S.\u03b9.app j,\n      comm := by { dsimp, simp } },\n    naturality' := \u03bb i j f, begin\n      ext, dsimp, simp, erw S.w,\n    end } }\n\n@[simps]\nprotected def is_colimit_cocone {K : J \u2964 endomorphisms C}\n  (S : cocone (K \u22d9 endomorphisms.forget C)) (hS : is_colimit S) :\n  is_colimit (endomorphisms.cocone S hS) :=\n{ desc := \u03bb S,\n  { f := hS.desc \u27e8S.X.X,\n    { app := \u03bb j, (S.\u03b9.app j).f,\n      naturality' := begin\n        intros i j f,\n        dsimp,\n        simp [\u2190 comp_f],\n      end }\u27e9,\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 (\u03bb e, e.f) at hm,\n    dsimp at *, simp [hm],\n  end }\n\n.\n\nprotected def cocone_iso {K : J \u2964 endomorphisms C} (S : cocone K)\n  (hS : is_colimit ((endomorphisms.forget C).map_cocone S)) :\n  endomorphisms.cocone _ hS \u2245 S :=\ncocones.ext\n({ hom :=\n  { f := \ud835\udfd9 _,\n    comm := by { apply hS.hom_ext, intros j, dsimp, simp, erw hS.fac, dsimp, simp, } },\n  inv :=\n  { f := \ud835\udfd9 _,\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 \u2964 endomorphisms C}\n  (S : cocone (K \u22d9 endomorphisms.forget C)) (hS : is_colimit S) :\n  (endomorphisms.forget C).map_cocone (endomorphisms.cocone S hS) \u2245 S :=\ncocones.ext\n(iso.refl _)\nbegin\n  intros j,\n  dsimp,\n  simp,\nend\n\ninstance has_colimit (K : J \u2964 endomorphisms C) [has_colimit (K \u22d9 endomorphisms.forget C)] :\n  has_colimit K :=\n\u27e8\u27e8\u27e8_, endomorphisms.is_colimit_cocone _ (colimit.is_colimit _)\u27e9\u27e9\u27e9\n\ninstance has_colimits_of_shape [has_colimits_of_shape J C] :\n  has_colimits_of_shape J (endomorphisms C) := \u27e8\u27e9\n\ninstance has_colimits [has_colimits C] : has_colimits (endomorphisms C) := \u27e8\u27e9\n\ninstance creates_colimit (K : J \u2964 endomorphisms C) : creates_colimit K (endomorphisms.forget _) :=\n{ reflects := \u03bb S hS, is_colimit.of_iso_colimit (endomorphisms.is_colimit_cocone _ _)\n    (endomorphisms.cocone_iso _ hS),\n  lifts := \u03bb S hS,\n  { lifted_cocone := endomorphisms.cocone _ hS,\n    valid_lift := endomorphisms.cocone_iso' _ _ } }\n\ninstance preserves_colimit (K : J \u2964 endomorphisms C) [has_colimit (K \u22d9 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) := \u27e8\u27e9\n\ninstance preserves_colimits [has_colimits C] : preserves_colimits (endomorphisms.forget C) := \u27e8\u27e9\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} \u2115) C]\n\n/-- `free X` is \u2a01\u2099X, 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 \u2a02_{\u2124} \u2124[T]` with the endomorphism given by multiplication by `T`. -/\n@[simps]\ndef free (X : C) : endomorphisms C :=\n{ X := \u2210 (\u03bb i : ulift.{v} \u2115, X),\n  e := sigma.desc $ \u03bb i, sigma.\u03b9 (\u03bb i : ulift.{v} \u2115, X) \u27e8i.down + 1\u27e9 }\n\n@[reassoc] lemma free.\u03b9_comp_e (X : C) (i : ulift.{v} \u2115) :\n  sigma.\u03b9 (\u03bb i : ulift.{v} \u2115, X) i \u226b (free X).e = sigma.\u03b9 (\u03bb i : ulift.{v} \u2115, X) \u27e8i.down + 1\u27e9 :=\nbegin\n  dsimp, simp only [colimit.\u03b9_desc, cofan.mk_\u03b9_app],\nend\n\n@[ext] lemma free.ext {X : C} {A : endomorphisms C} (f g : free X \u27f6 A)\n  (w : sigma.\u03b9 (\u03bb i : ulift.{v} \u2115, X) \u27e80\u27e9 \u226b f.f = sigma.\u03b9 (\u03bb i : ulift.{v} \u2115, X) \u27e80\u27e9 \u226b g.f) :\n  f = g :=\nbegin\n  ext \u27e8\u27e8i\u27e9\u27e9, dsimp,\n  induction i with i ih, { exact w },\n  apply_fun (\u03bb \u03b1, \u03b1 \u226b A.e) at ih,\n  simp only [category.assoc, \u2190 hom.comm, free.\u03b9_comp_e_assoc] at ih,\n  exact ih,\nend\n\n/-- The map `free T \u27f6 A` in `endomorphisms C` induced by a map `T \u27f6 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 \u27f6 A.X) : free X \u27f6 A :=\n{ f := sigma.desc $ \u03bb i, f \u226b (A.e ^ i.down : End A.X),\n  comm := begin\n    ext1 \u27e8i\u27e9, dsimp,\n    simp only [colimit.\u03b9_desc_assoc, cofan.mk_\u03b9_app,\n      colimit.\u03b9_desc, category.assoc, pow_succ, End.mul_def],\n  end }\n\nlemma free.desc_comp {X : C} {A B : endomorphisms C} (f : X \u27f6 A.X) (g : A \u27f6 B) :\n  free.desc f \u226b g = free.desc (f \u226b g.f) :=\nbegin\n  ext1, dsimp,\n  simp only [colimit.\u03b9_desc_assoc, cofan.mk_\u03b9_app, colimit.\u03b9_desc, category.assoc, pow_comm],\nend\n\ndef free.map {X Y : C} (f : X \u27f6 Y) : free X \u27f6 free Y :=\n{ f := sigma.desc $ \u03bb i, f \u226b sigma.\u03b9 (\u03bb i : ulift.{v} \u2115, Y) i,\n  comm := begin\n    ext1 \u27e8i\u27e9,\n    dsimp,\n    simp only [colimit.\u03b9_desc_assoc, cofan.mk_\u03b9_app, colimit.\u03b9_desc, category.assoc],\n  end }\n\nvariable (C)\n\ndef functor.free : C \u2964 endomorphisms C :=\n{ obj := free,\n  map := \u03bb _ _, free.map,\n  map_id' := \u03bb X, begin ext, dsimp, simp only [free.map, category.id_comp, colimit.\u03b9_desc,\n    cofan.mk_\u03b9_app, category.comp_id], end,\n  map_comp' := \u03bb X Y Z f g, begin ext, dsimp, simp only [free.map, category.assoc, colimit.\u03b9_desc,\n    cofan.mk_\u03b9_app, colimit.\u03b9_desc_assoc], end }\n\nend free\n\nsection cofree\n\nvariable {C}\nvariable [has_products_of_shape (ulift.{v} \u2115) C]\n\n/-- `cofree X` is \u220f\u2099X, 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 := \u220f (\u03bb i : ulift.{v} \u2115, X),\n  e := pi.lift $ \u03bb i, pi.\u03c0 _ \u27e8i.down + 1\u27e9 }\n\ndef cofree.lift {X : C} {A : endomorphisms C} (f : A.X \u27f6 X) :\n  A \u27f6 cofree X :=\n{ f := pi.lift $ \u03bb i, (A.e ^ i.down : End A.X) \u226b f,\n  comm := begin\n    dsimp [cofree],\n    ext \u27e8\u27e8j\u27e9\u27e9, dsimp,\n    simp only [category.assoc, limit.lift_\u03c0, fan.mk_\u03c0_app],\n    rw [\u2190 category.assoc, pow_succ, \u2190 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} \u2115) C] [has_coproducts_of_shape (ulift.{v} \u2115) C]\n\nlemma f_epi {X Y : endomorphisms C} (f : X \u27f6 Y) [epi f] : epi f.f :=\n{ left_cancellation := \u03bb Z g h w, begin\n    let gg : Y \u27f6 cofree Z := cofree.lift g,\n    let hh : Y \u27f6 cofree Z := cofree.lift h,\n    have : f \u226b gg = f \u226b hh,\n    { ext, dsimp [gg, hh, cofree.lift], simp,\n      simp_rw [\u2190 category.assoc, \u2190 pow_comm, category.assoc, w] },\n    rw cancel_epi at this,\n    apply_fun (\u03bb e, e.f \u226b pi.\u03c0 (\u03bb i : ulift.{v} \u2115, 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 \u27f6 Y) [mono f] : mono f.f :=\n{ right_cancellation := \u03bb Z g h w, begin\n    let gg : free Z \u27f6 X := free.desc g,\n    let hh : free Z \u27f6 X := free.desc h,\n    have : gg \u226b f = hh \u226b f,\n    { ext, dsimp [gg,hh, free.desc], simpa },\n    rw cancel_mono at this,\n    apply_fun (\u03bb e, sigma.\u03b9 ((\u03bb i : ulift.{v} \u2115, Z)) (ulift.up 0) \u226b 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 := \u03bb E Y f e he, begin\n    resetI,\n    let \u03c6 : X \u27f6 Y.X := sigma.\u03b9 (\u03bb i : ulift.{v} \u2115, X) \u27e80\u27e9 \u226b f.f,\n    haveI : epi e.f := f_epi _,\n    use free.desc (projective.factor_thru \u03c6 e.f),\n    rw [free.desc_comp, projective.factor_thru_comp],\n    ext1, dsimp, simp only [colimit.\u03b9_desc, cofan.mk_\u03b9_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.\u03c0 _,\n  epi := begin\n    suffices : epi (free.desc (projective.\u03c0 A.X)).f,\n    { resetI, apply epi_of_epi_f },\n    dsimp,\n    refine @epi_of_epi _ _ _ _ _ (sigma.\u03b9 _ _) _ (id _), { exact \u27e80\u27e9 },\n    simp only [colimit.\u03b9_desc, cofan.mk_\u03b9_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 := \u03bb A, \u27e8free.presentation A\u27e9 }\n\n-- generalize to colimits\ninstance projective_sigma {C \u03b9 : Type*} [category C] (P : \u03b9 \u2192 C) [has_coproduct P]\n  [\u2200 i, projective (P i)] :\n  projective (\u2210 P) :=\n{ factors := begin\n  introsI E X f e he,\n  let \u03c6 : \u2210 P \u27f6 E := sigma.desc (\u03bb i, projective.factor_thru (sigma.\u03b9 _ _ \u226b f) e),\n  refine \u27e8\u03c6, _\u27e9,\n  ext \u27e8i\u27e9,\n  rw [limits.colimit.\u03b9_desc_assoc, limits.cofan.mk_\u03b9_app, projective.factor_thru_comp],\nend }\n\ninstance projective_X [enough_projectives C] (P : endomorphisms C) [projective P] :\n  projective P.X :=\n\u27e8\u03bb 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 \u27f6 F.P := projective.factor_thru (\ud835\udfd9 _) F.f,\n  have hs\u03c0 : s \u226b F.f = \ud835\udfd9 _ := projective.factor_thru_comp _ _,\n  let X' : endomorphisms C := \u27e8X, \ud835\udfd9 _\u27e9,\n  let E' : endomorphisms C := \u27e8E, \ud835\udfd9 _\u27e9,\n  let e' : E' \u27f6 X' := \u27e8e, by { dsimp only, rw [category.id_comp, category.comp_id] }\u27e9,\n  haveI he' : epi e' := epi_of_epi_f e',\n  let \u03c6 : F.P.X \u27f6 E := projective.factor_thru (F.f.f \u226b f) e,\n  refine \u27e8s.f \u226b \u03c6, _\u27e9,\n  rw [category.assoc, projective.factor_thru_comp, \u2190 comp_f_assoc, hs\u03c0, id_f, category.id_comp],\nend\u27e9\n\nend projectives\n\nsection preadditive\nopen category_theory.preadditive\n\nvariables {\ud835\udcd0 : Type u} [category.{v} \ud835\udcd0] [preadditive \ud835\udcd0]\nvariables (X Y : endomorphisms \ud835\udcd0)\n\ninstance : has_zero (X \u27f6 Y) := \u27e8\u27e80, by simp only [comp_zero, zero_comp, hom.comm]\u27e9\u27e9\ninstance : has_add (X \u27f6 Y) := \u27e8\u03bb f g, \u27e8f.f + g.f, by simp only [comp_add, add_comp, hom.comm]\u27e9\u27e9\ninstance : has_sub (X \u27f6 Y) := \u27e8\u03bb f g, \u27e8f.f - g.f, by simp only [comp_sub, sub_comp, hom.comm]\u27e9\u27e9\ninstance : has_neg (X \u27f6 Y) := \u27e8\u03bb f, \u27e8-f.f, by simp only [comp_neg, neg_comp, hom.comm]\u27e9\u27e9\ninstance has_nsmul : has_smul \u2115 (X \u27f6 Y) := \u27e8\u03bb n f, \u27e8n \u2022 f.f, by simp only [comp_nsmul, nsmul_comp, hom.comm]\u27e9\u27e9\ninstance has_zsmul : has_smul \u2124 (X \u27f6 Y) := \u27e8\u03bb n f, \u27e8n \u2022 f.f, by simp only [comp_zsmul, zsmul_comp, hom.comm]\u27e9\u27e9\n\ninstance : add_comm_group (X \u27f6 Y) :=\n(f_injective X Y).add_comm_group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\n@[simp] lemma zero_f : hom.f (0 : X \u27f6 Y) = 0 := rfl\nvariables {X Y} (f g : X \u27f6 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 : \u2115) (f : X \u27f6 Y) : (n \u2022 f).f = n \u2022 f.f := rfl\n@[simp] lemma zsmul_f (n : \u2124) (f : X \u27f6 Y) : (n \u2022 f).f = n \u2022 f.f := rfl\n\nvariables (\ud835\udcd0)\n\ninstance : preadditive (endomorphisms \ud835\udcd0) :=\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 \ud835\udcd0).additive := {}\n\ninstance functor.free_additive [has_coproducts_of_shape (ulift.{v} \u2115) \ud835\udcd0] :\n  (functor.free \ud835\udcd0).additive := \u27e8\u03bb X Y f g, by { delta functor.free free.map,\n    ext, simp, }\u27e9\n\nlemma is_zero_X {X : endomorphisms \ud835\udcd0} (h : is_zero X) : is_zero X.X :=\nby { rw is_zero_iff_id_eq_zero at h \u22a2, apply_fun (\u03bb a, a.f) at h, exact h }\n\nend preadditive\n\nsection abelian\n\nvariables {\ud835\udcd0 : Type u} [category.{v} \ud835\udcd0] [abelian \ud835\udcd0]\n  {X Y : endomorphisms \ud835\udcd0} (f : X \u27f6 Y)\n\n@[simps]\nprotected def kernel_obj : endomorphisms \ud835\udcd0 :=\n{ X := kernel f.f,\n  e := kernel.lift _ (kernel.\u03b9 _ \u226b X.e) (by simp) }\n\n@[simps]\nprotected def kernel_\u03b9 : endomorphisms.kernel_obj f \u27f6 X :=\n{ f := kernel.\u03b9 _,\n  comm := by { dsimp, simp } }\n\nprotected def kernel_fork : kernel_fork f :=\nkernel_fork.of_\u03b9 (endomorphisms.kernel_\u03b9 f) $ by { ext, dsimp, simp }\n\n@[simp]\nprotected lemma kernel_fork_\u03b9_f :\n  (endomorphisms.kernel_fork f).\u03b9.f = kernel.\u03b9 _ := rfl\n\n@[simps]\nprotected def kernel_lift (s : kernel_fork f) :\n  s.X \u27f6 endomorphisms.kernel_obj f :=\n{ f := kernel.lift _ s.\u03b9.f $ by { rw [\u2190 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(\u03bb s, endomorphisms.kernel_lift f s)\n(\u03bb s, by { ext, dsimp, simp })\n(\u03bb s m hm, by { apply_fun (\u03bb e, e.f) at hm, ext, dsimp at *, simp [hm] } )\n\ninstance has_kernels : has_kernels (endomorphisms \ud835\udcd0) :=\n\u27e8\u03bb X Y f, \u27e8\u27e8\u27e8endomorphisms.kernel_fork _, endomorphisms.is_limit_kernel_fork _\u27e9\u27e9\u27e9\u27e9\n\n@[simps]\nprotected def cokernel_obj : endomorphisms \ud835\udcd0 :=\n{ X := cokernel f.f,\n  e := cokernel.desc _ (Y.e \u226b cokernel.\u03c0 _) $\n    by { simp only [\u2190 (reassoc_of f.comm), cokernel.condition, comp_zero] } }\n\n@[simps]\nprotected def cokernel_\u03c0 : Y \u27f6 endomorphisms.cokernel_obj f :=\n{ f := cokernel.\u03c0 _,\n  comm := by simp }\n\nprotected def cokernel_cofork : cokernel_cofork f :=\ncokernel_cofork.of_\u03c0 (endomorphisms.cokernel_\u03c0 f) $ by { ext, dsimp, simp }\n\n@[simp]\nprotected lemma cokernel_cofork_\u03c0_f :\n  (endomorphisms.cokernel_cofork f).\u03c0.f = cokernel.\u03c0 _ := rfl\n\n@[simps]\nprotected def cokernel_desc (s : cokernel_cofork f) :\n  endomorphisms.cokernel_obj f \u27f6 s.X :=\n{ f := cokernel.desc _ s.\u03c0.f $ by { rw [\u2190 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(\u03bb s, endomorphisms.cokernel_desc f s)\n(\u03bb s, by { ext, dsimp, simp })\n(\u03bb s m hm, by { apply_fun (\u03bb e, e.f) at hm, ext, dsimp at *, simp [hm] })\n\ninstance has_cokernels : has_cokernels (endomorphisms \ud835\udcd0) :=\n\u27e8\u03bb X Y f, \u27e8\u27e8\u27e8endomorphisms.cokernel_cofork _, endomorphisms.is_colimit_cokernel_cofork _\u27e9\u27e9\u27e9\u27e9\n\ndef kernel_fork_iso :\n  endomorphisms.kernel_fork f \u2245 kernel_fork.of_\u03b9 (endomorphisms.kernel_\u03b9 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_\u03b9 f.f (cokernel.condition _))) :\n  is_limit (limits.kernel_fork.of_\u03b9 f (endomorphisms.cokernel_cofork _).condition) :=\nis_limit_aux _\n(\u03bb S,\n{ f := hF.lift (kernel_fork.of_\u03b9 S.\u03b9.f begin\n    change _ \u226b (endomorphisms.cokernel_cofork _).\u03c0.f = _,\n    erw [\u2190 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 (\u03bb 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_\u03c0 f.f (kernel.condition _))) :\n  is_colimit (limits.cokernel_cofork.of_\u03c0 f (endomorphisms.kernel_fork _).condition) :=\nis_colimit_aux _\n(\u03bb S,\n{ f := hF.desc (cokernel_cofork.of_\u03c0 S.\u03c0.f begin\n    change (endomorphisms.kernel_fork _).\u03b9.f \u226b _ = _,\n    erw [\u2190 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 [\u2190 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 (\u03bb 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} \u2115) \ud835\udcd0] [has_products_of_shape (ulift.{v} \u2115) \ud835\udcd0] :\n  abelian (endomorphisms \ud835\udcd0) :=\n{ normal_mono_of_mono := begin\n    introsI X Y f _,\n    haveI := f_mono f,\n    let hE : is_limit (kernel_fork.of_\u03b9 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_\u03c0 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_\u03c0 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_\u03b9 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 \ud835\udcd0 := abelian.has_finite_products, -- WHY IS THIS NEEDED!?\n    constructor,\n  end,\n  .. (_ : preadditive (endomorphisms \ud835\udcd0)) }\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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\n\nnamespace category_theory\n\n/--\nA braided monoidal category is a monoidal category equipped with a braiding isomorphism\n`\u03b2_ X Y : X \u2297 Y \u2245 Y \u2297 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             : \u03a0 X Y : C, X \u2297 Y \u2245 Y \u2297 X)\n(braiding_naturality' : \u2200 {X X' Y Y' : C} (f : X \u27f6 Y) (g : X' \u27f6 Y'),\n  (f \u2297 g) \u226b (braiding Y Y').hom = (braiding X X').hom \u226b (g \u2297 f) . obviously)\n-- hexagon identities:\n(hexagon_forward'     : \u03a0 X Y Z : C,\n    (\u03b1_ X Y Z).hom \u226b (braiding X (Y \u2297 Z)).hom \u226b (\u03b1_ Y Z X).hom\n  = ((braiding X Y).hom \u2297 (\ud835\udfd9 Z)) \u226b (\u03b1_ Y X Z).hom \u226b ((\ud835\udfd9 Y) \u2297 (braiding X Z).hom)\n  . obviously)\n(hexagon_reverse'     : \u03a0 X Y Z : C,\n    (\u03b1_ X Y Z).inv \u226b (braiding (X \u2297 Y) Z).hom \u226b (\u03b1_ Z X Y).inv\n  = ((\ud835\udfd9 X) \u2297 (braiding Y Z).hom) \u226b (\u03b1_ X Z Y).inv \u226b ((braiding X Z).hom \u2297 (\ud835\udfd9 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 `\u03b2_` := 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\u00e9 Joyal and Ross Street,\n  \"Braided monoidal categories\", Macquarie Math Reports 860081 (1986).\n* Proposition 2.1 of Andr\u00e9 Joyal and Ross Street,\n  \"Braided tensor categories\" , Adv. Math. 102 (1993), 20\u201378.\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\u2081) [category.{v\u2081} C] [monoidal_category C] [braided_category C]\n\nlemma braiding_left_unitor_aux\u2081 (X : C) :\n  (\u03b1_ (\ud835\udfd9_ C) (\ud835\udfd9_ C) X).hom \u226b (\ud835\udfd9 _ \u2297 (\u03b2_ X (\ud835\udfd9_ C)).inv) \u226b (\u03b1_ _ X _).inv \u226b ((\u03bb_ X).hom \u2297 \ud835\udfd9 _) =\n  ((\u03bb_ _).hom \u2297 \ud835\udfd9 X) \u226b (\u03b2_ X _).inv :=\nby { rw [\u2190left_unitor_tensor, left_unitor_naturality], simp, }\n\nlemma braiding_left_unitor_aux\u2082 (X : C) :\n  ((\u03b2_ X (\ud835\udfd9_ C)).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C))) \u226b ((\u03bb_ X).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C))) = (\u03c1_ X).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C)) :=\ncalc ((\u03b2_ X (\ud835\udfd9_ C)).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C))) \u226b ((\u03bb_ X).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C)))\n    = ((\u03b2_ X (\ud835\udfd9_ C)).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C))) \u226b (\u03b1_ _ _ _).hom \u226b (\u03b1_ _ _ _).inv \u226b\n        ((\u03bb_ X).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C)))\n         : by simp\n... = ((\u03b2_ X (\ud835\udfd9_ C)).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C))) \u226b (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 _ \u2297 (\u03b2_ X _).hom) \u226b\n        (\ud835\udfd9 _ \u2297 (\u03b2_ X _).inv) \u226b (\u03b1_ _ _ _).inv \u226b ((\u03bb_ X).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C)))\n         : by { slice_rhs 3 4 { rw [\u2190id_tensor_comp, iso.hom_inv_id, tensor_id], }, rw [id_comp], }\n... = (\u03b1_ _ _ _).hom \u226b (\u03b2_ _ _).hom \u226b\n        (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 _ \u2297 (\u03b2_ X _).inv) \u226b (\u03b1_ _ _ _).inv \u226b ((\u03bb_ X).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C)))\n         : by { slice_lhs 1 3 { rw \u2190hexagon_forward }, simp only [assoc], }\n... = (\u03b1_ _ _ _).hom \u226b (\u03b2_ _ _).hom \u226b ((\u03bb_ _).hom \u2297 \ud835\udfd9 X) \u226b (\u03b2_ X _).inv\n         : by rw braiding_left_unitor_aux\u2081\n... = (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 _ \u2297 (\u03bb_ _).hom) \u226b (\u03b2_ _ _).hom \u226b (\u03b2_ X _).inv\n         : by { slice_lhs 2 3 { rw [\u2190braiding_naturality] }, simp only [assoc], }\n... = (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 _ \u2297 (\u03bb_ _).hom)\n         : by rw [iso.hom_inv_id, comp_id]\n... = (\u03c1_ X).hom \u2297 (\ud835\udfd9 (\ud835\udfd9_ C))\n         : by rw triangle\n\n@[simp]\nlemma braiding_left_unitor (X : C) : (\u03b2_ X (\ud835\udfd9_ C)).hom \u226b (\u03bb_ X).hom = (\u03c1_ X).hom :=\nby rw [\u2190tensor_right_iff, comp_tensor_id, braiding_left_unitor_aux\u2082]\n\nlemma braiding_right_unitor_aux\u2081 (X : C) :\n  (\u03b1_ X (\ud835\udfd9_ C) (\ud835\udfd9_ C)).inv \u226b ((\u03b2_ (\ud835\udfd9_ C) X).inv \u2297 \ud835\udfd9 _) \u226b (\u03b1_ _ X _).hom \u226b (\ud835\udfd9 _ \u2297 (\u03c1_ X).hom) =\n  (\ud835\udfd9 X \u2297 (\u03c1_ _).hom) \u226b (\u03b2_ _ X).inv :=\nby { rw [\u2190right_unitor_tensor, right_unitor_naturality], simp, }\n\nlemma braiding_right_unitor_aux\u2082 (X : C) :\n  ((\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03b2_ (\ud835\udfd9_ C) X).hom) \u226b ((\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03c1_ X).hom) = (\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03bb_ X).hom :=\ncalc ((\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03b2_ (\ud835\udfd9_ C) X).hom) \u226b ((\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03c1_ X).hom)\n    = ((\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03b2_ (\ud835\udfd9_ C) X).hom) \u226b (\u03b1_ _ _ _).inv \u226b (\u03b1_ _ _ _).hom \u226b\n        ((\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03c1_ X).hom)\n         : by simp\n... = ((\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03b2_ (\ud835\udfd9_ C) X).hom) \u226b (\u03b1_ _ _ _).inv \u226b ((\u03b2_ _ X).hom \u2297 \ud835\udfd9 _) \u226b\n        ((\u03b2_ _ X).inv \u2297 \ud835\udfd9 _) \u226b (\u03b1_ _ _ _).hom \u226b ((\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03c1_ X).hom)\n         : by { slice_rhs 3 4 { rw [\u2190comp_tensor_id, iso.hom_inv_id, tensor_id], }, rw [id_comp], }\n... = (\u03b1_ _ _ _).inv \u226b (\u03b2_ _ _).hom \u226b\n        (\u03b1_ _ _ _).inv \u226b ((\u03b2_ _ X).inv \u2297 \ud835\udfd9 _) \u226b (\u03b1_ _ _ _).hom \u226b ((\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03c1_ X).hom)\n         : by { slice_lhs 1 3 { rw \u2190hexagon_reverse }, simp only [assoc], }\n... = (\u03b1_ _ _ _).inv \u226b (\u03b2_ _ _).hom \u226b (\ud835\udfd9 X \u2297 (\u03c1_ _).hom) \u226b (\u03b2_ _ X).inv\n         : by rw braiding_right_unitor_aux\u2081\n... = (\u03b1_ _ _ _).inv \u226b ((\u03c1_ _).hom \u2297 \ud835\udfd9 _) \u226b (\u03b2_ _ X).hom \u226b (\u03b2_ _ _).inv\n         : by { slice_lhs 2 3 { rw [\u2190braiding_naturality] }, simp only [assoc], }\n... = (\u03b1_ _ _ _).inv \u226b ((\u03c1_ _).hom \u2297 \ud835\udfd9 _)\n         : by rw [iso.hom_inv_id, comp_id]\n... = (\ud835\udfd9 (\ud835\udfd9_ C)) \u2297 (\u03bb_ X).hom\n         : by rw [triangle_assoc_comp_right]\n\n@[simp]\nlemma braiding_right_unitor (X : C) : (\u03b2_ (\ud835\udfd9_ C) X).hom \u226b (\u03c1_ X).hom = (\u03bb_ X).hom :=\nby rw [\u2190tensor_left_iff, id_tensor_comp, braiding_right_unitor_aux\u2082]\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' : \u2200 X Y : C, (\u03b2_ X Y).hom \u226b (\u03b2_ Y X).hom = \ud835\udfd9 (X \u2297 Y) . obviously)\n\nrestate_axiom symmetric_category.symmetry'\nattribute [simp,reassoc] symmetric_category.symmetry\n\nvariables (C : Type u\u2081) [category.{v\u2081} C] [monoidal_category C] [braided_category C]\nvariables (D : Type u\u2082) [category.{v\u2082} D] [monoidal_category D] [braided_category D]\nvariables (E : Type u\u2083) [category.{v\u2083} 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' : \u2200 X Y : C, \u03bc X Y \u226b map (\u03b2_ X Y).hom = (\u03b2_ (obj X) (obj Y)).hom \u226b \u03bc 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) := \u27e8id C\u27e9\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' := \u03bb X Y,\n  begin\n    dsimp,\n    slice_lhs 2 3 { rw [\u2190category_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} {\u03b1 : F \u27f6 G} {\u03b2 : G \u27f6 H} :\n  (\u03b1 \u226b \u03b2).to_nat_trans =\n    @category_struct.comp (C \u2964 D) _ _ _ _ (\u03b1.to_nat_trans) (\u03b2.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 \u2245 G.to_lax_monoidal_functor) : F \u2245 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 `\u03bc X Y` to the right hand side,\n-- so that this makes a good `@[simp]` lemma.\n(braided' :\n  \u2200 X Y : C, map (\u03b2_ X Y).hom = inv (\u03bc X Y) \u226b (\u03b2_ (obj X) (obj Y)).hom \u226b \u03bc 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' := \u03bb 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) := \u27e8id C\u27e9\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} {\u03b1 : F \u27f6 G} {\u03b2 : G \u27f6 H} :\n  (\u03b1 \u226b \u03b2).to_nat_trans =\n    @category_struct.comp (C \u2964 D) _ _ _ _ (\u03b1.to_nat_trans) (\u03b2.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 \u2245 G.to_monoidal_functor) : F \u2245 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 := \u03bb 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 \u2192* 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 \u2192 F\nvariable  \u03c3 : 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 \u03c3.pc\n    (h_mem : mem_at mem code_verify_zero \u03c3.pc)\n    -- input arguments on the stack\n    (hin_range_check_ptr : range_check_ptr = mem (\u03c3.fp - 6))\n    (hin_val : val = cast_UnreducedBigInt3 mem (\u03c3.fp - 5))\n    -- conclusion\n  : ensures_ret mem \u03c3 (\u03bb \u03ba \u03c4,\n      \u03c4.ap = \u03c3.ap + 11 \u2227\n      \u2203 \u03bc \u2264 \u03ba, rc_ensures mem (rc_bound F) \u03bc (mem (\u03c3.fp - 6)) (mem $ \u03c4.ap - 1)\n        (spec_verify_zero mem \u03ba range_check_ptr val (mem (\u03c4.ap - 1)))) :=\nbegin\n  apply ensures_of_ensuresb, intro \u03bdbound,\n  have h_mem_rec := h_mem,\n  unpack_memory code_verify_zero at h_mem with \u27e8hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12, hpc13, hpc14, hpc15, hpc16, hpc17, hpc18, hpc19, hpc20, hpc21, hpc22\u27e9,\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 : \u2124) : F) = r1,\n  have hl_r1 := hl_rev_r1.symm, clear hl_rev_r1,\n  have htv_r1: r1 = _, {\n    have h_\u03b43_c0 : \u2200 x : F, x / (BASE : \u2124) = x * (-46768052394588894761721767695234645457402928824320 : \u2124),\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_\u03b43_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 : \u2124) : F) = r2,\n  have hl_r2 := hl_rev_r2.symm, clear hl_rev_r2,\n  have htv_r2: r2 = _, {\n    have h_\u03b411_c0 : \u2200 x : F, x / (BASE : \u2124) = x * (-46768052394588894761721767695234645457402928824320 : \u2124),\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_\u03b411_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_\u03b417_c0 : ((BASE : \u2124) / (4 : \u2124) : F) = (19342813113834066795298816 : \u2124),\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 : \u2124) / (4 : \u2124)) - r2, {\n    try { simp only [h_\u03b417_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\u2081: (range_check_ptr + 3 : F) = range_check_ptr\u2081,\n  have hl_range_check_ptr\u2081 := hl_rev_range_check_ptr\u2081.symm, clear hl_rev_range_check_ptr\u2081,\n  try { dsimp at hl_range_check_ptr\u2081 }, try { arith_simps at hl_range_check_ptr\u2081 },\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\u2081 := range_checked_offset' rc_h_range_check_ptr,\n  have rc_h_range_check_ptr\u2081' := range_checked_add_right rc_h_range_check_ptr\u2081,try { norm_cast at rc_h_range_check_ptr\u2081' },\n  use_only [range_check_ptr\u2081, hl_range_check_ptr\u2081],\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\u2081] }, },\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 := \u03bb _, unit,\n  res := \u03bb _ _ _ _, (),\n  Hid := \u03bb U, by {funext x, cases x, refl},\n  Hcomp := \u03bb U V W _ _, rfl,\n  Fring := \u03bb x, punit.comm_ring,\n  res_is_ring_hom := \u03bb U V _,\n  { map_one := rfl,\n    map_mul := \u03bb  _ _, rfl,\n    map_add := \u03bb _ _, rfl },\n  Ftop := \u03bb U, by apply_instance,\n  Ftop_ring := \u03bb U, by apply_instance,\n  res_continuous := \u03bb 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 _ _ \u27e8s\u27e9 \u27e8t\u27e9 _, refl},\n  gluing := by {intros _ _ c _, use (), intro i, cases c i, refl},\n  homeo :=\n  begin\n    rintros \u27e8U, HU\u27e9 \u27e8\u03b3, Uis, _\u27e9 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 \u27e8s, hs\u27e9,\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 := \u03bb U,\n  { complete := \u03bb 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 \u27e8\u27e9,\n  local_stalks := by rintro \u27e8\u27e9,\n  supp_maximal := by rintro \u27e8\u27e9 }\n\nexample : PerfectoidSpace \u27e837, by norm_num\u27e9 := \u27e8CLVRS.empty, by rintro \u27e8\u27e9\u27e9\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": "open tactic\nopen lean.parser\nopen interactive\n\n\n\n\nnamespace tactic.interactive\n\n\nopen lean\nopen lean.parser\n\nprivate meta def resolve_name' (n : name) : tactic expr :=\ndo {\n  p \u2190 resolve_name n,\n  match p.to_raw_expr with\n  | expr.const n _           := mk_const n -- create metavars for universe levels\n  | _                        := i_to_expr p\n  end\n}\n\nprivate meta def to_expr' (p : pexpr) : tactic expr :=\nlet e := p.to_raw_expr in\nmatch e with\n| (expr.const c [])          := do new_e \u2190 resolve_name' c, save_type_info new_e e, return new_e\n| (expr.local_const c _ _ _) := do new_e \u2190 resolve_name' c, save_type_info new_e e, return new_e\n| _                     := i_to_expr p\nend\n\nprivate meta def rw_goal_gos (m : transparency) (r : rw_rule) : tactic unit :=\nsave_info r.pos >> to_expr' r.rule >>= rewrite_core m tt tt occurrences.all r.symm\n\n\n\n  meta def rewrite_nth (r : parse ident) (n : nat) : tactic unit :=\n  do e \u2190 tactic.mk_const r,\n    tactic.rewrite_core reducible tt tt (occurrences.pos [n]) tt r\nend tactic.interactive\n\nlemma foo (p : 1 = 2): [ 1,1,1,2,1 ] = [ 1,1,2,2,1 ] :=\nbegin\ninduction p,\n  rewrite_nth p 3,\nend", "meta": {"author": "semorrison", "repo": "proof", "sha": "5ee398aa239a379a431190edbb6022b1a0aa2c70", "save_path": "github-repos/lean/semorrison-proof", "path": "github-repos/lean/semorrison-proof/proof-5ee398aa239a379a431190edbb6022b1a0aa2c70/lean/20170410-rewrite_nth.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5195213219520929, "lm_q2_score": 0.4186969093556867, "lm_q1q2_score": 0.21752197184572197}}
{"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 : \u2115) (b : \u2115) : \u2124 \u2192 \u2115 \u00d7 \u2115 :=\n  sorry\n\nnamespace fp\n\n\nstructure rmode \n  NE ::\nwhere\n\nclass float_cfg \nwhere\n  prec : \u2115\n  emax : \u2115\n  prec_pos : 0 < prec\n  prec_max : prec \u2264 emax\n\ndef prec [C : float_cfg] : \u2115 :=\n  float_cfg.prec\n\ndef emax [C : float_cfg] : \u2115 :=\n  float_cfg.emax\n\ndef emin [C : float_cfg] : \u2124 :=\n  1 - \u2191float_cfg.emax\n\ndef valid_finite [C : float_cfg] (e : \u2124) (m : \u2115) :=\n  emin \u2264 e + \u2191prec - 1 \u2227 e + \u2191prec - 1 \u2264 \u2191emax \u2227 e = max (e + \u2191(nat.size m) - \u2191prec) emin\n\nprotected instance dec_valid_finite [C : float_cfg] (e : \u2124) (m : \u2115) : Decidable (valid_finite e m) :=\n  eq.mpr sorry and.decidable\n\ninductive float [C : float_cfg] \nwhere\n| inf : Bool \u2192 float\n| nan : float\n| finite : Bool \u2192 (e : \u2124) \u2192 (m : \u2115) \u2192 valid_finite e m \u2192 float\n\ndef float.is_finite [C : float_cfg] : float \u2192 Bool :=\n  sorry\n\ndef to_rat [C : float_cfg] (f : float) : \u21a5(float.is_finite f) \u2192 \u211a :=\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 \u2192 semiquot Bool :=\n  sorry\n\nprotected def float.sign [C : float_cfg] : float \u2192 Bool :=\n  sorry\n\nprotected def float.is_zero [C : float_cfg] : float \u2192 Bool :=\n  sorry\n\nprotected def float.neg [C : float_cfg] : float \u2192 float :=\n  sorry\n\ndef div_nat_lt_two_pow [C : float_cfg] (n : \u2115) (d : \u2115) : \u2124 \u2192 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 \u27f6 Z) (g : Y \u27f6 Z)\nvariable (hg : \u2200 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 \u27f6 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 \u27f6 _).1.base\n    (pullback.snd : pullback f g \u27f6 _).1.base\n    (by simp only [\u2190 Scheme.comp_val_base, pullback.condition]))\n\nlemma pullback_comparison_comp_pullback_iso_prod_subtype_inv :\n  pullback_comparison f g \u226b (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 \u27f6 Z) (g : Y \u27f6 Z) (x : X.carrier) (y : Y.carrier)\n  (h : f.1.base x = g.1.base y) : pullback.triplet f g :=\n\u27e8x, y, _, h, rfl\u27e9\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 \u27f6 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    (\u03bb 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) \u27f6 X :=\n(pullback f (Z.affine_cover.map i.1)).affine_cover.map i.2.1 \u226b 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) \u27f6 Y :=\n(pullback g (Z.affine_cover.map i.1)).affine_cover.map i.2.2 \u226b 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) \u27f6 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) \u27f6\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 \u226b pullback.snd\n\ndef pullback_affine_cover_map_snd : \n  Scheme.Spec.obj (op $ pullback_affine_cover_ring_right f g i) \u27f6\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 \u226b 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 \u2245 Scheme.Spec.obj (op $ pullback_affine_cover_ring f g i) :=\nbegin\n  refine (as_iso $ pullback.map _ _ _ _ (\ud835\udfd9 _) (\ud835\udfd9 _) (\ud835\udfd9 _) _ _) \u226a\u226b pullback_symmetry _ _ \u226a\u226b\n    limit.iso_limit_cone \u27e8_, ((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\u27e9,\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 \u226b 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_\u03c0 \u27e8_, ((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\u27e9 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 \u226b 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_\u03c0 \u27e8_, ((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\u27e9 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 \u226b pullback_affine_cover_map_base f g i =\n    pullback_affine_cover_map_left f g i \u226b 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 \u226b pullback_affine_cover_map_base f g i =\n    pullback_affine_cover_map_right f g i \u226b 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  \u2203 i : (pullback_affine_cover f g).J, T.1 \u2208 (pullback_affine_cover_map_left f g i).opens_range \u2227 \n    T.2 \u2208 (pullback_affine_cover_map_right f g i).opens_range :=\nbegin\n  let i := Z.affine_cover.f T.z,\n  obtain \u27e8x, hx\u27e9 : T.x \u2208 (pullback.fst : pullback f (Z.affine_cover.map i) \u27f6 _).opens_range,\n  { rw [\u2190 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 \u27e8y, hy\u27e9 : T.y \u2208 (pullback.fst : pullback g (Z.affine_cover.map i) \u27f6 _).opens_range,\n  { rw [\u2190 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 \u27e8\u27e8i, x, y\u27e9, _, _\u27e9,\n  { obtain \u27e8x', hx'\u27e9 := (pullback f (Z.affine_cover.map i)).affine_cover.covers x,\n    conv_lhs { rw [\u2190 hx, \u2190 hx'] }, exact \u27e8x', rfl\u27e9 },\n  { obtain \u27e8y', hy'\u27e9 := (pullback g (Z.affine_cover.map i)).affine_cover.covers y,\n    conv_lhs { rw [\u2190 hy, \u2190 hy'] }, exact \u27e8y', rfl\u27e9 },\nend\n\nnoncomputable!\ndef pullback_Top_open_cover : opens (types.pullback_obj f.1.base g.1.base) :=\n\u27e8_, \u27e8_, (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\u27e9\u27e9  \n\nlemma pullback_Top_open_cover_supr :\n  supr (pullback_Top_open_cover f g) = \u22a4 :=\nbegin\n  rw eq_top_iff,\n  rintro \u27e8\u27e8x, y\u27e9, e\u27e9 -,\n  obtain \u27e8i, \u27e8x', rfl : _ = x\u27e9, \u27e8y', rfl : _ = y\u27e9\u27e9 :=\n    pullback_affine_cover_f_exists _ _ (pullback.triplet_mk f g x y e),\n  refine opens.mem_supr.mpr \u27e8i, \u27e8x', rfl\u27e9, \u27e8y', rfl\u27e9\u27e9\nend\n\nnoncomputable!\ndef pullback_Top_open_cover_preimage_homeo :\n  pullback_comparison f g \u207b\u00b9' (pullback_Top_open_cover f g i).1 \u2243\u209c\n    prime_spectrum (pullback_affine_cover_ring f g i) :=\nbegin\n  have : pullback_comparison f g \u207b\u00b9' (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 \u2243\u209c 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 \u27e8\u27e8\u27e8x, y\u27e9, e\u27e9, rfl\u27e9,\n      refine \u27e8\u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, \u27e8x, rfl\u27e9, \u27e8y, rfl\u27e9\u27e9, rfl\u27e9,\n      change (pullback_affine_cover_map_left f g i \u226b f).1.base x = \n        (pullback_affine_cover_map_right f g i \u226b g).1.base y,\n      simp only [ring_hom.algebra_map_to_algebra, \u2190 Scheme.Spec_map_val_base,\n        quiver.hom.op_unop, functor.image_preimage] at e,\n      rw [\u2190 pullback_affine_cover_map_fst_base, \u2190 pullback_affine_cover_map_snd_base,\n        Scheme.comp_val_base_apply, Scheme.comp_val_base_apply, e] },\n    { rintros \u27e8\u27e8\u27e8\u27e8x', y'\u27e9, e\u27e9, \u27e8x, (rfl : _ = x')\u27e9, \u27e8y, (rfl : _ = y')\u27e9\u27e9, rfl\u27e9,\n      refine \u27e8\u27e8\u27e8x, y\u27e9, _\u27e9, rfl\u27e9,\n      change (pullback_affine_cover_map_left f g i \u226b f).1.base x = \n        (pullback_affine_cover_map_right f g i \u226b 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, \u2190 Scheme.Spec_map_val_base,\n        quiver.hom.op_unop, functor.image_preimage, \u2190 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 {\u03b1 \u03b2 \u03b3 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n  [topological_space \u03b3] (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b2 \u2243\u209c \u03b3) (x) :\n  (h\u2081.trans h\u2082).symm x = h\u2081.symm (h\u2082.symm x) := rfl\n\nlemma homeomorph.symm_symm_apply {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n  (h : \u03b1 \u2243\u209c \u03b2) (x) : h.symm.symm x = h x := rfl \n\nlemma homeomorph.symm_apply_eq {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n  (h : \u03b1 \u2243\u209c \u03b2) {x y} : h.symm x = y \u2194 x = h y := h.to_equiv.symm_apply_eq\n\nlemma homeomorph.coe_set_congr_symm {\u03b1 : Type*} [topological_space \u03b1] (s t : set \u03b1)\n  (h : s = t) (x) : ((homeomorph.set_congr h).symm x : \u03b1) = x := rfl\n\nlemma homeomorph.coe_of_embedding {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n  (f : \u03b1 \u2192 \u03b2) (hf : embedding f) {x} : (homeomorph.of_embedding f hf x : \u03b2) = f x := rfl\n\nlemma Scheme.forget_to_Top_map' {X Y : Scheme} (f : X \u27f6 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 \u2218 prime_spectrum.tensor_product_to _ _ _ \u2218\n      pullback_Top_open_cover_preimage_homeo f g i :=\nbegin\n  rw [eq_comm, \u2190 (pullback_Top_open_cover_preimage_homeo f g i).coe_to_equiv, \n    \u2190 function.comp.assoc, \u2190 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, \u2190 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)) \u226b\n        pullback_affine_cover_map_left f g i).1.base x = _,\n    erw \u2190 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, \u2190 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)) \u226b\n        pullback_affine_cover_map_right f g i).1.base x = _,\n    erw \u2190 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 \u2245 CommRing.of R :=\n\u27e8ring_hom.id R, ring_hom.id R, rfl, rfl\u27e9\n\ndef Spec.stalk_map_iso {R S : CommRing.{u}} (f : R \u27f6 S) (x) :\n  arrow.mk (PresheafedSpace.stalk_map (Scheme.Spec.map f.op).val x) \u2245 \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 \u2190 cancel_epi (structure_sheaf.to_stalk R (prime_spectrum.comap f x)),\n  rw [structure_sheaf.stalk_iso_hom, \u2190 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    \u2190 Spec_\u0393_naturality'_assoc f, \u2190 category.assoc (to_Spec_\u0393 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 \u27f6 S) :\n  f.surjective_on_stalks \u2194\n    \u2200 x, function.surjective (PresheafedSpace.stalk_map (Scheme.Spec.map f.op).1 x) :=\nbegin\n  delta ring_hom.surjective_on_stalks,\n  have := \u03bb 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 \u27e8\u03bb H x, H x.as_ideal, \u03bb H x hx, H \u27e8x, hx\u27e9\u27e9\nend\n\nlemma Scheme.open_cover.exists_covers {X : Scheme} (\ud835\udcb0 : X.open_cover) (x : X.carrier) :\n  \u2203 i (y : (\ud835\udcb0.obj i).carrier), (\ud835\udcb0.map i).1.base y = x :=\n\u27e8_, \ud835\udcb0.covers x\u27e9\n\nlemma Scheme.comp_val' {X Y Z : Scheme.{u}} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b 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 \u27f6 _).1 x) :=\nbegin\n  obtain \u27e8i, y, rfl\u27e9 := (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 \u2190 PresheafedSpace.stalk_map.comp,\n  change morphism_property.surjective _ (PresheafedSpace.stalk_map\n    ((pullback_affine_cover f g).map i \u226b 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    \u2190 (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 _ \u27e8x, hx\u27e9)).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 \u2190 PresheafedSpace.stalk_map.comp,\n  change morphism_property.surjective _ (PresheafedSpace.stalk_map\n    (pullback_affine_cover_map_snd f g i \u226b 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 (\u03bb 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 \u2190 PresheafedSpace.stalk_map.comp,\n  convert_to function.surjective\n    (PresheafedSpace.stalk_map ((_ \u226b pullback.snd) \u226b Z.affine_cover.map i.1).1 x),\n  rw [category.assoc, \u2190 pullback.condition, \u2190 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 \u226b 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 \u2190 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 \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  let A : set (euclidean_space \u211d (fin n)), from sorry,\n  have H_A_open : open A, from sorry,\n  let B_0 : set (euclidean_space \u211d (fin n)), from sorry,\n  have H_B_0_empty : B_0 = \u2205, from sorry,\n  let B_n : set (euclidean_space \u211d (fin n)), from sorry,\n  have H_B_n_closed : is_closed B_n, from sorry,\n  have H_\u211dn_compact : is_compact \u211dn, from sorry,\n  let C_m : set (euclidean_space \u211d (fin n)), from sorry,\n  have H_C_m_open : open C_m, from sorry,\n  let C : set (euclidean_space \u211d (fin n)), from sorry,\n  have H_C_open : open C, from sorry,\n  have H_C_cover : \u211dn \u2286 \u22c3\u2080 C, from sorry,\n  have H_C_open_refinement : \ud835\udcaa A \u2286 \u22c3\u2080 C, from sorry,\n  have H_C_loc_finite : \u2200 (x : \u211dn), is_locally_finite (\u03bb (U : set (euclidean_space \u211d (fin n))), x \u2208 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 \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  intros A hA,\n  show \u2203 C : \u03b9 \u2192 set (euclidean_space \u211d (fin n)), \u2200 c \u2208 C, is_open c \u2227 \u2200 c \u2208 C, \u2203 U \u2208 A, c \u2286 U \u2227 \u2200 c' \u2208 C, c' \u2260 c \u2192 c' \u2229 c = \u2205, from by {\n    have h1 : \u2200 m : \u2115, \u2203 C\u2098 : \u03b9 \u2192 set (euclidean_space \u211d (fin n)), \u2200 c \u2208 C\u2098, is_open c \u2227 \n      \u2200 c \u2208 C\u2098, \u2203 U \u2208 A, c \u2286 U \u2227 \u2200 c' \u2208 C\u2098, c' \u2260 c \u2192 c' \u2229 c = \u2205, from sorry,\n    let C := \u03bb i : \u03b9, classical.some (h1 (i : \u2115)),\n    show \u2203 C : \u03b9 \u2192 set (euclidean_space \u211d (fin n)), \u2200 c \u2208 C, is_open c \u2227 \u2200 c \u2208 C, \u2203 U \u2208 A, c \u2286 U \u2227 \u2200 c' \u2208 C, c' \u2260 c \u2192 c' \u2229 c = \u2205, from sorry,\n  },  \nend\n\n--OUTPUT 3\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n    assume A : set (euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n))),\n    assume H : is_open_cover A,\n    let A1 := (\u03bb (a : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n))),\n        if h : a.U \u2208 A then \u27e8{ x | a.U.1 x \u2227 euclidean_space \u211d (fin n) \u2264 a.U.2 + (1 : \u211d) \u2227 euclidean_space \u211d (fin n) \u2265 a.U.2 - (1 : \u211d)}, h\u27e9 else \u27e8{ x // false }, _\u27e9),\n    have h1 : \u2200 a : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), (euclidean_space \u211d (fin n)) \u2208 A \u2227 (euclidean_space \u211d (fin n)) \u2208 a.U.1 \u2192 \u2203 c : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), c \u2208 A1 \u2227 c.U.1 < a.U.1, from sorry,\n    have h2 : \u2200 a : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), (euclidean_space \u211d (fin n)) \u2208 A \u2227 (euclidean_space \u211d (fin n)) \u2208 a.U.1 \u2192 \u2203 c : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), c \u2208 A1 \u2227 a.U.1 < c.U.1, from sorry,\n    have h3 : \u2200 a : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), (euclidean_space \u211d (fin n)) \u2208 A \u2192 \u2203 c : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), c \u2208 A1, from sorry,\n    have h4 : \u2200 a : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), (euclidean_space \u211d (fin n)) \u2208 A \u2192 \u2203 c : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), c \u2208 A1, from sorry,\n    have h5 : \u2200 a : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), (euclidean_space \u211d (fin n)) \u2208 A \u2227 (euclidean_space \u211d (fin n)) \u2208 a.U.1 \u2192 \u2203 c : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), c \u2208 A1 \u2227 c.U.1 < a.U.1 \u2192 \u2203 c : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), c \u2208 A1 \u2227 c.U.1 < a.U.1 \u2227 c.U.1 \u2208 a.U.1, from sorry,\n    have h6 : \u2200 a : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), (euclidean_space \u211d (fin n)) \u2208 A \u2227 (euclidean_space \u211d (fin n)) \u2208 a.U.1 \u2192 \u2203 c : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), c \u2208 A1 \u2227 c.U.1 < a.U.1 \u2227 c.U.1 \u2208 a.U.1 \u2192 \u2203 c : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), c \u2208 A1 \u2227 c.U.1 < a.U.1 \u2227 c.U.1 \u2208 a.U.1 \u2227 c.U.2 > a.U.2, from sorry,\n    have h7 : \u2200 a : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), (euclidean_space \u211d (fin n)) \u2208 A \u2227 (euclidean_space \u211d (fin n)) \u2208 a.U.1 \u2192 \u2203 c : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n)), c \u2208 A1 \u2227 c.U.1 < a.U.1 \u2227 c.U.1 \u2208 a.U.1 \u2227 c.U.2 > a.U.2, from sorry,\n    have h8 : \u2200 a : euclidean_space.sheaf.cover_data (euclidean_space \u211d (fin n))\nend\n\n--OUTPUT 4\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  intro U,\n  by_cases h : nonempty (euclidean_space \u211d (fin n)),\n  have h2 : U \u2286 \u22c3\u2080 U, from Union_of_Union_of_Elements_of_Union h,\n  have h3 : \u2200 x \u2208 U, \u2203 T : set (euclidean_space \u211d (fin n)), x \u2208 T \u2227 is_open T \u2227 T \u2208 U, from @elements_of_Union_of_set_is_Union_of_Elements_of_Union (euclidean_space \u211d (fin n)) _ _ U h2 (nonempty.choose h) h2,\n  let V := {T : set (euclidean_space \u211d (fin n)) | (\u2203x\u2208U, x\u2208T) \u2227 is_open T},\n  have h4 : V \u2286 \u22c3\u2080U, from Union_of_Union_of_Elements_of_Union h,\n  have h5 : \u2203 T : set (euclidean_space \u211d (fin n)), x \u2208 T \u2227 is_open T \u2227 T \u2208 V, from @elements_of_Union_of_set_is_Union_of_Elements_of_Union (euclidean_space \u211d (fin n)) _ _ V h4 (nonempty.choose h) h4,\n  show \u2203 V : set (euclidean_space \u211d (fin n)), is_open V \u2227 x \u2208 V \u2227 \u2200 (T : set (euclidean_space \u211d (fin n))), T \u2208 V \u2192 T \u2208 U, from @elements_of_Union_of_set_is_Union_of_Elements_of_Union (euclidean_space \u211d (fin n)) _ _ V h4 (nonempty.choose h) h4,\nend\n\n--OUTPUT 5\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (U : opens (euclidean_space \u211d (fin n))),\n  assume hU : is_open_cover U,\n  have h_U\u2080 : (\u2200 (V : opens (euclidean_space \u211d (fin n))), V \u2208 U \u2192 (V \u2260 \u2205)), from sorry,\n\n  have h_B\u2080 : (\u2200 V : opens (euclidean_space \u211d (fin n)), V \u2208 U \u2192 (\u211dn.ball 0 0 = \u2205)), from sorry,\n\n  have h_B\u2081 : (\u2200 m : \u2115, (\u211dn.ball 0 m \u2260 \u2205)), from sorry,\n\n  have h_B\u2082 : (\u2200 m : \u2115, (\u211dn.ball 0 m \u2208 U \u2192 \u211dn.ball 0 m \u2286 \u211dn.ball 0 (m + 1))), from sorry, -- \u2286 \u2482 \u2286\u2081\n\n  have h_B\u2083 : (\u2200 m : \u2115, (\u211dn.ball 0 m \u2208 U \u2192 \u211dn.ball 0 m \u2260 \u211dn.ball 0 (m + 1))), from sorry, -- \u2260 \u2482 \u2260\u2081\n\n  have h_R\u2081 : (\u2200 (m : \u2115) (x : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 m \u2192 \u2203 (N : \u2115), (m \u2264 N) \u2227 (x \u2208 \u211dn.ball 0 N))), from sorry,\n\n  have h_R\u2082 : (\u2200 (m : \u2115) (x : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 m \u2192 \u2203 (N : \u2115), (m \u2264 N) \u2227 (x \u2208 \u211dn.ball 0 N) \u2227 (\u2200 (n : \u2115), (m \u2264 n) \u2192 (n \u2264 N) \u2192 (x \u2208 \u211dn.ball 0 n)))), from sorry,\n\n  have h_R\u2083 : (\u2200 (m : \u2115) (x : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 m \u2192 (\u2200 (n : \u2115), (m \u2264 n) \u2192 (n \u2264 m + 1) \u2192 (x \u2208 \u211dn.ball 0 n)))), from sorry,\n\n  have h_R\u2084 : (\u2200 (m : \u2115) (x : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 m \u2192 (\u2203 (y : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 (m+1) \u2227 x \u2208 \u211dn.ball y 1) \u2227 (\u2200 (n : \u2115), (m \u2264 n) \u2192 (n \u2264 m + 1) \u2192 (x \u2208 \u211dn.ball 0 n))))), from sorry,\n\n  have h_R\u2085 : (\u2200 (m : \u2115) (x : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 m \u2192 (\u2203 (y : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 (m+1) \u2227 x \u2208 \u211dn.ball y 1) \u2227 (\u2200 (n : \u2115) (z : \u211d ^ (fin n)), (m \u2264 n) \u2192 (n \u2264 m + 1) \u2192 (z \u2208 \u211dn.ball 0 n) \u2192 (z \u2208 \u211dn.ball y 1))))), from sorry,\n\n  have h_R\u2086 : (\u2200 m : \u2115, (\u2203 (y : \u211d ^ (fin n)), (m \u2208 \u2115) \u2227 (\u2203 (x : \u211d ^ (fin n)), x \u2208 \u211dn.ball 0 (m+1) \u2227 x \u2208 \u211dn.ball y 1) \u2227 (\u2200 (n : \u2115) (z : \u211d ^ (fin n)), (m \u2264 n) \u2192 (n \u2264 m + 1) \u2192 (z \u2208 \u211dn.ball 0 n) \u2192 (z \u2208 \u211dn.ball y 1)))), from sorry,\n\n  have h_R\u2087 : (\u2200 (m : \u2115) (x y : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 m \u2192 x \u2208 \u211dn.ball y 1 \u2192 \u2203 (n : \u2115), (m \u2264 n) \u2227 (n \u2264 m + 1) \u2227 (x \u2208 \u211dn.ball 0 n))), from sorry,\n\n  have h_R\u2088 : (\u2200 (m : \u2115) (x y : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 m \u2192 x \u2208 \u211dn.ball y 1 \u2192 \u2203 (n : \u2115), (m \u2264 n) \u2227 (n \u2264 m + 1) \u2227 (x \u2208 \u211dn.ball 0 n) \u2227 (\u2200 (k : \u2115), (m \u2264 k) \u2192 (k \u2264 n) \u2192 (x \u2208 \u211dk.ball 0 k)))), from sorry,\n\n  have h_R\u2089 : (\u2200 (m : \u2115) (x y : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 m \u2192 x \u2208 \u211dn.ball y 1 \u2192 (\u2200 (k : \u2115), (m \u2264 k) \u2192 (k \u2264 m + 1) \u2192 (x \u2208 \u211dk.ball 0 k)))), from sorry,\n\n  have h_R\u2081\u2080 : (\u2200 m : \u2115, \u2203 (y : \u211d ^ (fin n)), (\u2203 (x : \u211d ^ (fin n)), x \u2208 \u211dn.ball 0 (m+1) \u2227 x \u2208 \u211dn.ball y 1) \u2227 (\u2200 (k : \u2115) (z : \u211d ^ (fin n)), (m \u2264 k) \u2192 (k \u2264 m + 1) \u2192 (z \u2208 \u211dk.ball 0 k) \u2192 (z \u2208 \u211dn.ball y 1))), from sorry,\n\n  have h_R\u2081\u2081 : (\u2200 (m : \u2115) (y z : \u211d ^ (fin n)), (\u2203 (x : \u211d ^ (fin n)), x \u2208 \u211dn.ball 0 (m+1) \u2227 x \u2208 \u211dn.ball y 1) \u2192 (\u2200 (k : \u2115) (w : \u211d ^ (fin n)), (m \u2264 k) \u2192 (k \u2264 m + 1) \u2192 (w \u2208 \u211dk.ball 0 k) \u2192 (w \u2208 \u211dn.ball y 1)) \u2192 (\u2203 (n : \u2115), (m \u2264 n) \u2227 (n \u2264 m + 1) \u2227 (z \u2208 \u211dn.ball 0 n)))), from sorry,\n\n  have h_R\u2081\u2082 : (\u2200 (m : \u2115) (y z : \u211d ^ (fin n)), (\u2203 (x : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 (m+1) \u2227 x \u2208 \u211dn.ball y 1)) \u2192 (\u2200 (k : \u2115) (w : \u211d ^ (fin n)), (m \u2264 k) \u2192 (k \u2264 m + 1) \u2192 (w \u2208 \u211dk.ball 0 k) \u2192 (w \u2208 \u211dn.ball y 1)) \u2192 (\u2203 (n : \u2115), (m \u2264 n) \u2227 (n \u2264 m + 1) \u2227 (z \u2208 \u211dn.ball 0 n) \u2227 (\u2200 (p : \u2115), (m \u2264 p) \u2192 (p \u2264 n) \u2192 (z \u2208 \u211dp.ball 0 p)))), from sorry,\n\n  have h_R\u2081\u2083 : (\u2200 (m : \u2115) (y z : \u211d ^ (fin n)), (\u2203 (x : \u211d ^ (fin n)), (x \u2208 \u211dn.ball 0 (m+1) \u2227 x \u2208 \u211dn.ball y 1)) \u2192 (\u2200 (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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 (\u22a5) := 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 {\u0393 : list form} {\u03c6 \u03c8 : form} : \u0393 \u22a2 (\u03c6 \u2283 \u03c6) \u2192 (\u03c8 \u2283 \u03c8) \u2194 \u0393 \u22a2 \u03c6 \u2192 \u03c8 := 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 \u211d 1)} {hA : is_compact A} : B \u2286 A \u2192 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 : \u2115 \u2192 X} {M : X} (hM : \u2200 n, x n \u2264 M) : is_limit x M \u2192 \u2200 n, x n \u2264 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 \u2286 J \u2192 I \u2286 \u22a5 := 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 = \u22c2\u2080 {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 \u2260 \u22a5 := 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 \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) := \nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : A \u2243\u1d49 \u211dn),\n  have h1 : \u2200 m : \u2115, \u2203 C : set (euclidean_space \u211d (fin n)), \n    (\u2200 x \u2208 \u211dn, exists i : fin n, x i \u2264 m \u2227 \u2203 i : fin n, m \u2264 x i) \u2192\n    (\u2200 j \u2264 m, \ud835\udcdd x j \u2286 (\u22c3 i \u2208 C, \u22c3 j \u2208 A, \ud835\udcdd x i \u2229 \ud835\udcdd x j)) \u2192\n    C \u2208 finset.powerset A \u2227 C.finite,\n  { assume m,\n    have h2 : \u2203 C : set (euclidean_space \u211d (fin n)), C \u2208 finset.powerset A \u2227 C.finite, \n    from sorry,\n    have h3 : \u2200 j \u2264 m, \ud835\udcdd x j \u2286 (\u22c3 i \u2208 C, \u22c3 j \u2208 A, \ud835\udcdd x i \u2229 \ud835\udcdd x j), from sorry,\n    have h4 : \u2200 x \u2208 \u211dn, exists i : fin n, x i \u2264 m \u2227 \u2203 i : fin n, m \u2264 x i, from sorry,\n    show \u2203 C : set (euclidean_space \u211d (fin n)), \n      (\u2200 x \u2208 \u211dn, exists i : fin n, x i \u2264 m \u2227 \u2203 i : fin n, m \u2264 x i) \u2192\n      (\u2200 j \u2264 m, \ud835\udcdd x j \u2286 (\u22c3 i \u2208 C, \u22c3 j \u2208 A, \ud835\udcdd x i \u2229 \ud835\udcdd x j)) \u2192\n      C \u2208 finset.powerset A \u2227 C.finite, from sorry,\n  },\n  have h5 : \u2200 j : \u2115, \u2200 x : \u211dn, x \u2208 \u211dn \u2192 \ud835\udcdd x j \u2286 (\u22c3 s \u2208 ((\u22c3 m \u2208 \u2115, classical.some (h1 m)) : set (euclidean_space \u211d (fin n))), \u22c3 t \u2208 A, \ud835\udcdd x s \u2229 \ud835\udcdd x t), from sorry,\n  have h6 : (\u22c3 m \u2208 \u2115, classical.some (h1 m)) \u2208 finset.powerset A \u2227 ((\u22c3 m \u2208 \u2115, classical.some (h1 m)) : set (euclidean_space \u211d (fin n))).finite, from sorry,\n  show \u2203 C : set (euclidean_space \u211d (fin n)), \n    (C \u2243\u1d48\u2081 \u211dn) \u2227 \n    (\u22c3 t \u2208 C, \ud835\udcdd x t) \u2243\u1d48\u2082 \u211dn \u2227 \n    C \u2208 finset.powerset A \u2227 C.finite, from sorry,\nend\n\n--OUTPUT 8\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  let B0 : \u211d\u1d4f := (0 : \u211d\u1d4f),\n  let B1 : \u211d\u1d4f := (1 : \u211d\u1d4f),\n  let A : set (set (euclidean_space \u211d (fin n))) := {s | \u2203 x : \u211d\u1d4f, s = (euclidean_space.ball x \u211d B1 : set (euclidean_space \u211d (fin n)))},\n  have h1 : is_open (\u22c3\u2080 A), sorry,\n  let C := (\u03bb (x : \u211d\u1d4f), { s | \u2203 y : \u211d\u1d4f, x \u2208 (euclidean_space.ball y \u211d B1 : set (euclidean_space \u211d (fin n))) \u2227 s = (euclidean_space.ball y \u211d B1 : set (euclidean_space \u211d (fin n)))} : set (euclidean_space \u211d (fin n)) \u2192 set (set (euclidean_space \u211d (fin n)))),\n  have h2 : \u2200 x : \u211d\u1d4f, is_open (C x), sorry,\n  have h3 : is_open (\u22c3\u2080 A), from sorry,\n  have h4 : is_open (\u22c3\u2080 (C (0 : \u211d\u1d4f))), from sorry,\n  \n  have h5 : (0 : \u211d\u1d4f) \u2208 euclidean_space.ball B0 \u211d B1, by { sorry },\n  have h6 : (0 : \u211d\u1d4f) \u2208 euclidean_space.ball (0 : \u211d\u1d4f) \u211d B1, by { sorry },\n  have h7 : (0 : \u211d\u1d4f) \u2208 (\u22c3\u2080 A), from sorry,\n\n  let Cm := (\u03bb (m : \u2115), { s | \u2203 y : \u211d\u1d3e\u1d50, finset.prod y B1 < m \u2227 s = (euclidean_space.ball y \u211d B1 : set (euclidean_space \u211d (fin n)))} : set (euclidean_space \u211d (fin n)) \u2192 set (set (euclidean_space \u211d (fin n)))),\n  have h8 : \u2200 m : \u2115, is_open (Cm m), sorry,\n  have h9 : is_open (\u22c3\u2080 (Cm 1)), from sorry,\n\n  let Cm := (\u03bb (m : \u2115), { s | \u2203 y : \u2115, finset.prod y B1 < m \u2227 s = (euclidean_space.ball y \u211d B1 : set (euclidean_space \u211d (fin n)))} : set (euclidean_space \u211d (fin n)) \u2192 set (set (euclidean_space \u211d (fin n)))),\n  have h10 : \u2200 m : \u2115, is_open (Cm m), sorry,\n  have h11 : is_open (\u22c3\u2080 (Cm 1)), from sorry,\n\n  have h12 : is_open (\u22c3 (m : \u2115) (h : m < (1 : \u2115)), Cm m), from sorry,\n\n  show paracompact_space (euclidean_space \u211d (fin n)), from sorry,\nend\n\n--OUTPUT 9\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) := \nbegin\n    sorry\nend\n\n--OUTPUT 10\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  show (paracompact_space (euclidean_space \u211d (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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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  \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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": "/-\nCopyright (c) 2019 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Y. Lewis\n-/\nimport data.set.basic\nimport algebra.category.Mon.basic\n\ndef X : Type := set \u2115\n\ninstance : has_coe_to_sort X Type := set.has_coe_to_sort\n\n@[derive ring] def T := \u2124\n\nclass binclass (T1 T2 : Type)\n\ninstance : binclass \u2124 \u2124 := \u27e8\u27e9\n\n@[derive [ring, binclass \u2124]] def U := \u2124\n\n@[derive \u03bb \u03b1, binclass \u03b1 \u2124] def V := \u2124\n\n-- test instance naming\nexample := U.ring\nexample := U.binclass\nexample := V.binclass\n\n@[derive ring] def id_ring (\u03b1) [ring \u03b1] : Type := \u03b1\n\n@[derive decidable_eq] def S := \u2115\n\n@[derive decidable_eq] inductive P | a | b | c\n\nopen category_theory\n\n-- Test that `delta_instance` works in the presence of universe metavariables.\nattribute [derive large_category] Mon\n\n-- test deriving instances on function types\n@[derive monad]\nmeta def my_tactic : Type \u2192 Type :=\ntactic\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/delta_instance.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5964331462646254, "lm_q2_score": 0.3629691917376783, "lm_q1q2_score": 0.21648685702523152}}
{"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 {\u03b1 : Type v} (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] : cofan X := cofan.mk\n{ val := (homotopy_category.colimit_cofan $ \u03bb a : \u03b1, (X a).val).X,\n  bdd := begin\n    obtain \u27e8n,hn\u27e9 := homotopy_category.is_uniformly_bounded_above.cond (val \u2218 X),\n      use n, intros i hi,\n    dsimp [homotopy_category.colimit_cofan],\n    let e : (\u2210 \u03bb (a : \u03b1), (X a).val.as).X i \u2245\n      (\u2210 \u03bb (a : \u03b1), (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(\u03bb a, (homotopy_category.colimit_cofan _).\u03b9.app a)\n\nnoncomputable\ndef is_colimit_cofan {\u03b1 : Type v} (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] : is_colimit (cofan X) :=\n{ desc := \u03bb S, (homotopy_category.is_colimit_cofan\n    (\u03bb a : \u03b1, (X a).val)).desc ((forget A).map_cocone S),\n  fac' := begin\n    intros S j,\n    erw (homotopy_category.is_colimit_cofan (\u03bb a : \u03b1, (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 (\u03bb a : \u03b1, (X a).val)).hom_ext,\n    intros j,\n    specialize hm j,\n    erw hm,\n    erw (homotopy_category.is_colimit_cofan (\u03bb a : \u03b1, (X a).val)).fac,\n    refl,\n  end }\n\ninstance has_coproduct_of_uniform_bound {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] :\n  has_coproduct X :=\nbegin\n  constructor, apply nonempty.intro,\n  refine \u27e8cofan X, is_colimit_cofan X\u27e9,\nend\n\ninstance is_K_projective_sigma {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  [\u2200 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) \u2245 (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 {\u03b1 : Type v}\n  (X : \u03b1 \u2192 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) \u2245\n    homotopy_category.colimit_cofan (val \u2218 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  {\u03b1 : Type v}\n  (X P : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  [uniformly_bounded P]\n  (\u03c0 : \u03a0 a, P a \u27f6 X a)\n  [\u2200 a, homotopy_category.is_quasi_iso (\u03c0 a)] :\n  homotopy_category.is_quasi_iso\n    (sigma.desc $ \u03bb a : \u03b1, \u03c0 a \u226b sigma.\u03b9 X a : sigma_obj P \u27f6 sigma_obj X) :=\nbegin\n  let t := sigma.desc (\u03bb (a : \u03b1), \u03c0 a \u226b sigma.\u03b9 X a),\n  change homotopy_category.is_quasi_iso ((forget A).map t),\n  let eP : (forget A).obj (\u2210 P) \u2245 \u2210 (\u03bb a, (forget A).obj (P a)) :=\n    preserves_colimit_iso (forget A) _,\n  let eX : (forget A).obj (\u2210 X) \u2245 \u2210 (\u03bb a, (forget A).obj (X a)) :=\n    preserves_colimit_iso (forget A) _,\n  let s : \u2210 (\u03bb a, (forget A).obj (P a)) \u27f6 \u2210 (\u03bb a, (forget A).obj (X a)) :=\n    sigma.desc (\u03bb (a : \u03b1), \u03c0 a \u226b sigma.\u03b9 (val \u2218 X) a),\n  suffices : (forget A).map t = eP.hom \u226b s \u226b 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 [\u2190 (forget A).map_comp, colimit.\u03b9_desc],\n  slice_rhs 0 1\n  { erw (is_colimit_of_preserves (forget A) (colimit.is_colimit (discrete.functor P))).fac },\n  erw colimit.\u03b9_desc,\n  dsimp, simp only [category.assoc], erw colimit.\u03b9_desc,\n  dsimp, simp only [functor.map_comp], refl,\nend\n\nvariables [enough_projectives A]\n\nnoncomputable\ndef uniform_\u03c0 {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] : sigma_obj (replace_uniformly X) \u27f6 sigma_obj X :=\nsigma.desc $ \u03bb a, \u03c0_uniformly _ _ \u226b sigma.\u03b9 _ a\n\ninstance is_quasi_iso_sigma_map_\u03c0_uniformly\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X] :\n  homotopy_category.is_quasi_iso (uniform_\u03c0 X) :=\nis_quasi_iso_sigma _ _ _\n\nopen opposite\n\nnoncomputable\ndef Ext_coproduct_iso\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  (i : \u2124) (Y) :\n  ((Ext i).obj (op (sigma_obj X))).obj Y \u2245\n  pi_obj (\u03bb a : \u03b1, ((Ext i).obj (op (X a))).obj Y) :=\nExt_iso i _ _ _ (uniform_\u03c0 X) \u226a\u226b\ncategory_theory.preadditive_yoneda_coproduct_iso (replace_uniformly X) (Y\u27e6i\u27e7) \u226a\u226b\ncategory_theory.pi_iso _ _ (\u03bb a, (Ext_iso i _ _ _ (\u03c0_uniformly X a)).symm)\n\nlemma \u03b9_Ext_coprodut_iso\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  (i : \u2124) (Y) (j) :\n  (Ext_coproduct_iso X i Y).inv \u226b\n  ((Ext i).map (sigma.\u03b9 X j : X j \u27f6 \u2210 X).op).app Y =\n  pi.\u03c0 _ _ :=\nbegin\n  rw iso.inv_comp_eq,\n  dsimp [Ext_coproduct_iso, pi_iso],\n  simp only [category.assoc, limit.lift_\u03c0, fan.mk_\u03c0_app],\n  simp only [\u2190 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_\u03c0],\n  ext t, simp only [comp_apply], dsimp,\n  simp only [\u2190 category.assoc], congr' 1,\n  apply lift_ext (\u2210 X).\u03c0, swap, apply_instance,\n  dsimp [uniform_\u03c0],\n  simp,\nend\n\nlemma \u03b9_Ext_coproduct_iso'\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  (i : \u2124) (Y) (j) :\n  (Ext_coproduct_iso X i Y).hom \u226b  pi.\u03c0 _ _ =\n  ((Ext i).map (sigma.\u03b9 X j : X j \u27f6 \u2210 X).op).app Y :=\nbegin\n  rw [\u2190 iso.eq_inv_comp, \u03b9_Ext_coprodut_iso],\nend\n\nlemma Ext_coproduct_iso_naturality\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X\u2081 X\u2082 : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X\u2081]\n  [uniformly_bounded X\u2082]\n  (g : X\u2081 \u27f6 X\u2082)\n  (i : \u2124) (Y) :\n  ((Ext i).map (sigma.desc (\u03bb b, g b \u226b sigma.\u03b9 X\u2082 b) : \u2210 X\u2081 \u27f6 \u2210 X\u2082).op).app Y \u226b\n  (Ext_coproduct_iso _ _ _).hom =\n  (Ext_coproduct_iso _ _ _).hom \u226b\n  pi.lift (\u03bb b, pi.\u03c0 _ b \u226b ((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_\u03c0, fan.mk_\u03c0_app, limit.lift_\u03c0_assoc],\n  simp only [\u2190 functor.map_comp, \u2190 op_comp],\n  congr' 2,\n  simp only [category.assoc],\n  apply lift_ext (\u2210 X\u2082).\u03c0, swap, apply_instance,\n  dsimp [quiver.hom.unop_op],\n  simp only [category.assoc, lift_lifts, lift_lifts_assoc],\n  dsimp [uniform_\u03c0],\n  simp only [colimit.\u03b9_desc_assoc, cofan.mk_\u03b9_app, category.assoc, colimit.\u03b9_desc,\n    lift_lifts_assoc],\nend\n\nlemma Ext_coproduct_iso_naturality'\n  [AB4 A]\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 bounded_homotopy_category A)\n  [uniformly_bounded X]\n  (i : \u2124) (Y\u2081 Y\u2082) (f : Y\u2081 \u27f6 Y\u2082) :\n  ((Ext i).obj (op (sigma_obj X))).map f \u226b\n  (Ext_coproduct_iso _ _ _).hom =\n  (Ext_coproduct_iso _ _ _).hom \u226b\n  pi.lift (\u03bb a, pi.\u03c0 _ a \u226b ((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_\u03c0, fan.mk_\u03c0_app, limit.lift_\u03c0_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  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 chain_complex A \u2115) :\n  bounded_homotopy_category.uniformly_bounded\n  (\u03bb 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 {\u03b1 : Type v}\n  {C : Type u} {D : Type u'} [category.{v} C] [category.{v} D] (F : C \u2964 D)\n  (X : \u03b1 \u2192 C) : discrete.functor X \u22d9 F \u2245 discrete.functor (F.obj \u2218 X) :=\n  discrete.nat_iso (\u03bb i, iso.refl _)\n\nnoncomputable\nlemma preserves_coproducts_aux\n  {\u03b1 : Type v} {C : Type u} {D : Type u'}\n  [category.{v} C] [category.{v} D]\n  (F : C \u2964 D)\n  [has_coproducts_of_shape \u03b1 C]\n  [\u2200 (X : \u03b1 \u2192 C), has_coproduct (\u03bb a, F.obj (X a))]\n  (e : \u03a0 (X : \u03b1 \u2192 C), F.obj (\u2210 X) \u2245 \u2210 (\u03bb a, F.obj (X a)))\n  (he : \u2200 (X : \u03b1 \u2192 C) (a : \u03b1), F.map (sigma.\u03b9 X a) \u226b (e X).hom = sigma.\u03b9 _ a) :\n  preserves_colimits_of_shape (discrete \u03b1) F :=\nbegin\n  constructor, intros K,\n  let E : K \u2245 discrete.functor K.obj := discrete.nat_iso (\u03bb _, 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 (\u03bb a : \u03b1, F.obj (K.obj a))),\n  apply_instance,\n  symmetry,\n  fapply cocones.ext,\n  apply e,\n  intros a,\n  convert (he (\u03bb 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 {\u03b1 : Type v}\n  {M N : Type} (c\u2081 : complex_shape M) (c\u2082 : complex_shape N) (e : c\u2081.embedding c\u2082) :\n  preserves_colimits_of_shape (discrete \u03b1)\n  (homological_complex.embed e : homological_complex A _ \u2964 _) :=\npreserves_coproducts_aux\n(homological_complex.embed e : homological_complex A _ \u2964 _)\n(\u03bb (X : \u03b1 \u2192 homological_complex A c\u2081), homological_complex.hom.iso_of_components\n(\u03bb i,\nbegin\n  rcases h : e.r i with _ | j,\n  { refine homological_complex.embed.X_iso_of_none _ h \u226a\u226b _,\n    refine _ \u226a\u226b (preserves_colimit_iso (homological_complex.eval A c\u2082 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 \u226a\u226b _,\n    refine (preserves_colimit_iso (homological_complex.eval _ _ _) _) \u226a\u226b _,\n    refine _ \u226a\u226b (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\u2081 : e.r i with _ | i';\n  rcases h\u2082 : 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\u2081, h\u2082], dsimp,\n    simp only [category.assoc],\n    rw \u2190 iso.eq_inv_comp,\n    dsimp [homological_complex.embed, homological_complex.embed.obj],\n    rw homological_complex.embed.d_of_some_of_some (\u2210 X) h\u2081 h\u2082,\n    simp only [category.assoc, iso.inv_hom_id_assoc],\n    apply (is_colimit_of_preserves (homological_complex.eval A c\u2081 i') _).hom_ext,\n    intros a,\n    simp only [functor.map_cocone_\u03b9_app, colimit.cocone_\u03b9, homological_complex.eval_map],\n    slice_lhs 1 2 {\n      erw (is_colimit_of_preserves (homological_complex.eval A c\u2081 i') _).fac },\n    dsimp,\n    simp only [has_colimit.iso_of_nat_iso_\u03b9_hom, discrete.nat_iso_hom_app, iso.symm_hom,\n      category.assoc, \u03b9_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\u2081 j') _).fac },\n    dsimp,\n    simp only [has_colimit.iso_of_nat_iso_\u03b9_hom, discrete.nat_iso_hom_app, iso.symm_hom,\n      category.assoc, \u03b9_preserves_colimits_iso_inv, homological_complex.eval_map],\n    slice_rhs 1 3\n    { rw \u2190 homological_complex.embed.d_of_some_of_some (X a) h\u2081 h\u2082 },\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 [\u2190 category.assoc, iso.comp_inv_eq],\n  simp_rw [\u2190 iso.eq_comp_inv, category.assoc],\n  slice_rhs 1 2\n  { erw (is_colimit_of_preserves (homological_complex.eval A c\u2082 i) _).fac },\n  dsimp,\n  simp only [has_colimit.iso_of_nat_iso_\u03b9_inv, discrete.nat_iso_inv_app, iso.symm_inv,\n    category.assoc, \u03b9_preserves_colimits_iso_inv, homological_complex.eval_map],\n  apply homological_complex.embed.f_of_some,\nend\n\nnoncomputable\ndef embed_coproduct_iso\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 chain_complex A \u2115) :\n  (homological_complex.embed complex_shape.embedding.nat_down_int_up).obj (\u2210 X) \u2245\n  (\u2210 \u03bb (a : \u03b1), (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) _ \u226a\u226b\nhas_colimit.iso_of_nat_iso (whisker_discrete_functor _ _)\n\nnoncomputable\ndef chain_complex_embed_cofan_iso\n  {\u03b1 : Type v}\n  (X : \u03b1 \u2192 chain_complex A \u2115) :\n  (bounded_homotopy_category.cofan\n    (\u03bb a, chain_complex.to_bounded_homotopy_category.obj (X a))) \u2245\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, \u2190 functor.map_comp],\n  congr' 1,\n  dsimp [embed_coproduct_iso],\n  simp only [category.assoc],\n  erw colimit.\u03b9_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  {\u03b1 : Type v} :\n  preserves_colimits_of_shape (discrete \u03b1)\n  (chain_complex.to_bounded_homotopy_category : chain_complex A _ \u2964 _) :=\nbegin\n  constructor, intros K,\n  let E : K \u2245 discrete.functor K.obj := discrete.nat_iso (\u03bb _, 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 : \u03b1 \u2192 bounded_homotopy_category A := \u03bb 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 \u22d9 chain_complex.to_bounded_homotopy_category \u2245\n    discrete.functor Q := discrete.nat_iso (\u03bb _, 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 (\u03c3 : Type) : nat \u2192 Type\n| nil : ind_vec 0\n| cons : \u03a0{n : nat}, \u03c3 \u2192 ind_vec n \u2192 ind_vec (n.succ)\n\ndef ind_vec.as_list {\u03c3 : Type} : \u2200{n : nat}, ind_vec \u03c3 n \u2192 list \u03c3\n| _ ind_vec.nil := []\n| _ (ind_vec.cons x xs) := x :: xs.as_list\n\nlemma ind_vec.as_list_length {\u03c3 : Type} {n : nat} (v : ind_vec \u03c3 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 {\u03c3 : Type} {n : nat} (v : ind_vec \u03c3 n) : vector \u03c3 n :=\n  \u27e8v.as_list, v.as_list_length\u27e9\n\ndef list.as_ind_vec {\u03c3 : Type} : \u03a0(xs : list \u03c3), ind_vec \u03c3 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 {\u03c3 : Type} {n : nat} : vector \u03c3 n \u2192 ind_vec \u03c3 n\n| \u27e8xs, h\u27e9 := eq.rec xs.as_ind_vec h\n\ndef ind_vec.map {\u03c3 \u03c4 : Type} : \u2200{n : nat}, ind_vec \u03c3 n \u2192 (\u03c3 \u2192 \u03c4) \u2192 ind_vec \u03c4 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 \u2192 atyp\n| bool : atyp\n| int : atyp\n| perm : atyp\n| ref : atyp\n| domain : \u03a0(k : domain_k), ind_vec atyp (domains k).t_args \u2192 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 \u2192 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 : \u2200{m : nat}, ind_vec (atyp domains n) m \u2192 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 \u2192 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 \u2192 method_k)\n\nwith a_exp : Type\n-- pure, heap-independent\n| const_bool : bool \u2192 a_exp\n| const_int : \u2124 \u2192 a_exp\n| domain_apply_indirect : domain_inv \u2192 a_exp\n| func_apply_indirect : func_inv \u2192 a_exp\n| and : a_exp \u2192 a_exp \u2192 a_exp\n| implies : a_exp \u2192 a_exp \u2192 a_exp\n| binding : nat \u2192 a_exp\n| all : (atyp ctx.domains cfg.type_bindings) \u2192 a_exp \u2192 a_exp\n| ex : (atyp ctx.domains cfg.type_bindings) \u2192 a_exp \u2192 a_exp\n\n-- normal, heap-dependent\n| deref : cfg.have_heap.typ \u2192 a_exp \u2192 field_k \u2192 a_exp\n\n-- local\n| arg (m : cfg.have_method.typ) : fin (ctx.methods (here m)).args.length \u2192 a_exp\n| out (m : cfg.have_method.typ) : fin (ctx.methods (here m)).out_args.length \u2192 a_exp\n| loc (m : cfg.have_method.typ) : fin (ctx.methods (here m)).locals.length \u2192 a_exp\n\n-- postcondition result\n| result : cfg.have_result.typ \u2192 a_exp\n\n-- assertions\n| acc_field : cfg.have_assn.typ \u2192 a_exp \u2192 field_k \u2192 a_exp \u2192 a_exp\n| acc_pred : cfg.have_assn.typ \u2192 pred_inv \u2192 a_exp \u2192 a_exp\n\nwith domain_inv : Type\n| apply (k : domain_func_k) : ind_vec a_exp (ctx.domain_funcs k).args.length \u2192 domain_inv\n\nwith func_inv : Type\n| apply (k : func_k) : ind_vec a_exp (ctx.funcs k).args.length \u2192 func_inv\n\nwith pred_inv : Type\n| apply (k : predicate_k) : ind_vec a_exp (ctx.predicates k).args.length \u2192 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    (\u03bb_, 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    (\u03bb_, 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 \u2192 stat\n| cond : (local_exp ctx here) \u2192 stat \u2192 stat \u2192 stat\n| assign : fin (ctx.methods here).locals.length \u2192 (local_exp ctx here) \u2192 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 : \u03a0(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 \u2192 method_k)\n: (list $ atyp ctx.domains cfg.type_bindings) \u2192 (a_exp ctx cfg here) \u2192 (atyp ctx.domains cfg.type_bindings) \u2192 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 : \u2124) : 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      \u2200(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      \u2200(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)) : \u2200l r, a_exp.t vs l atyp.bool \u2192 a_exp.t vs r atyp.bool \u2192 a_exp.t vs (a_exp.and l r) atyp.bool\n| implies (vs : (list $ atyp ctx.domains cfg.type_bindings)) : \u2200l r, a_exp.t vs l atyp.bool \u2192 a_exp.t vs r atyp.bool \u2192 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 \u2192 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 \u2192 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 \u2192 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 : \u2124 \u2192 value\n| rat : \u211a \u2192 value\n| obj : objects \u2192 value\n\nstructure heap :=\n  (mask : location \u2192 \u211a)\n  (value : location \u2192 value)\n\nstructure state :=\n  (heap : heap)\n  (locals : nat \u2192 value)\n\n-- semantics\ndef state.sat : state \u2192 exp \u2192 Prop := \u03bb 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": "theorem ex : let x := 1; x < 2 := by\n  intro x\n  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/lean/run/decidelet.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5698526514141571, "lm_q2_score": 0.37754066879814546, "lm_q1q2_score": 0.21514255113129732}}
{"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 {\u03b1:Type*} [preorder \u03b1] (a:with_top \u03b1):\n  \u00ac(@has_lt.lt (with_top \u03b1) _  (none:with_top \u03b1) 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 {\u03b1:Type*} [partial_order \u03b1] (a:\u03b1):\n  \u00ac(@has_le.le (with_top \u03b1) _ (none) (some a)):=\nbegin\n  intro A1,\n  have B1:(some a) \u2260 (none:with_top \u03b1),\n  {\n    simp,\n  },\n  have B3:(@has_le.le (with_top \u03b1) _ (some a) (none)) := with_top.le_none,\n  have B4 := @le_antisymm (with_top \u03b1) _ (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 \u2192 type\n| arrow : type \u2192 type \u2192 type\n\nvariables (cT : Type)\n\n@[reducible] def context (cT : Type) : Type := list (string \u00d7 type cT)\n\n-- instance : has_append (context cT) :=\n-- \u27e8\u03bb a b : list (string \u00d7 type cT), list.append b a\u27e9\n\nvariables {cT}\n\ninductive term (ct : type cT \u2192 Type) : \u03a0 (\u0393 : 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 (\u0393\u2081 \u0393\u2082 : context cT) {T\u2081 T\u2082 : type cT} (f : term \u0393\u2081 (T\u2081.arrow T\u2082)) (x : term \u0393\u2082 T\u2081) : \n    term (\u0393\u2081 ++ \u0393\u2082) T\u2082\n| lambda {\u0393 : context cT} (a : string) (T\u2081 : type cT) {T\u2082 : type cT}\n    (t : term (\u0393 ++ [(a, T\u2081)]) T\u2082) : term \u0393 (T\u2081.arrow T\u2082)\n\ninductive term2 (ct : type cT \u2192 Type) : \u03a0 (A : type cT), Type\n| const {T : type cT} (t : ct T) : term2 T\n| app {T\u2081 T\u2082 : type cT} (f : term2 (T\u2081.arrow T\u2082)) (x : term2 T\u2081) : term2 T\u2082\n| id {T\u2081 : type cT} : term2 (T\u2081.arrow T\u2081)\n| comp {T\u2081 T\u2082 T\u2083 : type cT} : term2 ((T\u2081.arrow T\u2082).arrow ((T\u2082.arrow T\u2083).arrow (T\u2081.arrow T\u2083)))\n| swap {T\u2081 T\u2082 T\u2083 : type cT} : term2 ((T\u2081.arrow (T\u2082.arrow T\u2083)).arrow (T\u2082.arrow (T\u2081.arrow T\u2083)))\n\ndef presheaf (ct : type cT \u2192 Type) : Type 1 := \n\u03a3 (F : type cT \u2192 Type), \u03a0 {A B : type cT}, term2 ct (A.arrow B) \u2192 F A \u2192 F B\n\nnamespace presheaf\n\nvariable {ct : type cT \u2192 Type}\n\ndef hom (F G : presheaf ct) : Type :=\n\u03a0 (A : type cT), F.1 A \u2192 G.1 A\n\ndef hom.comp {F G H : presheaf ct} (f : hom F G) (g : hom G H) : hom F H :=\n\u03bb A, g A \u2218 f A\n\ndef hom.id (F : presheaf ct) : hom F F := \u03bb _, id\n\nvariable (ct)\n\ndef yoneda (A : type cT) : presheaf ct := \n\u27e8\u03bb B, term2 ct (A.arrow B), \u03bb B C f g, term2.app (term2.app term2.comp g) f\u27e9\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\u03bb 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\u27e8\u03bb c, \u03a3 c' : type cT, term2 ct (c'.arrow c) \u00d7 F.1 c', \n  \u03bb A B f a, \u27e8a.1, (term2.app term2.comp a.2.1).app f, a.2.2\u27e9\u27e9\n\ndef to_sumthing (F : presheaf ct) : hom F (sumthing F) :=\n\u03bb A a, \u27e8A, term2.id, a\u27e9\n\ndef of_sumthing (F : presheaf ct) : hom (sumthing F) F :=\n\u03bb A b, F.2 b.2.1 b.2.2\n\ndef tensor (F G : presheaf ct) : presheaf ct :=\n\u27e8\u03bb c, \u03a3 c\u2081 c\u2082 : type cT, term2 ct (c\u2081.arrow (c\u2082.arrow c)) \u00d7 F.1 c \u00d7 G.1 c, \n  \u03bb A B f x, \u27e8x.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\u27e9\u27e9\n\ndef tensor_assoc\u2081 (F G H : presheaf ct) : \n  hom (tensor (tensor F G) H) (tensor F (tensor G H)) :=\n\u03bb A a, begin\n  rcases a with \u27e8c\u2081, c\u2082, h\u2081, \u27e8c\u2083, c\u2084, h\u2082, f, g\u27e9, h\u27e9,\n  exact \u27e8c\u2081, c\u2082, h\u2081, f, c\u2083, c\u2084, h\u2082, g, h\u27e9\nend\n\ndef tensor_assoc (F G H : presheaf ct) : \n  hom (tensor F (tensor G H)) (tensor (tensor F G) H) :=\n\u03bb A a, begin\n  rcases a with \u27e8c\u2081, c\u2082, h\u2081, f, c\u2083, c\u2084, h\u2082, g, h\u27e9,\n  exact \u27e8c\u2081, c\u2082, h\u2081, \u27e8c\u2083, c\u2084, h\u2082, f, g\u27e9, h\u27e9\nend\n\ndef tensor_map {F\u2081 G\u2081 F\u2082 G\u2082 : presheaf ct} (f : hom F\u2081 F\u2082) (g : hom G\u2081 G\u2082) :\n  hom (tensor F\u2081 G\u2081) (tensor F\u2082 G\u2082) :=\n\u03bb A a, \u27e8a.1, a.2.1, a.2.2.1, f _ a.2.2.2.1, g _ a.2.2.2.2\u27e9 \n\ndef homp (F G : presheaf ct) : presheaf ct :=\n\u27e8\u03bb c, \u03a3 c\u2081 c\u2082 : type cT, term2 ct (c\u2081.arrow (c\u2082.arrow c)) \u2192 F.1 c \u2192 G.1 c,\n  sorry\u27e9\n\nsection curry\n\nvariables {F G H : presheaf ct}\n\n-- def curryFa (F G H : presheaf ct) : presheaf ct :=\n-- \u27e8\u03bb A, hom () H, _\u27e9 \n\n-- def currya\u2081 : 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) \u2192 \n  (hom F (homp G H)) :=\nbegin\n  dsimp [tensor, yoneda, hom, homp] at *,\n  exact f _ \u27e8x.1, x.2.1, x.2.2, fA, gA\u27e9\nend\n\nend curry\n\ndef yoneda_hom (F G : type cT) : yoneda \n\ndef id : presheaf ct := \u27e8\u03bb _, unit, \u03bb _ _ _, id\u27e9\n\ndef tensor_id\u2081 (F : presheaf ct) : hom (tensor F id) F :=\n\u03bb A a, a.1\n\ndef tensor_id\u2082 (F : presheaf ct) : hom F (tensor F id) :=\n\u03bb A a, (a, ())\n\ndef id_tensor\u2082 (F : presheaf ct) : hom F (tensor id F) :=\n\u03bb A a, ((), a)\n\n\n\nend presheaf\n\nopen category_theory\n\nsection\n\ninductive type3 (cT : Type) : Type\n| const : cT \u2192 type3\n| arrow : type3 \u2192 type3 \u2192 type3\n| id {} : type3\n| tensor : type3 \u2192 type3 \u2192 type3\n\n\ndef type3.of_type : type cT \u2192 type3 cT \n| (type.const T) := type3.const T\n| (type.arrow T\u2081 T\u2082) := type3.arrow (type3.of_type T\u2081) (type3.of_type T\u2082)\n\ndef contexti : context cT \u2192 type3 cT\n| []       := type3.id\n| (T :: l) := type3.tensor (type3.of_type T.2) (contexti l)\n\ninductive term3 (const_term : type cT \u2192 Type) : \u03a0 (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\u2081 T\u2082 T\u2083 : type3 cT} :\n  term3 ((((T\u2081.tensor T\u2082).arrow T\u2083)).arrow (T\u2081.arrow (T\u2082.arrow T\u2083)))\n| uncurry {T\u2081 T\u2082 T\u2083 : type3 cT} :\n  term3 ((T\u2081.arrow (T\u2082.arrow T\u2083)).arrow ((T\u2081.tensor T\u2082).arrow T\u2083))\n| tensor_map {T\u2081 T\u2082 T\u2083 T\u2084 : type3 cT} (f\u2081 : term3 (T\u2081.arrow T\u2083))\n  (f\u2082 : term3 (T\u2082.arrow T\u2084)) : term3 ((T\u2081.tensor T\u2082).arrow (T\u2083.tensor T\u2084))\n| tensor_symm {T\u2081 T\u2082 : type3 cT} : term3 ((T\u2081.tensor T\u2082).arrow (T\u2082.tensor T\u2081))\n| lid\u2081 {T : type3 cT} : term3 ((type3.id.tensor T).arrow T)\n| lid\u2082 {T : type3 cT} : term3 (T.arrow (type3.id.tensor T))\n| app {T\u2081 T\u2082 : type3 cT} (f : term3 (T\u2081.arrow T\u2082)) (x : term3 T\u2081) : term3 T\u2082\n| comp {T\u2081 T\u2082 T\u2083 : type3 cT} (f : term3 (T\u2081.arrow T\u2082)) :\n  term3 ((T\u2082.arrow T\u2083).arrow (T\u2081.arrow T\u2083))\n\nnamespace term3 \n\nvariables {const_term : type cT \u2192 Type}\n\ndef tensor_mk {T\u2081 T\u2082 : type3 cT} : term3 const_term (T\u2081.arrow (T\u2082.arrow (T\u2081.tensor T\u2082))) := \nterm3.app term3.curry (term3.id _)\n\ndef rid\u2081 {T : type3 cT} : term3 const_term ((T.tensor type3.id).arrow T) :=\nterm3.app (term3.comp term3.tensor_symm) term3.lid\u2081\n\ndef rid\u2082 (T : type3 cT) : term3 const_term (T.arrow (T.tensor type3.id)) :=\nterm3.app (term3.comp term3.lid\u2082) term3.tensor_symm\n\ndef lift {T : type3 cT} : term3 const_term (T.arrow (type3.id.arrow T)) :=\nterm3.app term3.curry term3.rid\u2081\n\ndef drop {T : type3 cT} : term3 const_term ((type3.id.arrow T).arrow T) :=\nterm3.app (term3.comp (term3.rid\u2082 _)) \n  (term3.app (term3.uncurry) (term3.id _))\n\ndef assoc\u2081 {T\u2081 T\u2082 T\u2083 : type3 cT} : \n  term3 const_term (((T\u2081.tensor T\u2082).tensor T\u2083).arrow (T\u2081.tensor (T\u2082.tensor T\u2083))) :=\nterm3.app term3.uncurry $ term3.app term3.uncurry $\n  term3.app (term3.comp term3.tensor_mk) term3.curry\n\ndef assoc\u2082 {T\u2081 T\u2082 T\u2083 : type3 cT} :\n  term3 const_term ((T\u2081.tensor (T\u2082.tensor T\u2083)).arrow ((T\u2081.tensor T\u2082).tensor T\u2083)) :=\nterm3.app term3.uncurry $ term3.app (term3.comp \n  (term3.app term3.curry tensor_mk)) term3.uncurry\n\ndef contexti_append\u2081 : \u03a0 (\u0393\u2081 \u0393\u2082 : context cT), term3 const_term \n  ((contexti (\u0393\u2081 ++ \u0393\u2082)).arrow ((contexti \u0393\u2081).tensor (contexti \u0393\u2082)))\n| []      \u0393\u2082 := lid\u2082\n| (T::\u0393\u2081) \u0393\u2082 := term3.app (term3.comp (term3.tensor_map (term3.id _) \n  (contexti_append\u2081 _ _))) term3.assoc\u2082\n \ndef contexti_append\u2082 : \u03a0 (\u0393\u2081 \u0393\u2082 : context cT), term3 const_term \n  (((contexti \u0393\u2081).tensor (contexti \u0393\u2082)).arrow (contexti (\u0393\u2081 ++ \u0393\u2082)))\n| []      \u0393\u2082 := lid\u2081\n| (T::\u0393\u2081) \u0393\u2082 := term3.app (term3.comp term3.assoc\u2081) \n  (term3.tensor_map (term3.id _) (contexti_append\u2082 _ _))\n\nend term3\n\nvariables {const_term : type cT \u2192 Type}\nvariables (const_termi : \u03a0 {T : type cT}, const_term T \u2192 type3 cT)\n\ndef termi : \u03a0 {\u0393 : context cT} {A : type cT} (t : term const_term \u0393 A),\n  term3 const_term ((contexti \u0393).arrow (type3.of_type A))\n| _ A (term.const t) := term3.app term3.lift (term3.const t)\n| _ _ (term.var _ A) :=  term3.rid\u2081\n| _ T\u2082 (@term.app  _ _ \u0393\u2081 \u0393\u2082 T\u2081 _ f x) := \nterm3.app (term3.comp (term3.contexti_append\u2081 _ _)) \n  (term3.app term3.uncurry \n    (term3.app (term3.comp (termi f)) \n      (term3.comp (termi x))))\n| \u0393 (type.arrow _ T\u2082) (term.lambda a T\u2081 t) :=\nterm3.app term3.curry \n  (term3.app (term3.comp \n    (term3.app (term3.comp (term3.tensor_map (term3.id _) \n        (term3.rid\u2082 _))) (term3.contexti_append\u2082 \u0393 [(a, T\u2081)]))) (termi t))\n\ninductive term\u2083 (const_term : type cT \u2192 Type) : \u03a0 (A : type cT), Type\n| const {T : type cT} (t : const_term T) : term\u2083 T\n| id (T : type cT) : term\u2083 (T.arrow T)\n| app {T\u2081 T\u2082 : type cT} (f : term\u2083 (T\u2081.arrow T\u2082)) (x : term\u2083 T\u2081) : term\u2083 T\u2082\n| comp {T\u2081 T\u2082 T\u2083 : type cT} (f : term\u2083 (T\u2081.arrow T\u2082)) : \n  term\u2083 ((T\u2082.arrow T\u2083).arrow (T\u2081.arrow T\u2083))\n\nend\n\nopen term\n\ndef const_term : type unit \u2192 Type\n| (type.arrow (type.const ()) (type.arrow (type.const ()) (type.const ()))) := unit\n| _ := empty\n\ndef cTi : unit \u2192 Module R := \u03bb _, 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\u2081 T\u2082; try { apply empty.elim t },\n  cases T\u2081 with _ T\u2082 T\u2083; try { apply empty.elim t },\n  cases T\u2081,\n  cases T\u2082 with _ T\u2081 T\u2082; try { apply empty.elim t },\n  cases T\u2081 with _ T\u2081 T\u2082; try { apply empty.elim t },\n  cases T\u2081,\n  cases T\u2082 with _ T\u2081 T\u2082; 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\u2081 : @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\u2081 = 0 :=\nbegin\n  dunfold exmpl\u2081,\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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n\nopen function\nlemma assert_if_neg {p : Prop}\n  (x : p \u2192 roption \u03b1)\n  (h : \u00ac p)\n: assert p x = roption.none :=\nby { dsimp [assert,roption.none],\n     have : (\u2203 (h : p), (x h).dom) \u2194 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 \u2192 roption \u03b1)\n  (h : p)\n: assert p x = x h :=\nby { dsimp [assert],\n     have : (\u2203 (h : p), (x h).dom) \u2194 (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 {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 roption \u03b2)\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 Smt\n\ntheorem assoc (f : Prop \u2192 Prop \u2192 Prop) (p q r : Prop) :\n  f p (f q r) = f (f p q) r := by\n  smt\n  admit\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/Test/Prop/Assoc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5583269943353745, "lm_q2_score": 0.3812195662561499, "lm_q1q2_score": 0.21284517460963132}}
{"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 : \u211d\u22650) [fact (0 < p)] :\n  cone (X.diagram \u22d9 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 : \u211d\u22650) [fact (0 < p)]\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef linear_map (S : cone (X.diagram \u22d9 Radon_LC_functor p c)) (t : S.X) :\n  locally_constant X \u211d \u2192\u2097[\u211d] \u211d :=\n{ to_fun := \u03bb e, (S.\u03c0.app e.discrete_quotient t).1 e.locally_constant_lift,\n  map_add' := begin\n    intros e\u2081 e\u2082,\n    let W\u2081 := e\u2081.discrete_quotient,\n    let W\u2082 := e\u2082.discrete_quotient,\n    let W\u2081\u2082 := (e\u2081 + e\u2082).discrete_quotient,\n    let W := W\u2081 \u2293 W\u2082 \u2293 W\u2081\u2082,\n    let \u03c0\u2081 : W \u27f6 W\u2081 := hom_of_le (le_trans inf_le_left inf_le_left),\n    let \u03c0\u2082 : W \u27f6 W\u2082 := hom_of_le (le_trans inf_le_left inf_le_right),\n    let \u03c0\u2081\u2082 : W \u27f6 W\u2081\u2082 := hom_of_le inf_le_right,\n    rw [\u2190 S.w \u03c0\u2081, \u2190 S.w \u03c0\u2082, \u2190 S.w \u03c0\u2081\u2082],\n    dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap, continuous_map.comap_LC],\n    erw \u2190 ((S.\u03c0.app W) t).1.map_add, congr' 1,\n    ext \u27e8\u27e9, refl\n  end,\n  map_smul' := begin\n    intros r e,\n    let W\u2081 := e.discrete_quotient,\n    let W\u2082 := (r \u2022 e).discrete_quotient,\n    let W := W\u2081 \u2293 W\u2082,\n    let \u03c0\u2081 : W \u27f6 W\u2081 := hom_of_le inf_le_left,\n    let \u03c0\u2082 : W \u27f6 W\u2082 := hom_of_le inf_le_right,\n    rw [\u2190 S.w \u03c0\u2081, \u2190 S.w \u03c0\u2082],\n    dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap, continuous_map.comap_LC],\n    rw \u2190 smul_eq_mul,\n    erw \u2190 ((S.\u03c0.app W) t).1.map_smul, congr' 1,\n    ext \u27e8\u27e9, refl\n  end }\n\nvariables [fact (p \u2264 1)]\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef weak_dual (S : cone (X.diagram \u22d9 Radon_LC_functor p c)) (t : S.X) :\n  weak_dual \u211d (locally_constant X \u211d) :=\nlinear_map.mk_continuous_of_exists_bound (linear_map X p c S t)\nbegin\n  use c^(1/(p : \u211d)),\n  intros e,\n  suffices : \u2225 linear_map X p c S t e \u2225\u208a \u2264 c^(1/(p : \u211d)) * \u2225 e \u2225\u208a,\n    by exact_mod_cast this,\n  have hp : 0 < (p : \u211d) := by exact_mod_cast (fact.out (0 < p)),\n  have hp' : (p : \u211d) \u2260 0,\n  { exact ne_of_gt hp },\n  rw [\u2190 nnreal.rpow_le_rpow_iff hp, nnreal.mul_rpow, \u2190 nnreal.rpow_mul],\n  rw [(show 1 / (p : \u211d) * p = 1, by field_simp), nnreal.rpow_one],\n  have H := ((S.\u03c0.app e.discrete_quotient) t).2 \u22a5,\n  replace H := mul_le_mul H (le_refl (\u2225e\u2225\u208a^(p : \u211d))) (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 : \u2211 (x : (\u22a5 : discrete_quotient e.discrete_quotient)),\n    \u2225e\u2225\u208a ^ (p : \u211d) * \u2225(((S.\u03c0.app e.discrete_quotient) t).val)\n    ((\u22a5 : discrete_quotient e.discrete_quotient).fibre x).indicator_LC\u2225\u208a ^ (p : \u211d) =\n    \u2211 (x : e.discrete_quotient), \u2225e\u2225\u208a^(p : \u211d) *\n      \u2225 (linear_map X p c S t) (e.discrete_quotient.fibre x).indicator_LC \u2225\u208a^(p : \u211d),\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\u2081 := e.discrete_quotient,\n      let T\u2082 := (e.discrete_quotient.fibre\n        ((discrete_quotient.equiv_bot.symm) a)).indicator_LC.discrete_quotient,\n      let T := T\u2081 \u2293 T\u2082,\n      let \u03c0\u2081 : T \u27f6 T\u2081 := hom_of_le inf_le_left,\n      let \u03c0\u2082 : T \u27f6 T\u2082 := hom_of_le inf_le_right,\n      rw [\u2190 S.w \u03c0\u2081, \u2190 S.w \u03c0\u2082],\n      dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap],\n      congr' 1,\n      ext b, obtain \u27e8b,rfl\u27e9 := 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 \u03c0\u2081 (T.proj b) = T\u2081.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 \u27e8x,rfl\u27e9 := discrete_quotient.proj_surjective _ x,\n  change \u2225 e x \u2225\u208a \u2264 _,\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 \u22d9 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.\u03c0.app T t).2 \u22a5 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 \u2293 W,\n      let \u03c0\u2081 : E \u27f6 T := hom_of_le inf_le_left,\n      let \u03c0\u2082 : E \u27f6 W := hom_of_le inf_le_right,\n      rw [\u2190 S.w \u03c0\u2081, \u2190 S.w \u03c0\u2082],\n      dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap,\n        continuous_map.comap_LC],\n      congr' 1, ext b, obtain \u27e8b,rfl\u27e9 := 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 \u22d9 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 : \u211d\u22650) [fact (0 < p)] [fact (p \u2264 1)] :\n  is_limit (X.Radon_LC_cone p c) :=\n{ lift := \u03bb S, \u27e8is_limit_Radon_LC_cone.Radon_LC X p c S,\n    is_limit_Radon_LC_cone.continuous_Radon_LC X p c S\u27e9,\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\u2081 := ((continuous_map.comap_LC (X.as_limit_cone.\u03c0.app T)) e).discrete_quotient,\n    let W := W\u2081 \u2293 T,\n    let \u03c0\u2081 : W \u27f6 W\u2081 := hom_of_le inf_le_left,\n    let \u03c0\u2082 : W \u27f6 T := hom_of_le inf_le_right,\n    rw [\u2190 S.w \u03c0\u2081, \u2190 S.w \u03c0\u2082],\n    dsimp [Radon_LC_functor, map_Radon_LC, weak_dual.comap],\n    congr' 1, ext \u27e8\u27e9, refl,\n  end,\n  uniq' := begin\n    intros S m hm,\n    ext t T,\n    specialize hm T.discrete_quotient,\n    apply_fun (\u03bb 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] (T : discrete_quotient X) :\n  compact_space (Radon_LC (X.diagram.obj T) p c) :=\nbegin\n  change compact_space ((X.diagram \u22d9 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 \u22d9 real_measures.functor p \u22d9 CompHausFiltPseuNormGrp\u2081.level.obj c\n    \u22d9 CompHaus_to_Top).obj T),\n  { change compact_space ((X.fintype_diagram \u22d9 real_measures.functor p\n      \u22d9 CompHausFiltPseuNormGrp\u2081.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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  discrete_quotient X \u2964 CompHaus.{0} :=\n{ obj := \u03bb T, CompHaus.of $ (X.diagram.obj T).Radon_LC p c,\n  map := \u03bb 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  compact_space (X.Radon_LC p c) :=\nbegin\n  let e\u2081 : X.Radon_LC p c \u2245 limit (X.diagram \u22d9 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\u2082 :\n    CompHaus_to_Top.obj (limit $ X.Radon_LC_CompHaus_diagram p c) \u2245\n    limit (X.diagram \u22d9 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\u2082 \u226a\u226b e\u2081.symm),\n  haveI : compact_space\n    (CompHaus_to_Top.obj (limit $ X.Radon_LC_CompHaus_diagram p c)),\n  { show compact_space \u21a5((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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  Profinite.{0} \u2964 CompHaus.{0} :=\n{ obj := \u03bb X, CompHaus.of $ X.Radon_LC p c,\n  map := \u03bb X Y f, (Radon_LC_functor p c).map f,\n  map_id' := (Radon_LC_functor p c).map_id,\n  map_comp' := \u03bb 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 : \u211d\u22650) [fact (0 < p)] [fact (p \u2264 1)] :\n  cone (X.diagram \u22d9 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 `\u2133_p`.\n-/\ndef is_limit_Radon_LC_CompHaus_cone (X : Profinite.{0}) (p c : \u211d\u22650) [fact (0 < p)] [fact (p \u2264 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 : \u2115} (a : A pw) (d : D) (B : set Point) :=\nall_b a d (\u03bb b, b.A \u2208 B)\n\nlemma exi_ma_inf_n_of_exi_A {pw : \u2115} {d : D} {s s' : State} {hs}\n  (h\u2081 : \u2200 (n : \u2115), \u2203 (a : A pw), ((init_game a d s).play n).act)\n  (h\u2082 : s' = apply_D_move s (d.f s hs).m) :\n  \u2203 (ma : Valid_A_move pw s'.board),\n  {n : \u2115 | \u2203 (a : A pw) hs' hvm, a.f s' hs' hvm = ma \u2227\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 \u27e8a, h\u2083\u27e9 := h\u2081 n, obtain \u27e8a\u2081, h\u2084\u27e9 := h\u2081 1, have hs' : s'.act,\n  { subst h\u2082, assumption },\n  have hvm : A_has_valid_move pw s'.board,\n  { rw [play_1, play_move_at_act] at h\u2084, swap, { assumption },\n    have h\u2085 : play_D_move_at (init_game a\u2081 d s) hs = init_game a\u2081 d s',\n    { subst h\u2082, refl },\n    rw [h\u2085, play_A_move_at] at h\u2084, clear h\u2085, split_ifs at h\u2084 with h\u2085,\n    { exact h\u2085.2 },\n    { cases h\u2084 }},\n  exact \u27e8a.f s' hs' hvm, a, hs', hvm, rfl, h\u2083\u27e9,\nend\n\nlemma exi_A_forall_n_play_act_of_swap {pw : \u2115} {d : D} {s : State}\n  (h : \u2200 (n : \u2115), \u2203 (a : A pw), ((init_game a d s).play n).act) :\n  \u2203 (a : A pw), \u2200 (n : \u2115), ((init_game a d s).play n).act :=\nbegin\n  apply @exi_A_wins_of_invariant (\u03bb s, \u2200 (n : \u2115), \u2203 (a : A pw),\n    ((init_game a d s).play n).act); assumption <|> clear h; dsimp,\n  { rintro s h\u2081, specialize h\u2081 0, exact h\u2081.some_spec },\n  { rintro s s' hs h\u2081 h\u2082, obtain \u27e8ma, hma\u27e9 := exi_ma_inf_n_of_exi_A h\u2081 h\u2082,\n    use ma, rintro n, obtain \u27e8k, h\u2083, a, hs', hvm, hh, h\u2084\u27e9 := 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\u2085 := act_of_act_play h\u2084, rw play_move_at_act h\u2085,\n        have h\u2086 : play_D_move_at (init_game a d s) h\u2085 = init_game a d s',\n        { ext; try { refl }, exact h\u2082.symm },\n        rw [h\u2086, play_A_move_at, dif_pos], clear h\u2086, swap, { exact \u27e8hs', hvm\u27e9 },\n        change apply_A_move s' (a.f s' _ _).m = apply_A_move s' ma.m, congr' }},\n    exact act_play_le h\u2083 h\u2084 },\nend\n\nlemma D_wins_n_of_D_hws {pw : \u2115}\n  (h : D_hws pw) :\n  \u2203 (n : \u2115) (d : D), \u2200 (a : A pw),\n  D_wins_in a d n :=\nbegin\n  contrapose! h, rw forall_swap at h, change \u2200 (d : D) (n : \u2115), _ 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 : \u2200 (n : \u2115), \u2203 (a : A pw), ((init_game a d state\u2080).play n).act,\n  { intro n, specialize h n, cases h with a h, use a, rcases h with \u27e8k, h\u2081, h\u2082\u27e9,\n    obtain \u27e8k, rfl\u27e9 := nat.exists_eq_add_of_le h\u2081, apply act_play_le h\u2081 h\u2082 },\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 : \u2115} {a : A pw} {d : D}\n  (h : k \u2264 n) :\n  (simulate a d k).s.board.A \u2208 bounded (n * pw) :=\nbegin\n  induction k with k ih generalizing n,\n  { apply nat.zero_le },\n  { rw simulate at ih \u22a2, rw play_at_succ',\n    let g\u2081 : Game pw := _, change (init_game a d state\u2080).play k with g\u2081 at ih \u22a2,\n    rw Game.play_move, split_ifs with h\u2081, swap, { exact ih (nat.le_of_succ_le h) },\n    rw play_A_move_at, split_ifs with h\u2082,\n    { let s' := (play_D_move_at g\u2081 h\u2081).s,\n      change (apply_A_move_b s'.board (g\u2081.a.f _ _ _).m).A \u2208 _,\n      rw apply_A_move_b, dsimp, generalize_proofs h\u2083,\n      let ma := g\u2081.a.f s' h\u2081 h\u2083, change ma.m \u2208 _, have h\u2084 := ma.h.2.1,\n      have h\u2085 : s'.board.A = g\u2081.s.board.A := apply_D_move_A_eq,\n      rw h\u2085 at h\u2084, clear h\u2085, cases n, { cases h }, rw nat.succ_le_succ_iff at h,\n      specialize ih h, change _ \u2264 _ at ih, change _ \u2264 _, rw nat.succ_mul,\n      transitivity dist ma.m g\u2081.s.board.A + dist g\u2081.s.board.A center,\n      { exact dist_triangle },\n      { rw add_comm, exact add_le_add ih h\u2084 }},\n    { have h\u2083 : (play_D_move_at g\u2081 h\u2081).finish.s.board.A = g\u2081.s.board.A,\n      { exact apply_D_move_A_eq },\n      rw h\u2083, exact ih (nat.le_of_succ_le h) }},\nend\n\nlemma lem_2_1 {pw : \u2115}\n  (h : D_hws pw) :\n  \u2203 (N : \u2115) (d : D), \u2200 (a : A pw),\n  A_trapped_in_for a d (bounded N) :=\nbegin\n  obtain \u27e8n, d, h\u2081\u27e9 := D_wins_n_of_D_hws h,\n  use [n * pw, d], intro a, specialize h\u2081 a, intro k,\n  have h\u2082 := h\u2081 _ (le_refl _), by_cases h\u2083 : n \u2264 k,\n  { have h\u2084 := h\u2081 _ h\u2083, have h\u2085 := simulate_eq_of_not_act h\u2084 h\u2082,\n    rw h\u2085, clear' k h\u2081 h\u2082 h\u2083 h\u2084 h\u2085, exact A_bounded_n_pw (le_refl _) },\n  { push_neg at h\u2083, exact A_bounded_n_pw (le_of_lt h\u2083) },\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 analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open A) (hA2 : is_covering A),\n  have h1 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open Cm \u2227 is_covering Cm \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\u2200 (x : euclidean_space \u211d (fin n)), x \u2208 Cm \u2192 \u2203 (a : euclidean_space \u211d (fin n)), a \u2208 A \u2227 x \u2208 a) \u2227 (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open_cover A),\n  have h1 : \u2200 m : \u2115, \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) m)) \u2227 U \u2286 (\u22c3 (V : set (euclidean_space \u211d (fin n))) (hV : V \u2208 A), V) \u2227 (\u2200 (U : set (euclidean_space \u211d (fin n))) (hU : U \u2208 Cm), U \u2229 (ball (0 : euclidean_space \u211d (fin n)) m) \u2260 \u2205), from sorry,\n  have h2 : \u2200 m : \u2115, \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) m)) \u2227 U \u2286 (\u22c3 (V : set (euclidean_space \u211d (fin n))) (hV : V \u2208 A), V), from sorry,\n  have h3 : \u2200 m : \u2115, \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) m)), from sorry,\n  have h4 : \u2200 m : \u2115, \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm, from sorry,\n  have h5 : \u2200 m : \u2115, \u2203 (Cm : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) m)), from sorry,\n  have h6 : \u2200 m : \u2115, \u2203 (Cm : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) m)), from sorry,\n  have h7 : \u2203 (C : set (euclidean_space \u211d (fin n))), is_open_cover C \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h8 : \u2203 (C : set (euclidean_space \u211d (fin n))), is_open_cover C \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h9 : \u2203 (C : set (euclidean_space \u211d (fin n))), is_open_cover C, from sorry,\n  have h10 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h11 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h12 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h13 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h14 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h15 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h16 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h17 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h18 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n  have h19 : \u2203 (C : set (euclidean_space \u211d (fin n))), \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 C \u2192 U \u2286 (euclidean_space \u211d (fin n)) \\ (closure (ball (0 : euclidean_space \u211d (fin n)) 0)), from sorry,\n\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open_cover A),\n  have h1 : \u2200 (m : \u2115), is_compact (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h2 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h3 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h4 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h5 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h6 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h7 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h8 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h9 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h10 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h11 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h12 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h13 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h14 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h15 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h16 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h17 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h18 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h19 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 is_finite Cm \u2227 \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2192 U \u2286 (closed_ball (0 : \u211d^(fin n)) m), from sorry,\n  have h20 : \u2200 (m : \u2115), \u2203 (Cm : set (euclidean_space \u211d (fin 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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  \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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.2_max_tokens_2000_n_3/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.6150878555160665, "lm_q2_score": 0.34510527769342453, "lm_q1q2_score": 0.2122700651837251}}
{"text": "import Qq\nopen Qq Lean Elab Meta Tactic\n\nelab \"print_conjs\" : tactic => do\n  for ldecl in \u2190 getLCtx do\n    if let some ty \u2190 checkTypeQ (u := levelOne) ldecl.type q(Prop) then\n      if let ~q($p \u2227 $q) := ty then\n        logInfo m!\"left = {p}, right = {q}\"\n\nexample (h : true \u2227 False) : true := by\n  print_conjs\n  trivial", "meta": {"author": "gebner", "repo": "quote4", "sha": "c71f94e34c1cda52eef5c93dc9da409ab2727420", "save_path": "github-repos/lean/gebner-quote4", "path": "github-repos/lean/gebner-quote4/quote4-c71f94e34c1cda52eef5c93dc9da409ab2727420/examples/conjs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5156199157230157, "lm_q2_score": 0.411110869232168, "lm_q1q2_score": 0.21197695174630618}}
{"text": "import data.cpi.transition.basic\n\nnamespace cpi\nnamespace transition\n\nvariables {\u210d : Type} {\u03c9 : context}\nopen_locale congruence\n\nopen species.equiv\n\nprivate def no_rename_zero {\u0393} {n} {p : upair (fin n)} {q : upair (name \u0393)}\n  : upair.map name.extend q \u2260 upair.map name.zero p\n  := upair.rec_on q\n\n    (\u03bb a b eql, begin\n      rcases upair.exists_rep p with \u27e8 a', b', \u27e8 _ \u27e9 \u27e9,\n      rcases quotient.exact eql with \u27e8 l, _ \u27e9 | \u27e8 l, _ \u27e9; cases l\n    end)\n    (\u03bb a b, function.hfunext (by rw upair.mk.comm) (\u03bb a\u2082 b\u2082 _, heq.rfl))\n\nprivate def on_parallel_assoc\u2081_left {\u0393 \u2113} {A B C : species \u210d \u03c9 \u0393} :\n  \u2200 {\u03b1 : label \u210d \u0393 kind.species} {E : species \u210d \u03c9 \u0393}\n  , (A |\u209b B) [\u2113, \u03b1]\u27f6 (production.species E)\n  \u2192 \u03a3' E' (eq : production.species (E |\u209b C) \u2248 E')\n    , (A |\u209b B |\u209b C) [\u2113, \u03b1]\u27f6 E'\n| \u03b1 E (@com\u2081 _ _ _ _ x y _ _ a b F G _ _ rfl rfl tf tg) :=\n  \u27e8 _, production.equiv.species (symm (concretion.pseudo_apply.on_parallel\u2081 _ _ C)),\n   com\u2081 rfl rfl tf (parL_concretion C tg) \u27e9\n| \u03b1 E (parL_species C t) :=\n  \u27e8 _, production.equiv.species parallel_assoc\u2081, parL_species _ t \u27e9\n| \u03b1 E (parR_species _ t) :=\n  \u27e8 _, production.equiv.species equiv.parallel_assoc\u2081, parR_species _ (parL_species _ t) \u27e9\n\nprivate def on_parallel_assoc\u2081 {\u0393 \u2113} {A B C : species \u210d \u03c9 \u0393} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n  , ((A |\u209b B) |\u209b C) [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' E' (eq : E \u2248 E'), (A |\u209b B |\u209b C) [\u2113, \u03b1]\u27f6 E'\n| k \u03b1 E (@com\u2081 _ _ _ _ x y _ _ a b _ G _ _ rfl rfl (parL_concretion D tf) tg) :=\n  \u27e8 _, production.equiv.species (concretion.pseudo_apply.parallel_shift _ B G),\n   com\u2081 rfl rfl tf (parR_concretion _ tg) \u27e9\n| k \u03b1 E (@com\u2081 _ _ _ _ x y _ _ a b _ G _ _ rfl rfl (parR_concretion D tf) tg) :=\n  \u27e8 _, production.equiv.species (concretion.pseudo_apply.on_parallel\u2082' A _ G),\n   parR_species A (com\u2081 rfl rfl tf tg) \u27e9\n| k \u03b1 E (parL_species _ t) := on_parallel_assoc\u2081_left t\n| k \u03b1 E (parL_concretion B (parL_concretion C t)) :=\n  \u27e8 _, production.equiv.concretion concretion.equiv.parallel_assoc\u2081, parL_concretion _ t \u27e9\n| k \u03b1 E (parL_concretion C (parR_concretion D t)) :=\n  \u27e8 _, production.equiv.concretion concretion.equiv.parallel_assoc\u2082, parR_concretion _ (parL_concretion _ t) \u27e9\n| k \u03b1 E (parR_species D t) :=\n  \u27e8 _, production.equiv.species equiv.parallel_assoc\u2081, parR_species A (parR_species B t) \u27e9\n| k \u03b1 E (parR_concretion D t) :=\n  \u27e8 _, production.equiv.concretion concretion.equiv.parallel_assoc\u2083, parR_concretion A (parR_concretion B t) \u27e9\n\nprivate def on_parallel_symm {\u0393 \u2113} {A B : species \u210d \u03c9 \u0393} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n  , (A |\u209b B) [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' E' (eq : E \u2248 E'), (B |\u209b A) [\u2113, \u03b1]\u27f6 E'\n| ._ ._ ._ (@com\u2081 _ _ _ _ x y _ _ a b F G _ _ rfl rfl tf tg) := begin\n    rw upair.eq a b,\n    from \u27e8 _, production.equiv.species (concretion.pseudo_apply.symm F G), com\u2081 rfl rfl tg tf \u27e9\n  end\n| k \u03b1 ._ (parL_species _ t) := \u27e8 _, production.equiv.species parallel_symm, parR_species B t \u27e9\n| k \u03b1 ._ (parL_concretion _ t) := \u27e8 _, production.equiv.concretion concretion.equiv.parallel_symm, parR_concretion B t \u27e9\n| k \u03b1 ._ (parR_species _ t) := \u27e8 _, production.equiv.species parallel_symm, parL_species A t \u27e9\n| k \u03b1 ._ (parR_concretion _ t) := \u27e8 _, production.equiv.concretion (symm concretion.equiv.parallel_symm), parL_concretion A t \u27e9\n\nprivate def on_parallel_assoc\u2082_species {\u0393 \u2113} {A B C : species \u210d \u03c9 \u0393} :\n  \u2200 {\u03b1 : label \u210d \u0393 kind.species} {E : species \u210d \u03c9 \u0393}\n  , (B |\u209b C) [\u2113, \u03b1]\u27f6 (production.species E)\n  \u2192 \u03a3' (E' : production \u210d \u03c9 \u0393 kind.species) (eq : production.species (A |\u209b E) \u2248 E')\n    , ((A |\u209b B) |\u209b C) [\u2113, \u03b1]\u27f6 E'\n| \u03b1 E (parL_species _ t) :=\n  \u27e8 _, production.equiv.species equiv.parallel_assoc\u2082, parL_species _ (parR_species _ t) \u27e9\n| \u03b1 E (parR_species _ t) :=\n  \u27e8 _, production.equiv.species equiv.parallel_assoc\u2082, parR_species _ t \u27e9\n| \u03b1 E (com\u2081 rfl rfl tf tg) :=\n  \u27e8 _, production.equiv.species (concretion.pseudo_apply.on_parallel\u2082' A _ _).symm,\n   com\u2081 rfl rfl (parR_concretion _ tf) tg \u27e9\n\nprivate def on_parallel_assoc\u2082_concretion {\u0393 \u2113} {A B C : species \u210d \u03c9 \u0393} {b y} :\n  \u2200 {\u03b1 : label \u210d \u0393 kind.concretion} {E : concretion \u210d \u03c9 \u0393 b y}\n  , (B |\u209b C) [\u2113, \u03b1]\u27f6 (production.concretion E)\n  \u2192 \u03a3' (E' : production \u210d \u03c9 \u0393 kind.concretion) (eq : production.concretion (A |\u2082 E) \u2248 E')\n    , ((A |\u209b B) |\u209b C) [\u2113, \u03b1]\u27f6 E'\n| \u03b1 E (parL_concretion _ t) :=\n  \u27e8 _, production.equiv.concretion concretion.equiv.parallel_assoc\u2082.symm\n   , parL_concretion _ (parR_concretion _ t) \u27e9\n| \u03b1 E (parR_concretion _ t) :=\n  \u27e8 _, production.equiv.concretion concretion.equiv.parallel_assoc\u2083.symm, parR_concretion _ t \u27e9\n\nprivate def on_parallel_assoc\u2082 {\u0393 \u2113} {A B C : species \u210d \u03c9 \u0393} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n  , (A |\u209b B |\u209b C) [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' E' (eq : E \u2248 E'), ((A |\u209b B) |\u209b C) [\u2113, \u03b1]\u27f6 E'\n| ._ \u03b1 E (@com\u2081 _ _ _ _ x y _ _ a b F G _ _ rfl rfl tf (parL_concretion _ tg)) :=\n  \u27e8 _, production.equiv.species (concretion.pseudo_apply.on_parallel\u2081 F _ C),\n   parL_species _ (com\u2081 rfl rfl tf tg) \u27e9\n| ._ \u03b1 E (@com\u2081 _ _ _ _ x y _ _ a b F G _ _ rfl rfl tf (parR_concretion _ tg)) :=\n  \u27e8 _, production.equiv.species (concretion.pseudo_apply.parallel_shift F B _).symm,\n    com\u2081 rfl rfl (parL_concretion _ tf) tg \u27e9\n| k \u03b1 ._ (parL_species _ t) :=\n  \u27e8 _, production.equiv.species equiv.parallel_assoc\u2082, parL_species _ (parL_species _ t) \u27e9\n| k \u03b1 ._ (parL_concretion _ t) :=\n  \u27e8 _, production.equiv.concretion concretion.equiv.parallel_assoc\u2081.symm, parL_concretion _ (parL_concretion _ t) \u27e9\n| k \u03b1 ._ (parR_species _ t) := on_parallel_assoc\u2082_species t\n| k \u03b1 ._ (parR_concretion _ t) := on_parallel_assoc\u2082_concretion t\n\nprivate def on_choice_swap {\u0393 \u2113} {As : choices \u210d \u03c9 \u0393} :\n  \u2200 {k f g} {\u03b1 : label \u210d \u0393 k}\n    {\u03c0\u2081 : prefix_expr \u210d \u0393 f} {\u03c0\u2082 : prefix_expr \u210d \u0393 g}\n    {A : species \u210d \u03c9 (f.apply \u0393)} {B : species \u210d \u03c9 (g.apply \u0393)}\n    {E : production \u210d \u03c9 \u0393 k}\n  , (\u03a3# whole.cons \u03c0\u2081 A (whole.cons \u03c0\u2082 B As)) [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' E' (eq : E \u2248 E')\n    , (\u03a3# whole.cons \u03c0\u2082 B (whole.cons \u03c0\u2081 A As)) [\u2113, \u03b1]\u27f6 E'\n| ._ \u03b1 f g \u03c0\u2081 \u03c0\u2082 A B E (choice\u2081 a b b_len y _ _) := \u27e8 _, refl _, \u03be_choice (choice\u2081 a b b_len y _ _) \u27e9\n| ._ \u03b1 f g \u03c0\u2081 \u03c0\u2082 A B E (choice\u2082 k _ _) := \u27e8 _, refl _, \u03be_choice (choice\u2082 k _ _) \u27e9\n| ._ \u03b1 f g \u03c0\u2081 \u03c0\u2082 A B E (\u03be_choice (choice\u2081 a b b_len y _ _)) := \u27e8 _, refl _, choice\u2081 a b b_len y _ _ \u27e9\n| ._ \u03b1 f g \u03c0\u2081 \u03c0\u2082 A B E (\u03be_choice (choice\u2082 k _ _)) := \u27e8 _, refl _, choice\u2082 k _ _ \u27e9\n| k \u03b1 f g \u03c0\u2081 \u03c0\u2082 A B E (\u03be_choice (\u03be_choice t)) := \u27e8 _, refl _, \u03be_choice (\u03be_choice t) \u27e9\n\nprivate def on_\u03bd_parallel\u2082 {\u0393 \u2113} {M : affinity \u210d} {A : species \u210d \u03c9 \u0393} {B : species \u210d \u03c9 (context.extend (M.arity) \u0393)} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n  , (A |\u209b \u03bd(M) B) [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' E' (eq : E \u2248 E'), (\u03bd(M) rename name.extend A |\u209b B) [\u2113, \u03b1]\u27f6 E'\n| ._ ._ _ (com\u2081 rfl rfl tf (\u03bd\u2081_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  \u27e8 _, production.equiv.species (concretion.pseudo_apply.on_restriction _ _ _),\n    \u03bd\u2081_species M rfl (com\u2081 rfl rfl tf' tg) \u27e9\n| k \u03b1 _ (parL_species E t) :=\n  let t' := transition.rename (@name.extend _ M.arity) t in\n  \u27e8 _, production.equiv.species (\u03bd_parallel\u2082 M), \u03bd\u2081_species M rfl (parL_species _ t' ) \u27e9\n| k \u03b1 _ (parL_concretion E t) :=\n  let t' := transition.rename (@name.extend _ M.arity) t in\n  \u27e8 _, production.equiv.concretion (concretion.equiv.\u03bd_parallel\u2082 M).symm,\n   \u03bd\u2081_concretion M rfl (parL_concretion _ t' ) \u27e9\n\n| k \u03b1 _ (parR_species A (com\u2082 M k' ek rfl t)) :=\n  \u27e8 _, production.equiv.species (\u03bd_parallel\u2082 M), com\u2082 M k' ek rfl (parR_species _ t) \u27e9\n| k \u03b1 _ (parR_species A (\u03bd\u2081_species _ rfl t)) :=\n  \u27e8 _, production.equiv.species (\u03bd_parallel\u2082 M), \u03bd\u2081_species M rfl (parR_species _ t) \u27e9\n| k \u03b1 _ (parR_concretion A (\u03bd\u2081_concretion _ rfl t)) :=\n  \u27e8 _, production.equiv.concretion (concretion.equiv.\u03bd_parallel\u2081 M).symm,\n    \u03bd\u2081_concretion M rfl (parR_concretion _ t) \u27e9\n\nprivate def upair_extend {n} {\u0393} :\n  \u2200 {p : upair (name \u0393)} {a b : name (context.extend n \u0393)}\n  , upair.map name.extend p = upair.mk a b\n  \u2192 \u03a3' (a' b' : name \u0393), p = upair.mk a' b' \u2227 a = name.extend a' \u2227 b = name.extend b'\n| p (name.zero _) (name.zero _) e := false.elim (begin\n  rcases quot.exists_rep p with \u27e8 \u27e8 a, b \u27e9, ep \u27e9, have : upair.mk a b = p := ep, subst this,\n  rcases quotient.exact e with \u27e8 l, r \u27e9 | \u27e8 l, r \u27e9; contradiction,\nend)\n| p (name.zero _) (name.extend _) e := false.elim (begin\n  rcases quot.exists_rep p with \u27e8 \u27e8 a, b \u27e9, ep \u27e9, have : upair.mk a b = p := ep, subst this,\n  rcases quotient.exact e with \u27e8 l, r \u27e9 | \u27e8 l, r \u27e9; contradiction,\nend)\n| p (name.extend _) (name.zero _) e := false.elim (begin\n  rcases quot.exists_rep p with \u27e8 \u27e8 a, b \u27e9, ep \u27e9, have : upair.mk a b = p := ep, subst this,\n  rcases quotient.exact e with \u27e8 l, r \u27e9 | \u27e8 l, r \u27e9; contradiction,\nend)\n| p (name.extend a) (name.extend b) e := \u27e8 a, b, begin\n  have : upair.map name.extend p = upair.map name.extend (upair.mk a b) := e,\n  from \u27e8 upair.map.inj (@name.extend.inj _ _) this, rfl, rfl \u27e9,\nend \u27e9\n\nprivate noncomputable def on_\u03bd_parallel\u2081_species {\u0393 \u2113} {M : affinity \u210d} {A : species \u210d \u03c9 \u0393}\n  {B : species \u210d \u03c9 (context.extend M.arity \u0393)} :\n  \u2200 {A' : species \u210d \u03c9 (context.extend (M.arity) \u0393)}\n    {\u03b1' : label \u210d (context.extend M.arity \u0393) kind.species}\n    {\u03b1 : label \u210d \u0393 kind.species}\n    {E : species \u210d \u03c9 (context.extend M.arity \u0393)}\n  , (A' |\u209b B) [lookup.rename name.extend \u2113, \u03b1']\u27f6 (production.species E)\n  \u2192 A' = rename name.extend A \u2192 \u03b1' = label.rename name.extend \u03b1\n  \u2192 \u03a3' E' (eq : production.species (\u03bd(M)E) \u2248 E')\n    , (A |\u209b \u03bd(M) B) [\u2113, \u03b1]\u27f6 E'\n| A' \u03b1' \u03b1 E (parL_species _ t) eqA eq\u03b1 := begin\n  subst eqA, subst eq\u03b1,\n  rcases transition.rename_from name.extend t with \u27e8 \u03b1\u2082, \u27e8 B \u27e9, t\u2082, e\u03b1, eB \u27e9,\n  cases label.rename.inj (@name.extend.inj _ _) e\u03b1,\n  rw \u2190 production.species.inj eB,\n  from \u27e8 _, production.equiv.species (\u03bd_parallel\u2081 M), parL_species _ t\u2082 \u27e9,\nend\n| A' \u03b1' \u03b1 E (parR_species _ t) eqA eq\u03b1 := begin\n  subst eqA, subst eq\u03b1,\n  from \u27e8 _, production.equiv.species (\u03bd_parallel\u2081 M), parR_species _ (\u03bd\u2081_species M rfl t) \u27e9,\nend\n| A' \u03b1' \u03b1 E (@com\u2081 _ _ _ _ x y _ _ a b F G _ _ rfl e\u03b1 tf tg) eqA eq\u03b1 := begin\n  subst eqA, subst eq\u03b1,\n\n  cases \u03b1 with _ _ _ _ _ p,\n  case label.spontaneous { cases e\u03b1 },\n\n  rcases upair_extend (label.of_affinity.inj e\u03b1) with \u27e8 a, b, \u27e8 _ \u27e9, \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n  rcases transition.rename_from name.extend tf with \u27e8 \u27e8 a\u2082 \u27e9, \u27e8 F \u27e9, tf\u2082, \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n\n  from \u27e8 _, production.equiv.species (concretion.pseudo_apply.on_restriction _ M _).symm,\n    com\u2081 rfl rfl tf\u2082 (\u03bd\u2081_concretion M rfl tg) \u27e9,\nend\n\nprivate noncomputable def on_\u03bd_parallel\u2081_concretion {\u0393 \u2113} {M : affinity \u210d} {A : species \u210d \u03c9 \u0393}\n  {B : species \u210d \u03c9 (context.extend M.arity \u0393)} {b y} :\n  \u2200 {A' : species \u210d \u03c9 (context.extend (M.arity) \u0393)}\n    {\u03b1' : label \u210d (context.extend M.arity \u0393) kind.concretion}\n    {\u03b1 : label \u210d \u0393 kind.concretion}\n    {E : concretion \u210d \u03c9 (context.extend M.arity \u0393) b y}\n  , (A' |\u209b B) [lookup.rename name.extend \u2113, \u03b1']\u27f6 (production.concretion E)\n  \u2192 A' = rename name.extend A \u2192 \u03b1' = label.rename name.extend \u03b1\n  \u2192 \u03a3' E' (eq : production.concretion (\u03bd'(M)E) \u2248 E')\n    , (A |\u209b \u03bd(M) B) [\u2113, \u03b1]\u27f6 E'\n| A' \u03b1' \u03b1 E (parL_concretion _ t) eqA eq\u03b1 := begin\n  subst eqA, subst eq\u03b1,\n  rcases transition.rename_from name.extend t with \u27e8 \u03b1\u2082, \u27e8 B \u27e9, t\u2082, e\u03b1, \u27e8 _ \u27e9 \u27e9,\n  cases label.rename.inj (@name.extend.inj _ _) e\u03b1,\n  from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03bd_parallel\u2082 M), parL_concretion _ t\u2082 \u27e9,\nend\n| A' \u03b1' \u03b1 E (parR_concretion _ t) eqA eq\u03b1 := begin\n  subst eqA, subst eq\u03b1,\n  from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03bd_parallel\u2081 M), parR_concretion _ (\u03bd\u2081_concretion M rfl t) \u27e9,\nend\n\nprivate noncomputable def on_\u03bd_parallel\u2081 {\u0393 \u2113} {M : affinity \u210d} {A : species \u210d \u03c9 \u0393}\n  {B : species \u210d \u03c9 (context.extend (M.arity) \u0393)} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n  , (\u03bd(M) rename name.extend A |\u209b B) [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' E' (eq : E \u2248 E'), (A |\u209b \u03bd(M) B) [\u2113, \u03b1]\u27f6 E'\n| k \u03b1 ._ (\u03bd\u2081_species M rfl t) := on_\u03bd_parallel\u2081_species t rfl rfl\n| k \u03b1 ._ (\u03bd\u2081_concretion M rfl t) := on_\u03bd_parallel\u2081_concretion t rfl rfl\n| ._ \u03b1 ._ (@com\u2082 _ _ _ _ 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 \u27e8 \u03b1\u2082, \u27e8 E \u27e9, tf\u2082, e\u03b1, eE \u27e9, -- Annoying!\n\n    cases \u03b1\u2082; simp only [label.rename] at e\u03b1,\n    case label.spontaneous { cases e\u03b1 },\n    from absurd e\u03b1 no_rename_zero,\n  },\n  case parR_species : E t {\n    subst eqA,\n    from \u27e8 _, production.equiv.species (\u03bd_parallel\u2081 M), parR_species _ (com\u2082 M k ek rfl t ) \u27e9,\n  },\n  case com\u2081 : x y a b F G eF e\u03b1 tf tg {\n    subst eqA, exfalso,\n\n    rcases transition.rename_from name.extend tf with \u27e8 \u03b1\u2082, \u27e8 E \u27e9, tf\u2082, e\u03b1', eE \u27e9, -- Annoying!\n    cases \u03b1\u2082, simp only [label.rename] at e\u03b1', subst e\u03b1',\n\n    rcases upair.exists_rep p with \u27e8 p\u2081, p\u2082, h \u27e9, subst h,\n    rcases quotient.exact (label.of_affinity.inj e\u03b1) with \u27e8 l, r \u27e9 | \u27e8 l, r \u27e9; contradiction,\n  }\nend\n\nprivate noncomputable def on_\u03bd_drop\u2081 {\u0393 \u2113} {M : affinity \u210d} {A : species \u210d \u03c9 \u0393} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n  , (\u03bd(M) species.rename name.extend A) [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' (E' : production \u210d \u03c9 \u0393 k) (eq : E \u2248 E'), A [\u2113, \u03b1]\u27f6 E'\n| k \u03b1 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\u2082 : a b B k eqk eq\u03b1 t' {\n    subst eqA, subst eq\u03b1, exfalso,\n\n    rcases transition.rename_from name.extend t' with \u27e8 \u03b1\u2082, \u27e8 E\u2082 \u27e9 , t\u2082, eq\u03b1, eqE \u27e9,\n    cases \u03b1\u2082; simp only [label.rename] at eq\u03b1,\n    case label.spontaneous { cases eq\u03b1 },\n    from absurd eq\u03b1 no_rename_zero,\n  },\n  case \u03bd\u2081_species : \u03b1\u2081 \u03b1\u2082 E e\u03b1 t' {\n    subst eqA, subst e\u03b1,\n    rcases transition.rename_from name.extend t' with \u27e8 \u03b1\u2082, \u27e8 E\u2082 \u27e9 , t\u2082, eq\u03b1, eqE \u27e9,\n    cases label.rename.inj (@name.extend.inj _ _) eq\u03b1,\n    rw \u2190 production.species.inj eqE,\n    from \u27e8 _, production.equiv.species (\u03bd_drop\u2081 M), t\u2082 \u27e9,\n  },\n  case \u03bd\u2081_concretion : \u03b1\u2081 \u03b1\u2082 b y E e\u03b1 t' {\n    subst eqA, subst e\u03b1,\n    rcases transition.rename_from name.extend t' with \u27e8 \u03b1\u2082, \u27e8 E\u2082 \u27e9 , t\u2082, eq\u03b1, \u27e8 _ \u27e9 \u27e9,\n    cases label.rename.inj (@name.extend.inj _ _) eq\u03b1,\n    from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03bd_drop M), t\u2082 \u27e9,\n  }\nend\n\nprivate def on_\u03bd_drop\u2082 {\u0393 \u2113} {M : affinity \u210d} {A : species \u210d \u03c9 \u0393} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n  , A [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' (E' : production \u210d \u03c9 \u0393 k) (eq : E \u2248 E'), (\u03bd(M) species.rename name.extend A) [\u2113, \u03b1]\u27f6 E'\n| k \u03b1 (production.species E) t :=\n  let t' := transition.rename (@name.extend _ M.arity) t in\n  \u27e8 _, production.equiv.species (\u03bd_drop\u2082 M), \u03bd\u2081_species M rfl t' \u27e9\n| k \u03b1 (production.concretion E) t :=\n  let t' := transition.rename (@name.extend _ M.arity) t in\n  \u27e8 _, production.equiv.concretion (concretion.equiv.\u03bd_drop M).symm, \u03bd\u2081_concretion M rfl t' \u27e9\n\nprivate def on_\u03bd_swap\u2081 {\u0393 \u2113} {M N : affinity \u210d} {A : species \u210d \u03c9 (context.extend (N.arity) (context.extend (M.arity) \u0393))} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n    , (\u03bd(M) \u03bd(N) A) [\u2113, \u03b1]\u27f6 E\n    \u2192 \u03a3' (E' : production \u210d \u03c9 \u0393 k) (eq : E \u2248 E')\n      , (\u03bd(N) \u03bd(M) species.rename name.swap A) [\u2113, \u03b1]\u27f6 E'\n| ._ \u03b1 E\u2081 (\u03bd\u2081_species _ e\u03b1\u2081 (\u03bd\u2081_species _ e\u03b1\u2082 t)) := begin\n  subst e\u03b1\u2081, subst e\u03b1\u2082,\n  have t' := transition.rename name.swap t,\n  rw [label.rename_compose, label.rename_compose, name.swap_comp_extend, name.ext_extend, \u2190 label.rename_compose] at t',\n  rw [lookup.rename_compose, lookup.rename_compose, name.swap_comp_extend, name.ext_extend, \u2190 lookup.rename_compose] at t',\n  from \u27e8 _, production.equiv.species (\u03bd_swap\u2081 M N), \u03bd\u2081_species N rfl (\u03bd\u2081_species M rfl t' ) \u27e9,\nend\n| ._ \u03b1 E\u2081 (\u03bd\u2081_species _ e\u03b1 (com\u2082 _ k ek rfl t)) := begin\n  cases \u03b1; simp only [label.rename] at e\u03b1,\n  case label.of_affinity { contradiction },\n  subst e\u03b1,\n\n  have t' := transition.rename name.swap t,\n  rw [lookup.rename_compose, lookup.rename_compose, name.swap_comp_extend, name.ext_extend, \u2190 lookup.rename_compose] at t',\n  refine \u27e8 _, production.equiv.species (\u03bd_swap\u2081 M N), com\u2082 N k ek rfl (\u03bd\u2081_species M _ t') \u27e9,\n\n  simp only [label.rename, upair.map_compose, function.comp, name.swap],\nend\n| ._ \u03b1 E\u2081 (\u03bd\u2081_concretion _ rfl (\u03bd\u2081_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, \u2190 label.rename_compose] at t',\n  rw [lookup.rename_compose, lookup.rename_compose, name.swap_comp_extend, name.ext_extend, \u2190 lookup.rename_compose] at t',\n  from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03bd_swap M N), \u03bd\u2081_concretion N rfl (\u03bd\u2081_concretion M rfl t' ) \u27e9,\nend\n| ._ \u03b1 E\u2081 (com\u2082 _ k ek rfl (\u03bd\u2081_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, \u2190 lookup.rename_compose] at t',\n  refine \u27e8 _, production.equiv.species (\u03bd_swap\u2081 M N), \u03bd\u2081_species N rfl (com\u2082 M k ek _ t') \u27e9,\n\n  rw [upair.map_compose, upair.map_compose, name.swap_comp_extend, name.ext_zero],\nend\n\nprivate def on_\u03bd_swap\u2082 {\u0393 \u2113} {M N : affinity \u210d} {A : species \u210d \u03c9 (context.extend (N.arity) (context.extend (M.arity) \u0393))}:\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n  , (\u03bd(N) \u03bd(M) species.rename name.swap A) [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' (E' : production \u210d \u03c9 \u0393 k) (eq : E \u2248 E'), (\u03bd(M) \u03bd(N) A) [\u2113, \u03b1]\u27f6 E'\n| k \u03b1 E\u2081 t := begin\n  rcases on_\u03bd_swap\u2081 t with \u27e8 E', eqE, t' \u27e9,\n  rw [species.rename_compose, name.swap_swap, species.rename_id] at t',\n  from \u27e8 E', eqE, t' \u27e9,\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  \u2200 {\u0393 \u2113 k} {A : species \u210d \u03c9 \u0393} {B : species \u210d \u03c9 \u0393} {\u03b1 : label \u210d \u0393 k} {E : production \u210d \u03c9 \u0393 k}\n  , species.equivalent A B \u2192 A [\u2113, \u03b1]\u27f6 E\n  \u2192 \u03a3' (E' : production \u210d \u03c9 \u0393 k) (eq : E \u2248 E'), B [\u2113, \u03b1]\u27f6 E'\n| \u0393\u2081 \u2113\u2081 k\u2081 A\u2081 B\u2081 \u03b1\u2081 E\u2081 equ t\u2081 := begin\n  induction equ generalizing k\u2081,\n\n  case species.equivalent.refl { from \u27e8 E\u2081, refl _, t\u2081 \u27e9 },\n  case species.equivalent.trans : \u0393 A B C ab bc ih_ab ih_bc {\n    rcases ih_ab _ _ \u03b1\u2081 E\u2081 t\u2081 with \u27e8 E\u2082, eq\u2082, t\u2082 \u27e9,\n    rcases ih_bc _ _ \u03b1\u2081 E\u2082 t\u2082 with \u27e8 E\u2083, eq\u2083, t\u2083 \u27e9,\n    from \u27e8 E\u2083, trans eq\u2082 eq\u2083, t\u2083 \u27e9\n  },\n\n  case species.equivalent.\u03be_parallel\u2081 : \u0393 A A' B eq ih {\n    cases t\u2081,\n    case com\u2081 : x y a b F G E' \u03b1' eE e\u03b1 tf tg {\n      subst eE, subst e\u03b1,\n      rcases ih _ _ (#a) _ tf with \u27e8 F', equ, tf' \u27e9, cases F' with _ b y' F',\n      rcases production.equiv.arity equ with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n\n      from \u27e8 _, production.equiv.species (concretion.pseudo_apply.equiv (production.equiv.unwrap_c equ) (refl G)),\n             com\u2081 rfl rfl tf' tg \u27e9,\n    },\n    case parL_species : \u03b1' E t {\n      rcases ih _ _ _ _ t with \u27e8 E', equ, t' \u27e9, cases E',\n      from \u27e8 _, production.equiv.species (\u03be_parallel\u2081 (production.equiv.unwrap_s equ)), parL_species B t' \u27e9\n    },\n    case parL_concretion : \u03b1' b y E t {\n      rcases ih _ _ _ _ t with \u27e8 E', equ, t' \u27e9, cases E',\n      rcases production.equiv.arity equ with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n      from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03be_parallel\u2081 (production.equiv.unwrap_c equ)),\n        parL_concretion _ t' \u27e9,\n    },\n    case parR_species : \u03b1' E t {\n      from \u27e8 _, production.equiv.species (\u03be_parallel\u2081 \u27e8 eq \u27e9), parR_species _ t \u27e9,\n    },\n    case parR_concretion : \u03b1' b y E t {\n      from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03be_parallel' \u27e8 eq \u27e9), parR_concretion _ t \u27e9,\n    },\n  },\n\n  case species.equivalent.\u03be_parallel\u2082 : \u0393 A B B' eq ih {\n    cases t\u2081,\n    case com\u2081 : x y a b F G E' \u03b1' eE e\u03b1 tf tg {\n      subst eE, subst e\u03b1,\n      rcases ih _ _ (#b) _ tg with \u27e8 G', equ, tg' \u27e9, cases G' with _ b y' G',\n      rcases production.equiv.arity equ with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n      from \u27e8 _, production.equiv.species (concretion.pseudo_apply.equiv (refl F) (production.equiv.unwrap_c equ)),\n             com\u2081 rfl rfl tf tg' \u27e9,\n    },\n    case parL_species : \u03b1' E t {\n      from \u27e8 _, production.equiv.species (\u03be_parallel\u2082 \u27e8 eq \u27e9), parL_species _ t \u27e9,\n    },\n    case parL_concretion : \u03b1' b y E t {\n      from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03be_parallel \u27e8 eq \u27e9), parL_concretion _ t \u27e9,\n    },\n    case parR_species : \u03b1' E t {\n      rcases ih _ _ _ _ t with \u27e8 E', equ, t' \u27e9, cases E',\n      from \u27e8 _, production.equiv.species (\u03be_parallel\u2082 (production.equiv.unwrap_s equ)), parR_species _ t' \u27e9\n    },\n    case parR_concretion : \u03b1' b y E t {\n      rcases ih _ _ _ _ t with \u27e8 E', equ, t' \u27e9, cases E',\n      rcases production.equiv.arity equ with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n      from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03be_parallel\u2082 (production.equiv.unwrap_c equ)),\n        parR_concretion _ t' \u27e9,\n    },\n  },\n\n  case species.equivalent.\u03be_restriction : \u0393 M A A' eq ih {\n    cases t\u2081,\n\n    case com\u2082 : p p' B k ek ep t {\n      rcases ih _ _ _ _ t with \u27e8 E', equ, t' \u27e9,\n      cases E' with B',\n\n      from \u27e8 _, production.equiv.species (\u03be_restriction M (production.equiv.unwrap_s equ)), com\u2082 M k ek ep t' \u27e9,\n    },\n    case \u03bd\u2081_species : \u03b1 \u03b1' E e\u03b1 t {\n      rcases ih _ _ _ _ t with \u27e8 E', equ, t' \u27e9, cases E',\n      from \u27e8 _, production.equiv.species (\u03be_restriction M (production.equiv.unwrap_s equ)),\n        \u03bd\u2081_species M e\u03b1 t' \u27e9,\n    },\n    case \u03bd\u2081_concretion : \u03b1 \u03b1' b y E e\u03b1 t {\n      rcases ih _ _ _ _ t with \u27e8 E', equ, t' \u27e9, cases E',\n      rcases production.equiv.arity equ with \u27e8 \u27e8 _ \u27e9, \u27e8 _ \u27e9 \u27e9,\n      from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03be_restriction M (production.equiv.unwrap_c equ)),\n        \u03bd\u2081_concretion M e\u03b1 t' \u27e9,\n    },\n  },\n\n  case species.equivalent.\u03be_choice_here : \u0393 f \u03c0 A A' As eq ih {\n    cases t\u2081,\n    case \u03be_choice : t { refine \u27e8 _, refl _, \u03be_choice t \u27e9 },\n    case choice\u2081 : a n b b_len y {\n      from \u27e8 _, production.equiv.concretion (concretion.equiv.\u03be_apply \u27e8 eq \u27e9), choice\u2081 a b b_len y A' As \u27e9,\n    },\n    case choice\u2082 : k { from \u27e8 _, production.equiv.species \u27e8 eq \u27e9, choice\u2082 k A' As \u27e9 },\n  },\n\n  case species.equivalent.\u03be_choice_there : \u0393 f \u03c0 A As As' eq ih {\n    cases t\u2081,\n\n    case \u03be_choice : t {\n      rcases ih _ _ \u03b1\u2081 E\u2081 t with \u27e8 E', equ, t' \u27e9,\n      refine \u27e8 _, equ, \u03be_choice t' \u27e9,\n    },\n    case choice\u2081 : a n b b_len y A As { from \u27e8 _, refl _, choice\u2081 a b b_len y A As' \u27e9 },\n    case choice\u2082 : k A As { from \u27e8 _, refl _, choice\u2082 k A As' \u27e9 },\n  },\n\n  case species.equivalent.parallel_nil\u2081 : \u0393 A {\n    cases t\u2081,\n\n    -- No such transition for (nil \u27f6 _)\n    case com\u2081 : x y a b F G FG \u03b1 eFG e\u03b1 tf tg { cases tg },\n    case parR_species : \u03b1 E t { cases t },\n    case parR_concretion : \u03b1 b y E t { cases t },\n    case parL_species : \u03b1 E t { from \u27e8 _, production.equiv.species parallel_nil\u2081, t \u27e9 },\n    case parL_concretion : \u03b1 b y E t { from \u27e8 _, production.equiv.concretion concretion.equiv.parallel_nil, t \u27e9 },\n  },\n\n  case species.equivalent.parallel_nil\u2082 : \u0393 B {\n    cases E\u2081,\n    case production.species { from \u27e8 _, production.equiv.species parallel_nil\u2082, parL_species _ t\u2081 \u27e9 },\n    case production.concretion { from \u27e8 _, production.equiv.concretion concretion.equiv.parallel_nil.symm, parL_concretion _ t\u2081 \u27e9 },\n  },\n\n  case species.equivalent.choice_swap { from on_choice_swap t\u2081 },\n\n  case species.equivalent.parallel_assoc\u2081 { from on_parallel_assoc\u2081 t\u2081 },\n  case species.equivalent.parallel_assoc\u2082 { from on_parallel_assoc\u2082 t\u2081 },\n\n  case species.equivalent.parallel_symm { from on_parallel_symm t\u2081 },\n\n  case species.equivalent.\u03bd_parallel\u2081 { from on_\u03bd_parallel\u2081 t\u2081 },\n  case species.equivalent.\u03bd_parallel\u2082 { from on_\u03bd_parallel\u2082 t\u2081 },\n  case species.equivalent.\u03bd_drop\u2081 { from on_\u03bd_drop\u2081 t\u2081 },\n  case species.equivalent.\u03bd_drop\u2082 { from on_\u03bd_drop\u2082 t\u2081 },\n  case species.equivalent.\u03bd_swap\u2081 { from on_\u03bd_swap\u2081 t\u2081 },\n  case species.equivalent.\u03bd_swap\u2082 { from on_\u03bd_swap\u2082 t\u2081 },\nend\n\n/-- Drops the congruence restriction from `equivalent_of`. -/\nnoncomputable def equivalent_of.map {\u0393 \u2113} {A B : species \u210d \u03c9 \u0393} (h : species.equivalent A B)\n  {k} {\u03b1 : label \u210d \u0393 k}\n  : (\u03a3 (E : production \u210d \u03c9 \u0393 k), A [\u2113, \u03b1]\u27f6 E)\n  \u2192 (\u03a3 (E : production \u210d \u03c9 \u0393 k), B [\u2113, \u03b1]\u27f6 E)\n| \u27e8 E, t \u27e9 :=\n  let \u27e8 E', _, t' \u27e9 := equivalent_of h t in\n  \u27e8 E', t' \u27e9\n\n/-- Show that 'equivalent_of' twice yields the same thing. This is not going to\n    be fun. -/\naxiom equivalent_of.map_map {\u0393 \u2113} {A B : species \u210d \u03c9 \u0393} (h : species.equivalent A B)\n    {k} {\u03b1 : label \u210d \u0393 k} (t : \u03a3 (E : production \u210d \u03c9 \u0393 k), A [\u2113, \u03b1]\u27f6 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 {\u0393 \u2113} {A B : species \u210d \u03c9 \u0393} (h : species.equivalent A B)\n    {k} {\u03b1 : label \u210d \u0393 k}\n  : (\u03a3 (E : production \u210d \u03c9 \u0393 k), A [\u2113, \u03b1]\u27f6 E) \u2243 (\u03a3 (E : production \u210d \u03c9 \u0393 k), B [\u2113, \u03b1]\u27f6 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 := \u03bb x, begin\n         have this := equivalent_of.map_map h.symm x,\n         rw \u2190 species.equivalent.symm_symm h at this,\n         from this,\n       end }\n\nlemma equivalent_of.map_equiv {\u0393 \u2113} {A B : species \u210d \u03c9 \u0393} (h : species.equivalent A B)\n    {k} {\u03b1 : label \u210d \u0393 k}\n    (E : production \u210d \u03c9 \u0393 k) (t : A [\u2113, \u03b1]\u27f6 E)\n  : E \u2248 (equivalent_of.map h \u27e8 E, t \u27e9).1 := begin\n  unfold equivalent_of.map,\n  rcases (equivalent_of h t) with \u27e8 E', eqE, t' \u27e9,\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 Mathlib.Tactic.SuccessIfFailWithMsg\n\nexample : True := by\n  success_if_fail_with_msg \"no goals to be solved\" trivial; trivial\n  trivial\n\nexample : Nat \u2192 Nat \u2192 True := by\n  success_if_fail_with_msg \"no goals to be solved\"\n    intro\n    intro\n    trivial\n    trivial\n  intros; trivial\n\ndef err (t : Bool) := if t then\n  \"tactic 'rewrite' failed, equality or iff proof expected\n  n \u2264 Nat.succ n\nn : Nat\n\u22a2 True\"\n  else\n    \"not that message\n\u22a2 True\"\n\nexample (n : Nat) : True := by\n  success_if_fail_with_msg (err true) rw [Nat.le_succ n]\n  trivial\n\nexample : True := by\n  success_if_fail_with_msg (err false) fail \"not that message\"\n  trivial\n\n/- In the following, we use `success_if_fail_with_msg` to write tests for\n`success_if_fail_with_msg`, since the inner one should fail with a certain message. -/\n\nexample : True := by\n  success_if_fail_with_msg \"tactic 'trivial' succeeded, but was expected to fail\"\n    success_if_fail_with_msg \"message\" trivial\n  trivial\n\ndef err\u2082 := \"tactic 'fail \\\"different message!\\\"' failed, but got different error message:\n\ndifferent message!\n\u22a2 True\"\n\nexample : True := by\n  success_if_fail_with_msg err\u2082\n    success_if_fail_with_msg \"message\" fail \"different message!\"\n  trivial\n\nopen Lean Meta Mathlib Tactic\n\ndef alwaysFails : MetaM Unit := do throwError \"I failed!\"\n\ndef doesntFail : MetaM Unit := do\n  try successIfFailWithMessage \"I failed!\" alwaysFails\n  catch _ => throwError \"I *really* failed.\"\n\n#eval doesntFail\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/test/success_if_fail_with_msg.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5234203489363239, "lm_q2_score": 0.4035668537353746, "lm_q1q2_score": 0.2112351034013042}}
{"text": "import number_theory.bernoulli\n\n\n--OUTPUT 1\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\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 \u2260 0, from h,\n      have h3 : (1 : \u211a) \u2260 0, from by auto [ne.symm h2],\n      have h4 : 1 / x \u2260 0, from by auto [div_ne_zero h3],\n      have h5 : x \u2260 0, from ne.symm h,\n      have h6 : (1 + x) \u2260 0, from by auto [add_ne_zero],\n      have h7 : (1 + x) \u2260 0, from h6,\n      have h8 : (1 + x) \u2260 0, from by auto [add_ne_zero],\n      have h9 : 1 + x \u2260 0, from h8,\n      have h10 : (1 + x) \u2260 0, from by auto [add_ne_zero],\n      have h11 : (1 + x) \u2260 0, from by auto [add_ne_zero],\n      have h12 : \u2191(1 + x) \u2260 0, from h11,\n      have h13 : (1 : \u211a) \u2260 0, from by auto [ne.symm h2],\n      have h14 : 1 \u2260 0, from h13,\n      have h15 : (1 : \u211a) \u2260 0, from by auto [ne.symm h2],\n      have h16 : (1 : \u211a) \u2260 0, from by auto [ne.symm h2],\n      have h17 : (1 : \u211a) \u2260 0, from by auto [ne.symm h2],\n      have h18 : (1 : \u211a) \u2260 0, from by auto [ne.symm h2],\n      have h19 : (1 : \u211a) \u2260 0, from by auto [ne.symm h2],\n      have h20 : (1 : \u211a) \u2260 0, from by auto [ne.symm h2],\n      have h21 : 1 + x \u2260 0, from mul_ne_zero (cast h19) (cast h20),\n      have h22 : (1 + x) \u2260 0, from h21,\n      have h23 : (1 + x) \u2260 0, from h22,\n      have h24 : 1 \u2260 0, from ne.symm h2,\n      have h25 : 1 + x \u2260 0, from mul_ne_zero (cast h23) (cast h24),\n      have h26 : (1 + x) \u2260 0, from h25,\n      have h27 : (1 + x) \u2260 0, from by auto [add_ne_zero],\n      have h28 : (1 + x) \u2260 0, from h27,\n      rw show (1 : \u211a) = 1, from rfl,\n      rw show (1 : \u211a) = 1, from rfl,\n      rw show (1 : \u211a) = 1, from rfl,\n      rw show (1 : \u211a) = 1, from rfl,\n      rw show 1 + x = \u2191(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 = (\u2191x : \u211a), from rfl,\n      rw show \u2191(x : \u211a) = (\u2191x : \u211a), from rfl,\n      rw show x = (\u2191x : \u211a), from rfl,\n      rw show \u2191(x : \u211a) = (\u2191x : \u211a), from rfl,\n      rw show x = (\u2191x : \u211a), from rfl,\n      rw show \u2191(x : \u211a) = (\u2191x : \u211a), from rfl,\n      rw show x = (\u2191x : \u211a), from rfl,\n      rw show \u2191(x : \u211a) = (\u2191x : \u211a), from rfl,\n      rw show \u2191(x : \u211a) = (\u2191x : \u211a), from rfl,\n      have h29 : (1 + x) \u2260 0, from by auto [add_ne_zero],\n      have h30 : (1 + x) \u2260 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 \u2191(1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (1 + x), from rfl,\n      rw show (1 + x) = (1 + x), from rfl,\n      rw show \u2191(1 + x) = (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\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 (\u03bb (k : \u2115), (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 (\u03bb (k : \u2115), (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 (\u03bb (k : \u2115), (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k)).eval x : begin\n        apply nat.induction_on d,\n        repeat {rw \u2190add_zero},\n        simp,\n        assume d h,\n        rw [nat.add_succ, polynomial.eval_sum],\n        have h1 : \u2200 k : \u2115, (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 (\u03bb (k : \u2115), (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k)).eval x : rfl,\n  end,\n  have h2 : (polynomial.sum (\u03bb (k : \u2115), (polynomial.C (nat.choose (d + 1) k)) * polynomial.X^k)).eval x = (polynomial.sum (\u03bb (k : \u2115), 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 : \u2200 k : \u2115, (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 : \u2200 k : \u2115, (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 : \u2115) (x : \u211a) :\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 : \u2115) (x : \u211a) :\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 : \u2200 m : \u2115, m \u2264 n \u2192 (m : \u211a) \u2264 n, from \u03bb 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 : \u211a) * x^(0 - 1) : by simp [hd (by linarith)]\n                      ... = (polynomial.bernoulli 0).eval x + (0 : \u211a) : 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 : \u211a) * 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 : \u211a) * (x^d + 1) : by simp [ring]\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * ((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 : \u211a) * ((x + 1)^d - x^d) : by ring\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * (sum (\u03bb (m : \u2115), (d : \u211a) choose m * x^m) (d - 1)) : by rw[polynomial.eval_one, polynomial.eval_one]\n                     ... = (polynomial.bernoulli (d + 1)).eval x + sum (\u03bb (m : \u2115), (d : \u211a) choose m * (d : \u211a) * x^m) (d - 1) : by simp [ring]\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * sum (\u03bb (m : \u2115), m * x^m) (d - 1) : by simp\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * sum (\u03bb (m : \u2115), m * x^m) (d - 1) : by simp\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * sum (\u03bb (m : \u2115), ((m + 1) - 1 : \u211a) * x^m) (d - 1) : by simp\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m - (1 : \u211a) * x^m) (d - 1) : by refl\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 1) - (d : \u211a) * sum (\u03bb (m : \u2115), (1 : \u211a) * x^m) (d - 1) : by simp [sum_sub_sum]\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 1) - (d : \u211a) * (sum (\u03bb (m : \u2115), (1 : \u211a) * x^m) (d - 1)) : by simp\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 1) - (d : \u211a) * (x^(d - 1) + sum (\u03bb (m : \u2115), 1) (d - 2)) : by simp [sum_range_succ]\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 2) - (d : \u211a) * x^(d - 1) : by simp [sum_range_succ]\n                     ... = (polynomial.bernoulli (d + 1)).eval x + (d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 2) - (d : \u211a) * x^(d - 1) : by simp [sum_range_succ]\n                     ... = ((d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 2) + (polynomial.bernoulli (d + 1)).eval x - (d : \u211a) * x^(d - 1)) : by simp\n                     ... = ((d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 2) + ((polynomial.bernoulli (d + 1)).eval x - (d : \u211a) * x^(d - 1))) : by refl\n                     ... = ((d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 2) + ((polynomial.bernoulli (d + 1)).eval x - (d : \u211a) * x^(d - 1))) : by refl\n                     ... = (d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 2) + (polynomial.bernoulli (d + 1)).eval x - (d : \u211a) * x^(d - 1) : by simp\n                     ... = (d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a) * x^m) (d - 2) + (polynomial.bernoulli (d + 1)).eval x - (d : \u211a) * x^(d - 1) : by simp\n                     ... = (d : \u211a) * sum (\u03bb (m : \u2115), (m + 1 : \u211a)\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\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 (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * (polynomial.X : polynomial \u211a)^k) (\u03bb (k : \u2115), k * (polynomial.X : polynomial \u211a)^(k - 1)) =\n    (n + 1) * (polynomial.X : polynomial \u211a) ^ n, from by auto [polynomial.sum],\n    have h2 : polynomial.sum (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * ((polynomial.X : polynomial \u211a)^k)) (\u03bb (k : \u2115), k * ((polynomial.X : polynomial \u211a)^(k - 1))) =\n    polynomial.sum (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * ((polynomial.X : polynomial \u211a)^k)) (\u03bb (k : \u2115), k * x^(k - 1)), from by auto [polynomial.sum],\n    have h3 : n * (1 + x) ^ n - n * x ^ n = polynomial.sum (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * ((polynomial.X : polynomial \u211a)^k)) (\u03bb (k : \u2115), k * ((polynomial.X : polynomial \u211a)^(k - 1))), from\n      calc n * (1 + x) ^ n - n * x ^ n = polynomial.sum (\u03bb (k : \u2115), n * \u2191(choose (n + 1) k) * ((polynomial.X : polynomial \u211a)^k)) (\u03bb (k : \u2115), (k + 1) * ((polynomial.X : polynomial \u211a)^k)) : by auto [polynomial.sum, polynomial.sum, polynomial.sum, polynomial.sum]\n    ... = polynomial.sum (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * ((polynomial.X : polynomial \u211a)^k)) (\u03bb (k : \u2115), k * ((polynomial.X : polynomial \u211a)^k)) + (n + 1) * ((polynomial.X : polynomial \u211a)^n) : by auto [polynomial.sum]\n    ... = (n + 1) * ((polynomial.X : polynomial \u211a)^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 (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * ((polynomial.X : polynomial \u211a)^k)) (\u03bb (k : \u2115), k * ((polynomial.X : polynomial \u211a)^(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 (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * ((polynomial.X : polynomial \u211a)^k)) (\u03bb (k : \u2115), 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 (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * x^k) (\u03bb (k : \u2115), 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 (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * x^k) (\u03bb (k : \u2115), (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 (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * x^k) (\u03bb (k : \u2115), (k + 1) * x^k), from by auto [h6, h7, h8],\n    have h10 : polynomial.sum (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * x^k) (\u03bb (k : \u2115), (k + 1) * x^k) =\n    polynomial.sum (\u03bb (k : \u2115), (n + 1) * \u2191(choose (n + 1) k) * x^k) (\u03bb (k : \u2115), 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 : \u2115) (x : \u211a) :\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 \u2190 mul_assoc,\n    rw \u2190 mul_comm x,\n    rw \u2190 pow_succ,\n    rw mul_comm (l + 1) x,\nend\n\n--OUTPUT 7\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\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 (\u03bb (m : \u2115), C (m + 1) * (X^m + X^(m + 1))) n).eval (1 + x) =\n              (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * (X^m + X^(m + 1))) n).eval x, from by auto [eval_prod],\n    have h2 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * (X^m + X^(m + 1))) n).eval x =\n              (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * X^m) n).eval x +\n              (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * X^(m + 1)) n).eval x, from by auto [eval_prod, eval_add],\n    have h3 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * X^m) n).eval x =\n              (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x *\n              (polynomial.prod (\u03bb (m : \u2115), X^m) n).eval x, from by auto [eval_prod],\n    have h4 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x =\n              (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval 0, from by auto [eval_prod_const],\n    have h5 : (polynomial.prod (\u03bb (m : \u2115), X^m) n).eval x =\n              polynomial.prod (\u03bb (m : \u2115), X) n, from by auto [eval_prod],\n    have h6 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * X^(m + 1)) n).eval x =\n              (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x *\n              (polynomial.prod (\u03bb (m : \u2115), X) n) ^ (n + 1), from by auto [eval_prod],\n    have h7 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * X^(m + 1)) n).eval x =\n              (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x *\n              (polynomial.prod (\u03bb (m : \u2115), X) n) *\n              (polynomial.prod (\u03bb (m : \u2115), X) n) ^ n, from by auto [eval_prod],\n    have h8 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x =\n              (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval 0, from by auto [eval_prod_const],\n    have h9 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * X^m) n).eval (1 + x) =\n              (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval (1 + x) *\n              (polynomial.prod (\u03bb (m : \u2115), X^m) n).eval (1 + x), from by auto [eval_prod],\n    have h10 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * X^(m + 1)) n).eval (1 + x) =\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval (1 + x) *\n               (polynomial.prod (\u03bb (m : \u2115), X) n) *\n               (polynomial.prod (\u03bb (m : \u2115), X) n) ^ n, from by auto [eval_prod],\n    have h11 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval (1 + x) =\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x +\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n) *\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x, from by auto [eval_prod],\n    have h12 : (polynomial.prod (\u03bb (m : \u2115), X^m) n).eval (1 + x) =\n               (polynomial.prod (\u03bb (m : \u2115), X^m) n).eval x, from by auto [eval_prod],\n    have h13 : (polynomial.prod (\u03bb (m : \u2115), X) n) ^ (n + 1) =\n               (polynomial.prod (\u03bb (m : \u2115), X) n) * (polynomial.prod (\u03bb (m : \u2115), X) n) ^ n, from by auto [eval_prod],\n    have h14 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n) *\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x =\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x *\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n), from by auto [eval_prod, mul_comm],\n    have h15 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x =\n               polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n, from by auto [eval_prod_const],\n    have h16 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n) *\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval 0 =\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval 0 *\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n), from by auto [eval_prod, mul_comm],\n    have h17 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n) *\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval x *\n               (polynomial.prod (\u03bb (m : \u2115), X^m) n).eval x =\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * X^m) n).eval x *\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n), from by auto [eval_prod, mul_comm],\n    have h18 : (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n) *\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1)) n).eval 0 *\n               (polynomial.prod (\u03bb (m : \u2115), X^m) n).eval x =\n               (polynomial.prod (\u03bb (m : \u2115), C (m + 1) * X^m) n).eval 0 *\n               (polynomial.prod (\u03bb (m :\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  have h1 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x ^ (m - 1),\n  { assume m x h1,\n    have h2 : \u2200 k : \u2115, k \u2264 m \u2192 (((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) = \u2211 (k : \u2115) 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 = \u2211 (k : \u2115) 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) = \u2211 (k : \u2115) 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 : \u2211 (k : \u2115) in finset.range m, (m * C x ^ (k - 1) * C (mchoose k) * C (1 + x)) = m * \u2211 (k : \u2115) in finset.range m, (C x ^ (k - 1) * C (mchoose k) * C (1 + x)), from by auto [finset.sum_mul],\n    have h7 : \u2211 (k : \u2115) 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 * (\u2211 (k : \u2115) 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 (\u03bb (k : \u2115), C x ^ k * C (mchoose k) + m * C x ^ (k - 1) * C (mchoose k) * C (1 + x)) = finset.sum finset.range m (\u03bb (k : \u2115), 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 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 (polynomial.bernoulli m).eval x = mchoose m, from by auto using [bernoulli_eval, nat.eq_zero_of_le_zero],\n  have h3 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192  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 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 (polynomial.bernoulli m).eval x + m * x ^ (m - 1) = mchoose m + m * x ^ (m - 1), from by auto [h2, h3],\n  have h5 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 (polynomial.bernoulli m).eval (1 + x) = mchoose m + m * x ^ (m - 1), from by auto [h1, h4],\n  by_contradiction h6,\n  have h7 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 (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 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 (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 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 ((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 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 \u2211 (k : \u2115) in finset.range m, (polynomial.bernoulli k).eval (1 + x) + k * (1 + x) ^ (k - 1) = (1 + x) ^ (m - 1) * \u2211 (k : \u2115) in finset.range m, (1 + k) * (1 + x) ^ (k - 1), from by auto [C, has_mul.one] at h9,\n  have h11 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 \u2211 (k : \u2115) in finset.range m, (polynomial.bernoulli k).eval (1 + x) + k * (1 + x) ^ (k - 1) * (C (1 + x)) ^ n = (1 + x) ^ (m - 1) * \u2211 (k : \u2115) 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 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 (1 + x)^m * \u2211 (k : \u2115) in finset.range (m + 1), (((C (1 + x)) ^ k) * C (mchoose k)) = (1 + x) ^ (m - 1) * \u2211 (k : \u2115) 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 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 (1 + x)^m * \u2211 (k : \u2115) in finset.range (m + 1), ((\nend --Needs more than 2000 tokens!\n\n--OUTPUT 9\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\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\u2082_zero,\n  rw polynomial.eval\u2082_zero,\n  ring,\n  rw [h, pow_zero],\n  ring,\n  rw polynomial.eval\u2082_zero,\n  ring,\nend\n\n--OUTPUT 10\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\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 [\u2190 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 [\u2190 mul_assoc, mul_assoc, mul_comm, mul_assoc, mul_assoc, mul_comm, add_mul, add_mul, \u2191_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, \u2190 add_mul, add_mul, \u2190 add_mul, h11, \u2190 add_assoc, mul_comm, mul_assoc],\n    rw [\u2190 mul_add],\n  end,\n  rw h1,\n  rw mul_comm,\n  rw [mul_add, mul_assoc],\n  rw [\u2190 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 [\u2190 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 [\u2190 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 [\u2192 mul_comm, mul_comm (d + 2), \u2190 mul_add],\n  rw add_comm,\n  rw mul_assoc,\n  rw [\u2190 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 [\u2190 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from by auto [h2],\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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 : \u2115) (x : \u211a) :\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": "/-\nCopyright (c) 2019 Robert Y. Lewis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Robert Y. Lewis\n-/\nimport data.set\nimport algebra.category.Mon.basic\n\ndef X : Type := set \u2115\n\ninstance : has_coe_to_sort X Type := set.has_coe_to_sort\n\n@[derive ring] def T := \u2124\n\nclass binclass (T1 T2 : Type)\n\ninstance : binclass \u2124 \u2124 := \u27e8\u27e9\n\n@[derive [ring, binclass \u2124]] def U := \u2124\n\n@[derive \u03bb \u03b1, binclass \u03b1 \u2124] def V := \u2124\n\n-- test instance naming\nexample := U.ring\nexample := U.binclass\nexample := V.binclass\n\n@[derive ring] def id_ring (\u03b1) [ring \u03b1] : Type := \u03b1\n\n@[derive decidable_eq] def S := \u2115\n\n@[derive decidable_eq] inductive P | a | b | c\n\nopen category_theory\n\n-- Test that `delta_instance` works in the presence of universe metavariables.\nattribute [derive large_category] Mon\n\n-- test deriving instances on function types\n@[derive monad]\nmeta def my_tactic : Type \u2192 Type :=\ntactic\n", "meta": {"author": "jjaassoonn", "repo": "projective_space", "sha": "11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce", "save_path": "github-repos/lean/jjaassoonn-projective_space", "path": "github-repos/lean/jjaassoonn-projective_space/projective_space-11fe19fe9d7991a272e7a40be4b6ad9b0c10c7ce/test/delta_instance.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5926665999540697, "lm_q2_score": 0.3557748798522984, "lm_q1q2_score": 0.21085588839112934}}
{"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\u2081 C\u2082 C\u2083 : Type*} [category C\u2081] [category C\u2082] [category C\u2083] (F : C\u2081 \u2964 C\u2082)\n  [ess_surj F] (G : C\u2082 \u2964 C\u2083) [ess_surj G] : ess_surj (F \u22d9 G) :=\n\u27e8\u03bb Z, \u27e8_, \u27e8G.map_iso (F.obj_obj_preimage_iso (G.obj_preimage Z)) \u226a\u226b G.obj_obj_preimage_iso Z\u27e9\u27e9\u27e9\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 \u2964 D) (G : D \u2964 E) [ess_surj F]\n  (h : \u2200 (X Y : C), function.surjective (\u03bb (f : F.obj X \u27f6 F.obj Y), G.map f)) : full G :=\nG.full_of_surjective (\u03bb K\u2081 K\u2082 f, begin\n  let K'\u2081 := F.obj_preimage K\u2081,\n  let K'\u2082 := F.obj_preimage K\u2082,\n  let e\u2081 : F.obj K'\u2081 \u2245 K\u2081 := F.obj_obj_preimage_iso K\u2081,\n  let e\u2082 : F.obj K'\u2082 \u2245 K\u2082 := F.obj_obj_preimage_iso K\u2082,\n  obtain \u27e8f', hf'\u27e9 := h K'\u2081 K'\u2082 (G.map e\u2081.hom \u226b f \u226b G.map e\u2082.inv),\n  dsimp at hf',\n  refine \u27e8e\u2081.inv \u226b f' \u226b e\u2082.hom, _\u27e9,\n  simp only [G.map_comp, hf', assoc],\n  rw [\u2190 G.map_comp, e\u2082.inv_hom_id, G.map_id, comp_id, \u2190 G.map_comp_assoc, e\u2081.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 \u2964 D) (G : D \u2964 E) [ess_surj F]\n  (h : \u2200 (X Y : C), function.injective (\u03bb (f : F.obj X \u27f6 F.obj Y), G.map f)) : faithful G :=\n\u27e8\u03bb K\u2081 K\u2082 f\u2081 f\u2082 hf, begin\n  let K'\u2081 := F.obj_preimage K\u2081,\n  let K'\u2082 := F.obj_preimage K\u2082,\n  let e\u2081 : F.obj K'\u2081 \u2245 K\u2081 := F.obj_obj_preimage_iso K\u2081,\n  let e\u2082 : F.obj K'\u2082 \u2245 K\u2082 := F.obj_obj_preimage_iso K\u2082,\n  rw [\u2190 cancel_mono e\u2082.inv, \u2190 cancel_epi e\u2081.hom],\n  apply h,\n  dsimp,\n  simp only [hf, functor.map_comp],\nend\u27e9\n\nend category_theory\n\nvariables {C : Type*} [category C] [abelian C]\n\nnamespace derived_category\n\ninstance zero_is_le (n : \u2124) : (0 : derived_category C).is_le n :=\n\u27e8\u03bb i hi, is_zero.of_iso (is_zero_zero _)\n  (derived_category.homology_functor C i).map_zero_object\u27e9\n\ninstance zero_is_ge (n : \u2124) : (0 : derived_category C).is_ge n :=\n\u27e8\u03bb i hi, is_zero.of_iso (is_zero_zero _)\n  (derived_category.homology_functor C i).map_zero_object\u27e9\n\ndef is_plus (K : derived_category C) : Prop := \u2203 (n : \u2124), K.is_ge n\n\ndef is_minus (K : derived_category C) : Prop := \u2203 (n : \u2124), K.is_le n\n\nvariable (C)\nopen category_theory.triangulated\n\ninstance plus_is_triangulated_subcategory :\n  is_triangulated_subcategory (\u03bb (K : derived_category C), K.is_plus) :=\n{ zero := \u27e80, infer_instance\u27e9,\n  shift := begin\n    rintros K k \u27e8n, hn\u27e9,\n    haveI := hn,\n    exact \u27e8n-k, shift_is_ge K n k (n-k) (by linarith)\u27e9,\n  end,\n  ext\u2082 := begin\n    rintros T hT \u27e8n\u2081, hn\u2081\u27e9 \u27e8n\u2083, hn\u2083\u27e9,\n    exact \u27e8min n\u2081 n\u2083,\n      \u27e8\u03bb n hn, short_complex.exact.is_zero_of_both_zeros (homology_sequence.ex\u2082 hT n)\n        (is_zero.eq_of_src (hn\u2081.is_zero' _ (lt_of_lt_of_le hn (min_le_left n\u2081 n\u2083))) _ _)\n        (is_zero.eq_of_tgt (hn\u2083.is_zero' _ (lt_of_lt_of_le hn (min_le_right n\u2081 n\u2083))) _ _)\u27e9\u27e9,\n  end, }\n\nabbreviation plus := full_subcategory (\u03bb (K : derived_category C), K.is_plus)\nabbreviation minus := full_subcategory (\u03bb (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 : \u2124) [hn : K.is_ge n] :\n  derived_category.plus C :=\n\u27e8K, n, hn\u27e9\n\ndef mk' (K : derived_category C) (hK : K.is_plus) :\n  derived_category.plus C :=\n\u27e8K, hK\u27e9\n\nabbreviation \u03b9 : plus C \u2964 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 \u2124) : Prop :=\n  \u2203 (n : \u2124), K.is_strictly_ge n\n\ndef is_minus (K : cochain_complex C \u2124) : Prop :=\n  \u2203 (n : \u2124), K.is_strictly_le n\n\nlemma is_plus.Q {K : cochain_complex C \u2124} (h : K.is_plus) :\n  (derived_category.Q.obj K).is_plus :=\nbegin\n  obtain \u27e8n, hn\u27e9 := h,\n  haveI := hn,\n  exact \u27e8n, infer_instance\u27e9,\nend\n\ninstance zero_is_strictly_ge (n : \u2124) : is_strictly_ge (0 : cochain_complex C \u2124) n :=\n\u27e8\u03bb k hk, is_zero.of_iso (is_zero_zero _)\n  (homological_complex.eval C (complex_shape.up \u2124) k).map_zero_object\u27e9\n\ninstance zero_is_strictly_le (n : \u2124) : is_strictly_le (0 : cochain_complex C \u2124) n :=\n\u27e8\u03bb k hk, is_zero.of_iso (is_zero_zero _)\n  (homological_complex.eval C (complex_shape.up \u2124) k).map_zero_object\u27e9\n\nlemma mapping_cone_is_strictly_le {K L : cochain_complex C \u2124} (f : K \u27f6 L) (n k l : \u2124)\n  [K.is_strictly_le k] [L.is_strictly_le l] (hk : k \u2264 n+1) (hl : l \u2264 n) :\n  (mapping_cone f).is_strictly_le n :=\n\u27e8\u03bb 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\u27e9\n\nlemma mapping_cone_is_strictly_ge {K L : cochain_complex C \u2124} (f : K \u27f6 L) (n k l : \u2124)\n  [K.is_strictly_ge k] [L.is_strictly_ge l] (hk : n+1 \u2264 k) (hl : n \u2264 l) :\n  (mapping_cone f).is_strictly_ge n :=\n\u27e8\u03bb 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\u27e9\n\nlemma mapping_cone_is_plus {K L : cochain_complex C \u2124} (f : K \u27f6 L)\n  (hK : K.is_plus) (hL : L.is_plus) : (mapping_cone f).is_plus :=\nbegin\n  obtain \u27e8k, hK\u27e9 := hK,\n  obtain \u27e8l, hL\u27e9 := hL,\n  haveI := hK,\n  haveI := hL,\n  exact \u27e8min (k-1) l, mapping_cone_is_strictly_ge f _ k l\n    (by linarith [min_le_left (k-1) l]) (min_le_right _ _)\u27e9,\nend\n\nvariable (C)\nabbreviation plus :=\nfull_subcategory (\u03bb (K : cochain_complex C \u2124), cochain_complex.is_plus K)\nabbreviation minus :=\nfull_subcategory (\u03bb (K : cochain_complex C \u2124), cochain_complex.is_minus K)\n\nnamespace plus\n\nvariable {C}\n\nabbreviation \u03b9 : plus C \u2964 cochain_complex C \u2124 :=\nfull_subcategory_inclusion _\n\nvariable (C)\n\ndef shift_functor (k : \u2124) : plus C \u2964 plus C :=\nfull_subcategory.lift _ (\u03b9 \u22d9 shift_functor _ k) (\u03bb K, begin\n  obtain \u27e8n, hn\u27e9 := K.2,\n  haveI := hn,\n  refine \u27e8n-k, _\u27e9,\n  dsimp,\n  exact shift_is_strict_ge K.1 n k (n-k) (by linarith),\nend)\n\ninstance : has_shift (plus C) \u2124 :=\nhas_shift_of_fully_faithful \u03b9 (shift_functor C)\n  (\u03bb n, full_subcategory.lift_comp_inclusion _ _ _)\n\nend plus\n\nnamespace minus\n\nvariable {C}\n\nabbreviation \u03b9 : minus C \u2964 cochain_complex C \u2124 :=\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 \u2124)) :=\n\u03bb 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 \u27e8\u27e80\u27e9, _, \u27e80, infer_instance\u27e9\u27e9,\n    rw is_zero.iff_id_eq_zero,\n    change (homotopy_category.quotient _ _).map (\ud835\udfd9 0) = 0,\n    simp only [id_zero, functor.map_zero],\n  end,\n  shift := begin\n    rintro \u27e8X\u27e9 n hX,\n    exact ((cochain_complex.plus.shift_functor C n).obj \u27e8X, hX\u27e9).2,\n  end,\n  distinguished_cocone_triangle' := begin\n    rintro \u27e8X\u27e9 \u27e8Y\u27e9 hX hY \u27e8f : X \u27f6 Y\u27e9,\n    refine \u27e8_, _, _, _, \u27e8_, _, f, \u27e8iso.refl _\u27e9\u27e9\u27e9,\n    exact cochain_complex.mapping_cone_is_plus f hX hY,\n  end, }\n\nnamespace plus\n\nvariable {C}\n\nabbreviation \u03b9 : plus C \u2964 homotopy_category C (complex_shape.up \u2124) :=\nfull_subcategory_inclusion _\n\nvariable (C)\n\nabbreviation homology_functor (n : \u2124) : plus C \u2964 C :=\n\u03b9 \u22d9 homotopy_category.homology_functor C (complex_shape.up \u2124) n\n\ndef shift_homology_functor_iso (n k m : \u2124) (h : k + n = m):\n  shift_functor _ n \u22d9 homology_functor C k \u2245 homology_functor C m :=\n(functor.associator _ _ _).symm \u226a\u226b iso_whisker_right (\u03b9.comm_shift_iso n) _ \u226a\u226b\n  functor.associator _ _ _ \u226a\u226b\n  iso_whisker_left \u03b9 (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} (\u03c6 : K \u27f6 L) :\n  (subcategory.W (acyclic C)) \u03c6 \u2194 \u2200 (n : \u2124), is_iso ((homology_functor C n).map \u03c6) :=\nby simpa only [functor.kernel_of_is_homological_W,\n  \u2190 \u03bb n, nat_iso.is_iso_map_iff (shift_homology_functor_iso C _ _ _ (zero_add n)) \u03c6]\n\nvariable (C)\n\nlemma homology_functor_is_inverted_by (n : \u2124) :\n  (subcategory.W (acyclic C)).is_inverted_by (homology_functor C n) :=\n\u03bb 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_\u03b9_map_mem {K L : homotopy_category.plus C} (f : K \u27f6 L) :\n  subcategory.W (homotopy_category.acyclic C) (homotopy_category.plus.\u03b9.map f) \u2194\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 : \u2124) : C \u2964 homotopy_category.plus C :=\nfull_subcategory.lift _ (homological_complex.single C (complex_shape.up \u2124) n \u22d9\n  homotopy_category.quotient _ _) (\u03bb X, \u27e8n, by { dsimp, apply_instance, }\u27e9)\n\ndef single_functor_factors (n : \u2124) :\n  single_functor C n \u22d9 homotopy_category.plus.\u03b9 \u2245\n  (homological_complex.single C (complex_shape.up \u2124) n \u22d9 homotopy_category.quotient _ _) :=\nfull_subcategory.lift_comp_inclusion _ _ _\n\ninstance single_functor_additive (n : \u2124) : (single_functor C n).additive :=\n\u27e8\u03bb K L f\u2081 f\u2082, homotopy_category.plus.\u03b9.map_injective begin\n  dsimp only [single_functor],\n  simp only [full_subcategory.lift_map, functor.map_add],\nend\u27e9\n\nend plus\n\nend homotopy_category\n\nnamespace derived_category\n\nnamespace plus\n\nabbreviation Qh : homotopy_category.plus C \u2964 derived_category.plus C :=\nfull_subcategory.lift _ (homotopy_category.plus.\u03b9 \u22d9 derived_category.Qh)\nbegin\n  rintro \u27e8\u27e8K\u27e9, n, hn\u27e9,\n  refine \u27e8n, (_ : (Q.obj K).is_ge n)\u27e9,\n  rw \u2190 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_\u03b9_iso : (Qh : _ \u2964 derived_category.plus C) \u22d9 derived_category.plus.\u03b9 \u2245\n  homotopy_category.plus.\u03b9 \u22d9 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\u03bb K L f hf, begin\n  haveI : is_iso (derived_category.plus.\u03b9.map (Qh.map f)),\n  { erw [is_iso_map_iff_of_nat_iso (Qh_comp_\u03b9_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_\u03b9_map_mem] using hf, },\n  exact is_iso_of_reflects_iso (Qh.map f) \u03b9,\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 \u22d9 L C \u2245 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 \u27e8\u27e8K\u2081 : cochain_complex C \u2124\u27e9, hK\u2081\u27e9 \u27e8\u27e8K\u2082 : cochain_complex C \u2124\u27e9, hK\u2082\u27e9 f,\n  have hK\u2081' := hK\u2081,\n  have hK\u2082' := hK\u2082,\n  obtain \u27e8n\u2081, hn\u2081\u27e9 := hK\u2081',\n  obtain \u27e8n\u2082, hn\u2082\u27e9 := hK\u2082',\n  let n := min n\u2081 n\u2082,\n  haveI : K\u2081.is_strictly_ge n,\n  { haveI := hn\u2081, exact cochain_complex.is_strictly_ge_of_le _ _ _ (min_le_left n\u2081 n\u2082), },\n  haveI : K\u2082.is_strictly_ge n,\n  { haveI := hn\u2082, exact cochain_complex.is_strictly_ge_of_le _ _ _ (min_le_right n\u2081 n\u2082), },\n  let f' : Qh.obj \u27e8\u27e8K\u2081\u27e9, hK\u2081\u27e9 \u27f6 Qh.obj \u27e8\u27e8K\u2082\u27e9, hK\u2082\u27e9 :=\n    (L_iso C).inv.app _ \u226b f \u226b (L_iso C).hom.app _,\n  let f'' : derived_category.Q.obj K\u2081 \u27f6 derived_category.Q.obj K\u2082 := f',\n  obtain \u27e8K\u2083, hK\u2083', s, g, hs, fac\u27e9 := right_factorisation_of_is_strictly_ge f'' n,\n  replace fac := (Q.map s) \u226b= fac,\n  rw is_iso.hom_inv_id_assoc at fac,\n  haveI := hK\u2083',\n  haveI := hs,\n  have hK\u2083 : homotopy_category.is_plus C \u27e8K\u2083\u27e9 := \u27e8n, hK\u2083'\u27e9,\n  let s' : (\u27e8_, hK\u2083\u27e9 : homotopy_category.plus C) \u27f6 \u27e8_, hK\u2081\u27e9 := (homotopy_category.quotient _ _).map s,\n  let g' : (\u27e8_, hK\u2083\u27e9 : homotopy_category.plus C) \u27f6 \u27e8_, hK\u2082\u27e9 := (homotopy_category.quotient _ _).map g,\n  haveI : is_iso (F.map s') := hF _ begin\n    rw \u2190 homotopy_category.plus.mem_W_iff_\u03b9_map_mem,\n    erw homotopy_category.map_quotient_W_iff,\n    exact hs,\n  end,\n  refine \u27e8inv (F.map s') \u226b F.map g', _\u27e9,\n  dsimp only,\n  erw [functor.map_comp, \u2190 cancel_epi ((L C).map (F.map s')), \u2190 functor.map_comp_assoc,\n    is_iso.hom_inv_id, (L C).map_id, id_comp, \u2190 cancel_epi ((L_iso C).inv.app \u27e8_, hK\u2083\u27e9),\n    \u2190 (L_iso C).inv.naturality g', \u2190 fac],\n  dsimp only [f'', f'],\n  erw [assoc, \u2190 (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 \u27e8\u27e8K\u2081 : cochain_complex C \u2124\u27e9, hK\u2081\u27e9 \u27e8\u27e8K\u2082 : cochain_complex C \u2124\u27e9, hK\u2082\u27e9,\n  suffices : \u2200 (f : F.obj {obj := {as := K\u2081}, property := hK\u2081} \u27f6 F.obj {obj := {as := K\u2082}, property := hK\u2082})\n    (hf : (L C).map f = 0), f = 0,\n  { intros f\u2081 f\u2082 hf,\n    rw [\u2190 sub_eq_zero],\n    apply this,\n    simpa only [functor.map_sub, sub_eq_zero] using hf, },\n  intros f hf,\n  obtain \u27e8\u27e8\u27e8\u27e8K\u2081'\u27e9, hK\u2081'\u27e9, s, g, hs\u27e9, hz\u27e9 := 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 \u27e8g, rfl\u27e9 := (homotopy_category.quotient _ _).map_surjective g,\n  let g' : (\u27e8\u27e8K\u2081'\u27e9, hK\u2081'\u27e9 : homotopy_category.plus C) \u27f6 \u27e8\u27e8K\u2082\u27e9, hK\u2082\u27e9 :=\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 \u27e8\u27e8K\u2082' : cochain_complex C \u2124\u27e9, s, hs, fac\u27e9 := hg,\n  obtain \u27e8s, rfl\u27e9 := (homotopy_category.quotient _ _).map_surjective s,\n  have hK\u2082' := hK\u2082,\n  obtain \u27e8n, hn : K\u2082.is_strictly_ge n\u27e9 := hK\u2082',\n  rw zero_comp at fac,\n  let t : (\u27e8\u27e8K\u2082\u27e9, hK\u2082\u27e9 : homotopy_category.plus C) \u27f6 \u27e8\u27e8K\u2082'.trunc_ge n\u27e9, \u27e8n, infer_instance\u27e9\u27e9 :=\n    (homotopy_category.quotient _ _).map (s \u226b cochain_complex.trunc_ge.\u03c0 K\u2082' n),\n  haveI : is_iso (F.map t),\n  { apply hF,\n    erw [\u2190 homotopy_category.plus.mem_W_iff_\u03b9_map_mem, homotopy_category.map_quotient_W_iff],\n    haveI : quasi_iso s,\n    { simpa only [\u2190 homotopy_category.map_quotient_W_iff] using hs, },\n    haveI : quasi_iso (cochain_complex.trunc_ge.\u03c0 K\u2082' n),\n    { rw [cochain_complex.quasi_iso_trunc_ge_\u03c0_iff, \u2190 cochain_complex.is_ge_iff_of_quasi_iso s],\n      apply_instance, },\n    apply_instance, },\n  simp only [\u2190 cancel_mono (F.map t), zero_comp, \u2190 F.map_comp, \u2190 F.map_zero],\n  congr' 1,\n  dsimp [t],\n  erw [functor.map_comp, \u2190 assoc, fac, zero_comp],\nend\n\ninstance : ess_surj (L C) :=\n\u27e8begin\n  rintro \u27e8K, hK\u27e9,\n  let K' := Q.obj_preimage K,\n  let e : Q.obj K' \u2245 K := Q.obj_obj_preimage_iso K,\n  obtain \u27e8n, hn\u27e9 := 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 \u27e8(morphism_property.Q _).obj \u27e8\u27e8K'.trunc_ge n\u27e9, \u27e8n, infer_instance\u27e9\u27e9,\n    \u27e8derived_category.plus.\u03b9.preimage_iso (\u03b9.map_iso ((L_iso C).app _) \u226a\u226b\n      (as_iso (Q.map (cochain_complex.trunc_ge.\u03c0 K' n))).symm \u226a\u226b e)\u27e9\u27e9,\nend\u27e9\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 : _ \u2964 derived_category.plus C) :=\ness_surj.of_iso (L_iso C)\n\nend Qh_is_localization\n\ninstance Qh_is_localization :\n  (Qh : _ \u2964 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 : \u2124) : C \u2964 derived_category.plus C :=\nhomotopy_category.plus.single_functor C n \u22d9 derived_category.plus.Qh\n\ndef homology_functor (n : \u2124) : derived_category.plus C \u2964 C :=\nderived_category.plus.\u03b9 \u22d9 derived_category.homology_functor C n\n\ninstance homology_functor_additive (n : \u2124) : (homology_functor C n).additive :=\nby { dsimp only [homology_functor], apply_instance, }\n\ninstance homology_functor_is_homological (n : \u2124) : (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 \u2124)} (ex : S.short_exact)\n  (h\u2081 : S.X\u2081.is_plus) (h\u2082 : S.X\u2082.is_plus) (h\u2083 : S.X\u2083.is_plus) :\n    pretriangulated.triangle (derived_category.plus C) :=\npretriangulated.full_subcategory_lift_triangle _ (derived_category.triangle_of_ses ex)\n  h\u2081.Q h\u2082.Q h\u2083.Q\n\nlemma triangle_of_ses_dist {S : short_complex (cochain_complex C \u2124)} (ex : S.short_exact)\n  (h\u2081 : S.X\u2081.is_plus) (h\u2082 : S.X\u2082.is_plus) (h\u2083 : S.X\u2083.is_plus) :\n  triangle_of_ses ex h\u2081 h\u2082 h\u2083 \u2208 dist_triang (derived_category.plus C) :=\nbegin\n  change (full_subcategory_inclusion _).map_triangle.obj (triangle_of_ses ex h\u2081 h\u2082 h\u2083)\n    \u2208 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 {\u2102 \u210d : Type} {\u03c9 : context} [half_ring \u2102] [decidable_eq \u2102]\n\n/-- Maps a potential transition to the interaction space. -/\ndef potential_interaction_space [cpi_equiv \u210d \u03c9] {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} {A : prime_species \u210d \u03c9 \u0393}\n  : transition.transition_from \u2113 A.val\n  \u2192 interaction_space \u2102 \u210d \u03c9 \u0393\n| \u27e8 _, # a , @production.concretion _ _ _ b y G, tr \u27e9 := fin_fn.single \u27e8 \u27e6 A \u27e7, \u27e8 b, y, \u27e6 G \u27e7 \u27e9, a \u27e9 1\n| \u27e8 _, \u03c4@'_, E, tr \u27e9 := 0\n| \u27e8 _, \u03c4\u27e8_\u27e9, E, tr \u27e9 := 0\n\nlemma potential_interaction_space.equiv [cpi_equiv \u210d \u03c9] {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393}\n    {A B : prime_species \u210d \u03c9 \u0393} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E E' : production \u210d \u03c9 \u0393 k}\n    {t : A.val [\u2113, \u03b1]\u27f6 E} {t' : B.val [\u2113, \u03b1]\u27f6 E'}\n  , A \u2248 B \u2192 E \u2248 E'\n  \u2192 @potential_interaction_space \u2102 \u210d \u03c9 _ _ _ \u0393 \u2113 _ (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 : \u27e6 A \u27e7 = \u27e6 B \u27e7 := quot.sound eqA,\n  have : \u27e6 E \u27e7 = \u27e6 E' \u27e7 := quot.sound eqE,\n  rw [\u2039\u27e6 A \u27e7 = \u27e6 B \u27e7\u203a, \u2039\u27e6 E \u27e7 = \u27e6 E' \u27e7\u203a],\nend\n| _ (\u03c4@'_) E E' t t' _ _ := rfl\n| _ (\u03c4\u27e8_\u27e9) 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 \u210d \u03c9] {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A : prime_species \u210d \u03c9 \u0393)\n  : interaction_space \u2102 \u210d \u03c9 \u0393\n  := finset.sum (fintype.elems (transition.transition_from \u2113 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 \u210d \u03c9] {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A : species \u210d \u03c9 \u0393)\n  : interaction_space \u2102 \u210d \u03c9 \u0393\n  := (cpi_equiv.prime_decompose A).sum' (potential_interaction_space.from_prime \u2113)\n\n/-- `potential_interaction_space.from_species`, lifted to quotients. -/\ndef potential_interaction_space.from_species' [cpi_equiv_prop \u210d \u03c9] {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (A : species' \u210d \u03c9 \u0393)\n  : interaction_space \u2102 \u210d \u03c9 \u0393 := (cpi_equiv.prime_decompose' A).sum' (\u03bb B, quot.lift_on B\n    (potential_interaction_space.from_prime \u2113)\n    (\u03bb B\u2081 B\u2082 equ, begin\n      cases cpi_equiv_prop.transition_iso \u2113 equ with iso,\n      let isoF := cpi_equiv_prop.transition_from_iso iso,\n      suffices : \u2200 x\n        , (@potential_interaction_space \u2102 \u210d \u03c9 _ _ _ _ \u2113 _ x)\n        = potential_interaction_space (isoF.to_fun x),\n        from fintype.sum_iso _ _ isoF this,\n\n      rintros \u27e8 k, \u03b1, E, t \u27e9,\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 \u03b1).2 E t,\n      cases ((iso k \u03b1).fst).to_fun \u27e8E, t\u27e9 with E' t',\n      from potential_interaction_space.equiv equ eqE,\n    end))\n\nlemma potential_interaction_space.species_eq [cpi_equiv_prop \u210d \u03c9] {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} {A : species \u210d \u03c9 \u0393}\n  : (potential_interaction_space.from_species \u2113 A : interaction_space \u2102 \u210d \u03c9 \u0393)\n  = potential_interaction_space.from_species' \u2113 \u27e6 A \u27e7\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 \u03a3[x \u2208 B [\u03c4@k]\u2014\u2192 C] k and \u03a3[x \u2208 B [\u03c4\u27e8 a, b \u27e9]\u2014\u2192 C] M(a, b)\n    components of the definition of d(c \u25ef A)/dt. -/\ndef immediate_process_space [cpi_equiv \u210d \u03c9] {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} (conc : \u210d \u21aa \u2102)\n    {A : prime_species \u210d \u03c9 \u0393}\n  : transition.transition_from \u2113 A.val\n  \u2192 process_space \u2102 \u210d \u03c9 \u0393\n| \u27e8 _, # a , _, tr \u27e9 := 0\n| \u27e8 _, \u03c4@'k, production.species B, tr \u27e9 :=\n  conc k \u2022 (to_process_space \u27e6 B \u27e7 - fin_fn.single \u27e6 A \u27e7 1)\n| \u27e8 _, \u03c4\u27e8 n \u27e9, _, tr \u27e9 := 0\n\nlemma immediate_process_space.equiv [cpi_equiv \u210d \u03c9] {\u0393} {\u2113 : lookup \u210d \u03c9 \u0393} {conc : \u210d \u21aa \u2102}\n    {A B : prime_species \u210d \u03c9 \u0393} :\n  \u2200 {k} {\u03b1 : label \u210d \u0393 k} {E E' : production \u210d \u03c9 \u0393 k}\n    {t : A.val [\u2113, \u03b1]\u27f6 E} {t' : B.val [\u2113, \u03b1]\u27f6 E'}\n  , A \u2248 B \u2192 E \u2248 E'\n  \u2192 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| _ (\u03c4@'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 : \u27e6 A \u27e7 = \u27e6 B \u27e7 := quot.sound eqA,\n  have : \u27e6 E \u27e7 = \u27e6 E' \u27e7 := quot.sound eqE,\n  rw [\u2039\u27e6 A \u27e7 = \u27e6 B \u27e7\u203a, \u2039\u27e6 E \u27e7 = \u27e6 E' \u27e7\u203a],\nend\n| _ (\u03c4\u27e8 n \u27e9) 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 \u210d \u03c9] {\u0393} (conc : \u210d \u21aa \u2102) (\u2113 : lookup \u210d \u03c9 \u0393)\n    (A : prime_species \u210d \u03c9 \u0393)\n  : process_space \u2102 \u210d \u03c9 \u0393\n  := finset.sum (fintype.elems (transition.transition_from \u2113 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 \u210d \u03c9] {\u0393} (conc : \u210d \u21aa \u2102) (\u2113 : lookup \u210d \u03c9 \u0393) (A : species \u210d \u03c9 \u0393)\n  : process_space \u2102 \u210d \u03c9 \u0393\n  := (cpi_equiv.prime_decompose A).sum' (immediate_process_space.from_prime conc \u2113)\n\n/-- `immediate_process_space.from_species`, lifted to quotients. -/\ndef immediate_process_space.from_species' [cpi_equiv_prop \u210d \u03c9] {\u0393} (conc : \u210d \u21aa \u2102) (\u2113 : lookup \u210d \u03c9 \u0393) (A : species' \u210d \u03c9 \u0393)\n  : process_space \u2102 \u210d \u03c9 \u0393 := (cpi_equiv.prime_decompose' A).sum' (\u03bb B, quot.lift_on B\n    (immediate_process_space.from_prime conc \u2113)\n    (\u03bb B\u2081 B\u2082 equ, begin\n      cases cpi_equiv_prop.transition_iso \u2113 equ with iso,\n      let isoF := cpi_equiv_prop.transition_from_iso iso,\n      suffices : \u2200 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 \u27e8 k, \u03b1, E, t \u27e9,\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 \u03b1).2 E t,\n      cases ((iso k \u03b1).fst).to_fun \u27e8E, t\u27e9 with E' t',\n      from immediate_process_space.equiv equ eqE,\n    end))\n\nlemma immediate_process_space.species_eq [cpi_equiv_prop \u210d \u03c9] {\u0393} {conc : \u210d \u21aa \u2102} {\u2113 : lookup \u210d \u03c9 \u0393} {A : species \u210d \u03c9 \u0393}\n  : immediate_process_space.from_species conc \u2113 A\n  = immediate_process_space.from_species' conc \u2113 \u27e6 A \u27e7\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 (\u2202P). -/\ndef process_potential [cpi_equiv \u210d \u03c9] {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393)\n  : process \u2102 \u210d \u03c9 \u0393 \u2192 interaction_space \u2102 \u210d \u03c9 \u0393\n| (c \u25ef A) := c \u2022 potential_interaction_space.from_species \u2113 A\n| (P |\u209a Q) := process_potential P + process_potential Q\n\nlemma process_potential.nil_zero [cpi_equiv \u210d \u03c9] {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) (c : \u2102)\n  : process_potential \u2113 (c \u25ef 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 \u210d \u03c9]\n    (M : affinity \u210d) (\u2113 : lookup \u210d \u03c9 (context.extend M.arity context.nil)) (conc : \u210d \u21aa \u2102)\n  : process \u2102 \u210d \u03c9 (context.extend M.arity context.nil)\n  \u2192 process_space \u2102 \u210d \u03c9 (context.extend M.arity context.nil)\n| (c \u25ef A)\n  := c \u2022 immediate_process_space.from_species conc \u2113 A\n  + (\u00bd : \u2102) \u2022 (process_potential \u2113 (c \u25ef A) \u2298[conc] process_potential \u2113 (c \u25ef A))\n| (P |\u209a Q)\n  := process_immediate P + process_immediate Q\n   + (process_potential \u2113 P \u2298[conc] process_potential \u2113 Q)\n\nlemma process_immediate.nil_zero {conc : \u210d \u21aa \u2102} [cpi_equiv \u210d \u03c9]\n    (M : affinity \u210d) (\u2113 : lookup \u210d \u03c9 (context.extend M.arity context.nil))\n    (c : \u2102)\n  : process_immediate M \u2113 conc (c \u25ef 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 \u210d \u03c9] {\u0393} (\u2113 : lookup \u210d \u03c9 \u0393) :\n  \u2200 {P Q : process \u2102 \u210d \u03c9 \u0393}\n  , P \u2248 Q \u2192 process_potential \u2113 P = process_potential \u2113 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.\u03be_species : c A B equ {\n    suffices : potential_interaction_space.from_species \u2113 A\n             = potential_interaction_space.from_species \u2113 B,\n    { simp only [process_potential],  from congr_arg ((\u2022) c) this },\n\n    calc  potential_interaction_space.from_species \u2113 A\n        = potential_interaction_space.from_species' \u2113 \u27e6 A \u27e7 : potential_interaction_space.species_eq\n    ... = potential_interaction_space.from_species' \u2113 \u27e6 B \u27e7 : by rw quotient.sound equ\n    ... = potential_interaction_space.from_species \u2113 B : potential_interaction_space.species_eq.symm\n  },\n  case process.equiv.\u03be_parallel\u2081 : P P' Q eq ih {\n    unfold process_potential, rw ih,\n  },\n  case process.equiv.\u03be_parallel\u2082 : P Q Q' eq ih {\n    unfold process_potential, rw ih,\n  },\n  case process.equiv.parallel_nil : P C {\n    show process_potential \u2113 P + process_potential \u2113 (C \u25ef nil) = process_potential \u2113 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 \u210d \u03c9] (M : affinity \u210d)\n    (\u2113 : lookup \u210d \u03c9 (context.extend M.arity context.nil)) {conc : \u210d \u21aa \u2102} (c d : \u2102)\n    (Ds : interaction_space \u2102 \u210d \u03c9 (context.extend (M.arity) context.nil))\n    (Ps : process_space \u2102 \u210d \u03c9 (context.extend (M.arity) context.nil))\n  : (c \u2022 Ds) \u2298[conc] (d \u2022 Ds) + ((\u00bd : \u2102) \u2022 (c \u2022 Ds) \u2298[conc] (c \u2022 Ds) + (\u00bd : \u2102) \u2022 (d \u2022 Ds) \u2298[conc] (d \u2022 Ds))\n  = (\u00bd : \u2102) \u2022 (c \u2022 Ds + d \u2022 Ds) \u2298[conc] (c \u2022 Ds + d \u2022 Ds) := begin\n  generalize ehalf : (\u00bd : \u2102) = half,\n\n  rw [interaction_tensor.left_distrib (c \u2022 Ds) (d \u2022 Ds),\n      interaction_tensor.right_distrib (c \u2022 Ds),\n      interaction_tensor.right_distrib (d \u2022 Ds),\n      interaction_tensor.comm (d \u2022 Ds) (c \u2022 Ds)],\n\n  calc  (c \u2022 Ds) \u2298 (d \u2022 Ds)\n      + (half \u2022 (c \u2022 Ds) \u2298 (c \u2022 Ds) + half \u2022 (d \u2022 Ds) \u2298 (d \u2022 Ds))\n\n      = (1 : \u2102) \u2022 (c \u2022 Ds) \u2298[conc] (d \u2022 Ds)\n      + (half \u2022 (c \u2022 Ds) \u2298[conc] (c \u2022 Ds) + half \u2022 (d \u2022 Ds) \u2298[conc] (d \u2022 Ds))\n      : by simp only [one_smul]\n\n  ... = (half + half) \u2022 (c \u2022 Ds) \u2298[conc] (d \u2022 Ds)\n      + (half \u2022 (c \u2022 Ds) \u2298[conc] (c \u2022 Ds) + half \u2022 (d \u2022 Ds) \u2298[conc] (d \u2022 Ds))\n      : by rw [half_ring.one_is_two_halves, \u2190 ehalf]\n\n       ... = half \u2022 (c \u2022 Ds) \u2298[conc] (c \u2022 Ds) + half \u2022 (c \u2022 Ds) \u2298[conc] (d \u2022 Ds)\n           + (half \u2022 (c \u2022 Ds) \u2298[conc] (d \u2022 Ds) + half \u2022 (d \u2022 Ds) \u2298[conc] (d \u2022 Ds))\n           : begin\n             simp only [add_smul],\n             generalize : half \u2022 (c \u2022 Ds) \u2298[conc] (d \u2022 Ds) = cd,\n             generalize : half \u2022 (c \u2022 Ds) \u2298[conc] (c \u2022 Ds) = cc,\n             generalize : half \u2022 (d \u2022 Ds) \u2298[conc] (d \u2022 Ds) = dd,\n             abel,\n            end\n\n       ... = half \u2022 ((c \u2022 Ds) \u2298 (c \u2022 Ds) + (c \u2022 Ds) \u2298 (d \u2022 Ds)\n                    + ((c \u2022 Ds) \u2298 (d \u2022 Ds) + (d \u2022 Ds) \u2298 (d \u2022 Ds)))\n           : by simp only [smul_add]\nend\n\nprivate lemma process_immediate.split [cpi_equiv_prop \u210d \u03c9] [add_monoid \u210d]\n    (M : affinity \u210d) (\u2113 : lookup \u210d \u03c9 (context.extend M.arity context.nil))\n    (conc : \u210d \u21aa \u2102) (c : \u2102)\n    (A B : species \u210d \u03c9 (context.extend M.arity context.nil))\n  : process_immediate M \u2113 conc (c \u25ef (A |\u209b B))\n  = process_immediate M \u2113 conc (c \u25ef A |\u209a c \u25ef B) := begin\n  simp only [process_immediate, immediate_process_space.from_species,\n             process_potential.equiv \u2113 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 \u2113) = dA,\n  generalize : multiset.sum' (cpi_equiv.prime_decompose B) (immediate_process_space.from_prime conc \u2113) = dB,\n\n  have : process_potential \u2113 (c \u25ef A |\u209a c \u25ef B) = process_potential \u2113 (c \u25ef A) + process_potential \u2113 (c \u25ef B)\n    := rfl,\n  simp only [this],\n\n  generalize : process_potential \u2113 (c \u25ef A) = pA,\n  generalize : process_potential \u2113 (c \u25ef 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 : \u00bd \u2022 pA \u2298[conc] pA = iA,\n  generalize : \u00bd \u2022 pB \u2298[conc] pB = iB,\n  generalize : pA \u2298[conc] pB = iAB,\n\n  calc  c \u2022 dA + c \u2022 dB + (iA + (\u00bd : \u2102) \u2022 iAB + ((\u00bd : \u2102) \u2022 iAB + iB))\n      = c \u2022 dA + c \u2022 dB + (iA + iB + ((\u00bd : \u2102) \u2022 iAB + (\u00bd : \u2102) \u2022 iAB)) : by abel\n  ... = c \u2022 dA + c \u2022 dB + (iA + iB + iAB)\n        : by rw [\u2190 add_smul, \u2190 half_ring.one_is_two_halves, one_smul]\n  ... = c \u2022 dA + iA + (c \u2022 dB + iB) + iAB : by abel\nend\n\nlemma process_immediate.equiv [cpi_equiv_prop \u210d \u03c9] [add_monoid \u210d]\n    (M : affinity \u210d) (\u2113 : lookup \u210d \u03c9 (context.extend M.arity context.nil))\n    (conc : \u210d \u21aa \u2102)\n  : \u2200 {P Q : process \u2102 \u210d \u03c9 (context.extend M.arity context.nil)}\n  , P \u2248 Q\n  \u2192 process_immediate M \u2113 conc P\n  = process_immediate M \u2113 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.\u03be_species : c A B equ {\n    suffices : immediate_process_space.from_species conc \u2113 A\n             = immediate_process_space.from_species conc \u2113 B,\n    { simp only [process_immediate],\n      rw [process_potential.equiv \u2113 (process.equiv.\u03be_species equ), this]\n    },\n\n    calc  immediate_process_space.from_species conc \u2113 A\n        = immediate_process_space.from_species' conc \u2113 \u27e6 A \u27e7 : immediate_process_space.species_eq\n    ... = immediate_process_space.from_species' conc \u2113 \u27e6 B \u27e7 : by rw quotient.sound equ\n    ... = immediate_process_space.from_species conc \u2113 B : immediate_process_space.species_eq.symm\n  },\n  case process.equiv.\u03be_parallel\u2081 : P P' Q eq ih {\n    simp only [process_immediate, process_potential.equiv \u2113 eq, ih],\n  },\n  case process.equiv.\u03be_parallel\u2082 : P Q Q' eq ih {\n    simp only [process_immediate, process_potential.equiv \u2113 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 \u2113 P = p,\n    generalize : process_potential \u2113 Q = q,\n    generalize : process_potential \u2113 R = r,\n\n    calc  p \u2298 q + (p + q) \u2298 r\n        = p \u2298[conc] q + p \u2298[conc] r + q \u2298 r : by rw [interaction_tensor.left_distrib, add_assoc]\n    ... = q \u2298[conc] r + p \u2298[conc] q + p \u2298[conc] r : by simp only [add_comm, add_left_comm, interaction_tensor.comm]\n    ... = q \u2298[conc] r + p \u2298[conc] (q + r) : by rw [add_assoc, \u2190 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 \u2113 A = Ds,\n    generalize : immediate_process_space.from_species conc \u2113 A = Ps,\n\n    suffices\n      : (c \u2022 Ds) \u2298[conc] (d \u2022 Ds) + ((\u00bd : \u2102) \u2022 ((c \u2022 Ds) \u2298[conc] (c \u2022 Ds)) + (\u00bd : \u2102) \u2022 (d \u2022 Ds) \u2298[conc] (d \u2022 Ds))\n      = (\u00bd : \u2102) \u2022 ((c \u2022 Ds + d \u2022 Ds) \u2298[conc] (c \u2022 Ds + d \u2022 Ds)),\n      { simp only [add_assoc, add_comm, add_smul, add_left_comm, this] },\n\n    from process_immediate.join M \u2113 c d Ds Ps,\n  },\n  case process.equiv.split : A B c {\n    from process_immediate.split M \u2113 conc c A B\n  },\nend\n\n/-- dP/dt lifted to quotients. -/\ndef process_immediate.quot [cpi_equiv_prop \u210d \u03c9] [add_monoid \u210d]\n    (M : affinity \u210d) (\u2113 : lookup \u210d \u03c9 (context.extend M.arity context.nil))\n    (conc : \u210d \u21aa \u2102)\n  : process' \u2102 \u210d \u03c9 (context.extend M.arity context.nil)\n  \u2192 process_space \u2102 \u210d \u03c9 (context.extend M.arity context.nil)\n| P := quot.lift_on P (process_immediate M \u2113 conc)\n    (\u03bb P Q, process_immediate.equiv M \u2113 conc)\n\n/-- dP/dt lifted to process spaces. -/\ndef process_immediate.space [cpi_equiv_prop \u210d \u03c9] [half_ring \u210d]\n    (M : affinity \u210d) (\u2113 : lookup \u210d \u03c9 (context.extend M.arity context.nil))\n    (conc : \u210d \u21aa \u2102)\n  : process_space \u2102 \u210d \u03c9 (context.extend M.arity context.nil)\n  \u2192 process_space \u2102 \u210d \u03c9 (context.extend M.arity context.nil)\n| P := process_immediate.quot M \u2113 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 \u2192 F\nvariable  \u03c3 : 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 \u03c3.pc\n    (h_mem : mem_at mem code_get_generator_point \u03c3.pc)\n    -- input arguments on the stack\n    -- conclusion\n  : ensures_ret mem \u03c3 (\u03bb \u03ba \u03c4, \u03c4.ap = \u03c3.ap + 6 \u2227 spec_get_generator_point mem \u03ba (cast_EcPoint mem (\u03c4.ap - 6))) :=\nbegin\n  apply ensures_of_ensuresb, intro \u03bdbound,\n  have h_mem_rec := h_mem,\n  unpack_memory code_get_generator_point at h_mem with \u27e8hpc0, hpc1, hpc2, hpc3, hpc4, hpc5, hpc6, hpc7, hpc8, hpc9, hpc10, hpc11, hpc12\u27e9,\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\u2081 : Type (u+1) :=\n(M : Type u)\n[str : comphaus_filtered_pseudo_normed_group M]\n(exhaustive' : \u2200 m : M, \u2203 c, m \u2208 pseudo_normed_group.filtration M c)\n\nnamespace CompHausFiltPseuNormGrp\u2081\n\ninstance : has_coe_to_sort CompHausFiltPseuNormGrp\u2081 Type* := \u27e8\u03bb M, M.M\u27e9\ninstance (M : CompHausFiltPseuNormGrp\u2081) : comphaus_filtered_pseudo_normed_group M := M.str\n\nlemma exhaustive (M : CompHausFiltPseuNormGrp\u2081) (m : M) :\n  \u2203 c, m \u2208 pseudo_normed_group.filtration M c := M.exhaustive' _\n\ninstance : large_category CompHausFiltPseuNormGrp\u2081.{u} :=\n{ hom := \u03bb A B, strict_comphaus_filtered_pseudo_normed_group_hom A B,\n  id := \u03bb A, strict_comphaus_filtered_pseudo_normed_group_hom.id,\n  comp := \u03bb A B C f g, g.comp f }\n\n/-- The \"forget \u2081\" 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\u2081_to_CHFPNG\u2091\u2097 : CompHausFiltPseuNormGrp\u2081 \u2964 CompHausFiltPseuNormGrp :=\n{ obj := \u03bb M, CompHausFiltPseuNormGrp.of M,\n  map := \u03bb M\u2081 M\u2082 f, f.to_chfpsng_hom }\n\ninstance : faithful (CHFPNG\u2081_to_CHFPNG\u2091\u2097.{u}) :=\n{ map_injective' := \u03bb M\u2081 M\u2082 f g h,\n  by { ext x, apply_fun (\u03bb \u03c6, \u03c6.to_fun) at h, exact congr_fun h x } }\n\ninstance : concrete_category CompHausFiltPseuNormGrp\u2081.{u} :=\n{ forget :=\n  { obj := \u03bb M, M.M,\n    map := \u03bb A B f, f },\n  forget_faithful := \u27e8\u27e9 } .\n\ndef level : \u211d\u22650 \u2964 CompHausFiltPseuNormGrp\u2081.{u} \u2964 CompHaus :=\n{ obj := \u03bb c,\n  { obj := \u03bb M, CompHaus.of $ pseudo_normed_group.filtration M c,\n    map := \u03bb A B f, \u27e8_, f.level_continuous _\u27e9 },\n  map := \u03bb c\u2081 c\u2082 h,\n    { app := \u03bb M, by letI : fact (c\u2081 \u2264 c\u2082) := \u27e8le_of_hom h\u27e9; exact\n        \u27e8_, comphaus_filtered_pseudo_normed_group.continuous_cast_le _ _\u27e9 } } .\n\nsection limits\n\n/-!\nIn this section, we show (hopefully ;)) that `CompHausFiltPseuNormGrp\u2081` has limits.\n-/\n\nvariables {J : Type u} [small_category J] (G : J \u2964 CompHausFiltPseuNormGrp\u2081.{u})\n\nopen pseudo_normed_group\nopen category_theory.limits\n\n/-- This is a bifunctor which associates to each `c : \u211d\u22650` and `j : J`,\n  the `c`-th term of the filtration of `G.obj j`. -/\ndef cone_point_diagram : as_small.{u} \u211d\u22650 \u2964 J \u2964 CompHaus.{u} :=\nas_small.down \u22d9 level \u22d9 (whiskering_left _ _ _).obj G\n\n@[derive [topological_space, t2_space]]\ndef cone_point_type_filt (c : \u211d\u22650) : Type u :=\n{ x : \u03a0 j : J, filtration (G.obj j) c | \u2200 \u2983i j : J\u2984 (e : i \u27f6 j), (G.map e).level (x _) = x _ }\n\ninstance (c : \u211d\u22650) : 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 : \u211d\u22650) : has_coe_to_fun (cone_point_type_filt G c)\n  (\u03bb x, \u03a0 j : J, filtration (G.obj j) c) := \u27e8\u03bb x, x.1\u27e9\n\n@[ext] lemma ext {c} (x y : cone_point_type_filt G c) :\n  (\u21d1x : \u03a0 j : J, filtration (G.obj j) c) = y \u2192 x = y := subtype.ext\n\n@[simp] lemma level_apply {c : \u211d\u22650} {i j : J} (x : cone_point_type_filt G c) (e : i \u27f6 j) :\n  (G.map e).level (x i) = x j := x.2 e\n\n@[simp] lemma map_apply {c : \u211d\u22650} {i j : J} (x : cone_point_type_filt G c) (e : i \u27f6 j) :\n  (G.map e) (x i) = x j := by {rw \u2190 (G.map e).coe_level, simp }\n\ndef trans {c\u2081 c\u2082 : \u211d\u22650} (h : c\u2081 \u2264 c\u2082) (x : cone_point_type_filt G c\u2081) : cone_point_type_filt G c\u2082 :=\n\u27e8\u03bb j, cast_le' h (x j), \u03bb i j e, by { ext, simp }\u27e9\n\n@[simp] lemma trans_apply {c\u2081 c\u2082 : \u211d\u22650} (h : c\u2081 \u2264 c\u2082) (x : cone_point_type_filt G c\u2081) (j : J) :\n  x.trans h j = cast_le' h (x j) := by { ext, refl }\n\nlemma trans_injective {c\u2081 c\u2082 : \u211d\u22650} (h : c\u2081 \u2264 c\u2082) :\n  function.injective (trans h : cone_point_type_filt G c\u2081 \u2192 cone_point_type_filt G c\u2082) :=\nbegin\n  intros x y hh,\n  ext j,\n  apply_fun (\u03bb e, (e j : G.obj j)) at hh,\n  exact hh\nend\n\nlemma trans_continuous {c\u2081 c\u2082 : \u211d\u22650} (h : c\u2081 \u2264 c\u2082) :\n  continuous (trans h : cone_point_type_filt G c\u2081 \u2192 cone_point_type_filt G c\u2082) :=\nbegin\n  -- ;-)\n  let \u03b7 := ((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\u2082)))),\n  let T := (CompHaus.limit_cone.{_ u} (((cone_point_diagram G).obj (as_small.up.obj c\u2081)))),\n  exact (hS.map T \u03b7).continuous,\nend\n\nlemma continuous_apply {c : \u211d\u22650} (j : J) : continuous (\u03bb t : cone_point_type_filt G c, t j) :=\nbegin\n  change continuous ((\u03bb u : \u03a0 j, filtration (G.obj j) c, u j) \u2218\n    (\u03bb u : cone_point_type_filt G c, \u21d1u)),\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\u27e8\u03bb j, 0, \u03bb i j e, by { ext, dsimp, simp }\u27e9\n\ninstance {c} : has_neg (cone_point_type_filt G c) := has_neg.mk $ \u03bb x,\n\u27e8\u03bb j, - (x j), \u03bb i j e, by { ext, dsimp, simp, }\u27e9\n\ndef add' {c\u2081 c\u2082} (x : cone_point_type_filt G c\u2081) (y : cone_point_type_filt G c\u2082) :\n  cone_point_type_filt G (c\u2081 + c\u2082) :=\n\u27e8\u03bb j, add' (x j, y j), \u03bb i j e, by { ext, dsimp, simp, }\u27e9\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\u2081 c\u2082} (j : J) (x : cone_point_type_filt G c\u2081)\n  (y : cone_point_type_filt G c\u2082) : ((x.add' y) j : G.obj j) = x j + y j := rfl\n\nlemma continuous_neg {c} : continuous (\u03bb x : cone_point_type_filt G c, - x) :=\nbegin\n  apply continuous.subtype_mk,\n  apply continuous_pi,\n  intros j,\n  change continuous ((\u03bb x, -x) \u2218 (\u03bb 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 (\u03bb t : cone_point_type_filt G c1 \u00d7 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 \u00d7 cone_point_type_filt G c2 \u2192\n    (\u03a0 j : J, filtration (G.obj j) c1) \u00d7 (\u03a0 j : J, filtration (G.obj j) c2) :=\n    \u03bb t, (t.1,t.2),\n  let B : (\u03a0 j : J, filtration (G.obj j) c1) \u00d7 (\u03a0 j : J, filtration (G.obj j) c2) \u2192\n    filtration (G.obj j) c1 \u00d7 filtration (G.obj j) c2 := \u03bb t, (t.1 j, t.2 j),\n  let C : filtration (G.obj j) c1 \u00d7 filtration (G.obj j) c2 \u2192 filtration (G.obj j) (c1 + c2) :=\n    pseudo_normed_group.add',\n  change continuous (C \u2218 B \u2218 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 ((\u03bb t : \u03a0 j : J, filtration (G.obj j) c1, t j) \u2218 prod.fst),\n      apply continuous.comp,\n      apply _root_.continuous_apply,\n      exact continuous_fst },\n    { change continuous ((\u03bb t : \u03a0 j : J, filtration (G.obj j) c2, t j) \u2218 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 (\u03a3 (c : \u211d\u22650), cone_point_type_filt G c) :=\n{ r := \u03bb x y, \u2203 (d : \u211d\u22650) (hx : x.1 \u2264 d) (hy : y.1 \u2264 d), x.2.trans hx = y.2.trans hy,\n  iseqv := begin\n    refine \u27e8_,_,_\u27e9,\n    { rintro \u27e8c,x\u27e9,\n      use [c, le_refl _, le_refl _] },\n    { rintro \u27e8c,x\u27e9 \u27e8d,y\u27e9 \u27e8e,h1,h2,h\u27e9,\n      dsimp at *,\n      refine \u27e8_, le_sup_left, le_sup_right, _\u27e9,\n      ext j : 3,\n      symmetry,\n      apply_fun (\u03bb e, (e j : G.obj j)) at h,\n      exact h },\n    { rintro \u27e8c,x\u27e9 \u27e8d,y\u27e9 \u27e8e,z\u27e9 \u27e8i,h1,hh1,hhh1\u27e9 \u27e8j,h2,hh2,hhh2\u27e9,\n      dsimp at *,\n      refine \u27e8_, le_sup_left, le_sup_right, _\u27e9,\n      ext jj : 3,\n      apply_fun (\u03bb e, (e jj : G.obj jj)) at hhh1,\n      apply_fun (\u03bb 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 : \u211d\u22650) : cone_point_type_filt G c \u2192 cone_point_type G :=\nquotient.mk' \u2218 sigma.mk c\n\nlemma incl_injective (c : \u211d\u22650) :\n  function.injective (incl c : cone_point_type_filt G c \u2192 cone_point_type G) :=\nbegin\n  intros x y h,\n  replace h := quotient.exact' h,\n  obtain \u27e8d,h1,h2,h\u27e9 := 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\u2081 c\u2082 : \u211d\u22650} (h : c\u2081 \u2264 c\u2082) (x : cone_point_type_filt G c\u2081) :\n  incl _ (x.trans h) = incl _ x :=\nbegin\n  apply quotient.sound',\n  refine \u27e8c\u2081 \u2294 c\u2082, by simp, by simp, _\u27e9,\n  ext,\n  refl,\nend\n\nlemma incl_jointly_surjective (x : cone_point_type G) :\n  \u2203 (c : \u211d\u22650) (y : cone_point_type_filt G c), incl c y = x :=\nbegin\n  rcases x,\n  obtain \u27e8c,y\u27e9 := x,\n  use [c,y],\n  refl,\nend\n\ndef index (x : cone_point_type G) : \u211d\u22650 := (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 \u2294 (incl c x).index,\n  change _ = (cast_le' le_sup_left (x j) : G.obj j),\n  rw \u2190 cone_point_type_filt.trans_apply (le_sup_left : _ \u2264 e) x j,\n  rw \u2190 coe_cast_le' (le_sup_right : _ \u2264 e),\n  rw \u2190 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) := \u27e8incl 0 0\u27e9\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\u03bb 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\u03bb 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\u2081 c\u2082 : \u211d\u22650)\n  (x\u2081 : cone_point_type_filt G c\u2081) (x\u2082 : cone_point_type_filt G c\u2082) :\n  (incl c\u2081 x\u2081) + (incl c\u2082 x\u2082) = (incl (c\u2081 + c\u2082) (x\u2081.add' x\u2082)) :=\nbegin\n  rw add_def,\n  apply quotient.sound',\n  refine \u27e8max _ _, le_max_left _ _, le_max_right _ _, _\u27e9,\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 \u2190 x.preimage_spec},\n  apply quotient.sound',\n  refine \u27e8(0 : cone_point_type G).index + x.index, by simp, by simp, _\u27e9,\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 \u27e8x.index + y.index, le_refl _, le_of_eq (by {dsimp, rw add_comm}), _\u27e9,\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 \u27e8_, le_sup_left, le_sup_right, _\u27e9,\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 \u27e8_,le_sup_left, le_sup_right,_\u27e9,\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 : \u211d\u22650) : set (cone_point_type G) := set.range (incl c)\n\ndef filt_equiv (c : \u211d\u22650) : cone_point_type_filt G c \u2243 filt G c :=\nequiv.of_bijective (\u03bb x, \u27e8_, x, rfl\u27e9)\nbegin\n  split,\n  { intros x y h,\n    apply_fun (\u03bb e, e.val) at h,\n    apply incl_injective,\n    exact h },\n  { rintro \u27e8_,x,rfl\u27e9, 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 : \u211d\u22650) : filt G c \u2243\u209c 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 := \u27e8rfl\u27e9,\n  rw this.is_open_iff at hU,\n  obtain \u27e8U,hU,rfl\u27e9 := 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 : \u211d\u22650) : CompHaus.of (filt G c) \u2245\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 \u27e8_, le_sup_left, le_sup_right, _\u27e9,\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 \u27e8_, le_sup_left, le_sup_right, _\u27e9,\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 \u27e8_, le_sup_left, le_sup_right, _\u27e9,\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 \u27e8x,rfl\u27e9,\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 \u27e8x,rfl\u27e9,\n    use -x,\n    simp,\n  end,\n  add_mem_filtration := begin\n    rintros c1 c2 x1 x2 \u27e8x1,rfl\u27e9 \u27e8x2,rfl\u27e9,\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 \u00d7 filtration (cone_point_type G) c2 \u2192\n      cone_point_type_filt G c1 \u00d7 cone_point_type_filt G c2 :=\n      \u03bb t, \u27e8(filt_homeo G c1) t.1, (filt_homeo G c2) t.2\u27e9,\n    let E' : cone_point_type_filt G c1 \u00d7 cone_point_type_filt G c2 \u2192\n      filtration (cone_point_type G) c1 \u00d7 filtration (cone_point_type G) c2 :=\n      \u03bb t, \u27e8(filt_homeo G c1).symm t.1, (filt_homeo G c2).symm t.2\u27e9,\n    have hE'E : E' \u2218 E = id := by { dsimp [E,E'], ext, simp, simp },\n    have : (filt_homeo G (c1 + c2)).symm \u2218\n      (\u03bb t : cone_point_type_filt G c1 \u00d7 cone_point_type_filt G c2, t.1.add' t.2) \u2218 E = add',\n    { suffices : add' \u2218 E' = (filt_homeo G (c1 + c2)).to_equiv.symm \u2218\n        (\u03bb t : cone_point_type_filt G c1 \u00d7 cone_point_type_filt G c2, t.1.add' t.2),\n      { erw [\u2190 function.comp.assoc, \u2190 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 \u2190 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 \u2192 filtration (cone_point_type G) c) =\n      (filt_homeo G c).symm \u2218 (\u03bb x, -x) \u2218 filt_homeo G c,\n    { suffices :\n        (neg' : filtration (cone_point_type G) c \u2192 filtration (cone_point_type G) c) \u2218\n          (filt_homeo G c).to_equiv.symm = (filt_homeo G c).to_equiv.symm \u2218 (\u03bb x, -x),\n      { erw [\u2190 function.comp.assoc, \u2190 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\u2081 c\u2082 \u27e8h\u27e9,\n    change continuous (cast_le' h),\n    have : cast_le' h = (filt_homeo G c\u2082).symm \u2218\n      cone_point_type_filt.trans h \u2218 (filt_homeo G c\u2081),\n    { suffices : cast_le' h \u2218 (filt_homeo G c\u2081).to_equiv.symm =\n        (filt_homeo G c\u2082).to_equiv.symm \u2218 cone_point_type_filt.trans h,\n      { erw [\u2190 function.comp.assoc, \u2190 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\u2081 :=\n{ M := cone_point_type G,\n  exhaustive' := cone_point_type.incl_jointly_surjective }\n\ndef proj (j : J) : cone_point G \u27f6 G.obj j :=\n{ to_fun := \u03bb 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 \u27e8x,rfl\u27e9,\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 \u2192 filtration (G.obj j) c :=\n      \u03bb t, ((cone_point_type.filt_homeo G c) t) j,\n    suffices : continuous E,\n    { convert this,\n      ext \u27e8t,t,rfl\u27e9,\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 ((\u03bb (u : cone_point_type_filt G c), u j) \u2218 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  \u03c0 :=\n  { app := \u03bb 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 (\u03bb e, (e : G.obj j)) at this,\n      exact this.symm,\n    end } }\n\ndef index {M : CompHausFiltPseuNormGrp\u2081} (x : M) : \u211d\u22650 := (M.exhaustive x).some\ndef preimage {M : CompHausFiltPseuNormGrp\u2081} (x : M) : filtration M (index x) :=\n  \u27e8x,(M.exhaustive x).some_spec\u27e9\n\ndef limit_cone_lift_map (D : cone G) : D.X \u2192 cone_point G := \u03bb x,\ncone_point_type.incl (index x) \u27e8\u03bb j, (D.\u03c0.app j).level (preimage x), begin\n  intros i j e,\n  ext,\n  dsimp,\n  simp,\nend\u27e9\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 \u27e8_, le_sup_left, le_sup_right, _\u27e9,\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.\u03c0.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 \u27e8_, le_sup_left, le_sup_right, _\u27e9,\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.\u03c0.app j).map_add a b,\nend\n\nlemma limit_cone_lift_map_strict {D : cone G} {x : D.X} (c : \u211d\u22650) (hx : x \u2208 filtration D.X c) :\n  limit_cone_lift_map G D x \u2208 filtration (cone_point_type G) c :=\nbegin\n  dsimp [limit_cone_lift_map],\n  change _ \u2208 set.range _,\n  refine \u27e8\u27e8\u03bb j, (D.\u03c0.app j).level \u27e8x,hx\u27e9, _\u27e9, _\u27e9,\n  { intros i j e,\n    ext,\n    dsimp,\n    simp },\n  { dsimp,\n    apply quotient.sound',\n    refine \u27e8_, le_sup_left, le_sup_right, _\u27e9,\n    dsimp,\n    ext j,\n    simpa }\nend\n\ndef limit_cone_lift (D : cone G) : D.X \u27f6 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' := \u03bb 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 \u2192 cone_point_type_filt G c := \u03bb t,\n      \u27e8\u03bb j, (D.\u03c0.app j).level t, _\u27e9,\n    swap, {\n      intros i j e,\n      ext,\n      dsimp,\n      simp },\n    have : (cone_point_type.filt_homeo G c) \u2218 pseudo_normed_group.level\n      (limit_cone_lift_map G D) (\u03bb 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 \u27e8_, le_sup_left, le_sup_right, _\u27e9,\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.\u03c0.app j).level_continuous,\n  end }\n\ndef limit_cone_is_limit : is_limit (limit_cone G) :=\n{ lift := \u03bb S, limit_cone_lift _ _,\n  fac' := begin\n    intros S j,\n    ext,\n    change (limit_cone G).\u03c0.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 \u2190 (m x).preimage_spec,\n    apply quotient.sound',\n    refine \u27e8_, le_sup_left, le_sup_right, _\u27e9,\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 (\u03bb 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 \u27e8limit_cone _, limit_cone_is_limit _\u27e9\n\ninstance : has_limits CompHausFiltPseuNormGrp\u2081 :=\n\u27e8\u03bb J hJ, { has_limit := \u03bb G, by resetI; apply_instance }\u27e9\n\ninstance (c : \u211d\u22650) : preserves_limit G (level.obj c) :=\npreserves_limit_of_preserves_limit_cone (limit_cone_is_limit _)\n{ lift := \u03bb S,\n    (CompHaus.limit_cone_is_limit.{_ u} ((cone_point_diagram G).obj (as_small.up.obj c))).lift\n    _ \u226b (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 \u27e8t,ht\u27e9,\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 [\u2190 hm, category.assoc],\n    congr' 1,\n    rw \u2190 iso.eq_inv_comp,\n    ext \u27e8t,ht\u27e9,\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 : \u211d\u22650) : preserves_limits (level.obj c) :=\n{ preserves_limits_of_shape := \u03bb J _, by exactI\n  { preserves_limit := \u03bb G, by apply_instance, } }\n\nlemma mem_filtration_iff_of_is_limit (C : cone G) (hC : is_limit C) (c : \u211d\u22650) (x : C.X) :\n  x \u2208 pseudo_normed_group.filtration C.X c \u2194\n  (\u2200 j : J, C.\u03c0.app j x \u2208 pseudo_normed_group.filtration (G.obj j) c) :=\nbegin\n  split,\n  { intros h j,\n    apply (C.\u03c0.app j).strict h },\n  { intro h,\n    let E := limit_cone G,\n    let e : C \u2245 E := hC.unique_up_to_iso (limit_cone_is_limit _),\n    let eX : C.X \u2245 E.X := (cones.forget _).map_iso e,\n    let w := eX.hom x,\n    have hw : \u2200 j, E.\u03c0.app j w \u2208 filtration (G.obj j) c,\n    { intros j,\n      dsimp only [w],\n      change (eX.hom \u226b E.\u03c0.app _) _ \u2208 _,\n      dsimp only [eX, functor.map_iso, cones.forget],\n      convert h j,\n      simp },\n    suffices : w \u2208 filtration (limit_cone G).X c,\n    { convert eX.inv.strict this,\n      change _ = (eX.hom \u226b eX.inv) x,\n      rw iso.hom_inv_id,\n      refl },\n    change \u2203 z, _,\n    refine \u27e8\u27e8\u03bb j, \u27e8_, hw _\u27e9, _\u27e9, _\u27e9,\n    { intros i j f,\n      ext1,\n      dsimp,\n      change (E.\u03c0.app i \u226b G.map f) _ = _,\n      rw E.w },\n    { obtain \u27e8i,z,hz\u27e9 := cone_point_type.incl_jointly_surjective w,\n      let d : \u211d\u22650 := i \u2294 c,\n      conv_rhs { rw \u2190 hz },\n      rw \u2190 cone_point_type.incl_trans (le_sup_left : i \u2264 d),\n      rw \u2190 cone_point_type.incl_trans (le_sup_right : c \u2264 d),\n      congr' 1,\n      dsimp [cone_point_type_filt.trans],\n      ext j,\n      dsimp,\n      change E.\u03c0.app j _ = _,\n      rw \u2190 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 : \u2200 j, C.\u03c0.app j x = C.\u03c0.app j y) : x = y :=\nbegin\n  let E := limit_cone G,\n  let e : C \u2245 E := hC.unique_up_to_iso (limit_cone_is_limit _),\n  let eX : C.X \u2245 E.X := (cones.forget _).map_iso e,\n  apply_fun eX.hom,\n  swap,\n  { intros a b hh,\n    apply_fun (\u03bb e, eX.inv e) at hh,\n    change (eX.hom \u226b eX.inv) _ = (eX.hom \u226b eX.inv) _ at hh,\n    simpa only [iso.hom_inv_id] using hh },\n  have hh : \u2200 j, (E.\u03c0.app j) (eX.hom x) = (E.\u03c0.app j) (eX.hom y),\n  { intros j,\n    change (eX.hom \u226b E.\u03c0.app j) x = (eX.hom \u226b E.\u03c0.app j) y,\n    convert h j using 2,\n    all_goals { simp } },\n  obtain \u27e8ca,a,ha\u27e9 := cone_point_type.incl_jointly_surjective (eX.hom x),\n  obtain \u27e8cb,b,hb\u27e9 := cone_point_type.incl_jointly_surjective (eX.hom y),\n  rw [\u2190 ha, \u2190 hb] at \u22a2 hh,\n  let d : \u211d\u22650 := ca \u2294 cb,\n  rw \u2190 cone_point_type.incl_trans (le_sup_left : ca \u2264 d) at \u22a2 hh,\n  rw \u2190 cone_point_type.incl_trans (le_sup_right : cb \u2264 d) at \u22a2 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 {\u03b1 : Type u} [fintype \u03b1] (X : \u03b1 \u2192 CompHausFiltPseuNormGrp\u2081.{u}) :\n  CompHausFiltPseuNormGrp\u2081.{u} :=\n{ M := \u03a0 i, X i,\n  exhaustive' := begin\n    intro m,\n    choose cs hcs using (\u03bb i, (X i).exhaustive (m i)),\n    have : \u2203 c : \u211d\u22650, \u2200 i, cs i \u2264 c,\n    { use finset.univ.sup cs,\n      intros i,\n      apply finset.le_sup (finset.mem_univ i) },\n    obtain \u27e8c,hc\u27e9 := this,\n    refine \u27e8c, \u03bb i, pseudo_normed_group.filtration_mono (hc i) (hcs i)\u27e9,\n  end }\n\n@[simps]\ndef product.\u03c0 {\u03b1 : Type u} [fintype \u03b1] (X : \u03b1 \u2192 CompHausFiltPseuNormGrp\u2081.{u}) (i : \u03b1) :\n  product X \u27f6 X i :=\n{ to_fun := \u03bb m, m i,\n  map_zero' := rfl,\n  map_add' := \u03bb x y, rfl,\n  strict' := \u03bb 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 (\u03bb i, X i) c) := \u27e8rfl\u27e9,\n    let e : \u21a5(pseudo_normed_group.filtration \u21a5(product X) c) \u2192\n      \u21a5(pseudo_normed_group.filtration \u21a5(X i) c) :=\n      pseudo_normed_group.level (\u03bb (m : \u21a5(product X)), m i) _ c,\n    swap,\n    { intros c x hx,\n      apply hx },\n    change continuous e,\n    have : e = _ \u2218 (pseudo_normed_group.filtration_pi_equiv (\u03bb 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 {\u03b1 : Type u} [fintype \u03b1] (X : \u03b1 \u2192 CompHausFiltPseuNormGrp\u2081.{u})\n  (M : CompHausFiltPseuNormGrp\u2081.{u}) (f : \u03a0 i, M \u27f6 X i) :\n  M \u27f6 product X :=\n{ to_fun := \u03bb m i, f _ m,\n  map_zero' := by { ext, simp },\n  map_add' := by { intros, ext, simp },\n  strict' := \u03bb c x hx i, (f i).strict hx,\n  continuous' := begin\n    intros c,\n    have h : inducing (pseudo_normed_group.filtration_pi_equiv (\u03bb i, X i) c) := \u27e8rfl\u27e9,\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_\u03c0 {\u03b1 : Type u} [fintype \u03b1] (X : \u03b1 \u2192 CompHausFiltPseuNormGrp\u2081.{u})\n  (M : CompHausFiltPseuNormGrp\u2081.{u}) (f : \u03a0 i, M \u27f6 X i) (i) :\n  product.lift X M f \u226b product.\u03c0 X i = f i := by { ext, simp }\n\nlemma product.lift_unique {\u03b1 : Type u} [fintype \u03b1] (X : \u03b1 \u2192 CompHausFiltPseuNormGrp\u2081.{u})\n  (M : CompHausFiltPseuNormGrp\u2081.{u}) (f : \u03a0 i, M \u27f6 X i) (g : M \u27f6 product X)\n  (hg : \u2200 i, g \u226b product.\u03c0 X i = f i) : g = product.lift X M f :=\nby { ext, simp [\u2190 hg] }\n\nlemma product.hom_ext {\u03b1 : Type u} [fintype \u03b1] (X : \u03b1 \u2192 CompHausFiltPseuNormGrp\u2081.{u})\n  (M : CompHausFiltPseuNormGrp\u2081.{u}) (g\u2081 g\u2082 : M \u27f6 product X)\n  (h : \u2200 i, g\u2081 \u226b product.\u03c0 X i = g\u2082 \u226b product.\u03c0 X i) : g\u2081 = g\u2082 :=\nbegin\n  rw [product.lift_unique X M _ g\u2081 (\u03bb i, rfl), product.lift_unique X M _ g\u2082 (\u03bb i, rfl)],\n  simp [h],\nend\n\nend products\n\nend CompHausFiltPseuNormGrp\u2081\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": "/- import mcl\nimport parlang\nopen mcl\nopen mcl.mclk\n\n\nnamespace arrcp_mcl\n\n-- open classical\n-- local attribute [instance] prop_decidable\n-- instance a : decidable_eq string := sorry\n\n#check ([5] : vector _ _)\n\n\ndef sig : signature --:= \u03bb n, if n = \"i\" then { scope := scope.tlocal, type := \u27e8_, [1], type.int\u27e9 } else { scope := scope.shared, type := \u27e8_, [100], type.int\u27e9 }\n| \"i\" := { scope := scope.tlocal, type := \u27e8_, [1], type.int\u27e9 }\n| \"tid\" := { scope := scope.tlocal, type := \u27e8_, [1], type.int\u27e9 }\n| _ := { scope := scope.shared, type := \u27e8_, [100], type.int\u27e9 }\n\nlemma i_is_tlocal : is_tlocal (sig \"i\") := by apply eq.refl\nlemma a_is_shared : is_shared (sig \"a\") := by apply eq.refl\nlemma tid_is_tlocal : is_tlocal (sig \"tid\") := by apply eq.refl\n\ndef read_i := (expression.tlocal_var \"i\" (\u03bb_, 0) (show type_of (sig \"i\") = type.int, by apply eq.refl) (by refl) i_is_tlocal)\ndef read_tid := (expression.tlocal_var \"tid\" (\u03bb_, 0) (show type_of (sig \"tid\") = type.int, by apply eq.refl) (show (sig \"tid\").type.dim = 1, by apply eq.refl) tid_is_tlocal)\n\ndef arrcp\u2081 : mclp sig := mclp.intro (\u03bb m, 100) (\n    mclk.shared_assign \"b\" [read_tid] (by refl) (expression.shared_var \"a\" (\u03bb_, read_tid) (show type_of (sig \"a\") = type.int, by refl) (by refl) a_is_shared)\n)\n\n\ndef arrcp\u2082 : mclp sig := mclp.intro (\u03bb m, 10) (mclk.for \"i\" (by refl) (by refl) read_tid (read_i < 100) (mclk.tlocal_assign \"i\" [1] (show ((sig \"i\").type).dim = vector.length [1], by refl) (read_i + read_tid)) (\n    mclk.shared_assign \"b\" [read_i] (by refl) (expression.shared_var \"a\" (\u03bb_, read_i) (show type_of (sig \"a\") = type.int, by refl) (by refl) a_is_shared)\n))\n\n#eval mclp_to_program arrcp\u2081\n#eval mclp_to_program arrcp\u2082\n--#reduce mclp_to_program arrcp\u2082\n\nexample (c) : mclp_to_program arrcp\u2081 = c := begin\n    rw arrcp\u2081,\n    rw [mclp_to_program, mclk_to_kernel, prepend_load_expr, load_shared_vars_for_expr],\n    repeat {rw list.append},\n    repeat {rw list.foldl},\n    repeat {rw list.foldr},\nend\n\n\n#eval mclp_to_program arrcp\u2081\n#check ```(mclp_to_program arrcp\u2081)\n#print mclp_to_program\n\ndef X : \u2115 \u2192 \u2115 := \u03bb n, n + 2\n\nmeta def num_args : expr \u2192 nat\n| (expr.app f a) := num_args f + 1\n| e:=0\n\n#check X\n#check `(X)\n#eval parlang.expr.repr `(X)\n\nexample : mclp_rel eq arrcp\u2081 arrcp\u2082 eq := begin\n    apply rel_mclk_to_mclp,\nend\n\nend arrcp_mcl -/", "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/src/use_cases/arrcp_mcl.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.6334102775181399, "lm_q2_score": 0.33111974622959367, "lm_q1q2_score": 0.209734650351023}}
{"text": "import Smt\n\ntheorem assoc (f : Bool \u2192 Bool \u2192 Bool) (p q r : Bool) :\n  f p (f q r) == f (f p q) r := by\n  smt\n  admit\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/Test/Bool/Assoc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.40356685373537454, "lm_q1q2_score": 0.20966158534864873}}
{"text": "example (f : Fin n \u2192 Prop) (h : \u2200 i h, i = 0 \u2192 f \u27e8i, h\u27e9) : 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  | \u27e8i, _\u27e9 => 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 (\u03bb 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 \u2964 C} (T : C)\n  (E : limits.cocone F) (hE : limits.is_colimit E)\n  (f : T \u27f6 E.X)\n  (h : \u2200 j : J,\n    \u2203 (Z : C) (p : Z \u27f6 T) (q : Z \u27f6 F.obj j) (hq : epi q),\n      q \u226b E.\u03b9.app j = p \u226b f) : epi f :=\nbegin\n  constructor, intros W a b hh,\n  apply hE.hom_ext, intros j, specialize h j,\n  obtain \u27e8Z,p,q,hq,w\u27e9 := h, resetI,\n  rw \u2190 cancel_epi q, simp_rw [\u2190 category.assoc, w,\n    category.assoc, hh],\nend\n\nlemma epi_Profinite_to_Condensed_map_of_epi {X Y : Profinite.{u}}\n  (f : X \u27f6 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 (\u03bb _, Profinite.pullback f q')\n    (\u03bb _, Profinite.pullback.snd _ _) _ _,\n  { intro w,\n    rw Profinite.epi_iff_surjective at hf,\n    obtain \u27e8x, hx\u27e9 := hf (q' w),\n    refine \u27e8punit.star, \u27e8(x, w), hx\u27e9, rfl\u27e9, },\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 \u27e8\u27e9 \u27e8\u27e9 S g\u2081 g\u2082 H, dsimp only at H,\n    apply_fun (\u03bb \u03c6, Z.val.map \u03c6.op (b.val.app (op W) q)) at H,\n    simp only [op_comp, Z.val.map_comp] at H, exact H, },\n  obtain \u27e8t,ht1,ht2\u27e9 := 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) \u226b Z.val.map _) q =\n    (b.val.app (op W) \u226b Z.val.map _) q,\n  simp only [\u2190 nat_trans.naturality],\n  dsimp,\n  apply_fun (\u03bb e, Profinite_to_Condensed.map (Profinite.pullback.fst f q') \u226b e) at h,\n  apply_fun (\u03bb 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 (\ud835\udfd9 _),\n  apply_fun (\u03bb 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 \u2124\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 : \u2115) : Profinite.{u} :=\n--Profinite.product (\u03bb i : fin n, S)\n\n/-- `S.pmz n` is `(S \u00d7 {-1,0,1})^n`. -/\ndef Profinite.pmz (S : Profinite.{u}) (n : \u2115) : Profinite.{u} :=\nProfinite.sigma $ \u03bb (x : ulift.{u} (fin n \u2192 sign_type)), S.pow n\n\n/-- the canonical map of condensed sets `(S \u00d7 {-1,0,1})^n \u27f6 \u2124[S]` -/\ndef Profinite.pmz_to_free' (S : Profinite.{u}) (n : \u2115) :\n  (S.pmz n).to_Condensed \u27f6 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 (\u03bb (f : ulift.{u} (fin n \u2192 sign_type)), S.pow n)\n    (Condensed_Ab_to_CondensedSet.obj S.free')).symm $\n\u03bb (f : ulift.{u} (fin n \u2192 sign_type)),\nlet e := proetale_topology.to_sheafify (S.to_Condensed.val \u22d9 AddCommGroup.free') in\ne.app (op $ S.pow n) $\n  \u2211 i : fin n, finsupp.single (ulift.up $ Profinite.product.\u03c0 _ i) (f.down i : \u2124)\n\ndef Profinite.pmz_functor (n : \u2115) : Profinite.{u} \u2964 Profinite.{u} :=\n{ obj := \u03bb S, S.pmz n,\n  map := \u03bb S T f,\n    Profinite.sigma.desc _ $ \u03bb e,\n      (Profinite.product.lift (\u03bb i : fin n, T)\n        (\u03bb i, Profinite.product.\u03c0 _ i \u226b f)) \u226b Profinite.sigma.\u03b9 _ 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.\u03b9_desc],\n    refl,\n  end }\n\ndef Profinite.pmz_diagram (S : Profinite.{u}) (n : \u2115) :\n  discrete_quotient S \u2964 Profinite.{u} :=\nS.diagram \u22d9 Profinite.pmz_functor n\n\ndef Profinite.pmz_cone (S : Profinite.{u}) (n : \u2115) : 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 \u2964 Profinite.{u}) (\u03b1 : Type u) [fintype \u03b1] :\n  J \u2964 Profinite.{u} :=\n{ obj := \u03bb j, Profinite.sigma (\u03bb a : \u03b1, F.obj j),\n  map := \u03bb i j e, Profinite.sigma.desc _ $ \u03bb a,\n    F.map e \u226b Profinite.sigma.\u03b9 _ 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 \u2964 Profinite.{u}} (\u03b1 : Type u) [fintype \u03b1]\n  (E : limits.cone F) :\n  limits.cone (Profinite.sigma_functor F \u03b1) :=\n{ X := Profinite.sigma (\u03bb a : \u03b1, E.X),\n  \u03c0 :=\n  { app := \u03bb j, Profinite.sigma.desc _ $ \u03bb a,\n      E.\u03c0.app j \u226b Profinite.sigma.\u03b9 _ 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 \u2964 Profinite.{u}) (\u03b1 : Type u) [fintype \u03b1]\n  (E : limits.cone F) :\n  (Profinite.sigma_cone \u03b1 E).X \u27f6\n    (Profinite.limit_cone (Profinite.sigma_functor F \u03b1)).X :=\nProfinite.sigma.desc _ $ \u03bb a, (Profinite.limit_cone_is_limit\n  (Profinite.sigma_functor F \u03b1)).lift \u27e8E.X,\n  { app := \u03bb j, E.\u03c0.app j \u226b Profinite.sigma.\u03b9 _ a,\n  naturality' := begin\n    intros i j e, dsimp [Profinite.sigma_functor],\n    simp,\n  end }\u27e9\n\nlemma Profinite.exists_of_sigma_limit {J : Type u} [small_category J]\n  (F : J \u2964 Profinite.{u}) (\u03b1 : Type u) [fintype \u03b1] [is_cofiltered J]\n  (t : (Profinite.limit_cone (Profinite.sigma_functor F \u03b1)).X) :\n  \u2203 (a\u2080 : \u03b1) (t\u2080 : (Profinite.limit_cone F).X),\n    \u2200 j : J, Profinite.sigma.\u03b9 _ a\u2080\n      ((Profinite.limit_cone F).\u03c0.app j t\u2080) =\n      (Profinite.limit_cone (Profinite.sigma_functor F \u03b1)).\u03c0.app j t :=\nbegin\n  rcases t with \u27e8t,ht\u27e9, dsimp at ht,\n  obtain \u27e8j\u2080\u27e9 : nonempty J := is_cofiltered.nonempty,\n  let a\u2080 := (t j\u2080).1, use a\u2080,\n  have h1 : \u2200 \u2983i j : J\u2984 (f : i \u27f6 j), (t i).1 = (t j).1,\n  { intros i j e, specialize ht e,\n    apply_fun (\u03bb q, q.1) at ht,\n    cases t i, exact ht },\n  have h2 : \u2200 j : J, (t j).1 = a\u2080,\n  { intros j,\n    let j\u2081 := is_cofiltered.min j j\u2080,\n    rw \u2190 h1 (is_cofiltered.min_to_left j j\u2080), dsimp [a\u2080],\n    rw \u2190 h1 (is_cofiltered.min_to_right j j\u2080) },\n  let t\u2080 : (Profinite.limit_cone F).X := \u27e8_,_\u27e9,\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.\u03b9] at ht,\n    cases t j,\n    erw sigma.mk.inj_iff at ht,\n    exact eq_of_heq ht.2 },\n  use t\u2080,\n  intros j,\n  dsimp [Profinite.limit_cone, Profinite.sigma_functor, Profinite.sigma.\u03b9,\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 \u2964 Profinite.{u}) (\u03b1 : Type u) [fintype \u03b1]\n  (E : limits.cone F) (hE : limits.is_limit E) [is_cofiltered J] :\n  function.bijective (Profinite.sigma_to_limit F \u03b1 E) :=\nbegin\n  split,\n  { rintros \u27e8a,x\u27e9 \u27e8b,y\u27e9 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 (\u03bb e, e.1) at h,\n    have hh := h,\n    obtain \u27e8j\u2080\u27e9 : nonempty J := is_cofiltered.nonempty,\n    apply_fun (\u03bb e, (e j\u2080).1) at h, dsimp [Profinite.sigma.\u03b9] 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 (\u03bb 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 \u27e8a,s,ht\u27e9 := Profinite.exists_of_sigma_limit F \u03b1 t,\n    use a, let EE : E.X \u2245 (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)) \u226b E.\u03c0.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 \u2964 Profinite.{u}} (\u03b1 : Type u) [fintype \u03b1] [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 \u03b1 E)) :=\nbegin\n  apply Profinite.is_iso_of_bijective,\n  convert Profinite.bijective_sigma_to_limit F \u03b1 E hE,\n  symmetry,\n  apply (Profinite.limit_cone_is_limit (Profinite.sigma_functor F \u03b1)).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 \u2964 Profinite.{u}} (\u03b1 : Type u) [fintype \u03b1] [is_cofiltered J]\n  (E : limits.cone F) (hE : limits.is_limit E) :\n  limits.is_limit (Profinite.sigma_cone \u03b1 E) :=\nbegin\n  haveI : is_iso ((Profinite.limit_cone_is_limit _).lift (Profinite.sigma_cone \u03b1 E)) :=\n    Profinite.is_iso_lift_sigma_cone \u03b1 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 : \u2115) :\n  S.pmz n \u27f6 (Profinite.limit_cone (S.pmz_diagram n)).X :=\nProfinite.sigma.desc _ $ \u03bb f,\n  (Profinite.limit_cone_is_limit (S.pmz_diagram n)).lift \u27e8S.pow n,\n  { app := \u03bb T, Profinite.map_pow (S.as_limit_cone.\u03c0.app T) n \u226b\n      Profinite.sigma.\u03b9 _ f,\n    naturality' := begin\n      intros A B e,\n      dsimp [Profinite.pmz_diagram, Profinite.pmz_functor],\n      simpa,\n    end }\u27e9\n\ndef Profinite.pow_functor (n : \u2115) : Profinite.{u} \u2964 Profinite.{u} :=\n{ obj := \u03bb S, S.pow n,\n  map := \u03bb 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 \u2964 Profinite.{u}}\n  (E : limits.cone F) (n : \u2115) : limits.cone (F \u22d9 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 \u2964 Profinite.{u}}\n  (E : limits.cone F) (hE : limits.is_limit E) (n : \u2115) :\n  limits.is_limit (Profinite.pow_cone E n) :=\n{ lift := \u03bb Q, Profinite.product.lift _ $ \u03bb a,\n    hE.lift \u27e8Q.X,\n    { app := \u03bb j, Q.\u03c0.app j \u226b Profinite.product.\u03c0 _ a,\n      naturality' := begin\n        intros i j e, dsimp,\n        simp only [category.id_comp, category.assoc],\n        rw \u2190 Q.w e,\n        dsimp [Profinite.pow_functor, Profinite.map_pow],\n        simp,\n      end }\u27e9,\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_\u03c0, Profinite.product.lift_\u03c0_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_\u03c0],\n    apply hE.hom_ext,\n    intros j,\n    simp only [category.assoc, limits.is_limit.fac], rw \u2190 hm,\n    dsimp [Profinite.pow_cone, Profinite.pow_functor, Profinite.map_pow],\n    simp only [category.assoc, Profinite.product.lift_\u03c0],\n  end }\n\nlemma Profinite.is_iso_pmz_to_limit (S : Profinite.{u}) (n : \u2115) :\n  is_iso (S.pmz_to_limit n) :=\nbegin\n  let E := Profinite.sigma_cone (ulift.{u} (fin n \u2192 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 \u2245 (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 : \u2115) :\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 : \u2115) :\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 : \u2115) :\n  discrete_topology (S.pmz n) :=\nsigma.discrete_topology\n\n-- move this\nlemma _root_.sign_type.nnnorm_coe_int_le_one : \u2200 i : sign_type, \u2225(i : \u2124)\u2225\u208a \u2264 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 \u230aj\u230b\u208a \u2192 sign_type) :\n  (Profinite.of \u21a5T).pow \u230aj\u230b\u208a \u27f6\n  (ProFiltPseuNormGrp\u2081.level.obj j).obj (free_pfpng_functor.obj (Fintype.of \u21a5T)) :=\n{ to_fun := \u03bb t,\n  { val := \u2211 i : fin \u230aj\u230b\u208a, (\u03bb s, if t i = s then (e i : \u2124) else 0),\n    property := begin\n      have : \u2211 i : fin \u230aj\u230b\u208a, (\u2211 s : T, if t i = s then (1 : nnreal) else 0) \u2264 j,\n      { calc _\n            \u2264 \u2211 i : fin \u230aj\u230b\u208a, (1 : nnreal) : _\n        ... \u2264 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 \u230aj\u230b\u208a \u27f6\n    (ProFiltPseuNormGrp\u2081.level.obj j).obj (free_pfpng_functor.obj $ Fintype.of T) :=\nProfinite.sigma.desc _ $ \u03bb 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\u2081 T\u2082 : discrete_quotient S) (f : T\u2081 \u27f6 T\u2082)\n  (e : fin \u230aj\u230b\u208a \u2192 sign_type) (t : (Profinite.of T\u2081).pow \u230aj\u230b\u208a) (s : T\u2082) :\n(\u2211 i : fin \u230aj\u230b\u208a, \u03bb s : T\u2082, ite (S.fintype_diagram.map f (t i) = s) (e i : \u2124) 0) s =\n  (@finset.filter (@bundled.\u03b1 fintype (S.fintype_diagram.obj T\u2081))\n     (\u03bb w : T\u2081, S.fintype_diagram.map f w = s)\n     (\u03bb (a : @bundled.\u03b1 fintype (S.fintype_diagram.obj T\u2081)),\n        classical.prop_decidable _)\n     (@finset.univ (@bundled.\u03b1 fintype (S.fintype_diagram.obj T\u2081))\n        (@Fintype.fintype (S.fintype_diagram.obj T\u2081)))).sum\n    (\u2211 (i : fin \u230aj\u230b\u208a), \u03bb s : T\u2081, @ite \u2124 (t i = s) _ \u2191(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 \u230aj\u230b\u208a \u27f6 (S.fintype_diagram \u22d9 free_pfpng_functor) \u22d9\n    (ProFiltPseuNormGrp\u2081.level.obj j) :=\n{ app := \u03bb T, S.pmz_to_level j T,\n  naturality' := begin\n    intros T\u2081 T\u2082 f,\n    dsimp [Profinite.pmz_diagram, Profinite.pmz_to_level, Profinite.pmz_functor],\n    apply Profinite.sigma.hom_ext,\n    rintro \u27e8e\u27e9,\n    simp only [Profinite.sigma.\u03b9_desc_assoc, category.assoc, Profinite.sigma.\u03b9_desc],\n    ext t s,\n    exact Profinite.pmz_to_level_nat_trans_aux S j T\u2081 T\u2082 f e t s,\n  end }\n\ndef Profinite.pmz_to_free_pfpng (S : Profinite.{u}) (j : nnreal) :\n  S.pmz \u230aj\u230b\u208a \u27f6 (ProFiltPseuNormGrp\u2081.level.obj j).obj S.free_pfpng :=\nlet E := limits.is_limit_of_preserves (ProFiltPseuNormGrp\u2081.level.obj j)\n  (limits.limit.is_limit (S.fintype_diagram \u22d9 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 \u2964 Profinite.{u})\n  (\u03b1 : F \u27f6 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 : \u2200 (j : J), function.surjective \u21d1(\u03b1.app j)) :\n  function.surjective \u21d1(limits.is_limit.map cF hcG \u03b1) :=\nbegin\n  have := CompHaus.is_limit.surjective_of_surjective\n    (F \u22d9 Profinite_to_CompHaus)\n    (G \u22d9 Profinite_to_CompHaus)\n    (whisker_right \u03b1 _)\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 \u03b1)),\n  convert this,\n  apply hcG.hom_ext, intros j,\n  simp only [limits.is_limit.map_\u03c0, 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 \u22d9 Profinite_to_CompHaus))).inv.w j,\n  erw this,\n  dsimp, simp only [limits.limit.lift_\u03c0, limits.cones.postcompose_obj_\u03c0,\n    nat_trans.comp_app, functor.map_cone_\u03c0_app,\n    Profinite_to_CompHaus_map, whisker_right_app],\n  refl,\nend\n\nsection\nvariables {\u03b1 : Type*} [decidable_eq \u03b1] [nonempty \u03b1]\n\nopen finset\n\n-- TODO: Inlining this yields an app-builder exception\nlemma exists_signed_sum_aux {n : \u2115} (sgn : \u2115 \u2192 sign_type) (b : \u03b1) [decidable_eq \u03b1]\n  {f : \u03b1 \u2192 \u2124}\n  \u2983a : \u03b1\u2984 (g : \u2115 \u2192 \u03b1) (i : \u2115) :\n  ite ((range (n - (f a).nat_abs)).piecewise g (\u03bb _, a) i = b)\n        ((range (n - (f a).nat_abs)).piecewise sgn (\u03bb _, sign (f a)) i : \u2124) 0 =\n    (range (n - (f a).nat_abs)).piecewise (\u03bb j, ite (g j = b) \u2191(sgn j) 0)\n        (\u03bb j, ite (a = b) \u2191(sign (f a)) 0) i :=\nby { unfold piecewise, split_ifs; refl }\n\nlemma exists_signed_sum (s : finset \u03b1) (n : \u2115) (f : \u03b1 \u2192 \u2124) (hn : \u2211 i in s, (f i).nat_abs \u2264 n) :\n  \u2203 (sgn : \u2115 \u2192 sign_type) (g : \u2115 \u2192 \u03b1), (\u2200 i, g i \u2209 s \u2192 sgn i = 0) \u2227\n    \u2200 a \u2208 s, (\u2211 i in range n, if g i = a then (sgn i : \u2124) else 0) = f a :=\nbegin\n  induction s using finset.cons_induction with a s ha ih generalizing n,\n  { exact \u27e80, classical.arbitrary _, \u03bb _ _, rfl, \u03bb _, false.elim\u27e9 },\n  rw sum_cons at hn,\n  obtain \u27e8sgn, g, hg, hf\u27e9 := ih _ (le_tsub_of_add_le_left hn),\n  refine \u27e8(range $ n - (f a).nat_abs).piecewise sgn (\u03bb _, sign (f a)),\n    (range $ n - (f a).nat_abs).piecewise g (\u03bb _, a), \u03bb i hi, _, \u03bb b hb, _\u27e9,\n  { by_cases i \u2208 range (n - (f a).nat_abs),\n    { rw piecewise_eq_of_mem _ _ _ h at \u22a2 hi,\n      exact hg _ (\u03bb h, hi $ subset_cons _ h) },\n    { rw piecewise_eq_of_not_mem _ _ _ h at hi,\n      exact (hi $ mem_cons_self _ _).elim } },\n  transitivity \u2211 i in range n, (range $ n - (f a).nat_abs).piecewise\n    (\u03bb j, ite (g j = b) (sgn j : \u2124) 0) (\u03bb j, ite (a = b) (sign $ f a) 0) i,\n  { exact sum_congr rfl (\u03bb 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      \u2190int.sign_eq_sign, int.nat_cast_eq_coe_nat, (f b).sign_mul_nat_abs],\n    refine \u03bb 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 \u03b1]\n  (r : nnreal) (f : \u03b1 \u2192 \u2124) (hf : \u2211 i : \u03b1, \u2225f i\u2225\u208a \u2264 r) :\n  \u2203 (sgn : \u2115 \u2192 sign_type) (g : \u2115 \u2192 \u03b1),\n    \u2200 t, (\u2211 i in range \u230ar\u230b\u208a, if g i = t then (sgn i : \u2124) else 0) = f t :=\nbegin\n  refine Exists\u2082.imp (\u03bb _ _ h t, _) (exists_signed_sum univ \u230ar\u230b\u208a 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 \u03b1]\n  (r : nnreal) (f : \u03b1 \u2192 \u2124) (hf : \u2211 i : \u03b1, \u2225f i\u2225\u208a \u2264 r) :\n  \u2203 (sgn : fin \u230ar\u230b\u208a \u2192 sign_type) (g : fin \u230ar\u230b\u208a \u2192 \u03b1),\n    (\u2211 i : fin \u230ar\u230b\u208a, (\u03bb t : \u03b1, if g i = t then (sgn i : \u2124) else 0)) = f :=\nbegin\n  obtain \u27e8e,g,h\u27e9 := Profinite.pmz_to_free_pfpng_epi_aux' r f hf,\n  let e' : fin \u230ar\u230b\u208a \u2192 sign_type := \u03bb i, e i.1,\n  let g' : fin \u230ar\u230b\u208a \u2192 \u03b1 := \u03bb i, g i.1,\n  use [e',g'],\n  ext t, rw \u2190 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 := \u27e8T.proj (nonempty.some h)\u27e9\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\u2081.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 \u27e8(f : T \u2192 \u2124), hf : \u2211 i : T, _ \u2264 _\u27e9,\n  obtain \u27e8e,t,ht\u27e9 := Profinite.pmz_to_free_pfpng_epi_aux j f hf,\n  change \u2203 a : \u03a3 i, fin \u230aj\u230b\u208a \u2192 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  (\u03b7 : S.to_Condensed \u27f6 Condensed_Ab_to_CondensedSet.obj A)\n  (T : Profinite.{u}) :\n  (proetale_topology.to_sheafify _).app _ \u226b (S.free'_lift \u03b7).val.app (op T) =\n  free'_lift (\u03b7.val.app _) :=\nbegin\n  dsimp [Profinite.free'_lift],\n  rw [\u2190 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  (\u03b7 : S.to_Condensed \u27f6 Condensed_Ab_to_CondensedSet.obj A)\n  (T : Profinite.{u}) :\n  (proetale_topology.to_sheafify _).app _ \u226b (S.free'_lift \u03b7).val.app (op T) =\n  ((finsupp.lift \u21a5(A.val.obj (op T)) \u2124\n      (((Sheaf_to_presheaf proetale_topology (Type (u+1))).obj S.to_Condensed).obj (op T)))\n   (\u03b7.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 : \u2200 T : discrete_quotient S, S.free_pfpng_\u03c0 T u = S.free_pfpng_\u03c0 T v) : u = v :=\nbegin\n  let E : limits.cone (S.fintype_diagram \u22d9 free_pfpng_functor) :=\n    ProFiltPseuNormGrp\u2081.bounded_cone\n    \u27e8Ab.explicit_limit_cone.{u u} _, Ab.explicit_limit_cone_is_limit _\u27e9,\n  let hE : limits.is_limit E := ProFiltPseuNormGrp\u2081.bounded_cone_is_limit _,\n  let ee : S.free_pfpng \u2245 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 \u230aj\u230b\u208a) (T : discrete_quotient S)\n\nlemma lhs_helper : (S.free_pfpng_\u03c0 T) ((S.pmz_to_free_pfpng j) x).1 =\n  \u2211 i : fin \u230aj\u230b\u208a, pi.single (T.proj (x.2 i)) (x.1.down i : \u2124) :=\nbegin\n  change (((S.pmz_to_free_pfpng _) \u226b (ProFiltPseuNormGrp\u2081.level.obj j).map\n    (S.free_pfpng_\u03c0 T)) _).val = _,\n  dsimp [Profinite.pmz_to_free_pfpng, Profinite.free_pfpng_\u03c0],\n  erw \u2190 comp_apply,\n  erw limits.is_limit.fac,\n  dsimp [Profinite.pmz_to_level_nat_trans, Profinite.pmz_to_level],\n  rcases x with \u27e8x1,x2\u27e9,\n  dsimp [Profinite.pmz_cone, Profinite.sigma.desc, Profinite.pmz_to_level_component,\n    Profinite.pmz_functor, Profinite.product.lift, Profinite.sigma.\u03b9],\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\u2081 :\n  (\u03bb (f : ulift (fin \u230aj\u230b\u208a \u2192 sign_type)),\n  \u2211 (x : fin \u230aj\u230b\u208a),\n    ((proetale_topology.to_sheafify (S.to_Condensed.val \u22d9 AddCommGroup.free')).app\n      (op (S.pow \u230aj\u230b\u208a)))\n      (finsupp.single {down := Profinite.product.\u03c0 (\u03bb (i : fin \u230aj\u230b\u208a), S) x} \u2191(f.down x))) =\n  \u2211 (x : fin \u230aj\u230b\u208a), (\u03bb f, (proetale_topology.to_sheafify\n    (S.to_Condensed.val \u22d9 AddCommGroup.free')).app (op (S.pow \u230aj\u230b\u208a)) $\n    finsupp.single \u27e8Profinite.product.\u03c0 _ x\u27e9 (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) \u2192+ T \u2192 A :=\n{ to_fun := \u03bb f, f.down.1,\n  map_zero' := rfl,\n  map_add' := \u03bb _ _, rfl }\n\nlemma _root_.CompHausFiltPseuNormGrp.to_Condensed_app_sum_apply (n : \u2115)\n  (A : CompHausFiltPseuNormGrp.{u}) (T : Profinite.{u})\n    (g : fin n \u2192 (CompHausFiltPseuNormGrp.to_Condensed.obj A).val.obj (op T)) (t : T) :\n  (ulift.down (\u2211 i : fin n, g i)).1 t = \u2211 i : fin n,\n    (ulift.down (g i)).1 t :=\nbegin\n  let e := A.coe_add_monoid_hom T,\n  change _ = \u2211 (i : fin n), (e (g i)) t,\n  rw [\u2190 finset.sum_apply t finset.univ (\u03bb i : fin n, (e (g i))), \u2190 e.map_sum],\n  refl,\nend\n\nlemma Profinite.free'_lift_val_obj_sigma_equiv_symm {\u03b1 : Type u} [fintype \u03b1]\n  (A : Condensed.{u} Ab.{u+1}) (\u03b7 : S.to_Condensed \u27f6 Condensed_Ab_to_CondensedSet.obj A)\n  (X : \u03b1 \u2192 Profinite.{u}) (t) :\n  (S.free'_lift \u03b7).val.app (op $ Profinite.sigma X)\n  ((Condensed.val_obj_sigma_add_equiv _ _ ).symm t) =\n  (Condensed.val_obj_sigma_add_equiv _ _ ).symm (\u03bb a, (S.free'_lift \u03b7).val.app _ (t a)) :=\nbegin\n  apply_fun Condensed.val_obj_sigma_add_equiv (\u03bb (a : \u03b1), X a) A,\n  simp only [add_equiv.apply_symm_apply],\n  funext a,\n  dsimp,\n  simp only [\u2190 comp_apply, \u2190 nat_trans.naturality],\n  simp only [comp_apply],\n  congr' 1,\n  rw \u2190 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\u2081.{u}) :\n  A \u2243 (CompHausFiltPseuNormGrp.to_Condensed.obj\n    (CHFPNG\u2081_to_CHFPNG\u2091\u2097.obj\n      (PFPNG\u2081_to_CHFPNG\u2081\u2091\u2097.obj A))).val.obj\n      (op Profinite.punit) :=\n{ to_fun := \u03bb a, ulift.up $ \u27e8\u03bb _, a, begin\n    obtain \u27e8c,hc\u27e9 := ProFiltPseuNormGrp\u2081.exhaustive _ a,\n    refine \u27e8c, \u03bb _, \u27e8a,hc\u27e9, _, rfl\u27e9,\n    apply continuous_of_discrete_topology\n  end\u27e9,\n  inv_fun := \u03bb f, f.down.val punit.star,\n  left_inv := \u03bb t, rfl,\n  right_inv := \u03bb t, by { ext \u27e8\u27e9, refl } }\n\n-- move and rename\ndef rhs_helper_equiv' :\n  S \u2243 S.to_Condensed.val.obj (op Profinite.punit) :=\n{ to_fun := \u03bb s, ulift.up $ Profinite.pt s,\n  inv_fun := \u03bb s, (ulift.down s).1 punit.star,\n  left_inv := \u03bb t, rfl,\n  right_inv := \u03bb t, by { ext \u27e8\u27e9, refl } }\n\nlemma rhs_helper\u2084 {\u03b1 : Type u} [fintype \u03b1]\n  (A : ProFiltPseuNormGrp\u2081.{u})\n  (X : \u03b1 \u2192 Profinite.{u})\n  (e : \u03a0 (a : \u03b1),\n    (CompHausFiltPseuNormGrp.to_Condensed.obj\n    (CHFPNG\u2081_to_CHFPNG\u2091\u2097.obj\n      (PFPNG\u2081_to_CHFPNG\u2081\u2091\u2097.obj A))).val.obj (op $ X a))\n  (a\u2080 : \u03b1) (x\u2080 : X a\u2080) :\n  ((Condensed.val_obj_sigma_add_equiv X _).symm e).down.val \u27e8a\u2080,x\u2080\u27e9 =\n  (e a\u2080).down.val x\u2080 :=\nbegin\n  let B := Condensed_Ab_to_CondensedSet.obj\n    (CompHausFiltPseuNormGrp.to_Condensed.obj\n    (CHFPNG\u2081_to_CHFPNG\u2091\u2097.obj\n      (PFPNG\u2081_to_CHFPNG\u2081\u2091\u2097.obj A))) ,\n  let e\u2080 : (X a\u2080).to_Condensed \u27f6 B :=\n    (Profinite.to_Condensed_equiv _ B).symm (e a\u2080),\n  let ee : (Profinite.sigma X).to_Condensed \u27f6 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\u2080 : (X a\u2080).to_Condensed.val.obj (op Profinite.punit) :=\n    rhs_helper_equiv' _ x\u2080,\n  have : (rhs_helper_equiv A) ((e a\u2080).down.val x\u2080) =\n    e\u2080.val.app _ s\u2080, refl,\n  rw this,\n  have : e\u2080 = (Profinite_to_Condensed.map (Profinite.sigma.\u03b9 X a\u2080)) \u226b ee,\n  { dsimp only [e\u2080, ee], symmetry,\n    apply _root_.Condensed.val_obj_sigma_add_equiv_symm_apply },\n  rw this, refl,\nend\n\nlemma rhs_helper\u2083 (i : fin \u230aj\u230b\u208a) :\n  ((((S.free'_lift S.to_condensed_free_pfpng).val.app (op (S.pmz \u230aj\u230b\u208a)))\n    (((Condensed.val_obj_sigma_add_equiv (\u03bb (f : ulift (fin \u230aj\u230b\u208a \u2192 sign_type)), S.pow \u230aj\u230b\u208a)\n      S.free').symm)\n    (\u03bb (f : ulift (fin \u230aj\u230b\u208a \u2192 sign_type)),\n      ((proetale_topology.to_sheafify (S.to_Condensed.val \u22d9 AddCommGroup.free')).app\n      (op (S.pow \u230aj\u230b\u208a)))\n      (finsupp.single {down := Profinite.product.\u03c0 (\u03bb (i : fin \u230aj\u230b\u208a), S) i}\n        \u2191(f.down i))))).down).1 x =\n    (x.1.down i : \u2124) \u2022 (S.to_free_pfpng (x.2 i)).1 :=\nbegin\n  erw Profinite.free'_lift_val_obj_sigma_equiv_symm,\n  simp only [\u2190 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 (\u03bb (a : ulift (fin \u230aj\u230b\u208a \u2192 sign_type)), S.pow \u230aj\u230b\u208a)\n    S.condensed_free_pfpng,\n  change (Q.symm _).down.1 _ = _,\n  cases x with x1 x2,\n  erw rhs_helper\u2084,\n  refl,\nend\n\nlemma rhs_helper\u2082 (i : fin \u230aj\u230b\u208a) : (S.free_pfpng_\u03c0 T)\n  (((((S.free'_lift S.to_condensed_free_pfpng).val.app (op (S.pmz \u230aj\u230b\u208a)))\n    (((Condensed.val_obj_sigma_add_equiv (\u03bb (f : ulift (fin \u230aj\u230b\u208a \u2192 sign_type)), S.pow \u230aj\u230b\u208a)\n      S.free').symm)\n    (\u03bb (f : ulift (fin \u230aj\u230b\u208a \u2192 sign_type)),\n      ((proetale_topology.to_sheafify (S.to_Condensed.val \u22d9 AddCommGroup.free')).app\n      (op (S.pow \u230aj\u230b\u208a)))\n      (finsupp.single {down := Profinite.product.\u03c0 (\u03bb (i : fin \u230aj\u230b\u208a), S) i}\n        \u2191(f.down i))))).down).1 x) =\n  pi.single (T.proj (x.snd i)) \u2191(x.fst.down i) :=\nbegin\n  rw rhs_helper\u2083,\n  erw (S.free_pfpng_\u03c0 T).to_add_monoid_hom.map_zsmul,\n  change\n    _ \u2022 (((S.to_free_pfpng) \u226b (ProFiltPseuNormGrp\u2081.level.obj 1).map (S.free_pfpng_\u03c0 T)) _).val = _,\n  dsimp [Profinite.to_free_pfpng, Profinite.free_pfpng_\u03c0,\n    Profinite.free_pfpng_level_iso],\n  dsimp [limits.is_limit.cone_point_unique_up_to_iso],\n  erw \u2190 comp_apply,\n  erw \u2190 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_\u03c0 T)\n  ((((S.free'_lift S.to_condensed_free_pfpng).val.app (op (S.pmz \u230aj\u230b\u208a)))\n  ((S.pmz_to_free' \u230aj\u230b\u208a).val.app (op (S.pmz \u230aj\u230b\u208a)) {down := \ud835\udfd9 (S.pmz \u230aj\u230b\u208a)})).1.1 x) =\n  \u2211 i : fin \u230aj\u230b\u208a, pi.single (T.proj (x.2 i)) (x.1.down i : \u2124) :=\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\u2081],\n  rw [add_equiv.map_sum, add_monoid_hom.map_sum],\n  have := _root_.CompHausFiltPseuNormGrp.to_Condensed_app_sum_apply \u230aj\u230b\u208a _ _ _ x,\n  dsimp at this, erw this, clear this,\n  erw (S.free_pfpng_\u03c0 T).to_add_monoid_hom.map_sum,\n  congr' 1, funext i, dsimp,\n  erw rhs_helper\u2082,\nend\n\nlemma key (j : (ulift.{u+1} nnreal)) :\n  Profinite_to_Condensed.map (S.pmz_to_free_pfpng j.down) \u226b\n    (CHFPNG\u2081_to_CHFPNG\u2091\u2097.obj\n    (PFPNG\u2081_to_CHFPNG\u2081\u2091\u2097.obj S.free_pfpng)).level_Condensed_diagram_cocone.\u03b9.app j =\n  S.pmz_to_free' \u230aj.down\u230b\u208a \u226b\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\u2081_to_CHFPNG\u2091\u2097.obj\n    ((PFPNG\u2081_to_CHFPNG\u2081\u2091\u2097.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 \u230aj'\u230b\u208a).to_Condensed, S.pmz_to_free' \u230aj'\u230b\u208a,\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\u207b\u00b9\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 $ \u211d\u22650) (M : Type*)\n  extends comphaus_filtered_pseudo_normed_group M :=\n(Tinv : comphaus_filtered_pseudo_normed_group_hom M M)\n(Tinv_mem_filtration : \u2200 c x, x \u2208 filtration c \u2192 Tinv x \u2208 filtration (r'\u207b\u00b9 * c))\n\n/-- A *profinitely filtered pseudo-normed topological group with action by `T\u207b\u00b9`* is\na profinitely filtered pseudo-normed topological group `M` together with a\nnonnegative real `r'` and homomorphism `Tinv : M \u2192 M` such that\n`Tinv x \u2208 filtration M (r'\u207b\u00b9 * c)` for all `x \u2208 filtration M c`.\n-/\nclass profinitely_filtered_pseudo_normed_group_with_Tinv (r' : out_param $ \u211d\u22650) (M : Type*)\n  extends profinitely_filtered_pseudo_normed_group M :=\n(Tinv : comphaus_filtered_pseudo_normed_group_hom M M)\n(Tinv_mem_filtration : \u2200 c x, x \u2208 filtration c \u2192 Tinv x \u2208 filtration (r'\u207b\u00b9 * c))\n\nnamespace profinitely_filtered_pseudo_normed_group_with_Tinv\n\nvariables {r' : \u211d\u22650} {M M\u2081 M\u2082 M\u2083 : Type*}\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M\u2081]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M\u2082]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M\u2083]\n\nlemma aux {r' c c\u2082 : \u211d\u22650} (h : c \u2264 r' * c\u2082) : r'\u207b\u00b9 * c \u2264 c\u2082 :=\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\u2080 (c c\u2082 : \u211d\u22650) [h : fact (c \u2264 r' * c\u2082)] (x : filtration M c) : filtration M c\u2082 :=\n\u27e8Tinv (x : M), filtration_mono (aux h.1) (Tinv_mem_filtration _ _ x.2)\u27e9\n\nlemma Tinv\u2080_continuous (c c\u2082 : \u211d\u22650) [fact (c \u2264 r' * c\u2082)] :\n  continuous (@Tinv\u2080 r' M _ c c\u2082 _) :=\nTinv.continuous _ $ \u03bb x, rfl\n\nlemma Tinv_bound_by : (@Tinv _ M _).bound_by (r'\u207b\u00b9) := 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\u207b\u00b9. -/\nstructure comphaus_filtered_pseudo_normed_group_with_Tinv_hom (r' : \u211d\u22650) (M\u2081 M\u2082 : Type*)\n  [comphaus_filtered_pseudo_normed_group_with_Tinv r' M\u2081]\n  [comphaus_filtered_pseudo_normed_group_with_Tinv r' M\u2082]\n  extends M\u2081 \u2192+ M\u2082 :=\n(strict' : \u2200 \u2983c x\u2984, x \u2208 filtration M\u2081 c \u2192 to_fun x \u2208 filtration M\u2082 c)\n(continuous' : \u2200 c, continuous (pseudo_normed_group.level to_fun strict' c))\n(map_Tinv' : \u2200 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' : \u211d\u22650} {M M\u2081 M\u2082 M\u2083 : Type*}\nvariables [comphaus_filtered_pseudo_normed_group_with_Tinv r' M]\nvariables [comphaus_filtered_pseudo_normed_group_with_Tinv r' M\u2081]\nvariables [comphaus_filtered_pseudo_normed_group_with_Tinv r' M\u2082]\nvariables [comphaus_filtered_pseudo_normed_group_with_Tinv r' M\u2083]\nvariables (f g : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2081 M\u2082)\n\ninstance : has_coe_to_fun (comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2081 M\u2082)\n  (\u03bb _, M\u2081 \u2192 M\u2082):=\n\u27e8comphaus_filtered_pseudo_normed_group_with_Tinv_hom.to_fun\u27e9\n\n@[simp] lemma coe_mk (f) (h\u2081) (h\u2082) (h\u2083) (h\u2084) (h\u2085) :\n  \u21d1(\u27e8f, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085\u27e9 : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2081 M\u2082) = f :=\nrfl\n\n@[simp] lemma mk_to_monoid_hom (f) (h\u2081) (h\u2082) (h\u2083) (h\u2084) (h\u2085) :\n  (\u27e8f, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085\u27e9 :\n    comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2081 M\u2082).to_add_monoid_hom =\n    \u27e8f, h\u2081, h\u2082\u27e9 := rfl\n\n@[simp] lemma coe_to_add_monoid_hom : \u21d1f.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 {\u03b9 : Type*} (x : \u03b9 \u2192 M\u2081) (s : finset \u03b9) :\n  f (\u2211 i in s, x i) = \u2211 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 : \u2124) (x) : f (n \u2022 x) = n \u2022 (f x) := f.to_add_monoid_hom.map_zsmul _ _\n\nlemma strict : \u2200 \u2983c x\u2984, x \u2208 filtration M\u2081 c \u2192 f x \u2208 filtration M\u2082 c := f.strict'\n\n/-- `f.level c` is the function `filtration M\u2081 c \u2192 filtration M\u2082 c`\ninduced by a `comphaus_filtered_pseudo_normed_group_with_Tinv_hom M\u2081 M\u2082`. -/\n@[simps] def level : \u2200 (c : \u211d\u22650), filtration M\u2081 c \u2192 filtration M\u2082 c :=\npseudo_normed_group.level f f.strict\n\nlemma level_continuous (c : \u211d\u22650) : continuous (f.level c) := f.continuous' c\n\nlemma map_Tinv (x : M\u2081) : f (Tinv x) = Tinv (f x) := f.map_Tinv' x\n\nvariables {f g}\n\n@[ext] theorem ext (H : \u2200 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\u2081 M\u2082) :=\n\u27e8{ strict' := \u03bb c x h, zero_mem_filtration _,\n   continuous' := \u03bb c, @continuous_const _ (filtration M\u2082 c) _ _ 0,\n   map_Tinv' := \u03bb x, show 0 = Tinv (0 : M\u2082), from Tinv.map_zero.symm,\n   .. (0 : M\u2081 \u2192+ M\u2082) }\u27e9\n\ninstance : inhabited (comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2081 M\u2082) := \u27e80\u27e9\n\nlemma coe_inj \u2983f g : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2081 M\u2082\u2984\n  (h : (f : M\u2081 \u2192 M\u2082) = 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' := \u03bb c x, id,\n  continuous' := \u03bb c, by { convert continuous_id, ext, refl },\n  map_Tinv' := \u03bb 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\u2082 M\u2083)\n  (f : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2081 M\u2082) :\n  comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2081 M\u2083 :=\n{ strict' := \u03bb c x hx, g.strict (f.strict hx),\n  continuous' := \u03bb c, (g.level_continuous c).comp (f.level_continuous c),\n  map_Tinv' := \u03bb 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\u2081 M\u2082 :=\ncomphaus_filtered_pseudo_normed_group_hom.mk_of_strict f.to_add_monoid_hom\n(\u03bb c, \u27e8\u03bb x h, f.strict h, f.level_continuous c\u27e9)\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\u2081 M\u2082)\n  (hf1 : f.bound_by 1) (hfT) :\n  comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2081 M\u2082 :=\n{ to_fun := f,\n  strict' := \u03bb c x hx, by simpa only [one_mul] using hf1 hx,\n  continuous' := \u03bb c, f.continuous _ (\u03bb x, rfl),\n  map_Tinv' := hfT,\n  .. f }\n\n@[simp] lemma mk'_apply\n  (f : comphaus_filtered_pseudo_normed_group_hom M\u2081 M\u2082) (hf1) (hfT) (x : M\u2081) :\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\u2081 \u2243+ M\u2082) (he : \u2200 x, f x = e x)\n  (strict : \u2200 \u2983c x\u2984, x \u2208 filtration M\u2082 c \u2192 e.symm x \u2208 filtration M\u2081 c) :\n  comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' M\u2082 M\u2081 :=\n{ strict' := strict,\n  continuous' := \u03bb 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\u2081 c) \u2243 (filtration M\u2082 c) :=\n    \u27e8\u03bb x, \u27e8f x, f.strict x.2\u27e9, \u03bb x, \u27e8e.symm x, strict x.2\u27e9, \u03bb x, by simp [he], \u03bb x, by simp [he]\u27e9,\n    change continuous g.symm,\n    rw continuous_iff_is_closed,\n    intros U hU,\n    rw [\u2190 g.image_eq_preimage],\n    exact (hcont.closed_embedding g.injective).is_closed_map U hU,\n  end,\n  map_Tinv' := \u03bb 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, \u2190 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\u2081) (e : M\u2081 \u2243+ M\u2082) (he : \u2200 x, f x = e x)\n  (strict : \u2200 \u2983c x\u2984, x \u2208 filtration M\u2082 c \u2192 e.symm x \u2208 filtration M\u2081 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\u2082) (e : M\u2081 \u2243+ M\u2082) (he : \u2200 x, f x = e x)\n  (strict : \u2200 \u2983c x\u2984, x \u2208 filtration M\u2082 c \u2192 e.symm x \u2208 filtration M\u2081 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' : \u211d\u22650) :\n  profinitely_filtered_pseudo_normed_group_with_Tinv r' punit :=\n{ Tinv := comphaus_filtered_pseudo_normed_group_hom.id,\n  Tinv_mem_filtration := \u03bb 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' : \u211d\u22650) {\u03b9 : Type*} (M M\u2081 M\u2082 : \u03b9 \u2192 Type*)\nvariables [\u03a0 i, profinitely_filtered_pseudo_normed_group_with_Tinv r' (M i)]\nvariables [\u03a0 i, profinitely_filtered_pseudo_normed_group_with_Tinv r' (M\u2081 i)]\nvariables [\u03a0 i, profinitely_filtered_pseudo_normed_group_with_Tinv r' (M\u2082 i)]\n\ninstance pi : profinitely_filtered_pseudo_normed_group_with_Tinv r' (\u03a0 i, M i) :=\n{ Tinv := comphaus_filtered_pseudo_normed_group.pi_map (\u03bb i, Tinv)\n    \u27e8r'\u207b\u00b9, \u03bb i, Tinv_bound_by\u27e9,\n  Tinv_mem_filtration := \u03bb 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 : \u2115) :\n  profinitely_filtered_pseudo_normed_group_with_Tinv r' (M^N) :=\nprofinitely_filtered_pseudo_normed_group_with_Tinv.pi r' (\u03bb i, M)\n\ninclude r'\n@[simp] lemma pi_Tinv_apply (x : \u03a0 i, M i) (i : \u03b9) : Tinv x i = Tinv (x i) := rfl\nomit r'\n\n@[simps {fully_applied := ff}]\ndef pi_proj (i : \u03b9) : comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' (\u03a0 i, M i) (M i) :=\n{ to_fun := pi.eval_add_monoid_hom M i,\n  strict' := \u03bb c x hx, hx i,\n  continuous' := \u03bb c, (continuous_apply i).comp (filtration_pi_homeo M c).continuous,\n  map_Tinv' := \u03bb 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\u207b\u00b9`-action -/\n@[simps {fully_applied := ff}]\ndef pi_lift {N : Type*} [profinitely_filtered_pseudo_normed_group_with_Tinv r' N]\n  (f : \u03a0 i, comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' N (M i)) :\n  comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' N (\u03a0 i, M i) :=\n{ to_fun := add_monoid_hom.mk_to_pi (\u03bb i, (f i).to_add_monoid_hom),\n  strict' := \u03bb 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' := \u03bb x, by { ext i, exact (f i).map_Tinv x },\n  .. add_monoid_hom.mk_to_pi (\u03bb i, (f i).to_add_monoid_hom) }\n\n@[simps {fully_applied := ff}]\ndef pi_map (f : \u03a0 i, comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' (M\u2081 i) (M\u2082 i)) :\n  comphaus_filtered_pseudo_normed_group_with_Tinv_hom r' (\u03a0 i, M\u2081 i) (\u03a0 i, M\u2082 i) :=\npi_lift r' _ $ \u03bb 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": "--\n\nmutual\n\ndef f (x : Nat) : Nat \u2192 Nat\n| 0   => 1\n| x+1 => g x\n\ntheorem g (x : Nat) : Nat \u2192 Nat -- cannot mix theorems and definitions\n| 0   => 2\n| x+1 => f x\n\nend\n\nmutual\n\ndef f  : Nat \u2192 Nat\n| 0   => 1\n| x+1 => g x\n\nexample : Nat := -- cannot mix examples and definitions\ng 10\n\nend\n\nmutual\n\ndef f (x : Nat) : Nat \u2192 Nat\n| 0   => 1\n| x+1 => g x\n\nunsafe def g (x : Nat) : Nat \u2192 Nat -- cannot mix safe and unsafe definitions\n| 0   => 2\n| x+1 => f x\n\nend\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/mutualdef1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5621765008857981, "lm_q2_score": 0.3702253786982541, "lm_q1q2_score": 0.20813200793570397}}
{"text": "import analysis.inner_product_space.pi_L2\nimport topology.paracompact\n\n\n--OUTPUT 1\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume A : set (euclidean_space \u211d (fin n)),\n  assume h1 : is_open_cover A,\n  have h2 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open_cover Cm \u2227 \u2200 c \u2208 Cm, \u2203 a \u2208 A, c \u2286 a \u2227 c \u2286 (\u211dn \\ (closure (ball (0 : \u211dn) m))), from sorry,\n  have h3 : \u2200 m : \u2115, is_open_cover (\u22c3 m : \u2115, classical.some (h2 m)), from sorry,\n  have h4 : \u2200 m : \u2115, \u2200 c \u2208 (\u22c3 m : \u2115, classical.some (h2 m)), \u2203 a \u2208 A, c \u2286 a \u2227 c \u2286 (\u211dn \\ (closure (ball (0 : \u211dn) m))), from sorry,\n  have h5 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 closure (ball (0 : \u211dn) m)), from sorry,\n  have h6 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h7 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h8 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h9 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h10 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h11 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h12 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h13 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h14 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h15 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h16 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h17 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h18 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h19 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h20 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h21 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h22 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h23 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h24 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h25 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h26 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h27 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry,\n  have h28 : \u2200 x : \u211dn, \u2203 m : \u2115, \u2200 y : \u211dn, (y \u2208 (\u22c3 m : \u2115, classical.some (h2 m))) \u2192 (x \u2208 ball (0 : \u211dn) m), from sorry\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open_cover A),\n  have h1 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h2 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h3 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h4 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h5 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h6 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h7 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h8 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h9 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h10 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h11 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h12 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h13 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h14 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h15 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h16 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h17 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h18 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h19 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h20 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h21 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h22 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h23 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h24 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h25 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h26 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h27 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h28 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h29 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h30 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h31 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h32 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h33 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h34 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h35 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h36 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h37 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h38 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h39 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h40 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h41 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h42 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h43 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115), x \u2264 m \u2227 m \u2264 x + 1, from sorry,\n  have h44 : \u2200 (x : \u211d) (n : \u2115), \u2203 (m : \u2115),\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open A) (hA2 : is_cover A),\n  have h1 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h2 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h3 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h4 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h5 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h6 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h7 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n\n  have h8 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h9 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h10 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h11 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h12 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h13 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h14 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h15 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h16 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h17 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h18 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h19 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h20 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open Cm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Cm \u2192 x \u2209 (closure (ball (0 : euclidean_space \u211d (fin n)) (m - 1))), from sorry,\n  have h21 : \u2200 m : \u2115, \u2203 Cm : set (euclidean_space \u211d (fin n)), is_open C\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open A) (hA_cover : \u22c3\u2080 A = univ),\n\n  have h1 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h2 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h3 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h4 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h5 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h6 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h7 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h8 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h9 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h10 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h11 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h12 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h13 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h14 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h15 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h16 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h17 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h18 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h19 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h20 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h21 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_m \u2227 \u2200 U \u2208 A, \u2203 V \u2208 C_m, U \u2286 V \u2227 V \u2229 (closure (ball (0 : \u211d^n) m)) = \u2205, from sorry,\n\n  have h22 : \u2200 m : \u2115, \u2203 C_m : set (euclidean_space \u211d (fin n)), is_open C_\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open_cover A),\n  have h1 : \u2200 m : \u2115, is_open (ball (0 : \u211d^(fin n)) m), from sorry,\n  have h2 : \u2200 m : \u2115, is_compact (closure (ball (0 : \u211d^(fin n)) m)), from sorry,\n  have h3 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h4 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h5 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h6 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h7 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h8 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h9 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h10 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h11 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h12 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h13 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h14 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h15 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h16 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h17 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h18 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h19 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h20 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h21 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h22 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h23 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h24 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h25 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h26 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h27 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h28 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h29 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h30 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h31 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h32 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h33 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h34 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h35 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h36 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h37 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h38 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h39 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h40 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h41 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h42 : \u2200 m : \u2115, \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : is_open_cover C), sorry,\n  have h43 : \u2200 m : \u2115\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume A : set (euclidean_space \u211d (fin n)),\n  assume hA : is_open A,\n  assume hA2 : is_cover A,\n  have h1 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h2 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h3 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h4 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h5 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h6 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h7 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h8 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h9 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h10 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h11 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h12 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h13 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h14 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h15 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h16 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h17 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h18 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h19 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h20 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h21 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h22 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h23 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h24 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h25 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h26 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h27 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h28 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h29 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h30 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h31 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h32 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h33 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h34 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h35 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h36 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h37 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h38 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h39 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h40 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h41 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h42 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h43 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h44 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h45 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h46 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h47 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h48 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 x + m + 1 > 0, from sorry,\n  have h49 : \u2200 x : \u211d, \u2203 m : \u2115, x - m \u2264 0 \u2227 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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  \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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 \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))),\n  assume hA : is_open_cover A,\n  have h1 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 n : \u2115, n < m \u2192 x \u2209 closure (ball (0 : euclidean_space \u211d (fin n)) n), from sorry,\n  \n  have h2 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 n : \u2115, n < m \u2192 x \u2209 ball (0 : euclidean_space \u211d (fin n)) n, from sorry,\n  \n  have h3 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2203 C\u2098 : set (euclidean_space \u211d (fin n)), x \u2208 C\u2098 \u2227 C\u2098 \u2286 \u22c3\u2080 A \u2227 \u2200 y \u2208 C\u2098, y \u2208 ball (0 : euclidean_space \u211d (fin n)) m \u2227 y \u2209 ball (0 : euclidean_space \u211d (fin n)) (m - 1), from sorry,\n\n  show \u2203 C : set (euclidean_space \u211d (fin n)), is_open_cover C \u2227 is_locally_finite_cover C \u2227 A \u2264 C, from sorry,\nend\n\n--OUTPUT 2\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (U : set (euclidean_space \u211d (fin n))) (h1 : is_open U),\n  have h2 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = (\u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1), from sorry,\n  have h3 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h4 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h5 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h6 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h7 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h8 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h9 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h10 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h11 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h12 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h13 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h14 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h15 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h16 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h17 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h18 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h19 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h20 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h21 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h22 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h23 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h24 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h25 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h26 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_open_ball x 1, from sorry,\n  have h27 : \u2203 (K : set (euclidean_space \u211d (fin n))), is_compact K \u2227 U = \u22c3 (x : (euclidean_space \u211d (fin n))) (h2 : x \u2208 K), is_\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open A) (hA2 : \u22c3\u2080 A = univ),\n\n  let C0 : set (euclidean_space \u211d (fin n)) := {},\n  let B0 : set (euclidean_space \u211d (fin n)) := {},\n  let Bm : \u2115 \u2192 set (euclidean_space \u211d (fin n)) := \u03bb m, {x | \u2203 (y : euclidean_space \u211d (fin n)), y \u2208 Bm 0 \u2227 x \u2208 ball (euclidean_space \u211d (fin n)) y m},\n  let Cm : \u2115 \u2192 set (euclidean_space \u211d (fin n)) := \u03bb m, {x | \u2203 (y : euclidean_space \u211d (fin n)), y \u2208 Bm 0 \u2227 x \u2208 ball (euclidean_space \u211d (fin n)) y m \u2227 y \u2209 Bm 0},\n  let C : set (euclidean_space \u211d (fin n)) := {x | \u2203 (m : \u2115) (y : euclidean_space \u211d (fin n)), y \u2208 Bm 0 \u2227 x \u2208 ball (euclidean_space \u211d (fin n)) y m \u2227 y \u2209 Bm 0},\n  let B : set (euclidean_space \u211d (fin n)) := {x | \u2203 (m : \u2115) (y : euclidean_space \u211d (fin n)), y \u2208 Bm 0 \u2227 x \u2208 ball (euclidean_space \u211d (fin n)) y m},\n\n  have hB0 : is_open B0, from sorry,\n  have hBm : \u2200 m : \u2115, 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 : \u2200 m : \u2115, is_open (Cm m), from sorry,\n  have hC : is_open C, from sorry,\n\nend\n\n--OUTPUT 4\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (\u03c6 : set (euclidean_space \u211d (fin n))),\n  assume (h1 : \u03c6 = \u2205),\n  have h2 : \u03c6 = \u2205, from sorry,\n  have h3 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h4 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h5 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h6 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h7 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h8 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h9 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h10 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h11 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h12 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h13 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h14 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h15 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h16 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h17 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h18 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h19 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h20 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h21 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h22 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h23 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h24 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h25 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h26 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h27 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h28 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h29 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h30 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h31 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h32 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h33 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h34 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h35 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h36 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h37 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h38 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h39 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h40 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h41 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h42 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h43 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h44 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h45 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h46 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h47 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h48 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h49 : \u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 \u03c6 \u2192 U = \u2205, from sorry,\n  have h50 : \u2200 (U : set (euclidean_space\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open A) (h1 : A\u2080 \u2286 A),\n  have h2 : is_open (A\u2080), from sorry,\n  have h3 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h4 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h5 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h6 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h7 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h8 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h9 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h10 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h11 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h12 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h13 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h14 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h15 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h16 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h17 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h18 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h19 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h20 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h21 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h22 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h23 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h24 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h25 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h26 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h27 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h28 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h29 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h30 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h31 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h32 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h33 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h34 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h35 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h36 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h37 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h38 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h39 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h40 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h41 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h42 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h43 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h44 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h45 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h46 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h47 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h48 : \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, x \u2208 (B_m), from sorry,\n  have h49\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open A) (hA_cover : \u27eaA\u27eb = \u22a4),\n  \n  let B0 : set (euclidean_space \u211d (fin n)) := \u2205,\n  let B : \u2115 \u2192 set (euclidean_space \u211d (fin n)) := \u03bb m, (ball (0 : \u211d ^ n) m),\n  let Bbar : \u2115 \u2192 set (euclidean_space \u211d (fin n)) := \u03bb m, closure (B m),\n\n  let Bbar_compact : \u2115 \u2192 Prop := \u03bb m, compact (Bbar m),\n  let Bbar_compact_true : \u2200 m : \u2115, Bbar_compact m := by {\n    assume m : \u2115,\n    have h1 : compact (Bbar m), from sorry,\n    show Bbar_compact m, from h1,\n  },\n\n  let C : \u2115 \u2192 set (euclidean_space \u211d (fin n)) := \u03bb m, (B m) \u2229 (\u22a4 \\ (Bbar (m-1))),\n  let C_union : set (euclidean_space \u211d (fin n)) := \u22c3 (m : \u2115), (C m),\n\n  let C_union_cover : \u27eaC_union\u27eb = \u22a4 := by {\n    have h1 : \u27eaC_union\u27eb \u2286 \u22a4, from by {\n      assume x : (euclidean_space \u211d (fin n)),\n      assume h1 : x \u2208 \u27eaC_union\u27eb,\n      have h2 : \u2203 m : \u2115, x \u2208 (C m), from sorry,\n      cases h2 with m h2,\n      have h3 : x \u2208 (\u22a4 \\ (Bbar (m-1))), from sorry,\n      have h4 : x \u2208 \u22a4, from sorry,\n      show x \u2208 \u22a4, from h4,\n    },\n    have h2 : \u22a4 \u2286 \u27eaC_union\u27eb, from by {\n      assume x : (euclidean_space \u211d (fin n)),\n      assume h2 : x \u2208 \u22a4,\n      have h3 : \u2203 m : \u2115, x \u2208 (B m), from sorry,\n      cases h3 with m h3,\n      have h4 : x \u2208 (B m), from h3,\n      have h5 : x \u2208 (\u22a4 \\ (Bbar (m-1))), from sorry,\n      have h6 : x \u2208 (C m), from sorry,\n      have h7 : x \u2208 \u27eaC_union\u27eb, from sorry,\n      show x \u2208 \u27eaC_union\u27eb, from h7,\n    },\n    show \u27eaC_union\u27eb = \u22a4, from sorry,\n  },\n\n  let C_union_open : is_open C_union := by {\n    have h1 : \u2200 m : \u2115, is_open (C m), from by {\n      assume m : \u2115,\n      have h1 : is_open (B m), from sorry,\n      have h2 : is_open (\u22a4 \\ (Bbar (m-1))), from sorry,\n      have h3 : is_open ((B m) \u2229 (\u22a4 \\ (Bbar (m-1)))), from sorry,\n      show is_open (C m), from h3,\n    },\n    have h2 : \u2200 m : \u2115, 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 \u211d (fin n)),\n    assume h1 : x \u2208 C_union,\n    have h2 : \u2203 m : \u2115, x \u2208 (C m), from sorry,\n    cases h2 with m h2,\n    have h3 : x \u2208 (C m), from h2,\n    have h4 : x \u2208 (ball (0 : \u211d ^ n) m), from sorry,\n    have h5 : x \u2208 (\u22a4 \\ (Bbar (m-1))), from sorry,\n    have h6 : x \u2208 (Bbar m), from sorry,\n    have h7 : x \u2208 (closure (Bbar m)), from sorry,\n    have h8 : x \u2208 (\u27ea(closure (Bbar m))\u27eb), from sorry,\n    have h9 : \u27ea(closure (Bbar m))\u27eb \u2286 \u27ea(Bbar m)\u27eb, from sorry,\n    have h10 : \u27ea(Bbar m)\u27eb \u2286 \u27ea(B m)\u27eb, from sorry,\n    have h11 : \u27ea(closure (Bbar m))\u27eb \u2286 \u27ea(B m)\u27eb, from sorry,\n    have h12 : \u27ea(closure (Bbar m))\u27eb \u2286 (B m), from sorry,\n    have h13 : \u27ea(closure (Bbar m))\u27eb \u2286 ((B m) \u2229 (\u22a4 \\ (Bbar (m-1)))), from sorry,\n    have h14 : \u27ea(closure (Bbar m))\u27eb \u2286 (C m), from sorry,\n    have h15 : \u27ea(closure (Bbar m))\u27eb \u2286 (\u22c3 (n : \u2115), (C n)), from sorry,\n    have h16 : \u2203 m : \u2115, \u27ea(closure (Bbar m))\u27eb \u2286 (C m), from sorry,\n    have h17 : locally_finite_family (\u03bb n : \u2115, \u27ea(closure (Bbar n))\u27eb), from sorry,\n    have h18 : locally_finite_open (\u22c3 (n : \u2115), \u27ea(closure (Bbar n))\u27eb), from sorry,\n    show locally_finite_open C_union, from h18,\n  },\n\n  show \u2203 C_union : set (euclidean_space \u211d (fin n)),\n  is_open C_union \u2227 locally_finite_open C_union \u2227 \u27eaC_union\u27eb = \u22a4, \n  from sorry,\nend\n\n--OUTPUT 7\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n    assume A,\n    assume hA : open_cover (euclidean_space \u211d (fin n)) A,\n    have h1 : \u2200 n : \u2115, \u2203 Bn : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bn, from sorry,\n    have h2 : \u2203 B0 : set (euclidean_space \u211d (fin 0)), \u2200 x : euclidean_space \u211d (fin 0), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 B0, from sorry,\n    have h3 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h4 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h5 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h6 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h7 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h8 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h9 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h10 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h11 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h12 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h13 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h14 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h15 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h16 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h17 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h18 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h19 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h20 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h21 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h22 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h23 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h24 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m : \u2115, \u2200 k : \u2115, m \u2264 k \u2192 x \u2208 Bm, from sorry,\n    have h25 : \u2200 m : \u2115, \u2203 Bm : set (euclidean_space \u211d (fin n)), \u2200 x : euclidean_space \u211d (fin n), \u2203 m :\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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  \u211dn_locally_compact (n : \u2115) : locally_compact_space (euclidean_space \u211d (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  \u211dn_hausdorff (n : \u2115) : hausdorff_space (euclidean_space \u211d (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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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  \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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": "/-\nCopyright (c) 2020 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nimport Lean.Util.ForEachExpr\nimport Lean.Meta.ForEachExpr\nimport Lean.Meta.RecursorInfo\nimport Lean.Meta.Match.Match\nimport Lean.Meta.Transform\nimport Lean.Elab.PreDefinition.Basic\nnamespace Lean.Elab\nnamespace Structural\nopen Meta\n\nprivate def getFixedPrefix (declName : Name) (xs : Array Expr) (value : Expr) : MetaM Nat := do\n  let numFixedRef \u2190 IO.mkRef xs.size\n  forEachExpr' value fun e => do\n    if e.isAppOf declName then\n      let args := e.getAppArgs\n      numFixedRef.modify fun numFixed => if args.size < numFixed then args.size else numFixed\n      for arg in args, x in xs do\n        /- We should not use structural equality here. For example, given the definition\n           ```\n           def V.map {\u03b1 \u03b2} f x x_1 :=\n             @V.map.match_1.{1} \u03b1 (fun x x_2 => V \u03b2 x) x x_1\n               (fun x x_2 => @V.mk\u2081 \u03b2 x (f Bool.true x_2))\n               (fun e => @V.mk\u2082 \u03b2 (V.map (fun b => \u03b1 b) (fun b => \u03b2 b) f Bool.false e))\n           ```\n           The first three arguments at `V.map (fun b => \u03b1 b) (fun b => \u03b2 b) f Bool.false e` are \"fixed\"\n           modulo definitional equality.\n\n           We disable to proof irrelevance to be able to use structural recursion on inductive predicates.\n           For example, consider the example\n           ```\n          inductive PList (\u03b1 : Type) : Prop\n          | nil\n          | cons : \u03b1 \u2192 PList \u03b1 \u2192 PList \u03b1\n\n          infixr:67 \" ::: \" => PList.cons\n\n          set_option trace.Elab.definition.structural true in\n          def pmap {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) : PList \u03b1 \u2192 PList \u03b2\n          | PList.nil => PList.nil\n          | a:::as => f a ::: pmap f as\n          ```\n          The \"Fixed\" prefix would be 4 since all elements of type `PList \u03b1` are definitionally equal.\n        -/\n        if !(\u2190 withoutProofIrrelevance <| withReducible <| isDefEq arg x) then\n          -- We continue searching if e's arguments are not a prefix of `xs`\n          return true\n      return false\n    else\n      return true\n  numFixedRef.get\n\nstructure RecArgInfo where\n  /- `fixedParams ++ ys` are the arguments of the function we are trying to justify termination using structural recursion. -/\n  fixedParams : Array Expr\n  ys          : Array Expr  -- recursion arguments\n  pos         : Nat         -- position in `ys` of the argument we are recursing on\n  indicesPos  : Array Nat   -- position in `ys` of the inductive datatype indices we are recursing on\n  indName     : Name        -- inductive datatype name of the argument we are recursing on\n  indLevels   : List Level  -- inductice datatype universe levels of the argument we are recursing on\n  indParams   : Array Expr  -- inductive datatype parameters of the argument we are recursing on\n  indIndices  : Array Expr  -- inductive datatype indices of the argument we are recursing on, it is equal to `indicesPos.map fun i => ys.get! i`\n  reflexive   : Bool        -- true if we are recursing over a reflexive inductive datatype\n\nprivate def getIndexMinPos (xs : Array Expr) (indices : Array Expr) : Nat := do\n  let mut minPos := xs.size\n  for index in indices do\n    match xs.indexOf? index with\n    | some pos => if pos.val < minPos then minPos := pos.val\n    | _        => pure ()\n  return minPos\n\n-- Indices can only depend on other indices\nprivate def hasBadIndexDep? (ys : Array Expr) (indices : Array Expr) : MetaM (Option (Expr \u00d7 Expr)) := do\n  for index in indices do\n    let indexType \u2190 inferType index\n    for y in ys do\n      if !indices.contains y && (\u2190 dependsOn indexType y.fvarId!) then\n        return some (index, y)\n  return none\n\n-- Inductive datatype parameters cannot depend on ys\nprivate def hasBadParamDep? (ys : Array Expr) (indParams : Array Expr) : MetaM (Option (Expr \u00d7 Expr)) := do\n  for p in indParams do\n    let pType \u2190 inferType p\n    for y in ys do\n      if \u2190 dependsOn pType y.fvarId! then\n        return some (p, y)\n  return none\n\nprivate def throwStructuralFailed {\u03b1} : MetaM \u03b1 :=\n  throwError \"structural recursion cannot be used\"\n\nstructure State where\n  /- When compiling structural recursion we use the `brecOn` recursor automatically built by\n     the `inductive` command. For an inductive datatype `C`, it has the form\n     `C.brecOn As motive is c F`\n     where `As` are the inductive datatype parameters, `is` are the inductive datatype indices,\n     `c : C As is`, and `F : (js) \u2192 (d : C As js) \u2192 C.below d \u2192 motive d`\n     The `C.below d` is used to eliminate recursive applications. We refine its type when we process\n     a nested dependent pattern matcher using `MatcherApp.addArg`. See `replaceRecApps` for additional details.\n     We store the names of the matcher where we used `MatcherApp.addArg` at `matcherBelowDep`.\n     We use this information to generate the auxiliary `_sunfold` definition needed by the smart unfolding\n     technique used at WHNF. -/\n  matcherBelowDep : NameSet := {}\n\nabbrev M := StateRefT State MetaM\n\ninstance {\u03b1} : Inhabited (M \u03b1) where\n  default := throwError \"failed\"\n\nprivate def run {\u03b1} (x : M \u03b1) (s : State := {}) : MetaM (\u03b1 \u00d7 State) :=\n  StateRefT'.run x s\n\nprivate def orelse' {\u03b1} (x y : M \u03b1) : M \u03b1 := do\n  let saveState \u2190 get\n  orelseMergeErrors x (do set saveState; y)\n\nprivate partial def findRecArg {\u03b1} (numFixed : Nat) (xs : Array Expr) (k : RecArgInfo \u2192 M \u03b1) : M \u03b1 :=\n  let rec loop (i : Nat) : M \u03b1 := do\n    if h : i < xs.size then\n      let x := xs.get \u27e8i, h\u27e9\n      let localDecl \u2190 getFVarLocalDecl x\n      if localDecl.isLet then\n        throwStructuralFailed\n      else\n        let xType \u2190 whnfD localDecl.type\n        matchConstInduct xType.getAppFn (fun _ => loop (i+1)) fun indInfo us => do\n        if !(\u2190 hasConst (mkBRecOnName indInfo.name)) then\n          loop (i+1)\n        else if indInfo.isReflexive && !(\u2190 hasConst (mkBInductionOnName indInfo.name)) then\n          loop (i+1)\n        else\n          let indArgs    := xType.getAppArgs\n          let indParams  := indArgs.extract 0 indInfo.numParams\n          let indIndices := indArgs.extract indInfo.numParams indArgs.size\n          if !indIndices.all Expr.isFVar then\n            orelse'\n              (throwError \"argument #{i+1} was not used because its type is an inductive family and indices are not variables{indentExpr xType}\")\n              (loop (i+1))\n          else if !indIndices.allDiff then\n            orelse'\n              (throwError \"argument #{i+1} was not used because its type is an inductive family and indices are not pairwise distinct{indentExpr xType}\")\n              (loop (i+1))\n          else\n            let indexMinPos := getIndexMinPos xs indIndices\n            let numFixed    := if indexMinPos < numFixed then indexMinPos else numFixed\n            let fixedParams := xs.extract 0 numFixed\n            let ys          := xs.extract numFixed xs.size\n            match \u2190 hasBadIndexDep? ys indIndices with\n            | some (index, y) =>\n              orelse'\n                (throwError \"argument #{i+1} was not used because its type is an inductive family{indentExpr xType}\\nand index{indentExpr index}\\ndepends on the non index{indentExpr y}\")\n                (loop (i+1))\n            | none =>\n              match \u2190 hasBadParamDep? ys indParams with\n              | some (indParam, y) =>\n                orelse'\n                  (throwError \"argument #{i+1} was not used because its type is an inductive datatype{indentExpr xType}\\nand parameter{indentExpr indParam}\\ndepends on{indentExpr y}\")\n                  (loop (i+1))\n              | none =>\n                let indicesPos := indIndices.map fun index => match ys.indexOf? index with | some i => i.val | none => unreachable!\n                orelse'\n                  (mapError\n                    (k { fixedParams := fixedParams\n                         ys          := ys\n                         pos         := i - fixedParams.size\n                         indicesPos  := indicesPos\n                         indName     := indInfo.name\n                         indLevels   := us\n                         indParams   := indParams\n                         indIndices  := indIndices\n                         reflexive := indInfo.isReflexive })\n                    (fun msg => m!\"argument #{i+1} was not used for structural recursion{indentD msg}\"))\n                  (loop (i+1))\n    else\n      throwStructuralFailed\n  loop numFixed\n\nprivate def containsRecFn (recFnName : Name) (e : Expr) : Bool :=\n  (e.find? fun e => e.isConstOf recFnName).isSome\n\nprivate def ensureNoRecFn (recFnName : Name) (e : Expr) : MetaM Expr := do\n  if containsRecFn recFnName e then\n    Meta.forEachExpr e fun e => do\n      if e.isAppOf recFnName then\n        throwError \"unexpected occurrence of recursive application{indentExpr e}\"\n    pure e\n  else\n    pure e\n\nprivate def throwToBelowFailed {\u03b1} : MetaM \u03b1 :=\n  throwError \"toBelow failed\"\n\n/- See toBelow -/\nprivate partial def toBelowAux (C : Expr) : Expr \u2192 Expr \u2192 Expr \u2192 MetaM Expr\n  | belowDict, arg, F => do\n    let belowDict \u2190 whnf belowDict\n    trace[Elab.definition.structural] \"belowDict: {belowDict}, arg: {arg}\"\n    match belowDict with\n    | Expr.app (Expr.app (Expr.const `PProd _ _) d1 _) d2 _ =>\n      (do toBelowAux C d1 arg (\u2190 mkAppM `PProd.fst #[F]))\n      <|>\n      (do toBelowAux C d2 arg (\u2190 mkAppM `PProd.snd #[F]))\n    | Expr.app (Expr.app (Expr.const `And _ _) d1 _) d2 _ =>\n      (do toBelowAux C d1 arg (\u2190 mkAppM `And.left #[F]))\n      <|>\n      (do toBelowAux C d2 arg (\u2190 mkAppM `And.right #[F]))\n    | _ => forallTelescopeReducing belowDict fun xs belowDict => do\n      let argArgs := arg.getAppArgs\n      unless argArgs.size >= xs.size do throwToBelowFailed\n      let n := argArgs.size\n      let argTailArgs := argArgs.extract (n - xs.size) n\n      let belowDict := belowDict.replaceFVars xs argTailArgs\n      match belowDict with\n      | Expr.app belowDictFun belowDictArg _ =>\n        unless belowDictFun.getAppFn == C do throwToBelowFailed\n        unless \u2190 isDefEq belowDictArg arg do throwToBelowFailed\n        pure (mkAppN F argTailArgs)\n      | _ => throwToBelowFailed\n\n/- See toBelow -/\nprivate def withBelowDict {\u03b1} (below : Expr) (numIndParams : Nat) (k : Expr \u2192 Expr \u2192 MetaM \u03b1) : MetaM \u03b1 := do\n  let belowType \u2190 inferType below\n  trace[Elab.definition.structural] \"belowType: {belowType}\"\n  belowType.withApp fun f args => do\n    let motivePos := numIndParams + 1\n    unless motivePos < args.size do throwError \"unexpected 'below' type{indentExpr belowType}\"\n    let pre := mkAppN f (args.extract 0 numIndParams)\n    let preType \u2190 inferType pre\n    forallBoundedTelescope preType (some 1) fun x _ => do\n      let motiveType \u2190 inferType x[0]\n      let C \u2190 mkFreshUserName `C\n      withLocalDeclD C motiveType fun C =>\n        let belowDict := mkApp pre C\n        let belowDict := mkAppN belowDict (args.extract (numIndParams + 1) args.size)\n        k C belowDict\n\n/-\n  `below` is a free variable with type of the form `I.below indParams motive indices major`,\n  where `I` is the name of an inductive datatype.\n\n  For example, when trying to show that the following function terminates using structural recursion\n  ```lean\n  def addAdjacent : List Nat \u2192 List Nat\n  | []       => []\n  | [a]      => [a]\n  | a::b::as => (a+b) :: addAdjacent as\n  ```\n  when we are visiting `addAdjacent as` at `replaceRecApps`, `below` has type\n  `@List.below Nat (fun (x : List Nat) => List Nat) (a::b::as)`\n  The motive `fun (x : List Nat) => List Nat` depends on the actual function we are trying to compute.\n  So, we first replace it with a fresh variable `C` at `withBelowDict`.\n  Recall that `brecOn` implements course-of-values recursion, and `below` can be viewed as a dictionary\n  of the \"previous values\".\n  We search this dictionary using the auxiliary function `toBelowAux`.\n  The dictionary is built using the `PProd` (`And` for inductive predicates).\n  We keep searching it until we find `C recArg`, where `C` is the auxiliary fresh variable created at `withBelowDict`.  -/\nprivate partial def toBelow (below : Expr) (numIndParams : Nat) (recArg : Expr) : MetaM Expr := do\n  withBelowDict below numIndParams fun C belowDict =>\n    toBelowAux C belowDict recArg below\n\n/--\n  Return true iff `e` contains an application `recFnName .. t ..` where the term `t` is\n  the argument we are trying to recurse on, and it contains loose bound variables.\n\n  We use this test to decide whether we should process a matcher-application as a regular\n  applicaton or not. That is, whether we should push the `below` argument should be affected by the matcher or not.\n  If `e` does not contain an application of the form `recFnName .. t ..`, then we know\n  the recursion doesn't depend on any pattern variable in this matcher.\n-/\nprivate def recArgHasLooseBVarsAt (recFnName : Name) (recArgInfo : RecArgInfo) (e : Expr) : Bool :=\n  let recArgPos := recArgInfo.fixedParams.size + recArgInfo.pos\n  let app?   := e.find? fun e =>\n     e.isAppOf recFnName && e.getAppNumArgs > recArgPos && (e.getArg! recArgPos).hasLooseBVars\n  app?.isSome\n\nprivate partial def replaceRecApps (recFnName : Name) (recArgInfo : RecArgInfo) (below : Expr) (e : Expr) : M Expr :=\n  let rec loop (below : Expr) (e : Expr) : M Expr := do\n    match e with\n    | Expr.lam n d b c =>\n      withLocalDecl n c.binderInfo (\u2190 loop below d) fun x => do\n        mkLambdaFVars #[x] (\u2190 loop below (b.instantiate1 x))\n    | Expr.forallE n d b c =>\n      withLocalDecl n c.binderInfo (\u2190 loop below d) fun x => do\n        mkForallFVars #[x] (\u2190 loop below (b.instantiate1 x))\n    | Expr.letE n type val body _ =>\n      withLetDecl n (\u2190 loop below type) (\u2190 loop below val) fun x => do\n        mkLetFVars #[x] (\u2190 loop below (body.instantiate1 x))\n    | Expr.mdata d e _   => return mkMData d (\u2190 loop below e)\n    | Expr.proj n i e _  => return mkProj n i (\u2190 loop below e)\n    | Expr.app _ _ _ =>\n      let processApp (e : Expr) : M Expr :=\n        e.withApp fun f args => do\n          if f.isConstOf recFnName then\n            let numFixed  := recArgInfo.fixedParams.size\n            let recArgPos := recArgInfo.fixedParams.size + recArgInfo.pos\n            if recArgPos >= args.size then\n              throwError \"insufficient number of parameters at recursive application {indentExpr e}\"\n            let recArg := args[recArgPos]\n            -- For reflexive type, we may have nested recursive applications in recArg\n            let recArg \u2190 loop below recArg\n            let f \u2190 try toBelow below recArgInfo.indParams.size recArg catch  _ => throwError \"failed to eliminate recursive application{indentExpr e}\"\n            -- Recall that the fixed parameters are not in the scope of the `brecOn`. So, we skip them.\n            let argsNonFixed := args.extract numFixed args.size\n            -- The function `f` does not explicitly take `recArg` and its indices as arguments. So, we skip them too.\n            let mut fArgs := #[]\n            for i in [:argsNonFixed.size] do\n              if recArgInfo.pos != i && !recArgInfo.indicesPos.contains i then\n                let arg := argsNonFixed[i]\n                let arg \u2190 replaceRecApps recFnName recArgInfo below arg\n                fArgs := fArgs.push arg\n            return mkAppN f fArgs\n          else\n            return mkAppN (\u2190 loop below f) (\u2190 args.mapM (loop below))\n      let matcherApp? \u2190 matchMatcherApp? e\n      match matcherApp? with\n      | some matcherApp =>\n        if !recArgHasLooseBVarsAt recFnName recArgInfo e then\n          processApp e\n        else\n          /- Here is an example we currently not handle\n             ```\n             def g (xs : List Nat) : Nat :=\n             match xs with\n             | [] => 0\n             | y::ys =>\n               match ys with\n               | []       => 1\n               | _::_::zs => g zs + 1\n               | zs       => g ys + 2\n             ```\n             We are matching on `ys`, but still using `ys` in the third alternative.\n             If we push the `below` argument over the dependent match it will be able to eliminate recursive call using `zs`.\n             To make it work, users have to write the third alternative as `| zs => g zs + 2`\n             If this is too annoying in practice, we may replace `ys` with the matching term, but\n             this may generate weird error messages, when it doesn't work. -/\n          trace[Elab.definition.structural] \"below before matcherApp.addArg: {below} : {\u2190 inferType below}\"\n          let matcherApp \u2190 mapError (matcherApp.addArg below) (fun msg => \"failed to add `below` argument to 'matcher' application\" ++ indentD msg)\n          modify fun s => { s with matcherBelowDep := s.matcherBelowDep.insert matcherApp.matcherName }\n          let altsNew \u2190 (Array.zip matcherApp.alts matcherApp.altNumParams).mapM fun (alt, numParams) =>\n            lambdaTelescope alt fun xs altBody => do\n              trace[Elab.definition.structural] \"altNumParams: {numParams}, xs: {xs}\"\n              unless xs.size >= numParams do\n                throwError \"unexpected matcher application alternative{indentExpr alt}\\nat application{indentExpr e}\"\n              let belowForAlt := xs[numParams - 1]\n              mkLambdaFVars xs (\u2190 loop belowForAlt altBody)\n          pure { matcherApp with alts := altsNew }.toExpr\n      | none => processApp e\n    | e => ensureNoRecFn recFnName e\n  loop below e\n\nprivate def mkBRecOn (recFnName : Name) (recArgInfo : RecArgInfo) (value : Expr) : M Expr := do\n  let type  := (\u2190 inferType value).headBeta\n  let major := recArgInfo.ys[recArgInfo.pos]\n  let otherArgs := recArgInfo.ys.filter fun y => y != major && !recArgInfo.indIndices.contains y\n  trace[Elab.definition.structural] \"fixedParams: {recArgInfo.fixedParams}, otherArgs: {otherArgs}\"\n  let motive \u2190 mkForallFVars otherArgs type\n  let mut brecOnUniv \u2190 getLevel motive\n  trace[Elab.definition.structural] \"brecOn univ: {brecOnUniv}\"\n  let useBInductionOn := recArgInfo.reflexive && brecOnUniv == levelZero\n  if recArgInfo.reflexive && brecOnUniv != levelZero then\n    brecOnUniv \u2190 decLevel brecOnUniv\n  let motive \u2190 mkLambdaFVars (recArgInfo.indIndices.push major) motive\n  trace[Elab.definition.structural] \"brecOn motive: {motive}\"\n  let brecOn :=\n    if useBInductionOn then\n      Lean.mkConst (mkBInductionOnName recArgInfo.indName) recArgInfo.indLevels\n    else\n      Lean.mkConst (mkBRecOnName recArgInfo.indName) (brecOnUniv :: recArgInfo.indLevels)\n  let brecOn := mkAppN brecOn recArgInfo.indParams\n  let brecOn := mkApp brecOn motive\n  let brecOn := mkAppN brecOn recArgInfo.indIndices\n  let brecOn := mkApp brecOn major\n  check brecOn\n  let brecOnType \u2190 inferType brecOn\n  trace[Elab.definition.structural] \"brecOn     {brecOn}\"\n  trace[Elab.definition.structural] \"brecOnType {brecOnType}\"\n  forallBoundedTelescope brecOnType (some 1) fun F _ => do\n    let F := F[0]\n    let FType \u2190 inferType F\n    trace[Elab.definition.structural] \"FType: {FType}\"\n    let FType \u2190 instantiateForall FType recArgInfo.indIndices\n    let FType \u2190 instantiateForall FType #[major]\n    forallBoundedTelescope FType (some 1) fun below _ => do\n      let below := below[0]\n      let valueNew     \u2190 replaceRecApps recFnName recArgInfo below value\n      let Farg         \u2190 mkLambdaFVars (recArgInfo.indIndices ++ #[major, below] ++ otherArgs) valueNew\n      let brecOn       := mkApp brecOn Farg\n      pure $ mkAppN brecOn otherArgs\n\nprivate def shouldBetaReduce (e : Expr) (recFnName : Name) : Bool :=\n  if e.isHeadBetaTarget then\n    e.getAppFn.find? (\u00b7.isConstOf recFnName) |>.isSome\n  else\n    false\n\n/--\n  Beta reduce terms where the recursive function occurs in the lambda term.\n  This is useful to improve the effectiveness of `elimRecursion`.\n  Example:\n  ```\n  def f : Nat \u2192 Nat\n    | 0 => 1\n    | i+1 => (fun x => f x) i\n  ```\n-/\nprivate def preprocess (e : Expr) (recFnName : Name) : CoreM Expr :=\n  Core.transform e\n   fun e => return TransformStep.visit <|\n     if shouldBetaReduce e recFnName then\n       e.headBeta\n     else\n       e\n\nprivate def elimRecursion (preDef : PreDefinition) : M PreDefinition :=\n  withoutModifyingEnv do lambdaTelescope preDef.value fun xs value => do\n    addAsAxiom preDef\n    let value \u2190 preprocess value preDef.declName\n    trace[Elab.definition.structural] \"{preDef.declName} {xs} :=\\n{value}\"\n    let numFixed \u2190 getFixedPrefix preDef.declName xs value\n    trace[Elab.definition.structural] \"numFixed: {numFixed}\"\n    findRecArg numFixed xs fun recArgInfo => do\n      -- when (recArgInfo.indName == `Nat) throwStructuralFailed -- HACK to skip Nat argument\n      let valueNew \u2190 mkBRecOn preDef.declName recArgInfo value\n      let valueNew \u2190 mkLambdaFVars xs valueNew\n      trace[Elab.definition.structural] \"result: {valueNew}\"\n      -- Recursive applications may still occur in expressions that were not visited by replaceRecApps (e.g., in types)\n      let valueNew \u2190 ensureNoRecFn preDef.declName valueNew\n      pure { preDef with value := valueNew }\n\npartial def addSmartUnfoldingDefAux (preDef : PreDefinition) (matcherBelowDep : NameSet) : MetaM PreDefinition := do\n  let recFnName := preDef.declName\n  let isMarkedMatcherName (n : Name) : Bool    := matcherBelowDep.contains n\n  let isMarkedMatcherConst (e : Expr) : Bool   := e.isConst && isMarkedMatcherName e.constName!\n  let isMarkedMatcherApp (e : Expr) : Bool     := isMarkedMatcherConst e.getAppFn\n  let containsMarkedMatcher (e : Expr) : Bool := e.find? isMarkedMatcherConst |>.isSome\n  let rec visit (e : Expr) : MetaM Expr := do\n    match e with\n    | Expr.lam ..     => lambdaTelescope e fun xs b => do mkLambdaFVars xs (\u2190 visit b)\n    | Expr.forallE .. => forallTelescope e fun xs b => do mkForallFVars xs (\u2190 visit b)\n    | Expr.letE n type val body _ =>\n      withLetDecl n type (\u2190 visit val) fun x => do\n        mkLetFVars #[x] (\u2190 visit (body.instantiate1 x))\n    | Expr.mdata d b _   => return mkMData d (\u2190 visit b)\n    | Expr.proj n i s _  => return mkProj n i (\u2190 visit s)\n    | Expr.app .. =>\n      let processApp (e : Expr) : MetaM Expr :=\n        e.withApp fun f args => do\n          return mkAppN (\u2190 visit f) (\u2190 args.mapM visit)\n      match isMarkedMatcherApp e, (\u2190 matchMatcherApp? e) with\n      | true, some matcherApp =>\n        let altsNew \u2190 (Array.zip matcherApp.alts matcherApp.altNumParams).mapM fun (alt, numParams) =>\n          lambdaTelescope alt fun xs altBody => do\n            unless xs.size >= numParams do\n              throwError \"unexpected matcher application alternative{indentExpr alt}\\nat application{indentExpr e}\"\n            if containsMarkedMatcher altBody then\n              -- continue\n              mkLambdaFVars xs (\u2190 visit altBody)\n            else\n              -- add idRhs marker\n              let altBody \u2190 mkLambdaFVars xs[numParams:xs.size] altBody\n              let altBody \u2190 mkIdRhs altBody\n              mkLambdaFVars xs[0:numParams] altBody\n        pure { matcherApp with alts := altsNew }.toExpr\n      | _, _ => processApp e\n    | _ => pure e\n  return { preDef with\n    declName  := mkSmartUnfoldingNameFor preDef.declName,\n    value     := (\u2190 visit preDef.value),\n    modifiers := {}\n  }\n\npartial def addSmartUnfoldingDef (preDef : PreDefinition) (state : State) : TermElabM Unit := do\n  if (\u2190 isProp preDef.type) then\n    return ()\n  else\n    let preDefSUnfold \u2190 addSmartUnfoldingDefAux preDef state.matcherBelowDep\n    addNonRec preDefSUnfold\n\ndef structuralRecursion (preDefs : Array PreDefinition) : TermElabM Unit :=\n  if preDefs.size != 1 then\n    throwError \"structural recursion does not handle mutually recursive functions\"\n  else do\n    let (preDefNonRec, state) \u2190 run $ elimRecursion preDefs[0]\n    mapError (addNonRec preDefNonRec) (fun msg => m!\"structural recursion failed, produced type incorrect term{indentD msg}\")\n    addAndCompilePartialRec preDefs\n    addSmartUnfoldingDef preDefs[0] state\n\nbuiltin_initialize\n  registerTraceClass `Elab.definition.structural\n\nend Structural\n\nexport Structural (structuralRecursion)\n\nend Lean.Elab\n", "meta": {"author": "gebner", "repo": "lean4-old", "sha": "ee51cdfaf63ee313c914d83264f91f414a0e3b6e", "save_path": "github-repos/lean/gebner-lean4-old", "path": "github-repos/lean/gebner-lean4-old/lean4-old-ee51cdfaf63ee313c914d83264f91f414a0e3b6e/src/Lean/Elab/PreDefinition/Structural.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.523420348936324, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.20731013779372892}}
{"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 <| \u2190\n      `(instance : OfNat Align (nat_lit $val) := \u27e8\u27e8$shiftVal, by decide\u27e9\u27e9)\n  mkNullNode instances\n\ngen_ofNat_instances\nend\n\n/-- The default is byte-aligned. -/\ndef default : Align := 1\n\ninstance : Inhabited Align := \u27e8Align.default\u27e9\n\n-- ## Propositional Relations\n\ntheorem eq_of_shiftVal_eq : {a b : Align} \u2192 a.shiftVal = b.shiftVal \u2192 a = b\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem shiftVal_eq_of_eq {a b : Align} (h : a = b) : a.shiftVal = b.shiftVal :=\n  h \u25b8 rfl\n\ntheorem ne_of_shiftVal_ne {a b : Align} (h : a.shiftVal \u2260 b.shiftVal) : a \u2260 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 := \u27e8fun a b => a.shiftVal < b.shiftVal\u27e9\ninstance : LE Align := \u27e8fun a b => a.shiftVal <= b.shiftVal\u27e9\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": "\nimport Ledger.Costing\n\n\nnamespace Ledger.Costing.Test\n\n\n-- | Compare to output of `cardano-cli` during Epoch 330.\nexample : minimumAda default false {numPolicies :=  0, numAssets :=   0, sumAssetNameLengths :=        0} =   999978 := rfl\nexample : minimumAda default false {numPolicies :=  1, numAssets :=   1, sumAssetNameLengths :=        1} =  1344798 := rfl\nexample : minimumAda default false {numPolicies :=  1, numAssets :=   1, sumAssetNameLengths :=       32} =  1448244 := rfl\nexample : minimumAda default false {numPolicies :=  1, numAssets := 110, sumAssetNameLengths := 110 * 32} = 22137444 := rfl\nexample : minimumAda default false {numPolicies := 60, numAssets :=  60, sumAssetNameLengths :=  60 * 32} = 19758186 := rfl\nexample : minimumAda default true  {numPolicies :=  0, numAssets :=   0, sumAssetNameLengths :=        0} =  1344798 := rfl\nexample : minimumAda default true  {numPolicies :=  1, numAssets :=   1, sumAssetNameLengths :=        1} =  1689618 := rfl\nexample : minimumAda default true  {numPolicies :=  2, numAssets :=   2, sumAssetNameLengths :=        4} =  1862028 := rfl\n\n\nexample : feeForBytes default    0 = 155381         := rfl\nexample : feeForBytes default 1000 = 155381 + 44000 := rfl\n\n\nend Ledger.Costing.Test\n", "meta": {"author": "bwbush", "repo": "lean4balancing", "sha": "60fc31665abaa5b79428cb9444e6afdaca3c199a", "save_path": "github-repos/lean/bwbush-lean4balancing", "path": "github-repos/lean/bwbush-lean4balancing/lean4balancing-60fc31665abaa5b79428cb9444e6afdaca3c199a/src/Ledger/Costing/Test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.3849121444839335, "lm_q1q2_score": 0.20596588367265212}}
{"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: \u2200 {\u03b1:Type} {f:\u03b1 \u2192 poisonty_smt} p0 (l:list \u03b1) (\u03b7:freevar.env),\n  \u03b7\u27e6list.foldr (\u03bb itm (p:poisonty_smt), p & (f itm)) p0 l\u27e7 =\n    list.foldr (\u03bb itm (p:poisonty_smt), p & \u03b7\u27e6(f itm)\u27e7) (\u03b7\u27e6p0\u27e7) l\n:= begin\n  intros,\n  induction l,\n  { simp },\n  {\n    simp,\n    rw env.replace_sb_and,\n    rw \u2190 l_ih\n  }\nend\n\nlemma bop_poison_replace: \u2200 sz bopc (v1 v2:sbitvec sz) (\u03b7:freevar.env),\n  \u03b7\u27e6bop_poison irsem_smt sz bopc v1 v2\u27e7 =\n    bop_poison irsem_smt sz bopc (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7)\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: \u2200 sz bopc (v1 v2:sbitvec sz) (\u03b7:freevar.env) flag,\n  \u03b7\u27e6bop_poison_flag irsem_smt sz bopc flag v1 v2\u27e7 =\n  bop_poison_flag irsem_smt sz bopc flag (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6v2\u27e7)\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: \u03b7\u27e6uint_like.zero sz\u27e7 = 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: \u2200 sz bopc flags \u03b7 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 (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6p1\u27e7) (\u03b7\u27e6v2\u27e7) (\u03b7\u27e6p2\u27e7) =\n    (\u03b7\u27e6ubres\u27e7, \u03b7\u27e6vres\u27e7, \u03b7\u27e6pres\u27e7)\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:\u2200 (p1 p2 q1 q2:poisonty_smt),\n      p1&p2 = q1&q2 \u2194 p1 = q1 \u2227 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: \u2200 {sz:size} (v:intty_smt sz) (p:poisonty_smt) (\u03b7:freevar.env),\n  \u03b7\u27e6to_ival irsem_smt (v, p)\u27e7 = to_ival irsem_smt (\u03b7\u27e6v\u27e7, \u03b7\u27e6p\u27e7)\n:= begin\n  intros,\n  unfold to_ival,\n  unfold freevar.env.replace_valty\nend\n\nlemma step_bop_replace: \u2200 (ss:irstate_smt) bopc flags\n    (vop1 vop2: valty_smt)\n    vop1' vop2' (\u03b7:freevar.env) lhsn\n    (HVOP1:vop1' = \u03b7\u27e6vop1\u27e7)\n    (HVOP2:vop2' = \u03b7\u27e6vop2\u27e7),\n  step_bop irsem_smt vop1' vop2' bopc flags (\u03b7\u27e6ss\u27e7) lhsn =\n    \u03b7\u27e6step_bop irsem_smt vop1 vop2 bopc flags ss lhsn\u27e7'\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 \u2260 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        (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6p1\u27e7) (cast HTY (\u03b7\u27e6v2\u27e7)) (\u03b7\u27e6p2\u27e7) = 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 \u2190 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: \u2200 sz cond \u03b7 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 (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6p1\u27e7) (\u03b7\u27e6v2\u27e7) (\u03b7\u27e6p2\u27e7) = (\u03b7\u27e6vres\u27e7, \u03b7\u27e6pres\u27e7)\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: \u2200 (ss:irstate_smt) cond\n    (vop1 vop2: valty_smt)\n    vop1' vop2' (\u03b7:freevar.env) lhsn\n    (HVOP1:vop1' = \u03b7\u27e6vop1\u27e7)\n    (HVOP2:vop2' = \u03b7\u27e6vop2\u27e7),\n  step_icmpop irsem_smt vop1' vop2' cond (\u03b7\u27e6ss\u27e7) lhsn =\n    \u03b7\u27e6step_icmpop irsem_smt vop1 vop2 cond ss lhsn\u27e7'\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 \u2260 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 (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6p1\u27e7)\n        (cast HTY (\u03b7\u27e6v2\u27e7)) (\u03b7\u27e6p2\u27e7) = 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 \u2190 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: \u2200 sz \u03b7 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 (\u03b7\u27e6vcond\u27e7) (\u03b7\u27e6pcond\u27e7) sz (\u03b7\u27e6v1\u27e7) (\u03b7\u27e6p1\u27e7) (\u03b7\u27e6v2\u27e7) (\u03b7\u27e6p2\u27e7)\n    = (\u03b7\u27e6vres\u27e7, \u03b7\u27e6pres\u27e7)\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: \u2200 (ss:irstate_smt)\n    (vcond vop1 vop2: valty_smt)\n    vcond' vop1' vop2' (\u03b7:freevar.env) lhsn\n    (HVCOND:vcond' = \u03b7\u27e6vcond\u27e7)\n    (HVOP1:vop1' = \u03b7\u27e6vop1\u27e7)\n    (HVOP2:vop2' = \u03b7\u27e6vop2\u27e7),\n  step_selectop irsem_smt vcond' vop1' vop2' (\u03b7\u27e6ss\u27e7) lhsn =\n    \u03b7\u27e6step_selectop irsem_smt vcond vop1 vop2 ss lhsn\u27e7'\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 \u2190 env.replace_sbv_cast,\n      rw \u2190 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: \u2200 fromsz code op1 op1p tosz \u03b7 vres pres\n    (H:(vres, pres) = castop irsem_smt fromsz code op1 op1p tosz),\n  castop irsem_smt fromsz code (\u03b7\u27e6op1\u27e7) (\u03b7\u27e6op1p\u27e7) tosz\n    = (\u03b7\u27e6vres\u27e7, \u03b7\u27e6pres\u27e7)\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: \u2200 (ss:irstate_smt)\n    (vop:valty_smt) (code:uopcode) (toisz:nat) vop' (\u03b7:freevar.env) lhsn\n    (HVOP:vop' = \u03b7\u27e6vop\u27e7),\n  step_unaryop irsem_smt vop' code toisz (\u03b7\u27e6ss\u27e7) lhsn =\n    \u03b7\u27e6step_unaryop irsem_smt vop code toisz ss lhsn\u27e7'\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: \u2200 (ss:irstate_smt) (i:instruction)\n    (\u03b7:freevar.env),\n  step irsem_smt (\u03b7\u27e6ss\u27e7) i = \u03b7\u27e6step irsem_smt ss i\u27e7'\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: \u03b7\u27e6get_value irsem_smt ss op1 retty\u27e7' = vop1,\n    generalize HOP2: \u03b7\u27e6get_value irsem_smt ss op2 retty\u27e7' = 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: \u03b7\u27e6get_value irsem_smt ss op1 opty\u27e7' = vop1,\n    generalize HOP2: \u03b7\u27e6get_value irsem_smt ss op2 opty\u27e7' = 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: \u03b7\u27e6get_value irsem_smt ss cond condty\u27e7' = vopcond,\n    generalize HOP1: \u03b7\u27e6get_value irsem_smt ss op1 opty\u27e7' = vop1,\n    generalize HOP2: \u03b7\u27e6get_value irsem_smt ss op2 opty\u27e7' = 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: \u03b7\u27e6get_value irsem_smt ss op fromty\u27e7' = 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: \u2200 ss se i oss ose \u03b7\n    (HENC:encode ss se \u03b7)\n    (HOSS': oss = step irsem_smt ss i)\n    (HOSE': ose = step irsem_exec se i),\n  none_or_some oss ose (\u03bb ss' se', encode ss' se' \u03b7)\n:= begin\n  intros,\n  have HSTEP : none_or_some (step irsem_smt (\u03b7\u27e6ss\u27e7) i)\n      (step irsem_exec se i) (\u03bb ss' se', irstate_equiv ss' se'),\n  {\n    apply step_both_prf,\n    apply HENC,\n    refl, refl\n  },\n  have HOSS'': \u03b7\u27e6oss\u27e7' = step irsem_smt (\u03b7\u27e6ss\u27e7) i, {\n    rw step_replace,\n    rw HOSS'\n  },\n  simp at HOSS'',\n  rw \u2190 HOSS'' at *,\n  rw \u2190 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 \u2190 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 (\u03bb ss0 se0, encode ss0 se0 \u03b7),\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: (\u2203 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 \u2190 bigstep_unroll_some_smt, apply HOSS', rw HSS, rw HENC0_left,\n        rw \u2190 bigstep_unroll_some_exec, apply HOSE', rw HSE, rw HENC0_left_1\n      }\n    }\n  }\nend\n\nlemma bigstep_replace: \u2200 ss p (\u03b7:freevar.env),\n  \u03b7\u27e6bigstep irsem_smt ss p\u27e7' = bigstep irsem_smt (\u03b7\u27e6ss\u27e7) 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 (\u03b7\u27e6ss\u27e7) 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: \u03b7\u27e6step irsem_smt ss i\u27e7' = \u03b7\u27e6some ss'\u27e7',\n      {\n        rw HSS\n      },\n      rw \u2190 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 tidy.lib.mllist\nimport tidy.lib.pretty_print\nimport tidy.lib.tactic\n\nuniverses u\n\nopen tactic\nopen mllist\n\nmeta def kabstract_no_new_goals (t e : expr) (md : transparency) : tactic expr :=\ndo gs \u2190 get_goals,\n   r \u2190 kabstract t e md,\n   ng \u2190 num_goals,\n   guard (ng = gs.length),\n   return r\n\nmeta def kabstracter'\n  (pattern : tactic (expr \u00d7 expr \u00d7 list expr))\n  (lhs_replacer : list expr \u2192 tactic expr) :\n  expr \u00d7 list (expr \u00d7 (list expr)) \u2192 tactic (expr \u00d7 list (expr \u00d7 (list expr)))\n| p := do\n  (t, L) \u2190 pure p,\n  (e, e_type, mvars) \u2190 pattern,\n  t' \u2190 kabstract_no_new_goals t e semireducible,\n  -- TODO use the discharger to clear remaining metavariables\n  -- trace \"kabstract:\",\n  -- trace t,\n  -- trace e,\n  -- trace mvars,\n  -- mvars.mmap (\u03bb m, infer_type m) >>= trace,\n  -- trace t',\n  guard t'.has_var,\n  w \u2190 mk_meta_var e_type,\n  let t'' := t'.instantiate_var w,\n  mvars' \u2190 mvars.mmap instantiate_mvars,\n  return (t'', (w, mvars') :: L) -- FIXME should there be a prime here??\n\nmeta def kabstracter\n  (pattern : tactic (expr \u00d7 expr \u00d7 list expr))\n  (lhs_replacer : list expr \u2192 tactic expr) (t : expr) : tactic (mllist tactic (expr \u00d7 list (expr \u00d7 list expr))) :=\nmllist.fix (kabstracter' pattern lhs_replacer) (t, [])\n\nmeta def get_lhs : expr -> bool \u2192 list expr -> tactic (expr \u00d7 expr \u00d7 list expr)\n| (expr.pi n bi d b) symm mvars :=\ndo v <- mk_meta_var d,\n   b' <- whnf $ b.instantiate_var v,\n   get_lhs b' symm (v :: mvars)\n| `(%%a = %%b) symm mvars :=\n  do let (a, b) := if symm then (b, a) else (a, b),\n     ty \u2190 infer_type a,\n     return (a, ty, mvars)\n| _ _ _ := failed\n\nmeta def replacer : expr -> bool \u2192 list expr -> tactic expr\n| (expr.pi n bi d b) symm values := replacer b symm values\n| `(%%a = %%b) symm values :=\n  do let (a, b) := if symm then (b, a) else (a, b),\n     return (a.instantiate_vars values)\n| _ _ _ := failed\n\nmeta def mvars_to_var (e : expr) : expr :=\ne.replace (\u03bb e n, if e.is_meta_var then some (expr.var n) else none)\n\nmeta def do_substitutions\n  (eq : expr) (symm : bool)\n  (t_original : expr)\n  (lhs rhs : list expr \u2192 tactic expr)\n  (t_abstracted : expr)\n  (rewrite_mvar : expr \u00d7 list expr)\n  (restore_mvars : list (expr \u00d7 list expr)) : tactic (expr \u00d7 tactic expr \u00d7 list expr) :=\nlock_tactic_state $\ndo -- We first restore all the \"other\" metavariables to their original values.\n  --  trace \"do_substitutions\",\n   restore_mvars.mmap (\u03bb p, do l \u2190 lhs p.2, unify p.1 l),\n   t_restored \u2190 instantiate_mvars t_abstracted,\n\n   -- r' is the value of the remaining metavariable, after applying the lemma.\n   r' \u2190 rhs rewrite_mvar.2,\n\n   guard (\u00ac r'.has_meta_var),\n   -- We now begin constructing the `eq.rec` proof of equality. In fact, we don't construct it here,\n   -- we just construct a tactic that can produce it on demand!\n   let proof_tactic : tactic expr := do {\n    -- r is the original value of the remaining metavariable\n    r \u2190 lhs rewrite_mvar.2,\n\n    -- The lemma itself proves `r = r'`.\n    let inner_proof := rewrite_mvar.2.reverse.foldl (\u03bb f x : expr, f x) eq,\n    inner_proof \u2190 if symm then mk_eq_symm inner_proof else return inner_proof,\n    -- trace \"inner_proof:\",\n    -- trace inner_proof,\n\n    -- Next we compute the motive.\n    let t_with_var := mvars_to_var t_restored,\n    n \u2190 mk_fresh_name,\n    -- trace \"--\",\n    -- trace t_with_var,\n    -- trace t_original,\n    -- trace \"r:\",\n    -- trace r,\n    ty \u2190 infer_type r,\n    feq \u2190 mk_const `eq,\n    v \u2190 mk_mvar,\n    let C := expr.lam n binder_info.default ty (feq v t_original t_with_var),\n    -- trace \"motive:\",\n    -- trace C,\n\n    -- ... and prepare the actual proof.\n    refl \u2190 mk_eq_refl t_original,\n    proof \u2190 to_expr ```(@eq.rec _ %%r %%C %%refl _ %%inner_proof),\n    -- trace \"proof:\",\n    -- trace proof,\n    infer_type proof, -- this is a sanity check (perhaps we should be doing this earlier?)\n    return proof\n   },\n   -- Finally we finish rewriting the expression\n   unify rewrite_mvar.1 r',\n   result \u2190 instantiate_mvars t_restored,\n\n   metas : list expr \u2190 rewrite_mvar.2.mfilter (\u03bb m, do r \u2190 is_assigned m <|> return tt, return \u00ac r),\n   return (result, proof_tactic, metas)\n\nmeta def all_rewrites_core (t eq : expr) (symm : bool) : tactic (mllist tactic (expr \u00d7 tactic expr \u00d7 list expr)) :=\ndo ty \u2190 infer_type eq,\n  let matcher := get_lhs ty symm [],\n  let lhs := replacer ty symm,\n  let rhs := replacer ty \u00ac symm,\n  L \u2190 kabstracter matcher lhs t,\n  L.mfilter_map (\u03bb p, do_substitutions eq symm t lhs rhs p.1 p.2.head p.2.tail)\n\nmeta structure rewrite_all_cfg extends rewrite_cfg :=\n(discharger : tactic unit := skip) -- FIXME this is ignored for now\n(simplifier : expr \u2192 tactic (expr \u00d7 expr) := \u03bb e, failed) -- FIXME get rid of this?\n\nmeta def all_rewrites_lazy (r : expr \u00d7 bool) (t : expr) (cfg : rewrite_all_cfg := {}) : tactic (mllist tactic (expr \u00d7 (tactic expr))) :=\ndo\n   L \u2190 all_rewrites_core t r.1 r.2,\n   L.filter_map (\u03bb p, if p.2.2 = [] then some (p.1, p.2.1) else none)\n\nmeta def all_rewrites (r : expr \u00d7 bool) (t : expr) (cfg : rewrite_all_cfg := {}): tactic (list (expr \u00d7 expr)) :=\ndo L \u2190 all_rewrites_lazy r t cfg,\n   L \u2190 L.mmap (\u03bb p, do r \u2190 p.2, return (p.1, r)),\n   L.force\n\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/tidy/rewrite_all_2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.519521321952093, "lm_q2_score": 0.3960681662740417, "lm_q1q2_score": 0.2057658573258315}}
{"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 (\ud835\udc9e : Type u) [category.{v} \ud835\udc9e]\n\n@[protect_proj] structure struc : Type (max u v (w+1) (x+1)) :=\n( F : \ud835\udc9e \u2192 Type w )\n( F_iso : \u03a0 {A B : \ud835\udc9e}, (A \u2245 B) \u2192 F A \u2243 F B )\n( F_iso_refl : \u03a0 {A : \ud835\udc9e}, F_iso (iso.refl A) = equiv.refl (F A) )\n( F_iso_trans : \u03a0 {A B C : \ud835\udc9e} (e\u2081 : A \u2245 B) (e\u2082 : B \u2245 C), \n    equiv.trans (F_iso e\u2081) (F_iso e\u2082) = F_iso (iso.trans e\u2081 e\u2082) )\n( hom : \u03a0 {A B : \ud835\udc9e} (f : A \u27f6 B) (a : F A) (b : F B), Type x )\n( hom_iso : \u03a0 {A\u2081 A\u2082 B\u2081 B\u2082 : \ud835\udc9e} \n    (f\u2081 : A\u2081 \u27f6 B\u2081) (a\u2081 : F A\u2081) (b\u2081 : F B\u2081)\n    (f\u2082 : A\u2082 \u27f6 B\u2082) (a\u2082 : F A\u2082) (b\u2082 : F B\u2082)\n    (eA : A\u2081 \u2245 A\u2082) (eB : B\u2081 \u2245 B\u2082)\n    (hf : f\u2081 \u226b eB.hom = eA.hom \u226b f\u2082)\n    (ha : a\u2082 = F_iso eA a\u2081)\n    (hb : b\u2082 = F_iso eB b\u2081),\n    hom f\u2081 a\u2081 b\u2081 \u2243 hom f\u2082 a\u2082 b\u2082 )\n( hom_iso_refl : \u03a0 {A B : \ud835\udc9e} \n    (f : A \u27f6 B) (a : F A) (b : F B)\n    (hf : f \u226b (iso.refl B).hom = (iso.refl A).hom \u226b 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 : \u03a0 {A\u2081 A\u2082 A\u2083 B\u2081 B\u2082 B\u2083 : \ud835\udc9e}\n    (f\u2081 : A\u2081 \u27f6 B\u2081) (a\u2081 : F A\u2081) (b\u2081 : F B\u2081)\n    (f\u2082 : A\u2082 \u27f6 B\u2082) (a\u2082 : F A\u2082) (b\u2082 : F B\u2082)\n    (f\u2083 : A\u2083 \u27f6 B\u2083) (a\u2083 : F A\u2083) (b\u2083 : F B\u2083) \n    (eA\u2081\u2082 : A\u2081 \u2245 A\u2082) (eB\u2081\u2082 : B\u2081 \u2245 B\u2082)\n    (eA\u2082\u2083 : A\u2082 \u2245 A\u2083) (eB\u2082\u2083 : B\u2082 \u2245 B\u2083)\n    (hf\u2081\u2082 : f\u2081 \u226b eB\u2081\u2082.hom = eA\u2081\u2082.hom \u226b f\u2082)\n    (hf\u2082\u2083 : f\u2082 \u226b eB\u2082\u2083.hom = eA\u2082\u2083.hom \u226b f\u2083)\n    (ha\u2081\u2082 : a\u2082 = F_iso eA\u2081\u2082 a\u2081)\n    (ha\u2082\u2083 : a\u2083 = F_iso eA\u2082\u2083 a\u2082)\n    (hb\u2081\u2082 : b\u2082 = F_iso eB\u2081\u2082 b\u2081)\n    (hb\u2082\u2083 : b\u2083 = F_iso eB\u2082\u2083 b\u2082),\n    (hom_iso f\u2081 a\u2081 b\u2081 f\u2082 a\u2082 b\u2082 eA\u2081\u2082 eB\u2081\u2082 hf\u2081\u2082 ha\u2081\u2082 hb\u2081\u2082).trans\n    (hom_iso f\u2082 a\u2082 b\u2082 f\u2083 a\u2083 b\u2083 eA\u2082\u2083 eB\u2082\u2083 hf\u2082\u2083 ha\u2082\u2083 hb\u2082\u2083) =\n    hom_iso f\u2081 a\u2081 b\u2081 f\u2083 a\u2083 b\u2083 (eA\u2081\u2082.trans eA\u2082\u2083) (eB\u2081\u2082.trans eB\u2082\u2083) \n      (by simp [\u2190 hf\u2081\u2082, \u2190 hf\u2082\u2083, category.assoc]) \n      (by simp [ha\u2082\u2083, ha\u2081\u2082, \u2190 F_iso_trans]) \n      (by simp [hb\u2082\u2083, hb\u2081\u2082, \u2190 F_iso_trans]) )\n( id : \u03a0 {A : \ud835\udc9e} (a : F A), hom (\ud835\udfd9 A) a a )\n( hom_iso_id : \u03a0 {A\u2081 A\u2082 : \ud835\udc9e}\n    (a\u2081 : F A\u2081) (a\u2082 : F A\u2082)\n    (eA : A\u2081 \u2245 A\u2082)\n    (hf : \ud835\udfd9 A\u2081 \u226b eA.hom = eA.hom \u226b \ud835\udfd9 A\u2082)\n    (ha : a\u2082 = F_iso eA a\u2081),\n    hom_iso (\ud835\udfd9 A\u2081) a\u2081 a\u2081 (\ud835\udfd9 A\u2082) a\u2082 a\u2082 eA eA hf ha ha (id a\u2081) = id a\u2082 )\n( comp : \u03a0 {A B C : \ud835\udc9e} {a : F A} {b : F B} {c : F C}\n    {f : A \u27f6 B} {g : B \u27f6 C} (f' : hom f a b) (g' : hom g b c), \n    hom (f \u226b g) a c )\n( hom_iso_comp : \u03a0 {A\u2081 A\u2082 B\u2081 B\u2082 C\u2081 C\u2082}\n    (f\u2081 : A\u2081 \u27f6 B\u2081) (g\u2081 : B\u2081 \u27f6 C\u2081) (a\u2081 : F A\u2081) (b\u2081 : F B\u2081) (c\u2081 : F C\u2081)\n    (f\u2082 : A\u2082 \u27f6 B\u2082) (g\u2082 : B\u2082 \u27f6 C\u2082) (a\u2082 : F A\u2082) (b\u2082 : F B\u2082) (c\u2082 : F C\u2082)\n    (eA : A\u2081 \u2245 A\u2082) (eB : B\u2081 \u2245 B\u2082) (eC : C\u2081 \u2245 C\u2082)\n    (hf : f\u2081 \u226b eB.hom = eA.hom \u226b f\u2082)\n    (hg : g\u2081 \u226b eC.hom = eB.hom \u226b g\u2082)\n    (hfg : (f\u2081 \u226b g\u2081) \u226b eC.hom = eA.hom \u226b (f\u2082 \u226b g\u2082))\n    (ha : a\u2082 = F_iso eA a\u2081)\n    (hb : b\u2082 = F_iso eB b\u2081)\n    (hc : c\u2082 = F_iso eC c\u2081)\n    (f\u2081' : hom f\u2081 a\u2081 b\u2081)\n    (g\u2081' : hom g\u2081 b\u2081 c\u2081),\n    hom_iso (f\u2081 \u226b g\u2081) a\u2081 c\u2081 (f\u2082 \u226b g\u2082) a\u2082 c\u2082 eA eC hfg\n       ha hc (comp f\u2081' g\u2081') = \n      comp (hom_iso f\u2081 a\u2081 b\u2081 f\u2082 a\u2082 b\u2082 eA eB hf ha hb f\u2081') \n        (hom_iso g\u2081 b\u2081 c\u2081 g\u2082 b\u2082 c\u2082 eB eC  hg hb hc g\u2081') )\n( id_comp : \u03a0 {A B : \ud835\udc9e} {f : A \u27f6 B} {a : F A} {b : F B}\n    (f' : hom f a b), comp (id a) f' = hom_iso f a b (\ud835\udfd9 A \u226b 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 : \u03a0 {A B : \ud835\udc9e} {f : A \u27f6 B} {a : F A} {b : F B}\n    (f' : hom f a b), comp f' (id b) = hom_iso f a b (f \u226b \ud835\udfd9 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 : \u03a0 {A B C D : \ud835\udc9e} {f : A \u27f6 B} {g : B \u27f6 C} {h : C \u27f6 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 \u226b (g \u226b h)) a d ((f \u226b g) \u226b 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 \ud835\udc9e) (\u03bb _, \ud835\udc9e \u2192 Type w) :=\n{ coe := struc.F }\n\nvariables {\ud835\udc9e}\n\n-- @[protect_proj] class GS (F : \ud835\udc9e \u2192 Type w) :=\n-- ( hom : \u03a0 {A B : \ud835\udc9e} (f : A \u27f6 B) (a : F A) (b : F B), Type x )\n-- ( id : \u03a0 {A : \ud835\udc9e} (a b : F A) (h : a = b) (f : A \u27f6 A) (hf : f = \ud835\udfd9 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 \ud835\udc9e) \n\n-- lemma assoc_left {A B C D : \ud835\udc9e} {f : A \u27f6 B} {g : B \u27f6 C} {h : C \u27f6 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 \u27f6 C) (k : A \u27f6 D)\n--     (hi : f \u226b g = i) (hk : i \u226b h = k) :\n--     F.comp (F.comp f' g' hi) h' hk = F.comp f'\n--       (F.comp g' h' rfl) (by rw [\u2190 hk, \u2190 hi, category.assoc]) :=\n-- begin\n--   substs i k,\n--   rw struc.assoc,\n-- end\n\n-- lemma comp_eq_cast {A B C : \ud835\udc9e} {f : A \u27f6 B} {g : B \u27f6 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 \u27f6 C) (hi : f \u226b g = i)\n--   (j : A \u27f6 C) (hj : f \u226b 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 : \ud835\udc9e} {f : A \u27f6 B} {g : B \u27f6 C} {h : C \u27f6 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 \u27f6 C) (k : A \u27f6 D)\n--     (hi : f \u226b g = i) (hk : i \u226b h = k) :\n--     F.comp (F.comp f' g' hi) h' hk = cast (by rw [\u2190 hk, \u2190 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 : \ud835\udc9e} {f : A \u27f6 B} (g : A \u27f6 B) {a : F A} {b : F B}\n--   (h : \ud835\udfd9 A \u226b f = g) (f' : F.hom f a b) : \n--   F.comp (F.id a) f' h = cast (by rw [\u2190 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 : \ud835\udc9e} {f : A \u27f6 B} (g : A \u27f6 B) {a : F A} {b : F B}\n--   (h : f \u226b \ud835\udfd9 B = g) (f' : F.hom f a b) : \n--   F.comp f' (F.id b) h = cast (by rw [\u2190 h, category.comp_id]) f' :=\n-- begin\n--   rw [category.comp_id] at h,\n--   subst h,\n--   simp\n-- end \n\ndef sigma\u2082 (F : struc \ud835\udc9e) : Type* := sigma F\n\ninstance : category_struct (sigma\u2082 F) :=\n{ hom := \u03bb A B, \u03a3 (f : A.1 \u27f6 B.1), F.hom f A.2 B.2,\n  id := \u03bb A, \u27e8\ud835\udfd9 A.1, F.id A.2\u27e9,\n  comp := \u03bb A B C f g, \u27e8f.1 \u226b g.1, F.comp f.2 g.2\u27e9 }\n\nvariable {F}\n\nlemma sigma\u2082.hom_ext {A B : sigma\u2082 F} {f g : A \u27f6 B} \n  (h\u2081 : f.1 = g.1) (h\u2082 : 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\u2081,\n  simp at h\u2082,\n  subst h\u2082\nend\n\ndef sigma_category : category_struct (sigma F) :=\n{ hom := \u03bb A B, \u03a3 (f : A.1 \u27f6 B.1), F.hom f A.2 B.2,\n  id := \u03bb A, \u27e8\ud835\udfd9 A.1, F.id A.2\u27e9,\n  comp := \u03bb A B C f g, \u27e8f.1 \u226b g.1, F.comp f.2 g.2\u27e9 }\n\n@[simp] lemma comp_fst {A B C : sigma\u2082 F} (f : A \u27f6 B) (g : B \u27f6 C) :\n  (f \u226b g).fst = f.1 \u226b g.1 := rfl\n\n@[simp] lemma comp_snd {A B C : sigma\u2082 F} (f : A \u27f6 B) (g : B \u27f6 C) :\n  (f \u226b g).snd = F.comp f.2 g.2 := rfl\n\n@[simp] lemma id_fst {A : sigma\u2082 F} : sigma.fst (\ud835\udfd9 A) = \ud835\udfd9 A.1 := rfl\n\n@[simp] lemma id_snd {A : sigma\u2082 F} : sigma.snd (\ud835\udfd9 A) = F.id A.2 := rfl\n\nsection\n\nlocal attribute [instance] sigma_category\n\ninstance sigma.category : category (sigma\u2082 F) :=\n{ id_comp' := \u03bb A B f, begin\n      refine sigma\u2082.hom_ext _ _,\n      { simp },\n      { simp,\n        rw [\u2190 equiv.trans_apply], \n        erw F.hom_iso_trans,\n        simp }\n    end,\n  comp_id' := \u03bb A B f, begin\n      refine sigma\u2082.hom_ext _ _,\n      { simp },\n      { simp,\n        rw [\u2190 equiv.trans_apply], \n        erw F.hom_iso_trans,\n        simp }\n    end,\n  assoc' := \u03bb A B C D f g h, begin\n      refine sigma\u2082.hom_ext _ _,\n      { simp [category.assoc] },\n      { simp [struc.assoc],\n        rw \u2190 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 : \ud835\udc9e) : category_struct (F X) :=\n{ hom := \u03bb A B, F.hom (\ud835\udfd9 X) A B,\n  id := \u03bb A, F.id A,\n  comp := \u03bb A B C f g, F.hom_iso (\ud835\udfd9 X \u226b \ud835\udfd9 X) A C (\ud835\udfd9 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 : \ud835\udc9e} (x : F X) : \ud835\udfd9 x = F.id x := rfl \n\nlemma comp_def (X : \ud835\udc9e) (A B C : F X) (f : A \u27f6 B) (g : B \u27f6 C) :\n  f \u226b g = F.hom_iso (\ud835\udfd9 X \u226b \ud835\udfd9 X) A C (\ud835\udfd9 X) A C (iso.refl X) (iso.refl X) \n    (by simp) (by simp) (by simp) (F.comp f g) := rfl\n\ninstance (X : \ud835\udc9e) : category (F X) :=\n{ id_comp' := \u03bb A B f, begin \n      simp [id_def, comp_def],\n      rw [\u2190 equiv.trans_apply, F.hom_iso_trans],\n      simp\n    end,\n  comp_id' := \u03bb A B f, begin \n      simp [id_def, comp_def],\n      rw [\u2190 equiv.trans_apply, F.hom_iso_trans],\n      simp\n    end,\n  assoc' := \u03bb A B C D f g h,\n      begin\n        simp only [comp_def, \u2190 F.hom_iso_comp],\n        erw F.hom_iso_comp,\n      end }\n\ndef forget : sigma\u2082 F \u2964 \ud835\udc9e :=\n{ obj := sigma.fst,\n  map := \u03bb _ _, sigma.fst }\n\ndef thing (X : \ud835\udc9e) : F X \u2964 sigma\u2082 F :=\n{ obj := \u03bb A, \u27e8X, A\u27e9,\n  map := \u03bb A B f, \u27e8\ud835\udfd9 X, f\u27e9,\n  map_id' := \u03bb A, rfl,\n  map_comp' := \u03bb 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 (\ud835\udfd9 X \u226b \ud835\udfd9 X) rfl (\ud835\udfd9 X)\n        (category.comp_id _)],\n      symmetry,\n      rw [\u2190 cast_eq_iff_heq],\n      simp, refl,\n      simp,\n    end }\n\nopen opposite\n\nprotected def op (F : struc \ud835\udc9e) : struc \ud835\udc9e\u1d52\u1d56 :=\n{ F := \u03bb A, F.F (unop A),\n  hom := \u03bb A B f a b, F.hom f.unop b a,\n  id := \u03bb A a, F.id a,\n  comp := \u03bb A B C a b c f g f' g' h hH, \n    F.comp g' f' (by simp [\u2190 hH]),\n  id_comp := \u03bb A B f a b f', F.comp_id _,\n  comp_id := \u03bb A B f a b f', F.id_comp _,\n  assoc := \u03bb 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 \ud835\udc9e\u1d52\u1d56) : struc \ud835\udc9e :=\n{ F := \u03bb A, F.F (op A),\n  hom := \u03bb A B f a b, F.hom f.op b a,\n  id := \u03bb A a, F.id a,\n  comp := \u03bb A B C a b c f g f' g' h hH, \n     F.comp g' f' (by simp [\u2190 hH]),\n  id_comp := \u03bb A B f a b f', F.comp_id _,\n  comp_id := \u03bb A B f a b f', F.id_comp _,\n  assoc := \u03bb 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 : \ud835\udc9e \u2964 Type w) : struc \ud835\udc9e :=\n{ F := F.obj,\n  hom := \u03bb A B f a b, plift (F.map f a = b),\n  id := \u03bb A a, \u27e8by simp\u27e9,\n  comp := \u03bb A B C a b c f g h\u2081 h\u2082 _ h, \u27e8by simp [\u2190 h, F.map_comp, h\u2081.down, h\u2082.down]\u27e9,\n  assoc := \u03bb _ _ _ _ _ _ _ _ _ _ _ h\u2081 h\u2082 h\u2083, \n    begin simp [h\u2081.down, h\u2082.down, h\u2083.down] end,\n  id_comp := \u03bb _ _ _ _ _ h, \n    begin simp [h.down] end,\n  comp_id := \u03bb _ _ _ _ _ h, \n    begin simp [h.down] end }\n\ndef Module\u2082 : struc Ring :=\n{ F := \u03bb R, Module R,\n  hom := \u03bb R S f M\u2081 M\u2082, M\u2081 \u2192\u209b\u2097[f] M\u2082,\n  id := \u03bb R M, linear_map.id,\n  comp := \u03bb R S T M\u2081 M\u2082 M\u2083 f g f' g' _ h, \n    @linear_map.comp _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \u27e8h\u27e9 g' f',\n  id_comp := \u03bb R S f M\u2081 M\u2082 f', begin\n      cases f', cases f, refl\n    end,\n  comp_id := \u03bb R S f M\u2081 M\u2082 f', begin\n      cases f', cases f, refl,\n    end,\n  assoc := \u03bb R S T U f g h M\u2081 M\u2082 M\u2083 M\u2084 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 : \ud835\udc9e \u2964 Type) (G : struc (sigma\u2082 (of_functor F))) : struc \ud835\udc9e :=\n{ F := \u03bb X, \u03a0 a : F.obj X, G.F \u27e8X, a\u27e9,\n  hom := \u03bb X Y f x y, \u03a0 (a : F.obj X), \n    @struc.hom _ _ G \u27e8X, a\u27e9 \u27e8Y, F.map f a\u27e9 \u27e8f, \u27e8rfl\u27e9\u27e9 (x a) (y (F.map f a)),\n  id := \u03bb X x a, by convert (G.id (x a)); simp,\n  comp := \u03bb 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 := \u03bb 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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let \u0393 := F.fold \n    ((\u03bb (x : first_order.prop L) (y : L.Theory), y.union {x.to_true_logic_formula}) \u2218 \n    (\u03bb (x : first_order.predicate L) (y : L.Theory), y.union\n    (\u03bb (n : \u2115), {\u2203 (a1 : F.Model.\u03c3), \u2203 (a2 : F.Model.\u03c3), \u2203 (a3 : F.Model.\u03c3), \u2203 (L : F.Model.\u03c3 \u2192 F.Model.\u03c3), \u2203 (R : F.Model.\u03c3 \u2192 F.Model.\u03c3),\n      (\u2203* (a1 a2) (x.relation_symbol 2)) \u2227 \u00ac ((\u2203*)* (a1 a3) (x.relation_symbol 2)) \u2227 \u00ac ((\u2203*)* (a2 a3) (x.relation_symbol 2)) \u2227\n      ((\u2200* (b : F.Model.\u03c3), (L b =* a1 \u2227 R b =* a2) \u2228 (L b =* a2 \u2227 R b =* a3) \u2228 (L b =* a1 \u2227 R b =* a3))) \u2227\n      ((\u2200* (b : F.Model.\u03c3), \u00ac ((\u2203*)* (L b) (x.relation_symbol 1))) \u2227 (\u2200* (b : F.Model.\u03c3), \u00ac ((\u2203*)* (R b) (x.relation_symbol 1))) \u2227\n      ((\u2200* (b : F.Model.\u03c3), (L b =* b) \u2228 (R b =* b)) \u2228 (\u2200* (b : F.Model.\u03c3), \u00ac ((\u2203*)* (b) (x.relation_symbol 1)))))} n))) F,\n  have h1 : \u2200 n : \u2115, \u2203 (M : F.Model) [mfin : fintype M], M \u22a7 \u0393 n, from by {\n    assume n : \u2115,\n    let A := (\u03bb (n : \u2115), {\u2203 (a1 : F.Model.\u03c3), \u2203 (a2 : F.Model.\u03c3), \u2203 (a3 : F.Model.\u03c3), \u2203 (L : F.Model.\u03c3 \u2192 F.Model.\u03c3), \u2203 (R : F.Model.\u03c3 \u2192 F.Model.\u03c3),\n      (\u2203* (a1 a2) (x.relation_symbol 2)) \u2227 \u00ac ((\u2203*)* (a1 a3) (x.relation_symbol 2)) \u2227 \u00ac ((\u2203*)* (a2 a3) (x.relation_symbol 2)) \u2227\n      ((\u2200* (b : F.Model.\u03c3), (L b =* a1 \u2227 R b =* a2) \u2228 (L b =* a2 \u2227 R b =* a3) \u2228 (L b =* a1 \u2227 R b =* a3))) \u2227\n      ((\u2200* (b : F.Model.\u03c3), \u00ac ((\u2203*)* (L b) (x.relation_symbol 1))) \u2227 (\u2200* (b : F.Model.\u03c3), \u00ac ((\u2203*)* (R b) (x.relation_symbol 1))) \u2227\n      ((\u2200* (b : F.Model.\u03c3), (L b =* b) \u2228 (R b =* b)) \u2228 (\u2200* (b : F.Model.\u03c3), \u00ac ((\u2203*)* (b) (x.relation_symbol 1)))))} n),\n    let B := \u03bb (n : \u2115), F.fold \n    ((\u03bb (x : first_order.prop L) (y : L.Theory), y.union {x.to_true_logic_formula}) \u2218 \n    (\u03bb (x : first_order.predicate L) (y : L.Theory), y.union A)) F n,\n    have h2 : B n \u2286 \u0393 n, from by\n      apply subset.trans (\u03bb (x : first_order.formula L), subset_union.mpr \u27e8by {intros,simp [B,A],from \u03bb a b,by {apply F.mem_fold_right}},\n        by {intros, simp [B,A],from \u03bb a b,by {apply F.mem_fold_right}}\u27e9) subset_union_right,\n    have h3 : \u2203 (M : F.Model) [mfin : fintype M], M \u22a7 B n, from by\n      apply fintype.induction_on (h n).right (\u03bb a,\n        begin\n          {\n            let a3 := mk F.Model (a.val \u222a {a1,a2,a3,L,R}),\n            have h3 : (\u2203 (a1 : F.Model.\u03c3), \u2203 (a2 : F.Model.\u03c3), \u2203 (a3 : F.Model.\u03c3), \u2203 (L : F.Model.\u03c3 \u2192 F.Model.\u03c3), \u2203 (R : F.Model.\u03c3 \u2192 F.Model.\u03c3), (\u2203* (a1 a2) (x.relation_symbol 2)) \u2227 \u00ac ((\u2203*)* (a1 a3) (x.relation_symbol 2)) \u2227 \u00ac ((\u2203*)* (a2 a3) (x.relation_symbol 2)) \u2227 ((\u2200* (b : F.Model.\u03c3), (L b =* a1 \u2227 R b =* a2) \u2228 (L b =* a2 \u2227 R b =* a3) \u2228 (L b =* a1 \u2227 R b =* a3))) \u2227 ((\u2200* (b : F.Model.\u03c3), \u00ac ((\u2203*)* (L b) (x.relation_symbol 1))) \u2227 (\u2200* (b : F.Model.\u03c3), \u00ac ((\u2203*)* (R b) (x.relation_symbol 1))) \u2227 ((\u2200* (b : F.Model.\u03c3), (L b =* b) \u2228 (R b =* b)) \u2228 (\u2200* (b : F.Model.\u03c3), \u00ac ((\u2203*)* (b) (x.relation_symbol 1)))))), from\n              have h3 : \u2200 x y, x \u2260 y \u2192 \u00ac (\u2203* (a1 x) (x.relation_symbol 1) \u2227 \u2203* (a1 y) (x.relation_symbol 1)), from assume x y h12,\n                begin\n                  apply not_and.mp,\n                  suffices : \u00ac \u2203* (a1 x) (x.relation_symbol 1) \u2228 \u00ac \u2203* (a1 y) (x.relation_symbol 1), from or_not_and.mp this,\n                  suffices : \u00ac (\u2203* (a1 x) (x.relation_symbol 1) \u2227 \u2203* (a1 y) (x.relation_symbol 1)), from by {split,assumption, assumption,},\n                  simp [h12],\n                end,\n              have h4 : \u2200 x y, x \u2260 y \u2192 \u00ac (\u2203* (a2 x) (x.relation_symbol 1) \u2227 \u2203* (a2 y) (x.relation_symbol 1)), from assume x y h12,\n                begin\n                  apply not_and.mp,\n                  suffices : \u00ac \u2203* (a2 x) (x.relation_symbol 1) \u2228 \u00ac \u2203* (a2 y) (x.relation_symbol 1), from or_not_and.mp this,\n                  suffices : \u00ac (\u2203* (a2 x) (x.relation_symbol 1) \u2227 \u2203* (a2 y) (x.relation_symbol 1)), from by {split,assumption, assumption,},\n                  simp [h12],\n                end,\n              have h5 : \u2200 (b : F.Model.\u03c3), \u2203 (a1 : F.Model.\u03c3), \u2203 (a2 : F.Model.\u03c3), \u2203 (a3 : F.Model.\u03c3), \u2203 (L : F.Model.\u03c3 \u2192 F.Model.\u03c3), \u2203 (R : F.Model.\u03c3 \u2192 F.Model.\u03c3), (\u2203* (a1 a2) (x.relation\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  have h1 : \u2200 n : \u2115, \u2203 (m : F.Model) (h1 : n \u2264 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 : \u2115,\n    let \u27e8M, hM\u27e9 := h n in\n    let \u27e8m : F.Model, h1, h2\u27e9 := 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    \u27e8m, h1, h3\u27e9,\n  have h2 : \u2203 (M : F.Model), \u2200 n : \u2115, n \u2264 fintype.card M, from by {\n    apply first_order.compactness h1,\n    have h3 : \u2200 x : F.Model, first_order.Model.sat_of_mem L.Theory.rel_model F.Model.rel_sat x (F.Model.model_to_set x) \u2192 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, \u27e8@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\u27e9,\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 \u27e8M, hM\u27e9 := h2 in\n  have h3 : \u2203 (n : \u2115), n \u2264 fintype.card M \u2227 n \u2265 fintype.card M, from by {\n    let \u27e8n, hn\u27e9 := 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, \u27e8@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\u27e9,\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 \u27e8n, hn\u27e9 := 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 : \u2200 m : F.Model, fintype.card M = fintype.card m \u2192 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 \u27e8by {\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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from assume n : \u2115, by {\n        use M, split, use mfin, exact le_refl n,\n      },\n      have h10 : \u2203 (M : F.Model) [mfin : fintype M], \u2200 n : \u2115, n \u2264 @fintype.card M mfin, from h9 _,\n      let \u27e8N, hN\u27e9 := h10 in\n      let \u27e8m : F.Model, hm, hm2\u27e9 := F.Model.encode hN in\n      have h11 : M.type = m.type, from h5 m (h4.symm \u25b8 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 \u2190 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 \u25b8 h7) (eq.trans h8.symm h14),\n    }\u27e9,\n  },\n  use M, use h5,\nend\n\n--OUTPUT 3\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  assume L : first_order.language,\n  assume F : L.Theory,\n  assume h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin,\n  have h0 : \u2200 \u2983L : first_order.language\u2984 {F : L.Theory} [decidable_pred (F.Model.relations)] \u2983n : \u2115\u2984, (\u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) \u2192 \u2203 (M : F.Model) [hM : infinite M], n \u2264 @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 : \u2115,\n    assume hn : \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @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 \u2264 @fintype.card m _, from hmn,\n  },\n  cases (classical.choice (\u03bb n : \u2115, \u2203 (M : F.Model) [hM : infinite M], n \u2264 @fintype.card M hM)) with n hn,\n  have h1 : \u2203 (M : F.Model) [hM : infinite M], n \u2264 @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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (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 $ \u03bb (x), x.name \u2260 ``0 \u2227 x.arity = 0,  \n    let prefix : L.Formula_Prefix := L.Formula_Prefix.mk $ \u03bb (x), x.name \u2260 ``0 \u2227 x.arity = 0,\n    let \u03c6 : L.formula := L.formula.mk $ \u03bb (x), x.name \u2260 ``0 \u2227 x.arity = 0,\n    let qvars : L.Variables := L.Variables.mk $ \u03bb (x), x.name \u2260 ``0 \u2227 x.arity = 0,\n    let bvars : L.Variables := L.Variables.mk $ \u03bb (x), x.name \u2260 ``0 \u2227 x.arity = 0,\n    have h0 : \u2200 (x : L.Var) (h1 : (x : L.Variables) \u2208 qvars), x.name \u2260 ``0 \u2227 x.arity = 0, from by simp [h1.1,h1.2],\n    have h1 : \u2200 (x : L.Var) (h2 : (x : L.Variables) \u2208 vars), x.name \u2260 ``0 \u2227 x.arity = 0, from by {\n      assume x h2,\n      have h3 : (x : L.Variables) \u2208 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 : \u2200 (x : L.Var) (h3 : (x : L.Variables) \u2208 prefix), x.name \u2260 ``0 \u2227 x.arity = 0, from by {\n      assume x h3,\n      have h4 : (x : L.Variables) \u2208 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 : \u2200 (x : L.Var) (h4 : (x : L.Variables) \u2208 \u03c6), x.name \u2260 ``0 \u2227 x.arity = 0, from by { apply h2, },\n    exact L.formula.mk h3, \n  },\n  let \u0393 : 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 : \u2203 (M : F.Model) [mfin : fintype M], 0 \u2264 @fintype.card M mfin, from by simp,\n    exact classical.choice h0,\n  },\n\n\n  have overflowed : \u2200 (n : \u2115), \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, from by {\n    assume n : \u2115,\n    use finite_model_exists,\n    exact \u27e8by obviously\u27e9,\n  },\n  have \u2200 (n : \u2115), (\u2203 (m : F.Model) [mfin : fintype m], n \u2264 @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 : \u2203 (m : F.Model), \u2200 (h : m \u2208 \u0393), 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 : \u2200 (h : M \u2208 \u0393), F.Model.satisfies M h, from by {\n    apply classical.choice h_compactness,\n  },\n  have M_satisfies_all_formulas : F.Model.satisfies M \ud835\udfd9, from begin\n    have h0 : M \u2208 \u0393, from by simp [M,\u0393,fintype.eqv'],\n    have h1 : F.Model.satisfies M h0, from M_satisfies h0,\n    have h2 : \u2200 (h : \u0393), 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 : \u2203 a : M, \u2200 b : M, a \u2260 b, from by {\n      have h0 : \u2200 (n : \u2115), \u2203 a : M, \u2200 b : M, a \u2260 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 : \u2115,\n        have h1 : (1 : \u211a) \u2264 (n : \u211a), from by ring,\n        have h2 : n \u2264 n + 1 := by apply le_succ,\n        have h3 : (1 : \u211a) \u2264 (n + 1 : \u211a), from by apply le_trans h1 h2,\n        have h4 : (n : \u211a) \u2264 (n + 1 : \u211a), from by ring, \n        have h5 : (n : \u211d) \u2264 (n + 1 : \u211d), from by apply @rat.cast_le \u211a,\n        have h6 : (n : \u211d) < (n + 1 : \u211d), from by apply lt_succ_iff.mp h5,\n        have h7 : ((n + 1) : \u2115) < (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 : \u2203 (M : F.Model) [mfin : fintype M], (n :\u2115) \u2264 fintype.card M, from by {\n          have h9 : \u2203 (M : F.Model) [mfin : fintype M], (n :\u2115) \u2264 @fintype.card M mfin, from by {\n            apply overflowed,\n          },\n          exact h9,\n        },\n        have h10 : \u2203 (M : F.Model) [mfin : fintype M], n + 2 \u2264 @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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  have h1 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm' : m' \u2243 m], n \u2264 @fintype.card m' mfin'), from \n    assume n : \u2115,\n    begin\n      have h2 : \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin, by apply h,\n      have h3 : \u2200 (m : F.Model) [mfin : fintype m], \u2203 [mm' : m \u2243 m], n \u2264 @fintype.card m mfin, from \n        assume (m : F.Model) [mfin : fintype m], let \u27e8pm,hp\u27e9 := mfin.equiv_fin, let mm' : m \u2243 m := \u27e8pm,hp\u27e9, \u27e8mm'\u27e9,\n      have h4 : \u2203 (m : F.Model) [mfin : fintype m] [mm' : m \u2243 m], n \u2264 @fintype.card m mfin, from exists_imp_exists _ h3,\n      have h5 : \u2203 (m : F.Model) [mfin : fintype m] [mm' : m \u2243 m], n \u2264 @fintype.card m mfin', from exists_imp_exists _ h4, \n      exact h5,\n    end, \n  have h2 : \u2200 n : \u2115, \u2203 (a : F.Model) [mfin : fintype a] [ma : a \u22a7 L.A n], n \u2264 @fintype.card a mfin, from \n    assume n : \u2115, begin\n      have h3 : \u2203 (m : F.Model) [mfin : fintype m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm' : m' \u2243 m], n \u2264 @fintype.card m' mfin'), from (h1 n),\n      have h4 : \u2203 a [mfin : fintype a] [mm' : a \u2243 a], (\u2200 (m : F.Model) [mfin' : fintype m] [mm : m \u2243 a], n \u2264 @fintype.card m mfin'), from \n        exists_imp_exists_const (\u03bb (m : F.Model) [mfin : fintype m], \u2200 (m' : F.Model) [mfin' : fintype m'] [mm : m' \u2243 m], n \u2264 @fintype.card m' mfin') h3,\n      have h5 : \u2203 a [mfin : fintype a] [mm' : a \u2243 a], (\u2200 (m : F.Model) [mfin' : fintype m] [mm : a \u2243 m], n \u2264 @fintype.card m mfin'), from exists_imp_exists_const (\u03bb (m : F.Model) [mfin' : fintype m], \u2200 [mm : a \u2243 m], n \u2264 @fintype.card m mfin') h4,\n      have h6 : \u2203 a [mfin : fintype a] [mm' : a \u2243 a], (\u2200 (m : F.Model) [mfin' : fintype m] [mm : a \u2243 m], n \u2264 @fintype.card a mfin), from exists_imp_exists_const (\u03bb (m : F.Model) [mfin' : fintype m], n \u2264 @fintype.card a mfin) h5, \n      have h7 : \u2203 (m : F.Model) [mfin : fintype m] [mm' : m \u2243 m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm : m \u2243 m'], n \u2264 @fintype.card m' mfin'), from \n      begin \n        have h8 : \u2203 (a : F.Model) [mfin : fintype a] [mm' : a \u2243 a], (\u2200 (m : F.Model) [mfin' : fintype m] [mm : a \u2243 m], n \u2264 @fintype.card a mfin), from h6,\n        exact exists_imp_exists_const (\u03bb (m : F.Model) [mfin' : fintype m], \u2200 [mm : m \u2243 a], n \u2264 @fintype.card m mfin') h8,\n      end,\n      have h8 : \u2203 (m : F.Model) [mfin : fintype m] [mm' : m \u2243 m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm : m \u2243 m'], n \u2264 @fintype.card m mfin'), from exists_imp_exists_const (\u03bb (m : F.Model) [mfin' : fintype m], n \u2264 @fintype.card m mfin') h7,\n      have h9 : \u2203 (m : F.Model) [mfin : fintype m] [mm' : m \u2243 m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm : m \u2243 m'], n \u2264 @fintype.card m mfin) \u2227 (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm : m \u2243 m'], m' \u22a7 L.A n), from exists_imp_exists_const (\u03bb (m : F.Model) [mfin : fintype m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm : m \u2243 m'], m' \u22a7 L.A n)) h8,\n      exact h9,\n    end,\n  have h3 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm' : m \u2243 m'], n \u2264 @fintype.card m mfin) \u2227 (\u2200 n : \u2115, m \u22a7 L.A n), from \n    assume n : \u2115, begin\n      have h3 : \u2203 (m : F.Model) [mfin : fintype m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm' : m \u2243 m'], n \u2264 @fintype.card m mfin), from h2 n,\n      have h4 : \u2203 (m : F.Model) [mfin : fintype m], (\u2203 [mm' : m \u2243 m], n \u2264 @fintype.card m mfin), from \n        exists_imp_exists_const (\u03bb (m : F.Model) [mfin : fintype m], \u2203 [mm : m \u2243 m], n \u2264 @fintype.card m mfin) h3,\n      have h5 : \u2203 (m : F.Model) [mfin : fintype m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm : m' \u2243 m], n \u2264 @fintype.card m mfin) \u2227 (\u2200 n : \u2115, m \u22a7 L.A n), from \n        exists_imp_exists_const (\u03bb (m : F.Model) [mfin : fintype m], (\u2200 n : \u2115, m \u22a7 L.A n)) h4,\n      exact h5,\n    end,\n  have h4 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm : m' \u2243 m], m' \u22a7 F \u2227 (\u2200 n : \u2115, m' \u22a7 L.A n)), from\n    assume n : \u2115, begin\n      have h5 : \u2203 (m : F.Model) [mfin : fintype m], (\u2200 (m' : F.Model) [mfin' : fintype m'] [mm : m' \u2243\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  assume L F (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin),\n  use [L,F], split,\n  assume (n : \u2115), 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) (\u03bb i : fin (n + 3), 0) (n + 1) in\n  let h := function.update (finset.range n) (\u03bb i : fin (n + 3), 0) (n + 2) in\n  let i := function.update (finset.range n) (\u03bb i : fin (n + 3), 0) (n + 3) in\n  let G := function.update (finset.range n) (\u03bb i : fin (n + 3), 0) (n + 4) in\n  let \u0393 := L' \n  in\n  let \u03c6 := (\u2203(g),\n  (\u2203(h), \n  (\u2203(i), \n  (\u2203(G),\n   ((\u2200(x), \n    (\u2203(g), \n    (\u2203(h), \n    (\u2203(i), \n    (\u2203(G), \n    (\u2200(x), \n    (\u2200(g), \n    (\u2200(h), \n    (\u2200(i), \n    (\u2200(G), \n    ((\u2200(x), \n    (\u2200(g), \n    (\u2200(h), \n    ((neg (g = h)) \u2227 (neg (h = i)) \u2227 (neg (g = i))))))) \u2227 \n    (\u2200(x), \n    (\u2200(g), \n    (\u2200(h), \n    (\u2200(i), \n    (\u2200(G), \n    ((x < i) = (x < G)))))))))))))))))))))))))) \u2227\n    (\u2200(x), \n    (\u2200(g), \n    (\u2200(h), \n    (\u2200(i), \n    (\u2200(G), \n    ((g < h) = (g < i)))))))) \u2227 \n  (\u2200(x), \n  (\u2200(g), \n  (\u2200(h), \n  (\u2200(i), \n  (\u2200(G), \n  ((x = i) = (x = G)))))))) \u2227 \n  (\u2200(x), \n  (\u2200(g), \n  (\u2200(h), \n  (\u2200(i), \n  (\u2200(G), \n  ((x = i) = (x = G)))))))) \u2227 \n  (\u2200(x), \n  (\u2200(g), \n  (\u2200(h), \n  (\u2200(i), \n  (\u2200(G), \n  ((x = i) = (x = G)))))))) \u2227 \n  (\u2200(x), \n  (\u2200(g), \n  (\u2200(h), \n  (\u2200(i), \n  (\u2200(G), \n  ((x = i) = (x = G)))))))) \u2227 \n  (\u2200(x), \n  (\u2200(g), \n  (\u2200(h), \n  (\u2200(i), \n  (\u2200(G), \n  ((x = i) = (x = G))))))))) in\n  show \u2203 (M : F'.Model), infinite M, from\n  begin\n    have h1 : \u2200 n : \u2115, \u2203 (m : F'.Model) [mfin : fintype m], n \u2264 @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 : \u2200 n : \u2115, \u2203 (m : F'.Model), n \u2260 @fintype.card m,\n    from by {\n      assume (n : \u2115), \n      cases h1 n,\n      use g,\n      have h5 : @fintype.card g \u2260 n, from by rw [\u2190(card_insert_of_not_mem @@ set.not_mem_range_self _ _)],\n      have h6 : fintype.card g \u2260 n, from by rw [fintype.card_eq_nat_card, \u2190 h5], show n \u2260 @fintype.card g, from not_congr h6,\n    },\n    have h3 : \u2200 f : F'.Model, \u2203 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 [\u2190nat.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 : \u2203 (m : F'.Model), g \u2260 @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 \u03c6 := 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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  let A_1 : L.formula := \u2203 (x : L.sort) (y : L.sort),  x \u2260 y,\n  let A_2 : L.formula := \u2203 (x : L.sort) (y : L.sort) (z : L.sort), x \u2260 y \u2227 x \u2260 z \u2227 y \u2260 z,\n  let A_3 : L.formula := \u2203 (x : L.sort) (y : L.sort) (z : L.sort) (w : L.sort), x \u2260 y \u2227 x \u2260 z \u2227 x \u2260 w \u2227 y \u2260 z \u2227 y \u2260 w \u2227 z \u2260 w,\n  -- continue with other A_n, or just say \"define A_n inductively\"\n  let A_n : L.formula := \u03bb (n : \u2115), 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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (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 : \u2115) : \u2203 (p : \u2115), \u2200 (m : \u2115), m \u2265 p \u2192 m % n = n % n := by sorry\nend\n\n--OUTPUT 10\ntheorem overflow {L : first_order.language} {F : L.Theory} (h : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M := by {\n\nlet A\u2099 := \u03bb (n : \u2115), first_order.Theory.has_model F \n  (first_order.existsn (n : \u2115) (first_order.var 0) \u2227\n  first_order.bigand (n - 1) (\u03bb n : \u2115,\n   first_order.\u2200' first_order.var (n+1) (first_order.var 0) (ne first_order.var 1) \u2227\n   first_order.impl (n \u2260 0) (first_order.\u2200' first_order.var (n+1) (first_order.var n) (ne first_order.var (n+1))))),\n\n let h\u2099\u208a\u2081\u208b\u2099\u2096 := by {intros, rw succ_sub, rw add_comm,simp},\n let h\u2099\u208a\u2081\u208b\u2099\u2096\u208a\u2081 := by {intros, rw succ_sub, rw add_comm,rw succ_sub, rw add_comm,simp},\n let h\u2096\u208a\u2081 := by {intros, rw succ_sub, rw add_comm,simp},\n let \u0393 := (first_order.Theory.has_model.map A\u2099) h,\n\n\n have h0 : (\u2200 n : \u2115, \u0393 n), from by {intros, simp [\u0393],},\n have h1 : (ty), from by {\n   have h1 : ((\u2200 n : \u2115, \u0393 n)), from by {intros, from h0 _,},\n   have h2 : (has_finite.finite \u0393), from by {apply _,},\n   have h3 : (\u2203 (m : F.Model) [mfin : fintype m], nat.find (\u03bb n, \u0393 n)), from by {exact h2,},\n   have h4 : (\u2203 (m : F.Model) [mfin : fintype m], nat.find (\u03bb n, \u0393 n)), from by {exact h3,},},\n\n\nhave h2 : (has_finite.finite \u0393), from by {apply _,},\nhave h3 : (\u2203 (m : F.Model) [mfin : fintype m], nat.find (\u03bb n, \u0393 n)), from by {exact h2,},\nhave h4 : (\u2203 (m : F.Model) [mfin : fintype m], nat.find (\u03bb n, \u0393 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (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 \u2190 getMVarType' mvarId\n    let .const declName us := target.getAppFn\n      | throwTacticEx `ctor mvarId \"target is not an inductive datatype\"\n    let .inductInfo { ctors, .. } \u2190 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 \u00b7 idx.getNat)\n\nexample (p : Prop) : p := by \n  ctor 1 -- Error\n\nexample (h : q) : p \u2228 q := by \n  ctor 0 -- Error\n  exact h\n\nexample (h : q) : p \u2228 q := by \n  ctor 3 -- Error\n  exact h\n\nexample (h : q) : p \u2228 q := by \n  ctor 2\n  exact h\n\nexample (h : q) : p \u2228 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": "\nimport unitb.decomposition.component\n\nuniverse variables u\n\nnamespace decomposition\nsection\n\nopen predicate unitb function scheduling\n\nparameter {\u03b1  : Type}\nparameter {t : Type}\nparameter [sched t]\nparameter {s : t \u2192 program \u03b1}\nparameter {s\u2080 : \u03b1}\nparameter (asm : \u03b1 \u2192 \u03b1 \u2192 Prop)\nparameter (h\u2080 : \u2200 i, (s i).mch.first s\u2080)\nparameter (h : compatible asm s)\nnoncomputable def s' := compose s asm h\u2080 h\n\nparameters {asm h\u2080 h}\n\nvariables {i : t}\nvariables {p q : pred' \u03b1}\n\nlemma local_reasoning.transient\n  (T : transient' (s i) p q)\n: transient' s' p q :=\nbegin\n  unfold transient' system.transient nondet.program.transient comp,\n  unfold transient' system.transient nondet.program.transient comp at T,\n  cases T with e Te,\n  cases e,\n  case some e\n  { existsi some (\u27e8i,e\u27e9 : \u03a3 i, (s i).mch.lbl),\n    apply nondet.program.falsify.mk,\n    { apply Te.enable },\n    { apply Te.schedule },\n    { apply Te.negate' } },\n  case none\n  { existsi none,\n    apply nondet.program.falsify.mk,\n    { apply Te.enable },\n    { apply Te.schedule },\n    { apply Te.negate' } },\nend\n\nlemma local_reasoning.unless\n  (S : unless (s i) p q)\n: unless s' p q :=\nbegin\n  unfold unless,\n  intros \u03c3 \u03c3' STEP,\n  apply S,\n  unfold unitb.step has_safety.step step,\n  unfold unitb.step has_safety.step step at STEP,\n  unfold program.mch program.asm nondet.is_step nondet.program.lbl at STEP,\n  unfold program.mch program.asm nondet.is_step nondet.program.lbl,\n  cases STEP,\n  case or.inl STEP\n  { cases STEP with ev STEP,\n    cases ev,\n    case some ev\n    { cases ev with j Hj,\n      cases classical.em (i = j) with Heq Hne,\n      { subst j,\n        left, existsi some Hj,\n        apply STEP },\n      { right, apply h.step _ _ Hne,\n        unfold nondet.is_step,\n        existsi some Hj,\n        apply STEP, }, },\n    case none\n    { left, existsi none, apply STEP } },\n  case or.inr STEP\n  { right, apply h.asm, apply STEP, },\nend\n\ntheorem leads_to.subst {p q}\n  (H : p \u21a6 q in s i)\n: p \u21a6 q in s' :=\nunitb.leads_to.subst id _ _\n(@local_reasoning.transient i) (@local_reasoning.unless i) H\n\ntheorem often_imp_often.subst {p q}\n  (H : p >~> q in s i)\n: p >~> q in s' :=\nunitb.often_imp_often.subst id _ _\n(@local_reasoning.transient i) (@local_reasoning.unless i) H\n\nend\nend decomposition\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/decomposition/lemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.5350984286266116, "lm_q2_score": 0.38121956625614994, "lm_q1q2_score": 0.20398999086538427}}
{"text": "import number_theory.padics.padic_integers\n\n\n--OUTPUT 1\ntheorem p_adic_units (p : \u2115) (x : \u2115) (h : nat.coprime p x) : nat.units (p_adic_int p) x :=\nbegin\n  have h1 : nat.units (p_adic_int p) x \u2194 (p_adic_int p).norm x = 1, from by auto [units_iff_norm_eq_one],\n  have h2 : (p_adic_int p).norm x < 1, from by auto [h, p_adic_int.norm_eq_zero_iff, p_adic_int.norm_eq_one_iff, p_adic_int.norm_eq_p_iff, p_adic_int.norm_eq_p_pow_iff],\n  have h3 : p \u2223 x, from by auto [h2, p_adic_int.norm_eq_zero_iff, p_adic_int.norm_eq_one_iff, p_adic_int.norm_eq_p_iff, p_adic_int.norm_eq_p_pow_iff],\n  have h4 : \u00ac nat.coprime p x, from by auto [h3, nat.coprime_iff_prime_dvd],\n  show \u00ac nat.units (p_adic_int p) x, from by auto [h1, h2, units_iff_norm_eq_one],\nend\n\n--OUTPUT 2\ntheorem p_adic_units (p : \u2115) (x : \u2115) (h : gcd x p = 1) : \u2203 y : \u2115, x * y = 1 :=\nbegin\n  have h1 : \u2200 x : \u2115, \u2203 y : \u2115, x * y = 1, from by auto using [use (x\u207b\u00b9)],\n  have h2 : \u2200 x : \u2115, \u2203 y : \u2115, y * x = 1, from by auto using [use (x\u207b\u00b9)],\n  have h3 : \u2203 y : \u2115, x * y = 1, from by auto [h1],\n  have h4 : \u2203 y : \u2115, y * x = 1, from by auto [h2],\n  show \u2203 y : \u2115, x * y = 1, from by auto [h3, h4, exists_unique.unique, exists_unique.exists] using [use (x\u207b\u00b9)],\nend\n\n--OUTPUT 3\ntheorem p_adic_units (p : \u2115) (x : \u2115) (h : nat.coprime x p) : \u2203 y : \u2124, x * y = 1 :=\nbegin\n  have h1 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [nat.not_coprime_iff_dvd],\n  have h2 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h1],\n  have h3 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h2],\n  have h4 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h3],\n  have h5 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h4],\n  have h6 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h5],\n  have h7 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h6],\n  have h8 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h7],\n  have h9 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h8],\n  have h10 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h9],\n  have h11 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h10],\n  have h12 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h11],\n  have h13 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h12],\n  have h14 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h13],\n  have h15 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h14],\n  have h16 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h15],\n  have h17 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h16],\n  have h18 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h17],\n  have h19 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h18],\n  have h20 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h19],\n  have h21 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h20],\n  have h22 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h21],\n  have h23 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h22],\n  have h24 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h23],\n  have h25 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h24],\n  have h26 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h25],\n  have h27 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h26],\n  have h28 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h27],\n  have h29 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h28],\n  have h30 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h29],\n  have h31 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h30],\n  have h32 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h31],\n  have h33 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h32],\n  have h34 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h33],\n  have h35 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h34],\n  have h36 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h35],\n  have h37 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h36],\n  have h38 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h37],\n  have h39 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h38],\n  have h40 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h39],\n  have h41 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h40],\n  have h42 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h41],\n  have h43 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h42],\n  have h44 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h43],\n  have h45 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h44],\n  have h46 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h45],\n  have h47 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h46],\n  have h48 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h47],\n  have h49 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h48],\n  have h50 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h49],\n  have h51 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h50],\n  have h52 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h51],\n  have h53 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h52],\n  have h54 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h53],\n  have h55 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h54],\n  have h56 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h55],\n  have h57 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h56],\n  have h58 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h57],\n  have h59 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h58],\n  have h60 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h59],\n  have h61 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h60],\n  have h62 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h61],\n  have h63 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h62],\n  have h64 : \u00ac (\u2203 y : \u2124, x * y = 1), from by auto [h63],\n  have h65 : \u00ac (\u2203 y : \u2124, x * y = 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from by auto [h2],\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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`\np-adic units\nGiven a prime number $p$ and a natural number $x$, if $x$ is coprime to $p$, then $x$ is a unit in the $p$-adic integers.\n`proof`\nLet us prove the contrapositive, that is, is $x$ is not a unit of $\\mathbb{Z}_p$, then $x$ is not coprime to $p$. \nWe know that any element of $\\mathbb{Z}_p$ is a unit if and only if it has norm 1, thus $\\Vert x \\Vert \\neq 1$. Also, since every element of $\\mathbb{Z}_p$ must have norm less than or equal to 1, we conclude that $\\Vert x \\Vert < 1$. \nBut this must imply that $p | x$.\nThis completes our proof.\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_auto-Natural-Language-Proof-Translation/lean_proof_auto-3_few_shot_temperature_0.2_max_tokens_2000_n_3/clean_files/p-adic units.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO", "lm_q1_score": 0.7490872131147276, "lm_q2_score": 0.2720245510940225, "lm_q1q2_score": 0.20377011287780614}}
{"text": "import ..syntax_directed\nimport ..type_system\nimport .structural_subtyping\n\nnamespace flow_analysis\n\nlemma syntax_directed_subtyping.expr {\u039b : location} {\u03b3 : identifier} {e : base_expr}\n    {\u03c1 \u03c1' : phrase} :\n  ((\u039b, \u03b3) \u22a2\u209b\u2091 e : \u03c1 \u2227 \u03c1 \u2286\u209b \u03c1') \u2192 ((\u039b, \u03b3) \u22a2\u209b\u2091 e : \u03c1')\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 : \u039b \u03b3 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 : \u039b \u03b3 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 : \u039b \u03b3 a b z \u03c4 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 : \u039b \u03b3 e \u03c4 \u03c4' 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 (\u039b, \u03b3) \u22a2\u209b p : \u03c1 and \u22a2 \u03c1 \u2286\u209b \u03c1', then (\u039b, \u03b3) \u22a2\u209b p : \u03c1'\n -/\nlemma syntax_directed_subtyping {\u039b : location} {\u03b3 : identifier} {p : program}\n    {\u03c1 \u03c1' : phrase} :\n  ((\u039b, \u03b3) \u22a2\u209b p : \u03c1 \u2227 \u03c1 \u2286\u209b \u03c1') \u2192 ((\u039b, \u03b3) \u22a2\u209b p : \u03c1')\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 : \u039b \u03b3 v e \u03c4 \u03c4' 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 : \u039b \u03b3 v e \u03c4 \u03c4' 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 : \u039b \u03b3 c c' \u03c4 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    : \u039b \u03b3 e c c' \u03c4 \u03c4' 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 : \u039b \u03b3 e c \u03c4 \u03c4' he hc h\u03c4\u03c4' 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\u03c4\u03c4',\n    apply syntax_directed.program_typing.while he hc h,\n  },\n  case syntax_directed.program_typing.letvar : \u039b \u03b3 x e c \u03c4 \u03c4' 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 {\u039b : location} {\u03b3 : identifier} {e : base_expr}\n  {\u03c1 : phrase} : ((\u039b, \u03b3) \u22a2\u2091 e : \u03c1) \u2194 ((\u039b, \u03b3) \u22a2\u209b\u2091 e : \u03c1)\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 : \u039b \u03b3 e \u03c4 he ihe {\n      exact syntax_directed.expr_typing.r_val ihe (le_refl \u03c4), },\n    case type_system.expr_typing.subtype : \u039b \u03b3 p \u03c1 \u03c1' hp h\u03c1\u03c1' ih {\n      exact syntax_directed_subtyping.expr (and.intro ih h\u03c1\u03c1'),\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 : \u039b \u03b3 e \u03c4 \u03c4' he h\u03c4\u03c4' ih {\n      have h := phrase.ss.base h\u03c4\u03c4',\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 - (\u039b, \u03b3) \u22a2\u209c p : \u03c1 \u2194 (\u039b, \u03b3) \u22a2\u209b p : \u03c1 -/\ntheorem program_typing_eq {\u039b : location} {\u03b3 : identifier}\n  {p : program} {\u03c1 : phrase} : ((\u039b, \u03b3) \u22a2\u209c p : \u03c1) \u2194 ((\u039b, \u03b3) \u22a2\u209b p : \u03c1)\n:= begin\n  apply iff.intro,\n  { intro h,\n    induction h,\n    case type_system.program_typing.assign_var : \u039b \u03b3 e e' \u03c4 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 \u03c4),\n    },\n    case type_system.program_typing.assign_loc : \u039b \u03b3 e e' \u03c4 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 \u03c4),\n    },\n    case type_system.program_typing.compose : \u039b \u03b3 c c' \u03c4 hc hc' ihc ihc' {\n      exact syntax_directed.program_typing.compose ihc ihc',\n    },\n    case type_system.program_typing.branch : \u039b \u03b3 e c c' \u03c4 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 \u03c4),\n    },\n    case type_system.program_typing.while : \u039b \u03b3 e c \u03c4 he hc ihc {\n      have ihe := program_typing_eq.expr.1 he,\n      exact syntax_directed.program_typing.while ihe ihc (le_refl \u03c4),\n    },\n    case type_system.program_typing.letvar : \u039b \u03b3 x e c \u03c4 \u03c4' 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 : \u039b \u03b3 p \u03c1 \u03c1' hp h\u03c1\u03c1' ihp {\n      exact syntax_directed_subtyping (and.intro ihp h\u03c1\u03c1'),\n    },\n  },\n  { intro h,\n    induction h,\n    case syntax_directed.program_typing.assign_var : \u039b \u03b3 e e' \u03c4 \u03c4' he he' h\u03c4\u03c4' {\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\u03c4\u03c4')),\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 : \u039b \u03b3 e e' \u03c4 \u03c4' he he' h\u03c4\u03c4' {\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\u03c4\u03c4')),\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 : \u039b \u03b3 c c' \u03c4 hc hc' ihc ihc' {\n      exact type_system.program_typing.compose ihc ihc',\n    },\n    case syntax_directed.program_typing.branch\n        : \u039b \u03b3 e c c' \u03c4 \u03c4' he hc hc' h\u03c4'\u03c4 ihc ihc' {\n      have ihe := program_typing_eq.expr.2 he,\n      have h_sub := phrase.ss.cmd (phrase.ss.base h\u03c4'\u03c4),\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 : \u039b \u03b3 e c \u03c4 \u03c4' he hc h\u03c4\u03c4' ihc {\n      have ihe := program_typing_eq.expr.2 he,\n      have h_sub := phrase.ss.cmd (phrase.ss.base h\u03c4\u03c4'),\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        : \u039b \u03b3 x e c \u03c4 \u03c4' 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": "inductive Fam : Type \u2192 Type 1 where\n  | any : Fam \u03b1\n  | nat : Nat \u2192 Fam Nat\n\nexample (a : \u03b1) : Fam \u03b1 \u2192 \u03b1\n  | Fam.any => a\n  | Fam.nat n => n\n\ninductive Fam2 : Type \u2192 Type \u2192 Type 1 where\n  | any : Fam2 \u03b1 \u03b1\n  | nat : Nat \u2192 Fam2 Nat Nat\n\nexample (a : \u03b1) : Fam2 \u03b1 \u03b2 \u2192 \u03b2\n  | Fam2.any   => a\n  | Fam2.nat n => n\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/1018.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.640635854839898, "lm_q2_score": 0.3174262655876758, "lm_q1q2_score": 0.2033546470033972}}
{"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 \u22d9 CondensedSet_to_Condensed_Ab\n\nnamespace Condensed\n\nvariables (BD : package)\n\nabbreviation freeFunc : (Profinite\u1d52\u1d56 \u2964 Ab) \u2964 Profinite\u1d52\u1d56 \u2964 Ab :=\n(whiskering_right _ _ _).obj (forget _ \u22d9 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) \u2245\n  ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up \u2124)).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 _ _ _ \u226a\u226b _,\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 : \u2115) :\n  ((BD.eval' freeCond').obj M).X (int.of_nat (i+1)) \u2245\n  ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up \u2124)).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 : \u2115) :\n  ((BD.eval' freeCond').obj M).X (-[1+i]) \u2245\n  ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up \u2124)).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 _ _ _ \u226a\u226b _,\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\u2080 (M : Condensed.{u} Ab.{u+1}) :\n  (eval_freeCond'_iso.component_neg BD M 0).hom \u226b\n    ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up \u2124)).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) \u226b\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 \u2190 presheaf_to_Condensed_Ab.map_comp,\n  erw \u2190 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 [\u2190 functor.map_comp],\n  congr' 1, simp only [\u2190 nat_trans.comp_app], congr' 1,\n  apply biproduct.hom_ext, intros j,\n  simp only [category.assoc, biproduct.matrix_\u03c0, biproduct.lift_\u03c0],\n  dsimp only [functor.map_bicone],\n  rw biproduct.lift_desc,\n  erw [\u2190 Condensed_Ab_to_presheaf.map_comp, biproduct.matrix_\u03c0],\n  simp_rw [comp_zsmul, category.comp_id, \u2190 functor.map_zsmul, \u2190 functor.map_sum],\n  congr' 1,\n  apply biproduct.hom_ext', intros k,\n  rw [biproduct.\u03b9_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.\u03b9_\u03c0,\n    rw [dif_neg hb.symm, zsmul_zero] }\nend\n\nlemma eval_freeCond'_iso_component_aux_i (M : Condensed.{u} Ab.{u+1}) (i : \u2115) :\n(eval_freeCond'_iso.component_neg BD M (i+1)).hom \u226b\n    ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up \u2124)).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] \u226b\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 \u2190 presheaf_to_Condensed_Ab.map_comp,\n  erw \u2190 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 [\u2190 functor.map_comp],\n  congr' 1, simp only [\u2190 nat_trans.comp_app], congr' 1,\n  apply biproduct.hom_ext, intros j,\n  simp only [category.assoc, biproduct.matrix_\u03c0, biproduct.lift_\u03c0],\n  dsimp only [functor.map_bicone],\n  rw biproduct.lift_desc,\n  erw [\u2190 Condensed_Ab_to_presheaf.map_comp, biproduct.matrix_\u03c0],\n  simp_rw [comp_zsmul, category.comp_id, \u2190 functor.map_zsmul, \u2190 functor.map_sum],\n  congr' 1,\n  apply biproduct.hom_ext', intros k,\n  rw [biproduct.\u03b9_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.\u03b9_\u03c0,\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) \u2245\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(\u03bb 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)) \u27e8rfl\u27e9,\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\u2080 },\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 _ \u226b (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 : \u2115) :\n  (eval_freeCond'_iso_component BD M).hom.f (-[1+i]) =\n  begin\n    refine presheaf_to_Condensed_Ab.map _,\n    refine _ \u226b (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}\u1d52\u1d56 Ab.{u+1}).obj\n  (op S.val)).map_homological_complex (complex_shape.up \u2124)).obj\n  ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).X (int.of_nat 0) \u2245\n  ((BD.eval' (forget AddCommGroup \u22d9 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}\u1d52\u1d56 Ab.{u+1}).obj (op S.val)).map_biproduct _\nend\n\ndef component_pos (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) (i : \u2115) :\n  ((((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj\n    (op S.val)).map_homological_complex (complex_shape.up \u2124)).obj\n    ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).X\n    (int.of_nat (i + 1)) \u2245\n  ((BD.eval' (forget AddCommGroup \u22d9 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 : \u2115) :\n  ((((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj (op S.val)).map_homological_complex\n    (complex_shape.up \u2124)).obj\n    ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).X -[1+ i] \u2245\n  ((BD.eval' (forget AddCommGroup \u22d9 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}\u1d52\u1d56 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\u2080 (M : Condensed.{u} Ab.{u+1}) (S : ExtrDisc.{u}) :\n  (eval_freeAb_iso.component_neg BD M S 0).hom \u226b\n    ((BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free)).obj (M.val.obj (op S.val))).d\n      -[1+ 0] (int.of_nat 0) =\n  ((((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj (op S.val)).map_homological_complex\n    (complex_shape.up \u2124)).obj\n      ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).d -[1+ 0] (int.of_nat 0) \u226b\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, \u2190 functor.map_comp], congr' 3,\n  apply biproduct.hom_ext, intros j,\n  simp only [category.assoc, biproduct.lift_\u03c0, biproduct.matrix_\u03c0, biproduct.lift_desc],\n  erw biproduct.lift_\u03c0,\n  rw [\u2190 nat_trans.comp_app, biproduct.matrix_\u03c0],\n  simp_rw [\u2190 nat_trans.id_app, \u2190 nat_trans.app_zsmul, \u2190 nat_trans.comp_app,\n    \u2190 nat_trans.app_sum], congr' 1,\n  apply biproduct.hom_ext', intro k, simp only [comp_sum, biproduct.\u03b9_desc],\n  rw [finset.sum_eq_single_of_mem k (finset.mem_univ _),\n  biproduct.\u03b9_\u03c0_assoc, dif_pos rfl],\n  { simpa, },\n  { rintros b - hb, rw [biproduct.\u03b9_\u03c0_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 : \u2115) :\n  (eval_freeAb_iso.component_neg BD M S (i+1)).hom \u226b\n    ((BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free)).obj\n    (M.val.obj (op S.val))).d -[1+ (i+1)] -[1+ i] =\n  ((((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj\n    (op S.val)).map_homological_complex (complex_shape.up \u2124)).obj\n       ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))).d -[1+ (i+1)] -[1+ i] \u226b\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, \u2190 functor.map_comp], congr' 3,\n  apply biproduct.hom_ext, intros j,\n  simp only [category.assoc, biproduct.lift_\u03c0, biproduct.matrix_\u03c0, biproduct.lift_desc],\n  erw biproduct.lift_\u03c0,\n  rw [\u2190 nat_trans.comp_app, biproduct.matrix_\u03c0],\n  simp_rw [\u2190 nat_trans.id_app, \u2190 nat_trans.app_zsmul, \u2190 nat_trans.comp_app,\n    \u2190 nat_trans.app_sum], congr' 1,\n  apply biproduct.hom_ext', intro k, simp only [comp_sum, biproduct.\u03b9_desc],\n  rw [finset.sum_eq_single_of_mem k (finset.mem_univ _),\n  biproduct.\u03b9_\u03c0_assoc, dif_pos rfl],\n  { simpa, },\n  { rintros b - hb, rw [biproduct.\u03b9_\u03c0_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}\u1d52\u1d56 Ab.{u+1}).obj (op S.val)).map_homological_complex\n    (complex_shape.up \u2124)).obj\n  ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M)) \u2245\n  (BD.eval' $ category_theory.forget _ \u22d9 AddCommGroup.free).obj (M.val.obj (op S.val)) :=\nhomological_complex.hom.iso_of_components\n(\u03bb 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)) \u27e8rfl\u27e9,\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\u2080 },\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 : \u2115) :\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 \u27f6 Y) :\n  ((BD.eval' freeCond').map f \u226b (eval_freeCond'_iso_component BD Y).hom).f (int.of_nat 0) =\n  ((eval_freeCond'_iso_component BD X).hom \u226b\n     (Condensed_Ab_to_presheaf \u22d9\n        BD.eval' freeFunc \u22d9 presheaf_to_Condensed_Ab.map_homological_complex\n        (complex_shape.up \u2124)).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 \u2190 presheaf_to_Condensed_Ab.map_comp,\n  erw \u2190 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, \u2190 functor.map_comp],\n  congr' 2,\n  simp_rw \u2190 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_\u03c0, biproduct.lift_\u03c0_assoc, biproduct.lift_\u03c0],\n  erw [\u2190 Condensed_Ab_to_presheaf.map_comp, \u2190 Condensed_Ab_to_presheaf.map_comp,\n    biproduct.map_\u03c0],\nend\n\n.\n\nlemma eval_freeAb_iso_component_naturality (M : Condensed.{u} Ab.{u+1}) (S T : ExtrDisc.{u})\n  (f : S \u27f6 T) :\n  (eval_freeAb_iso_component BD M T).hom \u226b\n  (BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free)).map\n    (M.val.map (ExtrDisc_to_Profinite.map f).op) =\n  (nat_trans.map_homological_complex ((category_theory.evaluation Profinite\u1d52\u1d56 Ab).map f.val.op)\n  (complex_shape.up \u2124)).app ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M))\n    \u226b (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 _) \u226b AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) =\n      AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) \u226b AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _),\n    simp only [\u2190 functor.map_comp], congr' 2,\n    apply biproduct.hom_ext, rintro \u27e8j\u27e9,\n    dsimp [functor.map_bicone],\n    simp only [category.assoc],\n    erw biproduct.lift_\u03c0,\n    erw biproduct.map_\u03c0,\n    erw biproduct.lift_\u03c0_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 _) \u226b AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) =\n      AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) \u226b AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _),\n    simp only [\u2190 functor.map_comp], congr' 2,\n    apply biproduct.hom_ext, rintro \u27e8j\u27e9,\n    dsimp [functor.map_bicone],\n    simp only [category.assoc],\n    erw biproduct.lift_\u03c0,\n    erw biproduct.map_\u03c0,\n    erw biproduct.lift_\u03c0_assoc,\n    simp only [nat_trans.naturality],\n    refl },\nend\n\nlemma eval_freeCond'_iso_aux_neg\n  (X Y : Condensed Ab) (f : X \u27f6 Y) (i : \u2115) :\n  ((BD.eval' freeCond').map f \u226b (eval_freeCond'_iso_component BD Y).hom).f (-[1+i]) =\n  ((eval_freeCond'_iso_component BD X).hom \u226b\n     (Condensed_Ab_to_presheaf \u22d9\n        BD.eval' freeFunc \u22d9 presheaf_to_Condensed_Ab.map_homological_complex\n        (complex_shape.up \u2124)).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 \u2190 presheaf_to_Condensed_Ab.map_comp,\n  erw \u2190 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, \u2190 functor.map_comp],\n  congr' 2,\n  simp_rw \u2190 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_\u03c0, biproduct.lift_\u03c0_assoc, biproduct.lift_\u03c0],\n  erw [\u2190 Condensed_Ab_to_presheaf.map_comp, \u2190 Condensed_Ab_to_presheaf.map_comp,\n    biproduct.map_\u03c0],\nend\n\ndef eval_freeCond'_iso :\n  BD.eval' freeCond' \u2245\n  Condensed_Ab_to_presheaf \u22d9 BD.eval' freeFunc \u22d9 presheaf_to_Condensed_Ab.map_homological_complex _ :=\nnat_iso.of_components\n(\u03bb 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 \u22d9 BD.eval' freeFunc \u22d9\n  ((category_theory.evaluation _ _).obj (op S.val)).map_homological_complex _ \u2245\n  evaluation _ S.val \u22d9 BD.eval' (category_theory.forget _ \u22d9 AddCommGroup.free) :=\nnat_iso.of_components\n(\u03bb 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 _) \u226b AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) =\n      AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) \u226b AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _),\n    simp only [\u2190 functor.map_comp], congr' 2,\n    apply biproduct.hom_ext, intros j,\n    dsimp [functor.map_bicone],\n    simp only [category.assoc, biproduct.map_\u03c0, biproduct.lift_\u03c0],\n    erw biproduct.lift_\u03c0_assoc,\n    erw biproduct.lift_\u03c0,\n    simp_rw [\u2190 nat_trans.comp_app, biproduct.map_\u03c0],\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 _) \u226b AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) =\n      AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _) \u226b AddCommGroup.free.map ((category_theory.forget Ab.{u+1}).map _),\n    simp only [\u2190 functor.map_comp], congr' 2,\n    apply biproduct.hom_ext, intros j,\n    dsimp [functor.map_bicone],\n    simp only [category.assoc, biproduct.map_\u03c0, biproduct.lift_\u03c0],\n    erw biproduct.lift_\u03c0_assoc,\n    erw biproduct.lift_\u03c0,\n    simp_rw [\u2190 nat_trans.comp_app, biproduct.map_\u03c0],\n    refl },\nend\n\n-- Move this.\ndef point {A : Type u} (a : A) : punit.{u+1} \u27f6 A := \u03bb _, a\n\ndef tensor_to_unsheafified_homology_component_applied\n  (M : Condensed.{u} Ab.{u+1}) (i : \u2124) (S : ExtrDisc.{u}) (m : M.val.obj (op S.val)) :\n  ((BD.eval (forget AddCommGroup \u22d9 AddCommGroup.free)).obj\n    (AddCommGroup.free.obj punit)).val.as.homology i \u27f6\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 \u22d9 AddCommGroup.free)).map\n      ((AddCommGroup.adj.hom_equiv _ _).symm (point m))) \u226b\n      (homology_functor _ _ _).map (eval_freeAb_iso_component _ _ _).inv \u226b\n    (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 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 : \u2124)\n  (S : ExtrDisc.{u}) :\n  M.val.obj (op S.val) \u27f6\n  AddCommGroup.of\n    (((BD.eval (forget AddCommGroup \u22d9 AddCommGroup.free)).obj\n      (AddCommGroup.free.obj punit)).val.as.homology i \u27f6\n    (homological_complex.homology ((BD.eval' freeFunc).obj\n      (Condensed_Ab_to_presheaf.obj M)) i).obj (op S.val)) :=\nadd_monoid_hom.mk' (\u03bb m, tensor_to_unsheafified_homology_component_applied _ _ _ _ m)\nbegin\n  intros x y, rcases i with ((_|i)|i),\n  { erw [\u2190 add_comp, \u2190 functor.map_add, \u2190 functor.map_add], apply congr_arg2 _ _ rfl, congr' 2,\n    dsimp only [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv],\n    ext \u27e8\u27e9, 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 [\u2190 add_comp, \u2190 functor.map_add, \u2190 functor.map_add], apply congr_arg2 _ _ rfl, congr' 2,\n    dsimp only [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv],\n    ext \u27e8\u27e9, 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 : \u2124) (S T : ExtrDisc\u1d52\u1d56)\n  (f : S \u27f6 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) \u226b\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 [\u2190 nat_iso.app_inv, \u2190 category.assoc, iso.comp_inv_eq],\n  simp only [category.assoc],\n  have := functor.naturality_homology_functor_iso\n    ((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).map (ExtrDisc_to_Profinite.op.map f))\n    (complex_shape.up \u2124) i,\n  apply_fun (\u03bb 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 [\u2190 nat_iso.app_inv, \u2190 nat_iso.app_hom, iso.inv_hom_id_assoc],\n  clear this,\n  rw [\u2190 functor.map_iso_inv, \u2190 category.assoc, iso.comp_inv_eq, category.assoc, category.assoc],\n  dsimp [-homology_functor_map], simp only [\u2190 functor.map_comp],\n  rw [\u2190 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)) \u226b\n    (M.val.map (ExtrDisc_to_Profinite.map f.unop).op),\n  { ext \u27e8\u27e9,\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 : \u2124) :\n  (((Condensed_ExtrSheaf_equiv Ab).inverse.obj M).tensor\n    (((BD.eval (forget AddCommGroup \u22d9 AddCommGroup.free)).obj\n    (AddCommGroup.free.obj punit)).val.as.homology i)).val \u27f6\n  ExtrDisc_to_Profinite.op \u22d9 homological_complex.homology\n    ((BD.eval' freeFunc).obj (Condensed_Ab_to_presheaf.obj M)) i :=\n{ app := \u03bb S, AddCommGroup.tensor_uncurry $\n    tensor_to_unsheafified_homology_component _ _ _ _,\n  naturality' := \u03bb 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, \u2190 comp_apply], congr' 1,\n    apply tensor_to_unsheafified_homology_natural,\n  end }\n\ndef plain_eval_comparison_component (i : \u2124) (A : AddCommGroup.{u+1}) :\n  A \u27f6 AddCommGroup.of\n  ((homotopy_category.homology_functor _ _ i).obj\n    ((BD.eval (forget AddCommGroup \u22d9 AddCommGroup.free)).obj (AddCommGroup.free.obj punit)).val \u27f6\n    (homotopy_category.homology_functor _ _ i).obj\n    ((BD.eval (category_theory.forget AddCommGroup \u22d9 AddCommGroup.free)).obj A).val) :=\nadd_monoid_hom.mk' (\u03bb a, (homotopy_category.homology_functor _ _ _).map $ (BD.eval _).map $\n  (AddCommGroup.adj.hom_equiv _ _).symm (point a))\nbegin\n  intros x y, rw [\u2190 functor.map_add, \u2190 functor.map_add], congr' 2,\n  dsimp only [AddCommGroup.adj, adjunction.mk_of_hom_equiv_hom_equiv],\n  ext \u27e8\u27e9, 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 : \u2124) (A B : AddCommGroup.{u+1}) (f : A \u27f6 B) (x) :\n  ((plain_eval_comparison_component BD i B) (f x)) =\n  ((plain_eval_comparison_component BD i A) x) \u226b\n  (homotopy_category.homology_functor AddCommGroup (complex_shape.up \u2124) i).map\n    ((BD.eval (forget AddCommGroup \u22d9 AddCommGroup.free)).map f) :=\nbegin\n  dsimp only [plain_eval_comparison_component, add_monoid_hom.mk'_apply, functor.comp_map],\n  rw [\u2190 functor.map_comp], congr' 1,\n  erw [\u2190 (BD.eval (forget AddCommGroup \u22d9 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 \u27e8\u27e9,\n  simp only [free_abelian_group.lift.of, comp_apply],\n  refl,\nend\n\nlemma plain_eval_comparison_natural' (i : \u2124) (A B : AddCommGroup.{u+1}) (f : A \u27f6 B) :\n  (AddCommGroup.tensor_functor.flip.obj\n       (homological_complex.homology\n          ((BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free)).obj (AddCommGroup.free.obj punit)) i)).map f \u226b\n    AddCommGroup.tensor_uncurry (plain_eval_comparison_component BD i B) =\n  AddCommGroup.tensor_uncurry (plain_eval_comparison_component BD i A) \u226b\n    (BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free) \u22d9\n       homology_functor AddCommGroup (complex_shape.up \u2124) 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 : \u2124) :\n  AddCommGroup.tensor_functor.flip.obj\n  (((BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free)).obj\n    (AddCommGroup.free.obj punit)).homology i) \u27f6\n  BD.eval' (forget AddCommGroup \u22d9 AddCommGroup.free) \u22d9 homology_functor _ _ i :=\n{ app := \u03bb A, AddCommGroup.tensor_uncurry $ plain_eval_comparison_component _ _ _,\n  naturality' := \u03bb 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 : \u2124) (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)) \u226b\n  (homology_functor _ _ _).map\n  ((eval_freeAb_iso_component _ _ _).inv) \u226b\n  (((category_theory.evaluation Profinite.{u}\u1d52\u1d56 Ab.{u+1}).obj\n    (op S.val)).homology_functor_iso _ _).inv.app _  :=\nbegin\n  rw [\u2190 nat_iso.app_inv, \u2190 category.assoc, iso.eq_comp_inv, \u2190 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 [\u2190 comp_apply, category.assoc],\n  dsimp only [\u2190 nat_iso.app_inv, \u2190 nat_iso.app_hom],\n  simp only [iso.inv_hom_id_assoc],\n  congr' 2,\n  simp only [\u2190 category.assoc],\n  congr' 1,\n  simp only [category.assoc, iso.inv_hom_id, category.comp_id,\n    \u2190 functor.map_iso_hom, \u2190 functor.map_iso_inv],\nend\n\ndef tensor_to_homology_aux (M : Condensed.{u} Ab.{u+1}) (i : \u2124) :\n((Condensed_ExtrSheaf_equiv Ab).inverse.obj M).tensor\n  (((BD.eval (forget AddCommGroup \u22d9 AddCommGroup.free)).obj\n  (AddCommGroup.free.obj punit)).val.as.homology i) \u27f6\n  (presheaf_to_Sheaf ExtrDisc.proetale_topology Ab).obj\n  (ExtrDisc_to_Profinite.op \u22d9\n     homological_complex.homology ((BD.eval' freeFunc).obj\n     (Condensed_Ab_to_presheaf.obj M)) i) := Sheaf.hom.mk $\ntensor_to_unsheafified_homology _ _ _ \u226b grothendieck_topology.to_sheafify _ _\n\ndef tensor_to_homology (M : Condensed.{u} Ab.{u+1}) (i : \u2124) :\n  (tensor M $ ((BD.eval $\n    category_theory.forget AddCommGroup \u22d9 AddCommGroup.free).obj\n    (AddCommGroup.free.obj punit)).val.as.homology i) \u27f6\n  ((BD.eval freeCond').obj M).val.as.homology i :=\n(Condensed_ExtrSheaf_equiv Ab).functor.map\n  (tensor_to_homology_aux _ _ _ \u226b ExtrDisc_sheafification_iso.hom.app _)\n\u226b ((Condensed_ExtrSheaf_equiv _).counit_iso.app _).hom\n\u226b (homology_functor_sheafification_iso _ _).hom.app _\n\u226b (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 : \u2124) :\n  preserves_filtered_colimits\n  (AddCommGroup.tensor_functor.flip.obj (homological_complex.homology\n    ((BD.eval' (forget AddCommGroup.{u+1} \u22d9 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' := \u03bb 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 [\u2190 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 : \u2124) : functor.additive\n  (AddCommGroup.tensor_functor.flip.obj (homological_complex.homology\n    ((BD.eval' (forget AddCommGroup.{u+1} \u22d9 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} \u22d9 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 : \u2124) :\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} \u2124) i) :=\n\u27e8\u03bb J, begin\n  introI,\n  introI,\n  constructor,\n  intro K,\n  apply_instance,\nend\u27e9\n\ninstance preserves_filtered_colimits_eval'_forget_free_homology (i : \u2124) :\n  preserves_filtered_colimits\n  (BD.eval' (forget AddCommGroup.{u+1} \u22d9 AddCommGroup.free) \u22d9\n    homology_functor AddCommGroup.{u+1} (complex_shape.up \u2124) i) :=\nlimits.comp_preserves_filtered_colimits.{u+1 u+2 _ u+2}\n  (BD.eval' (forget AddCommGroup.{u+1} \u22d9 AddCommGroup.free))\n  (homology_functor AddCommGroup.{u+1} (complex_shape.up \u2124) i)\n\ninstance _root_.bounded_homotopy_category.forget_additive (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0] :\n  (bounded_homotopy_category.forget \ud835\udcd0).additive :=\n{ map_add' := \u03bb X Y f g, rfl }\n\ninstance additive_eval'_forget_free (i : \u2124) : functor.additive\n  (BD.eval' (forget AddCommGroup.{u+1} \u22d9 AddCommGroup.free) \u22d9\n    homology_functor AddCommGroup.{u+1} (complex_shape.up \u2124) i) :=\nbegin\n  show functor.additive (\n    (BD.eval (forget AddCommGroup.{u+1} \u22d9 AddCommGroup.free) \u22d9 bounded_homotopy_category.forget _) \u22d9\n      homotopy_category.homology_functor _ _ i),\n  exact functor.comp.additive (package.eval BD (forget AddCommGroup \u22d9 AddCommGroup.free) \u22d9 forget AddCommGroup)\n  (homotopy_category.homology_functor AddCommGroup (complex_shape.up \u2124) i)\nend\n.\n\nlemma coeff_star_smul (x : free_abelian_group.{u} punit) :\n  free_abelian_group.coeff punit.star x \u2022 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 \u27e8\u27e9, simp only [map_zsmul, free_abelian_group.coeff_of_self, smul_assoc, one_smul], },\n  { rintro x n hn \u27e8\u27e9 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) \u2022 \ud835\udfd9 _ :=\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 \u27e8\u27e9,\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 {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0] [enough_projectives \ud835\udcd0]\n  (X : bounded_homotopy_category \ud835\udcd0) (i : \u2124) :\n  (homotopy_category.homology_functor _ (complex_shape.up \u2124) i).map (\ud835\udfd9 X : _) =\n    \ud835\udfd9 ((homotopy_category.homology_functor _ (complex_shape.up \u2124) 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' (\u03bb (a : (AddCommGroup.free.obj punit)),\n     (free_abelian_group.coeff punit.star) a \u2022 \ud835\udfd9 A) $ by intros; simp only [map_add, add_smul]) :=\nbegin\n  constructor,\n  refine \u27e8add_monoid_hom.mk' (\u03bb a, free_abelian_group.of punit.star \u2297\u209c a) _, _, _\u27e9,\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 [\u2190 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 : \u2124) : 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 \u27e8\u27e9, exact h },\n  intros b, refine \u27e8free_abelian_group.lift (point b), _\u27e9,\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 : \u2124)\n  [\u2200 S : ExtrDisc.{u}, no_zero_smul_divisors \u2124 (M.val.obj (op S.val))] :\n  is_iso (tensor_to_homology_aux BD M i) :=\nbegin\n  suffices : \u2200 (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 : \u2124)\n  [\u2200 S : ExtrDisc.{u}, no_zero_smul_divisors \u2124 (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  [\u2200 S : ExtrDisc.{u}, no_zero_smul_divisors \u2124 (M.val.obj (op S.val))] (i : \u2124) :\n  ((BD.eval freeCond').obj M).val.as.homology i \u2245\n  (tensor M $ ((BD.eval $\n    category_theory.forget AddCommGroup \u22d9 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 \u27f6 N)\n\nset_option pp.universes false\n\n@[simp] lemma embed_f_0 {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {X Y : chain_complex \ud835\udcd0 \u2115} (f : X \u27f6 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 {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {X Y : chain_complex \ud835\udcd0 \u2115} (f : X \u27f6 Y) (n : \u2115) :\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 \u226b ((BD.eval' freeCond').map f).f 0 =\n  ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up \u2124)).map\n    ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))).f 0 \u226b\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 [\u2190 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 [\u2190 functor.map_comp], congr' 1,\n  simp only [\u2190 nat_trans.comp_app], congr' 1,\n  apply biproduct.hom_ext', intros j,\n  simp only [category.assoc, biproduct.\u03b9_desc_assoc, biproduct.\u03b9_desc,\n    biproduct.\u03b9_map_assoc],\n  dsimp only [functor.map_bicone, Condensed_Ab_to_presheaf, \u2190 Sheaf_to_presheaf_map],\n  simp only [\u2190 functor.map_comp], congr' 1,\n  erw biproduct.\u03b9_map,\nend\n\nlemma eval_freeCond'_iso_component_neg_natural (n : \u2115) :\n  (eval_freeCond'_iso.component_neg BD M n).inv \u226b ((BD.eval' freeCond').map f).f (-[1+ n]) =\n  ((presheaf_to_Condensed_Ab.map_homological_complex (complex_shape.up \u2124)).map\n    ((BD.eval' freeFunc).map (Condensed_Ab_to_presheaf.map f))).f -[1+ n] \u226b\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 [\u2190 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 [\u2190 functor.map_comp], congr' 1,\n  simp only [\u2190 nat_trans.comp_app], congr' 1,\n  apply biproduct.hom_ext', intros j,\n  simp only [category.assoc, biproduct.\u03b9_desc_assoc, biproduct.\u03b9_desc,\n    biproduct.\u03b9_map_assoc],\n  dsimp only [functor.map_bicone, Condensed_Ab_to_presheaf, \u2190 Sheaf_to_presheaf_map],\n  simp only [\u2190 functor.map_comp], congr' 1,\n  erw biproduct.\u03b9_map,\nend\n\nlemma eval_freeCond'_iso_component_natural :\n  (eval_freeCond'_iso_component.{u} BD M).inv \u226b (BD.eval' freeCond'.{u}).map f =\n  (presheaf_to_Condensed_Ab.{u}.map_homological_complex (complex_shape.up.{0} \u2124)).map\n    ((BD.eval' freeFunc.{u u+1}).map (Condensed_Ab_to_presheaf.{u}.map f)) \u226b\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) : (\ud835\udfd9 X : X \u2192 X) = id := rfl\n@[simp] lemma coe_comp {A B C : CompHaus} (f : A \u27f6 B) (g : B \u27f6 C) :\n  (f \u226b g : A \u2192 C) = g \u2218 f := rfl\n\nlemma coe_id_apply {X : CompHaus} (x : X) : (\ud835\udfd9 X : X \u2192 X) x = x := by simp\nlemma coe_comp_apply {X Y Z : CompHaus} (f : X \u27f6 Y) (g : Y \u27f6 Z) (x : X) :\n  (f \u226b 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)\u1d52\u1d56 \u2964 (opens X)\u1d52\u1d56` and the functor `F : (opens X)\u1d52\u1d56 \u2964 C`.\nFor an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) \u27f6 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 \u27f6 Y` between\ntopological spaces, we define `stalk_pushforward` as the induced map on the stalks\n`(f _* \u2131).stalk (f x) \u27f6 \u2131.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 \u2964 C :=\n((whiskering_left _ _ C).obj (open_nhds.inclusion x).op) \u22d9 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 \u2964 opens F.X \u2964 C\n-/\ndef stalk (\u2131 : X.presheaf C) (x : X) : C :=\n(stalk_functor C x).obj \u2131 -- -- colimit ((open_nhds.inclusion x).op \u22d9 \u2131)\n\n@[simp] lemma stalk_functor_obj (\u2131 : X.presheaf C) (x : X) :\n  (stalk_functor C x).obj \u2131 = \u2131.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) \u27f6 stalk F x :=\ncolimit.\u03b9 ((open_nhds.inclusion x.1).op \u22d9 F) (op \u27e8U, x.2\u27e9)\n\n@[simp, elementwise]\nlemma germ_res (F : X.presheaf C) {U V : opens X} (i : U \u27f6 V) (x : U) :\n  F.map i.op \u226b germ F x = germ F (i x : V) :=\nlet i' : (\u27e8U, x.2\u27e9 : open_nhds x.1) \u27f6 \u27e8V, (i x : V).2\u27e9 := i in\ncolimit.w ((open_nhds.inclusion x.1).op \u22d9 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\u2081 f\u2082 : F.stalk x \u27f6 Y}\n  (ih : \u2200 (U : opens X) (hxU : x \u2208 U), F.germ \u27e8x, hxU\u27e9 \u226b f\u2081 = F.germ \u27e8x, hxU\u27e9 \u226b f\u2082) : f\u2081 = f\u2082 :=\ncolimit.hom_ext $ \u03bb 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 \u27f6 G) : germ F x \u226b (stalk_functor C x.1).map f = f.app (op U) \u226b germ G x :=\ncolimit.\u03b9_map (whisker_left ((open_nhds.inclusion x.1).op) f) (op \u27e8U, x.2\u27e9)\n\nvariables (C)\n\n/--\nFor a presheaf `F` on a space `X`, a continuous map `f : X \u27f6 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 \u27f6 Y) (F : X.presheaf C) (x : X) : (f _* F).stalk (f x) \u27f6 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 \u27f6 Y) (F : X.presheaf C) (U : opens Y)\n  (x : (opens.map f).obj U) :\n  (f _* F).germ \u27e8f x, x.2\u27e9 \u226b F.stalk_pushforward C f x = F.germ x :=\nbegin\n  rw [stalk_pushforward, germ, colimit.\u03b9_map_assoc, colimit.\u03b9_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-- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240>\n-- However, I can't get the subsequent two proofs to work with either one.\n\n-- def stalk_pushforward (f : X \u27f6 Y) (\u2131 : X.presheaf C) (x : X) :\n--   (f _* \u2131).stalk (f x) \u27f6 \u2131.stalk x :=\n-- colim.map ((functor.associator _ _ _).inv \u226b\n--   whisker_right (nat_trans.op (open_nhds.inclusion_map_iso f x).inv) \u2131) \u226b\n-- colimit.pre ((open_nhds.inclusion x).op \u22d9 \u2131) (open_nhds.map f x).op\n\n-- def stalk_pushforward (f : X \u27f6 Y) (\u2131 : X.presheaf C) (x : X) :\n--   (f _* \u2131).stalk (f x) \u27f6 \u2131.stalk x :=\n-- (colim.map (whisker_right (nat_trans.op (open_nhds.inclusion_map_iso f x).inv) \u2131) :\n--   colim.obj ((open_nhds.inclusion (f x) \u22d9 opens.map f).op \u22d9 \u2131) \u27f6 _) \u226b\n-- colimit.pre ((open_nhds.inclusion x).op \u22d9 \u2131) (open_nhds.map f x).op\n\nnamespace stalk_pushforward\nlocal attribute [tidy] tactic.op_induction'\n\n@[simp] lemma id (\u2131 : X.presheaf C) (x : X) :\n  \u2131.stalk_pushforward C (\ud835\udfd9 X) x = (stalk_functor C x).map ((pushforward.id \u2131).hom) :=\nbegin\n  dsimp [stalk_pushforward, stalk_functor],\n  ext1,\n  tactic.op_induction',\n  rcases j with \u27e8\u27e8_, _\u27e9, _\u27e9,\n  rw [colimit.\u03b9_map_assoc, colimit.\u03b9_map, colimit.\u03b9_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 (\u2131 : X.presheaf C) (f : X \u27f6 Y) (g : Y \u27f6 Z) (x : X) :\n  \u2131.stalk_pushforward C (f \u226b g) x =\n  ((f _* \u2131).stalk_pushforward C g (f x)) \u226b (\u2131.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 \u27e8\u27e8_, _\u27e9, _\u27e9,\n  simp only [colimit.\u03b9_map_assoc, colimit.\u03b9_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.\u03b9_pre, colimit.\u03b9_pre],\n  refl,\nend\n\nlemma stalk_pushforward_iso_of_open_embedding {f : X \u27f6 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 \u22d9 f _* F) : _).symm \u226a\u226b 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 [\u2190 F.map_comp, \u2190 F.map_comp], congr } },\n   { ext U,\n     rw \u2190 iso.comp_inv_eq,\n     erw colimit.\u03b9_map_assoc,\n     rw [colimit.\u03b9_pre, category.assoc],\n     erw [colimit.\u03b9_map_assoc, colimit.\u03b9_pre, \u2190 F.map_comp_assoc],\n     apply colimit.w ((open_nhds.inclusion (f x)).op \u22d9 f _* F) _,\n     dsimp only [functor.op],\n     refine ((hom_of_le _).op : op (unop U) \u27f6 _),\n     exact set.image_preimage_subset _ _ },\n end\n\nend stalk_pushforward\n\nsection stalk_pullback\n\n/-- The morphism `\u2131_{f x} \u27f6 (f\u207b\u00b9\u2131)\u2093` that factors through `(f_*f\u207b\u00b9\u2131)_{f x}`. -/\ndef stalk_pullback_hom (f : X \u27f6 Y) (F : Y.presheaf C) (x : X) :\n  F.stalk (f x) \u27f6 (pullback_obj f F).stalk x :=\n(stalk_functor _ (f x)).map ((pushforward_pullback_adjunction C f).unit.app F) \u226b\n  stalk_pushforward _ _ _ x\n\n/-- The morphism `(f\u207b\u00b9\u2131)(U) \u27f6 \u2131_{f(x)}` for some `U \u220b x`. -/\ndef germ_to_pullback_stalk (f : X \u27f6 Y) (F : Y.presheaf C) (U : opens X) (x : U) :\n  (pullback_obj f F).obj (op U) \u27f6 F.stalk (f x) :=\ncolimit.desc (Lan.diagram (opens.map f).op F (op U))\n{ X := F.stalk (f x),\n  \u03b9 := { app := \u03bb V, F.germ \u27e8f x, V.hom.unop.le x.2\u27e9,\n          naturality' := \u03bb _ _ i, by { erw category.comp_id, exact F.germ_res i.left.unop _ } } }\n\n/-- The morphism `(f\u207b\u00b9\u2131)\u2093 \u27f6 \u2131_{f(x)}`. -/\ndef stalk_pullback_inv (f : X \u27f6 Y) (F : Y.presheaf C) (x : X) :\n  (pullback_obj f F).stalk x \u27f6 F.stalk (f x) :=\ncolimit.desc ((open_nhds.inclusion x).op \u22d9 presheaf.pullback_obj f F)\n{ X := F.stalk (f x),\n  \u03b9 := { app := \u03bb U, F.germ_to_pullback_stalk _ f (unop U).1 \u27e8x, (unop U).2\u27e9,\n          naturality' := \u03bb _ _ _, by { erw [colimit.pre_desc, category.comp_id], congr } } }\n\n/-- The isomorphism `\u2131_{f(x)} \u2245 (f\u207b\u00b9\u2131)\u2093`. -/\ndef stalk_pullback_iso (f : X \u27f6 Y) (F : Y.presheaf C) (x : X) :\n  F.stalk (f x) \u2245 (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.\u03b9_map_assoc,\n      nat_trans.op_id, Lan_obj_map, pushforward_pullback_adjunction_unit_app_app, category.assoc,\n      colimit.\u03b9_pre_assoc],\n    erw [colimit.\u03b9_desc, colimit.pre_desc, colimit.\u03b9_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 \u27e8\u27e8\u27e9\u27e9,\n    erw [colimit.map_desc, colimit.map_desc, colimit.\u03b9_desc_assoc,\n      colimit.\u03b9_desc_assoc, colimit.\u03b9_desc, category.comp_id],\n    simp only [cocone.whisker_\u03b9, colimit.cocone_\u03b9, open_nhds.inclusion_map_iso_inv,\n      cocones.precompose_obj_\u03b9, 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 \u2190colimit.w _\n      (@hom_of_le (open_nhds x) _\n         \u27e8_, U_property\u27e9 \u27e8(opens.map f).obj (unop j_left), j_hom.unop.le U_property\u27e9\n         j_hom.unop.le).op,\n    erw colimit.\u03b9_pre_assoc (Lan.diagram _ F _) (costructured_arrow.map _),\n    erw colimit.\u03b9_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 \u27f6 F.stalk x`. -/\nnoncomputable\ndef stalk_specializes (F : X.presheaf C) {x y : X} (h : x \u2933 y) : F.stalk y \u27f6 F.stalk x :=\nbegin\n  refine colimit.desc _ \u27e8_,\u03bb U, _,_\u27e9,\n  { exact colimit.\u03b9 ((open_nhds.inclusion x).op \u22d9 F)\n      (op \u27e8(unop U).1, (specializes_iff_forall_open.mp h _ (unop U).1.2 (unop U).2 : _)\u27e9) },\n  { intros U V i,\n    dsimp,\n    rw category.comp_id,\n    let U' : open_nhds x := \u27e8_, (specializes_iff_forall_open.mp h _ (unop U).1.2 (unop U).2 : _)\u27e9,\n    let V' : open_nhds x := \u27e8_, (specializes_iff_forall_open.mp h _ (unop V).1.2 (unop V).2 : _)\u27e9,\n    exact colimit.w ((open_nhds.inclusion x).op \u22d9 F) (show V' \u27f6 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 \u2933 y) :\n  F.germ y \u226b F.stalk_specializes h =\n    F.germ (\u27e8x, h.mem_open U.is_open y.prop\u27e9 : U) := colimit.\u03b9_desc _ _\n\n@[simp, reassoc, elementwise]\nlemma germ_stalk_specializes' (F : X.presheaf C) {U : opens X} {x y : X} (h : x \u2933 y) (hy : y \u2208 U) :\n  F.germ \u27e8y, hy\u27e9 \u226b F.stalk_specializes h =\n    F.germ \u27e8x, h.mem_open U.is_open hy\u27e9 := colimit.\u03b9_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) = \ud835\udfd9 _ :=\nF.stalk_hom_ext $ \u03bb _ _, 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 \u2933 y) (h' : y \u2933 z) :\n  F.stalk_specializes h' \u226b F.stalk_specializes h = F.stalk_specializes (h.trans h') :=\nF.stalk_hom_ext $ \u03bb _ _, by simp\n\n@[simp, reassoc, elementwise]\nlemma stalk_specializes_stalk_functor_map {F G : X.presheaf C} (f : F \u27f6 G) {x y : X} (h : x \u2933 y) :\n  F.stalk_specializes h \u226b (stalk_functor C x).map f =\n    (stalk_functor C y).map f \u226b G.stalk_specializes h :=\nby { ext, delta stalk_functor, simpa [stalk_specializes] }\n\n@[simp, reassoc, elementwise]\nlemma stalk_specializes_stalk_pushforward (f : X \u27f6 Y) (F : X.presheaf C) {x y : X} (h : x \u2933 y) :\n  (f _* F).stalk_specializes (f.map_specializes h) \u226b F.stalk_pushforward _ f x =\n    F.stalk_pushforward _ f y \u226b 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 \u2245 F.stalk y :=\n\u27e8F.stalk_specializes e.ge, F.stalk_specializes e.le, by simp, by simp\u27e9\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 \u2208 U} {hxV : x \u2208 V}\n  (W : opens X) (hxW : x \u2208 W) (iWU : W \u27f6 U) (iWV : W \u27f6 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 \u27e8x, hxU\u27e9 sU = F.germ \u27e8x, hxV\u27e9 sV :=\nby erw [\u2190 F.germ_res iWU \u27e8x, hxW\u27e9,\n    \u2190 F.germ_res iWV \u27e8x, hxW\u27e9, 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  \u2203 (U : opens X) (m : x \u2208 U) (s : F.obj (op U)), F.germ \u27e8x, m\u27e9 s = t :=\nbegin\n  obtain \u27e8U, s, e\u27e9 := 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 \u27e8V, m, s, e\u27e9,\nend\n\nlemma germ_eq (F : X.presheaf C) {U V : opens X} (x : X) (mU : x \u2208 U) (mV : x \u2208 V)\n  (s : F.obj (op U)) (t : F.obj (op V))\n  (h : germ F \u27e8x, mU\u27e9 s = germ F \u27e8x, mV\u27e9 t) :\n  \u2203 (W : opens X) (m : x \u2208 W) (iU : W \u27f6 U) (iV : W \u27f6 V), F.map iU.op s = F.map iV.op t :=\nbegin\n  obtain \u27e8W, iU, iV, e\u27e9 := (types.filtered_colimit.is_colimit_eq_iff.{v v} _\n    (is_colimit_of_preserves _ (colimit.is_colimit ((open_nhds.inclusion x).op \u22d9 F)))).mp h,\n  exact \u27e8(unop W).1, (unop W).2, iU.unop, iV.unop, e\u27e9,\nend\n\nlemma stalk_functor_map_injective_of_app_injective {F G : presheaf C X} (f : F \u27f6 G)\n  (h : \u2200 U : opens X, function.injective (f.app (op U))) (x : X) :\n  function.injective ((stalk_functor C x).map f) := \u03bb s t hst,\nbegin\n  rcases germ_exist F x s with \u27e8U\u2081, hxU\u2081, s, rfl\u27e9,\n  rcases germ_exist F x t with \u27e8U\u2082, hxU\u2082, t, rfl\u27e9,\n  simp only [stalk_functor_map_germ_apply _ \u27e8x,_\u27e9] at hst,\n  obtain \u27e8W, hxW, iWU\u2081, iWU\u2082, heq\u27e9 := G.germ_eq x hxU\u2081 hxU\u2082 _ _ hst,\n  rw [\u2190 comp_apply, \u2190 comp_apply, \u2190 f.naturality, \u2190 f.naturality, comp_apply, comp_apply] at heq,\n  replace heq := h W heq,\n  convert congr_arg (F.germ \u27e8x,hxW\u27e9) heq,\n  exacts [(F.germ_res_apply iWU\u2081 \u27e8x,hxW\u27e9 s).symm,\n          (F.germ_res_apply iWU\u2082 \u27e8x,hxW\u27e9 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 : \u2200 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\u2081 i\u2082 heq using \u03bb 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\u2081,\n  { intros x hxU,\n    rw [opens.mem_supr],\n    exact \u27e8\u27e8x, hxU\u27e9, m \u27e8x, hxU\u27e9\u27e9 },\n  { intro x,\n    rw [heq, subsingleton.elim (i\u2081 x) (i\u2082 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 \u27f6 G) (U : opens X) (h : \u2200 x : U, function.injective ((stalk_functor C x.val).map f)) :\n  function.injective (f.app (op U)) :=\n\u03bb s t hst, section_ext F _ _ _ $ \u03bb 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 \u27f6 G) :\n  (\u2200 x : X, function.injective ((stalk_functor C x).map f)) \u2194\n  (\u2200 U : opens X, function.injective (f.app (op U))) :=\n\u27e8\u03bb h U, app_injective_of_stalk_functor_map_injective f U (\u03bb x, h x.1),\n  stalk_functor_map_injective_of_app_injective f\u27e9\n\ninstance stalk_functor_preserves_mono (x : X) :\n  functor.preserves_monomorphisms (sheaf.forget C X \u22d9 stalk_functor C x) :=\n\u27e8\u03bb \ud835\udcd0 \ud835\udcd1 f m, concrete_category.mono_of_injective _ $\n  (app_injective_iff_stalk_functor_map_injective f.1).mpr\n    (\u03bb 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\u27e9\n\nlemma stalk_mono_of_mono {F G : sheaf C X} (f : F \u27f6 G) [mono f] :\n  \u03a0 x, mono $ (stalk_functor C x).map f.1 :=\n\u03bb x, by convert functor.map_mono (sheaf.forget.{v} C X \u22d9 stalk_functor C x) f\n\nlemma mono_of_stalk_mono {F G : sheaf C X} (f : F \u27f6 G)\n  [\u03a0 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 $ \u03bb U,\n  (concrete_category.mono_iff_injective_of_preserves_pullback _).mpr $\n  app_injective_of_stalk_functor_map_injective f.1 U.unop $ \u03bb \u27e8x, hx\u27e9,\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 \u2264 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 \u27f6 G)\n  (U : opens X) (hinj : \u2200 x : U, function.injective ((stalk_functor C x.1).map f.1))\n  (hsurj : \u2200 (t) (x : U), \u2203 (V : opens X) (m : x.1 \u2208 V) (iVU : V \u27f6 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 \u2264 supr V,\n  { intros x hxU,\n    rw [opens.mem_supr],\n    exact \u27e8\u27e8x, hxU\u27e9, mV \u27e8x, hxU\u27e9\u27e9 },\n  -- Since `F` is a sheaf, we can glue all the local preimages together to get a global preimage.\n  obtain \u27e8s, s_spec, -\u27e9 := 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 [\u2190 comp_apply, \u2190 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 \u2293 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 \u27e8z, (iVU x).le ((inf_le_left : V x \u2293 V y \u2264 V x) z.2)\u27e9),\n    dsimp only,\n    erw [stalk_functor_map_germ_apply, stalk_functor_map_germ_apply],\n    simp_rw [\u2190 comp_apply, f.1.naturality, comp_apply, heq, \u2190 comp_apply, \u2190 G.1.map_comp],\n    refl }\nend\n\nlemma app_surjective_of_stalk_functor_map_bijective {F G : sheaf C X} (f : F \u27f6 G)\n  (U : opens X) (h : \u2200 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 (\u03bb x, (h x).1) (\u03bb 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\u2080` of the germ of `t` at `x`\n  obtain \u27e8s\u2080,hs\u2080\u27e9 := (h x).2 (G.presheaf.germ x t),\n  -- ... and this preimage must come from some section `s\u2081` defined on some open neighborhood `V\u2081`\n  obtain \u27e8V\u2081,hxV\u2081,s\u2081,hs\u2081\u27e9 := F.presheaf.germ_exist x.1 s\u2080,\n  subst hs\u2081, rename hs\u2080 hs\u2081,\n  erw stalk_functor_map_germ_apply V\u2081 \u27e8x.1,hxV\u2081\u27e9 f.1 s\u2081 at hs\u2081,\n  -- Now, the germ of `f.app (op V\u2081) s\u2081` equals the germ of `t`, hence they must coincide on\n  -- some open neighborhood `V\u2082`.\n  obtain \u27e8V\u2082, hxV\u2082, iV\u2082V\u2081, iV\u2082U, heq\u27e9 := G.presheaf.germ_eq x.1 hxV\u2081 x.2 _ _ hs\u2081,\n  -- The restriction of `s\u2081` to that neighborhood is our desired local preimage.\n  use [V\u2082, hxV\u2082, iV\u2082U, F.1.map iV\u2082V\u2081.op s\u2081],\n  rw [\u2190 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 \u27f6 G)\n   (U : opens X) (h : \u2200 x : U, function.bijective ((stalk_functor C x.val).map f.1)) :\n  function.bijective (f.1.app (op U)) :=\n\u27e8app_injective_of_stalk_functor_map_injective f.1 U (\u03bb x, (h x).1),\n  app_surjective_of_stalk_functor_map_bijective f U h\u27e9\n\nlemma app_is_iso_of_stalk_functor_map_iso {F G : sheaf C X} (f : F \u27f6 G) (U : opens X)\n  [\u2200 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 \u27f6 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 \u27f6 G)\n  [\u2200 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 : \u2200 U : (opens X)\u1d52\u1d56, 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 \u27f6 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 \u27f6 G) :\n  is_iso f \u2194 \u2200 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": "example (n? : Option Nat) : False := by\n  match h:n?, h':n? with\n  | some 0, _ => {}\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/matchUnknownFVarBug.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 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\u00f4hoku 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 : \u2115 \u2192 A \u2964 B)\n[additive : \u2200 n, functor.additive (F n)]\n(\u03b4 : \u03a0 (n : \u2115),\n  short_exact_sequence.Trd A \u22d9 (F n) \u27f6 short_exact_sequence.Fst A \u22d9 (F (n+1)))\n(mono : \u2200 (S : short_exact_sequence _), mono ((F 0).map S.f))\n(exact' : \u2200 (n : \u2115) (S : short_exact_sequence _), exact ((F n).map S.f) ((F n).map S.g))\n(exact_\u03b4 : \u2200 (n : \u2115) (S : short_exact_sequence _),\n  exact ((F n).map S.g) ((\u03b4 n).app S))\n(\u03b4_exact : \u2200 (n : \u2115) (S : short_exact_sequence _),\n  exact ((\u03b4 n).app S) ((F (n+1)).map S.f))\n\nnamespace delta_functor\n\ninfixr ` \u2964\u03b4 `:26 := delta_functor\n\ninstance : has_coe_to_fun (A \u2964\u03b4 B) (\u03bb F, \u2115 \u2192 (A \u2964 B)) := \u27e8F\u27e9\n\ninstance additive_apply (F : A \u2964\u03b4 B) (n : \u2115) :\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 \u2964\u03b4 B) :=\n(\u03b7 : \u03a0 n, F n \u27f6 G n)\n(comm' : \u2200 n, F.\u03b4 n \u226b whisker_left _ (\u03b7 _) = whisker_left _ (\u03b7 _) \u226b G.\u03b4 _)\n\ninstance : quiver (A \u2964\u03b4 B) :=\n{ hom := hom }\n\nnamespace hom\n\ninstance {F G : A \u2964\u03b4 B} : has_coe_to_fun (F \u27f6 G) (\u03bb \u03b7, \u03a0 n, F n \u27f6 G n) :=\n\u27e8\u03b7\u27e9\n\n@[ext]\nlemma ext {F G : A \u2964\u03b4 B} (\u03b7 \u03b3 : F \u27f6 G) (h : \u2200 n, \u03b7 n = \u03b3 n) : \u03b7 = \u03b3 :=\nby { cases \u03b7, cases \u03b3, congr, ext1, apply h }\n\n@[simp]\nlemma \u03b7_eq_coe {F G : A \u2964\u03b4 B} (\u03b7 : F \u27f6 G) (n : \u2115) :\n  \u03b7.\u03b7 n = \u03b7 n := rfl\n\n@[simp, reassoc]\nlemma comm {F G : A \u2964\u03b4 B} (\u03b7 : F \u27f6 G) (n : \u2115) (S : short_exact_sequence A) :\n  (F.\u03b4 n).app S \u226b (\u03b7 (n+1)).app S.fst =\n  (\u03b7 n).app S.trd \u226b (G.\u03b4 n).app S :=\nbegin\n  have := \u03b7.comm' n,\n  apply_fun (\u03bb e, e.app S) at this,\n  exact this,\nend\n\n/-- Identity morphisms of delta functors. -/\ndef id (F : A \u2964\u03b4 B) : F \u27f6 F :=\n\u27e8\u03bb n, \ud835\udfd9 _, begin\n  intros n,\n  ext, dsimp,\n  erw nat_trans.id_app,\n  erw nat_trans.id_app,\n  simp,\nend\u27e9\n\n@[simp]\nlemma id_apply (F : A \u2964\u03b4 B) (n : \u2115) :\n  id F n = \ud835\udfd9 _ := rfl\n\n/-- Compositions of morphisms of delta functors. -/\ndef comp {F G H : A \u2964\u03b4 B} (\u03b7 : F \u27f6 G) (\u03b3 : G \u27f6 H) :\n  hom F H :=\n{ \u03b7 := \u03bb n, \u03b7 n \u226b \u03b3 n,\n  comm' := begin\n    intros n, ext,\n    dsimp,\n    simp,\n  end }\n\n@[simp]\nlemma comp_apply {F G H : A \u2964\u03b4 B} (\u03b7 : F \u27f6 G) (\u03b3 : G \u27f6 H) (n : \u2115) :\n  (hom.comp \u03b7 \u03b3) n = \u03b7 n \u226b \u03b3 n := rfl\n\nend hom\n\n/-- delta functors form a category. -/\ninstance category : category (A \u2964\u03b4 B) :=\n{ id := \u03bb F, hom.id _,\n  comp := \u03bb 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 \u2964\u03b4 B)) }\n\n/-- Universal delta functors. -/\nclass universal (F : A \u2964\u03b4 B) : Prop :=\n(cond : \u2200 (G : A \u2964\u03b4 B) (e0 : F 0 \u27f6 G 0), \u2203! e : F \u27f6 G, (e : \u03a0 n, F n \u27f6 G n) 0 = e0)\n\nnamespace tohoku\n\n/-- An effacement relative to a \u03b4 functor. -/\n@[nolint has_inhabited_instance]\nstructure effacement (F : A \u2964\u03b4 B) (X : A) (n : \u2115) :=\n(I : A)\n(\u03b9 : X \u27f6 I)\n[mono : category_theory.mono \u03b9]\n(w : (F (n+1)).map \u03b9 = 0)\n\n/-- Morphisms between effacements. -/\n@[ext, nolint has_inhabited_instance]\nstructure effacement.hom (F : A \u2964\u03b4 B) (X : A) (n : \u2115)\n  (e\u2081 e\u2082 : effacement F X n) :=\n(t : e\u2081.I \u27f6 e\u2082.I)\n(w : e\u2081.\u03b9 \u226b t = e\u2082.\u03b9)\n\ninstance effacement.category (F : A \u2964\u03b4 B) (X : A) (n : \u2115) :\n  category (effacement F X n) :=\n{ hom := \u03bb e\u2081 e\u2082, e\u2081.hom _ _ _ e\u2082,\n  id := \u03bb e, \u27e8\ud835\udfd9 _, category.comp_id _\u27e9,\n  comp := \u03bb a b c f g, \u27e8f.t \u226b g.t, by simp [reassoc_of f.w, g.w]\u27e9,\n  id_comp' := \u03bb a b f, effacement.hom.ext _ _ $ category.id_comp _,\n  comp_id' := \u03bb a b f, effacement.hom.ext _ _ $ category.comp_id _,\n  assoc' := \u03bb a b c d f g h,\n    effacement.hom.ext _ _ $ category.assoc _ _ _ }\n\ninstance effacement_mono (F : A \u2964\u03b4 B) (X : A) (n : \u2115)\n  (e : effacement F X n) : category_theory.mono e.\u03b9 := e.mono\n\n/-- Effacable \u03b4 functors. -/\nclass effaceable (F : A \u2964\u03b4 B) : Prop :=\n(cond [] : \u2200 (X : A) (n : \u2115), nonempty (effacement F X n))\n\n/-- A choice of effacement. -/\ndef choose_effacement (F : A \u2964\u03b4 B) [effaceable F] (X : A) (n : \u2115) : 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 \u2964\u03b4 B} {X n} (e : effacement F X n) : short_exact_sequence A :=\n{ fst := X,\n  snd := e.I,\n  trd := limits.cokernel e.\u03b9,\n  f := e.\u03b9,\n  g := limits.cokernel.\u03c0 _,\n  exact' := abelian.exact_cokernel e.\u03b9 }\n\n/-- An auxiliary definition used to obtain the isomorphism below -/\ndef effacement.cokernel_comparison {F : A \u2964\u03b4 B} {X n} (e : effacement F X n) :\n  limits.cokernel ((F n).map (limits.cokernel.\u03c0 e.\u03b9)) \u27f6 (F (n+1)).obj X :=\nlimits.cokernel.desc _ ((F.\u03b4 n).app e.ses) (F.exact_\u03b4 n e.ses).w\n\nopen_locale zero_object\ninstance effacement.epi_cokernel_comparison {F : A \u2964\u03b4 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.\u03c0 _ \u226b t),\n  { resetI,\n    apply epi_of_epi (limits.cokernel.\u03c0 _) t },\n  simp only [limits.cokernel.\u03c0_desc],\n  have : exact ((F.\u03b4 n).app e.ses) ((F (n+1)).map e.\u03b9) :=\n    F.\u03b4_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 \u2964\u03b4 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.\u03c0 e.\u03b9)) ((F.\u03b4 n).app e.ses),\n  exact abelian.category_theory.limits.cokernel.desc.category_theory.mono\n    ((F n).map (limits.cokernel.\u03c0 e.\u03b9))\n    ((F.\u03b4 n).app (effacement.ses e)) this,\n  exact F.exact_\u03b4 n e.ses,\nend\n\ninstance effacement.is_iso_cokernel_comparison {F : A \u2964\u03b4 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 \u2964\u03b4 B} {X n} (e : effacement F X n) :\n  limits.cokernel ((F n).map (limits.cokernel.\u03c0 e.\u03b9)) \u2245 (F (n+1)).obj X :=\nas_iso e.cokernel_comparison\n\n@[simp, reassoc]\nlemma effacement.cokernel_iso_spec {F : A \u2964\u03b4 B} {X n} (e : effacement F X n) :\n  limits.cokernel.\u03c0 _ \u226b e.cokernel_iso.hom =\n  (F.\u03b4 n).app e.ses :=\nlimits.cokernel.\u03c0_desc _ _ _\n\n/-- An auxiliary definition used in `lift` below. -/\ndef effacement.lift_app_aux {F G : A \u2964\u03b4 B} {X n}\n  (\u03b7 : F n \u27f6 G n) (e : effacement F X n) :\n  (F (n+1)).obj X \u27f6 (G (n+1)).obj X :=\ne.cokernel_iso.inv \u226b\nlimits.cokernel.desc _\n(\u03b7.app _ \u226b (G.\u03b4 n).app e.ses)\nbegin\n  rw [\u2190 category.assoc, \u03b7.naturality, category.assoc],\n  erw (G.exact_\u03b4 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 \u2964\u03b4 B} {X n}\n  (e\u2081 e\u2082 : effacement F X n) (q : e\u2081 \u27f6 e\u2082) :\n  e\u2081.ses \u27f6 e\u2082.ses :=\n{ fst := \ud835\udfd9 _,\n  snd := q.t,\n  trd := begin\n    refine limits.cokernel.desc _ _ _,\n    refine _ \u226b limits.cokernel.\u03c0 _,\n    exact q.t,\n    rw [\u2190 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.\u03c0_desc,\n    refl,\n  end }\n\n\nlemma effacement.lift_app_aux_eq_of_hom\n  {F G : A \u2964\u03b4 B} {X n}\n  (\u03b7 : F n \u27f6 G n) (e\u2081 e\u2082 : effacement F X n) (q : e\u2081 \u27f6 e\u2082) :\n  e\u2081.lift_app_aux \u03b7 = e\u2082.lift_app_aux \u03b7 :=\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.\u03c0_desc, effacement.cokernel_iso_spec_assoc],\n  rw \u2190 category.assoc, let t := _, change _ = t \u226b _,\n  have ht : t = (F n).map (e\u2081.map_ses e\u2082 q).trd \u226b limits.cokernel.\u03c0 _,\n  { dsimp [t], rw iso.comp_inv_eq,\n    simp only [category.assoc, effacement.cokernel_iso_spec],\n    erw (F.\u03b4 n).naturality (e\u2081.map_ses e\u2082 q),\n    dsimp [effacement.map_ses],\n    simp },\n  rw ht, clear ht t,\n  simp only [category.assoc, limits.cokernel.\u03c0_desc],\n  erw [nat_trans.naturality_assoc],\n  congr' 1,\n  erw (G.\u03b4 n).naturality (e\u2081.map_ses e\u2082 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 \u2964\u03b4 B} {X n}\n  (\u03b7 : F n \u27f6 G n) (e\u2081 e\u2082 : effacement F X n) :\n  e\u2081.lift_app_aux \u03b7 = e\u2082.lift_app_aux \u03b7 :=\nbegin\n  let II := limits.biprod e\u2081.I e\u2082.I,\n  let \u03b9 : X \u27f6 II := limits.biprod.lift e\u2081.\u03b9 e\u2082.\u03b9,\n  let e : effacement F X n := \u27e8II, \u03b9, _\u27e9, -- 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\u2081.I \u229e e\u2082.I) \u2245 (F (n + 1)).obj (e\u2081.I) \u229e (F (n+1)).obj (e\u2082.I) :=\n      functor.map_biprod (F (n+1)) _ _,\n    rw [\u2190 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 [\u2190 functor.map_comp, limits.biprod.lift_fst, e\u2081.w] },\n    { simp only [category.assoc, limits.biprod.lift_snd, limits.zero_comp],\n      simp only [\u2190 functor.map_comp, limits.biprod.lift_snd, e\u2082.w] } },\n  let \u03c0\u2081 : e \u27f6 e\u2081 := \u27e8limits.biprod.fst, _\u27e9,\n  swap, { dsimp [e], simp, },\n  let \u03c0\u2082 : e \u27f6 e\u2082 := \u27e8limits.biprod.snd, _\u27e9,\n  swap, { dsimp [e], simp, },\n  rw \u2190 effacement.lift_app_aux_eq_of_hom \u03b7 _ _ \u03c0\u2081,\n  rw \u2190 effacement.lift_app_aux_eq_of_hom \u03b7 _ _ \u03c0\u2082,\nend\n\nlemma effacement.lift_naturality\n  {F G : A \u2964\u03b4 B} {X Y n}\n  (\u03b7 : F n \u27f6 G n) (e\u2081 : effacement F X n) (e\u2082 : effacement F Y n) (f : X \u27f6 Y) :\n  e\u2081.lift_app_aux \u03b7 \u226b (G (n+1)).map f =\n  (F (n+1)).map f \u226b e\u2082.lift_app_aux \u03b7 :=\nbegin\n  let e\u2081' : effacement F X n :=\n    \u27e8limits.biprod e\u2081.I e\u2082.I, limits.biprod.lift e\u2081.\u03b9 (f \u226b e\u2082.\u03b9), _\u27e9, -- 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\u2081.I \u229e e\u2082.I) \u2245 (F (n + 1)).obj (e\u2081.I) \u229e (F (n+1)).obj (e\u2082.I) :=\n      functor.map_biprod (F (n+1)) _ _,\n    rw [\u2190 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 [\u2190 functor.map_comp, limits.biprod.lift_fst],\n    exact e\u2081.w,\n    simp only [category.assoc, limits.biprod.lift_snd, limits.zero_comp],\n    simp only [\u2190 functor.map_comp, limits.biprod.lift_snd],\n    simp only [functor.map_comp, e\u2082.w, limits.comp_zero] },\n  rw e\u2081.lift_app_aux_well_defined \u03b7 e\u2081',\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.\u03c0_desc_assoc, category.assoc],\n  erw limits.cokernel.\u03c0_desc_assoc,\n  let q : e\u2081'.ses \u27f6 e\u2082.ses := \u27e8f, limits.biprod.snd,\n    limits.cokernel.desc _ (limits.biprod.snd \u226b limits.cokernel.\u03c0 _) _, _, _\u27e9,\n  erw \u2190 (F.\u03b4 n).naturality_assoc q,\n  erw \u2190 (G.\u03b4 n).naturality q,\n  dsimp,\n  have : (F.\u03b4 n).app e\u2082.ses \u226b e\u2082.cokernel_iso.inv = limits.cokernel.\u03c0 _,\n  { rw iso.comp_inv_eq, simp, },\n  rw reassoc_of this, clear this,\n  simp only [category.assoc, limits.cokernel.\u03c0_desc],\n  erw \u2190 nat_trans.naturality_assoc,\n  refl,\n  { dsimp [e\u2081'],\n    simp },\n  { dsimp [e\u2081', effacement.ses],\n    simp },\n  { dsimp [e\u2081', effacement.ses], simp, },\nend\n\nlemma effacement.lift_\u03b4_naturality\n  {F G : A \u2964\u03b4 B} {n}\n  (\u03b7 : F n \u27f6 G n) (S : short_exact_sequence A)\n  (e\u2081 : effacement F S.fst n) (e\u2082 : effacement F S.snd n) :\n  (F.\u03b4 n).app S \u226b e\u2081.lift_app_aux \u03b7 =\n  \u03b7.app _ \u226b (G.\u03b4 _).app S :=\nbegin\n  let e\u2081' : effacement F S.fst n :=\n  \u27e8e\u2082.I, S.f \u226b e\u2082.\u03b9, by simp [e\u2082.w]\u27e9,\n  rw e\u2081.lift_app_aux_well_defined \u03b7 e\u2081',\n  let q : S \u27f6 e\u2081'.ses :=\n    \u27e8\ud835\udfd9 _, e\u2082.\u03b9, S.exact'.epi_desc (e\u2082.\u03b9 \u226b limits.cokernel.\u03c0 _) _, _, _\u27e9,\n  dsimp only [effacement.lift_app_aux],\n  have : (F.\u03b4 n).app S \u226b e\u2081'.cokernel_iso.inv = (F n).map q.trd \u226b\n    limits.cokernel.\u03c0 _,\n  { rw iso.comp_inv_eq,\n    simp,\n    erw (F.\u03b4 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.\u03c0_desc],\n  erw \u03b7.naturality_assoc,\n  congr' 1,\n  erw (G.\u03b4 n).naturality q, convert category.comp_id _,\n  { dsimp, simpa only [functor.map_id], },\n  rw \u2190 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 \u2964\u03b4 B) [effaceable F] (n) (\u03b7 : F n \u27f6 G n) :\n  F (n+1) \u27f6 G (n+1) :=\n{ app := \u03bb X, (choose_effacement F X n).lift_app_aux \u03b7,\n  naturality' := begin\n    intros X Y f,\n    symmetry,\n    apply effacement.lift_naturality,\n  end }\n\n/-- The lift of \u03b70. -/\nnoncomputable\ndef effaceable.lift (F G : A \u2964\u03b4 B) [effaceable F] (\u03b70 : F 0 \u27f6 G 0) : \u03a0 n, F n \u27f6 G n\n| 0 := \u03b70\n| (n+1) := effaceable.lift_component _ _ _ (effaceable.lift n)\n\n/-- The lift of \u03b70, as an actual delta functor. -/\ndef effaceable.lift_with_\u03b4 (F G : A \u2964\u03b4 B) [effaceable F] (\u03b70 : F 0 \u27f6 G 0) :\n  F \u27f6 G :=\n{ \u03b7 := effaceable.lift _ _ \u03b70,\n  comm' := begin\n    intros n, ext S : 2,\n    dsimp,\n    rcases n with (_|n),\n    { dsimp [effaceable.lift],\n      apply effacement.lift_\u03b4_naturality,\n      apply choose_effacement },\n    { dsimp [effaceable.lift],\n      apply effacement.lift_\u03b4_naturality,\n      apply choose_effacement },\n  end }\n\nlemma effaceable.lift_with_\u03b4_unique (F G : A \u2964\u03b4 B) [effaceable F] (\u03b70 : F 0 \u27f6 G 0)\n  (\u03b7 : F \u27f6 G) (h\u03b7 : \u03b7 0 = \u03b70) : \u03b7 = effaceable.lift_with_\u03b4 F G \u03b70 :=\nbegin\n  ext1 n, induction n with n hn,\n  { rw h\u03b7, refl },\n  { ext T, dsimp [effaceable.lift_with_\u03b4] at \u22a2 hn,\n    change _ = ((effaceable.lift F G \u03b70) _).app _,\n    dsimp [effaceable.lift],\n    change _ = effaceable.lift F G \u03b70 n at hn,\n    erw \u2190 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.\u03c0_desc],\n    have := effacement.lift_\u03b4_naturality (\u03b7 n) ((choose_effacement F T n).ses)\n      (choose_effacement _ _ _) (choose_effacement _ _ _),\n    erw \u2190 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.\u03c0_desc],\n    clear this,\n    have := \u03b7.comm' n,\n    apply_fun (\u03bb 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 \u2964\u03b4 B) [effaceable F] : universal F :=\nbegin\n  constructor, intros G \u03b70,\n  use effaceable.lift_with_\u03b4 F G \u03b70,\n  split,\n  { ext, refl, },\n  { intros \u03b7 h\u03b7, apply effaceable.lift_with_\u03b4_unique, exact h\u03b7, }\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\u1d52\u1d56 \u2964 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 (\u03b1 : Type*) (\u03b9 : out_param Type) (\u03b2 : out_param Type*) [has_zero \u03b2] :=\n(eval : \u03b1 \u2192 (\u03b9 \u2192\u2080 \u03b2))\n\ninstance Stream.Eval_base {\u03b9 : Type} {\u03b1 : Type*} [add_zero_class \u03b1] : \n  Eval (StreamExec \u03b9 \u03b1) \u03b9 \u03b1 :=\n{ eval := \u03bb s, s.eval }\n\ninstance SimpleStream.Eval_base {\u03b9 : Type} {\u03b1 : Type*} [linear_order \u03b9] [add_zero_class \u03b1] : \n  Eval (SimpleStream \u03b9 \u03b1) \u03b9 \u03b1 :=\n{ eval := \u03bb s, Eval.eval (\u2191s : StreamExec \u03b9 \u03b1) }\n\ninstance Stream.Eval_ind {\u03b9 \u03b1 \u03b9' \u03b1' : Type*} [add_zero_class \u03b1'] [Eval \u03b1 \u03b9' \u03b1'] :\n  Eval (StreamExec \u03b9 \u03b1) \u03b9 (\u03b9' \u2192\u2080 \u03b1') :=\n{ eval := \u03bb s, (Eval.eval <$\u2082> s).eval }\n\ninstance SimpleStream.Eval_ind {\u03b9 \u03b1 \u03b9' \u03b1' : Type*} [linear_order \u03b9] [add_zero_class \u03b1'] [Eval \u03b1 \u03b9' \u03b1'] :\n  Eval (SimpleStream \u03b9 \u03b1) \u03b9 (\u03b9' \u2192\u2080 \u03b1') :=\n{ eval := \u03bb s, Eval.eval (\u2191s : StreamExec \u03b9 \u03b1) }\n\nclass AddZeroEval (\u03b1 : Type*) (\u03b9 : out_param Type) (\u03b2 : out_param Type*) [add_zero_class \u03b2] \n  extends Eval \u03b1 \u03b9 \u03b2, has_add \u03b1, has_zero \u03b1 :=\n(hadd : \u2200 (x y : \u03b1), eval (x + y) = eval x + eval y)\n(hzero : eval 0 = 0)\n\nclass MulEval (\u03b1 : Type*) (\u03b9 : out_param Type) (\u03b2 : out_param Type*) [non_unital_non_assoc_semiring \u03b2]\n  extends Eval \u03b1 \u03b9 \u03b2, has_mul \u03b1 :=\n(hmul : \u2200 (x y : \u03b1), eval (x * y) = eval x * eval y)\n\nattribute [simp] AddZeroEval.hadd AddZeroEval.hzero\n  MulEval.hmul\n\n@[simp] lemma Eval.contract {\u03b9 \u03b9' : Type} {\u03b1 \u03b1' : Type*} [add_comm_monoid \u03b1'] [Eval \u03b1 \u03b9' \u03b1']\n  (s : StreamExec \u03b9 \u03b1) :\n  Eval.eval (contract_stream s) () = (Eval.eval s).sum_range :=\nby simp [Eval.eval, contract_stream, StreamExec.bimap_bimap, \u2190 contract_stream_spec_apply]\n\n@[simp] lemma Eval.contract' {\u03b9 \u03b9' : Type} {\u03b1 \u03b1' : Type*} [linear_order \u03b9] [add_comm_monoid \u03b1'] [Eval \u03b1 \u03b9' \u03b1']\n  (s : SimpleStream \u03b9 \u03b1) :\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\u2081 r\u2082` solves the word problem for the relation `of' r\u2081 r\u2082`, returning\na normalized word in `T` when possible, and `none` otherwise\n-/\nvariables {\u03b9 : Type} [decidable_eq \u03b9]\n\nopen multiplicative free_group P semidirect_product\n\n@[simp] lemma gpowers_hom_apply {G : Type*} [group G] (x : G) (y : C\u221e) :\n  gpowers_hom G x y = x ^ y.to_add := rfl\n\ndef base_case'_cons (r\u2081 : \u03b9) (r\u2082 : C\u221e) (i : \u03b9) (n : C\u221e) :\n  P (free_group \u03b9) \u2192 P (free_group \u03b9)\n| \u27e8w, \u27e8[], _\u27e9\u27e9 :=\n  if i = r\u2081 \u2227 to_add r\u2082 \u2223 to_add n\n  then \u27e8of' (1 : free_group \u03b9) (of_add (to_add n / to_add r\u2082)) * w, 1\u27e9\n  else \u27e8mul_free (of' i n) w, \u27e8[\u27e8i, n\u27e9], sorry\u27e9\u27e9\n| \u27e8w, \u27e8(j::l), h\u27e9\u27e9 :=\n  if i = r\u2081\n  then let x := to_add n + to_add j.2 in\n    if j.1 = r\u2081 \u2227 to_add r\u2082 \u2223 x\n    then \u27e8mul_free (of' i n) w * of' (1 : free_group \u03b9) (of_add (x / (to_add r\u2082))), \u27e8l, sorry\u27e9\u27e9\n    else if (to_add r\u2082 : \u2124) \u2223 to_add n\n      then \u27e8mul_free (of' i n) w * of' (1 : free_group \u03b9) (of_add (to_add n / to_add r\u2082)),\n        \u27e8(j :: l), h\u27e9\u27e9\n      else \u27e8mul_free (of' i n) w, of' i n * \u27e8j :: l, h\u27e9\u27e9\n  else \u27e8mul_free (of' i n) w, of' i n * \u27e8j :: l, h\u27e9\u27e9\n\ndef base_case' (r\u2081 : \u03b9) (r\u2082 : C\u221e) : free_group \u03b9 \u2192 P (free_group \u03b9)\n| \u27e8[], h\u27e9 := \u27e81, \u27e8[], h\u27e9\u27e9\n| \u27e8(i::l), h\u27e9 :=\n  base_case'_cons r\u2081 r\u2082 i.1 i.2 $ base_case' \u27e8l, coprod.pre.reduced_of_reduced_cons h\u27e9\nusing_well_founded { rel_tac := \u03bb _ _, `[exact \u27e8\u03bb _ _, true, sorry\u27e9], dec_tac := `[trivial] }\n\ndef base_case'_solver (T : set \u03b9) [decidable_pred T] (r\u2081 : \u03b9) (r\u2082 : C\u221e) : solver (of' r\u2081 r\u2082) T :=\n\u03bb w, let p := base_case' r\u2081 r\u2082 w in\nif p.right \u2208 closure_var T\n  then some p\n  else none\n\n/-- `base_case_core` takes a word `l\u2081` in the free_group as a `list (\u03a3 i : \u03b9, C\u221e)`\nand a normalized word with proof `p` as a `P (free_group \u03b9)`.\nIt returns a normalized version `reverse l\u2081 * p`, reduced modulo `of' r\u2081 r\u2082`  -/\n@[inline] def base_case_core (r\u2081 : \u03b9) (r\u2082 : C\u221e) : list (\u03a3 i : \u03b9, C\u221e) \u2192\n  P (free_group \u03b9) \u2192 P (free_group \u03b9)\n| []     p := p\n| (i::l\u2081)  \u27e8p, \u27e8[], _\u27e9\u27e9 :=\n  if i.1 = r\u2081\n    then if to_add r\u2082 \u2223 i.2\n      then let q := to_add i.2 / to_add r\u2082 in\n        base_case_core l\u2081 (inl (of' (1 : free_group \u03b9) q) * \u27e8p, 1\u27e9)\n      else base_case_core l\u2081 (inr (of' i.1 i.2) * \u27e8p, 1\u27e9)\n    else base_case_core l\u2081 (inr (of' i.1 i.2) * inl p)\n| (i::l\u2081) \u27e8p, \u27e8j::l\u2082, _\u27e9\u27e9 :=\n  if i.1 = r\u2081\n    then if j.1 = r\u2081\n      then\n        let x := to_add i.2 + to_add j.2 in\n        if to_add r\u2082 \u2223 x\n        then base_case_core l\u2081 (inl (of' (1 : free_group \u03b9) (of_add (to_add x / to_add r\u2082))) *\n          inr (of' j.1 j.2\u207b\u00b9) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n        else base_case_core l\u2081 (inr (of' i.1 i.2) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n      else if to_add r\u2082 \u2223 i.2\n        then let q := to_add i.2 / to_add r\u2082 in\n          base_case_core l\u2081 (inl (of' (1 : free_group \u03b9) q) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n        else base_case_core l\u2081 (inr (of' i.1 i.2) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n    else base_case_core l\u2081 (inr (of' i.1 i.2) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n\n-- def normalize_single (r\u2081 : \u03b9) (r\u2082 : C\u221e) (i : \u03b9) (n : C\u221e) : P (free_group \u03b9) :=\n-- if i = r\u2081 \u2227 to_add r\u2082 \u2223 to_add n\n--   then \u27e8of' 1 (of_add (to_add n / to_add r\u2082)), 1\u27e9\n--   else \u27e81, of' i n\u27e9\n\n-- def mul_left (r\u2081 : \u03b9) (r\u2082 : C\u221e) (i : \u03b9) (n : C\u221e) :\n--   P (free_group \u03b9) \u2192 P (free_group \u03b9)\n-- | \u27e8p, \u27e8[], _\u27e9\u27e9 := normalize_single r\u2081 r\u2082 i n * inl p\n-- | \u27e8p, \u27e8(j::l), _\u27e9\u27e9 :=\n-- if i = j.1\n--   then _\n--   else _\n\n-- -- @[inline] def base_case_core\u2082 (r\u2081 : \u03b9) (r\u2082 : C\u221e) : list (\u03a3 i : \u03b9, C\u221e) \u2192\n-- --   P (free_group \u03b9) \u2192 P (free_group \u03b9)\n-- -- | []     p := p\n-- -- | (i::l\u2081)  \u27e8p, \u27e8[], _\u27e9\u27e9 :=\n-- --   if i.1 = r\u2081\n-- --     then if to_add r\u2082 \u2223 i.2\n-- --       then let q := to_add i.2 / to_add r\u2082 in\n-- --         base_case_core l\u2081 (inl (of' (1 : free_group \u03b9) q) * \u27e8p, 1\u27e9)\n-- --       else base_case_core l\u2081 (inr (of' i.1 i.2) * \u27e8p, 1\u27e9)\n-- --     else base_case_core l\u2081 (inr (of' i.1 i.2) * inl p)\n-- -- | (i::l\u2081) \u27e8p, \u27e8j::l\u2082, _\u27e9\u27e9 :=\n-- --   if i.1 = r\u2081\n-- --     then if j.1 = r\u2081\n-- --       then\n-- --         let x := to_add i.2 + to_add j.2 in\n-- --         if to_add r\u2082 \u2223 x\n-- --         then base_case_core l\u2081 (inl (of' (1 : free_group \u03b9) (of_add (to_add x / to_add r\u2082))) *\n-- --           inr (of' j.1 j.2\u207b\u00b9) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n-- --         else base_case_core l\u2081 (inr (of' i.1 i.2) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n-- --       else if to_add r\u2082 \u2223 i.2\n-- --         then let q := to_add i.2 / to_add r\u2082 in\n-- --           base_case_core l\u2081 (inl (of' (1 : free_group \u03b9) q) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n-- --         else base_case_core l\u2081 (inr (of' i.1 i.2) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n-- --     else base_case_core l\u2081 (inr (of' i.1 i.2) * \u27e8p, \u27e8j::l\u2082, sorry\u27e9\u27e9)\n\n/-- `base_case` reduces a word `w` in the `free_group \u03b9` modulo `of' r\u2081 r\u2082` -/\n@[inline] def base_case (r\u2081 : \u03b9) (r\u2082 : C\u221e) (w : free_group \u03b9) : P (free_group \u03b9) :=\nbase_case_core r\u2081 r\u2082 w.to_list.reverse 1\n\n/-- `base_case_solver T r\u2081 r\u2082` solves the word problem for the relation `of' r\u2081 r\u2082`, returning\na normalized word in `T` when possible, and `none` otherwise -/\n@[inline] def base_case_solver (T : set \u03b9) [decidable_pred T] (r\u2081 : \u03b9) (r\u2082 : C\u221e) : solver (of' r\u2081 r\u2082) T :=\n\u03bb w, let p := base_case r\u2081 r\u2082 w in\nif p.right \u2208 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)\u207b\u00b9 *of 0^(-2 : \u2124) * (of 1)\u207b\u00b9 * of 0 ^2* (of 1)^(-2 : \u2124) * (of 0)^2)))\n#eval ((base_case 1 (of_add 1) ((of 0)\u207b\u00b9 * of 1 * of 0 ^ 2 * (of 1) * (of 0)\u207b\u00b9)).left)\n#eval ((base_case' 0 (of_add 2) (of 1 *of 0^2 * (of 1) * of 0 ^2* (of 1)^(-2 : \u2124) * (of 0)^2)).left)\n#eval ((base_case' 1 (of_add 1) ((of 0)\u207b\u00b9 * of 1 * of 0 ^ 2 * (of 1) * (of 0)\u207b\u00b9)).left)\n\n@[simp] lemma lhs_base_case'_cons (r\u2081 : \u03b9) (r\u2082 : C\u221e) (hr\u2082 : to_add r\u2082 \u2260 0) (i : \u03b9) (n : C\u221e) :\n  \u03a0 (x : P (free_group \u03b9)), lhs (of' r\u2081 r\u2082) (base_case'_cons r\u2081 r\u2082 i n x) =\n    of' i n * lhs (of' r\u2081 r\u2082) x\n| \u27e8w, \u27e8[], _\u27e9\u27e9 := begin\n  rw [base_case'_cons],\n  split_ifs,\n  { clear_aux_decl,\n    rcases h with \u27e8rfl, m, hm\u27e9,\n    simp [lhs_inl, free_group.lift, gpowers_hom_apply],\n    simp only [of'_eq_of_pow, \u2190 gpow_add, \u2190 gpow_neg, \u2190 gpow_mul,\n      int.div_eq_of_eq_mul_right hr\u2082 hm],\n    rw hm },\n  { simp [inl_aut] }\nend\n| \u27e8w, \u27e8(j::l), _\u27e9\u27e9 := begin\n  clear_aux_decl,\n  rw [base_case'_cons],\n  dsimp only,\n  split_ifs,\n  { subst r\u2081,\n    rcases h_1 with \u27e8rfl, m, hm\u27e9,\n    rw [int.div_eq_of_eq_mul_right hr\u2082 hm],\n    rw [\u2190 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, \u2190 gpow_add, \u2190 gpow_neg, \u2190 gpow_mul, \u2190 mul_assoc, hm],\n    simp },\n  { subst r\u2081,\n    rcases h_2 with \u27e8m, hm\u27e9,\n    rw [int.div_eq_of_eq_mul_right hr\u2082 hm],\n    simp [lhs_inl, free_group.lift, mul_assoc, gpowers_hom_apply, inl_aut, hm],\n    simp only [of'_eq_of_pow, \u2190 gpow_add, \u2190 gpow_neg, \u2190 gpow_mul, \u2190 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\u2081 : \u03b9) (r\u2082 : C\u221e) (hr\u2082 : to_add r\u2082 \u2260 0) :\n  \u2200 x : free_group \u03b9, lhs (of' r\u2081 r\u2082) (base_case' r\u2081 r\u2082 x) = x\n| \u27e8[], h\u27e9     := by rw [base_case']; simp\n| \u27e8(i::l), _\u27e9 := by rw [base_case', lhs_base_case'_cons, lhs_base_case'];\n    simp [inl_aut, inl_aut_inv, mul_assoc, hr\u2082]\nusing_well_founded { rel_tac := \u03bb _ _, `[exact \u27e8\u03bb _ _, true, sorry\u27e9], 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}}
{"text": "/- Author: E.W.Ayers \u00a9 2019 -/\nimport .M\nnamespace robot\nopen strategy task tactic expr\nmeta def strategy.merge : strategy \u2192 strategy \u2192 M strategy \n|(Use r\u2081) (Use r\u2082) := do\n    r \u2190 hypothetically' (do \n        unify r\u2081.lhs r\u2082.lhs,\n        unify r\u2081.rhs r\u2082.rhs, \n        rule_app.instantiate_mvars r\u2081\n    ),\n    pure $ Use r\n|_ _ := failure\n\nmeta def destroy_test : zipper \u2192 expr \u2192 M bool\n|e c := \n    (do cez \u2190 zipper.down_address e.address c,\n        eq_above \u2190 zipper.above_equal cez e,\n        guard (eq_above),\n        e_locals \u2190 list_local_const_terms e.current,\n        cez_locals \u2190 list_local_const_terms cez.current,\n        pure $ e_locals.any (\u2209 cez_locals)\n    )\n    <|>\n    (hypothetically' (zipper.find_subterm e.current c *> pure ff)) <|> pure tt\n\nmeta def task.test : expr \u2192 task \u2192 M bool\n|ce (task.Create n e) := do\n    e \u2190 instantiate_mvars e,\n    pp_ce \u2190 pp ce, pp_e \u2190 pp e,\n    -- trace_m \"task.test: \" $ (to_fmt \"testing that \" ++ pp_ce ++ \" satisfies Create \" ++ pp_e),\n    matches : list zipper \u2190 zipper.find_occurences (zipper.zip ce) e,\n    -- trace_m \"task.test: \" $ matches,\n    pure $ matches.length \u2265 n\n    -- pure $ bnot matches.empty\n|ce t@(task.CreateAll e) :=\n    -- trace_m \"task.test: \" $ t,\n    (hypothetically' (unify e ce *> pure tt)) <|> pure ff\n|ce t@(task.Annihilate x) :=\n    (zipper.find_subterm x ce *> pure ff) <|> pure tt\n|ce t@(task.Destroy e) := do\n    destroy_test e ce\n|ce t := notimpl\nmeta def hoist : task \u2192 strategy \u2192 M strategy\n|t s@(Use r\u2081) := do\n    passes \u2190 task.test r\u2081.rhs t,\n    if passes then pure s else failure\n|_  _ := failure\n\n-- -- automatically do moves which are 'cowild', that is, they just reduce to a variable.\n-- meta def simplify : M (list strategy) := \u03bb t, do\n--     ce \u2190 get_ce,\n--     lookahead \u2190 get_lookahead,\n--     list.mchoose (\u03bb r, \n--         rule.lhs_wildcard\n--     ) lookahead\n\n/-- Do In One Move. Check the lookahead table and see if any of \nthe entries in there cause the task to be achieved. -/\nmeta def task.diom : task \u2192 M (list strategy) := \u03bb t, do\n    ce \u2190 get_ce,\n    lookahead \u2190 get_lookahead,\n    -- trace_m \"diom: \" $ lookahead,\n    list.mchoose (\u03bb r, do \n        let rhs := rule_app.rhs r,\n        M.hypothetically' (do\n                -- trace_m \"task.diom: \" $ (r, t),\n                result \u2190 task.test rhs t,\n                if result then pure () else failure\n        ),\n        pure $ strategy.Use $ r\n    ) lookahead\n\nmeta def try_dioms : task \u2192 M refinement | t := do \n    -- trace \"trying dioms\",\n    dioms \u2190 task.diom t, \n    -- trace dioms,\n    if \u00ac dioms.empty then pure ([],dioms) else failure\n\nmeta def get_distance_reducer : expr \u2192 expr \u2192 M (rule_app)\n| a b := do\n    a \u2190 instantiate_mvars a, \n    ce \u2190 get_ce,\n    current_dist \u2190 zipper.get_distance ce a b,\n    -- trace_m \"\\ngdr: \" $ (ce, a, b,  current_dist),\n    rs \u2190 get_lookahead,\n    drs \u2190 list.mchoose (\u03bb r, (do\n        -- trace_m \"gdr: \" $ (rule_app.rhs r),\n        new_dist \u2190 zipper.get_distance (rule_app.rhs $ r) a b,\n        -- trace_m \"gdr: \" $ (rule_app.rhs r, new_dist),\n        pure (new_dist,r)\n        --pure $ new_dist < current_dist) <|> pure ff\n    )) rs,\n    let drs := drs.filter (\u03bb p : \u2115 \u00d7 rule_app, p.1 < current_dist),\n    drs \u2190 list.minby (int.of_nat \u2218 prod.fst) drs,\n    pure drs.2\n    \nmeta def has_single_subterm : expr \u2192 M unit := \u03bb a, do\n    lhs \u2190 get_ce,\n    rhs \u2190 get_rhs,\n    zipper.has_single_subterm a $ zipper.zip lhs,\n    -- [HACK] if the given symbol occurs twice in the RHS then we shouldn't consider it as a strategy\n    -- this is a hack because really the refinement process shouldn't look at higher tasks.\n    c \u2190 zipper.count_subterms a $ zipper.zip rhs,\n    when (c > 1) failure,\n    pure \u27e8\u27e9\n\n\nmeta def can_use_ReduceDistance : expr \u2192 M strategy := \u03bb e, (do\n    [a,b] \u2190 zipper.get_proper_children e | failure,\n    ce \u2190 get_ce,\n    zce \u2190 pure $ zipper.zip ce, \n    rhs \u2190 get_rhs,\n    -- trace_m \"can_use_ReduceDistance\" $ (a,b),\n    has_single_subterm a,\n    has_single_subterm b, \n    dist \u2190 zipper.get_distance ce a b,\n    -- trace_m \"can_use_ReduceDistance\" $ (a,b,dist),\n    r \u2190 get_distance_reducer a b,\n    pure $ ReduceDistance a b\n    )\n\nmeta def can_use_commutativity : expr \u2192 M bool := \u03bb e, (do \n    [a,b] \u2190 zipper.get_proper_children e | failure,\n    ce \u2190 get_ce,\n    zipper.has_single_subterm a $ zipper.zip ce,\n    zipper.has_single_subterm b $ zipper.zip ce,\n    zipper.get_distance ce b a,\n    pure tt\n) <|> pure ff\n\n/-- Refinement operator for tasks. -/\nmeta def task.refine (t : task) : M refinement := do\n    try_dioms t <|> \n    --pure (++) <*> (try_dioms t <|> pure \u2205) <*> -- [INFO] this line adds dioms in addition to usual subtasks.\nmatch t with\n|(task.Create n e) := do\n    rss \u2190 (list.singleton <$> can_use_ReduceDistance e) <|> pure [],\n    -- trace_m \"task.refine: \" $ rss,\n    ce \u2190 get_ce,\n    rt \u2190 get_rule_table,\n    submatches \u2190 rt.submatch e,\n    -- trace_m \"task.refine: \" $ (e,submatches),\n    use_comm \u2190 can_use_commutativity e,\n    -- trace_m \"task.refine: \" $ use_comm,\n    submatches \u2190 pure submatches, -- if use_comm then pure submatches else submatches.mfilter (\u03bb z, bnot <$> rule.is_commuter z),\n    -- [TODO] need a way of ignoring commutativity here. \n    -- trace_m \"task.refine: \" $ submatches,\n    strats \u2190 pure $ list.map strategy.Use $ list.filter (\u03bb r, \u00ac rule_app.lhsz_is_meta r) $ submatches,\n    pure $ ([],rss ++ strats)\n|(task.CreateAll a) := do\n    ce \u2190 get_ce >>= lift instantiate_mvars,\n    -- trace_m \"refine CreateAll: \" $ ce,\n    --scs \u2190 zipper.lowest_uncommon_subterms ce a,\n    scs \u2190 zipper.smallest_absent_subterms ce a,\n    -- trace_m \"refine CreateAll: \" $ scs,\n    --if scs.length = 0 then pure $ ([],[]) else do\n    -- if list.any scs (zipper.is_top)  then do \n    --     rt \u2190 get_rule_table,\n    --     hrws \u2190 rule_table.head_rewrites_rhs a rt,\n    --     pure $ ([], strategy.Use <$> hrws)\n    -- else do\n    let primaries := (\u03bb p : \u2115 \u00d7 zipper, task.Create p.1 p.2.current) <$> scs,\n    -- secondaries \u2190 list.mchoose (\u03bb p : _ \u00d7 _, do\n    --     z \u2190 zipper.up p.2,\n    --     pure $ task.Create p.1 z.current\n    --  ) scs,\n\n    -- find the smallest absent subterms on the LHS bit not RHS\n    rscs \u2190 zipper.smallest_absent_composite_subterms a ce,\n\n    to_destroy \u2190 pure \n        $ list.map (task.Destroy) \n        $ list.map (prod.snd)\n        $ rscs,\n\n    lhs_lcs \u2190 list_local_const_terms ce,\n    -- trace_m \"lhs_lcs: \" $ lhs_lcs,\n    rhs_lcs \u2190 list_local_const_terms a,\n    to_annihilate \u2190 pure $ list.map task.Annihilate $ lhs_lcs.filter (\u2209 rhs_lcs),\n    let scs := primaries  ++ to_destroy ++ to_annihilate,\n    pure $ (scs, [])\n|(task.Annihilate x) := do\n    ce \u2190 get_ce, rt \u2190 get_rule_table,\n    rss \u2190 (list.singleton <$> get_distance_reducer x x) <|> pure [],\n    -- find all rules which will remove `x` from the face of the earth?\n    -- trace_m \"refine annihilate: \" $ rss,\n    if \u00ac rss.empty then\n        pure $ ([],[strategy.ReduceDistance x x])\n    else pure \u2205 \n|(task.Destroy x) := do\n    rt \u2190 get_rule_table,\n    some xu \u2190 pure $ zipper.up x | pure \u2205,\n    submatches \u2190 rt.submatch_lhs x.current,\n    submatches \u2190 list.mmap (\u03bb r, rule_app.flip r) submatches,\n    \u27e8breakups,rewrites\u27e9 \u2190 list.msplit (\u03bb r, \n        (do z \u2190 zipper.find_non_unify_subterm x.current (rule_app.lhs r),\n            guard (\u00ac z.is_top),\n            pure $ sum.inl r\n        ) <|> (pure $ sum.inr r)\n    ) submatches,\n    --trace (breakups,rewrites),\n    if breakups.empty then pure $ ([], list.map Use rewrites) else\n    pure $ ([], list.map Use breakups)\n\n|(task.Merge x) := do -- MERGE\n    /- Find rules which will:\n        a. perform a factorisation such that `x` is factorised.\n        b. perform a straight merge such as `F(x) \u2229 F(x) = F(x)` or `x + x = 2 * x`\n        c. annihilate one instance of `x`. For example `x * 0 = 0`. \n\n        In general, this will produce too many bad candidates. \n        You don't want `x \u2229 x = x` to be seen as a good idea for a number problem, how to refine?\n        1. use n-gram triggers to suggest rules.\n        2. Use this subtask to refine sets of rules produced by other subtasks.\n    -/\n    notimpl\nend\n\n/-- Execute the strategy. This will generally perform a conversion of the LHS of the goal.\n    But in principle one can do anything to the tactic state.\n -/\nmeta def strategy.execute : strategy \u2192 M unit\n|(strategy.ReduceDistance a b) := do\n    repeat (do \n        h \u2190 get_distance_reducer a b,\n        run_conv $ rule_app.rewrite_conv h\n    )\n|s@(strategy.Use r)            := do\n    run_conv $ rule_app.rewrite_conv r\n\nmeta def strategy.refine : strategy \u2192 M refinement\n|(strategy.ReduceDistance a b) := \n    -- The ReduceDistance strategy is merely a greedy algorithm. There are no subtasks.\n    pure $ ([],[])\n|(strategy.Use r)              := do\n    ce \u2190 get_ce,\n    scs \u2190 zipper.smallest_absent_subterms ce r.lhs,\n    scs \u2190 pure $ if scs.empty then [(1,zipper.zip r.lhs)] else scs,\n    subs \u2190 scs.mmap (\u03bb z, task.Create z.1 <$> instantiate_mvars z.2.current),\n    pure \u27e8subs, []\u27e9\n\nend robot", "meta": {"author": "EdAyers", "repo": "lean-subtask", "sha": "04ac5a6c3bc3bfd190af4d6dcce444ddc8914e4b", "save_path": "github-repos/lean/EdAyers-lean-subtask", "path": "github-repos/lean/EdAyers-lean-subtask/lean-subtask-04ac5a6c3bc3bfd190af4d6dcce444ddc8914e4b/src/refine.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5273165085228825, "lm_q2_score": 0.38121956625614994, "lm_q1q2_score": 0.20102337065880066}}
{"text": "import Smt\n\ntheorem comm (f : Prop \u2192 Prop \u2192 Prop) (p q : Prop) : f p q = f q p := by\n  smt\n  admit\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/Test/Prop/Comm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. NO\n\n", "lm_q1_score": 0.5117166047041654, "lm_q2_score": 0.39233683016710835, "lm_q1q2_score": 0.20076527063350744}}
