summaryrefslogtreecommitdiff
path: root/plugins/nsatz/NsatzZ.v
blob: b57aa0ed6d5f8f53beacd104ea51f04d03603197 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

Require Import Reals ZArith.
Require Export NsatzR.

Open Scope Z_scope.

Lemma nsatzZhypR: forall x y:Z, x=y -> IZR x = IZR y.
Proof IZR_eq. (* or f_equal ... *)

Lemma nsatzZconclR: forall x y:Z, IZR x = IZR y -> x = y.
Proof eq_IZR.

Lemma nsatzZhypnotR: forall x y:Z, x<>y -> IZR x <> IZR y.
Proof IZR_neq.

Lemma nsatzZconclnotR: forall x y:Z, IZR x <> IZR y -> x <> y.
Proof.
intros x y H. contradict H. f_equal. assumption.
Qed.

Ltac nsatzZtoR1 :=
 repeat
  (match goal with
   | H:(@eq Z ?x ?y) |- _ =>
       generalize (@nsatzZhypR _ _ H); clear H; intro H
   | |- (@eq Z ?x ?y) => apply nsatzZconclR
   | H:not (@eq Z ?x ?y) |- _ =>
       generalize (@nsatzZhypnotR _ _ H); clear H; intro H
   | |- not (@eq Z ?x ?y) => apply nsatzZconclnotR
   end).

Lemma nsatzZR1: forall x y:Z, IZR(x+y) = (IZR x + IZR y)%R.
Proof plus_IZR.

Lemma nsatzZR2: forall x y:Z, IZR(x*y) = (IZR x * IZR y)%R.
Proof mult_IZR.

Lemma nsatzZR3: forall x y:Z, IZR(x-y) = (IZR x - IZR y)%R.
Proof.
intros; symmetry. apply Z_R_minus.
Qed.

Lemma nsatzZR4: forall (x:Z) p, IZR(x ^ Zpos p) = (IZR x ^ nat_of_P p)%R.
Proof.
intros. rewrite pow_IZR.
do 2 f_equal.
apply Zpos_eq_Z_of_nat_o_nat_of_P.
Qed.

Ltac nsatzZtoR2:=
  repeat
   (rewrite nsatzZR1 in * ||
    rewrite nsatzZR2 in * ||
    rewrite nsatzZR3 in * ||
    rewrite nsatzZR4 in *).

Ltac nsatzZ_begin :=
 intros;
 nsatzZtoR1;
 nsatzZtoR2;
 simpl in *.
 (*cbv beta iota zeta delta [nat_of_P Pmult_nat plus mult] in *.*)

Ltac nsatzZ :=
 nsatzZ_begin; (*idtac "nsatzZ_begin;";*)
 nsatzR.