diff --git a/.gitignore b/.gitignore index 065769eeba111c28e7250e496aec936c81b7db4f..633a7d72b4f6a96980eec0d1d508467a17ddfa92 100644 --- a/.gitignore +++ b/.gitignore @@ -204,3 +204,4 @@ hello-*.tar.gz /src/plugins/gui/gtk_compat.ml /src/plugins/gui/GSourceView.ml /src/plugins/gui/GSourceView.mli +/tests/crowbar/integer_bb_pretty diff --git a/Makefile b/Makefile index dced495df9d6f87380c3ec46461bc08e36d33b44..62da0160b06b00127cd4a487da4e77d2e5a8486b 100644 --- a/Makefile +++ b/Makefile @@ -924,6 +924,7 @@ PLUGIN_GUI_CMO:=$(VALUE_GUI_AUX) gui_files/gui_callstacks_manager \ gui_files/gui_red gui_files/register_gui PLUGIN_INTERNAL_TEST:= yes +PLUGIN_TESTS_LIB=tests/float/fval_test.ml PLUGIN_DISTRIBUTED:=yes VALUE_TYPES:=$(addprefix src/plugins/value_types/,\ cilE cvalue precise_locs value_types widen_type) @@ -958,6 +959,11 @@ PLUGIN_CMO:= options generator rte visit register PLUGIN_DISTRIBUTED:=yes PLUGIN_INTERNAL_TEST:=yes PLUGIN_TESTS_DIRS:=rte rte_manual +PLUGIN_TESTS_LIB:=\ + tests/rte/my_annotation/my_annotation.ml \ + tests/rte/rte_api/rte_get_annot.ml \ + tests/rte/compute_annot/compute_annot.ml \ + tests/rte/my_annot_proxy/my_annot_proxy.ml $(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME))) ################# @@ -1002,6 +1008,7 @@ $(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME))) PLUGIN_ENABLE:=$(ENABLE_CONSTANT_PROPAGATION) PLUGIN_NAME:=Constant_Propagation PLUGIN_DIR:=src/plugins/constant_propagation +PLUGIN_TESTS_LIB:=tests/constant_propagation/introduction_of_non_explicit_cast.ml PLUGIN_CMO:= propagationParameters \ api PLUGIN_DISTRIBUTED:=yes @@ -1065,6 +1072,8 @@ $(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME))) PLUGIN_ENABLE:=$(ENABLE_PDG) PLUGIN_NAME:=Pdg PLUGIN_DIR:=src/plugins/pdg +PLUGIN_TESTS_LIB:=tests/pdg/dyn_dpds.ml \ + tests/pdg/sets.ml PLUGIN_CMO:= pdg_parameters \ ctrlDpds \ pdg_state \ @@ -1093,6 +1102,8 @@ $(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME))) PLUGIN_ENABLE:=$(ENABLE_SCOPE) PLUGIN_NAME:=Scope PLUGIN_DIR:=src/plugins/scope +PLUGIN_TESTS_LIB:=tests/scope/bts971.ml \ + tests/scope/zones.ml PLUGIN_CMO:= datascope zones defs PLUGIN_GUI_CMO:=dpds_gui PLUGIN_DEPENDENCIES:=Eva Inout @@ -1401,17 +1412,18 @@ acsl_tests: byte $(PRINT_EXEC) acsl_tests find doc/speclang -name \*.c -exec ./bin/toplevel.byte$(EXE) {} \; > /dev/null -LONELY_TESTS_ML_FILES=$(wildcard $(TEST_DIRS_AS_PLUGIN:%=tests/%/*.ml)) -LONELY_TESTS_BYTE_FILES=$(LONELY_TESTS_ML_FILES:%.ml=%.cmo) -LONELY_TESTS_OPT_FILES=$(LONELY_TESTS_ML_FILES:%.ml=%.cmx) -LONELY_TESTS_DYN_FILES=$(LONELY_TESTS_ML_FILES:%.ml=%.cmxs) -$(LONELY_TESTS_BYTE_FILES): BFLAGS+=$(TEST_DIRS_AS_PLUGIN:%=-I tests/%) -$(LONELY_TESTS_OPT_FILES): OFLAGS+=$(TEST_DIRS_AS_PLUGIN:%=-I tests/%) -$(LONELY_TESTS_DYN_FILES): OFLAGS+=$(TEST_DIRS_AS_PLUGIN:%=-I tests/%) -.PRECIOUS: $(LONELY_TESTS_OPT_FILES) \ - $(LONELY_TESTS_DYN_FILES) \ - $(LONELY_TESTS_BYTE_FILES) \ - $(LONELY_TESTS_BYTE_FILES:%.cmo=%.cmi) +LONELY_TESTS_ML_FILES:=\ + $(shell find $(TEST_DIRS_AS_PLUGIN:%=tests/%) -name '*.ml') +$(foreach file,$(LONELY_TESTS_ML_FILES),\ + $(eval $(file:%.ml=%.cmo): BFLAGS+=-I $(dir $(file)))) +$(foreach file,$(LONELY_TESTS_ML_FILES),\ + $(eval $(file:%.ml=%.cmx): OFLAGS+=-I $(dir $(file)))) +$(foreach file,$(LONELY_TESTS_ML_FILES),\ + $(eval $(file:%.ml=%.cmxs): OFLAGS+=-I $(dir $(file)))) +.PRECIOUS: $(LONELY_TESTS_ML_FILES:%.ml=%.cmx) \ + $(LONELY_TESTS_DYN_FILES:%.ml=%.cmxs) \ + $(LONELY_TESTS_BYTE_FILES:%.ml=%.cmo) \ + $(LONELY_TESTS_BYTE_FILES:%.ml=%.cmi) bin/ocamldep_transitive_closure: devel_tools/ocamldep_transitive_closure.ml $(OCAMLOPT) -package ocamlgraph -package str -linkpkg -o $@ $< diff --git a/share/Makefile.plugin.template b/share/Makefile.plugin.template index 7d699300c57861a82917dfa14ecfb1e52be630f4..df7931022fe0916c4305b2b531a9c302032d2a14 100644 --- a/share/Makefile.plugin.template +++ b/share/Makefile.plugin.template @@ -399,6 +399,8 @@ endif # Some meta-variables for compilation flags NAME_BFLAGS :=@PLUGIN_NAME@_BFLAGS NAME_OFLAGS :=@PLUGIN_NAME@_OFLAGS +NAME_TEST_BFLAGS :=@PLUGIN_NAME@_TEST_BFLAGS +NAME_TEST_OFLAGS :=@PLUGIN_NAME@_TEST_OFLAGS TARGET_OFLAGS :=@PLUGIN_NAME@_TARGET_OFLAGS TARGET_BFLAGS :=@PLUGIN_NAME@_TARGET_BFLAGS ifeq ($(HAS_GUI),yes) @@ -434,12 +436,16 @@ endif PLUGIN_EXTRA_DIRS_INC:=$(patsubst %,-I $(PLUGIN_DIR)/% ,$(PLUGIN_EXTRA_DIRS)) # Set the compilation flags for the plugin -INCLUDE_FLAGS:=-I $(PLUGIN_DIR) -I $(INSTALLED_PLUGIN_DIR) \ - $(PLUGIN_EXTRA_DIRS_INC) \ - $(addprefix -package ,$(PLUGIN_PACKAGES) $(LIBRARY_NAMES)) - +INCLUDE_EXT_FLAGS:=-I $(INSTALLED_PLUGIN_DIR) \ + $(addprefix -package ,$(PLUGIN_PACKAGES) $(LIBRARY_NAMES)) +INCLUDE_FLAGS:=-I $(PLUGIN_DIR) $(PLUGIN_EXTRA_DIRS_INC) $(INCLUDE_EXT_FLAGS) $(NAME_BFLAGS):=$(BFLAGS) $(INCLUDE_FLAGS) $(PLUGIN_BFLAGS) $(NAME_OFLAGS):=$(OFLAGS) $(INCLUDE_FLAGS) $(PLUGIN_OFLAGS) +# DO NOT include the plugin's own directory as search path for compiling +# ml test scripts: they will be loaded in a separate phase, and will only see +# the plugin through its static API +$(NAME_TEST_BFLAGS):= $(BFLAGS) $(INCLUDE_EXT_FLAGS) $(PLUGIN_BFLAGS) +$(NAME_TEST_OFLAGS):= $(OFLAGS) $(INCLUDE_EXT_FLAGS) $(PLUGIN_OFLAGS) $(TARGET_BFLAGS):= $(PLUGIN_LINK_BFLAGS) $(TARGET_OFLAGS):= $(PLUGIN_LINK_OFLAGS) @@ -863,9 +869,9 @@ endif @PLUGIN_NAME@_TESTS_LIB_OPT_DYN:=$(PLUGIN_TESTS_LIB:%.ml=%.cmxs) @PLUGIN_NAME@_TESTS_LIB_BYTE:=$(PLUGIN_TESTS_LIB:%.ml=%.cmo) -$(@PLUGIN_NAME@_TESTS_LIB_OPT): OFLAGS:=$($(NAME_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) -$(@PLUGIN_NAME@_TESTS_LIB_OPT_DYN): OFLAGS:=$($(NAME_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) -$(@PLUGIN_NAME@_TESTS_LIB_BYTE): BFLAGS:=$($(NAME_BFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) +$(@PLUGIN_NAME@_TESTS_LIB_OPT): OFLAGS:=$($(NAME_TEST_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) +$(@PLUGIN_NAME@_TESTS_LIB_OPT_DYN): OFLAGS:=$($(NAME_TEST_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) +$(@PLUGIN_NAME@_TESTS_LIB_BYTE): BFLAGS:=$($(NAME_TEST_BFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) # [JS 2009/03/18] both .PRECIOUS are required in order to prevent 'make' # deletion of intermediate generated files. Such a deletion forces 'make' to diff --git a/share/analysis-scripts/frama-c.mk b/share/analysis-scripts/frama-c.mk index 6f0ec68c482eabf8234d60eefabfeecb41fae351..3da9f1cf65582a904f5e2903fb7f0cf3adffa336 100644 --- a/share/analysis-scripts/frama-c.mk +++ b/share/analysis-scripts/frama-c.mk @@ -186,16 +186,17 @@ SHELL := /bin/bash $(EVA) \ -load $(PARSE_RESULT)/framac.sav -save $@/framac.sav \ -eva-flamegraph $@/flamegraph.txt \ - -report-csv $@/alarms.csv -report-no-proven \ -kernel-log w:$@/warnings.log \ -from-log w:$@/warnings.log \ -inout-log w:$@/warnings.log \ - -report-log w:$@/warnings.log \ -scope-log w:$@/warnings.log \ -eva-log w:$@/warnings.log \ - -metrics-log a:$@/metrics.log \ + -then \ + -report-csv $@/alarms.csv -report-no-proven \ + -report-log w:$@/warnings.log \ -metrics-eva-cover \ - -then -nonterm -nonterm-log a:$@/nonterm.log \ + -metrics-log a:$@/metrics.log \ + -nonterm -nonterm-log a:$@/nonterm.log \ || ($(RM) $@/stats.txt && false) # Prevents having error code reporting in stats.txt } 2>&1 | $(SED_UNBUFFERED) '/\[eva\] Values at end of function/,999999d' | diff --git a/src/libraries/stdlib/integer.ml b/src/libraries/stdlib/integer.ml index 55d36122770094da3949f3540941b9fdc0bdccbd..1a7e593f79aede19b4ecddaf53d51964fa7020ce 100644 --- a/src/libraries/stdlib/integer.ml +++ b/src/libraries/stdlib/integer.ml @@ -109,17 +109,85 @@ let popcount = Z.popcount raises multiple [Failure _] exceptions *) failwith "Integer.of_string" - let max_int64 = of_int64 Int64.max_int let min_int64 = of_int64 Int64.min_int - let to_string = Z.to_string let to_float = Z.to_float let of_float z = try Z.of_float z with Z.Overflow -> raise Too_big + let bdigits = [| + "0000" ; (* 0 *) + "0001" ; (* 1 *) + "0010" ; (* 2 *) + "0011" ; (* 3 *) + "0100" ; (* 4 *) + "0101" ; (* 5 *) + "0110" ; (* 6 *) + "0111" ; (* 7 *) + "1000" ; (* 8 *) + "1001" ; (* 9 *) + "1010" ; (* 10 *) + "1011" ; (* 11 *) + "1100" ; (* 12 *) + "1101" ; (* 13 *) + "1110" ; (* 14 *) + "1111" ; (* 15 *) + |] + + let pp_bin_pos fmt r = Format.pp_print_string fmt bdigits.(r) + let pp_bin_neg fmt r = Format.pp_print_string fmt bdigits.(15-r) + + let pp_hex_pos fmt r = Format.fprintf fmt "%04X" r + let pp_hex_neg fmt r = Format.fprintf fmt "%04X" (0xFFFF-r) + + let bmask_bin = Z.of_int 0xF (* 4 bits mask *) + let bmask_hex = Z.of_int 0xFFFF (* 64 bits mask *) + + type digits = { + nbits : int ; (* max number of bits *) + bsize : int ; (* bits in each bloc *) + bmask : Z.t ; (* block mask, must be (1 << bsize) - 1 *) + sep : string ; + pp : Format.formatter -> int -> unit ; (* print one block *) + } + + let rec pp_digits d fmt n v = + if gt v zero || n < d.nbits then + begin + let r = Z.to_int (Z.logand v d.bmask) in + let k = d.bsize in + pp_digits d fmt (n + k) (Z.shift_right_trunc v k) ; + if gt v d.bmask || (n + k) < d.nbits + then Format.pp_print_string fmt d.sep ; + d.pp fmt r ; + end + + let pp_bin ?(nbits=1) ?(sep="") fmt v = + let nbits = if nbits <= 0 then 1 else nbits in + if le zero v then + ( Format.pp_print_string fmt "0b" ; + pp_digits { nbits ; sep ; bsize=4 ; + bmask = bmask_bin ; pp = pp_bin_pos } fmt 0 v ) + else + ( Format.pp_print_string fmt "1b" ; + pp_digits { nbits ; sep ; bsize=4 ; + bmask = bmask_bin ; pp = pp_bin_neg } fmt 0 (Z.lognot v) ) + + let pp_hex ?(nbits=1) ?(sep="") fmt v = + let nbits = if nbits <= 0 then 1 else nbits in + if le zero v then + ( Format.pp_print_string fmt "0x" ; + pp_digits { nbits ; sep ; bsize=16 ; + bmask = bmask_hex ; pp = pp_hex_pos } fmt 0 v ) + + else + ( Format.pp_print_string fmt "1x" ; + pp_digits { nbits ; sep ; bsize=16 ; + bmask = bmask_hex ; pp = pp_hex_neg } fmt 0 (Z.lognot v) ) + let pretty ?(hexa=false) fmt v = let rec aux v = if gt v two_power_60 then diff --git a/src/libraries/stdlib/integer.mli b/src/libraries/stdlib/integer.mli index 4e939382bf131017b673f534505420f04c0df94c..3ed0f1297471b8c393056437955eec4085c79363 100644 --- a/src/libraries/stdlib/integer.mli +++ b/src/libraries/stdlib/integer.mli @@ -150,8 +150,23 @@ val popcount: t -> int val pretty : ?hexa:bool -> t Pretty_utils.formatter - +val pp_bin : ?nbits:int -> ?sep:string -> t Pretty_utils.formatter +(** Print binary format. Digits are output by blocs of 4 bits + separated by [~sep] with at least [~nbits] total bits. If [nbits] is + non positive, it will be ignored. + + Positive values are prefixed with ["0b"] and negative values + are printed as their 2-complement ([lnot]) with prefix ["1b"]. *) + +val pp_hex : ?nbits:int -> ?sep:string -> t Pretty_utils.formatter +(** Print hexadecimal format. Digits are output by blocs of 16 bits + (4 hex digits) separated by [~sep] with at least [~nbits] total bits. + If [nbits] is non positive, it will be ignored. + + Positive values are preffixed with ["0x"] and negative values + are printed as their 2-complement ([lnot]) with prefix ["1x"]. *) (* + Local Variables: compile-command: "make -C ../../.." End: diff --git a/src/plugins/aorai/Makefile.in b/src/plugins/aorai/Makefile.in index 5478d009fa7e206bca7df4310e9062b357370d6a..423244b822a3af9883971dd6deabac001cfed778 100644 --- a/src/plugins/aorai/Makefile.in +++ b/src/plugins/aorai/Makefile.in @@ -80,7 +80,7 @@ PLUGIN_NO_DEFAULT_TEST:=yes endif PLUGIN_TESTS_DIRS:=aorai -PLUGIN_TESTS_LIB:=$(PLUGIN_DIR)/tests/aorai/Aorai_test.ml +PLUGIN_TESTS_LIB:=$(PLUGIN_DIR)/tests/aorai/Aorai_test.ml $(PLUGIN_DIR)/tests/aorai/name_projects.ml include $(FRAMAC_SHARE)/Makefile.dynamic @@ -101,7 +101,7 @@ $(Aorai_DIR)/tests/test_config_prove: \ $(SED) -e 's!@AORAI_WP_SHARE@!$(AORAI_WP_SHARE)!' $< > $@ $(CHMOD_RO) $@ -Aorai_DEFAULT_TESTS: $(Aorai_DIR)/tests/aorai/Aorai_test.cmxs $(Aorai_DIR)/tests/aorai/Aorai_test.cmo +Aorai_DEFAULT_TESTS: $(Aorai_DIR)/tests/aorai/Aorai_test.cmxs $(Aorai_DIR)/tests/aorai/Aorai_test.cmo $(Aorai_DIR)/tests/aorai/name_projects.cmxs $(Aorai_DIR)/tests/aorai/name_projects.cmo # Regenerating the Makefile on need diff --git a/src/plugins/aorai/tests/aorai/assigns.c b/src/plugins/aorai/tests/aorai/assigns.c index 7eb67e2087bbaa0ad8c729ab2efbf1bff2d8b1e9..c8d63fdb9dba75b9fb13a0021f32cf20f1435241 100644 --- a/src/plugins/aorai/tests/aorai/assigns.c +++ b/src/plugins/aorai/tests/aorai/assigns.c @@ -1,7 +1,8 @@ /* run.config* + EXECNOW: make -s @PTEST_DIR@/name_projects.cmxs OPT: -aorai-automata tests/aorai/assigns.ya -aorai-test 1 -load-module tests/aorai/Aorai_test.cmxs -aorai-test-number @PTEST_NUMBER@ @PROVE_OPTIONS@ OPT: -aorai-automata tests/aorai/assigns_det.ya -aorai-test 1 -load-module tests/aorai/Aorai_test.cmxs -aorai-test-number @PTEST_NUMBER@ @PROVE_OPTIONS@ - OPT: -aorai-automata tests/aorai/assigns.ya -load-script tests/aorai/name_projects.ml -aorai-test 1 -then -print + OPT: -aorai-automata tests/aorai/assigns.ya -load-module @PTEST_DIR@/name_projects -aorai-test 1 -then -print */ int X; diff --git a/src/plugins/qed/term.ml b/src/plugins/qed/term.ml index 045f0d2ff31bd97cf122a018ae543aa756bea6e3..99e54cad0af764e053ee1dafc7e361387e30b2e1 100644 --- a/src/plugins/qed/term.ml +++ b/src/plugins/qed/term.ml @@ -2540,7 +2540,8 @@ struct | (Bool|Prop) , (Bool|Prop) -> Prop | Int , Int -> Int | (Int|Real) , (Int|Real) -> Real - | _ -> raise Not_found + | _ -> + if Tau.equal a b then a else raise Not_found let rec merge_list t f = function | [] -> t diff --git a/src/plugins/wp/Cfloat.ml b/src/plugins/wp/Cfloat.ml index 6b98659afcd9cdbe5d55cd201c34ad8535ad708f..7c5a2c9f5a357dfe0080eb176d23012816b2740c 100644 --- a/src/plugins/wp/Cfloat.ml +++ b/src/plugins/wp/Cfloat.ml @@ -35,24 +35,29 @@ open Lang.F let library = "cfloat" -let result = Logic.Real -let params = [Logic.Sreal;Logic.Sreal] (* We can provide more parameters *) -let link f = Lang.infoprover (Qed.Engine.F_call f) +let f32 = datatype ~library "f32" +let f64 = datatype ~library "f64" -let make_fun_float name f = - extern_f ~library ~result ~params "%s_%a" name Ctypes.pp_float f +let t32 = Lang.(t_datatype f32 []) +let t64 = Lang.(t_datatype f64 []) -let make_pred_float name f = - extern_f ~library ~result:Logic.Prop ~params "%s_%a" name Ctypes.pp_float f +let ftau = function + | Float32 -> t32 + | Float64 -> t64 -let f_model = - extern_f ~library ~result ~params ~link:(link "model") "\\model" +let suffix fmt = function + | Float32 -> Format.pp_print_string fmt "f32" + | Float64 -> Format.pp_print_string fmt "f64" -let f_delta = - extern_f ~library ~result ~params ~link:(link "delta") "\\delta" +let link phi = Lang.infoprover (Qed.Engine.F_call phi) -let f_epsilon = - extern_f ~library ~result ~params ~link:(link "epsilon") "\\epsilon" +(* Qed exact representations, linked to f32/f64 *) +let fq32 = extern_f ~library ~result:t32 ~link:(link "to_f32") "q32" +let fq64 = extern_f ~library ~result:t64 ~link:(link "to_f64") "q64" + +let f_model ft = extern_f ~library ~result:(ftau ft) "model_%a" suffix ft +let f_delta ft = extern_f ~library ~result:(ftau ft) "delta_%a" suffix ft +let f_epsilon ft = extern_f ~library ~result:(ftau ft) "epsilon_%a" suffix ft (* -------------------------------------------------------------------------- *) (* --- Model Setting --- *) @@ -60,22 +65,83 @@ let f_epsilon = type model = Real | Float -let model = Context.create ~default:Real "Cfloat.model" +let model = Context.create ~default:Float "Cfloat.model" + +let tau_of_float f = + match Context.get model with + | Real -> Logic.Real + | Float -> ftau f + +(* -------------------------------------------------------------------------- *) +(* --- Operators --- *) +(* -------------------------------------------------------------------------- *) + +type op = + | LT + | EQ + | LE + | NE + | NEG + | ADD + | MUL + | DIV + | REAL + | ROUND + | EXACT + +[@@@ warning "-32"] +let op_name = function + | LT -> "flt" + | EQ -> "feq" + | LE -> "fle" + | NE -> "fne" + | NEG -> "fneg" + | ADD -> "fadd" + | MUL -> "fmul" + | DIV -> "fdiv" + | REAL -> "freal" + | ROUND -> "fround" + | EXACT -> "fexact" +[@@@ warning "+32"] (* -------------------------------------------------------------------------- *) -(* --- Literals --- *) +(* --- Registry --- *) (* -------------------------------------------------------------------------- *) -let code_lit = F.e_float +module REGISTRY = Model.Static + (struct + type key = lfun + type data = op * c_float + let name = "Wp.Cfloat.REGISTRY" + include Lang.Fun + end) + +let find = REGISTRY.find + +let () = Context.register + begin fun () -> + REGISTRY.define fq32 (EXACT,Float32) ; + REGISTRY.define fq64 (EXACT,Float64) ; + end + +(* -------------------------------------------------------------------------- *) +(* --- Literals --- *) +(* -------------------------------------------------------------------------- *) + +let rfloat = Floating_point.round_to_single_precision_float + +let fmake ulp value = match ulp with + | Float32 -> F.e_fun fq32 [F.e_float (rfloat value)] + | Float64 -> F.e_fun fq64 [F.e_float value] + +let qmake ulp q = fmake ulp (Transitioning.Q.to_float q) let mantissa = "\\([-+]?[0-9]*\\)" let comma = "\\(.\\(\\(0*[1-9]\\)*\\)0*\\)?" let exponent = "\\([eE]\\([-+]?[0-9]*\\)\\)?" let real = Str.regexp (mantissa ^ comma ^ exponent ^ "$") -let parse_literal l = - let open Cil_types in - let r = l.r_literal in +let parse_literal v r = try if Str.string_match real r 0 then let ma = Str.matched_group 1 r in @@ -88,120 +154,108 @@ let parse_literal l = let m = Q.of_string (ma ^ mb) in if n < 0 then Q.div m (d (-n)) else if n > 0 then Q.mul m (d n) else m - else Q.of_float l.r_nearest + else Q.of_float v with Failure _ -> - Warning.error ~source:"acsl" "Unexpected real literal %S" r + Warning.error "Unexpected constant literal %S" r -let acsl_lit l = F.e_real (parse_literal l) +let acsl_lit l = + let open Cil_types in + F.e_real (parse_literal l.r_nearest l.r_literal) + +let code_lit ulp value original = + match Context.get model , ulp , original with + | Float , Float32 , _ -> F.e_fun fq32 [F.e_float value] + | Float , Float64 , _ -> F.e_fun fq64 [F.e_float value] + | Real , _ , None -> F.e_float value + | Real , _ , Some r -> F.e_real (parse_literal value r) (* -------------------------------------------------------------------------- *) -(* --- Operators --- *) +(* --- Computations --- *) (* -------------------------------------------------------------------------- *) -let flt_rnd = Ctypes.f_memo (make_fun_float "to") -let flt_add = Ctypes.f_memo (make_fun_float "add") -let flt_mul = Ctypes.f_memo (make_fun_float "mul") -let flt_div = Ctypes.f_memo (make_fun_float "div") +let rec exact e = + match F.repr e with + | Qed.Logic.Kreal r -> r + | Qed.Logic.Kint z -> Q.of_bigint z + | Qed.Logic.Fun( f , [ q ] ) when f == fq32 || f == fq64 -> exact q + | _ -> raise Not_found -let () = - begin - let open LogicBuiltins in - add_builtin "\\model" [F Float32] f_model ; - add_builtin "\\model" [F Float64] f_model ; - add_builtin "\\delta" [F Float32] f_delta ; - add_builtin "\\delta" [F Float64] f_delta ; - add_builtin "\\epsilon" [F Float32] f_epsilon ; - add_builtin "\\epsilon" [F Float64] f_epsilon ; - end +let compute op ulp xs = + match op , xs with + | NEG , [ x ] -> qmake ulp (Q.neg (exact x)) + | ADD , [ x ; y ] -> qmake ulp (Q.add (exact x) (exact y)) + | MUL , [ x ; y ] -> qmake ulp (Q.mul (exact x) (exact y)) + | DIV , [ x ; y ] -> qmake ulp (Q.div (exact x) (exact y)) + | ROUND , [ x ] -> qmake ulp (exact x) + | REAL , [ x ] -> F.e_real (exact x) + | LE , [ x ; y ] -> F.e_bool (Q.leq (exact x) (exact y)) + | LT , [ x ; y ] -> F.e_bool (Q.lt (exact x) (exact y)) + | EQ , [ x ; y ] -> F.e_bool (Q.equal (exact x) (exact y)) + | NE , [ x ; y ] -> F.e_bool (not (Q.equal (exact x) (exact y))) + | _ -> raise Not_found (* -------------------------------------------------------------------------- *) -(* --- Floating Point Predicate --- *) +(* --- Operations --- *) (* -------------------------------------------------------------------------- *) -let fle _ = F.p_leq -let flt _ = F.p_lt -let feq _ = F.p_equal -let fneq _ = F.p_neq +let make_fun_float ?result name op ft = + let result = match result with None -> ftau ft | Some r -> r in + let phi = extern_f ~library ~result "%s_%a" name suffix ft in + Lang.F.set_builtin phi (compute op ft) ; + REGISTRY.define phi (op,ft) ; phi + +let make_pred_float name op ft = + let prop = Pretty_utils.sfprintf "%s_%a" name suffix ft in + let bool = Pretty_utils.sfprintf "%s_%ab" name suffix ft in + let phi = extern_p ~library ~bool ~prop () in + Lang.F.set_builtin phi (compute op ft) ; + REGISTRY.define phi (op,ft) ; phi + +let register = Ctypes.f_memo + +let real_of_flt = register (make_fun_float ~result:Logic.Real "of" REAL) +let flt_of_real = register (make_fun_float "to" ROUND) +let flt_add = register (make_fun_float "add" ADD) +let flt_mul = register (make_fun_float "mul" MUL) +let flt_div = register (make_fun_float "div" DIV) +let flt_neg = register (make_fun_float "neg" NEG) + +let flt_lt = register (make_pred_float "lt" LT) +let flt_eq = register (make_pred_float "eq" EQ) +let flt_le = register (make_pred_float "le" LE) +let flt_neq = register (make_pred_float "ne" NE) (* -------------------------------------------------------------------------- *) -(* --- Precision --- *) +(* --- Models --- *) (* -------------------------------------------------------------------------- *) -module OP = Model.Static - (struct - type key = Lang.lfun - type data = (term list -> term) - let name = "Wp.Cfloat.OP" - let compare = Lang.Fun.compare - let pretty = Lang.Fun.pretty - end) - -let define_fmodel_of fop op = +let () = begin - OP.define (fop Float32) op ; - OP.define (fop Float64) op ; + let open LogicBuiltins in + let register ft = + add_builtin "\\model" [F ft] (f_model ft) ; + add_builtin "\\delta" [F ft] (f_delta ft) ; + add_builtin "\\epsilon" [F ft] (f_epsilon ft) ; + in + register Float32 ; + register Float64 ; end -let builtin_model = function - | [e] -> - let open Qed.Logic in - begin match F.repr e with - | Fun(f,_) when f == f_model -> e - | Fun(f,_) when f == f_delta -> e_zero_real - | Fun(f,_) when f == f_epsilon -> e_zero_real - | Fun(op,xs) -> - let phi = OP.find op in - (* find phi before computing arguments *) - phi (List.map (fun e -> e_fun f_model [e]) xs) - | Kreal _ -> e - | _ -> raise Not_found - end - | _ -> raise Not_found - -let builtin_round ulp = function - | [e] -> - let open Qed.Logic in - begin match F.repr e with - | Div(x,y) -> e_fun (flt_div ulp) [x;y] - | Add ([_;_] as xs) -> e_fun (flt_add ulp) xs - | Mul ([_;_] as xs) -> e_fun (flt_mul ulp) xs - | Kreal r when Q.equal r Q.zero -> e - | Kreal r when Q.equal r Q.one -> e - | Kreal r -> - let flt = Transitioning.Q.to_float r in - let rnd = - match ulp with - | Float32 -> Floating_point.round_to_single_precision_float flt - | Float64 -> flt - in F.e_float rnd - | _ -> raise Not_found - end - | _ -> raise Not_found - -let builtin_error = function - | [e] -> - let open Qed.Logic in - begin match F.repr e with - | Fun(f,_) when f == f_model -> e_zero_real - | _ -> raise Not_found - end - | _ -> raise Not_found - (* -------------------------------------------------------------------------- *) (* --- Conversion Symbols --- *) (* -------------------------------------------------------------------------- *) +let real_of_float f a = + match Context.get model with + | Real -> a + | Float -> e_fun (real_of_flt f) [a] + let float_of_real f a = match Context.get model with | Real -> a - | Float -> e_fun (flt_rnd f) [a] + | Float -> e_fun (flt_of_real f) [a] let float_of_int f a = float_of_real f (Cmath.real_of_int a) -let real_of_float _f a = a - -let range = - let is_float = Ctypes.f_memo (make_pred_float "is") in - fun f a -> p_call (is_float f) [a] (* -------------------------------------------------------------------------- *) (* --- Float Arithmetics --- *) @@ -212,32 +266,35 @@ let fbinop rop fop f x y = | Real -> rop x y | Float -> e_fun (fop f) [x;y] +let fcmp rop fop f x y = + match Context.get model with + | Real -> rop x y + | Float -> p_call (fop f) [x;y] + let fadd = fbinop e_add flt_add let fmul = fbinop e_mul flt_mul let fdiv = fbinop e_div flt_div -let fopp _ = e_opp (* sign change is exact in floats *) -let fsub f x y = fadd f x (e_opp y) +let fopp f x = + match Context.get model with + | Real -> e_opp x + | Float -> e_fun (flt_neg f) [x] + +let fsub f x y = fadd f x (fopp f y) + +let flt = fcmp p_lt flt_lt +let fle = fcmp p_leq flt_le +let feq = fcmp p_equal flt_eq +let fneq = fcmp p_neq flt_neq (* -------------------------------------------------------------------------- *) (* --- Registry --- *) (* -------------------------------------------------------------------------- *) -let () = Context.register - begin fun () -> - - F.set_builtin f_model builtin_model ; - F.set_builtin f_delta builtin_error ; - F.set_builtin f_epsilon builtin_error ; - F.set_builtin (flt_rnd Float32) (builtin_round Float32) ; - F.set_builtin (flt_rnd Float64) (builtin_round Float64) ; - - define_fmodel_of flt_rnd (function [x] -> x | _ -> raise Not_found) ; - define_fmodel_of flt_add e_sum ; (* only 2 params in flt_add *) - define_fmodel_of flt_mul e_prod ; (* only 2 params in flt_mul *) - define_fmodel_of flt_div (function [x;y] -> e_div x y | _ -> raise Not_found) ; - end - -let configure m = Context.set model m +let configure m = + begin + Context.set model m ; + Context.set Lang.floats tau_of_float ; + end (* -------------------------------------------------------------------------- *) diff --git a/src/plugins/wp/Cfloat.mli b/src/plugins/wp/Cfloat.mli index 8f1e71f24bc8e379719b6e6c96bb6b15c4ad66e7..f1f46e5950f89fe509e97f6015f2dbf0c5906338 100644 --- a/src/plugins/wp/Cfloat.mli +++ b/src/plugins/wp/Cfloat.mli @@ -28,16 +28,39 @@ open Ctypes open Lang open Lang.F +val f32 : adt +val f64 : adt + +val t32 : tau +val t64 : tau + type model = Real | Float val configure : model -> unit -val code_lit : float -> term +val ftau : c_float -> tau (** model independant *) +val tau_of_float : c_float -> tau (** with respect to model *) + +type op = + | LT + | EQ + | LE + | NE + | NEG + | ADD + | MUL + | DIV + | REAL + | ROUND + | EXACT (** same as round, but argument is exact representation *) + +val find : lfun -> op * c_float + +val code_lit : c_float -> float -> string option -> term val acsl_lit : Cil_types.logic_real -> term val float_of_int : c_float -> unop val float_of_real : c_float -> unop val real_of_float : c_float -> unop -val range : c_float -> term -> pred val fopp : c_float -> unop val fadd : c_float -> binop @@ -50,11 +73,14 @@ val fle : c_float -> cmp val feq : c_float -> cmp val fneq : c_float -> cmp -val f_model : lfun -val f_delta : lfun -val f_epsilon : lfun +val f_model : c_float -> lfun +val f_delta : c_float -> lfun +val f_epsilon : c_float -> lfun + +val flt_of_real : c_float -> lfun +val real_of_flt : c_float -> lfun -val flt_rnd : c_float -> lfun val flt_add : c_float -> lfun val flt_mul : c_float -> lfun val flt_div : c_float -> lfun +val flt_neg : c_float -> lfun diff --git a/src/plugins/wp/Changelog b/src/plugins/wp/Changelog index 405600b3263fe6ba89283519d2f9b81372e9c413..844b5b50097f8f55d30a604eb2ec14cd13cf1498 100644 --- a/src/plugins/wp/Changelog +++ b/src/plugins/wp/Changelog @@ -20,6 +20,8 @@ # <Prover>: prover ############################################################################### +- Wp [2019/01/28] New floating-point model + ###################### Plugin WP 18.0 (Argon) ###################### diff --git a/src/plugins/wp/CodeSemantics.ml b/src/plugins/wp/CodeSemantics.ml index e7dacab67bf5ee7a8fb910ca905891cea21f3ce2..d1c55685ea4d7add16b3f3e43080df932afe60c3 100644 --- a/src/plugins/wp/CodeSemantics.ml +++ b/src/plugins/wp/CodeSemantics.ml @@ -32,6 +32,26 @@ open Sigs open Lang open Lang.F +module WpLog = Wp_parameters +let constfold_ctyp = function + | TArray (_,Some {enode = (Const CInt64 _) },_,_) as ct -> ct + | TArray (ty,Some len,cache,attr) as ct -> begin + match Cil.constFold true len with + | {enode = (Const CInt64 _) } as len -> + TArray(ty,Some len,cache,attr) + | _ -> ct + end + | ct -> ct + +let constfold_coffset = function + | Index({enode=Const (CInt64 _)}, _) as off -> off + | Index(idx, next) as off -> begin + match Cil.constFold true idx with + | {enode = (Const CInt64 _) } as idx -> Index(idx, next) + | _ -> off + end + | off -> off + module Make(M : Sigs.Model) = struct @@ -448,22 +468,18 @@ struct init_value ~sigma lv (Cil.typeOfLval lv) (Some exp) :: acc | CompoundInit ( ct , initl ) -> - - let len = List.length initl in - let acc = + let ct = constfold_ctyp ct in + let acc = (* updated acc with default init of structure *) match ct with - | TArray (ty,Some {enode = (Const CInt64 (size,_,_))},_,_) - when Integer.lt (Integer.of_int len) size -> - init_range ~sigma lv ty (Integer.of_int len) size None :: acc - - | TComp (cp,_,_) when len < (List.length cp.cfields) -> - + | TComp (cp,_,_) when cp.cstruct && (* not for union... *) + (List.length initl) < (List.length cp.cfields) -> + (* default init for unintialized field of a struct *) List.fold_left (fun acc f -> if List.exists (function | Field(g,_),_ -> Fieldinfo.equal f g - | _ -> false) + | _ -> WpLog.fatal "Kernel invariant broken into an initializer") initl then acc else @@ -477,47 +493,80 @@ struct | _ -> acc in match ct with - | TArray (ty,_,_,_) - when Wp_parameters.InitWithForall.get () -> - (* delayed: the last consecutive index have the same value - and are not yet initialized. - (i0,pred,il) =def \forall x. x \in [il;i0] t[x] == pred - *) + | TArray (ty,len,_,_) -> + let delayed = + match len with (* number of required elements *) + | Some {enode = (Const CInt64 (size,_,_))} -> + (size, None) + | _ -> (* CIL invariant broken. *) + WpLog.fatal "CIL invariant broken: unknown initialized array size" + in let make_quant acc = function - | None -> acc - | Some (Index({enode=Const (CInt64 (i0,_,_))}, NoOffset),exp,il) - when Integer.lt il i0 -> + (* adds delayed initializations from info about + the last consecutive indices having + the same value, but that have not yet initialized. *) + | (_,None) -> acc (* nothing was delayed *) + | (il,Some (i0,_,exp)) when Integer.lt il i0 -> + (* Added pred: \forall i \in [il .. i0] ; t[i]==exp *) let i2 = Integer.succ i0 in init_range ~sigma lv ty il i2 (Some exp) :: acc - | Some (off,exp,_) -> + | (_il,Some (_i0,off,exp)) -> + (* case [_il=_i0], so uses [off] corresponding to [_i0] + Added pred: t[i]==exp*) let lv = Cil.addOffsetLval off lv in init_value ~sigma lv ty (Some exp) :: acc in + let add_missing_indices acc i0 = function + (* adds eventual default value for missing indices. *) + | (i1, _) -> + if Integer.ge i0 i1 then (* no hole *) acc + else (* defaults values + Added pred: \forall i \in [i0 .. i1[ ; t[i]==default *) + init_range ~sigma lv ty i0 i1 None :: acc + in let acc, delayed = List.fold_left (fun (acc,delayed) (off,init) -> - match delayed, off, init with - | None, Index({enode=Const (CInt64 (i0,_,_))}, NoOffset), - SingleInit curr -> - (acc,Some(off,curr,i0)) - | Some (i0,prev,ip), Index({enode=Const (CInt64 (i,_,_))}, NoOffset), - SingleInit curr - when ExpStructEq.equal prev curr - && Integer.equal (Integer.pred ip) i -> - (acc,Some(i0,prev,i)) - | _, _,_ -> + let off = constfold_coffset off in + let idx,acc = match off with + | Index({enode=Const CInt64 (idx,_,_)}, _) -> + (match delayed with + | (iprev, _) when Integer.lt iprev idx -> + (* CIL invariant broken. + without that invariant, an algo with a 2sd pass + is required for introducing default values *) + WpLog.fatal "CIL invariant broken: unordered initializer"; + | _ -> ()) ; + idx, + (* adds default values for missing indices *) + add_missing_indices acc (Integer.succ idx) delayed + | _ -> (* CIL invariant broken. *) + WpLog.fatal "CIL invariant broken: unknown initialized index" + in + match off, init with (* only simple init can be delayed *) + | Index(_, NoOffset), SingleInit init -> begin + match delayed with + | (i_prev,(Some (_,_,init_delayed) as delayed_info)) + when Wp_parameters.InitWithForall.get () + && Integer.equal (Integer.pred i_prev) idx + && ExpStructEq.equal init_delayed init -> + acc, (idx,delayed_info) + | _ -> (* flush the delayed init, and store the new one *) + let acc = make_quant acc delayed in + acc, (idx, Some (idx,off,init)) + end + | Index(_, _),_ -> + (* flush the delayed init, and adds the current one *) let acc = make_quant acc delayed in - begin match off, init with - | Index({enode=Const (CInt64 (i0,_,_))}, NoOffset), - SingleInit curr -> - acc, Some (off,curr,i0) - | _ -> - let lv = Cil.addOffsetLval off lv in - init_variable ~sigma lv init acc, None - end) - (acc,None) - (List.rev initl) in - (make_quant acc delayed) + let lv = Cil.addOffsetLval off lv in + (init_variable ~sigma lv init acc), (idx, None) + | _ -> WpLog.fatal "CIL invariant broken: not an index" + ) + (acc,delayed) + (List.rev initl) + in + let acc = make_quant acc delayed in + add_missing_indices acc Integer.zero delayed | _ -> List.fold_left (fun acc (off,init) -> diff --git a/src/plugins/wp/Cvalues.ml b/src/plugins/wp/Cvalues.ml index 29210e6627c5ab23d665257f77f7c58056f0e190..f952969897624f89bcd5642823903d87a23adfb4 100644 --- a/src/plugins/wp/Cvalues.ml +++ b/src/plugins/wp/Cvalues.ml @@ -47,7 +47,7 @@ let equation = function let rec constant = function | CInt64(z,_,_) -> e_bigint z | CChr c -> e_int64 (Ctypes.char c) - | CReal(f,_,_) -> Cfloat.code_lit f + | CReal(f,fk,s) -> Cfloat.code_lit (Ctypes.c_float fk) f s | CEnum e -> constant_exp e.eival | CStr _ | CWStr _ -> Warning.error "String constants not yet implemented" @@ -193,7 +193,7 @@ module TYPE = STRUCTURAL let prefix = "Is" let natural = false let is_int = Cint.range - let is_float = Cfloat.range + let is_float _ _ = p_true let is_pointer _ = p_true end) diff --git a/src/plugins/wp/Lang.ml b/src/plugins/wp/Lang.ml index a77db4ea05c7cebfaad0d2540334d515b0c32435..fdcb24f90acfb8076919647c8c0e87985d746fff 100644 --- a/src/plugins/wp/Lang.ml +++ b/src/plugins/wp/Lang.ml @@ -142,6 +142,7 @@ and field = and tau = (field,adt) Logic.datatype let pointer = Context.create "Lang.pointer" +let floats = Context.create "Lang.floats" let new_extern_id = ref (-1) let new_extern ~debug ~library ~link = @@ -182,7 +183,7 @@ let t_datatype adt ts = Logic.Data(adt,ts) let rec tau_of_object = function | C_int _ -> Logic.Int - | C_float _ -> Logic.Real + | C_float f -> Context.get floats f | C_pointer t -> Context.get pointer t | C_comp c -> tau_of_comp c | C_array { arr_element = typ } -> t_array (tau_of_ctype typ) diff --git a/src/plugins/wp/Lang.mli b/src/plugins/wp/Lang.mli index d51bee26404ab071663fd95f9ad250c2c51180bb..4644a22391f0473387a54a6fad9ed2871a6d5e0a 100644 --- a/src/plugins/wp/Lang.mli +++ b/src/plugins/wp/Lang.mli @@ -167,6 +167,7 @@ val t_farray : tau -> tau -> tau val t_datatype : adt -> tau list -> tau val pointer : (typ -> tau) Context.value (** type of pointers *) +val floats : (c_float -> tau) Context.value (** type of floats *) val poly : string list Context.value (** polymorphism *) val parameters : (lfun -> sort list) -> unit (** definitions *) diff --git a/src/plugins/wp/LogicSemantics.ml b/src/plugins/wp/LogicSemantics.ml index 05b03df9c0481ed48c5dd7a3bf9ca1cd58cb9060..60c0efae3922f9f7c5b7ae12876965847cd93b65 100644 --- a/src/plugins/wp/LogicSemantics.ml +++ b/src/plugins/wp/LogicSemantics.ml @@ -510,8 +510,10 @@ struct L.map (Cint.convert i) (C.logic env t) | C_int i , L_pointer _ -> L.map_l2t (M.int_of_loc i) (C.logic env t) - | C_int i , (L_cfloat _ | L_real) -> + | C_int i , L_real -> L.map (Cint.of_real i) (C.logic env t) + | C_int i , L_cfloat f -> + L.map (fun v -> Cint.of_real i (Cfloat.real_of_float f v)) (C.logic env t) | C_int _, L_array _ -> Warning.error "@[Logic cast to sized integer (%a) from (%a) not implemented yet@]" Printer.pp_typ dst_ctype Printer.pp_logic_type t.term_type diff --git a/src/plugins/wp/MemEmpty.ml b/src/plugins/wp/MemEmpty.ml index a9999cc1990b2e2b24909ac5926e788623bbc9e2..cf7d3dc174069393407c5a60dcbca667178d9fb0 100644 --- a/src/plugins/wp/MemEmpty.ml +++ b/src/plugins/wp/MemEmpty.ml @@ -35,6 +35,8 @@ let configure () = Context.set Lang.pointer (fun _typ -> Logic.Int) ; Context.set Cvalues.null (p_equal e_zero) ; end +let no_binder = { bind = fun _ f v -> f v } +let configure_ia _ = no_binder let hypotheses () = [] diff --git a/src/plugins/wp/MemTyped.ml b/src/plugins/wp/MemTyped.ml index 4fbf8ef305ef565611689406e43c078cd379856a..a21158ffef6f1044e7ad7adf16eb9c0808fe4683 100644 --- a/src/plugins/wp/MemTyped.ml +++ b/src/plugins/wp/MemTyped.ml @@ -391,6 +391,8 @@ let configure () = Context.set Lang.pointer (fun _ -> t_addr) ; Context.set Cvalues.null (p_equal a_null) ; end +let no_binder = { bind = fun _ f v -> f v } +let configure_ia _ = no_binder type pointer = NoCast | Fits | Unsafe let pointer = Context.create "MemTyped.pointer" @@ -402,7 +404,8 @@ let pointer = Context.create "MemTyped.pointer" type chunk = | M_int | M_char - | M_float + | M_f32 + | M_f64 | M_pointer | T_alloc @@ -413,33 +416,36 @@ struct let rank = function | M_int -> 0 | M_char -> 1 - | M_float -> 2 - | M_pointer -> 3 - | T_alloc -> 4 + | M_f32 -> 2 + | M_f64 -> 3 + | M_pointer -> 4 + | T_alloc -> 5 let hash = rank let name = function | M_int -> "Mint" | M_char -> "Mchar" - | M_float -> "Mflt" + | M_f32 -> "Mf32" + | M_f64 -> "Mf64" | M_pointer -> "Mptr" | T_alloc -> "Malloc" let compare a b = rank a - rank b let equal = (=) let pretty fmt c = Format.pp_print_string fmt (name c) let key_of_chunk = function - | M_int | M_char | M_float | M_pointer -> t_addr + | M_int | M_char | M_f32 | M_f64 | M_pointer -> t_addr | T_alloc -> L.Int let val_of_chunk = function | M_int | M_char -> L.Int - | M_float -> L.Real + | M_f32 -> Cfloat.tau_of_float Ctypes.Float32 + | M_f64 -> Cfloat.tau_of_float Ctypes.Float64 | M_pointer -> t_addr | T_alloc -> L.Int - let tau_of_chunk = - let m = Array.make 5 L.Int in - List.iter - (fun c -> m.(rank c) <- L.Array(key_of_chunk c,val_of_chunk c)) - [M_int;M_char;M_float;M_pointer;T_alloc] ; - fun c -> m.(rank c) + let tau_of_chunk = function + | M_int | M_char -> L.Array(t_addr,L.Int) + | M_pointer -> L.Array(t_addr,t_addr) + | M_f32 -> L.Array(t_addr,Cfloat.tau_of_float Ctypes.Float32) + | M_f64 -> L.Array(t_addr,Cfloat.tau_of_float Ctypes.Float64) + | T_alloc -> L.Array(L.Int,L.Int) let basename_of_chunk = name let is_framed _ = false end @@ -454,10 +460,11 @@ type loc = term (* of type addr *) (* -------------------------------------------------------------------------- *) let m_int i = if Ctypes.is_char i then M_char else M_int +let m_float = function Float32 -> M_f32 | Float64 -> M_f64 let rec footprint = function | C_int i -> Heap.Set.singleton (m_int i) - | C_float _ -> Heap.Set.singleton M_float + | C_float f -> Heap.Set.singleton (m_float f) | C_pointer _ -> Heap.Set.singleton M_pointer | C_array a -> footprint (object_of a.arr_element) | C_comp c -> footprint_comp c @@ -1005,7 +1012,7 @@ module ARRAY = Model.Generator(Matrix.NATURAL) let loadvalue sigma obj l = match obj with | C_int i -> F.e_get (Sigma.value sigma (m_int i)) l - | C_float _ -> F.e_get (Sigma.value sigma M_float) l + | C_float f -> F.e_get (Sigma.value sigma (m_float f)) l | C_pointer _ -> F.e_get (Sigma.value sigma M_pointer) l | C_comp c -> let phi,cs = COMP.get c in @@ -1271,7 +1278,7 @@ let eqmem s obj l = let stored s obj l v = match obj with | C_int i -> updated s (m_int i) l v - | C_float _ -> updated s M_float l v + | C_float f -> updated s (m_float f) l v | C_pointer _ -> updated s M_pointer l v | C_comp _ | C_array _ -> Set(loadvalue s.post obj l, v) :: diff --git a/src/plugins/wp/MemVar.ml b/src/plugins/wp/MemVar.ml index cd5dcfd28d4f04fee81807c9d5604dea8bb52d43..b4d8a304b5e39ebcfb26c760a27b16bc269f24c9 100644 --- a/src/plugins/wp/MemVar.ml +++ b/src/plugins/wp/MemVar.ml @@ -49,6 +49,8 @@ struct let datatype = "MemVar." ^ V.datatype ^ M.datatype let configure = M.configure + let no_binder = { bind = fun _ f v -> f v } + let configure_ia _ = no_binder let hypotheses () = V.hypotheses () @ M.hypotheses () diff --git a/src/plugins/wp/MemZeroAlias.ml b/src/plugins/wp/MemZeroAlias.ml index 1983f2361f498823fd38afb9fccaa19e372d77e6..c88f4531a438160afc5b4b7377c13978f189b43e 100644 --- a/src/plugins/wp/MemZeroAlias.ml +++ b/src/plugins/wp/MemZeroAlias.ml @@ -39,6 +39,8 @@ let configure () = Context.set Lang.pointer (fun _typ -> Logic.Int) ; Context.set Cvalues.null F.(p_equal e_zero) ; end +let no_binder = { bind = fun _ f v -> f v } +let configure_ia _ = no_binder (* TODO: compute actual separation hypotheses *) let hypotheses () = [] diff --git a/src/plugins/wp/Sigs.ml b/src/plugins/wp/Sigs.ml index aa49e4f9d21b6052dbb868d93dfa3573905c5624..d451e04f15fcb2003abd1d85c6769e6a4afc1da0 100644 --- a/src/plugins/wp/Sigs.ml +++ b/src/plugins/wp/Sigs.ml @@ -27,6 +27,7 @@ open Cil_types open Ctypes open Lang.F +open Interpreted_automata (* -------------------------------------------------------------------------- *) (** {1 General Definitions} *) @@ -34,6 +35,8 @@ open Lang.F type 'a sequence = { pre : 'a ; post : 'a } +type 'a binder = { bind: 'b 'c. 'a -> ('b -> 'c) -> 'b -> 'c } + (** Oriented equality or arbitrary relation *) type equation = | Set of term * term (** [Set(a,b)] is [a := b]. *) @@ -267,6 +270,11 @@ sig (** Initializers to be run before using the model. Typically sets {!Context} values. *) + val configure_ia: automaton -> vertex binder + (** Given an automaton, return a vertex's binder. + Currently used by the automata compiler to bind current vertex. + See {!StmtSemantics}. *) + val datatype : string (** For projectification. Must be unique among models. *) diff --git a/src/plugins/wp/StmtSemantics.ml b/src/plugins/wp/StmtSemantics.ml index dcfe6882c457142db1f40bb156ea742e8f894c3e..968c460cb2b5941bbe21304fc8ea819281bf9330 100644 --- a/src/plugins/wp/StmtSemantics.ml +++ b/src/plugins/wp/StmtSemantics.ml @@ -66,6 +66,7 @@ struct (* --- Env Utilities --- *) (* -------------------------------------------------------------------------- *) + let result env = env.result let bind l n env = @@ -575,6 +576,8 @@ struct let automaton : env -> Interpreted_automata.automaton -> paths = fun env a -> let open Interpreted_automata in + let binder = M.configure_ia a in + let bind = binder.bind in let wto = WTO.partition ~pref ~init:a.entry_point ~succs:(G.succ a.graph) in let index = Compute.build_wto_index_table wto in @@ -620,26 +623,30 @@ struct do_list ~fresh_nodes paths nodes n2 l in let rec component nodes paths = function - | Wto.Node v -> do_node nodes v paths - | Wto.Component (v,l) -> - assert (not (Automata.Map.mem v nodes.local)); - let invariants,l = get_invariants g v l in - let n = get_node {nodes with local = Automata.Map.empty} v in - (* initialization *) - let n,paths = do_list ~fresh_nodes:true paths nodes n invariants in - (* preservation *) - let n_loop = Cfg.node () in - let _,paths = do_list ~fresh_nodes:true paths nodes n_loop invariants in - (* arbitrary number of loop *) - let n_havoc = Cfg.node () in - let havoc = Cfg.havoc n ~effects:{pre=n_havoc;post=n_loop} n_havoc in - let paths = (havoc |> paths_of_cfg) @^ paths in - (* body *) - let invariants_as_assumes = as_assumes invariants in - let _,paths = - do_list ~fresh_nodes:false paths (add_local nodes v n_havoc) - n_havoc invariants_as_assumes in - partition (add_local nodes v n_loop) paths l + | Wto.Node ((n, _) as v) -> bind n (do_node nodes v) paths + | Wto.Component ((n, _) as v, l) -> + let do_component (v, l) = + assert (not (Automata.Map.mem v nodes.local)); + let invariants,l = get_invariants g v l in + let n = get_node {nodes with local = Automata.Map.empty} v in + (* initialization *) + let n,paths = do_list ~fresh_nodes:true paths nodes n invariants in + (* preservation *) + let n_loop = Cfg.node () in + let _,paths = do_list ~fresh_nodes:true paths nodes n_loop invariants in + (* arbitrary number of loop *) + let n_havoc = Cfg.node () in + let havoc = Cfg.havoc n ~effects:{pre=n_havoc;post=n_loop} n_havoc in + let paths = (havoc |> paths_of_cfg) @^ paths in + (* body *) + let invariants_as_assumes = as_assumes invariants in + let _,paths = + do_list ~fresh_nodes:false paths (add_local nodes v n_havoc) + n_havoc invariants_as_assumes in + partition (add_local nodes v n_loop) paths l + in + bind n do_component (v, l) + and partition nodes paths l = List.fold_left (component nodes) paths l in @@ -744,21 +751,34 @@ struct let compute_kf kf = - let autom = Interpreted_automata.Compute.get_automaton ~annotations:true kf in + let open Interpreted_automata in + let autom = Compute.get_automaton ~annotations:true kf in (* let cout = open_out (Format.sprintf "/tmp/cfg_automata_%s.dot" (Kernel_function.get_name kf)) in * Interpreted_automata.Compute.output_to_dot cout autom; * close_out cout; *) - let nprepre = Cfg.node () in - let npre = Cfg.node () in - let npost = Cfg.node () in - let npostpost = Cfg.node () in - let env = empty_env kf in - let env = env @* [Clabels.pre,npre;Clabels.post,npost] in + let binder = M.configure_ia autom in + let bind = binder.bind in + let spec = Annotations.funspec kf in + (* start and end nodes of pre(resp. post)-conditions. *) + let pres = { pre = Cfg.node (); post = Cfg.node () } in + let posts = { pre = Cfg.node (); post = Cfg.node () } in + let env = empty_env kf @* [Clabels.pre,pres.post;Clabels.post,posts.pre] in + (* initialization *) let init = init ~is_pre_main:(WpStrategy.is_main_init kf) - (env @* [Clabels.here,nprepre]) in - let kf_spec = Annotations.funspec kf in - let pre = pre_spec (env @* [Clabels.here,nprepre;Clabels.next,npre]) kf_spec in - let paths = automaton (env @* [Clabels.here,npre;Clabels.next,npost]) autom in - let post = post_normal_spec (env @* [Clabels.here,npost;Clabels.next,npostpost]) kf_spec in - init @^ pre @^ paths @^ post, env @: Clabels.init + (env @* [Clabels.here,pres.pre]) in + (* pre-condition *) + let pre = + bind autom.entry_point @@ + pre_spec (env @* [Clabels.here,pres.pre;Clabels.next,pres.post]) + in + (* code *) + let paths = + automaton (env @* [Clabels.here,pres.post;Clabels.next,posts.pre]) autom + in + (* post-condition *) + let post = + bind autom.return_point @@ + post_normal_spec (env @* [Clabels.here,posts.pre;Clabels.next,posts.post]) + in + init @^ pre spec @^ paths @^ post spec, env @: Clabels.init end diff --git a/src/plugins/wp/doc/manual/wp_intro.tex b/src/plugins/wp/doc/manual/wp_intro.tex index da74357a7b980d3af92104006171c1c51d367aa9..1e3c5e076a67cc3e3d8a823eceda35a8c64bcd7d 100644 --- a/src/plugins/wp/doc/manual/wp_intro.tex +++ b/src/plugins/wp/doc/manual/wp_intro.tex @@ -340,12 +340,15 @@ For tackling this complexity, the \textsf{WP} plug-in relies on several or \texttt{-wp-rte} will generate a warning if some annotation might be not generated. -\item[Float Model:] floating-point operations are \emph{defined} to be - the mathematical ones \emph{with} a rounding operation. This is fully - consistent with the \textsf{IEEE} semantics. Most automated provers - are not able to discharge the generated proof obligations. Special - support for the \textsf{Gappa} theorem prover is available through - \textsf{Why3}. +\item[Float Model:] floating-point values are represent in a special + theory with dedicated operations over \texttt{float} and \texttt{double} + values and conversion from and to their \texttt{real} representation \emph{via} + rounding, as defined by the \textsc{C/ACSL} semantics. + + Although correct with respect to the \textsc{IEEE} specifications, this + model still provides very little support for proving properties with automated + provers. You may add additional properties using \emph{drivers} + as explained later. \item[Real Model:] floating-point operations are \emph{transformed} on reals, with \emph{no} rounding. This is completely unsound with diff --git a/src/plugins/wp/share/coqwp/Cfloat.v b/src/plugins/wp/share/coqwp/Cfloat.v index 0b7666721938c60d6a21bf9c9fda4a28ecd4b6c6..fd245b87bfb945f92a72fc968f38f392fd83c6b4 100644 --- a/src/plugins/wp/share/coqwp/Cfloat.v +++ b/src/plugins/wp/share/coqwp/Cfloat.v @@ -26,24 +26,35 @@ Require Import BuiltIn. Require Reals.Rbasic_fun. Require Reals.R_sqrt. Require BuiltIn. +Require bool.Bool. Require real.Real. Require real.RealInfix. Require real.Abs. Require real.Square. (* Why3 goal *) -Definition to_float32: R -> R. +Definition f32 : Type. Admitted. (* Why3 goal *) -Definition to_float64: R -> R. +Definition f64 : Type. Admitted. -(* Why3 assumption *) -Definition is_float32 (x:R): Prop := ((to_float32 x) = x). +(* Why3 goal *) +Definition to_f32: R -> f32. +Admitted. -(* Why3 assumption *) -Definition is_float64 (x:R): Prop := ((to_float64 x) = x). +(* Why3 goal *) +Definition of_f32: f32 -> R. +Admitted. + +(* Why3 goal *) +Definition to_f64: R -> f64. +Admitted. + +(* Why3 goal *) +Definition of_f64: f64 -> R. +Admitted. (* Why3 assumption *) Inductive rounding_mode := @@ -56,28 +67,26 @@ Axiom rounding_mode_WhyType : WhyType rounding_mode. Existing Instance rounding_mode_WhyType. (* Why3 goal *) -Definition round_double: rounding_mode -> R -> R. +Definition round_float: rounding_mode -> R -> f32. Admitted. (* Why3 goal *) -Definition round_float: rounding_mode -> R -> R. +Definition round_double: rounding_mode -> R -> f64. Admitted. (* Why3 goal *) -Lemma float_32 : forall (x:R), - ((to_float32 x) = (round_float NearestTiesToEven x)). +Lemma float_32 : forall (x:R), ((to_f32 x) = (round_float NearestTiesToEven + x)). Admitted. (* Why3 goal *) -Lemma float_64 : forall (x:R), - ((to_float64 x) = (round_double NearestTiesToEven x)). +Lemma float_64 : forall (x:R), ((to_f64 x) = (round_double NearestTiesToEven + x)). Admitted. (* Why3 assumption *) Inductive float_kind := - | Real : float_kind - | Float32 : float_kind - | Float64 : float_kind + | Finite : float_kind | NaN : float_kind | Inf_pos : float_kind | Inf_neg : float_kind. @@ -85,99 +94,310 @@ Axiom float_kind_WhyType : WhyType float_kind. Existing Instance float_kind_WhyType. (* Why3 goal *) -Definition classify_float: R -> float_kind. +Definition classify_f32: f32 -> float_kind. Admitted. +(* Why3 goal *) +Definition classify_f64: f64 -> float_kind. +Admitted. + +(* Why3 assumption *) +Definition is_finite_f32 (f:f32): Prop := ((classify_f32 f) = Finite). + +(* Why3 assumption *) +Definition is_finite_f64 (d:f64): Prop := ((classify_f64 d) = Finite). + +(* Why3 assumption *) +Definition is_NaN_f32 (f:f32): Prop := ((classify_f32 f) = NaN). + +(* Why3 assumption *) +Definition is_NaN_f64 (d:f64): Prop := ((classify_f64 d) = NaN). + (* Why3 assumption *) -Definition is_finite32 (x:R): Prop := ((classify_float x) = Float32). +Definition is_infinite_f32 (f:f32): Prop := ((classify_f32 f) = Inf_pos) \/ + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_finite64 (x:R): Prop := ((classify_float x) = Float32) \/ - ((classify_float x) = Float64). +Definition is_infinite_f64 (d:f64): Prop := ((classify_f64 d) = Inf_pos) \/ + ((classify_f64 d) = Inf_neg). (* Why3 assumption *) -Definition is_NaN (x:R): Prop := ((classify_float x) = NaN). +Definition is_positive_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_pos). (* Why3 assumption *) -Definition is_infinite (x:R): Prop := ((classify_float x) = Inf_pos) \/ - ((classify_float x) = Inf_neg). +Definition is_positive_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_pos). (* Why3 assumption *) -Definition is_positive_infinite (x:R): Prop := - ((classify_float x) = Inf_pos). +Definition is_negative_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_negative_infinite (x:R): Prop := - ((classify_float x) = Inf_neg). +Definition is_negative_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_neg). (* Why3 goal *) -Lemma is_finite_to_float_32 : forall (x:R), (is_finite32 (to_float32 x)). +Lemma is_finite_to_float_32 : forall (x:R), (is_finite_f32 (to_f32 x)). Admitted. (* Why3 goal *) -Lemma is_finite_to_float_64 : forall (x:R), (is_finite64 (to_float64 x)). +Lemma is_finite_to_float_64 : forall (x:R), (is_finite_f64 (to_f64 x)). Admitted. -(* Why3 assumption *) -Definition add_float32 (x:R) (y:R): R := (to_float32 (x + y)%R). +(* Why3 goal *) +Lemma to_float_is_finite_32 : forall (f:f32), (is_finite_f32 f) -> + ((to_f32 (of_f32 f)) = f). +Admitted. + +(* Why3 goal *) +Lemma to_float_is_finite_64 : forall (d:f64), (is_finite_f64 d) -> + ((to_f64 (of_f64 d)) = d). +Admitted. (* Why3 assumption *) -Definition add_float64 (x:R) (y:R): R := (to_float64 (x + y)%R). +Definition finite (x:R): Prop := (is_finite_f32 (to_f32 x)) /\ (is_finite_f64 + (to_f64 x)). + +(* Why3 goal *) +Lemma finite_small_f32 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 340282346600000016151267322115014000640%R)%R) -> (is_finite_f32 + (to_f32 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_small_f64 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R) -> + (is_finite_f64 (to_f64 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f32 : forall (f:f32), (is_finite_f32 f) <-> + (((-340282346600000016151267322115014000640%R)%R <= (of_f32 f))%R /\ + ((of_f32 f) <= 340282346600000016151267322115014000640%R)%R). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f64 : forall (d:f64), (is_finite_f64 d) <-> + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= (of_f64 d))%R /\ + ((of_f64 d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R). +Admitted. + +(* Why3 goal *) +Definition eq_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition eq_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition mul_float32 (x:R) (y:R): R := (to_float32 (x * y)%R). +Definition eq_f32 (x:f32) (y:f32): Prop := ((eq_f32b x y) = true). (* Why3 assumption *) -Definition mul_float64 (x:R) (y:R): R := (to_float64 (x * y)%R). +Definition eq_f64 (x:f64) (y:f64): Prop := ((eq_f64b x y) = true). + +(* Why3 goal *) +Lemma eq_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((eq_f32 x y) <-> ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma eq_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((eq_f64 x y) <-> ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition ne_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition ne_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition div_float32 (x:R) (y:R): R := (to_float32 (x / y)%R). +Definition ne_f32 (x:f32) (y:f32): Prop := ((ne_f32b x y) = true). (* Why3 assumption *) -Definition div_float64 (x:R) (y:R): R := (to_float64 (x / y)%R). +Definition ne_f64 (x:f64) (y:f64): Prop := ((ne_f64b x y) = true). + +(* Why3 goal *) +Lemma ne_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((ne_f32 x y) <-> ~ ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma ne_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((ne_f64 x y) <-> ~ ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition le_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition le_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition sqrt_float32 (x:R): R := (to_float32 (Reals.R_sqrt.sqrt x)). +Definition le_f32 (x:f32) (y:f32): Prop := ((le_f32b x y) = true). (* Why3 assumption *) -Definition sqrt_float64 (x:R): R := (to_float64 (Reals.R_sqrt.sqrt x)). +Definition le_f64 (x:f64) (y:f64): Prop := ((le_f64b x y) = true). (* Why3 goal *) -Definition model: R -> R. +Lemma le_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((le_f32 x y) <-> ((of_f32 x) <= (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma le_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((le_f64 x y) <-> ((of_f64 x) <= (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition lt_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition lt_f64b: f64 -> f64 -> bool. Admitted. (* Why3 assumption *) -Definition delta (x:R): R := (Reals.Rbasic_fun.Rabs (x - (model x))%R). +Definition lt_f32 (x:f32) (y:f32): Prop := ((lt_f32b x y) = true). (* Why3 assumption *) -Definition error (x:R): R := - ((delta x) / (Reals.Rbasic_fun.Rabs (model x)))%R. +Definition lt_f64 (x:f64) (y:f64): Prop := ((lt_f64b x y) = true). + +(* Why3 goal *) +Lemma lt_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((lt_f32 x y) <-> ((of_f32 x) < (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma lt_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((lt_f64 x y) <-> ((of_f64 x) < (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition neg_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition neg_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((of_f32 (neg_f32 x)) = (-(of_f32 x))%R). +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((of_f64 (neg_f64 x)) = (-(of_f64 x))%R). +Admitted. + +(* Why3 goal *) +Definition add_f32: f32 -> f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition add_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma add_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((add_f32 x + y) = (to_f32 ((of_f32 x) + (of_f32 y))%R))). +Admitted. (* Why3 goal *) -Lemma model_float_32 : forall (x:R), ((model (to_float32 x)) = (model x)). +Lemma add_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((add_f64 x + y) = (to_f64 ((of_f64 x) + (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_float_64 : forall (x:R), ((model (to_float64 x)) = (model x)). +Definition mul_f32: f32 -> f32 -> f32. Admitted. (* Why3 goal *) -Lemma model_add : forall (x:R) (y:R), - ((model (x + y)%R) = ((model x) + (model y))%R). +Definition mul_f64: f64 -> f64 -> f64. Admitted. (* Why3 goal *) -Lemma model_mul : forall (x:R) (y:R), - ((model (x * y)%R) = ((model x) * (model y))%R). +Lemma mul_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((mul_f32 x + y) = (to_f32 ((of_f32 x) * (of_f32 y))%R))). Admitted. (* Why3 goal *) -Lemma model_div : forall (x:R) (y:R), - ((model (x / y)%R) = ((model x) / (model y))%R). +Lemma mul_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((mul_f64 x + y) = (to_f64 ((of_f64 x) * (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_sqrt : forall (x:R), - ((model (Reals.R_sqrt.sqrt x)) = (Reals.R_sqrt.sqrt (model x))). +Definition div_f32: f32 -> f32 -> f32. Admitted. +(* Why3 goal *) +Definition div_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma div_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((div_f32 x + y) = (to_f32 ((of_f32 x) / (of_f32 y))%R))). +Admitted. + +(* Why3 goal *) +Lemma div_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((div_f64 x + y) = (to_f64 ((of_f64 x) / (of_f64 y))%R))). +Admitted. + +(* Why3 goal *) +Definition sqrt_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition sqrt_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((sqrt_f32 x) = (to_f32 (Reals.R_sqrt.sqrt (of_f32 x)))). +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((sqrt_f64 x) = (to_f64 (Reals.R_sqrt.sqrt (of_f64 x)))). +Admitted. + +(* Why3 goal *) +Definition model_f32: f32 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f32 (f:f32): R := + (Reals.Rbasic_fun.Rabs ((of_f32 f) - (model_f32 f))%R). + +(* Why3 assumption *) +Definition error_f32 (f:f32): R := + ((delta_f32 f) / (Reals.Rbasic_fun.Rabs (model_f32 f)))%R. + +(* Why3 goal *) +Definition model_f64: f64 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f64 (f:f64): R := + (Reals.Rbasic_fun.Rabs ((of_f64 f) - (model_f64 f))%R). + +(* Why3 assumption *) +Definition error_f64 (f:f64): R := + ((delta_f64 f) / (Reals.Rbasic_fun.Rabs (model_f64 f)))%R. + diff --git a/src/plugins/wp/share/ergo/Cfloat.mlw b/src/plugins/wp/share/ergo/Cfloat.mlw index 4114401bdc9df5d349adec5ac5c4abd6be234cf0..53d827ee5091005aa9994a4ac9a18398aa6b9e82 100644 --- a/src/plugins/wp/share/ergo/Cfloat.mlw +++ b/src/plugins/wp/share/ergo/Cfloat.mlw @@ -23,17 +23,22 @@ (* this is the prelude for Alt-Ergo, version >= 0.95.2 *) (** The theory BuiltIn_ must be appended to this file*) (** The theory Bool_ must be appended to this file*) +(** The theory bool_Bool_ must be appended to this file*) (** The theory real_Real_ must be appended to this file*) (** The theory real_RealInfix_ must be appended to this file*) (** The theory real_Abs_ must be appended to this file*) (** The theory real_Square_ must be appended to this file*) -logic to_float32 : real -> real +type f32 -logic to_float64 : real -> real +type f64 -predicate is_float32(x: real) = (to_float32(x) = x) +logic to_f32 : real -> f32 -predicate is_float64(x: real) = (to_float64(x) = x) +logic of_f32 : f32 -> real + +logic to_f64 : real -> f64 + +logic of_f64 : f64 -> real type rounding_mode = Up | Down | ToZero | NearestTiesToAway | NearestTiesToEven @@ -60,102 +65,286 @@ axiom match_rounding_mode_NearestTiesToEven : (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. (match_rounding_mode(NearestTiesToEven, z, z1, z2, z3, z4) = z4)) -logic round_double : rounding_mode, real -> real +logic round_float : rounding_mode, real -> f32 -logic round_float : rounding_mode, real -> real +logic round_double : rounding_mode, real -> f64 axiom float_32 : (forall x:real [round_float(NearestTiesToEven, x)]. - (to_float32(x) = round_float(NearestTiesToEven, x))) + (to_f32(x) = round_float(NearestTiesToEven, x))) axiom float_64 : (forall x:real [round_double(NearestTiesToEven, x)]. - (to_float64(x) = round_double(NearestTiesToEven, x))) + (to_f64(x) = round_double(NearestTiesToEven, x))) -type float_kind = Real | Float32 | Float64 | NaN | Inf_pos | Inf_neg +type float_kind = Finite | NaN | Inf_pos | Inf_neg -logic match_float_kind : float_kind, 'a, 'a, 'a, 'a, 'a, 'a -> 'a +logic match_float_kind : float_kind, 'a, 'a, 'a, 'a -> 'a -axiom match_float_kind_Real : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Real, z, z1, z2, z3, z4, z5) = z)) - -axiom match_float_kind_Float32 : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Float32, z, z1, z2, z3, z4, z5) = z1)) - -axiom match_float_kind_Float64 : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Float64, z, z1, z2, z3, z4, z5) = z2)) +axiom match_float_kind_Finite : + (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. + (match_float_kind(Finite, z, z1, z2, z3) = z)) axiom match_float_kind_NaN : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(NaN, z, z1, z2, z3, z4, z5) = z3)) + (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. + (match_float_kind(NaN, z, z1, z2, z3) = z1)) axiom match_float_kind_Inf_pos : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Inf_pos, z, z1, z2, z3, z4, z5) = z4)) + (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. + (match_float_kind(Inf_pos, z, z1, z2, z3) = z2)) axiom match_float_kind_Inf_neg : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Inf_neg, z, z1, z2, z3, z4, z5) = z5)) + (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. + (match_float_kind(Inf_neg, z, z1, z2, z3) = z3)) + +logic classify_f32 : f32 -> float_kind + +logic classify_f64 : f64 -> float_kind + +predicate is_finite_f32(f: f32) = (classify_f32(f) = Finite) -logic classify_float : real -> float_kind +predicate is_finite_f64(d: f64) = (classify_f64(d) = Finite) -predicate is_finite32(x: real) = (classify_float(x) = Float32) +predicate is_NaN_f32(f: f32) = (classify_f32(f) = NaN) -predicate is_finite64(x: real) = ((classify_float(x) = Float32) or - (classify_float(x) = Float64)) +predicate is_NaN_f64(d: f64) = (classify_f64(d) = NaN) -predicate is_NaN(x: real) = (classify_float(x) = NaN) +predicate is_infinite_f32(f: f32) = ((classify_f32(f) = Inf_pos) or + (classify_f32(f) = Inf_neg)) -predicate is_infinite(x: real) = ((classify_float(x) = Inf_pos) or - (classify_float(x) = Inf_neg)) +predicate is_infinite_f64(d: f64) = ((classify_f64(d) = Inf_pos) or + (classify_f64(d) = Inf_neg)) -predicate is_positive_infinite(x: real) = (classify_float(x) = Inf_pos) +predicate is_positive_infinite_f32(f: f32) = (classify_f32(f) = Inf_pos) -predicate is_negative_infinite(x: real) = (classify_float(x) = Inf_neg) +predicate is_positive_infinite_f64(d: f64) = (classify_f64(d) = Inf_pos) + +predicate is_negative_infinite_f32(f: f32) = (classify_f32(f) = Inf_neg) + +predicate is_negative_infinite_f64(d: f64) = (classify_f64(d) = Inf_neg) axiom is_finite_to_float_32 : - (forall x:real [is_finite32(to_float32(x))]. is_finite32(to_float32(x))) + (forall x:real [is_finite_f32(to_f32(x))]. is_finite_f32(to_f32(x))) axiom is_finite_to_float_64 : - (forall x:real [is_finite64(to_float64(x))]. is_finite64(to_float64(x))) + (forall x:real [is_finite_f64(to_f64(x))]. is_finite_f64(to_f64(x))) + +axiom to_float_is_finite_32 : + (forall f:f32 [to_f32(of_f32(f))| is_finite_f32(f)]. (is_finite_f32(f) -> + (to_f32(of_f32(f)) = f))) + +axiom to_float_is_finite_64 : + (forall d:f64 [to_f64(of_f64(d))| is_finite_f64(d)]. (is_finite_f64(d) -> + (to_f64(of_f64(d)) = d))) + +predicate finite(x: real) = (is_finite_f32(to_f32(x)) and + is_finite_f64(to_f64(x))) + +axiom finite_small_f32 : + (forall x:real. + ((((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0) <= x) and + (x <= 340282346600000016151267322115014000640.0)) -> + is_finite_f32(to_f32(x)))) + +axiom finite_small_f64 : + (forall x:real. + ((((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0) <= x) and + (x <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0)) -> + is_finite_f64(to_f64(x)))) + +axiom finite_range_f32 : + (forall f:f32. (is_finite_f32(f) -> + ((-340282346600000016151267322115014000640.0) <= of_f32(f)))) + +axiom finite_range_f321 : + (forall f:f32. (is_finite_f32(f) -> + (of_f32(f) <= 340282346600000016151267322115014000640.0))) + +axiom finite_range_f322 : + (forall f:f32. + ((((-340282346600000016151267322115014000640.0) <= of_f32(f)) and + (of_f32(f) <= 340282346600000016151267322115014000640.0)) -> + is_finite_f32(f))) + +axiom finite_range_f64 : + (forall d:f64. (is_finite_f64(d) -> + ((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0) <= of_f64(d)))) + +axiom finite_range_f641 : + (forall d:f64. (is_finite_f64(d) -> + (of_f64(d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0))) + +axiom finite_range_f642 : + (forall d:f64. + ((((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0) <= of_f64(d)) and + (of_f64(d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0)) -> + is_finite_f64(d))) + +logic eq_f32b : f32, f32 -> bool + +logic eq_f64b : f64, f64 -> bool + +predicate eq_f32(x: f32, y: f32) = (eq_f32b(x, y) = true) + +predicate eq_f64(x: f64, y: f64) = (eq_f64b(x, y) = true) + +axiom eq_finite_f32 : + (forall x:f32. forall y:f32 [eq_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (eq_f32(x, y) -> (of_f32(x) = of_f32(y)))))) + +axiom eq_finite_f321 : + (forall x:f32. forall y:f32 [eq_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> ((of_f32(x) = of_f32(y)) -> eq_f32(x, y))))) + +axiom eq_finite_f64 : + (forall x:f64. forall y:f64 [eq_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (eq_f64(x, y) -> (of_f64(x) = of_f64(y)))))) + +axiom eq_finite_f641 : + (forall x:f64. forall y:f64 [eq_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> ((of_f64(x) = of_f64(y)) -> eq_f64(x, y))))) + +logic ne_f32b : f32, f32 -> bool + +logic ne_f64b : f64, f64 -> bool + +predicate ne_f32(x: f32, y: f32) = (ne_f32b(x, y) = true) + +predicate ne_f64(x: f64, y: f64) = (ne_f64b(x, y) = true) + +axiom ne_finite_f32 : + (forall x:f32. forall y:f32 [ne_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (ne_f32(x, y) -> (not (of_f32(x) = of_f32(y))))))) + +axiom ne_finite_f321 : + (forall x:f32. forall y:f32 [ne_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> ((not (of_f32(x) = of_f32(y))) -> ne_f32(x, y))))) + +axiom ne_finite_f64 : + (forall x:f64. forall y:f64 [ne_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (ne_f64(x, y) -> (not (of_f64(x) = of_f64(y))))))) + +axiom ne_finite_f641 : + (forall x:f64. forall y:f64 [ne_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> ((not (of_f64(x) = of_f64(y))) -> ne_f64(x, y))))) + +logic le_f32b : f32, f32 -> bool + +logic le_f64b : f64, f64 -> bool + +predicate le_f32(x: f32, y: f32) = (le_f32b(x, y) = true) + +predicate le_f64(x: f64, y: f64) = (le_f64b(x, y) = true) + +axiom le_finite_f32 : + (forall x:f32. forall y:f32 [le_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (le_f32(x, y) -> (of_f32(x) <= of_f32(y)))))) + +axiom le_finite_f321 : + (forall x:f32. forall y:f32 [le_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> ((of_f32(x) <= of_f32(y)) -> le_f32(x, y))))) + +axiom le_finite_f64 : + (forall x:f64. forall y:f64 [le_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (le_f64(x, y) -> (of_f64(x) <= of_f64(y)))))) + +axiom le_finite_f641 : + (forall x:f64. forall y:f64 [le_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> ((of_f64(x) <= of_f64(y)) -> le_f64(x, y))))) + +logic lt_f32b : f32, f32 -> bool + +logic lt_f64b : f64, f64 -> bool + +predicate lt_f32(x: f32, y: f32) = (lt_f32b(x, y) = true) + +predicate lt_f64(x: f64, y: f64) = (lt_f64b(x, y) = true) + +axiom lt_finite_f32 : + (forall x:f32. forall y:f32 [lt_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (lt_f32(x, y) -> (of_f32(x) < of_f32(y)))))) + +axiom lt_finite_f321 : + (forall x:f32. forall y:f32 [lt_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> ((of_f32(x) < of_f32(y)) -> lt_f32(x, y))))) + +axiom lt_finite_f64 : + (forall x:f64. forall y:f64 [lt_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (lt_f64(x, y) -> (of_f64(x) < of_f64(y)))))) + +axiom lt_finite_f641 : + (forall x:f64. forall y:f64 [lt_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> ((of_f64(x) < of_f64(y)) -> lt_f64(x, y))))) + +logic neg_f32 : f32 -> f32 + +logic neg_f64 : f64 -> f64 + +axiom neg_finite_f32 : + (forall x:f32 [neg_f32(x)]. (is_finite_f32(x) -> + (of_f32(neg_f32(x)) = (-of_f32(x))))) + +axiom neg_finite_f64 : + (forall x:f64 [neg_f64(x)]. (is_finite_f64(x) -> + (of_f64(neg_f64(x)) = (-of_f64(x))))) + +logic add_f32 : f32, f32 -> f32 + +logic add_f64 : f64, f64 -> f64 + +axiom add_finite_f32 : + (forall x:f32. forall y:f32 [add_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (add_f32(x, y) = to_f32((of_f32(x) + of_f32(y))))))) + +axiom add_finite_f64 : + (forall x:f64. forall y:f64 [add_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (add_f64(x, y) = to_f64((of_f64(x) + of_f64(y))))))) + +logic mul_f32 : f32, f32 -> f32 -function add_float32(x: real, y: real) : real = to_float32((x + y)) +logic mul_f64 : f64, f64 -> f64 -function add_float64(x: real, y: real) : real = to_float64((x + y)) +axiom mul_finite_f32 : + (forall x:f32. forall y:f32 [mul_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (mul_f32(x, y) = to_f32((of_f32(x) * of_f32(y))))))) -function mul_float32(x: real, y: real) : real = to_float32((x * y)) +axiom mul_finite_f64 : + (forall x:f64. forall y:f64 [mul_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (mul_f64(x, y) = to_f64((of_f64(x) * of_f64(y))))))) -function mul_float64(x: real, y: real) : real = to_float64((x * y)) +logic div_f32 : f32, f32 -> f32 -function div_float32(x: real, y: real) : real = to_float32((x / y)) +logic div_f64 : f64, f64 -> f64 -function div_float64(x: real, y: real) : real = to_float64((x / y)) +axiom div_finite_f32 : + (forall x:f32. forall y:f32 [div_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (div_f32(x, y) = to_f32((of_f32(x) / of_f32(y))))))) -function sqrt_float32(x: real) : real = to_float32(sqrt(x)) +axiom div_finite_f64 : + (forall x:f64. forall y:f64 [div_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (div_f64(x, y) = to_f64((of_f64(x) / of_f64(y))))))) -function sqrt_float64(x: real) : real = to_float64(sqrt(x)) +logic sqrt_f32 : f32 -> f32 -logic model : real -> real +logic sqrt_f64 : f64 -> f64 -function delta(x: real) : real = abs_real((x - model(x))) +axiom sqrt_finite_f32 : + (forall x:f32 [sqrt_f32(x)]. (is_finite_f32(x) -> + (sqrt_f32(x) = to_f32(sqrt(of_f32(x)))))) -function error(x: real) : real = (delta(x) / abs_real(model(x))) +axiom sqrt_finite_f64 : + (forall x:f64 [sqrt_f64(x)]. (is_finite_f64(x) -> + (sqrt_f64(x) = to_f64(sqrt(of_f64(x)))))) -axiom model_float_32 : (forall x:real. (model(to_float32(x)) = model(x))) +logic model_f32 : f32 -> real -axiom model_float_64 : (forall x:real. (model(to_float64(x)) = model(x))) +function delta_f32(f: f32) : real = abs_real((of_f32(f) - model_f32(f))) -axiom model_add : - (forall x:real. forall y:real. (model((x + y)) = (model(x) + model(y)))) +function error_f32(f: f32) : real = (delta_f32(f) / abs_real(model_f32(f))) -axiom model_mul : - (forall x:real. forall y:real. (model((x * y)) = (model(x) * model(y)))) +logic model_f64 : f64 -> real -axiom model_div : - (forall x:real. forall y:real. (model((x / y)) = (model(x) / model(y)))) +function delta_f64(f: f64) : real = abs_real((of_f64(f) - model_f64(f))) -axiom model_sqrt : (forall x:real. (model(sqrt(x)) = sqrt(model(x)))) +function error_f64(f: f64) : real = (delta_f64(f) / abs_real(model_f64(f))) diff --git a/src/plugins/wp/share/src/Cfloat.v b/src/plugins/wp/share/src/Cfloat.v index b995e0c55e8d4d8c573e794c0dcc90cc367674d4..2e91223270243ab2f1aea16be655e01e627251c8 100644 --- a/src/plugins/wp/share/src/Cfloat.v +++ b/src/plugins/wp/share/src/Cfloat.v @@ -4,24 +4,35 @@ Require Import BuiltIn. Require Reals.Rbasic_fun. Require Reals.R_sqrt. Require BuiltIn. +Require bool.Bool. Require real.Real. Require real.RealInfix. Require real.Abs. Require real.Square. (* Why3 goal *) -Definition to_float32: R -> R. +Definition f32 : Type. Admitted. (* Why3 goal *) -Definition to_float64: R -> R. +Definition f64 : Type. Admitted. -(* Why3 assumption *) -Definition is_float32 (x:R): Prop := ((to_float32 x) = x). +(* Why3 goal *) +Definition to_f32: R -> f32. +Admitted. -(* Why3 assumption *) -Definition is_float64 (x:R): Prop := ((to_float64 x) = x). +(* Why3 goal *) +Definition of_f32: f32 -> R. +Admitted. + +(* Why3 goal *) +Definition to_f64: R -> f64. +Admitted. + +(* Why3 goal *) +Definition of_f64: f64 -> R. +Admitted. (* Why3 assumption *) Inductive rounding_mode := @@ -34,28 +45,26 @@ Axiom rounding_mode_WhyType : WhyType rounding_mode. Existing Instance rounding_mode_WhyType. (* Why3 goal *) -Definition round_double: rounding_mode -> R -> R. +Definition round_float: rounding_mode -> R -> f32. Admitted. (* Why3 goal *) -Definition round_float: rounding_mode -> R -> R. +Definition round_double: rounding_mode -> R -> f64. Admitted. (* Why3 goal *) -Lemma float_32 : forall (x:R), - ((to_float32 x) = (round_float NearestTiesToEven x)). +Lemma float_32 : forall (x:R), ((to_f32 x) = (round_float NearestTiesToEven + x)). Admitted. (* Why3 goal *) -Lemma float_64 : forall (x:R), - ((to_float64 x) = (round_double NearestTiesToEven x)). +Lemma float_64 : forall (x:R), ((to_f64 x) = (round_double NearestTiesToEven + x)). Admitted. (* Why3 assumption *) Inductive float_kind := - | Real : float_kind - | Float32 : float_kind - | Float64 : float_kind + | Finite : float_kind | NaN : float_kind | Inf_pos : float_kind | Inf_neg : float_kind. @@ -63,99 +72,310 @@ Axiom float_kind_WhyType : WhyType float_kind. Existing Instance float_kind_WhyType. (* Why3 goal *) -Definition classify_float: R -> float_kind. +Definition classify_f32: f32 -> float_kind. Admitted. +(* Why3 goal *) +Definition classify_f64: f64 -> float_kind. +Admitted. + +(* Why3 assumption *) +Definition is_finite_f32 (f:f32): Prop := ((classify_f32 f) = Finite). + +(* Why3 assumption *) +Definition is_finite_f64 (d:f64): Prop := ((classify_f64 d) = Finite). + +(* Why3 assumption *) +Definition is_NaN_f32 (f:f32): Prop := ((classify_f32 f) = NaN). + +(* Why3 assumption *) +Definition is_NaN_f64 (d:f64): Prop := ((classify_f64 d) = NaN). + (* Why3 assumption *) -Definition is_finite32 (x:R): Prop := ((classify_float x) = Float32). +Definition is_infinite_f32 (f:f32): Prop := ((classify_f32 f) = Inf_pos) \/ + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_finite64 (x:R): Prop := ((classify_float x) = Float32) \/ - ((classify_float x) = Float64). +Definition is_infinite_f64 (d:f64): Prop := ((classify_f64 d) = Inf_pos) \/ + ((classify_f64 d) = Inf_neg). (* Why3 assumption *) -Definition is_NaN (x:R): Prop := ((classify_float x) = NaN). +Definition is_positive_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_pos). (* Why3 assumption *) -Definition is_infinite (x:R): Prop := ((classify_float x) = Inf_pos) \/ - ((classify_float x) = Inf_neg). +Definition is_positive_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_pos). (* Why3 assumption *) -Definition is_positive_infinite (x:R): Prop := - ((classify_float x) = Inf_pos). +Definition is_negative_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_negative_infinite (x:R): Prop := - ((classify_float x) = Inf_neg). +Definition is_negative_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_neg). (* Why3 goal *) -Lemma is_finite_to_float_32 : forall (x:R), (is_finite32 (to_float32 x)). +Lemma is_finite_to_float_32 : forall (x:R), (is_finite_f32 (to_f32 x)). Admitted. (* Why3 goal *) -Lemma is_finite_to_float_64 : forall (x:R), (is_finite64 (to_float64 x)). +Lemma is_finite_to_float_64 : forall (x:R), (is_finite_f64 (to_f64 x)). Admitted. -(* Why3 assumption *) -Definition add_float32 (x:R) (y:R): R := (to_float32 (x + y)%R). +(* Why3 goal *) +Lemma to_float_is_finite_32 : forall (f:f32), (is_finite_f32 f) -> + ((to_f32 (of_f32 f)) = f). +Admitted. + +(* Why3 goal *) +Lemma to_float_is_finite_64 : forall (d:f64), (is_finite_f64 d) -> + ((to_f64 (of_f64 d)) = d). +Admitted. (* Why3 assumption *) -Definition add_float64 (x:R) (y:R): R := (to_float64 (x + y)%R). +Definition finite (x:R): Prop := (is_finite_f32 (to_f32 x)) /\ (is_finite_f64 + (to_f64 x)). + +(* Why3 goal *) +Lemma finite_small_f32 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 340282346600000016151267322115014000640%R)%R) -> (is_finite_f32 + (to_f32 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_small_f64 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R) -> + (is_finite_f64 (to_f64 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f32 : forall (f:f32), (is_finite_f32 f) <-> + (((-340282346600000016151267322115014000640%R)%R <= (of_f32 f))%R /\ + ((of_f32 f) <= 340282346600000016151267322115014000640%R)%R). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f64 : forall (d:f64), (is_finite_f64 d) <-> + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= (of_f64 d))%R /\ + ((of_f64 d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R). +Admitted. + +(* Why3 goal *) +Definition eq_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition eq_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition mul_float32 (x:R) (y:R): R := (to_float32 (x * y)%R). +Definition eq_f32 (x:f32) (y:f32): Prop := ((eq_f32b x y) = true). (* Why3 assumption *) -Definition mul_float64 (x:R) (y:R): R := (to_float64 (x * y)%R). +Definition eq_f64 (x:f64) (y:f64): Prop := ((eq_f64b x y) = true). + +(* Why3 goal *) +Lemma eq_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((eq_f32 x y) <-> ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma eq_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((eq_f64 x y) <-> ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition ne_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition ne_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition div_float32 (x:R) (y:R): R := (to_float32 (x / y)%R). +Definition ne_f32 (x:f32) (y:f32): Prop := ((ne_f32b x y) = true). (* Why3 assumption *) -Definition div_float64 (x:R) (y:R): R := (to_float64 (x / y)%R). +Definition ne_f64 (x:f64) (y:f64): Prop := ((ne_f64b x y) = true). + +(* Why3 goal *) +Lemma ne_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((ne_f32 x y) <-> ~ ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma ne_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((ne_f64 x y) <-> ~ ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition le_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition le_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition sqrt_float32 (x:R): R := (to_float32 (Reals.R_sqrt.sqrt x)). +Definition le_f32 (x:f32) (y:f32): Prop := ((le_f32b x y) = true). (* Why3 assumption *) -Definition sqrt_float64 (x:R): R := (to_float64 (Reals.R_sqrt.sqrt x)). +Definition le_f64 (x:f64) (y:f64): Prop := ((le_f64b x y) = true). (* Why3 goal *) -Definition model: R -> R. +Lemma le_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((le_f32 x y) <-> ((of_f32 x) <= (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma le_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((le_f64 x y) <-> ((of_f64 x) <= (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition lt_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition lt_f64b: f64 -> f64 -> bool. Admitted. (* Why3 assumption *) -Definition delta (x:R): R := (Reals.Rbasic_fun.Rabs (x - (model x))%R). +Definition lt_f32 (x:f32) (y:f32): Prop := ((lt_f32b x y) = true). (* Why3 assumption *) -Definition error (x:R): R := - ((delta x) / (Reals.Rbasic_fun.Rabs (model x)))%R. +Definition lt_f64 (x:f64) (y:f64): Prop := ((lt_f64b x y) = true). + +(* Why3 goal *) +Lemma lt_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((lt_f32 x y) <-> ((of_f32 x) < (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma lt_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((lt_f64 x y) <-> ((of_f64 x) < (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition neg_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition neg_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((of_f32 (neg_f32 x)) = (-(of_f32 x))%R). +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((of_f64 (neg_f64 x)) = (-(of_f64 x))%R). +Admitted. + +(* Why3 goal *) +Definition add_f32: f32 -> f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition add_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma add_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((add_f32 x + y) = (to_f32 ((of_f32 x) + (of_f32 y))%R))). +Admitted. (* Why3 goal *) -Lemma model_float_32 : forall (x:R), ((model (to_float32 x)) = (model x)). +Lemma add_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((add_f64 x + y) = (to_f64 ((of_f64 x) + (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_float_64 : forall (x:R), ((model (to_float64 x)) = (model x)). +Definition mul_f32: f32 -> f32 -> f32. Admitted. (* Why3 goal *) -Lemma model_add : forall (x:R) (y:R), - ((model (x + y)%R) = ((model x) + (model y))%R). +Definition mul_f64: f64 -> f64 -> f64. Admitted. (* Why3 goal *) -Lemma model_mul : forall (x:R) (y:R), - ((model (x * y)%R) = ((model x) * (model y))%R). +Lemma mul_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((mul_f32 x + y) = (to_f32 ((of_f32 x) * (of_f32 y))%R))). Admitted. (* Why3 goal *) -Lemma model_div : forall (x:R) (y:R), - ((model (x / y)%R) = ((model x) / (model y))%R). +Lemma mul_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((mul_f64 x + y) = (to_f64 ((of_f64 x) * (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_sqrt : forall (x:R), - ((model (Reals.R_sqrt.sqrt x)) = (Reals.R_sqrt.sqrt (model x))). +Definition div_f32: f32 -> f32 -> f32. Admitted. +(* Why3 goal *) +Definition div_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma div_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((div_f32 x + y) = (to_f32 ((of_f32 x) / (of_f32 y))%R))). +Admitted. + +(* Why3 goal *) +Lemma div_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((div_f64 x + y) = (to_f64 ((of_f64 x) / (of_f64 y))%R))). +Admitted. + +(* Why3 goal *) +Definition sqrt_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition sqrt_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((sqrt_f32 x) = (to_f32 (Reals.R_sqrt.sqrt (of_f32 x)))). +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((sqrt_f64 x) = (to_f64 (Reals.R_sqrt.sqrt (of_f64 x)))). +Admitted. + +(* Why3 goal *) +Definition model_f32: f32 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f32 (f:f32): R := + (Reals.Rbasic_fun.Rabs ((of_f32 f) - (model_f32 f))%R). + +(* Why3 assumption *) +Definition error_f32 (f:f32): R := + ((delta_f32 f) / (Reals.Rbasic_fun.Rabs (model_f32 f)))%R. + +(* Why3 goal *) +Definition model_f64: f64 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f64 (f:f64): R := + (Reals.Rbasic_fun.Rabs ((of_f64 f) - (model_f64 f))%R). + +(* Why3 assumption *) +Definition error_f64 (f:f64): R := + ((delta_f64 f) / (Reals.Rbasic_fun.Rabs (model_f64 f)))%R. + diff --git a/src/plugins/wp/share/src/cfloat.why b/src/plugins/wp/share/src/cfloat.why index 718a16a45d89854e89b0109a043b08107374a072..711a803b32eab70a51cc93d9f5d22534c97c7c4f 100644 --- a/src/plugins/wp/share/src/cfloat.why +++ b/src/plugins/wp/share/src/cfloat.why @@ -26,6 +26,7 @@ theory Cfloat + use import bool.Bool use import real.RealInfix use import real.Abs use import real.Square @@ -34,140 +35,184 @@ theory Cfloat (* --- C-Integer Arithmetics for Alt-Ergo --- *) (* -------------------------------------------------------------------------- *) + type f32 (* single precision IEEE *) + type f64 (* double precision IEEE *) + (* C-Float Conversion *) - function to_float32 real : real - function to_float64 real : real - predicate is_float32 (x : real) = to_float32(x)=x - predicate is_float64 (x : real) = to_float64(x)=x + function to_f32 real : f32 + function of_f32 f32 : real + + function to_f64 real : f64 + function of_f64 f64 : real (* C-Float Rounding Modes *) type rounding_mode = Up | Down | ToZero | NearestTiesToAway | NearestTiesToEven - function round_double rounding_mode real : real - function round_float rounding_mode real : real + + function round_float rounding_mode real : f32 + function round_double rounding_mode real : f64 axiom float_32: forall x:real [ round_float NearestTiesToEven x ]. - to_float32 x = round_float NearestTiesToEven x + to_f32 x = round_float NearestTiesToEven x axiom float_64: forall x:real [ round_double NearestTiesToEven x ]. - to_float64 x = round_double NearestTiesToEven x + to_f64 x = round_double NearestTiesToEven x (* C-Float Classification *) - type float_kind = Real | Float32 | Float64 | NaN | Inf_pos | Inf_neg + type float_kind = Finite | NaN | Inf_pos | Inf_neg + + function classify_f32 f32 : float_kind + function classify_f64 f64 : float_kind + + predicate is_finite_f32 (f:f32) = (classify_f32 f = Finite) + predicate is_finite_f64 (d:f64) = (classify_f64 d = Finite) + + predicate is_NaN_f32 (f:f32) = (classify_f32 f = NaN) + predicate is_NaN_f64 (d:f64) = (classify_f64 d = NaN) - function classify_float real : float_kind - predicate is_finite32(x:real) = classify_float x = Float32 - predicate is_finite64(x:real) = classify_float(x) = Float32 || - classify_float(x) = Float64 - predicate is_NaN(x:real) = classify_float(x) = NaN - predicate is_infinite(x:real) = classify_float(x) = Inf_pos || - classify_float(x) = Inf_neg - predicate is_positive_infinite(x:real) = classify_float(x) = Inf_pos - predicate is_negative_infinite(x:real) = classify_float(x) = Inf_neg + predicate is_infinite_f32 (f:f32) = (classify_f32 f = Inf_pos || classify_f32 f = Inf_neg) + predicate is_infinite_f64 (d:f64) = (classify_f64 d = Inf_pos || classify_f64 d = Inf_neg) + + predicate is_positive_infinite_f32 (f:f32) = (classify_f32 f = Inf_pos) + predicate is_positive_infinite_f64 (d:f64) = (classify_f64 d = Inf_pos) + + predicate is_negative_infinite_f32 (f:f32) = (classify_f32 f = Inf_neg) + predicate is_negative_infinite_f64 (d:f64) = (classify_f64 d = Inf_neg) axiom is_finite_to_float_32 : - forall x:real [is_finite32(to_float32 x)]. is_finite32(to_float32 x) + forall x:real [is_finite_f32(to_f32 x)]. is_finite_f32 (to_f32 x) axiom is_finite_to_float_64 : - forall x:real [is_finite64(to_float64 x)]. is_finite64(to_float64 x) + forall x:real [is_finite_f64(to_f64 x)]. is_finite_f64 (to_f64 x) - (* C-Float Rounded Arithmetics *) + axiom to_float_is_finite_32 : + forall f:f32 [ to_f32( of_f32 f ) | is_finite_f32(f) ]. is_finite_f32(f) -> to_f32( of_f32 f ) = f - function add_float32 (x:real)(y:real) : real = to_float32 (x +. y) - function add_float64 (x:real)(y:real) : real = to_float64 (x +. y) + axiom to_float_is_finite_64 : + forall d:f64 [ to_f64( of_f64 d ) | is_finite_f64(d) ]. is_finite_f64(d) -> to_f64( of_f64 d ) = d - function mul_float32 (x:real)(y:real) : real = to_float32 (x *. y) - function mul_float64 (x:real)(y:real) : real = to_float64 (x *. y) + (* Finite Constants *) - function div_float32 (x:real)(y:real) : real = to_float32 (x /. y) - function div_float64 (x:real)(y:real) : real = to_float64 (x /. y) + predicate finite (x:real) = (is_finite_f32 (to_f32 x)) /\ (is_finite_f64 (to_f64 x)) - function sqrt_float32 (x:real) : real = to_float32(sqrt x) - function sqrt_float64 (x:real) : real = to_float64(sqrt x) + constant max_f32 : real = 340282346600000016151267322115014000640.0 + constant max_f64 : real = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 - function model real : real - function delta(x:real) : real = abs( x -. model x ) - function error(x:real) : real = delta(x) /. abs(model x) + axiom finite_small_f32 : forall x:real. -. max_f64 <=. x <=. max_f32 -> is_finite_f32(to_f32 x) + axiom finite_small_f64 : forall x:real. -. max_f64 <=. x <=. max_f64 -> is_finite_f64(to_f64 x) + axiom finite_range_f32 : forall f:f32. is_finite_f32(f) <-> -. max_f32 <=. of_f32 f <=. max_f32 + axiom finite_range_f64 : forall d:f64. is_finite_f64(d) <-> -. max_f64 <=. of_f64 d <=. max_f64 - axiom model_float_32: forall x:real. model(to_float32 x) = model x - axiom model_float_64: forall x:real. model(to_float64 x) = model x - axiom model_add: forall x y:real. model (x +. y) = model x +. model y - axiom model_mul: forall x y:real. model (x *. y) = model x *. model y - axiom model_div: forall x y:real. model (x /. y) = model x /. model y - axiom model_sqrt: forall x:real. model (sqrt x) = sqrt(model(x)) + (* Equal *) + function eq_f32b (x:f32) (y:f32) : bool + function eq_f64b (x:f64) (y:f64) : bool + predicate eq_f32 (x:f32) (y:f32) = (eq_f32b x y = true) + predicate eq_f64 (x:f64) (y:f64) = (eq_f64b x y = true) -end + axiom eq_finite_f32 : forall x,y:f32 [eq_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + eq_f32 x y <-> of_f32 x = of_f32 y -(** Realization using why3 floats *) + axiom eq_finite_f64 : forall x,y:f64 [eq_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + eq_f64 x y <-> of_f64 x = of_f64 y -(* - (* C-Float IEEE-754 *) + (* Not Equal *) - use export floating_point.Rounding - use import floating_point.Single - use import floating_point.Double + function ne_f32b (x:f32) (y:f32) : bool + function ne_f64b (x:f64) (y:f64) : bool + predicate ne_f32 (x:f32) (y:f32) = (ne_f32b x y = true) + predicate ne_f64 (x:f64) (y:f64) = (ne_f64b x y = true) - type rounding_mode = Rounding.mode + axiom ne_finite_f32 : forall x,y:f32 [ne_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + ne_f32 x y <-> of_f32 x <> of_f32 y - function round_float (m:rounding_mode) (x:real) : real = Single.round m x - function round_double (m:rounding_mode) (x:real) : real = Double.round m x + axiom ne_finite_f64 : forall x,y:f64 [ne_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + ne_f64 x y <-> of_f64 x <> of_f64 y + (* Comparison (<=) *) - (* C-Float Conversion *) + function le_f32b (x:f32) (y:f32) : bool + function le_f64b (x:f64) (y:f64) : bool + predicate le_f32 (x:f32) (y:f32) = (le_f32b x y = true) + predicate le_f64 (x:f64) (y:f64) = (le_f64b x y = true) - function to_float32 (x:real) : real = Single.round NearestTiesToEven x - function to_float64 (x:real) : real = Double.round NearestTiesToEven x + axiom le_finite_f32 : forall x,y:f32 [le_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + le_f32 x y <-> of_f32 x <=. of_f32 y - predicate is_float32 real - predicate is_float64 real + axiom le_finite_f64 : forall x,y:f64 [le_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + le_f64 x y <-> of_f64 x <=. of_f64 y + (* Comparison (<) *) - axiom def_float32: forall x:real [ is_float32(x) ]. is_float32 x -> to_float32 x = x - axiom def_float64: forall x:real [ is_float64(x) ]. is_float64 x -> to_float64 x = x + function lt_f32b (x:f32) (y:f32) : bool + function lt_f64b (x:f64) (y:f64) : bool + predicate lt_f32 (x:f32) (y:f32) = (lt_f32b x y = true) + predicate lt_f64 (x:f64) (y:f64) = (lt_f64b x y = true) - predicate is_finite32 (x:real) = abs(x) <=. Single.max_single - predicate is_finite64 (x:real) = abs(x) <=. Double.max_double + axiom lt_finite_f32 : forall x,y:f32 [lt_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + lt_f32 x y <-> of_f32 x <. of_f32 y - axiom is_finite_to_float_32 : - forall x:real [is_finite32(to_float32 x)]. is_finite32(to_float32 x) + axiom lt_finite_f64 : forall x,y:f64 [lt_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + lt_f64 x y <-> of_f64 x <. of_f64 y - axiom is_finite_to_float_64 : - forall x:real [is_finite64(to_float64 x)]. is_finite64(to_float64 x) + (* Negation *) + + + function neg_f32 (x:f32) : f32 + function neg_f64 (x:f64) : f64 + + axiom neg_finite_f32 : forall x:f32 [neg_f32 x]. is_finite_f32 x -> of_f32 (neg_f32 x) = -. (of_f32 x) + axiom neg_finite_f64 : forall x:f64 [neg_f64 x]. is_finite_f64 x -> of_f64 (neg_f64 x) = -. (of_f64 x) + + (* Addition *) - (* C-Float Conversions are projections *) + function add_f32 (x:f32) (y:f32) : f32 + function add_f64 (x:f64) (y:f64) : f64 - axiom proj_float32 : forall x:real [ to_float32(to_float32 x) ]. to_float32(to_float32 x)=to_float32 x - axiom proj_float64 : forall x:real [ to_float64(to_float64 x) ]. to_float64(to_float64 x)=to_float64 x + axiom add_finite_f32 : forall x,y:f32 [add_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + add_f32 x y = to_f32 (of_f32 x +. of_f32 y) - (* C-Float Arithemtics *) + axiom add_finite_f64 : forall x,y:f64 [add_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + add_f64 x y = to_f64 (of_f64 x +. of_f64 y) + (* Multiplication *) - function add_float32(x:real)(y:real):real = to_float32(x +. y) - function add_float64(x:real)(y:real):real = to_float64(x +. y) + function mul_f32 (x:f32) (y:f32) : f32 + function mul_f64 (x:f64) (y:f64) : f64 - function mul_float32(x:real)(y:real):real = to_float32(x *. y) - function mul_float64(x:real)(y:real):real = to_float64(x *. y) + axiom mul_finite_f32 : forall x,y:f32 [mul_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + mul_f32 x y = to_f32 (of_f32 x *. of_f32 y) - function div_float32(x:real)(y:real):real = to_float32(x /. y) - function div_float64(x:real)(y:real):real = to_float64(x /. y) + axiom mul_finite_f64 : forall x,y:f64 [mul_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + mul_f64 x y = to_f64 (of_f64 x *. of_f64 y) + (* Division *) - function sqrt_float32(x:real):real = to_float32(sqrt x) - function sqrt_float64(x:real):real = to_float64(sqrt x) + function div_f32 (x:f32) (y:f32) : f32 + function div_f64 (x:f64) (y:f64) : f64 - (* C-Float Precision *) + axiom div_finite_f32 : forall x,y:f32 [div_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + div_f32 x y = to_f32 (of_f32 x /. of_f32 y) - function model real : real - function delta (x:real) : real = abs ( x -. (model x) ) - function error (x:real) : real = (delta x) /. (abs (model x)) + axiom div_finite_f64 : forall x,y:f64 [div_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + div_f64 x y = to_f64 (of_f64 x /. of_f64 y) - axiom model_float_32: forall x:real. model(to_float32 x) = model x - axiom model_float_64: forall x:real. model(to_float64 x) = model x - axiom model_add: forall x y:real. model(x +. y) = model x +. model y - axiom model_mul: forall x y:real. model(x *. y) = model x *. model y - axiom model_div: forall x y:real. model(x /. y) = model x /. model y - axiom model_sqrt: forall x:real. model(sqrt(x)) = sqrt(model x) + (* Square Root *) + function sqrt_f32 f32 : f32 + function sqrt_f64 f64 : f64 -*) + axiom sqrt_finite_f32 : forall x:f32 [sqrt_f32 x]. is_finite_f32 x -> sqrt_f32 x = to_f32 (sqrt (of_f32 x)) + axiom sqrt_finite_f64 : forall x:f64 [sqrt_f64 x]. is_finite_f64 x -> sqrt_f64 x = to_f64 (sqrt (of_f64 x)) + + (* Models *) + + function model_f32 (f:f32) : real + function delta_f32 (f:f32) : real = abs( of_f32 f -. model_f32 f ) + function error_f32 (f:f32) : real = (delta_f32 f) /. (abs (model_f32 f)) + + function model_f64 (f:f64) : real + function delta_f64 (f:f64) : real = abs( of_f64 f -. model_f64 f ) + function error_f64 (f:f64) : real = (delta_f64 f) /. (abs (model_f64 f)) + +end diff --git a/src/plugins/wp/share/why3/Cfloat.v b/src/plugins/wp/share/why3/Cfloat.v index 0b7666721938c60d6a21bf9c9fda4a28ecd4b6c6..fd245b87bfb945f92a72fc968f38f392fd83c6b4 100644 --- a/src/plugins/wp/share/why3/Cfloat.v +++ b/src/plugins/wp/share/why3/Cfloat.v @@ -26,24 +26,35 @@ Require Import BuiltIn. Require Reals.Rbasic_fun. Require Reals.R_sqrt. Require BuiltIn. +Require bool.Bool. Require real.Real. Require real.RealInfix. Require real.Abs. Require real.Square. (* Why3 goal *) -Definition to_float32: R -> R. +Definition f32 : Type. Admitted. (* Why3 goal *) -Definition to_float64: R -> R. +Definition f64 : Type. Admitted. -(* Why3 assumption *) -Definition is_float32 (x:R): Prop := ((to_float32 x) = x). +(* Why3 goal *) +Definition to_f32: R -> f32. +Admitted. -(* Why3 assumption *) -Definition is_float64 (x:R): Prop := ((to_float64 x) = x). +(* Why3 goal *) +Definition of_f32: f32 -> R. +Admitted. + +(* Why3 goal *) +Definition to_f64: R -> f64. +Admitted. + +(* Why3 goal *) +Definition of_f64: f64 -> R. +Admitted. (* Why3 assumption *) Inductive rounding_mode := @@ -56,28 +67,26 @@ Axiom rounding_mode_WhyType : WhyType rounding_mode. Existing Instance rounding_mode_WhyType. (* Why3 goal *) -Definition round_double: rounding_mode -> R -> R. +Definition round_float: rounding_mode -> R -> f32. Admitted. (* Why3 goal *) -Definition round_float: rounding_mode -> R -> R. +Definition round_double: rounding_mode -> R -> f64. Admitted. (* Why3 goal *) -Lemma float_32 : forall (x:R), - ((to_float32 x) = (round_float NearestTiesToEven x)). +Lemma float_32 : forall (x:R), ((to_f32 x) = (round_float NearestTiesToEven + x)). Admitted. (* Why3 goal *) -Lemma float_64 : forall (x:R), - ((to_float64 x) = (round_double NearestTiesToEven x)). +Lemma float_64 : forall (x:R), ((to_f64 x) = (round_double NearestTiesToEven + x)). Admitted. (* Why3 assumption *) Inductive float_kind := - | Real : float_kind - | Float32 : float_kind - | Float64 : float_kind + | Finite : float_kind | NaN : float_kind | Inf_pos : float_kind | Inf_neg : float_kind. @@ -85,99 +94,310 @@ Axiom float_kind_WhyType : WhyType float_kind. Existing Instance float_kind_WhyType. (* Why3 goal *) -Definition classify_float: R -> float_kind. +Definition classify_f32: f32 -> float_kind. Admitted. +(* Why3 goal *) +Definition classify_f64: f64 -> float_kind. +Admitted. + +(* Why3 assumption *) +Definition is_finite_f32 (f:f32): Prop := ((classify_f32 f) = Finite). + +(* Why3 assumption *) +Definition is_finite_f64 (d:f64): Prop := ((classify_f64 d) = Finite). + +(* Why3 assumption *) +Definition is_NaN_f32 (f:f32): Prop := ((classify_f32 f) = NaN). + +(* Why3 assumption *) +Definition is_NaN_f64 (d:f64): Prop := ((classify_f64 d) = NaN). + (* Why3 assumption *) -Definition is_finite32 (x:R): Prop := ((classify_float x) = Float32). +Definition is_infinite_f32 (f:f32): Prop := ((classify_f32 f) = Inf_pos) \/ + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_finite64 (x:R): Prop := ((classify_float x) = Float32) \/ - ((classify_float x) = Float64). +Definition is_infinite_f64 (d:f64): Prop := ((classify_f64 d) = Inf_pos) \/ + ((classify_f64 d) = Inf_neg). (* Why3 assumption *) -Definition is_NaN (x:R): Prop := ((classify_float x) = NaN). +Definition is_positive_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_pos). (* Why3 assumption *) -Definition is_infinite (x:R): Prop := ((classify_float x) = Inf_pos) \/ - ((classify_float x) = Inf_neg). +Definition is_positive_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_pos). (* Why3 assumption *) -Definition is_positive_infinite (x:R): Prop := - ((classify_float x) = Inf_pos). +Definition is_negative_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_negative_infinite (x:R): Prop := - ((classify_float x) = Inf_neg). +Definition is_negative_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_neg). (* Why3 goal *) -Lemma is_finite_to_float_32 : forall (x:R), (is_finite32 (to_float32 x)). +Lemma is_finite_to_float_32 : forall (x:R), (is_finite_f32 (to_f32 x)). Admitted. (* Why3 goal *) -Lemma is_finite_to_float_64 : forall (x:R), (is_finite64 (to_float64 x)). +Lemma is_finite_to_float_64 : forall (x:R), (is_finite_f64 (to_f64 x)). Admitted. -(* Why3 assumption *) -Definition add_float32 (x:R) (y:R): R := (to_float32 (x + y)%R). +(* Why3 goal *) +Lemma to_float_is_finite_32 : forall (f:f32), (is_finite_f32 f) -> + ((to_f32 (of_f32 f)) = f). +Admitted. + +(* Why3 goal *) +Lemma to_float_is_finite_64 : forall (d:f64), (is_finite_f64 d) -> + ((to_f64 (of_f64 d)) = d). +Admitted. (* Why3 assumption *) -Definition add_float64 (x:R) (y:R): R := (to_float64 (x + y)%R). +Definition finite (x:R): Prop := (is_finite_f32 (to_f32 x)) /\ (is_finite_f64 + (to_f64 x)). + +(* Why3 goal *) +Lemma finite_small_f32 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 340282346600000016151267322115014000640%R)%R) -> (is_finite_f32 + (to_f32 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_small_f64 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R) -> + (is_finite_f64 (to_f64 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f32 : forall (f:f32), (is_finite_f32 f) <-> + (((-340282346600000016151267322115014000640%R)%R <= (of_f32 f))%R /\ + ((of_f32 f) <= 340282346600000016151267322115014000640%R)%R). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f64 : forall (d:f64), (is_finite_f64 d) <-> + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= (of_f64 d))%R /\ + ((of_f64 d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R). +Admitted. + +(* Why3 goal *) +Definition eq_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition eq_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition mul_float32 (x:R) (y:R): R := (to_float32 (x * y)%R). +Definition eq_f32 (x:f32) (y:f32): Prop := ((eq_f32b x y) = true). (* Why3 assumption *) -Definition mul_float64 (x:R) (y:R): R := (to_float64 (x * y)%R). +Definition eq_f64 (x:f64) (y:f64): Prop := ((eq_f64b x y) = true). + +(* Why3 goal *) +Lemma eq_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((eq_f32 x y) <-> ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma eq_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((eq_f64 x y) <-> ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition ne_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition ne_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition div_float32 (x:R) (y:R): R := (to_float32 (x / y)%R). +Definition ne_f32 (x:f32) (y:f32): Prop := ((ne_f32b x y) = true). (* Why3 assumption *) -Definition div_float64 (x:R) (y:R): R := (to_float64 (x / y)%R). +Definition ne_f64 (x:f64) (y:f64): Prop := ((ne_f64b x y) = true). + +(* Why3 goal *) +Lemma ne_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((ne_f32 x y) <-> ~ ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma ne_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((ne_f64 x y) <-> ~ ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition le_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition le_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition sqrt_float32 (x:R): R := (to_float32 (Reals.R_sqrt.sqrt x)). +Definition le_f32 (x:f32) (y:f32): Prop := ((le_f32b x y) = true). (* Why3 assumption *) -Definition sqrt_float64 (x:R): R := (to_float64 (Reals.R_sqrt.sqrt x)). +Definition le_f64 (x:f64) (y:f64): Prop := ((le_f64b x y) = true). (* Why3 goal *) -Definition model: R -> R. +Lemma le_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((le_f32 x y) <-> ((of_f32 x) <= (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma le_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((le_f64 x y) <-> ((of_f64 x) <= (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition lt_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition lt_f64b: f64 -> f64 -> bool. Admitted. (* Why3 assumption *) -Definition delta (x:R): R := (Reals.Rbasic_fun.Rabs (x - (model x))%R). +Definition lt_f32 (x:f32) (y:f32): Prop := ((lt_f32b x y) = true). (* Why3 assumption *) -Definition error (x:R): R := - ((delta x) / (Reals.Rbasic_fun.Rabs (model x)))%R. +Definition lt_f64 (x:f64) (y:f64): Prop := ((lt_f64b x y) = true). + +(* Why3 goal *) +Lemma lt_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((lt_f32 x y) <-> ((of_f32 x) < (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma lt_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((lt_f64 x y) <-> ((of_f64 x) < (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition neg_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition neg_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((of_f32 (neg_f32 x)) = (-(of_f32 x))%R). +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((of_f64 (neg_f64 x)) = (-(of_f64 x))%R). +Admitted. + +(* Why3 goal *) +Definition add_f32: f32 -> f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition add_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma add_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((add_f32 x + y) = (to_f32 ((of_f32 x) + (of_f32 y))%R))). +Admitted. (* Why3 goal *) -Lemma model_float_32 : forall (x:R), ((model (to_float32 x)) = (model x)). +Lemma add_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((add_f64 x + y) = (to_f64 ((of_f64 x) + (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_float_64 : forall (x:R), ((model (to_float64 x)) = (model x)). +Definition mul_f32: f32 -> f32 -> f32. Admitted. (* Why3 goal *) -Lemma model_add : forall (x:R) (y:R), - ((model (x + y)%R) = ((model x) + (model y))%R). +Definition mul_f64: f64 -> f64 -> f64. Admitted. (* Why3 goal *) -Lemma model_mul : forall (x:R) (y:R), - ((model (x * y)%R) = ((model x) * (model y))%R). +Lemma mul_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((mul_f32 x + y) = (to_f32 ((of_f32 x) * (of_f32 y))%R))). Admitted. (* Why3 goal *) -Lemma model_div : forall (x:R) (y:R), - ((model (x / y)%R) = ((model x) / (model y))%R). +Lemma mul_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((mul_f64 x + y) = (to_f64 ((of_f64 x) * (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_sqrt : forall (x:R), - ((model (Reals.R_sqrt.sqrt x)) = (Reals.R_sqrt.sqrt (model x))). +Definition div_f32: f32 -> f32 -> f32. Admitted. +(* Why3 goal *) +Definition div_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma div_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((div_f32 x + y) = (to_f32 ((of_f32 x) / (of_f32 y))%R))). +Admitted. + +(* Why3 goal *) +Lemma div_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((div_f64 x + y) = (to_f64 ((of_f64 x) / (of_f64 y))%R))). +Admitted. + +(* Why3 goal *) +Definition sqrt_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition sqrt_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((sqrt_f32 x) = (to_f32 (Reals.R_sqrt.sqrt (of_f32 x)))). +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((sqrt_f64 x) = (to_f64 (Reals.R_sqrt.sqrt (of_f64 x)))). +Admitted. + +(* Why3 goal *) +Definition model_f32: f32 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f32 (f:f32): R := + (Reals.Rbasic_fun.Rabs ((of_f32 f) - (model_f32 f))%R). + +(* Why3 assumption *) +Definition error_f32 (f:f32): R := + ((delta_f32 f) / (Reals.Rbasic_fun.Rabs (model_f32 f)))%R. + +(* Why3 goal *) +Definition model_f64: f64 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f64 (f:f64): R := + (Reals.Rbasic_fun.Rabs ((of_f64 f) - (model_f64 f))%R). + +(* Why3 assumption *) +Definition error_f64 (f:f64): R := + ((delta_f64 f) / (Reals.Rbasic_fun.Rabs (model_f64 f)))%R. + diff --git a/src/plugins/wp/share/why3/Cfloat.why b/src/plugins/wp/share/why3/Cfloat.why index c9f00f51c5f5c6fc749708f962605f061d39d436..91baa7e38d97daab5d8e31a315e87f2486a4fe46 100644 --- a/src/plugins/wp/share/why3/Cfloat.why +++ b/src/plugins/wp/share/why3/Cfloat.why @@ -21,17 +21,22 @@ (**************************************************************************) theory Cfloat +use bool.Bool as Bool use real.Real as Real use real.Abs as Abs use real.Square as Square -function to_float32 real : real +type f32 -function to_float64 real : real +type f64 -predicate is_float32 (x:real) = ((to_float32 x) = (x)) +function to_f32 real : f32 -predicate is_float64 (x:real) = ((to_float64 x) = (x)) +function of_f32 f32 : real + +function to_f64 real : f64 + +function of_f64 f64 : real type rounding_mode = | Up @@ -40,82 +45,210 @@ type rounding_mode = | NearestTiesToAway | NearestTiesToEven -function round_double rounding_mode real : real +function round_float rounding_mode real : f32 -function round_float rounding_mode real : real +function round_double rounding_mode real : f64 -axiom float_32 : forall x:real [round_float NearestTiesToEven x]. - ((to_float32 x) = (round_float NearestTiesToEven x)) +axiom float_32 : forall x:real [round_float NearestTiesToEven x]. ((to_f32 + x) = (round_float NearestTiesToEven x)) -axiom float_64 : forall x:real [round_double NearestTiesToEven x]. - ((to_float64 x) = (round_double NearestTiesToEven x)) +axiom float_64 : forall x:real [round_double NearestTiesToEven x]. ((to_f64 + x) = (round_double NearestTiesToEven x)) type float_kind = - | Real - | Float32 - | Float64 + | Finite | NaN | Inf_pos | Inf_neg -function classify_float real : float_kind +function classify_f32 f32 : float_kind + +function classify_f64 f64 : float_kind + +predicate is_finite_f32 (f:f32) = ((classify_f32 f) = (Finite)) + +predicate is_finite_f64 (d:f64) = ((classify_f64 d) = (Finite)) + +predicate is_NaN_f32 (f:f32) = ((classify_f32 f) = (NaN)) + +predicate is_NaN_f64 (d:f64) = ((classify_f64 d) = (NaN)) + +predicate is_infinite_f32 (f:f32) = ("asym_split" ((classify_f32 + f) = (Inf_pos))) || ((classify_f32 f) = (Inf_neg)) + +predicate is_infinite_f64 (d:f64) = ("asym_split" ((classify_f64 + d) = (Inf_pos))) || ((classify_f64 d) = (Inf_neg)) + +predicate is_positive_infinite_f32 (f:f32) = ((classify_f32 f) = (Inf_pos)) + +predicate is_positive_infinite_f64 (d:f64) = ((classify_f64 d) = (Inf_pos)) + +predicate is_negative_infinite_f32 (f:f32) = ((classify_f32 f) = (Inf_neg)) + +predicate is_negative_infinite_f64 (d:f64) = ((classify_f64 d) = (Inf_neg)) + +axiom is_finite_to_float_32 : forall x:real [is_finite_f32 (to_f32 x)]. + is_finite_f32 (to_f32 x) + +axiom is_finite_to_float_64 : forall x:real [is_finite_f64 (to_f64 x)]. + is_finite_f64 (to_f64 x) + +axiom to_float_is_finite_32 : forall f:f32 [to_f32 (of_f32 f)| is_finite_f32 + f]. is_finite_f32 f -> ((to_f32 (of_f32 f)) = (f)) + +axiom to_float_is_finite_64 : forall d:f64 [to_f64 (of_f64 d)| is_finite_f64 + d]. is_finite_f64 d -> ((to_f64 (of_f64 d)) = (d)) + +predicate finite (x:real) = is_finite_f32 (to_f32 x) /\ is_finite_f64 (to_f64 + x) + +function max_f32 : real = 340282346600000016151267322115014000640.0 + +function max_f64 : real = + 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 + +axiom finite_small_f32 : forall x:real. + (Real.(<=) ((Real.(-_) (max_f64))) (x)) /\ (Real.(<=) (x) (max_f32)) -> + is_finite_f32 (to_f32 x) + +axiom finite_small_f64 : forall x:real. + (Real.(<=) ((Real.(-_) (max_f64))) (x)) /\ (Real.(<=) (x) (max_f64)) -> + is_finite_f64 (to_f64 x) + +axiom finite_range_f32 : forall f:f32. is_finite_f32 f <-> + (Real.(<=) ((Real.(-_) (max_f32))) (of_f32 f)) /\ (Real.(<=) (of_f32 + f) (max_f32)) + +axiom finite_range_f64 : forall d:f64. is_finite_f64 d <-> + (Real.(<=) ((Real.(-_) (max_f64))) (of_f64 d)) /\ (Real.(<=) (of_f64 + d) (max_f64)) + +function eq_f32b f32 f32 : Bool.bool + +function eq_f64b f64 f64 : Bool.bool + +predicate eq_f32 (x:f32) (y:f32) = ((eq_f32b x y) = (Bool.True)) + +predicate eq_f64 (x:f64) (y:f64) = ((eq_f64b x y) = (Bool.True)) + +axiom eq_finite_f32 : forall x:f32, y:f32 [eq_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> eq_f32 x y <-> ((of_f32 x) = (of_f32 y)) + +axiom eq_finite_f64 : forall x:f64, y:f64 [eq_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> eq_f64 x y <-> ((of_f64 x) = (of_f64 y)) + +function ne_f32b f32 f32 : Bool.bool + +function ne_f64b f64 f64 : Bool.bool + +predicate ne_f32 (x:f32) (y:f32) = ((ne_f32b x y) = (Bool.True)) + +predicate ne_f64 (x:f64) (y:f64) = ((ne_f64b x y) = (Bool.True)) + +axiom ne_finite_f32 : forall x:f32, y:f32 [ne_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> ne_f32 x y <-> not ((of_f32 x) = (of_f32 y)) + +axiom ne_finite_f64 : forall x:f64, y:f64 [ne_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> ne_f64 x y <-> not ((of_f64 x) = (of_f64 y)) + +function le_f32b f32 f32 : Bool.bool + +function le_f64b f64 f64 : Bool.bool + +predicate le_f32 (x:f32) (y:f32) = ((le_f32b x y) = (Bool.True)) + +predicate le_f64 (x:f64) (y:f64) = ((le_f64b x y) = (Bool.True)) + +axiom le_finite_f32 : forall x:f32, y:f32 [le_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> le_f32 x y <-> (Real.(<=) (of_f32 x) (of_f32 y)) + +axiom le_finite_f64 : forall x:f64, y:f64 [le_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> le_f64 x y <-> (Real.(<=) (of_f64 x) (of_f64 y)) + +function lt_f32b f32 f32 : Bool.bool + +function lt_f64b f64 f64 : Bool.bool + +predicate lt_f32 (x:f32) (y:f32) = ((lt_f32b x y) = (Bool.True)) + +predicate lt_f64 (x:f64) (y:f64) = ((lt_f64b x y) = (Bool.True)) + +axiom lt_finite_f32 : forall x:f32, y:f32 [lt_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> lt_f32 x y <-> (Real.(<) (of_f32 x) (of_f32 y)) + +axiom lt_finite_f64 : forall x:f64, y:f64 [lt_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> lt_f64 x y <-> (Real.(<) (of_f64 x) (of_f64 y)) + +function neg_f32 f32 : f32 -predicate is_finite32 (x:real) = ((classify_float x) = (Float32)) +function neg_f64 f64 : f64 -predicate is_finite64 (x:real) = ("asym_split" ((classify_float - x) = (Float32))) || ((classify_float x) = (Float64)) +axiom neg_finite_f32 : forall x:f32 [neg_f32 x]. is_finite_f32 x -> ((of_f32 + (neg_f32 x)) = ((Real.(-_) (of_f32 x)))) -predicate is_NaN (x:real) = ((classify_float x) = (NaN)) +axiom neg_finite_f64 : forall x:f64 [neg_f64 x]. is_finite_f64 x -> ((of_f64 + (neg_f64 x)) = ((Real.(-_) (of_f64 x)))) -predicate is_infinite (x:real) = ("asym_split" ((classify_float - x) = (Inf_pos))) || ((classify_float x) = (Inf_neg)) +function add_f32 f32 f32 : f32 -predicate is_positive_infinite (x:real) = ((classify_float x) = (Inf_pos)) +function add_f64 f64 f64 : f64 -predicate is_negative_infinite (x:real) = ((classify_float x) = (Inf_neg)) +axiom add_finite_f32 : forall x:f32, y:f32 [add_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> ((add_f32 x y) = (to_f32 (Real.(+) (of_f32 x) (of_f32 + y)))) -axiom is_finite_to_float_32 : forall x:real [is_finite32 (to_float32 x)]. - is_finite32 (to_float32 x) +axiom add_finite_f64 : forall x:f64, y:f64 [add_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> ((add_f64 x y) = (to_f64 (Real.(+) (of_f64 x) (of_f64 + y)))) -axiom is_finite_to_float_64 : forall x:real [is_finite64 (to_float64 x)]. - is_finite64 (to_float64 x) +function mul_f32 f32 f32 : f32 -function add_float32 (x:real) (y:real) : real = to_float32 (Real.(+) (x) (y)) +function mul_f64 f64 f64 : f64 -function add_float64 (x:real) (y:real) : real = to_float64 (Real.(+) (x) (y)) +axiom mul_finite_f32 : forall x:f32, y:f32 [mul_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> ((mul_f32 x y) = (to_f32 (Real.(*) (of_f32 x) (of_f32 + y)))) -function mul_float32 (x:real) (y:real) : real = to_float32 (Real.(*) (x) (y)) +axiom mul_finite_f64 : forall x:f64, y:f64 [mul_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> ((mul_f64 x y) = (to_f64 (Real.(*) (of_f64 x) (of_f64 + y)))) -function mul_float64 (x:real) (y:real) : real = to_float64 (Real.(*) (x) (y)) +function div_f32 f32 f32 : f32 -function div_float32 (x:real) (y:real) : real = to_float32 (Real.(/) (x) (y)) +function div_f64 f64 f64 : f64 -function div_float64 (x:real) (y:real) : real = to_float64 (Real.(/) (x) (y)) +axiom div_finite_f32 : forall x:f32, y:f32 [div_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> ((div_f32 x y) = (to_f32 (Real.(/) (of_f32 x) (of_f32 + y)))) -function sqrt_float32 (x:real) : real = to_float32 (Square.sqrt x) +axiom div_finite_f64 : forall x:f64, y:f64 [div_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> ((div_f64 x y) = (to_f64 (Real.(/) (of_f64 x) (of_f64 + y)))) -function sqrt_float64 (x:real) : real = to_float64 (Square.sqrt x) +function sqrt_f32 f32 : f32 -function model real : real +function sqrt_f64 f64 : f64 -function delta (x:real) : real = Abs.abs (Real.(-) (x) (model x)) +axiom sqrt_finite_f32 : forall x:f32 [sqrt_f32 x]. is_finite_f32 x -> + ((sqrt_f32 x) = (to_f32 (Square.sqrt (of_f32 x)))) -function error (x:real) : real = (Real.(/) (delta x) (Abs.abs (model x))) +axiom sqrt_finite_f64 : forall x:f64 [sqrt_f64 x]. is_finite_f64 x -> + ((sqrt_f64 x) = (to_f64 (Square.sqrt (of_f64 x)))) -axiom model_float_32 : forall x:real. ((model (to_float32 x)) = (model x)) +function model_f32 f32 : real -axiom model_float_64 : forall x:real. ((model (to_float64 x)) = (model x)) +function delta_f32 (f:f32) : real = Abs.abs (Real.(-) (of_f32 f) (model_f32 + f)) -axiom model_add : forall x:real, y:real. ((model - (Real.(+) (x) (y))) = ((Real.(+) (model x) (model y)))) +function error_f32 (f:f32) : real = (Real.(/) (delta_f32 f) (Abs.abs + (model_f32 f))) -axiom model_mul : forall x:real, y:real. ((model - (Real.(*) (x) (y))) = ((Real.(*) (model x) (model y)))) +function model_f64 f64 : real -axiom model_div : forall x:real, y:real. ((model - (Real.(/) (x) (y))) = ((Real.(/) (model x) (model y)))) +function delta_f64 (f:f64) : real = Abs.abs (Real.(-) (of_f64 f) (model_f64 + f)) -axiom model_sqrt : forall x:real. ((model (Square.sqrt x)) = (Square.sqrt - (model x))) +function error_f64 (f:f64) : real = (Real.(/) (delta_f64 f) (Abs.abs + (model_f64 f))) end diff --git a/src/plugins/wp/share/wp.driver b/src/plugins/wp/share/wp.driver index 8e5056482a5df61dd216775890657cf170601b3f..7dd358acc6900842611fed12bc90a0c096eaa60c 100644 --- a/src/plugins/wp/share/wp.driver +++ b/src/plugins/wp/share/wp.driver @@ -95,16 +95,16 @@ ctor "\\Down"() = "Down"; ctor "\\ToZero"() = "ToZero"; ctor "\\NearestAway"() = "NearestTiesToAway"; ctor "\\NearestEven"() = "NearestTiesToEven"; -predicate "\\is_finite"(float32) = "is_finite32"; -predicate "\\is_finite"(float64) = "is_finite64"; -predicate "\\is_NaN"(float32) = "is_NaN"; -predicate "\\is_NaN"(float64) = "is_NaN"; -predicate "\\is_infinite"(float32) = "is_infinite" ; -predicate "\\is_infinite"(float64) = "is_infinite" ; -predicate "\\is_plus_infinity"(float32) = "is_positive_infinite"; -predicate "\\is_plus_infinity"(float64) = "is_positive_infinite"; -predicate "\\is_minus_infinity"(float32) = "is_negative_infinite"; -predicate "\\is_minus_infinity"(float64) = "is_negative_infinite"; +predicate "\\is_finite"(float32) = "is_finite_f32"; +predicate "\\is_finite"(float64) = "is_finite_f64"; +predicate "\\is_NaN"(float32) = "is_NaN_f32"; +predicate "\\is_NaN"(float64) = "is_NaN_f64"; +predicate "\\is_infinite"(float32) = "is_infinite_f32" ; +predicate "\\is_infinite"(float64) = "is_infinite_f64" ; +predicate "\\is_plus_infinity"(float32) = "is_positive_infinite_f32"; +predicate "\\is_plus_infinity"(float64) = "is_positive_infinite_f64"; +predicate "\\is_minus_infinity"(float32) = "is_negative_infinite_f32"; +predicate "\\is_minus_infinity"(float64) = "is_negative_infinite_f64"; logic bool "\\round_float"(rounding_mode,real) = "round_float"; logic bool "\\round_double"(rounding_mode,real) = "round_double"; diff --git a/src/plugins/wp/tests/wp_acsl/classify_float.c.0.report.json b/src/plugins/wp/tests/wp_acsl/classify_float.c.0.report.json index c76558630aed65afb7c6242902488dd7ffbe763b..3414144c5e1e515b56db8688cc0889b23bb25493 100644 --- a/src/plugins/wp/tests/wp_acsl/classify_float.c.0.report.json +++ b/src/plugins/wp/tests/wp_acsl/classify_float.c.0.report.json @@ -1,26 +1,26 @@ -{ "wp:global": { "alt-ergo": { "total": 3, "valid": 3, "rank": 2 }, - "wp:main": { "total": 3, "valid": 3, "rank": 2 } }, +{ "wp:global": { "alt-ergo": { "total": 3, "valid": 3, "rank": 1 }, + "wp:main": { "total": 3, "valid": 3, "rank": 1 } }, "wp:axiomatics": { "": { "lemma_NaN_not_finite": { "alt-ergo": { "total": 1, "valid": 1, - "rank": 2 }, + "rank": 1 }, "wp:main": { "total": 1, "valid": 1, - "rank": 2 } }, + "rank": 1 } }, "lemma_InfP_not_finite": { "alt-ergo": { "total": 1, "valid": 1, - "rank": 2 }, + "rank": 1 }, "wp:main": { "total": 1, "valid": 1, - "rank": 2 } }, + "rank": 1 } }, "lemma_InfN_not_finite": { "alt-ergo": { "total": 1, "valid": 1, - "rank": 2 }, + "rank": 1 }, "wp:main": { "total": 1, "valid": 1, - "rank": 2 } }, + "rank": 1 } }, "wp:section": { "alt-ergo": { "total": 3, "valid": 3, - "rank": 2 }, + "rank": 1 }, "wp:main": { "total": 3, "valid": 3, - "rank": 2 } } } } } + "rank": 1 } } } } } diff --git a/src/plugins/wp/tests/wp_acsl/init_value.i b/src/plugins/wp/tests/wp_acsl/init_value.i index 382ae866678afdd2183fd0ef54a7f9a2e88625e0..b9d9caeabadd4510e4a64607a265906f70f4274c 100644 --- a/src/plugins/wp/tests/wp_acsl/init_value.i +++ b/src/plugins/wp/tests/wp_acsl/init_value.i @@ -1,9 +1,9 @@ /* run.config - OPT: - OPT: -main main_ko + OPT: -wp-init-const -wp-no-let + OPT: -main main_ko -wp-no-let */ /* run.config_qualif - OPT: -wp -wp-par 1 -wp-prop="-qed_ko" + OPT: -wp-init-const -wp -wp-par 1 -wp-prop="-qed_ko" OPT: -main main_ko -wp-par 1 -wp-prop qed_ko -wp-steps 50 */ @@ -11,25 +11,33 @@ /* --- GOAL: partial and complete initialization of value --- */ /* -------------------------------------------------------------------------- */ -struct S { int a; int b;}; +struct S { int a; int b;}; struct S s = {2}; int t[2] = {1}; +int t1[9+1] = {[5 ... 6]=2, [0 ... 3 ]=1 }; -struct St {int tab[10];}; +struct St {int tab[9+1];}; struct St st = {{1,2,3,4}}; -struct Sc {int a; int b[3]; int c;}; +struct Sc {int a; int b[2+1]; int c;}; struct Sc sc0 = {1,{2,3,4},5}; struct Sc sc1 = {1,2,3,4,5}; -struct Sc sc2 = {1,{2,3},4}; +struct Sc sc2 = {1,{2,3},4}; struct Sc sc3 = {1,2,3,4}; +struct Sc sq0 = {2,{2,2},2}; +struct Sc sq1 = {.b={2,2}}; + unsigned char tab[32]; -int u []; +union U { + short t[4]; + short a; + long long b; +} u = {.a=-1 }; /*@ requires qed_ok: Struct_Simple_a: s.a == 2 ; requires qed_ok: Struct_Simple_b: s.b == 0 ; @@ -44,8 +52,15 @@ int u []; requires qed_ok: Sc_c_3 : sc3.c == 0; requires qed_ok: Tab_no_init : tab[5] == 0 ; requires qed_ok: Tab_todo : \forall int i; 0 <= i <= 31 ==> tab[i] <= 255; + requires qed_ok: sq0.b[1]==2; + requires qed_ok: sq0.b[2]==0; + requires qed_ok: \forall integer i; 0 <= i <= 3 ==> t1[i] == 1; + requires qed_ok: todo: t1[4] == 0; + requires qed_ok: \forall integer i; 5 < i <= 6 ==> t1[i] == 2; + requires qed_ok: \forall integer i; 6 < i <= 9 ==> t1[i] == 0; + requires qed_ok: direct_init_union: u.a == -1; */ -void main (void){return;} +void main (int a){return;}; /*@ requires qed_ko: Sc_eq_ko : sc2 == sc3; requires qed_ko: Sc_t : sc3.b[2] == 3 ; @@ -53,6 +68,33 @@ void main (void){return;} requires qed_ko: Tab_no_init : tab[5] == 1 ; requires qed_ko: With_Array_Struct_3 : st.tab[3] == 3 ; requires qed_ko: Simple_Array_1 : t[1] == 1 ; + requires qed_ko: T1_6: t1[6] == 0; + requires qed_ko: indirect_init_union_b: u.b == 0; + requires qed_ko: indirect_init_union_t: u.t[0] == 0; */ void main_ko (void){return;} +const int ta1[5] = { [2]=1,[4]=1 }; +/*@ ensures qed_ok: ta1[0]==ta1[1] && ta1[1]==ta1[3]; + @ ensures qed_ko: ta1[4]==0; + @ ensures qed_ko: ta1[3]==1; */ +void fa1(void) {return ;} + +const int ta2[5] = { [2 ... 3]=1 }; +/*@ ensures qed_ok: ta2[0]==ta2[1] && ta2[1]==ta2[4]; + @ ensures qed_ko: ta2[4]==1; + @ ensures qed_ko: ta2[1]==1; */ +void fa2(void) {return ;} + +const int ta3[5] = { [1]=1, [3]=1}; +/*@ ensures qed_ok: ta3[0]==ta3[2] && ta1[2]==ta1[4]; + @ ensures qed_ko: ta3[0]==1; + @ ensures qed_ko: ta3[2]==1; + @ ensures qed_ko: ta2[4]==1; */ +void fa3(void) {return ;} + +const struct { int a, b, c; } ts1[4] = { [2].a=1, [2].b=1 }; +/*@ ensures qed_ok: ts1[0]==ts1[1] && ts1[1]==ts1[3] && ts1[2].a ==ts1[2].b; + @ ensures qed_ko: ts1[2].c==1; + @ ensures qed_ko: ts1[0].a==1;*/ +void fs1(void) {return ;} diff --git a/src/plugins/wp/tests/wp_acsl/init_value.i.0.report.json b/src/plugins/wp/tests/wp_acsl/init_value.i.0.report.json index c17fa6765cc6fa85a9777e245367cf448b04cbb9..577a3f779da8f885a59f3b5dc6353e0b41ac3db5 100644 --- a/src/plugins/wp/tests/wp_acsl/init_value.i.0.report.json +++ b/src/plugins/wp/tests/wp_acsl/init_value.i.0.report.json @@ -1,7 +1,48 @@ -{ "wp:global": { "alt-ergo": { "total": 3, "valid": 3, "rank": 8 }, - "qed": { "total": 10, "valid": 10 }, - "wp:main": { "total": 13, "valid": 13, "rank": 8 } }, - "wp:functions": { "main": { "main_requires_qed_ok_Tab_todo": { "alt-ergo": +{ "wp:global": { "alt-ergo": { "total": 7, "valid": 7, "rank": 29 }, + "qed": { "total": 17, "valid": 17 }, + "wp:main": { "total": 24, "valid": 24, "rank": 29 } }, + "wp:functions": { "main": { "main_requires_qed_ok_direct_init_union": + { "qed": { "total": 1, "valid": 1 }, + "wp:main": { "total": 1, "valid": 1 } }, + "main_requires_qed_ok_5": { "alt-ergo": + { "total": 1, + "valid": 1, + "rank": 2 }, + "wp:main": + { "total": 1, + "valid": 1, + "rank": 2 } }, + "main_requires_qed_ok_4": { "alt-ergo": + { "total": 1, + "valid": 1, + "rank": 2 }, + "wp:main": + { "total": 1, + "valid": 1, + "rank": 2 } }, + "main_requires_qed_ok_todo": { "qed": { "total": 1, + "valid": 1 }, + "wp:main": + { "total": 1, + "valid": 1 } }, + "main_requires_qed_ok_3": { "alt-ergo": + { "total": 1, + "valid": 1, + "rank": 2 }, + "wp:main": + { "total": 1, + "valid": 1, + "rank": 2 } }, + "main_requires_qed_ok_2": { "qed": { "total": 1, + "valid": 1 }, + "wp:main": + { "total": 1, + "valid": 1 } }, + "main_requires_qed_ok": { "qed": { "total": 1, + "valid": 1 }, + "wp:main": { "total": 1, + "valid": 1 } }, + "main_requires_qed_ok_Tab_todo": { "alt-ergo": { "total": 1, "valid": 1, "rank": 2 }, @@ -66,11 +107,47 @@ "main_requires_qed_ok_Struct_Simple_a": { "qed": { "total": 1, "valid": 1 }, "wp:main": { "total": 1, "valid": 1 } }, - "wp:section": { "alt-ergo": { "total": 3, - "valid": 3, + "wp:section": { "alt-ergo": { "total": 6, + "valid": 6, "rank": 8 }, - "qed": { "total": 10, - "valid": 10 }, - "wp:main": { "total": 13, - "valid": 13, - "rank": 8 } } } } } + "qed": { "total": 14, + "valid": 14 }, + "wp:main": { "total": 20, + "valid": 20, + "rank": 8 } } }, + "fa1": { "fa1_ensures_qed_ok": { "qed": { "total": 1, + "valid": 1 }, + "wp:main": { "total": 1, + "valid": 1 } }, + "wp:section": { "qed": { "total": 1, + "valid": 1 }, + "wp:main": { "total": 1, + "valid": 1 } } }, + "fa2": { "fa2_ensures_qed_ok": { "qed": { "total": 1, + "valid": 1 }, + "wp:main": { "total": 1, + "valid": 1 } }, + "wp:section": { "qed": { "total": 1, + "valid": 1 }, + "wp:main": { "total": 1, + "valid": 1 } } }, + "fa3": { "fa3_ensures_qed_ok": { "qed": { "total": 1, + "valid": 1 }, + "wp:main": { "total": 1, + "valid": 1 } }, + "wp:section": { "qed": { "total": 1, + "valid": 1 }, + "wp:main": { "total": 1, + "valid": 1 } } }, + "fs1": { "fs1_ensures_qed_ok": { "alt-ergo": { "total": 1, + "valid": 1, + "rank": 29 }, + "wp:main": { "total": 1, + "valid": 1, + "rank": 29 } }, + "wp:section": { "alt-ergo": { "total": 1, + "valid": 1, + "rank": 29 }, + "wp:main": { "total": 1, + "valid": 1, + "rank": 29 } } } } } diff --git a/src/plugins/wp/tests/wp_acsl/init_value.i.1.report.json b/src/plugins/wp/tests/wp_acsl/init_value.i.1.report.json index 822dac63d5b1a265e7358c45605fe58931b65e40..890d8170ecfaf478cb43e8608883a3bb550a2ed6 100644 --- a/src/plugins/wp/tests/wp_acsl/init_value.i.1.report.json +++ b/src/plugins/wp/tests/wp_acsl/init_value.i.1.report.json @@ -1,6 +1,18 @@ -{ "wp:global": { "alt-ergo": { "total": 6, "unknown": 6 }, - "wp:main": { "total": 6, "unknown": 6 } }, - "wp:functions": { "main_ko": { "main_ko_requires_qed_ko_Simple_Array_1": +{ "wp:global": { "alt-ergo": { "total": 18, "unknown": 18 }, + "wp:main": { "total": 18, "unknown": 18 } }, + "wp:functions": { "main_ko": { "main_ko_requires_qed_ko_indirect_init_union_t": + { "alt-ergo": { "total": 1, "unknown": 1 }, + "wp:main": { "total": 1, "unknown": 1 } }, + "main_ko_requires_qed_ko_indirect_init_union_b": + { "alt-ergo": { "total": 1, "unknown": 1 }, + "wp:main": { "total": 1, "unknown": 1 } }, + "main_ko_requires_qed_ko_T1_6": { "alt-ergo": + { "total": 1, + "unknown": 1 }, + "wp:main": + { "total": 1, + "unknown": 1 } }, + "main_ko_requires_qed_ko_Simple_Array_1": { "alt-ergo": { "total": 1, "unknown": 1 }, "wp:main": { "total": 1, "unknown": 1 } }, "main_ko_requires_qed_ko_With_Array_Struct_3": @@ -24,7 +36,59 @@ "main_ko_requires_qed_ko_Sc_eq_ko": { "alt-ergo": { "total": 1, "unknown": 1 }, "wp:main": { "total": 1, "unknown": 1 } }, - "wp:section": { "alt-ergo": { "total": 6, - "unknown": 6 }, - "wp:main": { "total": 6, - "unknown": 6 } } } } } + "wp:section": { "alt-ergo": { "total": 9, + "unknown": 9 }, + "wp:main": { "total": 9, + "unknown": 9 } } }, + "fa1": { "fa1_ensures_qed_ko_2": { "alt-ergo": { "total": 1, + "unknown": 1 }, + "wp:main": { "total": 1, + "unknown": 1 } }, + "fa1_ensures_qed_ko": { "alt-ergo": { "total": 1, + "unknown": 1 }, + "wp:main": { "total": 1, + "unknown": 1 } }, + "wp:section": { "alt-ergo": { "total": 2, + "unknown": 2 }, + "wp:main": { "total": 2, + "unknown": 2 } } }, + "fa2": { "fa2_ensures_qed_ko_2": { "alt-ergo": { "total": 1, + "unknown": 1 }, + "wp:main": { "total": 1, + "unknown": 1 } }, + "fa2_ensures_qed_ko": { "alt-ergo": { "total": 1, + "unknown": 1 }, + "wp:main": { "total": 1, + "unknown": 1 } }, + "wp:section": { "alt-ergo": { "total": 2, + "unknown": 2 }, + "wp:main": { "total": 2, + "unknown": 2 } } }, + "fa3": { "fa3_ensures_qed_ko_3": { "alt-ergo": { "total": 1, + "unknown": 1 }, + "wp:main": { "total": 1, + "unknown": 1 } }, + "fa3_ensures_qed_ko_2": { "alt-ergo": { "total": 1, + "unknown": 1 }, + "wp:main": { "total": 1, + "unknown": 1 } }, + "fa3_ensures_qed_ko": { "alt-ergo": { "total": 1, + "unknown": 1 }, + "wp:main": { "total": 1, + "unknown": 1 } }, + "wp:section": { "alt-ergo": { "total": 3, + "unknown": 3 }, + "wp:main": { "total": 3, + "unknown": 3 } } }, + "fs1": { "fs1_ensures_qed_ko_2": { "alt-ergo": { "total": 1, + "unknown": 1 }, + "wp:main": { "total": 1, + "unknown": 1 } }, + "fs1_ensures_qed_ko": { "alt-ergo": { "total": 1, + "unknown": 1 }, + "wp:main": { "total": 1, + "unknown": 1 } }, + "wp:section": { "alt-ergo": { "total": 2, + "unknown": 2 }, + "wp:main": { "total": 2, + "unknown": 2 } } } } } diff --git a/src/plugins/wp/tests/wp_acsl/oracle/classify_float.res.oracle b/src/plugins/wp/tests/wp_acsl/oracle/classify_float.res.oracle index ff906a4045f1c9ecf8984a16e62378e90f510786..c376b86e98ce5ec321a21c7b88f978e7d29d847d 100644 --- a/src/plugins/wp/tests/wp_acsl/oracle/classify_float.res.oracle +++ b/src/plugins/wp/tests/wp_acsl/oracle/classify_float.res.oracle @@ -8,19 +8,17 @@ Lemma InfN_not_finite: Assume: 'InfP_not_finite' 'NaN_not_finite' -Prove: (is_float64 x_0) - -> ((not (\is_finite x_0)) \/ (not (\is_minus_infinity x_0))) +Prove: (not (\is_finite x_0)) \/ (not (\is_minus_infinity x_0)) ------------------------------------------------------------ Lemma InfP_not_finite: Assume: 'NaN_not_finite' -Prove: (is_float64 x_0) - -> ((not (\is_finite x_0)) \/ (not (\is_plus_infinity x_0))) +Prove: (not (\is_finite x_0)) \/ (not (\is_plus_infinity x_0)) ------------------------------------------------------------ Lemma NaN_not_finite: -Prove: (is_float64 x_0) -> ((not (\is_finite x_0)) \/ (not (\is_NaN x_0))) +Prove: (not (\is_finite x_0)) \/ (not (\is_NaN x_0)) ------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_acsl/oracle/init_value.0.res.oracle b/src/plugins/wp/tests/wp_acsl/oracle/init_value.0.res.oracle index ad4d9f1ea971d2c837da496bee9cee9a1fa814ba..bcd9a305a139c01b26fa11ccc56af7dbdfd3c080 100644 --- a/src/plugins/wp/tests/wp_acsl/oracle/init_value.0.res.oracle +++ b/src/plugins/wp/tests/wp_acsl/oracle/init_value.0.res.oracle @@ -1,47 +1,386 @@ -# frama-c -wp [...] +# frama-c -wp -wp-no-let [...] [kernel] Parsing tests/wp_acsl/init_value.i (no preprocessing) [wp] Running WP plugin... [wp] Loading driver 'share/wp.driver' [wp] Warning: Missing RTE guards +------------------------------------------------------------ + Function fa1 +------------------------------------------------------------ + +Goal Post-condition 'qed_ok' in 'fa1': +Let x = ta1_0[4]. +Let x_1 = ta1_0[0]. +Let x_2 = ta1_0[1]. +Let x_3 = ta1_0[3]. +Assume { + Type: is_sint32(x_1) /\ is_sint32(x_2) /\ is_sint32(x_3) /\ is_sint32(x). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (ta1_0[i] = 0))). + (* Initializer *) + Init: ta1_0[2] = 1. + (* Initializer *) + Init: x = 1. + (* Initializer *) + Init: forall i : Z. ((3 <= i) -> ((i <= 3) -> (ta1_0[i] = 0))). +} +Prove: (x_2 = x_1) /\ (x_3 = x_2). + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa1': +Let x = ta1_0[4]. +Assume { + Type: is_sint32(ta1_0[0]) /\ is_sint32(ta1_0[1]) /\ is_sint32(ta1_0[3]) /\ + is_sint32(x). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (ta1_0[i] = 0))). + (* Initializer *) + Init: ta1_0[2] = 1. + (* Initializer *) + Init: x = 1. + (* Initializer *) + Init: forall i : Z. ((3 <= i) -> ((i <= 3) -> (ta1_0[i] = 0))). +} +Prove: x = 0. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa1': +Let x = ta1_0[4]. +Let x_1 = ta1_0[3]. +Assume { + Type: is_sint32(ta1_0[0]) /\ is_sint32(ta1_0[1]) /\ is_sint32(x_1) /\ + is_sint32(x). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (ta1_0[i] = 0))). + (* Initializer *) + Init: ta1_0[2] = 1. + (* Initializer *) + Init: x = 1. + (* Initializer *) + Init: forall i : Z. ((3 <= i) -> ((i <= 3) -> (ta1_0[i] = 0))). +} +Prove: x_1 = 1. + +------------------------------------------------------------ +------------------------------------------------------------ + Function fa2 +------------------------------------------------------------ + +Goal Post-condition 'qed_ok' in 'fa2': +Let x = ta2_0[0]. +Let x_1 = ta2_0[1]. +Let x_2 = ta2_0[4]. +Assume { + Type: is_sint32(x) /\ is_sint32(x_1) /\ is_sint32(x_2). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (ta2_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 3) -> (ta2_0[i] = 1))). + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 4) -> (ta2_0[i] = 0))). +} +Prove: (x_1 = x) /\ (x_2 = x_1). + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa2': +Let x = ta2_0[4]. +Assume { + Type: is_sint32(ta2_0[0]) /\ is_sint32(ta2_0[1]) /\ is_sint32(x). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (ta2_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 3) -> (ta2_0[i] = 1))). + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 4) -> (ta2_0[i] = 0))). +} +Prove: x = 1. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa2': +Let x = ta2_0[1]. +Assume { + Type: is_sint32(ta2_0[0]) /\ is_sint32(x) /\ is_sint32(ta2_0[4]). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (ta2_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 3) -> (ta2_0[i] = 1))). + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 4) -> (ta2_0[i] = 0))). +} +Prove: x = 1. + +------------------------------------------------------------ +------------------------------------------------------------ + Function fa3 +------------------------------------------------------------ + +Goal Post-condition 'qed_ok' in 'fa3': +Let x = ta1_0[4]. +Let x_1 = ta1_0[2]. +Let x_2 = ta3_0[0]. +Let x_3 = ta3_0[2]. +Assume { + Type: is_sint32(x_1) /\ is_sint32(x) /\ is_sint32(x_2) /\ is_sint32(x_3). + (* Initializer *) + Init: forall i : Z. ((i <= 0) -> ((0 <= i) -> (ta3_0[i] = 0))). + (* Initializer *) + Init: ta3_0[1] = 1. + (* Initializer *) + Init: ta3_0[3] = 1. + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 2) -> (ta3_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 4) -> (ta3_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (ta1_0[i] = 0))). + (* Initializer *) + Init: x_1 = 1. + (* Initializer *) + Init: x = 1. + (* Initializer *) + Init: forall i : Z. ((3 <= i) -> ((i <= 3) -> (ta1_0[i] = 0))). +} +Prove: (x = x_1) /\ (x_3 = x_2). + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa3': +Let x = ta3_0[0]. +Assume { + Type: is_sint32(x) /\ is_sint32(ta3_0[2]). + (* Initializer *) + Init: forall i : Z. ((i <= 0) -> ((0 <= i) -> (ta3_0[i] = 0))). + (* Initializer *) + Init: ta3_0[1] = 1. + (* Initializer *) + Init: ta3_0[3] = 1. + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 2) -> (ta3_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 4) -> (ta3_0[i] = 0))). +} +Prove: x = 1. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa3': +Let x = ta3_0[2]. +Assume { + Type: is_sint32(ta3_0[0]) /\ is_sint32(x). + (* Initializer *) + Init: forall i : Z. ((i <= 0) -> ((0 <= i) -> (ta3_0[i] = 0))). + (* Initializer *) + Init: ta3_0[1] = 1. + (* Initializer *) + Init: ta3_0[3] = 1. + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 2) -> (ta3_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 4) -> (ta3_0[i] = 0))). +} +Prove: x = 1. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa3': +Let x = ta2_0[4]. +Assume { + Type: is_sint32(x). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (ta2_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 3) -> (ta2_0[i] = 1))). + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 4) -> (ta2_0[i] = 0))). +} +Prove: x = 1. + +------------------------------------------------------------ +------------------------------------------------------------ + Function fs1 +------------------------------------------------------------ + +Goal Post-condition 'qed_ok' in 'fs1': +Let a = ts1_0[2]. +Let x = a.F5_c. +Let x_1 = a.F5_b. +Let x_2 = a.F5_a. +Let a_1 = ts1_0[0]. +Let a_2 = ts1_0[1]. +Let a_3 = ts1_0[3]. +Assume { + Type: IsS5(a_1) /\ IsS5(a_2) /\ IsS5(a_3) /\ is_sint32(a_1.F5_a) /\ + is_sint32(x_2) /\ is_sint32(x_1) /\ is_sint32(x). + (* Initializer *) + Init: forall i : Z. let a_4 = ts1_0[i] in ((0 <= i) -> ((i <= 1) -> + (((a_4.F5_a) = 0) /\ ((a_4.F5_b) = 0) /\ ((a_4.F5_c) = 0)))). + (* Initializer *) + Init: x_2 = 1. + (* Initializer *) + Init: x_1 = 1. + (* Initializer *) + Init: x = 0. + (* Initializer *) + Init: forall i : Z. let a_4 = ts1_0[i] in ((3 <= i) -> ((i <= 3) -> + (((a_4.F5_a) = 0) /\ ((a_4.F5_b) = 0) /\ ((a_4.F5_c) = 0)))). +} +Prove: (x_1 = x_2) /\ EqS5(a_1, a_2) /\ EqS5(a_2, a_3). + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fs1': +Let a = ts1_0[2]. +Let x = a.F5_c. +Let x_1 = a.F5_b. +Let x_2 = a.F5_a. +Let a_1 = ts1_0[0]. +Assume { + Type: IsS5(a_1) /\ IsS5(ts1_0[1]) /\ IsS5(ts1_0[3]) /\ + is_sint32(a_1.F5_a) /\ is_sint32(x_2) /\ is_sint32(x_1) /\ + is_sint32(x). + (* Initializer *) + Init: forall i : Z. let a_2 = ts1_0[i] in ((0 <= i) -> ((i <= 1) -> + (((a_2.F5_a) = 0) /\ ((a_2.F5_b) = 0) /\ ((a_2.F5_c) = 0)))). + (* Initializer *) + Init: x_2 = 1. + (* Initializer *) + Init: x_1 = 1. + (* Initializer *) + Init: x = 0. + (* Initializer *) + Init: forall i : Z. let a_2 = ts1_0[i] in ((3 <= i) -> ((i <= 3) -> + (((a_2.F5_a) = 0) /\ ((a_2.F5_b) = 0) /\ ((a_2.F5_c) = 0)))). +} +Prove: x = 1. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fs1': +Let a = ts1_0[2]. +Let x = a.F5_c. +Let x_1 = a.F5_b. +Let x_2 = a.F5_a. +Let a_1 = ts1_0[0]. +Let x_3 = a_1.F5_a. +Assume { + Type: IsS5(a_1) /\ IsS5(ts1_0[1]) /\ IsS5(ts1_0[3]) /\ is_sint32(x_3) /\ + is_sint32(x_2) /\ is_sint32(x_1) /\ is_sint32(x). + (* Initializer *) + Init: forall i : Z. let a_2 = ts1_0[i] in ((0 <= i) -> ((i <= 1) -> + (((a_2.F5_a) = 0) /\ ((a_2.F5_b) = 0) /\ ((a_2.F5_c) = 0)))). + (* Initializer *) + Init: x_2 = 1. + (* Initializer *) + Init: x_1 = 1. + (* Initializer *) + Init: x = 0. + (* Initializer *) + Init: forall i : Z. let a_2 = ts1_0[i] in ((3 <= i) -> ((i <= 3) -> + (((a_2.F5_a) = 0) /\ ((a_2.F5_b) = 0) /\ ((a_2.F5_c) = 0)))). +} +Prove: x_3 = 1. + +------------------------------------------------------------ ------------------------------------------------------------ Function main ------------------------------------------------------------ Goal Pre-condition 'qed_ok,Struct_Simple_a' in 'main': -Prove: true. +Let x = s.F1_S_b. +Let x_1 = s.F1_S_a. +Assume { + Type: is_sint32(x_1) /\ is_sint32(x). + (* Initializer *) + Init: x_1 = 2. + (* Initializer *) + Init: x = 0. +} +Prove: x_1 = 2. ------------------------------------------------------------ Goal Pre-condition 'qed_ok,Struct_Simple_b' in 'main': -Prove: true. +Let x = s.F1_S_b. +Let x_1 = s.F1_S_a. +Assume { + Type: is_sint32(x_1) /\ is_sint32(x). + (* Initializer *) + Init: x_1 = 2. + (* Initializer *) + Init: x = 0. +} +Prove: x = 0. ------------------------------------------------------------ Goal Pre-condition 'qed_ok,Simple_Array_0' in 'main': -Prove: true. +Let x = t[0]. +Assume { + Type: is_sint32(x) /\ is_sint32(t[1]). + (* Initializer *) + Init: x = 1. + (* Initializer *) + Init: forall i : Z. ((0 < i) -> ((i <= 1) -> (t[i] = 0))). +} +Prove: x = 1. ------------------------------------------------------------ Goal Pre-condition 'qed_ok,Simple_Array_1' in 'main': -Let x = t[1]. +Let x = t[0]. +Let x_1 = t[1]. Assume { - Type: is_sint32(x). + Type: is_sint32(x) /\ is_sint32(x_1). (* Initializer *) - Init: t[0] = 1. + Init: x = 1. (* Initializer *) Init: forall i : Z. ((0 < i) -> ((i <= 1) -> (t[i] = 0))). } -Prove: x = 0. +Prove: x_1 = 0. ------------------------------------------------------------ Goal Pre-condition 'qed_ok,With_Array_Struct_5' in 'main': -Prove: true. +Let a = st_0.F2_St_tab. +Let a_1 = a[3]. +Let a_2 = a[5]. +Assume { + Type: is_sint32(a_1) /\ is_sint32(a_2). + (* Initializer *) + Init: a[0] = 1. + (* Initializer *) + Init: a[1] = 2. + (* Initializer *) + Init: a[2] = 3. + (* Initializer *) + Init: a_1 = 4. + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 9) -> (a[i] = 0))). +} +Prove: a_2 = 0. ------------------------------------------------------------ Goal Pre-condition 'qed_ok,With_Array_Struct_3' in 'main': -Prove: true. +Let a = st_0.F2_St_tab. +Let a_1 = a[3]. +Assume { + Type: is_sint32(a_1) /\ is_sint32(a[5]). + (* Initializer *) + Init: a[0] = 1. + (* Initializer *) + Init: a[1] = 2. + (* Initializer *) + Init: a[2] = 3. + (* Initializer *) + Init: a_1 = 4. + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 9) -> (a[i] = 0))). +} +Prove: a_1 = 4. ------------------------------------------------------------ @@ -76,27 +415,96 @@ Prove: EqS3_Sc(sc1_0, sc0_0). ------------------------------------------------------------ Goal Pre-condition 'qed_ok,Sc_t' in 'main': -Prove: true. +Let x = sc2_0.F3_Sc_c. +Let a = sc2_0.F3_Sc_b. +Let a_1 = a[2]. +Assume { + Type: is_sint32(x) /\ is_sint32(a_1). + (* Initializer *) + Init: (sc2_0.F3_Sc_a) = 1. + (* Initializer *) + Init: a[0] = 2. + (* Initializer *) + Init: a[1] = 3. + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 2) -> (a[i] = 0))). + (* Initializer *) + Init: x = 4. +} +Prove: a_1 = 0. ------------------------------------------------------------ Goal Pre-condition 'qed_ok,Sc_t' in 'main': -Prove: true. +Let x = sc3_0.F3_Sc_c. +Let a = sc3_0.F3_Sc_b. +Let a_1 = a[2]. +Assume { + Type: is_sint32(x) /\ is_sint32(a_1). + (* Initializer *) + Init: (sc3_0.F3_Sc_a) = 1. + (* Initializer *) + Init: a[0] = 2. + (* Initializer *) + Init: a[1] = 3. + (* Initializer *) + Init: a_1 = 4. + (* Initializer *) + Init: x = 0. +} +Prove: a_1 = 4. ------------------------------------------------------------ Goal Pre-condition 'qed_ok,Sc_c_2' in 'main': -Prove: true. +Let x = sc2_0.F3_Sc_c. +Let a = sc2_0.F3_Sc_b. +Assume { + Type: is_sint32(x) /\ is_sint32(a[2]). + (* Initializer *) + Init: (sc2_0.F3_Sc_a) = 1. + (* Initializer *) + Init: a[0] = 2. + (* Initializer *) + Init: a[1] = 3. + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 2) -> (a[i] = 0))). + (* Initializer *) + Init: x = 4. +} +Prove: x = 4. ------------------------------------------------------------ Goal Pre-condition 'qed_ok,Sc_c_3' in 'main': -Prove: true. +Let x = sc3_0.F3_Sc_c. +Let a = sc3_0.F3_Sc_b. +Let a_1 = a[2]. +Assume { + Type: is_sint32(x) /\ is_sint32(a_1). + (* Initializer *) + Init: (sc3_0.F3_Sc_a) = 1. + (* Initializer *) + Init: a[0] = 2. + (* Initializer *) + Init: a[1] = 3. + (* Initializer *) + Init: a_1 = 4. + (* Initializer *) + Init: x = 0. +} +Prove: x = 0. ------------------------------------------------------------ Goal Pre-condition 'qed_ok,Tab_no_init' in 'main': -Prove: true. +Let x = tab_0[5]. +Assume { + Type: is_uint8(x). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 31) -> (tab_0[i] = 0))). +} +Prove: x = 0. ------------------------------------------------------------ @@ -111,3 +519,117 @@ Assume { Prove: tab_0[i] <= 255. ------------------------------------------------------------ + +Goal Pre-condition 'qed_ok' in 'main': +Let a = sq0_0.F3_Sc_b. +Let a_1 = a[1]. +Assume { + Type: is_sint32(a_1) /\ is_sint32(a[2]). + (* Initializer *) + Init: (sq0_0.F3_Sc_a) = 2. + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (a[i] = 2))). + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 2) -> (a[i] = 0))). + (* Initializer *) + Init: (sq0_0.F3_Sc_c) = 2. +} +Prove: a_1 = 2. + +------------------------------------------------------------ + +Goal Pre-condition 'qed_ok' in 'main': +Let a = sq0_0.F3_Sc_b. +Let a_1 = a[2]. +Assume { + Type: is_sint32(a[1]) /\ is_sint32(a_1). + (* Initializer *) + Init: (sq0_0.F3_Sc_a) = 2. + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 1) -> (a[i] = 2))). + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 2) -> (a[i] = 0))). + (* Initializer *) + Init: (sq0_0.F3_Sc_c) = 2. +} +Prove: a_1 = 0. + +------------------------------------------------------------ + +Goal Pre-condition 'qed_ok' in 'main': +Assume { + Type: is_sint32(t1_0[4]). + (* Goal *) + When: (0 <= i) /\ (i <= 3). + (* Initializer *) + Init: forall i_1 : Z. ((0 <= i_1) -> ((i_1 <= 3) -> (t1_0[i_1] = 1))). + (* Initializer *) + Init: forall i_1 : Z. ((5 <= i_1) -> ((i_1 <= 6) -> (t1_0[i_1] = 2))). + (* Initializer *) + Init: forall i_1 : Z. ((4 <= i_1) -> ((i_1 <= 4) -> (t1_0[i_1] = 0))). + (* Initializer *) + Init: forall i_1 : Z. ((7 <= i_1) -> ((i_1 <= 9) -> (t1_0[i_1] = 0))). +} +Prove: t1_0[i] = 1. + +------------------------------------------------------------ + +Goal Pre-condition 'qed_ok,todo' in 'main': +Let x = t1_0[4]. +Assume { + Type: is_sint32(x). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 3) -> (t1_0[i] = 1))). + (* Initializer *) + Init: forall i : Z. ((5 <= i) -> ((i <= 6) -> (t1_0[i] = 2))). + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 4) -> (t1_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((7 <= i) -> ((i <= 9) -> (t1_0[i] = 0))). +} +Prove: x = 0. + +------------------------------------------------------------ + +Goal Pre-condition 'qed_ok' in 'main': +Assume { + Type: is_sint32(t1_0[4]). + (* Goal *) + When: (6 <= i) /\ (i <= 6). + (* Initializer *) + Init: forall i_1 : Z. ((0 <= i_1) -> ((i_1 <= 3) -> (t1_0[i_1] = 1))). + (* Initializer *) + Init: forall i_1 : Z. ((5 <= i_1) -> ((i_1 <= 6) -> (t1_0[i_1] = 2))). + (* Initializer *) + Init: forall i_1 : Z. ((4 <= i_1) -> ((i_1 <= 4) -> (t1_0[i_1] = 0))). + (* Initializer *) + Init: forall i_1 : Z. ((7 <= i_1) -> ((i_1 <= 9) -> (t1_0[i_1] = 0))). +} +Prove: t1_0[i] = 2. + +------------------------------------------------------------ + +Goal Pre-condition 'qed_ok' in 'main': +Assume { + Type: is_sint32(t1_0[4]). + (* Goal *) + When: (7 <= i) /\ (i <= 9). + (* Initializer *) + Init: forall i_1 : Z. ((0 <= i_1) -> ((i_1 <= 3) -> (t1_0[i_1] = 1))). + (* Initializer *) + Init: forall i_1 : Z. ((5 <= i_1) -> ((i_1 <= 6) -> (t1_0[i_1] = 2))). + (* Initializer *) + Init: forall i_1 : Z. ((4 <= i_1) -> ((i_1 <= 4) -> (t1_0[i_1] = 0))). + (* Initializer *) + Init: forall i_1 : Z. ((7 <= i_1) -> ((i_1 <= 9) -> (t1_0[i_1] = 0))). +} +Prove: t1_0[i] = 0. + +------------------------------------------------------------ + +Goal Pre-condition 'qed_ok,direct_init_union' in 'main': +Let x = u.F4_U_a. +Assume { Type: is_sint16(x). (* Initializer *) Init: x = (-1). } +Prove: x = (-1). + +------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_acsl/oracle/init_value.1.res.oracle b/src/plugins/wp/tests/wp_acsl/oracle/init_value.1.res.oracle index a95fc1f3809f0317d6310d97e8de7e9b290253c0..125cf6eebc17d9a97091d3c08a58f882d44e2219 100644 --- a/src/plugins/wp/tests/wp_acsl/oracle/init_value.1.res.oracle +++ b/src/plugins/wp/tests/wp_acsl/oracle/init_value.1.res.oracle @@ -1,17 +1,155 @@ -# frama-c -wp [...] +# frama-c -wp -wp-no-let [...] [kernel] Parsing tests/wp_acsl/init_value.i (no preprocessing) [wp] Running WP plugin... [wp] Loading driver 'share/wp.driver' [wp] Warning: Missing RTE guards +------------------------------------------------------------ + Function fa1 +------------------------------------------------------------ + +Goal Post-condition 'qed_ok' in 'fa1': +Let x = ta1_0[0]. +Let x_1 = ta1_0[1]. +Let x_2 = ta1_0[3]. +Assume { + Type: is_sint32(x) /\ is_sint32(x_1) /\ is_sint32(x_2) /\ + is_sint32(ta1_0[4]). +} +Prove: (x_1 = x) /\ (x_2 = x_1). + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa1': +Let x = ta1_0[4]. +Assume { + Type: is_sint32(ta1_0[0]) /\ is_sint32(ta1_0[1]) /\ is_sint32(ta1_0[3]) /\ + is_sint32(x). +} +Prove: x = 0. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa1': +Let x = ta1_0[3]. +Assume { + Type: is_sint32(ta1_0[0]) /\ is_sint32(ta1_0[1]) /\ is_sint32(x) /\ + is_sint32(ta1_0[4]). +} +Prove: x = 1. + +------------------------------------------------------------ +------------------------------------------------------------ + Function fa2 +------------------------------------------------------------ + +Goal Post-condition 'qed_ok' in 'fa2': +Let x = ta2_0[0]. +Let x_1 = ta2_0[1]. +Let x_2 = ta2_0[4]. +Assume { Type: is_sint32(x) /\ is_sint32(x_1) /\ is_sint32(x_2). } +Prove: (x_1 = x) /\ (x_2 = x_1). + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa2': +Let x = ta2_0[4]. +Assume { Type: is_sint32(ta2_0[0]) /\ is_sint32(ta2_0[1]) /\ is_sint32(x). } +Prove: x = 1. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa2': +Let x = ta2_0[1]. +Assume { Type: is_sint32(ta2_0[0]) /\ is_sint32(x) /\ is_sint32(ta2_0[4]). } +Prove: x = 1. + +------------------------------------------------------------ +------------------------------------------------------------ + Function fa3 +------------------------------------------------------------ + +Goal Post-condition 'qed_ok' in 'fa3': +Let x = ta1_0[2]. +Let x_1 = ta1_0[4]. +Let x_2 = ta3_0[0]. +Let x_3 = ta3_0[2]. +Assume { + Type: is_sint32(x) /\ is_sint32(x_1) /\ is_sint32(x_2) /\ is_sint32(x_3). +} +Prove: (x_1 = x) /\ (x_3 = x_2). + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa3': +Let x = ta3_0[0]. Assume { Type: is_sint32(x) /\ is_sint32(ta3_0[2]). } +Prove: x = 1. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa3': +Let x = ta3_0[2]. Assume { Type: is_sint32(ta3_0[0]) /\ is_sint32(x). } +Prove: x = 1. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fa3': +Let x = ta2_0[4]. Assume { Type: is_sint32(x). } +Prove: x = 1. + +------------------------------------------------------------ +------------------------------------------------------------ + Function fs1 +------------------------------------------------------------ + +Goal Post-condition 'qed_ok' in 'fs1': +Let a = ts1_0[0]. +Let a_1 = ts1_0[1]. +Let a_2 = ts1_0[3]. +Let a_3 = ts1_0[2]. +Let x = a_3.F5_a. +Let x_1 = a_3.F5_b. +Assume { + Type: IsS5(a) /\ IsS5(a_1) /\ IsS5(a_2) /\ is_sint32(a.F5_a) /\ + is_sint32(x) /\ is_sint32(x_1) /\ is_sint32(a_3.F5_c). +} +Prove: (x_1 = x) /\ EqS5(a, a_1) /\ EqS5(a_1, a_2). + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fs1': +Let a = ts1_0[0]. +Let a_1 = ts1_0[2]. +Let x = a_1.F5_c. +Assume { + Type: IsS5(a) /\ IsS5(ts1_0[1]) /\ IsS5(ts1_0[3]) /\ is_sint32(a.F5_a) /\ + is_sint32(a_1.F5_a) /\ is_sint32(a_1.F5_b) /\ is_sint32(x). +} +Prove: x = 1. + +------------------------------------------------------------ + +Goal Post-condition 'qed_ko' in 'fs1': +Let a = ts1_0[0]. +Let x = a.F5_a. +Let a_1 = ts1_0[2]. +Assume { + Type: IsS5(a) /\ IsS5(ts1_0[1]) /\ IsS5(ts1_0[3]) /\ is_sint32(x) /\ + is_sint32(a_1.F5_a) /\ is_sint32(a_1.F5_b) /\ is_sint32(a_1.F5_c). +} +Prove: x = 1. + +------------------------------------------------------------ ------------------------------------------------------------ Function main_ko ------------------------------------------------------------ Goal Pre-condition 'qed_ko,Sc_eq_ko' in 'main_ko': +Let x = sc2_0.F3_Sc_c. Let a = sc2_0.F3_Sc_b. Let a_1 = sc3_0.F3_Sc_b. +Let a_2 = a_1[2]. Assume { - Type: IsS3_Sc(sc2_0) /\ IsS3_Sc(sc3_0). + Type: IsS3_Sc(sc2_0) /\ IsS3_Sc(sc3_0) /\ is_sint32(x) /\ is_sint32(a_2). (* Initializer *) Init: (sc3_0.F3_Sc_a) = 1. (* Initializer *) @@ -19,7 +157,7 @@ Assume { (* Initializer *) Init: a_1[1] = 3. (* Initializer *) - Init: a_1[2] = 4. + Init: a_2 = 4. (* Initializer *) Init: (sc3_0.F3_Sc_c) = 0. (* Initializer *) @@ -31,29 +169,80 @@ Assume { (* Initializer *) Init: forall i : Z. ((2 <= i) -> ((i <= 2) -> (a[i] = 0))). (* Initializer *) - Init: (sc2_0.F3_Sc_c) = 4. + Init: x = 4. } Prove: EqS3_Sc(sc2_0, sc3_0). ------------------------------------------------------------ Goal Pre-condition 'qed_ko,Sc_t' in 'main_ko': -Prove: false. +Let a = sc3_0.F3_Sc_b. +Let a_1 = a[2]. +Assume { + Type: IsS3_Sc(sc3_0) /\ is_sint32(a_1). + (* Initializer *) + Init: (sc3_0.F3_Sc_a) = 1. + (* Initializer *) + Init: a[0] = 2. + (* Initializer *) + Init: a[1] = 3. + (* Initializer *) + Init: a_1 = 4. + (* Initializer *) + Init: (sc3_0.F3_Sc_c) = 0. +} +Prove: a_1 = 3. ------------------------------------------------------------ Goal Pre-condition 'qed_ko,Sc_c_2' in 'main_ko': -Prove: false. +Let x = sc2_0.F3_Sc_c. +Let a = sc2_0.F3_Sc_b. +Assume { + Type: IsS3_Sc(sc2_0) /\ is_sint32(x). + (* Initializer *) + Init: (sc2_0.F3_Sc_a) = 1. + (* Initializer *) + Init: a[0] = 2. + (* Initializer *) + Init: a[1] = 3. + (* Initializer *) + Init: forall i : Z. ((2 <= i) -> ((i <= 2) -> (a[i] = 0))). + (* Initializer *) + Init: x = 4. +} +Prove: x = 2. ------------------------------------------------------------ Goal Pre-condition 'qed_ko,Tab_no_init' in 'main_ko': -Prove: false. +Let x = tab_0[5]. +Assume { + Type: is_uint8(x). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 31) -> (tab_0[i] = 0))). +} +Prove: x = 1. ------------------------------------------------------------ Goal Pre-condition 'qed_ko,With_Array_Struct_3' in 'main_ko': -Prove: false. +Let a = st_0.F2_St_tab. +Let a_1 = a[3]. +Assume { + Type: is_sint32(a_1). + (* Initializer *) + Init: a[0] = 1. + (* Initializer *) + Init: a[1] = 2. + (* Initializer *) + Init: a[2] = 3. + (* Initializer *) + Init: a_1 = 4. + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 9) -> (a[i] = 0))). +} +Prove: a_1 = 3. ------------------------------------------------------------ @@ -69,3 +258,42 @@ Assume { Prove: x = 1. ------------------------------------------------------------ + +Goal Pre-condition 'qed_ko,T1_6' in 'main_ko': +Let x = t1_0[6]. +Assume { + Type: is_sint32(x). + (* Initializer *) + Init: forall i : Z. ((0 <= i) -> ((i <= 3) -> (t1_0[i] = 1))). + (* Initializer *) + Init: forall i : Z. ((5 <= i) -> ((i <= 6) -> (t1_0[i] = 2))). + (* Initializer *) + Init: forall i : Z. ((4 <= i) -> ((i <= 4) -> (t1_0[i] = 0))). + (* Initializer *) + Init: forall i : Z. ((7 <= i) -> ((i <= 9) -> (t1_0[i] = 0))). +} +Prove: x = 0. + +------------------------------------------------------------ + +Goal Pre-condition 'qed_ko,indirect_init_union_b' in 'main_ko': +Let x = u.F4_U_b. +Assume { + Type: is_sint64(x) /\ is_sint16((u.F4_U_t)[0]). + (* Initializer *) + Init: (u.F4_U_a) = (-1). +} +Prove: x = 0. + +------------------------------------------------------------ + +Goal Pre-condition 'qed_ko,indirect_init_union_t' in 'main_ko': +Let a = (u.F4_U_t)[0]. +Assume { + Type: is_sint64(u.F4_U_b) /\ is_sint16(a). + (* Initializer *) + Init: (u.F4_U_a) = (-1). +} +Prove: a = 0. + +------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_acsl/oracle_qualif/classify_float.0.res.oracle b/src/plugins/wp/tests/wp_acsl/oracle_qualif/classify_float.0.res.oracle index fdedb97beae9bdd2234a9fe64805ddf4ba4a71ec..354a7ea0d71689e221ef9fc4f3deda3e53b09e2c 100644 --- a/src/plugins/wp/tests/wp_acsl/oracle_qualif/classify_float.0.res.oracle +++ b/src/plugins/wp/tests/wp_acsl/oracle_qualif/classify_float.0.res.oracle @@ -12,5 +12,5 @@ [wp] Report 'tests/wp_acsl/classify_float.c.0.report.json' ------------------------------------------------------------- Axiomatics WP Alt-Ergo Total Success -Lemma - 3 (4..16) 3 100% +Lemma - 3 (1..12) 3 100% ------------------------------------------------------------- diff --git a/src/plugins/wp/tests/wp_acsl/oracle_qualif/init_value.0.res.oracle b/src/plugins/wp/tests/wp_acsl/oracle_qualif/init_value.0.res.oracle index 92b036f055d7519eb692112cf797fd7af95ebee0..0619f73d418710651fd29071598ac152e5d46f4e 100644 --- a/src/plugins/wp/tests/wp_acsl/oracle_qualif/init_value.0.res.oracle +++ b/src/plugins/wp/tests/wp_acsl/oracle_qualif/init_value.0.res.oracle @@ -3,7 +3,11 @@ [wp] Running WP plugin... [wp] Loading driver 'share/wp.driver' [wp] Warning: Missing RTE guards -[wp] 13 goals scheduled +[wp] 24 goals scheduled +[wp] [Qed] Goal typed_fa1_ensures_qed_ok : Valid +[wp] [Qed] Goal typed_fa2_ensures_qed_ok : Valid +[wp] [Qed] Goal typed_fa3_ensures_qed_ok : Valid +[wp] [Alt-Ergo] Goal typed_fs1_ensures_qed_ok : Valid [wp] [Qed] Goal typed_main_requires_qed_ok_Struct_Simple_a : Valid [wp] [Qed] Goal typed_main_requires_qed_ok_Struct_Simple_b : Valid [wp] [Qed] Goal typed_main_requires_qed_ok_Simple_Array_0 : Valid @@ -17,11 +21,22 @@ [wp] [Qed] Goal typed_main_requires_qed_ok_Sc_c_3 : Valid [wp] [Qed] Goal typed_main_requires_qed_ok_Tab_no_init : Valid [wp] [Alt-Ergo] Goal typed_main_requires_qed_ok_Tab_todo : Valid -[wp] Proved goals: 13 / 13 - Qed: 10 - Alt-Ergo: 3 +[wp] [Qed] Goal typed_main_requires_qed_ok : Valid +[wp] [Qed] Goal typed_main_requires_qed_ok_2 : Valid +[wp] [Alt-Ergo] Goal typed_main_requires_qed_ok_3 : Valid +[wp] [Qed] Goal typed_main_requires_qed_ok_todo : Valid +[wp] [Alt-Ergo] Goal typed_main_requires_qed_ok_4 : Valid +[wp] [Alt-Ergo] Goal typed_main_requires_qed_ok_5 : Valid +[wp] [Qed] Goal typed_main_requires_qed_ok_direct_init_union : Valid +[wp] Proved goals: 24 / 24 + Qed: 17 + Alt-Ergo: 7 [wp] Report 'tests/wp_acsl/init_value.i.0.report.json' ------------------------------------------------------------- Functions WP Alt-Ergo Total Success -main 10 3 (28..40) 13 100% +main 14 6 (28..40) 20 100% +fa1 1 - 1 100% +fa2 1 - 1 100% +fa3 1 - 1 100% +fs1 - 1 (160..184) 1 100% ------------------------------------------------------------- diff --git a/src/plugins/wp/tests/wp_acsl/oracle_qualif/init_value.1.res.oracle b/src/plugins/wp/tests/wp_acsl/oracle_qualif/init_value.1.res.oracle index be8da727ece44e5a51f0d16f40bd6d6a7191d97e..6fd6542afa8361c5a6836072b77949b948416ead 100644 --- a/src/plugins/wp/tests/wp_acsl/oracle_qualif/init_value.1.res.oracle +++ b/src/plugins/wp/tests/wp_acsl/oracle_qualif/init_value.1.res.oracle @@ -3,17 +3,33 @@ [wp] Running WP plugin... [wp] Loading driver 'share/wp.driver' [wp] Warning: Missing RTE guards -[wp] 6 goals scheduled +[wp] 18 goals scheduled +[wp] [Alt-Ergo] Goal typed_fa1_ensures_qed_ko : Unknown +[wp] [Alt-Ergo] Goal typed_fa1_ensures_qed_ko_2 : Unknown +[wp] [Alt-Ergo] Goal typed_fa2_ensures_qed_ko : Unknown +[wp] [Alt-Ergo] Goal typed_fa2_ensures_qed_ko_2 : Unknown +[wp] [Alt-Ergo] Goal typed_fa3_ensures_qed_ko : Unknown +[wp] [Alt-Ergo] Goal typed_fa3_ensures_qed_ko_2 : Unknown +[wp] [Alt-Ergo] Goal typed_fa3_ensures_qed_ko_3 : Unknown +[wp] [Alt-Ergo] Goal typed_fs1_ensures_qed_ko : Unknown +[wp] [Alt-Ergo] Goal typed_fs1_ensures_qed_ko_2 : Unknown [wp] [Alt-Ergo] Goal typed_main_ko_requires_qed_ko_Sc_eq_ko : Unknown [wp] [Alt-Ergo] Goal typed_main_ko_requires_qed_ko_Sc_t : Unknown [wp] [Alt-Ergo] Goal typed_main_ko_requires_qed_ko_Sc_c_2 : Unknown [wp] [Alt-Ergo] Goal typed_main_ko_requires_qed_ko_Tab_no_init : Unknown [wp] [Alt-Ergo] Goal typed_main_ko_requires_qed_ko_With_Array_Struct_3 : Unknown [wp] [Alt-Ergo] Goal typed_main_ko_requires_qed_ko_Simple_Array_1 : Unknown -[wp] Proved goals: 0 / 6 - Alt-Ergo: 0 (unknown: 6) +[wp] [Alt-Ergo] Goal typed_main_ko_requires_qed_ko_T1_6 : Unknown +[wp] [Alt-Ergo] Goal typed_main_ko_requires_qed_ko_indirect_init_union_b : Unknown +[wp] [Alt-Ergo] Goal typed_main_ko_requires_qed_ko_indirect_init_union_t : Unknown +[wp] Proved goals: 0 / 18 + Alt-Ergo: 0 (unknown: 18) [wp] Report 'tests/wp_acsl/init_value.i.1.report.json' ------------------------------------------------------------- Functions WP Alt-Ergo Total Success -main_ko - - 6 0.0% +main_ko - - 9 0.0% +fa1 - - 2 0.0% +fa2 - - 2 0.0% +fa3 - - 3 0.0% +fs1 - - 2 0.0% ------------------------------------------------------------- diff --git a/src/plugins/wp/tests/wp_bts/bts_1174.s b/src/plugins/wp/tests/wp_bts/bts_1174.s index cf366f0bf18e1d2d827a4187f0e84f1536afbbad..c1d443b3b02a23d7bd40478f0e9968e91bae2842 100644 --- a/src/plugins/wp/tests/wp_bts/bts_1174.s +++ b/src/plugins/wp/tests/wp_bts/bts_1174.s @@ -41,7 +41,6 @@ Hint job,property,qed_ok. Proof. intros. Require Import Fourier. - unfold r_1. fourier. Qed. diff --git a/src/plugins/wp/tests/wp_bts/bts_1601.c.0.report.json b/src/plugins/wp/tests/wp_bts/bts_1601.c.0.report.json index d0ce516506beeaad2343e8fb80b3566156b9b1f2..ec4414770b3982d5b0b092c959d7c902e3567387 100644 --- a/src/plugins/wp/tests/wp_bts/bts_1601.c.0.report.json +++ b/src/plugins/wp/tests/wp_bts/bts_1601.c.0.report.json @@ -1,5 +1,6 @@ -{ "wp:global": { "qed": { "total": 8, "valid": 8 }, - "wp:main": { "total": 8, "valid": 8 } }, +{ "wp:global": { "alt-ergo": { "total": 1, "valid": 1, "rank": 4 }, + "qed": { "total": 7, "valid": 7 }, + "wp:main": { "total": 8, "valid": 8, "rank": 4 } }, "wp:functions": { "foo": { "foo_assert_7": { "qed": { "total": 1, "valid": 1 }, "wp:main": { "total": 1, @@ -24,15 +25,21 @@ "valid": 1 }, "wp:main": { "total": 1, "valid": 1 } }, - "foo_assert": { "qed": { "total": 1, - "valid": 1 }, + "foo_assert": { "alt-ergo": { "total": 1, + "valid": 1, + "rank": 4 }, "wp:main": { "total": 1, - "valid": 1 } }, + "valid": 1, + "rank": 4 } }, "foo_basic_ensures": { "qed": { "total": 1, "valid": 1 }, "wp:main": { "total": 1, "valid": 1 } }, - "wp:section": { "qed": { "total": 8, - "valid": 8 }, + "wp:section": { "alt-ergo": { "total": 1, + "valid": 1, + "rank": 4 }, + "qed": { "total": 7, + "valid": 7 }, "wp:main": { "total": 8, - "valid": 8 } } } } } + "valid": 8, + "rank": 4 } } } } } diff --git a/src/plugins/wp/tests/wp_bts/oracle/bts_1174.res.oracle b/src/plugins/wp/tests/wp_bts/oracle/bts_1174.res.oracle index d98a6cfde684e9c5a8b8e86fce83dde1af255301..0f15882a71638c4b6817b680fb0d30129b4f6887 100644 --- a/src/plugins/wp/tests/wp_bts/oracle/bts_1174.res.oracle +++ b/src/plugins/wp/tests/wp_bts/oracle/bts_1174.res.oracle @@ -8,16 +8,16 @@ ------------------------------------------------------------ Goal Assertion 'qed_ok' (file tests/wp_bts/bts_1174.i, line 11): -Let r = mul_float64(x, 2.0). +Let r = of_f64(x). Assume { - Type: is_sint32(a) /\ is_float64(x) /\ is_float64(r). + Type: is_sint32(a). (* Goal *) - When: .0 <= x. + When: .0 <= r. (* Pre-condition *) - Have: (x <= 10.0) /\ (-10.0 <= x). + Have: (r <= 10.0) /\ (-10.0 <= r). (* Then *) Have: a != 0. } -Prove: .0 <= r. +Prove: .0 <= of_f64(mul_f64(x, to_f64(2.0))). ------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_bts/oracle/bts_1601.res.oracle b/src/plugins/wp/tests/wp_bts/oracle/bts_1601.res.oracle index 1dcb038b3f130200fa0166f389d513578b8eddb8..897003473316c3a94c56e22d00d8626c152a9aa4 100644 --- a/src/plugins/wp/tests/wp_bts/oracle/bts_1601.res.oracle +++ b/src/plugins/wp/tests/wp_bts/oracle/bts_1601.res.oracle @@ -8,7 +8,14 @@ ------------------------------------------------------------ Goal Assertion (file tests/wp_bts/bts_1601.c, line 72): -Prove: true. +Assume { + Type: is_uint32(tenumRMode_0). + (* Residual *) + When: ne_f32(fRrValue_0, to_f32(.0)). + (* Goal *) + When: of_f32(fRrValue_0) = .0. +} +Prove: tenumRMode_0 = 1. ------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_bts/oracle_qualif/bts_1601.res.oracle b/src/plugins/wp/tests/wp_bts/oracle_qualif/bts_1601.res.oracle index 05f5b3589dee9714717c28c26af2110583741864..255379c5ae2ab87693bb6f9c74f2c4ef4f2b82ed 100644 --- a/src/plugins/wp/tests/wp_bts/oracle_qualif/bts_1601.res.oracle +++ b/src/plugins/wp/tests/wp_bts/oracle_qualif/bts_1601.res.oracle @@ -4,7 +4,7 @@ [wp] Loading driver 'share/wp.driver' [wp] Warning: Missing RTE guards [wp] 8 goals scheduled -[wp] [Qed] Goal typed_foo_assert : Valid +[wp] [Alt-Ergo] Goal typed_foo_assert : Valid [wp] [Qed] Goal typed_foo_assert_2 : Valid [wp] [Qed] Goal typed_foo_assert_3 : Valid [wp] [Qed] Goal typed_foo_assert_4 : Valid @@ -13,9 +13,10 @@ [wp] [Qed] Goal typed_foo_assert_7 : Valid [wp] [Qed] Goal typed_foo_basic_ensures : Valid [wp] Proved goals: 8 / 8 - Qed: 8 + Qed: 7 + Alt-Ergo: 1 [wp] Report 'tests/wp_bts/bts_1601.c.0.report.json' ------------------------------------------------------------- Functions WP Alt-Ergo Total Success -foo 8 - 8 100% +foo 7 1 (12..24) 8 100% ------------------------------------------------------------- diff --git a/src/plugins/wp/tests/wp_plugin/combined.c b/src/plugins/wp/tests/wp_plugin/combined.c index e698ae498d812c5788580c80ab143b62567331da..33a5d1e193a283f4649865cca1511645456121ac 100644 --- a/src/plugins/wp/tests/wp_plugin/combined.c +++ b/src/plugins/wp/tests/wp_plugin/combined.c @@ -3,7 +3,8 @@ */ /* run.config_qualif - OPT: -wp-par 1 -load-script tests/wp_plugin/combined.ml + EXECNOW: @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -wp-par 1 -load-module @PTEST_DIR@/@PTEST_NAME@ */ /* ZD : this should not be here such as it cannot be tested by all frama-c diff --git a/src/plugins/wp/tests/wp_plugin/combined.ml b/src/plugins/wp/tests/wp_plugin/combined.ml deleted file mode 100644 index 6b9da9a310774ff2577df057db2234f367d9d1b2..0000000000000000000000000000000000000000 --- a/src/plugins/wp/tests/wp_plugin/combined.ml +++ /dev/null @@ -1,22 +0,0 @@ -let main () = - Ast.compute (); - let module OLS = Datatype.List(Datatype.String) in - let module OKF = Datatype.Option(Kernel_function) in - let module OP = Datatype.Option(Property) in - Dynamic.get - ~plugin:"Wp" "wp_compute" - (Datatype.func3 OKF.ty OLS.ty OP.ty Datatype.unit) - (Some - (try Globals.Functions.find_by_name "job" - with Not_found -> assert false)) - [] - None; - let report = - Dynamic.get - ~plugin:"Report" "print" (Datatype.func Datatype.unit Datatype.unit) - in - report (); - !Db.Value.compute (); - report () - -let () = Db.Main.extend main diff --git a/src/plugins/wp/tests/wp_plugin/oracle/combined.res.oracle b/src/plugins/wp/tests/wp_plugin/oracle/combined.res.oracle index 299e5c4b1a5a9d3ef52579e0104f2e788c80b53b..c8a980291364c79ed27ab5f1a70676174e4b91f0 100644 --- a/src/plugins/wp/tests/wp_plugin/oracle/combined.res.oracle +++ b/src/plugins/wp/tests/wp_plugin/oracle/combined.res.oracle @@ -7,7 +7,7 @@ Function job ------------------------------------------------------------ -Goal Assertion (file tests/wp_plugin/combined.c, line 26): +Goal Assertion (file tests/wp_plugin/combined.c, line 27): Assume { Type: is_sint32(A). (* Heap *) @@ -17,7 +17,7 @@ Prove: (50 <= A) /\ (A <= 100). ------------------------------------------------------------ -Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 28): +Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 29): Assume { Type: is_sint32(A) /\ is_sint32(i) /\ is_sint32(v) /\ is_sint32(1 + i). (* Heap *) @@ -39,12 +39,12 @@ Prove: (-1) <= i. ------------------------------------------------------------ -Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 28): +Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 29): Prove: true. ------------------------------------------------------------ -Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 29): +Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 30): Let a = havoc(Mint_undef_0, Mint_0, shift_sint32(t, 0), 50). Assume { Type: is_sint32(A) /\ is_sint32(i) /\ is_sint32(v) /\ is_sint32(1 + i). @@ -68,12 +68,12 @@ Prove: P_P(a[shift_sint32(t, i) <- v][shift_sint32(t, i_1)]). ------------------------------------------------------------ -Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 29): +Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 30): Prove: true. ------------------------------------------------------------ -Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 34): +Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 35): Let x = 1 + j. Assume { Type: is_sint32(A) /\ is_sint32(i) /\ is_sint32(j) /\ is_sint32(x). @@ -98,12 +98,12 @@ Prove: A <= x. ------------------------------------------------------------ -Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 34): +Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 35): Prove: true. ------------------------------------------------------------ -Goal Assertion (file tests/wp_plugin/combined.c, line 39): +Goal Assertion (file tests/wp_plugin/combined.c, line 40): Let a = havoc(Mint_undef_1, Mint_0, shift_sint32(t, 0), 50). Assume { Type: is_sint32(A) /\ is_sint32(i_1) /\ is_sint32(j). @@ -130,36 +130,36 @@ Prove: P_P(havoc(Mint_undef_0, a, shift_sint32(t, A), 100 - A) ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 30) (1/3): +Goal Loop assigns (file tests/wp_plugin/combined.c, line 31) (1/3): Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 30) (2/3): -Effect at line 32 +Goal Loop assigns (file tests/wp_plugin/combined.c, line 31) (2/3): +Effect at line 33 Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 30) (3/3): -Call Result at line 32 +Goal Loop assigns (file tests/wp_plugin/combined.c, line 31) (3/3): +Call Result at line 33 Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 35) (1/3): +Goal Loop assigns (file tests/wp_plugin/combined.c, line 36) (1/3): Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 35) (2/3): -Effect at line 37 +Goal Loop assigns (file tests/wp_plugin/combined.c, line 36) (2/3): +Effect at line 38 Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 35) (3/3): -Call Result at line 37 +Goal Loop assigns (file tests/wp_plugin/combined.c, line 36) (3/3): +Call Result at line 38 Let a = shift_sint32(t, j). Assume { Type: is_sint32(A) /\ is_sint32(i) /\ is_sint32(j). diff --git a/src/plugins/wp/tests/wp_plugin/oracle/float_format.res.oracle b/src/plugins/wp/tests/wp_plugin/oracle/float_format.res.oracle index a1eef7741a054dfba2b25b6e86bd265a8f2ec84c..85e995df2796c0b54545c3d7c1c66198eb899050 100644 --- a/src/plugins/wp/tests/wp_plugin/oracle/float_format.res.oracle +++ b/src/plugins/wp/tests/wp_plugin/oracle/float_format.res.oracle @@ -11,9 +11,9 @@ ------------------------------------------------------------ Goal Post-condition 'KO' in 'output': -Let r = to_float32(add_float64((3602879701896397.0/18014398509481984), - to_float64(x))). -Assume { Type: is_float32(x) /\ is_float32(r). } -Prove: ((1.0/5) + x) = r. +Let r = of_f32(x). +Prove: ((1.0/5) + r) + = of_f32(to_f32(of_f64(add_f64(to_f64((3602879701896397.0/18014398509481984)), + to_f64(r))))). ------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_plugin/oracle_qualif/dynamic.res.oracle b/src/plugins/wp/tests/wp_plugin/oracle_qualif/dynamic.res.oracle index d357167c4f7b728abe945858687833a62b8185cb..9949b7df67fc9164904f434bb2b69b956958c459 100644 --- a/src/plugins/wp/tests/wp_plugin/oracle_qualif/dynamic.res.oracle +++ b/src/plugins/wp/tests/wp_plugin/oracle_qualif/dynamic.res.oracle @@ -6,16 +6,16 @@ [wp] Loading driver 'share/wp.driver' [wp] Warning: Missing RTE guards [wp] 13 goals scheduled -[wp] [Alt-Ergo] Goal typed_call_s3_callsf1f2 : Valid +[wp] [Alt-Ergo] Goal typed_call_calls_f1_f2_s3 : Valid [wp] [Qed] Goal typed_call_ensures_part1 : Valid [wp] [Qed] Goal typed_call_ensures_part2 : Valid [wp] [Alt-Ergo] Goal typed_call_call_f1_requires : Valid -[wp] [Qed] Goal typed_guarded_call_s9_callsg : Valid +[wp] [Qed] Goal typed_guarded_call_calls_g_s9 : Valid [wp] [Alt-Ergo] Goal typed_guarded_call_ensures_part1 : Valid [wp] [Qed] Goal typed_guarded_call_ensures_part2 : Valid [wp] [Qed] Goal typed_guarded_call_ensures_2_part1 : Valid [wp] [Qed] Goal typed_guarded_call_ensures_2_part2 : Valid -[wp] [Qed] Goal typed_no_call_s17_callsunreachable_g : Valid +[wp] [Qed] Goal typed_no_call_calls_unreachable_g_s17 : Valid [wp] [Qed] Goal typed_no_call_ensures_part1 : Valid [wp] [Qed] Goal typed_no_call_ensures_part2 : Valid [wp] [Qed] Goal typed_no_call_call_unreachable_g_requires : Valid diff --git a/src/plugins/wp/tests/wp_plugin/oracle_qualif/float_format.1.res.oracle b/src/plugins/wp/tests/wp_plugin/oracle_qualif/float_format.1.res.oracle index 780f135fb5304d51af6296a5624ea990e68ce078..97b86f838a739b903ae5c37ab8f562360e1d342d 100644 --- a/src/plugins/wp/tests/wp_plugin/oracle_qualif/float_format.1.res.oracle +++ b/src/plugins/wp/tests/wp_plugin/oracle_qualif/float_format.1.res.oracle @@ -7,9 +7,9 @@ [wp] Loading driver 'share/wp.driver' [wp] Warning: Missing RTE guards [wp] 1 goal scheduled -[wp] [Alt-Ergo] Goal typed_output_ensures_KO : Unknown +[wp] [Alt-Ergo] Goal typed_output_ensures_KO : Step limit [wp] Proved goals: 0 / 1 - Alt-Ergo: 0 (unknown: 1) + Alt-Ergo: 0 (interrupted: 1) [wp] Report 'tests/wp_plugin/float_format.i.1.report.json' ------------------------------------------------------------- Functions WP Alt-Ergo Total Success diff --git a/tests/builtins/Longinit_sequencer.i b/tests/builtins/Longinit_sequencer.i index 2998da18c7d5bfa4f9e0d48f067fde4c44a6b860..4d9b50cd565baedf36d4ebb071a2915ff4527216 100644 --- a/tests/builtins/Longinit_sequencer.i +++ b/tests/builtins/Longinit_sequencer.i @@ -1,4 +1,4 @@ /* run.config* -EXECNOW: make tests/builtins/Longinit_sequencer.cmxs -OPT: -load-module tests/builtins/Longinit_sequencer.cmxs -eva-show-progress -res-file @PTEST_RESULT@ +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress -res-file @PTEST_RESULT@ */ diff --git a/tests/builtins/big_local_array.i b/tests/builtins/big_local_array.i index ccf98764fd086b47e1a139aa5743a4fee0a9b313..d6e1f53181467a2ec7876261086d4a39869f7d19 100644 --- a/tests/builtins/big_local_array.i +++ b/tests/builtins/big_local_array.i @@ -1,6 +1,7 @@ /* run.config* +EXECNOW: make -s @PTEST_DIR@/big_local_array_script.cmxs OPT: -eva-show-progress -print -journal-disable -eva -report -OPT: -load-script tests/builtins/big_local_array_script.ml -then-on prj -print -report +OPT: -load-module @PTEST_DIR@/big_local_array_script -then-on prj -print -report OPT: -eva-show-progress -print -journal-disable -no-initialized-padding-locals -eva */ diff --git a/tests/callgraph/function_pointer.i b/tests/callgraph/function_pointer.i index be249adbd33ce25d7fd82f7a52247bcc42cf0f7f..b28287119069e61b95d7115a89eeb8592e7e8412 100644 --- a/tests/callgraph/function_pointer.i +++ b/tests/callgraph/function_pointer.i @@ -1,10 +1,10 @@ /* run.config COMMENT: Test option -cg-function-pointers EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs - OPT: -cg-function-pointers -load-module @PTEST_DIR@/@PTEST_NAME@ - OPT: -cg-no-services -cg-function-pointers -load-module @PTEST_DIR@/@PTEST_NAME@ - OPT: -cg-no-function-pointers -load-module @PTEST_DIR@/@PTEST_NAME@ - OPT: -cg-no-services -cg-no-function-pointers -load-module @PTEST_DIR@/@PTEST_NAME@ + OPT: -cg-function-pointers -no-autoload-plugins -load-module eva,@PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -cg-no-services -cg-function-pointers -no-autoload-plugins -load-module eva,@PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -cg-no-function-pointers -no-autoload-plugins -load-module eva,@PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -cg-no-services -cg-no-function-pointers -no-autoload-plugins -load-module eva,@PTEST_DIR@/@PTEST_NAME@.cmxs */ int (*fptr)(int); diff --git a/tests/cil/mkBinOp.i b/tests/cil/mkBinOp.i index caa9dd0c396370d25700c25ca86ae605882e0348..1bab30cf83cef46281180438db232f21b9d1224b 100644 --- a/tests/cil/mkBinOp.i +++ b/tests/cil/mkBinOp.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -print -constfold +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print -constfold */ int main(void) { diff --git a/tests/constant_propagation/introduction_of_non_explicit_cast.c b/tests/constant_propagation/introduction_of_non_explicit_cast.c index 2d99b7676d0c061844695bf90822e6ed0fe5a68c..9e95b6e88db2c472e56cd47ad852b696c28e2a8b 100644 --- a/tests/constant_propagation/introduction_of_non_explicit_cast.c +++ b/tests/constant_propagation/introduction_of_non_explicit_cast.c @@ -1,8 +1,8 @@ /* run.config - OPT: -load-script tests/constant_propagation/introduction_of_non_explicit_cast.ml -eva -eva-show-progress -deps -journal-disable + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva -eva-show-progress -deps -journal-disable */ - int x,y,z; int TAB[10]; struct st { int a, b ; } s1, s2; diff --git a/tests/crowbar/integer_bb_pretty.ml b/tests/crowbar/integer_bb_pretty.ml new file mode 100644 index 0000000000000000000000000000000000000000..2c6ec812e2968f282f1efb3e3cb19a7c45c9ef0a --- /dev/null +++ b/tests/crowbar/integer_bb_pretty.ml @@ -0,0 +1,59 @@ +open Crowbar + +let reparse v s = + let failure info = + Crowbar.fail + ("Pretty-printing '" ^ (Z.to_string v) ^ "' returns '" ^ s ^ "'" ^ info) + in + if String.length s <= 2 then failure ""; + let is_neg = s.[0] = '1' in + let is_hex = s.[1] = 'x' in + let s = String.(concat "" (split_on_char '_' s)) in + let v' = + if is_neg then begin + let chr = if is_hex then 'F' else '1' in + let module M = struct exception Found of int end in + let check i c = if i > 1 && c <> chr then raise (M.Found i) in + try String.iteri check s; Z.minus_one + with M.Found idx -> + let len, v' = + if is_hex then begin + let remains = String.sub s idx (String.length s - idx) in + let v' = Z.of_string ("0x" ^ remains) in + 4 * (String.length remains), v' + end else begin + let remains = String.sub s idx (String.length s - idx) in + let v' = Z.of_string ("0b" ^ remains) in + String.length remains, v' + end + in + let m = Z.(one lsl len) in + let m = Z.pred m in + let v' = Z.logxor m v' in + Z.pred (Z.lognot (Z.pred v')) + end else + Z.of_string s + in + if not (Z.equal v v') then + failure (" reparsed as '" ^ Z.format "%b" v' ^ "' (" ^ Z.to_string v' ^ ")") + +let test z is_hex nbits has_sep = + guard (nbits >= 0 && nbits <= 1024); + let sep = if has_sep then Some "_" else None in + let pp z = if is_hex then + Integer.pp_hex ~nbits ?sep z + else + Integer.pp_bin ~nbits ?sep z + in + let s = Format.asprintf "%a" pp z in + reparse z s + +let zarith = + let open Crowbar in + fix (fun zarith -> + choose + [ map [int64] Z.of_int64; + map [zarith; int64] (fun z i -> Z.((z lsl 64) + of_int64 i)) ]) + +let () = Crowbar.add_test ~name:"pp_bin_hex" + [ zarith; Crowbar.bool; Crowbar.int; Crowbar.bool ] test diff --git a/tests/float/fval_test.i b/tests/float/fval_test.i index eda0e94bd4445ca7c827ff7600569fe3d5518e1d..cabb28768924493f9964d6329934d0356b2e5143 100644 --- a/tests/float/fval_test.i +++ b/tests/float/fval_test.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/float/fval_test.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ */ /* run.config* DONTRUN: diff --git a/tests/jcdb/jcdb.c b/tests/jcdb/jcdb.c index e065ddbec3380d2ffa6ebb902d1b3838a631422c..ddf00afcd0acb406597062b30cab1a821f769faf 100644 --- a/tests/jcdb/jcdb.c +++ b/tests/jcdb/jcdb.c @@ -2,7 +2,7 @@ EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -json-compilation-database @PTEST_DIR@ -print OPT: -json-compilation-database @PTEST_DIR@/with_arguments.json -print -OPT: -json-compilation-database @PTEST_DIR@/with_arguments.json -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -json-compilation-database @PTEST_DIR@/with_arguments.json -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs EXECNOW: LOG list_files.res LOG list_files.err share/analysis-scripts/list_files.py @PTEST_DIR@/compile_commands_working.json > @PTEST_DIR@/result/list_files.res 2> @PTEST_DIR@/result/list_files.err */ #include <stdio.h> diff --git a/tests/journal/control.i b/tests/journal/control.i index 03c9193098e1b927237577588f973faaeb7a6e45..8a7acc8e682ff542811632ac5f9436e3a9a0f4f9 100644 --- a/tests/journal/control.i +++ b/tests/journal/control.i @@ -5,10 +5,10 @@ OPT: -load-script tests/journal/result/control_journal -journal-disable CMD: FRAMAC_LIB=lib/fc ./bin/toplevel.byte OPT: -load-script tests/journal/result/control_journal_bis -calldeps -journal-disable - EXECNOW: BIN abstract_cpt_journal.ml FRAMAC_LIB=lib/fc ./bin/toplevel.byte -journal-enable -load-script tests/journal/abstract_cpt.ml -load-script tests/journal/use_cpt.ml -journal-name tests/journal/result/abstract_cpt_journal.ml > /dev/null 2> /dev/null + EXECNOW: make -s @PTEST_DIR@/abstract_cpt.cmxs + EXECNOW: BIN abstract_cpt_journal.ml FRAMAC_LIB=lib/fc ./bin/toplevel.byte -journal-enable -load-module @PTEST_DIR@/abstract_cpt -load-script tests/journal/use_cpt.ml -journal-name tests/journal/result/abstract_cpt_journal.ml > /dev/null 2> /dev/null CMD: FRAMAC_LIB=lib/fc ./bin/toplevel.byte - OPT: -load-script tests/journal/result/abstract_cpt_journal.ml -load-script tests/journal/abstract_cpt.ml -load-script tests/journal/use_cpt.ml - + OPT: -load-script tests/journal/result/abstract_cpt_journal.ml -load-module @PTEST_DIR@/abstract_cpt -load-script tests/journal/use_cpt.ml */ int x,y,c,d; diff --git a/tests/journal/intra.i b/tests/journal/intra.i index e5d5ab003425ddf34ceee667dbe4ede23b9338cd..dea5fdbface5e49569a2d52996e69ac8b4d52f06 100644 --- a/tests/journal/intra.i +++ b/tests/journal/intra.i @@ -1,7 +1,7 @@ /* run.config - EXECNOW: make -s tests/journal/intra.cmxs - EXECNOW: BIN intra_journal.ml @frama-c@ -eva-show-progress -load-module ./tests/journal/intra -journal-enable -journal-name tests/journal/result/intra_journal.ml tests/journal/intra.i > /dev/null 2> /dev/null - CMD: @frama-c@ -load-module ./tests/journal/intra + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + EXECNOW: BIN intra_journal.ml @frama-c@ -eva-show-progress -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -journal-enable -journal-name tests/journal/result/intra_journal.ml @PTEST_DIR@/@PTEST_NAME@.i > /dev/null 2> /dev/null + CMD: @frama-c@ -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -load-script tests/journal/result/intra_journal -journal-disable */ diff --git a/tests/libc/fc_libc.c b/tests/libc/fc_libc.c index 5b85156aea37ea5d264a52c07910e37b9eb1d4cd..298bc1b03740873f4764513b51d10747b6869bd3 100644 --- a/tests/libc/fc_libc.c +++ b/tests/libc/fc_libc.c @@ -1,7 +1,10 @@ /* run.config* - OPT: -load-script tests/libc/check_libc_naming_conventions.ml -print -cpp-extra-args='-nostdinc -Ishare/libc' -metrics -metrics-libc -load-script tests/libc/check_const.ml -load-module metrics -eva @VALUECONFIG@ -then -lib-entry -no-print -metrics-no-libc + EXECNOW: make -s @PTEST_DIR@/check_libc_naming_conventions.cmxs + EXECNOW: make -s @PTEST_DIR@/check_const.cmxs + EXECNOW: make -s @PTEST_DIR@/check_parsing_individual_headers.cmxs + OPT: -load-module @PTEST_DIR@/check_libc_naming_conventions -print -cpp-extra-args='-nostdinc -Ishare/libc' -metrics -metrics-libc -load-module @PTEST_DIR@/check_const -load-module metrics -eva @VALUECONFIG@ -then -lib-entry -no-print -metrics-no-libc OPT: -print -print-libc - OPT: -load-script tests/libc/check_parsing_individual_headers.ml + OPT: -load-module @PTEST_DIR@/check_parsing_individual_headers CMD: ./tests/libc/check_full_libc.sh OPT: **/ diff --git a/tests/libc/oracle/fc_libc.0.res.oracle b/tests/libc/oracle/fc_libc.0.res.oracle index ffa163ed517ced7ae131d1bd9f87f61300909256..c1ea9b1264b8f540555594d7684ce6cc084d13d7 100644 --- a/tests/libc/oracle/fc_libc.0.res.oracle +++ b/tests/libc/oracle/fc_libc.0.res.oracle @@ -4,10 +4,10 @@ [eva] Initial state computed [eva:initial-state] Values of globals at initialization -[eva] tests/libc/fc_libc.c:157: assertion got status valid. -[eva] tests/libc/fc_libc.c:158: assertion got status valid. -[eva] tests/libc/fc_libc.c:159: assertion got status valid. [eva] tests/libc/fc_libc.c:160: assertion got status valid. +[eva] tests/libc/fc_libc.c:161: assertion got status valid. +[eva] tests/libc/fc_libc.c:162: assertion got status valid. +[eva] tests/libc/fc_libc.c:163: assertion got status valid. [eva] Recording results for main [eva] done for function main [eva] ====== VALUES COMPUTED ====== diff --git a/tests/misc/add_assigns.i b/tests/misc/add_assigns.i index 5b2b95af84a9f8b267b95b237093296b438f8229..a6a820ecce977ef9f528f95bcb149fe3df18001a 100644 --- a/tests/misc/add_assigns.i +++ b/tests/misc/add_assigns.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -then -report -then -print +OPT: -no-autoload-plugins -load-module report,@PTEST_DIR@/@PTEST_NAME@.cmxs -then -report -then -print */ /*@ assigns *x; */ diff --git a/tests/misc/behavior_names.i b/tests/misc/behavior_names.i index 969831729e947a8c410642c19d50fbd01730a3f1..d4e48cb5bf64a0462aa4b9196b3d1dd23f533b9a 100644 --- a/tests/misc/behavior_names.i +++ b/tests/misc/behavior_names.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/behavior_names.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ behavior foo: ensures \true; */ diff --git a/tests/misc/bts0452.i b/tests/misc/bts0452.i index 98005844997d596e37329504f7abdabeaf175f76..1f3fc795582b79b21aad809bf852bfb655ce3cd7 100644 --- a/tests/misc/bts0452.i +++ b/tests/misc/bts0452.i @@ -1,7 +1,7 @@ /* run.config - OPT: -typecheck -load-script tests/misc/bts0452.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -typecheck -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ - /* must emit falls-through warning. */ int f (int foo, char** args) { switch(foo) { diff --git a/tests/misc/bts0489.i b/tests/misc/bts0489.i index db94a185c42a8f4948e11331ceed034f854b9a1f..c33db7d4c1a3f7b4d29d0fc48a0aeaf37101775b 100644 --- a/tests/misc/bts0489.i +++ b/tests/misc/bts0489.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/bts0489.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ typedef unsigned char uint8_t; diff --git a/tests/misc/bts1201.i b/tests/misc/bts1201.i index 7e59976a1ab11f91a4cde0c78ed7630c66fa5c14..cbaf4a4e3d114ba17709f3f7fc7bfe0c6f8f5d27 100644 --- a/tests/misc/bts1201.i +++ b/tests/misc/bts1201.i @@ -1,8 +1,8 @@ /* run.config - OPT: -eva-verbose 2 -load-script tests/misc/bts1201.ml -print + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -eva-verbose 2 -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ -void main() { - //@ assert \true; +void main() { //@ assert \true; } void main2() { diff --git a/tests/misc/bts1347.i b/tests/misc/bts1347.i index 4351b7a05c365f721926ec2916c2d8b9ba6c7e54..54f633c7beacbf0a298590ec7bd5efb20003b577 100644 --- a/tests/misc/bts1347.i +++ b/tests/misc/bts1347.i @@ -1,6 +1,6 @@ /* run.config - OPT: -load-script tests/misc/bts1347.ml -eva-show-progress -then -report + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress -then -report */ - int f(int *x) { return *x; } int g(int *x) { return *(x++); } diff --git a/tests/misc/bug_0209.c b/tests/misc/bug_0209.c index e1c584267f93d9cbebcfba033d9ae35f99eec16f..a345a39f3b0ce1c51d4d918965de6620914abbde 100644 --- a/tests/misc/bug_0209.c +++ b/tests/misc/bug_0209.c @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/bug_0209.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ // Everything is done by the script diff --git a/tests/misc/callsite.i b/tests/misc/callsite.i index cb222eb5e95aa3ea93f1f110a8eb5e8b88bca06e..7dcfc493a8c89c38f1bb6189b0c562cccb8841e9 100644 --- a/tests/misc/callsite.i +++ b/tests/misc/callsite.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/callsite.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ // Don't use -debug 1 option in the test command. diff --git a/tests/misc/change_main.i b/tests/misc/change_main.i index 9239d7f51bb663bc2a4d62f841a4887970a04919..c6f70943352c91f4348680131c67bb9e27329040 100644 --- a/tests/misc/change_main.i +++ b/tests/misc/change_main.i @@ -1,5 +1,6 @@ /* run.config* -OPT: -eva -main f -load-script tests/misc/change_main.ml -then-on change_main -main g -eva +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -eva -main f -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -then-on change_main -main g -eva */ int f(int x) { return x; } diff --git a/tests/misc/cli_string_multiple_map.i b/tests/misc/cli_string_multiple_map.i index 35a34f02c7751c7f8f58cc91af0f557d408f1c04..b4a7c3bc23730ae8b09c9d851046c6b3e300b520 100644 --- a/tests/misc/cli_string_multiple_map.i +++ b/tests/misc/cli_string_multiple_map.i @@ -1,3 +1,4 @@ /* run.config - OPT: -load-script tests/misc/cli_string_multiple_map.ml -multiple-map a:1,b:2,a:3 + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -multiple-map a:1,b:2,a:3 */ diff --git a/tests/misc/copy_kf.i b/tests/misc/copy_kf.i index 029cbd00d67d6d1580476a8703c235814ecc057c..15fe7d6bc47b3ae91e25275f2bc159cebaeca86d 100644 --- a/tests/misc/copy_kf.i +++ b/tests/misc/copy_kf.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ requires \valid(p); assigns *p; ensures *p == x; */ diff --git a/tests/misc/copy_machdep.i b/tests/misc/copy_machdep.i index 3c150a094ff67a252ea8c3875e854a75b839b327..0b6f32f439f5a76fcda2d18135977d049f386d84 100644 --- a/tests/misc/copy_machdep.i +++ b/tests/misc/copy_machdep.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -machdep x86_64 -enums int -no-unicode +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -machdep x86_64 -enums int -no-unicode */ int main () { return 0; } diff --git a/tests/misc/custom_machdep.c b/tests/misc/custom_machdep.c index e92b67f2a8e902f76929347cdee85a7b35688149..f7a377dc16250f21911dbc5f014d7a50b33bac3f 100644 --- a/tests/misc/custom_machdep.c +++ b/tests/misc/custom_machdep.c @@ -1,5 +1,6 @@ /* run.config* -OPT: -cpp-extra-args="-I@PTEST_DIR@/@PTEST_NAME@ -D__FC_MACHDEP_CUSTOM" -load-script @PTEST_DIR@/@PTEST_NAME@/@PTEST_NAME@.ml -machdep custom -print -then -print +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@/@PTEST_NAME@.cmxs +OPT: -cpp-extra-args="-I@PTEST_DIR@/@PTEST_NAME@ -D__FC_MACHDEP_CUSTOM" -load-module @PTEST_DIR@/@PTEST_NAME@/@PTEST_NAME@ -machdep custom -print -then -print COMMENT: we need a -then to test double registering of a machdep */ diff --git a/tests/misc/ensures.i b/tests/misc/ensures.i index 140bf8122f031aa574e460218275fceb1fb3112b..ae04e6fb897e157311e2131e8c00117972aaa048 100644 --- a/tests/misc/ensures.i +++ b/tests/misc/ensures.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/ensures.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ //@ ensures *p==1; void main(int * p){ *p = 0; } diff --git a/tests/misc/exception.i b/tests/misc/exception.i index 4b73ec776649d824fae164bf23655cd6ab7c26c1..a6e5006eb7dbab9286b39fbeaf6ea28e5c22be19 100644 --- a/tests/misc/exception.i +++ b/tests/misc/exception.i @@ -1,7 +1,7 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs - OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -print - OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -remove-exn -print + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -remove-exn -print */ struct my_exn { int e; }; diff --git a/tests/misc/filepath.i b/tests/misc/filepath.i index eb178f8224607c8dce90532cc9b037ff562b16f4..f5c0183704fb0f14aba28d804eb133137365c870 100644 --- a/tests/misc/filepath.i +++ b/tests/misc/filepath.i @@ -1,3 +1,4 @@ /* run.config - OPT: -no-autoload-plugins -load-module @PTEST_DIR@/filepath_test.ml + EXECNOW: make -s @PTEST_DIR@/filepath_test.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/filepath_test */ diff --git a/tests/misc/find_enclosing_loop.c b/tests/misc/find_enclosing_loop.c index 0a46b537168e8095a426f03541433800664ae563..76cc35a53187fc9e58ea906527669b5a9482e117 100644 --- a/tests/misc/find_enclosing_loop.c +++ b/tests/misc/find_enclosing_loop.c @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/misc/find_enclosing_loop.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ void f () { diff --git a/tests/misc/global_decl_loc.i b/tests/misc/global_decl_loc.i index 3da30326dde49e4dacd4027a5ac9515fe448b0b5..d13cbce847364dbce968f270f47d9cae11260cd8 100644 --- a/tests/misc/global_decl_loc.i +++ b/tests/misc/global_decl_loc.i @@ -1,4 +1,4 @@ /* run.config - OPT: @PTEST_DIR@/global_decl_loc2.i -load-module @PTEST_DIR@/global_decl_loc.cmxs + OPT: @PTEST_DIR@/global_decl_loc2.i -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int g; diff --git a/tests/misc/init_from_cil.i b/tests/misc/init_from_cil.i index 276161982d21dae400626a206eca75b7064b3b44..7d767032b7e6c7ef1acc8f6a4a7e1ff655cab5f7 100644 --- a/tests/misc/init_from_cil.i +++ b/tests/misc/init_from_cil.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/init_from_cil.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int f(int x); diff --git a/tests/misc/issue109.i b/tests/misc/issue109.i index 5d51ec4b48a0d12becb70887d913d3b9527781cd..51c709c227b1c61c905901b787e50e87c0825216 100644 --- a/tests/misc/issue109.i +++ b/tests/misc/issue109.i @@ -1,7 +1,7 @@ /* run.config - OPT: -eva -eva-show-progress -slevel-function main:10 -load-script tests/misc/issue109.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -eva -eva-show-progress -slevel-function main:10 -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ - void main() { int i, j = 0; for (i=0; i<10; i++) { diff --git a/tests/misc/issue_191.c b/tests/misc/issue_191.c index bbba9a680d785fa60685908e9b32322d466639ec..a345a39f3b0ce1c51d4d918965de6620914abbde 100644 --- a/tests/misc/issue_191.c +++ b/tests/misc/issue_191.c @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/issue_191.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ // Everything is done by the script diff --git a/tests/misc/justcopy.i b/tests/misc/justcopy.i index 1045df89354df37d9bb6936a454ceedadd769c85..8cfd1982b8925ce6626f5d9b9d91594011759c5a 100644 --- a/tests/misc/justcopy.i +++ b/tests/misc/justcopy.i @@ -1,3 +1,4 @@ /* run.config - OPT: -load-script tests/misc/justcopy.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ diff --git a/tests/misc/keep_entry_point.i b/tests/misc/keep_entry_point.i index 48746aabe0562d04934b6bf12ea7d704afc45169..6ade640dbb8933cb359dac79d608f7acf33fc4d3 100644 --- a/tests/misc/keep_entry_point.i +++ b/tests/misc/keep_entry_point.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -main f -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print +OPT: -main f -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ static int f(void); diff --git a/tests/misc/log-file.i b/tests/misc/log-file.i index 661521ddb7c8d6f929fc18396167c8510f561b67..833ee51da34f8228cc4ab373fe8573b430b7ca3f 100644 --- a/tests/misc/log-file.i +++ b/tests/misc/log-file.i @@ -1,4 +1,5 @@ /* run.config + EXECNOW: make -s @PTEST_DIR@/plugin_log.cmxs LOG: log-file-kernel-warnings.txt LOG: log-file-kernel-results.txt LOG: log-file-feedback.txt @@ -7,7 +8,7 @@ LOG: plugin-log-all.txt FILTER: sed 's|Your Frama-C version is.*|Your Frama-C version is VERSION|' STDOPT: #"-kernel-log w:@PTEST_RESULT@/log-file-kernel-warnings.txt,r:@PTEST_RESULT@/log-file-kernel-results.txt -eva-log f:@PTEST_RESULT@/log-file-feedback.txt,afewr:@PTEST_RESULT@/log-file-value-all.txt -eva-log :@PTEST_RESULT@/log-file-value-default.txt -then -kernel-log f:@PTEST_RESULT@/log-file-feedback.txt" - OPT: -load-module tests/misc/plugin_log.ml -kernel-msg-key foo-category -kernel-log=a:@PTEST_RESULT@/plugin-log-all.txt + OPT: -load-module tests/misc/plugin_log -kernel-msg-key foo-category -kernel-log=a:@PTEST_RESULT@/plugin-log-all.txt DONTRUN: test disabled due to non-deterministic errors in CI */ int f(void); // generates kernel warning (missing spec) diff --git a/tests/misc/log_twice.i b/tests/misc/log_twice.i index 4d912840dfc75a6f69c357e731f420a3b333ed44..e5c6f3a5f23f1f5e9fbe1a0f713c81101ead221d 100644 --- a/tests/misc/log_twice.i +++ b/tests/misc/log_twice.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/log_twice -eva-show-progress + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -eva-show-progress */ int* f() { diff --git a/tests/misc/my_visitor.c b/tests/misc/my_visitor.c index 921a82c24c416653c44b705dedb7d86cb431dd12..29355fd152e80c899adebc677eb1abba062d46d5 100644 --- a/tests/misc/my_visitor.c +++ b/tests/misc/my_visitor.c @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -EXECNOW: LOG my_visitor_sav.res LOG my_visitor_sav.err BIN my_visitor.sav FRAMAC_PLUGIN=./lib/plugins @frama-c@ @PTEST_FILE@ -load-module @PTEST_DIR@/@PTEST_NAME@ -main f -save @PTEST_DIR@/@PTEST_NAME@.sav > @PTEST_DIR@/result/@PTEST_NAME@_sav.res 2> @PTEST_DIR@/result/@PTEST_NAME@_sav.err +EXECNOW: LOG my_visitor_sav.res LOG my_visitor_sav.err BIN my_visitor.sav FRAMAC_PLUGIN=./lib/plugins @frama-c@ @PTEST_FILE@ -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -main f -save @PTEST_DIR@/@PTEST_NAME@.sav > @PTEST_DIR@/result/@PTEST_NAME@_sav.res 2> @PTEST_DIR@/result/@PTEST_NAME@_sav.err OPT: -load @PTEST_DIR@/@PTEST_NAME@.sav -print */ int f() { diff --git a/tests/misc/oracle/ensures.res.oracle b/tests/misc/oracle/ensures.res.oracle index 7648b92dd837a79640186839b0e38b1770b249e8..7acf87d61616ae7b517495ee6013e35bbdeaf2a7 100644 --- a/tests/misc/oracle/ensures.res.oracle +++ b/tests/misc/oracle/ensures.res.oracle @@ -4,7 +4,7 @@ [eva] Initial state computed [eva:initial-state] Values of globals at initialization -[eva:alarm] tests/misc/ensures.i:4: Warning: +[eva:alarm] tests/misc/ensures.i:5: Warning: function main: postcondition got status invalid. [eva] done for function main [kernel] main: behavior default! diff --git a/tests/misc/oracle/log-file-feedback.txt b/tests/misc/oracle/log-file-feedback.txt index 36ffb1f22e57f630e6be7ebd23b2467ab31370ea..941d344dc0af8f47c2ec0f194933b87cdb04c53a 100644 --- a/tests/misc/oracle/log-file-feedback.txt +++ b/tests/misc/oracle/log-file-feedback.txt @@ -3,13 +3,13 @@ [eva] Computing initial state [eva] Initial state computed [eva] computing for function f <- main. -Called from tests/misc/log-file.i:18. +Called from tests/misc/log-file.i:20. [eva] using specification for function f [eva] Done for function f [eva] computing for function g <- main. -Called from tests/misc/log-file.i:19. +Called from tests/misc/log-file.i:21. [eva] using specification for function g [eva] Done for function g -tests/misc/log-file.i:20:[eva] starting to merge loop iterations +tests/misc/log-file.i:22:[eva] starting to merge loop iterations [eva] Recording results for main [eva] done for function main diff --git a/tests/misc/oracle/log-file-kernel-warnings.txt b/tests/misc/oracle/log-file-kernel-warnings.txt index 3ab2fc7cdc3e703ae681512fcc3dfe307c4e2042..4e35b1c74cec91a3ba4e36c94232ff1ccbbf3e6e 100644 --- a/tests/misc/oracle/log-file-kernel-warnings.txt +++ b/tests/misc/oracle/log-file-kernel-warnings.txt @@ -1 +1 @@ -tests/misc/log-file.i:18:[kernel:annot:missing-spec] warning: Neither code nor specification for function f, generating default assigns from the prototype +tests/misc/log-file.i:20:[kernel:annot:missing-spec] warning: Neither code nor specification for function f, generating default assigns from the prototype diff --git a/tests/misc/oracle/log-file-value-all.txt b/tests/misc/oracle/log-file-value-all.txt index 258754c1f7f836687e390ddb4e262f18960c866d..c19d8ff15faac9301d00a3f1878c008f2c7ef9fe 100644 --- a/tests/misc/oracle/log-file-value-all.txt +++ b/tests/misc/oracle/log-file-value-all.txt @@ -2,15 +2,15 @@ [eva] Computing initial state [eva] Initial state computed [eva] computing for function f <- main. -Called from tests/misc/log-file.i:18. +Called from tests/misc/log-file.i:20. [eva] using specification for function f [eva] Done for function f [eva] computing for function g <- main. -Called from tests/misc/log-file.i:19. +Called from tests/misc/log-file.i:21. [eva] using specification for function g -tests/misc/log-file.i:15:[eva] warning: no 'assigns \result \from ...' clause specified for function g +tests/misc/log-file.i:17:[eva] warning: no 'assigns \result \from ...' clause specified for function g [eva] Done for function g -tests/misc/log-file.i:20:[eva] starting to merge loop iterations +tests/misc/log-file.i:22:[eva] starting to merge loop iterations [eva] Recording results for main [eva] done for function main [eva] ====== VALUES COMPUTED ====== diff --git a/tests/misc/oracle/log-file-value-default.txt b/tests/misc/oracle/log-file-value-default.txt index 9d4908aa0b45d572c09498784aaebc250f71a300..93553049c30efa17102275ef8c4b8187d04efeea 100644 --- a/tests/misc/oracle/log-file-value-default.txt +++ b/tests/misc/oracle/log-file-value-default.txt @@ -1,2 +1,2 @@ -tests/misc/log-file.i:15:[eva] warning: no 'assigns \result \from ...' clause specified for function g +tests/misc/log-file.i:17:[eva] warning: no 'assigns \result \from ...' clause specified for function g [eva] ====== VALUES COMPUTED ====== diff --git a/tests/misc/oracle/log-file.0.res.oracle b/tests/misc/oracle/log-file.0.res.oracle index 75c688457ba46f7f783c6fa33d20957f376a068f..83288a2ea513c05a7125a26eea8b5a4cee999871 100644 --- a/tests/misc/oracle/log-file.0.res.oracle +++ b/tests/misc/oracle/log-file.0.res.oracle @@ -5,18 +5,18 @@ [eva:initial-state] Values of globals at initialization [eva] computing for function f <- main. - Called from tests/misc/log-file.i:18. -[kernel:annot:missing-spec] tests/misc/log-file.i:18: Warning: + Called from tests/misc/log-file.i:20. +[kernel:annot:missing-spec] tests/misc/log-file.i:20: Warning: Neither code nor specification for function f, generating default assigns from the prototype [eva] using specification for function f [eva] Done for function f [eva] computing for function g <- main. - Called from tests/misc/log-file.i:19. + Called from tests/misc/log-file.i:21. [eva] using specification for function g -[eva] tests/misc/log-file.i:15: Warning: +[eva] tests/misc/log-file.i:17: Warning: no 'assigns \result \from ...' clause specified for function g [eva] Done for function g -[eva] tests/misc/log-file.i:20: starting to merge loop iterations +[eva] tests/misc/log-file.i:22: starting to merge loop iterations [eva] Recording results for main [eva] done for function main [eva] ====== VALUES COMPUTED ====== diff --git a/tests/misc/oracle/log_twice.res.oracle b/tests/misc/oracle/log_twice.res.oracle index 871920c55ba2fee41bfc176a78c22e59d809ea86..30fcb6869ca0f742ade2702953dcb5493a9573e9 100644 --- a/tests/misc/oracle/log_twice.res.oracle +++ b/tests/misc/oracle/log_twice.res.oracle @@ -5,19 +5,19 @@ [eva:initial-state] Values of globals at initialization [eva] computing for function f <- main. - Called from tests/misc/log_twice.i:11. + Called from tests/misc/log_twice.i:12. [eva] Recording results for f [eva] Done for function f -[eva:locals-escaping] tests/misc/log_twice.i:11: Warning: +[eva:locals-escaping] tests/misc/log_twice.i:12: Warning: locals {x} escaping the scope of f through \result<f> -[eva:alarm] tests/misc/log_twice.i:12: Warning: +[eva:alarm] tests/misc/log_twice.i:13: Warning: accessing left-value that contains escaping addresses. assert ¬\dangling(&p); -[kernel] tests/misc/log_twice.i:12: Warning: +[kernel] tests/misc/log_twice.i:13: Warning: all target addresses were invalid. This path is assumed to be dead. [eva] Recording results for main [eva] done for function main -[eva] tests/misc/log_twice.i:12: +[eva] tests/misc/log_twice.i:13: assertion 'Eva,dangling_pointer' got final status invalid. [eva] Analyzing a complete application starting at main [eva] Computing initial state @@ -25,17 +25,17 @@ [eva:initial-state] Values of globals at initialization [eva] computing for function f <- main. - Called from tests/misc/log_twice.i:11. + Called from tests/misc/log_twice.i:12. [eva] Recording results for f [eva] Done for function f -[eva:locals-escaping] tests/misc/log_twice.i:11: Warning: +[eva:locals-escaping] tests/misc/log_twice.i:12: Warning: locals {x} escaping the scope of f through \result<f> -[eva:alarm] tests/misc/log_twice.i:12: Warning: +[eva:alarm] tests/misc/log_twice.i:13: Warning: accessing left-value that contains escaping addresses. assert ¬\dangling(&p); -[kernel] tests/misc/log_twice.i:12: Warning: +[kernel] tests/misc/log_twice.i:13: Warning: all target addresses were invalid. This path is assumed to be dead. [eva] Recording results for main [eva] done for function main -[eva] tests/misc/log_twice.i:12: +[eva] tests/misc/log_twice.i:13: assertion 'Eva,dangling_pointer' got final status invalid. diff --git a/tests/misc/oracle/pp_bin_hex.res.oracle b/tests/misc/oracle/pp_bin_hex.res.oracle new file mode 100644 index 0000000000000000000000000000000000000000..4791a522a343769216bd7ce7e105707e34f739e4 --- /dev/null +++ b/tests/misc/oracle/pp_bin_hex.res.oracle @@ -0,0 +1,86 @@ +-------------------------------------------------- +Dec. 0 +Hex. 0x0000 +Bin. 0b0000_0000 +-------------------------------------------------- +Dec. 1 +Hex. 0x0001 +Bin. 0b0000_0001 +-------------------------------------------------- +Dec. -1 +Hex. 1xFFFF +Bin. 1b1111_1111 +-------------------------------------------------- +Dec. 2 +Hex. 0x0002 +Bin. 0b0000_0010 +-------------------------------------------------- +Dec. -2 +Hex. 1xFFFE +Bin. 1b1111_1110 +-------------------------------------------------- +Dec. 5 +Hex. 0x0005 +Bin. 0b0000_0101 +-------------------------------------------------- +Dec. -5 +Hex. 1xFFFB +Bin. 1b1111_1011 +-------------------------------------------------- +Dec. 9 +Hex. 0x0009 +Bin. 0b0000_1001 +-------------------------------------------------- +Dec. -9 +Hex. 1xFFF7 +Bin. 1b1111_0111 +-------------------------------------------------- +Dec. 16 +Hex. 0x0010 +Bin. 0b0001_0000 +-------------------------------------------------- +Dec. -16 +Hex. 1xFFF0 +Bin. 1b1111_0000 +-------------------------------------------------- +Dec. 127 +Hex. 0x007F +Bin. 0b0111_1111 +-------------------------------------------------- +Dec. -127 +Hex. 1xFF81 +Bin. 1b1000_0001 +-------------------------------------------------- +Dec. 128 +Hex. 0x0080 +Bin. 0b1000_0000 +-------------------------------------------------- +Dec. -128 +Hex. 1xFF80 +Bin. 1b1000_0000 +-------------------------------------------------- +Dec. 255 +Hex. 0x00FF +Bin. 0b1111_1111 +-------------------------------------------------- +Dec. -255 +Hex. 1xFF01 +Bin. 1b0000_0001 +-------------------------------------------------- +Dec. 4279173135 +Hex. 0xFF0F_000F +Bin. 0b1111_1111_0000_1111_0000_0000_0000_1111 +-------------------------------------------------- +Dec. -4279173135 +Hex. 1x00F0_FFF1 +Bin. 1b0000_0000_1111_0000_1111_1111_1111_0001 +-------------------------------------------------- +Dec. 386334727 +Hex. 0x1707_0007 +Bin. 0b0001_0111_0000_0111_0000_0000_0000_0111 +-------------------------------------------------- +Dec. -386334727 +Hex. 1xE8F8_FFF9 +Bin. 1b1110_1000_1111_1000_1111_1111_1111_1001 +-------------------------------------------------- +[kernel] Parsing tests/misc/pp_bin_hex.i (no preprocessing) diff --git a/tests/misc/oracle/save_comments.res.oracle b/tests/misc/oracle/save_comments.res.oracle index fa8ecc7b92399bcdf1721529af1bad62ab343057..939609307f205e0f994526ba6ebc2ea685f0989c 100644 --- a/tests/misc/oracle/save_comments.res.oracle +++ b/tests/misc/oracle/save_comments.res.oracle @@ -2,7 +2,8 @@ Printing default project first time: /* Generated by Frama-C */ /* run.config - OPT: -load-script tests/misc/save_comments.ml -keep-comments + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -keep-comments */ int f(void) { @@ -15,7 +16,8 @@ int f(void) Printing default project second time: /* Generated by Frama-C */ /* run.config - OPT: -load-script tests/misc/save_comments.ml -keep-comments + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -keep-comments */ int f(void) { @@ -34,7 +36,8 @@ End of comments Printing saved project: /* Generated by Frama-C */ /* run.config - OPT: -load-script tests/misc/save_comments.ml -keep-comments + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -keep-comments */ int f(void) { diff --git a/tests/misc/pp_bin_hex.i b/tests/misc/pp_bin_hex.i new file mode 100644 index 0000000000000000000000000000000000000000..a53499be69922b6d91cd0d4926968829ccf22a93 --- /dev/null +++ b/tests/misc/pp_bin_hex.i @@ -0,0 +1,3 @@ +/* run.config + OPT: -no-autoload-plugins -load-script tests/misc/pp_bin_hex.ml +*/ diff --git a/tests/misc/pp_bin_hex.ml b/tests/misc/pp_bin_hex.ml new file mode 100644 index 0000000000000000000000000000000000000000..41ab2e6ab92ee1beef120983f3e307461ada4811 --- /dev/null +++ b/tests/misc/pp_bin_hex.ml @@ -0,0 +1,37 @@ +let pp_dec fmt z = Integer.pretty ~hexa:false fmt z +let pp_hex fmt z = Integer.pp_hex ~nbits:16 ~sep:"_" fmt z +let pp_bin fmt z = Integer.pp_bin ~nbits:8 ~sep:"_" fmt z + +let hrule () = + Format.printf "--------------------------------------------------@." + +let testcase z = + begin + hrule () ; + Format.printf "Dec. %a@." pp_dec z ; + Format.printf "Hex. %a@." pp_hex z ; + Format.printf "Bin. %a@." pp_bin z ; + end + +let () = + begin + List.iter + (fun z -> + testcase z ; + if not (Integer.equal z Integer.zero) then + testcase (Integer.neg z) + ) [ + Integer.of_string "0" ; + Integer.of_string "1" ; + Integer.of_string "2" ; + Integer.of_string "5" ; + Integer.of_string "9" ; + Integer.of_string "16" ; + Integer.of_string "127" ; + Integer.of_string "128" ; + Integer.of_string "0xFF" ; + Integer.of_string "0xFF0F000F" ; + Integer.of_string "0x17070007" ; + ] ; + hrule () ; + end diff --git a/tests/misc/print_machdep.i b/tests/misc/print_machdep.i index 80afbbd20f335c72d597dbc6c45cf6e37d304c37..0762669acd646cdbd6257081b52f420d15c7e2b2 100644 --- a/tests/misc/print_machdep.i +++ b/tests/misc/print_machdep.i @@ -1,4 +1,3 @@ /* run.config - CMD: @frama-c@ -no-autoload-plugins - OPT: -print-machdep + OPT: -no-autoload-plugins -print-machdep */ diff --git a/tests/misc/remove_status_hyps.i b/tests/misc/remove_status_hyps.i index 65348944a6d4a5ede92bee270d3aa2c8352a3070..a436356626c8169ba8c349bf26bb5d2d31c72a52 100644 --- a/tests/misc/remove_status_hyps.i +++ b/tests/misc/remove_status_hyps.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/remove_status_hyps.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int main(void) { diff --git a/tests/misc/save_comments.i b/tests/misc/save_comments.i index 6ee3a950e34b306f68b62dc474d4a364156afafb..aaf7cccdef62fdaaaea56d6e6b5160163941eea4 100644 --- a/tests/misc/save_comments.i +++ b/tests/misc/save_comments.i @@ -1,8 +1,8 @@ /* run.config - OPT: -load-script tests/misc/save_comments.ml -keep-comments + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -keep-comments */ - int f() { int x = 0; /* Hello, I'm the f function */ diff --git a/tests/misc/static.i b/tests/misc/static.i index 4c5ea035b725324d3a71332ef52c1d4e2a78a5ad..b0863c3a2b3908f34f1bfe07919867975270aa3c 100644 --- a/tests/misc/static.i +++ b/tests/misc/static.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int x; diff --git a/tests/misc/test_datatype.i b/tests/misc/test_datatype.i index ffe2a11b457e9c4671e36a98bb2106a129035cd6..19405eb11ec4c3d5e608f535e9aeab5f595fb19a 100644 --- a/tests/misc/test_datatype.i +++ b/tests/misc/test_datatype.i @@ -1,4 +1,4 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ diff --git a/tests/misc/version.i b/tests/misc/version.i index cd0bcd0bf8696a3febda5e79680981cf9a2aed9d..3a762af550b5fb818f962ec7d88d225747f95e50 100644 --- a/tests/misc/version.i +++ b/tests/misc/version.i @@ -1,3 +1,4 @@ /* run.config - OPT: -load-script tests/misc/version.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ diff --git a/tests/misc/vis_queueInstr.i b/tests/misc/vis_queueInstr.i index f9f32820ed0dc77562cb2d9e938ec18c823d4a97..61fd2bb820de4616e9e18edfc2cd55a5eedd711b 100644 --- a/tests/misc/vis_queueInstr.i +++ b/tests/misc/vis_queueInstr.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print -then-on A -print +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print -then-on A -print */ int main(){ diff --git a/tests/misc/vis_spec.i b/tests/misc/vis_spec.i index 9515609a61d1cc5892d2bd348a2f5ffb61f4d9cd..c40858396b4be923663a262dc97a0cdc4b187771 100644 --- a/tests/misc/vis_spec.i +++ b/tests/misc/vis_spec.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/vis_spec.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ //@ assigns \nothing; diff --git a/tests/misc/visitor_creates_func_bts_1349.i b/tests/misc/visitor_creates_func_bts_1349.i index 3fc9e30144b24c39aacd54b9183f1f5617cb66e7..a03c0cd1c45050418effd185243b6dff7a1f7e3e 100644 --- a/tests/misc/visitor_creates_func_bts_1349.i +++ b/tests/misc/visitor_creates_func_bts_1349.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/Visitor_creates_func_bts_1349.ml -then-on test -print + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-script @PTEST_DIR@/@PTEST_NAME@ -then-on test -print */ int a = 10; diff --git a/tests/misc/Visitor_creates_func_bts_1349.ml b/tests/misc/visitor_creates_func_bts_1349.ml similarity index 100% rename from tests/misc/Visitor_creates_func_bts_1349.ml rename to tests/misc/visitor_creates_func_bts_1349.ml diff --git a/tests/misc/well_typed_alarm.i b/tests/misc/well_typed_alarm.i index ec5f84df44fadd1ae56dfd540851c7dc198c0794..236200877af3a87006d77bafa01de09eef090645 100644 --- a/tests/misc/well_typed_alarm.i +++ b/tests/misc/well_typed_alarm.i @@ -1,7 +1,7 @@ /* run.config* -OPT: -load-script @PTEST_DIR@/@PTEST_NAME@.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ - int main(int c) { int x = 0; int y = 0; diff --git a/tests/pdg/dyn_dpds.c b/tests/pdg/dyn_dpds.c index 459bd5a60d78cfeaf7100d5e608388f1caaa6a41..20168cf1621c6ed2ae366c5dc958e353dd524c74 100644 --- a/tests/pdg/dyn_dpds.c +++ b/tests/pdg/dyn_dpds.c @@ -1,17 +1,17 @@ /* run.config - OPT: -load-script tests/pdg/dyn_dpds.ml -eva-show-progress -deps -journal-disable -pdg-print -pdg-verbose 2 + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress -deps -journal-disable -pdg-print -pdg-verbose 2 */ /* To have a look at the dot PDG : - bin/toplevel.byte -deps -pdg-dot pdg -eva-show-progress -fct-pdg main tests/pdg/dyn_dpds.c ; + bin/toplevel.byte -deps -pdg-dot pdg -eva-show-progress -fct-pdg main @PTEST_DIR@/@PTEST_NAME@.c ; zgrviewer pdg.main.dot - or use tests/pdg/dyn_dpds.ml to test the dynamic dependencies. + or use @PTEST_DIR@/@PTEST_NAME@.ml to test the dynamic dependencies. */ - int G; int main (int a, int b, int c) { diff --git a/tests/pdg/sets.c b/tests/pdg/sets.c index 9623e013f31c3dbe56f85351cb8bb66e57864cc7..3efc61ce72bd3318339f327989bcf123587acb84 100644 --- a/tests/pdg/sets.c +++ b/tests/pdg/sets.c @@ -1,9 +1,9 @@ /* run.config - OPT: -eva-show-progress -load-script tests/pdg/sets.ml -lib-entry -main f -pdg -inout -journal-disable -pdg-print -pdg-verbose 2 + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -eva-show-progress -load-module @PTEST_DIR@/@PTEST_NAME@ -lib-entry -main f -pdg -inout -journal-disable -pdg-print -pdg-verbose 2 */ - int b, c, x, y, z, t; void f(int a) { y = 0; // 1, node 9 diff --git a/tests/rte/precond2.c b/tests/rte/precond2.c index 2c3844e757435034d26935ecf9cfd2dcc952e029..72d360e0d96667335f976b60727fdeb9843b965c 100644 --- a/tests/rte/precond2.c +++ b/tests/rte/precond2.c @@ -1,5 +1,6 @@ /* run.config - OPT: -warn-special-float none -load-script tests/rte/compute_annot/compute_annot.ml -journal-disable + EXECNOW: make -s @PTEST_DIR@/compute_annot/compute_annot.cmxs + OPT: -warn-special-float none -load-module @PTEST_DIR@/compute_annot/compute_annot -journal-disable */ int global = 15; diff --git a/tests/rte/threefunc.c b/tests/rte/threefunc.c index 44aa8d37cd24c7e8fbd3027e21a2ead6d43c24d6..03b2ad3b373fd5dcc26253574999f9bccfa59a30 100644 --- a/tests/rte/threefunc.c +++ b/tests/rte/threefunc.c @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/rte/my_annotation/my_annotation.ml +EXECNOW: make -s @PTEST_DIR@/my_annotation/my_annotation.cmxs +OPT: -load-module @PTEST_DIR@/my_annotation/my_annotation */ diff --git a/tests/rte/twofunc.c b/tests/rte/twofunc.c index 38ce35dac65ffdac7071447de3145e63aa84bed7..2732ad9f1f99b79c79b2f9450870d3904a69cd71 100644 --- a/tests/rte/twofunc.c +++ b/tests/rte/twofunc.c @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/rte/my_annot_proxy/my_annot_proxy.ml +EXECNOW: make -s @PTEST_DIR@/my_annot_proxy/my_annot_proxy.cmxs +OPT: -load-module @PTEST_DIR@/my_annot_proxy/my_annot_proxy */ diff --git a/tests/rte/twofunc3.c b/tests/rte/twofunc3.c index 8894e7cbee4a51fb176dc870a4302db5171ae2ad..b7102aaf7086db45e0bfbf0924a346a8edab1bcb 100644 --- a/tests/rte/twofunc3.c +++ b/tests/rte/twofunc3.c @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/rte/rte_api/rte_get_annot.ml -journal-disable + EXECNOW: make -s @PTEST_DIR@/rte_api/rte_get_annot.cmxs + OPT: -load-module @PTEST_DIR@/rte_api/rte_get_annot -journal-disable */ diff --git a/tests/saveload/basic.i b/tests/saveload/basic.i index d091c2203be2d30c683283c29998dddb3d416940..e0d5d8f8b74aa58031d88339800120da3fb0c659 100644 --- a/tests/saveload/basic.i +++ b/tests/saveload/basic.i @@ -1,13 +1,14 @@ /* run.config - EXECNOW: make -s ./tests/saveload/basic.cmxs - EXECNOW: LOG basic_sav.res LOG basic_sav.err BIN basic.sav @frama-c@ -load-module ./tests/saveload/basic -eva -out -input -deps -eva-show-progress ./tests/saveload/basic.i -save ./tests/saveload/result/basic.sav > ./tests/saveload/result/basic_sav.res 2> ./tests/saveload/result/basic_sav.err - EXECNOW: LOG basic_sav.1.res LOG basic_sav.1.err BIN basic.1.sav ./bin/toplevel.opt -save ./tests/saveload/result/basic.1.sav ./tests/saveload/basic.i -eva -out -input -deps -eva-show-progress > ./tests/saveload/result/basic_sav.1.res 2> ./tests/saveload/result/basic_sav.1.err + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + EXECNOW: LOG basic_sav.res LOG basic_sav.err BIN basic.sav @frama-c@ -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva -out -input -deps -eva-show-progress ./@PTEST_DIR@/@PTEST_NAME@.i -save ./tests/saveload/result/basic.sav > ./tests/saveload/result/basic_sav.res 2> ./tests/saveload/result/basic_sav.err + EXECNOW: LOG basic_sav.1.res LOG basic_sav.1.err BIN basic.1.sav ./bin/toplevel.opt -save ./tests/saveload/result/basic.1.sav @PTEST_DIR@/@PTEST_NAME@.i -eva -out -input -deps -eva-show-progress > ./tests/saveload/result/basic_sav.1.res 2> ./tests/saveload/result/basic_sav.1.err OPT: -load ./tests/saveload/result/basic.sav -eva -out -input -deps -journal-disable - CMD: @frama-c@ -load-module ./tests/saveload/basic + CMD: @frama-c@ -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -load ./tests/saveload/result/basic.1.sav -eva -out -input -deps -journal-disable -print OPT: -load ./tests/saveload/result/basic.1.sav -eva -out -input -deps -journal-disable - EXECNOW: LOG status_sav.res LOG status_sav.err BIN status.sav @frama-c@ -load-script tests/saveload/status.ml -save ./tests/saveload/result/status.sav ./tests/saveload/basic.i > ./tests/saveload/result/status_sav.res 2> ./tests/saveload/result/status_sav.err - OPT: -load-script tests/saveload/status.ml -load ./tests/saveload/result/status.sav + EXECNOW: make -s @PTEST_DIR@/status.cmxs + EXECNOW: LOG status_sav.res LOG status_sav.err BIN status.sav @frama-c@ -load-module @PTEST_DIR@/status -save ./tests/saveload/result/status.sav @PTEST_DIR@/@PTEST_NAME@.i > ./tests/saveload/result/status_sav.res 2> ./tests/saveload/result/status_sav.err + OPT: -load-module @PTEST_DIR@/status -load ./tests/saveload/result/status.sav OPT: -load ./tests/saveload/result/status.sav */ diff --git a/tests/saveload/load_one.i b/tests/saveload/load_one.i index 2c6aa23233a1a0d9baf17cbd8442b40a14c40e4f..8f58edd16793be9f8f058ad48543ab1df2132096 100644 --- a/tests/saveload/load_one.i +++ b/tests/saveload/load_one.i @@ -1,7 +1,7 @@ /* run.config - OPT: -load-script tests/saveload/load_one.ml -eva-show-progress + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress */ - int G; int f (int x, int y) { diff --git a/tests/saveload/multi_project.i b/tests/saveload/multi_project.i index b3a6c55cc1ba9915f315ba8f5d8273e37f63a6bc..e8c3589515cd3bdca84e5679e3a52330cfbbbb50 100644 --- a/tests/saveload/multi_project.i +++ b/tests/saveload/multi_project.i @@ -1,8 +1,8 @@ /* run.config - EXECNOW: BIN multi_project.sav LOG multi_project_sav.res LOG multi_project_sav.err ./bin/toplevel.opt -save ./tests/saveload/result/multi_project.sav -eva-show-progress -semantic-const-folding ./tests/saveload/multi_project.i > tests/saveload/result/multi_project_sav.res 2> tests/saveload/result/multi_project_sav.err - EXECNOW: make -s ./tests/saveload/multi_project.cmxs + EXECNOW: BIN multi_project.sav LOG multi_project_sav.res LOG multi_project_sav.err ./bin/toplevel.opt -save ./tests/saveload/result/multi_project.sav -eva-show-progress -semantic-const-folding @PTEST_DIR@/@PTEST_NAME@.i > tests/saveload/result/multi_project_sav.res 2> tests/saveload/result/multi_project_sav.err + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -load ./tests/saveload/result/multi_project.sav -journal-disable - CMD: @frama-c@ -load-module ./tests/saveload/multi_project + CMD: @frama-c@ -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva -eva-show-progress */ int f(int x) { diff --git a/tests/saveload/oracle/basic_sav.1.res b/tests/saveload/oracle/basic_sav.1.res index 985eb96467566d2d7978358d57e350538de45307..056059606204259f47c4619d6aa71f6dd14adaa0 100644 --- a/tests/saveload/oracle/basic_sav.1.res +++ b/tests/saveload/oracle/basic_sav.1.res @@ -4,9 +4,9 @@ [eva] Initial state computed [eva:initial-state] Values of globals at initialization -[eva] tests/saveload/basic.i:18: assertion got status valid. -[eva] tests/saveload/basic.i:19: starting to merge loop iterations -[eva:alarm] tests/saveload/basic.i:19: Warning: +[eva] tests/saveload/basic.i:19: assertion got status valid. +[eva] tests/saveload/basic.i:20: starting to merge loop iterations +[eva:alarm] tests/saveload/basic.i:20: Warning: signed overflow. assert -2147483648 ≤ i - 1; [eva] Recording results for main [eva] done for function main diff --git a/tests/saveload/oracle/basic_sav.res b/tests/saveload/oracle/basic_sav.res index 985eb96467566d2d7978358d57e350538de45307..056059606204259f47c4619d6aa71f6dd14adaa0 100644 --- a/tests/saveload/oracle/basic_sav.res +++ b/tests/saveload/oracle/basic_sav.res @@ -4,9 +4,9 @@ [eva] Initial state computed [eva:initial-state] Values of globals at initialization -[eva] tests/saveload/basic.i:18: assertion got status valid. -[eva] tests/saveload/basic.i:19: starting to merge loop iterations -[eva:alarm] tests/saveload/basic.i:19: Warning: +[eva] tests/saveload/basic.i:19: assertion got status valid. +[eva] tests/saveload/basic.i:20: starting to merge loop iterations +[eva:alarm] tests/saveload/basic.i:20: Warning: signed overflow. assert -2147483648 ≤ i - 1; [eva] Recording results for main [eva] done for function main diff --git a/tests/saveload/serialized_queue.i b/tests/saveload/serialized_queue.i index fe5a57bd8f72e2e63b0b2930443f942be55eecc4..3d2c450536e513b1580c0197708c6f78599e4c31 100644 --- a/tests/saveload/serialized_queue.i +++ b/tests/saveload/serialized_queue.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script @PTEST_DIR@/@PTEST_NAME@.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ // empty C file, we're only interested in the script itself diff --git a/tests/scope/bts971.c b/tests/scope/bts971.c index d23783b30da5267e2f5364fa961f46bd80ee0847..b50076a1a38082a0c1f3d15ae9b1cfa66e8fa6e0 100644 --- a/tests/scope/bts971.c +++ b/tests/scope/bts971.c @@ -1,7 +1,7 @@ /* run.config - OPT: -journal-disable -load-script tests/scope/bts971.ml -then -main main2 + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -journal-disable -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -then -main main2 */ - /* bug 971: */ volatile foo; int v; diff --git a/tests/scope/zones.c b/tests/scope/zones.c index b60197f2d884c12dbf8d011b0de8cc5a5cefce94..884e57b2162c1665bbac00b98c150d5e02c6373c 100644 --- a/tests/scope/zones.c +++ b/tests/scope/zones.c @@ -1,10 +1,10 @@ /* run.config - OPT: -load-script tests/scope/zones.ml -eva -eva-show-progress -journal-disable +# EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -eva -eva-show-progress -journal-disable */ - -/* bin/viewer.opt -eva tests/scope/zones.c */ +/* bin/viewer.opt -eva @PTEST_DIR@/@PTEST_NAME@.c */ int T [10]; struct Tstr { int a; int b; } S; diff --git a/tests/slicing/adpcm.c b/tests/slicing/adpcm.c index 3ca387a3406fa599e26887b96303c2ae4bc6f396..88dbc4dbda0d8a796d81743dfda2b7dfab5b14e1 100644 --- a/tests/slicing/adpcm.c +++ b/tests/slicing/adpcm.c @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/adpcm.cmxs - OPT: -eva-show-progress -load-module ./tests/slicing/libSelect.cmxs -load-module ./tests/slicing/adpcm.cmxs -ulevel -1 -deps -slicing-level 2 -journal-disable + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -eva-show-progress -load-module ./tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -ulevel -1 -deps -slicing-level 2 -journal-disable */ #include "tests/test/adpcm.c" diff --git a/tests/slicing/combine.i b/tests/slicing/combine.i index 983a97af1402259919d337a17cf10b82544f227b..16d12c1adcd6a2813d481d626b1535c4714bb64f 100644 --- a/tests/slicing/combine.i +++ b/tests/slicing/combine.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/combine.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/combine.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -journal-disable */ diff --git a/tests/slicing/ex_spec_interproc.i b/tests/slicing/ex_spec_interproc.i index 9f6d8ca13606bc64e5756bdca896f27205dc580f..962dd869e61cbda26e097423225fba45df9b3713 100644 --- a/tests/slicing/ex_spec_interproc.i +++ b/tests/slicing/ex_spec_interproc.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/ex_spec_interproc.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/ex_spec_interproc.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -journal-disable */ diff --git a/tests/slicing/horwitz.i b/tests/slicing/horwitz.i index 3cc83fb2dd7b2f056e084b53fc52f6c15b18ed94..0178857313f549f260b26554f05c18a927bde711 100644 --- a/tests/slicing/horwitz.i +++ b/tests/slicing/horwitz.i @@ -1,12 +1,12 @@ /* run.config - EXECNOW: make -s tests/slicing/horwitz.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/horwitz.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -slicing-level 0 -journal-disable */ -/* bin/toplevel.opt -deps -eva tests/slicing/horwitz.c */ -/* bin/toplevel.opt -deps -pdg-debug -pdg tests/slicing/horwitz.c */ -/* cf aussi tests/slicing/horwitz.ml */ +/* bin/toplevel.opt -deps -eva @PTEST_DIR@/@PTEST_NAME@.c */ +/* bin/toplevel.opt -deps -pdg-debug -pdg @PTEST_DIR@/@PTEST_NAME@.c */ +/* cf aussi @PTEST_DIR@/@PTEST_NAME@.ml */ int add (int a, int b) { return a+b; diff --git a/tests/slicing/mark_all_slices.i b/tests/slicing/mark_all_slices.i index 3454c9e2befc3c6b0162dc468a7115f5e1d2c9a8..d25812226596c855a7380ef38ddc9520f0f0c405 100644 --- a/tests/slicing/mark_all_slices.i +++ b/tests/slicing/mark_all_slices.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/mark_all_slices.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/mark_all_slices.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -slicing-level 3 -no-slice-callers -journal-disable */ int A, B, C, D; diff --git a/tests/slicing/merge.i b/tests/slicing/merge.i index b25108129ad6606803c84d0febb9df5497bea6d5..bf0509784e30e9adfe5159b4e8cff4be9597d3b9 100644 --- a/tests/slicing/merge.i +++ b/tests/slicing/merge.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/merge.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/libAnim.cmxs -load-module tests/slicing/merge.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/libAnim.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -slicing-level 3 -journal-disable */ diff --git a/tests/slicing/min_call.i b/tests/slicing/min_call.i index bb033d1fc639504a1224b21697fc0ff03975a26d..f7cc89e6a8dd1b8e1b9b580e0a2bdc2dc0457a75 100644 --- a/tests/slicing/min_call.i +++ b/tests/slicing/min_call.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/min_call.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/min_call.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -lib-entry -main g -journal-disable -slicing-level 3 */ diff --git a/tests/slicing/select_by_annot.i b/tests/slicing/select_by_annot.i index fe285f2541c43f31036a42f891208315269498bb..a0cd4471cf1e72b7b7e5ecfc74212bbc83f1bfb2 100644 --- a/tests/slicing/select_by_annot.i +++ b/tests/slicing/select_by_annot.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/select_by_annot.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/select_by_annot.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -lib-entry -main main -journal-disable CMD: bin/toplevel.opt OPT: -eva-show-progress -check -deps -lib-entry -main main -slice-pragma main -journal-disable -then-on 'Slicing export' -set-project-as-default -print -check -then -print -ocode @PTEST_DIR@/result/ocode_@PTEST_NUMBER@_@PTEST_NAME@.i -then @PTEST_DIR@/result/ocode_@PTEST_NUMBER@_@PTEST_NAME@.i -check -no-deps diff --git a/tests/slicing/select_simple.i b/tests/slicing/select_simple.i index 9e30123cd9bd1662a26cdb7c74e287e2aaa2e79f..9883f3ff5832c4114b5d9af361e3bdc732257829 100644 --- a/tests/slicing/select_simple.i +++ b/tests/slicing/select_simple.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/select_simple.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/select_simple.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -journal-disable */ diff --git a/tests/slicing/simple_intra_slice.i b/tests/slicing/simple_intra_slice.i index 065111000339285f6f469292a3d992d89d795d98..e335e824fe8810dc5832f1d524f0a9f00728b079 100644 --- a/tests/slicing/simple_intra_slice.i +++ b/tests/slicing/simple_intra_slice.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/simple_intra_slice.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/simple_intra_slice.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -no-slice-callers -journal-disable */ int Unknown; diff --git a/tests/slicing/slice_no_body.i b/tests/slicing/slice_no_body.i index 0f261cfc5c8e0be129134359987f92540895e34e..9c249f20d9f10a391b1ad939bb7e8605473596a7 100644 --- a/tests/slicing/slice_no_body.i +++ b/tests/slicing/slice_no_body.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/slice_no_body.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/slice_no_body.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -lib-entry -main h -journal-disable */ diff --git a/tests/slicing/switch.i b/tests/slicing/switch.i index 11e453ccb719566980ce711bea9d90cdd5d820cd..0b1ca36ce07a809cf0c2cbbaec82b11bd2150ed1 100644 --- a/tests/slicing/switch.i +++ b/tests/slicing/switch.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/switch.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/switch.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -journal-disable */ int main (char choix) { diff --git a/tests/spec/Extend.i b/tests/spec/Extend.i index dd42b2180708242016365f0c6c3518062ca0b972..ff81bb51cab62adebb757548a563b5c5c4ac1a00 100644 --- a/tests/spec/Extend.i +++ b/tests/spec/Extend.i @@ -1,6 +1,6 @@ /* run.config -EXECNOW: make @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -copy -kernel-warn-key=annot-error=active +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -copy -kernel-warn-key=annot-error=active */ /*@ foo x == 0; diff --git a/tests/spec/add_global.i b/tests/spec/add_global.i index 0eeae27f26ff17543f3219293e44182bc5e22337..7ed406648a9ae0f6d2d9f3d5357314714edf358c 100644 --- a/tests/spec/add_global.i +++ b/tests/spec/add_global.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ int main () { return 0; } diff --git a/tests/spec/bts0578.i b/tests/spec/bts0578.i index 4d3a94ab5cecf0919d35a0beeea9433f38f410c8..c94e20665e6bda514c2d2f3460c2c132504d509c 100644 --- a/tests/spec/bts0578.i +++ b/tests/spec/bts0578.i @@ -1,5 +1,6 @@ /* run.config - OPT: -print -load-script ./tests/spec/bts0578.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -print -load-module ./@PTEST_DIR@/@PTEST_NAME@ */ /*@ behavior foo: ensures \true; */ diff --git a/tests/spec/bts0655.i b/tests/spec/bts0655.i index b994e76793c1467df1e4d2dc3af4ba9bda747209..b5947620ab99b29f05efcec6781e7549d0ff63c8 100644 --- a/tests/spec/bts0655.i +++ b/tests/spec/bts0655.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/spec/bts0655.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ @ ensures \result == \max( a, b ); diff --git a/tests/spec/comparison.i b/tests/spec/comparison.i index 9fc56fc54cfb485abfc7007da7dfae3add8102e1..a62a8a65c779ed28e8b1795d4182dc1a0897c66e 100644 --- a/tests/spec/comparison.i +++ b/tests/spec/comparison.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/spec/comparison.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ predicate foo(boolean a, boolean b) = a == b; */ diff --git a/tests/spec/expr_to_term.i b/tests/spec/expr_to_term.i index 74bd6f5aa8b625b8e0099467e25d85794a6b5922..12078604eca0f6f0bf50d630d939b9539203ff83 100644 --- a/tests/spec/expr_to_term.i +++ b/tests/spec/expr_to_term.i @@ -1,8 +1,7 @@ /* run.config -EXECNOW: make @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ - int x[10]; struct S { int y; int z; } s; diff --git a/tests/spec/location_char.c b/tests/spec/location_char.c index 3b9e457c7bbc26bda4de6536508d5f914e28b97a..99339a087cfd144ae6a400c10249fa9394530e4b 100644 --- a/tests/spec/location_char.c +++ b/tests/spec/location_char.c @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ requires x <= 0; diff --git a/tests/spec/model.i b/tests/spec/model.i index 0d4fe0b8b8f4672fb9ff0bc29b15e1669f8375c2..840ab0193bc7883a50f8671c43f01ad4264e3c08 100644 --- a/tests/spec/model.i +++ b/tests/spec/model.i @@ -1,8 +1,8 @@ /* run.config -STDOPT: +"-load-script tests/spec/model.ml" +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +STDOPT: +"-no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" */ struct S { int x; int y; }; - typedef struct S T; /*@ model struct S { integer z }; */ diff --git a/tests/spec/pp_empty_spec.i b/tests/spec/pp_empty_spec.i index 0835b8c2332205289f637c06c42bcf7597904778..6d337f8500a51c4c764145969e8ef1c73bcff1f0 100644 --- a/tests/spec/pp_empty_spec.i +++ b/tests/spec/pp_empty_spec.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script @PTEST_DIR@/@PTEST_NAME@.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int main(void) { int x = 0; diff --git a/tests/spec/property_test.i b/tests/spec/property_test.i index 07866538d3b1fcd413af495a25efa29e3c5d35c2..6f1de940f0cb8b128f6d9fefa4c635c806f5a267 100644 --- a/tests/spec/property_test.i +++ b/tests/spec/property_test.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/spec/property_test.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int X; diff --git a/tests/spec/type_constructors_in_env.i b/tests/spec/type_constructors_in_env.i index f60aaadd9d224592b2297d6df9eab1cf6c096d68..636049ed329cfd848d51760fd52d2d84701261fc 100644 --- a/tests/spec/type_constructors_in_env.i +++ b/tests/spec/type_constructors_in_env.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ type foo = A | B; */ diff --git a/tests/syntax/Refresh_visitor.i b/tests/syntax/Refresh_visitor.i index 07ebc38f1b1206f7404b2cb9c4aa0c4782d79e89..0786760a68f8f6abcb244f9485e74fdeac8cbee5 100644 --- a/tests/syntax/Refresh_visitor.i +++ b/tests/syntax/Refresh_visitor.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -eva-show-progress +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress */ struct S { int i; }; diff --git a/tests/syntax/add_allocates.i b/tests/syntax/add_allocates.i index de0ffa3fe47e7ec04c07eda84e9e262a483a07c4..2153e41ea67e6f54eeaf4a2b2719f3abb359eeac 100644 --- a/tests/syntax/add_allocates.i +++ b/tests/syntax/add_allocates.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/syntax/add_allocates.ml -print + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ diff --git a/tests/syntax/ast_init.i b/tests/syntax/ast_init.i index 77d503529616cf024179a591aa65f33bf83c04d0..1e9aad67b5d3289f2c50f423edf4697fb2fb77fa 100644 --- a/tests/syntax/ast_init.i +++ b/tests/syntax/ast_init.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int f(int x) { return x; } diff --git a/tests/syntax/char_is_unsigned.i b/tests/syntax/char_is_unsigned.i index f87954814a8e3d056d969c21a0df2de678014fe9..a3fbe427e1e26c1733ff8eecd4e4bd29fa9270d3 100644 --- a/tests/syntax/char_is_unsigned.i +++ b/tests/syntax/char_is_unsigned.i @@ -1,5 +1,6 @@ -/* run.config - OPT:-print -load-script tests/syntax/machdep_char_unsigned.ml -machdep unsigned_char -then -constfold -rte +/* run.config + EXECNOW: make -s @PTEST_DIR@/machdep_char_unsigned.cmxs + OPT:-print -load-module @PTEST_DIR@/machdep_char_unsigned -machdep unsigned_char -then -constfold -rte */ char t[10]; diff --git a/tests/syntax/clone_test.i b/tests/syntax/clone_test.i index e0a82386a6c8f795a3e7d70252220e76f625f0e2..7d94b47b61384b15dac0b60062acd1148947726a 100644 --- a/tests/syntax/clone_test.i +++ b/tests/syntax/clone_test.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script @PTEST_DIR@/@PTEST_NAME@.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ diff --git a/tests/syntax/copy_visitor_bts_1073.c b/tests/syntax/copy_visitor_bts_1073.c index 1c03240bfff694e5541238663e80381011ac77e7..a20b81af83fc0cb5b769207afd287f77450a2a17 100644 --- a/tests/syntax/copy_visitor_bts_1073.c +++ b/tests/syntax/copy_visitor_bts_1073.c @@ -1,6 +1,8 @@ /* run.config -OPT: -load-script tests/syntax/copy_visitor_bts_1073.ml -OPT: -load-script tests/syntax/copy_visitor_bts_1073_bis.ml -test -then-on filtered -print +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@_bis.cmxs +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@_bis -test -then-on filtered -print */ #include "stdio.h" diff --git a/tests/syntax/forloophook.i b/tests/syntax/forloophook.i index 6fee07446ff502447a466480a7b40e3b9708cddb..d9e38bd7b222e52182a102421f32151e285020ec 100644 --- a/tests/syntax/forloophook.i +++ b/tests/syntax/forloophook.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/syntax/forloophook.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ void f() { for (int i=0; i< 10; i++); diff --git a/tests/syntax/formals_decl_leak.i b/tests/syntax/formals_decl_leak.i index 6a521af4ade9356c5ed4431debc0970ff9d87596..93a7dc265a729926ce94aac380f8ec67a67198b8 100644 --- a/tests/syntax/formals_decl_leak.i +++ b/tests/syntax/formals_decl_leak.i @@ -1,5 +1,6 @@ /* run.config -OPT: -print -load-script tests/syntax/formals_decl_leak.ml tests/syntax/formals_decl_leak_1.i +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -print -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs @PTEST_DIR@/@PTEST_NAME@_1.i */ void f(int x); diff --git a/tests/syntax/get_astinfo_bts1136.i b/tests/syntax/get_astinfo_bts1136.i index bbb4f115aa35e1323469e5de9abb7633af777c9b..694aacdf37979df8db7e8043f9ed6268c82efa73 100644 --- a/tests/syntax/get_astinfo_bts1136.i +++ b/tests/syntax/get_astinfo_bts1136.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/syntax/get_astinfo_bts1136.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int f (int x) { return x; } int g (int x) { return x; } diff --git a/tests/syntax/inserted_casts.c b/tests/syntax/inserted_casts.c index 62ce8c000f283dfbfa406daaa8ab0f9b59805724..805496d3d23a36a8bb973199a0e95203a72363ab 100644 --- a/tests/syntax/inserted_casts.c +++ b/tests/syntax/inserted_casts.c @@ -1,7 +1,7 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs - STDOPT: +"-load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" - STDOPT: +"-load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" +"-machdep x86_64" + STDOPT: +"-no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" + STDOPT: +"-no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" +"-machdep x86_64" */ #include "stddef.h" int f(int b) diff --git a/tests/syntax/logic_env.i b/tests/syntax/logic_env.i index 6d8082506687116f05472ed8e711b5cee580024e..9570e109382c07d8d19a57248a384cbc372b9e66 100644 --- a/tests/syntax/logic_env.i +++ b/tests/syntax/logic_env.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/syntax/logic_env_script.ml +EXECNOW: make -s @PTEST_DIR@/logic_env_script.cmxs +OPT: -load-module @PTEST_DIR@/logic_env_script */ //@ predicate foo(integer x) = x == 0; diff --git a/tests/syntax/mutable_test.i b/tests/syntax/mutable_test.i index b8ed2d45fb4ca9f14eedb77ca9b8522ad008c015..3c480aa053427eebf9bcf9ca6c5dcfd257cad058 100644 --- a/tests/syntax/mutable_test.i +++ b/tests/syntax/mutable_test.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ struct R_1 { diff --git a/tests/syntax/oracle/get_astinfo_bts1136.res.oracle b/tests/syntax/oracle/get_astinfo_bts1136.res.oracle index cffcd6e4b73cd1290264656bf7e80aefd76fe204..6366ae5e8ee9b4b79e1ce7de9a6dc6e2d8a70370 100644 --- a/tests/syntax/oracle/get_astinfo_bts1136.res.oracle +++ b/tests/syntax/oracle/get_astinfo_bts1136.res.oracle @@ -1,13 +1,13 @@ [kernel] Parsing tests/syntax/get_astinfo_bts1136.i (no preprocessing) -found variable vid:22 formal in f -found variable vid:25 formal in g -found variable vid:28 formal in h -found variable vid:30 formal in i -found variable vid:32 formal in j -found variable vid:34 formal in k -[do_v] vid:28 formal in h -[do_v] vid:25 formal in g -[do_v] vid:22 formal in f -[do_v] vid:34 local in k -[do_v] vid:32 local in j -[do_v] vid:30 local in i +found variable vid:20 formal in f +found variable vid:23 formal in g +found variable vid:26 formal in h +found variable vid:28 formal in i +found variable vid:30 formal in j +found variable vid:32 formal in k +[do_v] vid:26 formal in h +[do_v] vid:23 formal in g +[do_v] vid:20 formal in f +[do_v] vid:32 local in k +[do_v] vid:30 local in j +[do_v] vid:28 local in i diff --git a/tests/syntax/oracle/syntactic_hook.res.oracle b/tests/syntax/oracle/syntactic_hook.res.oracle index 4d15d03a3ad3423d6b318c306cfbdfe997c2aee2..f91bf389edacd90454102c87b50ef336951d9660 100644 --- a/tests/syntax/oracle/syntactic_hook.res.oracle +++ b/tests/syntax/oracle/syntactic_hook.res.oracle @@ -1,22 +1,22 @@ [kernel] Parsing tests/syntax/syntactic_hook.i (no preprocessing) [kernel] tests/syntax/syntactic_hook.i:5: - New global node introducing identifier f(22) + New global node introducing identifier f(20) [kernel] First occurrence of f [kernel] tests/syntax/syntactic_hook.i:7: - New global node introducing identifier k(25) + New global node introducing identifier k(23) [kernel] First occurrence of k [kernel] tests/syntax/syntactic_hook.i:9: - New global node introducing identifier k(25) + New global node introducing identifier k(23) [kernel] New occurrence of existing identifier k [kernel] tests/syntax/syntactic_hook.i:11: - New global node introducing identifier main(31) + New global node introducing identifier main(29) [kernel] First occurrence of main [kernel] tests/syntax/syntactic_hook.i:13: - New global node introducing identifier t(35) + New global node introducing identifier t(33) [kernel] First occurrence of t [kernel] tests/syntax/syntactic_hook.i:13: Warning: [SH]: definition of local function t -[kernel] :0: New global node introducing identifier g(37) +[kernel] :0: New global node introducing identifier g(35) [kernel] First occurrence of g [kernel:typing:implicit-function-declaration] tests/syntax/syntactic_hook.i:17: Warning: Calling undeclared function g. Old style K&R code? diff --git a/tests/syntax/reorder.i b/tests/syntax/reorder.i index a754b95d776a02a5cbdd5bba66b7b75ab834d7be..a611137930713ae5fbb4db09a2cbefdf59513905 100644 --- a/tests/syntax/reorder.i +++ b/tests/syntax/reorder.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/syntax/reorder.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int x; diff --git a/tests/syntax/syntactic_hook.i b/tests/syntax/syntactic_hook.i index e5c19d372e4d3f7ba2012a42514e35805d4e4d72..d887e89667ec5464d71f2d68e749dfe68465f196 100644 --- a/tests/syntax/syntactic_hook.i +++ b/tests/syntax/syntactic_hook.i @@ -1,7 +1,7 @@ /* run.config - STDOPT: +"-load-script tests/syntax/syntactic_hook.ml" + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + STDOPT: +"-no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" */ - int f(void); int k(int *); diff --git a/tests/syntax/typedef_multi_1.c b/tests/syntax/typedef_multi_1.c index fac8ea328939009b61a97e51f0f01a2d5e03c945..33a8d6c3537a3452d299e6a481c5514bbdb93022 100644 --- a/tests/syntax/typedef_multi_1.c +++ b/tests/syntax/typedef_multi_1.c @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/syntax/typedef_multi.ml tests/syntax/typedef_multi_2.c + EXECNOW: make -s @PTEST_DIR@/typedef_multi.cmxs + OPT: -load-module @PTEST_DIR@/typedef_multi tests/syntax/typedef_multi_2.c */ #include "tests/syntax/typedef_multi.h" diff --git a/tests/syntax/vdescr_bts1387.i b/tests/syntax/vdescr_bts1387.i index 7ef2f74b3ccce4b99ef88b539449c45b24854699..b20b1226bd2c890329ecea47201df49299e8f69b 100644 --- a/tests/syntax/vdescr_bts1387.i +++ b/tests/syntax/vdescr_bts1387.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/syntax/vdescr_bts1387.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int f(int); int g(int); diff --git a/tests/syntax/visit_create_local.i b/tests/syntax/visit_create_local.i index 68bfe516292bfea1bbb41bc7327aa4acaf026ad1..6d9a88989bca1c8106862f9bb5dd304b6da357c0 100644 --- a/tests/syntax/visit_create_local.i +++ b/tests/syntax/visit_create_local.i @@ -1,4 +1,5 @@ /* run.config -OPT: -load-script tests/syntax/visit_create_local.ml -then-on bidon -print +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -then-on bidon -print */ void main() { int x,y; x = y; }