LateMetaVariableInstantiation.agda 960 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. module LateMetaVariableInstantiation where
  2. data ℕ : Set where
  3. zero : ℕ
  4. suc : (n : ℕ) → ℕ
  5. {-# BUILTIN NATURAL ℕ #-}
  6. postulate
  7. yippie : (A : Set) → A
  8. slow : (A : Set) → ℕ → A
  9. slow A zero = yippie A
  10. slow A (suc n) = slow _ n
  11. data _≡_ {A : Set} (x : A) : A → Set where
  12. refl : x ≡ x
  13. foo : slow ℕ 1000 ≡ yippie ℕ
  14. foo = refl
  15. -- Consider the function slow. Previously normalisation of slow n
  16. -- seemed to take time proportional to n². The reason was that, even
  17. -- though the meta-variable corresponding to the underscore was
  18. -- solved, the stored code still contained a meta-variable:
  19. -- slow A (suc n) = slow (_173 A n) n
  20. -- (For some value of 173.) The evaluation proceeded as follows:
  21. -- slow A 1000 =
  22. -- slow (_173 A 999) 999 =
  23. -- slow (_173 (_173 A 999) 998) 998 =
  24. -- ...
  25. -- Furthermore, in every iteration the Set argument was traversed, to
  26. -- see if there was any de Bruijn index to raise.