|
HI: When I read "scala language specification", I saw "skolemization" and "type packing" in the following three sections: http://scala-lang.org/files/archive/spec/2.11/03-types.html#existential-types http://scala-lang.org/files/archive/spec/2.11/03-types.html#conformance http://scala-lang.org/files/archive/spec/2.11/06-expressions.html#expression-typing What does them mean? I found in the https://en.wikipedia.org/wiki/Skolem_normal_form , which says: ..................... s an example, the formula [image: \forall x \exists y \forall z. P(x,y,z)] is not in Skolem normal form because it contains the existential quantifier [image: \exists y]. Skolemization replaces [image: y] with [image: f(x)], where [image: f] is a new function symbol, and removes the quantification over [image: y]. The resulting formula is [image: \forall x \forall z . P(x,f(x),z)]. The Skolem term [image: f(x)] contains [image: x], but not [image: z], because the quantifier to be removed [image: \exists y] is in the scope of [image: \forall x], but not in that of [image: \forall z]; ..................... I can understand the above words, but I still do not catch the things in "scala language specificaton". Something I found that written by Martin is as follow, which I do not understand: https://groups.google.com/forum/#!msg/scala-internals/0j8laVNTQsI/kRXMF_c8bGsJ ..................... Skolems are indeed synthetic type "constants" that are copies of existentially bound or universally bound type variables. E.g. if you are in the rhs a method def foo[T](x: T) = ... foo[List[T]].... the skolem named T refers to the unknown type instance of T when foo is called. It needs to be different from the type parameter because in a recursive call as in the foo[List[T]] above the type parameter gets substituted with List[T], but the type skolem stays what it is. The other form of skolem is an existential skolem. Say you have a function def bar(xs: List[T] forSome { type T }) = xs.head the each occurrence of xs on the right will give have type List[T'] where T' is a fresh copy of T. That's what we call an existential skolem. Hope this helps! - Martin ..................... Could someone give a talk? Many Thanks. You received this message because you are subscribed to the Google Groups "scala-internals" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout. asked Mar 7 2016 at 07:26 |