1 (* file combining all the function data *)
5 This gives the verification of a sample inequality drawn from ineq.hl.
10 flyspeck_needs "../formal_lp/formal_interval/interval_m/recurse.hl";;
11 flyspeck_needs "../formal_lp/formal_interval/interval_m/verifier.hl";;
20 (********************************)
23 let tm = (rand o concl o SPEC_ALL) Sphere.delta_x in
24 expr_to_vector_fun tm;;
27 let tm = (rand o concl o SPEC_ALL o REWRITE_RULE[Sphere.delta_x]) Sphere.delta_y in
28 expr_to_vector_fun tm;;
31 let tm = (rand o concl o SPEC_ALL) Sphere.delta_x4 in
32 expr_to_vector_fun tm;;
35 let tm = (rand o concl o SPECL[`y1*y1`; `y2*y2`; `y3*y3`; `y4*y4`; `y5*y5`; `y6*y6`]) Sphere.delta_x4 in
36 expr_to_vector_fun tm;;
39 let tf_delta_x = build_taylor pp delta_x_poly;;
40 let tf_delta_y = build_taylor pp delta_y_poly;;
41 let tf_delta_x4 = build_taylor pp delta_x4_poly;;
42 let tf_delta_y4 = build_taylor pp delta_y4_poly;;
44 let x = replicate 1.0 8 and
45 y = replicate 2.0 8 and
46 z = replicate 3.0 8 and
49 evalf4 tf_delta_x w x y z;;
50 evalf4 tf_delta_y w x y z;;
51 evalf4 tf_delta_x4 w x y z;;
54 (************************************)
57 let four_y1_delta_y_poly =
58 let x_var, tm = dest_abs delta_y_poly in
59 mk_abs (x_var, mk_binop mul_op_real `&4` (mk_binop mul_op_real `(x:real^6)$1 * x$1` tm));;
61 let neg_delta_y4_poly =
62 let x_var, tm = dest_abs delta_y4_poly in
63 mk_abs (x_var, mk_comb (neg_op_real, tm));;
65 let four_y1_delta_y = build_taylor pp four_y1_delta_y_poly;;
66 let neg_delta_y4 = build_taylor pp neg_delta_y4_poly;;
69 let pi_taylor = build_taylor 10 `\x:real^1. pi`;;
70 let neg_pi_taylor = build_taylor 10 `\x:real^1. --pi`;;
71 let pi2_taylor = build_taylor 10 `\x:real^1. pi / &2`;;
74 let f = tf_product x1 (tf_product x1 x3);;
75 let f = Uni_compose (uinv, x2);;
81 let denom = Uni_compose (uinv, Uni_compose (usqrt, four_y1_delta_y)) in
82 Plus (pi2_taylor, Uni_compose (uatan, tf_product neg_delta_y4 denom));;
89 let dih1 = dih_y_taylor and
90 dih2 = Composite (dih_y_taylor, x2, x3, x1, x5, x6, x4, unit, unit) and
91 dih3 = Composite (dih_y_taylor, x3, x1, x2, x6, x4, x5, unit, unit) in
92 Plus (dih1, Plus (dih2, Plus (dih3, neg_pi_taylor)));;
95 let pi_val= 3.1415926535897932;;
96 let sol0_val = 0.5512855984325308;;
97 let const1_val = sol0_val /. pi_val;;
98 let const1_plus1 = const1_val +. 1.0;;
101 let ly_taylor = build_taylor pp `\x:real^1. #2.52 / #0.52 - x$1 * inv(#0.52)`;;
102 let lnazim_y_taylor =
103 tf_product ly_taylor dih_y_taylor;;
107 let azim1 = lnazim_y_taylor and
108 azim2 = Composite (lnazim_y_taylor, x2, x3, x1, x5, x6, x4, unit, unit) and
109 azim3 = Composite (lnazim_y_taylor, x3, x1, x2, x6, x4, x5, unit, unit) in
110 let f1 = Scale (sol_y_taylor, mk_interval (const1_plus1, const1_plus1)) and
111 f2 = Plus (azim1, Plus (azim2, azim3)) in
112 Plus (f1, Scale (f2, mk_interval (~-.const1_val, ~-.const1_val)));;
115 (*********************)
117 let rec count_f0_flags r =
119 | Result_false _ -> failwith "False result"
120 | Result_glue (_,_,_,r1,r2) -> count_f0_flags r1 + count_f0_flags r2
121 | Result_pass (_,flag,_,_) -> if flag then 1 else 0
122 | Result_pass_mono _ -> 0;;
126 | Result_false _ -> failwith "False result"
127 | Result_glue (mono,_,_,r1,r2) -> List.concat mono @ all_mono r1 @ all_mono r2
128 | Result_pass (mono,_,_,_) -> List.concat mono
129 | Result_pass_mono _ -> [];;
133 | Result_false _ -> failwith "False result"
134 | Result_glue (_,_,_,r1,r2) -> all_pass r1 @ all_pass r2
135 | Result_pass (_,_,x,z) -> [x,z]
136 | Result_pass_mono _ -> [];;
139 let rec count_pass_mono r =
141 | Result_false _ -> failwith "False result"
142 | Result_glue (_,_,_,r1,r2) -> count_pass_mono r1 + count_pass_mono r2
143 | Result_pass (_,_,_,_) -> 0
144 | Result_pass_mono _ -> 1;;
146 let rec count_convex r =
148 | Result_false _ -> failwith "False result"
149 | Result_glue (_,_,flag,r1,r2) -> (if flag then 1 else 0) + count_convex r1 + count_convex r2
156 (*********************)
158 let x = [2.0001; 2.0001; 2.0001; 2.0; 2.0; 2.0; 0.0; 0.0] and
159 z = [2.52; 2.52; 2.52; 2.0; 2.0; 2.0; 0.0; 0.0];;
161 let taum_test1 = run_test taum_taylor x z true 0.0 true true true;;
163 result_size taum_test1;;
165 let taum_test1_0 = run_test0 taum_taylor x z true 0.0 true true true;;
167 result_size taum_test1_0;;
170 count_f0_flags taum_test1;;
171 length (all_mono taum_test1);;
172 count_pass_mono taum_test1;;
173 count_convex taum_test1;;
179 let x = [2.0; 2.0; 2.0; 2.0; 2.0; 2.52; 0.0; 0.0] and
180 z = [2.52; 2.52; 2.52; 2.0; 2.0; 2.52; 0.0; 0.0];;
182 (CONV_RULE (NUM_REDUCE_CONV THENC REAL_RAT_REDUCE_CONV) o SPECL[`2`; `1`]) Sphere.tame_table_d;;
184 let taum_test2 = run_test taum_taylor x z true 0.103 false;;
185 result_size taum_test2;;
188 let x = [2.0; 2.0; 2.0; 2.1771; 2.0; 2.0; 0.0; 0.0] and
189 z = [2.52; 2.52; 2.52; 2.52; 2.52; 2.52; 0.0; 0.0];;
191 let taum_test3 = run_test taum_taylor x z true 0.04 false;;
192 result_size taum_test3;;
199 replicate 2.0 6 @ [0.;0.],
200 replicate 2.52 6 @ [0.;0.];;
201 let ineq = Plus (taum_taylor, Scale (dih_y_taylor, mk_interval (0.626, 0.626)));;
202 let taum_test4 = run_test ineq x z true 0.77 true true true;;
204 result_size taum_test4;;
206 count_f0_flags taum_test4;;
207 length (all_mono taum_test4);;
208 count_pass_mono taum_test4;;
209 count_convex taum_test4;;
212 let ineq = Plus (taum_taylor, Scale (dih_y_taylor, mk_interval (-0.259, -0.259)));;
213 let taum_test5 = run_test ineq x z true (-0.32) false;;
215 result_size taum_test5;;
221 replicate 2.0 6 @ [0.;0.],
222 replicate 2.52 6 @ [0.;0.];;
224 let ineq1_test = run_test dih_y_taylor x z true 0.852 true true true;;
226 result_size ineq1_test;;
228 let ineq1_test0 = run_test0 dih_y_taylor x z true 0.852 true true true;;
229 (* 604796 (true false true) 308962 (true true true) *)
230 result_size ineq1_test0;;
234 count_f0_flags ineq1_test;;
235 all_mono ineq1_test;;
236 count_pass_mono ineq1_test;;
237 count_convex ineq1_test;;
241 let xx = `[&2;&2;&2;&2;&2;&2]` and
242 zz = `[#2.52;#2.52;#2.52;#2.52;#2.52;#2.52]`;;
243 let xx1 = convert_to_float_list pp true xx and
244 zz1 = convert_to_float_list pp false zz;;
246 m_verify_domain_test n pp eval_delta_x4 ineq1_test xx1 zz1;;
250 let dd = (evalf dih_y_taylor x x).dd;;
251 map (fun i -> mth (mth dd i) i) iter8;;
254 let ineq2_test = run_test dih_y_taylor x z false 1.893 true true false;;
255 (* 4905 (4886 with derivatives) *)
256 result_size ineq2_test;;
258 let ineq2_test0 = run_test0 dih_y_taylor x z false 1.893 true true true;;
259 (* 35842 (true false true) 35842 (true true true) *)
260 result_size ineq2_test0;;
262 let all_p = all_pass ineq2_test;;
263 let xx, zz = List.nth all_p 134;;
264 let dd = (evalf dih_y_taylor xx zz).dd;;
265 map (fun i -> mth (mth dd i) i) iter8;;
269 count_f0_flags ineq2_test;;
270 all_mono ineq2_test;;
271 count_pass_mono ineq2_test;;
272 count_convex ineq2_test;;
274 count_f0_flags ineq2_test0;;
275 length (all_mono ineq2_test0);;
276 count_pass_mono ineq2_test0;;
277 count_convex ineq2_test0;;
281 let rec pass_intervals r =
283 | Result_false _ -> failwith "False result"
284 | Result_glue (_,r1,r2) -> pass_intervals r1 @ pass_intervals r2
285 | Result_pass (x,z) -> [x,z];;
288 let intersect_results r1 r2 =
289 let i1 = pass_intervals r1 and
290 i2 = pass_intervals r2 in
291 let i = intersect i1 i2 in
295 let n1, i1 = intersect_results ineq1_test ineq2_test;;
297 let n2, i2 = intersect_results ineq1_test taum_test4;;
299 let n3, i3 = intersect_results ineq2_test taum_test4;;
302 let n4, i4 = intersect_results taum_test4 taum_test5;;
303 maxl (map (maxl o filter (fun x -> x <> 0.) o snd o center_form) (pass_intervals taum_test4));;
308 (*****************************)
316 Ineq.getexact "5735387903";;
317 Ineq.getexact "5490182221";;
318 Ineq.getexact "2570626711";;
319 Ineq.getexact "3296257235";;
321 Ineq.getexact "8519146937";;
322 Ineq.getexact "4667071578";;
323 Ineq.getexact "1395142356";;
324 Ineq.getexact "7394240696";;
325 Ineq.getexact "7726998381";;
326 Ineq.getexact "4047599236";;
328 Ineq.getexact "8248508703";;
329 Ineq.getexact "7931207804";;
331 Ineq.getexact "4491491732";;
336 (**********************************)