Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in size preservation #2

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions test/Bugs/TBTShiftShouldNotBeSizePreserving.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{-# OPTIONS --type-based-termination #-}
-- {-# OPTIONS -v term.tbt:40 #-}

module _ where

data Nat : Set where
zero : Nat
suc : Nat → Nat

data Maybe (A : Set) : Set where
nothing : Maybe A
just : A → Maybe A

shift_case : Maybe Nat → Maybe Nat
shift_case nothing = nothing
shift_case (just zero) = nothing
shift_case (just (suc x)) = just x

-- Should not be size preserving
shift : (Nat → Maybe Nat) → (Nat → Maybe Nat)
shift f n = shift_case (f (suc n))

inc : Nat → Maybe Nat
inc n = just (suc n)

-- This is luckily not recognized as size preserving
shift_inc : Nat → Maybe Nat
shift_inc n = shift inc n

-- Should be rejected
test : Maybe Nat → Maybe Nat
test nothing = nothing
test (just zero) = nothing
test (just (suc n)) = test (shift inc n)

-- Don't normalize this!
diverge : Maybe Nat
diverge = test (just (suc zero))
Loading