Skip to content

Commit d274853

Browse files
committed
Revert "chore: downstream-lean4 adaptations for nightly-2026-10-07"
This reverts commit 52199f1. This is necessary as a temporary measure while ProofWidgets' nightly-testing doesn't have the downstream-lean4 changes.
1 parent 4d5bfb4 commit d274853

13 files changed

Lines changed: 92 additions & 91 deletions

‎Mathlib/Tactic/ClickSuggestions.lean‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ meta section
5858

5959
namespace Mathlib.Tactic.ClickSuggestions
6060

61-
open Lean Meta Server Widget ProofWidgets
61+
open Lean Meta Server Widget ProofWidgets Jsx
6262

6363
/-- Run `k` with the `RwKind` of the selected position, and the subexpression at that position.
6464
If the subexpression contains bound variables, then they are introduced as free variables. -/
@@ -137,7 +137,7 @@ public def rpc (props : PanelWidgetProps) : RequestM (RequestTask Html) :=
137137
let (solvedHtml, solvedToken) ← mkRefreshComponent
138138
let targetHtml ←
139139
if let .hyp h := loc.loc then
140-
pure jsx%{<span> hypothesis {← exprToHtml (.fvar h)}</span>}
140+
pure <span> hypothesis {← exprToHtml (.fvar h)} </span>
141141
else
142142
Meta.viewSubexpr (fun _ e ↦ exprToHtml e) loc.pos (← loc.rootExpr)
143143
let html ← mkRefreshComponentM
@@ -151,13 +151,13 @@ public def rpc (props : PanelWidgetProps) : RequestM (RequestTask Html) :=
151151
hyp? := loc.fvarId?
152152
pos := loc.pos
153153
} |>.run (← IO.mkRef {})
154-
return jsx%{<details open={true}>
154+
return <details «open»={true}>
155155
<summary className="mv2 pointer">
156156
Suggestions for {targetHtml}: {statusHtml}
157157
</summary>
158158
{solvedHtml}
159159
{html}
160-
</details>}
160+
</details>
161161

162162
/-- The component called by the `#click_suggestions` command. -/
163163
@[widget_module]

‎Mathlib/Tactic/ClickSuggestions/Apply.lean‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public meta section
1818

1919
namespace Mathlib.Tactic.ClickSuggestions
2020

21-
open Lean Meta ProofWidgets
21+
open Lean Meta ProofWidgets Jsx
2222

2323
/-- The structure for `apply` lemmas stored in the `RefinedDiscrTree`. -/
2424
structure ApplyLemma where
@@ -108,8 +108,7 @@ def ApplyLemma.try (lem : ApplyLemma) (assignableMVars : Array Expr) :
108108
let tactic ← tacticSyntax lem.name proof (isClosing := isClosing) (justLemmaName := justLemmaName)
109109
let mut htmls := #[]
110110
for goal in newGoals do
111-
htmls := htmls.push
112-
jsx%{<div><strong className="goal-vdash">⊢ </strong>{← exprToHtml goal}</div>}
111+
htmls := htmls.push <div> <strong className="goal-vdash">⊢ </strong> {← exprToHtml goal} </div>
113112
if isClosing then
114113
htmls := #[.text "Goal accomplished! 🎉️"]
115114
addSolvedSuggestion tactic
@@ -118,7 +117,7 @@ def ApplyLemma.try (lem : ApplyLemma) (assignableMVars : Array Expr) :
118117
pure none
119118
else
120119
some <$> mkSuggestion tactic (.element "div" #[] htmls) (isClosing := isClosing)
121-
htmls := htmls.push jsx%{<div>{← lem.name.toHtml}</div>}
120+
htmls := htmls.push <div> {← lem.name.toHtml} </div>
122121
let unfiltered ← mkSuggestion tactic (.element "div" #[] htmls) (isClosing := isClosing)
123122
let pattern ← do
124123
let (_, _, e) ← forallMetaTelescopeReducing (← lem.name.getType)

‎Mathlib/Tactic/ClickSuggestions/ApplyAt.lean‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public meta section
1717

1818
namespace Mathlib.Tactic.ClickSuggestions
1919

20-
open Lean Meta ProofWidgets
20+
open Lean Meta ProofWidgets Jsx
2121

2222
/-- The structure for `apply at` lemmas stored in the `RefinedDiscrTree`. -/
2323
structure ApplyAtLemma where
@@ -83,14 +83,13 @@ def ApplyAtLemma.try (lem : ApplyAtLemma) (assignableMVars : Array Expr) :
8383
let tactic ← tacticSyntax lem
8484
let mut htmls := #[← exprToHtml replacement]
8585
for goal in newGoals do
86-
htmls := htmls.push
87-
jsx%{<div><strong className="goal-vdash">⊢ </strong>{← exprToHtml goal}</div>}
86+
htmls := htmls.push <div> <strong className="goal-vdash">⊢ </strong> {← exprToHtml goal} </div>
8887
let filtered ←
8988
if unhelpfulMVars then
9089
pure none
9190
else
9291
some <$> mkSuggestion tactic (.element "div" #[] htmls)
93-
htmls := htmls.push jsx%{<div>{← lem.name.toHtml}</div>}
92+
htmls := htmls.push <div> {← lem.name.toHtml} </div>
9493
let unfiltered ← mkSuggestion tactic (.element "div" #[] htmls)
9594
let pattern ← do
9695
let (xs, _, _) ← forallMetaTelescopeReducing (← lem.name.getType)

‎Mathlib/Tactic/ClickSuggestions/GRewrite.lean‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public meta section
1717

1818
namespace Mathlib.Tactic.ClickSuggestions
1919

20-
open Lean Meta Mathlib.Tactic ProofWidgets
20+
open Lean Meta Mathlib.Tactic ProofWidgets Jsx
2121

2222
/-- `GRewritePos` contains the ìnformation about a given subexpression position needed for
2323
applying a `grw` lemma. -/
@@ -224,13 +224,13 @@ def GrwLemma.try (i : GrwInfo) (lem : GrwLemma) (assignableMVars : Array Expr) :
224224
let mut htmls := #[← exprToHtml replacement]
225225
for goal in extraGoals do
226226
htmls := htmls.push
227-
jsx%{<div><strong className="goal-vdash">⊢ </strong>{← exprToHtml goal}</div>}
227+
<div> <strong className="goal-vdash">⊢ </strong> {← exprToHtml goal} </div>
228228
let filtered ←
229229
if isRefl || unhelpfulMVars then
230230
pure none
231231
else
232232
some <$> mkSuggestion tactic (.element "div" #[] htmls) (isClosing := isClosing)
233-
htmls := htmls.push jsx%{<div>{← lem.name.toHtml}</div>}
233+
htmls := htmls.push <div> {← lem.name.toHtml} </div>
234234
let unfiltered ← mkSuggestion tactic (.element "div" #[] htmls) (isClosing := isClosing)
235235
let pattern ← do
236236
let (_, _, e) ← forallMetaTelescopeReducing (← lem.name.getType)

‎Mathlib/Tactic/ClickSuggestions/Rewrite.lean‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public meta section
1717

1818
namespace Mathlib.Tactic.ClickSuggestions
1919

20-
open Lean Meta ProofWidgets
20+
open Lean Meta ProofWidgets Jsx
2121

2222
/-- The structure for rewrite lemmas stored in the `RefinedDiscrTree`. -/
2323
structure RwLemma where
@@ -141,14 +141,13 @@ def RwLemma.try (i : RwInfo) (lem : RwLemma) (assignableMVars : Array Expr) :
141141
addSolvedSuggestion tactic
142142
let mut htmls := #[← exprToHtml replacement]
143143
for goal in extraGoals do
144-
htmls := htmls.push
145-
jsx%{<div><strong className="goal-vdash">⊢ </strong>{← exprToHtml goal}</div>}
144+
htmls := htmls.push <div> <strong className="goal-vdash">⊢ </strong> {← exprToHtml goal} </div>
146145
let filtered ←
147146
if isRefl || unhelpfulMVars then
148147
pure none
149148
else
150149
some <$> mkSuggestion tactic (.element "div" #[] htmls) (isClosing := isClosing)
151-
htmls := htmls.push jsx%{<div>{← lem.name.toHtml}</div>}
150+
htmls := htmls.push (<div> {← lem.name.toHtml} </div>)
152151
let unfiltered ← mkSuggestion tactic (.element "div" #[] htmls) (isClosing := isClosing)
153152
let pattern ← do
154153
let (_, _, e) ← forallMetaTelescopeReducing (← lem.name.getType)

‎Mathlib/Tactic/ClickSuggestions/SectionState.lean‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This is used for `apply`, `apply at`, `rw` and `grw` suggestions.
1818
public meta section
1919

2020
namespace Mathlib.Tactic.ClickSuggestions
21-
open Lean Widget ProofWidgets
21+
open Lean Widget ProofWidgets Jsx
2222

2323
/-- `Result` stores the information from a lemma that was successfully applied. -/
2424
structure Result (α : Type) where
@@ -102,27 +102,26 @@ def renderSection (tactic : String) (kind : SectionKind) (s : SectionState α) :
102102
let mut all := .element "div" #[] <| results.map (·.unfiltered)
103103
let mut filtered := .element "div" #[] <| results.filterMap (·.filtered)
104104
unless errors.isEmpty do
105-
all := jsx%{<div>{all}{renderErrors errors}</div>}
106-
filtered := jsx%{<div>{filtered}{renderErrors errors}</div>}
105+
all := <div> {all} {renderErrors errors} </div>
106+
filtered := <div> {filtered} {renderErrors errors} </div>
107107
let suffix := match kind with
108108
| .hyp => " (local hypotheses)"
109109
| .currFile => " (current file)"
110110
| .imported => ""
111-
let header := jsx%{<span>{.text tactic} ({pattern}){.text suffix}</span>}
111+
let header := <span> {.text s!"{tactic} ("} {pattern} {.text ")"} {.text suffix} </span>
112112
if kind matches .imported then
113-
return jsx%{<FilterDetails summary={header} all={all} filtered={filtered}
114-
initiallyFiltered={true} />}
113+
return <FilterDetails summary={header} all={all} filtered={filtered} initiallyFiltered={true} />
115114
else
116115
-- We don't filter local results, because there aren't that many of them.
117-
return jsx%{<details open={true}><summary>{header}</summary>{all}</details>}
116+
return <details «open»={true}> <summary> {header} </summary> {all} </details>
118117
where
119118
renderErrors (errors : Array Html) : Html :=
120-
jsx%{<details open={true}>
119+
<details «open»={true}>
121120
<summary className="mv2 pointer">
122-
<span class="error"> Failures: </span>
121+
<span «class»="error"> Failures: </span>
123122
</summary>
124123
{Html.element "ul" #[("style", json% { "padding-left" : "30px"})] errors}
125-
</details>}
124+
</details>
126125

127126
/-- Spawn a task that computes a piece of `Html` to be displayed when finished. -/
128127
@[specialize]
@@ -147,10 +146,10 @@ def spawnTask {α} (premise : Premise) (k : ClickSuggestionsM α) :
147146
throw ex
148147
return .ok none
149148
BaseIO.asTask <| act.catchExceptions fun ex =>
150-
return .error jsx%{<li>
149+
return .error <li>
151150
{premiseHtml} failed:
152151
<br/>
153152
<InteractiveMessage msg={← Server.WithRpcRef.mk ex.toMessageData} />
154-
</li>}
153+
</li>
155154

156155
end Mathlib.Tactic.ClickSuggestions

‎Mathlib/Tactic/ClickSuggestions/TryPremises.lean‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ meta section
1717

1818
namespace Mathlib.Tactic.ClickSuggestions
1919

20-
open Lean ProofWidgets
20+
open Lean ProofWidgets Jsx
2121

2222
/-- An array of candidate lemmas, corresponding to a single section. -/
2323
inductive Candidates where
@@ -176,34 +176,34 @@ public def librarySearchSuggestions (rootExpr subExpr : Expr) (lctx : LocalConte
176176
}
177177

178178
Core.checkInterrupted
179-
token.update jsx%{<div> loading local hypotheses ⏳️ </div>}
179+
token.update <div> loading local hypotheses ⏳️ </div>
180180
let pres ← computeLCtxDiscrTrees choice lctx fvarId?
181181
Core.checkInterrupted
182182
for cand in ← getCandidates rwInfo gpos pres do
183183
sections := sections.push (← runSuggestions .hyp assignableMVars cand)
184184

185185
Core.checkInterrupted
186-
token.update jsx%{<div>
186+
token.update <div>
187187
{.element "div" #[] sections}
188188
<div> loading theorem in the current file ⏳️ </div>
189-
</div>}
189+
</div>
190190
let pres ← computeModuleDiscrTrees choice parentDecl?
191191
Core.checkInterrupted
192192
for cand in ← getCandidates rwInfo gpos pres do
193193
sections := sections.push (← runSuggestions .currFile assignableMVars cand)
194194

195195
Core.checkInterrupted
196-
token.update jsx%{<div>
196+
token.update <div>
197197
{.element "div" #[] sections}
198198
<div> initializing discrimination trees ⏳️ </div>
199-
</div>}
199+
</div>
200200
computeImportDiscrTrees choice
201201
Core.checkInterrupted
202202
let reportProgress (tac : String) :=
203-
token.update jsx%{<div>
203+
token.update <div>
204204
{.element "div" #[] sections}
205-
<div>{.text s!"loading imported `{tac}` theorems ⏳️"}</div>
206-
</div>}
205+
<div> {.text s!"loading imported `{tac}` theorems ⏳️"} </div>
206+
</div>
207207
for cand in ← getImportCandidates rwInfo gpos reportProgress do
208208
sections := sections.push (← runSuggestions .imported assignableMVars cand)
209209

‎Mathlib/Tactic/ClickSuggestions/Unfold.lean‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ So, all such results are filtered out. This is implemented with `isUserFriendly`
5454

5555
meta section
5656

57-
open Lean Meta ProofWidgets
57+
open Lean Meta ProofWidgets Jsx
5858

5959
namespace Mathlib.Tactic.ClickSuggestions
6060

@@ -141,10 +141,10 @@ public def suggestUnfold (e : Expr) (rwKind : RwKind) :
141141
let htmls ← results.mapM fun unfold => do
142142
let tactic ← tacticSyntax e unfold rwKind
143143
mkSuggestion tactic (← exprToHtml unfold)
144-
return jsx%{<details>
144+
return <details>
145145
<summary className="mv2 pointer"> unfold </summary>
146146
{.element "div" #[] htmls}
147-
</details>}
147+
</details>
148148

149149
open Elab in
150150
/-- `#unfold? e` gives all unfolds of `e`.

‎Mathlib/Tactic/ClickSuggestions/Util.lean‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ public meta section
2424

2525
namespace Mathlib.Tactic.ClickSuggestions
2626

27-
open Lean Meta ProofWidgets Server
27+
open Lean Meta ProofWidgets Jsx Server
2828

2929
section
3030

3131
open Widget PrettyPrinter.Delaborator
3232

3333
/-- Turn an `Expr` into an HTML with hover info. -/
3434
def exprToHtml (e : Expr) : MetaM Html :=
35-
return jsx%{<InteractiveCode fmt={← Widget.ppExprTagged e}/>}
35+
return <InteractiveCode fmt={← Widget.ppExprTagged e}/>
3636

3737
/-- Turn a constant into an HTML with hover info.
3838
This avoids the `@` that may appear when using `exprToHtml`. -/
@@ -49,7 +49,7 @@ def constToHtml (n : Name) : MetaM Html := do
4949
fileMap := default
5050
ngen := (← getNGen)
5151
}
52-
return jsx%{<InteractiveCode fmt={← tagCodeInfos ctx infos tt}/>}
52+
return <InteractiveCode fmt={← tagCodeInfos ctx infos tt}/>
5353

5454
/-- Display `fmt` with a docstring as if it is the constant `n`. -/
5555
def formatToHtmlWithDoc (fmt : Format) (n : Name) : MetaM Html := do
@@ -71,7 +71,7 @@ def formatToHtmlWithDoc (fmt : Format) (n : Name) : MetaM Html := do
7171
-- TODO: I would love to print this using the same keyword colour used by the editor,
7272
-- but I don't think this is possible. Additionally, `InteractiveCode` already overwrites the
7373
-- colour and style of the text (namely the expression style)
74-
return jsx%{<InteractiveCode fmt={← tagCodeInfos ctx infos tt} />}
74+
return <InteractiveCode fmt={← tagCodeInfos ctx infos tt} />
7575

7676

7777
/-- Pretty print a tactic with its docstring as hover info.
@@ -233,7 +233,7 @@ where
233233
else
234234
-- TODO: use a fancier throbber instead of `⏳️`?
235235
let title := "ongoing computations: " ++ String.intercalate ", " status.keys;
236-
jsx%{<span title={title}>⏳️</span>}
236+
<span title={title}> {.text "⏳️"} </span>
237237

238238
section Meta
239239

@@ -366,24 +366,24 @@ def mkSuggestion (tac : TSyntax `tactic) (html : Html) (isClosing := false) :
366366
let buttonText := if isClosing then "[done] " else "[apply] "
367367
let button :=
368368
-- TODO: The hover on this button should be a `CodeWithInfos`, instead of a string.
369-
jsx%{<span style={json% { "white-space" : "pre"}} className="font-code">
369+
<span style={json% { "white-space" : "pre"}} className="font-code">
370370
{ .ofComponent MakeEditLink (.ofReplaceRange (← read).meta range newText) #[.text buttonText] }
371-
</span>};
372-
return jsx%{<div display="flex"
371+
</span>;
372+
return <div display="flex"
373373
style={json% { "display" : "flex", "align-items" : "flex-start", "margin-bottom" : "1em" }}>
374-
{button}{html}
375-
</div>}
374+
{button} {html}
375+
</div>
376376

377377
/-- Add suggestion `tac` to the list of tactics that solve the goal. -/
378378
def addSolvedSuggestion (tac : TSyntax `tactic) : ClickSuggestionsM Unit := do
379379
let html ← mkSuggestion tac (.text (← PrettyPrinter.ppTactic tac).pretty) (isClosing := true)
380380
modify fun s ↦ { s with solvedSuggestions := s.solvedSuggestions.push html }
381-
(← read).solvedToken.update jsx%{<details open={true}>
381+
(← read).solvedToken.update <details «open»={true}>
382382
<summary className="mv2 pointer">
383383
These tactics solve the goal: 🎉️
384384
</summary>
385385
{.element "div" #[] (← get).solvedSuggestions}
386-
</details>}
386+
</details>
387387

388388
end Widget
389389

‎Mathlib/Tactic/Widget/CommDiag.lean‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,18 @@ abbrev ExprEmbeds := Array (String × Expr)
5555

5656
/-! ## Widget for general commutative diagrams -/
5757

58+
open scoped Jsx in
5859
/-- Construct a commutative diagram from a Penrose `sub`stance program and expressions `embeds` to
5960
display as labels in the diagram. -/
6061
def mkCommDiag (sub : String) (embeds : ExprEmbeds) : MetaM Html := do
6162
let embeds ← embeds.mapM fun (s, h) =>
62-
return (s, jsx%{<InteractiveCode fmt={← Widget.ppExprTagged h} />})
63-
return jsx%{
63+
return (s, <InteractiveCode fmt={← Widget.ppExprTagged h} />)
64+
return (
6465
<PenroseDiagram
6566
embeds={embeds}
6667
dsl={include_str ".."/".."/".."/"widget"/"src"/"penrose"/"commutative.dsl"}
6768
sty={include_str ".."/".."/".."/"widget"/"src"/"penrose"/"commutative.sty"}
68-
sub={sub} />}
69+
sub={sub} />)
6970

7071
/-! ## Commutative triangles -/
7172

0 commit comments

Comments
 (0)