Reputation: 205
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 :
∀ {a} {A : Set a} {n} (todos : Vec Todo n) (text : String) →
last (AddTodo todos text) ≡
record
{ id = 1
; completed = false
; text = text
}
AddTodoLastAddedElementIsTodo todos text = vecLast todos
and
vecLast : ∀ {a} {A : Set a} {l n} (xs : Vec A n) → last (xs ∷ʳ l) ≡ l
vecLast [] = refl
vecLast (_ ∷ xs) = P.trans (prop (xs ∷ʳ _)) (vecLast xs)
where
prop : ∀ {a} {A : Set a} {n x} (xs : Vec A (suc n)) → last (x ∷ xs) ≡ last xs
prop xs with initLast xs
... | _ , _ , refl = refl
I tried using rewrite
and got:
AddTodoSetsNewCompletedToFalse :
∀ {a} {A : Set a} {n} (todos : Vec Todo n) (text : String) →
Todo.completed (last (AddTodo todos text)) ≡ false
AddTodoSetsNewCompletedToFalse todos text rewrite AddTodoLastAddedElementIsTodo todos text = refl
but the error:
_a_100 : Agda.Primitive.Level
showed up.
I'm not sure how to resolve this. from here I understand that this is related to the implicit argument. But not sure how to fix it
This sort of error indicates an unsolved metavariable, which means that Agda has failed to infer an implicit argument
Thanks!
Upvotes: 0
Views: 124
Reputation: 27636
You do not use A
for anything in the type of AddTodoSetsNewCompletedToFalse
. Also, that is not an error, but an unsolved meta.
So what happens is that wherever you use AddTodoSetsNewCompletedToFalse
, nothing in the arguments or the result type constrains the choice of A
(and, subsequently, a
) so the unifier has no way of solving these metavariables. You can make explicit what happens by writing AddTodoSetsNewCompletedToFalse {a = _} {A = _}
and observing that these two metas are unsolved.
You should simply remove the first two parameters (a
and A
) from AddTodoSetsNewCompletedToFalse
's type.
Upvotes: 0