Skip to content

Files

Latest commit

702f566 · Aug 20, 2023

History

History
38 lines (35 loc) · 3.32 KB

foundations.md

File metadata and controls

38 lines (35 loc) · 3.32 KB

Definition

I guess I should define the terms first:

  • small letters denote variable name, capital letters denote terms (exceptions below).
  • T denotes a type name.
  • V denotes the set of all variable names.
  • F denotes the set of all function names.
  • K denotes the set of all constants.
  • term definition:
    1. if x V K then x is a term.
    2. if f F , and A and B are terms, then so is f ( A , B ) .
  • the functions have type signature ( T 1 , T 2 ) T 3 .
  • T denotes any type i.e., type names as well as function types.
  • A : T means that A is of type T .
  • Γ denotes a set X 0 := Y 0 , X 1 := Y 1 , , X n := Y n of axioms (defined using the axiom keyword).
  • Π denotes a set X 1 : T 1 , X 2 : T 2 , , X n : T n of type assignments (defined using the type keyword).
  • in A [ x / Y ] , x / Y denotes a pattern/replacement pair, where x is a variable, while Y is a term.
  • the substitution algorithm A [ x / Y ] is defined as follows:
    1. x [ x / Y ] = Y .
    2. a [ x / Y ] = a , a V { x } .
    3. k [ x / Y ] = k , k K .
    4. f ( A , B ) [ x / Y ] = f ( A [ x / Y ] , B [ x / Y ] ) .

Foundations

The heart of nnoq is a single operator, :=, which is governed by the following axioms:
1. Π A : T Γ A := A (reflexivity)
2. Γ A := B Γ B := C Γ A := C (transitivity)
3. ( A := B ) Γ Π A : T Π B : T Γ A := B (derivability from axioms)
4. Γ A := B Γ C := D Π f ( A , C ) : T Γ f ( A , C ) := f ( B , D ) (congruence)
5. Γ A := B Π A : T A Π A [ x / Y ] : T A Γ A [ x / Y ] := B [ x / Y ] (substitution)

the following five axioms are for the type analysis (inference and checking):
6. Π , A : T , Π A : T (derivability from type assignments/declarations)
7. ( A := b ) Γ Π A : T Π b : T (type inference from := #1)
8. ( a := B ) Γ Π B : T Π a : T (type inference from := #2)
9. Π , x : T x A : T A Π , A [ x / Y ] : T A Y : T x Π A [ x / Y ] : T A (typed variable elimination)
10. Π f : ( T 1 , T 2 ) T 3 Π A : T 1 Π B : T 2 Π f ( A , B ) : T 3 (typed function instantiation)

nnoq builds on top of this foundation by generalizing the functions to arbitrary arity. however, this does not increase its power, as an n-arity function f : ( T 1 , , T n ) T r e t can be easily emulated in the core by n functions f 1 : ( T n , F 0 ) F 1 , f 2 : ( T n 1 , F 1 ) F 2 , , f n : ( T 1 , F n 1 ) T r e t and a constant f 0 : F 0 .