88namespace ProofWidgets
99open Lean Server
1010
11- /-- The `State` is expected to have a `ToJson` instance that returns an object,
12- where the keys are field names (as strings) and the values are the field
13- values (as numbers, strings, arrays, or objects). -/
14- structure Step (State TransitionLabel : Type ) where
15- label : TransitionLabel
16- postState : State
17- deriving Repr, Inhabited
18-
19- structure Trace (State TransitionLabel : Type ) where
20- start : State
21- steps : List (Step State TransitionLabel)
22- deriving Repr, Inhabited
23-
24- instance jsonOfTrace {State TransitionLabel : Type } [ToJson State] [ToJson TransitionLabel] : ToJson (Trace State TransitionLabel) where
25- toJson := fun tr =>
26- let states : Array Json :=
27- #[ Json.mkObj
28- [ ("index" , toJson 0 ),
29- ("fields" , toJson tr.start),
30- ("transition" , "after_init" ) ]] ++
31- (tr.steps.toArray.mapIdx (fun i st =>
32- let idx := i + 1
33- Json.mkObj
34- [ ("index" , toJson idx),
35- ("fields" , toJson st.postState),
36- ("transition" , toJson st.label)]))
37- Json.arr states
38-
3911structure TraceDisplayProps where
40- /-- The trace to display, as the JSON-encoded value of a `Trace ` instance. -/
41- trace : Json
12+ /-- The model checking result to display, as the JSON-encoded value of a `ModelCheckingResult ` instance. -/
13+ result : Json
4214 /-- Display orientation: "vertical" or "horizontal" -/
4315 layout : String := "vertical"
4416deriving RpcEncodable
@@ -49,14 +21,14 @@ def TraceDisplayViewer : Component TraceDisplayProps where
4921
5022namespace DisplayTraceCommand
5123
52- /-- Display a value of type `Json` (obtained from a `Trace ` instance) in the infoview. -/
24+ /-- Display a value of type `Json` (obtained from a `ModelCheckingResult ` instance) in the infoview. -/
5325syntax (name := displayTraceCmd) "#displayTrace " term : command
5426
5527open Lean Elab Command in
5628@ [command_elab displayTraceCmd]
5729def elabDisplayTraceCmd : CommandElab := fun
58- | stx@`(#displayTrace $trace ) => do
59- let t ← `(open ProofWidgets.Jsx in <TraceDisplayViewer trace ={$trace } layout={"vertical" } />)
30+ | stx@`(#displayTrace $result ) => do
31+ let t ← `(open ProofWidgets.Jsx in <TraceDisplayViewer result ={$result } layout={"vertical" } />)
6032 let html ← ← liftTermElabM <| ProofWidgets.HtmlCommand.evalCommandMHtml <| ← ``(HtmlEval.eval $t)
6133 liftCoreM <| Widget.savePanelWidgetInfo
6234 (hash HtmlDisplayPanel.javascript)
0 commit comments