Merge pull request 'chore: Update Lean to v4.20.1' (#209) from chore/toolchain into dev
Reviewed-on: #209
This commit is contained in:
commit
9a8b5040f5
|
@ -4,6 +4,7 @@ import Pantograph.Protocol
|
||||||
import Pantograph.Serial
|
import Pantograph.Serial
|
||||||
import Lean.Environment
|
import Lean.Environment
|
||||||
import Lean.Replay
|
import Lean.Replay
|
||||||
|
import Lean.Util.Path
|
||||||
|
|
||||||
open Lean
|
open Lean
|
||||||
open Pantograph
|
open Pantograph
|
||||||
|
@ -130,17 +131,19 @@ def inspect (args: Protocol.EnvInspect) (options: @&Protocol.Options): Protocol.
|
||||||
} }
|
} }
|
||||||
| _ => pure core
|
| _ => pure core
|
||||||
let result ← if args.source?.getD false then
|
let result ← if args.source?.getD false then
|
||||||
let srcSearchPath ← initSrcSearchPath
|
try
|
||||||
let sourceUri? ← module?.bindM (Server.documentUriFromModule srcSearchPath ·)
|
let sourceUri? ← module?.bindM (Server.documentUriFromModule? ·)
|
||||||
let declRange? ← findDeclarationRanges? name
|
let declRange? ← findDeclarationRanges? name
|
||||||
let sourceStart? := declRange?.map (·.range.pos)
|
let sourceStart? := declRange?.map (·.range.pos)
|
||||||
let sourceEnd? := declRange?.map (·.range.endPos)
|
let sourceEnd? := declRange?.map (·.range.endPos)
|
||||||
.pure {
|
.pure {
|
||||||
result with
|
result with
|
||||||
sourceUri?,
|
sourceUri? := sourceUri?.map (toString ·),
|
||||||
sourceStart?,
|
sourceStart?,
|
||||||
sourceEnd?,
|
sourceEnd?,
|
||||||
}
|
}
|
||||||
|
catch _e =>
|
||||||
|
.pure result
|
||||||
else
|
else
|
||||||
.pure result
|
.pure result
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -69,7 +69,7 @@ def createCoreContext (options: Array String): IO Core.Context := do
|
||||||
@[export pantograph_create_core_state]
|
@[export pantograph_create_core_state]
|
||||||
def createCoreState (imports: Array String): IO Core.State := do
|
def createCoreState (imports: Array String): IO Core.State := do
|
||||||
let env ← Lean.importModules
|
let env ← Lean.importModules
|
||||||
(imports := imports.map (λ str => { module := str.toName, runtimeOnly := false }))
|
(imports := imports.map (λ str => { module := str.toName }))
|
||||||
(opts := {})
|
(opts := {})
|
||||||
(trustLevel := 1)
|
(trustLevel := 1)
|
||||||
(loadExts := true)
|
(loadExts := true)
|
||||||
|
|
|
@ -51,7 +51,7 @@ def test_sexp_of_elab (env: Environment): IO LSpec.TestSeq := do
|
||||||
("λ x: Array Nat => x.data", [], "(:lambda x ((:c Array) (:c Nat)) ((:c Array.data) (:c Nat) 0))"),
|
("λ x: Array Nat => x.data", [], "(:lambda x ((:c Array) (:c Nat)) ((:c Array.data) (:c Nat) 0))"),
|
||||||
("λ {α: Sort (u + 1)} => List α", [`u], "(:lambda α (:sort (+ u 1)) ((:c List) 0) :i)"),
|
("λ {α: Sort (u + 1)} => List α", [`u], "(:lambda α (:sort (+ u 1)) ((:c List) 0) :i)"),
|
||||||
("λ {α} => List α", [], "(:lambda α (:sort (+ (:mv _uniq.4) 1)) ((:c List) 0) :i)"),
|
("λ {α} => List α", [], "(:lambda α (:sort (+ (:mv _uniq.4) 1)) ((:c List) 0) :i)"),
|
||||||
("(2: Nat) <= (5: Nat)", [], "((:c LE.le) (:mv _uniq.18) (:mv _uniq.19) ((:c OfNat.ofNat) (:mv _uniq.4) (:lit 2) (:mv _uniq.5)) ((:c OfNat.ofNat) (:mv _uniq.14) (:lit 5) (:mv _uniq.15)))"),
|
("(2: Nat) <= (5: Nat)", [], "((:c LE.le) (:mv _uniq.20) (:mv _uniq.21) ((:c OfNat.ofNat) (:mv _uniq.4) (:lit 2) (:mv _uniq.5)) ((:c OfNat.ofNat) (:mv _uniq.15) (:lit 5) (:mv _uniq.16)))"),
|
||||||
]
|
]
|
||||||
entries.foldlM (λ suites (source, levels, target) =>
|
entries.foldlM (λ suites (source, levels, target) =>
|
||||||
let termElabM := do
|
let termElabM := do
|
||||||
|
|
|
@ -96,10 +96,10 @@ def test_symbol_location (env : Environment) : TestT IO Unit := do
|
||||||
|
|
||||||
-- Extraction of source doesn't work for symbols in `Init` for some reason
|
-- Extraction of source doesn't work for symbols in `Init` for some reason
|
||||||
checkTrue "file" result.sourceUri?.isNone
|
checkTrue "file" result.sourceUri?.isNone
|
||||||
checkEq "pos" (result.sourceStart?.map (·.column)) <| .some 0
|
checkEq "sourceStart" (result.sourceStart?.map (·.column)) <| .some 0
|
||||||
checkEq "pos" (result.sourceEnd?.map (·.column)) <| .some 88
|
checkEq "sourceEnd" (result.sourceEnd?.map (·.column)) <| .some 88
|
||||||
let { imports, constNames, .. } ← Environment.moduleRead ⟨"Init.Data.Nat.Basic"⟩
|
let { imports, constNames, .. } ← Environment.moduleRead ⟨"Init.Data.Nat.Basic"⟩
|
||||||
checkEq "imports" imports #["Init.SimpLemmas", "Init.Data.NeZero"]
|
checkEq "imports" imports #["Init.SimpLemmas", "Init.Data.NeZero", "Init.Grind.Tactics"]
|
||||||
checkTrue "constNames" $ constNames.contains "Nat.succ_add"
|
checkTrue "constNames" $ constNames.contains "Nat.succ_add"
|
||||||
|
|
||||||
def test_matcher (env : Environment) : TestT IO Unit := do
|
def test_matcher (env : Environment) : TestT IO Unit := do
|
||||||
|
|
|
@ -104,7 +104,7 @@ example : (1 : Nat) + (2 * 3) = 1 + (4 - 3) + (6 - 4) + 3 := by
|
||||||
simp
|
simp
|
||||||
def test_tactic_timeout : Test := do
|
def test_tactic_timeout : Test := do
|
||||||
step "goal.start" ({ expr := "(1 : Nat) + (2 * 3) = 1 + (4 - 3) + (6 - 4) + 3" }: Protocol.GoalStart)
|
step "goal.start" ({ expr := "(1 : Nat) + (2 * 3) = 1 + (4 - 3) + (6 - 4) + 3" }: Protocol.GoalStart)
|
||||||
({ stateId := 0, root := "_uniq.319" }: Protocol.GoalStartResult)
|
({ stateId := 0, root := "_uniq.355" }: Protocol.GoalStartResult)
|
||||||
-- timeout of 10 milliseconds
|
-- timeout of 10 milliseconds
|
||||||
step "options.set" ({ timeout? := .some 10 } : Protocol.OptionsSet)
|
step "options.set" ({ timeout? := .some 10 } : Protocol.OptionsSet)
|
||||||
({ }: Protocol.OptionsSetResult)
|
({ }: Protocol.OptionsSetResult)
|
||||||
|
@ -277,9 +277,9 @@ def test_frontend_process_sorry : Test := do
|
||||||
def test_import_open : Test := do
|
def test_import_open : Test := do
|
||||||
let header := "import Init\nopen Nat\nuniverse u"
|
let header := "import Init\nopen Nat\nuniverse u"
|
||||||
let goal1: Protocol.Goal := {
|
let goal1: Protocol.Goal := {
|
||||||
name := "_uniq.67",
|
name := "_uniq.77",
|
||||||
target := { pp? := .some "n + 1 = n.succ" },
|
target := { pp? := .some "n + 1 = n.succ" },
|
||||||
vars := #[{ name := "_uniq.66", userName := "n", type? := .some { pp? := .some "Nat" }}],
|
vars := #[{ name := "_uniq.76", userName := "n", type? := .some { pp? := .some "Nat" }}],
|
||||||
}
|
}
|
||||||
step "frontend.process"
|
step "frontend.process"
|
||||||
({
|
({
|
||||||
|
@ -294,7 +294,7 @@ def test_import_open : Test := do
|
||||||
],
|
],
|
||||||
}: Protocol.FrontendProcessResult)
|
}: Protocol.FrontendProcessResult)
|
||||||
step "goal.start" ({ expr := "∀ (n : Nat), n + 1 = Nat.succ n"} : Protocol.GoalStart)
|
step "goal.start" ({ expr := "∀ (n : Nat), n + 1 = Nat.succ n"} : Protocol.GoalStart)
|
||||||
({ stateId := 0, root := "_uniq.65" }: Protocol.GoalStartResult)
|
({ stateId := 0, root := "_uniq.75" }: Protocol.GoalStartResult)
|
||||||
step "goal.tactic" ({ stateId := 0, tactic? := .some "intro n" }: Protocol.GoalTactic)
|
step "goal.tactic" ({ stateId := 0, tactic? := .some "intro n" }: Protocol.GoalTactic)
|
||||||
({ nextStateId? := .some 1, goals? := #[goal1], }: Protocol.GoalTacticResult)
|
({ nextStateId? := .some 1, goals? := #[goal1], }: Protocol.GoalTacticResult)
|
||||||
step "goal.tactic" ({ stateId := 1, tactic? := .some "apply add_one" }: Protocol.GoalTactic)
|
step "goal.tactic" ({ stateId := 1, tactic? := .some "apply add_one" }: Protocol.GoalTactic)
|
||||||
|
|
|
@ -25,8 +25,8 @@ def test_instantiate_mvar: TestM Unit := do
|
||||||
addTest $ assertUnreachable e
|
addTest $ assertUnreachable e
|
||||||
return ()
|
return ()
|
||||||
let t ← Lean.Meta.inferType expr
|
let t ← Lean.Meta.inferType expr
|
||||||
addTest $ LSpec.check "typing" ((toString (← serializeExpressionSexp t)) =
|
checkEq "typing" (toString (← serializeExpressionSexp t))
|
||||||
"((:c LE.le) (:c Nat) (:c instLENat) ((:c OfNat.ofNat) (:mv _uniq.2) (:lit 2) (:mv _uniq.3)) ((:c OfNat.ofNat) (:mv _uniq.14) (:lit 5) (:mv _uniq.15)))")
|
"((:c LE.le) (:c Nat) (:c instLENat) ((:c OfNat.ofNat) (:mv _uniq.2) (:lit 2) (:mv _uniq.3)) ((:c OfNat.ofNat) (:mv _uniq.15) (:lit 5) (:mv _uniq.16)))"
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
def startProof (expr: String): TestM (Option GoalState) := do
|
def startProof (expr: String): TestM (Option GoalState) := do
|
||||||
|
@ -118,8 +118,9 @@ def test_m_couple_simp: TestM Unit := do
|
||||||
let serializedState1 ← state1.serializeGoals (options := { ← read with printDependentMVars := true })
|
let serializedState1 ← state1.serializeGoals (options := { ← read with printDependentMVars := true })
|
||||||
addTest $ LSpec.check "apply Nat.le_trans" (serializedState1.map (·.target.pp?) =
|
addTest $ LSpec.check "apply Nat.le_trans" (serializedState1.map (·.target.pp?) =
|
||||||
#[.some "2 ≤ ?m", .some "?m ≤ 5", .some "Nat"])
|
#[.some "2 ≤ ?m", .some "?m ≤ 5", .some "Nat"])
|
||||||
|
let n := state1.goals[2]!
|
||||||
addTest $ LSpec.check "(metavariables)" (serializedState1.map (·.target.dependentMVars?.get!) =
|
addTest $ LSpec.check "(metavariables)" (serializedState1.map (·.target.dependentMVars?.get!) =
|
||||||
#[#["_uniq.38"], #["_uniq.38"], #[]])
|
#[#[toString n.name], #[toString n.name], #[]])
|
||||||
|
|
||||||
let state2 ← match ← state1.tacticOn (goalId := 2) (tactic := "exact 2") with
|
let state2 ← match ← state1.tacticOn (goalId := 2) (tactic := "exact 2") with
|
||||||
| .success state _ => pure state
|
| .success state _ => pure state
|
||||||
|
@ -158,10 +159,10 @@ def test_m_couple_simp: TestM Unit := do
|
||||||
addTest $ assertUnreachable "(5 root)"
|
addTest $ assertUnreachable "(5 root)"
|
||||||
return ()
|
return ()
|
||||||
let rootStr: String := toString (← Lean.Meta.ppExpr root)
|
let rootStr: String := toString (← Lean.Meta.ppExpr root)
|
||||||
addTest $ LSpec.check "(5 root)" (rootStr = "Nat.le_trans (of_eq_true (Init.Data.Nat.Basic._auxLemma.4 2)) (of_eq_true (eq_true_of_decide (Eq.refl true)))")
|
checkEq "(5 root)" rootStr "Nat.le_trans (of_eq_true (_proof_4✝ 2)) (of_eq_true (eq_true_of_decide (Eq.refl true)))"
|
||||||
let unfoldedRoot ← unfoldAuxLemmas root
|
let unfoldedRoot ← unfoldAuxLemmas root
|
||||||
addTest $ LSpec.check "(5 root)" ((toString (← Lean.Meta.ppExpr unfoldedRoot)) =
|
checkEq "(5 root)" (toString (← Lean.Meta.ppExpr unfoldedRoot))
|
||||||
"Nat.le_trans (of_eq_true (eq_true (Nat.le_refl 2))) (of_eq_true (eq_true_of_decide (Eq.refl true)))")
|
"Nat.le_trans (of_eq_true (_proof_4✝ 2)) (of_eq_true (eq_true_of_decide (Eq.refl true)))"
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
def test_proposition_generation: TestM Unit := do
|
def test_proposition_generation: TestM Unit := do
|
||||||
|
@ -258,7 +259,7 @@ def test_partial_continuation: TestM Unit := do
|
||||||
|
|
||||||
-- Continuation should fail if the state does not exist:
|
-- Continuation should fail if the state does not exist:
|
||||||
match state0.resume coupled_goals with
|
match state0.resume coupled_goals with
|
||||||
| .error error => addTest $ LSpec.check "(continuation failure message)" (error = "Goals [_uniq.40, _uniq.41, _uniq.38, _uniq.47] are not in scope")
|
| .error error => addTest $ LSpec.check "(continuation failure message)" (error = "Goals [_uniq.44, _uniq.45, _uniq.42, _uniq.51] are not in scope")
|
||||||
| .ok _ => addTest $ assertUnreachable "(continuation failure)"
|
| .ok _ => addTest $ assertUnreachable "(continuation failure)"
|
||||||
-- Continuation should fail if some goals have not been solved
|
-- Continuation should fail if some goals have not been solved
|
||||||
match state2.continue state1 with
|
match state2.continue state1 with
|
||||||
|
|
|
@ -7,9 +7,6 @@ open Lean
|
||||||
|
|
||||||
namespace Pantograph.Test.Serial
|
namespace Pantograph.Test.Serial
|
||||||
|
|
||||||
def tempPath : IO System.FilePath := do
|
|
||||||
Prod.snd <$> IO.FS.createTempFile
|
|
||||||
|
|
||||||
structure MultiState where
|
structure MultiState where
|
||||||
coreContext : Core.Context
|
coreContext : Core.Context
|
||||||
env: Environment
|
env: Environment
|
||||||
|
@ -35,7 +32,7 @@ def test_environment_pickling : TestM Unit := do
|
||||||
let coreDst : Core.State := { env := ← getEnv }
|
let coreDst : Core.State := { env := ← getEnv }
|
||||||
|
|
||||||
let name := `mystery
|
let name := `mystery
|
||||||
let envPicklePath ← tempPath
|
IO.FS.withTempFile λ _ envPicklePath => do
|
||||||
let ((), _) ← runCoreM coreSrc do
|
let ((), _) ← runCoreM coreSrc do
|
||||||
let type: Expr := .forallE `p (.sort 0) (.forallE `h (.bvar 0) (.bvar 1) .default) .default
|
let type: Expr := .forallE `p (.sort 0) (.forallE `h (.bvar 0) (.bvar 1) .default) .default
|
||||||
let value: Expr := .lam `p (.sort 0) (.lam `h (.bvar 0) (.bvar 0) .default) .default
|
let value: Expr := .lam `p (.sort 0) (.lam `h (.bvar 0) (.bvar 0) .default) .default
|
||||||
|
@ -56,13 +53,10 @@ def test_environment_pickling : TestM Unit := do
|
||||||
let anotherName := `mystery2
|
let anotherName := `mystery2
|
||||||
checkTrue s!"Doesn't have symbol {anotherName}" (env'.find? anotherName).isNone
|
checkTrue s!"Doesn't have symbol {anotherName}" (env'.find? anotherName).isNone
|
||||||
|
|
||||||
IO.FS.removeFile envPicklePath
|
|
||||||
|
|
||||||
def test_goal_state_pickling_simple : TestM Unit := do
|
def test_goal_state_pickling_simple : TestM Unit := do
|
||||||
let coreSrc : Core.State := { env := ← getEnv }
|
let coreSrc : Core.State := { env := ← getEnv }
|
||||||
let coreDst : Core.State := { env := ← getEnv }
|
let coreDst : Core.State := { env := ← getEnv }
|
||||||
let statePath ← tempPath
|
IO.FS.withTempFile λ _ statePath => do
|
||||||
|
|
||||||
let type: Expr := .forallE `p (.sort 0) (.forallE `h (.bvar 0) (.bvar 1) .default) .default
|
let type: Expr := .forallE `p (.sort 0) (.forallE `h (.bvar 0) (.bvar 1) .default) .default
|
||||||
let stateGenerate : MetaM GoalState := runTermElabMInMeta do
|
let stateGenerate : MetaM GoalState := runTermElabMInMeta do
|
||||||
GoalState.create type
|
GoalState.create type
|
||||||
|
@ -78,8 +72,6 @@ def test_goal_state_pickling_simple : TestM Unit := do
|
||||||
let types ← metaM.run'
|
let types ← metaM.run'
|
||||||
checkTrue "Goals" $ types[0]!.equal type
|
checkTrue "Goals" $ types[0]!.equal type
|
||||||
|
|
||||||
IO.FS.removeFile statePath
|
|
||||||
|
|
||||||
structure Test where
|
structure Test where
|
||||||
name : String
|
name : String
|
||||||
routine: TestM Unit
|
routine: TestM Unit
|
||||||
|
|
24
flake.lock
24
flake.lock
|
@ -5,11 +5,11 @@
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1743550720,
|
"lastModified": 1749398372,
|
||||||
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
|
"narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
|
"rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -44,11 +44,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1743534244,
|
"lastModified": 1750275702,
|
||||||
"narHash": "sha256-WnoYs2iyrfgh35eXErCOyos8E2YbW3LT1xm/EtT88/k=",
|
"narHash": "sha256-CpwSdtwvrQCR+ZfXZweFHJMG583EYijCRGEeGrgBsjU=",
|
||||||
"owner": "lenianiva",
|
"owner": "lenianiva",
|
||||||
"repo": "lean4-nix",
|
"repo": "lean4-nix",
|
||||||
"rev": "5eb7f03be257e327fdb3cca9465392e68dc28a4d",
|
"rev": "95a315f6e7d5e463090ae4977d5e2e6c3b4ef0d0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -59,11 +59,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1743975612,
|
"lastModified": 1750151854,
|
||||||
"narHash": "sha256-o4FjFOUmjSRMK7dn0TFdAT0RRWUWD+WsspPHa+qEQT8=",
|
"narHash": "sha256-3za+1J9FifMetO7E/kwgyW+dp+8pPBNlWKfcBovnn6M=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "a880f49904d68b5e53338d1e8c7bf80f59903928",
|
"rev": "ad5c70bcc5cc5178205161b7a7d61a6e80f6d244",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -75,11 +75,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs-lib": {
|
"nixpkgs-lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1743296961,
|
"lastModified": 1748740939,
|
||||||
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
|
"narHash": "sha256-rQaysilft1aVMwF14xIdGS3sj1yHlI6oKQNBRTF40cc=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs.lib",
|
"repo": "nixpkgs.lib",
|
||||||
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
|
"rev": "656a64127e9d791a334452c6b6606d17539476e2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
leanprover/lean4:v4.19.0
|
leanprover/lean4:v4.20.1
|
||||||
|
|
Loading…
Reference in New Issue