Questions tagged [transitivity]
34 questions
42
votes
3 answers
JavaScript equality transitivity is weird
I've been reading Douglas Crockford's JavaScript: The Good Parts, and I came across this weird example that doesn't make sense to me:
'' == '0' // false
0 == '' // true
0 == '0' // true
false == undefined //…

Hristo
- 45,559
- 65
- 163
- 230
11
votes
3 answers
Is the JavaScript operator === provably transitive?
JavaScript's quirky weakly-typed == operator can easily be shown to be non-transitive as follows:
var a = "16";
var b = 16;
var c = "0x10";
alert(a == b && b == c && a != c); // alerts true
I wonder if there are any similar tricks one can play with…

Ray Toal
- 86,166
- 18
- 182
- 232
8
votes
2 answers
Is there any implementation of Python2 where ordering is transitive?
Is there any existing implementation of Python2 where ordering is transitive? That is, where it's impossible to see this behaviour without creating user-defined types:
>>> x < y < z < x
True
CPython is not transitive because of this…

wim
- 338,267
- 99
- 616
- 750
7
votes
1 answer
Sorting algorithm for inconsistent (non-transitive) human preferences
Suppose I have a file with a one-liner (joke) on each line. I want to sort the jokes by how funny I find them. My first thought is to implement any sorting algorithm (preferably one that makes as few comparisons as possible) and having the…

nebuch
- 6,475
- 4
- 20
- 39
7
votes
4 answers
Why is it allowed in C++ to modify a constant object's pointer member variable's memory from outside?
I've been trying to understand when I write a function in C++ with a constant argument and a pointer variable inside of that object than the const flag is not protecting the underlying memory against modifications.
For example it's perfectly legal…

Kristof01
- 71
- 1
- 3
6
votes
2 answers
Coq: apply transitivity with substitution
I want to proof this lemma in Coq:
a : Type
b : Type
f : a -> b
g : a -> b
h : a -> b
______________________________________(1/1)
(forall x : a, f x = g x) ->
(forall x : a, g x = h x) -> forall x : a, f x = h x
I know that…

SvenK
- 2,584
- 2
- 21
- 24
5
votes
2 answers
How to write a transitive comparator when "equality" implies "order doesn't matter"?
I have a set of items that are serialized to a file. Some items can rely on other items, but circular references are not allowed. Thus, they need to be serialized in a way such that if A relies on B, B is serialized first in the file.
I wrote my…

Craig Otis
- 31,257
- 32
- 136
- 234
4
votes
1 answer
Why does floor lose precision, and how is it affecting transitivity of equality?
I begin by defining a large integer n:
Prelude> let n = 5705979550618670446308578858542675373983
Prelude> n :: Integer
5705979550618670446308578858542675373983
Next I looked at the behavior of s1 and s2:
Prelude> let s1 = (sqrt (fromIntegral…

Rob
- 5,223
- 5
- 41
- 62
2
votes
5 answers
Is Inequality Transitive in Java?
If I have 3 objects a, b, and c, and I want to check that none of them are equal to each other, I need to check:
if (!a.equals(b) && !b.equals(c) && !a.equals(c)) { // to simplify, assume non-null
// do something
}
According to the Java docs,…

luketorjussen
- 3,156
- 1
- 21
- 38
2
votes
2 answers
Inconsistent Local Transitivity Output in igraph
I need to determine the transitivity for each node in a network, but am getting inconsistent results.
set.seed(123)
a <- rbinom(144, 1, .5)
b <- graph.adjacency(matrix(a, nrow = 12, ncol = 12), mode = "undirected")
transitivity(b, type =…

Gary DeYoung
- 106
- 7
2
votes
1 answer
SQL Server Query to find min date based on transitive relationship
Running into a bit of a headache with this one query and some hints/suggestions would be greatly appreciated. I couldn't find anything really related to my problem -I found some stuff on transitive closures which isn't quite what I need since my…

Wilsonia
- 37
- 5
2
votes
1 answer
Unnecessary predicate definition for simple transitivity checkup?
For the given facts:
trust_direct(p1, p2).
trust_direct(p1, p3).
trust_direct(p2, p4).
trust_direct(p2, p5).
trust_direct(p5, p6).
trust_direct(p6, p7).
trust_direct(p7, p8).
trust_direct(p100, p200).
This solution:
trusts(A, B) :-
…

daniel451
- 10,626
- 19
- 67
- 125
2
votes
1 answer
Sort array based on binary comparisons while minimizing intransitive trials
I have a list of 15 cities. I randomly draw 70 pairs out of the possible 15*14/2=105 pairs of cities. For each of the 70 pairs, I ask my participants to decide whether city A is bigger than city B.
The important thing is, sometimes participants…

elisa
- 965
- 9
- 27
2
votes
2 answers
python transitivity between dictionaries
I have a list like the following in python (the real one is huge and I cannot do this only by looking at it):
original1=[['email', 'tel', 'fecha', 'descripcion', 'categ'],
['a@gmail.com', '1', '2014-08-06 00:00:06', 'MySpace a',…

GabyLP
- 3,649
- 7
- 45
- 66
2
votes
4 answers
Are Active Directory forest trusts transitive?
I'm working on trouble shooting an application under development that uses information from Active Directory in a multi-forest environment and I have the current problem down to figuring out if forest trusts are transitive, and if so under what…

DrStalker
- 9,061
- 17
- 43
- 47