2015-11-05 05:53:12 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2015 Daniel Selsam. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Author: Daniel Selsam
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "kernel/expr_pair.h"
|
2015-11-09 21:19:59 +00:00
|
|
|
#include "library/blast/state.h"
|
2015-11-12 22:14:18 +00:00
|
|
|
#include "library/simplifier/simp_rule_set.h"
|
2015-11-05 05:53:12 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
namespace blast {
|
|
|
|
|
|
|
|
namespace simp {
|
|
|
|
|
|
|
|
/* Struct to store results of simplification */
|
|
|
|
struct result {
|
|
|
|
/* Invariant [m_pf : m_orig <rel> m_new] */
|
2015-11-16 16:54:21 +00:00
|
|
|
/* Note: we only keep [m_old] to make the code easier to understand.
|
|
|
|
It could be optimized away in the future. */
|
2015-11-05 05:53:12 +00:00
|
|
|
expr m_new;
|
2015-11-16 16:54:21 +00:00
|
|
|
|
|
|
|
/* If proof is not provided, it is assumed to be reflexivity */
|
2015-11-05 05:53:12 +00:00
|
|
|
optional<expr> m_proof;
|
|
|
|
|
|
|
|
public:
|
2015-11-16 16:54:21 +00:00
|
|
|
result() {}
|
2015-11-05 05:53:12 +00:00
|
|
|
result(expr const & e): m_new(e) {}
|
2015-11-16 16:54:21 +00:00
|
|
|
result(expr const & e, expr const & proof): m_new(e), m_proof(proof) {}
|
|
|
|
result(expr const & e, optional<expr> const & proof): m_new(e), m_proof(proof) {}
|
|
|
|
|
|
|
|
bool has_proof() const { return static_cast<bool>(m_proof); }
|
2015-11-05 05:53:12 +00:00
|
|
|
|
|
|
|
expr get_new() const { return m_new; }
|
|
|
|
expr get_proof() const { lean_assert(m_proof); return *m_proof; }
|
|
|
|
|
|
|
|
/* The following assumes that [e] and [m_new] are definitionally equal */
|
|
|
|
void update(expr const & e) { m_new = e; }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-11-12 22:14:18 +00:00
|
|
|
simp::result simplify(name const & rel, expr const & e, simp_rule_sets const & srss);
|
2015-11-05 05:53:12 +00:00
|
|
|
|
|
|
|
void initialize_simplifier();
|
|
|
|
void finalize_simplifier();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|