Skip to content

Commit

Permalink
patches for nightly-2025-01-04, and drop Batteries dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-em committed Jan 4, 2025
1 parent 1622a86 commit 189ebbf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
12 changes: 9 additions & 3 deletions Plausible/Gen.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Henrik Böving, Simon Hudon
-/
import Plausible.Random
import Batteries.Data.List.Perm

/-!
# `Gen` Monad
Expand Down Expand Up @@ -98,15 +97,22 @@ def elements (xs : List α) (pos : 0 < xs.length) : Gen α := do
let ⟨x, _, h2⟩ ← up <| chooseNatLt 0 xs.length pos
return xs[x]

open List in

/-!
adaptation_note
Due to an error in `nightly-2025-01-04`, we temporarily need `open Classical in` here,
and `(α := α)` at the call site of `List.perm_insertIdx`. Both should be removed after `nightly-2025-01-05` is available.
-/
open List in
open Classical in
/-- Generate a random permutation of a given list. -/
def permutationOf : (xs : List α) → Gen { ys // xs ~ ys }
| [] => pure ⟨[], Perm.nil⟩
| x::xs => do
let ⟨ys, h1⟩ ← permutationOf xs
let ⟨n, _, h3⟩ ← up <| choose Nat 0 ys.length (by omega)
return ⟨insertIdx n x ys, Perm.trans (Perm.cons _ h1) (List.perm_insertIdx _ _ h3).symm⟩
return ⟨insertIdx n x ys, Perm.trans (Perm.cons _ h1) (List.perm_insertIdx (α := α) _ _ h3).symm⟩

/-- Given two generators produces a tuple consisting out of the result of both -/
def prodOf {α : Type u} {β : Type v} (x : Gen α) (y : Gen β) : Gen (α × β) := do
Expand Down
1 change: 1 addition & 0 deletions Plausible/Sampleable.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Henrik Böving, Simon Hudon
-/
import Lean.Elab.Command
import Lean.Meta.Eval
import Plausible.Gen

/-!
Expand Down
4 changes: 2 additions & 2 deletions lake-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"type": "git",
"subDir": null,
"scope": "leanprover-community",
"rev": "8ce422eb59adf557fac184f8b1678c75fa03075c",
"rev": "18c0c2e5a1edb93e8bc86536872872522cea50f4",
"name": "batteries",
"manifestFile": "lake-manifest.json",
"inputRev": "v4.16.0-rc1",
"inputRev": "nightly-testing",
"inherited": false,
"configFile": "lakefile.toml"}],
"name": "plausible",
Expand Down
5 changes: 0 additions & 5 deletions lakefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ name = "Test"

[[lean_lib]]
name = "Plausible"

[[require]]
name = "batteries"
scope = "leanprover-community"
rev = "v4.16.0-rc1"
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:v4.16.0-rc1
leanprover/lean4:nightly-2025-01-04

0 comments on commit 189ebbf

Please sign in to comment.