Commit 12121e6a authored by MARCHE Claude's avatar MARCHE Claude

bitvecotrs, power_sum

parent b6331a81
......@@ -87,21 +87,24 @@ theory Pow2real
use import real.RealInfix
function pow2 (i:int) : real
axiom Power_0 : pow2 0 = 1.0
axiom Power_s : forall n: int. n >= 0 -> pow2 (n+1) = 2.0 *. pow2 n
axiom Power_p : forall n: int. n <= 0 -> pow2 (n-1) = 0.5 *. pow2 n
(* axiom Power_s : forall n:int. pow2 (n+1) = 2.0 *. pow2 n
lemma Power_s_all : forall n:int. pow2 (n+1) = 2.0 *. pow2 n
lemma Power_p_all : forall n:int. pow2 (n-1) = 0.5 *. pow2 n
axiom Power_p : forall n:int. pow2 (n-1) = 0.5 *. pow2 n
*)
lemma Power_1 : pow2 1 = 2.0
lemma Power_neg1 : pow2 (-1) = 0.5
lemma Power_non_null: forall n:int. pow2 n <> 0.0
lemma Power_neg : forall n:int. pow2 (-n) = 1.0 /. pow2 n
lemma Power_sum_aux : forall n m: int. m >= 0 -> pow2 (n+m) = pow2 n *. pow2 m
lemma Power_sum : forall n m: int. pow2 (n+m) = pow2 n *. pow2 m
use Pow2int
......
......@@ -7,15 +7,26 @@ Parameter pow2: Z -> R.
Axiom Power_0 : ((pow2 0%Z) = 1%R).
Axiom Power_s : forall (n:Z), ((pow2 (n + 1%Z)%Z) = (2%R * (pow2 n))%R).
Axiom Power_s : forall (n:Z), (0%Z <= n)%Z ->
((pow2 (n + 1%Z)%Z) = (2%R * (pow2 n))%R).
Axiom Power_p : forall (n:Z),
Axiom Power_p : forall (n:Z), (n <= 0%Z)%Z ->
((pow2 (n - 1%Z)%Z) = ((05 / 10)%R * (pow2 n))%R).
Axiom Power_s_all : forall (n:Z), ((pow2 (n + 1%Z)%Z) = (2%R * (pow2 n))%R).
Axiom Power_p_all : forall (n:Z),
((pow2 (n - 1%Z)%Z) = ((05 / 10)%R * (pow2 n))%R).
Axiom Power_1 : ((pow2 1%Z) = 2%R).
Axiom Power_neg1 : ((pow2 (-1%Z)%Z) = (05 / 10)%R).
Axiom Power_neg : forall (n:Z), ((pow2 (-n)%Z) = (Rdiv 1%R (pow2 n))%R).
Axiom Power_sum_aux : forall (n:Z) (m:Z), (0%Z <= m)%Z ->
((pow2 (n + m)%Z) = ((pow2 n) * (pow2 m))%R).
(* YOU MAY EDIT THE CONTEXT BELOW *)
Open Scope Z_scope.
(* DO NOT EDIT BELOW *)
......@@ -24,32 +35,16 @@ Theorem Power_sum : forall (n:Z) (m:Z),
((pow2 (n + m)%Z) = ((pow2 n) * (pow2 m))%R).
(* YOU MAY EDIT THE PROOF BELOW *)
intros n m.
assert (hm:m>=0 \/ m <=0) by omega.
destruct hm.
cut (0 <= m); auto with zarith.
apply Z_lt_induction with
(P:= fun m =>
0 <= m ->pow2 (n + m) = (pow2 n * pow2 m)%R);
auto with zarith.
intros x Hind Hxpos.
assert (h:(x = 0 \/ x > 0)) by omega.
destruct h.
subst x.
rewrite Power_0.
replace (n+0) with n by omega.
rewrite Rmult_1_r.
auto.
replace (x) with ((x-1)+1) by omega.
rewrite Power_s;auto with zarith.
replace (n + (x-1+1)) with (n+(x-1)+1) by omega.
rewrite Power_s;auto with zarith.
rewrite Hind;auto with zarith.
rewrite <-Rmult_assoc.
rewrite <-Rmult_assoc.
rewrite Rmult_comm with (r1:=pow2 n)(r2:=2%R).
auto with zarith.
apply Power_sum_aux; auto with zarith.
pose (m' := -m).
replace m with (-m') by (subst m'; omega).
replace (n+ - m') with (- ((-n) + m')) by omega.
repeat rewrite Power_neg.
rewrite Power_sum_aux.
rewrite Power_neg.
field.
Qed.
(* DO NOT EDIT BELOW *)
......
(* This file is generated by Why3's Coq driver *)
(* Beware! Only edit allowed sections below *)
Require Import ZArith.
Require Import Rbase.
Parameter pow2: Z -> R.
Axiom Power_0 : ((pow2 0%Z) = 1%R).
Axiom Power_s : forall (n:Z), (0%Z <= n)%Z ->
((pow2 (n + 1%Z)%Z) = (2%R * (pow2 n))%R).
Axiom Power_p : forall (n:Z), (n <= 0%Z)%Z ->
((pow2 (n - 1%Z)%Z) = ((05 / 10)%R * (pow2 n))%R).
Axiom Power_s_all : forall (n:Z), ((pow2 (n + 1%Z)%Z) = (2%R * (pow2 n))%R).
Axiom Power_p_all : forall (n:Z),
((pow2 (n - 1%Z)%Z) = ((05 / 10)%R * (pow2 n))%R).
Axiom Power_1 : ((pow2 1%Z) = 2%R).
Axiom Power_neg1 : ((pow2 (-1%Z)%Z) = (05 / 10)%R).
Axiom Power_neg : forall (n:Z), ((pow2 (-n)%Z) = (Rdiv 1%R (pow2 n))%R).
(* YOU MAY EDIT THE CONTEXT BELOW *)
Open Scope Z_scope.
(* DO NOT EDIT BELOW *)
Theorem Power_sum_aux : forall (n:Z) (m:Z), (0%Z <= m)%Z ->
((pow2 (n + m)%Z) = ((pow2 n) * (pow2 m))%R).
(* YOU MAY EDIT THE PROOF BELOW *)
intros n m Hmpos.
cut (0 <= m); auto with zarith.
apply Z_lt_induction with
(P:= fun m =>
0 <= m ->pow2 (n + m) = (pow2 n * pow2 m)%R);
auto with zarith.
intros x Hind Hxpos.
assert (h:(x = 0 \/ x > 0)) by omega.
destruct h.
subst x.
rewrite Power_0.
replace (n+0) with n by omega.
rewrite Rmult_1_r.
auto.
replace (x) with ((x-1)+1) by omega.
rewrite Power_s_all;auto with zarith.
replace (n + (x-1+1)) with (n+(x-1)+1) by omega.
rewrite Power_s_all;auto with zarith.
rewrite Hind;auto with zarith.
rewrite <-Rmult_assoc.
rewrite <-Rmult_assoc.
rewrite Rmult_comm with (r1:=pow2 n)(r2:=2%R).
auto with zarith.
Qed.
(* DO NOT EDIT BELOW *)
......@@ -64,7 +64,7 @@
expanded="true">
<theory
name="Pow2int"
verified="true"
verified="false"
expanded="false">
<goal
name="Power_1"
......@@ -83,58 +83,16 @@
<goal
name="Power_sum"
sum="359eadaae8b7571af3ad546bc8656944"
proved="true"
proved="false"
expanded="false"
shape="ainfix =apow2ainfix +V0V1ainfix *apow2V0apow2V1Iainfix >=V1c0Aainfix >=V0c0F">
<proof
prover="coq"
timelimit="5"
edited="bitvector1_Pow2int_Power_sum_1.v"
obsolete="true"><undone/>
obsolete="false"><undone/>
</proof>
<proof
prover="z3-3"
timelimit="5"
edited=""
obsolete="false">
<result status="timeout" time="5.05"/>
</proof>
<proof
prover="alt-ergo-0.93.1"
timelimit="5"
edited=""
obsolete="false">
<result status="unknown" time="1.33"/>
</proof>
<proof
prover="cvc3"
timelimit="5"
edited=""
obsolete="false">
<result status="unknown" time="0.26"/>
</proof>
<proof
prover="alt-ergo"
timelimit="20"
edited=""
obsolete="false">
<result status="valid" time="0.01"/>
</proof>
<proof
prover="z3"
timelimit="5"
edited=""
obsolete="false">
<result status="timeout" time="5.04"/>
</proof>
<proof
prover="cvc3-2.4"
timelimit="5"
edited=""
obsolete="false">
<result status="timeout" time="5.04"/>
</proof>
</goal>
<goal
name="pow2_0"
......@@ -1037,9 +995,107 @@
name="Pow2real"
verified="false"
expanded="true">
<goal
name="Power_s_all"
sum="c5fb9d8ded63621318b01c609abbdcd9"
proved="true"
expanded="false"
shape="ainfix =apow2ainfix +V0c1ainfix *.c2.0apow2V0F">
<proof
prover="z3-3"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
<proof
prover="alt-ergo-0.93.1"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
<proof
prover="cvc3"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
<proof
prover="alt-ergo"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.01"/>
</proof>
<proof
prover="z3"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
<proof
prover="cvc3-2.4"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
</goal>
<goal
name="Power_p_all"
sum="33c293d72214a95af3757e54840605f2"
proved="true"
expanded="false"
shape="ainfix =apow2ainfix -V0c1ainfix *.c0.5apow2V0F">
<proof
prover="z3-3"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
<proof
prover="alt-ergo-0.93.1"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
<proof
prover="cvc3"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
<proof
prover="alt-ergo"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.01"/>
</proof>
<proof
prover="z3"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
<proof
prover="cvc3-2.4"
timelimit="5"
edited=""
obsolete="false">
<result status="valid" time="0.00"/>
</proof>
</goal>
<goal
name="Power_1"
sum="05eff9d48281eb24cb06eb9caecf811e"
sum="41fe8e90054bbca35d861229fb18b32d"
proved="true"
expanded="false"
shape="ainfix =apow2c1c2.0">
......@@ -1053,7 +1109,7 @@
</goal>
<goal
name="Power_neg1"
sum="873e5deb81e7067f1c64b8bc0263fae2"
sum="0c2a780794aa529ee62fd6c37f584de4"
proved="true"
expanded="false"
shape="ainfix =apow2aprefix -c1c0.5">
......@@ -1066,51 +1122,135 @@
</proof>
</goal>
<goal
name="Power_sum"
sum="840e38f2212623d9db3cadc11d1beb95"
name="Power_neg"
sum="2e03270eae8aa0fd339e31ddf8a274c9"
proved="false"
expanded="true"
shape="ainfix =apow2aprefix -V0ainfix /.c1.0apow2V0F">
<proof
prover="z3-3"
timelimit="5"
edited=""
obsolete="false">
<result status="timeout" time="5.04"/>
</proof>
<proof
prover="alt-ergo-0.93.1"
timelimit="5"
edited=""
obsolete="false">
<result status="timeout" time="5.04"/>
</proof>
<proof
prover="cvc3"
timelimit="5"
edited=""
obsolete="false">
<result status="failure" time="0.00"/>
</proof>
<proof
prover="alt-ergo"
timelimit="5"
edited=""
obsolete="false">
<result status="timeout" time="5.04"/>
</proof>
<proof
prover="z3"
timelimit="5"
edited=""
obsolete="false">
<result status="timeout" time="5.04"/>
</proof>
<proof
prover="cvc3-2.4"
timelimit="5"
edited=""
obsolete="false">
<result status="failure" time="0.00"/>
</proof>
</goal>
<goal
name="Power_sum_aux"
sum="1221e979dfc352306bada6d6dfe05d1b"
proved="true"
expanded="false"
shape="ainfix =apow2ainfix +V0V1ainfix *.apow2V0apow2V1Iainfix >=V1c0F">
<proof
prover="coq"
timelimit="5"
edited="bitvector1_Pow2real_Power_sum_aux_1.v"
obsolete="false">
<result status="valid" time="0.54"/>
</proof>
</goal>
<goal
name="Power_sum"
sum="2163e22ca032c3d693e05d06bce6be39"
proved="false"
expanded="true"
shape="ainfix =apow2ainfix +V0V1ainfix *.apow2V0apow2V1F">
<proof
prover="coq"
timelimit="2"
edited="bitvector1_Pow2real_Power_sum_1.v"
obsolete="true">
<result status="unknown" time="0.55"/>
</proof>
<proof
prover="z3-3"
timelimit="5"
edited=""
obsolete="false">
<result status="timeout" time="5.04"/>
</proof>
<proof
prover="alt-ergo-0.93.1"
timelimit="5"
edited=""
obsolete="false">
<result status="unknown" time="0.51"/>
<result status="timeout" time="5.04"/>
</proof>
<proof
prover="cvc3"
timelimit="10"
edited=""
obsolete="false">
<result status="unknown" time="1.27"/>
<result status="highfailure" time="0.00"/>
</proof>
<proof
prover="alt-ergo"
timelimit="20"
edited=""
obsolete="false">
<result status="timeout" time="24.72"/>
<result status="timeout" time="5.04"/>
</proof>
<proof
prover="z3"
timelimit="10"
edited=""
obsolete="false">
<result status="timeout" time="12.00"/>
<result status="timeout" time="5.04"/>
</proof>
<proof
prover="cvc3-2.4"
timelimit="5"
edited=""
obsolete="false">
<result status="highfailure" time="0.00"/>
</proof>
</goal>
<goal
name="Pow2_int_real"
sum="b9531f5432cd945068f410e4ad7c7a1e"
proved="true"
sum="e71777ba72faf1090abcd5b09355fde1"
proved="false"
expanded="false"
shape="ainfix =apow2V0afrom_intapow2V0Iainfix >=V0c0F">
<proof
prover="alt-ergo"
timelimit="20"
edited=""
obsolete="false">
obsolete="true">
<result status="valid" time="0.03"/>
</proof>
</goal>
......@@ -1483,332 +1623,332 @@
</theory>
<theory
name="TestDouble"
verified="true"
verified="false"
expanded="false">
<goal
name="nth_one1"
sum="6583426a0a32f6a37297b050014372c7"
proved="true"
sum="946a42621e1d5e0bf76266b723e50211"
proved="false"
expanded="false"
shape="ainfix =anthaoneV0aFalseIainfix <=V0c51Aainfix <=c0V0F">
<proof
prover="alt-ergo"
timelimit="10"
edited=""
obsolete="false">
obsolete="true">
<result status="valid" time="0.06"/>
</proof>
</goal>
<goal
name="nth_one2"
sum="140ab55923b656faa74b45f2e6eaa3bf"
proved="true"
sum="6c086e35000bc12e12049f638514dccd"
proved="false"
expanded="false"
shape="ainfix =anthaoneV0aTrueIainfix <=V0c61Aainfix <=c52V0F">
<proof
prover="alt-ergo"
timelimit="10"
edited=""
obsolete="false">
obsolete="true">
<result status="valid" time="0.05"/>
</proof>
</goal>
<goal
name="nth_one3"
sum="f7aa9a2c6191395f0fc940451af44621"
proved="true"
sum="49cd9c457ec9938435231ddc3456eefe"
proved="false"
expanded="false"
shape="ainfix =anthaoneV0aFalseIainfix <=V0c63Aainfix <=c62V0F">
<proof
prover="alt-ergo"
timelimit="10"
edited=""
obsolete="false">
obsolete="true">
<result status="valid" time="0.04"/>
</proof>
</goal>
<goal
name="sign_one"
sum="2e06c9c5c1decff6d79d59e64dc2ba59"
proved="true"
sum="b8feffbfc0ede3e6be5d026e3f32a7e2"
proved="false"
expanded="false"
shape="ainfix =asignaoneaFalse">
<proof
prover="cvc3"
timelimit="10"
edited=""
obsolete="false">
obsolete="true">
<result status="valid" time="0.02"/>
</proof>
<proof
prover="alt-ergo"
timelimit="10"
edited=""
obsolete="false">
obsolete="true">
<result status="valid" time="0.03"/>
</proof>
</goal>
<goal
name="exp_one"
sum="160f819738377a5896cbf3925cd94cef"
proved="true"
sum="a5451eb48b120f1d9e1a943984019df0"
proved="false"
expanded="false"
shape="ainfix =aexpaonec1023">
<proof
prover="coq"
timelimit="5"
edited="bitvector1_TestDouble_exp_one_2.v"
obsolete="false">
obsolete="true">
<result status="valid" time="0.66"/>
</proof>
<proof
prover="cvc3"
timelimit="20"
edited=""
obsolete="false">
obsolete="true">
<result status="valid" time="0.46"/>
</proof>
<proof
prover="alt-ergo"
timelimit="10"
edited=""
obsolete="false">
obsolete="true">
<result status="valid" time="4.73"/>
</proof>
</goal>
<goal
name="mantissa_one"
sum="100740e59af030e776cce00e4fbcf174"
proved="true"
sum="42a67a19a5e04bd4c2003a03c59dfe5e"
proved="false"
expanded="false"
shape="ainfix =amantissaaonec0">
<proof
prover="alt-ergo"
timelimit="10"
edited=""
obsolete="false">
obsolete="true">
<result status="valid" time="0.23"/>
</proof>
</goal>
<goal
name="double_value_of_1"
sum="ffe7ee1439e0da9c625f1016edfeea20"
proved="true"
sum="0756184d935a17cc1e50f883d8db743c"
proved="false"
expanded="false"
shape="ainfix =adouble_of_bv64aonec1.0">
<proof
prover="cvc3"
timelimit="10"
edited=""