Commit dfce1fb3 authored by MARCHE Claude's avatar MARCHE Claude

One more lemma in number.Coprime, finished example gcd.mlw

parent 91427594
......@@ -56,6 +56,8 @@ module BinaryGcd
lemma odd1: forall n: int. 0 <= n -> not (even n) <-> n = 2 * div n 2 + 1
lemma div_nonneg: forall n: int. 0 <= n -> 0 <= div n 2
use number.Coprime
lemma gcd_even_even: forall u v: int. 0 <= v -> 0 <= u ->
gcd (2 * u) (2 * v) = 2 * gcd u v
lemma gcd_even_odd: forall u v: int. 0 <= v -> 0 <= u ->
......@@ -64,9 +66,11 @@ module BinaryGcd
even u -> odd v -> gcd u v = gcd (div u 2) v
lemma odd_odd_div2: forall u v: int. 0 <= v -> 0 <= u ->
div ((2*u+1) - (2*v+1)) 2 = u - v
lemma gcd_odd_odd: forall u v: int. 0 <= v -> 0 <= u ->
lemma gcd_odd_odd_aux: forall u v: int. 0 <= v <= u ->
gcd (2 * u + 1) (2 * v + 1) = gcd ((2*u+1) - 1*(2*v+1)) (2 * v + 1)
lemma gcd_odd_odd: forall u v: int. 0 <= v <= u ->
gcd (2 * u + 1) (2 * v + 1) = gcd (u - v) (2 * v + 1)
lemma gcd_odd_odd2: forall u v: int. 0 <= v -> 0 <= u ->
lemma gcd_odd_odd2: forall u v: int. 0 <= v <= u ->
odd u -> odd v -> gcd u v = gcd (div (u - v) 2) v
let rec binary_gcd (u v: int) : int
......
(* This file is generated by Why3's Coq driver *)
(* Beware! Only edit allowed sections below *)
Require Import BuiltIn.
Require BuiltIn.
Require int.Int.
Require int.Abs.
Require int.EuclideanDivision.
Require int.ComputerDivision.
Require number.Parity.
Require number.Divisibility.
Require number.Gcd.
Require number.Prime.
Require number.Coprime.
(* Why3 assumption *)
Definition unit := unit.
Axiom qtmark : Type.
Parameter qtmark_WhyType : WhyType qtmark.
Existing Instance qtmark_WhyType.
(* Why3 assumption *)
Definition lt_nat (x:Z) (y:Z): Prop := (0%Z <= y)%Z /\ (x < y)%Z.
(* Why3 assumption *)
Inductive lex: (Z* Z)%type -> (Z* Z)%type -> Prop :=
| Lex_1 : forall (x1:Z) (x2:Z) (y1:Z) (y2:Z), (lt_nat x1 x2) -> (lex (x1,
y1) (x2, y2))
| Lex_2 : forall (x:Z) (y1:Z) (y2:Z), (lt_nat y1 y2) -> (lex (x, y1) (x,
y2)).
Axiom even1 : forall (n:Z), (0%Z <= n)%Z -> ((number.Parity.even n) <->
(n = (2%Z * (ZArith.BinInt.Z.quot n 2%Z))%Z)).
Axiom odd1 : forall (n:Z), (0%Z <= n)%Z -> ((~ (number.Parity.even n)) <->
(n = ((2%Z * (ZArith.BinInt.Z.quot n 2%Z))%Z + 1%Z)%Z)).
Axiom div_nonneg : forall (n:Z), (0%Z <= n)%Z ->
(0%Z <= (ZArith.BinInt.Z.quot n 2%Z))%Z.
Axiom gcd_even_even : forall (u:Z) (v:Z), (0%Z <= v)%Z -> ((0%Z <= u)%Z ->
((number.Gcd.gcd (2%Z * u)%Z (2%Z * v)%Z) = (2%Z * (number.Gcd.gcd u
v))%Z)).
(* Why3 goal *)
Theorem gcd_even_odd : forall (u:Z) (v:Z), (0%Z <= v)%Z -> ((0%Z <= u)%Z ->
((number.Gcd.gcd (2%Z * u)%Z ((2%Z * v)%Z + 1%Z)%Z) = (number.Gcd.gcd u
((2%Z * v)%Z + 1%Z)%Z))).
(* Why3 intros u v h1 h2. *)
intros u v h1 h2.
rewrite Gcd.Comm.
rewrite number.Coprime.gcd_coprime.
now rewrite Gcd.Comm.
unfold Coprime.coprime.
rewrite <- Gcd.Gcd_computer_mod; auto with zarith.
rewrite ComputerDivision.Mod_mult; auto with zarith.
Qed.
......@@ -36,10 +36,14 @@
<prover
id="8"
name="Z3"
version="3.2"/>
<prover
id="9"
name="Z3"
version="4.3.1"/>
<file
name="../gcd.mlw"
verified="false"
verified="true"
expanded="true">
<theory
name="EuclideanAlgorithm"
......@@ -303,7 +307,7 @@
<result status="valid" time="0.02"/>
</proof>
<proof
prover="8"
prover="9"
timelimit="30"
memlimit="1000"
obsolete="false"
......@@ -338,7 +342,7 @@
name="BinaryGcd"
locfile="../gcd.mlw"
loclnum="47" loccnumb="7" loccnume="16"
verified="false"
verified="true"
expanded="true">
<goal
name="even1"
......@@ -394,8 +398,8 @@
<goal
name="gcd_even_even"
locfile="../gcd.mlw"
loclnum="59" loccnumb="8" loccnume="21"
sum="2117c22fad1f5cf9dbb1c0bbd3f0007c"
loclnum="61" loccnumb="8" loccnume="21"
sum="0ff4c69edc2188c2f55dfbccac02e22e"
proved="true"
expanded="false"
shape="ainfix =agcdainfix *c2V0ainfix *c2V1ainfix *c2agcdV0V1Iainfix &lt;=c0V0Iainfix &lt;=c0V1F">
......@@ -411,17 +415,26 @@
<goal
name="gcd_even_odd"
locfile="../gcd.mlw"
loclnum="61" loccnumb="8" loccnume="20"
sum="ea1adaec01593d8597d40b3477d0ddff"
proved="false"
expanded="true"
loclnum="63" loccnumb="8" loccnume="20"
sum="c36b3627edc8b2c18b59a14a5123965d"
proved="true"
expanded="false"
shape="ainfix =agcdainfix *c2V0ainfix +ainfix *c2V1c1agcdV0ainfix +ainfix *c2V1c1Iainfix &lt;=c0V0Iainfix &lt;=c0V1F">
<proof
prover="5"
timelimit="5"
memlimit="1000"
edited="gcd_BinaryGcd_gcd_even_odd_2.v"
obsolete="false"
archived="false">
<result status="valid" time="0.94"/>
</proof>
</goal>
<goal
name="gcd_even_odd2"
locfile="../gcd.mlw"
loclnum="63" loccnumb="8" loccnume="21"
sum="be0aba8ca2a549c75915af770866e101"
loclnum="65" loccnumb="8" loccnume="21"
sum="f3dd458ad1d04257c641287548a5706b"
proved="true"
expanded="false"
shape="ainfix =agcdV0V1agcdadivV0c2V1IaoddV1IaevenV0Iainfix &lt;=c0V0Iainfix &lt;=c0V1F">
......@@ -437,13 +450,13 @@
<goal
name="odd_odd_div2"
locfile="../gcd.mlw"
loclnum="65" loccnumb="8" loccnume="20"
sum="0d15e618ecb822a8e2f46a3635f1afc0"
loclnum="67" loccnumb="8" loccnume="20"
sum="b89ce00430a2682c5bcb0952c205d475"
proved="true"
expanded="false"
shape="ainfix =adivainfix -ainfix +ainfix *c2V0c1ainfix +ainfix *c2V1c1c2ainfix -V0V1Iainfix &lt;=c0V0Iainfix &lt;=c0V1F">
<proof
prover="8"
prover="9"
timelimit="6"
memlimit="1000"
obsolete="false"
......@@ -451,23 +464,64 @@
<result status="valid" time="0.01"/>
</proof>
</goal>
<goal
name="gcd_odd_odd_aux"
locfile="../gcd.mlw"
loclnum="69" loccnumb="8" loccnume="23"
sum="c9f41981a2bbb4f585b9a1b165277005"
proved="true"
expanded="false"
shape="ainfix =agcdainfix +ainfix *c2V0c1ainfix +ainfix *c2V1c1agcdainfix -ainfix +ainfix *c2V0c1ainfix *c1ainfix +ainfix *c2V1c1ainfix +ainfix *c2V1c1Iainfix &lt;=V1V0Aainfix &lt;=c0V1F">
<proof
prover="1"
timelimit="5"
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="0.03"/>
</proof>
</goal>
<goal
name="gcd_odd_odd"
locfile="../gcd.mlw"
loclnum="67" loccnumb="8" loccnume="19"
sum="03a93660eb212da1addde8091434f006"
proved="false"
expanded="true"
shape="ainfix =agcdainfix +ainfix *c2V0c1ainfix +ainfix *c2V1c1agcdainfix -V0V1ainfix +ainfix *c2V1c1Iainfix &lt;=c0V0Iainfix &lt;=c0V1F">
loclnum="71" loccnumb="8" loccnume="19"
sum="7d0f42fe2077e24ed0584c4a42509617"
proved="true"
expanded="false"
shape="ainfix =agcdainfix +ainfix *c2V0c1ainfix +ainfix *c2V1c1agcdainfix -V0V1ainfix +ainfix *c2V1c1Iainfix &lt;=V1V0Aainfix &lt;=c0V1F">
<proof
prover="1"
timelimit="5"
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="0.04"/>
</proof>
<proof
prover="8"
timelimit="5"
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="0.04"/>
</proof>
<proof
prover="9"
timelimit="5"
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="0.02"/>
</proof>
</goal>
<goal
name="gcd_odd_odd2"
locfile="../gcd.mlw"
loclnum="69" loccnumb="8" loccnume="20"
sum="212983c6f1456c4ae97edc3cc29e14ab"
loclnum="73" loccnumb="8" loccnume="20"
sum="3e147c7ac37b87dc87f24f02a4353789"
proved="true"
expanded="false"
shape="ainfix =agcdV0V1agcdadivainfix -V0V1c2V1IaoddV1IaoddV0Iainfix &lt;=c0V0Iainfix &lt;=c0V1F">
shape="ainfix =agcdV0V1agcdadivainfix -V0V1c2V1IaoddV1IaoddV0Iainfix &lt;=V1V0Aainfix &lt;=c0V1F">
<proof
prover="1"
timelimit="6"
......@@ -480,9 +534,9 @@
<goal
name="WP_parameter binary_gcd"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="VC for binary_gcd"
sum="4266a948997b3d24897a17785f42e048"
sum="2ded6e9da0fc59f9c4a630f811c42b51"
proved="true"
expanded="false"
shape="iiiiainfix =agcdV2V1agcdV0V1Aainfix &gt;=V1c0Aainfix &gt;=V2c0AalexaTuple2V1V2aTuple2V1V0Ladivainfix -V0V1c2ainfix =agcdV0V3agcdV0V1Aainfix &gt;=V3c0Aainfix &gt;=V0c0AalexaTuple2V3V0aTuple2V1V0LadivV1c2aevenV1iainfix =agcdV4V1agcdV0V1Aainfix &gt;=V1c0Aainfix &gt;=V4c0AalexaTuple2V1V4aTuple2V1V0LadivV0c2ainfix =ainfix *c2agcdV6V5agcdV0V1Aainfix &gt;=V5c0Aainfix &gt;=V6c0AalexaTuple2V5V6aTuple2V1V0LadivV0c2LadivV1c2aevenV1aevenV0ainfix =V0agcdV0V1ainfix =V1c0ainfix =agcdV1V0agcdV0V1Aainfix &gt;=V0c0Aainfix &gt;=V1c0AalexaTuple2V0V1aTuple2V1V0ainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -495,9 +549,9 @@
<goal
name="WP_parameter binary_gcd.1"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="1. variant decrease"
sum="0cfd55fb0b10e56f1f37c73c94b4843b"
sum="ef046f25bc5cd9675bef571ee6900dd2"
proved="true"
expanded="false"
shape="variant decreasealexaTuple2V0V1aTuple2V1V0Iainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -523,9 +577,9 @@
<goal
name="WP_parameter binary_gcd.2"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="2. precondition"
sum="413f01117d2caf1e3350bc6f73f9cf67"
sum="80a1c2079ed5f0a42cbc85862fd78e02"
proved="true"
expanded="false"
shape="preconditionainfix &gt;=V0c0Aainfix &gt;=V1c0Iainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -551,9 +605,9 @@
<goal
name="WP_parameter binary_gcd.3"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="3. postcondition"
sum="7f9fa5433322b46be3737d44a64aacf4"
sum="ae86b72f5166c3d6449234b6c8551bce"
proved="true"
expanded="false"
shape="postconditionainfix =agcdV1V0agcdV0V1Iainfix &gt;=V0c0Aainfix &gt;=V1c0Iainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -579,9 +633,9 @@
<goal
name="WP_parameter binary_gcd.4"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="4. postcondition"
sum="67fd0edfbd264e781201c1933bf72445"
sum="475dcfd89458b36e418ca5977df9bd9e"
proved="true"
expanded="false"
shape="postconditionainfix =V0agcdV0V1Iainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -607,9 +661,9 @@
<goal
name="WP_parameter binary_gcd.5"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="5. variant decrease"
sum="dfd113846d3757415b653efbb7df7ffd"
sum="2e1337a48640bcc573397294c6ceed62"
proved="true"
expanded="false"
shape="variant decreasealexaTuple2V2V3aTuple2V1V0LadivV0c2LadivV1c2IaevenV1IaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -623,21 +677,13 @@
archived="false">
<result status="valid" time="0.05"/>
</proof>
<proof
prover="6"
timelimit="6"
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="4.55"/>
</proof>
</goal>
<goal
name="WP_parameter binary_gcd.6"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="6. precondition"
sum="b188f1847a7239c9569cbe2bbe2d4906"
sum="c440c38e89135654d3992fe2552e78b9"
proved="true"
expanded="false"
shape="preconditionainfix &gt;=V2c0Aainfix &gt;=V3c0LadivV0c2LadivV1c2IaevenV1IaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -663,9 +709,9 @@
<goal
name="WP_parameter binary_gcd.7"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="7. postcondition"
sum="4121ff76f1a41e818c1f5c463ee7b315"
sum="15b8c4d6aaf509f04d9ea2c9ac26d4a9"
proved="true"
expanded="false"
shape="postconditionainfix =ainfix *c2agcdV3V2agcdV0V1Iainfix &gt;=V2c0Aainfix &gt;=V3c0LadivV0c2LadivV1c2IaevenV1IaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -685,15 +731,15 @@
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="0.09"/>
<result status="valid" time="0.41"/>
</proof>
</goal>
<goal
name="WP_parameter binary_gcd.8"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="8. variant decrease"
sum="4cc7532dee639aae88d5a5665a32a97c"
sum="6a61cc11939da2225c6f4ed3d0d26e03"
proved="true"
expanded="false"
shape="variant decreasealexaTuple2V1V2aTuple2V1V0LadivV0c2INaevenV1IaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -711,9 +757,9 @@
<goal
name="WP_parameter binary_gcd.9"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="9. precondition"
sum="a735a6b0a0b756938288a4b4dc375833"
sum="d53f41c70789bb025266f2c929177924"
proved="true"
expanded="false"
shape="preconditionainfix &gt;=V1c0Aainfix &gt;=V2c0LadivV0c2INaevenV1IaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -739,9 +785,9 @@
<goal
name="WP_parameter binary_gcd.10"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="10. postcondition"
sum="b76230c8d5a348f01e1fb62b2a5f1798"
sum="a7ef60aa71b0def6348341329417ab6b"
proved="true"
expanded="false"
shape="postconditionainfix =agcdV2V1agcdV0V1Iainfix &gt;=V1c0Aainfix &gt;=V2c0LadivV0c2INaevenV1IaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -761,15 +807,15 @@
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="0.14"/>
<result status="valid" time="0.60"/>
</proof>
</goal>
<goal
name="WP_parameter binary_gcd.11"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="11. variant decrease"
sum="bbcba9732a0e6e4f28cf5fef85c50ac6"
sum="c0073931eac7733d9ee9205983b9810e"
proved="true"
expanded="false"
shape="variant decreasealexaTuple2V2V0aTuple2V1V0LadivV1c2IaevenV1INaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -789,15 +835,15 @@
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="5.09"/>
<result status="valid" time="2.43"/>
</proof>
</goal>
<goal
name="WP_parameter binary_gcd.12"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="12. precondition"
sum="4cb731a1903b70f2030a5c8fa30ecdba"
sum="6dcb89859f1ce0b59658981c63dc232c"
proved="true"
expanded="false"
shape="preconditionainfix &gt;=V2c0Aainfix &gt;=V0c0LadivV1c2IaevenV1INaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -823,9 +869,9 @@
<goal
name="WP_parameter binary_gcd.13"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="13. postcondition"
sum="cffd3912ad76a895e2db1d06ed137203"
sum="8a39ef78de142e956a5432e6501df9d8"
proved="true"
expanded="false"
shape="postconditionainfix =agcdV0V2agcdV0V1Iainfix &gt;=V2c0Aainfix &gt;=V0c0LadivV1c2IaevenV1INaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -845,15 +891,15 @@
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="0.14"/>
<result status="valid" time="0.63"/>
</proof>
</goal>
<goal
name="WP_parameter binary_gcd.14"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="14. variant decrease"
sum="a72f35ef8028697df16656aa3cf4fa03"
sum="6072e986e2ab8ee5b3511d8ba0aa8286"
proved="true"
expanded="false"
shape="variant decreasealexaTuple2V1V2aTuple2V1V0Ladivainfix -V0V1c2INaevenV1INaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -879,9 +925,9 @@
<goal
name="WP_parameter binary_gcd.15"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="15. precondition"
sum="e75774a7747851bca92442d0b6da2141"
sum="ce3f844d28753cfccbe92d1d394d3dbf"
proved="true"
expanded="false"
shape="preconditionainfix &gt;=V1c0Aainfix &gt;=V2c0Ladivainfix -V0V1c2INaevenV1INaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -909,15 +955,15 @@
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="0.09"/>
<result status="valid" time="0.59"/>
</proof>
</goal>
<goal
name="WP_parameter binary_gcd.16"
locfile="../gcd.mlw"
loclnum="72" loccnumb="10" loccnume="20"
loclnum="76" loccnumb="10" loccnume="20"
expl="16. postcondition"
sum="20bb58d8f9ddac1b62a39d86788b6fea"
sum="3d8cc01e7b0bf5b9c640c0427df49220"
proved="true"
expanded="false"
shape="postconditionainfix =agcdV2V1agcdV0V1Iainfix &gt;=V1c0Aainfix &gt;=V2c0Ladivainfix -V0V1c2INaevenV1INaevenV0INainfix =V1c0INainfix &gt;V1V0Iainfix &gt;=V1c0Aainfix &gt;=V0c0F">
......@@ -937,7 +983,7 @@
memlimit="1000"
obsolete="false"
archived="false">
<result status="valid" time="0.03"/>
<result status="valid" time="0.09"/>
</proof>
</goal>
</transf>
......
......@@ -67,3 +67,21 @@ apply Znumtheory.prime_mult; auto.
now rewrite <- Prime.prime_is_Zprime.
Qed.
(* Why3 goal *)
Lemma gcd_coprime : forall (a:Z) (b:Z) (c:Z), (coprime a b) ->
((number.Gcd.gcd a (b * c)%Z) = (number.Gcd.gcd a c)).
intros a b c h1.
apply Z.gcd_unique.
- apply Z.gcd_nonneg.
- apply Gcd.gcd_def1.
- apply Divisibility.divides_multl.
apply Gcd.gcd_def2.
- intros q h2 h3.
apply Gcd.gcd_def3.
trivial.
apply Gauss with b; split; auto.
rewrite coprime_is_Zrel_prime.
rewrite coprime_is_Zrel_prime in h1.
now apply Znumtheory.rel_prime_div with (2:=h2).
Qed.
......@@ -118,7 +118,6 @@ theory Gcd
clone algebra.AC with type t = int, function op = gcd,
lemma Comm.Comm, lemma Assoc
(*** FIXME: Alt-Ergo proves gcd_0_pos even without gcd_unique *)
lemma gcd_0_pos: forall a: int. 0 <= a -> gcd a 0 = a
lemma gcd_0_neg: forall a: int. a < 0 -> gcd a 0 = -a
......@@ -196,5 +195,7 @@ theory Coprime
forall p a b:int.
prime p /\ divides p (a*b) -> divides p a \/ divides p b
lemma gcd_coprime:
forall a b c. coprime a b -> gcd a (b*c) = gcd a c
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment