summaryrefslogtreecommitdiff
path: root/backends/lean/Base/Progress/Base.lean
diff options
context:
space:
mode:
Diffstat (limited to 'backends/lean/Base/Progress/Base.lean')
-rw-r--r--backends/lean/Base/Progress/Base.lean36
1 files changed, 23 insertions, 13 deletions
diff --git a/backends/lean/Base/Progress/Base.lean b/backends/lean/Base/Progress/Base.lean
index 0ad16ab6..a64212a5 100644
--- a/backends/lean/Base/Progress/Base.lean
+++ b/backends/lean/Base/Progress/Base.lean
@@ -22,8 +22,9 @@ structure PSpecDesc where
evars : Array Expr
-- The function applied to its arguments
fArgsExpr : Expr
- -- The function
- fName : Name
+ -- ⊤ if the function is a constant (must be if we are registering a theorem,
+ -- but is not necessarily the case if we are looking at a goal)
+ fIsConst : Bool
-- The function arguments
fLevels : List Level
args : Array Expr
@@ -82,19 +83,28 @@ section Methods
-- Destruct the equality
let (mExpr, ret) ← destEq th.consumeMData
trace[Progress] "After splitting the equality:\n- lhs: {th}\n- rhs: {ret}"
- -- Destruct the monadic application to dive into the bind, if necessary (this
- -- is for when we use `withPSpec` inside of the `progress` tactic), and
- -- destruct the application to get the function name
- mExpr.consumeMData.withApp fun mf margs => do
- trace[Progress] "After stripping the arguments of the monad expression:\n- mf: {mf}\n- margs: {margs}"
- let (fArgsExpr, f, args) ← do
+ -- Recursively destruct the monadic application to dive into the binds,
+ -- if necessary (this is for when we use `withPSpec` inside of the `progress` tactic),
+ -- and destruct the application to get the function name
+ let rec strip_monad mExpr := do
+ mExpr.consumeMData.withApp fun mf margs => do
+ trace[Progress] "After stripping the arguments of the monad expression:\n- mf: {mf}\n- margs: {margs}"
if mf.isConst ∧ mf.constName = ``Bind.bind then do
-- Dive into the bind
let fExpr := (margs.get! 4).consumeMData
- fExpr.withApp fun f args => pure (fExpr, f, args)
- else pure (mExpr, mf, margs)
+ -- Recursve
+ strip_monad fExpr
+ else
+ -- No bind
+ pure (mExpr, mf, margs)
+ let (fArgsExpr, f, args) ← strip_monad mExpr
trace[Progress] "After stripping the arguments of the function call:\n- f: {f}\n- args: {args}"
- if ¬ f.isConst then throwError "Not a constant: {f}"
+ let fLevels ← do
+ -- If we are registering a theorem, then the function must be a constant
+ if ¬ f.isConst then
+ if isGoal then pure []
+ else throwError "Not a constant: {f}"
+ else pure f.constLevels!
-- *Sanity check* (activated if we are analyzing a theorem to register it in a DB)
-- Check if some existentially quantified variables
let _ := do
@@ -113,8 +123,8 @@ section Methods
fvars := fvars
evars := evars
fArgsExpr
- fName := f.constName!
- fLevels := f.constLevels!
+ fIsConst := f.isConst
+ fLevels
args := args
ret := ret
post := post