Skip to content

Commit

Permalink
chore(tactic/pi_instance): add a docstring, remove a little bit of re…
Browse files Browse the repository at this point in the history
…dundancy (#2500)
  • Loading branch information
khoek committed Apr 24, 2020
1 parent b7af283 commit e7bd312
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/tactic/pi_instances.lean
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,29 @@ Automation for creating instances of mathematical structures for pi types

namespace tactic

open interactive interactive.types lean.parser expr
open functor has_seq list nat tactic.interactive
open tactic.interactive

meta def derive_field : tactic unit :=
/-- Attempt to clear a goal obtained by refining a `pi_instance` goal. -/
meta def pi_instance_derive_field : tactic unit :=
do b ← target >>= is_prop,
field ← get_current_field,
if b then do
field ← get_current_field,
vs ← introv [] <|> pure [],
hs ← intros <|> pure [],
resetI,
x ← get_unused_name,
try (() <$ ext1 [rcases_patt.one x] <|> () <$ intro x),
x' ← try_core (get_local x),
reset_instance_cache,
xn ← get_unused_name,
try (() <$ ext1 [rcases_patt.one xn] <|> () <$ intro xn),
xvoption.iget <$> try_core (get_local xn),
applyc field,
hs.mmap (λ h, try $
() <$ (to_expr ``(congr_fun %%h %%(x'.iget)) >>= apply) <|>
() <$ apply (h x'.iget) <|>
() <$ (to_expr ``(congr_fun %%h %%xv) >>= apply) <|>
() <$ apply (h xv) <|>
() <$ (to_expr ``(set.mem_image_of_mem _ %%h) >>= apply) <|>
() <$ (solve_by_elim) ),
() <$ solve_by_elim),
return ()
else focus1 $ do
field ← get_current_field,
e ← mk_const field,
expl_arity ← get_expl_arity e,
xs ← (iota expl_arity).mmap $ λ _, intro1,
expl_arity ← mk_const field >>= get_expl_arity,
xs ← (list.iota expl_arity).mmap $ λ _, intro1,
x ← intro1,
applyc field,
xs.mmap' (λ h, try $
Expand All @@ -54,7 +51,7 @@ it defaults to `pi.partial_order`. Any field of the instance that
-/
meta def pi_instance : tactic unit :=
refine_struct ``( { ..pi.partial_order, .. } );
propagate_tags (try (derive_field ; done))
propagate_tags (try $ pi_instance_derive_field >> done)

run_cmd add_interactive [`pi_instance]

Expand Down

0 comments on commit e7bd312

Please sign in to comment.