simplified and factorized some code (share term containers)
cleanup: check i>=0 for bvar/var in ScopedTerm, share a common fresh_var generator
WIP: typed prolog-like term for type inference