{"id":50771074,"url":"https://github.com/splch/lean4ufpl","last_synced_at":"2026-06-11T18:31:27.301Z","repository":{"id":324834714,"uuid":"1098710595","full_name":"splch/lean4ufpl","owner":"splch","description":"A Lean 4 library and demo for a typed, multi-modal logic for philosophy","archived":false,"fork":false,"pushed_at":"2025-11-18T04:48:13.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-02T10:24:27.075Z","etag":null,"topics":["lean4","philosophy"],"latest_commit_sha":null,"homepage":"","language":"Lean","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/splch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-18T03:33:16.000Z","updated_at":"2025-11-18T04:47:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/splch/lean4ufpl","commit_stats":null,"previous_names":["splch/lean4ufpl"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/splch/lean4ufpl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splch%2Flean4ufpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splch%2Flean4ufpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splch%2Flean4ufpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splch%2Flean4ufpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/splch","download_url":"https://codeload.github.com/splch/lean4ufpl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splch%2Flean4ufpl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34213180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["lean4","philosophy"],"created_at":"2026-06-11T18:31:27.211Z","updated_at":"2026-06-11T18:31:27.296Z","avatar_url":"https://github.com/splch.png","language":"Lean","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UFPL - Unified Formal Philosophy Language (Lean 4)\n\nUFPL is a **typed, multi‑modal logic** embedded in Lean 4. It gives you:\n- multi‑sorted **terms** and **formulas** (individuals, agents, actions, worlds, time),\n- **modalities** (alethic `□/◇`, epistemic `K/B`, deontic `Obl`, temporal `G/F/H/P`),\n- a standard **Kripke/relational semantics** (`sat` over `Prop`),\n- and a finite, executable **Boolean semantics** (`satB`) for quick model checks.\n\nThis repository includes two illustrative examples:\n1. **Necessity of Identity** (Kripke): a short proof that `a = b → □(a = b)` for rigid names.\n2. **Trolley**: a small deontic model with outcome worlds and a Boolean evaluator.\n\n## Quick start\n\n**Requirements**\n- Lean 4 toolchain (pinned): `leanprover/lean4:v4.25.0`\n- Lake build tool (comes with the Lean toolchain)\n\n```bash\n# Build the library and the demo executable\nlake build\n\n# Run the demo\nlake exe ufpl\n```\n\n**Expected output (shape)**\n\n```\nUFPL demo:\n  Facts□@w0 (Bool):          true\n  LesserEvil@w0 (Bool):      true\n  ObligationToDivert (Bool): true\n  Necessity of identity theorem compiled (see Examples/NecIdentity.lean).\n```\n\n\u003e The first three lines come from the Trolley example (Boolean semantics).\n\u003e The last line indicates the Necessity‑of‑Identity proof compiled successfully.\n\n## Repository layout\n\n```\n.\n├── lakefile.toml          # Lake (TOML) project file\n├── lake-manifest.json     # Lake dependency lockfile (generated)\n├── lean-toolchain         # Toolchain pin (Lean 4 version)\n├── Main.lean              # Executable entry point (prints example results)\n├── README.md\n├── UFPL.lean              # Library root (re-exports core)\n└── UFPL\n   ├── Core\n   │  ├── Types.lean       # Sorts, symbol signatures, hetero lists (HList)\n   │  ├── Syntax.lean      # Terms and Form (with modalities)\n   │  ├── Semantics.lean   # Kripke/temporal/deontic semantics: `sat` / `validIn`\n   │  └── EvalBool.lean    # Finite Boolean semantics: `EvalSupport`, `satB`\n   └── Examples\n      ├── NecIdentity.lean # a=b → □(a=b) with rigid constants\n      └── Trolley.lean     # deontic example + finite Bool evaluator\n```\n\n### Lake configuration (excerpt)\n\n`lakefile.toml`:\n\n```toml\nname = \"ufpl\"\nversion = \"0.1.0\"\ndefaultTargets = [\"ufpl\", \"UFPL\"]\n\n[[lean_lib]]\nname = \"UFPL\"\n\n[[lean_exe]]\nname = \"ufpl\"\nroot = \"Main\"\n```\n\nToolchain pin (Lean):\n\n```\nleanprover/lean4:v4.25.0\n```\n\n## What’s in the core\n\n### Types \u0026 symbols\n\n* **Sorts** (`Ty`): `ind` (individuals), `agt` (agents), `act` (actions/events), `wld` (object‑language worlds if needed), `tim` (times).\n* **Symbols**: `ConstSym`, `FuncSym`, `PredSym`, grouped in a `Signature`.\n* **HList**: typed, heterogeneous lists for symbol arguments.\n\n### Syntax\n\n* **Terms**: variables, constants, function application.\n* **Formulas**: propositional connectives, equality, quantifiers, and modalities:\n\n  * `box / dia`  → `□/◇`\n  * `knows / believes`  → `K_a/B_a`\n  * `obl`  → `Obl`, with derived `perm`, `forb`\n  * `G/F/H/P`  → temporal “always/eventually” (future/past)\n* Scoped notations:\n\n  ```lean\n  scoped notation \"□\" φ =\u003e UFPL.Core.Form.box φ\n  scoped notation \"◇\" φ =\u003e UFPL.Core.Form.dia φ\n  ```\n\n### Semantics\n\n* **Prop semantics (`sat`)**: `sat M w t ρ φ : Prop` with a model `M`\n\n  * Model fields: domains per sort, worlds `W`, times `T` with `le`, alethic `Rbox`,\n    epistemic/doxastic `RK/RB`, and deontic `ideal`.\n  * Interprets predicates as `W → T → args → Prop`.\n\n* **Boolean semantics (`satB`)** (finite execution):\n\n  * `EvalSupport` provides finite `worlds`, `times`, and per‑sort domains, plus Boolean adapters for `Rbox`, `ideal`, `RK`, `RB`, `le`, and atomic predicates.\n  * `satB` mirrors `sat` but returns `Bool`, enabling quick `lake exe` runs.\n\n\u003e Use `sat` for proofs and meta‑theory; use `satB` for quick checks on finite frames.\n\n## The examples\n\n### 1) Necessity of Identity (UFPL/Examples/NecIdentity.lean)\n\n* Constants `H` and `P` for Hesperus/Phosphorus.\n* UFPL formula: `H = P → □(H = P)`.\n* Lean theorem:\n\n  ```lean\n  theorem necIdentity_HP_valid {Sig : Signature} (M : Model Sig) :\n    validIn M NecId_HP := by\n    intro w t ρ h\n    intro w' _R\n    simpa [sat, NecId_HP] using h\n  ```\n\n  Because constants are interpreted rigidly in the core semantics, equality is world‑independent.\n\n### 2) Trolley (UFPL/Examples/Trolley.lean)\n\n* Three worlds: decision `w0`, outcomes `wD` (divert), `wN` (no divert).\n* Outcome facts (e.g., `Divert → Kill1 ∧ ¬Kill5`) and a “lesser evil” obligation (avoid 5 deaths).\n* Boolean support `E` enumerates the **finite** worlds/times and provides Boolean adapters.\n* `Main.lean` prints:\n\n  * `□facts @ w0` (the outcome laws as seen from the decision world),\n  * `lesserEvil @ w0`,\n  * and the resulting **obligation to divert**.\n\n## How to extend\n\n1. **Add symbols** to your `Signature` (predicates, functions, constants).\n2. **Choose domains** per sort and define a **model**:\n\n   * temporal order `le`, relations `Rbox/RK/RB/ideal`, and an interpreter for atomics.\n3. **(Optional) Add `EvalSupport`** for finite `satB` runs:\n\n   * enumerate `worlds`, `times`, and each sort’s finite domain,\n   * provide Boolean versions of your relations and atomic predicate.\n4. **Write formulas** using `Form` (or add macros/notation if you prefer).\n5. **Evaluate** with `sat` (Prop) or `satB` (Bool), or **prove** with Lean.\n\n## Design notes \u0026 limitations\n\n* **Typed by construction**: UFPL’s sorts prevent category mistakes (e.g., you can’t apply a person‑predicate to an action).\n* **Modalities are parametric in the frame**: pick frame conditions (T/S4/S5, D for deontic, etc.) by restricting your relations; UFPL’s core leaves this open.\n* **Boolean semantics** (`satB`) is an **executable** approximation that requires finite supports; quantifiers range over the listed elements.\n* This repo focuses on **semantics and examples**. A full **proof system** (ND/sequent) and macros for a surface language are natural next steps.\n\n## Development\n\n* Build library \u0026 examples: `lake build`\n* Run demo: `lake exe ufpl`\n* Toolchain pin: `leanprover/lean4:v4.25.0` (see `lean-toolchain`)\n* Consider adding a `.gitignore` with:\n\n  ```\n  .lake/\n  lake-packages/\n  build/\n  ```\n\n## Acknowledgments / License\n\n* Logic design inspired by standard modal/temporal/deontic/epistemic frameworks.\n* License: MIT \n\n*Questions or ideas?* Open an issue or start a discussion in your fork.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplch%2Flean4ufpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsplch%2Flean4ufpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplch%2Flean4ufpl/lists"}