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

« back to all changes in this revision

Viewing changes to test-suite/micromega/square.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
(*                                                                      *)
 
3
(* Micromega: A reflexive tactic using the Positivstellensatz           *)
 
4
(*                                                                      *)
 
5
(*  Frédéric Besson (Irisa/Inria) 2006-2008                             *)
 
6
(*                                                                      *)
 
7
(************************************************************************)
 
8
 
 
9
Require Import ZArith Zwf Psatz QArith.
 
10
Open Scope Z_scope.
 
11
 
 
12
Lemma Zabs_square : forall x,  (Zabs  x)^2 = x^2.
 
13
Proof.
 
14
 intros ; case (Zabs_dec x) ; intros ; psatz Z 2.
 
15
Qed.
 
16
Hint Resolve Zabs_pos Zabs_square.
 
17
 
 
18
Lemma integer_statement :  ~exists n, exists p, n^2 = 2*p^2 /\ n <> 0.
 
19
Proof.
 
20
intros [n [p [Heq Hnz]]]; pose (n' := Zabs n); pose (p':=Zabs p).
 
21
assert (facts : 0 <= Zabs n /\ 0 <= Zabs p /\ Zabs n^2=n^2
 
22
         /\ Zabs p^2 = p^2) by auto.
 
23
assert (H : (0 < n' /\ 0 <= p' /\ n' ^2 = 2* p' ^2)) by 
 
24
  (destruct facts as [Hf1 [Hf2 [Hf3 Hf4]]]; unfold n', p' ; psatz Z 2).
 
25
generalize p' H; elim n' using (well_founded_ind (Zwf_well_founded 0)); clear.
 
26
intros n IHn p [Hn [Hp Heq]].
 
27
assert (Hzwf : Zwf 0 (2*p-n) n) by (unfold Zwf; psatz Z 2).
 
28
assert (Hdecr : 0 < 2*p-n /\ 0 <= n-p /\ (2*p-n)^2=2*(n-p)^2) by psatz Z 2.
 
29
apply (IHn (2*p-n) Hzwf (n-p) Hdecr).
 
30
Qed.
 
31
 
 
32
Open Scope Q_scope.
 
33
 
 
34
Lemma QnumZpower : forall x : Q, Qnum (x ^ 2)%Q = ((Qnum x) ^ 2) %Z.
 
35
Proof.
 
36
  intros.
 
37
  destruct x.
 
38
  cbv beta  iota zeta delta - [Zmult].
 
39
  ring.
 
40
Qed.
 
41
 
 
42
 
 
43
Lemma QdenZpower : forall x : Q, ' Qden (x ^ 2)%Q = ('(Qden x) ^ 2) %Z.
 
44
Proof.
 
45
  intros.
 
46
  destruct x.
 
47
  simpl.
 
48
  unfold Zpower_pos.
 
49
  simpl.
 
50
  rewrite Pmult_1_r.
 
51
  reflexivity.
 
52
Qed.
 
53
 
 
54
Theorem sqrt2_not_rational : ~exists x:Q, x^2==2#1.
 
55
Proof.
 
56
 unfold Qeq; intros [x]; simpl (Qden (2#1)); rewrite Zmult_1_r.
 
57
 intros HQeq.
 
58
 assert (Heq : (Qnum x ^ 2 = 2 * ' Qden x ^ 2%Q)%Z) by 
 
59
   (rewrite QnumZpower in HQeq ; rewrite QdenZpower in HQeq ; auto).
 
60
 assert (Hnx : (Qnum x <> 0)%Z)
 
61
 by (intros Hx; simpl in HQeq; rewrite Hx in HQeq; discriminate HQeq).
 
62
 apply integer_statement; exists (Qnum x); exists (' Qden x); auto.
 
63
Qed.