Skip to content

Commit

Permalink
feat(tactics/ext): use applyc _ {new_goals := new_goals.all}
Browse files Browse the repository at this point in the history
This causes goals to appear in the same order they appear as hypotheses of the
`@[extensionality]` lemma, rather than being reordered to put dependent
goals first.

This doesn't appear to affect any uses of `ext` in mathlib,
but is occasionally helpful in the development of category theory.

(Indeed, I have been running into tactic mode proofs that fail to
typecheck, when using ext, and this avoids the problem)
  • Loading branch information
semorrison committed Sep 13, 2018
1 parent 1206356 commit 883bdd0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tactic/ext.lean
Expand Up @@ -162,9 +162,9 @@ meta def ext1 (xs : ext_patt) : tactic ext_patt :=
do subject ← target >>= get_ext_subject,
m ← extensional_attribute.get_cache,
do { rule ← m.find subject,
applyc rule } <|>
applyc rule {new_goals := new_goals.all} } <|>
do { ls ← attribute.get_instances `extensionality,
ls.any_of applyc } <|>
ls.any_of (λ n, applyc n {new_goals := new_goals.all}) } <|>
fail format!"no applicable extensionality rule found for {subject}",
try_intros xs

Expand Down
27 changes: 26 additions & 1 deletion tests/tactics.lean
Expand Up @@ -3,7 +3,7 @@ Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon, Scott Morrison
-/
import tactic data.set.lattice data.prod
import tactic data.set.lattice data.prod data.vector
tactic.rewrite data.stream.basic

section solve_by_elim
Expand Down Expand Up @@ -478,6 +478,31 @@ begin
trivial
end

structure dependent_fields :=
(a : bool)
(v : if a thenelse ℤ)

@[extensionality] lemma df.ext (s t : dependent_fields) (h : s.a = t.a)
(w : (@eq.rec _ s.a (λ b, if b thenelse ℤ) s.v t.a h) = t.v): s = t :=
begin
cases s, cases t,
dsimp at *,
congr,
exact h,
subst h,
simp,
simp at w,
exact w,
end

example (s : dependent_fields) : s = s :=
begin
ext,
guard_target s.a = s.a,
refl,
refl,
end

end ext

section apply_rules
Expand Down

0 comments on commit 883bdd0

Please sign in to comment.