Wiki Agenda Contact Version française

Binary multiplication

See this description on Wikipedia


Authors: Jean-Christophe Filliâtre

Topics: Mathematics

Tools: Why3

see also the index (by topic, by tool, by reference, by year)


module BinaryMultiplication

  use import mach.int.Int
  use import number.Parity
  use import ref.Ref

  let binary_mult (a b: int)
    requires { b >= 0 }
    ensures  { result = a * b }
  = let x = ref a in
    let y = ref b in
    let z = ref 0 in
    while !y <> 0 do
      invariant { 0 <= !y }
      invariant { !z + !x * !y = a * b }
      variant   { !y }
      if odd !y then z := !z + !x;
      x := 2 * !x;
      y := !y / 2
    done;
    !z

end


download ZIP archive

Why3 Proof Results for Project "binary_multiplication"

Theory "binary_multiplication.BinaryMultiplication": fully verified in 0.74 s

ObligationsAlt-Ergo (0.99.1)
VC for binary_mult0.74