-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test/Bugs: an function that is recognized as size preserving but shou…
…ld not
- Loading branch information
1 parent
0f7011c
commit 5e092eb
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |