Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: mention that inferType does not ensure type correctness #5087

Merged
merged 3 commits into from
Sep 7, 2024

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Aug 18, 2024

This also adds links to the implementations of whnf and inferType to make it easier to navigate this part of the code base.

@kmill kmill added the documentation Documentation improvement label Aug 18, 2024
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Aug 18, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Aug 18, 2024

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase b486c6748b153bda628575635baa28aeeb38b8c5 --onto 53e6e99a29362bc8069330f2bf045a10c8f65912. (2024-08-18 19:02:48)
  • ✅ Mathlib branch lean-pr-testing-5087 has successfully built against this PR. (2024-08-20 19:06:47) View Log
  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2024-09-07 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. (2024-09-07 20:50:02)

/--
Returns the inferred type of the given expression.

The type inference algorithm assumes the expression is type-correct for efficiency,
Copy link
Contributor

@hargoniX hargoniX Aug 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you maybe provide an example for a term that it might succeed on but provide a wrong result? This claim probably sounds quite fancy if you are used to the academic notion of "if type inference succeeds the type it returns is right"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've added some examples of both accidental success and necessary failure.


The type inference algorithm does not do general type checking,
which is instead handled by the `Lean.Meta.check` algorithm.
Type inference only looks at subterms that are necessary for determining an expression's type,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth mentioning that we do not guarantee that Lean.Meta.check is as efficient and complete as the check implemented in the kernel.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've moved the mention of Lean.Meta.check to a new paragraph with a comment about the kernel.

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Aug 20, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Aug 20, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Aug 20, 2024
@kmill kmill added this pull request to the merge queue Aug 31, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 31, 2024
@kmill kmill force-pushed the inferType_doc_update branch from 0330a2f to 9380611 Compare September 7, 2024 20:31
@kmill kmill enabled auto-merge September 7, 2024 20:31
@kmill kmill added this pull request to the merge queue Sep 7, 2024
Merged via the queue into leanprover:master with commit e5e5778 Sep 7, 2024
13 checks passed
tobiasgrosser pushed a commit to opencompl/lean4 that referenced this pull request Sep 16, 2024
…rover#5087)

This also adds links to the implementations of `whnf` and `inferType` to
make it easier to navigate this part of the code base.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR documentation Documentation improvement toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants