Commit 26dc2b1c authored by MARCHE Claude's avatar MARCHE Claude

Cleaning, add a few tests in the repository

parent 3c96a98a
......@@ -188,7 +188,7 @@ Release Notes (details in file CHANGES):
2 possible default strategies
. favor use of many prover before splitting or increading timeout
. favor use of many prover before splitting or increasing timeout
. or, on the contrary, favor splitting
......
theory T
use import int.Int
constant n : int
constant a : int
constant b : int
constant c : int
constant d : int
constant e : int
constant f : int
goal G : (n * a + b) * (n * c + d) =
n*n*a*c + n*(a*d+b*c) + b*d
goal G3 : (n * n * a + n * b + c) * (n * n * d + n * e + f) =
n*n*n*n*a*d + n*n*n*(a*e+b*d) + n*n*(a*f + b*e+c*d) +
n*(b*f+c*e) + c*f
end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE why3session PUBLIC "-//Why3//proof session v5//EN"
"http://why3.lri.fr/why3session.dtd">
<why3session shape_version="4">
<prover id="0" name="CVC4" version="1.4" timelimit="2" memlimit="1000"/>
<prover id="1" name="Z3" version="4.3.1" timelimit="2" memlimit="1000"/>
<prover id="2" name="Alt-Ergo" version="0.95.2" timelimit="2" memlimit="1000"/>
<file name="../distr.why" expanded="true">
<theory name="T" sum="288cdd62e8daae77f995e681126ca4b6" expanded="true">
<goal name="G" expanded="true">
<proof prover="0"><result status="valid" time="0.01"/></proof>
<proof prover="1"><result status="valid" time="0.00"/></proof>
<proof prover="2"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="G3" expanded="true">
<proof prover="0"><result status="valid" time="0.00"/></proof>
<proof prover="1"><result status="valid" time="0.01"/></proof>
<proof prover="2"><result status="valid" time="0.02"/></proof>
</goal>
</theory>
</file>
</why3session>
theory DivTest
use import real.Real
constant div_m1_2 : real = (-1.0) / 2.0
constant div_1_m2 : real = 1.0 / (-2.0)
constant div_m1_m2 : real = (-1.0) / (-2.0)
goal ok1 : div_m1_2 = -0.5
goal ok3 : div_1_m2 = -0.5
goal ok5 : div_m1_m2 = 0.5
goal smoke1 : div_m1_2 = 0.0
goal smoke3 : div_1_m2 = 1.0
goal smoke5 : div_m1_m2 = 0.0
goal div_bound0: forall x y. 0.0 < x <= y -> 0.0 < x/y <= 1.0
lemma div_le:
forall x y z. 0.0 < y -> x <= z * y -> x/y <= z
lemma div_lt:
forall x y z. 0.0 < y -> x < z * y -> x/y < z
lemma le_div:
forall x y z. 0.0 < y -> z * y <= x -> z <= x/y
lemma lt_div:
forall x y z. 0.0 < y -> z * y < x -> z < x/y
goal div_bound1: forall x y. 0.0 < x <= y -> 0.0 < x/y <= 1.0
end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE why3session PUBLIC "-//Why3//proof session v5//EN"
"http://why3.lri.fr/why3session.dtd">
<why3session shape_version="4">
<prover id="0" name="CVC3" version="2.4.1" timelimit="2" memlimit="1000"/>
<prover id="1" name="MetiTarski" version="2.2" timelimit="5" memlimit="1000"/>
<prover id="2" name="CVC4" version="1.4" timelimit="5" memlimit="1000"/>
<prover id="3" name="Eprover" version="1.4" timelimit="2" memlimit="1000"/>
<prover id="4" name="Z3" version="4.3.1" timelimit="2" memlimit="1000"/>
<prover id="5" name="Simplify" version="1.5.4" timelimit="2" memlimit="1000"/>
<prover id="6" name="Gappa" version="1.1.1" timelimit="5" memlimit="1000"/>
<prover id="7" name="Alt-Ergo" version="0.95.2" timelimit="2" memlimit="1000"/>
<prover id="8" name="Vampire" version="0.6" timelimit="2" memlimit="1000"/>
<prover id="9" name="Alt-Ergo" version="0.99.1" timelimit="5" memlimit="1000"/>
<prover id="10" name="Z3" version="4.3.2" timelimit="5" memlimit="1000"/>
<file name="../div_real.why" expanded="true">
<theory name="DivTest" sum="58cd42167084cc6ca94b14e42e5e98bd" expanded="true">
<goal name="ok1">
<proof prover="0"><result status="valid" time="0.00"/></proof>
<proof prover="1"><result status="valid" time="0.01"/></proof>
<proof prover="2"><result status="valid" time="0.01"/></proof>
<proof prover="4"><result status="valid" time="0.00"/></proof>
<proof prover="6"><result status="valid" time="0.00"/></proof>
<proof prover="7"><result status="valid" time="0.02" steps="0"/></proof>
<proof prover="9"><result status="valid" time="0.01" steps="0"/></proof>
<proof prover="10"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="ok3">
<proof prover="0"><result status="valid" time="0.00"/></proof>
<proof prover="1"><result status="valid" time="0.01"/></proof>
<proof prover="2"><result status="valid" time="0.00"/></proof>
<proof prover="4"><result status="valid" time="0.00"/></proof>
<proof prover="6"><result status="valid" time="0.00"/></proof>
<proof prover="7"><result status="valid" time="0.00" steps="0"/></proof>
<proof prover="9"><result status="valid" time="0.01" steps="0"/></proof>
<proof prover="10"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="ok5">
<proof prover="0"><result status="valid" time="0.00"/></proof>
<proof prover="1"><result status="valid" time="0.01"/></proof>
<proof prover="2"><result status="valid" time="0.00"/></proof>
<proof prover="4"><result status="valid" time="0.00"/></proof>
<proof prover="6"><result status="valid" time="0.00"/></proof>
<proof prover="7"><result status="valid" time="0.02" steps="0"/></proof>
<proof prover="9"><result status="valid" time="0.01" steps="0"/></proof>
<proof prover="10"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="smoke1">
<proof prover="1"><result status="unknown" time="0.32"/></proof>
<proof prover="2"><result status="unknown" time="0.00"/></proof>
<proof prover="4"><result status="unknown" time="0.01"/></proof>
<proof prover="5"><result status="unknown" time="0.01"/></proof>
<proof prover="6"><result status="unknown" time="0.00"/></proof>
<proof prover="7"><result status="unknown" time="0.01"/></proof>
<proof prover="8"><result status="unknown" time="1.91"/></proof>
<proof prover="9"><result status="unknown" time="0.01"/></proof>
<proof prover="10"><result status="unknown" time="0.02"/></proof>
</goal>
<goal name="smoke3">
<proof prover="1"><result status="unknown" time="0.32"/></proof>
<proof prover="2"><result status="unknown" time="0.01"/></proof>
<proof prover="4"><result status="unknown" time="0.01"/></proof>
<proof prover="5"><result status="unknown" time="0.00"/></proof>
<proof prover="6"><result status="unknown" time="0.00"/></proof>
<proof prover="7"><result status="unknown" time="0.01"/></proof>
<proof prover="8"><result status="unknown" time="1.98"/></proof>
<proof prover="9"><result status="unknown" time="0.01"/></proof>
<proof prover="10"><result status="unknown" time="0.01"/></proof>
</goal>
<goal name="smoke5">
<proof prover="1"><result status="unknown" time="0.30"/></proof>
<proof prover="2"><result status="unknown" time="0.00"/></proof>
<proof prover="3"><result status="timeout" time="1.97"/></proof>
<proof prover="4"><result status="unknown" time="0.01"/></proof>
<proof prover="5"><result status="timeout" time="1.93"/></proof>
<proof prover="6"><result status="unknown" time="0.00"/></proof>
<proof prover="7"><result status="unknown" time="0.01"/></proof>
<proof prover="8"><result status="unknown" time="2.02"/></proof>
<proof prover="9"><result status="unknown" time="0.01"/></proof>
<proof prover="10"><result status="unknown" time="0.01"/></proof>
</goal>
<goal name="div_bound0" expanded="true">
<proof prover="1"><result status="valid" time="0.04"/></proof>
<proof prover="4"><result status="valid" time="0.62"/></proof>
<proof prover="10"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="div_le">
<proof prover="1"><result status="valid" time="0.02"/></proof>
<proof prover="4"><result status="valid" time="0.02"/></proof>
<proof prover="10"><result status="valid" time="0.02"/></proof>
</goal>
<goal name="div_lt">
<proof prover="1"><result status="valid" time="0.02"/></proof>
<proof prover="4"><result status="valid" time="0.00"/></proof>
<proof prover="10"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="le_div">
<proof prover="1"><result status="valid" time="0.03"/></proof>
<proof prover="4"><result status="valid" time="0.73"/></proof>
<proof prover="10"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="lt_div">
<proof prover="1"><result status="valid" time="0.03"/></proof>
<proof prover="3"><result status="valid" time="0.23"/></proof>
<proof prover="4"><result status="valid" time="0.00"/></proof>
<proof prover="10"><result status="valid" time="0.02"/></proof>
</goal>
<goal name="div_bound1">
<proof prover="1"><result status="valid" time="0.04"/></proof>
<proof prover="3"><result status="valid" time="0.69"/></proof>
<proof prover="8"><result status="valid" time="0.09"/></proof>
<proof prover="10"><result status="valid" time="0.02"/></proof>
</goal>
</theory>
</file>
</why3session>
module PGCD
use import int.Int
use import ref.Refint
use import int.EuclideanDivision
predicate divides (m: int) (n: int) =
exists k: int. n = k * m
predicate common_div (m:int) (n:int) (cd:int) =
divides cd m /\ divides cd n
predicate is_gcd (m: int) (n: int) (gcd: int) =
common_div m n gcd /\ (forall d: int. common_div m n d -> divides d gcd)
lemma is_gcd_self: (* Proof by iProver or Spass *)
forall n: int. is_gcd n n n
lemma common_div_a_b:
forall a b k:int. common_div (a-b) b k -> common_div a b k
(* Isabelle proof
proof -
from assms have "\<exists>pa pb::int. (a-b) = pa * k \<and> b = pb * k" using common_div_def and divides_def by simp
then obtain pa pb where "(a-b) = pa * k" and "b = pb * k" by auto
hence "a-b+b = pa * k + pb * k" by simp
hence "a = (pa + pb) * k" using Mul_distr_r by simp
hence "divides k a" using divides_def by simp
thus "common_div a b k" using assms and common_div_def by simp
qed
*)
lemma common_div_b_a: (* Proof by Alt-Ergo *)
forall a b k:int. common_div a (b-a) k -> common_div a b k
lemma common_div_commutes: (* Proof by Alt-Ergo *)
forall a b k:int. common_div a b k -> common_div b a k
lemma gcd_commutes: (* Proof by Alt-Ergo *)
forall a b k:int. is_gcd a b k -> is_gcd b a k
lemma gcd_a_b:
forall a b k:int. is_gcd (a-b) b k -> is_gcd a b k
(* Isabelle proof
proof -
from assms have "common_div (a-b) b k" using is_gcd_def by simp
then have 1: "common_div a b k" using common_div_a_b by simp
(* show that any other common divisor of a and b divides k *)
{ fix p
assume h: "common_div a b p"
hence "\<exists>ka kb::int. (a = ka * p) \<and> (b = kb * p)" using common_div_def and divides_def by simp
then obtain ka kb where "a = ka * p" and "b = kb * p" by auto
hence "a - b = (ka - kb) * p" using int_distrib by simp
hence "divides p (a-b)" using divides_def by simp
hence "common_div (a-b) b p" using h and common_div_def by simp
hence "divides p k" using assms and is_gcd_def by simp
}
hence "\<forall>p::int. common_div a b p \<longrightarrow> divides p k" by simp
thus "is_gcd a b k" using 1 and is_gcd_def by simp
qed
*)
lemma gcd_b_a: (* Proof by Alt-Ergo *)
forall a b k:int. is_gcd a (b-a) k -> is_gcd a b k
(* Correctness and termination by Alt-Ergo *)
let pgcd (p: int) (q: int)
requires { p > 0 /\ q > 0 }
ensures { is_gcd p q result }
=
let a = ref p in
let b = ref q in
while (!a <> !b) do
invariant { !a > 0 /\ !b > 0 /\ forall k: int. is_gcd !a !b k -> is_gcd p q k }
variant { !a + !b }
if !a > !b then
a := !a - !b
else
b := !b - !a
done;
!a
end
theory PGCD_PGCD_common_div_a_b_1
imports Why3
begin
why3_open "PGCD_PGCD_common_div_a_b_1.xml"
why3_vc common_div_a_b
proof -
from assms have "\<exists>pa pb::int. (a-b) = pa * k \<and> b = pb * k" using common_div_def and divides_def by simp
then obtain pa pb where "(a-b) = pa * k" and "b = pb * k" by auto
hence "a-b+b = pa * k + pb * k" by simp
hence "a = (pa + pb) * k" using Mul_distr_r by simp
hence "divides k a" using divides_def by simp
thus "common_div a b k" using assms and common_div_def by simp
qed
why3_end
end
theory PGCD_PGCD_gcd_a_b_1
imports Why3
begin
why3_open "PGCD_PGCD_gcd_a_b_1.xml"
why3_vc gcd_a_b
proof -
from assms have "common_div (a-b) b k" using is_gcd_def by simp
then have 1: "common_div a b k" using common_div_a_b by simp
(* show that any other common divisor of a and b divides k *)
{ fix p
assume h: "common_div a b p"
hence "\<exists>ka kb::int. (a = ka * p) \<and> (b = kb * p)" using common_div_def and divides_def by simp
then obtain ka kb where "a = ka * p" and "b = kb * p" by auto
hence "a - b = (ka - kb) * p" using int_distrib by simp
hence "divides p (a-b)" using divides_def by simp
hence "common_div (a-b) b p" using h and common_div_def by simp
hence "divides p k" using assms and is_gcd_def by simp
}
hence "\<forall>p::int. common_div a b p \<longrightarrow> divides p k" by simp
thus "is_gcd a b k" using 1 and is_gcd_def by simp
qed
why3_end
end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE why3session PUBLIC "-//Why3//proof session v5//EN"
"http://why3.lri.fr/why3session.dtd">
<why3session shape_version="4">
<prover id="0" name="Isabelle" version="2014" timelimit="2" memlimit="1000"/>
<prover id="1" name="Alt-Ergo" version="0.99.1" timelimit="2" memlimit="1000"/>
<prover id="2" name="Eprover" version="1.4" timelimit="2" memlimit="1000"/>
<prover id="3" name="Vampire" version="0.6" timelimit="2" memlimit="1000"/>
<file name="../PGCD.mlw" expanded="true">
<theory name="PGCD" sum="2f961ae95bba7ce8e0cebe0d69d8bb94" expanded="true">
<goal name="is_gcd_self" expanded="true">
<proof prover="2"><result status="valid" time="0.11"/></proof>
<proof prover="3"><result status="valid" time="0.24"/></proof>
</goal>
<goal name="common_div_a_b" expanded="true">
<proof prover="0" edited="PGCD_PGCD_common_div_a_b_1.xml"><result status="valid" time="9.39"/></proof>
</goal>
<goal name="common_div_b_a" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="15"/></proof>
</goal>
<goal name="common_div_commutes" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="2"/></proof>
</goal>
<goal name="gcd_commutes" expanded="true">
<proof prover="1"><result status="valid" time="0.01" steps="14"/></proof>
</goal>
<goal name="gcd_a_b" expanded="true">
<proof prover="0" edited="PGCD_PGCD_gcd_a_b_1.xml"><result status="valid" time="9.83"/></proof>
</goal>
<goal name="gcd_b_a" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="28"/></proof>
</goal>
<goal name="WP_parameter pgcd" expl="VC for pgcd" expanded="true">
<proof prover="1"><result status="valid" time="0.10" steps="86"/></proof>
</goal>
</theory>
</file>
</why3session>
module M
use import int.Int
goal g1 : (=) 1 2
goal g2 : (>) 1 2
goal g3 : (<>) 1 2
end
theory T "expl:my explanation"
goal g "expl:my goal" : false
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