Skip to content

Commit

Permalink
doc string for LSimp.Result and MetaMCtxM
Browse files Browse the repository at this point in the history
  • Loading branch information
lecopivo committed Aug 30, 2024
1 parent 462e763 commit 791d344
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions SciLean/Tactic/GTrans/MetaLCtxM.lean
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ def _root_.Lean.Meta.Context.mkCtxCfg (ctx : ContextCtx) (cfg : ContextCfg) : Me

-- TODO: change the monad such that we can only add variables to the context and not remove them
-- or completely changes the context
/-- Similar to `MetaM` but allows modifying local context.
Most imporantly it has a variant of `lambdaTelescope` called `introLet` such that instead of
```
lambdaTelescope e fun xs b => do
f xs b
```
we can call
```
let (b,xs) ← lambdaIntro e
f xs b
```
For example running `lambdaTelescope` does not work well with for loops but `lambdaIntro` does.
Important functions introducing new free variables to the context:
- `lambdaIntro`
- `letIntro`
- `introLocalDecl`
- `introLetDecl`
Also you can run `MetaLCtxM` inside of `MetaM` with `MetaLCtxM.runInMeta`.
-/
abbrev MetaLCtxM := ReaderT Meta.ContextCfg $ StateT Meta.ContextCtx $ StateRefT Meta.State CoreM


Expand Down
12 changes: 12 additions & 0 deletions SciLean/Tactic/LSimp/Types.lean
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@ namespace SciLean.Tactic.LSimp
-- Result ------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------


/-- Result of `lsimp` -/
structure Result where
/-- Result of simplification -/
expr : Expr
/-- Proof that the result is propositionally equal to the original expression. It is `none` if
it is defeq to the original. -/
proof? : Option Expr := none
/-- This array keeps track of the newly introduced free variables that appear in the result.
We run `lsimp` in `MetaLCtxM` which allows modifying the local context by adding new free
variables.
See `Result.bindVars` which is a function that takes the result and the proof and binds all
these newly introduced free variables such that the result is valid in the original context
of the expression we are simplifying. -/
vars : Array Expr := #[]
cache : Bool := true
deriving Inhabited
Expand Down

0 comments on commit 791d344

Please sign in to comment.