-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Lean/Elab/Tactic/BVDecide/Frontend/Normalize/IntToBitVec.lean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/- | ||
Copyright (c) 2025 Lean FRO, LLC. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Henrik Böving | ||
-/ | ||
prelude | ||
import Lean.Elab.Tactic.Simp | ||
import Lean.Elab.Tactic.BVDecide.Frontend.Normalize.Basic | ||
import Lean.Elab.Tactic.BVDecide.Frontend.Attr | ||
|
||
/-! | ||
This module contains the implementation of the pre processing pass for reducing `UIntX`/`IntX` to | ||
`BitVec` and thus allow `bv_decide` to reason about them. | ||
-/ | ||
|
||
namespace Lean.Elab.Tactic.BVDecide | ||
namespace Frontend.Normalize | ||
|
||
open Lean.Meta | ||
|
||
def intToBitVecPass : Pass where | ||
name := `intToBitVec | ||
run' goal := do | ||
let intToBvThms ← intToBitVecExt.getTheorems | ||
let cfg ← PreProcessM.getConfig | ||
let simpCtx ← Simp.mkContext | ||
(config := { failIfUnchanged := false, zetaDelta := true, maxSteps := cfg.maxSteps }) | ||
(simpTheorems := #[intToBvThms]) | ||
(congrTheorems := (← getSimpCongrTheorems)) | ||
|
||
let hyps ← goal.getNondepPropHyps | ||
let ⟨result?, _⟩ ← simpGoal goal (ctx := simpCtx) (fvarIdsToSimp := hyps) | ||
let some (_, newGoal) := result? | return none | ||
return newGoal | ||
|
||
end Frontend.Normalize | ||
end Lean.Elab.Tactic.BVDecide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Std.Tactic.BVDecide | ||
|
||
example (a b : UInt8) : a + b = b + a := by | ||
bv_decide | ||
|
||
example (a b : UInt8) : a + b = a := by | ||
bv_decide |