| /- |
| 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. |
| -/ |
| import Pantograph.Goal |
|
|
| import Lean.Data.Json |
| import Lean.Data.Position |
| import Lean.Message |
|
|
| namespace Pantograph.Protocol |
|
|
| open Lean (Json ToJson FromJson Position Name) |
|
|
| / |
| structure Options where |
| |
| |
| printJsonPretty: Bool := false |
| |
| printExprPretty: Bool := true |
| |
| printExprAST: Bool := false |
| printDependentMVars: Bool := false |
| |
| |
| |
| noRepeat: Bool := false |
| |
| printAuxDecls: Bool := false |
| |
| printImplementationDetailHyps: Bool := false |
| |
| automaticMode: Bool := true |
| |
| timeout: Nat := 0 |
| deriving ToJson |
|
|
| abbrev OptionsT := ReaderT Options |
|
|
| / |
| structure OptionsSet where |
| printJsonPretty?: Option Bool := .none |
| printExprPretty?: Option Bool := .none |
| printExprAST?: Option Bool := .none |
| printDependentMVars?: Option Bool := .none |
| noRepeat?: Option Bool := .none |
| printAuxDecls?: Option Bool := .none |
| printImplementationDetailHyps?: Option Bool := .none |
| automaticMode?: Option Bool := .none |
| timeout?: Option Nat := .none |
| deriving FromJson |
| structure OptionsSetResult where |
| deriving ToJson |
| structure OptionsPrint where |
| deriving FromJson |
|
|
| |
|
|
| structure BoundExpression where |
| binders: Array (String × String) |
| target: String |
| deriving ToJson |
| structure Expression where |
| |
| pp?: Option String := .none |
| |
| sexp?: Option String := .none |
| dependentMVars?: Option (Array Name) := .none |
| deriving ToJson |
|
|
| structure Variable where |
| / |
| name: Name := .anonymous |
| / |
| userName: Name |
| / |
| isInaccessible: Bool := false |
| type?: Option Expression := .none |
| value?: Option Expression := .none |
| deriving ToJson |
| inductive Fragment where |
| | tactic |
| | conv |
| | calc |
| deriving BEq, DecidableEq, Repr, ToJson |
| structure Goal where |
| / |
| name : Name := .anonymous |
| / |
| userName? : Option Name := .none |
| fragment : Fragment := .tactic |
| / |
| target : Expression |
| / |
| vars : Array Variable := #[] |
| deriving ToJson |
|
|
| |
|
|
| structure Command where |
| cmd: String |
| payload: Json |
| deriving FromJson |
|
|
| structure InteractionError where |
| error: String |
| desc: String |
| deriving ToJson |
|
|
| namespace InteractionError |
|
|
| def errorIndex (desc : String) : InteractionError := { error := "index", desc } |
| def errorCommand (desc : String) : InteractionError := { error := "command", desc } |
| def errorExpr (desc : String) : InteractionError := { error := "expr", desc } |
| def errorParse (desc : String) : InteractionError := { error := "parse", desc } |
| def errorIO (desc : String) : InteractionError := { error := "io", desc } |
| def errorException (desc : String) : InteractionError := { error := "exception", desc } |
|
|
| end InteractionError |
|
|
| structure Reset where |
| deriving FromJson |
| structure Stat where |
| deriving FromJson |
| structure StatResult where |
| |
| nGoals: Nat |
| deriving ToJson |
|
|
| |
| structure ExprEcho where |
| expr: String |
| type?: Option String := .none |
| |
| levels?: Option (Array Name) := .none |
| deriving FromJson |
| structure ExprEchoResult where |
| expr: Expression |
| type: Expression |
| deriving ToJson |
|
|
| |
| structure EnvDescribe where |
| deriving FromJson |
| structure EnvDescribeResult where |
| imports : Array Name |
| modules : Array Name |
| deriving ToJson |
|
|
| |
| structure EnvModuleRead where |
| module : Name |
| deriving FromJson |
| structure EnvModuleReadResult where |
| imports: Array Name |
| constNames: Array Name |
| extraConstNames: Array Name |
| deriving ToJson |
|
|
| |
| structure EnvCatalog where |
| filename : String |
| modulePrefix? : Option String := .none |
| invertFilter : Bool := false |
| deriving FromJson |
| structure EnvCatalogResult where |
| nSymbols : Nat |
| deriving ToJson |
|
|
| |
| structure EnvInspect where |
| name: Name |
| |
| |
| value?: Option Bool := .some false |
| |
| dependency?: Option Bool := .some false |
| |
| source?: Option Bool := .some false |
| deriving FromJson |
| |
| structure InductInfo where |
| numParams: Nat |
| numIndices: Nat |
| all: Array Name |
| ctors: Array Name |
| isRec: Bool := false |
| isReflexive: Bool := false |
| isNested: Bool := false |
| deriving ToJson |
| |
| structure ConstructorInfo where |
| induct: Name |
| cidx: Nat |
| numParams: Nat |
| numFields: Nat |
| deriving ToJson |
|
|
| / |
| structure RecursorRule where |
| ctor: Name |
| nFields: Nat |
| rhs: Expression |
| deriving ToJson |
| structure RecursorInfo where |
| all: Array Name |
| numParams: Nat |
| numIndices: Nat |
| numMotives: Nat |
| numMinors: Nat |
| rules: Array RecursorRule |
| k: Bool |
| deriving ToJson |
| structure EnvInspectResult where |
| type: Expression |
| isUnsafe: Bool := false |
| value?: Option Expression := .none |
| module?: Option Name := .none |
| |
| publicName?: Option Name := .none |
| typeDependency?: Option (Array Name) := .none |
| valueDependency?: Option (Array Name) := .none |
| inductInfo?: Option InductInfo := .none |
| constructorInfo?: Option ConstructorInfo := .none |
| recursorInfo?: Option RecursorInfo := .none |
|
|
| |
| sourceUri?: Option String := .none |
| sourceStart?: Option Position := .none |
| sourceEnd?: Option Position := .none |
| deriving ToJson |
|
|
| structure EnvAdd where |
| name: Name |
| levels?: Option (Array Name) := .none |
| type?: Option String := .none |
| value: String |
| isTheorem: Bool := false |
| deriving FromJson |
| structure EnvAddResult where |
| deriving ToJson |
|
|
| structure EnvSaveLoad where |
| path: System.FilePath |
| deriving FromJson |
| structure EnvSaveLoadResult where |
| deriving ToJson |
|
|
| structure EnvParse where |
| input : String |
| category : Name |
| deriving FromJson |
| structure EnvParseResult where |
| |
| pos : Nat |
| deriving ToJson |
|
|
| structure GoalStart where |
| |
| expr: Option String |
| |
| levels?: Option (Array Name) := .none |
| copyFrom: Option Name := .none |
| deriving FromJson |
| structure GoalStartResult where |
| stateId: Nat := 0 |
| |
| root: Name |
| deriving ToJson |
| structure GoalTactic where |
| stateId: Nat |
| |
| goalId?: Option Nat := .none |
| |
| autoResume?: Option Bool := .none |
| |
| tactic?: Option String := .none |
| |
| mode?: Option String := .none |
| |
| expr?: Option String := .none |
| have?: Option String := .none |
| let?: Option String := .none |
| draft?: Option String := .none |
|
|
| |
| |
| binderName?: Option Name := .none |
|
|
| deriving FromJson |
| structure GoalTacticResult where |
| |
| nextStateId?: Option Nat := .none |
| |
| |
| goals?: Option (Array Goal) := .none |
|
|
| messages? : Option (Array Lean.SerialMessage) := .some #[] |
|
|
| |
| parseError? : Option String := .none |
|
|
| hasSorry : Bool := false |
| hasUnsafe : Bool := false |
| deriving ToJson |
| structure GoalContinue where |
| |
| target: Nat |
|
|
| |
| |
| branch?: Option Nat := .none |
| |
| goals?: Option (Array Name) := .none |
| deriving FromJson |
| structure GoalContinueResult where |
| nextStateId: Nat |
| goals: (Array Goal) |
| deriving ToJson |
|
|
| structure GoalSubsume where |
| stateId : Nat |
| goal : Name |
| srcStateId? : Option Nat := .none |
| candidates : Array Name |
| deriving FromJson |
| deriving instance ToJson for Subsumption |
| / |
| structure GoalSubsumeResult where |
| result : Subsumption |
| stateId? : Option Nat := .none |
| subsumptor? : Option Name := .none |
| deriving ToJson |
|
|
| |
| structure GoalDelete where |
| |
| stateIds: List Nat |
| deriving FromJson |
| structure GoalDeleteResult where |
| deriving ToJson |
|
|
| structure GoalPrint where |
| stateId: Nat |
|
|
| |
| rootExpr?: Option Bool := .some False |
| |
| parentExprs?: Option Bool := .some False |
| |
| goals?: Option Bool := .some False |
| |
| extraMVars?: Option (Array Name) := .none |
| deriving FromJson |
| structure GoalPrintResult where |
| |
| root?: Option Expression := .none |
| |
| parentExprs?: Option (List (Option Expression)) := .none |
| goals: Array Goal := #[] |
| extraMVars: Array Expression := #[] |
|
|
| rootHasSorry : Bool := false |
| rootHasUnsafe : Bool := false |
| rootHasMVar : Bool := true |
| deriving ToJson |
|
|
| |
| structure GoalDiag where |
| printContext: Bool := true |
| printValue: Bool := true |
| printNewMVars: Bool := false |
| |
| printAll: Bool := false |
| instantiate: Bool := true |
| printSexp: Bool := false |
|
|
| structure GoalSave where |
| id: Nat |
| path: System.FilePath |
| deriving FromJson |
| structure GoalSaveResult where |
| deriving ToJson |
| structure GoalLoad where |
| path: System.FilePath |
| deriving FromJson |
| structure GoalLoadResult where |
| id: Nat |
| deriving ToJson |
|
|
| / |
| structure FrontendProcess where |
| |
| fileName?: Option String := .none |
| file?: Option String := .none |
| |
| readHeader : Bool := false |
| |
| inheritEnv : Bool := false |
| |
| invocations?: Option String := .none |
| |
| newConstants: Bool := false |
| deriving FromJson |
| structure InvokedTactic where |
| goalBefore: String |
| goalAfter: String |
| tactic: String |
|
|
| |
| usedConstants: Array Name |
| deriving ToJson |
|
|
| structure CompilationUnit where |
| |
| boundary: (Nat × Nat) |
| messages: Array Lean.SerialMessage := #[] |
| |
| nInvocations?: Option Nat := .none |
|
|
| |
| newConstants?: Option (Array Name) := .none |
| deriving ToJson |
| structure FrontendProcessResult where |
| units: List CompilationUnit |
| deriving ToJson |
|
|
| / |
| structure FrontendDataUnit where |
| invocations? : Option (List Protocol.InvokedTactic) := .none |
| deriving ToJson |
| structure FrontendData where |
| units : List FrontendDataUnit |
| deriving ToJson |
|
|
| structure FrontendDistil where |
| file : String |
| / |
| names -/ |
| binderName? : Option Name := .none |
| / |
| will be incorporated into the generated goal state. -/ |
| ignoreValues : Bool := true |
| deriving FromJson |
| structure FrontendDistilSearchTarget where |
| stateId : Nat |
| goals : Array Goal |
| deriving ToJson |
| structure FrontendDistilResult where |
| targets : List FrontendDistilSearchTarget |
| deriving ToJson |
|
|
| structure FrontendTrack where |
| src : String |
| dst : String |
| deriving FromJson |
| structure FrontendTrackResult where |
| failure? : Option String := .none |
| srcMessages : Array Lean.SerialMessage := #[] |
| dstMessages : Array Lean.SerialMessage := #[] |
| deriving ToJson |
|
|
| structure FrontendRefactor where |
| file : String |
| coreOptions : Array String |
| deriving FromJson |
| structure FrontendRefactorResult where |
| file : String |
| deriving ToJson |
|
|
| abbrev FallibleT := ExceptT InteractionError |
|
|
| abbrev throw {m : Type v → Type w} [MonadExceptOf InteractionError m] {α : Type v} (e : InteractionError) : m α := |
| throwThe InteractionError e |
|
|