2 (* for derivatives in 6 dimensions *)
4 let HAS_SIZE_6 = define_finite_type 6;;
6 let DIMINDEX_6 = MATCH_MP DIMINDEX_UNIQUE HAS_SIZE_6;;
8 let lift_6 = new_definition `lift_6 (f:real->real->real->real->real->real->real) =
9 (\ (v:real^6). lift (f (v$1) (v$2) (v$3) (v$4) (v$5) (v$6)) )`;;
11 let drop_6 = new_definition `drop_6 (f:real^6->real^1) =
12 (\x1 x2 x3 x4 x5 x6. drop (f (vector [x1;x2;x3;x4;x5;x6])))`;;
14 let lambda_ext = prove_by_refinement(
15 `!P Q. (!i. 1 <= i /\ i <= dimindex (:B) ==> ((P:num->A) i = Q i)) =
16 (((lambda i. P i):A^B) = (lambda i. Q i))`,
20 REWRITE_TAC [GSYM LAMBDA_UNIQUE];
21 SIMP_TAC [LAMBDA_BETA];
26 let vector6 = prove_by_refinement(
27 `!(v:real^6). vector [v$1; v$2; v$3; v$4; v$5; v$6] = v`,
30 REWRITE_TAC [vector;GSYM LAMBDA_UNIQUE];
31 REWRITE_TAC [DIMINDEX_6;ARITH_RULE `1 <= i /\ i <=6 <=> (i=1 \/ i=2 \/ i=3 \/ i=4 \/ i=5 \/ i=6)`];
32 REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[EL;HD;TL;ARITH_RULE `1-1=0 /\ 2 - 1 = SUC 0 /\ 3 - 1 = SUC (SUC 0) /\ 4 - 1 = SUC (SUC(SUC 0)) /\ 5 - 1 = SUC (SUC(SUC(SUC 0))) /\ 6 - 1 = SUC(SUC(SUC(SUC(SUC 0))))`]
36 let vector6_comp = prove_by_refinement(
38 (vector:(A)list -> A^6) [x1;x2;x3;x4;x5;x6]$1 = x1 /\
39 (vector:(A)list -> A^6) [x1;x2;x3;x4;x5;x6]$2 = x2 /\
40 (vector:(A)list -> A^6) [x1;x2;x3;x4;x5;x6]$3 = x3 /\
41 (vector:(A)list -> A^6) [x1;x2;x3;x4;x5;x6]$4 = x4 /\
42 (vector:(A)list -> A^6) [x1;x2;x3;x4;x5;x6]$5 = x5 /\
43 (vector:(A)list -> A^6) [x1;x2;x3;x4;x5;x6]$6 = x6
48 SIMP_TAC [REWRITE_RULE[DIMINDEX_6] (INST_TYPE[`:6`,`:B`] LAMBDA_BETA); ARITH_RULE `1 <= 1 /\ 1 <=6 /\ 1 <= 2 /\ 2 <= 6 /\ 1 <= 3 /\ 3 <= 6 /\ 1 <= 4 /\ 4 <= 6 /\ 1 <= 5 /\ 5 <= 6 /\ 1 <= 6 /\ 6 <= 6 `;EL;HD;TL;ARITH_RULE `1-1=0 /\ 2 - 1 = SUC 0 /\ 3 - 1 = SUC (SUC 0) /\ 4 - 1 = SUC (SUC(SUC 0)) /\ 5 - 1 = SUC (SUC(SUC(SUC 0))) /\ 6 - 1 = SUC(SUC(SUC(SUC(SUC 0))))`]
53 let lift6_drop6 = prove_by_refinement(
54 `!f. lift_6 (drop_6 f) = f`,
57 REWRITE_TAC [lift_6;drop_6;lift;drop];
59 ONCE_REWRITE_TAC[FUN_EQ_THM];
62 REWRITE_TAC [(GSYM VECTOR_ONE)];
68 let drop6_lift6 = prove_by_refinement(
69 `!f. drop_6 (lift_6 f) = f`,
72 REWRITE_TAC [lift_6;drop_6;vector6_comp;LIFT_DROP];
74 REPEAT (MATCH_MP_TAC EQ_EXT THEN GEN_TAC);
81 (* f'' is the Hessian, viewed as a bilinear function at x.
82 I plan to use this always on a product X of compact intervals in 6-d,
83 such that X SUBSET P. We should be able to take `s = (:real^6)` in every case. *)
86 let derived_form2a = new_definition `derived_form2a
87 p (f:real^6->real) (f':real^6->real^6->real)
88 (f'':real^6 -> real^6 ->real^6 ->real) (x:real^6) (s:real^6->bool) =
89 ((!(y:real^6). p y ==> ((has_derivative) (lift o f) (lift o (f' y)) (at y)) ) /\
90 (!t. p x ==> (has_derivative) (\u. lift (f' u t)) (\t'. lift (f'' x t t')) (at x within s)) /\
91 (!(y:real^6) t t'. p y ==> (continuous) (\u. lift (f'' u t t')) (at y within s)))
95 let derived_form2b = new_definition `derived_form2b
96 p (f:real^6->real) (f':real^6->real^6->real)
97 (f'':real^6 -> real^6 ->real^6 ->real) (x:real^6) (s:real^6->bool) =
98 ((!(y:real^6). p y ==> ((has_derivative) (lift o f) (lift o (f' y)) (at y)) ) /\
99 (!t. p x ==> (has_derivative) (\u. lift (f' u t)) (\t'. lift (f'' x t t')) (at x within s)) /\ ( open p) /\
100 (!(y:real^6) t t'. p y ==> (continuous) (\u. lift (f'' u t t')) (at y within s)))
105 1. Clairaut's theorem on equality of mixed partials.
106 This uses the continuity and openness assumptions, so they have beeen added
108 Many proofs are available, google search "Equality of Mixed Partials"
109 For example, http://www.math.ubc.ca/~feldman/m226/mixed.pdf
111 2. Multivariate Taylor's theorem,
112 This can be deduced from REAL_TAYLOR by
113 taking t-derivative along a line segement `\t. f(x + t % v)`
115 3. Identification of Hessian as a bilinear function with the
116 matrix of second partials. This should follow from JACOBIAN_WORKS.
119 Automatic generation of derived_form2b from f.
124 let mixed_equal = prove_by_refinement(
125 `!f f' f'' x s. derived_form2b p f f' f'' x s ==>
126 (!t t'. p y ==> f'' y t t' = f'' y t' t)`,