• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated about 1 year ago

Reviews

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

Repository Details

a pragmatic point-free theorem prover assistant

Poi

a pragmatic point-free theorem prover assistant

Standard Library

=== Poi 0.23 ===
Type `help` for more information.
> and[not]
and[not]
or
∵ and[not] => or
<=>  not · nor
     ∵ not · nor <=> or
∴ or

To run Poi Reduce from your Terminal, type:

cargo install --example poi poi

Then, to run:

poi

You can use help to learn more about commands in Poi and the theory behind it.

Download and check it out! (Think about it as a tool to learn by doing)

Also, check out the FAQ on Path Semantics:

Example: Length of concatenated lists

Poi lets you specify a goal and automatically prove it.

For example, when computing the length of two concatenated lists, there is a faster way, which is to compute the length of each list and add them together:

> goal len(a)+len(b)
new goal: (len(a) + len(b))
> len(a++b)
len((a ++ b))
depth: 1 <=>  (len · concat)(a)(b)
     ∵ (f · g)(a)(b) <=> f(g(a)(b))
.
(len · concat)(a)(b)
(concat[len] · (len · fst, len · snd))(a)(b)
∵ len · concat => concat[len] · (len · fst, len · snd)
(add · (len · fst, len · snd))(a)(b)
∵ concat[len] => add
depth: 0 <=>  ((len · fst)(a)(b) + (len · snd)(a)(b))
     ∵ (f · (g0, g1))(a)(b) <=> f(g0(a)(b))(g1(a)(b))
((len · fst)(a)(b) + (len · snd)(a)(b))
(len(a) + (len · snd)(a)(b))
∵ (f · fst)(a)(_) => f(a)
(len(a) + len(b))
∵ (f · snd)(_)(a) => f(a)
∴ (len(a) + len(b))
Q.E.D.

The notation concat[len] is a "normal path", which lets you transform into a more efficient program. Normal paths are composable and point-free, unlike their equational representations.

Example: Levenshtein proof search

For deep automated theorem proving, Poi uses Levenshtein distance heuristic. This is simply the minimum single-character edit distance in text representation.

Try the following:

> goal a + b + c + d
> d + c + b + a
> auto lev

The command auto lev tells Poi to automatically pick the equivalence with smallest Levenshtein distance found in any sub-proof.

Introduction to Poi and Path Semantics

In "point-free" or "tacit" programming, functions do not identify the arguments (or "points") on which they operate. See Wikipedia article.

Poi is an implementation of a small subset of Path Semantics. In order to explain how Poi works, one needs to explain a bit about Path Semantics.

Path Semantics is an extremely expressive language for mathematical programming, which has a "path-space" in addition to normal computation. If normal programming is 2D, then Path Semantics is 3D. Path Semantics is often used in combination with Category Theory, Logic, etc.

A "path" (or "normal path") is a way of navigating between functions, for example:

and[not] <=> or

Translated into words, this sentence means:

If you flip the input and output bits of an `and` function,
then you can predict the output directly from the input bits
using the function `or`.

In normal programming, there is no way to express this idea directly, but you can represent the logical relationship as an equation:

not(and(a, b)) = or(not(a), not(b))

This is known as one of De Morgan's laws.

When represented as a commutative diagram, one can visualize the dimensions:

         not x not
      o ---------> o           o -------> path-space
      |            |           |  x
  and |            | or        |     x
      V            V           |   x
      o ---------> o           V        x - Sets are points
           not            computation

Computation and paths is like complex numbers where the "real" part is computation and the "imaginary" part is the path.

This is written in asymmetric path notation:

and[not x not -> not] <=> or

In symmetric path notation:

and[not] <=> or

Both computation and path-space are directional, meaning that one can not always find the inverse. Composition in path-space is just function composition:

f[g][h] <=> f[h . g]

If one imagines computation = 2D, then computation + path-space = 3D.

Path Semantics can be thought of as "point-free style" sub-set of equations. This sub-set of equations is particularly helpful in programming.

Design of Poi

Poi is designed to be used as a Rust library.

It means that anybody can create their own tools on top of Poi, without needing a lot of dependencies.

Poi uses primarily rewriting-rules for theorem proving. This means that the core design is "stupid" and will do dumb things like running in infinite loops when given the wrong rules.

However, this design makes also Poi very flexible, because it can pattern match in any way, independent of computational direction. It is relatively easy to define such rules in Rust code.

Syntax

Poi uses Piston-Meta to describe its syntax. Piston-Meta is a meta parsing language for human readable text documents. It makes it possible to easily make changes to Poi's grammar, and also preserve backward compatibility.

Since Piston-Meta can describe its own grammar rules, it means that future versions of Piston-Meta can parse grammars of old versions of Poi. The old documents can then be transformed into new versions of Poi using synthesis.

Core Design

At the core of Poi, there is the Expr structure:

/// Function expression.
#[derive(Clone, PartialEq, Debug)]
pub enum Expr {
    /// A symbol that is used together with symbolic knowledge.
    Sym(Symbol),
    /// Some function that returns a value, ignoring the argument.
    ///
    /// This can also be used to store values, since zero arguments is a value.
    Ret(Value),
    /// A binary operation on functions.
    Op(Op, Box<Expr>, Box<Expr>),
    /// A tuple for more than one argument.
    Tup(Vec<Expr>),
    /// A list.
    List(Vec<Expr>),
}

The simplicity of the Expr structure is important and heavily based on advanced path semantical knowledge.

A symbol contains every domain-specific symbol and generalisations of symbols.

The Ret variant comes from the notation used in Higher Order Operator Overloading. Instead of describing a value as value, it is thought of as a function of some unknown input type, which returns a known value. For example, if a function returns 2 for all inputs, this is written \2. This means that point-free transformations on functions sometimes can compute stuff, without explicitly needing to reference the concrete value directly. See paper Higher Order Operator Overloading and Existential Path Equations for more information.

The Op variant generalizes binary operators on functions, such as Composition, Path (normal path), Apply (call a function) and Constrain (partial functions).

The Tup variant represents tuples of expressions, where a singleton (a tuple of one element) is "lifted up" one level. This is used e.g. to transition from and[not x not -> not] to and[not] without having to write rules for asymmetric cases.

The List variant represents lists of expressions, e.g. [1, 2, 3]. This differs from Tup by the property that singletons are not "lifted up".

Representing Knowledge

In higher dimensions of functional programming, the definition of "normalization" depends on the domain specific use of a theory. Intuitively, since there are more directions, what counts as progression toward an answer is somewhat chosen arbitrarily. Therefore, the subjectivity of this choice must be reflected in the representation of knowledge.

Poi's representation of knowledge is designed for multi-purposes. Unlike in normal programming, you do not want to always do e.g. evaluation. Instead, you design different tools for different purposes, using the same knowledge.

The Knowledge struct represents mathematical knowledge in form of rules:

/// Represents knowledge about symbols.
pub enum Knowledge {
    /// A symbol has some definition.
    Def(Symbol, Expr),
    /// A reduction from a more complex expression into another by normalization.
    Red(Expr, Expr),
    /// Two expressions that are equivalent but neither normalizes the other.
    Eqv(Expr, Expr),
    /// Two expressions that are equivalent but evaluates from left to right.
    EqvEval(Expr, Expr),
}

The Def variant represents a definition. A definition is inlined when evaluating an expression.

The Red variant represents what counts as "normalization" in a domain specific theory. It can use computation in the sense of normal evaluation, or use path-space. This rule is directional, which means it pattern matches on the first expression and binds variables, which are synthesized using the second expression.

The Eqv variant represents choices that one can make when traveling along a path. Going in one direction might be as good as another. This is used when it is not clear which direction one should go. This rule is bi-directional, which means one can treat it as a reduction both ways.

The EqvEval variant is similar to Eqv, but when evaluating an expression, it reduces from left to right. This is used on e.g. sin(Ï„ / 8). You usually want the readability of sin(Ï„ / 8) when doing theorem proving. For example, in Poi Reduce, the value of sin(Ï„ / 8) is presented as a choice (equivalence). When evaluating an expression it is desirable to just replace it with the computed value.

What Poi is not

Some people hoped that Poi might be used to solve problems where dependent types are used, but in a more convenient way.

Although Poi uses ideas from dependent types, it is not suitable for other applications of dependent types, e.g. verification of programs by applying it to some immediate representation of machine code.

Normal paths might be used for such applications in the future, but this might require a different architecture.

This implementation is designed for algebraic problems:

  • The object model is restricted to dynamical types
  • Reductions are balanced with equivalences

This means that not everything is provable, because this makes automated theorem proving harder, something that is required for the necessary depth of algebraic solving.

More Repositories

1

path_semantics

A research project in path semantics, a re-interpretation of functions for expressing mathematics
Rust
155
star
2

avalog

An experimental implementation of Avatar Logic with a Prolog-like syntax
Rust
63
star
3

prop

Propositional logic with types in Rust
Rust
56
star
4

monotonic_solver

A monotonic solver designed to be easy to use with Rust enum expressions
Rust
44
star
5

mix_economy

A research project to mix-regulate economy in MMO worlds
Rust
33
star
6

pocket_prover

A fast, brute force, automatic theorem prover for first order logic
Rust
33
star
7

linear_solver

A linear solver designed to be easy to use with Rust enums.
Rust
32
star
8

tree_mem_sort

An in-memory topological sort algorithm for trees based on Group Theory
Rust
24
star
9

lojban

A Lojban parser in Piston-Meta
Rust
22
star
10

quickbacktrack

Library for back tracking with customizable search for moves
Rust
22
star
11

advancedresearch.github.io

The website for the AdvancedResearch community
20
star
12

discrete

Combinatorial phantom types for discrete mathematics
Rust
14
star
13

hooo

Propositional logic with exponentials
Rust
13
star
14

nano_ecs

A bare-bones macro-based Entity-Component-System
Rust
8
star
15

ethicophysics

various mathematical properties arising from the exercise of free will by the human animal
TeX
8
star
16

higher_order_core

Core structs and traits for programming with higher order structures in Rust
Rust
7
star
17

asi_core0

An agent architecture candidate core for Artificial Super Intelligence (ASI).
Rust
7
star
18

reachability_solver

A linear reachability solver for directional edges
Rust
6
star
19

graph_solver

An undirected graph constraint solver for node and edge colors
Rust
5
star
20

last_order_logic

An experimental logical language
Rust
5
star
21

avatar_graph

A library for Avatar Graphs
Rust
5
star
22

joker_calculus

An implementation of Joker Calculus in Rust
Rust
5
star
23

trinoise

A mathematical noise pattern of 3 values based on Number Theory and Set Theory
Rust
4
star
24

higher_order_point

An experimental higher order data structure for 3D points
Rust
4
star
25

environmental_mega_robotic_systems

Software for controlling mega robotic systems to deal with environmental problems - such as excess CO2 (pre-alpha)
Rust
4
star
26

self_organizing_fractal_noise

Research on self-organizing fractal noise
4
star
27

path_iter

A cocategory enumeration library based on path semantics
Rust
3
star
28

hilbert_image_to_sound

A library for turning images into sound using Hilbert space-filling curves
Rust
3
star
29

utility_programming

A library for composable utility programming.
Rust
3
star
30

graph_builder

An algorithm for generating graphs with post-filtering and edge composition.
Rust
3
star
31

caso

Category Theory Solver for Commutative Diagrams
Rust
3
star
32

hypo

Automatic hypothesis testing
Rust
3
star
33

debug_sat

A debuggable automatic theorem prover for boolean satisfiability problems (SAT).
Rust
3
star
34

permutative_group_of_functions

Formally checked proofs of permutative group of functions in Coq IDE
Coq
2
star
35

closure_calculus

A Rust library for Barry Jay's Closure Calculus
Rust
2
star
36

proof_of_normal_path_composition

A proof of normal path composition in path semantics using diagonal commuting square in Cubical Type Theory
2
star
37

star_fizzle

A simple non-deterministic cellular automata with remarkable properties
2
star
38

homotopy

A library for homotopy logic
Rust
2
star
39

sync

A research project about synchronizability and cosynchronizability
Rust
2
star
40

observer_selection_effects

Various experiments in optimization algorithms derived from probabilistic observer selection effects
Rust
2
star
41

aude

An automated differentiation solver with a Lisp-like functional programming language
Rust
2
star
42

pingle

PiNGLE: The Piston Natural Grounded Language Environment
Python
2
star
43

truth_beauty_bux

A cryptocurrency that helps people rather than harming them
TeX
2
star
44

max_tree

A utility maximizer library based on a maximum tree structure.
Rust
2
star
45

avatar_hypergraph_rewriting

Hypergraph rewriting system with avatars for symbolic distinction
Rust
2
star
46

challenges

Toolkits and challenges for applying agent architecture candidate cores for Artificial Super Intelligence (ASI) in simulated environments
Rust
2
star
47

room

An experiment to test The Room Hypothesis of Common Sense
Rust
1
star
48

dig

A simple logistic environment primitive
Rust
1
star
49

attention_trace

A research project into attention trace
1
star
50

algexeno_cistercian

Visual Algexenotation with Cistercian numerals as hyperprimes
Rust
1
star
51

pocket_prover-set

A base logical system for PocketProver to reason about set properties
Rust
1
star
52

error_predictive_learning

Black-box learning algorithm using error prediction levels
Rust
1
star
53

iknow

A self-describing knowledge format with support for Rust-like syntax
Rust
1
star
54

path_semantics_std

A Rust type checked implementation of the standard dictionary of path semantics using constrained functions
Rust
1
star