Skip to content

Commit

Permalink
use differentiable tactic when differentiating
Browse files Browse the repository at this point in the history
  • Loading branch information
lecopivo committed Jul 13, 2023
1 parent db890d1 commit 4d226de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 28 deletions.
39 changes: 12 additions & 27 deletions SciLean/FTrans/FDeriv/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Mathlib.Analysis.Calculus.FDeriv.Linear

import SciLean.Tactic.LSimp.Elab
import SciLean.FunctionSpaces.ContinuousLinearMap.Basic
import SciLean.FunctionSpaces.Differentiable.Basic

namespace SciLean

Expand All @@ -32,14 +33,14 @@ variable {E : ι → Type _} [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpa

@[ftrans]
theorem fderiv.id_rule
: (fderiv K fun x : X => x) = fun _ => ContinuousLinearMap.id K X -- fun _ => fun dx →L[K] dx
:= by funext x; simp
: (fderiv K fun x : X => x) = fun _ => fun dx =>L[K] dx
:= by ext x dx; simp


@[ftrans]
theorem fderiv.const_rule (x : X)
: (fderiv K fun _ : Y => x) = fun _ => 0
:= by funext x; simp
: (fderiv K fun _ : Y => x) = fun _ => fun dx =>L[K] 0
:= by ext x dx; simp


theorem fderiv.let_rule_at
Expand Down Expand Up @@ -183,7 +184,7 @@ def fderiv.ftransInfo : FTrans.Info where

applyLambdaLambdaRule e := return none

discharger := `(tactic| simp)
discharger := `(tactic| differentiable)

#check MacroM
-- do
Expand Down Expand Up @@ -219,10 +220,7 @@ example :
=
fun _ => fun dx =>L[K] dx
:=
by ftrans only; rfl


#exit
by ftrans only

example (x : X) :
(fderiv K λ _ : Y => x)
Expand All @@ -231,24 +229,13 @@ example (x : X) :
:=
by ftrans only

theorem hihi (x : X) :
(fderiv K λ _ : Y => x)
=
fun _ => 0
:=
by ftrans only

set_option trace.Meta.Tactic.ftrans.step true
set_option trace.Meta.Tactic.simp.rewrite true
set_option trace.Meta.Tactic.simp.discharge true


example :
(fderiv K λ x : X => (x + x) + (x + x) + (x + x))
=
fun _ => 0
:= by
ftrans only
ext x dx; simp
sorry

example (x' : X) :
Expand All @@ -262,17 +249,15 @@ example (x' : X) :
rw [HAdd.hAdd.arg_a4a5.fderiv_comp _ _ (by simp) (by simp)]
sorry

#exit

example (x' : X) :
(fderiv K λ x : X => x + x')
=
fun _ => 0
fun _ => fun dx =>L[K] dx
:= by
ftrans only
sorry

ftrans only; simp
ext x dx; simp

#exit

-- set_option pp.all true
example :
Expand Down
2 changes: 1 addition & 1 deletion SciLean/FunctionSpaces/Differentiable/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ macro "differentiable" : tactic =>
-- Basic rules -----------------------------------------------------------------
--------------------------------------------------------------------------------

namespace IsContinuousLinearMap
namespace Differentiable

variable
{R : Type _} [NontriviallyNormedField R]
Expand Down

0 comments on commit 4d226de

Please sign in to comment.