2 (* port of lineInterval.cc.
3 Only the top section has been translated. The rest should be
4 automatically generated from HOL Light specs.
6 This impements basic operations on the type line,
7 such as addition and scalar multiplication.
11 flyspeck_needs "../formal_lp/formal_interval/interval_m/interval.hl";;
13 module Line_interval = struct
19 (* general utilities *)
22 let table f = map f iter8;;
24 let table2 f = map (fun i -> map (fun j-> f i j) iter8) iter8;;
26 let rth m x i = if (i >=0) && (i < m) then List.nth x i else
27 failwith (Printf.sprintf "index %d not in 0..%d" i (m-1));;
29 let mth x i = if (i >=0) && (i < 8) then List.nth x i else
30 failwith (Printf.sprintf "index %d not in 0..8" i );;
32 let mth2 a i j = mth (mth a i) j;;
34 let maxl xs = end_itlist max xs;;
36 let minl xs = end_itlist min xs;;
38 (* line interval proper *)
40 let partial line i = mth line.df i ;;
42 let mk_line(f1,df1) = { f = f1; df =df1};;
46 mk_line(z,replicate z 8);;
49 mk_line(one,replicate zero 8);;
54 fun a b -> mk_line ( a.f * b.f, map (fun i -> a.f * mth b.df i + b.f * mth a.df i) iter8);;
58 fun a b -> mk_line ( a.f * b, map (fun x -> x * b) a.df);;
61 let one = mk_interval(1.0,1.0) in
69 mk_line ( f, map (fun i -> ((mth b.df i) * a.f - (mth a.df i) * b.f)* r2) iter8);;
74 mk_line(b.f + a.f, map (fun i -> mth b.df i + mth a.df i) iter8);;
79 mk_line(b.f - a.f, map (fun i -> mth b.df i - mth a.df i) iter8);;
84 mk_line(ineg a.f, map ineg a.df);;
87 let one = mk_interval(1.0,1.0) in
88 let two = mk_interval(2.0,2.0) in
93 let rs = one / (two * f) in
94 mk_line(f, map (fun i -> mth a.df i * rs) iter8);;
96 let latan = (* arctan (a/b) *)
97 let one = mk_interval(1.0,1.0) in
103 let f = iatan (a.f/b.f) in
104 let rden = one/ (a.f * a.f + b.f * b.f) in
105 mk_line(f, map (fun i -> rden * (mth a.df i * b.f - mth b.df i * a.f)) iter8);;