Termination check on unionWith

后端 未结 2 842
醉话见心
醉话见心 2021-01-24 06:51

I\'m having a problem with termination checking, very similar to the one described in this question and also this Agda bug report/feature request.

The problem is convinc

2条回答
  •  有刺的猬
    2021-01-24 07:39

    It seems the first solution proposed for the earlier list-merge question does indeed work here, but only under Agda version 2.3.3+. Here's the full version, with a slightly nicer syntax for ∷.

    data FiniteMap (l : Key) : Set (k ⊔ v ⊔ ℓ) where
       [] : FiniteMap l
       _∷[_]_ : (kv : KV) → let k = proj₁ kv in l < k → (m : FiniteMap k) → FiniteMap l
    
    -- Split into two definitions to help the termination checker.
    unionWith : ∀ {l} → Op₂ Value → Op₂ (FiniteMap l)
    unionWith′ : ∀ {l} → Op₂ Value → (kv : KV) → let k = proj₁ kv in l < k → FiniteMap k → Op₁ (FiniteMap l)
    
    unionWith _ [] [] = []
    unionWith _ [] m = m
    unionWith _ m [] = m
    unionWith _⊕_ ((k , v) ∷[ k _ _ k′ _ _ k′

提交回复
热议问题