0

We've been trying out some AGDA by basically playing parts of the natural number from Lean in AGDA. However, for inequalities we came across an error that was not present in the Lean solution to this problem.

This is the code:

module minimalExample where

open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
open import Agda.Builtin.Sigma

-- x ≤ x + 1
data _leq_ {x : Nat} {y : Nat} : Nat -> Nat -> Set where
    leqpr : (k : Nat) -> x + k ≡ y -> x leq y

leqSuccOfLeq : {x y : Nat} -> x leq y -> x leq (suc y)
leqSuccOfLeq ineq = leqpr {! ineq !} {!   !}

If we try and case-split on the variable ineq we get the following error:

Unbound variable i when checking that the expression ? has type Nat

We assume there is something wrong with our definition, but we don't know what. We already tried a definition using a $\Sigma$ as well, but that didn't fix the problem. Also, we are aware that it is more common to define this definition inductively, but made this an exercise where this is specifically not the case.

Does anyone know how to fix this?

EDIT: The mistake gallais highlighted was the essential mistake, however the error on unbounded variables still occurred on an automatic case split. But hard-coding the case split resolved that problem.

Emiel Lanckriet
  • 95
  • 2
  • 12
  • I'm not getting the error on the interactive case split. This is very strange. Do you still get it if you rename `ineq` to `i` (i.e. is doom emacs truncating the name of the variable to just 1 character when sending the interactive command?) – gallais Feb 26 '21 at 22:48
  • I will check, however we are working in VSCode, that might also cause the problem. – Emiel Lanckriet Feb 27 '21 at 09:52

1 Answers1

3
data _leq_ {x : Nat} {y : Nat} : Nat -> Nat -> Set where
    leqpr : (k : Nat) -> x + k ≡ y -> x leq y

defines a family with 2 implicit parameters (x & y) and two explicit indices (that are set to x & y respectively in the leqpr constructor's return type).

You probably meant to write:

data _leq_ (x y : Nat) : Set where
    leqpr : (k : Nat) -> x + k ≡ y -> x leq y
gallais
  • 11,823
  • 2
  • 30
  • 63