This PR modifies the pretty printing of pi types. Now `∀` will be preferred over `→` for propositions if the domain is not a proposition. For example, `∀ (n : Nat), True` pretty prints as `∀ (n : Nat), True` rather than as `Nat → True`. There is also now an option `pp.foralls` (default true) that when false disables using `∀` at all, for pedagogical purposes. This PR also adjusts instance implicit binder pretty printing — nondependent pi types won't show the instance binder name. Closes #1834. The linked RFC also suggests using `_` for binder names in case of non-dependance. We're tabling that idea. Potentially it is useful for hygienic names; this could improve how `Nat → True` pretty prints as `∀ (a : Nat), True`, with this `a` that's chosen by implication notation elaboration. Relatedly, this PR exposes even further the issue where binder names are reused in a confusing way. Consider: `Nat → Nat → (a : Nat) → a = a` pretty prints as `∀ (a a a : Nat), a = a`.
27 lines
1.5 KiB
Text
27 lines
1.5 KiB
Text
sanitychecks.lean:1:8-1:15: error: fail to show termination for
|
|
unsound
|
|
with errors
|
|
failed to infer structural recursion:
|
|
no parameters suitable for structural recursion
|
|
|
|
well-founded recursion cannot be used, 'unsound' does not take any (non-fixed) arguments
|
|
sanitychecks.lean:4:8-4:32: error: 'partial' theorems are not allowed, 'partial' is a code generation directive
|
|
sanitychecks.lean:7:7-7:31: error: 'unsafe' theorems are not allowed
|
|
sanitychecks.lean:10:0-10:23: error: failed to synthesize
|
|
Inhabited False
|
|
|
|
Additional diagnostic information may be available using the `set_option diagnostics true` command.
|
|
sanitychecks.lean:18:12-18:20: error: invalid use of 'partial', 'Foo.unsound3' is not a function
|
|
False
|
|
sanitychecks.lean:20:0-20:54: error: failed to compile 'partial' definition 'Foo.unsound4', could not prove that the type
|
|
∀ (x : Unit), False
|
|
is nonempty.
|
|
|
|
This process uses multiple strategies:
|
|
- It looks for a parameter that matches the return type.
|
|
- It tries synthesizing 'Inhabited' and 'Nonempty' instances for the return type, while making every parameter into a local 'Inhabited' instance.
|
|
- It tries unfolding the return type.
|
|
|
|
If the return type is defined using the 'structure' or 'inductive' command, you can try adding a 'deriving Nonempty' clause to it.
|
|
sanitychecks.lean:22:12-22:20: error: (kernel) invalid declaration, it uses unsafe declaration 'unsafeCast'
|
|
sanitychecks.lean:25:12-25:20: error: (kernel) invalid declaration, it uses unsafe declaration 'unsafeCast'
|