Skip to content

Commit 29a9aae

Browse files
andrewmw94kim-em
andauthored
feat: fixes for v4.14.0-rc1 (leanprover-community#57)
* Bump toolchain to 4.12 Signed-off-by: Andrew Wells <[email protected]> * No longer need to drop messages and trees in proccessCommandsWithInfoTrees Signed-off-by: Andrew Wells <[email protected]> * bump toolchains to nightly Signed-off-by: Andrew Wells <[email protected]> * Reformat expected goal state Signed-off-by: Andrew Wells <[email protected]> * use flatten and flatMap instead of join and bind Signed-off-by: Andrew Wells <[email protected]> * filter out sorries with null position Signed-off-by: Andrew Wells <[email protected]> * Update Mathlib tests to nightly/master Signed-off-by: Andrew Wells <[email protected]> * Update to nightly-2024-10-21 Signed-off-by: Andrew Wells <[email protected]> * move to v4.14.0-rc1 * update calc.expected.out --------- Signed-off-by: Andrew Wells <[email protected]> Co-authored-by: Kim Morrison <[email protected]>
1 parent 65f1337 commit 29a9aae

12 files changed

+80
-49
lines changed

REPL/Frontend.lean

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ def processCommandsWithInfoTrees
2020
(commandState : Command.State) : IO (Command.State × List Message × List InfoTree) := do
2121
let commandState := { commandState with infoState.enabled := true }
2222
let s ← IO.processCommands inputCtx parserState commandState <&> Frontend.State.commandState
23-
let msgs := s.messages.toList.drop commandState.messages.toList.length
24-
let trees := s.infoState.trees.toList.drop commandState.infoState.trees.size
25-
26-
pure (s, msgs, trees)
23+
pure (s, s.messages.toList, s.infoState.trees.toList)
2724

2825
/--
2926
Process some text input, with or without an existing command state.

REPL/JSON.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ structure Sorry where
8383
deriving FromJson
8484

8585
instance : ToJson Sorry where
86-
toJson r := Json.mkObj <| .join [
86+
toJson r := Json.mkObj <| .flatten [
8787
[("goal", r.goal)],
8888
[("proofState", toJson r.proofState)],
8989
if r.pos.line ≠ 0 then [("pos", toJson r.pos)] else [],
@@ -132,7 +132,7 @@ def Json.nonemptyList [ToJson α] (k : String) : List α → List (String × Jso
132132
| l => [⟨k, toJson l⟩]
133133

134134
instance : ToJson CommandResponse where
135-
toJson r := Json.mkObj <| .join [
135+
toJson r := Json.mkObj <| .flatten [
136136
[("env", r.env)],
137137
Json.nonemptyList "messages" r.messages,
138138
Json.nonemptyList "sorries" r.sorries,
@@ -153,7 +153,7 @@ structure ProofStepResponse where
153153
deriving ToJson, FromJson
154154

155155
instance : ToJson ProofStepResponse where
156-
toJson r := Json.mkObj <| .join [
156+
toJson r := Json.mkObj <| .flatten [
157157
[("proofState", r.proofState)],
158158
[("goals", toJson r.goals)],
159159
Json.nonemptyList "messages" r.messages,

REPL/Lean/Environment.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ and then replace the new constants.
2626
def unpickle (path : FilePath) : IO (Environment × CompactedRegion) := unsafe do
2727
let ((imports, map₂), region) ← _root_.unpickle (Array Import × PHashMap Name ConstantInfo) path
2828
let env ← importModules imports {} 0
29-
return (← env.replay (HashMap.ofList map₂.toList), region)
29+
return (← env.replay (Std.HashMap.ofList map₂.toList), region)
3030

3131
end Lean.Environment

REPL/Lean/InfoTree.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ partial def filter (p : Info → Bool) (m : MVarId → Bool := fun _ => false) :
131131
| .context ctx tree => tree.filter p m |>.map (.context ctx)
132132
| .node info children =>
133133
if p info then
134-
[.node info (children.toList.map (filter p m)).join.toPArray']
134+
[.node info (children.toList.map (filter p m)).flatten.toPArray']
135135
else
136-
(children.toList.map (filter p m)).join
136+
(children.toList.map (filter p m)).flatten
137137
| .hole mvar => if m mvar then [.hole mvar] else []
138138

139139
/-- Discard all nodes besides `.context` nodes and `TacticInfo` nodes. -/
@@ -156,7 +156,7 @@ partial def findAllInfo (t : InfoTree) (ctx? : Option ContextInfo) (p : Info →
156156
| context ctx t => t.findAllInfo (ctx.mergeIntoOuter? ctx?) p
157157
| node i ts =>
158158
let info := if p i then [(i, ctx?)] else []
159-
let rest := ts.toList.bind (fun t => t.findAllInfo ctx? p)
159+
let rest := ts.toList.flatMap (fun t => t.findAllInfo ctx? p)
160160
info ++ rest
161161
| _ => []
162162

REPL/Main.lean

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,20 @@ def recordProofSnapshot (proofState : ProofSnapshot) : M m Nat := do
9595
return id
9696

9797
def sorries (trees : List InfoTree) (env? : Option Environment) : M m (List Sorry) :=
98-
trees.bind InfoTree.sorries |>.mapM
99-
fun ⟨ctx, g, pos, endPos⟩ => do
100-
let (goal, proofState) ← match g with
101-
| .tactic g => do
102-
let s ← ProofSnapshot.create ctx none env? [g]
103-
pure ("\n".intercalate <| (← s.ppGoals).map fun s => s!"{s}", some s)
104-
| .term lctx (some t) => do
105-
let s ← ProofSnapshot.create ctx lctx env? [] [t]
106-
pure ("\n".intercalate <| (← s.ppGoals).map fun s => s!"{s}", some s)
107-
| .term _ none => unreachable!
108-
let proofStateId ← proofState.mapM recordProofSnapshot
109-
return Sorry.of goal pos endPos proofStateId
98+
trees.flatMap InfoTree.sorries |>.filter (fun t => match t.2.1 with
99+
| .term _ none => false
100+
| _ => true ) |>.mapM
101+
fun ⟨ctx, g, pos, endPos⟩ => do
102+
let (goal, proofState) ← match g with
103+
| .tactic g => do
104+
let s ← ProofSnapshot.create ctx none env? [g]
105+
pure ("\n".intercalate <| (← s.ppGoals).map fun s => s!"{s}", some s)
106+
| .term lctx (some t) => do
107+
let s ← ProofSnapshot.create ctx lctx env? [] [t]
108+
pure ("\n".intercalate <| (← s.ppGoals).map fun s => s!"{s}", some s)
109+
| .term _ none => unreachable!
110+
let proofStateId ← proofState.mapM recordProofSnapshot
111+
return Sorry.of goal pos endPos proofStateId
110112

111113
def ppTactic (ctx : ContextInfo) (stx : Syntax) : IO Format :=
112114
ctx.runMetaM {} try
@@ -115,7 +117,7 @@ def ppTactic (ctx : ContextInfo) (stx : Syntax) : IO Format :=
115117
pure "<failed to pretty print>"
116118

117119
def tactics (trees : List InfoTree) : M m (List Tactic) :=
118-
trees.bind InfoTree.tactics |>.mapM
120+
trees.flatMap InfoTree.tactics |>.mapM
119121
fun ⟨ctx, stx, goals, pos, endPos, ns⟩ => do
120122
let proofState := some (← ProofSnapshot.create ctx none none goals)
121123
let goals := s!"{(← ctx.ppGoals goals)}".trim
@@ -216,9 +218,9 @@ def runCommand (s : Command) : M IO (CommandResponse ⊕ Error) := do
216218
let env ← recordCommandSnapshot cmdSnapshot
217219
let jsonTrees := match s.infotree with
218220
| some "full" => trees
219-
| some "tactics" => trees.bind InfoTree.retainTacticInfo
220-
| some "original" => trees.bind InfoTree.retainTacticInfo |>.bind InfoTree.retainOriginal
221-
| some "substantive" => trees.bind InfoTree.retainTacticInfo |>.bind InfoTree.retainSubstantive
221+
| some "tactics" => trees.flatMap InfoTree.retainTacticInfo
222+
| some "original" => trees.flatMap InfoTree.retainTacticInfo |>.flatMap InfoTree.retainOriginal
223+
| some "substantive" => trees.flatMap InfoTree.retainTacticInfo |>.flatMap InfoTree.retainSubstantive
222224
| _ => []
223225
let infotree ← if jsonTrees.isEmpty then
224226
pure none

REPL/Snapshots.lean

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def unpickle (path : FilePath) : IO (CommandSnapshot × CompactedRegion) := unsa
8383
let ((imports, map₂, cmdState, cmdContext), region) ←
8484
_root_.unpickle (Array Import × PHashMap Name ConstantInfo × CompactableCommandSnapshot ×
8585
Command.Context) path
86-
let env ← (← importModules imports {} 0).replay (HashMap.ofList map₂.toList)
86+
let env ← (← importModules imports {} 0).replay (Std.HashMap.ofList map₂.toList)
8787
let p' : CommandSnapshot :=
8888
{ cmdState := { cmdState with env }
8989
cmdContext }
@@ -194,7 +194,6 @@ def create (ctx : ContextInfo) (lctx? : Option LocalContext) (env? : Option Envi
194194
(goals : List MVarId) (types : List Expr := []) : IO ProofSnapshot := do
195195
ctx.runMetaM (lctx?.getD {}) do
196196
let goals := goals ++ (← types.mapM fun t => Expr.mvarId! <$> Meta.mkFreshExprMVar (some t))
197-
goals.head!.withContext do
198197
let s ← getThe Core.State
199198
let s := match env? with
200199
| none => s
@@ -285,9 +284,9 @@ def unpickle (path : FilePath) (cmd? : Option CommandSnapshot) :
285284
let env ← match cmd? with
286285
| none =>
287286
enableInitializersExecution
288-
(← importModules imports {} 0).replay (HashMap.ofList map₂.toList)
287+
(← importModules imports {} 0).replay (Std.HashMap.ofList map₂.toList)
289288
| some cmd =>
290-
cmd.cmdState.env.replay (HashMap.ofList map₂.toList)
289+
cmd.cmdState.env.replay (Std.HashMap.ofList map₂.toList)
291290
let p' : ProofSnapshot :=
292291
{ coreState := { coreState with env }
293292
coreContext

lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:v4.11.0
1+
leanprover/lean4:v4.14.0-rc1

test/Mathlib/lake-manifest.json

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"type": "git",
66
"subDir": null,
77
"scope": "leanprover-community",
8-
"rev": "9c6c2d647e57b2b7a0b42dd8080c698bd33a1b6f",
8+
"rev": "76e9ebe4176d29cb9cc89c669ab9f1ce32b33c3d",
99
"name": "batteries",
1010
"manifestFile": "lake-manifest.json",
1111
"inputRev": "main",
1212
"inherited": true,
13-
"configFile": "lakefile.lean"},
13+
"configFile": "lakefile.toml"},
1414
{"url": "https://github.com/leanprover-community/quote4",
1515
"type": "git",
1616
"subDir": null,
1717
"scope": "leanprover-community",
18-
"rev": "9d0bdd07bdfe53383567509348b1fe917fc08de4",
18+
"rev": "303b23fbcea94ac4f96e590c1cad6618fd4f5f41",
1919
"name": "Qq",
2020
"manifestFile": "lake-manifest.json",
2121
"inputRev": "master",
@@ -25,7 +25,7 @@
2525
"type": "git",
2626
"subDir": null,
2727
"scope": "leanprover-community",
28-
"rev": "deb279eb7be16848d0bc8387f80d6e41bcdbe738",
28+
"rev": "45d016d59cf45bcf8493a203e9564cfec5203d9b",
2929
"name": "aesop",
3030
"manifestFile": "lake-manifest.json",
3131
"inputRev": "master",
@@ -35,17 +35,17 @@
3535
"type": "git",
3636
"subDir": null,
3737
"scope": "leanprover-community",
38-
"rev": "a96aee5245720f588876021b6a0aa73efee49c76",
38+
"rev": "1383e72b40dd62a566896a6e348ffe868801b172",
3939
"name": "proofwidgets",
4040
"manifestFile": "lake-manifest.json",
41-
"inputRev": "v0.0.41",
41+
"inputRev": "v0.0.46",
4242
"inherited": true,
4343
"configFile": "lakefile.lean"},
4444
{"url": "https://github.com/leanprover/lean4-cli",
4545
"type": "git",
4646
"subDir": null,
47-
"scope": "",
48-
"rev": "2cf1030dc2ae6b3632c84a09350b675ef3e347d0",
47+
"scope": "leanprover",
48+
"rev": "726b3c9ad13acca724d4651f14afc4804a7b0e4d",
4949
"name": "Cli",
5050
"manifestFile": "lake-manifest.json",
5151
"inputRev": "main",
@@ -55,20 +55,40 @@
5555
"type": "git",
5656
"subDir": null,
5757
"scope": "leanprover-community",
58-
"rev": "1ef0b288623337cb37edd1222b9c26b4b77c6620",
58+
"rev": "ac7b989cbf99169509433124ae484318e953d201",
5959
"name": "importGraph",
6060
"manifestFile": "lake-manifest.json",
6161
"inputRev": "main",
6262
"inherited": true,
6363
"configFile": "lakefile.toml"},
64+
{"url": "https://github.com/leanprover-community/LeanSearchClient",
65+
"type": "git",
66+
"subDir": null,
67+
"scope": "leanprover-community",
68+
"rev": "7bedaed1ef024add1e171cc17706b012a9a37802",
69+
"name": "LeanSearchClient",
70+
"manifestFile": "lake-manifest.json",
71+
"inputRev": "main",
72+
"inherited": true,
73+
"configFile": "lakefile.toml"},
74+
{"url": "https://github.com/leanprover-community/plausible",
75+
"type": "git",
76+
"subDir": null,
77+
"scope": "leanprover-community",
78+
"rev": "0f1430e6f1193929f13905d450b2a44a54f3927e",
79+
"name": "plausible",
80+
"manifestFile": "lake-manifest.json",
81+
"inputRev": "main",
82+
"inherited": true,
83+
"configFile": "lakefile.toml"},
6484
{"url": "https://github.com/leanprover-community/mathlib4",
6585
"type": "git",
6686
"subDir": null,
6787
"scope": "",
68-
"rev": "8edf04f0977c3183d3b633792e03fd570be1777f",
88+
"rev": "a7fc949f1b05c2a01e01c027fd9f480496a1253e",
6989
"name": "mathlib",
7090
"manifestFile": "lake-manifest.json",
71-
"inputRev": "master",
91+
"inputRev": "v4.14.0-rc1",
7292
"inherited": false,
7393
"configFile": "lakefile.lean"}],
7494
"name": "«repl-mathlib-tests»",

test/Mathlib/lakefile.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defaultTargets = ["ReplMathlibTests"]
44
[[require]]
55
name = "mathlib"
66
git = "https://github.com/leanprover-community/mathlib4"
7-
rev = "master"
7+
rev = "v4.14.0-rc1"
88

99
[[lean_lib]]
1010
name = "ReplMathlibTests"

test/Mathlib/lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:v4.11.0
1+
leanprover/lean4:v4.14.0-rc1

test/all_tactics.expected.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"tactic": "exact t",
1010
"proofState": 1,
1111
"pos": {"line": 1, "column": 32},
12-
"goals": "t : Nat ⊢ Nat",
12+
"goals": "t : Nat\n⊢ Nat",
1313
"endPos": {"line": 1, "column": 39}}],
1414
"env": 0}
1515

test/calc.expected.out

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
{"tactics":
22
[{"usedConstants":
3-
["Trans.trans", "instOfNatNat", "instTransEq", "Nat", "OfNat.ofNat", "Eq"],
3+
["Trans.trans",
4+
"sorryAx",
5+
"instOfNatNat",
6+
"instTransEq",
7+
"Nat",
8+
"OfNat.ofNat",
9+
"Bool.false",
10+
"Eq"],
411
"tactic": "calc\n 3 = 4 := by sorry\n 4 = 5 := by sorry",
512
"proofState": 2,
613
"pos": {"line": 1, "column": 22},
714
"goals": "⊢ 3 = 5",
815
"endPos": {"line": 3, "column": 19}},
16+
{"usedConstants": [],
17+
"tactic": "\n 3 = 4 := by sorry\n 4 = 5 := by sorry",
18+
"proofState": 3,
19+
"pos": {"line": 2, "column": 2},
20+
"goals": "no goals",
21+
"endPos": {"line": 3, "column": 19}},
922
{"usedConstants":
1023
["sorryAx", "instOfNatNat", "Nat", "OfNat.ofNat", "Bool.false", "Eq"],
1124
"tactic": "sorry",
12-
"proofState": 3,
25+
"proofState": 4,
1326
"pos": {"line": 2, "column": 14},
1427
"goals": "⊢ 3 = 4",
1528
"endPos": {"line": 2, "column": 19}},
1629
{"usedConstants":
1730
["sorryAx", "instOfNatNat", "Nat", "OfNat.ofNat", "Bool.false", "Eq"],
1831
"tactic": "sorry",
19-
"proofState": 4,
32+
"proofState": 5,
2033
"pos": {"line": 3, "column": 14},
2134
"goals": "⊢ 4 = 5",
2235
"endPos": {"line": 3, "column": 19}}],

0 commit comments

Comments
 (0)