Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View gallais's full-sized avatar

G. Allais gallais

View GitHub Profile
@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
open import Relation.Binary
module Reasoning {a ℓ₁ ℓ₂ ℓ₃} {A : Set a}
{_≈_ : Rel A ℓ₁} (≈-trans : Transitive _≈_) (≈-sym : Symmetric _≈_) (≈-refl : Reflexive _≈_)
{_≤_ : Rel A ℓ₂} (≤-trans : Transitive _≤_) (≤-respˡ-≈ : _≤_ Respectsˡ _≈_) (≤-respʳ-≈ : _≤_ Respectsʳ _≈_) (≤-refl : Reflexive _≤_)
{_<_ : Rel A ℓ₃} (<-trans : Transitive _<_) (<-respˡ-≈ : _<_ Respectsˡ _≈_) (<-respʳ-≈ : _<_ Respectsʳ _≈_) (<⇒≤ : _<_ ⇒ _≤_)
(<-≤-trans : ∀ {x y z} → x < y → y ≤ z → x < z)
(≤-<-trans : ∀ {x y z} → x ≤ y → y < z → x < z)
where
module bins where
open import Size
open import Codata.Stream
open import Codata.Thunk
open import Data.List.Base as List using (List; _∷_; [])
open import Data.List.NonEmpty as List⁺ using (List⁺; _∷_; [_])
open import Function
open import Relation.Unary
@gallais
gallais / generic-injective.agda
Created September 29, 2018 04:28
Generic combinator for injectivity proofs.
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.HeterogeneousEquality
open import Data.Maybe
open import Function
cong⁻¹ : ∀ {A B : Set} {a a'} (f : A → Maybe B) →
(eq : a ≡ a') →
from-just (f a) ≅ from-just (f a')
cong⁻¹ {a = a} f refl = refl