(* driver for Isabelle/HOL *)
(* main author: Stefan Berghofer <stefan.berghofer@secunet.com> *)


valid "Finished Why3 theory"
valid "All verification conditions have been proved"
unknown "The following verification conditions remain to be proved" "incomplete proof"
(* fail "\\*\\*\\* \\(.*\\)$" "\\1" *)
time "why3cpulimit time : %s s"

transformation "eliminate_negative_constants"
transformation "eliminate_literal"
transformation "eliminate_if_fmla"
transformation "eliminate_epsilon"
transformation "eliminate_let_fmla"
transformation "simplify_formula"

theory BuiltIn
  syntax type int "<type name=\"Int.int\"/>"
  syntax type real "<type name=\"Real.real\"/>"

  syntax predicate  (=)   "<app><const name=\"HOL.eq\"/>%1%2</app>"
end

theory HighOrd
  syntax type (->) "<fun>%1%2</fun>"
  syntax function (@) "<app>%1%2</app>"
end

theory Bool
  syntax type bool   "<type name=\"HOL.bool\"/>"

  syntax function True  "<const name=\"HOL.True\"/>"
  syntax function False "<const name=\"HOL.False\"/>"
end

theory bool.Bool
  syntax function andb  "<app><const name=\"HOL.conj\"/>%1%2</app>"
  syntax function orb   "<app><const name=\"HOL.disj\"/>%1%2</app>"
  syntax function xorb  "<app><const name=\"HOL.Not\"/><app><const name=\"HOL.eq\"/>%1%2</app></app>"
  syntax function notb  "<app><const name=\"HOL.Not\"/>%1</app>"
  syntax function implb "<app><const name=\"HOL.implies\"/>%1%2</app>"
end

theory int.Int
  syntax function zero "<number val=\"0\"><type name=\"Int.int\"/></number>"
  syntax function one  "<number val=\"1\"><type name=\"Int.int\"/></number>"

  syntax function (+)  "<app><const name=\"Groups.plus_class.plus\"/>%1%2</app>"
  syntax function (-)  "<app><const name=\"Groups.minus_class.minus\"/>%1%2</app>"
  syntax function (*)  "<app><const name=\"Groups.times_class.times\"/>%1%2</app>"
  syntax function (-_) "<app><const name=\"Groups.uminus_class.uminus\"/>%1</app>"

  syntax predicate (<=) "<app><const name=\"Orderings.ord_class.less_eq\"/>%1%2</app>"
  syntax predicate (<)  "<app><const name=\"Orderings.ord_class.less\"/>%1%2</app>"
  syntax predicate (>=) "<app><const name=\"Orderings.ord_class.less_eq\"/>%2%1</app>"
  syntax predicate (>)  "<app><const name=\"Orderings.ord_class.less\"/>%2%1</app>"

  remove prop MulComm.Comm
  remove prop MulAssoc.Assoc
  remove prop Unit_def_l
  remove prop Unit_def_r
  remove prop Inv_def_l
  remove prop Inv_def_r
  remove prop Assoc
  remove prop Mul_distr_l
  remove prop Mul_distr_r
  remove prop Comm
  remove prop Unitary
  remove prop Refl
  remove prop Trans
  remove prop Antisymm
  remove prop Total
  remove prop NonTrivialRing
  remove prop CompatOrderAdd
  remove prop CompatOrderMult
  remove prop ZeroLessOne
end

theory int.Abs
  syntax function abs "<app><const name=\"Groups.abs_class.abs\"/>%1</app>"

  remove prop Abs_pos
end

theory int.MinMax
  syntax function min "<app><const name=\"Orderings.ord_class.min\"/>%1%2</app>"
  syntax function max "<app><const name=\"Orderings.ord_class.max\"/>%1%2</app>"
end

theory int.Exponentiation
  syntax function power "<app><const name=\"Power.power_class.power\"/>%1<app><const name=\"Int.nat\"/>%2</app></app>"
end

theory list.List
  syntax type list "<type name=\"List.list\">%1</type>"

  syntax function Nil "<const name=\"List.list.Nil\">%t0</const>"
  syntax function Cons "<app><const name=\"List.list.Cons\"/>%1%2</app>"
end

theory list.Length
  syntax function length "<app><const name=\"Nat.semiring_1_class.of_nat\"><fun><type name=\"Nat.nat\"/><type name=\"Int.int\"/></fun></const><app><const name=\"List.length\"/>%1</app></app>"
end

theory list.Append
  syntax function (++) "<app><const name=\"List.append\"/>%1%2</app>"
end

theory list.Reverse
  syntax function reverse "<app><const name=\"List.rev\"/>%1</app>"
end

theory list.Mem
  syntax predicate mem "<app><const name=\"Set.member\"/>%1<app><const name=\"List.list.set\"/>%2</app></app>"
end

theory list.NthNoOpt
  syntax function nth "<app><const name=\"List.nth\"/>%2<app><const name=\"Int.nat\"/>%1</app></app>"
end

theory list.HdTlNoOpt
  syntax function hd "<app><const name=\"List.list.hd\"/>%1</app>"
  syntax function tl "<app><const name=\"List.list.tl\"/>%1</app>"
end

theory list.Distinct
  syntax predicate distinct "<app><const name=\"List.distinct\"/>%1</app>"
end

theory option.Option
  syntax type option "<type name=\"Option.option\">%1</type>"

  syntax function None "<const name=\"Option.option.None\">%t0</const>"
  syntax function Some "<app><const name=\"Option.option.Some\"/>%1</app>"
end

theory map.Map
  syntax function get "<app>%1%2</app>"
  syntax function ([]) "<app>%1%2</app>"
  syntax function set "<app><const name=\"Fun.fun_upd\"/>%1%2%3</app>"
  syntax function ([<-]) "<app><const name=\"Fun.fun_upd\"/>%1%2%3</app>"
end

theory set.Fset
  syntax function cardinal "<app><const name=\"Nat.semiring_1_class.of_nat\"><fun><type name=\"Nat.nat\"/><type name=\"Int.int\"/></fun></const><app><const name=\"FSet.fcard\"/>%1</app></app>"
end

theory number.Parity
  syntax predicate even "<app><const name=\"Parity.semiring_parity_class.even\"/>%1</app>"
  syntax predicate odd  "<app><const name=\"Parity.semiring_parity_class.odd\"/>%1</app>"
end

theory number.Divisibility
  syntax predicate divides "<app><const name=\"Rings.dvd_class.dvd\"/>%1%2</app>"
end

theory number.Gcd
  syntax function gcd "<app><const name=\"GCD.gcd_class.gcd\"/>%1%2</app>"
end

theory number.Prime
  syntax predicate prime "<app><const name=\"Factorial_Ring.normalization_semidom_class.prime\"/>%1</app>"
end

theory number.Coprime
  syntax predicate coprime "<app><const name=\"Rings.algebraic_semidom_class.coprime\"/>%1%2</app>"
end

theory algebra.Field
  syntax function inv "<app><const name=\"Fields.inverse_class.inverse\"/>%1</app>"
  syntax function (/) "<app><const name=\"Rings.divide_class.divide\"/>%1%2</app>"
end

theory real.Real
  syntax function zero "<number val=\"0\"><type name=\"Real.real\"/></number>"
  syntax function one  "<number val=\"1\"><type name=\"Real.real\"/></number>"

  syntax function (+)  "<app><const name=\"Groups.plus_class.plus\"/>%1%2</app>"
  syntax function (-)  "<app><const name=\"Groups.minus_class.minus\"/>%1%2</app>"
  syntax function (*)  "<app><const name=\"Groups.times_class.times\"/>%1%2</app>"
  syntax function (-_) "<app><const name=\"Groups.uminus_class.uminus\"/>%1</app>"

  syntax predicate (<=) "<app><const name=\"Orderings.ord_class.less_eq\"/>%1%2</app>"
  syntax predicate (<)  "<app><const name=\"Orderings.ord_class.less\"/>%1%2</app>"
  syntax predicate (>=) "<app><const name=\"Orderings.ord_class.less_eq\"/>%2%1</app>"
  syntax predicate (>)  "<app><const name=\"Orderings.ord_class.less\"/>%2%1</app>"

  remove prop MulComm.Comm
  remove prop MulAssoc.Assoc
  remove prop Unit_def_l
  remove prop Unit_def_r
  remove prop Inv_def_l
  remove prop Inv_def_r
  remove prop Assoc
  remove prop Mul_distr_l
  remove prop Mul_distr_r
  remove prop Comm
  remove prop Unitary
  remove prop Refl
  remove prop Trans
  remove prop Antisymm
  remove prop Total
  remove prop NonTrivialRing
  remove prop CompatOrderAdd
  remove prop CompatOrderMult
  remove prop ZeroLessOne
end

theory real.Abs
  syntax function abs "<app><const name=\"Groups.abs_class.abs\"/>%1</app>"

  remove prop Abs_pos
end

theory real.MinMax
  syntax function min "<app><const name=\"Orderings.ord_class.min\"/>%1%2</app>"
  syntax function max "<app><const name=\"Orderings.ord_class.max\"/>%1%2</app>"
end

theory real.Trigonometry
  syntax function tan "<app><const name=\"Transcendental.tan\"/>%1</app>"
end

theory bv.BV_Gen
  meta "literal:keep" type t
  syntax function to_int "<app><const name=\"Word.sint\"/>%1</app>"
end

theory bv.BV64
  meta "literal:keep" type t
end

theory bv.BV32
  meta "literal:keep" type t
end

theory bv.BV16
  meta "literal:keep" type t
end

theory bv.BV8
  meta "literal:keep" type t
end

(* this file has an extension .aux rather than .gen since it should not be distributed *)
import "isabelle-realizations.aux"
