fix(frontends/lean/proof_qed_elaborator): information about synthesized variables in a proof-qed block was being lost
This commit is contained in:
parent
7073f036d8
commit
64f6601fe3
6 changed files with 97 additions and 4 deletions
|
@ -257,11 +257,14 @@ expr elaborator::visit_by(expr const & e, optional<expr> const & t, constraint_s
|
||||||
|
|
||||||
expr elaborator::visit_proof_qed(expr const & e, optional<expr> const & t, constraint_seq & cs) {
|
expr elaborator::visit_proof_qed(expr const & e, optional<expr> const & t, constraint_seq & cs) {
|
||||||
lean_assert(is_proof_qed_annotation(e));
|
lean_assert(is_proof_qed_annotation(e));
|
||||||
|
info_manager * im = nullptr;
|
||||||
|
if (infom())
|
||||||
|
im = &m_pre_info_data;
|
||||||
pair<expr, constraint_seq> ecs = visit(get_annotation_arg(e));
|
pair<expr, constraint_seq> ecs = visit(get_annotation_arg(e));
|
||||||
expr m = m_full_context.mk_meta(m_ngen, t, e.get_tag());
|
expr m = m_full_context.mk_meta(m_ngen, t, e.get_tag());
|
||||||
register_meta(m);
|
register_meta(m);
|
||||||
constraint c = mk_proof_qed_cnstr(env(), m, ecs.first, ecs.second,
|
constraint c = mk_proof_qed_cnstr(env(), m, ecs.first, ecs.second, m_unifier_config,
|
||||||
m_unifier_config, m_relax_main_opaque);
|
im, m_relax_main_opaque);
|
||||||
cs += c;
|
cs += c;
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,14 @@ Author: Leonardo de Moura
|
||||||
#include "library/reducible.h"
|
#include "library/reducible.h"
|
||||||
#include "library/metavar_closure.h"
|
#include "library/metavar_closure.h"
|
||||||
#include "frontends/lean/util.h"
|
#include "frontends/lean/util.h"
|
||||||
|
#include "frontends/lean/info_manager.h"
|
||||||
namespace lean {
|
namespace lean {
|
||||||
/** \brief Create a "choice" constraint that postpone the
|
/** \brief Create a "choice" constraint that postpone the
|
||||||
solving the constraints <tt>(cs union (m =?= e))</tt>.
|
solving the constraints <tt>(cs union (m =?= e))</tt>.
|
||||||
*/
|
*/
|
||||||
constraint mk_proof_qed_cnstr(environment const & env, expr const & m, expr const & e,
|
constraint mk_proof_qed_cnstr(environment const & env, expr const & m, expr const & e,
|
||||||
constraint_seq const & cs, unifier_config const & cfg, bool relax) {
|
constraint_seq const & cs, unifier_config const & cfg,
|
||||||
|
info_manager * im, bool relax) {
|
||||||
justification j = mk_failed_to_synthesize_jst(env, m);
|
justification j = mk_failed_to_synthesize_jst(env, m);
|
||||||
auto choice_fn = [=](expr const & meta, expr const & meta_type, substitution const & s,
|
auto choice_fn = [=](expr const & meta, expr const & meta_type, substitution const & s,
|
||||||
name_generator const & _ngen) {
|
name_generator const & _ngen) {
|
||||||
|
@ -45,6 +47,10 @@ constraint mk_proof_qed_cnstr(environment const & env, expr const & m, expr cons
|
||||||
// we erase internal justifications
|
// we erase internal justifications
|
||||||
return update_justification(c, j);
|
return update_justification(c, j);
|
||||||
});
|
});
|
||||||
|
if (im)
|
||||||
|
im->instantiate(new_s);
|
||||||
|
// TODO(Leo): the solution new_s also assigns auxiliary metavariables
|
||||||
|
// that are needed to generate data for the info_manager
|
||||||
constraints r = cls.mk_constraints(new_s, j, relax);
|
constraints r = cls.mk_constraints(new_s, j, relax);
|
||||||
return append(r, postponed);
|
return append(r, postponed);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,11 +6,17 @@ Author: Leonardo de Moura
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "library/unifier.h"
|
#include "library/unifier.h"
|
||||||
|
#include "frontends/lean/info_manager.h"
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
/** \brief Create a "choice" constraint that postpone the
|
/** \brief Create a "choice" constraint that postpone the
|
||||||
solving the constraints <tt>(cs union (m =?= e))</tt>.
|
solving the constraints <tt>(cs union (m =?= e))</tt>.
|
||||||
|
|
||||||
|
\remark A proof-qed block may instantiate meta-variables in the
|
||||||
|
info_manager. Thus, we provide the info_manager to make sure
|
||||||
|
this assignments are reflected on it.
|
||||||
*/
|
*/
|
||||||
constraint mk_proof_qed_cnstr(environment const & env, expr const & m, expr const & e,
|
constraint mk_proof_qed_cnstr(environment const & env, expr const & m, expr const & e,
|
||||||
constraint_seq const & cs, unifier_config const & cfg, bool relax);
|
constraint_seq const & cs, unifier_config const & cfg,
|
||||||
|
info_manager * im, bool relax);
|
||||||
}
|
}
|
||||||
|
|
3
tests/lean/interactive/proof_qed.input
Normal file
3
tests/lean/interactive/proof_qed.input
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
VISIT proof_qed.lean
|
||||||
|
WAIT
|
||||||
|
INFO 11
|
61
tests/lean/interactive/proof_qed.input.expected.out
Normal file
61
tests/lean/interactive/proof_qed.input.expected.out
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
-- BEGINWAIT
|
||||||
|
-- ENDWAIT
|
||||||
|
-- BEGININFO
|
||||||
|
-- SYMBOL|11|4
|
||||||
|
@
|
||||||
|
-- ACK
|
||||||
|
-- TYPE|11|5
|
||||||
|
∀ {A : Type} {a b c : A}, eq a b → eq b c → eq a c
|
||||||
|
-- ACK
|
||||||
|
-- IDENTIFIER|11|5
|
||||||
|
eq.trans
|
||||||
|
-- ACK
|
||||||
|
-- TYPE|11|14
|
||||||
|
Type
|
||||||
|
-- ACK
|
||||||
|
-- SYNTH|11|14
|
||||||
|
A
|
||||||
|
-- ACK
|
||||||
|
-- SYMBOL|11|14
|
||||||
|
_
|
||||||
|
-- ACK
|
||||||
|
-- TYPE|11|16
|
||||||
|
A
|
||||||
|
-- ACK
|
||||||
|
-- SYNTH|11|16
|
||||||
|
a
|
||||||
|
-- ACK
|
||||||
|
-- SYMBOL|11|16
|
||||||
|
_
|
||||||
|
-- ACK
|
||||||
|
-- TYPE|11|18
|
||||||
|
A
|
||||||
|
-- ACK
|
||||||
|
-- SYNTH|11|18
|
||||||
|
b
|
||||||
|
-- ACK
|
||||||
|
-- SYMBOL|11|18
|
||||||
|
_
|
||||||
|
-- ACK
|
||||||
|
-- TYPE|11|20
|
||||||
|
A
|
||||||
|
-- ACK
|
||||||
|
-- SYNTH|11|20
|
||||||
|
c
|
||||||
|
-- ACK
|
||||||
|
-- SYMBOL|11|20
|
||||||
|
_
|
||||||
|
-- ACK
|
||||||
|
-- TYPE|11|22
|
||||||
|
eq a b
|
||||||
|
-- ACK
|
||||||
|
-- IDENTIFIER|11|22
|
||||||
|
H1
|
||||||
|
-- ACK
|
||||||
|
-- TYPE|11|25
|
||||||
|
eq b c
|
||||||
|
-- ACK
|
||||||
|
-- IDENTIFIER|11|25
|
||||||
|
H2
|
||||||
|
-- ACK
|
||||||
|
-- ENDINFO
|
14
tests/lean/interactive/proof_qed.lean
Normal file
14
tests/lean/interactive/proof_qed.lean
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import logic
|
||||||
|
open eq.ops
|
||||||
|
set_option pp.notation false
|
||||||
|
section
|
||||||
|
parameter {A : Type}
|
||||||
|
parameters {a b c d e : A}
|
||||||
|
theorem tst : a = b → b = c → c = d → d = e → a = e :=
|
||||||
|
take H1 H2 H3 H4,
|
||||||
|
have e1 : a = c,
|
||||||
|
proof
|
||||||
|
@eq.trans _ _ _ _ H1 H2
|
||||||
|
∎,
|
||||||
|
e1 ⬝ H3 ⬝ H4
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue