Created
September 6, 2018 18:23
-
-
Save rntz/75ee7314a34e31d9e06ea7eb15fcfa2d to your computer and use it in GitHub Desktop.
some agda that obviously terminates, but not to agda
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
postulate | |
A : Set | |
_≤_ : A → A → Set | |
⊥ : A | |
_∨_ : A → A → A | |
id : ∀{a} → a ≤ a | |
_•_ : ∀{a b c} → a ≤ b → b ≤ c → a ≤ c | |
data Tree : Set where | |
empty : Tree | |
leaf : (x : A) -> Tree | |
node : (l r : Tree) -> Tree | |
data _⊑_ : Tree → Tree → Set where | |
tree• : ∀{a b c} → a ⊑ b → b ⊑ c → a ⊑ c | |
-- In my actual use case I'd add more constructors here, but just tree• | |
-- suffices to demonstrate the issue. | |
record Fun : Set where | |
field ap : Tree → A | |
field map : ∀{T U} → T ⊑ U → ap T ≤ ap U | |
open Fun | |
-- Consider the following definitions, or and Or. | |
or : Tree → A | |
or empty = ⊥ | |
or (leaf x) = x | |
or (node T U) = or T ∨ or U | |
Or : Fun | |
ap Or = or | |
map Or (tree• T≤U U≤V) = map Or T≤U • map Or U≤V | |
-- If I try to combine these into a single definition, termination checking | |
-- fails. Why? :( | |
Or' : Fun | |
ap Or' empty = ⊥ | |
ap Or' (leaf x) = x | |
ap Or' (node T U) = ap Or' T ∨ ap Or' U | |
map Or' (tree• T≤U U≤V) = map Or' T≤U • map Or' U≤V |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment