Decimal digits that the kernel can evaluate #
Nat.toDecimal n is the list of the decimal digits of n, most significant first: Lean core's
Nat.toDigits 10 n, behind toString n (Nat.toDecimal_eq_toDigits). It is defined again, by
recursion on a fuel argument and with its body exposed, so that the kernel evaluates it:
Nat.toDigits has no exposed body. Int.toDecimal writes an integer, with - if it is
negative.
Nat.ofDecimal? is the checked reader of decimal numerals shared by the DIMACS and OPB front
ends: one or more decimal digits, read from the left by Nat.digitStep, which is the step of
core's Nat.ofDigitChars 10 (Nat.foldl_digitStep_eq_ofDigitChars). Each front end adds its
own syntax at its boundary: DIMACS its _ digit separators, OPB its signs. Reading back what
Nat.toDecimal writes gives the number (Nat.ofDecimal?_toDecimal), by core's
Nat.ofDigitChars_ten_toDigits.
Main definitions #
Nat.toDecimal,Int.toDecimal: the decimal digits of a number, of an integer.Nat.digitStep: reading one more digit.Nat.ofDecimal?: reading a decimal numeral.
Main statements #
Nat.toDecimal_eq_toDigits: the digits are those ofNat.toDigits 10.Nat.isDigit_of_mem_toDecimal: the digits are decimal digits.Nat.foldl_digitStep_eq_ofDigitChars: reading digits is core'sNat.ofDigitChars 10.Nat.ofDecimal?_toDecimal: reading back the digits of a number gives it.
The decimal digits of n, most significant first, without leading zeros: ['0'] for
0.
The value 10 * m + d of the digit c, with value d, after the value m of the digits
before it: the step of Nat.ofDigitChars 10.
The decimal digits of an integer, with - in front if it is negative.
The decimal digit of d < 10 is core's Nat.digitChar d.
The digits are those of Lean core's Nat.toDigits 10, which toString writes.
Reading digits by Nat.digitStep is core's Nat.ofDigitChars 10.
Reading back the decimal digits of a number gives it.