Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions leanpkg.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "."
version = "0.1"
lean_version = "leanprover-community/lean:3.35.1"
lean_version = "leanprover-community/lean:3.45.0"
path = "src"

[dependencies]
mathlib = {git = "https://github.com/leanprover-community/mathlib", rev = "77ba0c4160793de8a824461128c57ca394792143"}
mathlib = {git = "https://github.com/leanprover-community/mathlib", rev = "b2af6ee923fac9d60bd4e2fdce27b11287cc614f"}
13 changes: 13 additions & 0 deletions print_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ def trace_deps(file_map):
print(f"trace_deps: Processed {n_ok} / {n} dependency links")
return graph

def add_informal_statements_to_decls(informal, file_map):
for file in file_map:
for decl in file_map[file]:
informal_statement = ""
if decl['kind'] == 'theorem':
informal_decl = informal.get(decl['name'], None)
if informal_decl is not None and decl['args'] == informal_decl['args'] and decl['type'] == informal_decl['type']:
informal_statement = informal_decl['informal_statement']
decl['informal_statement'] = informal_statement

def load_json():
try:
with open('export.json', 'r', encoding='utf-8') as f:
Expand All @@ -333,6 +343,9 @@ def load_json():
print(raw)
raise
file_map, loc_map = separate_results(decls['decls'])
with gzip.open('tagged_nl2.json.gz') as tagged_nl:
translations = json.load(tagged_nl)
add_informal_statements_to_decls(translations, file_map)
for entry in decls['tactic_docs']:
if len(entry['tags']) == 0:
entry['tags'] = ['untagged']
Expand Down
36 changes: 36 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -697,3 +697,39 @@ a:hover {
margin-top: 2em;
margin-bottom: 2em;
}

.informal_statement {
margin-top: 1em;
}

.informal_statement .explain {
color:var(--link-color);
}

.informal_statement .explain .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;

/* Position the tooltip text - see examples below! */
top: -5px;
left: 105%;

}
Comment thread
robertylewis marked this conversation as resolved.
Outdated
Comment thread
robertylewis marked this conversation as resolved.
Outdated

.informal_statement .statement, .informal_statement .translation_qs {
margin-left: 2ch;
}

.informal_statement .translation_qs {
color:gray;
}

/* Show the tooltip text when you mouse over the tooltip container */
.informal_statement .explain:hover .tooltiptext {
visibility: visible;
}
Comment thread
robertylewis marked this conversation as resolved.
Outdated
Binary file added tagged_nl2.json.gz
Binary file not shown.
23 changes: 23 additions & 0 deletions templates/decl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@

{{ decl.doc_string | convert_markdown }}

{% if decl.informal_statement %}

<details open>
<summary>Informal translation</summary>

<div class="informal_statement">
<div class="statement">
{{ decl.informal_statement }}
Comment thread
robertylewis marked this conversation as resolved.
Outdated
</div>
Comment on lines +41 to +43
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm worried the mathjax rendering is going to have quite a large impact on page load times. Could we maybe:

  • Defer mathjax rendering of .informal_statement until the details is expanded
  • Put a "expand informal math" setting in the sidebar next to the color scheme setting, so that users can opt to collapse everything by default and get the associated performance boost.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think the details should be collapsed by default, not for performance but because the translations are misleadingly sketchy:

Right now I put it in a <details> menu, expanded by default to make browsing this demo easier. I think they should be collapsed by default in production, at least until the translations improve.

But a toggle also sounds like a good idea.

Do you know how to defer the rendering?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's a (possibly outdated) question about deferring here: https://stackoverflow.com/a/27952213/102441

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This page in the documentation also seems relevant.

Enabling Lazy Typesetting would also be a reasonable option.


<div class="translation_qs">
This translation to informal mathematics is automatically generated and should NOT be trusted!
The translation is a <a href="">beta feature powered by OpenAI's Codex API</a>.
<br>
Does this translation look correct? <a href="">Yes</a> | <a href = "">No</a>
</div>
</div>


</details>

{% endif %}

{% if decl.equations | length %}
<details>
<summary>Equations</summary>
Expand Down