-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show proof states after =>, and not after semicolons (#27)
- Loading branch information
1 parent
aa1d3c1
commit 866dd83
Showing
6 changed files
with
267 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
|
||
import SubVerso.Examples | ||
import SubVerso.Highlighting.Highlighted | ||
|
||
/-! These are SubVerso tests that don't involve a subprocess, to make development easier. -/ | ||
|
||
|
||
open SubVerso Examples | ||
|
||
partial def SubVerso.Highlighting.Highlighted.asString (hl : Highlighted) : String := Id.run do | ||
let mut out := "" | ||
match hl with | ||
| .seq hls => | ||
for x in hls.map asString do | ||
out := out ++ x | ||
| .span _ hl' => | ||
out := out ++ hl'.asString | ||
| .tactics _ _ _ hl' => | ||
out := out ++ hl'.asString | ||
| .point .. => pure () | ||
| .text s => out := out ++ s | ||
| .token t => out := out ++ t.content | ||
out | ||
|
||
|
||
partial def SubVerso.Highlighting.Highlighted.proofStates (hl : Highlighting.Highlighted) : Array (String × Array (Goal String)) := Id.run do | ||
let mut out := #[] | ||
match hl with | ||
| .seq hls => | ||
for x in hls.map proofStates do | ||
out := out ++ x | ||
| .span _ hl' => | ||
out := out ++ hl'.proofStates | ||
| .tactics info _ _ hl' => | ||
out := out.push (hl'.asString, info.map (·.map (·.asString))) | ||
| _ => pure () | ||
out | ||
|
||
%example proof | ||
theorem test (n : Nat) : n * 1 = n := by | ||
induction n with | ||
| zero => rfl | ||
| succ n ih => | ||
rw [← ih] | ||
cases n | ||
next => simp | ||
case' succ => | ||
skip | ||
case succ => | ||
. skip; simp | ||
%end | ||
|
||
%dump proof into proofJson | ||
|
||
%dumpE proof into proofEx | ||
|
||
|
||
|
||
-- We don't have #guard_msgs in all supported Lean versions, so here's a dumb replacement: | ||
|
||
open Lean Elab Command in | ||
elab "#evalString" s:str e:term : command => do | ||
let msgs ← MonadMessageState.getMessages | ||
try | ||
MonadMessageState.setMessages {} | ||
elabCommand <| ← `(#eval $e) | ||
let msgs' ← MonadMessageState.getMessages | ||
let [msg] := msgs'.toList | ||
| throwError "Too many messages" | ||
if (← msg.toString) != s.getString then | ||
throwErrorAt e "Expected {s.getString}, got {← msg.toString}" | ||
finally | ||
MonadMessageState.setMessages msgs | ||
|
||
#evalString "[[some `zero], [some `succ], [none], [some `succ.succ], [none]]\n" | ||
(proofEx.highlighted[0].proofStates.data.filter (·.fst == "=>") |>.map (·.snd.data.map (·.name))) | ||
|
||
|
||
|
||
def main : IO Unit := pure () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters