Commit 7f0cc13a authored by MARCHE Claude's avatar MARCHE Claude

examples gcd, with version using fast WP

parent 93c99f44
......@@ -80,10 +80,12 @@ module BinaryGcd
=
if v > u then binary_gcd v u else
if v = 0 then u else
if even u then if even v then 2 * binary_gcd (u / 2) (v / 2)
else binary_gcd (u / 2) v
else if even v then binary_gcd u (v / 2)
else binary_gcd ((u - v) / 2) v
if mod u 2 = 0 then
if mod u 2 = 0 then 2 * binary_gcd (u / 2) (v / 2)
else binary_gcd (u / 2) v
else
if mod u 2 = 0 then binary_gcd u (v / 2)
else binary_gcd ((u - v) / 2) v
end
......
This diff is collapsed.
<?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="Alt-Ergo" version="0.99.1" timelimit="5" memlimit="1000"/>
<prover id="1" name="CVC4" version="1.4" timelimit="5" memlimit="1000"/>
<prover id="2" name="Z3" version="4.3.2" timelimit="5" memlimit="1000"/>
<file name="../gcd.mlw" expanded="true">
<theory name="EuclideanAlgorithm" sum="644b8d8ecd1a9e6f8fe429dc2c6ceeda">
<goal name="VC euclid" expl="VC for euclid">
<transf name="split_goal_wp">
<goal name="VC euclid.1" expl="1. division by zero">
<proof prover="0"><result status="valid" time="0.02" steps="3"/></proof>
</goal>
<goal name="VC euclid.2" expl="2. variant decrease">
<proof prover="0"><result status="valid" time="0.05" steps="47"/></proof>
</goal>
<goal name="VC euclid.3" expl="3. precondition">
<proof prover="0"><result status="valid" time="0.02" steps="7"/></proof>
</goal>
<goal name="VC euclid.4" expl="4. postcondition">
<proof prover="0"><result status="valid" time="1.15" steps="192"/></proof>
</goal>
</transf>
</goal>
</theory>
<theory name="EuclideanAlgorithmIterative" sum="0b539327de02ae3286b21bfab58f2abf">
<goal name="VC euclid" expl="VC for euclid">
<transf name="split_goal_wp">
<goal name="VC euclid.1" expl="1. loop invariant init">
<proof prover="0"><result status="valid" time="0.01" steps="2"/></proof>
</goal>
<goal name="VC euclid.2" expl="2. loop invariant init">
<proof prover="0"><result status="valid" time="0.02" steps="0"/></proof>
</goal>
<goal name="VC euclid.3" expl="3. division by zero">
<proof prover="0"><result status="valid" time="0.02" steps="6"/></proof>
</goal>
<goal name="VC euclid.4" expl="4. loop invariant preservation">
<proof prover="0"><result status="valid" time="0.03" steps="20"/></proof>
</goal>
<goal name="VC euclid.5" expl="5. loop invariant preservation">
<proof prover="0"><result status="valid" time="0.02" steps="13"/></proof>
</goal>
<goal name="VC euclid.6" expl="6. loop variant decrease">
<proof prover="1"><result status="valid" time="0.03"/></proof>
</goal>
<goal name="VC euclid.7" expl="7. postcondition">
<proof prover="0"><result status="valid" time="0.03" steps="16"/></proof>
</goal>
</transf>
</goal>
</theory>
<theory name="BinaryGcd" sum="b0618b3f5d4ce4520643c4d190df2ed9">
<goal name="even1">
<proof prover="0"><result status="valid" time="0.03" steps="16"/></proof>
</goal>
<goal name="odd1">
<proof prover="0"><result status="valid" time="0.03" steps="14"/></proof>
</goal>
<goal name="div_nonneg">
<proof prover="0"><result status="valid" time="0.03" steps="4"/></proof>
</goal>
<goal name="gcd_even_even">
<proof prover="0"><result status="valid" time="0.04" steps="28"/></proof>
</goal>
<goal name="gcd_even_odd">
<proof prover="2"><result status="valid" time="0.03"/></proof>
</goal>
<goal name="gcd_even_odd2">
<proof prover="0"><result status="valid" time="0.07" steps="24"/></proof>
</goal>
<goal name="odd_odd_div2">
<proof prover="0"><result status="valid" time="0.21" steps="178"/></proof>
</goal>
<goal name="VC gcd_odd_odd" expl="VC for gcd_odd_odd">
<proof prover="0"><result status="valid" time="0.06" steps="32"/></proof>
</goal>
<goal name="gcd_odd_odd2">
<proof prover="0"><result status="valid" time="0.53" steps="30"/></proof>
</goal>
<goal name="VC binary_gcd" expl="VC for binary_gcd">
<transf name="split_goal_wp">
<goal name="VC binary_gcd.1" expl="1. variant decrease">
<proof prover="2"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="VC binary_gcd.2" expl="2. precondition">
<proof prover="2"><result status="valid" time="0.02"/></proof>
</goal>
<goal name="VC binary_gcd.3" expl="3. division by zero">
<proof prover="2"><result status="valid" time="0.00"/></proof>
</goal>
<goal name="VC binary_gcd.4" expl="4. division by zero">
<proof prover="2"><result status="valid" time="0.00"/></proof>
</goal>
<goal name="VC binary_gcd.5" expl="5. variant decrease">
<proof prover="2"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="VC binary_gcd.6" expl="6. precondition">
<proof prover="0"><result status="valid" time="0.02" steps="16"/></proof>
<proof prover="2"><result status="valid" time="0.02"/></proof>
</goal>
<goal name="VC binary_gcd.7" expl="7. division by zero">
<proof prover="0"><result status="valid" time="0.02" steps="8"/></proof>
<proof prover="2"><result status="valid" time="0.00"/></proof>
</goal>
<goal name="VC binary_gcd.8" expl="8. variant decrease">
<proof prover="0"><result status="valid" time="0.01" steps="8"/></proof>
<proof prover="2"><result status="valid" time="0.00"/></proof>
</goal>
<goal name="VC binary_gcd.9" expl="9. precondition">
<proof prover="0"><result status="valid" time="0.01" steps="8"/></proof>
<proof prover="2"><result status="valid" time="0.00"/></proof>
</goal>
<goal name="VC binary_gcd.10" expl="10. division by zero">
<proof prover="0"><result status="valid" time="0.03" steps="8"/></proof>
<proof prover="2"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="VC binary_gcd.11" expl="11. variant decrease">
<proof prover="0"><result status="valid" time="0.01" steps="8"/></proof>
<proof prover="2"><result status="valid" time="0.00"/></proof>
</goal>
<goal name="VC binary_gcd.12" expl="12. precondition">
<proof prover="0"><result status="valid" time="0.02" steps="8"/></proof>
<proof prover="2"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="VC binary_gcd.13" expl="13. division by zero">
<proof prover="0"><result status="valid" time="0.02" steps="8"/></proof>
<proof prover="2"><result status="valid" time="0.00"/></proof>
</goal>
<goal name="VC binary_gcd.14" expl="14. variant decrease">
<proof prover="0"><result status="valid" time="0.04" steps="24"/></proof>
<proof prover="2"><result status="valid" time="0.02"/></proof>
</goal>
<goal name="VC binary_gcd.15" expl="15. precondition">
<proof prover="0"><result status="valid" time="0.02" steps="11"/></proof>
<proof prover="2"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="VC binary_gcd.16" expl="16. postcondition">
<proof prover="2"><result status="valid" time="0.02"/></proof>
</goal>
</transf>
</goal>
</theory>
<theory name="EuclideanAlgorithm31" sum="96988f323e3bdbdcd87c5915f5871171">
<goal name="VC euclid" expl="VC for euclid">
<transf name="split_goal_wp">
<goal name="VC euclid.1" expl="1. integer overflow">
<proof prover="0"><result status="valid" time="0.02" steps="3"/></proof>
</goal>
<goal name="VC euclid.2" expl="2. division by zero">
<proof prover="0"><result status="valid" time="0.02" steps="5"/></proof>
</goal>
<goal name="VC euclid.3" expl="3. integer overflow">
<proof prover="0"><result status="valid" time="0.09" steps="52"/></proof>
</goal>
<goal name="VC euclid.4" expl="4. variant decrease">
<proof prover="0"><result status="valid" time="0.95" steps="177"/></proof>
</goal>
<goal name="VC euclid.5" expl="5. precondition">
<proof prover="0"><result status="valid" time="0.02" steps="15"/></proof>
</goal>
<goal name="VC euclid.6" expl="6. postcondition">
<proof prover="0"><result status="valid" time="0.25" steps="90"/></proof>
</goal>
</transf>
</goal>
</theory>
</file>
</why3session>
......@@ -25,6 +25,11 @@ theory Parity
lemma even_2k: forall k: int. even (2 * k)
lemma odd_2k1: forall k: int. odd (2 * k + 1)
use import int.ComputerDivision
lemma even_mod2 :
forall n:int. even n <-> div n 2 = 0
end
(** {2 Divisibility} *)
......
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