{"id":15061115,"url":"https://github.com/zeta611/stappl","last_synced_at":"2025-07-29T03:02:15.581Z","repository":{"id":242461120,"uuid":"789999879","full_name":"Zeta611/stappl","owner":"Zeta611","description":"🎲 Statically typed probabilistic programming language, feat. GADT","archived":false,"fork":false,"pushed_at":"2024-06-13T03:06:33.000Z","size":855,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T07:40:57.265Z","etag":null,"topics":["gadt","generalized-algebraic-data-type","ocaml","probabilistic-graphical-models","probabilistic-programming","type-system"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zeta611.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-22T04:38:45.000Z","updated_at":"2024-07-14T17:07:05.000Z","dependencies_parsed_at":"2024-10-12T21:31:59.440Z","dependency_job_id":null,"html_url":"https://github.com/Zeta611/stappl","commit_stats":null,"previous_names":["zeta611/stappl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeta611%2Fstappl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeta611%2Fstappl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeta611%2Fstappl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeta611%2Fstappl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zeta611","download_url":"https://codeload.github.com/Zeta611/stappl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248170903,"owners_count":21059274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gadt","generalized-algebraic-data-type","ocaml","probabilistic-graphical-models","probabilistic-programming","type-system"],"created_at":"2024-09-24T23:09:34.419Z","updated_at":"2025-04-10T06:36:53.545Z","avatar_url":"https://github.com/Zeta611.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# STAPPL: STAtically typed Probabilistic Programming Language\n\nSTAPPL is a compiler for the STAtically typed Probabilistic Programming Language.\n\n## How to Use\n\nInstall the necessary OCaml packages:\n\n```sh\nopam install . --deps-only\n```\n\nYou can run the program using the following command:\n\n```sh\ndune exec -- stappl \u003cprogram.stp\u003e\n```\n\nThis will parse and compile the program, perform inference, and save the distribution plot of the final query variable as a PNG image file.\n\nYou will also need a working Python environment with [`numpy`](https://numpy.org/) and [`seaborn`](https://seaborn.pydata.org/) (and their dependencies), as `seaborn` is used to create the plot.\nIt is recommend to create a Python virtual environment (optional), and then install `numpy` and `seaborn` inside the environment using pip:\n\n```sh\npip install -U numpy seabron\n```\n\n## Example\n\nHere's an example program and its components:\n\n### Input Program\n\n```ocaml\n# student.stp\nfun determine_grade(difficult, smart) {\n  if difficult \u0026 smart then 0.8\n    else if difficult \u0026 !smart then 0.3\n    else if !difficult \u0026 smart then 0.95\n    else 0.5\n}\n\nlet difficult = sample(bernoulli(0.4)) in\nlet smart = sample(bernoulli(0.3)) in\nlet grade = bernoulli(determine_grade(difficult, smart)) in\nlet sat = bernoulli(\n  if smart then 0.94 +. 0.01  # partial evaluate to 0.95\n    else 0.2\n) in\nobserve(grade, false);\nobserve(sat, true);\nsmart\n```\n\n#### Pretty Print (-pp)\n\n```scheme\n((funs\n  (((name determine_grade) (params (difficult smart))\n    (body\n     (If (And (Var difficult) (Var smart)) (Real 0.8)\n      (If (And (Var difficult) (Not (Var smart))) (Real 0.3)\n       (If (And (Not (Var difficult)) (Var smart)) (Real 0.95) (Real 0.5))))))))\n (exp\n  (Assign difficult (Sample (Call bernoulli ((Real 0.4))))\n   (Assign smart (Sample (Call bernoulli ((Real 0.3))))\n    (Assign grade\n     (Call bernoulli ((Call determine_grade ((Var difficult) (Var smart)))))\n     (Assign sat\n      (Call bernoulli\n       ((If (Var smart) (Radd (Real 0.94) (Real 0.01)) (Real 0.2))))\n      (Seq (Observe (Var grade) (Bool false))\n       (Seq (Observe (Var sat) (Bool true)) (Var smart)))))))))\n```\n\n#### Graph Mode (-graph)\n\n```scheme\n((vertices (X1 X2 X3 X4)) (arcs ((X1 X3) (X2 X3) (X2 X4)))\n (pmdf_map\n  ((X1 (Call bernoulli ((Value 0.4)))) (X2 (Call bernoulli ((Value 0.3))))\n   (X3\n    (If (Value true)\n     (Call bernoulli\n      ((If (Bop \u0026\u0026 (Value true) (Bop \u0026\u0026 (Var X1) (Var X2))) (Value 0.8)\n        (If\n         (Bop \u0026\u0026 (Bop \u0026\u0026 (Value true) (Uop not (Bop \u0026\u0026 (Var X1) (Var X2))))\n          (Bop \u0026\u0026 (Var X1) (Uop ! (Var X2))))\n         (Value 0.3)\n         (If\n          (Bop \u0026\u0026\n           (Bop \u0026\u0026 (Bop \u0026\u0026 (Value true) (Uop not (Bop \u0026\u0026 (Var X1) (Var X2))))\n            (Uop not (Bop \u0026\u0026 (Var X1) (Uop ! (Var X2)))))\n           (Bop \u0026\u0026 (Uop ! (Var X1)) (Var X2)))\n          (Value 0.95) (Value 0.5))))))\n     (Value 1)))\n   (X4\n    (If (Value true)\n     (Call bernoulli\n      ((If (Bop \u0026\u0026 (Value true) (Var X2)) (Value 0.95) (Value 0.2))))\n     (Value 1)))))\n (obs_map ((X3 (Value false)) (X4 (Value true)))))\n```\n\n#### Inference Mode\n\n![student.png](./samples/student.png)\n\n## License\n\nSTAPPL is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeta611%2Fstappl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeta611%2Fstappl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeta611%2Fstappl/lists"}