Skip to content

Commit 685879c

Browse files
committed
major refactor: name change and updated libraries
1 parent 2718043 commit 685879c

18 files changed

Lines changed: 171 additions & 101 deletions

MDPLib.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- This module serves as the root of the `MDPLib` library.
2+
-- Import modules here that should be built as part of the library.
3+
4+
import MDPLib.Probability.Prelude
5+
import MDPLib.Probability.Defs
6+
import MDPLib.Probability.Basic
7+
import MDPLib.Probability.Quantile
8+
9+
import MDPLib.Risk.VaR
10+
11+
import MDPLib.MDP.Histories
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Mathlib.Data.NNReal.Basic
1616
import Mathlib.Data.Finset.Basic
1717
import Mathlib.Data.Finset.Image
1818

19-
import Probability.Probability.Basic
19+
import MDPLib.Probability.Basic
2020

2121
namespace MDPs
2222

@@ -388,10 +388,9 @@ theorem hist_horiz_exact (t : ℕ) (h : Hist M) (hh : h ∈ M.HistoriesHorizon t
388388

389389
def MDP.HistoriesHorizonT (M : MDP) (t : ℕ) : Finset (M.HistT t) :=
390390
let H := M.HistoriesHorizon t
391-
let f : {h : Hist M // h ∈ H} → M.HistT t :=
392-
fun hh => ⟨hh.1, hist_horiz_exact t hh.1 hh.2
393-
have finj : Injective f :=
394-
by unfold Injective f; intro h₁ h₂ steq; rewrite [Subtype.eq_iff] at steq; simpa using steq
391+
let f : {h : Hist M // h ∈ H} → M.HistT t := fun hh => ⟨hh.1, hist_horiz_exact t hh.1 hh.2
392+
have finj : Injective f := by unfold Injective f; intro h₁ h₂ steq; grind only
393+
-- TODO: this used to work instead of grind: rw [Subtype.ext_iff] at steq; simpa using steq
395394
H.attach.map ⟨f, finj⟩
396395

397396
theorem hist_horiz_complete_t (t : ℕ) (h : M.HistT t) : h ∈ M.HistoriesHorizonT t := by
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Probability.Probability.Defs
1+
import MDPLib.Probability.Defs
22

33
import Mathlib.Algebra.BigOperators.Fin
44
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Probability.Probability.Prelude
1+
import MDPLib.Probability.Prelude
22

33
import Mathlib.Data.Matrix.Mul -- dot product definitions and results
44
import Mathlib.Algebra.Notation.Pi.Defs -- operations on functions
@@ -155,13 +155,19 @@ infix:50 "≥ᵣ" => FinRV.geq
155155
/-- Boolean random variable represening Y > y inequality -/
156156
infix:50 ">ᵣ" => FinRV.gt
157157

158+
example (a b : ℕ) (h : a ≤ b +1) : (a ≤ b) ∨ (a = b + 1) := by exact Nat.le_or_eq_of_le_succ h
159+
160+
lemma exclusion {a b : ℕ} (h : a > b + 1) : (a > b) ∧ ¬(a = b + 1) :=
161+
⟨ Nat.lt_of_succ_lt h, Ne.symm (Nat.ne_of_lt h) ⟩
162+
158163
/-- Equivalence when extending the random variable to another element. -/
159164
theorem le_of_le_eq (D : FinRV n ℕ) (m : ℕ) : ((D ≤ᵣ m) + (D =ᵣ m.succ)) = (D ≤ᵣ m.succ) := by
160165
funext x --extensionality principle for functions
161166
unfold FinRV.leq FinRV.eq instHAdd Add.add Pi.instAdd
162-
simp [instBoolAdd]
163-
have := Nat.lt_trichotomy (D x) (m+1)
164-
grind only [cases Or]
167+
rw [Pi.add_apply, bool_sum_or]
168+
by_cases h : D x ≤ m.succ
169+
· simp [h, Nat.le_or_eq_of_le_succ]
170+
· simp [h, exclusion (Nat.not_le.mp h) ]
165171

166172
/-- Defines a preimage of an RV. This is a set with a decidable membership. -/
167173
def preimage (f : FinRV n ρ) : ρ → Set (Fin n) :=
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Probability.Probability.Prelude
1+
import MDPLib.Probability.Prelude
22

33
import Probability.Probability.Defs
44
import Mathlib.Data.Matrix.Mul
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Probability.Probability.Basic
1+
import MDPLib.Probability.Basic
22
import Mathlib.Data.EReal.Basic
33
import Mathlib.Data.Set.Operations
44
import Mathlib.Data.Fin.VecNotation

0 commit comments

Comments
 (0)