(**************************************************************************)
(*                                                                        *)
(*  This file is part of WP plug-in of Frama-C.                           *)
(*                                                                        *)
(*  Copyright (C) 2007-2015                                               *)
(*    CEA (Commissariat a l'energie atomique et aux energies              *)
(*         alternatives)                                                  *)
(*                                                                        *)
(*  you can redistribute it and/or modify it under the terms of the GNU   *)
(*  Lesser General Public License as published by the Free Software       *)
(*  Foundation, version 2.1.                                              *)
(*                                                                        *)
(*  It is distributed in the hope that it will be useful,                 *)
(*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *)
(*  GNU Lesser General Public License for more details.                   *)
(*                                                                        *)
(*  See the GNU Lesser General Public License version 2.1                 *)
(*  for more details (enclosed in the file licenses/LGPLv2.1).            *)
(*                                                                        *)
(**************************************************************************)

theory Cint
use bool.Bool as Bool
use int.Int as Int

function max_uint8 : int = 256

function max_sint8 : int = 128

function max_uint16 : int = 65536

function max_sint16 : int = 32768

function max_uint32 : int = 4294967296

function max_sint32 : int = 2147483648

function max_uint64 : int = 18446744073709551616

function max_sint64 : int = 9223372036854775808

predicate is_uint8 int

axiom is_uint8_def : forall x:int [is_uint8 x]. is_uint8 x <->
  (Int.(<=) (0) (x)) /\ (Int.(<) (x) (max_uint8))

predicate is_sint8 int

axiom is_sint8_def : forall x:int [is_sint8 x]. is_sint8 x <->
  (Int.(<=) ((Int.(-_) (max_sint8))) (x)) /\ (Int.(<) (x) (max_sint8))

predicate is_uint16 int

axiom is_uint16_def : forall x:int [is_uint16 x]. is_uint16 x <->
  (Int.(<=) (0) (x)) /\ (Int.(<) (x) (max_uint16))

predicate is_sint16 (x:int) = (Int.(<=) ((Int.(-_) (max_sint16))) (x)) /\
  (Int.(<) (x) (max_sint16))

predicate is_uint32 int

axiom is_uint32_def : forall x:int [is_uint32 x]. is_uint32 x <->
  (Int.(<=) (0) (x)) /\ (Int.(<) (x) (max_uint32))

predicate is_sint32 int

axiom is_sint32_def : forall x:int [is_sint32 x]. is_sint32 x <->
  (Int.(<=) ((Int.(-_) (max_sint32))) (x)) /\ (Int.(<) (x) (max_sint32))

predicate is_uint64 int

axiom is_uint64_def : forall x:int [is_uint64 x]. is_uint64 x <->
  (Int.(<=) (0) (x)) /\ (Int.(<) (x) (max_uint64))

predicate is_sint64 int

axiom is_sint64_def : forall x:int [is_sint64 x]. is_sint64 x <->
  (Int.(<=) ((Int.(-_) (max_sint64))) (x)) /\ (Int.(<) (x) (max_sint64))

function to_uint8 int : int

function to_sint8 int : int

function to_uint16 int : int

function to_sint16 int : int

function to_uint32 int : int

function to_sint32 int : int

function to_uint64 int : int

function to_sint64 int : int

function two_power_abs int : int

predicate is_uint (n:int) (x:int) = (Int.(<=) (0) (x)) /\
  (Int.(<) (x) (two_power_abs n))

predicate is_sint (n:int) (x:int) = (Int.(<=) ((Int.(-_) (two_power_abs
  n))) (x)) /\ (Int.(<) (x) (two_power_abs n))

function to_uint int int : int

function to_sint int int : int

axiom is_to_uint8 : forall x:int [is_uint8 (to_uint8 x)]. is_uint8 (to_uint8
  x)

axiom is_to_sint8 : forall x:int [is_sint8 (to_sint8 x)]. is_sint8 (to_sint8
  x)

axiom is_to_uint16 : forall x:int [is_uint16 (to_uint16 x)]. is_uint16
  (to_uint16 x)

axiom is_to_sint16 : forall x:int [is_sint16 (to_sint16 x)]. is_sint16
  (to_sint16 x)

axiom is_to_uint32 : forall x:int [is_uint32 (to_uint32 x)]. is_uint32
  (to_uint32 x)

axiom is_to_sint32 : forall x:int [is_sint32 (to_sint32 x)]. is_sint32
  (to_sint32 x)

axiom is_to_uint64 : forall x:int [is_uint64 (to_uint64 x)]. is_uint64
  (to_uint64 x)

axiom is_to_sint64 : forall x:int [is_sint64 (to_sint64 x)]. is_sint64
  (to_sint64 x)

axiom id_uint8 : forall x:int [to_uint8 x]. (Int.(<=) (0) (x)) /\
  (Int.(<) (x) (max_uint8)) -> ((to_uint8 x) = (x))

axiom id_sint8 : forall x:int [to_sint8 x].
  (Int.(<=) ((Int.(-_) (max_sint8))) (x)) /\ (Int.(<) (x) (max_sint8)) ->
  ((to_sint8 x) = (x))

axiom id_uint16 : forall x:int [to_uint16 x]. (Int.(<=) (0) (x)) /\
  (Int.(<) (x) (max_uint16)) -> ((to_uint16 x) = (x))

axiom id_sint16 : forall x:int [to_sint16 x].
  (Int.(<=) ((Int.(-_) (max_sint16))) (x)) /\ (Int.(<) (x) (max_sint16)) ->
  ((to_sint16 x) = (x))

axiom id_uint32 : forall x:int [to_uint32 x]. (Int.(<=) (0) (x)) /\
  (Int.(<) (x) (max_uint32)) -> ((to_uint32 x) = (x))

axiom id_sint32 : forall x:int [to_sint32 x].
  (Int.(<=) ((Int.(-_) (max_sint32))) (x)) /\ (Int.(<) (x) (max_sint32)) ->
  ((to_sint32 x) = (x))

axiom id_uint64 : forall x:int [to_uint64 x]. (Int.(<=) (0) (x)) /\
  (Int.(<) (x) (max_uint64)) -> ((to_uint64 x) = (x))

axiom id_sint64 : forall x:int [to_sint64 x].
  (Int.(<=) ((Int.(-_) (max_sint64))) (x)) /\ (Int.(<) (x) (max_sint64)) ->
  ((to_sint64 x) = (x))

axiom proj_int8 : forall x:int [to_sint8 (to_uint8 x)]. ((to_sint8 (to_uint8
  x)) = (to_sint8 x))

axiom proj_int16 : forall x:int [to_sint16 (to_uint16 x)]. ((to_sint16
  (to_uint16 x)) = (to_sint16 x))

axiom proj_int32 : forall x:int [to_sint32 (to_uint32 x)]. ((to_sint32
  (to_uint32 x)) = (to_sint32 x))

axiom proj_int64 : forall x:int [to_sint64 (to_uint64 x)]. ((to_sint64
  (to_uint64 x)) = (to_sint64 x))

function lnot int : int

function land int int : int

function lxor int int : int

function lor int int : int

function lsl int int : int

function lsr int int : int

function bit_testb int int : Bool.bool

predicate bit_test int int

end
