Timings for naturals.v
Require Import
HoTT.Types.Sigma.
Require Import
HoTT.Classes.theory.naturals.
Require Import
HoTT.Classes.interfaces.abstract_algebra
HoTT.Classes.interfaces.orders
HoTT.Classes.theory.rings
HoTT.Classes.orders.rings
HoTT.Classes.implementations.peano_naturals.
Require Export
HoTT.Classes.orders.nat_int.
Generalizable Variables N R Rle Rlt f.
Context `{Funext} `{Univalence}.
Context `{Naturals N} `{!TrivialApart N}.
Instance nat_nonneg x : PropHolds (0 ≤ x).
apply (to_semiring_nonneg (f:=id)).
Lemma nat_le_plus {x y: N}: x ≤ y <-> exists z, y = x + z.
destruct (decompose_le E) as [z [Ez1 Ez2]].
apply compose_le with z; [solve_propholds | trivial].
Lemma nat_not_neg x : ~(x < 0).
apply le_not_lt_flip, nat_nonneg.
Lemma nat_0_or_pos x : x = 0 |_| 0 < x.
destruct (trichotomy (<) 0 x) as [?|[?|?]]; auto.
destruct (nat_not_neg x).
Lemma nat_0_or_ge_1 x : x = 0 |_| 1 ≤ x.
destruct (nat_0_or_pos x);auto.
Lemma nat_ne_0_pos x : x <> 0 <-> 0 < x.
destruct (nat_0_or_pos x); auto.
intros E;destruct E;trivial.
destruct (irreflexivity (<) 0).
Lemma nat_ne_0_ge_1 x : x <> 0 <-> 1 ≤ x.
#[export] Instance orderreflecting_left_mult : forall (z : N), PropHolds (z <> 0) -> OrderReflecting (z *.).
apply (order_reflecting_pos (.*.) z).
#[export] Instance slow_nat_le_dec: forall x y: N, Decidable (x ≤ y) | 10.
destruct (nat_le_dec (naturals_to_semiring _ nat x) (naturals_to_semiring _ nat y))
as [E | E].
apply (order_reflecting (naturals_to_semiring N nat)).
apply order_preserving;trivial.
Context `{IsCRing R} `{Apart R} `{!FullPseudoSemiRingOrder (A:=R) Rle Rlt}
`{!IsSemiRingPreserving (f : N -> R)}.
Lemma negate_to_ring_nonpos n : -f n ≤ 0.
apply flip_nonneg_negate.
apply to_semiring_nonneg.
Lemma between_to_ring n : -f n ≤ f n.
apply to_semiring_nonneg.
#[export]
Hint Extern 20 (PropHolds (_ ≤ _)) => eapply @nat_nonneg : typeclass_instances.