fact
stringlengths
0
6.66k
type
stringclasses
10 values
imports
stringclasses
399 values
filename
stringclasses
465 values
symbolic_name
stringlengths
1
75
index_level
int64
0
7.85k
Z_is_apart@{} : IsApart Z := ltac:(first [exact Z_is_apart'@{Ularge Ularge Ularge Ularge Ularge Ularge}| exact Z_is_apart'@{}]).
Instance
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_is_apart@
2,700
Z_full_psorder' : FullPseudoOrder Zle Zlt. Proof. split;[apply _|split;try apply _|]. - apply (Z_ind2 _). intros a b;rewrite !Zlt_def;unfold PairT.Tlt. apply pseudo_order_antisym. - hnf. intros a b E c;revert a b c E. apply (Z_ind3 (fun _ _ _ => _ -> _)). intros [pa na] [pb nb] [pc nc];rewrite !Zlt_def;unfold PairT.Tlt. intros E1. apply (strictly_order_preserving (+ nc)) in E1. eapply (merely_destruct (cotransitive E1 _));intros [E2|E2];apply tr. + left. apply (strictly_order_reflecting ((nb) +)). assert (Hrw : nb + (pa + nc) = pa + nb + nc) by ring_with_nat;rewrite Hrw;exact E2. + right. apply (strictly_order_reflecting ((na) +)). assert (Hrw : na + (pc + nb) = nb + (pc + na)) by ring_with_nat;rewrite Hrw;clear Hrw. assert (Hrw : na + (pb + nc) = pb + na + nc) by ring_with_nat;rewrite Hrw;clear Hrw. trivial. - apply @Z_ind2. + intros a b. apply @istrunc_prod;[|apply _]. apply (@istrunc_arrow _). apply ishprop_sum;try apply _. intros E1 E2;apply (irreflexivity lt a). transitivity b;trivial. + intros a b;rewrite Zapart_def,!Zlt_def;unfold PairT.Tapart,PairT.Tlt. apply apart_iff_total_lt. - apply (Z_ind2 _). intros a b;rewrite Zle_def,Zlt_def;unfold PairT.Tlt,PairT.Tle. apply le_iff_not_lt_flip. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_full_psorder'
2,701
Z_full_psorder@{} : FullPseudoOrder Zle Zlt := ltac:(first [exact Z_full_psorder'@{Ularge Ularge Ularge Ularge Ularge Ularge Ularge Ularge Ularge}| exact Z_full_psorder'@{Ularge Ularge Ularge Ularge Ularge Ularge Ularge Ularge Ularge Ularge}| exact Z_full_psorder'@{}]).
Instance
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_full_psorder@
2,702
Zmult_strong_ext_l' : forall z : Z, StrongExtensionality (z *.). Proof. red;apply (Z_ind3 (fun _ _ _ => _ -> _)). intros [zp zn] [xp xn] [yp yn];rewrite !Zapart_def;unfold PairT.Tapart;simpl. intros E1. refine (merely_destruct (strong_binary_extensionality (+) (zp * (xp + yn)) (zn * (yp + xn)) (zp * (yp + xn)) (zn * (xp + yn)) _) _). - assert (Hrw : zp * (xp + yn) + zn * (yp + xn) = zp * xp + zn * xn + (zp * yn + zn * yp)) by ring_with_nat;rewrite Hrw;clear Hrw. assert (Hrw : zp * (yp + xn) + zn * (xp + yn) = zp * yp + zn * yn + (zp * xn + zn * xp)) by ring_with_nat;rewrite Hrw;exact E1. - intros [E2|E2]. + apply (strong_extensionality (zp *.)). trivial. + apply symmetry;apply (strong_extensionality (zn *.)). trivial. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Zmult_strong_ext_l'
2,703
Zmult_strong_ext_l@{} : forall z : Z, StrongExtensionality (z *.
Instance
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Zmult_strong_ext_l@
2,704
Z_full_pseudo_srorder@{} : FullPseudoSemiRingOrder Zle Zlt. Proof. pose proof Z_ring. first [apply from_full_pseudo_ring_order@{UN UN UN UN UN UN UN Ularge}| apply from_full_pseudo_ring_order]; try apply _. apply apartness.strong_binary_setoid_morphism_commutative. Qed.
Instance
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_full_pseudo_srorder@
2,705
Z_to_ring_morphism' `{IsCRing B} : IsSemiRingPreserving (integers_to_ring Z B). Proof. split;split;red. - change (@sg_op B _) with (@plus B _); change (@sg_op Z _) with (@plus Z _). apply (Z_ind2 _). intros [pa na] [pb nb]. unfold integers_to_ring;simpl. rewrite !(preserves_plus (f:=naturals_to_semiring N B)). rewrite negate_plus_distr. ring_with_nat. - change (@mon_unit B _) with (@zero B _); change (@mon_unit Z _) with (@zero Z _). unfold integers_to_ring;simpl. rewrite (preserves_0 (f:=naturals_to_semiring N B)). rewrite negate_0,plus_0_r;trivial. - change (@sg_op B _) with (@mult B _); change (@sg_op Z _) with (@mult Z _). apply (Z_ind2 _). intros [pa na] [pb nb]. unfold integers_to_ring;simpl. rewrite !(preserves_plus (f:=naturals_to_semiring N B)). rewrite !(preserves_mult (f:=naturals_to_semiring N B)). rewrite (preserves_plus (f:=naturals_to_semiring N B)). rewrite !(preserves_mult (f:=naturals_to_semiring N B)). rewrite negate_plus_distr. rewrite negate_mult_distr_r,negate_mult_distr_l. rewrite <-(negate_mult_negate (naturals_to_semiring N B na) (naturals_to_semiring N B nb)). ring_with_nat. - change (@mon_unit B _) with (@one B _); change (@mon_unit Z _) with (@one Z _). unfold integers_to_ring;simpl. rewrite (preserves_1 (f:=naturals_to_semiring N B)). rewrite (preserves_0 (f:=naturals_to_semiring N B)). rewrite negate_0,plus_0_r;trivial. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_to_ring_morphism'
2,706
Z_to_ring_morphism@{} `{IsCRing B} : IsSemiRingPreserving (integers_to_ring Z B) := ltac:(first [exact Z_to_ring_morphism'@{Ularge}| exact Z_to_ring_morphism'@{}]).
Instance
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_to_ring_morphism@
2,707
Z_to_ring_unique@{} `{IsCRing B} (h : Z -> B) `{!IsSemiRingPreserving h} : forall x : Z, integers_to_ring Z B x = h x. Proof. pose proof Z_ring. apply (Z_ind _). intros [pa na];unfold integers_to_ring;simpl. rewrite Npair_splits. rewrite (preserves_plus (f:=h)),(preserves_negate (f:=h)). change (h (' pa)) with (Compose h (cast N Z) pa). change (h (' na)) with (Compose h (cast N Z) na). rewrite 2!(naturals_initial (h:=Compose h (cast N Z))). trivial. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_to_ring_unique@
2,708
Z_abs_aux_0@{} : forall a b z : N, a + z = b -> z = 0 -> naturals_to_semiring N Z 0 = ' {| PairT.pos := a; PairT.neg := b |}. Proof. intros a b z E E'. rewrite (preserves_0 (A:=N)). rewrite E',plus_0_r in E. rewrite E. apply Z_path. red;simpl. apply plus_comm. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_abs_aux_0@
2,709
Z_abs_aux_neg@{} : forall a b z : N, a + z = b -> naturals_to_semiring N Z z = - ' {| PairT.pos := a; PairT.neg := b |}. Proof. intros a b z E. rewrite <-(naturals.to_semiring_unique (cast N Z)). apply Z_path. red;simpl. rewrite plus_0_r,plus_comm;trivial. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_abs_aux_neg@
2,710
Z_abs_aux_pos@{} : forall a b z : N, b + z = a -> naturals_to_semiring N Z z = ' {| PairT.pos := a; PairT.neg := b |}. Proof. intros a b z E. rewrite <-(naturals.to_semiring_unique (cast N Z)). apply Z_path;red;simpl. rewrite plus_0_r,plus_comm;trivial. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_abs_aux_pos@
2,711
Z_abs_def@{} : forall x : PairT.T N, (exists n : N, naturals_to_semiring N Z n = ' x) |_| (exists n : N, naturals_to_semiring N Z n = - ' x). Proof. intros [a b]. destruct (nat_distance_sig a b) as [[z E]|[z E]]. - destruct (dec (z = 0)) as [E'|_]. + left. exists 0. apply Z_abs_aux_0 with z;trivial. + right. exists z. apply Z_abs_aux_neg;trivial. - left. exists z. apply Z_abs_aux_pos;trivial. Defined.
Definition
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_abs_def@
2,712
Z_abs_respects' : forall (x y : PairT.T N) (E : PairT.equiv x y), transport (fun q : Z => (exists n : N, naturals_to_semiring N Z n = q) |_| (exists n : N, naturals_to_semiring N Z n = - q)) (Z_path E) (Z_abs_def x) = Z_abs_def y. Proof. intros [pa pb] [na nb] E. red in E; simpl in E. unfold Z_abs_def. destruct (nat_distance_sig pa pb) as [[z1 E1] | [z1 E1]];simpl. - destruct (dec (z1 = 0)) as [E2 | E2]. + rewrite Sum.transport_sum. rewrite Sigma.transport_sigma. destruct (nat_distance_sig na nb) as [[z2 E3] | [z2 E3]]; [destruct (dec (z2 = 0)) as [E4 | E4]|];simpl. * apply ap. apply Sigma.path_sigma_hprop;simpl. apply PathGroupoids.transport_const. * destruct E4. rewrite <-E1,<-E3,E2,plus_0_r,<-(plus_0_r (na+pa)) in E. rewrite plus_assoc,(plus_comm pa) in E. apply (left_cancellation plus _) in E. trivial. * apply ap. apply Sigma.path_sigma_hprop. simpl. rewrite PathGroupoids.transport_const. rewrite E2,plus_0_r in E1. rewrite <-E3,E1 in E. apply (left_cancellation plus (pb + nb)). rewrite plus_0_r. etransitivity;[apply E|]. ring_with_nat. + rewrite Sum.transport_sum,Sigma.transport_sigma. destruct (nat_distance_sig na nb) as [[z2 E3] | [z2 E3]]; [destruct (dec (z2 = 0)) as [E4 | E4]|];simpl. * destruct E2. rewrite E4,plus_0_r in E3;rewrite <-E1,<-E3 in E. apply (left_cancellation plus (pa+na)). rewrite (plus_comm pa na),plus_0_r,<-plus_assoc. rewrite (plus_comm na pa). symmetry;trivial. * apply ap. apply Sigma.path_sigma_hprop. simpl. rewrite PathGroupoids.transport_const. rewrite <-E1,<-E3 in E. apply (left_cancellation plus (pa + na)). rewrite <-(plus_assoc pa na z2),(plus_comm pa na),<-plus_assoc. symmetry;trivial. * destruct E2. rewrite <-E1,<-E3 in E. assert (Erw : nb + z2 + (pa + z1) = (pa + nb) + (z2 + z1)) by ring_with_nat. rewrite <-(plus_0_r (pa+nb)),Erw in E. apply (left_cancellation plus _),symmetry,naturals.zero_sum in E. apply E. - rewrite Sum.transport_sum,Sigma.transport_sigma. simpl. destruct (nat_distance_sig na nb) as [[z2 E3] | [z2 E3]]; [destruct (dec (z2 = 0)) as [E4 | E4]|];simpl. + apply ap. apply Sigma.path_sigma_hprop. simpl. rewrite PathGroupoids.transport_const. rewrite <-E1,<-E3,E4,plus_0_r in E. apply (left_cancellation plus (na+pb)). rewrite plus_0_r. path_via (pb + z1 + na). ring_with_nat. + destruct E4. rewrite <-E1,<-E3 in E. assert (Hrw : pb + z1 + (na + z2) = (na + pb) + (z1 + z2)) by ring_with_nat. rewrite <-(plus_0_r (na+pb)),Hrw in E. apply (left_cancellation _ _),naturals.zero_sum in E. apply E. + apply ap,Sigma.path_sigma_hprop. simpl. rewrite PathGroupoids.transport_const. rewrite <-E1,<-E3 in E. apply (left_cancellation plus (pb+nb)). path_via (pb + z1 + nb);[|path_via (nb + z2 + pb)];ring_with_nat. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_abs_respects'
2,713
Z_abs' : IntAbs Z N. Proof. red. apply (Z_rect _ Z_abs_def). exact Z_abs_respects'. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_abs'
2,714
a b : n_to_z a * n_to_z b = 0 -> n_to_z a = 0 |_| n_to_z b = 0. Proof. rewrite <-rings.preserves_mult. rewrite <-!(naturals.to_semiring_unique (cast N Z)). intros E. change 0 with (' 0) in E. apply (injective _) in E. apply zero_product in E. destruct E as [E|E];rewrite E;[left|right];apply preserves_0. Qed.
Definition
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
zero_product_aux
2,715
Z_zero_product' : ZeroProduct Z. Proof. intros x y E. destruct (int_abs_sig Z N x) as [[a Ea]|[a Ea]], (int_abs_sig Z N y) as [[b Eb]|[b Eb]]. - rewrite <-Ea,<-Eb in E. apply zero_product_aux in E. rewrite <-Ea,<-Eb. trivial. - apply (ap negate) in E. rewrite negate_mult_distr_r in E. rewrite <-Ea,<-Eb in E. rewrite negate_0 in E. apply zero_product_aux in E. destruct E as [E|E]. + left;rewrite <-Ea;trivial. + right. apply (injective negate). rewrite negate_0,<-Eb;trivial. - apply (ap negate) in E. rewrite negate_mult_distr_l in E. rewrite <-Ea,<-Eb in E. rewrite negate_0 in E. apply zero_product_aux in E. destruct E as [E|E]. + left. apply (injective negate). rewrite negate_0,<-Ea;trivial. + right;rewrite <-Eb;trivial. - rewrite <-negate_mult_negate,<-Ea,<-Eb in E. apply zero_product_aux in E. destruct E as [E|E]. + left. apply (injective negate). rewrite negate_0,<-Ea;trivial. + right. apply (injective negate). rewrite negate_0,<-Eb;trivial. Qed.
Lemma
Require Import HoTT.HIT.quotient Require Import Import ring_quote.Quoting.Instances. Module Import PairT.
Classes\implementations\natpair_integers.v
Z_zero_product'
2,716
Type := one: T → | cons: T → → .
Inductive
Require Import
Classes\implementations\ne_list.v
ne_list
2,717
(a b: ne_list): ne_list := match a with | one x => cons x b | cons x y => cons x ( y b) end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
app
2,718
{R} (u: T → R) (f: T → R → R) (a: ne_list): R := match a with | one x => u x | cons x y => f x ( u f y) end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
foldr
2,719
(f: T → T → T) (a: ne_list): T := match a with | one x => x | cons x y => f x ( f y) end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
foldr1
2,720
(l: ne_list): T := match l with one x => x | cons x _ => x end.
Definition
Require Import
Classes\implementations\ne_list.v
head
2,721
(l: ne_list): list T := match l with | one x => x :: nil | cons x xs => x :: xs end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
to_list
2,722
(x: T) (xs: list T): ne_list := match xs with | nil => one x | List.
Fixpoint
Require Import
Classes\implementations\ne_list.v
from_list
2,723
(l: ne_list): list T := match l with one _ => nil | cons _ x => to_list x end.
Definition
Require Import
Classes\implementations\ne_list.v
tail
2,724
(l: ne_list): l = from_list (head l) (tail l).
Lemma
Require Import
Classes\implementations\ne_list.v
decomp_eq
2,725
ne_list → T := foldr1 (fun x y => y).
Definition
Require Import
Classes\implementations\ne_list.v
last
2,726
(x: T) (n: nat): ne_list := match n with | 0 => one x | S n' => cons x ( x n') end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
replicate_Sn
2,727
(n: nat) (l: ne_list): ne_list := match l, n with | cons x xs, S n' => n' xs | _, _ => one (head l) end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
take
2,728
(l: ne_list) : list T := match l with | one _ => nil | cons x xs => x :: xs end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
front
2,729
(P: ne_list → Type) (Pone: ∀ x, P (one x)) (Ptwo: ∀ x y, P (cons x (one y))) (Pmore: ∀ x y z, P z → (∀ y', P (cons y' z)) → P (cons x (cons y z))) : ∀ l, P l.
Lemma
Require Import
Classes\implementations\ne_list.v
two_level_rect
2,730
(l: ne_list) : S (length (List.Core.tail (to_list l))) = length (to_list l). Proof. destruct l; reflexivity. Qed.
Lemma
Require Import
Classes\implementations\ne_list.v
tail_length
2,731
{T} (l: ne_list T): ne_list (ne_list T) := match l with | one x => one (one x) | cons x y => cons l ( y) end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
tails
2,732
{T} (y x: ne_list T): InList x (to_list (tails y)) → leq (length (to_list x)) (length (to_list y)). Proof. induction y; cbn. - intros [[] | C]. + constructor. + elim C. - intros [[] | C]. + exact _. + by apply leq_succ_r, IHy. Qed.
Lemma
Require Import
Classes\implementations\ne_list.v
tails_are_shorter
2,733
{A B} (f: A → B) (l: ne_list A): ne_list B := match l with | one x => one (f x) | cons h t => cons (f h) ( f t) end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
map
2,734
{A B} (f: A → B) (l: ne_list A) : to_list (map f l) = List.Core. f (to_list l). Proof. induction l. - reflexivity. - cbn. rewrite <- IHl. reflexivity. Qed.
Lemma
Require Import
Classes\implementations\ne_list.v
list_map
2,735
{A} (l: ne_list A): ne_list (ne_list A) := match l with | one x => one (one x) | cons h t => cons (one h) (map (cons h) ( t)) end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
inits
2,736
{A B: Type} (l: ne_list A) (m: ne_list B) : ne_list (A * B) := match l with | one a => one (a, head m) | cons a l => match m with | one b => one (a, b) | cons b m => cons (a, b) ( l m) end end.
Fixpoint
Require Import
Classes\implementations\ne_list.v
zip
2,737
Symmetric@{N N} natpaths. Proof. unfold natpaths; apply _. Defined.
Definition
Require Import
Classes\implementations\peano_naturals.v
natpaths_symm
2,738
a b : S a + b =N= S (a + b) := idpath. Local Instance add_0_r : RightIdentity@{N N} (plus : Plus nat) (zero : Zero nat). Proof. intros a; induction a as [| a IHa]. - reflexivity. - apply (ap S), IHa. Qed.
Definition
Require Import
Classes\implementations\peano_naturals.v
add_S_l
2,739
forall a b, a + S b =N= S (a + b). Proof. intros a b; induction a as [| a IHa]. - reflexivity. - apply (ap S), IHa. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
add_S_r
2,740
a b : (S a) * b =N= b + a * b := idpath. Local Instance mul_1_l : LeftIdentity@{N N} (mult : Mult nat) (one : One nat) := add_0_r. Local Instance mul_0_r : RightAbsorb@{N N} (mult : Mult nat) (zero : Zero nat). Proof. intros a; induction a as [| a IHa]. - reflexivity. - change (a * 0 = 0). exact IHa. Qed.
Definition
Require Import
Classes\implementations\peano_naturals.v
mul_S_l
2,741
a b : a * S b =N= a + a * b. Proof. induction a as [| a IHa]. - reflexivity. - change (S (b + a * S b) = S (a + (b + a * b))). apply (ap S). rhs rapply add_assoc. rhs rapply (ap (fun x => x + _) (add_comm _ _)). rhs rapply (add_assoc _ _ _)^. exact (ap (plus b) IHa). Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
mul_S_r
2,742
x := match x with | 0%nat => 0 | S k => k end. Global Instance S_inj : IsInjective@{N N} S := { injective := fun a b E => ap E }. Global Instance nat_dec: DecidablePaths@{N} nat. Proof. hnf. apply (nat_rect@{N} (fun x => forall y, _)). - intros [|b]. + left;reflexivity. + right;apply symmetric_neq,S_neq_0. - intros a IHa [|b]. + right;apply S_neq_0. + destruct (IHa b). * left. apply ap;trivial. * right;intros E. apply (injective S) in E. auto. Defined.
Definition
Require Import
Classes\implementations\peano_naturals.v
pred
2,743
IsSemiCRing@{N} nat. Proof. repeat (split; try exact _). Qed.
Instance
Require Import
Classes\implementations\peano_naturals.v
nat_semiring
2,744
O =N= 0. Proof. reflexivity. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
O_nat_0
2,745
x : S x =N= x + 1. Proof. rewrite add_comm. reflexivity. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
S_nat_plus_1
2,746
x : S x =N= 1 + x. Proof. reflexivity. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
S_nat_1_plus
2,747
(P : nat -> Type) : P 0 -> (forall n, P n -> P (1 + n)) -> forall n, P n. Proof. apply nat_rect. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
nat_induction
2,748
forall a b : nat, a + b =N= 0 -> a =N= 0 /\ b =N= 0. Proof. intros [|a];[intros [|b];auto|]. - intros E. destruct (S_neq_0 _ E). - intros ? E. destruct (S_neq_0 _ E). Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
plus_eq_zero
2,749
forall a b : nat, a * b =N= 0 -> a =N= 0 |_| b =N= 0. Proof. intros [|a] [|b];auto. - intros _;right;reflexivity. - simpl_nat. intros E. destruct (S_neq_0 _ E). Defined.
Lemma
Require Import
Classes\implementations\peano_naturals.v
mult_eq_zero
2,750
NoZeroDivisors nat. Proof. intros x [Ex [y [Ey1 Ey2]]]. apply mult_eq_zero in Ey2. destruct Ey2;auto. Qed.
Instance
Require Import
Classes\implementations\peano_naturals.v
nat_zero_divisors
2,751
forall z:nat, LeftCancellation@{N} plus z. Proof. red. intros a;induction a as [|a IHa];simpl_nat;intros b c E. - trivial. - apply IHa. apply (injective S). assumption. Qed.
Instance
Require Import
Classes\implementations\peano_naturals.v
nat_plus_cancel_l
2,752
forall z : nat, PropHolds (~ (z =N= 0)) -> LeftCancellation@{N} (.*.) z. Proof. unfold PropHolds. unfold LeftCancellation. intros a Ea b c E;revert b c a Ea E. induction b as [|b IHb];intros [|c];simpl_nat;intros a Ea E. - reflexivity. - rewrite mul_0_r in E. rewrite mul_S_r in E;apply symmetry in E. apply plus_eq_zero in E. destruct (Ea (fst E)). - rewrite mul_0_r,mul_S_r in E. apply plus_eq_zero in E. destruct (Ea (fst E)). - rewrite 2!mul_S_r in E. apply (left_cancellation _ _) in E. apply ap. apply IHb with a;trivial. Qed.
Instance
Require Import
Classes\implementations\peano_naturals.v
nat_mult_cancel_l
2,753
forall n k, n <= k + n. Proof. induction k. - apply Nat.Core.leq_refl. - simpl_nat. constructor. assumption. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
le_plus
2,754
forall n m : nat, iff@{N N N} (n <= m) (sig@{N N} (fun k => m =N= k + n)). Proof. intros n m;split. - intros E;induction E as [|m E IH]. + exists 0;split. + destruct IH as [k IH]. exists (S k). rewrite IH;reflexivity. - intros [k Hk]. rewrite Hk. apply le_plus. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
le_exists
2,755
forall a, 0 <= a. Proof. induction a;constructor;auto. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
zero_least
2,756
forall a b : nat, iff@{N N N} (a <= b) (S a <= S b). Proof. intros. etransitivity;[apply le_exists|]. etransitivity;[|apply symmetry,le_exists]. split;intros [k E];exists k. - rewrite E,add_S_r. reflexivity. - rewrite add_S_r in E;apply (injective _) in E. trivial. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
le_S_S
2,757
forall a : nat, 0 < S a. Proof. intros. apply le_S_S. apply zero_least. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
lt_0_S
2,758
forall a b, a <= S b -> a <= b |_| a = S b. Proof. intros [|a] b. - intros;left;apply zero_least. - intros E. apply (snd (le_S_S _ _)) in E. destruct E as [|b E];auto. left. apply le_S_S. trivial. Defined.
Lemma
Require Import
Classes\implementations\peano_naturals.v
le_S_either
2,759
forall a b : nat, a <= b |_| b < a. Proof. induction a as [|a IHa]. - intros;left;apply zero_least. - intros [|b]. + right. apply lt_0_S. + destruct (IHa b). * left. apply le_S_S;trivial. * right. apply le_S_S. trivial. Defined.
Lemma
Require Import
Classes\implementations\peano_naturals.v
le_lt_dec
2,760
forall a, ~ (a < 0). Proof. intros a E. apply le_exists in E. destruct E as [k E]. apply natpaths_symm,plus_eq_zero in E. apply (S_neq_0 _ (snd E)). Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
not_lt_0
2,761
forall a b, a < b -> a <= b. Proof. intros. destruct b. - destruct (not_lt_0 a). trivial. - constructor. apply le_S_S. trivial. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
lt_le
2,762
Trichotomy@{N N i} (lt:Lt nat). Proof. hnf. fold natpaths. intros a b. destruct (le_lt_dec a b) as [[|]|E];auto. - right;left;split. - left. apply le_S_S. trivial. Qed.
Instance
Require Import
Classes\implementations\peano_naturals.v
nat_trichotomy
2,763
is_mere_relation nat nat_apart. Proof. intros;apply ishprop_sum;try apply _. intros E1 E2. apply (irreflexivity nat_lt x). transitivity y;trivial. Qed.
Instance
Require Import
Classes\implementations\peano_naturals.v
nat_apart_mere
2,764
x y : Decidable (nat_apart x y). Proof. rapply decidable_sum@{N N N}; apply Nat.Core.decidable_lt. Defined.
Instance
Require Import
Classes\implementations\peano_naturals.v
decidable_nat_apart
2,765
forall a b, ~ (a < b) -> b <= a. Proof. intros ?? E. destruct (le_lt_dec b a);auto. destruct E;auto. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
nat_not_lt_le
2,766
forall a b : nat, a < b -> ~ (b <= a). Proof. intros a b E1 E2. apply le_exists in E1;apply le_exists in E2. destruct E1 as [k1 E1], E2 as [k2 E2]. apply (S_neq_0 (k1 + k2)). apply (left_cancellation (+) a). fold natpaths. rewrite add_0_r. rewrite E1 in E2. rewrite add_S_r;rewrite !add_S_r in E2. rewrite (add_assoc a), (add_comm a), <-(add_assoc k1), (add_comm a). rewrite (add_assoc k1), (add_comm k1), <-(add_assoc k2). apply natpaths_symm,E2. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
nat_lt_not_le
2,767
forall a, 0 < S a. Proof. intros;apply le_S_S,zero_least. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
S_gt_0
2,768
forall a, ~ (a =N= 0) -> 0 < a. Proof. intros [|a] E. - destruct E;split. - apply S_gt_0. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
nonzero_gt_0
2,769
forall a b c : nat, a <= b -> b < c -> a < c. Proof. intros a b c E1 E2. apply le_exists in E1;apply le_exists in E2. destruct E1 as [k1 E1],E2 as [k2 E2];rewrite E2,E1. rewrite add_S_r,add_assoc. apply le_S_S,le_plus. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
nat_le_lt_trans
2,770
forall a b : nat, a < b -> forall c, a < c |_| c < b. Proof. intros a b E1 c. destruct (le_lt_dec c a) as [E2|E2]. - right. apply nat_le_lt_trans with a;trivial. - left;trivial. Defined.
Lemma
Require Import
Classes\implementations\peano_naturals.v
lt_strong_cotrans
2,771
nat_full' : FullPseudoSemiRingOrder nat_le nat_lt. Proof. split;[apply _|split|]. - split;try apply _. + intros a b [E1 E2]. destruct (irreflexivity lt a). transitivity b;trivial. + hnf. intros a b E c;apply tr;apply lt_strong_cotrans;trivial. + reflexivity. - intros a b E. apply nat_not_lt_le,le_exists in E. destruct E as [k E];exists k;rewrite plus_comm;auto. - split. + intros a b E. apply le_exists in E;destruct E as [k Hk]. rewrite Hk. rewrite add_S_r,<-add_S_l. rewrite plus_assoc,(plus_comm z (S k)), <-plus_assoc. apply le_S_S,le_plus. + intros a b E. apply le_exists in E;destruct E as [k E]. rewrite <-add_S_r,plus_assoc,(plus_comm k z),<-plus_assoc in E. apply (left_cancellation plus _) in E. rewrite E;apply le_plus. - intros ???? E. apply trivial_apart in E. destruct (dec (apart x₁ x₂)) as [?|ex];apply tr;auto. right. apply tight_apart in ex. apply trivial_apart. intros ey. apply E. apply ap011;trivial. - unfold PropHolds. intros a b Ea Eb. apply nonzero_gt_0. intros E. apply mult_eq_zero in E. destruct E as [E|E];[rewrite E in Ea|rewrite E in Eb]; apply (irreflexivity lt 0);trivial. - intros a b;split. + intros E1 E2. apply nat_lt_not_le in E2. auto. + intros E. destruct (le_lt_dec a b);auto. destruct E;auto. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
nat_full'
2,772
nat_full@{} := ltac:(first[exact nat_full'@{Ularge Ularge}| exact nat_full'@{Ularge Ularge N}| exact nat_full'@{}]).
Definition
Require Import
Classes\implementations\peano_naturals.v
nat_full@
2,773
n m : n <= Nat.Core.nat_max n m. Proof. revert m. induction n as [|n' IHn]; intros m; induction m as [|m' IHm]; try reflexivity; cbn. - apply zero_least. - apply le_S_S. exact (IHn m'). Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
le_nat_max_l
2,774
n m : m <= Nat.Core.nat_max n m. Proof. revert m. induction n as [|n' IHn]; intros m; induction m as [|m' IHm]; try reflexivity; cbn. - apply zero_least. - apply le_S_S. exact (IHn m'). Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
le_nat_max_r
2,775
OrderEmbedding S. Proof. split. - intros ??;apply le_S_S. - intros ??;apply le_S_S. Qed.
Instance
Require Import
Classes\implementations\peano_naturals.v
S_embedding
2,776
(h : nat -> R) `{!IsSemiRingPreserving h} x : naturals_to_semiring nat R x = h x. Proof. induction x as [|n E]. + change (0 = h 0). apply symmetry,preserves_0. + rewrite f_S. change (1 + naturals_to_semiring nat R n = h (1+n)). rewrite (preserves_plus (f:=h)). rewrite E. apply ap10,ap,symmetry,preserves_1. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
toR_unique
2,777
Naturals@{N N N N N N N i} nat. Proof. split;try apply _. intros;apply toR_unique, _. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
nat_naturals
2,778
forall a b, cut_minus (a + b) b =N= a. Proof. unfold cut_minus,nat_cut_minus. intros a b;revert a;induction b as [|b IH]. - intros [|a];simpl;try split. apply ap,add_0_r. - intros [|a]. + simpl. pose proof (IH 0) as E. rewrite add_0_l in E. exact E. + simpl. change nat_plus with plus. rewrite add_S_r,<-add_S_l;apply IH. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
plus_minus
2,779
forall n m : nat, n <= m -> m =N= (n + (cut_minus m n)). Proof. intros n m E. apply le_exists in E. destruct E as [k E];rewrite E. rewrite plus_minus. apply add_comm. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
le_plus_minus
2,780
forall a b, a <= b -> cut_minus a b =N= 0. Proof. unfold cut_minus,nat_cut_minus. intros a b;revert a;induction b as [|b IH];intros [|a];simpl. - split. - intros E;destruct (not_lt_0 _ E). - split. - intros E. apply IH;apply le_S_S,E. Qed.
Lemma
Require Import
Classes\implementations\peano_naturals.v
minus_ge
2,781
`{!IsBoundedJoinSemiLattice B} : IsBoundedJoinSemiLattice (A -> B). Proof. repeat split; try apply _; reduce_fun. * apply associativity. * apply left_identity. * apply right_identity. * apply commutativity. * apply binary_idempotent. Defined.
Instance
Require Import
Classes\implementations\pointwise.v
boundedjoinsemilattice_fun
2,782
`{!IsBoundedMeetSemiLattice B} : IsBoundedMeetSemiLattice (A -> B). Proof. repeat split; try apply _; reduce_fun. * apply associativity. * apply left_identity. * apply right_identity. * apply commutativity. * apply binary_idempotent. Defined.
Instance
Require Import
Classes\implementations\pointwise.v
boundedmeetsemilattice_fun
2,783
{A B : Type} (f : A -> B) {p : MapIn (Tr (-1)) f} : IsInjective f := fun x y pfeq => ap pr1 (@center _ (p (f y) (x; pfeq) (y; idpath))). Section strong_injective. Context {A B} {Aap : Apart A} {Bap : Apart B} (f : A -> B) . Class IsStrongInjective := { strong_injective : forall x y, x ≶ y -> f x ≶ f y ; strong_injective_mor : StrongExtensionality f }. End strong_injective. Section extras. Class CutMinusSpec A (cm : CutMinus A) `{Zero A} `{Plus A} `{Le A} := { cut_minus_le : forall x y, y ≤ x -> x ∸ y + y = x ; cut_minus_0 : forall x y, x ≤ y -> x ∸ y = 0 }. Global ishprop_issemigrouppreserving `{Funext} {A B : Type} `{IsHSet B} `{SgOp A} `{SgOp B} {f : A -> B} : IsHProp (IsSemiGroupPreserving f). Proof. unfold IsSemiGroupPreserving; exact _. Defined.
Instance
Require Import Spaces.Nat.Core. Require Import Modalities.ReflectiveSubuniverse.
Classes\interfaces\abstract_algebra.v
isinjective_mapinO_tr
2,784
{A B : Type} `{Plus A, Plus B, Mult A, Mult B, Zero A, Zero B, One A, One B} {f : A -> B} : _ <~> IsSemiRingPreserving f := ltac:(issig).
Definition
Require Import Spaces.Nat.Core. Require Import Modalities.ReflectiveSubuniverse.
Classes\interfaces\abstract_algebra.v
issig_IsSemiRingPreserving
2,785
{A B : Type} `{SgOp A} `{SgOp B} `{MonUnit A} `{MonUnit B} {f : A -> B} : _ <~> IsMonoidPreserving f := ltac:(issig). Global Instance ishprop_ismonoidpreserving `{Funext} {A B : Type} `{SgOp A} `{SgOp B} `{IsHSet B} `{MonUnit A} `{MonUnit B} (f : A -> B) : IsHProp (IsMonoidPreserving f). Proof. srapply (istrunc_equiv_istrunc _ ). srapply (istrunc_equiv_istrunc _ (equiv_sigma_prod0 _ _)^-1). srapply istrunc_prod. unfold IsUnitPreserving. exact _. Defined.
Definition
Require Import Spaces.Nat.Core. Require Import Modalities.ReflectiveSubuniverse.
Classes\interfaces\abstract_algebra.v
issig_IsMonoidPreserving
2,786
x y : _ <~> @IsSemiGroup x y := ltac:(issig). Global Instance ishprop_issemigroup `{Funext} : forall x y, IsHProp (@IsSemiGroup x y). Proof. intros x y; apply istrunc_S; intros a b. rewrite <- (eisretr ( x y) a). rewrite <- (eisretr ( x y) b). set (a' := ( x y)^-1 a). set (b' := ( x y)^-1 b). clearbody a' b'; clear a b. srapply (contr_equiv _ (ap ( x y))). rewrite <- (eissect (equiv_sigma_prod0 _ _) a'). rewrite <- (eissect (equiv_sigma_prod0 _ _) b'). set (a := equiv_sigma_prod0 _ _ a'). set (b := equiv_sigma_prod0 _ _ b'). clearbody a b; clear a' b'. srapply (contr_equiv _ (ap (equiv_sigma_prod0 _ _)^-1)). srapply (contr_equiv _ (equiv_path_prod _ _)). srapply contr_prod. destruct a as [a' a], b as [b' b]. do 3 (nrefine (contr_equiv' _ (@equiv_path_forall H _ _ _ _)); nrefine (@contr_forall H _ _ _); intro). exact _. Defined.
Definition
Require Import Spaces.Nat.Core. Require Import Modalities.ReflectiveSubuniverse.
Classes\interfaces\abstract_algebra.v
issig_issemigroup
2,787
x y z : _ <~> @IsMonoid x y z := ltac:(issig). Global Instance ishprop_ismonoid `{Funext} x y z : IsHProp (@IsMonoid x y z). Proof. apply istrunc_S. intros a b. rewrite <- (eisretr ( x y z) a). rewrite <- (eisretr ( x y z) b). set (a' := ( x y z)^-1 a). set (b' := ( x y z)^-1 b). clearbody a' b'; clear a b. srapply (contr_equiv _ (ap ( x y z))). rewrite <- (eissect (equiv_sigma_prod0 _ _) a'). rewrite <- (eissect (equiv_sigma_prod0 _ _) b'). set (a := equiv_sigma_prod0 _ _ a'). set (b := equiv_sigma_prod0 _ _ b'). clearbody a b; clear a' b'. srapply (contr_equiv _ (ap (equiv_sigma_prod0 _ _)^-1)). srapply (contr_equiv _ (equiv_path_prod _ _)). srapply contr_prod. destruct a as [a' a], b as [b' b]; cbn. rewrite <- (eissect (equiv_sigma_prod0 _ _) a). rewrite <- (eissect (equiv_sigma_prod0 _ _) b). set (a'' := equiv_sigma_prod0 _ _ a). set (b'' := equiv_sigma_prod0 _ _ b). clearbody a'' b''; clear a b. srapply (contr_equiv _ (ap (equiv_sigma_prod0 _ _)^-1)). srapply (contr_equiv _ (equiv_path_prod _ _)). destruct a'' as [a a''], b'' as [b b'']; cbn. snrapply contr_prod. all: srapply contr_paths_contr. all: srapply contr_inhabited_hprop. all: srapply istrunc_forall. Defined.
Definition
Require Import Spaces.Nat.Core. Require Import Modalities.ReflectiveSubuniverse.
Classes\interfaces\abstract_algebra.v
issig_ismonoid
2,788
w x y z : _ <~> @IsGroup w x y z := ltac:(issig). Global Instance ishprop_isgroup `{Funext} w x y z : IsHProp (@IsGroup w x y z). Proof. apply istrunc_S. intros a b. rewrite <- (eisretr ( w x y z) a). rewrite <- (eisretr ( w x y z) b). set (a' := ( w x y z)^-1 a). set (b' := ( w x y z)^-1 b). clearbody a' b'; clear a b. srapply (contr_equiv _ (ap ( w x y z))). rewrite <- (eissect (equiv_sigma_prod0 _ _) a'). rewrite <- (eissect (equiv_sigma_prod0 _ _) b'). set (a := equiv_sigma_prod0 _ _ a'). set (b := equiv_sigma_prod0 _ _ b'). clearbody a b; clear a' b'. srapply (contr_equiv _ (ap (equiv_sigma_prod0 _ _)^-1)). srapply (contr_equiv _ (equiv_path_prod _ _)). srapply contr_prod. destruct a as [a' a], b as [b' b]; cbn. rewrite <- (eissect (equiv_sigma_prod0 _ _) a). rewrite <- (eissect (equiv_sigma_prod0 _ _) b). set (a'' := equiv_sigma_prod0 _ _ a). set (b'' := equiv_sigma_prod0 _ _ b). clearbody a'' b''; clear a b. srapply (contr_equiv _ (ap (equiv_sigma_prod0 _ _)^-1)). srapply (contr_equiv _ (equiv_path_prod _ _)). destruct a'' as [a a''], b'' as [b b'']; cbn. srapply contr_prod. all: srapply contr_paths_contr. all: srapply contr_inhabited_hprop. all: srapply istrunc_forall. Defined.
Definition
Require Import Spaces.Nat.Core. Require Import Modalities.ReflectiveSubuniverse.
Classes\interfaces\abstract_algebra.v
issig_isgroup
2,789
Cast Q F := rationals_to_field Q F.
Definition
From HoTT.Classes Require Import
Classes\interfaces\archimedean.v
qinc
2,790
{A} {P : Type} {sP : IsHProp P} (x : merely A) : (A -> P) -> P. Proof. intros E;revert x. apply Trunc_ind. - apply _. - exact E. Qed.
Lemma
null
Classes\interfaces\canonical_names.v
merely_destruct
2,791
{A : Type} (a : A) := a.
Definition
null
Classes\interfaces\canonical_names.v
id
2,792
`{Apart A} (P: A -> Type) : Apart (sig P) := fun x y => x.
Definition
null
Classes\interfaces\canonical_names.v
sig_apart
2,793
R `{Zero R} `{Apart R} := sig (≶ zero).
Definition
null
Classes\interfaces\canonical_names.v
ApartZero
2,794
R `{Zero R} `{Le R} := sig (le zero).
Definition
null
Classes\interfaces\canonical_names.v
NonNeg
2,795
R `{Zero R} `{Lt R} := sig (lt zero).
Definition
null
Classes\interfaces\canonical_names.v
Pos
2,796
R `{Zero R} `{Le R} := sig (fun y => le y zero).
Definition
null
Classes\interfaces\canonical_names.v
NonPos
2,797
`{Abs A} := fun x : A => (abs_sig x).
Definition
null
Classes\interfaces\canonical_names.v
abs
2,798
`{UnaryIdempotent A f} x : f (f x) = f x. Proof. change (f (f x)) with (Compose f f x). apply (ap (fun g => g x)). change (Compose f f = f). apply idempotency. apply _. Qed.
Lemma
null
Classes\interfaces\canonical_names.v
unary_idempotency
2,799