agda / agda

Agda is a dependently typed programming language / interactive theorem prover.

Home Page:https://wiki.portal.chalmers.se/agda/pmwiki.php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TBT: do not count rhs `j : Size< i` towards `j < i` in termination

andreasabel opened this issue · comments

The syntax-based termination checker forbids T because it makes Agda loop.

{-# OPTIONS --type-based-termination #-}
{-# OPTIONS --sized-types #-}

module TypeBasedTermination.BoundedSizeNoMatch where

open import Agda.Builtin.Size
open import Agda.Builtin.Equality

-- The following should not termination check,
-- otherwise eta expansion can loop
T : Size  Set
T i = (j : Size< i)  T j

-- This loops:
loops : (i : Size) (x y : T i)  x ≡ y
loops i x y = refl

TBT currently accepts T which sends the type-checker into infinite eta-expansion for loops.

Type-based termination is clueless about the original sized types. The problem here was that I did not run size checking for Pi types, which resulted in ignoring a recursive call.