Skip to content

Instantly share code, notes, and snippets.

View larrytheliquid's full-sized avatar

Larry Diehl larrytheliquid

View GitHub Profile
@larrytheliquid
larrytheliquid / gist:3909860
Last active April 28, 2016 13:42
inductive-recursive universe for dependent types
open import Data.Empty using ( ⊥ ; ⊥-elim )
open import Data.Unit using ( ⊤ ; tt )
open import Data.Bool using ( Bool ; true ; false ; if_then_else_ )
renaming ( _≟_ to _≟B_ )
open import Data.Nat using ( ℕ ; zero ; suc )
renaming ( _≟_ to _≟ℕ_ )
open import Data.Product using ( Σ ; _,_ )
open import Relation.Nullary using ( Dec ; yes ; no )
open import Relation.Binary using ( Decidable )
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl )
λ A m n →
ind
(`Arg (Tag ("nil" ∷ "cons" ∷ []))
(λ t →
case
(λ _ →
Desc
(`Arg (Tag ("zero" ∷ "suc" ∷ []))
(λ t₁ → case (λ _ → Desc ⊤) (`End tt , `Rec tt (`End tt) , tt) t₁))
@larrytheliquid
larrytheliquid / HypotheticalFunMatching.agda
Created June 29, 2013 19:49
What goes wrong if you were to allow matching against value/neutral forms of functions? Are there any good references on this?
open import Data.Bool
open import Data.Nat
module HypotheticalFunMatching where
{-
Imagine that the expressions in the pattern positions are first evaluated to values/neutrals.
So for example, "not" really becomes elimBool and "_+_" becomes two nested elimℕ's.
A wildcard match is always necessary because there are infinitely many intentionally different
functions.
@larrytheliquid
larrytheliquid / LocalProps.agda
Last active December 15, 2015 03:09
How does local completeness generalize to eliminators?
{-
How does local completeness (http://www.cs.cmu.edu/~fp/courses/15317-f09/lectures/03-harmony.pdf) generalize to eliminators?
Below is the eliminator for `ℕ` that does not include the inductive hypothesis `P n` in the `suc n` branch.
It still passes local completeness because the `suc n` branch still includes the `n` index, it merely omits the inductive hypothesis.
Caveats:
1. `ℕ` is a datatype rather than a standard logical proposition, and it has many proofs/inhabitants for the same type.
2. I'm being more strict here by requiring the expansion to equal the input, rather than merely proving the same proposition.
-}
airtheliquid:spire larrytheliquid$ ./spire
Enter type:
If (Not (Not True)) Bool Unit
Enter term:
Not True
Well typed!
=> False : Bool
open import Data.Bool
open import Data.Nat
open import Data.String
module CrazyNames where
data U : Set where
`Bool `ℕ : U
El : U → Set
El `Bool = Bool
@larrytheliquid
larrytheliquid / TrailEquality.agda
Created February 3, 2013 15:23
Trail equality
module TrailEquality where
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.HeterogeneousEquality
data Maybe (A : Set) : Set where
just : (x : A) → Maybe A
nothing : Maybe A
data ℕ : Set where
zero : ℕ
@larrytheliquid
larrytheliquid / gist:3890780
Created October 15, 2012 04:10
IR DT Types + Terms
open import Level
open import Data.Product public using ( Σ ; _,_ ; proj₁ ; proj₂ )
data ⊥ {a} : Set a where
! : ∀ {a b} {A : Set a} → ⊥ {b} → A
! ()
record ⊤ {a} : Set a where
constructor tt
@larrytheliquid
larrytheliquid / gist:3889346
Created October 14, 2012 18:04
inductive-recursive universe for dependent types (no unicode)
module IRDTT where
open import Level
open import Data.Product using ( _,_ )
renaming ( Σ to Sigma ; proj₁ to proj1 ; proj₂ to proj2 )
open import Data.Sum
renaming ( _⊎_ to Sum ; inj₁ to inj1 ; inj₂ to inj2 )
record Unit {a} : Set a where
constructor tt
@larrytheliquid
larrytheliquid / gist:3886590
Created October 13, 2012 23:27
inductive-recursive universe for dependent types
module IRDTT where
open import Level
open import Data.Product public using ( Σ ; _,_ ; proj₁ ; proj₂ )
open import Data.Sum public using ( _⊎_ ; inj₁ ; inj₂ )
record ⊤ {a} : Set a where
constructor tt
data Type {a} : Set (suc a)
⟦_⟧ : ∀{a} → Type {a} → Set a