Questions tagged [agda]

Agda is a dependently typed, total functional programming language and a proof assistant.

Agda is a dependently typed functional programming language. It has inductive families, i.e., data types which depend on values, such as the type of vectors of a given length. It also has parametrised modules, mixfix operators, Unicode characters, and an interactive Emacs interface which can assist the programmer in writing the program.

Agda is a proof assistant. It is an interactive system for writing and checking proofs. Agda is based on intuitionistic type theory, a foundational system for constructive mathematics developed by the Swedish logician Per Martin-Löf. It has many similarities with other proof assistants based on dependent types, such as Coq, Epigram, Matita and NuPRL.

The current version is 2.6.1.1

Useful links

819 questions
0
votes
1 answer

Agda stdlib Vec calling last after doing fromList on a List

I have the following function: natListLast : List ℕ → ℕ natListLast nats = v.last (v.fromList nats) and I currently get this error: l.foldr (λ _ → suc) 0 nats != suc _n_126 of type ℕ when checking that the expression fromList nats has type Vec ℕ (1…
fsuna064
  • 195
  • 1
  • 7
0
votes
1 answer

Agda stdlib Vec fromList of list with arbitrary length

I'm trying to use Data.Vec fromList on a Data.List of arbitrary length: natListToVec : {n : ℕ} → List ℕ → Vec ℕ n natListToVec nats = v.fromList nats but get the error: l.foldr (λ _ → suc) 0 nats != n of type ℕ when checking that the expression…
fsuna064
  • 195
  • 1
  • 7
0
votes
1 answer

Agda stdlib List max

I'm trying to get the max element of a Data.List: listMax : max ℕ (2 ∷ 1 ∷ []) ≟ 2 listMax = ? but don't understand why I'm getting this error: Set !=< (Relation.Binary.Bundles.TotalOrder _b_20 _ℓ₁_21 _ℓ₂_22) when checking that the expression ℕ has…
fsuna064
  • 195
  • 1
  • 7
0
votes
1 answer

Agda Vec.filter gives a Vec≤, how do I go back to a Vec?

I noticed that the signature for Vec.filter is filter : ∀ {n} → Vec A n → Vec≤ A n In order to go back to a Vec can I only use padRight : ∀ {n} → A → Vec≤ A n → Vec A n or padLeft : ∀ {n} → A → Vec≤ A n → Vec A n ? Ideally I would like to get…
fsuna064
  • 195
  • 1
  • 7
0
votes
1 answer

Agda Vec how to filter out elements

Hi I think I don't understand well how to use Vec.filter from Data/Vec.agda. I know how to "filter in" (keep) elements in the vector filterProof : v.filter (λ e → e ≟ 2) (2 v.∷ v.[]) ≡ (2 vb.∷ vb.[]) filterProof = refl however I'm not sure how to…
fsuna064
  • 195
  • 1
  • 7
0
votes
1 answer

Agda: rewrite subexpression

I'm trying to prove: AddTodoSetsNewCompletedToFalse : ∀ {n : ℕ} (todos : Vec Todo (1 + n)) (text : String) → Todo.completed (last (AddTodo todos text)) ≡ false AddTodoSetsNewCompletedToFalse todos text = ? where AddTodoLastAddedElementIsTodo…
fsuna064
  • 195
  • 1
  • 7
0
votes
1 answer

Agda: proof about `Vec` `last` using `with`

I'm trying to prove the following statement vecNat : ∀ {n} (xs : Vec ℕ n) → last (xs ∷ʳ 1) ≡ 1 But I get confused the (x ∷ xs) case. vecNat5 : ∀ {n} (xs : Vec ℕ n) → last (xs ∷ʳ 1) ≡ 1 vecNat5 [] = refl vecNat5 (x ∷ xs) = {! 0!} The goal…
fsuna064
  • 195
  • 1
  • 7
0
votes
1 answer

Agda: return the last element of a List

When I check in agda-stdlib/src/Data/List/Base.agda I see that there is no last function but I see in agda-stdlib/src/Data/Vec/Base.agda a function for last. When I try to use it though I get some type errors that I'm unsure I understand. This is…
fsuna064
  • 195
  • 1
  • 7
0
votes
1 answer

Opening the top-level module applied on arguments

I'd like to put the definition of a top-level Agda module and a local anonymous module using it in the same file. However, the top-level module has parameters, and I'd like to instantiate it in the second module. So basically I would like to do…
Cactus
  • 27,075
  • 9
  • 69
  • 149
0
votes
1 answer

How do I find further constraints than boundary conditions?

In the following Agda code, I have one hole with some potential filling; alas, the filling doesn't typecheck. It seems to fulfill all the constraints Agda shows, so I'd like to know where I could find what other, invisible constraints there are. {-#…
Cactus
  • 27,075
  • 9
  • 69
  • 149
0
votes
1 answer

Proving two dependent (AVL tree key-value) pairs equal

The standard library's AVL tree implementation uses dependent pairs to store key-value pairs. I have two such pairs whose keys (k and k′) I have shown to be equal (k≡k′). They also contain the same value (v). I'd like to prove that the pairs are…
123omnomnom
  • 294
  • 1
  • 10
0
votes
1 answer

Why does Agda reduce my function application for some arguments but not for others?

I am playing with joinˡ⁺ from the standard library's AVL tree implementation. This function is defined with six pattern matching clauses. When I apply the function to an argument, then Agda does or doesn't reduce my function application expression,…
123omnomnom
  • 294
  • 1
  • 10
0
votes
1 answer

Lifting a boolean statement to a proposition

Given a list, a "property" (a function to Bools), and a proof any f xs ≡ true, I want to get a value of Any (λ x → T (f x)) ns, i.e. I want a to convert a proof from any to a proof of Any. So far, I have been able to sketch the proof, but I am stuck…
helq
  • 1,451
  • 1
  • 9
  • 12
0
votes
1 answer

Why does `sym` need to be used in this case when using `rewriting`?

Given the Peano definition of natural numbers: data ℕ : Set where zero : ℕ suc : ℕ → ℕ _+_ : ℕ → ℕ → ℕ zero + n = n (suc m) + n = suc (m + n) We can prove by different methods the property ∀ (m : ℕ) → zero + m ≡ m + zero. For example: comm-+₀…
helq
  • 1,451
  • 1
  • 9
  • 12
0
votes
1 answer

`with f x` matches `false`, but cannot construct `f x == false`

A piece of code here: -- transitivity trans : {A : Set} {x y z : A} -> x == y -> y == z -> x == z trans refl refl = refl union-pair' : {A : Set} -> (m n : S {A}) -> (x : A) -> (ismember (set-union (set-pair m n)) x) ==…
Sassa NF
  • 5,306
  • 15
  • 22