Tomáš Skřivan
Carnegie Mellon University
Hoskinson Center for Formal Mathematics
15.5.2024
define natural numbers and
prove commutativity of addition
def foo (x : R) : R := x^2
def foo_deriv (x : R) : R := 2*x
AD
def foo (x : R) : R := x^2
noncomputable
def foo_deriv (x : R) : R := fderiv R (fun x' => foo x') x 1
noncomputable
def fderiv (f : X → Y) (x : X) : X →L[𝕜] Y :=
if h : ∃ (f' : X →L[𝕜] Y), (fun x' => f x' - f x - f' (x' - x)) =o[𝓝 x] fun x' => x' - x then
choose h
else
0
def foo_deriv (x : R) : R := (fderiv R (fun x' => foo x') x 1) rewrite_by fun_trans
@[fun_trans]
noncomputable
def fderiv (f : X → Y) (x : X) : X →L[𝕜] Y := ...
@[fun_trans]
theorem fderiv_add :
(fderiv K fun x => f x + g x)
=
fun x => fderiv K f x + fderiv K g x := ...
@[fun_trans]
theorem fderiv_comp :
fderiv 𝕜 (fun x => (f (g x)))
=
fun x => fun dx =>L[K] fderiv K f (g x) (fderiv K g x dx) := ...
@[fun_trans]
theorem fderiv_id :
(fderiv K fun x : X => x) = fun _ => fun dx =>L[K] dx := ...
def saxpy (a : Float) (x y : Float^[n]) := a•x+y
def saxpy_optimized (a : Float) (x y : Float^[n]) := x.mapIdx (fun i xi => a*xi + y[i])
?
def_optimize saxpy by
simp only [HAdd.hAdd,Add.add,HSMul.hSMul,SMul.smul]
simp only [mapMono_mapIdxMono]