Commit 2022-02-01 18:42 cc9b9f34

View on Github →

refactor: remove numeric (#177) This removes the Numeric parent for Semiring which was used for both coercions and numerals, and replaces it by a low-priority instance for OfNat on Semiring. The coercion from Nat to R is removed. Numerals are now implemented using Nat.cast. As Sebastian has noted, to avoid diamonds for numerals it suffices that Nat.cast n and (n : R) are definitionally equal for every n : Nat. It is not necessary that (Nat.cast ∙) and (∙ : R) are definitionally equal as functions (and after this PR they are not, for most rings). Similarly, Nat.cast is carefully defined so that both 0 = 0 and 1 = 1 are true definitionally in any ring. The setup still has a couple of downsides:

  1. OfNat.ofNat must never be applied to anything except concrete natural numbers (or we get diamonds).
  2. (123456 : R) is a massive performance issue when executing in the VM. :-/ (Which is not entirely true, in reality it fails quickly due to a stack overflow.) We do not register Nat.cast as a coercion because of the performance issues.

Estimated changes

added theorem Nat.cast_Int
added theorem Nat.cast_Nat
added theorem Nat.cast_add
added theorem Nat.cast_mul
added theorem Nat.cast_one
added theorem Nat.cast_pow
added theorem Nat.cast_succ'
added theorem Nat.cast_succ
added theorem Nat.cast_succ_succ
added theorem Nat.cast_zero
deleted theorem Nat.ofNat_eq_Nat
added theorem Nat.pow_succ'
added theorem neg_mul_eq_neg_mul
deleted theorem ofNat_add
deleted theorem ofNat_eq_ofNat
deleted theorem ofNat_mul
deleted theorem ofNat_one
deleted theorem ofNat_pow
deleted theorem ofNat_zero
added theorem Fin.ext
added theorem Fin.ext_iff
added theorem Fin.neg_def
added theorem Fin.ofNat'_one
added theorem Fin.ofNat'_succ
added theorem Fin.ofNat'_zero
added theorem Fin.one_val
modified theorem Fin.size_positive'