1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(*i $Id: Qfield.v 11208 2008-07-04 16:57:46Z letouzey $ i*)
12
Require Export QArith_base.
13
Require Import NArithRing.
15
(** * field and ring tactics for rational numbers *)
17
Definition Qsrt : ring_theory 0 1 Qplus Qmult Qminus Qopp Qeq.
26
exact Qmult_plus_distr_l.
31
Definition Qsft : field_theory 0 1 Qplus Qmult Qminus Qopp Qdiv Qinv Qeq.
43
Lemma Qpower_theory : power_theory 1 Qmult Qeq Z_of_N Qpower.
52
| inject_Z ?z => isZcst z
70
| Zpos ?n => Ncst (Npos n)
76
Add Field Qfield : Qsft
77
(decidable Qeq_bool_eq,
78
completeness Qeq_eq_bool,
80
power_tac Qpower_theory [Qpow_tac]).
82
(** Exemple of use: *)
86
Let ex1 : forall x y z : Q, (x+y)*z == (x*z)+(y*z).
91
Let ex2 : forall x y : Q, x+y == y+x.
96
Let ex3 : forall x y z : Q, (x+y)+z == x+(y+z).
101
Let ex4 : (inject_Z 1)+(inject_Z 1)==(inject_Z 2).
105
Let ex5 : 1+1 == 2#1.
109
Let ex6 : (1#1)+(1#1) == 2#1.
113
Let ex7 : forall x : Q, x-x== 0.
118
Let ex8 : forall x : Q, x^1 == x.
123
Let ex9 : forall x : Q, x^0 == 1.
128
Let ex10 : forall x y : Q, ~(y==0) -> (x/y)*y == x.
136
Lemma Qopp_plus : forall a b, -(a+b) == -a + -b.
141
Lemma Qopp_opp : forall q, - -q==q.