{"id":15061147,"url":"https://github.com/cosmicboots/ipcf","last_synced_at":"2026-01-02T12:35:26.820Z","repository":{"id":236352681,"uuid":"761472526","full_name":"cosmicboots/iPCF","owner":"cosmicboots","description":"Intensional PCF interpreter","archived":false,"fork":false,"pushed_at":"2024-06-05T17:12:12.000Z","size":146,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T09:13:40.217Z","etag":null,"topics":["intensonality","interpreter","lambda-calculus","ocaml"],"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/cosmicboots.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-02-21T22:28:36.000Z","updated_at":"2024-05-14T20:42:16.000Z","dependencies_parsed_at":"2024-05-15T13:51:56.940Z","dependency_job_id":"1b633451-e011-4fc4-bb8e-a59ee3b9c78b","html_url":"https://github.com/cosmicboots/iPCF","commit_stats":null,"previous_names":["cosmicboots/ipcf"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmicboots%2FiPCF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmicboots%2FiPCF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmicboots%2FiPCF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmicboots%2FiPCF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cosmicboots","download_url":"https://codeload.github.com/cosmicboots/iPCF/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243707382,"owners_count":20334619,"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":["intensonality","interpreter","lambda-calculus","ocaml"],"created_at":"2024-09-24T23:09:50.724Z","updated_at":"2026-01-02T12:35:26.754Z","avatar_url":"https://github.com/cosmicboots.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iPCF\n\nIntensional Programming Computable Functions (iPCF) extends the PCF lambda\ncalculus language by adding intentionality, and was introduced in a [paper by\nG. A. Kavvos](https://seis.bristol.ac.uk/~tz20861/papers/ipcf.pdf).\n\nThis project aims to implement an interpreter for iPCF in OCaml.\n\n## Building the Project\n\nThis project is written in OCaml, and thus it's recommended to use the\n[Dune](https://dune.build/) build system to build the project.\n\nAssuming you have the OCaml tool chain (including Dune and\n[opam](https://opam.ocaml.org/)) installed, you can setup an environment and\ninstall all the project dependencies with the following:\n\n```shell\nopam switch create .\n```\n\nAt this point you should have a local switch (OCaml's term for environment)\nsetup in the `./_opam` directory.\n\nYou can then build the project with:\n\n```shell\ndune build\n```\n\nWhich will output the `ipcf` binary at `./_build/install/default/bin/ipcf`.\n\nUnit tests can be run with `dune test`, and running the binary directly can be\ndone with `dune exec ipcf`.\n\n## The Interpreter\n\nStarting the interpreter is as simple as calling the `ipcf` binary:\n```\n❯ ./ipcf\n\n=========================\nWelcome to the iPCF REPL!\n=========================\n\nYou can exit the REPL with either [exit] or [CTRL+D]\n\niPCF\u003e\n```\n\n### Storing Expressions\n\nExpressions can be saved in the REPL by assigning them to a variable using the\nwalrus operator (`:=`):\n```\niPCF\u003e kcomb := \\x .\\y . x\nkcomb : 'a -\u003e 'b -\u003e 'a\n```\n\nThese expressions can then be reused in later expressions:\n```\niPCF\u003e kcomb true false\ntrue : 'a\n```\n\n### Built-in REPL Commands\n\nThe interpreter supports a few special commands, which are all prefixed with a\ncolon:\n\n- `:quit`: Exits the REPL\n- `:ctx`: Prints all the expressions that are stored in the REPL  \n  _The interpreter also supports case-insensitive tab completion for items in the context!_\n- `:load \u003cfile\u003e` or `:l \u003cfile\u003e`: Loads a file with iPCF expressions and evaluates them\n\n## Language Syntax\n\n### Primitive Types\n\nThe language supports natural numbers and booleans as primitive data types.\n\n**Booleans**:\n```\niPCF\u003e true\ntrue : Bool\niPCF\u003e false\nfalse : Bool\n```\n\n**Natural Numbers** are encoded using the [Church\nEncoding](https://en.wikipedia.org/wiki/Church_encoding#Church_numerals):\n```\niPCF\u003e zero\n0 : Nat\niPCF\u003e succ zero\n1 : Nat\niPCF\u003e succ succ zero\n2 : Nat\n```\n\nThe interpreter also supports the `pred` and \"is zero\" (`?`)\nfunctions:\n```\niPCF\u003e pred zero\npred 0 : Nat\niPCF\u003e pred succ zero\n0 : Nat\niPCF\u003e pred succ succ zero\n1 : Nat\niPCF\u003e zero?\ntrue : Bool\niPCF\u003e (succ zero)?\nfalse : Bool\n```\n\nConstant numerals can also be used and will internally expanded to the Church\nEncoding:\n```\niPCF\u003e 0\n0 : Nat\niPCF\u003e 1\n1 : Nat\niPCF\u003e 42\n42 : Nat\n```\n\n### Control Flow\n\nIf-then-else expressions are supported with the following syntax:\n```\nif \u003ccondition\u003e then \u003ctrue-branch\u003e else \u003cfalse-branch\u003e\n```\n\nFor example:\n```\niPCF\u003e if true then succ 0 else 0\n1 : Nat\n```\n\n### Abstraction and Application\n\nLambda abstractions are supported with the following syntax:\n```\n\\ \u003cvariable\u003e . \u003cbody\u003e\n```\n\nFor example, the I combinator (identity function) would be written as:\n```\niPCF\u003e \\x . x\n(fun) : 'a -\u003e 'a\n```\n\nAnd the K combinator as:\n```\niPCF\u003e \\x . \\y . x\n(fun) : 'a -\u003e 'b -\u003e 'a\n```\n\n### Intensional Syntax\n\n\nThere are 3 main pieces of syntax that are added to the language to support\nintensionality:\n\n1. The box constructor: `box \u003cexpr\u003e`\n2. The box eliminator (unbox): `let box \u003cvar\u003e \u003c- \u003cexpr\u003e in \u003cbody\u003e`  \n   This unboxes the term `\u003cexpr\u003e` and binds it to `\u003cvar\u003e` in `\u003cbody\u003e`.\n3. The intensional fixed point combinator: `fix \u003cvar\u003e in \u003cbody\u003e`  \n\n\n## Intensional Operations\n\nThere are currently a hand full of built in intensional operations:\n\n- `isApp : Box ('a) -\u003e Box (Bool)`: Checks if the boxed term is an application\n- `isAbs : Box ('a) -\u003e Box (Bool)`: Checks if the boxed term is an abstraction\n- `numberOfVars : Box ('a) -\u003e Box (Nat)`: Counts the number of variables used in the boxed term\n- `isNormalForm : Box ('a) -\u003e Box (Bool)`: Checks if the boxed term is in normal form\n- `tick : Box ('b) -\u003e Box ('a)`: Reduces the boxed term by a single reduction step\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmicboots%2Fipcf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosmicboots%2Fipcf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmicboots%2Fipcf/lists"}