Consider the following set of modules:
---- MODULE M3 ----
EXTENDS Sequences, Naturals
CCC == 99
ExprM3 == 43 + CCC
====
---- MODULE M2 ----
H1 == INSTANCE M3
====
---- MODULE Main ----
EXTENDS Naturals
VARIABLE x
H == INSTANCE M2
Init == x = H!H1!ExprM3
Next == x' = x
====
Based on my understanding of instantiation semantics (from Chapter 17 of Specifying Systems, "The Meaning of a Module"), the H == INSTANCE M2 definition in the Main module will import into Main all definitions from M2 but prefixed with H!. This will (transitively) include all definitions from M3 prefixed with H1! (i.e. the definitions from M3 will be prefixed by H!H1!).
So, in Main, the expression H!H1!ExprM3 would then refer, syntactically, to the expression
43 + CCC
This seems problematic, though, since CCC is not actually a definition that appears in the context of Main by the basic instantiation rules.
Is there some detail about instantiation semantics I am missing here? Intuitively, it seems as if CCC in the case above should in some sense be evaluated "in the context of" M3 (i.e. where CCC is a well defined expression), but I am trying to reconcile this with the basic instantiation rules as I understand them.