lean4-htt/tests/elab_fail/univInference.lean.out.expected
Kyle Miller 8f1c18d9f4
feat: pretty print level metavariables using index (#13030)
This PR improves pretty printing of level metavariables: they now print
with a per-definition index rather than their per-module internal
identifiers. Furthermore, `+` is printed uniformly in level expressions
with surrounding spaces. **Breaking metaprogramming change:** level
pretty printing should use `delabLevel` or `MessageData.ofLevel`;
functions such as `format` or `toString` do not have access to the
indices, since they are stored in the current metacontext. Absent index
information, metavariables print with the raw internal identifier as
`?_mvar.nnn`. **Note:** The heartbeat counter also increases quicker due
to counting allocations that record level metavariable indices. In some
tests we needed to increase `maxHeartbeats` by 20–50% to compensate,
without a corresponding slowdown.
2026-04-01 22:34:29 +00:00

37 lines
2.8 KiB
Text

univInference.lean:25:48-25:54: warning: Inferred universe level for type may be unnecessarily high. The inferred resulting universe is
Type (max u v)
but it possibly could be
Sort (max (max 1 u) v)
Explicitly providing a resulting universe with no metavariables will silence this warning.
Note: The elaborated resulting universe after constructor elaboration is
Type ?u
The inference algorithm attempts to compute the smallest level for `?u` such that all universe constraints for all constructor fields are satisfied, with some approximations. The following derived constraint(s) are the cause of this possible unnecessarily high universe:
v ≤ ?u + 1
u ≤ ?u + 1
For example, if the resulting universe is of the form `Sort (?r + 1)` and a constructor field is in universe `Sort u`, the constraint `u ≤ ?r + 1` leads to the unnecessarily high resulting universe `Sort (u + 1)`. Using `Sort (max 1 u)` avoids this universe bump, if using it is possible.
S6 : Sort (max w₁ w₂) → Type w₂ → Sort (max w₁ (w₂ + 1))
univInference.lean:45:48-45:62: error: Invalid universe polymorphic resulting type: The resulting universe is not `Prop`, but it may be `Prop` for some parameter values:
Sort (max u v)
Hint: A possible solution is to use levels of the form `max 1 _` or `_ + 1` to ensure the universe is of the form `Type _`
univInference.lean:64:48-64:54: warning: Inferred universe level for type may be unnecessarily high. The inferred resulting universe is
Type (max u v)
but it possibly could be
Sort (max (max 1 u) v)
Explicitly providing a resulting universe with no metavariables will silence this warning.
Note: The elaborated resulting universe after constructor elaboration is
Type ?u
The inference algorithm attempts to compute the smallest level for `?u` such that all universe constraints for all constructor fields are satisfied, with some approximations. The following derived constraint(s) are the cause of this possible unnecessarily high universe:
v ≤ ?u + 1
u ≤ ?u + 1
For example, if the resulting universe is of the form `Sort (?r + 1)` and a constructor field is in universe `Sort u`, the constraint `u ≤ ?r + 1` leads to the unnecessarily high resulting universe `Sort (u + 1)`. Using `Sort (max 1 u)` avoids this universe bump, if using it is possible.
univInference.lean:73:48-73:62: error: Invalid universe polymorphic resulting type: The resulting universe is not `Prop`, but it may be `Prop` for some parameter values:
Sort (max u v)
Hint: A possible solution is to use levels of the form `max 1 _` or `_ + 1` to ensure the universe is of the form `Type _`
univInference.lean:94:7-94:13: error: Failed to infer universe levels in type of field `t1`
Sort ?u
univInference.lean:136:7-136:8: error: Failed to infer universe levels in type of binder `b`
sorry