All Projects → evhub → pyprover

evhub / pyprover

Licence: Apache-2.0 license
Resolution theorem proving for predicate logic in pure Python.

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to pyprover

awesome-rust-formalized-reasoning
An exhaustive list of all Rust resources regarding automated or semi-automated formalization efforts in any area, constructive mathematics, formal algorithms, and program verification.
Stars: ✭ 185 (+160.56%)
Mutual labels:  theorem-proving, prover, theorem-prover
LinearOne
LinearOne is a prototype theorem prover for first-order (multiplicative, intuitionistic) linear logic.
Stars: ✭ 16 (-77.46%)
Mutual labels:  theorem-proving, first-order-logic
ostrich
An SMT Solver for string constraints
Stars: ✭ 18 (-74.65%)
Mutual labels:  theorem-proving, theorem-prover
first order logic prover
No description or website provided.
Stars: ✭ 52 (-26.76%)
Mutual labels:  theorem-proving, first-order-logic
cicada
Cicada Language
Stars: ✭ 9 (-87.32%)
Mutual labels:  prover, theorem-prover
rusty-razor
Razor is a tool for constructing finite models for first-order theories
Stars: ✭ 54 (-23.94%)
Mutual labels:  theorem-proving
informatica-public
Public code developed during my MSc study at University of Bologna
Stars: ✭ 79 (+11.27%)
Mutual labels:  theorem-proving
TheoLog
Vorlesungsunterlagen "Theoretische Informatik und Logik", Fakultät Informatik, TU Dresden
Stars: ✭ 20 (-71.83%)
Mutual labels:  first-order-logic
gapt
GAPT: General Architecture for Proof Theory
Stars: ✭ 83 (+16.9%)
Mutual labels:  theorem-proving
Awesome-Neural-Logic
Awesome Neural Logic and Causality: MLN, NLRL, NLM, etc. 因果推断,神经逻辑,强人工智能逻辑推理前沿领域。
Stars: ✭ 106 (+49.3%)
Mutual labels:  first-order-logic
fm-notes
Unassorted scribbles on formal methods, type theory, category theory, and so on, and so on
Stars: ✭ 19 (-73.24%)
Mutual labels:  theorem-proving
Leo-III
An Automated Theorem Prover for Classical Higher-Order Logic with Henkin Semantics
Stars: ✭ 29 (-59.15%)
Mutual labels:  theorem-proving
gidti
Book: Gentle Introduction to Dependent Types with Idris
Stars: ✭ 70 (-1.41%)
Mutual labels:  theorem-proving
coq jupyter
Jupyter kernel for Coq
Stars: ✭ 70 (-1.41%)
Mutual labels:  theorem-proving
tarski
Tarski - An AI Planning Modeling Framework
Stars: ✭ 30 (-57.75%)
Mutual labels:  first-order-logic
Set-Theory
Coq encoding of ZFC and formalization of the textbook Elements of Set Theory
Stars: ✭ 55 (-22.54%)
Mutual labels:  theorem-proving
lsw2
OWL and Semantic Web toolkit for Common Lisp, used for construction and reasoning over ontologies and ontology-structured data
Stars: ✭ 22 (-69.01%)
Mutual labels:  first-order-logic
Lean
Homepage Theorem Proving in Lean FAQ
Stars: ✭ 2,006 (+2725.35%)
Mutual labels:  theorem-proving
Fstar
A Proof-oriented Programming Language
Stars: ✭ 2,171 (+2957.75%)
Mutual labels:  theorem-proving
Coq
Coq is a formal proof management system. It provides a formal language to write mathematical definitions, executable algorithms and theorems together with an environment for semi-interactive development of machine-checked proofs.
Stars: ✭ 3,566 (+4922.54%)
Mutual labels:  theorem-proving

PyProver

PyProver is a resolution theorem prover for first-order predicate logic. PyProver is written in Coconut which compiles to pure, universal Python, allowing PyProver to work on any Python version.

Installing PyProver is as simple as

pip install pyprover

Usage

To use PyProver from a Python interpreter, it is recommended to

from pyprover import *

which will populate the global namespace with capital letters as propositions/predicates, and lowercase letters as constants/variables/functions. When using PyProver from a Python file, however, it is recommended to only import what you need.

Formulas can be constructed using the built-in Python operators on propositions and terms combined with Exists (or EX), ForAll (or FA), Eq, top, and bot. For example:

A & B
A | ~B
~(A | B)
P >> Q
P >> (Q >> P)
(F & G) >> H
E >> top
bot >> E
FA(x, F(x))
TE(x, F(x) | G(x))
FA(x, F(f(x)) >> F(x))
Eq(a, b)

Alternatively, the expr(formula) function can be used, which parses a formula in standard mathematical notation. For example:

F ∧ G ∨ (C → ¬D)
F /\ G \/ (C -> ~D)
F & G | (C -> -D)
⊤ ∧ ⊥
top /\ bot
F -> G -> H
A x. F(x) /\ G(x)
∀x. F(x) /\ G(x)
E x. C(x) \/ D(x)
∃x. C(x) \/ D(x)
∀x. ∃y. G(f(x, y))
a = b
forall x: A, B(x)
exists x: A, B(x)

Note that expr requires propositions/predicates to start with a capital letter and constants/variables/functions to start with a lowercase letter.

Once a formula has been constructed, various functions are provided to work with them. Some of the most important of these are:

  • strict_simplify(expr) finds an equivalent, standardized version of the given expr,
  • simplify(expr) is the same as strict_simplify, but it implicitly assumes TE(x, top) (something exists),
  • strict_proves(givens, concl) determines if concl can be derived from givens, and
  • proves(givens, concl) is the same as strict_proves, but it implicitly assumes TE(x, top) (something exists).

To construct additional propositions/predicates, the function props("name1 name2 name3 ...") will return propositions/predicates for the given names, and to construct additional constants/variables/functions, the function terms("name1 name2 name3 ...") can be used similarly.

Examples

The backtick infix syntax here is from Coconut. If using Python instead simply adjust to standard function call syntax.

from pyprover import *

# constructive propositional logic
assert (E, E>>F, F>>G) `proves` G
assert (E>>F, F>>G) `proves` E>>G

# classical propositional logic
assert ~~E `proves` E
assert top `proves` (E>>F)|(F>>E)

# constructive predicate logic
assert R(j) `proves` TE(x, R(x))
assert (FA(x, R(x) >> S(x)), TE(y, R(y))) `proves` TE(z, S(z))

# classical predicate logic
assert ~FA(x, R(x)) `proves` TE(y, ~R(y))
assert top `proves` TE(x, D(x)) | FA(x, ~D(x))

# use of expr parser
assert expr(r"A x. E y. F(x) \/ G(y)") == FA(x, TE(y, F(x) | G(y)))
assert expr(r"a = b /\ b = c") == Eq(a, b) & Eq(b, c)

Compiling PyProver

If you want to compile PyProver yourself instead of installing it from PyPI with pip, you can

  1. clone the git repository,
  2. run make setup, and
  3. run make install.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].