Skip to content

Commit

Permalink
fix up parametric discontinuities tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lecopivo committed May 17, 2024
1 parent 698064b commit 5e6da43
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
3 changes: 2 additions & 1 deletion SciLean/Core/FunctionTransformations/Preimage.lean
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ theorem Prod.mk.arg_fstsnd.preimage_rule_prod (f : α → β) (g : α → γ) (B
=
f ⁻¹' B ∩ g ⁻¹' C := sorry_proof


@[pp_dot]
def _root_.Set.fst (A : Set (α×β)) (b : β) : Set α := {x | (x,b) ∈ A}
@[pp_dot]
def _root_.Set.snd (A : Set (α×β)) (a : α) : Set β := {y | (a,y) ∈ A}

@[fun_trans]
Expand Down
17 changes: 16 additions & 1 deletion test/prob_ad/affine_discont_1d.lean
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@ example (w : R) (a b c : R) (ha : a ≠ 0) :
∫' x in Icc (0:R) 1,
if a * x + b ≤ c * w' then (1:R) else 0)
=
if 0 ≤ w ∧ w ≤ 1 then 1 else 0 := by
sorry := by

conv =>
lhs
integral_deriv

sorry_proof




variable (w : R) (a b c : R) (ha : a ≠ 0)


/--
info: let ds := ∫' x, (Scalar.abs a)⁻¹ * c ∂(surfaceMeasure 0).restrict ({x | a * x + b - c * w = 0} ∩ Icc 0 1);
ds : R
-/
#guard_msgs in
#check (∂ w':=w,
∫' x in Icc (0:R) 1,
if a * x + b ≤ c * w' then (1:R) else 0) rewrite_by integral_deriv
22 changes: 22 additions & 0 deletions test/prob_ad/affine_discont_2d.lean
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,25 @@ example (w : R) (a b c d : R) :
autodiff

sorry_proof



variable (w : R) (a b c d : R)




/--
info: let ds :=
∫' x,
jacobian R (fun x => (planeDecomposition (a, b) ⋯) ((d * w - c) / Scalar.sqrt (a ^ 2 + b ^ 2), x)) x *
((Scalar.sqrt (a ^ 2 + b ^ 2))⁻¹ *
d) ∂volume.restrict
(((fun x12 => (planeDecomposition (a, b) ⋯) x12) ⁻¹' Icc 0 1 ×ˢ Icc 0 1).snd
((d * w - c) / Scalar.sqrt (a ^ 2 + b ^ 2)));
ds : R
-/
#guard_msgs in
#check (∂ w':=w,
∫' x in Icc (0:R) 1, ∫' y in Icc (0:R) 1,
if a * x + b * y + c ≤ d * w' then (1:R) else 0) rewrite_by integral_deriv; autodiff
File renamed without changes.
19 changes: 19 additions & 0 deletions test/prob_ad/simple_discont_2d.lean
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,22 @@ example (w : R) :
autodiff

sorry_proof



variable (w : R)

/--
info: let ds :=
∫' x,
jacobian R (fun x => (planeDecomposition (1, 1) ⋯) (w / Scalar.sqrt (1 + 1), x)) x *
(Scalar.sqrt
(1 +
1))⁻¹ ∂volume.restrict
(preimageSnd ((fun x12 => (planeDecomposition (1, 1) ⋯) x12) ⁻¹' Icc 0 1 ×ˢ Icc 0 1) (w / Scalar.sqrt (1 + 1)));
ds : R
-/
#guard_msgs in
#check (∂ w':=w,
∫' x in Icc (0:R) 1, ∫' y in Icc (0:R) 1,
if x + y ≤ w' then (1:R) else 0) rewrite_by integral_deriv; autodiff

0 comments on commit 5e6da43

Please sign in to comment.