Skip to content

Commit 84fc89d

Browse files
committed
rename discard to record
1 parent f867ab2 commit 84fc89d

12 files changed

+32
-59
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Commands may be of the form
2121
```
2222

2323
```json
24-
{ "cmd" : "example : f = 2 := rfl", "env" : 1, "discard": true }
24+
{ "cmd" : "example : f = 2 := rfl", "env" : 1, "record": true }
2525
```
2626

2727
The input includes:
2828
* A required `cmd` field containing the Lean command to execute
2929
* An optional `env` field specifying a previous environment ID to build upon
30-
* An optional `discard` field (default: false) to discard the environment after execution
30+
* An optional `record` field (default: false) to record the environment after execution
3131
* Optional fields for additional information:
3232
* `allTactics`: when true, includes all tactic steps in the response
3333
* `rootGoals`: when true, includes root goals as sorries
@@ -46,7 +46,7 @@ You can backtrack simply by using earlier values for `env`.
4646
The response includes:
4747
* A numeric label for the `Environment` after your command,
4848
which you can use as the starting point for subsequent commands.
49-
This will be `none` if `discard` was enabled.
49+
This will be `none` if `record` was enabled.
5050
* Any messages generated while processing your command.
5151
* A list of the `sorry`s in your command, including
5252
* their expected type, and

REPL/JSON.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ structure CommandOptions where
2323
/-- Run Lean commands.
2424
If `env = none`, starts a new session (in which you can use `import`).
2525
If `env = some n`, builds on the existing environment `n`.
26-
Setting `discard = true` will discard the environment after execution, useful for memory management.
27-
When `discard = true`, the response's `env` field will be `none`.
26+
Setting `record = false` will discard the environment after execution, useful for memory management.
27+
When `record = false`, the response's `env` field will be `none`.
2828
-/
2929
structure Command extends CommandOptions where
3030
env : Option Nat
3131
cmd : String
32-
discard : Option Bool := false
32+
record : Option Bool := true
3333
deriving ToJson, FromJson
3434

3535
/-- Process a Lean file in a fresh environment. -/

REPL/Main.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,12 @@ def runCommand (s : Command) : M IO (CommandResponse ⊕ Error) := do
322322
fileMap := default,
323323
snap? := none,
324324
cancelTk? := none } }
325-
let env ← match s.discard with
326-
| some true => pure none
327-
| _ => do
325+
let env ← match s.record with
326+
| some true =>
328327
let id ← recordCommandSnapshot cmdSnapshot
329328
pure (some id)
329+
| _ => do pure none
330+
330331
let jsonTrees := match s.infotree with
331332
| some "full" => trees
332333
| some "tactics" => trees.flatMap InfoTree.retainTacticInfo

test/Mathlib/test/discardCmd.expected.out

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{}
2+
3+
{"message": "Unknown environment."}
4+
5+
{"message": "Unknown proof state."}
6+
7+
{"message": "Unknown environment."}
8+
9+
{"message": "Unknown proof state."}
10+

test/Mathlib/test/discardCmd.in renamed to test/Mathlib/test/record_cmd.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{"cmd": "import Mathlib"}
22

3-
{"cmd": "theorem mathd_numbertheory_345 : (2000 + 2001 + 2002 + 2003 + 2004 + 2005 + 2006) % 7 = 0 := sorry", "env":0, "discard": true}
3+
{"cmd": "theorem mathd_numbertheory_345 : (2000 + 2001 + 2002 + 2003 + 2004 + 2005 + 2006) % 7 = 0 := sorry", "env":0, "record": false}
44

55
{"tactic": "norm_num", "proofState": 0}
66

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{"env": 0}
1+
{}
22

33
{"messages":
44
[{"severity": "info",
@@ -8,10 +8,5 @@
88

99
{"message": "Unknown environment."}
1010

11-
{"messages":
12-
[{"severity": "info",
13-
"pos": {"line": 1, "column": 0},
14-
"endPos": {"line": 1, "column": 5},
15-
"data": "37"}],
16-
"env": 1}
11+
{"message": "Unknown environment."}
1712

test/discardCmd.in renamed to test/record_cmd.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{"cmd": "def f := 37"}
22

3-
{"cmd": "#eval true", "discard": true}
3+
{"cmd": "#eval true", "record": false}
44

55
{"cmd": "#eval false", "env":1}
66

test/discardCmd2.expected.out renamed to test/record_cmd2.expected.out

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
{"severity": "error",
77
"pos": {"line": 1, "column": 18},
88
"endPos": {"line": 1, "column": 20},
9-
"data": "unsolved goals\n⊢ 2 = 2"}],
10-
"env": 0}
9+
"data": "unsolved goals\n⊢ 2 = 2"}]}
1110

1211
{"messages":
1312
[{"severity": "info",
1413
"pos": {"line": 1, "column": 0},
1514
"endPos": {"line": 2, "column": 3},
16-
"data": "Goals accomplished!"}],
17-
"env": 1}
15+
"data": "Goals accomplished!"}]}
1816

1917
{"messages":
2018
[{"severity": "error",

test/discardCmd2.in renamed to test/record_cmd2.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
{"cmd": "example : 2=2 := by\nrfl"}
44

5-
{"cmd": "theorem gc_demo (P Q R : Prop) : (P → Q) → (Q → R) → (P → R) := by", "discard": true}
5+
{"cmd": "theorem gc_demo (P Q R : Prop) : (P → Q) → (Q → R) → (P → R) := by", "record": false}
66

7-
{"cmd": "theorem gc_demo (P Q R : Prop) : (P → Q) → (Q → R) → (P → R) := by\nintro h1 h2 p", "discard": true}
7+
{"cmd": "theorem gc_demo (P Q R : Prop) : (P → Q) → (Q → R) → (P → R) := by\nintro h1 h2 p", "record": false}
88

9-
{"cmd": "theorem gc_demo (P Q R : Prop) : (P → Q) → (Q → R) → (P → R) := by\nintro h1 h2 p\napply?", "discard": true}
9+
{"cmd": "theorem gc_demo (P Q R : Prop) : (P → Q) → (Q → R) → (P → R) := by\nintro h1 h2 p\napply?", "record": false}

0 commit comments

Comments
 (0)