Skip to content

Commit 1f56956

Browse files
committed
merge master
2 parents c09b5d0 + ba9a63b commit 1f56956

File tree

8 files changed

+28
-16
lines changed

8 files changed

+28
-16
lines changed

Aesop/Options/Public.lean

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ structure Options where
7272
/--
7373
Heartbeat limit for individual Aesop rules. If a rule goes over this limit, it
7474
fails, but Aesop itself continues until it reaches the limit set by the
75-
`maxHeartbeats` option. If `maxRuleHeartbeats = 0`, there is no per-rule
76-
limit.
75+
`maxHeartbeats` option. If `maxRuleHeartbeats = 0` or `maxRuleHeartbeats` is
76+
greater than `maxHeartbeats`, the `maxHeartbeats` limit is used for the
77+
individual rules as well.
7778
-/
7879
maxRuleHeartbeats := 0
7980
/--

Aesop/Search/Expansion/Basic.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def runRuleTac (tac : RuleTac) (ruleName : RuleName)
1717
let result ←
1818
tryCatchRuntimeEx
1919
(Sum.inr <$> preState.runMetaM' do
20-
withMaxHeartbeats input.options.maxRuleHeartbeats do
20+
withAtMostMaxHeartbeats input.options.maxRuleHeartbeats do
2121
tac input)
2222
(λ e => return Sum.inl e)
2323
if ← Check.rules.isEnabled then

Aesop/Util/Basic.lean

+14-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ open DiscrTree
8080
-- For `type = ∀ (x₁, ..., xₙ), T`, returns keys that match `T * ... *` (with
8181
-- `n` stars).
8282

83-
def getConclusionDiscrTreeKeys (type : Expr) :
84-
MetaM (Array Key) :=
83+
def getConclusionDiscrTreeKeys (type : Expr) : MetaM (Array Key) :=
8584
withoutModifyingState do
8685
let (_, _, conclusion) ← forallMetaTelescope type
8786
mkDiscrTreePath conclusion
@@ -416,6 +415,19 @@ def withMaxHeartbeats [Monad m] [MonadLiftT BaseIO m]
416415
}
417416
withReader f x
418417

418+
/--
419+
Runs a computation for at most the given number of heartbeats times 1000 or the
420+
global heartbeat limit, whichever is lower. Note that heartbeats spent on the
421+
computation still count towards the global heartbeat count. If 0 is given, the
422+
global heartbeat limit is used.
423+
-/
424+
def withAtMostMaxHeartbeats [Monad m] [MonadLiftT BaseIO m] [MonadLiftT CoreM m]
425+
[MonadWithReaderOf Core.Context m] (n : Nat) (x : m α) : m α := do
426+
let globalMaxHeartbeats ← getMaxHeartbeats
427+
let maxHeartbeats :=
428+
if n == 0 then globalMaxHeartbeats else min n globalMaxHeartbeats
429+
withMaxHeartbeats maxHeartbeats x
430+
419431
open Lean.Elab Lean.Elab.Term in
420432
def elabPattern (stx : Syntax) : TermElabM Expr :=
421433
withRef stx $ withReader adjustCtx $ withSynthesize $ elabTerm stx none

AesopTest/List.lean

+2-3
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ theorem X.append_ne_nil_of_ne_nil_left (s t : List α) : s ≠ [] → s ++ t ≠
540540
theorem X.append_ne_nil_of_ne_nil_right (s t : List α) : t ≠ [] → s ++ t ≠ [] := by
541541
induction s <;> aesop
542542

543-
attribute [-simp] append_eq_nil
544543
@[simp] theorem X.append_eq_nil {p q : List α} : (p ++ q) = [] ↔ p = [] ∧ q = [] := by
545544
aesop (add 1% cases List)
546545

@@ -718,7 +717,7 @@ theorem replicate_right_injective (a : α) : Injective (λ n => replicate n a) :
718717
/-! ### flatMap -/
719718

720719
instance : Bind List where
721-
bind l f := List.flatMap l f
720+
bind l f := List.flatMap f l
722721

723722
@[simp] theorem bind_eq_flatMap {α β} (f : α → List β) (l : List α) :
724723
l >>= f = l.flatMap f := rfl
@@ -892,7 +891,7 @@ theorem last_append (l₁ l₂ : List α) (h : l₂ ≠ []) :
892891
last (l₁ ++ l₂) (append_ne_nil_of_right_ne_nil l₁ h) = last l₂ h := by
893892
induction l₁ <;> aesop
894893

895-
theorem last_concat {a : α} (l : List α) : last (concat l a) (by exact X.concat_ne_nil a l) = a := by
894+
theorem last_concat {a : α} (l : List α) : last (concat l a) (X.concat_ne_nil a l) = a := by
896895
aesop
897896

898897
@[simp] theorem last_singleton (a : α) : last [a] (cons_ne_nil a []) = a := rfl

AesopTest/RulePattern.lean

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ example (m n : Nat) : (↑m : Int) < 0 ∧ (↑n : Int) > 0 := by
2323
set_option aesop.check.script false in
2424
aesop!
2525
all_goals
26-
guard_hyp fwd_2 : 0 ≤ (n : Int)
27-
guard_hyp fwd_1 : 0 ≤ (m : Int)
26+
guard_hyp fwd : 0 ≤ (n : Int)
27+
guard_hyp fwd_2 : 0 ≤ (m : Int)
2828
falso
2929

3030
@[aesop safe forward (pattern := min x y)]
@@ -44,8 +44,8 @@ axiom triangle (a b : Int) : |a + b| ≤ |a| + |b|
4444

4545
example : |a + b| ≤ |c + d| := by
4646
aesop!
47-
guard_hyp fwd : |c + d| ≤ |c| + |d|
48-
guard_hyp fwd_1 : |a + b| ≤ |a| + |b|
47+
guard_hyp fwd_1 : |c + d| ≤ |c| + |d|
48+
guard_hyp fwd : |a + b| ≤ |a| + |b|
4949
falso
5050

5151
@[aesop safe apply (pattern := (0 : Nat))]

lake-manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"type": "git",
66
"subDir": null,
77
"scope": "",
8-
"rev": "2e82cd8e5d6462f20ffd810ea0e9460475e0b455",
8+
"rev": "512d7fa38234139a34c04e3b3438fc142b51bbee",
99
"name": "batteries",
1010
"manifestFile": "lake-manifest.json",
11-
"inputRev": "nightly-testing",
11+
"inputRev": "v4.17.0-rc1",
1212
"inherited": false,
1313
"configFile": "lakefile.toml"}],
1414
"name": "aesop",

lakefile.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ precompileModules = false # We would like to turn this on, but it breaks the Mat
66
[[require]]
77
name = "batteries"
88
git = "https://github.com/leanprover-community/batteries"
9-
rev = "nightly-testing"
9+
rev = "v4.17.0-rc1"
1010

1111
[[lean_lib]]
1212
name = "Aesop"

lean-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:nightly-2024-12-19
1+
leanprover/lean4:v4.17.0-rc1

0 commit comments

Comments
 (0)