agda

Are there examples Agda code running in production? [closed]

不想你离开。 提交于 2019-12-06 16:32:18
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Agda is a nice programming language to explore dependent types and play around with intuitionistic type theory and to experiment with

An agda proposition used in the type — what does it mean?

China☆狼群 提交于 2019-12-06 13:24:19
I am taking this from the "Brutal Introduction to Agda" http://oxij.org/note/BrutalDepTypes/ Suppose we want to define division by two on even numbers. We can do this as: div : (n : N) -> even n -> N div zero p = zero div (succ (succ n)) p= succ (div n p) div (succ zero) () N is the natural numbers and even is the following "proposition" even : N -> Set even zero = \top even (succ zero) = \bot even (succ (succ n)) = even n data \bot : Set where record \top : Set where When you evaluate the expression div (succ (succ zero)) You get \p -> succ zero Which is what you expect. However, what I don't

How can i change working of forall in agda?

人走茶凉 提交于 2019-12-06 09:11:40
I am working with pair of Stream of rationals, Lets say (L,R) Where L and R are Stream of rationals. There are 3 conditions which L and R both have to satisfy to say it is valid. I have written the code as.. isCut_ : cut → Set isCut x = (p q : pair ) → if((((p mem (getLC x)) ∨ (p mem (getRC x)))) ∧ ((not (p mem getLC x)) ∨ (not (p mem getRC x))) ∧ (not (p <pair q) ∨ ((p mem getLC x) ∨ (q mem getRC x))))then ⊤ else ⊥ I really wanted to change the return type of this function to Bool. Here cut means (L, R) and mem is membership. The problem coming from forall p q which expect return type to be

Instance search limitations

我与影子孤独终老i 提交于 2019-12-06 07:28:57
The instance arguments machinery is described in an old paper and at the Agda wiki . Are there some notable facts that these sources do not mention? What are limitations of instance search? Removing ambiguity If we typecheck this: open import Category.Functor open import Category.Monad open RawFunctor open RawMonad and run C-c C-w _<$>_ ( C-c C-w is "explain why a particular name in scope"), we get (after some cleaning) _<$>_ is in scope as * a record field Category.Functor.RawFunctor._<$>_ * a record field Category.Monad.RawMonad._._<$>_ I.e. _<$>_ is ambiguous, so it's cumbersome to use

Pattern match on specialised constructors

主宰稳场 提交于 2019-12-06 03:33:33
问题 I've been banging my head against a problem for a few days, but my Agda skills are not very strong. I am trying to write a function over an indexed data type which is defined only at a particular index. This is only possible for certain specialisations of the data constructors. I can't figure out how to define such a function. I've tried to reduce my problem to a smaller example. The setup involves lists of natural numbers, with a type for witnessing members of the list, and a function for

Self-representation and universes in OTT

送分小仙女□ 提交于 2019-12-06 02:19:59
The question is about Observational Type Theory . Consider this setting: data level : Set where # : ℕ -> level ω : level _⊔_ : level -> level -> level # α ⊔ # β = # (α ⊔ℕ β) _ ⊔ _ = ω _⊔ᵢ_ : level -> level -> level α ⊔ᵢ # 0 = # 0 α ⊔ᵢ β = α ⊔ β mutual Prop = Univ (# 0) Type = Univ ∘ # ∘ suc data Univ : level -> Set where bot : Prop top : Prop nat : Type 0 univ : ∀ α -> Type α σ≡ : ∀ {α β γ} -> α ⊔ β ≡ γ -> (A : Univ α) -> (⟦ A ⟧ -> Univ β) -> Univ γ π≡ : ∀ {α β γ} -> α ⊔ᵢ β ≡ γ -> (A : Univ α) -> (⟦ A ⟧ -> Univ β) -> Univ γ πᵤ : ∀ {α} -> (A : Univ α) {k : ⟦ A ⟧ -> level} -> (∀ x -> Univ (k x))

Monadic substitution under binders

喜夏-厌秋 提交于 2019-12-06 01:36:16
In the following Agda code, I have a term language based on de Bruijn indices. I can define substitution over terms in the usual de Bruijn indices way, using renaming to allow the substitution to proceed under a binder. module Temp where data Type : Set where unit : Type _⇾_ : Type → Type → Type -- A context is a snoc-list of types. data Cxt : Set where ε : Cxt _∷_ : Cxt → Type → Cxt -- Context membership. data _∈_ (τ : Type) : Cxt → Set where here : ∀ {Γ} → τ ∈ Γ ∷ τ there : ∀ {Γ τ′} → τ ∈ Γ → τ ∈ Γ ∷ τ′ infix 3 _∈_ data Term (Γ : Cxt) : Type → Set where var : ∀ {τ} → τ ∈ Γ → Term Γ τ 〈〉 :

Problems with instance arguments in Agda

人走茶凉 提交于 2019-12-05 21:58:15
I'm trying to follow the code for McBride's How to Keep Your Neighbours in Order , and can't understand why Agda (I'm using Agda 2.4.2.2) gives the following error message: Instance search can only be used to find elements in a named type when checking that the expression t has type .T for function _:-_ . The code is given bellow data Zero : Set where record One : Set where constructor <> data Two : Set where tt ff : Two So : Two -> Set So tt = One So ff = Zero record <<_>> (P : Set) : Set where constructor ! field {{ prf }} : P _=>_ : Set -> Set -> Set P => T = {{ p : P }} -> T infixr 3 _=>_

Termination-checking substitution via (monadic) join and fmap

杀马特。学长 韩版系。学妹 提交于 2019-12-05 21:30:59
I'm using sized types, and have a substitution function for typed terms which termination-checks if I give a definition directly, but not if I factor it via (monadic) join and fmap. {-# OPTIONS --sized-types #-} module Subst where open import Size To show the problem, it's enough to have unit and sums. I have data types of Trie and Term , and I use tries with a codomain of Term inside Term , as part of the elimination form for sums. data Type : Set where 𝟏 : Type _+_ : Type → Type → Type postulate Cxt : Set → Set -- Every value in the trie is typed in a context obtained by extending Γ. data

How to extract the second element of Sigma on the Calculus of Constructions?

老子叫甜甜 提交于 2019-12-05 20:48:36
问题 I'm attempting to do that as follows: λ (A : *) -> λ (B : (A -> *)) -> λ (t : (∀ (r : *) -> (∀ (x : a) -> (B x) -> r)) -> r) -> (t (B (t A (λ (x : A) -> λ (y : (B x)) -> x))) (λ (x : A) -> λ (y : (B x)) -> y)) Notice that, since the value returned by that function depends on a value inside the sigma itself, I need to extract that value. This code doesn't check, because, I believe, it fails to unify the type extracted from Sigma with the type inside it. Is there any workaround? 来源: https:/