union TwoList<K, V> {
nil
vnode(V, TwoList)
knode(K, TwoList)
}
postulate tl_induction : all T: type, E : type.
all P : fn TwoList<T, E> -> bool.
if P(nil) and (all k : T, tl : TwoList<T, E>. if P(tl) then P(knode(k, tl)))
then all x : TwoList<T, E>. P(x)
I ran into this while working on induction stuff, ignore the weird theorem, the error is
Exception: /home/calvin/Documents/Programming/343/deduce/blah.pf:38.75-38.77: expected a term of type TwoList
but got term tl of type TwoList<T,E>
in context of call knode(k, tl)
function type: (fn <K,V> K, TwoList -> TwoList<K,V>)
inferred type arguments: K := T, V := E
The solution of course is to change the TwoList in the union declaration to TwoList<K, V>. Maybe it is important to have the ability to not instantiate types, but I would hazard a guess that this shouldn't be allowed. If so we should probably catch this error at the union declaration instead of when typechecking theorems.
It's also possible to do stuff where we swap the order of type parameters, making it impossible(?) to create a recursive function on the union.
union TwoList<K, V> {
nil
vnode(V, TwoList<V, K>)
knode(K, TwoList<K, V>)
}
Again I'm not sure if we should do something about this.
I ran into this while working on induction stuff, ignore the weird theorem, the error is
The solution of course is to change the
TwoListin theuniondeclaration toTwoList<K, V>. Maybe it is important to have the ability to not instantiate types, but I would hazard a guess that this shouldn't be allowed. If so we should probably catch this error at the union declaration instead of when typechecking theorems.It's also possible to do stuff where we swap the order of type parameters, making it impossible(?) to create a recursive function on the union.
Again I'm not sure if we should do something about this.