Skip to content

Instantly share code, notes, and snippets.

View gallais's full-sized avatar

G. Allais gallais

View GitHub Profile
@gallais
gallais / get.v
Last active March 4, 2020 18:44
Terminating map via commuting conversions
Inductive Tree (A : Set) : Set :=
| Leaf : A -> Tree A
| Node : bool -> Tree A * Tree A -> Tree A.
Definition subTree {A : Set} (b : bool) (lr : Tree A * Tree A) : Tree A :=
match (b, lr) with
| (true, (a, b)) => a
| (false, (a, b)) => b
end.
@gallais
gallais / Negative.idr
Created March 2, 2020 11:56
Using the lack of strict positivity to run an infinite computation
data EventT : (event : Type) -> (m : Type -> Type) -> (a : Type) -> Type where
MkEventTCont : (event -> m (EventT event m a)) -> EventT event m a
MkEventTTerm : m a -> EventT event m a
MkEventTEmpty : EventT event m a
data LAM : (x : Type) -> Type where
App : x -> x -> LAM x
Lam : (x -> x) -> LAM x
LC : Type
@gallais
gallais / search.agda
Created December 17, 2019 20:12
example of search
open import Agda.Builtin.Equality
open import Agda.Builtin.Nat hiding (_+_; _<_)
open import Data.Nat
open import Data.Nat.Properties
open import Relation.Binary
-- C-c C-z RET _*_ _≡_ RET
@gallais
gallais / Rose.agda
Created June 4, 2019 10:41
Use case for ∷-dec
open import Data.List using (List); open List
open import Data.List.Properties
open import Data.Product
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Relation.Nullary.Product
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
private variable A : Set
@gallais
gallais / linear.agda
Last active March 26, 2019 21:57
Raw linear terms
open import Data.Nat.Base
open import Data.Vec
open import Data.Bool.Base using (Bool; false; true)
open import Data.Product
variable
m n : ℕ
b : Bool
Γ Δ Ξ T I O : Vec Bool n
open import Size
open import Codata.Thunk
data BinaryTreePath (i : Size) : Set where
here : BinaryTreePath i
branchL : Thunk BinaryTreePath i → BinaryTreePath i
branchR : Thunk BinaryTreePath i → BinaryTreePath i
zero : ∀ {i} → BinaryTreePath i
zero = branchL λ where .force → zero
@gallais
gallais / scopecheck.agda
Created March 19, 2019 11:33
Crash course in scope checking
module scope where
import Level as L
open import Data.Nat.Base
open import Data.Vec hiding (_>>=_)
open import Data.Fin.Base
open import Data.String
open import Data.Maybe as Maybe
open import Data.Product as Prod
open import Relation.Nullary
@gallais
gallais / filter.agda
Created March 3, 2019 20:49
Fully certified filter
open import Level
open import Data.List.Base hiding (filter)
open import Data.List.Relation.Unary.All
open import Data.List.Relation.Ternary.Interleaving.Propositional
open import Function
open import Relation.Nullary
open import Relation.Unary
module _ {a} {A : Set a} where
@gallais
gallais / ViewExample.agda
Last active February 13, 2019 14:19
Using a View makes proving easier
open import Relation.Nullary
open import Agda.Builtin.Equality
data X : Set where
a b c : X
firstA : (x y z : X) → X
firstA a y z = a
firstA x a z = a
firstA x y a = a
module Container
%default total
record Container where
constructor MkContainer
shape : Type
position : shape -> Type
container : Container -> Type -> Type