Skip to content

rzrn/general-recursive-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Firstly we assume that we have natural numbers β„•: 0, 1, 2, …

We consider functions ℕᡏ β†’ β„•, and identify ℕ⁰ β†’ β„• with just β„•, i.e. we have unique k assigned to each function. f : ℕᡏ β†’ β„• means that f accepts k arguments.

Now we postulate a few basic functions:

  • Constant functions for each k, n ∈ β„•: C k n : ℕᡏ β†’ β„•.
  • Successor function: S : β„• β†’ β„•.
  • Projection functions for each 1 ≀ i ≀ k ∈ β„•: Ο€ i k : ℕᡏ β†’ β„•.

And a few basic operators that construct a new function from some already defined ones:

  • Composition operator f ∘ (g₁, …, gβ‚™) : ℕᡏ β†’ β„•, where f : ℕⁿ β†’ β„• and gα΅’ : ℕᡏ β†’ β„• for each 1 ≀ i ≀ n.
  • Primitive recursion operator ρ f g : ℕᡏ⁺¹ β†’ β„•, where f : ℕᡏ β†’ β„• and g : ℕᡏ⁺² β†’ β„•.
  • Minimization operator ΞΌ f : ℕᡏ β†’ β„• where f : ℕᡏ⁺¹ β†’ β„•.

This is enough to write typechecker, but now we need to give computational semantics for these functions.

We denote function application as f(x₁, …, xβ‚™) for function f : ℕⁿ β†’ β„•.

Then we define function application recursively:

  • (C k n)(x₁, …, xβ‚–) ≑ n.
  • S(x) ≑ x + 1 (here we assume that there is a way to calculate x + 1, but it’s not necessary to define x + y for arbitrary x, y ∈ β„•).
  • (Ο€ i k)(x₁, …, xβ‚–) ≑ xα΅’.
  • (f ∘ (g₁, …, gβ‚™))(x₁, …, xβ‚–) ≑ f(g₁(x₁, …, xβ‚–), …, gβ‚™(x₁, …, xβ‚–)).
  • (ρ f g)(0, x₁, …, xβ‚–) ≑ f(x₁, …, xβ‚–).
  • (ρ f g)(y + 1, x₁, …, xβ‚–) ≑ g(y, (ρ f g)(y, x₁, …, xβ‚–), x₁, …, xβ‚–).
  • (ΞΌ f)(x₁, …, xβ‚–) is a minimum y such that f(y, x₁, …, xβ‚–) ≑ 0. If f(y, x₁, …, xβ‚–) is always greater than zero, it does not terminate.

About

Toy point free language implementing GRF

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published