{"id":19437753,"url":"https://github.com/wenkokke/schmitty","last_synced_at":"2026-01-27T01:32:42.162Z","repository":{"id":39750335,"uuid":"288259623","full_name":"wenkokke/schmitty","owner":"wenkokke","description":"Agda bindings to SMT-LIB2 compatible solvers.","archived":false,"fork":false,"pushed_at":"2024-10-07T18:24:24.000Z","size":10267,"stargazers_count":96,"open_issues_count":4,"forks_count":8,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-02-25T07:15:28.228Z","etag":null,"topics":["agda","smt-solver"],"latest_commit_sha":null,"homepage":"","language":"Agda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wenkokke.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}},"created_at":"2020-08-17T18:44:13.000Z","updated_at":"2025-02-19T06:13:12.000Z","dependencies_parsed_at":"2023-01-31T01:31:07.205Z","dependency_job_id":"0914a671-9dbc-4e22-945f-ec3d84b3278d","html_url":"https://github.com/wenkokke/schmitty","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/wenkokke/schmitty","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkokke%2Fschmitty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkokke%2Fschmitty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkokke%2Fschmitty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkokke%2Fschmitty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenkokke","download_url":"https://codeload.github.com/wenkokke/schmitty/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkokke%2Fschmitty/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28795468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T01:07:07.743Z","status":"ssl_error","status_checked_at":"2026-01-27T01:07:06.974Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["agda","smt-solver"],"created_at":"2024-11-10T15:15:47.061Z","updated_at":"2026-01-27T01:32:42.145Z","avatar_url":"https://github.com/wenkokke.png","language":"Agda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Schmitty the Solver\n```agda\n{-# OPTIONS --allow-exec #-}\n{-# OPTIONS --guardedness #-}\n\nopen import Data.Integer\nopen import Data.List\nopen import Data.Product\nopen import Function\nopen import Relation.Binary.PropositionalEquality\nopen import SMT.Theories.Ints as Ints\nopen import SMT.Backend.Z3 Ints.theory\n```\nIf you wanna solve some problems, you’re in luck! Schmitty is an Agda library which gives you bindings to SMT solvers! I know, cool right?!\n```agda\nverycool : ∀ (x y : ℤ) → x ≤ y → y ≤ x → x ≡ y\nverycool = solveZ3\n```\nSo, basically, what Schmitty offers you is a well-typed embedding of *some* of the SMT-LIB language in Agda. That means you can't *just* shout “solve” at your problems, you can also write SMT queries yourself!\n```agda\nblegh : Script [] (INT ∷ INT ∷ []) (SAT ∷ [])\nblegh = `declare-const \"x\" INT\n      $ `declare-const \"y\" INT\n      $ `assert (`app₂ leq (# 0) (# 1))\n      $ `assert (`app₂ leq (# 1) (# 0))\n      $ `assert (`app₁ not (`app₂ eq (# 0) (# 1)))\n      $ `check-sat\n      $ []\n```\nOhh, that's *almost* the script that our call to `solveZ3` above generates! What a lucky coincidence! You see, top-level constants are existentially quantified, so that script asks Z3 to see if `∃[ x ] ∃[ y ] (x ≤ y → y ≤ x → x ≢ y)` is satisfiable… and if it is, then, well, there *must* be a counter-example to our original goal!\n```agda\n_ : z3 blegh ≡ unsat ∷ []\n_ = refl\n```\nLucky us! It's *very* unsatisfiable… Wait, how did that work?! Did you just *call Z3 while type checking?!* Yes, dear reader, I did. You might’ve seen that I recently extended Agda with the `execTC` primitive, which allows you to make arbitrary system calls during type checking… well, within reason at least. Schmitty lets you take the script above, print it as an SMT-LIB term, and pass it to Z3!\n\nDid you pick up on that `unsat` there? Schmitty doesn’t just give you back the solver’s output… she’s kind enough to actually parse the output for you! In fact, when Schmitty prints the term, she also builds you an output parser, which parses the expected solver output, including models! Let’s make sure our next query is satisfiable!\n```agda\nyesss : Script [] (INT ∷ INT ∷ []) (MODEL (INT ∷ INT ∷ []) ∷ [])\nyesss = `declare-const \"x\" INT\n      $ `declare-const \"y\" INT\n      $ `assert (`app₂ leq (`app₂ sub (# 0) (# 1)) (`app₂ add (# 0) (# 1)))\n      $ `assert (`app₁ not (`app₂ eq (# 0) (# 1)))\n      $ `get-model\n      $ []\n```\nIf we call `get-model` instead of `check-sat`, Schmitty will give us back a valid model!\n```agda\n_ : z3 yesss ≡ ((sat , + 1 ∷ + 0 ∷ []) ∷ [])\n_ = refl\n```\nOkay, I know that wasn’t a particularly hard problem, but I was in a rush. Send me a pull-request if you’ve got more interesting questions for Schmitty!\n\nWait, we can get models? Cool! We could use that to get counter-examples, if you try to prove something that *isn't* true! We, uh… We do:\n```agda\nwoops : ∀ (x y : ℤ) → x - y ≤ x + y → x ≡ y\nwoops = solveZ3\n\n-- \u003e Found counter-example:\n--     x = + 1\n--     y = + 0\n--   refuting (z : + 1 ≤ + 1) → + 1 ≡ + 0\n--   when checking that the expression unquote solveZ3 has type\n--   (x y : ℤ) → x - y ≤ x + y → x ≡ y\n```\n\nRight now, Schmitty supports three theories—[Core][SMT.Theories.Core], [Ints][SMT.Theories.Ints], and [Reals][SMT.Theories.Reals]—and two backends—[Z3][SMT.Backend.Z3], and [CVC4][SMT.Backend.CVC4]. If you’re missing your favourite theory or solver, your contribution is more than welcome!\n\n# Installation\n\n- [agda][agda] (\u003e= [v2.6.2][agda-version])\n- [agda-stdlib][agda-stdlib] (\u003e= [v1.7][agda-stdlib-version])\n- [agdarsec][agdarsec] ([v0.5.0][agdarsec-version])\n\nNote that the path to `z3` must be added to the list of trusted executables in Agda. See  [manual.](https://agda.readthedocs.io/en/latest/language/reflection.html?highlight=trusted#system-calls)\n# Roadmap\n\n- [ ] Issue: move theorems proved via SMT solvers into Prop or the Classical monad (moderate);\n- [ ] Issue: only normalise closed subterms in error messages (moderate);\n- [ ] Add error reporting to the parser (easy);\n- [ ] Add backends for other SMT-LIB compliant solvers:\n      ([verit](https://verit.loria.fr/),\n       [bitwuzla](https://bitwuzla.github.io/),\n       [yices2](https://yices.csl.sri.com/),\n       *etc*)\n- [ ] Add theory of real arithmetic linked to Agda rational numbers (easy);\n- [ ] Add theory of floating-point numbers linked to Agda floats (easy);\n- [ ] Add theory of strings linked to Agda strings (easy);\n- [ ] Add theory of sequences linked to Agda lists (moderate);\n- [ ] Add theory of uninterpreted functions and constants linked to Agda names (moderate);\n- [ ] Add theory of regular expressions linked to [gallais/aGdaREP][aGdaREP] (moderate);\n- [ ] Add theory of algebraic datatypes linked to Agda datatypes (moderate);\n- [ ] Add theory of arrays linked to an axiomatisation of Haskell arrays (moderate);\n- [ ] Add support for [combined theories][CombinedTheories] (moderate);\n- [ ] Add support for [logic declarations][LogicDeclarations] (moderate);\n- [ ] Add proof reconstruction for SAT using [`Kanso.Boolean.SatSolver`][SatSolver] (moderate);\n- [ ] Add proof reconstruction for [Z3 proofs][Z3Proofs] (cf. [*Proof Reconstruction for Z3 in Isabelle/HOL*][IsabelleHol]) (hard).\n\n[Data.Float]: https://agda.github.io/agda-stdlib/Data.Float.html\n[Data.Rational]: https://agda.github.io/agda-stdlib/Data.Rational.html\n[SMT.Theory]: https://wenkokke.github.io/schmitty/SMT.Theory.html\n[SMT.Theories.Core]: https://wenkokke.github.io/schmitty/SMT.Theories.Core.html\n[SMT.Theories.Core.Extensions]: https://wenkokke.github.io/schmitty/SMT.Theories.Core.Extensions.html\n[SMT.Theories.Ints]: https://wenkokke.github.io/schmitty/SMT.Theories.Ints.html\n[SMT.Theories.Reals]: https://wenkokke.github.io/schmitty/SMT.Theories.Reals.html\n[SMT.Theories.Raw.Reflection]: https://wenkokke.github.io/schmitty/SMT.Theories.Raw.Reflection.html\n[SMT.Script]: https://wenkokke.github.io/schmitty/SMT.Script.html\n[SMT.Logics]: https://wenkokke.github.io/schmitty/SMT.Logics.html\n[SMT.Backend.Z3]: https://wenkokke.github.io/schmitty/SMT.Backend.Z3.html\n[SMT.Backend.CVC4]: https://wenkokke.github.io/schmitty/SMT.Backend.CVC4.html\n[Text.Parser.String]: https://wenkokke.github.io/schmitty/Text.Parser.String.html\n[gallais]: https://github.com/gallais\n[kazkansouh]: https://github.com/kazkansouh\n[satsolver]: https://github.com/wenkokke/schmitty/tree/master/extra/Kanso\n[agda]: https://github.com/agda/agda\n[agda-version]: https://github.com/agda/agda/releases/tag/v2.6.2\n[agda-stdlib]: https://github.com/agda/agda-stdlib\n[agda-stdlib-version]: https://github.com/agda/agda-stdlib/releases/tag/v1.7\n[agdarsec]: https://github.com/gallais/agdarsec\n[agdarsec-version]: https://github.com/gallais/agdarsec/releases/tag/v0.5.0\n[FloatingPoint]: http://www.philipp.ruemmer.org/publications/smt-fpa.pdf\n[IsabelleHol]: http://www21.in.tum.de/~boehmes/proofrec.pdf\n[SatSolver]: https://github.com/wenkokke/schmitty/blob/master/extra/Kanso/Boolean/SatSolver.agda\n[CombinedTheories]: http://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2017-07-18.pdf#subsection.5.4.1\n[LogicDeclarations]: http://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2017-07-18.pdf#subsection.5.5.1\n[Z3Proofs]: http://ceur-ws.org/Vol-418/paper10.pdf\n[aGdaREP]: https://github.com/gallais/aGdaREP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenkokke%2Fschmitty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenkokke%2Fschmitty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenkokke%2Fschmitty/lists"}