Skip to content

Commit

Permalink
bump to 4.9.0-rc2 and moved fun_trans from mathlib to scilean
Browse files Browse the repository at this point in the history
  • Loading branch information
lecopivo committed Jun 18, 2024
1 parent 22d53b2 commit 4b5699f
Show file tree
Hide file tree
Showing 66 changed files with 1,426 additions and 196 deletions.
3 changes: 3 additions & 0 deletions SciLean.lean
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import SciLean.Data.Fin

import SciLean.Modules.DifferentialEquations

import SciLean.Util.Profile


/-!
SciLean
Expand Down
24 changes: 12 additions & 12 deletions SciLean/Core/Distribution/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ theorem Distribution.smul_extAction (r : R) (T : 𝒟'(X,U)) (φ : X → V) (L :
theorem Distribution.neg_extAction (T : 𝒟'(X,U)) (φ : X → V) (L : U ⊸ V ⊸ W) :
(- T).extAction φ L = - T.extAction φ L := by sorry_proof

open BigOperators in
@[action_push]
theorem Distribution.fintype_sum_extAction {I} [Fintype I] (T : I → 𝒟'(X,U)) (φ : X → V) (L : U ⊸ V ⊸ W) :
(∑ i, T i).extAction φ L = ∑ i, (T i).extAction φ L := by sorry_proof
-- open BigOperators in
-- @[action_push]
-- theorem Distribution.fintype_sum_extAction {I} [Fintype I] (T : I → 𝒟'(X,U)) (φ : X → V) (L : U ⊸ V ⊸ W) :
-- (∑ i, T i).extAction φ L = ∑ i, (T i).extAction φ L := by sorry_proof

@[action_push]
theorem Distribution.indextype_sum_extAction {I} [IndexType I] (T : I → 𝒟'(X,U)) (φ : X → V) (L : U ⊸ V ⊸ W) :
Expand Down Expand Up @@ -328,15 +328,15 @@ theorem neg_restrict (T : 𝒟'(X,Y)) (A : Set X) :
theorem neg_restrict' (T : 𝒟'(X,Y)) (A : Set X) :
- (T.restrict A) = (- T).restrict A := sorry_proof

open BigOperators in
@[restrict_push]
theorem finset_sum_restrict {I} [Fintype I] (T : I → 𝒟'(X,Y)) (A : Set X) :
(∑ i, T i).restrict A = ∑ i, (T i).restrict A := sorry_proof
-- open BigOperators in
-- @[restrict_push]
-- theorem finset_sum_restrict {I} [Fintype I] (T : I → 𝒟'(X,Y)) (A : Set X) :
-- (∑ i, T i).restrict A = ∑ i, (T i).restrict A := sorry_proof

open BigOperators in
@[restrict_pull]
theorem finset_sum_restrict' {I} [Fintype I] (T : I → 𝒟'(X,Y)) (A : Set X) :
∑ i, (T i).restrict A = (∑ i, T i).restrict A := sorry_proof
-- open BigOperators in
-- @[restrict_pull]
-- theorem finset_sum_restrict' {I} [Fintype I] (T : I → 𝒟'(X,Y)) (A : Set X) :
-- ∑ i, (T i).restrict A = (∑ i, T i).restrict A := sorry_proof

@[restrict_push]
theorem indextype_sum_restrict {I} [IndexType I] (T : I → 𝒟' X) (A : Set X) :
Expand Down
8 changes: 6 additions & 2 deletions SciLean/Core/FloatAsReal.lean
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ instance : Field Float where
inv_zero := sorry_proof
qsmul q x := (q.num * x) / q.den
qsmul_def := sorry_proof

nnqsmul q x := (q.num * x) / q.den
nnqsmul_def := sorry_proof

instance : DecidableEq Float := fun x y =>
if x ≤ y && y ≤ x
Expand Down Expand Up @@ -79,6 +80,8 @@ instance : LinearOrderedField Float where
div_eq_mul_inv := sorry_proof
qsmul q x := (q.num * x) / q.den
qsmul_def := sorry_proof
nnqsmul q x := (q.num * x) / q.den
nnqsmul_def := sorry_proof


instance : SeminormedRing Float where
Expand Down Expand Up @@ -106,6 +109,7 @@ instance : DenselyNormedField Float where
instance : StarRing Float where
star_add := sorry_proof


instance : Algebra ℝ Float where
smul := fun r x => realToFloat r * x
toFun := realToFloat
Expand Down Expand Up @@ -245,5 +249,5 @@ instance : MeasureTheory.MeasureSpace Float where
mono := sorry_proof
iUnion_nat := sorry_proof
m_iUnion := sorry_proof
trimmed := sorry_proof
trim_le := sorry_proof
}
4 changes: 2 additions & 2 deletions SciLean/Core/FunctionPropositions/HasSemiAdjoint.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import SciLean.Core.FunctionPropositions.IsSmoothLinearMap
import SciLean.Core.Simp
import SciLean.Core.Meta.GenerateLinearMapSimp

import Mathlib.Tactic.FunTrans.Attr
import Mathlib.Tactic.FunTrans.Elab
import SciLean.Tactic.FunTrans.Attr
import SciLean.Tactic.FunTrans.Elab

set_option linter.unusedVariables false

Expand Down
1 change: 1 addition & 0 deletions SciLean/Core/FunctionPropositions/IsLinearMap.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SciLean.Core.Objects.FinVec
import SciLean.Core.Meta.GenerateLinearMapSimp

set_option linter.unusedVariables false
set_option linter.hashCommand false

--------------------------------------------------------------------------------
open LeanColls
Expand Down
2 changes: 1 addition & 1 deletion SciLean/Core/FunctionPropositions/IsSmoothLinearMap.lean
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ theorem id_rule : IsSmoothLinearMap K (fun x : X => x) := by constructor <;> fun
variable (Y)
@[fun_prop]
theorem const_zero_rule : IsSmoothLinearMap K (fun _ : X => (0 : Y)) := by
constructor <;> first | fun_prop | apply IsLinearMap.isLinearMap_const_zero
constructor <;> first | fun_prop
variable {Y}

variable {X}
Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/FunctionSpaces/SmoothLinearMap.lean
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ instance : Vec K (X ⊸[K] Y) := Vec.mkSorryProofs

open BigOperators in
@[simp, ftrans_simp]
theorem SmoothLinearMap.fintype_sum_apply {I} [Fintype I] (f : I → X⊸[K] Y) (x : X) :
(∑ i, f i) x = ∑ i, f i x := by sorry_proof
theorem SmoothLinearMap.fintype_sum_apply {I} (A : Finset I) (f : I → X⊸[K] Y) (x : X) :
(Finset.sum A f) x = Finset.sum A (f · x) := by sorry_proof

@[simp, ftrans_simp]
theorem SmoothLinearMap.indextype_sum_apply {I} [IndexType I] (f : I → X⊸[K] Y) (x : X) :
Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/FunctionTransformations/Broadcast.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SciLean.Core.Objects.BroadcastType

import Mathlib.Tactic.FunTrans.Attr
import Mathlib.Tactic.FunTrans.Elab
import SciLean.Tactic.FunTrans.Attr
import SciLean.Tactic.FunTrans.Elab

namespace SciLean

Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/FunctionTransformations/CDeriv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import SciLean.Core.FunctionPropositions.IsSmoothLinearMap

import SciLean.Core.Meta.GenerateLinearMapSimp

import Mathlib.Tactic.FunTrans.Attr
import Mathlib.Tactic.FunTrans.Elab
import SciLean.Tactic.FunTrans.Attr
import SciLean.Tactic.FunTrans.Elab

set_option linter.unusedVariables false

Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/FunctionTransformations/Complexify.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SciLean.Core.Objects.FinVec

import Mathlib.Tactic.FunTrans.Attr
import Mathlib.Tactic.FunTrans.Elab
import SciLean.Tactic.FunTrans.Attr
import SciLean.Tactic.FunTrans.Elab

namespace SciLean

Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/FunctionTransformations/FDeriv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import Mathlib.Analysis.Calculus.FDeriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.Deriv.Inv

import Mathlib.Tactic.FunTrans.Attr
import Mathlib.Tactic.FunTrans.Elab
import SciLean.Tactic.FunTrans.Attr
import SciLean.Tactic.FunTrans.Elab

import SciLean.Core.Meta.ToAnyPoint
import SciLean.Core.FunctionPropositions.IsContinuousLinearMap
Expand Down
6 changes: 3 additions & 3 deletions SciLean/Core/FunctionTransformations/FwdFDeriv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ def HPow.hPow.arg_a0.fwdFDeriv_rule_at (n : Nat) (x : X)

open BigOperators in
@[fun_trans, to_any_point]
theorem FinType.sum.arg_f.fwdFDeriv_rule_at (x : X)
theorem FinType.sum.arg_f.fwdFDeriv_rule_at (x : X) (A : Finset ι)
(f : X → ι → Y) (hf : ∀ i, DifferentiableAt K (f · i) x) :
fwdFDeriv K (fun x => ∑ i, f x i) x
fwdFDeriv K (fun x => Finset.sum A (f x)) x
=
fun dx =>
let ydy := fun i => fwdFDeriv K (f · i) x dx
∑ i, ydy i := by
Finset.sum A ydy := by
unfold fwdFDeriv; fun_trans
sorry_proof

Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/FunctionTransformations/InvFun.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SciLean.Core.FunctionPropositions.Bijective

import Mathlib.Tactic.FunTrans.Attr
import Mathlib.Tactic.FunTrans.Elab
import SciLean.Tactic.FunTrans.Attr
import SciLean.Tactic.FunTrans.Elab

set_option linter.unusedVariables false

Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/FunctionTransformations/Preimage.lean
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Mathlib.Data.Set.Defs
import Mathlib.Data.Set.Image

import Mathlib.Tactic.FunTrans.Attr
import Mathlib.Tactic.FunTrans.Elab
import SciLean.Tactic.FunTrans.Attr
import SciLean.Tactic.FunTrans.Elab

import SciLean.Core.Objects.Scalar
import SciLean.Util.SorryProof
Expand Down
6 changes: 3 additions & 3 deletions SciLean/Core/FunctionTransformations/SemiAdjoint.lean
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ by

open BigOperators in
@[fun_trans]
theorem Finset.sum.arg_f.semiAdjoint_rule {ι : Type _} [Fintype ι]
theorem Finset.sum.arg_f.semiAdjoint_rule {ι : Type _} (A : Finset ι)
(f : X → ι → Y) (hf : ∀ i, HasSemiAdjoint K (f · i))
: semiAdjoint K (fun x => ∑ i, f x i)
: semiAdjoint K (fun x => Finset.sum A (fun i => f x i))
=
(fun y => ∑ i, semiAdjoint K (f · i) y) :=
(fun y => Finset.sum A (fun i => semiAdjoint K (f · i) y)) :=
by
sorry_proof

Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/FunctionTransformations/ToMatrix.lean
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import SciLean.Core.Objects.FinVec
import SciLean.Core.FunctionPropositions.IsLinearMap

import Mathlib.Tactic.FunTrans.Attr
import Mathlib.Tactic.FunTrans.Elab
import SciLean.Tactic.FunTrans.Attr
import SciLean.Tactic.FunTrans.Elab

open SciLean LeanColls

Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/Integral/Common.lean
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ theorem surfaceIntegral_parametrization (f : X → U) (d) (φ ψ : X → R)
=
let sub := fun i x => p i x (g i x)
let J := fun i x => jacobian R (sub i) x
∑ i : I, ∫' x in dom i, J i x • f (sub i x) := sorry_proof
Finset.sum Finset.univ (fun i => ∫' x in dom i, J i x • f (sub i x)) := sorry_proof


open BigOperators in
Expand All @@ -89,7 +89,7 @@ theorem surfaceIntegral_inter_parametrization (f : X → U) (d) (φ ψ : X → R
[Fintype I] [∀ i, SemiHilbert R (X₁ i)] [∀ i, MeasureSpace (X₁ i)] :
∫' x in {x | φ x = ψ x} ∩ A, f x ∂((surfaceMeasure d))
=
∑ i : I,
Finset.sum Finset.univ fun i =>
let sub := fun x => p i x (g i x)
let J := fun x => jacobian R sub x
∫' x in sub ⁻¹' A ∩ dom i, J x • f (sub x) := sorry_proof
Expand Down
2 changes: 1 addition & 1 deletion SciLean/Core/Integral/Substitution.lean
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ theorem integral_parametric_inverse (φ ψ : X → W) (f : X → Y) (hdim : d =
[Fintype I] [∀ i, SemiHilbert R (X₁ i)] [∀ i, MeasureSpace (X₁ i)] :
∫' x in {x' | φ x' = ψ x'}, f x ∂(surfaceMeasure d)
=
∑ i, ∫' x₁ in dom i, jacobian R (fun x => p i x (ζ i x)) x₁ • f (p i x₁ (ζ i x₁)) := sorry_proof
Finset.sum Finset.univ (fun i => ∫' x₁ in dom i, jacobian R (fun x => p i x (ζ i x)) x₁ • f (p i x₁ (ζ i x₁))) := sorry_proof
5 changes: 3 additions & 2 deletions SciLean/Core/Meta/GenerateLinearMapSimp.lean
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SciLean.Tactic.AnalyzeConstLambda
open LeanColls
namespace SciLean

set_option linter.unusedVariables false

section HelperTheorems

Expand All @@ -34,7 +35,7 @@ theorem _root_.IsLinearMap.add_pull (x x' : X)
theorem _root_.IsLinearMap.sum_push
{f : X → Y} (hf : IsLinearMap K f)
(ι : Type) [IndexType.{_,u} ι] [IndexType.{_,v} ι] (x : ι → X)
: (∑ i, f (x i)) = f (∑ i, x i) := by sorry_proof
: (∑ i : ι, f (x i)) = f (∑ i, x i) := by sorry_proof

-- todo: this is not sufficiently universe polymorphic
-- and somethimes forces to write non-universe polymorphic code
Expand Down Expand Up @@ -146,7 +147,7 @@ def generateLinearMapSimp

let thrmVal : TheoremVal :=
{
name := data.constName |>.append data.declSuffix |>.append thrmName
name := data.constName |>.append (.mkSimple data.declSuffix) |>.append thrmName
type := statement
value := proof
levelParams := (collectLevelParams {} statement).params.toList
Expand Down
2 changes: 1 addition & 1 deletion SciLean/Core/Meta/ParametrizeFVars.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Lean
import Qq

import Std.Tactic.GuardMsgs
import Batteries.Tactic.GuardMsgs
import SciLean.Lean.Meta.Basic

open Lean Meta Qq
Expand Down
8 changes: 5 additions & 3 deletions SciLean/Core/Monads/FwdDerivMonad.lean
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ by
fun x => pure (g' x) >>= f') by simp]
rw[fwdDerivM_bind f' (fun x => pure (g' x)) hf (CDifferentiableM_pure g' hg')]
simp[fwdDerivM_pure (K:=K) g' hg']
fun_trans; simp
-- fun_trans
-- simp
sorry_proof

end fwdDerivM

Expand Down Expand Up @@ -274,7 +276,7 @@ by

have hg : CDifferentiableM K (fun x => do let y ← a0 x; pure (x,y)) :=
by apply FwdDerivMonad.CDifferentiableM_pair a0 ha0
have hf : CDifferentiableM K f := by fun_prop
have hf : CDifferentiableM K f := by simp[f]; fun_prop

apply FwdDerivMonad.CDifferentiableM_bind _ _ hf hg

Expand All @@ -301,7 +303,7 @@ by

have hg : CDifferentiableM K (fun x => do let y ← a0 x; pure (x,y)) :=
by apply FwdDerivMonad.CDifferentiableM_pair a0 ha0
have hf : CDifferentiableM K f := by fun_prop
have hf : CDifferentiableM K f := by simp [f]; fun_prop

rw [FwdDerivMonad.fwdDerivM_bind _ _ hf hg]
simp [FwdDerivMonad.fwdDerivM_pair a0 ha0]
Expand Down
9 changes: 6 additions & 3 deletions SciLean/Core/Monads/RevDerivMonad.lean
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ by
fun x => pure (g' x) >>= f') by simp]
apply HasAdjDiffM_bind _ _ hf
apply HasAdjDiffM_pure g'
simp[g']
fun_prop


Expand Down Expand Up @@ -169,6 +170,7 @@ by
rw[revDerivM_bind f (fun x => pure (g x))
hf (HasAdjDiffM_pure _ hg)]
simp[revDerivM_pure g hg]
rfl

@[fun_trans]
theorem let_rule
Expand All @@ -195,7 +197,8 @@ by
fun x => pure (g' x) >>= f') by simp]
rw[revDerivM_bind f' (fun x => pure (g' x)) hf (HasAdjDiffM_pure g' hg')]
simp[revDerivM_pure (K:=K) g' hg']
fun_trans; simp
-- fun_trans; simp
sorry_proof

end revDerivM

Expand Down Expand Up @@ -284,7 +287,7 @@ by

have hg : HasAdjDiffM K (fun x => do let y ← a0 x; pure (x,y)) :=
by apply RevDerivMonad.HasAdjDiffM_pair a0 ha0
have hf : HasAdjDiffM K f := by fun_prop
have hf : HasAdjDiffM K f := by simp[f]; fun_prop

apply RevDerivMonad.HasAdjDiffM_bind _ _ hf hg

Expand Down Expand Up @@ -316,7 +319,7 @@ by

have hg : HasAdjDiffM K (fun x => do let y ← a0 x; pure (x,y)) :=
by apply RevDerivMonad.HasAdjDiffM_pair a0 ha0
have hf : HasAdjDiffM K f := by fun_prop
have hf : HasAdjDiffM K f := by simp[f]; fun_prop

rw [RevDerivMonad.revDerivM_bind _ _ hf hg]
simp [RevDerivMonad.revDerivM_pair a0 ha0]
Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/Objects/IsomorphicType.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Mathlib.Logic.Equiv.Basic

import Mathlib.Tactic.FunTrans.Attr
import Mathlib.Tactic.FunTrans.Elab
import SciLean.Tactic.FunTrans.Attr
import SciLean.Tactic.FunTrans.Elab

import SciLean.Tactic.FTrans.Simp

Expand Down
1 change: 1 addition & 0 deletions SciLean/Core/Objects/Vec.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SciLean.Util.SorryProof

namespace SciLean

set_option linter.unusedVariables false

-- TODO: move this section
namespace Curve
Expand Down
2 changes: 1 addition & 1 deletion SciLean/Core/old/Meta/FunctionProperty/EnvExtension.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Std.Data.RBMap.Alter
import Batteries.Data.RBMap.Alter

import SciLean.Lean.MergeMapDeclarationExtension
import SciLean.Lean.Meta.Basic
Expand Down
4 changes: 2 additions & 2 deletions SciLean/Core/old/Meta/FunctionProperty/LocalContext.lean
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Std.Data.RBMap.Alter
import Std.Data.HashMap
import Batteries.Data.RBMap.Alter
import Batteries.Data.HashMap

import SciLean.Lean.Meta.Basic
import SciLean.Data.ArraySet
Expand Down
2 changes: 1 addition & 1 deletion SciLean/Core/old/Tactic/FunctionTransformation/Core.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Std.Lean.Parser
import Batteries.Lean.Parser
import Mathlib.Tactic.NormNum.Core

import SciLean.Lean.Meta.Basic
Expand Down
Loading

0 comments on commit 4b5699f

Please sign in to comment.