I'll provide two programming examples twice. They are not about the "real"/physical world, as programming languages are abstractions invented by humans, but they illustrate the non-transitive property you want.
In the Smalltalk-80 programming language, every Class is an Object, but not every Object is a Class. This language has an intricate metaclass hierarchy (which you are invited to check in order to follow this explanation), which determines the following facts:
- 'Hello, world!' is an Object.
- Object is a Class.
- However, 'Hello, world!' is not a Class. (It is just an ordinary
non-class object.)
And also the following facts:
- String is an Object.
- Object is a Class.
- String is a Class.
Explanation:
String is a direct instance of String class, which extends Object class, which extends Class, which extends ClassDescription, which extends Behavior, which extends Object. Therefore, String is an (indirect) instance of Object.
Object is a direct instance of Object class, which extends Class. Therefore, Object is an (indirect) instance of Class.
(Reiterating part of the initial bullet point:) String is a direct instance of String class, which extends Object class, which extends Class. Therefore, String is an (indirect) instance of Class.
Regarding the 'Hello, world!' string:
'Hello, world!' is a direct instance of String, which extends Object. Therefore, 'Hello, world!' is an (indirect) instance of Object.
However, 'Hello, world!' is not an (indirect) instance of Class, as Object does not extend Class.
In the Java programming language, the facts are similar. Only the explanation differs as Java has a much simpler metaclass hierarchy:
String is a direct instance of Class, which extends Object. Therefore, String is an (indirect) instance of Object.
Object is a direct instance of Class.
(Reiterating part of the initial bullet point:) String is a direct instance of Class.
Regarding the "Hello, world!" string in Java, the explanation is identical to the one provided for the 'Hello, world!' string in Smalltalk-80.
All these facts can be made visible by running the following Java source code:
//https://replit.com/languages/java10
public class Main {
public static void main(String args[]) {
System.out.println("Hello, world!");
System.out.println("\"Hello, world!\" is a direct instance of: " + "Hello, world!".getClass());
//System.out.println("\"Hello, world!\" extends: " + "Hello, world!".getSuperclass()); //uncommenting it fails: "Hello, world!" is not a class
System.out.println("String extends: " + String.class.getSuperclass());
System.out.println("Is \"Hello, world!\" an (indirect) instance of Object? " + ("Hello, world!" instanceof Object));
System.out.println("String is a direct instance of: " + String.class.getClass());
System.out.println("Class is a direct instance of: " + Class.class.getClass());
System.out.println("Class extends: " + Class.class.getSuperclass());
System.out.println("Is String an (indirect) instance of Object? " + (String.class instanceof Object));
System.out.println("Is Class an (indirect) instance of Object? " + (Class.class instanceof Object));
System.out.println("Object is a direct instance of: " + Object.class.getClass());
System.out.println("Is Object an (indirect) instance of Object? " + (Object.class instanceof Object));
System.out.println("Object extends: " + Object.class.getSuperclass());
}
}
Output:
"Hello, world!" is a direct instance of: class java.lang.String
String extends: class java.lang.Object
Is "Hello, world!" an (indirect) instance of Object? true
String is a direct instance of: class java.lang.Class
Class is a direct instance of: class java.lang.Class
Class extends: class java.lang.Object
Is String an (indirect) instance of Object? true
Is Class an (indirect) instance of Object? true
Object is a direct instance of: class java.lang.Class
Is Object an (indirect) instance of Object? true
Object extends: null