Let's take the code and look at what happens along the way.

We are defining 2 sets

```
Set1 = sets:from_list("orchestra").
{set,8,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],"sc",[],[],[],"o","r","e","h",[],[],"a","t",[],[],[]}}}
```

and

```
Set2 = sets:from_list("carthorse").
{set,8,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],"sc",[],[],[],"o","r","e","h",[],[],"a","t",[],[],[]}}}
```

where the second lines represent the values created with a representation. So based on the above definition, we infer that the representation chosen for storing sets is of a tuple.

We can refer to the Term Comparison section of Erlang Reference manual which states that

`...Lists are compared element by element. Tuples are ordered by size, two tuples with the same size are compared element by element...`

Having that as an invariant, now lets look at the set which comes about after an `intersection`

```
Intersection = sets:intersection(Set1, Set2).
{set,8,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],"cs",[],[],[],"o","r","e","h",[],[],"a","t",[],[],[]}}}
```

Again, this being a set gets the same underlying representation of the tuple, but if we look at the last element, there is a string (essentially a list of characters in Erlang) `"cs"`

, which is different in value in the same place when we defined `Set1`

and `Set2`

. And hence the inequality as per the `Term Comparison`

.

Now, let's attempt to change the sub-value `"cs"`

inside `Intersection`

to `"sc"`

and then as per the `Term Comparison`

rules, two sets must satisfy equality.

```
Improvised_Intersection = setelement(9, Intersection, {setelement(2, element(1, element(9, Intersection)), "sc")}).
{set,8,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],"sc",[],[],[],"o","r","e","h",[],[],"a","t",[],[],[]}}}
```

And now let's compare `Improvised_Intersection`

with `Set1`

and `Set2`

, which gives

```
Improvised_Intersection =:= Set1.
true
Improvised_Intersection =:= Set2.
true
Intersection =:= Improvised_Intersection.
false
```

It's just an attempt to provide some insight into what already @Richard and others have pointed out.