Commit f88de190 authored by Clément Fumex's avatar Clément Fumex

+ use literals in ieee_float theory

+ add 'minInt and 'maxInt attributes for range types
+ add 'eb and 'sb attributes for float types
+ make ieee_float realization compatible with Coq 8.4
parent 76b65d70
......@@ -57,9 +57,8 @@ end
theory ieee_float.Float32
(* Part I *)
syntax type t "Float32"
syntax converter from_binary "((_ to_fp 8 24) ((_ int2bv 32) %1))"
syntax converter (!_) "((_ to_fp 8 24) %1 %2)"
meta "literal:keep" type t
syntax literal t "(fp #b%s1b #b%e8b #b%m23b)"
syntax function zeroF "((_ to_fp 8 24) #x00000000)"
......@@ -69,9 +68,8 @@ end
theory ieee_float.Float64
(* Part I *)
syntax type t "Float64"
syntax converter from_binary "((_ to_fp 11 53) ((_ int2bv 64) %1))"
syntax converter (!_) "((_ to_fp 11 53) %1 %2)"
meta "literal:keep" type t
syntax literal t "(fp #b%s1b #b%e11b #b%m52b)"
syntax function zeroF "((_ to_fp 11 53) #x0000000000000000)"
......
module TestIeeeFloat
theory A
use import ieee_float.Float32
use real.Abs
lemma Test00: forall x:t. abs x .<= (of_int RNE 2) -> .- (of_int RNE 3) .<= x
use ieee_float.Float32
use ieee_float.Float64
lemma Test01:
forall x:t.
.-(of_int RNE 2) .<= x .<= (of_int RNE 2) -> .- (of_int RNE 4) .<= x .* x .<= (of_int RNE 4)
lemma ebsb32 : Float32.t'eb = 8 /\ Float32.t'sb = 24
lemma ebsb64 : Float64.t'eb = 11 /\ Float64.t'sb = 53
end
......@@ -15,18 +12,18 @@ module M603_018
use import ieee_float.Float32
constant x : t = zeroF
constant y : t = of_int RNE 1
constant z : t = y ./ (of_int RNE 2)
constant t : t = (x .+ y) ./ (of_int RNE 2)
constant y : t = 1.0
constant z : t = y ./ (2.0:t)
constant t : t = (x .+ y) ./ (2.0:t)
let triplet (x y z : t)
requires { x .<= z /\ z .<= y }
requires { .-(of_int RNE 1) .<= x /\ x .<= (of_int RNE 10) }
requires { y .= x .+ (of_int RNE 1) }
requires { .-(1.0:t) .<= x /\ x .<= (10.0:t) }
requires { y .= x .+ (1.0:t) }
requires { roundToIntegral RTN z = x }
requires { roundToIntegral RTP z = y }
=
let t = (x .+ y) ./ (of_int RNE 2) in
let t = (x .+ y) ./ (2.0:t) in
assert { roundToIntegral RTN x .= x };
assert { roundToIntegral RTN y .= y };
assert { roundToIntegral RTN z .= x };
......@@ -60,40 +57,34 @@ module M121_039_nonlinear
use import ieee_float.Float32
constant max : t = of_int RNE 340282346638528859811704183484516925440
constant max : t = 340282346638528859811704183484516925440.0
constant min : t = .- max
constant one : t = of_int RNE 1
constant zero : t = zeroF
constant one : t = 1.0
predicate in_range (x :t) = min .<= x .<= max
(* predicate axiom_mult t t t *)
(* axiom axiom_mult : forall a b y. *)
(* axiom_mult a b y = if a .<= b /\ y .<= zero then a .* y .>= b .* y else false *)
predicate axiom_mult (a b y : t) =
if a .<= b /\ y .<= zero then a .* y .>= b .* y else false
if a .<= b /\ y .<= zeroF then a .* y .>= b .* y else false
let test (a x y:t)
requires { zero .<= a .<= one }
requires { zeroF .<= a .<= one }
requires { .- one .<= x .<= one }
requires { .- one .<= y .<= one }
requires { x .> zero /\ y .< zero /\ x .+ y .>= zero }
ensures { result .>= zero /\ result .<= (of_int RNE 2) }
requires { x .> zeroF /\ y .< zeroF /\ x .+ y .>= zeroF }
ensures { result .>= zeroF /\ result .<= (2.0:t) }
=
assert { axiom_mult a one y };
assert { a .>= zero };
assert { a .>= zeroF };
assert { a .<= one };
assert { x .> zero };
assert { y .<= zero };
assert { y .* a .<= zero };
assert { x .> zeroF };
assert { y .<= zeroF };
assert { y .* a .<= zeroF };
assert { y .* a .>= y .* one };
assert { x .+ y .* a .>= x .+ y };
assert { x .+ y .>= zero };
assert { x .+ y .* a .>= zero };
assert { x .+ y .>= zeroF };
assert { x .+ y .* a .>= zeroF };
x .+ y .* a
......@@ -113,12 +104,3 @@ module LB09_025_conversion
to_int RNE x
end
module Test
use import ieee_float.Float32
constant half : t = of_int RNE 1 ./ of_int RNE 2
goal G1: forall x. is_finite x -> x .- half .<= roundToIntegral RNA x .<= x .+ half
end
This diff is collapsed.
......@@ -2,19 +2,19 @@ theory CheckBV64
use import bv.BV64
use int.Int
constant one : t = of_int 1
constant two : t = of_int 2
constant one : t = 1
constant two : t = 2
constant sz : int = 64
constant mx : int = 0xFFFF_FFFF_FFFF_FFFF
constant md : int = 0x1_0000_0000_0000_0000
constant lastb : t = of_int 0x8000_0000_0000_0000
constant mx : int = 0xFFFF_FFFF_FFFF_FFFF
constant md : int = 0x1_0000_0000_0000_0000
constant lastb : t = 0x8000_0000_0000_0000
goal ok_zero : zeros = (of_int 0)
goal ok_zero : zeros = (0:t)
goal ok_ones : ones = (of_int mx)
goal ok_zero2 : t'int zeros = 0
goal ok_ones2 : t'int ones = mx
goal ok_zero2 : t'int zeros = 0
goal ok_ones2 : t'int ones = mx
goal ok_size : size = sz
goal ok_max : max_int = mx
goal ok_max : t'maxInt = mx
goal ok_tpsize : two_power_size = md
goal ok1 : add ones one = zeros
......@@ -57,15 +57,15 @@ theory CheckBV64
(* from example/logic/bitvectors.why *)
constant b0000 : t = of_int 0b0000
constant b0001 : t = of_int 0b0001
constant b0010 : t = of_int 0b0010
constant b0011 : t = of_int 0b0011
constant b0110 : t = of_int 0b0110
constant b0101 : t = of_int 0b0101
constant b0111 : t = of_int 0b0111
constant b1100 : t = of_int 0b1100
constant b11100 : t = of_int 0b11100
constant b0000 : t = 0b0000
constant b0001 : t = 0b0001
constant b0010 : t = 0b0010
constant b0011 : t = 0b0011
constant b0110 : t = 0b0110
constant b0101 : t = 0b0101
constant b0111 : t = 0b0111
constant b1100 : t = 0b1100
constant b11100 : t = 0b11100
constant size_sub_one : int = Int.(-) size 1
......@@ -76,23 +76,23 @@ theory CheckBV64
goal f2 : bw_or b0011 b0110 = b0110
goal g3 : bw_xor b0011 b0110 = b0101
goal g4 : bw_not b0011 = (of_int 0xFFFFFFFFFFFFFFFC)
goal g4 : bw_not b0011 = (0xFFFFFFFFFFFFFFFC:t)
goal g3a : lsr_bv b0111 (of_int 2) = b0001
goal g3a : lsr_bv b0111 (2:t) = b0001
goal g3b : lsr_bv ones (of_int size_sub_one) = b0001
goal f3 : lsr_bv ones (of_int 0x100000001) = (of_int 0x7FFFFFFF)
goal f3 : lsr_bv ones (0x100000001:t) = (0x7FFFFFFF:t)
goal g4a : lsl_bv b0111 (of_int 2) = b11100
goal g4b : lsl_bv b0001 (of_int 31) = (of_int 0x80000000)
goal g4a : lsl_bv b0111 (2:t) = b11100
goal g4b : lsl_bv b0001 (31:t) = (0x80000000:t)
goal g5a : asr_bv b0111 (of_int 2) = b0001
goal g5a : asr_bv b0111 (2:t) = b0001
goal g5b : asr_bv ones (of_int (Int.(-) size 1)) = ones
goal g7 : t'int b11100 = 28
goal f7 : t'int ones = Int.(-_) 1
goal g8a : nth_bv b0110 (of_int 2) = True
goal g8b : nth_bv b0110 (of_int 3) = False
goal g8a : nth_bv b0110 (2:t) = True
goal g8b : nth_bv b0110 (3:t) = False
goal Nth_Bv_bw_and:
forall v1 v2 n. ult n size_bv ->
......@@ -145,19 +145,19 @@ theory CheckBV32
use import bv.BV32
use int.Int
constant one : t = of_int 1
constant two : t = of_int 2
constant one : t = 1
constant two : t = 2
constant sz : int = 32
constant mx : int = 0xFFFFFFFF
constant md : int = 0x100000000
constant lastb : t = of_int 0x80000000
constant lastb : t = 0x80000000
goal ok_zero : zeros = (of_int 0)
goal ok_zero : zeros = (0:t)
goal ok_ones : ones = (of_int mx)
goal ok_zero2 : t'int zeros = 0
goal ok_ones2 : t'int ones = mx
goal ok_zero2 : t'int zeros = 0
goal ok_ones2 : t'int ones = mx
goal ok_size : size = sz
goal ok_max : max_int = mx
goal ok_max : t'maxInt = mx
goal ok_tpsize : two_power_size = md
goal ok1 : add ones one = zeros
......@@ -203,19 +203,19 @@ theory CheckBV16
use import bv.BV16
use int.Int
constant one : t = of_int 1
constant two : t = of_int 2
constant one : t = 1
constant two : t = 2
constant sz : int = 16
constant mx : int = 65535
constant md : int = 65536
constant lastb : t = of_int 32768
constant lastb : t = 32768
goal ok_zero : zeros = (of_int 0)
goal ok_zero : zeros = (0:t)
goal ok_ones : ones = (of_int mx)
goal ok_zero2 : t'int zeros = 0
goal ok_ones2 : t'int ones = mx
goal ok_zero2 : t'int zeros = 0
goal ok_ones2 : t'int ones = mx
goal ok_size : size = sz
goal ok_max : max_int = mx
goal ok_max : t'maxInt = mx
goal ok_tpsize : two_power_size = md
goal ok1 : add ones one = zeros
......@@ -261,19 +261,19 @@ theory CheckBV8
use import bv.BV8
use int.Int
constant one : t = of_int 1
constant two : t = of_int 2
constant one : t = 1
constant two : t = 2
constant sz : int = 8
constant mx : int = 255
constant md : int = 256
constant lastb : t = of_int 128
constant lastb : t = 128
goal ok_zero : zeros = (of_int 0)
goal ok_zero : zeros = (0:t)
goal ok_ones : ones = (of_int mx)
goal ok_zero2 : t'int zeros = 0
goal ok_ones2 : t'int ones = mx
goal ok_zero2 : t'int zeros = 0
goal ok_ones2 : t'int ones = mx
goal ok_size : size = sz
goal ok_max : max_int = mx
goal ok_max : t'maxInt = mx
goal ok_tpsize : two_power_size = md
goal ok1 : add ones one = zeros
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE why3session PUBLIC "-//Why3//proof session v5//EN"
"http://why3.lri.fr/why3session.dtd">
<why3session shape_version="4">
<prover id="1" name="Z3" version="4.4.2" timelimit="11" steplimit="0" memlimit="4000"/>
<prover id="2" name="CVC4" version="1.4" timelimit="11" steplimit="0" memlimit="4000"/>
<prover id="3" name="Alt-Ergo" version="1.01" timelimit="11" steplimit="0" memlimit="4000"/>
<file name="../ieee_float.mlw" expanded="true">
<theory name="TestIeeeFloat" sum="9626577688521ad42852a971b5d056ff" expanded="true">
<goal name="Test00" expanded="true">
<proof prover="1"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="Test01" expanded="true">
<proof prover="1"><result status="valid" time="12.50"/></proof>
</goal>
</theory>
<theory name="M603_018" sum="edea63e177c099c0def0aaed6f99c750" expanded="true">
<goal name="WP_parameter triplet" expl="VC for triplet" expanded="true">
<proof prover="1"><result status="timeout" time="10.56"/></proof>
<proof prover="2"><result status="unknown" time="5.39"/></proof>
<proof prover="3"><result status="highfailure" time="9.25"/></proof>
</goal>
<goal name="G1" expanded="true">
<proof prover="1"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="G2" expanded="true">
<proof prover="1"><result status="valid" time="0.01"/></proof>
<proof prover="2"><result status="valid" time="0.08"/></proof>
<proof prover="3"><result status="valid" time="0.03" steps="14"/></proof>
</goal>
<goal name="G3" expanded="true">
<proof prover="1"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="G4" expanded="true">
<proof prover="1"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="G5" expanded="true">
<proof prover="1"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="G6" expanded="true">
<proof prover="1"><result status="valid" time="0.00"/></proof>
<proof prover="2"><result status="valid" time="0.08"/></proof>
<proof prover="3"><result status="valid" time="0.03" steps="14"/></proof>
</goal>
<goal name="G7" expanded="true">
<proof prover="1"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="G8" expanded="true">
<proof prover="1"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="G9" expanded="true">
<proof prover="1"><result status="valid" time="0.00"/></proof>
<proof prover="2"><result status="valid" time="0.12"/></proof>
<proof prover="3"><result status="valid" time="0.11" steps="140"/></proof>
</goal>
<goal name="G10" expanded="true">
<proof prover="1"><result status="valid" time="0.00"/></proof>
</goal>
</theory>
<theory name="M121_039_nonlinear" sum="673222610c1bf6e6c9111b886ac4347f" expanded="true">
<goal name="WP_parameter test" expl="VC for test" expanded="true">
<transf name="split_goal_wp" expanded="true">
<goal name="WP_parameter test.1" expl="1. assertion" expanded="true">
<proof prover="1"><result status="timeout" time="10.57"/></proof>
<proof prover="2"><result status="timeout" time="12.06"/></proof>
<proof prover="3"><result status="highfailure" time="4.29"/></proof>
</goal>
<goal name="WP_parameter test.2" expl="2. assertion" expanded="true">
<proof prover="1"><result status="valid" time="0.00"/></proof>
<proof prover="2"><result status="valid" time="0.07"/></proof>
<proof prover="3"><result status="valid" time="0.03" steps="21"/></proof>
</goal>
<goal name="WP_parameter test.3" expl="3. assertion" expanded="true">
<proof prover="1"><result status="valid" time="0.00"/></proof>
<proof prover="2"><result status="valid" time="0.07"/></proof>
<proof prover="3"><result status="valid" time="0.03" steps="21"/></proof>
</goal>
<goal name="WP_parameter test.4" expl="4. assertion" expanded="true">
<proof prover="1"><result status="valid" time="0.00"/></proof>
<proof prover="2"><result status="valid" time="0.07"/></proof>
<proof prover="3"><result status="valid" time="0.03" steps="21"/></proof>
</goal>
<goal name="WP_parameter test.5" expl="5. assertion" expanded="true">
<proof prover="1"><result status="valid" time="0.00"/></proof>
<proof prover="2"><result status="valid" time="0.10"/></proof>
<proof prover="3"><result status="valid" time="0.03" steps="22"/></proof>
</goal>
<goal name="WP_parameter test.6" expl="6. assertion" expanded="true">
<proof prover="1"><result status="valid" time="2.35"/></proof>
</goal>
<goal name="WP_parameter test.7" expl="7. assertion" expanded="true">
<proof prover="1"><result status="timeout" time="10.94"/></proof>
<proof prover="2"><result status="timeout" time="11.94"/></proof>
<proof prover="3"><result status="highfailure" time="4.28"/></proof>
</goal>
<goal name="WP_parameter test.8" expl="8. assertion" expanded="true">
<proof prover="1"><result status="timeout" time="10.79"/></proof>
<proof prover="2"><result status="timeout" time="11.91"/></proof>
<proof prover="3"><result status="highfailure" time="4.46"/></proof>
</goal>
<goal name="WP_parameter test.9" expl="9. assertion" expanded="true">
<proof prover="1"><result status="valid" time="0.01"/></proof>
<proof prover="2"><result status="valid" time="0.06"/></proof>
<proof prover="3"><result status="valid" time="0.03" steps="25"/></proof>
</goal>
<goal name="WP_parameter test.10" expl="10. assertion" expanded="true">
<proof prover="1"><result status="valid" time="0.18"/></proof>
<proof prover="2"><result status="valid" time="3.11"/></proof>
</goal>
<goal name="WP_parameter test.11" expl="11. postcondition" expanded="true">
<proof prover="1"><result status="valid" time="7.39"/></proof>
</goal>
</transf>
</goal>
</theory>
<theory name="LB09_025_conversion" sum="1cce16b73b44bb26d7c42668659aa4ff" expanded="true">
<goal name="WP_parameter fti" expl="VC for fti" expanded="true">
<transf name="split_goal_wp" expanded="true">
<goal name="WP_parameter fti.1" expl="1. postcondition" expanded="true">
<proof prover="1"><result status="timeout" time="10.83"/></proof>
<proof prover="2"><result status="timeout" time="11.82"/></proof>
<proof prover="3"><result status="highfailure" time="4.78"/></proof>
</goal>
<goal name="WP_parameter fti.2" expl="2. postcondition" expanded="true">
<proof prover="1"><result status="timeout" time="10.46"/></proof>
<proof prover="2"><result status="timeout" time="12.01"/></proof>
<proof prover="3"><result status="highfailure" time="5.88"/></proof>
</goal>
<goal name="WP_parameter fti.3" expl="3. postcondition" expanded="true">
<proof prover="1"><result status="valid" time="0.00"/></proof>
<proof prover="2"><result status="valid" time="0.05"/></proof>
<proof prover="3"><result status="valid" time="0.03" steps="11"/></proof>
</goal>
</transf>
</goal>
</theory>
<theory name="Test" sum="ee987103086bb1677a6382ca333aeb34" expanded="true">
<goal name="G1" expanded="true">
<proof prover="1"><result status="timeout" time="21.63"/></proof>
<proof prover="2"><result status="timeout" time="11.78"/></proof>
<proof prover="3"><result status="highfailure" time="5.56"/></proof>
</goal>
</theory>
</file>
</why3session>
......@@ -19,7 +19,7 @@ theory BV_Check
use import bv.Pow2int
lemma two_power_size_val : two_power_size = pow2 size
lemma max_int_val : max_int = two_power_size - 1
lemma max_int_val : t'maxInt = two_power_size - 1
lemma to_uint_extensionality :
forall v,v':t. t'int v = t'int v' -> v = v'
......@@ -34,10 +34,10 @@ theory BV_Check
lemma Of_int_zero: zeros = of_int 0
lemma Of_int_ones: ones = of_int max_int
lemma Of_int_ones: ones = of_int t'maxInt
goal nth_out_of_bound:
forall x n. size <= n <= max_int -> nth x n = False
forall x n. size <= n <= t'maxInt -> nth x n = False
goal Nth_zero: forall n:int. 0 <= n < size -> nth zeros n = False
......
This diff is collapsed.
......@@ -520,14 +520,32 @@ let add_types dl th =
let uc = add_ty_decl uc ts in
match ts.ts_def with
| NoDef | Alias _ -> uc
| Range _ ->
| Range rg ->
(* FIXME: "t'to_int" is probably better *)
let nm = ts.ts_name.id_string ^ "'int" in
let id = id_derive nm ts.ts_name in
let pj = create_fsymbol id [ty_app ts []] ty_int in
let uc = add_param_decl uc pj in
add_meta uc meta_range [MAts ts; MAls pj]
| Float _ ->
let uc = add_meta uc meta_range [MAts ts; MAls pj] in
(* create max attribute *)
let nm = ts.ts_name.id_string ^ "'maxInt" in
let id = id_derive nm ts.ts_name in
let ls = create_fsymbol id [] ty_int in
let t =
t_const Number.(ConstInt (int_const_dec (BigInt.to_string rg.ir_upper)))
ty_int
in
let uc = add_logic_decl uc [make_ls_defn ls [] t] in
(* create min attribute *)
let nm = ts.ts_name.id_string ^ "'minInt" in
let id = id_derive nm ts.ts_name in
let ls = create_fsymbol id [] ty_int in
let t =
t_const Number.(ConstInt (int_const_dec (BigInt.to_string rg.ir_lower)))
ty_int
in
add_logic_decl uc [make_ls_defn ls [] t]
| Float fmt ->
(* FIXME: "t'to_real" is probably better *)
let nm = ts.ts_name.id_string ^ "'real" in
let id = id_derive nm ts.ts_name in
......@@ -538,7 +556,19 @@ let add_types dl th =
let id = id_derive nm ts.ts_name in
let iF = create_psymbol id [ty_app ts []] in
let uc = add_param_decl uc iF in
add_meta uc meta_float [MAts ts; MAls pj; MAls iF]
let uc = add_meta uc meta_float [MAts ts; MAls pj; MAls iF] in
(* create exponent digits attribute *)
let nm = ts.ts_name.id_string ^ "'eb" in
let id = id_derive nm ts.ts_name in
let ls = create_fsymbol id [] ty_int in
let t = t_nat_const fmt.Number.fp_exponent_digits in
let uc = add_logic_decl uc [make_ls_defn ls [] t] in
(* create significand digits attribute *)
let nm = ts.ts_name.id_string ^ "'sb" in
let id = id_derive nm ts.ts_name in
let ls = create_fsymbol id [] ty_int in
let t = t_nat_const fmt.Number.fp_significand_digits in
add_logic_decl uc [make_ls_defn ls [] t]
in
try
let th = List.fold_left add_ty_decl th abstr in
......
......@@ -51,7 +51,7 @@ let rec abstract_terms kn range_metas float_metas type_kept acc t =
| _ ->
t_map_fold (abstract_terms kn range_metas float_metas type_kept) acc t
let elim le_int le_real abs_real type_kept kn
let elim le_int le_real neg_real type_kept kn
range_metas float_metas d (known_lit,task) =
match d.d_node with
| Dtype ts when Mts.exists (fun ts' _ -> ts_equal ts ts') range_metas
......@@ -98,11 +98,13 @@ let elim le_int le_real abs_real type_kept kn
let m_string = Format.flush_str_formatter () in
Number.print_in_base 10 None Format.str_formatter e;
let e_string = Format.flush_str_formatter () in
let term = t_const
let max_term = t_const
(Number.ConstReal
(Number.real_const_hex m_string "" (Some e_string))) ty_real in
(* compose axiom *)
let f = t_app le_real [t_app abs_real [v_term] (Some ty_real); term] None in
let f = t_and (t_app le_real [t_app neg_real [max_term] (Some ty_real); v_term] None)
(t_app le_real [v_term; max_term] None) in
(* t_app le_real [t_app abs_real [v_term] (Some ty_real); term] None in *)
let f = t_implies (t_app is_finite [t_var v] None) f in
let f = t_forall_close [v] [] f in
let ax_decl = create_prop_decl Paxiom pr f in
......@@ -116,11 +118,11 @@ let elim le_int le_real abs_real type_kept kn
let t = List.fold_left Task.add_decl task (List.rev local_decl) in
(known_lit, Task.add_decl t d)
let eliminate le_int le_real abs_real type_kept
let eliminate le_int le_real neg_real type_kept
range_metas float_metas t (known_lit, acc) =
match t.Task.task_decl.td_node with
| Decl d ->
elim le_int le_real abs_real type_kept
elim le_int le_real neg_real type_kept
t.Task.task_known range_metas float_metas d (known_lit, acc)
| Meta (m, [MAts ts]) when meta_equal m meta_keep_lit ->
let td = create_meta Libencoding.meta_kept [MAty (ty_app ts [])] in
......@@ -135,8 +137,7 @@ let eliminate_literal env =
let le_int = ns_find_ls th.th_export ["infix <="] in
let th = Env.read_theory env ["real"] "Real" in
let le_real = ns_find_ls th.th_export ["infix <="] in
let th = Env.read_theory env ["real"] "Abs" in
let abs_real = ns_find_ls th.th_export ["abs"] in
let neg_real = ns_find_ls th.th_export ["prefix -"] in
Trans.on_meta meta_range (fun range_metas ->
Trans.on_meta meta_float (fun float_metas ->
let range_metas = List.fold_left (fun acc meta_arg ->
......@@ -151,7 +152,7 @@ let eliminate_literal env =
Trans.on_tagged_ts meta_keep_lit
(fun type_kept ->
Trans.fold_map
(eliminate le_int le_real abs_real type_kept
(eliminate le_int le_real neg_real type_kept
range_metas float_metas)
Mterm.empty None)))
......
......@@ -398,18 +398,17 @@ end
theory BV64
constant size : int = 64
constant two_power_size : int = 0x1_0000_0000_0000_0000
constant max_int : int = 0xFFFF_FFFF_FFFF_FFFF
use int.Int (* needed to use range types *)
type t = < range 0x0000_0000_0000_0000 0xFFFF_FFFF_FFFF_FFFF >
type t = < range 0 0xFFFF_FFFF_FFFF_FFFF >
clone export BV_Gen with
type t = t,
function to_uint = t'int,
constant size = size,
constant two_power_size = two_power_size,
constant max_int = max_int,
constant max_int = t'maxInt,
goal size_pos,
goal two_power_size_val,
goal max_int_val
......@@ -419,18 +418,17 @@ end
theory BV32
constant size : int = 32
constant two_power_size : int = 0x1_0000_0000
constant max_int : int = 0xFFFF_FFFF
use int.Int (* needed to use range types *)
type t = < range 0x0000_0000 0xFFFF_FFFF >
type t = < range 0 0xFFFF_FFFF >
clone export BV_Gen with
type t = t,
function to_uint = t'int,
constant size = size,
constant two_power_size = two_power_size,
constant max_int = max_int,
constant max_int = t'maxInt,
goal size_pos,
goal two_power_size_val,
goal max_int_val
......@@ -440,18 +438,17 @@ end
theory BV16
constant size : int = 16
constant two_power_size : int = 0x1_0000
constant max_int : int = 0xFFFF
use int.Int (* needed to use range types *)
type t = < range 0x0000 0xFFFF >
type t = < range 0 0xFFFF >
clone export BV_Gen with
type t = t,
function to_uint = t'int,
constant size = size,
constant two_power_size = two_power_size,
constant max_int = max_int,
constant max_int = t'maxInt,
goal size_pos,
goal two_power_size_val,
goal max_int_val
......@@ -461,18 +458,17 @@ end
theory BV8
constant size : int = 8
constant two_power_size : int = 0x1_00
constant max_int : int = 0xFF
use int.Int (* needed to use range types *)
type t = < range 0x00 0xFF >
type t = < range 0 0xFF >
clone export BV_Gen with
type t = t,
function to_uint = t'int,
constant size = size,
constant two_power_size = two_power_size,
constant max_int = max_int,
constant max_int = t'maxInt,
goal size_pos,
goal two_power_size_val,
goal max_int_val
......
......@@ -64,12 +64,6 @@ theory GenericFloat
(* [m;x] = ( 1 + m * 2^(1-eb) ) * 2^( x - exp_bias ) *)
(* max_value = [2^(eb-1); 2^sb - 2] *)
(* constructor, perform an unchecked convertion from the binary *)
(* representation of a float. this is a workaround and should *)
(* only be used for literals! *)
function from_binary int : t
function (!) mode real : t (* constructor from real literals *)
(* {3 Operators} *)
function abs t : t
......@@ -489,8 +483,6 @@ theory GenericFloat
no_overflow m (to_real x *. to_real y +. to_real z) /\
to_real (fma m x y z) = round m (to_real x *. to_real y +. to_real z)
(* /!\ externalize square root? more generally, externalize any part
that needs another theory ? /!\ *)
use real.Square
axiom sqrt_finite: forall m:mode, x:t [sqrt m x].
......@@ -699,19 +691,6 @@ theory GenericFloat
axiom int_to_real: forall m x.
is_int x -> to_real x = FromInt.from_int (to_int m x)