diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,6 @@
+module Main(main)
+
+import Distribution.Simple
+
+main :: IO ()
+main = defaultMain
diff --git a/opentheory-bits.cabal b/opentheory-bits.cabal
new file mode 100644
--- /dev/null
+++ b/opentheory-bits.cabal
@@ -0,0 +1,29 @@
+name: opentheory-bits
+version: 1.63
+category: Formal Methods
+synopsis: Natural number to bit-list conversions
+license: MIT
+license-file: LICENSE
+cabal-version: >= 1.8.0.2
+build-type: Simple
+author: Joe Leslie-Hurd <joe@gilith.com>
+maintainer: Joe Leslie-Hurd <joe@gilith.com>
+description:
+  Natural number to bit-list conversions - this package was automatically
+  generated from the OpenTheory package natural-bits-1.63
+
+library
+  build-depends:
+    base >= 4.0 && < 5.0,
+    QuickCheck >= 2.4.0.1 && < 3.0,
+    opentheory-primitive >= 1.3 && < 2.0,
+    opentheory >= 1.195 && < 1.196,
+    opentheory-probability >= 1.46 && < 1.47
+
+  hs-source-dirs: src
+
+  ghc-options: -Wall
+
+  exposed-modules:
+    OpenTheory.Natural.Bits
+    OpenTheory.Natural.Uniform
diff --git a/src/OpenTheory/Natural/Bits.hs b/src/OpenTheory/Natural/Bits.hs
new file mode 100644
--- /dev/null
+++ b/src/OpenTheory/Natural/Bits.hs
@@ -0,0 +1,62 @@
+{- |
+module: $Header$
+description: Natural number to bit-list conversions
+license: MIT
+
+maintainer: Joe Leslie-Hurd <joe@gilith.com>
+stability: provisional
+portability: portable
+-}
+
+module OpenTheory.Natural.Bits
+where
+
+import qualified OpenTheory.Natural as Natural
+import qualified OpenTheory.Primitive.Natural as Primitive.Natural
+
+singleton :: Bool -> Primitive.Natural.Natural
+singleton b = if b then 1 else 0
+
+cons :: Bool -> Primitive.Natural.Natural -> Primitive.Natural.Natural
+cons h t = singleton h + 2 * t
+
+append :: [Bool] -> Primitive.Natural.Natural -> Primitive.Natural.Natural
+append l n = foldr cons n l
+
+headBits :: Primitive.Natural.Natural -> Bool
+headBits n = Natural.naturalOdd n
+
+shiftRight ::
+  Primitive.Natural.Natural -> Primitive.Natural.Natural ->
+    Primitive.Natural.Natural
+shiftRight n k = n `div` 2 ^ k
+
+bit :: Primitive.Natural.Natural -> Primitive.Natural.Natural -> Bool
+bit n i = headBits (shiftRight n i)
+
+bound ::
+  Primitive.Natural.Natural -> Primitive.Natural.Natural ->
+    Primitive.Natural.Natural
+bound n k = n `mod` 2 ^ k
+
+fromList :: [Bool] -> Primitive.Natural.Natural
+fromList l = append l 0
+
+shiftLeft ::
+  Primitive.Natural.Natural -> Primitive.Natural.Natural ->
+    Primitive.Natural.Natural
+shiftLeft n k = 2 ^ k * n
+
+tailBits :: Primitive.Natural.Natural -> Primitive.Natural.Natural
+tailBits n = n `div` 2
+
+toList :: Primitive.Natural.Natural -> [Bool]
+toList n = if n == 0 then [] else headBits n : toList (tailBits n)
+
+toVector ::
+  Primitive.Natural.Natural -> Primitive.Natural.Natural -> [Bool]
+toVector n k =
+  if k == 0 then [] else headBits n : toVector (tailBits n) (k - 1)
+
+width :: Primitive.Natural.Natural -> Primitive.Natural.Natural
+width n = if n == 0 then 0 else width (tailBits n) + 1
diff --git a/src/OpenTheory/Natural/Uniform.hs b/src/OpenTheory/Natural/Uniform.hs
new file mode 100644
--- /dev/null
+++ b/src/OpenTheory/Natural/Uniform.hs
@@ -0,0 +1,28 @@
+{- |
+module: $Header$
+description: Natural number to bit-list conversions
+license: MIT
+
+maintainer: Joe Leslie-Hurd <joe@gilith.com>
+stability: provisional
+portability: portable
+-}
+
+module OpenTheory.Natural.Uniform
+where
+
+import qualified OpenTheory.Natural.Bits as Bits
+import qualified OpenTheory.Primitive.Natural as Natural
+import qualified OpenTheory.Primitive.Random as Primitive.Random
+import qualified OpenTheory.Random as Random
+
+random :: Natural.Natural -> Primitive.Random.Random -> Natural.Natural
+random n =
+  \r -> let w = Bits.width (n - 1) in loop w r
+  where
+  {-loop :: Natural.Natural -> Primitive.Random.Random -> Natural.Natural-}
+    loop w r =
+      let (r1, r2) = Primitive.Random.split r in
+      let l = Random.bits w r1 in
+      let m = Bits.fromList l in
+      if m < n then m else loop w r2
