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 Why3.mach.c.C.
Require Import Why3.mach.int.Unsigned.
Require Import multiprecision.lemmas.Lemmas.
Require Import multiprecision.types.Config.
Require Import multiprecision.types.Types.
Require Import multiprecision.types.Int32Eq.
Require Import multiprecision.types.UInt64Eq.
Require Import multiprecision.ptralias.Alias.
Open Scope Z_scope.
Theorem wmpn_add'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 sx)) (fact5 : writable r = true) : valid x (bv_signed sy) ∧ valid y (bv_signed sy) ∧ valid r (bv_signed sy) ∧ 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 -> (∀(o1 : bv 64%N), (0%Z ≤ bv_unsigned o1 ∧ bv_unsigned o1 ≤ 1%Z) ∧ value r1 (bv_signed sy) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed sy) * bv_unsigned o1 = value x (bv_signed sy) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r1 ∨ offset r1 + bv_signed sy ≤ j -> pelts r1 j = pelts r j) -> (∀(o2 : bool), (bv_unsigned o1 = bv_unsigned (0%bv : bv 64%N) -> o2 = true) ∧ (o2 = true -> o1 = (0%bv : bv 64%N)) -> (if decide (¬ o2 = true) then ((bv_signed sy ≤ bv_signed sy ∧ bv_signed sy ≤ bv_signed sx) ∧ value r1 (bv_signed sy) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed sy) * bv_unsigned o1 = value x (bv_signed sy) + value y (bv_signed sy) ∧ (0%Z ≤ bv_unsigned o1 ∧ bv_unsigned o1 ≤ 1%Z) ∧ (sy = sx ∨ bv_unsigned o1 = 1%Z) ∧ (∀(j : Z), j < offset r1 ∨ offset r1 + bv_signed sx ≤ j -> pelts r1 j = pelts r j)) ∧ (∀(i : bv 32%N) (c : bv 64%N) (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 -> (bv_signed sy ≤ bv_signed i ∧ bv_signed i ≤ bv_signed sx) ∧ value r2 (bv_signed i) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed i) * bv_unsigned c = value x (bv_signed i) + value y (bv_signed sy) ∧ (0%Z ≤ bv_unsigned c ∧ bv_unsigned c ≤ 1%Z) ∧ (i = sx ∨ bv_unsigned c = 1%Z) ∧ (∀(j : Z), j < offset r2 ∨ offset r2 + bv_signed sx ≤ j -> pelts r2 j = pelts r j) -> (if decide (bv_signed i < bv_signed sx) then (min x ≤ offset x + bv_signed i ∧ offset x + bv_signed i < C.max x) ∧ (∀(res : bv 64%N), bv_unsigned res = ZEuclid.modulo (bv_unsigned (pelts x (offset x + bv_signed i)) + 1%Z) (18446744073709551615%Z + 1%Z) -> ((min r2 ≤ offset r2 + bv_signed i ∧ offset r2 + bv_signed i < C.max r2) ∧ writable r2 = true) ∧ (∀(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 -> pelts r3 = fun_updt (pelts r2) (offset r3 + bv_signed i) res ∧ pelts r3 (offset r3 + bv_signed i) = res -> int'32_in_bounds (bv_signed i + 1%Z) ∧ (∀(o3 : bv 32%N), bv_signed o3 = bv_signed i + 1%Z -> (∀(o4 : bool), (bv_unsigned res = bv_unsigned (0%bv : bv 64%N) -> o4 = true) ∧ (o4 = true -> res = (0%bv : bv 64%N)) -> (if decide (¬ o4 = true) then ((bv_signed sy ≤ bv_signed o3 ∧ bv_signed o3 ≤ bv_signed sx) ∧ (o3 = sx ∨ bv_unsigned (0%bv : bv 64%N) = 0%Z) ∧ value r3 (bv_signed o3) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed o3) * bv_unsigned (0%bv : bv 64%N) = value x (bv_signed o3) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r3 ∨ offset r3 + bv_signed sx ≤ j -> pelts r3 j = pelts r j)) ∧ (∀(i1 : bv 32%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 -> (bv_signed sy ≤ bv_signed i1 ∧ bv_signed i1 ≤ bv_signed sx) ∧ (i1 = sx ∨ bv_unsigned (0%bv : bv 64%N) = 0%Z) ∧ value r4 (bv_signed i1) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed i1) * bv_unsigned (0%bv : bv 64%N) = value x (bv_signed i1) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r4 ∨ offset r4 + bv_signed sx ≤ j -> pelts r4 j = pelts r j) -> (if decide (bv_signed i1 < bv_signed sx) then (min x ≤ offset x + bv_signed i1 ∧ offset x + bv_signed i1 < C.max x) ∧ ((min r4 ≤ offset r4 + bv_signed i1 ∧ offset r4 + bv_signed i1 < C.max r4) ∧ writable r4 = true) ∧ (∀(r5 : ptr (bv 64%N)), 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 r5 = fun_updt (pelts r4) (offset r5 + bv_signed i1) (pelts x (offset x + bv_signed i1)) ∧ pelts r5 (offset r5 + bv_signed i1) = pelts x (offset x + bv_signed i1) -> int'32_in_bounds (bv_signed i1 + 1%Z) ∧ (∀(o5 : bv 32%N), bv_signed o5 = bv_signed i1 + 1%Z -> (0%Z ≤ bv_signed sx - bv_signed i1 ∧ bv_signed sx - bv_signed o5 < bv_signed sx - bv_signed i1) ∧ (bv_signed sy ≤ bv_signed o5 ∧ bv_signed o5 ≤ bv_signed sx) ∧ (o5 = sx ∨ bv_unsigned (0%bv : bv 64%N) = 0%Z) ∧ value r5 (bv_signed o5) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed o5) * bv_unsigned (0%bv : bv 64%N) = value x (bv_signed o5) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r5 ∨ offset r5 + bv_signed sx ≤ j -> pelts r5 j = pelts r j))) else value r4 (bv_signed sx) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed sx) * bv_unsigned (0%bv : bv 64%N) = value x (bv_signed sx) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r4 ∨ offset r4 + bv_signed sx ≤ j -> pelts r4 j = pelts r j) ∧ 0%Z ≤ bv_unsigned (0%bv : bv 64%N) ∧ bv_unsigned (0%bv : bv 64%N) ≤ 1%Z)) else (0%Z ≤ bv_signed sx - bv_signed i ∧ bv_signed sx - bv_signed o3 < bv_signed sx - bv_signed i) ∧ (bv_signed sy ≤ bv_signed o3 ∧ bv_signed o3 ≤ bv_signed sx) ∧ value r3 (bv_signed o3) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed o3) * bv_unsigned c = value x (bv_signed o3) + value y (bv_signed sy) ∧ (0%Z ≤ bv_unsigned c ∧ bv_unsigned c ≤ 1%Z) ∧ (o3 = sx ∨ bv_unsigned c = 1%Z) ∧ (∀(j : Z), j < offset r3 ∨ offset r3 + bv_signed sx ≤ j -> pelts r3 j = pelts r j)))))) else ((bv_signed sy ≤ bv_signed i ∧ bv_signed i ≤ bv_signed sx) ∧ (i = sx ∨ bv_unsigned c = 0%Z) ∧ value r2 (bv_signed i) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed i) * bv_unsigned c = value x (bv_signed i) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r2 ∨ offset r2 + bv_signed sx ≤ j -> pelts r2 j = pelts r j)) ∧ (∀(i1 : bv 32%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 -> (bv_signed sy ≤ bv_signed i1 ∧ bv_signed i1 ≤ bv_signed sx) ∧ (i1 = sx ∨ bv_unsigned c = 0%Z) ∧ value r3 (bv_signed i1) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed i1) * bv_unsigned c = value x (bv_signed i1) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r3 ∨ offset r3 + bv_signed sx ≤ j -> pelts r3 j = pelts r j) -> (if decide (bv_signed i1 < bv_signed sx) then (min x ≤ offset x + bv_signed i1 ∧ offset x + bv_signed i1 < C.max x) ∧ ((min r3 ≤ offset r3 + bv_signed i1 ∧ offset r3 + bv_signed i1 < C.max r3) ∧ writable r3 = true) ∧ (∀(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 -> pelts r4 = fun_updt (pelts r3) (offset r4 + bv_signed i1) (pelts x (offset x + bv_signed i1)) ∧ pelts r4 (offset r4 + bv_signed i1) = pelts x (offset x + bv_signed i1) -> int'32_in_bounds (bv_signed i1 + 1%Z) ∧ (∀(o3 : bv 32%N), bv_signed o3 = bv_signed i1 + 1%Z -> (0%Z ≤ bv_signed sx - bv_signed i1 ∧ bv_signed sx - bv_signed o3 < bv_signed sx - bv_signed i1) ∧ (bv_signed sy ≤ bv_signed o3 ∧ bv_signed o3 ≤ bv_signed sx) ∧ (o3 = sx ∨ bv_unsigned c = 0%Z) ∧ value r4 (bv_signed o3) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed o3) * bv_unsigned c = value x (bv_signed o3) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r4 ∨ offset r4 + bv_signed sx ≤ j -> pelts r4 j = pelts r j))) else value r3 (bv_signed sx) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed sx) * bv_unsigned c = value x (bv_signed sx) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r3 ∨ offset r3 + bv_signed sx ≤ j -> pelts r3 j = pelts r j) ∧ 0%Z ≤ bv_unsigned c ∧ bv_unsigned c ≤ 1%Z)))) else ((bv_signed sy ≤ bv_signed sy ∧ bv_signed sy ≤ bv_signed sx) ∧ (sy = sx ∨ bv_unsigned o1 = 0%Z) ∧ value r1 (bv_signed sy) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed sy) * bv_unsigned o1 = value x (bv_signed sy) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r1 ∨ offset r1 + bv_signed sx ≤ j -> pelts r1 j = pelts r j)) ∧ (∀(i : bv 32%N) (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 -> (bv_signed sy ≤ bv_signed i ∧ bv_signed i ≤ bv_signed sx) ∧ (i = sx ∨ bv_unsigned o1 = 0%Z) ∧ value r2 (bv_signed i) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed i) * bv_unsigned o1 = value x (bv_signed i) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r2 ∨ offset r2 + bv_signed sx ≤ j -> pelts r2 j = pelts r j) -> (if decide (bv_signed i < bv_signed sx) then (min x ≤ offset x + bv_signed i ∧ offset x + bv_signed i < C.max x) ∧ ((min r2 ≤ offset r2 + bv_signed i ∧ offset r2 + bv_signed i < C.max r2) ∧ writable r2 = true) ∧ (∀(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 -> pelts r3 = fun_updt (pelts r2) (offset r3 + bv_signed i) (pelts x (offset x + bv_signed i)) ∧ pelts r3 (offset r3 + bv_signed i) = pelts x (offset x + bv_signed i) -> int'32_in_bounds (bv_signed i + 1%Z) ∧ (∀(o3 : bv 32%N), bv_signed o3 = bv_signed i + 1%Z -> (0%Z ≤ bv_signed sx - bv_signed i ∧ bv_signed sx - bv_signed o3 < bv_signed sx - bv_signed i) ∧ (bv_signed sy ≤ bv_signed o3 ∧ bv_signed o3 ≤ bv_signed sx) ∧ (o3 = sx ∨ bv_unsigned o1 = 0%Z) ∧ value r3 (bv_signed o3) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed o3) * bv_unsigned o1 = value x (bv_signed o3) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r3 ∨ offset r3 + bv_signed sx ≤ j -> pelts r3 j = pelts r j))) else value r2 (bv_signed sx) + Z.pow (18446744073709551615%Z + 1%Z) (bv_signed sx) * bv_unsigned o1 = value x (bv_signed sx) + value y (bv_signed sy) ∧ (∀(j : Z), j < offset r2 ∨ offset r2 + bv_signed sx ≤ j -> pelts r2 j = pelts r j) ∧ 0%Z ≤ bv_unsigned o1 ∧ bv_unsigned o1 ≤ 1%Z)))))).
Admitted.
