summaryrefslogtreecommitdiff
path: root/contrib/setoid_ring/ZArithRing.v
blob: 8de7021e84b79cdcd1effe5a57c937bd564f06bb (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
(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

Require Export Ring.
Require Import ZArith_base.
Require Import Zpow_def.

Import InitialRing.

Set Implicit Arguments.

Ltac Zcst t :=
  match isZcst t with
    true => t
  | _ => NotConstant
  end.

Ltac isZpow_coef t :=
  match t with 
  | Zpos ?p => isPcst p
  | Z0 => true
  | _ => false
  end.

Definition N_of_Z x :=
 match x with
 | Zpos p => Npos p
 | _ => N0
 end.

Ltac Zpow_tac t :=
 match isZpow_coef t with
 | true => constr:(N_of_Z t)
 | _ => constr:(NotConstant)
 end.

Ltac Zpower_neg :=
  repeat match goal with
  | [|- ?G] => 
    match G with 
    | context c [Zpower _ (Zneg _)] =>
      let t := context c [Z0] in
      change t
    end
  end.   


Add Ring Zr : Zth
  (decidable Zeqb_ok, constants [Zcst], preprocess [Zpower_neg;unfold Zsucc],
   power_tac Zpower_theory [Zpow_tac]).