Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use omega in the get_elem tactic #3515

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Init/Tactics.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1425,13 +1425,14 @@ macro_rules | `(‹$type›) => `((by assumption : $type))
by the notation `arr[i]` to prove any side conditions that arise when
constructing the term (e.g. the index is in bounds of the array).
The default behavior is to just try `trivial` (which handles the case
where `i < arr.size` is in the context) and `simp_arith`
where `i < arr.size` is in the context) and `simp_arith` and `omega`
(for doing linear arithmetic in the index).
-/
syntax "get_elem_tactic_trivial" : tactic

macro_rules | `(tactic| get_elem_tactic_trivial) => `(tactic| trivial)
macro_rules | `(tactic| get_elem_tactic_trivial) => `(tactic| simp (config := { arith := true }); done)
macro_rules | `(tactic| get_elem_tactic_trivial) => `(tactic| omega)

/--
`get_elem_tactic` is the tactic automatically called by the notation `arr[i]`
Expand Down
7 changes: 7 additions & 0 deletions tests/lean/getElem.lean
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ def withTwoRanges (xs : Array Nat) : Option Nat := Id.run do
if xs[i] == xs[j] then
return i
return none

def palindromeNeedsOmega (xs : Array Nat) : Bool := Id.run do
for h : i in [:xs.size/2] do
have : i < xs.size/2 := h.2 -- omega does not understand range yet
if xs[xs.size - 1 - i] ≠ xs[i] then
return false
return true
Loading