fact
stringlengths
7
17.4k
type
stringclasses
23 values
library
stringclasses
22 values
imports
listlengths
0
26
filename
stringclasses
369 values
symbolic_name
stringlengths
1
47
docstring
stringclasses
1 value
Ring R : (CRing_Ring R) (preprocess [unfold cg_minus;simpl]).
Add
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
Ring
Ring cpolycring_th : (CRing_Ring (cpoly_cring R)) (preprocess [unfold cg_minus;simpl]). (** [Bernstein n i] is the ith element of the n dimensional Bernstein basis *)
Add
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
Ring
Bernstein (n i:nat) {struct n}: (i <= n) -> cpoly_cring R := match n return (i <= n) -> cpoly_cring R with O => fun _ => [1] |S n' => match i return (i <= S n') -> cpoly_cring R with O => fun _ => ([1][-]_X_)[*](Bernstein (Nat.le_0_l n')) |S i' => fun p => match (le_lt_eq_dec _ _ p) with | left p' => ([1][-]_X_)[*](Bernstein (proj1 (Nat.lt_succ_r _ _) p'))[+]_X_[*](Bernstein (le_S_n _ _ p)) | right _ => _X_[*](Bernstein (proj1 (Nat.lt_succ_r _ _) p)) end end end. (** These lemmas provide an induction principle for polynomials using the Bernstien basis *)
Fixpoint
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
Bernstein
Bernstein_inv1 : forall n i (H:i < n) (H0:S i <= S n), Bernstein H0[=]([1][-]_X_)[*](Bernstein (proj1 (Nat.lt_succ_r _ _) (proj1 (Nat.succ_lt_mono _ _) H)))[+]_X_[*](Bernstein (le_S_n _ _ H0)). Proof. intros n i H H0. simpl (Bernstein H0). destruct (le_lt_eq_dec _ _ H0). replace (proj1 (Nat.lt_succ_r (S i) n) l) with (proj1 (Nat.lt_succ_r _ _) (proj1 (Nat.succ_lt_mono _ _) H)) by apply le_irrelevent. reflexivity. exfalso; lia. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
Bernstein_inv1
Bernstein_inv2 : forall n (H:S n <= S n), Bernstein H[=]_X_[*](Bernstein (le_S_n _ _ H)). Proof. intros n H. simpl (Bernstein H). destruct (le_lt_eq_dec _ _ H). exfalso; lia. replace (proj1 (Nat.lt_succ_r n n) H) with (le_S_n n n H) by apply le_irrelevent. reflexivity. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
Bernstein_inv2
Bernstein_ind : forall n i (H:i<=n) (P : nat -> nat -> cpoly_cring R -> Prop), P 0 0 [1] -> (forall n p, P n 0 p -> P (S n) 0 (([1][-]_X_)[*]p)) -> (forall n p, P n n p -> P (S n) (S n) (_X_[*]p)) -> (forall i n p q, (i < n) -> P n i p -> P n (S i) q -> P (S n) (S i) (([1][-]_X_)[*]q[+]_X_[*]p)) -> P n i (Bernstein H). Proof. intros n i H P H0 H1 H2 H3. revert n i H. induction n; intros [|i] H. apply H0. exfalso; auto with *. apply H1. apply IHn. simpl. destruct (le_lt_eq_dec (S i) (S n)). apply H3; auto with *. inversion e. revert H. rewrite H5. intros H. apply H2. auto with *. Qed. (** [1] important property of the Bernstein basis is that its elements form a partition of unity *)
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
Bernstein_ind
partitionOfUnity : forall n, @Sumx (cpoly_cring R) _ (fun i H => Bernstein (proj1 (Nat.lt_succ_r i n) H)) [=][1]. Proof. induction n. reflexivity. set (A:=(fun (i : nat) (H : i < S n) => Bernstein (proj1 (Nat.lt_succ_r i n) H))) in *. set (B:=(fun i => ([1][-]_X_)[*](part_tot_nat_fun (cpoly_cring R) _ A i)[+]_X_[*]match i with O => [0] | S i' => (part_tot_nat_fun _ _ A i') end)). rewrite -> (fun a b => Sumx_Sum0 _ a b B). unfold B. rewrite -> Sum0_plus_Sum0. do 2 rewrite -> mult_distr_sum0_lft. rewrite -> Sumx_to_Sum in IHn; auto with *. setoid_replace (Sum0 (S (S n)) (part_tot_nat_fun (cpoly_cring R) (S n) A)) with (Sum0 (S (S n)) (part_tot_nat_fun (cpoly_cring R) (S n) A)[-][0]) using relation (@st_eq (cpoly_cring R)) by ring. change (Sum0 (S (S n)) (part_tot_nat_fun (cpoly_cring R) (S n) A)[-][0]) with (Sum 0 (S n) (part_tot_nat_fun (cpoly_cring R) (S n) A)). set (C:=(fun i : nat => match i with | 0 => ([0] : cpoly_cring R) | S i' => part_tot_nat_fun (cpoly_cring R) (S n) A i' end)). setoid_replace (Sum0 (S (S n)) C) with (Sum0 (S (S n)) C[-][0]) using relation (@st_eq (cpoly_cring R)) by ring. change (Sum0 (S (S n)) C[-][0]) with (Sum 0 (S n) C). rewrite -> Sum_last. rewrite -> IHn. replace (part_tot_nat_fun (cpoly_cring R) (S n) A (S n)) with ([0]:cpoly_cring R). rewrite -> Sum_first. change (C 0) with ([0]:cpoly_cring R). rewrite <- (Sum_shift _ (part_tot_nat_fun (cpoly_cring R) (S n) A)) by reflexivity. rewrite -> IHn by ring. ring. unfold part_tot_nat_fun. destruct (le_lt_dec (S n) (S n)). reflexivity. exfalso; lia. intros i j Hij. subst. intros Hi Hj. unfold A. replace (proj1 (Nat.lt_succ_r j n) Hi) with (proj1 (Nat.lt_succ_r j n) Hj) by apply le_irrelevent. apply eq_reflexive. destruct i; intros Hi; unfold B, A, part_tot_nat_fun. simpl. symmetry. rewrite <- (le_irrelevent _ _ (Nat.le_0_l _) _). ring. destruct (le_lt_dec (S n) i). exfalso; lia. destruct (le_lt_dec (S n) (S i)); simpl (Bernstein (proj1 (Nat.lt_succ_r (S i) (S n)) Hi)); destruct (le_lt_eq_dec (S i) (S n) (proj1 (Nat.lt_succ_r (S i) (S n)) Hi)). exfalso; lia. replace (proj1 (Nat.lt_succ_r i n) (proj1 (Nat.lt_succ_r (S i) (S n)) Hi)) with (proj1 (Nat.lt_succ_r i n) l) by apply le_irrelevent. ring. replace (le_S_n i n (proj1 (Nat.lt_succ_r (S i) (S n)) Hi)) with (proj1 (Nat.lt_succ_r i n) l) by apply le_irrelevent. replace l1 with l0 by apply le_irrelevent. reflexivity. exfalso; lia. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
partitionOfUnity
RaiseDegreeA : forall n i (H:i<=n), (nring (S n))[*]_X_[*]Bernstein H[=](nring (S i))[*]Bernstein (le_n_S _ _ H). Proof. induction n. intros [|i] H; [|exfalso; lia]. repeat split; ring. intros i H. change (nring (S (S n)):cpoly_cring R) with (nring (S n)[+][1]:cpoly_cring R). rstepl (nring (S n)[*]_X_[*]Bernstein H[+]_X_[*]Bernstein H). destruct i as [|i]. simpl (Bernstein H) at 1. rstepl (([1][-]_X_)[*](nring (S n)[*]_X_[*]Bernstein (Nat.le_0_l n))[+] _X_[*]Bernstein H). rewrite -> IHn. rstepl ((([1][-]_X_)[*]Bernstein (le_n_S _ _ (Nat.le_0_l n))[+]_X_[*]Bernstein H)). rstepr (Bernstein (le_n_S 0 (S n) H)). set (le_n_S 0 n (Nat.le_0_l n)). rewrite (Bernstein_inv1 l). rewrite (le_irrelevent _ _ (proj1 (Nat.lt_succ_r 1 (S n)) (proj1 (Nat.succ_lt_mono 0 (S n)) l)) l). rewrite (le_irrelevent _ _ H (le_S_n 0 (S n) (le_n_S 0 (S n) H))). reflexivity. simpl (Bernstein H) at 1. destruct (le_lt_eq_dec _ _ H). rstepl (([1][-]_X_)[*](nring (S n)[*]_X_[*]Bernstein (proj1 (Nat.lt_succ_r (S i) n) l))[+] _X_[*](nring (S n)[*]_X_[*]Bernstein (le_S_n i n H))[+] _X_[*]Bernstein H). do 2 rewrite -> IHn. change (nring (S (S i)):cpoly_cring R) with (nring (S i)[+][1]:cpoly_cring R). set (l0:= (le_n_S (S i) n (proj1 (Nat.lt_succ_r (S i) n) l))). replace (le_n_S i n (le_S_n i n H)) with H by apply le_irrelevent. rstepl ((nring (S i)[+][1])[*](([1][-]_X_)[*]Bernstein l0[+]_X_[*]Bernstein H)). rewrite (Bernstein_inv1 l). replace (proj1 (Nat.lt_succ_r (S (S i)) (S n)) (proj1 (Nat.succ_lt_mono (S i) (S n)) l)) with l0 by apply le_irrelevent. replace (le_S_n (S i) (S n) (le_n_S (S i) (S n) H)) with H by apply le_irrelevent. reflexivity. rstepl (_X_[*](nring (S n)[*]_X_[*]Bernstein (proj1 (Nat.lt_succ_r _ _) H))[+] _X_[*]Bernstein H). rewrite IHn. replace (le_n_S i n (proj1 (Nat.lt_succ_r i n) H)) with H by apply le_irrelevent. revert H. inversion_clear e. intros H. rewrite -> (Bernstein_inv2 (le_n_S _ _ H)). replace (le_S_n (S n) (S n) (le_n_S (S n) (S n) H)) with H by apply le_irrelevent. change (nring (S (S n)):cpoly_cring R) with (nring (S n)[+][1]:cpoly_cring R). ring. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
RaiseDegreeA
RaiseDegreeB : forall n i (H:i<=n), (nring (S n))[*]([1][-]_X_)[*]Bernstein H[=](nring (S n - i))[*]Bernstein (le_S _ _ H). Proof. induction n. intros [|i] H; [|exfalso; lia]. repeat split; ring. intros i H. change (nring (S (S n)):cpoly_cring R) with (nring (S n)[+][1]:cpoly_cring R). set (X0:=([1][-](@cpoly_var R))) in *. rstepl (nring (S n)[*]X0[*]Bernstein H[+]X0[*]Bernstein H). destruct i as [|i]. simpl (Bernstein H) at 1. fold X0. rstepl (X0[*](nring (S n)[*]X0[*]Bernstein (Nat.le_0_l n))[+] X0[*]Bernstein H). rewrite -> IHn. replace (le_S 0 n (Nat.le_0_l n)) with H by apply le_irrelevent. simpl (S n - 0). change (nring (S (S n) - 0):cpoly_cring R) with (nring (S n)[+][1]:cpoly_cring R). rstepl ((nring (S n))[*](X0[*]Bernstein H)[+]X0[*]Bernstein H). change (Bernstein (le_S _ _ H)) with (X0[*]Bernstein (Nat.le_0_l (S n))). replace (Nat.le_0_l (S n)) with H by apply le_irrelevent. ring. simpl (Bernstein H) at 1. destruct (le_lt_eq_dec _ _ H). fold X0. rstepl (X0[*](nring (S n)[*]X0[*]Bernstein (proj1 (Nat.lt_succ_r (S i) n) l))[+] _X_[*](nring (S n)[*]X0[*]Bernstein (le_S_n i n H))[+] X0[*]Bernstein H). do 2 rewrite -> IHn. rewrite (Nat.sub_succ_l i n) by auto with *. rewrite (Nat.sub_succ_l (S i) (S n)) by auto with *. replace (S n - S i) with (n - i) by auto with *. change (nring (S (n - i)):cpoly_cring R) with (nring (n - i)[+][1]:cpoly_cring R). replace (le_S (S i) n (proj1 (Nat.lt_succ_r (S i) n) l)) with H by apply le_irrelevent. set (l0:= (le_S i n (le_S_n i n H))). rstepl ((nring (n - i)[+][1])[*](X0[*]Bernstein H[+]_X_[*]Bernstein l0)). rewrite -> (Bernstein_inv1 H). fold X0. replace (proj1 (Nat.lt_succ_r _ _) (proj1 (Nat.succ_lt_mono _ _) H)) with H by apply le_irrelevent. replace (le_S_n _ _ (le_S (S i) (S n) H)) with l0 by apply le_irrelevent. reflexivity. revert H. inversion e. clear - IHn. intros H. assert (l:(n < (S n))) by auto. rewrite -> (Bernstein_inv1 l). fold X0. rstepl (_X_[*](nring (S n)[*]X0[*]Bernstein (proj1 (Nat.lt_succ_r _ _) H))[+] X0[*]Bernstein H). rewrite -> IHn. replace (S n - n) with 1 by auto with *. replace (S (S n) - S n) with 1 by auto with *. replace (le_S_n n (S n) (le_S (S n) (S n) H)) with (le_S n n (proj1 (Nat.lt_succ_r n n) H)) by apply le_irrelevent. replace (proj1 (Nat.lt_succ_r (S n) (S n)) (proj1 (Nat.succ_lt_mono n (S n)) l)) with H by apply le_irrelevent. ring. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
RaiseDegreeB
RaiseDegree : forall n i (H: i<=n), (nring (S n))[*]Bernstein H[=](nring (S n - i))[*]Bernstein (le_S _ _ H)[+](nring (S i))[*]Bernstein (le_n_S _ _ H). Proof. intros n i H. rstepl ((nring (S n))[*]([1][-]_X_)[*]Bernstein H[+](nring (S n))[*]_X_[*]Bernstein H). rewrite RaiseDegreeA, RaiseDegreeB. reflexivity. Qed. Opaque Bernstein. (** Given a vector of coefficents for a polynomial in the Bernstein basis, return the polynomial *) Arguments Vector.nil {A}. Arguments Vector.cons [A].
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
RaiseDegree
evalBernsteinBasisH (n i:nat) (v:Vector.t R i) : i <= n -> cpoly_cring R := match v in Vector.t _ i return i <= n -> cpoly_cring R with |Vector.nil => fun _ => [0] |Vector.cons a i' v' => match n as n return (S i' <= n) -> cpoly_cring R with | O => fun p => False_rect _ (Nat.nle_succ_0 _ p) | S n' => fun p => _C_ a[*]Bernstein (le_S_n _ _ p)[+]evalBernsteinBasisH v' (Nat.lt_le_incl _ _ p) end end.
Fixpoint
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
evalBernsteinBasisH
evalBernsteinBasis (n:nat) (v:Vector.t R n) : cpoly_cring R := evalBernsteinBasisH v (Nat.le_refl n). (** The coefficents are linear *) Opaque polyconst.
Definition
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
evalBernsteinBasis
Vbinary : forall (n : nat), Vector.t A n -> Vector.t A n -> Vector.t A n. Proof. induction n as [| n h]; intros v v0. apply Vector.nil. inversion v as [| a n0 H0 H1]; inversion v0 as [| a0 n1 H2 H3]. exact (Vector.cons (g a a0) n (h H0 H2)). Defined.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
Vbinary
Vid n : Vector.t A n -> Vector.t A n := match n with | O => fun _ => Vector.nil | S n' => fun v : Vector.t A (S n') => Vector.cons (Vector.hd v) _ (Vector.tl v) end.
Definition
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
Vid
Vid_eq : forall (n:nat) (v:Vector.t A n), v = Vid v. Proof. destruct v; auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
Vid_eq
VSn_eq : forall (n : nat) (v : Vector.t A (S n)), v = Vector.cons (Vector.hd v) _ (Vector.tl v). Proof. intros. exact (Vid_eq v). Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
VSn_eq
V0_eq : forall (v : Vector.t A 0), v = Vector.nil. Proof. intros. exact (Vid_eq v). Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
V0_eq
evalBernsteinBasisPlus : forall n (v1 v2: Vector.t R n), evalBernsteinBasis (Vbinary (fun (x y:R)=>x[+]y) v1 v2)[=]evalBernsteinBasis v1[+]evalBernsteinBasis v2. Proof. unfold evalBernsteinBasis. intros n. generalize (Nat.le_refl n). generalize n at 1 3 4 6 7 9 11. intros i. induction i. intros l v1 v2. rewrite (V0_eq v1), (V0_eq v2). ring. intros l v1 v2. destruct n as [|n]. exfalso; auto with *. rewrite (VSn_eq v1), (VSn_eq v2). simpl. rewrite IHi. rewrite -> c_plus. ring. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
evalBernsteinBasisPlus
evalBernsteinBasisConst : forall n c, evalBernsteinBasis (Vector.const c (S n))[=]_C_ c. Proof. intros n c. stepr (evalBernsteinBasis (Vector.const c (S n))[+]_C_ c[*]Sum (S n) n (part_tot_nat_fun _ _ (fun (i : nat) (H : i < S n) => Bernstein (proj1 (Nat.lt_succ_r i n) H)))). rewrite -> Sum_empty by auto with *. ring. unfold evalBernsteinBasis. generalize (Nat.le_refl (S n)). generalize (S n) at 1 4 5 6. intros i l. induction i. rstepr (_C_ c[*][1]). rewrite <- (partitionOfUnity n). rewrite -> Sumx_to_Sum; auto with *. intros i j Hij. rewrite Hij. intros H H'. replace (proj1 (Nat.lt_succ_r j n) H) with (proj1 (Nat.lt_succ_r j n) H') by apply le_irrelevent. reflexivity. rstepl (evalBernsteinBasisH (Vector.const c i) (Nat.lt_le_incl i (S n) l)[+] _C_ c[*](Bernstein (le_S_n i n l)[+] Sum (S i) n (part_tot_nat_fun (cpoly_cring R) (S n) (fun (i0 : nat) (H : i0 < S n) => Bernstein (proj1 (Nat.lt_succ_r i0 n) H))))). replace (Bernstein (le_S_n _ _ l)) with (part_tot_nat_fun (cpoly_cring R) (S n) (fun (i0 : nat) (H : i0 < S n) => Bernstein (proj1 (Nat.lt_succ_r i0 n) H)) i). rewrite <- Sum_first. apply IHi. clear - i. unfold part_tot_nat_fun. destruct (le_lt_dec (S n) i). exfalso; auto with *. simpl. replace (proj1 (Nat.lt_succ_r _ _) l0) with (le_S_n _ _ l) by apply le_irrelevent. reflexivity. Qed. Variable eta : RingHom Q_as_CRing R. Opaque Qred. Opaque Q_as_CRing. Opaque Vbinary. Opaque Vector.const. (** To convert a polynomial to the Bernstein basis, we need to know how to multiply a bernstein basis element by [_X_] can convert it to the Bernstein basis. At this point we must work with rational coeffients. So we assume there is a ring homomorphism from [Q] to R *)
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
evalBernsteinBasisConst
BernsteinBasisTimesXH (n i:nat) (v:Vector.t R i) : i <= n -> Vector.t R (S i) := match v in Vector.t _ i return i <= n -> Vector.t R (S i) with | Vector.nil => fun _ => Vector.cons [0] _ Vector.nil | Vector.cons a i' v' => match n as n return S i' <= n -> Vector.t R (S (S i')) with | O => fun p => False_rect _ (Nat.nle_succ_0 _ p) | S n' => fun p => Vector.cons (eta(Qred (i#P_of_succ_nat n'))[*]a) _ (BernsteinBasisTimesXH v' (Nat.lt_le_incl _ _ p)) end end.
Fixpoint
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
BernsteinBasisTimesXH
BernsteinBasisTimesX (n:nat) (v:Vector.t R n) : Vector.t R (S n) := BernsteinBasisTimesXH v (Nat.le_refl n).
Definition
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
BernsteinBasisTimesX
evalBernsteinBasisTimesX : forall n (v:Vector.t R n), evalBernsteinBasis (BernsteinBasisTimesX v)[=]_X_[*]evalBernsteinBasis v. Proof. intros n. unfold evalBernsteinBasis, BernsteinBasisTimesX. generalize (Nat.le_refl (S n)) (Nat.le_refl n). generalize n at 1 3 5 7 9 11. intros i. induction i. intros l l0 v. rewrite (V0_eq v). simpl. rewrite <- c_zero. ring. intros l l0 v. destruct n as [|n]. exfalso; auto with *. rewrite (VSn_eq v). simpl. rewrite -> IHi. rewrite -> c_mult. rewrite -> ring_dist_unfolded. apply csbf_wd; try reflexivity. set (A:= (_C_ (eta (Qred (Qmake (Zpos (P_of_succ_nat i)) (P_of_succ_nat n)))))). rstepl (_C_ (Vector.hd v)[*](A[*]Bernstein (le_S_n (S i) (S n) l))). rstepr (_C_ (Vector.hd v)[*](_X_[*]Bernstein (le_S_n i n l0))). apply mult_wdr. unfold A; clear A. assert (Hn : (nring (S n):Q)[#][0]). stepl (S n:Q). simpl. unfold Qap, Qeq. auto with *. symmetry; apply nring_Q. setoid_replace (Qred (P_of_succ_nat i # P_of_succ_nat n)) with (([1][/](nring (S n))[//]Hn)[*](nring (S i))). set (eta':=RHcompose _ _ _ _C_ eta). change (_C_ (eta (([1][/]nring (S n)[//]Hn)[*]nring (S i)))) with ((eta' (([1][/]nring (S n)[//]Hn)[*]nring (S i))):cpoly_cring R). rewrite -> rh_pres_mult. rewrite -> rh_pres_nring. rewrite <- mult_assoc_unfolded. replace (le_S_n (S i) (S n) l) with (le_n_S _ _ (le_S_n i n l0)) by apply le_irrelevent. rewrite <- RaiseDegreeA. rewrite <- (@rh_pres_nring _ _ eta'). rewrite <- mult_assoc_unfolded. rewrite -> mult_assoc_unfolded. rewrite <- rh_pres_mult. setoid_replace (eta' (([1][/]nring (S n)[//]Hn)[*]nring (S n))) with ([1]:cpoly_cring R). ring. rewrite <- (@rh_pres_unit _ _ eta'). apply csf_wd. apply (@div_1 Q_as_CField). rewrite -> Qred_correct. rewrite -> Qmake_Qdiv. change (Zpos (P_of_succ_nat n)) with ((S n):Z). rewrite <- (nring_Q (S n)). change (Zpos (P_of_succ_nat i)) with ((S i):Z). rewrite <- (nring_Q (S i)). change (nring (S i)/nring (S n) == (1/(nring (S n)))*nring (S i))%Q. field. apply Hn. Qed. (** Convert a polynomial to the Bernstein basis *)
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
evalBernsteinBasisTimesX
BernsteinCoefficents (p:cpoly_cring R) : sigT (Vector.t R) := match p with | cpoly_zero _ => existT _ _ Vector.nil | cpoly_linear _ c p' => let (n', b') := (BernsteinCoefficents p') in existT _ _ (Vbinary (fun (x y:R)=>x[+]y) (Vector.const c _) (BernsteinBasisTimesX b')) end.
Fixpoint
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
BernsteinCoefficents
evalBernsteinCoefficents : forall p, (let (n,b) := BernsteinCoefficents p in evalBernsteinBasis b)[=]p. Proof. induction p. reflexivity. simpl. destruct (BernsteinCoefficents p). rewrite -> evalBernsteinBasisPlus. rewrite -> evalBernsteinBasisConst. rewrite -> evalBernsteinBasisTimesX. rewrite -> IHp. rewrite -> poly_linear. ring. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
evalBernsteinCoefficents
BernsteinNonNeg : forall x:F, [0] [<=] x -> x [<=] [1] -> forall n i (p:Nat.le i n), [0][<=](Bernstein F p)!x. Proof. intros x Hx0 Hx1. induction n. intros i p. simpl (Bernstein F p). autorewrite with apply. auto with *. intros [|i] p; simpl (Bernstein F p). autorewrite with apply. auto with *. destruct (le_lt_eq_dec (S i) (S n) p); autorewrite with apply; auto with *. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "Require Import CoRN.", "From Coq Require Import Lia." ]
algebra/Bernstein.v
BernsteinNonNeg
is_CAbGroup (G : CGroup) := commutes (csg_op (c:=G)).
Definition
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
is_CAbGroup
CAbGroup : Type := {cag_crr : CGroup; cag_proof : is_CAbGroup cag_crr}. Local Coercion cag_crr : CAbGroup >-> CGroup.
Record
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
CAbGroup
CAbGroup_is_CAbGroup : is_CAbGroup G. Proof. elim G; auto. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
CAbGroup_is_CAbGroup
cag_commutes : commutes (csg_op (c:=G)). Proof. exact CAbGroup_is_CAbGroup. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
cag_commutes
cag_commutes_unfolded : forall x y : G, x[+]y [=] y[+]x. Proof cag_commutes.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
cag_commutes_unfolded
subcrr : CGroup := Build_SubCGroup _ _ Punit op_pres_P inv_pres_P.
Let
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
subcrr
isabgrp_scrr : is_CAbGroup subcrr. Proof. red in |- *. intros x y. case x. case y. intros. simpl in |- *. apply cag_commutes_unfolded. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
isabgrp_scrr
Build_SubCAbGroup : CAbGroup := Build_CAbGroup subcrr isabgrp_scrr.
Definition
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
Build_SubCAbGroup
cag_op_inv : forall x y : G, [--] (x[+]y) [=] [--]x[+] [--]y. Proof. intros x y. astepr ([--]y[+] [--]x). apply cg_inv_op. Qed. Hint Resolve cag_op_inv: algebra.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
cag_op_inv
assoc_1 : forall x y z : G, x[-] (y[-]z) [=] x[-]y[+]z. Proof. intros x y z; unfold cg_minus in |- *. astepr (x[+]([--]y[+]z)). Step_final (x[+]([--]y[+] [--][--]z)). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
assoc_1
minus_plus : forall x y z : G, x[-] (y[+]z) [=] x[-]y[-]z. Proof. intros x y z. unfold cg_minus in |- *. Step_final (x[+]([--]y[+] [--]z)). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
minus_plus
op_lft_resp_ap : forall x y z : G, y [#] z -> x[+]y [#] x[+]z. Proof. intros x y z H. astepl (y[+]x). astepr (z[+]x). apply op_rht_resp_ap; assumption. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
op_lft_resp_ap
cag_ap_cancel_lft : forall x y z : G, x[+]y [#] x[+]z -> y [#] z. Proof. intros x y z H. apply ap_symmetric_unfolded. apply cg_ap_cancel_rht with x. apply ap_symmetric_unfolded. astepl (x[+]y). astepr (x[+]z). auto. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
cag_ap_cancel_lft
plus_cancel_ap_lft : forall x y z : G, z[+]x [#] z[+]y -> x [#] y. Proof. intros x y z H. apply cag_ap_cancel_lft with z. assumption. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
plus_cancel_ap_lft
cag_crr : CAbGroup >-> CGroup.
Coercion
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
cag_crr
plus_rext : forall x y z : S, plus x y [#] plus x z -> y [#] z. Proof. intros x y z H. apply plus_lext with x. astepl (plus x y). astepr (plus x z). auto. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
plus_rext
plus_runit : forall x : S, plus x unit [=] x. Proof. intro x. Step_final (plus unit x). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
plus_runit
plus_is_fun : bin_fun_strext _ _ _ plus. Proof. intros x x' y y' H. elim (ap_cotransitive_unfolded _ _ _ H (plus x y')); intro H'. right; apply plus_lext with x. astepl (plus x y); astepr (plus x y'); auto. left; eauto. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
plus_is_fun
inv_inv' : forall x : S, plus (inv x) x [=] unit. Proof. intro. Step_final (plus x (inv x)). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
inv_inv'
plus_fun : CSetoid_bin_op S := Build_CSetoid_bin_fun _ _ _ plus plus_is_fun.
Definition
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
plus_fun
Build_CSemiGroup' : CSemiGroup. Proof. apply Build_CSemiGroup with S plus_fun. exact plus_assoc. Defined.
Definition
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
Build_CSemiGroup'
Build_CMonoid' : CMonoid. Proof. apply Build_CMonoid with Build_CSemiGroup' unit. apply Build_is_CMonoid. exact plus_runit. exact plus_lunit. Defined.
Definition
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
Build_CMonoid'
Build_CGroup' : CGroup. Proof. apply Build_CGroup with Build_CMonoid' inv. split. auto. apply inv_inv'. Defined.
Definition
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
Build_CGroup'
Build_CAbGroup' : CAbGroup. Proof. apply Build_CAbGroup with Build_CGroup'. exact plus_comm. Defined.
Definition
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
Build_CAbGroup'
nmult (a:G) (n:nat) {struct n} : G := match n with | O => [0] | S p => a[+]nmult a p end.
Fixpoint
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
nmult
nmult_wd : forall (x y:G) (n m:nat), (x [=] y) -> n = m -> nmult x n [=] nmult y m. Proof. simple induction n; intros. rewrite <- H0; algebra. rewrite <- H1; simpl in |- *; algebra. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
nmult_wd
nmult_one : forall x:G, nmult x 1 [=] x. Proof. simpl in |- *; algebra. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
nmult_one
nmult_Zero : forall n:nat, nmult [0] n [=] [0]. Proof. intro n. induction n. algebra. simpl in |- *; Step_final (([0]:G)[+][0]). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
nmult_Zero
nmult_plus : forall m n x, nmult x m[+]nmult x n [=] nmult x (m + n). Proof. simple induction m. simpl in |- *; algebra. clear m; intro m. intros. simpl in |- *. Step_final (x[+](nmult x m[+]nmult x n)). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
nmult_plus
nmult_mult : forall n m x, nmult (nmult x m) n [=] nmult x (m * n). Proof. simple induction n. intro. rewrite Nat.mul_0_r. algebra. clear n; intros. simpl in |- *. rewrite Nat.mul_comm. simpl in |- *. eapply eq_transitive_unfolded. 2: apply nmult_plus. rewrite Nat.mul_comm. algebra. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
nmult_mult
nmult_inv : forall n x, nmult [--]x n [=] [--] (nmult x n). Proof. intro; induction n; simpl in |- *. algebra. intros. Step_final ([--]x[+] [--](nmult x n)). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
nmult_inv
nmult_plus' : forall n x y, nmult x n[+]nmult y n [=] nmult (x[+]y) n. Proof. intro; induction n; simpl in |- *; intros. algebra. astepr (x[+]y[+](nmult x n[+]nmult y n)). astepr (x[+](y[+](nmult x n[+]nmult y n))). astepr (x[+](y[+]nmult x n[+]nmult y n)). astepr (x[+](nmult x n[+]y[+]nmult y n)). Step_final (x[+](nmult x n[+](y[+]nmult y n))). Qed. Hint Resolve nmult_wd nmult_Zero nmult_inv nmult_plus nmult_plus': algebra.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
nmult_plus'
zmult a z := caseZ_diff z (fun n m => nmult a n[-]nmult a m). (*
Definition
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult
Zeq_imp_nat_eq : forall m n:nat, m = n -> m = n. auto. intro m; induction m. intro n; induction n; auto. intro; induction n. intro. inversion H. intros. rewrite (IHm n). auto. repeat rewrite inj_S in H. auto with zarith. Qed. *)
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
Zeq_imp_nat_eq
zmult_char : forall (m n:nat) z, z = (m - n)%Z -> forall x, zmult x z [=] nmult x m[-]nmult x n. Proof. simple induction z; intros. simpl in |- *. replace m with n. Step_final ([0]:G). auto with zarith. simpl in |- *. astepl (nmult x (nat_of_P p)). apply cg_cancel_rht with (nmult x n). astepr (nmult x m). astepl (nmult x (nat_of_P p + n)). apply nmult_wd; algebra. rewrite <- convert_is_POS in H. auto with zarith. simpl in |- *. astepl [--](nmult x (nat_of_P p)). unfold cg_minus in |- *. astepr ([--][--](nmult x m)[+] [--](nmult x n)). astepr [--]([--](nmult x m)[+]nmult x n). apply un_op_wd_unfolded. apply cg_cancel_lft with (nmult x m). astepr (nmult x m[+] [--](nmult x m)[+]nmult x n). astepr ([0][+]nmult x n). astepr (nmult x n). astepl (nmult x (m + nat_of_P p)). apply nmult_wd; algebra. rewrite <- min_convert_is_NEG in H. auto with zarith. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult_char
zmult_wd : forall (x y:G) (n m:Z), (x [=] y) -> n = m -> zmult x n [=] zmult y m. Proof. do 3 intro. case n; intros; inversion H0. algebra. unfold zmult in |- *. simpl in |- *. astepl (nmult x (nat_of_P p)); Step_final (nmult y (nat_of_P p)). simpl in |- *. astepl [--](nmult x (nat_of_P p)). Step_final [--](nmult y (nat_of_P p)). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult_wd
zmult_one : forall x:G, zmult x 1 [=] x. Proof. simpl in |- *; algebra. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult_one
zmult_min_one : forall x:G, zmult x (-1) [=] [--]x. Proof. intros; simpl in |- *; Step_final ([0][-]x). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult_min_one
zmult_zero : forall x:G, zmult x 0 [=] [0]. Proof. simpl in |- *; algebra. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult_zero
zmult_Zero : forall k:Z, zmult [0] k [=] [0]. Proof. intro; induction k; simpl in |- *. algebra. Step_final (([0]:G)[-][0]). Step_final (([0]:G)[-][0]). Qed. Hint Resolve zmult_zero: algebra.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult_Zero
zmult_plus : forall m n x, zmult x m[+]zmult x n [=] zmult x (m + n). Proof. intros; case m; case n; intros. simpl in |- *; Step_final ([0][+]([0][-][0]):G). simpl in |- *; Step_final ([0][+](nmult x (nat_of_P p)[-][0])). simpl in |- *; Step_final ([0][+]([0][-]nmult x (nat_of_P p))). simpl in |- *; Step_final (nmult x (nat_of_P p)[-][0][+][0]). simpl in |- *. astepl (nmult x (nat_of_P p0)[+]nmult x (nat_of_P p)). astepr (nmult x (nat_of_P (p0 + p))). rewrite nat_of_P_plus_morphism. apply nmult_plus. simpl (zmult x (Zpos p0)[+]zmult x (Zneg p)) in |- *. astepl (nmult x (nat_of_P p0)[+] [--](nmult x (nat_of_P p))). astepl (nmult x (nat_of_P p0)[-]nmult x (nat_of_P p)). apply eq_symmetric_unfolded; apply zmult_char with (z := (Zpos p0 + Zneg p)%Z). rewrite convert_is_POS. unfold Zminus in |- *. rewrite min_convert_is_NEG; auto. rewrite <- Zplus_0_r_reverse. Step_final (zmult x (Zneg p)[+][0]). simpl (zmult x (Zneg p0)[+]zmult x (Zpos p)) in |- *. astepl ([--](nmult x (nat_of_P p0))[+]nmult x (nat_of_P p)). astepl (nmult x (nat_of_P p)[+] [--](nmult x (nat_of_P p0))). astepl (nmult x (nat_of_P p)[-]nmult x (nat_of_P p0)). rewrite Zplus_comm. apply eq_symmetric_unfolded; apply zmult_char with (z := (Zpos p + Zneg p0)%Z). rewrite convert_is_POS. unfold Zminus in |- *. rewrite min_convert_is_NEG; auto. simpl in |- *. astepl ([--](nmult x (nat_of_P p0))[+] [--](nmult x (nat_of_P p))). astepl [--](nmult x (nat_of_P p0)[+]nmult x (nat_of_P p)). astepr [--](nmult x (nat_of_P (p0 + p))). apply un_op_wd_unfolded. rewrite nat_of_P_plus_morphism. apply nmult_plus. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult_plus
zmult_mult : forall m n x, zmult (zmult x m) n [=] zmult x (m * n). Proof. simple induction m; simple induction n; simpl in |- *; intros. Step_final ([0][-][0][+]([0]:G)). astepr ([0]:G). astepl (nmult ([0][-][0]) (nat_of_P p)). Step_final (nmult [0] (nat_of_P p)). astepr [--]([0]:G). astepl [--](nmult ([0][-][0]) (nat_of_P p)). Step_final [--](nmult [0] (nat_of_P p)). algebra. astepr (nmult x (nat_of_P (p * p0))). astepl (nmult (nmult x (nat_of_P p)) (nat_of_P p0)[-][0]). astepl (nmult (nmult x (nat_of_P p)) (nat_of_P p0)). rewrite nat_of_P_mult_morphism. apply nmult_mult. astepr [--](nmult x (nat_of_P (p * p0))). astepl ([0][-]nmult (nmult x (nat_of_P p)) (nat_of_P p0)). astepl [--](nmult (nmult x (nat_of_P p)) (nat_of_P p0)). rewrite nat_of_P_mult_morphism. apply un_op_wd_unfolded. apply nmult_mult. algebra. astepr [--](nmult x (nat_of_P (p * p0))). astepl (nmult [--](nmult x (nat_of_P p)) (nat_of_P p0)[-][0]). astepl (nmult [--](nmult x (nat_of_P p)) (nat_of_P p0)). rewrite nat_of_P_mult_morphism. eapply eq_transitive_unfolded. apply nmult_inv. apply un_op_wd_unfolded. apply nmult_mult. astepr (nmult x (nat_of_P (p * p0))). astepr [--][--](nmult x (nat_of_P (p * p0))). astepl ([0][-]nmult [--](nmult x (nat_of_P p)) (nat_of_P p0)). astepl [--](nmult [--](nmult x (nat_of_P p)) (nat_of_P p0)). rewrite nat_of_P_mult_morphism. apply un_op_wd_unfolded. eapply eq_transitive_unfolded. apply nmult_inv. apply un_op_wd_unfolded. apply nmult_mult. Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult_mult
zmult_plus' : forall z x y, zmult x z[+]zmult y z [=] zmult (x[+]y) z. Proof. intro z; pattern z in |- *. apply nats_Z_ind. intro n; case n. intros; simpl in |- *. Step_final (([0]:G)[+]([0][-][0])). clear n; intros. rewrite POS_anti_convert; simpl in |- *. set (p := nat_of_P (P_of_succ_nat n)) in *. astepl (nmult x p[+]nmult y p). Step_final (nmult (x[+]y) p). intro n; case n. intros; simpl in |- *. Step_final (([0]:G)[+]([0][-][0])). clear n; intros. rewrite NEG_anti_convert; simpl in |- *. set (p := nat_of_P (P_of_succ_nat n)) in *. astepl ([--](nmult x p)[+] [--](nmult y p)). astepr [--](nmult (x[+]y) p). Step_final [--](nmult x p[+]nmult y p). Qed.
Lemma
algebra
[ "Require Export CoRN." ]
algebra/CAbGroups.v
zmult_plus'
is_CAbMonoid (G : CMonoid) := commutes (csg_op (c:=G)).
Definition
algebra
[ "Require Export CoRN.", "Require Import CoRN." ]
algebra/CAbMonoids.v
is_CAbMonoid
CAbMonoid : Type := {cam_crr :> CMonoid; cam_proof : is_CAbMonoid cam_crr}.
Record
algebra
[ "Require Export CoRN.", "Require Import CoRN." ]
algebra/CAbMonoids.v
CAbMonoid
CAbMonoid_is_CAbMonoid : is_CAbMonoid M. Proof. elim M; auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN." ]
algebra/CAbMonoids.v
CAbMonoid_is_CAbMonoid
cam_commutes : commutes (csg_op (c:=M)). Proof. exact CAbMonoid_is_CAbMonoid. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN." ]
algebra/CAbMonoids.v
cam_commutes
cam_commutes_unfolded : forall x y : M, x[+]y [=] y[+]x. Proof cam_commutes.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN." ]
algebra/CAbMonoids.v
cam_commutes_unfolded
subcrr : CMonoid := Build_SubCMonoid _ _ Punit op_pres_P.
Let
algebra
[ "Require Export CoRN.", "Require Import CoRN." ]
algebra/CAbMonoids.v
subcrr
isabgrp_scrr : is_CAbMonoid subcrr. Proof. red in |- *. intros x y. case x. case y. intros. simpl in |- *. apply cam_commutes_unfolded. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Import CoRN." ]
algebra/CAbMonoids.v
isabgrp_scrr
Build_SubCAbMonoid : CAbMonoid := Build_CAbMonoid _ isabgrp_scrr.
Definition
algebra
[ "Require Export CoRN.", "Require Import CoRN." ]
algebra/CAbMonoids.v
Build_SubCAbMonoid
R_Set := CauchySeq F.
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_Set
R_lt (x y : R_Set) := {N : nat | {e : F | [0] [<] e | forall n, N <= n -> e [<=] CS_seq _ y n[-]CS_seq _ x n}}.
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_lt
R_ap (x y : R_Set) := R_lt x y or R_lt y x.
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_ap
R_eq (x y : R_Set) := Not (R_ap x y).
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_eq
R_lt_cotrans : cotransitive R_lt. Proof. red in |- *. intros x y. elim x; intros x_ px. elim y; intros y_ py. intros Hxy z. elim z; intros z_ pz. elim Hxy; intros N H. elim H; clear Hxy H; intros e He HN. simpl in HN. set (e3 := e [/]ThreeNZ) in *. cut ([0] [<] e3); [ intro He3 | unfold e3 in |- *; apply pos_div_three; auto ]. set (e6 := e [/]SixNZ) in *. cut ([0] [<] e6); [ intro He6 | unfold e6 in |- *; apply pos_div_six; auto ]. set (e12 := e [/]TwelveNZ) in *. cut ([0] [<] e12); [ intro He12 | unfold e12 in |- *; apply pos_div_twelve; auto ]. set (e24 := e [/]TwentyFourNZ) in *. cut ([0] [<] e24); [ intro He24 | unfold e24 in |- *; apply pos_div_twentyfour; auto ]. elim (px e24 He24); intros Nx HNx. elim (py e24 He24); intros Ny HNy. elim (pz e24 He24); intros Nz HNz. set (NN := Nat.max N (Nat.max Nx (Nat.max Ny Nz))) in *. set (x0 := x_ NN) in *. set (y0 := y_ NN) in *. set (z0 := z_ NN) in *. elim (less_cotransitive_unfolded _ (x0[+]e3) (y0[-]e3)) with z0. intro Hyz. left. exists NN; exists e6; auto. intros n Hn; simpl in |- *. apply leEq_wdl with (e3[-] (e24[+]e24[+]e24[+]e24)). 2: unfold e3, e6, e12, e24 in |- *; rational. apply leEq_transitive with (e3[-] (z0[-]z_ Nz[+] (z_ Nz[-]z_ n) [+] (x_ n[-]x_ Nx) [+] (x_ Nx[-]x0))). apply minus_resp_leEq_rht. repeat apply plus_resp_leEq_both. unfold z0 in |- *; elim (HNz NN); auto; unfold NN in |- *; eauto with arith. apply shift_minus_leEq; apply shift_leEq_plus'. unfold cg_minus in |- *; apply shift_plus_leEq'. elim (HNz n); auto; apply Nat.le_trans with NN; auto; unfold NN in |- *; eauto with arith. elim (HNx n); auto; apply Nat.le_trans with NN; auto; unfold NN in |- *; eauto with arith. apply shift_minus_leEq; apply shift_leEq_plus'. unfold cg_minus in |- *; apply shift_plus_leEq'. unfold x0 in |- *; elim (HNx NN); auto; unfold NN in |- *; eauto with arith. apply shift_minus_leEq. rstepr (z0[-]x0). apply shift_leEq_minus; astepl (x0[+]e3); apply less_leEq; auto. intro Hzx. right. exists NN; exists e6; auto. intros n Hn; simpl in |- *. apply leEq_wdl with (e3[-] (e24[+]e24[+]e24[+]e24)). 2: unfold e3, e6, e12, e24 in |- *; rational. apply leEq_transitive with (e3[-] (z_ Nz[-]z0[+] (z_ n[-]z_ Nz) [+] (y_ Ny[-]y_ n) [+] (y0[-]y_ Ny))). apply minus_resp_leEq_rht. repeat apply plus_resp_leEq_both. apply shift_minus_leEq; apply shift_leEq_plus'. unfold cg_minus in |- *; apply shift_plus_leEq'. unfold z0 in |- *; elim (HNz NN); auto; unfold NN in |- *; eauto with arith. elim (HNz n); auto; apply Nat.le_trans with NN; auto; unfold NN in |- *; eauto with arith. apply shift_minus_leEq; apply shift_leEq_plus'. unfold cg_minus in |- *; apply shift_plus_leEq'. elim (HNy n); auto; apply Nat.le_trans with NN; auto; unfold NN in |- *; eauto with arith. unfold y0 in |- *; elim (HNy NN); auto; unfold NN in |- *; eauto with arith. apply shift_minus_leEq. rstepr (y0[-]z0). apply shift_leEq_minus; apply shift_plus_leEq'; apply less_leEq; auto. apply shift_less_minus. astepl (x0[+] (e3[+]e3)); apply shift_plus_less'. apply less_leEq_trans with e. apply shift_plus_less. apply less_wdl with ((e[-]e3) [/]TwoNZ). 2: unfold e3 in |- *; rational. apply pos_div_two'. apply shift_less_minus; astepl e3; unfold e3 in |- *; apply pos_div_three'; auto. unfold x0, y0, NN in |- *; apply HN; eauto with arith. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_lt_cotrans
R_ap_cotrans : cotransitive R_ap. Proof. red in |- *; intros x y Hxy z. elim Hxy; intro H; elim (R_lt_cotrans _ _ H z); unfold R_ap in |- *; auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_ap_cotrans
R_ap_symmetric : Csymmetric R_ap. Proof. red in |- *; intros x y Hxy. elim Hxy; unfold R_ap in |- *; auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_ap_symmetric
R_lt_irreflexive : irreflexive R_lt. Proof. red in |- *; intros x Hx. elim Hx; intros N HN. elim HN; clear Hx HN; intros e He HN. apply (ap_irreflexive_unfolded _ (x N)). apply less_imp_ap. apply less_leEq_trans with (x N[+]e). astepl (x N[+][0]); apply plus_resp_less_lft; auto. apply shift_plus_leEq'; auto with arith. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_lt_irreflexive
R_ap_irreflexive : irreflexive R_ap. Proof. red in |- *; intros x Hx. elim (R_lt_irreflexive x). elim Hx; auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_ap_irreflexive
R_ap_eq_tight : tight_apart R_eq R_ap. Proof. split; auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_ap_eq_tight
R_CSetoid : CSetoid. Proof. apply Build_CSetoid with R_Set R_eq R_ap. split. exact R_ap_irreflexive. exact R_ap_symmetric. exact R_ap_cotrans. exact R_ap_eq_tight. Defined.
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_CSetoid
R_plus (x y : R_CSetoid) : R_CSetoid := Build_CauchySeq _ _ (CS_seq_plus F _ _ (CS_proof _ x) (CS_proof _ y)).
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_plus
R_zero := Build_CauchySeq _ _ (CS_seq_const F [0]).
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_zero
R_plus_lft_ext : forall x y z, R_plus x z [#] R_plus y z -> x [#] y. Proof. intros x y z Hxy. elim Hxy; clear Hxy; intro H; [ left | right ]; elim H; intros N HN; elim HN; clear H HN; intros e He HN; exists N; exists e; auto; intros n Hn; simpl in HN. rstepr (CS_seq _ y n[+]CS_seq _ z n[-] (CS_seq _ x n[+]CS_seq _ z n)); auto. rstepr (CS_seq _ x n[+]CS_seq _ z n[-] (CS_seq _ y n[+]CS_seq _ z n)); auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_plus_lft_ext
R_plus_assoc : associative R_plus. Proof. intros x y z Hap. elim Hap; clear Hap; intro H; elim H; intros N HN; elim HN; clear H HN; intros e He HN; simpl in HN; apply (less_irreflexive_unfolded _ e). apply leEq_less_trans with (CS_seq _ x N[+]CS_seq _ y N[+]CS_seq _ z N[-] (CS_seq _ x N[+] (CS_seq _ y N[+]CS_seq _ z N))); auto. rstepl ([0]:F); auto. apply leEq_less_trans with (CS_seq _ x N[+] (CS_seq _ y N[+]CS_seq _ z N) [-] (CS_seq _ x N[+]CS_seq _ y N[+]CS_seq _ z N)); auto. rstepl ([0]:F); auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_plus_assoc
R_zero_lft_unit : forall x, R_plus R_zero x [=] x. Proof. intro x; intro x_ap. apply (R_lt_irreflexive x). elim x_ap; clear x_ap; intro x_lt; elim x_lt; intros N H; elim H; clear x_lt H; intros e He HN; exists N; exists e; auto; simpl in HN; intros n Hn. astepr (CS_seq _ x n[-] ([0][+]CS_seq _ x n)); auto. astepr ([0][+]CS_seq _ x n[-]CS_seq _ x n); auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_zero_lft_unit
R_plus_comm : forall x y, R_plus x y [=] R_plus y x. Proof. intros x y Hxy. elim Hxy; clear Hxy; intro H; elim H; intros N HN; elim HN; clear H HN; intros e He HN; simpl in HN; apply (less_irreflexive_unfolded _ e). apply leEq_less_trans with (CS_seq _ y N[+]CS_seq _ x N[-] (CS_seq _ x N[+]CS_seq _ y N)); auto. rstepl ([0]:F); auto. apply leEq_less_trans with (CS_seq _ x N[+]CS_seq _ y N[-] (CS_seq _ y N[+]CS_seq _ x N)); auto. rstepl ([0]:F); auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_plus_comm
R_inv (x : R_CSetoid) : R_CSetoid := Build_CauchySeq _ _ (CS_seq_inv F _ (CS_proof _ x)).
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_inv
R_inv_is_inv : forall x, R_plus x (R_inv x) [=] R_zero. Proof. intro x; intro x_ap. apply (R_lt_irreflexive R_zero). elim x_ap; clear x_ap; intro x_lt; elim x_lt; intros N H; elim H; clear x_lt H; intros e He HN; exists N; exists e; auto; simpl in HN; intros n Hn. simpl in |- *; astepr ([0][-] (CS_seq _ x n[+][--] (CS_seq _ x n))); auto. simpl in |- *; astepr (CS_seq _ x n[+][--] (CS_seq _ x n) [-][0]); auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_inv_is_inv
R_inv_ext : un_op_strext _ R_inv. Proof. intros x y Hxy. elim Hxy; clear Hxy; intro x_lt; [ right | left ]; elim x_lt; intros N H; elim H; clear x_lt H; intros e He HN; exists N; exists e; auto; simpl in HN; intros n Hn. rstepr ([--] (CS_seq _ y n) [-][--] (CS_seq _ x n)); auto. rstepr ([--] (CS_seq _ x n) [-][--] (CS_seq _ y n)); auto. Qed.
Lemma
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_inv_ext
Rinv : CSetoid_un_op R_CSetoid. Proof. red in |- *. apply Build_CSetoid_un_op with R_inv. exact R_inv_ext. Defined.
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
Rinv
R_CAbGroup : CAbGroup. Proof. apply Build_CAbGroup' with R_CSetoid R_zero R_plus Rinv. exact R_plus_lft_ext. exact R_zero_lft_unit. exact R_plus_comm. exact R_plus_assoc. exact R_inv_is_inv. Defined.
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_CAbGroup
R_mult (x y : R_CAbGroup) : R_CAbGroup := Build_CauchySeq _ _ (CS_seq_mult F _ _ (CS_proof _ x) (CS_proof _ y)).
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_mult
R_one : R_CAbGroup := Build_CauchySeq _ _ (CS_seq_const F [1]).
Definition
algebra
[ "Require Export CoRN.", "Require Export CoRN." ]
algebra/Cauchy_COF.v
R_one