Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d728a42

Browse files
committedJan 29, 2025·
respect new rewrites
1 parent 02dc33b commit d728a42

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed
 

Diff for: ‎src/Lean/Elab/Tactic/BVDecide/Frontend/Normalize/IntToBitVec.lean

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Henrik Böving
55
-/
66
prelude
7-
import Lean.Elab.Tactic.Simp
87
import Lean.Elab.Tactic.BVDecide.Frontend.Normalize.Basic
98
import Lean.Elab.Tactic.BVDecide.Frontend.Attr
109
import Lean.Elab.Tactic.Simp
11-
import Lean.Meta.Tactic.Generalize
1210

1311
/-!
1412
This module contains the implementation of the pre processing pass for reducing `UIntX`/`IntX` to
@@ -26,8 +24,17 @@ namespace Frontend.Normalize
2624

2725
open Lean.Meta
2826

27+
/--
28+
Contains information for the `USize` elimination pass.
29+
-/
2930
structure USizeState where
31+
/--
32+
Contains terms of the form `USize.toBitVec e` that we will translate to constant width `BitVec`.
33+
-/
3034
relevantTerms : Std.HashSet Expr := {}
35+
/--
36+
Contains all hypotheses that contain terms from `relevantTerms`
37+
-/
3138
relevantHyps : Std.HashSet FVarId := {}
3239

3340
private abbrev M := StateRefT USizeState MetaM
@@ -83,9 +90,9 @@ where
8390
replaceUSize (goal : MVarId) : M MVarId := do
8491
if let some (numBits, numBitsEq) ← findNumBitsEq goal then
8592
goal.withContext do
86-
let relevantHyps := (← get).relevantHyps.toArray
93+
let relevantHyps := (← get).relevantHyps.toArray.map mkFVar
8794
let relevantTerms := (← get).relevantTerms.toArray
88-
let (app, abstractedHyps) ← liftMkBindingM <| MetavarContext.revert (relevantHyps.map mkFVar) goal true
95+
let (app, abstractedHyps) ← liftMkBindingM <| MetavarContext.revert relevantHyps goal true
8996
let newMVar := app.getAppFn.mvarId!
9097
let targetType ← newMVar.getType
9198
/-

Diff for: ‎tests/lean/run/bv_uint.lean

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ a.toBitVec = 0xff#8
1010
b.toBitVec = 0xff#8
1111
-/
1212
#guard_msgs in
13-
example (a b : UInt8) : a + b = a := by
13+
example (a b : UInt8) : a + b > a := by
1414
bv_decide
1515

1616

@@ -25,7 +25,7 @@ a.toBitVec = 0xffff#16
2525
b.toBitVec = 0xffff#16
2626
-/
2727
#guard_msgs in
28-
example (a b : UInt16) : a + b = a := by
28+
example (a b : UInt16) : a + b > a := by
2929
bv_decide
3030

3131

@@ -40,7 +40,7 @@ a.toBitVec = 0xffffffff#32
4040
b.toBitVec = 0xffffffff#32
4141
-/
4242
#guard_msgs in
43-
example (a b : UInt32) : a + b = a := by
43+
example (a b : UInt32) : a + b > a := by
4444
bv_decide
4545

4646

@@ -55,7 +55,7 @@ a.toBitVec = 0xffffffffffffffff#64
5555
b.toBitVec = 0xffffffffffffffff#64
5656
-/
5757
#guard_msgs in
58-
example (a b : UInt64) : a + b = a := by
58+
example (a b : UInt64) : a + b > a := by
5959
bv_decide
6060

6161

@@ -70,7 +70,7 @@ warning: Detected USize in the goal but no hypothesis about System.Platform.numB
7070
warning: declaration uses 'sorry'
7171
-/
7272
#guard_msgs in
73-
example (a b : USize) : a + b = a := by
73+
example (a b : USize) : a + b > a := by
7474
bv_normalize
7575
sorry
7676

0 commit comments

Comments
 (0)
Please sign in to comment.