Skip to content

Subtyping is not reflexive and not transitive with triangular rule #24166

@julbinb

Description

@julbinb

In julia 0.6.0 subtyping is not reflexive for some examples.

julia> (Tuple{T, T} where Int<:T<:Int) <: (Tuple{T, T} where Int<:T<:Int)
false

julia> (Tuple{T, T} where T>:Int) <: (Tuple{T, T} where T>:Int)
false

It seems to me that there is a problem with lower bounds in triangular dispatched cases, because these examples work fine:

julia> (Tuple{T, T} where T>:Number) <: (Tuple{T, T} where T>:Number)
true

julia> (Tuple{T, T} where T<:Int) <: (Tuple{T, T} where T<:Int)
true

Also, transitivity is broken:

julia> T1 = Tuple{Number, Number, Ref{Number}}
Tuple{Number,Number,Ref{Number}}

julia> T2 = Tuple{T, T, Ref{T}} where T
Tuple{T,T,Ref{T}} where T

julia> T3 = Tuple{S, S, Ref{Q} where Q} where S
Tuple{S,S,Ref{Q} where Q} where S

julia> T1 <: T2
true

julia> T2 <: T3
true

julia> T1 <: T3
false

Although, to my understanding, T1 <: T2 == true and T1 <: T3 == false are correct, but T2 <: T3 == true is not. So it's not really transitivity, but rather some problem with T2 on the left.

Finally, this looks weird:

julia> (Tuple{T, T} where Number<:T<:Number) <: Tuple{Number, Number}
true

julia> Tuple{Number, Number} <: (Tuple{T, T} where Number<:T<:Number)
true

julia> Vector{Tuple{T, T} where Number<:T<:Number} <: Vector{Tuple{Number, Number}}
false

I don't see why vectors should not be in subtype relation.

Here is the version info:

Julia Version 0.6.0
Commit 903644385b (2017-06-19 13:05 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

@JeffBezanson

Metadata

Metadata

Assignees

Labels

types and dispatchTypes, subtyping and method dispatch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions