open import Paths
open import Logic::HLevels

open data SetTrunc (A : Type)
| inj A
| trunc : isSet (SetTrunc A)

variable A B : Type

// TODO: improve the termination checker so that it unfolds unrecursive calls generate unfolded lambdas properly
def rec (AB) (isSet B) (SetTrunc A) : B
| f, x, inj af a
| f, x, trunc a b p q i jx (rec f x a) (rec f x b) (\ krec f x (p k)) (\ krec f x (q k)) i j