# Documentation

Mathlib.Tactic.NormNum.Result

## The Result type for norm_num#

We set up predicates IsNat, IsInt, and IsRat, stating that an element of a ring is equal to the "normal form" of a natural number, integer, or rational number coerced into that ring.

We then define Result e, which contains a proof that a typed expression e : Q($α) is equal to the coercion of an explicit natural number, integer, or rational number, or is either true or false. A shortcut (non)instance for AddMonoidWithOne ℕ to shrink generated proofs. Instances For A shortcut (non)instance for AddMonoidWithOne α from Ring α to shrink generated proofs. Instances For Represent an integer as a "raw" typed expression. This uses .lit (.natVal n) internally to represent a natural number, rather than the preferred OfNat.ofNat form. We use this internally to avoid unnecessary typeclass searches. This function is the inverse of Expr.intLit!. Instances For Represent an integer as a "raw" typed expression. This .lit (.natVal n) internally to represent a natural number, rather than the preferred OfNat.ofNat form. We use this internally to avoid unnecessary typeclass searches. Instances For structure Mathlib.Meta.NormNum.IsNat {α : Type u_1} [] (a : α) (n : ) : • out : a = n The element is equal to the coercion of the natural number. Assert that an element of a semiring is equal to the coercion of some natural number. Instances For def Nat.rawCast {α : Type u_1} [] (n : ) : α A "raw nat cast" is an expression of the form (Nat.rawCast lit : α) where lit is a raw natural number literal. These expressions are used by tactics like ring to decrease the number of typeclass arguments required in each use of a number literal at type α. Instances For theorem Mathlib.Meta.NormNum.IsNat.to_eq {α : Type u_1} [] {n : } {a : α} {a' : α} : n = a'a = a' theorem Mathlib.Meta.NormNum.IsNat.to_raw_eq {α : Type u_1} {a : α} {n : } [] : a = theorem Mathlib.Meta.NormNum.IsNat.of_raw (α : Type u_1) [] (n : ) : theorem Mathlib.Meta.NormNum.isNat.natElim {p : } {n : } {n' : } : p n'p n structure Mathlib.Meta.NormNum.IsInt {α : Type u_1} [Ring α] (a : α) (n : ) : • out : a = n The element is equal to the coercion of the integer. Assert that an element of a ring is equal to the coercion of some integer. Instances For def Int.rawCast {α : Type u_1} [Ring α] (n : ) : α A "raw int cast" is an expression of the form: • (Nat.rawCast lit : α) where lit is a raw natural number literal • (Int.rawCast (Int.negOfNat lit) : α) where lit is a nonzero raw natural number literal (That is, we only actually use this function for negative integers.) This representation is used by tactics like ring to decrease the number of typeclass arguments required in each use of a number literal at type α. Instances For theorem Mathlib.Meta.NormNum.IsInt.to_isNat {α : Type u_1} [Ring α] {a : α} {n : } : theorem Mathlib.Meta.NormNum.IsNat.to_isInt {α : Type u_1} [Ring α] {a : α} {n : } : theorem Mathlib.Meta.NormNum.IsInt.to_raw_eq {α : Type u_1} {a : α} {n : } [Ring α] : a = theorem Mathlib.Meta.NormNum.IsInt.of_raw (α : Type u_1) [Ring α] (n : ) : theorem Mathlib.Meta.NormNum.IsInt.neg_to_eq {α : Type u_1} [Ring α] {n : } {a : α} {a' : α} : n = a'a = -a' theorem Mathlib.Meta.NormNum.IsInt.nonneg_to_eq {α : Type u_1} [Ring α] {n : } {a : α} {a' : α} (h : ) (e : n = a') : a = a' inductive Mathlib.Meta.NormNum.IsRat {α : Type u_1} [Ring α] (a : α) (num : ) (denom : ) : Assert that an element of a ring is equal to num / denom (and denom is invertible so that this makes sense). We will usually also have num and denom coprime, although this is not part of the definition. Instances For def Rat.rawCast {α : Type u_1} [] (n : ) (d : ) : α A "raw rat cast" is an expression of the form: • (Nat.rawCast lit : α) where lit is a raw natural number literal • (Int.rawCast (Int.negOfNat lit) : α) where lit is a nonzero raw natural number literal • (Rat.rawCast n d : α) where n is a raw int cast, d is a raw nat cast, and d is not 1 or 0. This representation is used by tactics like ring to decrease the number of typeclass arguments required in each use of a number literal at type α. Instances For theorem Mathlib.Meta.NormNum.IsRat.to_isNat {α : Type u_1} [Ring α] {a : α} {n : } : theorem Mathlib.Meta.NormNum.IsNat.to_isRat {α : Type u_1} [Ring α] {a : α} {n : } : theorem Mathlib.Meta.NormNum.IsRat.to_isInt {α : Type u_1} [Ring α] {a : α} {n : } : theorem Mathlib.Meta.NormNum.IsInt.to_isRat {α : Type u_1} [Ring α] {a : α} {n : } : theorem Mathlib.Meta.NormNum.IsRat.to_raw_eq {α : Type u_1} {n : } {d : } [] {a : α} : a = theorem Mathlib.Meta.NormNum.IsRat.neg_to_eq {α : Type u_1} [] {n : } {d : } {a : α} {n' : α} {d' : α} : n = n'd = d'a = -(n' / d') theorem Mathlib.Meta.NormNum.IsRat.nonneg_to_eq {α : Type u_1} [] {n : } {d : } {a : α} {n' : α} {d' : α} : n = n'd = d'a = n' / d' theorem Mathlib.Meta.NormNum.IsRat.of_raw (α : Type u_1) [] (n : ) (d : ) (h : d 0) : theorem Mathlib.Meta.NormNum.IsRat.den_nz {α : Type u_1} [] {a : α} {n : } {d : } : d 0 • isBool: Untyped version of Result.isBool. • isNat: Untyped version of Result.isNat. • isNegNat: Untyped version of Result.isNegNat. • isRat: Untyped version of Result.isRat. The result of norm_num running on an expression x of type α. Untyped version of Result. Instances For instance Mathlib.Meta.NormNum.instInhabitedResult : {a : Lean.Level} → {α : Q(Type a)} → {x : Q(«$α»)} →
instance Mathlib.Meta.NormNum.instToMessageDataResult :
{a : Lean.Level} → {α : Q(Type a)} → {x : Q(«$α»)} → def Mathlib.Meta.NormNum.Result.toRat : {a : Lean.Level} → {α : Q(Type a)} → {e : Q(«$α»)} →

Returns the rational number that is the result of norm_num evaluation.

Instances For
def Mathlib.Meta.NormNum.Result.toRatNZ :
{a : Lean.Level} → {α : Q(Type a)} → {e : Q(«$α»)} → Returns the rational number that is the result of norm_num evaluation, along with a proof that the denominator is nonzero in the isRat case. Instances For @[reducible] Given Mathlib.Meta.NormNum.Result.isBool p b, this is the type of p. Note that BoolResult p b is definitionally equal to Expr, and if you write match b with ..., then in the true branch BoolResult p true is reducibly equal to Q($p) and in the false branch it is reducibly equal to Q(¬ \$p).

Instances For
def Mathlib.Meta.NormNum.Result.ofBoolResult {p : Q(Prop)} {b : Bool} (prf : ) :

Obtain a Result from a BoolResult.

Instances For