lean4-htt/tests/lean/run/rw1.lean
Leonardo de Moura f7fe2a775c feat(library/init/meta/rewrite_tactic): improve rewrite tactic
`rewrite` tactic improvements
- Add support for `auto_param` and `opt_param`
- Order new goals using the same strategies available for `apply`
- Allow user to set configuration object in interactive mode.

@Armael This commit should address the issue you raised about the order
of new goals in the `rewrite` tactic.
See new test tests/lean/run/rw1.lean for examples.
2017-06-30 12:03:27 -07:00

84 lines
1.6 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace Ex1
variables
(f : nat → nat → nat)
(p : nat → nat → Prop)
(h₁ : ∀ a b c, p b c → f a b = a)
(x y z : nat)
(h₂ : p y z)
include f h₁ x y z h₂
open tactic
example : f x y = 0 + x :=
begin
rw [h₁],
/- Resulting goals
... ⊢ x = 0 + x
... ⊢ p y ?m_1
... ⊢ -- This is ?m_1
-/
(do n ← num_goals, guard $ n = 3),
simp,
exact h₂
end
example : f x y = 0 + x :=
begin
rw [h₁] {new_goals := new_goals.non_dep_only},
/- Resulting goals
... ⊢ x = 0 + x
... ⊢ p y ?m_1
?m_1 is not included as a new goal because it occurs above.
-/
(do n ← num_goals, guard $ n = 2),
simp,
exact h₂
end
example : f x y = 0 + x :=
begin
rw [h₁] {new_goals := new_goals.all},
/- Resulting goals
... ⊢ x = 0 + x
... ⊢ -- This is ?m_1
... ⊢ p y ?m_1
The order is preserved in this mode.
-/
(do n ← num_goals, guard $ n = 3),
simp,
exact z,
exact h₂
end
end Ex1
namespace Ex2
open tactic
constant f : nat → nat
constant p : nat → Prop
/- The following lemma has an "auto_param", i.e., if `h` is not provided we
try to synthesize it using the `assumption` tactic -/
lemma f_lemma (a : nat) (h : p a . assumption) : f a = a :=
sorry
/- `rw` has support for "auto_param"'s. -/
example (x : nat) (h : p x) : f x = 0 + x :=
begin
rw [f_lemma],
(do n ← num_goals, guard $ n = 1),
simp
end
/- We can disable auto_param support. -/
example (x : nat) (h : p x) : f x = 0 + x :=
begin
rw [f_lemma] {auto_param := ff},
(do n ← num_goals, guard $ n = 2),
simp,
exact h
end
end Ex2