agda

How to deal with Agda not being sure in whether to generate constructor case in the `with` statement?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 07:20:11
问题 I have the following code: open import Data.Nat open import Agda.Builtin.Char open import Data.Maybe digit' : ℕ → Maybe ℕ digit' n with compare n (primCharToNat '9') ... | greater _ _ = nothing ... | _ = ? digit : Char → Maybe ℕ digit c = digit' (primCharToNat c) Unfortunately, Agda "load file" command in emacs fails with the following message: tmp.agda:7,1-8,12 I'm not sure if there should be a case for the constructor less, because I get stuck when trying to solve the following unification

What is a valid type signature for the `Any-∃` exercise?

∥☆過路亽.° 提交于 2019-12-11 06:36:21
问题 #### Exercise `Any-∃` Show that `Any P xs` is isomorphic to `∃[ x ∈ xs ] P x`. Leaving aside the fact that ∃[ x ∈ xs ] P x is not even valid syntax - only Σ[ x ∈ xs ] P x could be valid, none of the type signatures I've tried typecheck for that particular problem. Any-∃ : ∀ {A : Set} {P : A → Set} {xs : List A} → Any P xs ≃ Σ[ x ∈ xs ] P x List A !=< Set _a_1582 of type Set when checking that the expression xs has type Set _a_1582 The most obvious thing here fails. I sort of understand what

Appropriate use of universe polymorphism

假如想象 提交于 2019-12-11 06:29:42
问题 I've been working for a couple of weeks on an Agda project, glibly ignoring level polymorphism as much as I can. Unfortunately (or perhaps fortunately) I seem to have reached the point where I need to start understanding it. Until now I've been using level variables only when they are needed as a second argument to Rel (or third argument to REL ). Otherwise I have omitted them, just using Set directly. Now I have some client code that explicitly quantifies over levels a and tries to pass some

Is there an element-in-list datatype defined in the standard library?

我与影子孤独终老i 提交于 2019-12-11 05:56:28
问题 data _[_]=_ {A : Set a} : ∀ {n} → Vec A n → Fin n → A → Set a where here : ∀ {n} {x} {xs : Vec A n} → x ∷ xs [ zero ]= x there : ∀ {n} {i} {x y} {xs : Vec A n} (xs[i]=x : xs [ i ]= x) → y ∷ xs [ suc i ]= x This is for Vec , but I can't find an analogous one for List . 回答1: It is available in a more generic form in Data.List.Relation.Unary.Any . Here is how it is defined. data Any {A : Set a} (P : Pred A p) : Pred (List A) (a ⊔ p) where here : ∀ {x xs} (px : P x) → Any P (x ∷ xs) there : ∀ {x

Constructing a path with constraints in an isSet type

狂风中的少年 提交于 2019-12-11 05:22:19
问题 I am trying to write a proof for an equality in results of a function with a HIT domain. Because the function is defined over a HIT, the proof of equality also has to handle path cases. In those cases, Agda reports a ton of constraints on the higher-dimensional path I'm required to construct; for example: Goal: fromList (toList m) ≡ εˡ m i ———————————————————————————————————————————————————————————— i : I m : FreeMonoid A AIsSet : isSet A A : Type ℓ ℓ : Level ———— Constraints ————————————————

What is the proper way to represent a beta-equality type for λ-terms?

别等时光非礼了梦想. 提交于 2019-12-11 04:17:31
问题 I'm looking for a BetaEq type indexed on a : Term , b : Term , that can be inhabited iff a and b are identical, or if they can be turned into identical terms after a series of beta-reductions. For example, suppose id = (lam (var 0)) , a = (app id (app id id)) and b = (app (app id id) id) ; then we should be able to construct a term of type BetaEq a b , because both sides can be reduced to (app id id) . I've attempted this: data BetaEq : (a : Term) -> (b : Term) -> Set where refl : (a : Term)

Accessing element from Stream in agda

对着背影说爱祢 提交于 2019-12-11 03:52:55
问题 I have made a stream of (N x N) type. How can i access the individual element of the pair ?? genL : ℕ → Stream (ℕ × ℕ) → Stream (ℕ × ℕ) genL k ((x , y) :: xs) = if ((y * k) lt x) then (x , y) :: (♯ genL k (♭ xs)) else genL k (♭ xs) It says there is no constuctor , in stream. I have one solution in mind that i will create records of pair then it will works. Apart from that is there any other way to acccess the element. 回答1: The constructor is _∷_ (type \:: to get ∷ ), not _::_ . Anyway your

How does agda's inspect function work?

半世苍凉 提交于 2019-12-11 02:58:03
问题 I've seen an example of the inspect function in my last question Using the value of a computed function for a proof in agda , but I'm still having trouble wrapping my head around that. Here's a simple example: Given the function crazy , crazy : ℕ -> ℕ crazy 0 = 10 crazy 1 = 0 crazy 2 = 0 crazy 3 = 1 crazy 4 = 0 crazy xxx = xxx I want to create a safe function such that safe : {nn : ℕ} -> (id nn) ≢ 0 -> Fin (id nn) . In other words it will return one number mod crazy, if you give it a proof

Map with Strings as Keys in Agda?

谁说我不能喝 提交于 2019-12-11 02:31:46
问题 I'm having some trouble figuring out how to properly make a Map with String keys in Agda. I've got the following: import Data.AVL.IndexedMap Var = String data Type where -- ... alwaysType : Var -> Set alwaysType _ = Type open Data.AVL.IndexedMap alwaysType (StrictTotalOrder.isStrictTotalOrder Data.String.strictTotalOrder) This gives the error: String != Σ String _Key_90 of type Set when checking that the expression StrictTotalOrder.isStrictTotalOrder strictTotalOrder has type Relation.Binary

Using subst in an application would screw up type of the result

﹥>﹥吖頭↗ 提交于 2019-12-10 23:55:56
问题 I have a definition with the following type: insert : ∀ {n} → (i : Fin (suc n)) → ∀ t → Env n → Env (suc n) weaken : ∀ {t t₀ n} {Γ : Env n} → (i : Fin (suc n)) → (e : Γ ⊢ t₀) → (insert i t Γ) ⊢ t₀ Given two environments Γ : Env n and Γ′ : Env n′ , and a pointer to a position in the second one, i : Fin (suc n) , I would like to weaken an e : (Γ′ ++ Γ) ⊢ t₀ . In theory, this should be easy by using something like let i′ = raise n′ i weaken {t} i′ e : insert i′ t (Γ′ ++ Γ) ⊢ t₀ However, in