mirror of
https://github.com/Smaug123/agdaproofs
synced 2025-10-07 21:08:39 +00:00
Add Church numerals
This commit is contained in:
24
Computability/LambdaCalculus/ChurchNumeral.agda
Normal file
24
Computability/LambdaCalculus/ChurchNumeral.agda
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{-# OPTIONS --safe --warning=error --without-K #-}
|
||||||
|
|
||||||
|
open import LogicalFormulae
|
||||||
|
open import Lists.Lists
|
||||||
|
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
|
||||||
|
open import Decidable.Sets
|
||||||
|
open import Numbers.Naturals.Definition
|
||||||
|
open import Numbers.Naturals.Semiring
|
||||||
|
|
||||||
|
module Computability.LambdaCalculus.ChurchNumeral where
|
||||||
|
|
||||||
|
open import UnorderedSet.Definition ℕDecideEquality
|
||||||
|
open import Computability.LambdaCalculus.Definition
|
||||||
|
|
||||||
|
private
|
||||||
|
iter : ℕ → Term
|
||||||
|
iter zero = var 0
|
||||||
|
iter (succ n) = apply (var 1) (iter n)
|
||||||
|
|
||||||
|
church : ℕ → Term
|
||||||
|
church n = lam 1 (lam 0 (iter n))
|
||||||
|
|
||||||
|
churchSucc : Term
|
||||||
|
churchSucc = lam 0 (lam 1 (lam 2 (apply (var 1) (apply (apply (var 0) (var 1)) (var 2)))))
|
17
Computability/LambdaCalculus/Definition.agda
Normal file
17
Computability/LambdaCalculus/Definition.agda
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{-# OPTIONS --safe --warning=error --without-K #-}
|
||||||
|
|
||||||
|
open import LogicalFormulae
|
||||||
|
open import Lists.Lists
|
||||||
|
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
|
||||||
|
open import Decidable.Sets
|
||||||
|
open import Numbers.Naturals.Definition
|
||||||
|
open import Numbers.Naturals.Semiring
|
||||||
|
|
||||||
|
module Computability.LambdaCalculus.Definition where
|
||||||
|
|
||||||
|
open import UnorderedSet.Definition (ℕDecideEquality)
|
||||||
|
|
||||||
|
data Term : Set where
|
||||||
|
var : (v : ℕ) → Term
|
||||||
|
lam : (x : ℕ) → Term → Term
|
||||||
|
apply : Term → Term → Term
|
@@ -156,6 +156,8 @@ open import Modules.PolynomialModule
|
|||||||
open import Modules.Lemmas
|
open import Modules.Lemmas
|
||||||
open import Modules.DirectSum
|
open import Modules.DirectSum
|
||||||
|
|
||||||
|
open import Computability.LambdaCalculus.ChurchNumeral
|
||||||
|
|
||||||
open import ProjectEuler.Problem1
|
open import ProjectEuler.Problem1
|
||||||
|
|
||||||
module Everything.Safe where
|
module Everything.Safe where
|
||||||
|
Reference in New Issue
Block a user