From Stdlib Require Import Strings.String.
From Stdlib Require Import String Ascii.
From Stdlib Require Arith.
From stdpp Require Import base.
From stdpp Require Import fin_maps.
From stdpp Require Import gmap.
From stdpp Require Import base gmultiset.
From Stdlib Require Classical.
From Stdlib Require Import ZArith.
From stdpp.bitvector Require Import definitions tactics.
From Stdlib Require Import Sorting.Sorted.
From Stdlib Require Import Reals.Rbasic_fun.
From Stdlib Require Import Reals.Abstract.ConstructiveAbs.
From Stdlib Require Import Reals.Rdefinitions.
From stdpp Require Import list_relations.
From stdpp Require Import list_numbers.
From stdpp Require Import functions.
From Stdlib Require Import ClassicalEpsilon.
From stdpp Require Import base decidable.
From Stdlib Require Import ZArith.Zeuclid.
From Stdlib Require Import ZArith.Znumtheory.
From stdpp Require Import propset.
From Stdlib Require Import Reals.
Require Import Why3.Base.
Require Import Why3.why3.Ref.Ref.
Require Import Why3.map.Const.
Require Import Why3.map.MapEq.
Require Import multiprecision.mul.Mul.
Require Import Why3.mach.int.Unsigned.
Require Import Why3.mach.c.C.
Require Import multiprecision.types.Config.
Require Import multiprecision.types.Types.
Require Import multiprecision.types.Int32Eq.
Require Import multiprecision.types.UInt64Eq.
Require Import multiprecision.lemmas.Lemmas.
Require Import multiprecision.util.Util.
Require Import multiprecision.ptralias.Alias.
Require Import multiprecision.add.Add.
Open Scope Z_scope.
Lemma wmpn_mul_basecase'vc (sy : bv 32%N) (sx : bv 32%N) (x : ptr (bv 64%N)) (y : ptr (bv 64%N)) (r : ptr (bv 64%N)) (fact0 : 0%Z < bv_signed sy) (fact1 : bv_signed sy ≤ bv_signed sx) (fact2 : valid x (bv_signed sx)) (fact3 : valid y (bv_signed sy)) (fact4 : valid r (bv_signed sy + bv_signed sx)) (fact5 : writable r = true) : min y ≤ offset y ∧ offset y < C.max y ∧ valid x (bv_signed sx) ∧ valid r (bv_signed sx) ∧ writable r = true ∧ (∀(r1 : ptr (bv 64%N)), length (data r1) = length (data r) ∧ offset r1 = offset r ∧ min r1 = min r ∧ C.max r1 = C.max r ∧ writable r1 = writable r ∧ zone1 r1 = zone1 r -> (∀(c : bv 64%N), value r1 (bv_signed sx) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed sx) * bv_unsigned c = value x (bv_signed sx) * bv_unsigned (pelts y (offset y)) ∧ (∀(j : Z), j < offset r1 ∨ offset r1 + bv_signed sx ≤ j -> pelts r1 j = pelts r j) -> ((min r1 ≤ offset r1 + bv_signed sx ∧ offset r1 + bv_signed sx < C.max r1) ∧ writable r1 = true) ∧ (∀(r2 : ptr (bv 64%N)), length (data r2) = length (data r1) ∧ offset r2 = offset r1 ∧ min r2 = min r1 ∧ C.max r2 = C.max r1 ∧ writable r2 = writable r1 ∧ zone1 r2 = zone1 r1 -> pelts r2 = fun_updt (pelts r1) (offset r2 + bv_signed sx) c ∧ pelts r2 (offset r2 + bv_signed sx) = c -> (min r2 ≤ offset r2 + 1%Z ∧ offset r2 + 1%Z ≤ C.max r2) ∧ (∀(o1 : ptr (bv 64%N)), offset o1 = offset r2 + 1%Z ∧ plength o1 = plength r2 ∧ pelts o1 = pelts r2 ∧ data o1 = data r2 ∧ min o1 = min r2 ∧ C.max o1 = C.max r2 ∧ zone1 o1 = zone1 r2 ∧ writable o1 = writable r2 -> (min y ≤ offset y + 1%Z ∧ offset y + 1%Z ≤ C.max y) ∧ (∀(o2 : ptr (bv 64%N)), offset o2 = offset y + 1%Z ∧ plength o2 = plength y ∧ pelts o2 = pelts y ∧ data o2 = data y ∧ min o2 = min y ∧ C.max o2 = C.max y ∧ zone1 o2 = zone1 y ∧ writable o2 = writable y -> int'32_in_bounds (bv_signed sy - 1%Z) ∧ (∀(o3 : bv 32%N), bv_signed o3 = bv_signed sy - 1%Z -> ((1%Z ≤ 1%Z ∧ 1%Z ≤ bv_signed sy) ∧ 1%Z = bv_signed sy - bv_signed o3 ∧ value r2 (1%Z + bv_signed sx) = value x (bv_signed sx) * value y 1%Z ∧ offset o1 = offset r2 + 1%Z ∧ plength o1 = plength r2 ∧ min o1 = min r2 ∧ C.max o1 = C.max r2 ∧ pelts o1 = pelts r2 ∧ writable o1 = true ∧ offset o2 = offset y + 1%Z ∧ plength o2 = plength y ∧ min o2 = min y ∧ C.max o2 = C.max y ∧ pelts o2 = pelts y ∧ (∀(j : Z), j < offset r2 ∨ offset r2 + (bv_signed sy + bv_signed sx) ≤ j -> pelts r2 j = pelts r j)) ∧ (∀(vn : bv 32%N) (i : bv 32%N) (vp : ptr (bv 64%N)) (rp : ptr (bv 64%N)) (r3 : ptr (bv 64%N)), length (data r3) = length (data r2) ∧ offset r3 = offset r2 ∧ min r3 = min r2 ∧ C.max r3 = C.max r2 ∧ writable r3 = writable r2 ∧ zone1 r3 = zone1 r2 -> (1%Z ≤ bv_signed i ∧ bv_signed i ≤ bv_signed sy) ∧ bv_signed i = bv_signed sy - bv_signed vn ∧ value r3 (bv_signed i + bv_signed sx) = value x (bv_signed sx) * value y (bv_signed i) ∧ offset rp = offset r3 + bv_signed i ∧ plength rp = plength r3 ∧ min rp = min r3 ∧ C.max rp = C.max r3 ∧ pelts rp = pelts r3 ∧ writable rp = true ∧ offset vp = offset y + bv_signed i ∧ plength vp = plength y ∧ min vp = min y ∧ C.max vp = C.max y ∧ pelts vp = pelts y ∧ (∀(j : Z), j < offset r3 ∨ offset r3 + (bv_signed sy + bv_signed sx) ≤ j -> pelts r3 j = pelts r j) -> (if decide (2%Z ≤ bv_signed vn) then (0%Z < bv_signed sx ∧ valid x (bv_signed sx) ∧ valid vp 2%Z ∧ valid rp (bv_signed sx + 2%Z) ∧ writable rp = true) ∧ (∀(rp1 : ptr (bv 64%N)) (r4 : ptr (bv 64%N)), data rp1 = data r4 ∧ length (data r4) = length (data rp) ∧ offset rp1 = offset rp ∧ min rp1 = min rp ∧ C.max rp1 = C.max rp ∧ writable rp1 = writable rp ∧ zone1 rp1 = zone1 rp -> data rp1 = data r4 ∧ length (data r4) = length (data rp) ∧ offset rp1 = offset rp ∧ min rp1 = min rp ∧ C.max rp1 = C.max rp ∧ writable rp1 = writable rp ∧ zone1 rp1 = zone1 rp -> length (data r4) = length (data r3) ∧ offset r4 = offset r3 ∧ min r4 = min r3 ∧ C.max r4 = C.max r3 ∧ writable r4 = writable r3 ∧ zone1 r4 = zone1 r3 -> (∀(res : bv 64%N), value rp1 (bv_signed sx + 1%Z) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed sx + 1%Z) * bv_unsigned res = value rp (bv_signed sx) + value x (bv_signed sx) * value vp 2%Z ∧ (∀(j : Z), j < offset rp1 ∨ offset rp1 + bv_signed sx + 1%Z ≤ j -> pelts rp1 j = pelts rp j) -> int'32_in_bounds (bv_signed sx + 1%Z) ∧ (∀(o4 : bv 32%N), bv_signed o4 = bv_signed sx + 1%Z -> ((min rp1 ≤ offset rp1 + bv_signed o4 ∧ offset rp1 + bv_signed o4 < C.max rp1) ∧ writable rp1 = true) ∧ (∀(rp2 : ptr (bv 64%N)) (r5 : ptr (bv 64%N)), data rp2 = data r5 ∧ length (data r5) = length (data rp1) ∧ offset rp2 = offset rp1 ∧ min rp2 = min rp1 ∧ C.max rp2 = C.max rp1 ∧ writable rp2 = writable rp1 ∧ zone1 rp2 = zone1 rp1 -> data rp2 = data r5 ∧ length (data r5) = length (data rp1) ∧ offset rp2 = offset rp1 ∧ min rp2 = min rp1 ∧ C.max rp2 = C.max rp1 ∧ writable rp2 = writable rp1 ∧ zone1 rp2 = zone1 rp1 -> length (data r5) = length (data r4) ∧ offset r5 = offset r4 ∧ min r5 = min r4 ∧ C.max r5 = C.max r4 ∧ writable r5 = writable r4 ∧ zone1 r5 = zone1 r4 -> pelts rp2 = fun_updt (pelts rp1) (offset rp2 + bv_signed o4) res ∧ pelts rp2 (offset rp2 + bv_signed o4) = res -> int'32_in_bounds (bv_signed i + 2%Z) ∧ (∀(o5 : bv 32%N), bv_signed o5 = bv_signed i + 2%Z -> (min rp2 ≤ offset rp2 + 2%Z ∧ offset rp2 + 2%Z ≤ C.max rp2) ∧ (∀(o6 : ptr (bv 64%N)), offset o6 = offset rp2 + 2%Z ∧ plength o6 = plength rp2 ∧ pelts o6 = pelts rp2 ∧ data o6 = data rp2 ∧ min o6 = min rp2 ∧ C.max o6 = C.max rp2 ∧ zone1 o6 = zone1 rp2 ∧ writable o6 = writable rp2 -> (min vp ≤ offset vp + 2%Z ∧ offset vp + 2%Z ≤ C.max vp) ∧ (∀(o7 : ptr (bv 64%N)), offset o7 = offset vp + 2%Z ∧ plength o7 = plength vp ∧ pelts o7 = pelts vp ∧ data o7 = data vp ∧ min o7 = min vp ∧ C.max o7 = C.max vp ∧ zone1 o7 = zone1 vp ∧ writable o7 = writable vp -> int'32_in_bounds (bv_signed vn - 2%Z) ∧ (∀(o8 : bv 32%N), bv_signed o8 = bv_signed vn - 2%Z -> bv_signed o8 < bv_signed vn ∧ (1%Z ≤ bv_signed o5 ∧ bv_signed o5 ≤ bv_signed sy) ∧ bv_signed o5 = bv_signed sy - bv_signed o8 ∧ value r5 (bv_signed o5 + bv_signed sx) = value x (bv_signed sx) * value y (bv_signed o5) ∧ offset o6 = offset r5 + bv_signed o5 ∧ plength o6 = plength r5 ∧ min o6 = min r5 ∧ C.max o6 = C.max r5 ∧ pelts o6 = pelts r5 ∧ writable o6 = true ∧ offset o7 = offset y + bv_signed o5 ∧ plength o7 = plength y ∧ min o7 = min y ∧ C.max o7 = C.max y ∧ pelts o7 = pelts y ∧ (∀(j : Z), j < offset r5 ∨ offset r5 + (bv_signed sy + bv_signed sx) ≤ j -> pelts r5 j = pelts r j))))))))) else ((1%Z ≤ bv_signed i ∧ bv_signed i ≤ bv_signed sy) ∧ bv_signed i = bv_signed sy - bv_signed vn ∧ value r3 (bv_signed i + bv_signed sx) = value x (bv_signed sx) * value y (bv_signed i) ∧ offset rp = offset r3 + bv_signed i ∧ plength rp = plength r3 ∧ min rp = min r3 ∧ C.max rp = C.max r3 ∧ pelts rp = pelts r3 ∧ writable rp = true ∧ offset vp = offset y + bv_signed i ∧ plength vp = plength y ∧ min vp = min y ∧ C.max vp = C.max y ∧ pelts vp = pelts y ∧ (∀(j : Z), j < offset r3 ∨ offset r3 + (bv_signed sy + bv_signed sx) ≤ j -> pelts r3 j = pelts r j)) ∧ (∀(vn1 : bv 32%N) (i1 : bv 32%N) (vp1 : ptr (bv 64%N)) (rp1 : ptr (bv 64%N)) (r4 : ptr (bv 64%N)), length (data r4) = length (data r3) ∧ offset r4 = offset r3 ∧ min r4 = min r3 ∧ C.max r4 = C.max r3 ∧ writable r4 = writable r3 ∧ zone1 r4 = zone1 r3 -> (1%Z ≤ bv_signed i1 ∧ bv_signed i1 ≤ bv_signed sy) ∧ bv_signed i1 = bv_signed sy - bv_signed vn1 ∧ value r4 (bv_signed i1 + bv_signed sx) = value x (bv_signed sx) * value y (bv_signed i1) ∧ offset rp1 = offset r4 + bv_signed i1 ∧ plength rp1 = plength r4 ∧ min rp1 = min r4 ∧ C.max rp1 = C.max r4 ∧ pelts rp1 = pelts r4 ∧ writable rp1 = true ∧ offset vp1 = offset y + bv_signed i1 ∧ plength vp1 = plength y ∧ min vp1 = min y ∧ C.max vp1 = C.max y ∧ pelts vp1 = pelts y ∧ (∀(j : Z), j < offset r4 ∨ offset r4 + (bv_signed sy + bv_signed sx) ≤ j -> pelts r4 j = pelts r j) -> (if decide (1%Z ≤ bv_signed vn1) then (min vp1 ≤ offset vp1 ∧ offset vp1 < C.max vp1) ∧ (valid x (bv_signed sx) ∧ valid rp1 (bv_signed sx) ∧ writable rp1 = true) ∧ (∀(rp2 : ptr (bv 64%N)) (r5 : ptr (bv 64%N)), data rp2 = data r5 ∧ length (data r5) = length (data rp1) ∧ offset rp2 = offset rp1 ∧ min rp2 = min rp1 ∧ C.max rp2 = C.max rp1 ∧ writable rp2 = writable rp1 ∧ zone1 rp2 = zone1 rp1 -> data rp2 = data r5 ∧ length (data r5) = length (data rp1) ∧ offset rp2 = offset rp1 ∧ min rp2 = min rp1 ∧ C.max rp2 = C.max rp1 ∧ writable rp2 = writable rp1 ∧ zone1 rp2 = zone1 rp1 -> length (data r5) = length (data r4) ∧ offset r5 = offset r4 ∧ min r5 = min r4 ∧ C.max r5 = C.max r4 ∧ writable r5 = writable r4 ∧ zone1 r5 = zone1 r4 -> (∀(res : bv 64%N), value rp2 (bv_signed sx) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed sx) * bv_unsigned res = value rp1 (bv_signed sx) + value x (bv_signed sx) * bv_unsigned (pelts vp1 (offset vp1)) ∧ (∀(j : Z), j < offset rp2 ∨ offset rp2 + bv_signed sx ≤ j -> pelts rp2 j = pelts rp1 j) -> ((min rp2 ≤ offset rp2 + bv_signed sx ∧ offset rp2 + bv_signed sx < C.max rp2) ∧ writable rp2 = true) ∧ (∀(rp3 : ptr (bv 64%N)) (r6 : ptr (bv 64%N)), data rp3 = data r6 ∧ length (data r6) = length (data rp2) ∧ offset rp3 = offset rp2 ∧ min rp3 = min rp2 ∧ C.max rp3 = C.max rp2 ∧ writable rp3 = writable rp2 ∧ zone1 rp3 = zone1 rp2 -> data rp3 = data r6 ∧ length (data r6) = length (data rp2) ∧ offset rp3 = offset rp2 ∧ min rp3 = min rp2 ∧ C.max rp3 = C.max rp2 ∧ writable rp3 = writable rp2 ∧ zone1 rp3 = zone1 rp2 -> length (data r6) = length (data r5) ∧ offset r6 = offset r5 ∧ min r6 = min r5 ∧ C.max r6 = C.max r5 ∧ writable r6 = writable r5 ∧ zone1 r6 = zone1 r5 -> pelts rp3 = fun_updt (pelts rp2) (offset rp3 + bv_signed sx) res ∧ pelts rp3 (offset rp3 + bv_signed sx) = res -> int'32_in_bounds (bv_signed i1 + 1%Z) ∧ (∀(o4 : bv 32%N), bv_signed o4 = bv_signed i1 + 1%Z -> (min rp3 ≤ offset rp3 + 1%Z ∧ offset rp3 + 1%Z ≤ C.max rp3) ∧ (∀(o5 : ptr (bv 64%N)), offset o5 = offset rp3 + 1%Z ∧ plength o5 = plength rp3 ∧ pelts o5 = pelts rp3 ∧ data o5 = data rp3 ∧ min o5 = min rp3 ∧ C.max o5 = C.max rp3 ∧ zone1 o5 = zone1 rp3 ∧ writable o5 = writable rp3 -> (min vp1 ≤ offset vp1 + 1%Z ∧ offset vp1 + 1%Z ≤ C.max vp1) ∧ (∀(o6 : ptr (bv 64%N)), offset o6 = offset vp1 + 1%Z ∧ plength o6 = plength vp1 ∧ pelts o6 = pelts vp1 ∧ data o6 = data vp1 ∧ min o6 = min vp1 ∧ C.max o6 = C.max vp1 ∧ zone1 o6 = zone1 vp1 ∧ writable o6 = writable vp1 -> int'32_in_bounds (bv_signed vn1 - 1%Z) ∧ (∀(o7 : bv 32%N), bv_signed o7 = bv_signed vn1 - 1%Z -> bv_signed o7 < bv_signed vn1 ∧ (1%Z ≤ bv_signed o4 ∧ bv_signed o4 ≤ bv_signed sy) ∧ bv_signed o4 = bv_signed sy - bv_signed o7 ∧ value r6 (bv_signed o4 + bv_signed sx) = value x (bv_signed sx) * value y (bv_signed o4) ∧ offset o5 = offset r6 + bv_signed o4 ∧ plength o5 = plength r6 ∧ min o5 = min r6 ∧ C.max o5 = C.max r6 ∧ pelts o5 = pelts r6 ∧ writable o5 = true ∧ offset o6 = offset y + bv_signed o4 ∧ plength o6 = plength y ∧ min o6 = min y ∧ C.max o6 = C.max y ∧ pelts o6 = pelts y ∧ (∀(j : Z), j < offset r6 ∨ offset r6 + (bv_signed sy + bv_signed sx) ≤ j -> pelts r6 j = pelts r j)))))))) else value r4 (bv_signed sy + bv_signed sx) = value x (bv_signed sx) * value y (bv_signed sy) ∧ (∀(j : Z), j < offset r4 ∨ offset r4 + (bv_signed sy + bv_signed sx) ≤ j -> pelts r4 j = pelts r j))))))))))).
Admitted.
