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: Propas generic argument is an objectAin the ∞-groupoid - Morphism:
Ty<F, Pow<B, A>>is a morphismFfromAtoB,f : A -> B - Identity:
Id<A>is the identity morphismid{A} : A -> A - Composition:
Comp<G, F>is the compositiong . f - Inverse:
Inv<F>is the imaginary inverseinv(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§
Modules§
- bool_
alg - Boolean algebra
- dep
- Dependent Types
- eqx
- Equality helper macro.
- feq
- Equality
- fin
- Finite sets.
- fun_ext
- Function Extensionality
- id
- Identity function.
- inv
- Imaginary Inverse
- list
- List.
- natc
- Closed natural numbers
- natp
- Natural numbers.
- phott
- Propositional Homotopy Type Theory
- real
- Real numbers.
Structs§
- App
- Applied function.
- Dup
- Duplicate function.
- FComp
- Composition.
- Fst
- Fst.
- IsConst
- Whether some symbol is a constant.
- Lam
- Lambda.
- Norm1
f[g1 -> g2].- Norm2
f[g1 x g2 -> g3].- ParTup
- Parallel tuple.
- Snd
- Snd.
- Subst
- Substitute in expression
e[a := b]. - Tup
- Tuple.
- Type
- Cumulative type hierarchy.
Traits§
- VProp
- Implemented by variable propositions.
Functions§
- and_
is_ const is_const(a) ⋀ is_const(b) => is_const(a ⋀ b).- app2_
fun_ ty (f : x -> y -> z) ⋀ (a : x) ⋀ (b : y) => f(a)(b) : z.- app2_
lam_ ty (f : x => y => z) ⋀ (a : x) ⋀ (b : y) => f(a)(b) : z.- app_eq
(x == y) => (f(x) == f(y)).- app_
fun_ ext (f : (x -> y)) ⋀ (g : (x -> y)) ⋀ (f(a) == g(a))^(a : x) => ∃ a : x { f == g }.- app_
fun_ swap_ ty (f(a) : y)^(a : x) => (f(b) : y)^(b : x).- app_
fun_ ty (f : (x -> y)) ⋀ (a : x) => (f(a) : y).- app_
fun_ unfold (f(a)^a : x -> y)^true => (f : x -> y).- app_
is_ const is_const(f) ⋀ is_const(x) => is_const(f(x)).- app_
lam_ ty (f : (x => y)) ⋀ (a : x) => (f(a) : y).- app_
lift_ ty_ lam (f(a) == b) ⋀ (a : x) ⋀ (b : y) => (\(a : x) = f(a)) : (x => y).- app_
map_ eq (f == g) => (f(x) == g(y)).- app_
rev_ fun_ ty (f(a) : y)^(a : x) => (f : (x -> y)).- app_
rev_ lam_ ty (a : x) ⋀ (f(a) : y) => (f : (x => y)).- app_
tauto_ ⚠lam_ to_ tauto_ fun_ ty (f(a)^a : x => y)^true => (f : x -> y).- app_
theory theory(f(x)).- app_
to_ comp g(f(x)) => (g . f)(x).- comp_
app (f(a) == b) ⋀ (g(b) == c) => g(f(a)) == c.- comp_
app_ def (f(a) == b) ⋀ (g(b) == c) ⋀ (h == (g . f)) => h(a) == c.- comp_
assoc h . (g . f) == (h . g) . f.- comp_
eq_ left (f == h) => (f . g) == (h . g).- comp_
eq_ right (g == h) => (f . g) == (f . h).- comp_
id_ left (f : a -> b) => (id{b} . f == f).- comp_
id_ right (f : a -> b) => (f . id{a} == f).- comp_
in_ left_ arg (g . f) ⋀ (g == h) => (h . f).- comp_
in_ right_ arg (g . f) ⋀ (f == h) => (g . h).- comp_
is_ const is_const(f) ⋀ is_const(g) => is_const(g . f).- comp_qu
~f ⋀ ~g => ~(g . f).- comp_
to_ app (g . f)(x) => g(f(x)).- comp_ty
(f : x -> y) ⋀ (g : y -> z) => (g . f) : x -> z.- const_
eq (a == b) => (is_const(a) == is_const(b)).- const_
in_ arg is_const(a) ⋀ (a == b) => is_const(b).- const_
tup is_const(a) ⋀ is_const(b) => is_const((a, b)).- cover
(a : b) ⋀ ((a == x) ⋁ (a == y))^(a : b) ⋀ c^(a == x) ⋀ c^(a == y) => c.- dup_def
dup(a) = (a, a).- dup_
is_ const is_const(dup).- dup_ty
dup : a -> (a, a).- eq_
app_ comp (g . f)(x) == g(f(x)).- eq_
app_ norm1 g2(f(inv(g1)(x))) == f[g1 -> g2](x).- eq_
app_ norm2 g3(f(inv(g1 x g2)(x))) == f[g1 x g2 -> g3](x).- eq_
norm2_ norm1 f[g1 x g2 -> g3] == f[(g1 x g2) -> g3].- eq_
norm2_ norm1_ comp f[g1 x g2 -> g3][g4 x g5 -> g6] == f[(g1 x g2) -> g3][(g4 x g5) -> g6].- fcomp_
is_ const is_const(comp).- fst
t : (a, b) => fst(t) : a.- fst_def
fst((a, b)) = a.- fst_
is_ const is_const(fst).- fst_
lower t : (x : a, b) => fst(t) == x.- fst_ty
fst : (a, b) -> a.- fun_
to_ ⚠lam_ ty f : x -> y => f : x => y.- fun_ty
(a : x) ⋀ (b : y) => (a -> b) : (x -> y).- fun_
type0 (a : type(n)) ⋀ (b : type(m)) => (a -> b) : type(0).- fun_
type_ ty (type(n) -> type(m)) : type(0).- imply_
is_ const is_const(a) ⋀ is_const(b) => is_const(a => b).- judgement_
ty (b : type(n)) => (a : b) : type(n).- lam
(c : x) => ((\(a : x) = b)(c) == b[a := c]).- lam_
app_ nop (a : x) => ((\(a : x) = b)(a) == b.- lam_
app_ trivial (b : x) => ((\(a : x) = b)(b) == b.- lam_
app_ ty (a : x) ⋀ (b : y) ⋀ (c : x) => ((\(a : x) = b)(c) : y).- lam_
app_ ty_ trivial (b : x) => (\(a : x) = b)(b) : x.- lam_
eq_ lift (a : x) ⋀ (b == c) => (\(a : x) = b) == (\(a : x) = c).- lam_fst
(c : x) => (\(a : x) = \(b : y) = a)(c) == (\(b : y[a := c]) = c).- lam_
fst_ ty (a : x) ⋀ (b : y) => (\(a : x) = \(b : y) = a) : x- lam_id
(x : type(n)) ⋀ (b : x) => (\(a : x) = a)(b) = b.- lam_
id_ app_ ty (a : x) ⋀ (b : x) => (\(a : x) = a)(b) : x.- lam_
id_ eq (\(a : x) = a) == id{a}.- lam_
id_ q (\(a : x) = a) ~~ id{x}.- lam_
id_ ty (a : x) => (\(a : x) = a) : (x => x).- lam_
lift (a : x) ⋀ b => (\(a : x) = b).- lam_snd
(c : x) => (\(a : x) = \(b : y) = b)(c) == (\(b : y[a := c]) = b).- lam_
snd_ ty (a : x) ⋀ (b : y) => (\(a : x) = \(b : y) = b) : y.- lam_ty
(a : x) ⋀ (b : y) => (\(a : x) = b) : (x => y).- norm1_
comp f[g1 -> g2][g3 -> g4] == f[(g3 . g1) -> (g4 . g2)].- norm1_
def f[g1 -> g2] == (g2 . f) . inv(g1).- norm1_
eq (f == h) => f[g1 -> g2] == h[g1 -> g2].- norm1_
eq_ in (g1 == h) => f[g1 -> g2] == f[h -> g2].- norm1_
eq_ out (g2 == h) => f[g1 -> g2] == f[g1 -> h].- norm1_
id (f : a -> b) => (f[id{a} -> id{b}] == f)for 1 argument.- norm1_
inv (f : a -> a) => id{a}[f -> id{a}] == inv(f).- norm1_
ty (f : a -> b) ⋀ (g1 : a -> c) ⋀ (g2 : b -> d) => f[g1 -> g2] : c -> d.- norm2_
app (inv(g1) ~~ h1) ⋀ (inv(g1) ~~ h2) ⋀ (g1(b1) = a1) ⋀ (g2(b2) = a2) ⋀ (f(b1, b2) = c) ⋀ (g3(c) = d) => f[g1 x g2 -> g3](a1, a2) = d.- norm2_
comp f[g1 x g2 -> g3][g4 x g5 -> g6] == f[(g4 . g1) x (g5 . g2) -> (g6 . g3)].- norm2_
def f[g1 x g2 -> g3] == (g3 . f) . (inv(g1) x inv(g2)).- norm2_
eq (f == h) => f[g1 x g2 -> g3] == h[g1 x g2 -> g3].- norm2_
ty (f : (a1, a2) -> b) ⋀ (g1 : a1 -> c1) ⋀ (g2 : a2 -> c2) ⋀ (g3 : b -> d) => f[g1 x g2 -> g3] : (c1, c2) -> d.- or_
is_ const is_const(a) ⋀ is_const(b) => is_const(a ⋁ b).- par_
tup_ app_ is_ const is_const(f) ⋀ is_const(g) => is_const(f x g).- par_
tup_ comp (g1 x g2) . (f1 x f2) == ((g1 . f1) x (g2 . f2)).- par_
tup_ def (f(i0) == o0) ⋀ (g(i1) == o1) => (f x g)(i0, i1) == (o0, o1).- par_
tup_ fun_ ty (f : (x1 -> y1)) ⋀ (g : (x2 -> y2)) => (f x g) : ((x1, x2) -> (y1, y2)).- par_
tup_ id (id{a} x id{b}) == id{(a, b)}.- par_
tup_ inv inv(f x g) == inv(f) x inv(g).- par_
tup_ is_ const is_const(par_tup).- par_
tup_ lam_ ty (f : (x1 => y1)) ⋀ (g : (x2 => y2)) => (f x g) : ((x1, x2) => (y1, y2)).- pord_
is_ const is_const(a) ⋀ is_const(b) => is_const(pord(a, b)).- q_
inv_ ty (f : A -> B) ⋀ (inv(f) ~~ g) => ((f ~~ g) : ((A -> B) ~~ (B -> A))).- snd
t : (a, b) => snd(t) : a.- snd_def
snd((a, b)) = b.- snd_
is_ const is_const(snd).- snd_
lower t : (a, x : b) => snd(t) == x.- snd_ty
snd : (a, b) -> b.- subst_
app f(a)[b := c] == f[b := c](a[b := c]).- subst_
const is_const(a) => (a[b := c] == a).- subst_
eq a[c := d] == b => a[c := d][e := f] == b[e := f].- subst_
eq_ lam_ body a[c := d] == b => (\(e) = a[c := d]) == (\(e) = b).- subst_
lam (\(a : x) = b)[a := c] == b[a := c].- subst_
lam_ const (\(a : x) = b)[a := c] == b[a := c].- subst_
nop a[b := b] == a.- subst_
trivial a[a := b] == b- subst_
tup (a, b)[c := d] == (a[c := d], b[c := d]).- subst_
ty (a : b) => (b[c := a] == b).- sym_
norm1_ comp f[g1][g2] == f[g2 . g1]for 1 argument.- sym_
norm1_ id (f : a -> a) => (f[id{a}] == f)for 1 argument.- sym_
norm1_ ty (f : a -> a) ⋀ (g : a -> b) => f[g] : b -> b.- sym_
norm2_ app (inv(g) ~~ h) ⋀ (g(b1) = a1) ⋀ (g(b2) = a2) ⋀ (f(b1, b2) = c) ⋀ (g(c) = d) => f[g](a1, a2) = d.- sym_
norm2_ comp f[g1][g2] == f[g2 . g1]for 2 arguments.- sym_
norm2_ id (f : (a, a) -> a) => f[id{a}] == ffor 2 arguments.- sym_
norm2_ ty (f : (a, a) -> a) ⋀ (g : a -> b) => f[g] : (b, b) -> b.- tauto_
lam_ ⚠to_ tauto_ fun_ ty (f : x => y)^true => (f^true : x -> y).- tup3_
eq_ fst (a == b) => (a, c, d) == (b, c, d).- tup3_
eq_ snd (a == b) => (c, a, d) == (c, b, d).- tup3_
eq_ trd (a == b) => (c, d, a) == (c, d, b).- tup3_
fst (a, b, c) : (x, y, z) => (a : x).- tup3_
rev_ eq_ fst (c : x) ⋀ (d : y) ⋀ ((a, c, d) == (b, c, d)) => (a == b).- tup3_
rev_ eq_ snd (c : x) ⋀ (d : y) ⋀ ((c, a, d) == (c, b, d)) => (a == b).- tup3_
rev_ eq_ trd (c : x) ⋀ (d : y) ⋀ ((c, d, a) == (c, d, b)) => (a == b).- tup3_
snd (a, b, c) : (x, y, z) => (b : y).- tup3_
trd (a, b, c) : (x, y, z) => (c : z).- tup_
const is_const((a, b)) => is_const(a) ⋀ is_const(b).- tup_eq
(a == b) ⋀ (c == d) => (a, c) == (b, d).- tup_
eq_ fst (a == b) => (a, c) == (b, c).- tup_
eq_ fst_ snd (a, b) == (fst((a, b)), snd((a, b))).- tup_
eq_ snd (a == b) => (c, a) == (c, b).- tup_fst
(a, b) : (x, y) => (a : x).- tup_
fst_ const is_const((a, b)) => is_const(a).- tup_
in_ left_ arg (a, b) ⋀ (a == c) => (c, b).- tup_
in_ right_ arg (a, b) ⋀ (b == c) => (a, c).- tup_
is_ const is_const(a) ⋀ is_const(b) => is_const((a, b)).- tup_
rev_ eq_ fst (c : d) ⋀ ((a, c) == (b, c)) => (a == b).- tup_
rev_ eq_ snd (c : d) ⋀ ((c, a) == (c, b)) => (a == b).- tup_snd
(a, b) : (x, y) => (b : y).- tup_
snd_ const is_const((a, b)) => is_const(b).- tup_ty
(a : x) ⋀ (b : y) => (a, b) : (x, y).- tup_
type_ ty (type(n), type(m)) : type(0).- ty_
is_ const is_const(a) ⋀ is_const(b) => is_const(a : b).- type_
imply type(n) => type(n+1).- type_
is_ const is_const(type(n)).- type_ty
type(n) : type(n+1).
Type Aliases§
- App2
- Apply 2 function arguments using function currying.
- Comp
f . g.- IsVar
- A proof that some symbol is not a constant.
- LamFst
\(a : x) = \(b : y) = a.- LamId
\(a : x) = a.- LamSnd
\(a : x) = \(b : y) = b.- Par
- Apply parallel tuple to two functions.
- ParInv
- Apply parallel tuple to two inverted functions.
- SymNorm1
f[g]of 1 argument.- SymNorm2
f[g]of 2 arguments.- Tup3
- Tuple of 3 elements.