refactor(library/tactic): remove 'append' and 'interleave' tacticals

Preparation for major refactoring in the tactic framework.
This commit is contained in:
Leonardo de Moura 2016-02-24 15:53:50 -08:00
parent 9b15c4c669
commit 1924b2884c
13 changed files with 21 additions and 70 deletions

View file

@ -21,8 +21,6 @@ namespace tactic
-- a term of type 'tactic' into a tactic that sythesizes a term
definition and_then (t1 t2 : tactic) : tactic := builtin
definition or_else (t1 t2 : tactic) : tactic := builtin
definition append (t1 t2 : tactic) : tactic := builtin
definition interleave (t1 t2 : tactic) : tactic := builtin
definition par (t1 t2 : tactic) : tactic := builtin
definition fixpoint (f : tactic → tactic) : tactic := builtin
definition repeat (t : tactic) : tactic := builtin

View file

@ -368,7 +368,10 @@ namespace sigma
begin
fapply equiv.MK,
{ intro v,
induction v with p b, induction p: append (apply inl) (apply inr); constructor; assumption },
induction v with p b,
induction p,
{ apply inl, constructor, assumption },
{ apply inr, constructor, assumption }},
{ intro p, induction p with v v: induction v; constructor; assumption},
{ intro p, induction p with v v: induction v; reflexivity},
{ intro v, induction v with p b, induction p: reflexivity},
@ -379,9 +382,14 @@ namespace sigma
begin
fapply equiv.MK,
{ intro v,
induction v with a p, induction p: append (apply inl) (apply inr); constructor; assumption},
induction v with a p,
induction p,
{ apply inl, constructor, assumption},
{ apply inr, constructor, assumption}},
{ intro p,
induction p with v v: induction v; constructor; append (apply inl) (apply inr); assumption},
induction p with v v,
{ induction v, constructor, apply inl, assumption },
{ induction v, constructor, apply inr, assumption }},
{ intro p, induction p with v v: induction v; reflexivity},
{ intro v, induction v with a p, induction p: reflexivity},
end

View file

@ -159,7 +159,12 @@ namespace sum
fapply equiv.MK,
all_goals try (intro z; induction z with u v;
all_goals try induction u; all_goals try induction v),
all_goals try (repeat append (append (apply inl) (apply inr)) assumption; now),
exact inl (inl u),
exact inl (inr a),
exact inr a,
exact inl a,
exact inr (inl a),
exact inr (inr v),
all_goals reflexivity
end

View file

@ -22,8 +22,6 @@ namespace tactic
definition and_then (t1 t2 : tactic) : tactic := builtin
definition or_else (t1 t2 : tactic) : tactic := builtin
definition append (t1 t2 : tactic) : tactic := builtin
definition interleave (t1 t2 : tactic) : tactic := builtin
definition par (t1 t2 : tactic) : tactic := builtin
definition fixpoint (f : tactic → tactic) : tactic := builtin
definition repeat (t : tactic) : tactic := builtin
definition at_most (t : tactic) (k : num) : tactic := builtin

View file

@ -206,7 +206,6 @@ name const * g_subsingleton_helim = nullptr;
name const * g_tactic = nullptr;
name const * g_tactic_all_goals = nullptr;
name const * g_tactic_and_then = nullptr;
name const * g_tactic_append = nullptr;
name const * g_tactic_apply = nullptr;
name const * g_tactic_assert_hypothesis = nullptr;
name const * g_tactic_assumption = nullptr;
@ -237,7 +236,6 @@ name const * g_tactic_generalize_tac = nullptr;
name const * g_tactic_id = nullptr;
name const * g_tactic_identifier = nullptr;
name const * g_tactic_identifier_list = nullptr;
name const * g_tactic_interleave = nullptr;
name const * g_tactic_intro = nullptr;
name const * g_tactic_intros = nullptr;
name const * g_tactic_location = nullptr;
@ -481,7 +479,6 @@ void initialize_constants() {
g_tactic = new name{"tactic"};
g_tactic_all_goals = new name{"tactic", "all_goals"};
g_tactic_and_then = new name{"tactic", "and_then"};
g_tactic_append = new name{"tactic", "append"};
g_tactic_apply = new name{"tactic", "apply"};
g_tactic_assert_hypothesis = new name{"tactic", "assert_hypothesis"};
g_tactic_assumption = new name{"tactic", "assumption"};
@ -512,7 +509,6 @@ void initialize_constants() {
g_tactic_id = new name{"tactic", "id"};
g_tactic_identifier = new name{"tactic", "identifier"};
g_tactic_identifier_list = new name{"tactic", "identifier_list"};
g_tactic_interleave = new name{"tactic", "interleave"};
g_tactic_intro = new name{"tactic", "intro"};
g_tactic_intros = new name{"tactic", "intros"};
g_tactic_location = new name{"tactic", "location"};
@ -757,7 +753,6 @@ void finalize_constants() {
delete g_tactic;
delete g_tactic_all_goals;
delete g_tactic_and_then;
delete g_tactic_append;
delete g_tactic_apply;
delete g_tactic_assert_hypothesis;
delete g_tactic_assumption;
@ -788,7 +783,6 @@ void finalize_constants() {
delete g_tactic_id;
delete g_tactic_identifier;
delete g_tactic_identifier_list;
delete g_tactic_interleave;
delete g_tactic_intro;
delete g_tactic_intros;
delete g_tactic_location;
@ -1032,7 +1026,6 @@ name const & get_subsingleton_helim_name() { return *g_subsingleton_helim; }
name const & get_tactic_name() { return *g_tactic; }
name const & get_tactic_all_goals_name() { return *g_tactic_all_goals; }
name const & get_tactic_and_then_name() { return *g_tactic_and_then; }
name const & get_tactic_append_name() { return *g_tactic_append; }
name const & get_tactic_apply_name() { return *g_tactic_apply; }
name const & get_tactic_assert_hypothesis_name() { return *g_tactic_assert_hypothesis; }
name const & get_tactic_assumption_name() { return *g_tactic_assumption; }
@ -1063,7 +1056,6 @@ name const & get_tactic_generalize_tac_name() { return *g_tactic_generalize_tac;
name const & get_tactic_id_name() { return *g_tactic_id; }
name const & get_tactic_identifier_name() { return *g_tactic_identifier; }
name const & get_tactic_identifier_list_name() { return *g_tactic_identifier_list; }
name const & get_tactic_interleave_name() { return *g_tactic_interleave; }
name const & get_tactic_intro_name() { return *g_tactic_intro; }
name const & get_tactic_intros_name() { return *g_tactic_intros; }
name const & get_tactic_location_name() { return *g_tactic_location; }

View file

@ -208,7 +208,6 @@ name const & get_subsingleton_helim_name();
name const & get_tactic_name();
name const & get_tactic_all_goals_name();
name const & get_tactic_and_then_name();
name const & get_tactic_append_name();
name const & get_tactic_apply_name();
name const & get_tactic_assert_hypothesis_name();
name const & get_tactic_assumption_name();
@ -239,7 +238,6 @@ name const & get_tactic_generalize_tac_name();
name const & get_tactic_id_name();
name const & get_tactic_identifier_name();
name const & get_tactic_identifier_list_name();
name const & get_tactic_interleave_name();
name const & get_tactic_intro_name();
name const & get_tactic_intros_name();
name const & get_tactic_location_name();

View file

@ -201,7 +201,6 @@ subsingleton.helim
tactic
tactic.all_goals
tactic.and_then
tactic.append
tactic.apply
tactic.assert_hypothesis
tactic.assumption
@ -232,7 +231,6 @@ tactic.generalize_tac
tactic.id
tactic.identifier
tactic.identifier_list
tactic.interleave
tactic.intro
tactic.intros
tactic.location

View file

@ -108,10 +108,7 @@ static tactic assumption_tactic_core(bool conservative) {
expr const & h = hs[i];
tactic curr = exact_tactic(elab, h, false, false, conservative);
if (tac) {
if (conservative)
tac = orelse(*tac, curr);
else
tac = append(*tac, curr);
tac = orelse(*tac, curr);
} else {
tac = curr;
}

View file

@ -406,10 +406,6 @@ void initialize_expr_to_tactic() {
[]() { return beta_tactic(); });
register_bin_tac(get_tactic_and_then_name(),
[](tactic const & t1, tactic const & t2) { return then(t1, t2); });
register_bin_tac(get_tactic_append_name(),
[](tactic const & t1, tactic const & t2) { return append(t1, t2); });
register_bin_tac(get_tactic_interleave_name(),
[](tactic const & t1, tactic const & t2) { return interleave(t1, t2); });
register_bin_tac(get_tactic_par_name(),
[](tactic const & t1, tactic const & t2) { return par(t1, t2); });
register_bin_tac(get_tactic_or_else_name(),

View file

@ -179,20 +179,6 @@ tactic try_for(tactic const & t, unsigned ms, unsigned check_ms) {
});
}
tactic append(tactic const & t1, tactic const & t2) {
return tactic([=](environment const & env, io_state const & ios, proof_state const & _s) -> proof_state_seq {
proof_state s = _s.update_report_failure(false);
return append(t1(env, ios, s), t2(env, ios, s), "APPEND tactical");
});
}
tactic interleave(tactic const & t1, tactic const & t2) {
return tactic([=](environment const & env, io_state const & ios, proof_state const & _s) -> proof_state_seq {
proof_state s = _s.update_report_failure(false);
return interleave(t1(env, ios, s), t2(env, ios, s), "INTERLEAVE tactical");
});
}
tactic par(tactic const & t1, tactic const & t2, unsigned check_ms) {
return tactic([=](environment const & env, io_state const & ios, proof_state const & _s) -> proof_state_seq {
proof_state s = _s.update_report_failure(false);

View file

@ -76,25 +76,12 @@ tactic using_params(tactic const & t, options const & opts);
thread finished.
*/
tactic try_for(tactic const & t, unsigned ms, unsigned check_ms = 1);
/**
\brief Execute both tactics and and combines their results.
The results produced by tactic \c t1 are listed before the ones
from tactic \c t2.
*/
tactic append(tactic const & t1, tactic const & t2);
/** \brief Return a tactic that rotate goals to the left n steps */
tactic rotate_left(unsigned n);
/** \brief Return a tactic that rotate goals to the right n steps */
tactic rotate_right(unsigned n);
inline tactic operator+(tactic const & t1, tactic const & t2) { return append(t1, t2); }
/**
\brief Execute both tactics and and combines their results.
The results produced by tactics \c t1 and \c t2 are interleaved
to guarantee fairness.
*/
tactic interleave(tactic const & t1, tactic const & t2);
/**
\brief Return a tactic that executes \c t1 and \c t2 in parallel.
This is similar to \c append and \c interleave. The order of

View file

@ -3,4 +3,4 @@ variable q : nat → Prop
variables a b c : nat
example : p c → p b → q b → p a → ∃ x, p x ∧ q x :=
by intros; repeat (constructor | eassumption); now
by blast

View file

@ -12,19 +12,7 @@ theorem inl_inhabited {A : Type} (B : Type) (H : inhabited A) : inhabited (sum A
theorem inr_inhabited (A : Type) {B : Type} (H : inhabited B) : inhabited (sum A B)
:= inhabited.destruct H (λ b, inhabited.mk (sum.inr A b))
infixl `..`:10 := append
notation `(` h `|` r:(foldl `|` (e r, tactic.or_else r e) h) `)` := r
infixl `;`:15 := tactic.and_then
reveal inl_inhabited inr_inhabited
definition my_tac := repeat (trace "iteration"; state;
( apply @inl_inhabited; trace "used inl"
.. apply @inr_inhabited; trace "used inr"
.. apply @num.is_inhabited; trace "used num")) ; now
tactic_hint my_tac
theorem T : inhabited (sum false num)
theorem T : inhabited (sum false num) :=
inhabited.mk (sum.inr false 0)
end foo