fact: Fixpoint aeval (s: ident -> option Z) (a: aexp) : option Z := match a with | CONST n => check_for_overflow n | VAR x => s x | PLUS a1 a2 => match aeval s a1, aeval s a2 with | Some n1, Some n2 => check_for_overflow (n1 + n2) | _, _ => None end | MINUS a1 a2 => match aeval s a1, aeval s a2 with | Some n1, Some n2 => check_for_overflow (n1 - n2) | _, _ => None end | TIMES a1 a2 => match aeval s a1, aeval s a2 with | Some n1, Some n2 => check_for_overflow (n1 * n2) | _, _ => None end | QUOT a1 a2 => match aeval s a1, aeval s a2 with | Some n1, Some n2 => if n2 =? 0 then None else check_for_overflow (n1 / n2) | _, _ => None end end.
imports: Coq(Arith ZArith Psatz Bool String List Program.Equality) CDF(Sequences Simulation)