File: Mathlib/Data/Nat/Cast/Defs.lean

full_name: Nat.unaryCast
code: /-- The numeral `((0+1)+⋯)+1`. -/
protected def Nat.unaryCast [One R] [Zero R] [Add R] : ℕ → R
  
goal: ℕ → R

full_name: Nat.AtLeastTwo
code: /-- A type class for natural numbers which are greater than or equal to `2`. -/
class Nat.AtLeastTwo (n : ℕ) : Prop where
  prop : n ≥ 2
goal: Prop

full_name: Nat.AtLeastTwo.prop
code: /-- A type class for natural numbers which are greater than or equal to `2`. -/
class Nat.AtLeastTwo (n : ℕ) : Prop where
  prop : n ≥ 2
goal: n ≥ 2

full_name: instNatAtLeastTwo
code: instance instNatAtLeastTwo {n : ℕ} : Nat.AtLeastTwo (n + 2) 
goal: (n + 2).AtLeastTwo

full_name: Nat.AtLeastTwo.one_lt
code: lemma one_lt : 1 < n 
goal: 1 < n

full_name: Nat.AtLeastTwo.ne_one
code: lemma ne_one : n ≠ 1 
goal: n ≠ 1

full_name: instOfNatAtLeastTwo
code: /-- Recognize numeric literals which are at least `2` as terms of `R` via `Nat.cast`. This
instance is what makes things like `37 : R` type check.  Note that `0` and `1` are not needed
because they are recognized as terms of `R` (at least when `R` is an `AddMonoidWithOne`) through
`Zero` and `One`, respectively. -/
@[nolint unusedArguments]
instance (priority := 100) instOfNatAtLeastTwo {n : ℕ} [NatCast R] [Nat.AtLeastTwo n] :
    OfNat R n 
goal: OfNat R n

full_name: Nat.cast_ofNat
code: @[simp, norm_cast] theorem Nat.cast_ofNat {n : ℕ} [NatCast R] [Nat.AtLeastTwo n] :
  (Nat.cast (no_index (OfNat.ofNat n)) : R) = OfNat.ofNat n 
goal: ↑(OfNat.ofNat n) = OfNat.ofNat n

full_name: Nat.cast_eq_ofNat
code: theorem Nat.cast_eq_ofNat {n : ℕ} [NatCast R] [Nat.AtLeastTwo n] :
    (Nat.cast n : R) = OfNat.ofNat n 
goal: ↑n = OfNat.ofNat n

full_name: AddMonoidWithOne
code: /-- An `AddMonoidWithOne` is an `AddMonoid` with a `1`.
It also contains data for the unique homomorphism `ℕ → R`. -/
class AddMonoidWithOne (R : Type*) extends NatCast R, AddMonoid R, One R where
  natCast := Nat.unaryCast
  /-- The canonical map `ℕ → R` sends `0 : ℕ` to `0 : R`. -/
  natCast_zero : natCast 0 = 0 := by intros; rfl
  /-- The canonical map `ℕ → R` is a homomorphism. -/
  natCast_succ : ∀ n, natCast (n + 1) = natCast n + 1 := by intros; rfl
goal: Type u_2

full_name: AddMonoidWithOne.natCast_succ
code: /-- An `AddMonoidWithOne` is an `AddMonoid` with a `1`.
It also contains data for the unique homomorphism `ℕ → R`. -/
class AddMonoidWithOne (R : Type*) extends NatCast R, AddMonoid R, One R where
  natCast := Nat.unaryCast
  /-- The canonical map `ℕ → R` sends `0 : ℕ` to `0 : R`. -/
  natCast_zero : natCast 0 = 0 := by intros; rfl
  /-- The canonical map `ℕ → R` is a homomorphism. -/
  natCast_succ : ∀ n, natCast (n + 1) = natCast n + 1 := by intros; rfl
goal: NatCast.natCast (n + 1) = NatCast.natCast n + 1

full_name: AddMonoidWithOne.natCast_zero
code: /-- An `AddMonoidWithOne` is an `AddMonoid` with a `1`.
It also contains data for the unique homomorphism `ℕ → R`. -/
class AddMonoidWithOne (R : Type*) extends NatCast R, AddMonoid R, One R where
  natCast := Nat.unaryCast
  /-- The canonical map `ℕ → R` sends `0 : ℕ` to `0 : R`. -/
  natCast_zero : natCast 0 = 0 := by intros; rfl
  /-- The canonical map `ℕ → R` is a homomorphism. -/
  natCast_succ : ∀ n, natCast (n + 1) = natCast n + 1 := by intros; rfl
goal: NatCast.natCast 0 = 0

full_name: AddCommMonoidWithOne
code: /-- An `AddCommMonoidWithOne` is an `AddMonoidWithOne` satisfying `a + b = b + a`.  -/
class AddCommMonoidWithOne (R : Type*) extends AddMonoidWithOne R, AddCommMonoid R
goal: Type u_2

full_name: Nat.cast_zero
code: @[simp, norm_cast]
theorem cast_zero : ((0 : ℕ) : R) = 0 
goal: ↑0 = 0

full_name: Nat.cast_succ
code: @[norm_cast 500]
theorem cast_succ (n : ℕ) : ((succ n : ℕ) : R) = n + 1 
goal: ↑n.succ = ↑n + 1

full_name: Nat.cast_add_one
code: theorem cast_add_one (n : ℕ) : ((n + 1 : ℕ) : R) = n + 1 
goal: ↑(n + 1) = ↑n + 1

full_name: Nat.cast_ite
code: @[simp, norm_cast]
theorem cast_ite (P : Prop) [Decidable P] (m n : ℕ) :
    ((ite P m n : ℕ) : R) = ite P (m : R) (n : R) 
goal: ↑(if P then m else n) = if P then ↑m else ↑n

full_name: Nat.cast_one
code: @[simp, norm_cast]
theorem cast_one [AddMonoidWithOne R] : ((1 : ℕ) : R) = 1 
goal: ↑1 = 1

full_name: Nat.cast_add
code: @[simp, norm_cast]
theorem cast_add [AddMonoidWithOne R] (m n : ℕ) : ((m + n : ℕ) : R) = m + n 
goal: ↑(m + n) = ↑m + ↑n

full_name: Nat.binCast
code: /-- Computationally friendlier cast than `Nat.unaryCast`, using binary representation. -/
protected def binCast [Zero R] [One R] [Add R] : ℕ → R
  
goal: ℕ → R

full_name: Nat.binCast_eq
code: @[simp]
theorem binCast_eq [AddMonoidWithOne R] (n : ℕ) :
    (Nat.binCast n : R) = ((n : ℕ) : R) 
goal: n.binCast = ↑n

full_name: Nat.cast_two
code: theorem cast_two [AddMonoidWithOne R] : ((2 : ℕ) : R) = (2 : R) 
goal: ↑2 = 2

full_name: AddMonoidWithOne.unary
code: /-- `AddMonoidWithOne` implementation using unary recursion. -/
protected abbrev AddMonoidWithOne.unary [AddMonoid R] [One R] : AddMonoidWithOne R 
goal: AddMonoidWithOne R

full_name: AddMonoidWithOne.binary
code: /-- `AddMonoidWithOne` implementation using binary recursion. -/
protected abbrev AddMonoidWithOne.binary [AddMonoid R] [One R] : AddMonoidWithOne R 
goal: AddMonoidWithOne R

full_name: one_add_one_eq_two
code: theorem one_add_one_eq_two [AddMonoidWithOne R] : 1 + 1 = (2 : R) 
goal: 1 + 1 = 2

full_name: two_add_one_eq_three
code: theorem two_add_one_eq_three [AddMonoidWithOne R] : 2 + 1 = (3 : R) 
goal: 2 + 1 = 3

full_name: three_add_one_eq_four
code: theorem three_add_one_eq_four [AddMonoidWithOne R] : 3 + 1 = (4 : R) 
goal: 3 + 1 = 4