The below smt2 code gives an error related to type.
( declare-datatypes ( ( List 1 ) )
( ( par ( T ) ( ( cons ( hd T ) ( tl ( List T ) ) )
( nil )
) )
) )
(declare-sort Ty 0)
(define-fun-rec func ((x (List Ty) ) (y (List Ty))) (List Ty)
(match x ( ((cons xt xts) ( cons xt (func xts y)) )
( nil nil )
)
)
)
ERROR:
(error "Both branches of the ITE must be a subtype of a common type.
then branch: ((lambda ((xt Ty) (xts (List Ty))) (cons xt (func xts y))) (hd x) (tl x))
its type : (List Ty)
else branch: nil
its type : (List T)
")
Why doesn't it figure out using the return type and is there any way to do that ?
One way is to have manually put it as (nil (as nil (List Ty)) )
which solves the error But I don't want to specify the return types at every nil in the program.
Is there any other way ? or any option that I need to mention enable ?