Skip to content

Commit

Permalink
merge nightly-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-em committed Dec 2, 2024
2 parents 972cb84 + 0c995c6 commit e6e9188
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Aesop/Builder/Cases.lean
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def check (decl : Name) (p : CasesPattern) : MetaM Unit :=

def toIndexingMode (p : CasesPattern) : MetaM IndexingMode :=
withoutModifyingState do
.hyps <$> DiscrTree.mkPath (← p.toExpr) discrTreeConfig
.hyps <$> (withConfigWithKey discrTreeConfig <| DiscrTree.mkPath (← p.toExpr))

end CasesPattern

Expand Down
2 changes: 1 addition & 1 deletion Aesop/Builder/Forward.lean
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private def forwardIndexingModeCore (type : Expr)
match args.get? i with
| some arg =>
let argT := (← arg.mvarId!.getDecl).type
let keys ← DiscrTree.mkPath argT discrTreeConfig
let keys ← withConfigWithKey discrTreeConfig <| DiscrTree.mkPath argT
return .hyps keys
| none => throwError
"aesop: internal error: immediate arg for forward rule is out of range"
Expand Down
2 changes: 1 addition & 1 deletion Aesop/Frontend/RuleExpr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def elabSingleIndexingMode (stx : Syntax) : ElabM IndexingMode :=
elabKeys (stx : Syntax) : ElabM (Array DiscrTree.Key) :=
show TermElabM _ from withoutModifyingState do
let e ← elabPattern stx
DiscrTree.mkPath (← instantiateMVars e) discrTreeConfig
withConfigWithKey discrTreeConfig <| DiscrTree.mkPath (← instantiateMVars e)

def IndexingMode.elab (stxs : Array Syntax) : ElabM IndexingMode :=
.or <$> stxs.mapM elabSingleIndexingMode
Expand Down
4 changes: 2 additions & 2 deletions Aesop/Index.lean
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private def applicableByTargetRules (ri : Index α) (goal : MVarId)
(include? : Rule α → Bool) :
MetaM (Array (Rule α × Array IndexMatchLocation)) :=
goal.withContext do
let rules ← ri.byTarget.getUnify (← goal.getType) discrTreeConfig
let rules ← withConfigWithKey discrTreeConfig <| ri.byTarget.getUnify (← goal.getType)
let mut rs := Array.mkEmpty rules.size
-- Assumption: include? is true for most rules.
for r in rules do
Expand All @@ -114,7 +114,7 @@ private def applicableByHypRules (ri : Index α) (goal : MVarId)
for localDecl in ← getLCtx do
if localDecl.isImplementationDetail then
continue
let rules ← ri.byHyp.getUnify localDecl.type discrTreeConfig
let rules ← withConfigWithKey discrTreeConfig <| ri.byHyp.getUnify localDecl.type
for r in rules do
if include? r then
rs := rs.push (r, #[.hyp localDecl])
Expand Down
2 changes: 1 addition & 1 deletion Aesop/Index/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Aesop

-- This value controls whether we use 'powerful' reductions, e.g. iota, when
-- indexing Aesop rules. See the `DiscrTree` docs for details.
def discrTreeConfig : WhnfCoreConfig := { iota := false }
def discrTreeConfig : ConfigWithKey := { iota := false : Config}.toConfigWithKey

inductive IndexingMode : Type
| unindexed
Expand Down
4 changes: 2 additions & 2 deletions Aesop/RuleSet.lean
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def LocalRuleSet.erase (rs : LocalRuleSet) (f : RuleFilter) :
Σ' a : Array (Name × SimpTheorems), a.size = rs.simpTheoremsArray.size :=
⟨rs.simpTheoremsArray, rfl⟩
if let some id := f.matchesLocalNormSimpRule? then
if let some idx := localNormSimpRules.findIdx? (·.id == id) then
if let some idx := localNormSimpRules.findFinIdx? (·.id == id) then
localNormSimpRules := localNormSimpRules.eraseIdx idx
if let some decl := f.matchesSimpTheorem? then
for h : i in [:rs.simpTheoremsArray.size] do
Expand All @@ -377,7 +377,7 @@ def LocalRuleSet.erase (rs : LocalRuleSet) (f : RuleFilter) :
if SimpTheorems.containsDecl simpTheorems decl then
let origin := .decl decl (inv := false)
simpTheoremsArray' :=
⟨simpTheoremsArray'.fst.set ⟨i, i_valid⟩
⟨simpTheoremsArray'.fst.set i
(name, simpTheorems.eraseCore origin),
by simp [simpTheoremsArray'.snd, Array.size_set]⟩
anyErased := true
Expand Down
2 changes: 1 addition & 1 deletion Aesop/RuleTac/ElabRuleTerm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def elabRuleTermForSimpCore (goal : MVarId) (term : Term) (ctx : Simp.Context)
elabSimpTheorems (mkSimpArgs term) ctx simprocs isSimpAll

def checkElabRuleTermForSimp (term : Term) (isSimpAll : Bool) : ElabM Unit := do
let ctx := { simpTheorems := #[{}] }
let ctx ← Simp.mkContext (simpTheorems := #[{}] )
let simprocs := #[{}]
discard $ elabRuleTermForSimpCore (← read).goal term ctx simprocs isSimpAll

Expand Down
2 changes: 1 addition & 1 deletion Aesop/RuleTac/Forward.lean
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ partial def makeForwardHyps (e : Expr) (pat? : Option RulePattern)
(proofTypesAcc : Std.HashSet Expr) :
MetaM (Array (Expr × Nat) × Array FVarId × Std.HashSet Expr) := do
if h : i < immediateMVars.size then
let mvarId := immediateMVars.get ⟨i, h⟩
let mvarId := immediateMVars[i]
let type ← mvarId.getType
(← getLCtx).foldlM (init := (proofsAcc, usedHypsAcc, proofTypesAcc)) λ s@(proofsAcc, usedHypsAcc, proofTypesAcc) ldecl => do
if ldecl.isImplementationDetail then
Expand Down
6 changes: 3 additions & 3 deletions Aesop/Search/Expansion/Simp.lean
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def addLetDeclsToSimpTheorems (ctx : Simp.Context) : MetaM Simp.Context := do
if ldecl.hasValue && ! ldecl.isImplementationDetail then
simpTheoremsArray := simpTheoremsArray.modify 0 λ simpTheorems =>
simpTheorems.addLetDeclToUnfold ldecl.fvarId
return { ctx with simpTheorems := simpTheoremsArray }
return ctx.setSimpTheorems simpTheoremsArray

def addLetDeclsToSimpTheoremsUnlessZetaDelta (ctx : Simp.Context) :
MetaM Simp.Context := do
Expand All @@ -58,7 +58,7 @@ def simpGoal (mvarId : MVarId) (ctx : Simp.Context)
(simplifyTarget : Bool := true) (fvarIdsToSimp : Array FVarId := #[])
(stats : Simp.Stats := {}) : MetaM SimpResult := do
let mvarIdOld := mvarId
let ctx := { ctx with config.failIfUnchanged := false }
let ctx := ctx.setFailIfUnchanged false
let (result, { usedTheorems := usedSimps, .. }) ←
Meta.simpGoal mvarId ctx simprocs discharge? simplifyTarget fvarIdsToSimp
stats
Expand Down Expand Up @@ -89,7 +89,7 @@ def simpAll (mvarId : MVarId) (ctx : Simp.Context)
(simprocs : Simp.SimprocsArray) (stats : Simp.Stats := {}) :
MetaM SimpResult :=
mvarId.withContext do
let ctx := { ctx with config.failIfUnchanged := false }
let ctx := ctx.setFailIfUnchanged false
let ctx ← addLetDeclsToSimpTheoremsUnlessZetaDelta ctx
match ← Lean.Meta.simpAll mvarId ctx simprocs stats with
| (none, stats) => return .solved stats.usedTheorems
Expand Down
9 changes: 4 additions & 5 deletions Aesop/Search/SearchM.lean
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ open Lean.Meta

namespace Aesop

structure NormSimpContext extends Simp.Context where
structure NormSimpContext where
toContext : Simp.Context
enabled : Bool
useHyps : Bool
configStx? : Option Term
Expand Down Expand Up @@ -83,10 +84,8 @@ protected def run (ruleSet : LocalRuleSet) (options : Aesop.Options')
MetaM (α × State Q × Tree × Stats) := do
let t ← mkInitialTree goal
let normSimpContext := {
config := simpConfig
maxDischargeDepth := UInt32.ofNatTruncate simpConfig.maxDischargeDepth
simpTheorems := ruleSet.simpTheoremsArray.map (·.snd)
congrTheorems := ← getSimpCongrTheorems
toContext := ← Simp.mkContext simpConfig (simpTheorems := ruleSet.simpTheoremsArray.map (·.snd))
(congrTheorems := ← getSimpCongrTheorems)
simprocs := ruleSet.simprocsArray.map (·.snd)
configStx? := simpConfigStx?
enabled := options.enableSimp
Expand Down
2 changes: 1 addition & 1 deletion Aesop/Tree/TreeM.lean
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def getRootGoal : TreeM GoalRef := do
let cref ← getRootMVarCluster
let grefs := (← cref.get).goals
if h : grefs.size = 1 then
return grefs.get ⟨0, by simp [h]⟩
return grefs[0]
else
throwError "aesop: internal error: unexpected number of goals in root mvar cluster: {grefs.size}"

Expand Down
6 changes: 3 additions & 3 deletions Aesop/Util/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ open DiscrTree

-- For `type = ∀ (x₁, ..., xₙ), T`, returns keys that match `T * ... *` (with
-- `n` stars).
def getConclusionDiscrTreeKeys (type : Expr) (config : WhnfCoreConfig) :
def getConclusionDiscrTreeKeys (type : Expr) (config : ConfigWithKey) :
MetaM (Array Key) :=
withoutModifyingState do
let (_, _, conclusion) ← forallMetaTelescope type
mkPath conclusion config
withConfigWithKey config <| mkPath conclusion
-- We use a meta telescope because `DiscrTree.mkPath` ignores metas (they
-- turn into `Key.star`) but not fvars.

Expand Down Expand Up @@ -117,7 +117,7 @@ private partial def filterTrieM [Monad m] [Inhabited σ] (f : σ → α → m σ
if h : i < children.size then
let (key, t) := children[i]'h
let (t, acc) ← filterTrieM f p acc t
go acc (i + 1) (children.set ⟨i, h⟩ (key, t))
go acc (i + 1) (children.set i (key, t))
else
return (children, acc)

Expand Down
7 changes: 1 addition & 6 deletions Aesop/Util/Tactic/Unfold.lean
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ namespace Aesop
-- Lean.Meta.unfoldLocalDecl.

def mkUnfoldSimpContext : MetaM Simp.Context := do
return {
simpTheorems := #[]
congrTheorems := ← getSimpCongrTheorems
config := Simp.neutralConfig
dischargeDepth := 0
}
Simp.mkContext Simp.neutralConfig (simpTheorems := #[]) (congrTheorems := ← getSimpCongrTheorems)

@[inline]
def unfoldManyCore (ctx : Simp.Context) (unfold? : Name → Option (Option Name))
Expand Down
4 changes: 2 additions & 2 deletions AesopTest/RulePattern.lean
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ example (m n : Nat) : (↑m : Int) < 0 ∧ (↑n : Int) > 0 := by
set_option aesop.check.script false in
aesop!
all_goals
guard_hyp fwd_1 : 0 ≤ (m : Int)
guard_hyp fwd_2 : 0 ≤ (n : Int)
guard_hyp fwd_1 : 0 ≤ (n : Int)
guard_hyp fwd_2 : 0 ≤ (m : Int)
falso

@[aesop safe forward (pattern := min x y)]
Expand Down
8 changes: 4 additions & 4 deletions AesopTest/SaturatePerformance.lean
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ import Aesop
error: unsolved goals
α : Type u_1
l0 l1 l2 : List α
fwd : (l0 ++ l1 ++ l2).length ≥ 0
fwd_1 : l0.length ≥ 0
fwd : (l0 ++ l1).length ≥ 0
fwd_1 : (l0 ++ l1 ++ l2).length ≥ 0
fwd_2 : l2.length ≥ 0
fwd_3 : l1.length ≥ 0
fwd_4 : (l0 ++ l1).length ≥ 0
fwd_3 : l0.length ≥ 0
fwd_4 : l1.length ≥ 0
⊢ (l0 ++ l1 ++ l2).length = l0.length + l1.length + l2.length
-/
#guard_msgs in
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:v4.15.0-rc1
leanprover/lean4:v4.15.0-rc1

0 comments on commit e6e9188

Please sign in to comment.