diff --git a/src/Init/Tactics.lean b/src/Init/Tactics.lean index 5bd567a2ee05..27aedb895a01 100644 --- a/src/Init/Tactics.lean +++ b/src/Init/Tactics.lean @@ -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]` diff --git a/tests/lean/getElem.lean b/tests/lean/getElem.lean index 9adc07898569..9291946a20d5 100644 --- a/tests/lean/getElem.lean +++ b/tests/lean/getElem.lean @@ -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