Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jcommelin committed Feb 15, 2019
1 parent 5da8605 commit b8b48cf
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/tactic/merge_goals.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/-
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
Tactic to merge identical goals.
-/

import category.fold

namespace tactic

private meta def map_unify (g : expr) : list expr → tactic unit
| [] := fail ()
| (x :: xs) := unify g x <|> map_unify xs

/- This returns either ac or ac ++ [g] depending on whether g unifies with some goal in ac -/
private meta def unify_or_add (g : expr) (ac : tactic (list expr)) : tactic (list expr) :=
do l ← ac, (map_unify g l >> return l) <|> return (l ++ [g])

meta def merge_goals : tactic unit :=
do gs ← get_goals,
new_gs ← traversable.foldr unify_or_add (return []) gs,
set_goals new_gs

namespace interactive

meta def merge_goals : tactic unit :=
tactic.merge_goals

end interactive

example : ((true ∧ true) ∧ (true ∧ true)) ∧ (((∀ (x y : ℕ), x + y = y + x) ∧ true) ∧ (true ∧ true)) :=
begin
split; split; split,
merge_goals,
exact trivial,
exact nat.add_comm,
end

end tactic

0 comments on commit b8b48cf

Please sign in to comment.