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-typeshttp://scala-lang.org/files/archive/spec/2.11/03-types.html#conformancehttp://scala-lang.org/files/archive/spec/2.11/06-expressions.html#expression-typingWhat does them mean?
I found in the
https://en.wikipedia.org/wiki/Skolem_normal_form , which says:
.....................
s an example, the formula
is not in Skolem normal form because it contains the existential quantifier
. Skolemization replaces
with
, where
is a new function symbol, and removes the quantification over
. The resulting formula is
. The Skolem term
contains
, but not
, because the quantifier to be removed
is in the scope of
, but not in that of
; .....................
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.