Pantograph/Pantograph/Commands.lean

157 lines
4.3 KiB
Plaintext
Raw Normal View History

/-
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
/-- Main Option structure, placed here to avoid name collision -/
structure Options where
-- 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
-- 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
-- See `pp.auxDecls`
printAuxDecls: Bool := false
-- See `pp.implementationDetailHyps`
printImplementationDetailHyps: Bool := false
deriving Lean.ToJson
2023-08-14 21:43:40 -07:00
abbrev OptionsT := ReaderT Options
--- 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 -/
isInaccessible?: Option Bool := .none
type?: Option Expression := .none
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 ---
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 ---
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
-- Return the type of an expression
structure ExprEcho where
expr: String
deriving Lean.FromJson
structure ExprEchoResult where
expr: Expression
type: Expression
deriving Lean.ToJson
2023-05-17 21:58:03 -07:00
-- Print all symbols in environment
structure LibCatalog where
2023-05-17 21:58:03 -07:00
deriving Lean.FromJson
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
-- Print the type of a symbol
structure LibInspect where
2023-05-22 19:45:08 -07:00
name: String
-- If true/false, show/hide the value expressions; By default definitions
-- values are shown and theorem values are hidden.
value?: Option Bool := .some false
deriving Lean.FromJson
structure LibInspectResult where
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
/-- 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
deriving Lean.FromJson
structure OptionsSetResult where
deriving Lean.ToJson
structure OptionsPrint where
2023-05-25 13:40:03 -07:00
deriving Lean.FromJson
abbrev OptionsPrintResult := Options
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
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
goalId: Nat
2023-05-21 17:41:39 -07:00
tactic: String
deriving Lean.FromJson
structure ProofTacticResult where
-- Existence of this field shows success
goals?: Option (Array Goal) := .none
-- Next proof state id, if successful
goalIds?: Option (Array Nat) := .none
-- Existence of this field shows failure
tacticErrors?: Option (Array String) := .none
2023-05-21 17:41:39 -07:00
deriving Lean.ToJson
2023-05-17 21:58:03 -07:00
2023-05-09 18:01:09 -07:00
end Pantograph.Commands