• This repository has been archived on 17/Jan/2022
  • Stars
    star
    225
  • Rank 177,187 (Top 4 %)
  • Language
    Python
  • Created over 10 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An automated theorem prover for first-order logic.

An automated theorem prover for first-order logic. For any provable formula, this program is guaranteed to find the proof (eventually). However, as a consequence of the negative answer to Hilbert's Entscheidungsproblem, there are some unprovable formulae that will cause this program to loop forever.

Some notes:

  • The proof steps are shown as sequents.
  • The actual theorem prover is in prover.py. The command-line interface (including the parser) is in main.py. language.py contains boilerplate classes used to represent logical formulae.
  • The system will not accept a lemma unless it can be proven. An axiom is admitted without proof.
  • This is only a pedagogical tool. It is too slow to be used for anything practical.

To get started, run main.py:

$ ./main.py
First-Order Logic Theorem Prover
2014 Stephan Boyer

Terms:

  x               (variable)
  f(term, ...)    (function)

Formulae:

  P(term)        (predicate)
  not P          (complement)
  P or Q         (disjunction)
  P and Q        (conjunction)
  P implies Q    (implication)
  forall x. P    (universal quantification)
  exists x. P    (existential quantification)

Enter formulae at the prompt. The following commands are also available for manipulating axioms:

  axioms              (list axioms)
  lemmas              (list lemmas)
  axiom <formula>     (add an axiom)
  lemma <formula>     (prove and add a lemma)
  remove <formula>    (remove an axiom or lemma)
  reset               (remove all axioms and lemmas)

>

Example session:

> P or not P
0. ⊢ (P ∨ ¬P)
1. ⊢ P, ¬P
2. P ⊢ P
Formula proven: (P ∨ ¬P).

> P and not P
0. ⊢ (P ∧ ¬P)
1. ⊢ P
Formula unprovable: (P ∧ ¬P).

> forall x. P(x) implies (Q(x) implies P(x))
0. ⊢ (∀x. (P(x) → (Q(x) → P(x))))
1. ⊢ (P(v1) → (Q(v1) → P(v1)))
2. P(v1) ⊢ (Q(v1) → P(v1))
3. Q(v1), P(v1) ⊢ P(v1)
Formula proven: (∀x. (P(x) → (Q(x) → P(x)))).

> exists x. (P(x) implies forall y. P(y))
0. ⊢ (∃x. (P(x) → (∀y. P(y))))
1. ⊢ (P(t1) → (∀y. P(y))), (∃x. (P(x) → (∀y. P(y))))
2. P(t1) ⊢ (∀y. P(y)), (∃x. (P(x) → (∀y. P(y))))
3. P(t1) ⊢ (∀y. P(y)), (P(t2) → (∀y. P(y))), (∃x. (P(x) → (∀y. P(y))))
4. P(t1) ⊢ (P(t2) → (∀y. P(y))), (∃x. (P(x) → (∀y. P(y)))), P(v1)
5. P(t1), P(t2) ⊢ (∀y. P(y)), (∃x. (P(x) → (∀y. P(y)))), P(v1)
6. P(t1), P(t2) ⊢ (∀y. P(y)), (P(t3) → (∀y. P(y))), (∃x. (P(x) → (∀y. P(y)))), P(v1)
7. P(t1), P(t2) ⊢ (P(t3) → (∀y. P(y))), P(v2), (∃x. (P(x) → (∀y. P(y)))), P(v1)
8. P(t3), P(t1), P(t2) ⊢ (∀y. P(y)), P(v2), (∃x. (P(x) → (∀y. P(y)))), P(v1)
  t3 = v1
Formula proven: (∃x. (P(x) → (∀y. P(y)))).

> axiom forall x. Equals(x, x)
Axiom added: (∀x. Equals(x, x)).

> axioms
(∀x. Equals(x, x))

> lemma Equals(a, a)
0. (∀x. Equals(x, x)) ⊢ Equals(a, a)
1. Equals(t1, t1), (∀x. Equals(x, x)) ⊢ Equals(a, a)
  t1 = a
Lemma proven: Equals(a, a).

> lemmas
Equals(a, a)

> remove forall x. Equals(x, x)
Axiom removed: (∀x. Equals(x, x)).
This lemma was proven using that axiom and was also removed:
  Equals(a, a)

Copyright (C) 2014 Stephan Boyer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

toast

Containerize your development and continuous integration environments. 🥂
Rust
1,499
star
2

docuum

Docuum performs least recently used (LRU) eviction of Docker images. 🗑️
Rust
489
star
3

proofs

My personal repository of formally verified mathematics.
Coq
259
star
4

tagref

Tagref helps you maintain cross-references in your code.
Rust
148
star
5

socket.js

A realtime communication framework for Node.js.
JavaScript
143
star
6

hashpass

A simple password manager with a twist.
TypeScript
113
star
7

effects

A brief exploration of the various approaches to modeling side effects in a purely functional programming language.
Haskell
100
star
8

typical

Data interchange with algebraic data types.
Rust
81
star
9

raytracer

A browser-based real-time raytracer written in CoffeeScript.
CSS
53
star
10

data-structure-explorer

A web-based pedagogical tool for exploring data structures.
JavaScript
48
star
11

cfg-checker

Search for ambiguities in context-free grammars.
C++
38
star
12

unicode

Portable ASCII and Unicode string manipulation functions for C++.
C++
21
star
13

doesgoogleexecutejavascript

Google executes JavaScript, even if the script is fetched from the network. However, Google does not make AJAX requests.
JavaScript
15
star
14

dotfiles

My configuration files.
Shell
13
star
15

paxos

An implementation of single-decree Paxos.
Rust
10
star
16

dubstepn

My personal blog.
Ruby
9
star
17

base16-circus-scheme

A theme for the Base16 color system.
6
star
18

gigamesh

A home for all your notes.
TypeScript
6
star
19

coq-intro

An introduction to proving theorems and certifying programs with Coq.
Coq
5
star
20

gigamesh-schema

The Typical schema for the Gigamesh data model.
Perl
3
star
21

stem-cell

A simple project to demonstrate the cross-platform release management process I use for my open source work.
Shell
3
star
22

subjunct

A website for sharing secrets.
Ruby
3
star
23

garnet

A fast and minimalist template engine for Node.
JavaScript
2
star
24

webpack-scaffolding

Scaffolding for building web applications.
JavaScript
2
star
25

gists

Small projects that don't deserve their own repository.
Python
1
star