2023-05-24 22:33:10 -07:00
|
|
|
|
/-
|
|
|
|
|
All the command input/output structures are stored here
|
|
|
|
|
|
|
|
|
|
Note that no command other than `InteractionError` may have `error` as one of
|
|
|
|
|
its field names to avoid confusion with error messages generated by the REPL.
|
|
|
|
|
-/
|
2023-05-09 18:01:09 -07:00
|
|
|
|
import Lean.Data.Json
|
|
|
|
|
|
|
|
|
|
namespace Pantograph.Commands
|
|
|
|
|
|
2023-08-14 17:07:53 -07:00
|
|
|
|
|
|
|
|
|
/-- Main Option structure, placed here to avoid name collision -/
|
|
|
|
|
structure Options where
|
2023-08-16 19:25:32 -07:00
|
|
|
|
-- When false, suppress newlines in Json objects. Useful for machine-to-machine interaction.
|
|
|
|
|
-- This should be false` by default to avoid any surprises with parsing.
|
|
|
|
|
printJsonPretty: Bool := false
|
2023-08-14 17:07:53 -07:00
|
|
|
|
-- When enabled, pretty print every expression
|
|
|
|
|
printExprPretty: Bool := true
|
|
|
|
|
-- When enabled, print the raw AST of expressions
|
|
|
|
|
printExprAST: Bool := false
|
|
|
|
|
-- When enabled, the types and values of persistent variables in a proof goal
|
|
|
|
|
-- are not shown unless they are new to the proof step. Reduces overhead
|
|
|
|
|
proofVariableDelta: Bool := false
|
2023-08-15 15:40:54 -07:00
|
|
|
|
-- See `pp.auxDecls`
|
|
|
|
|
printAuxDecls: Bool := false
|
|
|
|
|
-- See `pp.implementationDetailHyps`
|
|
|
|
|
printImplementationDetailHyps: Bool := false
|
2023-08-14 17:07:53 -07:00
|
|
|
|
deriving Lean.ToJson
|
|
|
|
|
|
2023-08-14 21:43:40 -07:00
|
|
|
|
abbrev OptionsT := ReaderT Options
|
|
|
|
|
|
2023-08-14 17:07:53 -07:00
|
|
|
|
--- Expression Objects ---
|
|
|
|
|
|
|
|
|
|
structure BoundExpression where
|
|
|
|
|
binders: Array (String × String)
|
|
|
|
|
target: String
|
|
|
|
|
deriving Lean.ToJson
|
|
|
|
|
structure Expression where
|
|
|
|
|
-- Pretty printed expression
|
|
|
|
|
pp?: Option String := .none
|
|
|
|
|
-- AST structure
|
|
|
|
|
sexp?: Option String := .none
|
|
|
|
|
deriving Lean.ToJson
|
|
|
|
|
|
|
|
|
|
structure Variable where
|
|
|
|
|
name: String
|
|
|
|
|
/-- Does the name contain a dagger -/
|
2023-08-15 15:40:54 -07:00
|
|
|
|
isInaccessible?: Option Bool := .none
|
|
|
|
|
type?: Option Expression := .none
|
2023-08-14 17:07:53 -07:00
|
|
|
|
value?: Option Expression := .none
|
|
|
|
|
deriving Lean.ToJson
|
|
|
|
|
structure Goal where
|
|
|
|
|
/-- String case id -/
|
|
|
|
|
caseName?: Option String := .none
|
|
|
|
|
/-- Is the goal in conversion mode -/
|
|
|
|
|
isConversion: Bool := false
|
|
|
|
|
/-- target expression type -/
|
|
|
|
|
target: Expression
|
|
|
|
|
/-- Variables -/
|
|
|
|
|
vars: Array Variable := #[]
|
|
|
|
|
deriving Lean.ToJson
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- Individual Commands and return types ---
|
|
|
|
|
|
2023-05-20 15:58:38 -07:00
|
|
|
|
structure Command where
|
|
|
|
|
cmd: String
|
|
|
|
|
payload: Lean.Json
|
|
|
|
|
deriving Lean.FromJson
|
|
|
|
|
|
|
|
|
|
structure InteractionError where
|
|
|
|
|
error: String
|
|
|
|
|
desc: String
|
|
|
|
|
deriving Lean.ToJson
|
|
|
|
|
|
|
|
|
|
|
2023-08-13 21:19:06 -07:00
|
|
|
|
--- Individual command and return types ---
|
|
|
|
|
|
2023-08-16 19:25:32 -07:00
|
|
|
|
|
|
|
|
|
structure Reset where
|
2023-08-13 21:19:06 -07:00
|
|
|
|
deriving Lean.FromJson
|
2023-08-27 19:58:52 -07:00
|
|
|
|
structure Stat where
|
|
|
|
|
deriving Lean.FromJson
|
|
|
|
|
structure StatResult where
|
|
|
|
|
-- Number of goals states
|
|
|
|
|
nGoals: Nat
|
2023-08-13 21:19:06 -07:00
|
|
|
|
deriving Lean.ToJson
|
2023-05-20 15:58:38 -07:00
|
|
|
|
|
2023-08-16 19:25:32 -07:00
|
|
|
|
-- Return the type of an expression
|
|
|
|
|
structure ExprEcho where
|
|
|
|
|
expr: String
|
2023-08-14 17:07:53 -07:00
|
|
|
|
deriving Lean.FromJson
|
2023-08-16 19:25:32 -07:00
|
|
|
|
structure ExprEchoResult where
|
|
|
|
|
expr: Expression
|
|
|
|
|
type: Expression
|
|
|
|
|
deriving Lean.ToJson
|
2023-05-17 21:58:03 -07:00
|
|
|
|
|
2023-05-20 15:58:38 -07:00
|
|
|
|
-- Print all symbols in environment
|
2023-08-16 19:25:32 -07:00
|
|
|
|
structure LibCatalog where
|
2023-05-17 21:58:03 -07:00
|
|
|
|
deriving Lean.FromJson
|
2023-08-16 19:25:32 -07:00
|
|
|
|
structure LibCatalogResult where
|
2023-05-27 23:10:39 -07:00
|
|
|
|
symbols: Array String
|
2023-05-09 22:51:19 -07:00
|
|
|
|
deriving Lean.ToJson
|
2023-05-20 15:58:38 -07:00
|
|
|
|
-- Print the type of a symbol
|
2023-08-16 19:25:32 -07:00
|
|
|
|
structure LibInspect where
|
2023-05-22 19:45:08 -07:00
|
|
|
|
name: String
|
2023-08-14 17:07:53 -07:00
|
|
|
|
-- If true/false, show/hide the value expressions; By default definitions
|
|
|
|
|
-- values are shown and theorem values are hidden.
|
|
|
|
|
value?: Option Bool := .some false
|
2023-05-20 14:04:09 -07:00
|
|
|
|
deriving Lean.FromJson
|
2023-08-16 19:25:32 -07:00
|
|
|
|
structure LibInspectResult where
|
2023-08-14 17:07:53 -07:00
|
|
|
|
type: Expression
|
|
|
|
|
value?: Option Expression := .none
|
2023-05-22 16:00:41 -07:00
|
|
|
|
module?: Option String
|
2023-05-25 13:40:03 -07:00
|
|
|
|
deriving Lean.ToJson
|
|
|
|
|
|
2023-08-16 19:25:32 -07:00
|
|
|
|
/-- Set options; See `Options` struct above for meanings -/
|
|
|
|
|
structure OptionsSet where
|
|
|
|
|
printJsonPretty?: Option Bool
|
|
|
|
|
printExprPretty?: Option Bool
|
|
|
|
|
printExprAST?: Option Bool
|
|
|
|
|
proofVariableDelta?: Option Bool
|
|
|
|
|
printAuxDecls?: Option Bool
|
|
|
|
|
printImplementationDetailHyps?: Option Bool
|
2023-08-15 15:40:54 -07:00
|
|
|
|
deriving Lean.FromJson
|
2023-08-16 19:25:32 -07:00
|
|
|
|
structure OptionsSetResult where
|
2023-05-26 16:55:33 -07:00
|
|
|
|
deriving Lean.ToJson
|
2023-08-16 19:25:32 -07:00
|
|
|
|
structure OptionsPrint where
|
2023-05-25 13:40:03 -07:00
|
|
|
|
deriving Lean.FromJson
|
2023-08-16 19:25:32 -07:00
|
|
|
|
abbrev OptionsPrintResult := Options
|
2023-05-20 14:04:09 -07:00
|
|
|
|
|
2023-05-21 17:41:39 -07:00
|
|
|
|
structure ProofStart where
|
|
|
|
|
-- Only one of the fields below may be populated.
|
2023-05-22 00:49:37 -07:00
|
|
|
|
expr: Option String -- Proof expression
|
|
|
|
|
copyFrom: Option String -- Theorem name
|
2023-05-17 21:58:03 -07:00
|
|
|
|
deriving Lean.FromJson
|
2023-05-21 17:41:39 -07:00
|
|
|
|
structure ProofStartResult where
|
2023-08-27 19:53:09 -07:00
|
|
|
|
goalId: Nat := 0 -- Proof tree id
|
2023-05-21 17:41:39 -07:00
|
|
|
|
deriving Lean.ToJson
|
|
|
|
|
structure ProofTactic where
|
2023-05-22 19:45:08 -07:00
|
|
|
|
-- Identifiers for tree, state, and goal
|
2023-08-27 19:53:09 -07:00
|
|
|
|
goalId: Nat
|
2023-05-21 17:41:39 -07:00
|
|
|
|
tactic: String
|
|
|
|
|
deriving Lean.FromJson
|
2023-08-15 15:40:54 -07:00
|
|
|
|
structure ProofTacticResult where
|
|
|
|
|
-- Existence of this field shows success
|
|
|
|
|
goals?: Option (Array Goal) := .none
|
|
|
|
|
-- Next proof state id, if successful
|
2023-08-27 19:53:09 -07:00
|
|
|
|
goalIds?: Option (Array Nat) := .none
|
2023-08-15 15:40:54 -07:00
|
|
|
|
-- Existence of this field shows failure
|
|
|
|
|
tacticErrors?: Option (Array String) := .none
|
2023-05-21 17:41:39 -07:00
|
|
|
|
deriving Lean.ToJson
|
2023-08-27 19:53:09 -07:00
|
|
|
|
|
2023-05-17 21:58:03 -07:00
|
|
|
|
|
2023-05-09 18:01:09 -07:00
|
|
|
|
end Pantograph.Commands
|