https://github.com/arsalan0c/pflp-ml
Probabilistic functional logic language embedded in OCaml
https://github.com/arsalan0c/pflp-ml
functional-logic kanren probabilistic-programming
Last synced: 2 months ago
JSON representation
Probabilistic functional logic language embedded in OCaml
- Host: GitHub
- URL: https://github.com/arsalan0c/pflp-ml
- Owner: arsalan0c
- Created: 2021-05-21T10:16:33.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-02T11:17:51.000Z (almost 4 years ago)
- Last Synced: 2025-02-06T04:12:55.148Z (4 months ago)
- Topics: functional-logic, kanren, probabilistic-programming
- Language: OCaml
- Homepage:
- Size: 41 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://github.com/arsalanc-v2/pflp-ml/actions/workflows/ci.yml)
# pflp-ml
An embedded DSL for probabilistic programming in OCaml, based on
1. [PFLP](https://arxiv.org/pdf/1905.07212.pdf) by Dylus, Christiansen and Teegen
2. [kanren](https://github.com/arsalanc-v2/kanren)## Installation
You will need `opam`, `OCaml` and `dune` .The code can be obtained with:
```
git clone --recursive https://github.com/arsalanc-v2/pflp-ml.git
```## Tests
The tests (examples) in `./examples` can be run with:
```
cd pflp-ml
dune runtest
```
## Interface
```OCaml
exception PflpFailure of Base.string
val failwith : Base.string -> 'atype probability = Base.float
val prob : Base.float -> Mk.Micro.termval dist :
Mk.Micro.term ->
Base.float ->
Mk.Micro.substitution * Mk.Micro.var -> Mk.Micro.state Mk.Micro.streamval dist_to_probability : Mk.Micro.term -> Base.float
val dist_to_event : Mk.Micro.term -> Mk.Micro.term
val certainly :
Mk.Micro.term ->
Mk.Micro.substitution * Mk.Micro.var -> Mk.Micro.state Mk.Micro.streamval ( $ ) :
('a -> 'b Mk.Micro.stream) ->
('a -> 'b Mk.Micro.stream) -> 'a -> 'b Mk.Micro.streamval member :
(Mk.Micro.state -> 'a Mk.Micro.stream) Base.List.t ->
Mk.Micro.state -> 'a Mk.Micro.streamval enum :
Mk.Micro.term Base.List.t ->
Base.float Base.List.t -> Mk.Micro.state -> Mk.Micro.state Mk.Micro.streamval uniform :
Mk.Micro.term Base.List.t ->
Mk.Micro.state -> Mk.Micro.state Mk.Micro.streamval ( >>>= ) :
('a -> (('b, Mk.Micro.term, 'c) Base.Map.t * 'd) Mk.Micro.stream) ->
(Mk.Micro.term -> Mk.Micro.state -> Mk.Micro.state Mk.Micro.stream) ->
'a -> Mk.Micro.state Mk.Micro.streamval join_with :
(Mk.Micro.term -> Mk.Micro.term -> Mk.Micro.term) ->
('a -> (('b, Mk.Micro.term, 'c) Base.Map.t * 'd) Mk.Micro.stream) ->
(Mk.Micro.state ->
(('e, Mk.Micro.term, 'f) Base.Map.t * 'g) Mk.Micro.stream) ->
'a -> Mk.Micro.state Mk.Micro.streamval filter_dist :
(Mk.Micro.term -> bool) ->
('a -> (('b, Mk.Micro.term, 'c) Base.Map.t * 'd) Mk.Micro.stream) ->
'a -> Mk.Micro.state Mk.Micro.streamval ( $$ ) :
(Mk.Micro.term -> bool) ->
('a -> (('b, Mk.Micro.term, 'c) Base.Map.t * 'd) Mk.Micro.stream) ->
'a -> Base__Float.t
```## References
- [pflp reference implementation](https://github.com/finnteegen/pflp/)