~ubuntu-branches/ubuntu/wily/coq-doc/wily

« back to all changes in this revision

Viewing changes to theories/QArith/Qfield.v

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu, Stéphane Glondu, Samuel Mimram
  • Date: 2010-01-07 22:50:39 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100107225039-n3cq82589u0qt0s2
Tags: 8.2pl1-1
[ Stéphane Glondu ]
* New upstream release (Closes: #563669)
  - remove patches
* Packaging overhaul:
  - use git, advertise it in Vcs-* fields of debian/control
  - use debhelper 7 and dh with override
  - use source format 3.0 (quilt)
* debian/control:
  - set Maintainer to d-o-m, set Uploaders to Sam and myself
  - add Homepage field
  - bump Standards-Version to 3.8.3
* Register PDF documentation into doc-base
* Add debian/watch
* Update debian/copyright

[ Samuel Mimram ]
* Change coq-doc's description to mention that it provides documentation in
  pdf format, not postscript, closes: #543545.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
(************************************************************************)
 
8
 
 
9
(*i $Id: Qfield.v 11208 2008-07-04 16:57:46Z letouzey $ i*)
 
10
 
 
11
Require Export Field.
 
12
Require Export QArith_base.
 
13
Require Import NArithRing.
 
14
 
 
15
(** * field and ring tactics for rational numbers *)
 
16
 
 
17
Definition Qsrt : ring_theory 0 1 Qplus Qmult Qminus Qopp Qeq.
 
18
Proof.
 
19
  constructor.
 
20
  exact Qplus_0_l.
 
21
  exact Qplus_comm.
 
22
  exact Qplus_assoc.
 
23
  exact Qmult_1_l.
 
24
  exact Qmult_comm.
 
25
  exact Qmult_assoc.
 
26
  exact Qmult_plus_distr_l.
 
27
  reflexivity.
 
28
  exact Qplus_opp_r.
 
29
Qed.
 
30
 
 
31
Definition Qsft : field_theory 0 1 Qplus Qmult Qminus Qopp Qdiv Qinv Qeq.
 
32
Proof.
 
33
  constructor.
 
34
  exact Qsrt.
 
35
  discriminate.
 
36
  reflexivity.
 
37
  intros p Hp.
 
38
  rewrite Qmult_comm.
 
39
  apply Qmult_inv_r.
 
40
  exact Hp.
 
41
Qed.
 
42
 
 
43
Lemma Qpower_theory : power_theory 1 Qmult Qeq Z_of_N Qpower.
 
44
Proof.
 
45
constructor.
 
46
intros r [|n];
 
47
reflexivity.
 
48
Qed.
 
49
 
 
50
Ltac isQcst t :=
 
51
  match t with
 
52
  | inject_Z ?z => isZcst z
 
53
  | Qmake ?n ?d =>
 
54
    match isZcst n with
 
55
      true => isPcst d
 
56
    | _ => false
 
57
    end
 
58
  | _ => false
 
59
  end.
 
60
 
 
61
Ltac Qcst t :=
 
62
  match isQcst t with
 
63
    true => t
 
64
    | _ => NotConstant
 
65
  end.
 
66
 
 
67
Ltac Qpow_tac t :=
 
68
  match t with
 
69
  | Z0 => N0
 
70
  | Zpos ?n => Ncst (Npos n)
 
71
  | Z_of_N ?n => Ncst n
 
72
  | NtoZ ?n => Ncst n
 
73
  | _ => NotConstant
 
74
  end.
 
75
 
 
76
Add Field Qfield : Qsft 
 
77
 (decidable Qeq_bool_eq, 
 
78
  completeness Qeq_eq_bool,
 
79
  constants [Qcst], 
 
80
  power_tac Qpower_theory [Qpow_tac]).
 
81
 
 
82
(** Exemple of use: *)
 
83
 
 
84
Section Examples. 
 
85
 
 
86
Let ex1 : forall x y z : Q, (x+y)*z ==  (x*z)+(y*z).
 
87
  intros.
 
88
  ring.
 
89
Qed.
 
90
 
 
91
Let ex2 : forall x y : Q, x+y == y+x.
 
92
  intros. 
 
93
  ring.
 
94
Qed.
 
95
 
 
96
Let ex3 : forall x y z : Q, (x+y)+z == x+(y+z).
 
97
  intros.
 
98
  ring.
 
99
Qed.
 
100
 
 
101
Let ex4 : (inject_Z 1)+(inject_Z 1)==(inject_Z 2).
 
102
  ring.
 
103
Qed.
 
104
 
 
105
Let ex5 : 1+1 == 2#1.
 
106
  ring.
 
107
Qed.
 
108
 
 
109
Let ex6 : (1#1)+(1#1) == 2#1.
 
110
  ring.
 
111
Qed.
 
112
 
 
113
Let ex7 : forall x : Q, x-x== 0.
 
114
  intro.
 
115
  ring.
 
116
Qed.
 
117
 
 
118
Let ex8 : forall x : Q, x^1 == x.
 
119
  intro.
 
120
  ring.
 
121
Qed.
 
122
 
 
123
Let ex9 : forall x : Q, x^0 == 1.
 
124
  intro.
 
125
  ring.
 
126
Qed.
 
127
 
 
128
Let ex10 : forall x y : Q, ~(y==0) -> (x/y)*y == x.
 
129
intros.
 
130
field.
 
131
auto.
 
132
Qed.
 
133
 
 
134
End Examples.
 
135
 
 
136
Lemma Qopp_plus : forall a b,  -(a+b) == -a + -b.
 
137
Proof.
 
138
  intros; ring.
 
139
Qed.
 
140
 
 
141
Lemma Qopp_opp : forall q, - -q==q.
 
142
Proof.
 
143
  intros; ring.
 
144
Qed.