forked from leanprover-community/plausible
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArbitraryFueled.lean
More file actions
32 lines (26 loc) · 1.18 KB
/
ArbitraryFueled.lean
File metadata and controls
32 lines (26 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/-
Copyright (c) 2025 AWS. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: AWS
-/
import Plausible.Arbitrary
import Plausible.Gen
namespace Plausible
open Gen
/-- A typeclass for *fueled* random generation, i.e. a variant of
the `Arbitrary` typeclass where the fuel for the generator is made explicit.
- This typeclass is equivalent to Rocq QuickChick's `arbitrarySized` typeclass
(QuickChick uses the `Nat` parameter as both fuel and the generator size,
here we use it just for fuel, as Plausible's `Gen` type constructor
already internalizes the size parameter.) -/
class ArbitraryFueled (α : Type) where
/-- Takes a `Nat` and produces a random generator dependent on the `Nat` parameter
(which indicates the amount of fuel to be used before failing). -/
arbitraryFueled : Nat → Gen α
/-- Every `ArbitraryFueled` instance gives rise to an `Arbitrary` instance -/
instance [ArbitraryFueled α] : Arbitrary α where
arbitrary := Gen.sized ArbitraryFueled.arbitraryFueled
/-- Raised when a fueled generator fails due to insufficient fuel. -/
def Gen.outOfFuel : GenError :=
.genError "out of fuel"
end Plausible