l3lab/ntp-mathlib huggingface dataset:
theorem mem_basicOpen_top' {U : Opens X} (f : X.presheaf.obj (op U)) (x : X.carrier) :
    x ∈ X.basicOpen f ↔ ∃ (m : x ∈ U), IsUnit (X.presheaf.germ (⟨x, m⟩ : U) f) := by
  fconstructor
  · 

Proof state:
case mp
X : Scheme
V U✝ : Opens ↑↑X.toPresheafedSpace
f✝ g : ↑(X.presheaf.obj (op U✝))
U : Opens ↑↑X.toPresheafedSpace
f : ↑(X.presheaf.obj (op U))
x : ↑↑X.toPresheafedSpace
⊢ x ∈ X.basicOpen f → ∃ (m : x ∈ U), IsUnit ((Presheaf.germ X.presheaf { val := x, property := m }) f)

Next tactic:
rintro ⟨y, hy1, rfl⟩
theorem mem_basicOpen_top' {U : Opens X} (f : X.presheaf.obj (op U)) (x : X.carrier) :
    x ∈ X.basicOpen f ↔ ∃ (m : x ∈ U), IsUnit (X.presheaf.germ (⟨x, m⟩ : U) f) := by
  fconstructor
  · rintro ⟨y, hy1, rfl⟩
    

Proof state:
case mp.intro.intro
X : Scheme
V U✝ : Opens ↑↑X.toPresheafedSpace
f✝ g : ↑(X.presheaf.obj (op U✝))
U : Opens ↑↑X.toPresheafedSpace
f : ↑(X.presheaf.obj (op U))
y : ↥U
hy1 :
  y ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) f)}
⊢ ∃ (m : ↑y ∈ U), IsUnit ((Presheaf.germ X.presheaf { val := ↑y, property := m }) f)

Next tactic:
exact ⟨y.2, hy1⟩
theorem mem_basicOpen_top' {U : Opens X} (f : X.presheaf.obj (op U)) (x : X.carrier) :
    x ∈ X.basicOpen f ↔ ∃ (m : x ∈ U), IsUnit (X.presheaf.germ (⟨x, m⟩ : U) f) := by
  fconstructor
  · rintro ⟨y, hy1, rfl⟩
    exact ⟨y.2, hy1⟩
  · 

Proof state:
case mpr
X : Scheme
V U✝ : Opens ↑↑X.toPresheafedSpace
f✝ g : ↑(X.presheaf.obj (op U✝))
U : Opens ↑↑X.toPresheafedSpace
f : ↑(X.presheaf.obj (op U))
x : ↑↑X.toPresheafedSpace
⊢ (∃ (m : x ∈ U), IsUnit ((Presheaf.germ X.presheaf { val := x, property := m }) f)) → x ∈ X.basicOpen f

Next tactic:
rintro ⟨m, hm⟩
theorem mem_basicOpen_top' {U : Opens X} (f : X.presheaf.obj (op U)) (x : X.carrier) :
    x ∈ X.basicOpen f ↔ ∃ (m : x ∈ U), IsUnit (X.presheaf.germ (⟨x, m⟩ : U) f) := by
  fconstructor
  · rintro ⟨y, hy1, rfl⟩
    exact ⟨y.2, hy1⟩
  · rintro ⟨m, hm⟩
    

Proof state:
case mpr.intro
X : Scheme
V U✝ : Opens ↑↑X.toPresheafedSpace
f✝ g : ↑(X.presheaf.obj (op U✝))
U : Opens ↑↑X.toPresheafedSpace
f : ↑(X.presheaf.obj (op U))
x : ↑↑X.toPresheafedSpace
m : x ∈ U
hm : IsUnit ((Presheaf.germ X.presheaf { val := x, property := m }) f)
⊢ x ∈ X.basicOpen f

Next tactic:
exact ⟨⟨x, m⟩, hm, rfl⟩
theorem basicOpen_eq_of_affine {R : CommRingCat} (f : R) :
    (Scheme.Spec.obj <| op R).basicOpen ((SpecΓIdentity.app R).inv f) =
      PrimeSpectrum.basicOpen f := by
  

Proof state:
R : CommRingCat
f : ↑R
⊢ (Scheme.Spec.obj (op R)).basicOpen ((SpecΓIdentity.app R).inv f) = PrimeSpectrum.basicOpen f

Next tactic:
ext x
theorem basicOpen_eq_of_affine {R : CommRingCat} (f : R) :
    (Scheme.Spec.obj <| op R).basicOpen ((SpecΓIdentity.app R).inv f) =
      PrimeSpectrum.basicOpen f := by
  ext x
  

Proof state:
case h.h
R : CommRingCat
f : ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
⊢ x ∈ ↑((Scheme.Spec.obj (op R)).basicOpen ((SpecΓIdentity.app R).inv f)) ↔ x ∈ ↑(PrimeSpectrum.basicOpen f)

Next tactic:
erw [Scheme.mem_basicOpen_top]
theorem basicOpen_eq_of_affine {R : CommRingCat} (f : R) :
    (Scheme.Spec.obj <| op R).basicOpen ((SpecΓIdentity.app R).inv f) =
      PrimeSpectrum.basicOpen f := by
  ext x
  erw [Scheme.mem_basicOpen_top]
  

Proof state:
case h.h
R : CommRingCat
f : ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
⊢ IsUnit
      ((Presheaf.germ (Scheme.Spec.obj (op R)).presheaf { val := x, property := _root_.trivial })
        ((SpecΓIdentity.app R).inv f)) ↔
    x ∈ ↑(PrimeSpectrum.basicOpen f)

Next tactic:
suffices IsUnit (StructureSheaf.toStalk R x f) ↔ f ∉ PrimeSpectrum.asIdeal x by exact this
theorem basicOpen_eq_of_affine {R : CommRingCat} (f : R) :
    (Scheme.Spec.obj <| op R).basicOpen ((SpecΓIdentity.app R).inv f) =
      PrimeSpectrum.basicOpen f := by
  ext x
  erw [Scheme.mem_basicOpen_top]
  suffices IsUnit (StructureSheaf.toStalk R x f) ↔ f ∉ PrimeSpectrum.asIdeal x by 

Proof state:
R : CommRingCat
f : ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
this : IsUnit ((StructureSheaf.toStalk (↑R) x) f) ↔ f ∉ x.asIdeal
⊢ IsUnit
      ((Presheaf.germ (Scheme.Spec.obj (op R)).presheaf { val := x, property := _root_.trivial })
        ((SpecΓIdentity.app R).inv f)) ↔
    x ∈ ↑(PrimeSpectrum.basicOpen f)

Next tactic:
exact this
theorem basicOpen_eq_of_affine {R : CommRingCat} (f : R) :
    (Scheme.Spec.obj <| op R).basicOpen ((SpecΓIdentity.app R).inv f) =
      PrimeSpectrum.basicOpen f := by
  ext x
  erw [Scheme.mem_basicOpen_top]
  suffices IsUnit (StructureSheaf.toStalk R x f) ↔ f ∉ PrimeSpectrum.asIdeal x by exact this
  

Proof state:
case h.h
R : CommRingCat
f : ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
⊢ IsUnit ((StructureSheaf.toStalk (↑R) x) f) ↔ f ∉ x.asIdeal

Next tactic:
erw [← isUnit_map_iff (StructureSheaf.stalkToFiberRingHom R x),
    StructureSheaf.stalkToFiberRingHom_toStalk]
theorem basicOpen_eq_of_affine {R : CommRingCat} (f : R) :
    (Scheme.Spec.obj <| op R).basicOpen ((SpecΓIdentity.app R).inv f) =
      PrimeSpectrum.basicOpen f := by
  ext x
  erw [Scheme.mem_basicOpen_top]
  suffices IsUnit (StructureSheaf.toStalk R x f) ↔ f ∉ PrimeSpectrum.asIdeal x by exact this
  erw [← isUnit_map_iff (StructureSheaf.stalkToFiberRingHom R x),
    StructureSheaf.stalkToFiberRingHom_toStalk]
  

Proof state:
case h.h
R : CommRingCat
f : ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
⊢ IsUnit ((algebraMap (↑R) (Localization.AtPrime x.asIdeal)) f) ↔ f ∉ x.asIdeal

Next tactic:
exact
    (IsLocalization.AtPrime.isUnit_to_map_iff (Localization.AtPrime (PrimeSpectrum.asIdeal x))
        (PrimeSpectrum.asIdeal x) f :
      _)
@[simp]
theorem basicOpen_eq_of_affine' {R : CommRingCat}
    (f : (Spec.toSheafedSpace.obj (op R)).presheaf.obj (op ⊤)) :
    (Scheme.Spec.obj <| op R).basicOpen f =
      PrimeSpectrum.basicOpen ((SpecΓIdentity.app R).hom f) := by
  

Proof state:
R : CommRingCat
f : ↑((Spec.toSheafedSpace.obj (op R)).presheaf.obj (op ⊤))
⊢ (Scheme.Spec.obj (op R)).basicOpen f = PrimeSpectrum.basicOpen ((SpecΓIdentity.app R).hom f)

Next tactic:
convert basicOpen_eq_of_affine ((SpecΓIdentity.app R).hom f)
@[simp]
theorem basicOpen_eq_of_affine' {R : CommRingCat}
    (f : (Spec.toSheafedSpace.obj (op R)).presheaf.obj (op ⊤)) :
    (Scheme.Spec.obj <| op R).basicOpen f =
      PrimeSpectrum.basicOpen ((SpecΓIdentity.app R).hom f) := by
  convert basicOpen_eq_of_affine ((SpecΓIdentity.app R).hom f)
  

Proof state:
case h.e'_2.h.h.e'_3.h.h
R : CommRingCat
f : ↑((Spec.toSheafedSpace.obj (op R)).presheaf.obj (op ⊤))
e_1✝¹ :
  Opens ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace =
    Opens ↑↑(Scheme.Spec.obj (op ((𝟭 CommRingCat).obj R))).toPresheafedSpace
e_1✝ : Scheme.Spec.obj (op R) = Scheme.Spec.obj (op ((𝟭 CommRingCat).obj R))
he✝ : ⊤ = ⊤
⊢ f = (SpecΓIdentity.app ((𝟭 CommRingCat).obj R)).inv ((SpecΓIdentity.app R).hom f)

Next tactic:
exact (Iso.hom_inv_id_apply (SpecΓIdentity.app R) f).symm
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : Opens X} (h : U = V) (W) :
    (Scheme.Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
      eqToHom (by 

Proof state:
X : Scheme
U V : Opens ↑↑X.toPresheafedSpace
h : U = V
W : (Opens ↑↑(Spec.obj (op (X.presheaf.obj (op V)))).toPresheafedSpace)ᵒᵖ
⊢ (Spec.obj (op (X.presheaf.obj (op V)))).presheaf.obj W =
    ((Spec.map (X.presheaf.map (eqToHom h).op).op).val.base _* (Spec.obj (op (X.presheaf.obj (op U)))).presheaf).obj W

Next tactic:
cases h
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : Opens X} (h : U = V) (W) :
    (Scheme.Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
      eqToHom (by cases h; 

Proof state:
case refl
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
W : (Opens ↑↑(Spec.obj (op (X.presheaf.obj (op U)))).toPresheafedSpace)ᵒᵖ
⊢ (Spec.obj (op (X.presheaf.obj (op U)))).presheaf.obj W =
    ((Spec.map (X.presheaf.map (eqToHom (_ : U = U)).op).op).val.base _*
          (Spec.obj (op (X.presheaf.obj (op U)))).presheaf).obj
      W

Next tactic:
induction W using Opposite.rec'
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : Opens X} (h : U = V) (W) :
    (Scheme.Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
      eqToHom (by cases h; induction W using Opposite.rec'; 

Proof state:
case refl.h
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
X✝ : Opens ↑↑(Spec.obj (op (X.presheaf.obj (op U)))).toPresheafedSpace
⊢ (Spec.obj (op (X.presheaf.obj (op U)))).presheaf.obj (op X✝) =
    ((Spec.map (X.presheaf.map (eqToHom (_ : U = U)).op).op).val.base _*
          (Spec.obj (op (X.presheaf.obj (op U)))).presheaf).obj
      (op X✝)

Next tactic:
dsimp
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : Opens X} (h : U = V) (W) :
    (Scheme.Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
      eqToHom (by cases h; induction W using Opposite.rec'; dsimp; 

Proof state:
case refl.h
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
X✝ : Opens ↑↑(Spec.obj (op (X.presheaf.obj (op U)))).toPresheafedSpace
⊢ (Spec.obj (op (X.presheaf.obj (op U)))).presheaf.obj (op X✝) =
    (Spec.obj (op (X.presheaf.obj (op U)))).presheaf.obj
      (op ((Opens.map (Spec.map (X.presheaf.map (𝟙 (op U))).op).val.base).obj X✝))

Next tactic:
simp
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : Opens X} (h : U = V) (W) :
    (Scheme.Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
      eqToHom (by cases h; induction W using Opposite.rec'; dsimp; simp) := by
  

Proof state:
X : Scheme
U V : Opens ↑↑X.toPresheafedSpace
h : U = V
W : (Opens ↑↑(Spec.obj (op (X.presheaf.obj (op V)))).toPresheafedSpace)ᵒᵖ
⊢ (Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
    eqToHom
      (_ :
        (Spec.obj (op (X.presheaf.obj (op V)))).presheaf.obj W =
          ((Spec.map (X.presheaf.map (eqToHom h).op).op).val.base _*
                (Spec.obj (op (X.presheaf.obj (op U)))).presheaf).obj
            W)

Next tactic:
have : Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 _ := by
    rw [X.presheaf.map_id, op_id, Scheme.Spec.map_id]
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : Opens X} (h : U = V) (W) :
    (Scheme.Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
      eqToHom (by cases h; induction W using Opposite.rec'; dsimp; simp) := by
  have : Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 _ := by
    

Proof state:
X : Scheme
U V : Opens ↑↑X.toPresheafedSpace
h : U = V
W : (Opens ↑↑(Spec.obj (op (X.presheaf.obj (op V)))).toPresheafedSpace)ᵒᵖ
⊢ Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 (Spec.obj (op (X.presheaf.obj (op U))))

Next tactic:
rw [X.presheaf.map_id, op_id, Scheme.Spec.map_id]
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : Opens X} (h : U = V) (W) :
    (Scheme.Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
      eqToHom (by cases h; induction W using Opposite.rec'; dsimp; simp) := by
  have : Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 _ := by
    rw [X.presheaf.map_id, op_id, Scheme.Spec.map_id]
  

Proof state:
X : Scheme
U V : Opens ↑↑X.toPresheafedSpace
h : U = V
W : (Opens ↑↑(Spec.obj (op (X.presheaf.obj (op V)))).toPresheafedSpace)ᵒᵖ
this : Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 (Spec.obj (op (X.presheaf.obj (op U))))
⊢ (Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
    eqToHom
      (_ :
        (Spec.obj (op (X.presheaf.obj (op V)))).presheaf.obj W =
          ((Spec.map (X.presheaf.map (eqToHom h).op).op).val.base _*
                (Spec.obj (op (X.presheaf.obj (op U)))).presheaf).obj
            W)

Next tactic:
cases h
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : Opens X} (h : U = V) (W) :
    (Scheme.Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
      eqToHom (by cases h; induction W using Opposite.rec'; dsimp; simp) := by
  have : Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 _ := by
    rw [X.presheaf.map_id, op_id, Scheme.Spec.map_id]
  cases h
  

Proof state:
case refl
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
this : Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 (Spec.obj (op (X.presheaf.obj (op U))))
W : (Opens ↑↑(Spec.obj (op (X.presheaf.obj (op U)))).toPresheafedSpace)ᵒᵖ
⊢ (Spec.map (X.presheaf.map (eqToHom (_ : U = U)).op).op).val.c.app W =
    eqToHom
      (_ :
        (Spec.obj (op (X.presheaf.obj (op U)))).presheaf.obj W =
          ((Spec.map (X.presheaf.map (eqToHom (_ : U = U)).op).op).val.base _*
                (Spec.obj (op (X.presheaf.obj (op U)))).presheaf).obj
            W)

Next tactic:
refine' (Scheme.congr_app this _).trans _
theorem Scheme.Spec_map_presheaf_map_eqToHom {X : Scheme} {U V : Opens X} (h : U = V) (W) :
    (Scheme.Spec.map (X.presheaf.map (eqToHom h).op).op).val.c.app W =
      eqToHom (by cases h; induction W using Opposite.rec'; dsimp; simp) := by
  have : Scheme.Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 _ := by
    rw [X.presheaf.map_id, op_id, Scheme.Spec.map_id]
  cases h
  refine' (Scheme.congr_app this _).trans _
  

Proof state:
case refl
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
this : Spec.map (X.presheaf.map (𝟙 (op U))).op = 𝟙 (Spec.obj (op (X.presheaf.obj (op U))))
W : (Opens ↑↑(Spec.obj (op (X.presheaf.obj (op U)))).toPresheafedSpace)ᵒᵖ
⊢ (𝟙 (Spec.obj (op (X.presheaf.obj (op U))))).val.c.app W ≫
      (Spec.obj (op (X.presheaf.obj (op U)))).presheaf.map
        (eqToHom
          (_ :
            (Opens.map (𝟙 (Spec.obj (op (X.presheaf.obj (op U))))).val.base).op.obj W =
              (Opens.map (Spec.map (X.presheaf.map (𝟙 (op U))).op).val.base).op.obj W)) =
    eqToHom
      (_ :
        (Spec.obj (op (X.presheaf.obj (op U)))).presheaf.obj W =
          ((Spec.map (X.presheaf.map (eqToHom (_ : U = U)).op).op).val.base _*
                (Spec.obj (op (X.presheaf.obj (op U)))).presheaf).obj
            W)

Next tactic:
simp [eqToHom_map]
instance : FloorSemiring ℕ where
  floor := id
  ceil := id
  floor_of_neg ha := (Nat.not_lt_zero _ ha).elim
  gc_floor _ := by
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
a✝ n✝ : ℕ
x✝ : 0 ≤ a✝
⊢ n✝ ≤ id a✝ ↔ ↑n✝ ≤ a✝

Next tactic:
rw [Nat.cast_id]
instance : FloorSemiring ℕ where
  floor := id
  ceil := id
  floor_of_neg ha := (Nat.not_lt_zero _ ha).elim
  gc_floor _ := by
    rw [Nat.cast_id]
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
a✝ n✝ : ℕ
x✝ : 0 ≤ a✝
⊢ n✝ ≤ id a✝ ↔ n✝ ≤ a✝

Next tactic:
rfl
instance : FloorSemiring ℕ where
  floor := id
  ceil := id
  floor_of_neg ha := (Nat.not_lt_zero _ ha).elim
  gc_floor _ := by
    rw [Nat.cast_id]
    rfl
  gc_ceil n a := by
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
n a : ℕ
⊢ id n ≤ a ↔ n ≤ ↑a

Next tactic:
rw [Nat.cast_id]
instance : FloorSemiring ℕ where
  floor := id
  ceil := id
  floor_of_neg ha := (Nat.not_lt_zero _ ha).elim
  gc_floor _ := by
    rw [Nat.cast_id]
    rfl
  gc_ceil n a := by
    rw [Nat.cast_id]
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
n a : ℕ
⊢ id n ≤ a ↔ n ≤ a

Next tactic:
rfl
theorem floor_lt_one (ha : 0 ≤ a) : ⌊a⌋₊ < 1 ↔ a < 1 :=
  (floor_lt ha).trans <| by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
⊢ a < ↑1 ↔ a < 1

Next tactic:
rw [Nat.cast_one]
theorem lt_floor_add_one (a : α) : a < ⌊a⌋₊ + 1 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
⊢ a < ↑⌊a⌋₊ + 1

Next tactic:
simpa using lt_succ_floor a
@[simp]
theorem floor_coe (n : ℕ) : ⌊(n : α)⌋₊ = n :=
  eq_of_forall_le_iff fun a => by
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n✝ n a : ℕ
⊢ a ≤ ⌊↑n⌋₊ ↔ a ≤ n

Next tactic:
rw [le_floor_iff, Nat.cast_le]
@[simp]
theorem floor_coe (n : ℕ) : ⌊(n : α)⌋₊ = n :=
  eq_of_forall_le_iff fun a => by
    rw [le_floor_iff, Nat.cast_le]
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n✝ n a : ℕ
⊢ 0 ≤ ↑n

Next tactic:
exact n.cast_nonneg
@[simp]
theorem floor_zero : ⌊(0 : α)⌋₊ = 0 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌊0⌋₊ = 0

Next tactic:
rw [← Nat.cast_zero, floor_coe]
@[simp]
theorem floor_one : ⌊(1 : α)⌋₊ = 1 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌊1⌋₊ = 1

Next tactic:
rw [← Nat.cast_one, floor_coe]
theorem floor_of_nonpos (ha : a ≤ 0) : ⌊a⌋₊ = 0 :=
  ha.lt_or_eq.elim FloorSemiring.floor_of_neg <| by
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : a ≤ 0
⊢ a = 0 → ⌊a⌋₊ = 0

Next tactic:
rintro rfl
theorem floor_of_nonpos (ha : a ≤ 0) : ⌊a⌋₊ = 0 :=
  ha.lt_or_eq.elim FloorSemiring.floor_of_neg <| by
    rintro rfl
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
n : ℕ
ha : 0 ≤ 0
⊢ ⌊0⌋₊ = 0

Next tactic:
exact floor_zero
theorem floor_mono : Monotone (floor : α → ℕ) := fun a b h => by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a ≤ b
⊢ ⌊a⌋₊ ≤ ⌊b⌋₊

Next tactic:
obtain ha | ha := le_total a 0
theorem floor_mono : Monotone (floor : α → ℕ) := fun a b h => by
  obtain ha | ha := le_total a 0
  · 

Proof state:
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a ≤ b
ha : a ≤ 0
⊢ ⌊a⌋₊ ≤ ⌊b⌋₊

Next tactic:
rw [floor_of_nonpos ha]
theorem floor_mono : Monotone (floor : α → ℕ) := fun a b h => by
  obtain ha | ha := le_total a 0
  · rw [floor_of_nonpos ha]
    

Proof state:
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a ≤ b
ha : a ≤ 0
⊢ 0 ≤ ⌊b⌋₊

Next tactic:
exact Nat.zero_le _
theorem floor_mono : Monotone (floor : α → ℕ) := fun a b h => by
  obtain ha | ha := le_total a 0
  · rw [floor_of_nonpos ha]
    exact Nat.zero_le _
  · 

Proof state:
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a ≤ b
ha : 0 ≤ a
⊢ ⌊a⌋₊ ≤ ⌊b⌋₊

Next tactic:
exact le_floor ((floor_le ha).trans h)
theorem le_floor_iff' (hn : n ≠ 0) : n ≤ ⌊a⌋₊ ↔ (n : α) ≤ a := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
⊢ n ≤ ⌊a⌋₊ ↔ ↑n ≤ a

Next tactic:
obtain ha | ha := le_total a 0
theorem le_floor_iff' (hn : n ≠ 0) : n ≤ ⌊a⌋₊ ↔ (n : α) ≤ a := by
  obtain ha | ha := le_total a 0
  · 

Proof state:
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
ha : a ≤ 0
⊢ n ≤ ⌊a⌋₊ ↔ ↑n ≤ a

Next tactic:
rw [floor_of_nonpos ha]
theorem le_floor_iff' (hn : n ≠ 0) : n ≤ ⌊a⌋₊ ↔ (n : α) ≤ a := by
  obtain ha | ha := le_total a 0
  · rw [floor_of_nonpos ha]
    

Proof state:
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
ha : a ≤ 0
⊢ n ≤ 0 ↔ ↑n ≤ a

Next tactic:
exact
      iff_of_false (Nat.pos_of_ne_zero hn).not_le
        (not_le_of_lt <| ha.trans_lt <| cast_pos.2 <| Nat.pos_of_ne_zero hn)
theorem le_floor_iff' (hn : n ≠ 0) : n ≤ ⌊a⌋₊ ↔ (n : α) ≤ a := by
  obtain ha | ha := le_total a 0
  · rw [floor_of_nonpos ha]
    exact
      iff_of_false (Nat.pos_of_ne_zero hn).not_le
        (not_le_of_lt <| ha.trans_lt <| cast_pos.2 <| Nat.pos_of_ne_zero hn)
  · 

Proof state:
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
ha : 0 ≤ a
⊢ n ≤ ⌊a⌋₊ ↔ ↑n ≤ a

Next tactic:
exact le_floor_iff ha
theorem floor_pos : 0 < ⌊a⌋₊ ↔ 1 ≤ a := by
  -- Porting note: broken `convert le_floor_iff' Nat.one_ne_zero`
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ 0 < ⌊a⌋₊ ↔ 1 ≤ a

Next tactic:
rw [Nat.lt_iff_add_one_le, zero_add, le_floor_iff' Nat.one_ne_zero, cast_one]
theorem pos_of_floor_pos (h : 0 < ⌊a⌋₊) : 0 < a :=
  (le_or_lt a 0).resolve_left fun ha => lt_irrefl 0 <| by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
h : 0 < ⌊a⌋₊
ha : a ≤ 0
⊢ 0 < 0

Next tactic:
rwa [floor_of_nonpos ha] at h
@[simp]
theorem floor_eq_zero : ⌊a⌋₊ = 0 ↔ a < 1 := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌊a⌋₊ = 0 ↔ a < 1

Next tactic:
rw [← lt_one_iff, ← @cast_one α]
@[simp]
theorem floor_eq_zero : ⌊a⌋₊ = 0 ↔ a < 1 := by
  rw [← lt_one_iff, ← @cast_one α]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌊a⌋₊ < 1 ↔ a < ↑1

Next tactic:
exact floor_lt' Nat.one_ne_zero
theorem floor_eq_iff (ha : 0 ≤ a) : ⌊a⌋₊ = n ↔ ↑n ≤ a ∧ a < ↑n + 1 := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
⊢ ⌊a⌋₊ = n ↔ ↑n ≤ a ∧ a < ↑n + 1

Next tactic:
rw [← le_floor_iff ha, ← Nat.cast_one, ← Nat.cast_add, ← floor_lt ha, Nat.lt_add_one_iff,
    le_antisymm_iff, and_comm]
theorem floor_eq_iff' (hn : n ≠ 0) : ⌊a⌋₊ = n ↔ ↑n ≤ a ∧ a < ↑n + 1 := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
⊢ ⌊a⌋₊ = n ↔ ↑n ≤ a ∧ a < ↑n + 1

Next tactic:
rw [← le_floor_iff' hn, ← Nat.cast_one, ← Nat.cast_add, ← floor_lt' (Nat.add_one_ne_zero n),
    Nat.lt_add_one_iff, le_antisymm_iff, and_comm]
theorem add_one_le_ceil_iff : n + 1 ≤ ⌈a⌉₊ ↔ (n : α) < a := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ n + 1 ≤ ⌈a⌉₊ ↔ ↑n < a

Next tactic:
rw [← Nat.lt_ceil, Nat.add_one_le_iff]
@[simp]
theorem one_le_ceil_iff : 1 ≤ ⌈a⌉₊ ↔ 0 < a := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ 1 ≤ ⌈a⌉₊ ↔ 0 < a

Next tactic:
rw [← zero_add 1, Nat.add_one_le_ceil_iff, Nat.cast_zero]
theorem ceil_le_floor_add_one (a : α) : ⌈a⌉₊ ≤ ⌊a⌋₊ + 1 := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
⊢ ⌈a⌉₊ ≤ ⌊a⌋₊ + 1

Next tactic:
rw [ceil_le, Nat.cast_add, Nat.cast_one]
theorem ceil_le_floor_add_one (a : α) : ⌈a⌉₊ ≤ ⌊a⌋₊ + 1 := by
  rw [ceil_le, Nat.cast_add, Nat.cast_one]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
⊢ a ≤ ↑⌊a⌋₊ + 1

Next tactic:
exact (lt_floor_add_one a).le
@[simp]
theorem ceil_intCast {α : Type*} [LinearOrderedRing α] [FloorSemiring α] (z : ℤ) :
    ⌈(z : α)⌉₊ = z.toNat :=
  eq_of_forall_ge_iff fun a => by
    

Proof state:
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedSemiring α✝
inst✝² : FloorSemiring α✝
a✝ : α✝
n : ℕ
α : Type u_4
inst✝¹ : LinearOrderedRing α
inst✝ : FloorSemiring α
z : ℤ
a : ℕ
⊢ ⌈↑z⌉₊ ≤ a ↔ Int.toNat z ≤ a

Next tactic:
simp only [ceil_le, Int.toNat_le]
@[simp]
theorem ceil_intCast {α : Type*} [LinearOrderedRing α] [FloorSemiring α] (z : ℤ) :
    ⌈(z : α)⌉₊ = z.toNat :=
  eq_of_forall_ge_iff fun a => by
    simp only [ceil_le, Int.toNat_le]
    

Proof state:
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedSemiring α✝
inst✝² : FloorSemiring α✝
a✝ : α✝
n : ℕ
α : Type u_4
inst✝¹ : LinearOrderedRing α
inst✝ : FloorSemiring α
z : ℤ
a : ℕ
⊢ ↑z ≤ ↑a ↔ z ≤ ↑a

Next tactic:
norm_cast
@[simp]
theorem ceil_natCast (n : ℕ) : ⌈(n : α)⌉₊ = n :=
  eq_of_forall_ge_iff fun a => by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n✝ n a : ℕ
⊢ ⌈↑n⌉₊ ≤ a ↔ n ≤ a

Next tactic:
rw [ceil_le, cast_le]
@[simp]
theorem ceil_zero : ⌈(0 : α)⌉₊ = 0 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌈0⌉₊ = 0

Next tactic:
rw [← Nat.cast_zero, ceil_natCast]