diff --git a/library/data/rbtree/basic.lean b/library/data/rbtree/basic.lean index 943f15c882..166a69f5ad 100644 --- a/library/data/rbtree/basic.lean +++ b/library/data/rbtree/basic.lean @@ -11,7 +11,7 @@ namespace tactic namespace interactive meta def blast_disjs : tactic unit := -focus1 $ repeat $ any_goals $ any_hyp $ λ h, do +focus1 $ iterate $ any_goals $ any_hyp $ λ h, do t ← infer_type h, guard (t.is_or ≠ none), tactic.cases h [h.local_pp_name, h.local_pp_name] @@ -50,13 +50,13 @@ meta def is_searchable_constructor_app : expr → bool | _ := ff meta def apply_is_searchable_constructors : tactic unit := -repeat $ any_goals $ do +iterate $ any_goals $ do t ← target, guard $ is_searchable_constructor_app t, constructor meta def destruct_is_searchable_hyps : tactic unit := -repeat $ any_goals $ any_hyp $ λ h, do +iterate $ any_goals $ any_hyp $ λ h, do t ← infer_type h, guard $ is_searchable_constructor_app t, cases h, diff --git a/library/data/rbtree/insert.lean b/library/data/rbtree/insert.lean index 4e7185b688..9bdd2906d3 100644 --- a/library/data/rbtree/insert.lean +++ b/library/data/rbtree/insert.lean @@ -657,10 +657,10 @@ inductive is_bad_red_black : rbnode α → nat → Prop | bad_red {c₁ c₂ n l r v} (rb_l : is_red_black l c₁ n) (rb_r : is_red_black r c₂ n) : is_bad_red_black (red_node l v r) n lemma balance1_rb {l r t : rbnode α} {y v : α} {c_l c_r c_t n} : is_red_black l c_l n → is_red_black r c_r n → is_red_black t c_t n → ∃ c, is_red_black (balance1 l y r v t) c (succ n) := -by intros h₁ h₂ h₃; cases h₁; cases h₂; repeat {assumption <|> constructor} +by intros h₁ h₂ h₃; cases h₁; cases h₂; iterate {assumption <|> constructor} lemma balance2_rb {l r t : rbnode α} {y v : α} {c_l c_r c_t n} : is_red_black l c_l n → is_red_black r c_r n → is_red_black t c_t n → ∃ c, is_red_black (balance2 l y r v t) c (succ n) := -by intros h₁ h₂ h₃; cases h₁; cases h₂; repeat {assumption <|> constructor} +by intros h₁ h₂ h₃; cases h₁; cases h₂; iterate {assumption <|> constructor} lemma balance1_node_rb {t s : rbnode α} {y : α} {c n} : is_bad_red_black t n → is_red_black s c n → ∃ c, is_red_black (balance1_node t y s) c (succ n) := by intros h _; cases h; simp [balance1_node]; apply balance1_rb; assumption' @@ -685,7 +685,7 @@ variable (lt) lemma ins_rb {t : rbnode α} (x) : ∀ {c n} (h : is_red_black t c n), ins_rb_result (ins lt t x) c n := begin apply ins.induction lt t x; intros; cases h; simp [ins, *, ins_rb_result], - { repeat { constructor } }, + { iterate { constructor } }, { specialize ih rb_l, cases ih, constructor, assumption' }, { constructor, assumption' }, { specialize ih rb_r, cases ih, constructor, assumption' }, diff --git a/library/data/stream.lean b/library/data/stream.lean index 032643cf03..fa2fee604f 100644 --- a/library/data/stream.lean +++ b/library/data/stream.lean @@ -33,7 +33,7 @@ def drop (n : nat) (s : stream α) : stream α := s n protected theorem eta (s : stream α) : head s :: tail s = s := -funext (λ i, begin cases i, repeat {refl} end) +funext (λ i, begin cases i; refl end) theorem nth_zero_cons (a : α) (s : stream α) : nth 0 (a :: s) = a := rfl @@ -154,7 +154,7 @@ exists.intro 0 rfl theorem const_eq (a : α) : const a = a :: const a := begin apply stream.ext, intro n, - cases n, repeat {refl} + cases n; refl end theorem tail_const (a : α) : tail (const a) = const a := @@ -217,7 +217,7 @@ assume hh ht₁ ht₂, eq_of_bisim (λ s₁ s₂, head s₁ = head s₂ ∧ s₁ = tail s₁ ∧ s₂ = tail s₂) (λ s₁ s₂ ⟨h₁, h₂, h₃⟩, begin - constructor, exact h₁, rw [← h₂, ← h₃], repeat {constructor, repeat {assumption}} + constructor, exact h₁, rw [← h₂, ← h₃], iterate { constructor, iterate { assumption } } end) (and.intro hh (and.intro ht₁ ht₂)) diff --git a/library/init/algebra/functions.lean b/library/init/algebra/functions.lean index 71ca481a22..1795b9841a 100644 --- a/library/init/algebra/functions.lean +++ b/library/init/algebra/functions.lean @@ -24,7 +24,7 @@ solve1 $ intros >> try `[apply le_of_not_le, assumption] meta def tactic.interactive.min_tac (a b : interactive.parse lean.parser.pexpr) : tactic unit := -`[by_cases (%%a ≤ %%b), repeat {min_tac_step}] +`[by_cases (%%a ≤ %%b), iterate {min_tac_step}] lemma min_le_left (a b : α) : min a b ≤ a := by min_tac a b @@ -451,10 +451,10 @@ lemma abs_abs_sub_abs_le_abs_sub (a b : α) : abs (abs a - abs b) ≤ abs (a - b begin apply nonneg_le_nonneg_of_squares_le, apply abs_nonneg, - repeat {rw abs_sub_square}, - repeat {rw abs_mul_abs_self}, + iterate {rw abs_sub_square}, + iterate {rw abs_mul_abs_self}, apply sub_le_sub_left, - repeat {rw mul_assoc}, + iterate {rw mul_assoc}, apply mul_le_mul_of_nonneg_left, rw [← abs_mul], apply le_abs_self, diff --git a/library/init/data/int/order.lean b/library/init/data/int/order.lean index 0a86b0c515..115813b37e 100644 --- a/library/init/data/int/order.lean +++ b/library/init/data/int/order.lean @@ -162,7 +162,7 @@ iff.mpr (int.lt_iff_le_and_ne _ _) protected lemma mul_nonneg {a b : ℤ} (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a * b := le.elim ha (assume n, assume hn, le.elim hb (assume m, assume hm, - le.intro (show 0 + ↑n * ↑m = a * b, begin rw [← hn, ← hm], repeat {rw zero_add} end))) + le.intro (show 0 + ↑n * ↑m = a * b, begin rw [← hn, ← hm], simp [zero_add] end))) protected lemma mul_pos {a b : ℤ} (ha : 0 < a) (hb : 0 < b) : 0 < a * b := lt.elim ha (assume n, assume hn, diff --git a/library/init/data/nat/lemmas.lean b/library/init/data/nat/lemmas.lean index dca3f2c74e..2638dc834b 100644 --- a/library/init/data/nat/lemmas.lean +++ b/library/init/data/nat/lemmas.lean @@ -428,7 +428,7 @@ protected lemma bit0_inj : ∀ {n m : ℕ}, bit0 n = bit0 m → n = m | (n+1) (m+1) h := have succ (succ (n + n)) = succ (succ (m + m)), begin unfold bit0 at h, simp [add_one, add_succ, succ_add] at h, exact h end, - have n + n = m + m, by repeat {injection this with this}, + have n + n = m + m, by iterate { injection this with this }, have n = m, from bit0_inj this, by rw this diff --git a/library/init/meta/coinductive_predicates.lean b/library/init/meta/coinductive_predicates.lean index 782de855f4..43de616af7 100644 --- a/library/init/meta/coinductive_predicates.lean +++ b/library/init/meta/coinductive_predicates.lean @@ -526,7 +526,7 @@ meta def add_coinductive_predicate (eqs ++ [eq']).mmap' subst else skip, eapply ((const r.func_nm u_params).app_of_list $ ps ++ fs), - repeat assumption) + iterate assumption) end), exact h)), @@ -588,7 +588,7 @@ do solve1 (do target >>= instantiate_mvars >>= change, -- TODO: bug in existsi & constructor when mvars in hyptohesis bs.mmap existsi, - repeat econstructor), + iterate econstructor), -- clean up remaining coinduction steps all_goals (do diff --git a/library/init/meta/converter/conv.lean b/library/init/meta/converter/conv.lean index a03442bc1d..ab721975e7 100644 --- a/library/init/meta/converter/conv.lean +++ b/library/init/meta/converter/conv.lean @@ -107,7 +107,7 @@ do (r, lhs, rhs) ← target_lhs_rhs, return () meta def funext : conv unit := -repeat $ do +iterate $ do (r, lhs, rhs) ← target_lhs_rhs, guard (r = `eq), (expr.lam n _ _ _) ← return lhs, diff --git a/library/init/meta/interactive.lean b/library/init/meta/interactive.lean index b47dd99ca9..694f024aeb 100644 --- a/library/init/meta/interactive.lean +++ b/library/init/meta/interactive.lean @@ -599,10 +599,10 @@ meta def contradiction : tactic unit := tactic.contradiction /-- -`repeat { t }` repeatedly applies tactic `t` until `t` fails. The compound tactic always succeeds. +`iterate { t }` repeatedly applies tactic `t` until `t` fails. The compound tactic always succeeds. -/ -meta def repeat : itactic → tactic unit := -tactic.repeat +meta def iterate : itactic → tactic unit := +tactic.iterate /-- `try { t }` tries to apply tactic `t`, but succeeds whether or not `t` succeeds. diff --git a/library/init/meta/relation_tactics.lean b/library/init/meta/relation_tactics.lean index 4d66c9ce67..8da8a8155e 100644 --- a/library/init/meta/relation_tactics.lean +++ b/library/init/meta/relation_tactics.lean @@ -42,6 +42,6 @@ target >>= relation_lhs_rhs /-- Try to apply subst exhaustively -/ meta def subst_vars : tactic unit := -focus1 $ repeat (any_hyp subst) >> try (reflexivity reducible) +focus1 $ iterate (any_hyp subst) >> try (reflexivity reducible) end tactic diff --git a/library/init/meta/smt/interactive.lean b/library/init/meta/smt/interactive.lean index 2b38ffb230..a8dd5a2ea4 100644 --- a/library/init/meta/smt/interactive.lean +++ b/library/init/meta/smt/interactive.lean @@ -16,7 +16,7 @@ meta def skip : smt_tactic unit := return () meta def solve_goals : smt_tactic unit := -repeat close +iterate close meta def step {α : Type} (tac : smt_tactic α) : smt_tactic unit := tac >> solve_goals @@ -222,8 +222,8 @@ meta def try (t : itactic) : smt_tactic unit := smt_tactic.try t /-- Keep applying the given tactic until it fails. -/ -meta def repeat (t : itactic) : smt_tactic unit := -smt_tactic.repeat t +meta def iterate (t : itactic) : smt_tactic unit := +smt_tactic.iterate t /-- Apply the given tactic to all remaining goals. -/ meta def all_goals (t : itactic) : smt_tactic unit := @@ -256,7 +256,7 @@ smt_tactic.eblast /-- Keep applying heuristic instantiation using the given lemmas until the current goal is solved, or it fails. -/ meta def eblast_using (l : parse pexpr_list_or_texpr) : smt_tactic unit := do hs ← add_hinst_lemmas_from_pexprs reducible ff l hinst_lemmas.mk, - smt_tactic.repeat (smt_tactic.ematch_using hs >> smt_tactic.try smt_tactic.close) + smt_tactic.iterate (smt_tactic.ematch_using hs >> smt_tactic.try smt_tactic.close) meta def guard_expr_eq (t : expr) (p : parse $ tk ":=" *> texpr) : smt_tactic unit := do e ← to_expr p, guard (expr.alpha_eqv t e) diff --git a/library/init/meta/smt/rsimp.lean b/library/init/meta/smt/rsimp.lean index 814e976ead..c7d555b847 100644 --- a/library/init/meta/smt/rsimp.lean +++ b/library/init/meta/smt/rsimp.lean @@ -124,7 +124,7 @@ do focus1 $ using_smt_with {em_attr := cfg.attr_name} $ do add_lemmas_from_facts, add_lemmas extra, - repeat_at_most cfg.max_rounds (ematch >> try smt_tactic.close), + iterate_at_most cfg.max_rounds (ematch >> try smt_tactic.close), (done >> return cc_state.mk) <|> to_cc_state diff --git a/library/init/meta/smt/smt_tactic.lean b/library/init/meta/smt/smt_tactic.lean index 1f6473bb51..d79914b2b2 100644 --- a/library/init/meta/smt/smt_tactic.lean +++ b/library/init/meta/smt/smt_tactic.lean @@ -155,21 +155,21 @@ meta def try {α : Type} (t : smt_tactic α) : smt_tactic unit := (λ ⟨a, new_ss⟩, result.success ((), new_ss)) (λ e ref s', result.success ((), ss) ts) -/-- `repeat_at_most n t`: repeat the given tactic at most n times or until t fails -/ -meta def repeat_at_most : nat → smt_tactic unit → smt_tactic unit +/-- `iterate_at_most n t`: repeat the given tactic at most n times or until t fails -/ +meta def iterate_at_most : nat → smt_tactic unit → smt_tactic unit | 0 t := return () -| (n+1) t := (do t, repeat_at_most n t) <|> return () +| (n+1) t := (do t, iterate_at_most n t) <|> return () -/-- `repeat_exactly n t` : execute t n times -/ -meta def repeat_exactly : nat → smt_tactic unit → smt_tactic unit +/-- `iterate_exactly n t` : execute t n times -/ +meta def iterate_exactly : nat → smt_tactic unit → smt_tactic unit | 0 t := return () -| (n+1) t := do t, repeat_exactly n t +| (n+1) t := do t, iterate_exactly n t -meta def repeat : smt_tactic unit → smt_tactic unit := -repeat_at_most 100000 +meta def iterate : smt_tactic unit → smt_tactic unit := +iterate_at_most 100000 meta def eblast : smt_tactic unit := -repeat (ematch >> try close) +iterate (ematch >> try close) open tactic @@ -404,7 +404,7 @@ open smt_tactic meta def using_smt {α} (t : smt_tactic α) (cfg : smt_config := {}) : tactic α := do ss ← smt_state.mk cfg, - (a, _) ← (do a ← t, repeat close, return a) ss, + (a, _) ← (do a ← t, iterate close, return a) ss, return a meta def using_smt_with {α} (cfg : smt_config) (t : smt_tactic α) : tactic α := diff --git a/library/init/meta/tactic.lean b/library/init/meta/tactic.lean index 3f9069e4be..3bb6c2d9ba 100644 --- a/library/init/meta/tactic.lean +++ b/library/init/meta/tactic.lean @@ -114,18 +114,18 @@ meta def success_if_fail {α : Type u} (t : tactic α) : tactic unit := end open nat -/-- (repeat_at_most n t): repeat the given tactic at most n times or until t fails -/ -meta def repeat_at_most : nat → tactic unit → tactic unit +/-- (iterate_at_most n t): repeat the given tactic at most n times or until t fails -/ +meta def iterate_at_most : nat → tactic unit → tactic unit | 0 t := skip -| (succ n) t := (do t, repeat_at_most n t) <|> skip +| (succ n) t := (do t, iterate_at_most n t) <|> skip -/-- (repeat_exactly n t) : execute t n times -/ -meta def repeat_exactly : nat → tactic unit → tactic unit +/-- (iterate_exactly n t) : execute t n times -/ +meta def iterate_exactly : nat → tactic unit → tactic unit | 0 t := skip -| (succ n) t := do t, repeat_exactly n t +| (succ n) t := do t, iterate_exactly n t -meta def repeat : tactic unit → tactic unit := -repeat_at_most 100000 +meta def iterate : tactic unit → tactic unit := +iterate_at_most 100000 meta def returnopt (e : option α) : tactic α := λ s, match e with