2025 James B. Wilson
Towards the Curry-Howard isomorphism.
Introduction rule in logic, e.g. A∧BA,B(I∧)
Formation of type A×B:TypeA,B:Type(F×)
Intro/Constructor of data (a,b):A×Ba:A,b:B(I×)
Eliminiation rules in logic, e.g. AA∧B(E∗∧) BA∧B(E∧∗)
Elim/Getters of type getA(x):Ax:A×B(E∗×)getB(x):Bx:A×B(E×∗)
{
Computation/Comprehension a:b:getA(a,b)getB(a,b)AB=a=b(C∧)
{
Intro. logic, e.g. A∧BA,B(I∧)
Formation of type A×B:TypeA,B:Type(F×)
Intro/Constructor of data (a,b):A×Ba:A,b:B(I×)
Elim. logic, e.g. AA∧B(E∗∧) BA∧B(E∧∗)
Elim/Getters of type x:getA(x):getB(x):A×BAB(E×)
{
Computation a:b:getA(a,b)getB(a,b)AB=a=b(C∧)
{
Text
import ctx;
class Pair[A,B]
makePair(a:A, b:B) {
myA = a; myB = b
}
getA():A { return myA }
getB():B { return myB }
> x = new Pair("five", 5)
> x.getA()
five
> x.getB()
5
Introduction Γ⊢A⇒BΓ,A⊢B(I⇒)
Formation of type A→B:TypeA,B:Type(F→)
Intro/Constructor of data Φ:x:proof:(x↦Φ):StringVariable(a:A⊢Φ∣x:=a:B)A→B
Eliminiation ΓΓΓ⊢A⇒B⊢A⊢B(E⇒)
Elim/APPLY f:a:f(a):A→BAB(E→)
{
Computation/Comprehension Φ:x:proof:a:f(a) StringVariable(a:A⊢Φ∣x:=a:B)A=Φ∣x:=a
{
(I→)
(C→)
Introduction Γ⊢A⇒BΓ,A⊢B
Formation of type A→B:TypeA,B:Type(F→)
Intro/Constructor of data prog:x:proof:(x↦prog):StringVariable(a:A⊢prog∣x:=a:B)A→B
Eliminiation ΓΓΓ⊢A⇒B⊢A⊢B
Elim/APPLY f:a:f(a):A→BAB(E→)
{
Computation/Comprehension prog:x:proof:a:f(a) StringVariable(a:A⊢prog∣x:=a:B)A=prog∣x:=a
{
(I→)
(C→)
def myFunc(x:A):B {
program
... x ...
}
> b = myFunc(a)
You the programmer!
(Or a theorem prover)
The computer
Formation of type A→B:TypeA,B:Type(F→)
public class MyFunction {
String myFunc(int x) {
return "I saw engine number " + x;
}
public static void main(String[] args) {
MyFunction f = new MyFunction();
System.out.println(5);
}
}
Intro/Constructor of data prog:x:proof:(x↦prog):StringVariable(a:A⊢prog∣x:=a:B)A→B
Elim/APPLY f:a:f(a):A→BAB(E→)
Computation/Comprehension prog:x:proof:a:f(a) StringVariable(a:A⊢prog∣x:=a:B)A=prog∣x:=a
Visit: https://www.jdoodle.com/online-java-compiler
Formation of type A→B:TypeA,B:Type(F→)
def myFunc(x:Int):String =
"I saw engine number " + x
print(myFunc(5))
Intro/Constructor of data prog:x:proof:(x↦prog):StringVariable(a:A⊢prog∣x:=a:B)A→B
Elim/APPLY f:a:f(a):A→BAB(E→)
Computation/Comprehension prog:x:proof:a:f(a) StringVariable(a:A⊢prog∣x:=a:B)A=prog∣x:=a
Visit: https://scastie.scala-lang.org/
Formation of type A→B:TypeA,B:Type(F→)
module Main where
myFunc :: Int -> String
myFunc x = "I saw engine number " ++ show x
main = print (myFunc 5)
Intro/Constructor of data prog:x:proof:(x↦prog):StringVariable(a:A⊢prog∣x:=a:B)A→B
Elim/APPLY f:a:f(a):A→BAB(E→)
Computation/Comprehension prog:x:proof:a:f(a) StringVariable(a:A⊢prog∣x:=a:B)A=prog∣x:=a
Visit: https://replit.com/
Formation of type A→B:TypeA,B:Type(F→)
# Give me an integer x
# My function will return a poem.
def myFunc(x):
return "I saw engine number " + str(x)
> myFunc(5)
I saw engine number 5
Intro/Constructor of data prog:x:proof:(x↦prog):StringVariable(a:A⊢prog∣x:=a:B)A→B
Elim/APPLY f:a:f(a):A→BAB(E→)
Computation/Comprehension prog:x:proof:a:f(a) StringVariable(a:A⊢prog∣x:=a:B)A=prog∣x:=a
Visit: https://replit.com/
message = "I saw engine number "
# # Give me an integer x
# My function will return a poem.
def myFunc(x):
return message + str(x)
> myFunc(5)
I saw engine number 5
This data is a constant, but from where?
The context of the function!
Nearly all functions have implicit context,
in fact logic predicts this Γ,P⇒Q
# Give me a message and an integer x
# My function will return a poem.
def myFunc(message, x):
return message + str(x)
> myFunc("My favorite number is ", 5)
My favorite number is 5