Module prop::fun

source ·
Expand description

Functional programming as propositions

Model is derived from PSQ, PSI and HOOO EP.

Introduction to Functional Programming

In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. For more information, see wikipedia article.

Foundational Path Semantics (PSI/PSQ/HOOO EP) is lower level than functional programming.

For example, a : T in functional programming is a primitive notion, which can not be reduced to something else. However, in foundational Path Semantics, a : T might be modelled as (a => T) ⋀ (a < T) where < is path semantical order.

Notice that in Rust, a : T is built into the language itself. The problem is that Rust does not support e.g. dependent types. This is why foundational Path Semantics is needed, to prove properties of higher level languages with more complex type systems than Rust. The motivation is to use a small set of axioms, powerful enough to develop some intuition in isolation, but also can be used as a starting point for more advanced logical frameworks.

There are many theorems that are provable in foundational Path Semantics, which are not provable in normal functional programming. Therefore, one should think about foundational Path Semantics as a more general model of mathematics.

Normal functional programming can be thought of as a “library” written in foundational Path Semantics. New operators and definitions are made using new axioms. However, these new axioms work in harmony with existing axioms.

For example, function composition g . f is not a primitive notion that is built into foundational Path Semantics. This operator needs to be defined and axioms introduced that describe mathematical properties of function composition. When these new axioms are defined, one can use them to prove theorems about function composition.

Types

A type x : T uses Ty<X, T> from the path_semantics module (PSI).

A function type f : X -> Y uses Ty<F, Pow<Y, X>> from the hooo module (HOOO EP).

A lambda/closure type f : X => Y uses Ty<F, Imply<X, Y>>.

Imaginary Inverse

For information about the imaginary inverse, see the fun::inv module.

Function Extensionality

For information about function extensionality, see the fun::fun_ext module.

Dependent Types

For information about dependent types, see the fun::dep module.

Category Theory Perspective

This model seen from a Category Theory perspective produces an ∞-groupoid.

  • Object: A: Prop as generic argument is an object A in the ∞-groupoid
  • Morphism: Ty<F, Pow<B, A>> is a morphism F from A to B, f : A -> B
  • Identity: Id<A> is the identity morphism id{A} : A -> A
  • Composition: Comp<G, F> is the composition g . f
  • Inverse: Inv<F> is the imaginary inverse inv(f)

The imaginary inverse adds an inverse for every morphism in the category, which results in a groupoid. However, since the inverse is imaginary, the groupoid is category realizable.

Any expression constructed from these operations can be used where A: Prop is allowed. Therefore, morphisms and higher morphisms are also objects, hence this form an ∞-groupoid.

Qubit Truths

For information about qubit truths, see the fun::id module.

Re-exports

  • pub use dep::*;
  • pub use feq::*;
  • pub use id::*;
  • pub use inv::*;

Modules

  • Boolean algebra
  • Dependent Types
  • Equality helper macro.
  • Equality
  • Finite sets.
  • Function Extensionality
  • Identity function.
  • Imaginary Inverse
  • List.
  • Closed natural numbers
  • Natural numbers.
  • Propositional Homotopy Type Theory
  • Real numbers.

Structs

Traits

  • Implemented by variable propositions.

Functions

Type Definitions

  • Apply 2 function arguments using function currying.
  • f . g.
  • A proof that some symbol is not a constant.
  • \(a : x) = \(b : y) = a.
  • \(a : x) = a.
  • \(a : x) = \(b : y) = b.
  • Apply parallel tuple to two functions.
  • Apply parallel tuple to two inverted functions.
  • f[g] of 1 argument.
  • f[g] of 2 arguments.
  • Tuple of 3 elements.