IVy is a research tool intended to allow interactive development of protocols and their proofs of correctness and to provide a platform for developing and experimenting with automated proof techniques. In particular, IVy provides interactive visualization of automated proofs, and supports a use model in which the human protocol designer and the automated tool interact to expose errors and prove correctness.
Here is an example using ivy to reproduce the bug:
#lang ivy1.8
include numbers
include order
process p = {
export action take_mod(y:nat,x:nat) # Computes y % x
implement take_mod {
require x ~= 0;
var rem : nat;
rem := y.mod(x);
debug "Taking Mod" with dividend = y,
divisor = x,
remainder = rem
;
}
export action mod_table(upto:nat,by:nat) # prints y % by for y = 0,1,...,upto-1
implement mod_table {
var dividend :nat;
dividend := 0;
while dividend < upto {
take_mod(dividend, by);
dividend := dividend.next;
}
}
} with nat
Running the above program, I can produce the following output:
Modulo in ivy has a correctness bug. In numbers.ivy and order.ivy,
mod
is defined asWhen it should instead be defined as
(For example,
mod(3, 2)
should equal3 - (3 / 2) * 2 = 3 - 1 * 2 = 1
, not3 - (3 / 2) * 3 = 3 - 1 * 3 = 0
.Here is an example using ivy to reproduce the bug:
Running the above program, I can produce the following output: