Open Jazzpirate opened 6 years ago
It's not specified yet how to handle structures or includes whose domains are nested theories.
Your example should not be well-typed at all. The structure inner would need a morphism Outer -> NestedTest2 in order to see Outer/Inner at all. How to provide that morphism is an open design question.
@florian-rabe that's unrelated. You can replace the include of ?NestedTest by an include of ?Outer, put it above the structure, giving you the morphism you want and it will still fail. The problem is that Elaboration attempts to apply the structure-morphism to a, which is not part of the flattened version of ?Inner.
Even with that include present, the behavior is not specified.
The behavior you expect in this case is reasonable, but an implementation has never been attempted.
Is there an alternative behavior one might expect or can I get working then? :D
The structure inner needs to know a morphism m:Outer->NestedTest2 (possibly the identity morphism).
There are two main options to provide it:
In both cases, if m is the identity, it could be inferred, and that is an easy special case to get going quickly. Probably, when the structure is checked/elaborated, we could add an include of the identity morphism from Outer->NestedTest2 to it.
If the involved theories take parameters, special care is needed to get the details right.
Ok. So to get the details wrt nested theories as right as possible:
They're special in the sense that they only make sense inside their parent theory. So to use them outside the parent theory, a morphism is needed.
A module is nested iff its local name has more than one step.
1.: Yeah, so that seems to be missing in the current implementation. The backend treats them just like any other theory.
Suggestion: I'll add checks to the structure checker (and ModelsOf) such that whenever a structure (including plain includes) to a nested theory occurs, an implicit morphism needs to exist?
fixed with 62b17f9f97fcbcc107332dc1d5d3f6038bfd334b
This is one of those "not even wrong" kind of changes.
Without specifying what is supposed to happen, it is impossible to judge if this change makes things better or worse.
It's plausible that the most desirable specification will include the now-produced behavior as a special case. It's also possible that the changes made were exactly the right ones to create that behavior.
But we don't know that until we specify the semantics of importing nested theories.
I understand completely. This was my train of thought, we can maybe use that as a starting point to think about this in more depth:
A minimal example that breaks:
theory NestedTest : ur:?LF = A : type ❙ a : A ❙ ❚
theory Outer : ur:?LF = include ?NestedTest ❙
❚
theory NestedTest2 : ur:?LF = structure inner : ?Outer/Inner = b @ c ❙ ❚ include ?NestedTest ❙ test : A ⟶ type ❙ test2 : test a ❙ claim : test c ❘ = test2 ❙ // works iff a = c ❙ ❚