tutorial: projecting out of a structure that may or may not be a Prop - #153
Merged
Conversation
`MaybeProp.{u} : Sort u` is a proposition exactly for `u := 0`. Lean's
`inductive` command refuses such a declaration, but the kernel accepts it,
and projecting out of it is fine at every instantiation: a structure that
is not a `Prop` had every constructor field's universe checked against its
resulting universe, and that inequality survives instantiation, so wherever
the structure does become a proposition all of its fields do too.
That argument turns on the two checks agreeing on what a proposition is.
Waiving the field universe bound at declaration time and forbidding data
projections are two halves of one rule: a kernel generous about "is this a
`Prop`?" when declaring the inductive and strict about it when checking a
projection puts a data field inside a proposition, and proof irrelevance
collapses it into a proof of `False`. Erring the other way is safe but
incomplete, and that is what these tests catch — asking "could this be a
`Prop`?" and then demanding the field be definitely a proof rejects a
legitimate declaration. `projMaybeProp` catches that at the field being
asked for, `projMaybePropPast` on the way past a preceding one, which is a
separate code path.
The shape is not exotic: a dependent pair kept at the exact maximum of its
components lands in `Sort (max u v)`, which poses the same question, and
this is why `PProd` and `PSigma` use `Sort (max 1 u v)` instead.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UakEtNJTcwyaEtfLhR8BLn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MaybeProp.{u} : Sort uis a proposition exactly foru := 0. Lean'sinductivecommand refuses such a declaration, but the kernel accepts it,and projecting out of it is fine at every instantiation: a structure that
is not a
Prophad every constructor field's universe checked against itsresulting universe, and that inequality survives instantiation, so wherever
the structure does become a proposition all of its fields do too.
That argument turns on the two checks agreeing on what a proposition is.
Waiving the field universe bound at declaration time and forbidding data
projections are two halves of one rule: a kernel generous about "is this a
Prop?" when declaring the inductive and strict about it when checking aprojection puts a data field inside a proposition, and proof irrelevance
collapses it into a proof of
False. Erring the other way is safe butincomplete, and that is what these tests catch — asking "could this be a
Prop?" and then demanding the field be definitely a proof rejects alegitimate declaration.
projMaybePropcatches that at the field beingasked for,
projMaybePropPaston the way past a preceding one, which is aseparate code path.
The shape is not exotic: a dependent pair kept at the exact maximum of its
components lands in
Sort (max u v), which poses the same question, andthis is why
PProdandPSigmauseSort (max 1 u v)instead.Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01UakEtNJTcwyaEtfLhR8BLn