Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 5271ced

Browse files
committed
feat(tactic/congr): apply to iff propositions
1 parent d60d161 commit 5271ced

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/tactic/interactive.lean

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,20 @@ meta def clear_ : tactic unit := tactic.repeat $ do
139139
cl ← infer_type h >>= is_class, guard (¬ cl),
140140
tactic.clear h
141141

142+
meta def apply_iff_congr_core (tgt : expr) : tactic unit :=
143+
do applyc ``iff_of_eq,
144+
(lhs, rhs) ← target >>= match_iff,
145+
guard lhs.is_app,
146+
clemma ← mk_specialized_congr_lemma lhs,
147+
apply_congr_core clemma
148+
149+
meta def congr_core' : tactic unit :=
150+
do tgt ← target,
151+
apply_eq_congr_core tgt
152+
<|> apply_heq_congr_core
153+
<|> apply_iff_congr_core tgt
154+
<|> fail "congr tactic failed"
155+
142156
/--
143157
Same as the `congr` tactic, but takes an optional argument which gives
144158
the depth of recursive applications. This is useful when `congr`
@@ -147,7 +161,7 @@ is too aggressive in breaking down the goal. For example, given
147161
and `⊢ y = x`, while `congr' 2` produces the intended `⊢ x + y = y + x`. -/
148162
meta def congr' : parse (with_desc "n" small_nat)? → tactic unit
149163
| (some 0) := failed
150-
| o := focus1 (assumption <|> (congr_core >>
164+
| o := focus1 (assumption <|> (congr_core' >>
151165
all_goals (reflexivity <|> `[apply proof_irrel_heq] <|>
152166
`[apply proof_irrel] <|> try (congr' (nat.pred <$> o)))))
153167

0 commit comments

Comments
 (0)