| 1 |
(* ========================================================================== *) |
| 2 |
(* Formal verification of nonlinear inequalities in HOL Light *) |
| 3 |
(* *) |
| 4 |
(* Copyright (c) 2014 Alexey Solovyev *) |
| 5 |
(* *) |
| 6 |
(* This file is distributed under the terms of the MIT licence *) |
| 7 |
(* ========================================================================== *) |
| 8 |
|
| 9 |
(* -------------------------------------------------------------------------- *) |
| 10 |
(* Formal interval evaluation of functions: asn, acs *) |
| 11 |
(* -------------------------------------------------------------------------- *) |
| 12 |
|
| 13 |
needs "Formal_ineqs/arith/float_pow.hl";; |
| 14 |
needs "Formal_ineqs/trig/atn_eval.hl";; |
| 15 |
|
| 16 |
module type Asn_acs_eval_sig = |
| 17 |
sig |
| 18 |
val float_asn_lo : int -> term -> thm |
| 19 |
val float_asn_hi : int -> term -> thm |
| 20 |
val float_interval_asn : int -> thm -> thm |
| 21 |
|
| 22 |
val float_acs_lo : int -> term -> thm |
| 23 |
val float_acs_hi : int -> term -> thm |
| 24 |
val float_interval_acs : int -> thm -> thm |
| 25 |
end;; |
| 26 |
|
| 27 |
module Asn_acs_eval : Asn_acs_eval_sig = struct |
| 28 |
|
| 29 |
open Misc_functions;; |
| 30 |
open Interval_arith;; |
| 31 |
open Arith_nat;; |
| 32 |
open Float_theory;; |
| 33 |
open Arith_float;; |
| 34 |
open Float_pow;; |
| 35 |
open More_float;; |
| 36 |
open Poly;; |
| 37 |
open Atn_eval;; |
| 38 |
open Misc_vars;; |
| 39 |
|
| 40 |
prioritize_real();; |
| 41 |
|
| 42 |
let neg_one_float = lhand (concl (float_neg one_float));; |
| 43 |
let float_neg1_eq = FLOAT_TO_NUM_CONV neg_one_float;; |
| 44 |
|
| 45 |
let th_rule = UNDISCH_ALL o PURE_REWRITE_RULE[real_zero] o |
| 46 |
PURE_REWRITE_RULE[GSYM IMP_IMP; GSYM float1_eq; GSYM float_neg1_eq] o SPEC_ALL;; |
| 47 |
|
| 48 |
let asn_pos_hi_th = (th_rule o prove) |
| 49 |
(`float_num F n e pow 2 <= b /\ |
| 50 |
c <= &1 - b /\ |
| 51 |
r <= sqrt c /\ |
| 52 |
(real_zero < r <=> T) /\ |
| 53 |
(float_num F n e) / r <= t /\ |
| 54 |
atn t <= hi |
| 55 |
==> asn (float_num F n e) <= hi`, |
| 56 |
REWRITE_TAC[real_zero] THEN STRIP_TAC THEN |
| 57 |
ASSUME_TAC (SPECL[`n:num`; `e:num`] FLOAT_F_POS) THEN |
| 58 |
ABBREV_TAC `x = float_num F n e` THEN |
| 59 |
SUBGOAL_THEN `-- &1 < x /\ x < &1` ASSUME_TAC THENL [ |
| 60 |
REWRITE_TAC[REAL_ARITH `(-- &1 < x /\ x < &1) <=> (abs x < abs (&1))`] THEN |
| 61 |
REWRITE_TAC[REAL_LT_SQUARE_ABS; REAL_ARITH `&1 pow 2 = &1`] THEN |
| 62 |
MATCH_MP_TAC REAL_LET_TRANS THEN EXISTS_TAC `b:real` THEN ASM_REWRITE_TAC[] THEN |
| 63 |
SUBGOAL_THEN `&0 < c` MP_TAC THENL [ |
| 64 |
ONCE_REWRITE_TAC[GSYM SQRT_LT_0] THEN ASM_ARITH_TAC; |
| 65 |
ALL_TAC |
| 66 |
] THEN |
| 67 |
ASM_ARITH_TAC; |
| 68 |
ALL_TAC |
| 69 |
] THEN |
| 70 |
ASM_SIMP_TAC[ASN_ATN] THEN |
| 71 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `atn t` THEN ASM_REWRITE_TAC[ATN_MONO_LE_EQ] THEN |
| 72 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `x / r` THEN ASM_REWRITE_TAC[real_div] THEN |
| 73 |
MATCH_MP_TAC REAL_LE_LMUL THEN ASM_REWRITE_TAC[] THEN |
| 74 |
MATCH_MP_TAC REAL_LE_INV2 THEN ASM_REWRITE_TAC[] THEN |
| 75 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `sqrt c` THEN ASM_REWRITE_TAC[] THEN |
| 76 |
MATCH_MP_TAC SQRT_MONO_LE THEN ASM_ARITH_TAC);; |
| 77 |
|
| 78 |
let asn_pos_lo_th = (th_rule o prove) |
| 79 |
(`b <= float_num F n e pow 2 /\ |
| 80 |
&1 - b <= c /\ |
| 81 |
sqrt c <= r /\ |
| 82 |
(float_num F n e < &1 <=> T) /\ |
| 83 |
t <= (float_num F n e) / r /\ |
| 84 |
lo <= atn t |
| 85 |
==> lo <= asn (float_num F n e)`, |
| 86 |
REWRITE_TAC[] THEN STRIP_TAC THEN |
| 87 |
ASSUME_TAC (SPECL[`n:num`; `e:num`] FLOAT_F_POS) THEN |
| 88 |
ABBREV_TAC `x = float_num F n e` THEN |
| 89 |
SUBGOAL_THEN `-- &1 < x /\ x < &1` ASSUME_TAC THENL [ |
| 90 |
ASM_ARITH_TAC; |
| 91 |
ALL_TAC |
| 92 |
] THEN |
| 93 |
ASM_SIMP_TAC[ASN_ATN; REAL_ARITH `&0 <= x /\ x < &1 ==> -- &1 < x /\ x < &1`] THEN |
| 94 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `atn t` THEN ASM_REWRITE_TAC[ATN_MONO_LE_EQ] THEN |
| 95 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `x / r` THEN ASM_REWRITE_TAC[real_div] THEN |
| 96 |
MATCH_MP_TAC REAL_LE_LMUL THEN ASM_REWRITE_TAC[] THEN |
| 97 |
MATCH_MP_TAC REAL_LE_INV2 THEN ASM_REWRITE_TAC[SQRT_LT_0] THEN |
| 98 |
CONJ_TAC THENL [ |
| 99 |
REWRITE_TAC[REAL_ARITH `&0 < &1 - a <=> a < &1`; ABS_SQUARE_LT_1] THEN |
| 100 |
ASM_ARITH_TAC; |
| 101 |
ALL_TAC |
| 102 |
] THEN |
| 103 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `sqrt c` THEN ASM_REWRITE_TAC[] THEN |
| 104 |
MATCH_MP_TAC SQRT_MONO_LE THEN ASM_ARITH_TAC);; |
| 105 |
|
| 106 |
let asn_neg_hi_th = (th_rule o prove) |
| 107 |
(`b <= float_num T n e pow 2 /\ |
| 108 |
&1 - b <= c /\ |
| 109 |
sqrt c <= r /\ |
| 110 |
(-- &1 < float_num T n e <=> T) /\ |
| 111 |
(float_num T n e) / r <= t /\ |
| 112 |
atn t <= hi |
| 113 |
==> asn (float_num T n e) <= hi`, |
| 114 |
REWRITE_TAC[interval_arith; FLOAT_NEG_T; REAL_POW_NEG; ARITH_RULE `EVEN 2`] THEN STRIP_TAC THEN |
| 115 |
ASSUME_TAC (SPECL[`n:num`; `e:num`] FLOAT_F_POS) THEN |
| 116 |
ABBREV_TAC `x = float_num F n e` THEN |
| 117 |
ASM_SIMP_TAC[ASN_ATN; REAL_ARITH `&0 <= x /\ -- &1 < --x ==> -- &1 < --x /\ --x < &1`] THEN |
| 118 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `atn t` THEN ASM_REWRITE_TAC[ATN_MONO_LE_EQ] THEN |
| 119 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `--x / r` THEN ASM_REWRITE_TAC[real_div] THEN |
| 120 |
REWRITE_TAC[REAL_MUL_LNEG; REAL_LE_NEG2; REAL_POW_NEG; ARITH_RULE `EVEN 2`] THEN |
| 121 |
MATCH_MP_TAC REAL_LE_LMUL THEN ASM_REWRITE_TAC[] THEN |
| 122 |
MATCH_MP_TAC REAL_LE_INV2 THEN ASM_REWRITE_TAC[SQRT_LT_0] THEN |
| 123 |
CONJ_TAC THENL [ |
| 124 |
REWRITE_TAC[REAL_ARITH `&0 < &1 - a <=> a < &1`; ABS_SQUARE_LT_1] THEN |
| 125 |
ASM_ARITH_TAC; |
| 126 |
ALL_TAC |
| 127 |
] THEN |
| 128 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `sqrt c` THEN ASM_REWRITE_TAC[] THEN |
| 129 |
MATCH_MP_TAC SQRT_MONO_LE THEN ASM_ARITH_TAC);; |
| 130 |
|
| 131 |
let asn_neg_lo_th = (th_rule o prove) |
| 132 |
(`float_num T n e pow 2 <= b /\ |
| 133 |
c <= &1 - b /\ |
| 134 |
r <= sqrt c /\ |
| 135 |
(real_zero < r <=> T) /\ |
| 136 |
t <= (float_num T n e) / r /\ |
| 137 |
lo <= atn t |
| 138 |
==> lo <= asn (float_num T n e)`, |
| 139 |
REWRITE_TAC[real_zero; FLOAT_NEG_T; REAL_POW_NEG; ARITH_RULE `EVEN 2`] THEN STRIP_TAC THEN |
| 140 |
ASSUME_TAC (SPECL[`n:num`; `e:num`] FLOAT_F_POS) THEN |
| 141 |
ABBREV_TAC `x = float_num F n e` THEN |
| 142 |
SUBGOAL_THEN `-- &1 < --x /\ --x < &1` ASSUME_TAC THENL [ |
| 143 |
REWRITE_TAC[REAL_ARITH `(-- &1 < --x /\ --x < &1) <=> (abs x < abs (&1))`] THEN |
| 144 |
REWRITE_TAC[REAL_LT_SQUARE_ABS; REAL_ARITH `&1 pow 2 = &1`] THEN |
| 145 |
MATCH_MP_TAC REAL_LET_TRANS THEN EXISTS_TAC `b:real` THEN ASM_REWRITE_TAC[] THEN |
| 146 |
SUBGOAL_THEN `&0 < c` MP_TAC THENL [ |
| 147 |
ONCE_REWRITE_TAC[GSYM SQRT_LT_0] THEN ASM_ARITH_TAC; |
| 148 |
ALL_TAC |
| 149 |
] THEN |
| 150 |
ASM_ARITH_TAC; |
| 151 |
ALL_TAC |
| 152 |
] THEN |
| 153 |
ASM_SIMP_TAC[ASN_ATN] THEN |
| 154 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `atn t` THEN ASM_REWRITE_TAC[ATN_MONO_LE_EQ] THEN |
| 155 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `--x / r` THEN ASM_REWRITE_TAC[real_div] THEN |
| 156 |
REWRITE_TAC[REAL_MUL_LNEG; REAL_LE_NEG2; REAL_POW_NEG; ARITH_RULE `EVEN 2`] THEN |
| 157 |
MATCH_MP_TAC REAL_LE_LMUL THEN ASM_REWRITE_TAC[] THEN |
| 158 |
MATCH_MP_TAC REAL_LE_INV2 THEN ASM_REWRITE_TAC[] THEN |
| 159 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `sqrt c` THEN ASM_REWRITE_TAC[] THEN |
| 160 |
MATCH_MP_TAC SQRT_MONO_LE THEN ASM_ARITH_TAC);; |
| 161 |
|
| 162 |
let acs_hi_th = (th_rule o prove) |
| 163 |
(`(x <= &1 <=> T) /\ |
| 164 |
(-- &1 <= x <=> T) /\ |
| 165 |
interval_arith (pi / &2) (a, b) /\ |
| 166 |
c <= asn x /\ |
| 167 |
b - c <= hi |
| 168 |
==> acs x <= hi`, |
| 169 |
REWRITE_TAC[interval_arith] THEN STRIP_TAC THEN |
| 170 |
ASM_SIMP_TAC[ACS_ASN] THEN ASM_ARITH_TAC);; |
| 171 |
|
| 172 |
let acs_lo_th = (th_rule o prove) |
| 173 |
(`(x <= &1 <=> T) /\ |
| 174 |
(-- &1 <= x <=> T) /\ |
| 175 |
interval_arith (pi / &2) (a, b) /\ |
| 176 |
asn x <= c /\ |
| 177 |
lo <= a - c |
| 178 |
==> lo <= acs x`, |
| 179 |
REWRITE_TAC[interval_arith] THEN STRIP_TAC THEN |
| 180 |
ASM_SIMP_TAC[ACS_ASN] THEN ASM_ARITH_TAC);; |
| 181 |
|
| 182 |
let asn_interval = (th_rule o prove) |
| 183 |
(`interval_arith x (a, b) /\ |
| 184 |
(-- &1 <= a <=> T) /\ |
| 185 |
(b <= &1 <=> T) /\ |
| 186 |
lo <= asn a /\ |
| 187 |
asn b <= hi |
| 188 |
==> interval_arith (asn x) (lo, hi)`, |
| 189 |
REWRITE_TAC[interval_arith] THEN STRIP_TAC THEN CONJ_TAC THENL [ |
| 190 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `asn a` THEN ASM_REWRITE_TAC[] THEN |
| 191 |
MATCH_MP_TAC ASN_MONO_LE THEN ASM_ARITH_TAC; |
| 192 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `asn b` THEN ASM_REWRITE_TAC[] THEN |
| 193 |
MATCH_MP_TAC ASN_MONO_LE THEN ASM_ARITH_TAC; |
| 194 |
]);; |
| 195 |
|
| 196 |
let acs_interval = (th_rule o prove) |
| 197 |
(`interval_arith x (a, b) /\ |
| 198 |
(-- &1 <= a <=> T) /\ |
| 199 |
(b <= &1 <=> T) /\ |
| 200 |
lo <= acs b /\ |
| 201 |
acs a <= hi |
| 202 |
==> interval_arith (acs x) (lo, hi)`, |
| 203 |
REWRITE_TAC[interval_arith] THEN STRIP_TAC THEN CONJ_TAC THENL [ |
| 204 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `acs b` THEN ASM_REWRITE_TAC[] THEN |
| 205 |
MATCH_MP_TAC ACS_MONO_LE THEN ASM_ARITH_TAC; |
| 206 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `acs a` THEN ASM_REWRITE_TAC[] THEN |
| 207 |
MATCH_MP_TAC ACS_MONO_LE THEN ASM_ARITH_TAC; |
| 208 |
]);; |
| 209 |
|
| 210 |
let acs_interval2 = (th_rule o prove) |
| 211 |
(`interval_arith x (a, b) /\ |
| 212 |
(-- &1 <= a <=> T) /\ |
| 213 |
(b <= &1 <=> T) /\ |
| 214 |
interval_arith (pi / &2) (low, high) /\ |
| 215 |
asn b <= t /\ |
| 216 |
lo <= low - t /\ |
| 217 |
r <= asn a /\ |
| 218 |
high - r <= hi |
| 219 |
==> interval_arith (acs x) (lo, hi)`, |
| 220 |
REWRITE_TAC[interval_arith] THEN STRIP_TAC THEN |
| 221 |
SUBGOAL_THEN `-- &1 <= x /\ x <= &1` ASSUME_TAC THENL [ |
| 222 |
ASM_ARITH_TAC; |
| 223 |
ALL_TAC |
| 224 |
] THEN |
| 225 |
ASM_SIMP_TAC[ACS_ASN] THEN CONJ_TAC THENL [ |
| 226 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `low - t` THEN ASM_REWRITE_TAC[real_sub] THEN |
| 227 |
MATCH_MP_TAC REAL_LE_ADD2 THEN ASM_REWRITE_TAC[REAL_LE_NEG2] THEN |
| 228 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `asn b` THEN ASM_REWRITE_TAC[] THEN |
| 229 |
MATCH_MP_TAC ASN_MONO_LE THEN ASM_REWRITE_TAC[]; |
| 230 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `high - r` THEN ASM_REWRITE_TAC[real_sub] THEN |
| 231 |
MATCH_MP_TAC REAL_LE_ADD2 THEN ASM_REWRITE_TAC[REAL_LE_NEG2] THEN |
| 232 |
MATCH_MP_TAC REAL_LE_TRANS THEN EXISTS_TAC `asn a` THEN ASM_REWRITE_TAC[] THEN |
| 233 |
MATCH_MP_TAC ASN_MONO_LE THEN ASM_REWRITE_TAC[]; |
| 234 |
]);; |
| 235 |
|
| 236 |
(* ---------------------------- *) |
| 237 |
(* asn, acs of a float *) |
| 238 |
(* ---------------------------- *) |
| 239 |
|
| 240 |
let float_asn_hi pp x_tm = |
| 241 |
let s, n_tm, e_tm = dest_float x_tm in |
| 242 |
if s = "F" then |
| 243 |
let x_pow2 = float_pow_hi pp 2 x_tm in |
| 244 |
let b_tm = rand (concl x_pow2) in |
| 245 |
let b1 = float_sub_lo pp one_float b_tm in |
| 246 |
let c_tm = lhand (concl b1) in |
| 247 |
let sqrt_c = float_sqrt_lo pp c_tm in |
| 248 |
let r_tm = lhand (concl sqrt_c) in |
| 249 |
let x_div_r = float_div_hi pp x_tm r_tm in |
| 250 |
let t_tm = rand (concl x_div_r) in |
| 251 |
let atn_t = float_atn_hi pp t_tm in |
| 252 |
let hi_tm = rand (concl atn_t) in |
| 253 |
let cmp = float_gt0 r_tm in |
| 254 |
if fst (dest_const (rand (concl cmp))) = "F" then |
| 255 |
failwith ("float_asn_hi: r <= 0: " ^ string_of_term x_tm) |
| 256 |
else |
| 257 |
let th0 = INST[n_tm, n_var_num; e_tm, e_var_num; hi_tm, hi_var_real; |
| 258 |
b_tm, b_var_real; c_tm, c_var_real; r_tm, r_var_real; |
| 259 |
t_tm, t_var_real] asn_pos_hi_th in |
| 260 |
itlist MY_PROVE_HYP [x_pow2; b1; sqrt_c; x_div_r; atn_t; cmp] th0 |
| 261 |
else |
| 262 |
let x_pow2 = float_pow_lo pp 2 x_tm in |
| 263 |
let b_tm = lhand (concl x_pow2) in |
| 264 |
let b1 = float_sub_hi pp one_float b_tm in |
| 265 |
let c_tm = rand (concl b1) in |
| 266 |
let sqrt_c = float_sqrt_hi pp c_tm in |
| 267 |
let r_tm = rand (concl sqrt_c) in |
| 268 |
let x_div_r = float_div_hi pp x_tm r_tm in |
| 269 |
let t_tm = rand (concl x_div_r) in |
| 270 |
let atn_t = float_atn_hi pp t_tm in |
| 271 |
let hi_tm = rand (concl atn_t) in |
| 272 |
let cmp = float_lt neg_one_float x_tm in |
| 273 |
if fst (dest_const (rand (concl cmp))) = "F" then |
| 274 |
failwith ("float_asn_hi: x <= -1: " ^ string_of_term x_tm) |
| 275 |
else |
| 276 |
let th0 = INST[n_tm, n_var_num; e_tm, e_var_num; hi_tm, hi_var_real; |
| 277 |
b_tm, b_var_real; c_tm, c_var_real; r_tm, r_var_real; |
| 278 |
t_tm, t_var_real] asn_neg_hi_th in |
| 279 |
itlist MY_PROVE_HYP [x_pow2; b1; sqrt_c; x_div_r; atn_t; cmp] th0;; |
| 280 |
|
| 281 |
let float_asn_lo pp x_tm = |
| 282 |
let s, n_tm, e_tm = dest_float x_tm in |
| 283 |
if s = "T" then |
| 284 |
let x_pow2 = float_pow_hi pp 2 x_tm in |
| 285 |
let b_tm = rand (concl x_pow2) in |
| 286 |
let b1 = float_sub_lo pp one_float b_tm in |
| 287 |
let c_tm = lhand (concl b1) in |
| 288 |
let sqrt_c = float_sqrt_lo pp c_tm in |
| 289 |
let r_tm = lhand (concl sqrt_c) in |
| 290 |
let x_div_r = float_div_lo pp x_tm r_tm in |
| 291 |
let t_tm = lhand (concl x_div_r) in |
| 292 |
let atn_t = float_atn_lo pp t_tm in |
| 293 |
let lo_tm = lhand (concl atn_t) in |
| 294 |
let cmp = float_gt0 r_tm in |
| 295 |
if fst (dest_const (rand (concl cmp))) = "F" then |
| 296 |
failwith ("float_asn_lo: r <= 0: " ^ string_of_term x_tm) |
| 297 |
else |
| 298 |
let th0 = INST[n_tm, n_var_num; e_tm, e_var_num; lo_tm, lo_var_real; |
| 299 |
b_tm, b_var_real; c_tm, c_var_real; r_tm, r_var_real; |
| 300 |
t_tm, t_var_real] asn_neg_lo_th in |
| 301 |
itlist MY_PROVE_HYP [x_pow2; b1; sqrt_c; x_div_r; atn_t; cmp] th0 |
| 302 |
else |
| 303 |
let x_pow2 = float_pow_lo pp 2 x_tm in |
| 304 |
let b_tm = lhand (concl x_pow2) in |
| 305 |
let b1 = float_sub_hi pp one_float b_tm in |
| 306 |
let c_tm = rand (concl b1) in |
| 307 |
let sqrt_c = float_sqrt_hi pp c_tm in |
| 308 |
let r_tm = rand (concl sqrt_c) in |
| 309 |
let x_div_r = float_div_lo pp x_tm r_tm in |
| 310 |
let t_tm = lhand (concl x_div_r) in |
| 311 |
let atn_t = float_atn_lo pp t_tm in |
| 312 |
let lo_tm = lhand (concl atn_t) in |
| 313 |
let cmp = float_lt x_tm one_float in |
| 314 |
if fst (dest_const (rand (concl cmp))) = "F" then |
| 315 |
failwith ("float_asn_hi: 1 <= x: " ^ string_of_term x_tm) |
| 316 |
else |
| 317 |
let th0 = INST[n_tm, n_var_num; e_tm, e_var_num; lo_tm, lo_var_real; |
| 318 |
b_tm, b_var_real; c_tm, c_var_real; r_tm, r_var_real; |
| 319 |
t_tm, t_var_real] asn_pos_lo_th in |
| 320 |
itlist MY_PROVE_HYP [x_pow2; b1; sqrt_c; x_div_r; atn_t; cmp] th0;; |
| 321 |
|
| 322 |
let float_acs_hi pp x_tm = |
| 323 |
let flag1, cmp1 = float_prove_le x_tm one_float in |
| 324 |
let flag2, cmp2 = float_prove_le neg_one_float x_tm in |
| 325 |
if flag1 && flag2 then |
| 326 |
let pi2 = pi2_approx_array.(pp) in |
| 327 |
let bounds = rand (concl pi2) in |
| 328 |
let ltm, b_tm = dest_comb bounds in |
| 329 |
let a_tm = rand ltm in |
| 330 |
let asn_x = float_asn_lo pp x_tm in |
| 331 |
let c_tm = lhand (concl asn_x) in |
| 332 |
let sub = float_sub_hi pp b_tm c_tm in |
| 333 |
let hi_tm = rand (concl sub) in |
| 334 |
let th0 = INST[x_tm, x_var_real; a_tm, a_var_real; b_tm, b_var_real; |
| 335 |
c_tm, c_var_real; hi_tm, hi_var_real] acs_hi_th in |
| 336 |
itlist MY_PROVE_HYP [cmp1; cmp2; pi2; asn_x; sub] th0 |
| 337 |
else |
| 338 |
failwith ("float_acs_hi: x < -1 or x > 1: " ^ string_of_term x_tm);; |
| 339 |
|
| 340 |
let float_acs_lo pp x_tm = |
| 341 |
let flag1, cmp1 = float_prove_le x_tm one_float in |
| 342 |
let flag2, cmp2 = float_prove_le neg_one_float x_tm in |
| 343 |
if flag1 && flag2 then |
| 344 |
let pi2 = pi2_approx_array.(pp) in |
| 345 |
let bounds = rand (concl pi2) in |
| 346 |
let ltm, b_tm = dest_comb bounds in |
| 347 |
let a_tm = rand ltm in |
| 348 |
let asn_x = float_asn_hi pp x_tm in |
| 349 |
let c_tm = rand (concl asn_x) in |
| 350 |
let sub = float_sub_lo pp a_tm c_tm in |
| 351 |
let lo_tm = lhand (concl sub) in |
| 352 |
let th0 = INST[x_tm, x_var_real; a_tm, a_var_real; b_tm, b_var_real; |
| 353 |
c_tm, c_var_real; lo_tm, lo_var_real] acs_lo_th in |
| 354 |
itlist MY_PROVE_HYP [cmp1; cmp2; pi2; asn_x; sub] th0 |
| 355 |
else |
| 356 |
failwith ("float_acs_lo: x < -1 or x > 1: " ^ string_of_term x_tm);; |
| 357 |
|
| 358 |
|
| 359 |
(* ---------------------------- *) |
| 360 |
(* asn, acs of an interval *) |
| 361 |
(* ---------------------------- *) |
| 362 |
|
| 363 |
let float_interval_asn pp x_th = |
| 364 |
let x_tm, bounds = dest_interval_arith (concl x_th) in |
| 365 |
let ltm, b_tm = dest_comb bounds in |
| 366 |
let a_tm = rand ltm in |
| 367 |
let flag1, cmp1 = float_prove_le neg_one_float a_tm in |
| 368 |
let flag2, cmp2 = float_prove_le b_tm one_float in |
| 369 |
if flag1 && flag2 then |
| 370 |
let asn_a = float_asn_lo pp a_tm and |
| 371 |
asn_b = float_asn_hi pp b_tm in |
| 372 |
let lo_tm = lhand (concl asn_a) and |
| 373 |
hi_tm = rand (concl asn_b) in |
| 374 |
let th0 = INST[x_tm, x_var_real; a_tm, a_var_real; b_tm, b_var_real; |
| 375 |
lo_tm, lo_var_real; hi_tm, hi_var_real] asn_interval in |
| 376 |
itlist MY_PROVE_HYP [x_th; cmp1; cmp2; asn_a; asn_b] th0 |
| 377 |
else |
| 378 |
failwith ("float_interval_asn: x < -1 or x > 1: " ^ string_of_term (concl x_th));; |
| 379 |
|
| 380 |
let float_interval_acs pp x_th = |
| 381 |
let x_tm, bounds = dest_interval_arith (concl x_th) in |
| 382 |
let ltm, b_tm = dest_comb bounds in |
| 383 |
let a_tm = rand ltm in |
| 384 |
let flag1, cmp1 = float_prove_le neg_one_float a_tm in |
| 385 |
let flag2, cmp2 = float_prove_le b_tm one_float in |
| 386 |
if flag1 && flag2 then |
| 387 |
let acs_a = float_acs_hi pp a_tm and |
| 388 |
acs_b = float_acs_lo pp b_tm in |
| 389 |
let lo_tm = lhand (concl acs_b) and |
| 390 |
hi_tm = rand (concl acs_a) in |
| 391 |
let th0 = INST[x_tm, x_var_real; a_tm, a_var_real; b_tm, b_var_real; |
| 392 |
lo_tm, lo_var_real; hi_tm, hi_var_real] acs_interval in |
| 393 |
itlist MY_PROVE_HYP [x_th; cmp1; cmp2; acs_a; acs_b] th0 |
| 394 |
else |
| 395 |
failwith ("float_interval_acs: x < -1 or x > 1: " ^ string_of_term (concl x_th));; |
| 396 |
|
| 397 |
(* UNUSED *) |
| 398 |
let float_interval_acs2 pp x_th = |
| 399 |
let x_tm, bounds = dest_interval_arith (concl x_th) in |
| 400 |
let ltm, b_tm = dest_comb bounds in |
| 401 |
let a_tm = rand ltm in |
| 402 |
let flag1, cmp1 = float_prove_le neg_one_float a_tm in |
| 403 |
let flag2, cmp2 = float_prove_le b_tm one_float in |
| 404 |
if flag1 && flag2 then |
| 405 |
let asn_a = float_asn_lo pp a_tm and |
| 406 |
asn_b = float_asn_hi pp b_tm and |
| 407 |
pi2 = pi2_approx_array.(pp) in |
| 408 |
let bounds = rand (concl pi2) in |
| 409 |
let ltm, high_tm = dest_comb bounds in |
| 410 |
let low_tm = rand ltm in |
| 411 |
let t_tm = rand (concl asn_b) and |
| 412 |
r_tm = lhand (concl asn_a) in |
| 413 |
let sub_lo = float_sub_lo pp low_tm t_tm and |
| 414 |
sub_hi = float_sub_hi pp high_tm r_tm in |
| 415 |
let lo_tm = lhand (concl sub_lo) and |
| 416 |
hi_tm = rand (concl sub_hi) in |
| 417 |
let th0 = INST[x_tm, x_var_real; a_tm, a_var_real; b_tm, b_var_real; |
| 418 |
low_tm, low_var_real; high_tm, high_var_real; |
| 419 |
t_tm, t_var_real; r_tm, r_var_real; |
| 420 |
lo_tm, lo_var_real; hi_tm, hi_var_real] acs_interval2 in |
| 421 |
itlist MY_PROVE_HYP [x_th; cmp1; cmp2; pi2; asn_a; asn_b; sub_lo; sub_hi] th0 |
| 422 |
else |
| 423 |
failwith ("float_interval_acs: x < -1 or x > 1: " ^ string_of_term (concl x_th));; |
| 424 |
|
| 425 |
end;; |