summaryrefslogtreecommitdiff
path: root/plugins/ring/LegacyNArithRing.v
blob: b358251a51e3632ba6daa7af3229f80522894f25 (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
(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2014     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

(* Instantiation of the Ring tactic for the binary natural numbers *)

Require Import Bool.
Require Export LegacyRing.
Require Export ZArith_base.
Require Import NArith.
Require Import Eqdep_dec.

Definition Neq (n m:N) :=
  match (n ?= m)%N with
  | Datatypes.Eq => true
  | _ => false
  end.

Lemma Neq_prop : forall n m:N, Is_true (Neq n m) -> n = m.
  intros n m H; unfold Neq in H.
  apply N.compare_eq.
  destruct (n ?= m)%N; [ reflexivity | contradiction | contradiction ].
Qed.

Definition NTheory : Semi_Ring_Theory N.add N.mul 1%N 0%N Neq.
  split.
    apply N.add_comm.
    apply N.add_assoc.
    apply N.mul_comm.
    apply N.mul_assoc.
    apply N.add_0_l.
    apply N.mul_1_l.
    apply N.mul_0_l.
    apply N.mul_add_distr_r.
    apply Neq_prop.
Qed.

Add Legacy Semi Ring
  N N.add N.mul 1%N 0%N Neq NTheory [ Npos 0%N xO xI 1%positive ].