Issue3027.agda 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. open import Agda.Builtin.Nat
  2. open import Agda.Builtin.Bool
  3. open import Agda.Builtin.Equality
  4. F : Bool → Set
  5. F false = Bool
  6. F true = Nat
  7. f : ∀ b → F b → Nat
  8. f false false = 0
  9. f false true = 1
  10. f true x = 2
  11. data D : Nat → Set where
  12. mkD : (b : Bool) (x : F b) → D (f b x)
  13. mutual
  14. ?X : Nat → Set
  15. ?X = _
  16. ?b : Nat → Bool
  17. ?b = _
  18. -- Here we should check
  19. -- (n : Nat) → ?X n == (x : F (?b 0)) → D (f (?b 0) x)
  20. -- and get stuck on comparing the domains, but special inference
  21. -- for constructors is overeager and compares the target types,
  22. -- solving
  23. -- ?X : Nat → Set
  24. -- ?X x := D (f (?b 0) x)
  25. -- Note that the call to f is not well-typed unless we solve the
  26. -- (as yet unsolved) constraint Nat == F (?b 0).
  27. constr₁ : (n : Nat) → ?X n
  28. constr₁ = mkD (?b 0)
  29. -- Now we can form other constraints on ?X. This one simplifies to
  30. -- f (?b 0) 1 ≡ 0 (*)
  31. constr₂ : ?X 1 ≡ D 0
  32. constr₂ = refl
  33. -- Finally, we pick the wrong solution for ?b, causing (*) to become
  34. -- f false 1 ≡ 0
  35. -- which crashes with an impossible when we try to reduce the call to f.
  36. solve-b : ?b ≡ λ _ → false
  37. solve-b = refl