2013-08-04 16:37:52 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
2013-09-13 10:35:29 +00:00
|
|
|
#include "kernel/expr.h"
|
2013-08-04 16:37:52 +00:00
|
|
|
|
|
|
|
namespace lean {
|
2013-12-30 19:46:03 +00:00
|
|
|
// See src/builtin/kernel.lean for signatures.
|
2013-09-02 16:11:53 +00:00
|
|
|
extern expr const TypeU;
|
2013-08-06 03:06:07 +00:00
|
|
|
|
|
|
|
/** \brief Return the Lean Boolean type. */
|
2013-08-06 18:27:14 +00:00
|
|
|
expr mk_bool_type();
|
2013-09-02 16:11:53 +00:00
|
|
|
extern expr const Bool;
|
2013-11-26 19:30:18 +00:00
|
|
|
bool is_bool(expr const & e);
|
2013-08-04 16:37:52 +00:00
|
|
|
|
2013-08-06 03:06:07 +00:00
|
|
|
/** \brief Create a Lean Boolean value (true/false) */
|
2013-08-06 18:27:14 +00:00
|
|
|
expr mk_bool_value(bool v);
|
2013-09-02 16:11:53 +00:00
|
|
|
extern expr const True;
|
|
|
|
extern expr const False;
|
2013-08-06 03:06:07 +00:00
|
|
|
/** \brief Return true iff \c e is a Lean Boolean value. */
|
2013-08-04 16:37:52 +00:00
|
|
|
bool is_bool_value(expr const & e);
|
2013-08-06 03:06:07 +00:00
|
|
|
/**
|
|
|
|
\brief Convert a Lean Boolean value into a C++ Boolean value.
|
|
|
|
\pre is_bool_value(e)
|
|
|
|
*/
|
2013-08-04 16:37:52 +00:00
|
|
|
bool to_bool(expr const & e);
|
2013-08-06 03:06:07 +00:00
|
|
|
/** \brief Return true iff \c e is the Lean true value. */
|
2013-08-04 16:37:52 +00:00
|
|
|
bool is_true(expr const & e);
|
2013-08-06 03:06:07 +00:00
|
|
|
/** \brief Return true iff \c e is the Lean false value. */
|
2013-08-04 16:37:52 +00:00
|
|
|
bool is_false(expr const & e);
|
2013-08-05 21:23:43 +00:00
|
|
|
|
2013-08-06 18:27:14 +00:00
|
|
|
expr mk_if_fn();
|
2013-11-29 19:35:58 +00:00
|
|
|
bool is_if_fn(expr const & e);
|
|
|
|
inline bool is_if(expr const & e) { return is_app(e) && is_if_fn(arg(e, 0)); }
|
2013-08-06 18:27:14 +00:00
|
|
|
inline expr mk_if(expr const & A, expr const & c, expr const & t, expr const & e) { return mk_app(mk_if_fn(), A, c, t, e); }
|
|
|
|
inline expr If(expr const & A, expr const & c, expr const & t, expr const & e) { return mk_if(A, c, t, e); }
|
|
|
|
inline expr mk_bool_if(expr const & c, expr const & t, expr const & e) { return mk_if(mk_bool_type(), c, t, e); }
|
|
|
|
inline expr bIf(expr const & c, expr const & t, expr const & e) { return mk_bool_if(c, t, e); }
|
2013-08-06 03:06:07 +00:00
|
|
|
|
2013-08-07 03:21:43 +00:00
|
|
|
expr mk_implies_fn();
|
2013-11-29 19:35:58 +00:00
|
|
|
bool is_implies_fn(expr const & e);
|
|
|
|
inline bool is_implies(expr const & e) { return is_app(e) && is_implies_fn(arg(e, 0)); }
|
2013-08-07 03:21:43 +00:00
|
|
|
inline expr mk_implies(expr const & e1, expr const & e2) { return mk_app(mk_implies_fn(), e1, e2); }
|
|
|
|
inline expr Implies(expr const & e1, expr const & e2) { return mk_implies(e1, e2); }
|
|
|
|
|
2013-08-18 22:03:58 +00:00
|
|
|
expr mk_iff_fn();
|
2013-11-29 19:35:58 +00:00
|
|
|
bool is_iff_fn(expr const & e);
|
|
|
|
inline bool is_iff(expr const & e) { return is_app(e) && is_iff_fn(arg(e, 0)); }
|
2013-08-18 22:03:58 +00:00
|
|
|
inline expr mk_iff(expr const & e1, expr const & e2) { return mk_app(mk_iff_fn(), e1, e2); }
|
|
|
|
inline expr Iff(expr const & e1, expr const & e2) { return mk_iff(e1, e2); }
|
|
|
|
|
2013-08-06 18:27:14 +00:00
|
|
|
expr mk_and_fn();
|
2013-11-29 19:35:58 +00:00
|
|
|
bool is_and_fn(expr const & e);
|
|
|
|
inline bool is_and(expr const & e) { return is_app(e) && is_and_fn(arg(e, 0)); }
|
2013-08-06 18:27:14 +00:00
|
|
|
inline expr mk_and(expr const & e1, expr const & e2) { return mk_app(mk_and_fn(), e1, e2); }
|
|
|
|
inline expr And(expr const & e1, expr const & e2) { return mk_and(e1, e2); }
|
2013-08-06 03:06:07 +00:00
|
|
|
|
2013-08-06 18:27:14 +00:00
|
|
|
expr mk_or_fn();
|
2013-11-29 19:35:58 +00:00
|
|
|
bool is_or_fn(expr const & e);
|
|
|
|
inline bool is_or(expr const & e) { return is_app(e) && is_or_fn(arg(e, 0)); }
|
2013-08-06 18:27:14 +00:00
|
|
|
inline expr mk_or(expr const & e1, expr const & e2) { return mk_app(mk_or_fn(), e1, e2); }
|
|
|
|
inline expr Or(expr const & e1, expr const & e2) { return mk_or(e1, e2); }
|
2013-08-06 03:06:07 +00:00
|
|
|
|
2013-08-06 18:27:14 +00:00
|
|
|
expr mk_not_fn();
|
2013-11-29 19:35:58 +00:00
|
|
|
bool is_not_fn(expr const & e);
|
|
|
|
inline bool is_not(expr const & e) { return is_app(e) && is_not_fn(arg(e, 0)); }
|
2013-08-06 18:27:14 +00:00
|
|
|
inline expr mk_not(expr const & e) { return mk_app(mk_not_fn(), e); }
|
|
|
|
inline expr Not(expr const & e) { return mk_not(e); }
|
2013-08-06 03:06:07 +00:00
|
|
|
|
2013-08-06 18:27:14 +00:00
|
|
|
expr mk_forall_fn();
|
2013-11-29 19:35:58 +00:00
|
|
|
bool is_forall_fn(expr const & e);
|
|
|
|
inline bool is_forall(expr const & e) { return is_app(e) && is_forall_fn(arg(e, 0)); }
|
2013-08-06 18:27:14 +00:00
|
|
|
inline expr mk_forall(expr const & A, expr const & P) { return mk_app(mk_forall_fn(), A, P); }
|
|
|
|
inline expr Forall(expr const & A, expr const & P) { return mk_forall(A, P); }
|
2013-08-06 03:06:07 +00:00
|
|
|
|
2013-08-06 18:27:14 +00:00
|
|
|
expr mk_exists_fn();
|
2013-11-29 19:35:58 +00:00
|
|
|
bool is_exists_fn(expr const & e);
|
|
|
|
inline bool is_exists(expr const & e) { return is_app(e) && is_exists_fn(arg(e, 0)); }
|
2013-08-06 18:27:14 +00:00
|
|
|
inline expr mk_exists(expr const & A, expr const & P) { return mk_app(mk_exists_fn(), A, P); }
|
|
|
|
inline expr Exists(expr const & A, expr const & P) { return mk_exists(A, P); }
|
2013-08-06 03:06:07 +00:00
|
|
|
|
2013-08-30 21:26:12 +00:00
|
|
|
expr mk_homo_eq_fn();
|
2013-11-29 19:35:58 +00:00
|
|
|
bool is_homo_eq_fn(expr const & e);
|
|
|
|
inline bool is_homo_eq(expr const & e) { return is_app(e) && is_homo_eq_fn(arg(e, 0)); }
|
2013-08-30 21:26:12 +00:00
|
|
|
inline expr mk_homo_eq(expr const & A, expr const & l, expr const & r) { return mk_app(mk_homo_eq_fn(), A, l, r); }
|
|
|
|
inline expr hEq(expr const & A, expr const & l, expr const & r) { return mk_homo_eq(A, l, r); }
|
|
|
|
|
2013-08-07 03:21:43 +00:00
|
|
|
expr mk_mp_fn();
|
|
|
|
inline expr MP(expr const & a, expr const & b, expr const & H1, expr const & H2) { return mk_app(mk_mp_fn(), a, b, H1, H2); }
|
|
|
|
|
|
|
|
expr mk_discharge_fn();
|
|
|
|
inline expr Discharge(expr const & a, expr const & b, expr const & H) { return mk_app(mk_discharge_fn(), a, b, H); }
|
2013-08-06 18:27:14 +00:00
|
|
|
|
2013-08-07 08:16:37 +00:00
|
|
|
expr mk_case_fn();
|
|
|
|
inline expr Case(expr const & P, expr const & H1, expr const & H2, expr const & a) { return mk_app(mk_case_fn(), P, H1, H2, a); }
|
|
|
|
|
2013-10-30 00:07:30 +00:00
|
|
|
expr mk_refl_fn();
|
|
|
|
inline expr Refl(expr const & A, expr const & a) { return mk_app(mk_refl_fn(), A, a); }
|
|
|
|
|
2013-08-06 18:27:14 +00:00
|
|
|
expr mk_subst_fn();
|
2013-08-08 04:47:58 +00:00
|
|
|
inline expr Subst(expr const & A, expr const & a, expr const & b, expr const & P, expr const & H1, expr const & H2) { return mk_app({mk_subst_fn(), A, a, b, P, H1, H2}); }
|
2013-08-06 21:37:30 +00:00
|
|
|
|
2013-08-06 21:47:13 +00:00
|
|
|
expr mk_eta_fn();
|
|
|
|
inline expr Eta(expr const & A, expr const & B, expr const & f) { return mk_app(mk_eta_fn(), A, B, f); }
|
|
|
|
|
2013-08-07 15:29:20 +00:00
|
|
|
expr mk_imp_antisym_fn();
|
|
|
|
inline expr ImpAntisym(expr const & a, expr const & b, expr const & H1, expr const & H2) { return mk_app(mk_imp_antisym_fn(), a, b, H1, H2); }
|
|
|
|
|
2013-12-01 21:56:38 +00:00
|
|
|
expr mk_abst_fn();
|
|
|
|
inline expr Abst(expr const & A, expr const & B, expr const & f, expr const & g, expr const & H) { return mk_app({mk_abst_fn(), A, B, f, g, H}); }
|
|
|
|
|
2013-12-22 02:23:37 +00:00
|
|
|
expr mk_hsymm_fn();
|
2013-12-30 19:46:03 +00:00
|
|
|
inline expr HSymm(expr const & A, expr const & B, expr const & a, expr const & b, expr const & H1) { return mk_app({mk_hsymm_fn(), A, B, a, b, H1}); }
|
2013-12-22 02:23:37 +00:00
|
|
|
|
|
|
|
expr mk_htrans_fn();
|
|
|
|
inline expr HTrans(expr const & A, expr const & B, expr const & C, expr const & a, expr const & b, expr const & c, expr const & H1, expr const & H2) {
|
|
|
|
return mk_app({mk_htrans_fn(), A, B, C, a, b, c, H1, H2});
|
|
|
|
}
|
|
|
|
|
2013-12-30 19:46:03 +00:00
|
|
|
expr mk_trivial();
|
|
|
|
#define Trivial mk_trivial()
|
|
|
|
|
|
|
|
expr mk_true_ne_false();
|
|
|
|
#define TrueNeFalse mk_true_ne_false();
|
|
|
|
|
|
|
|
expr mk_em_fn();
|
|
|
|
inline expr EM(expr const & a) { return mk_app(mk_em_fn(), a); }
|
|
|
|
|
|
|
|
expr mk_false_elim_fn();
|
|
|
|
inline expr FalseElim(expr const & a, expr const & H) { return mk_app(mk_false_elim_fn(), a, H); }
|
|
|
|
|
|
|
|
expr mk_absurd_fn();
|
|
|
|
inline expr Absurd(expr const & a, expr const & H1, expr const & H2) { return mk_app(mk_absurd_fn(), a, H1, H2); }
|
|
|
|
|
|
|
|
expr mk_double_neg_fn();
|
|
|
|
inline expr DoubleNeg(expr const & a) { return mk_app(mk_double_neg_fn(), a); }
|
|
|
|
|
|
|
|
expr mk_double_neg_elim_fn();
|
|
|
|
inline expr DoubleNegElim(expr const & P, expr const & H) { return mk_app(mk_double_neg_elim_fn(), P, H); }
|
|
|
|
|
|
|
|
expr mk_mt_fn();
|
|
|
|
inline expr MT(expr const & a, expr const & b, expr const & H1, expr const & H2) { return mk_app(mk_mt_fn(), a, b, H1, H2); }
|
|
|
|
|
|
|
|
expr mk_contrapos_fn();
|
|
|
|
inline expr Contrapos(expr const & a, expr const & b, expr const & H) { return mk_app(mk_contrapos_fn(), a, b, H); }
|
|
|
|
|
|
|
|
expr mk_false_imp_any_fn();
|
|
|
|
inline expr FalseImpAny(expr const & a) { return mk_app(mk_false_imp_any_fn(), a); }
|
|
|
|
|
|
|
|
expr mk_absurd_elim_fn();
|
|
|
|
inline expr AbsurdElim(expr const & a, expr const & c, expr const & H1, expr const & H2) {
|
|
|
|
return mk_app(mk_absurd_elim_fn(), a, c, H1, H2);
|
|
|
|
}
|
|
|
|
|
|
|
|
expr mk_eq_mp_fn();
|
|
|
|
inline expr EqMP(expr const & a, expr const & b, expr const & H1, expr const & H2) { return mk_app(mk_eq_mp_fn(), a, b, H1, H2); }
|
|
|
|
|
|
|
|
expr mk_not_imp1_fn();
|
|
|
|
inline expr NotImp1(expr const & a, expr const & b, expr const & H) { return mk_app(mk_not_imp1_fn(), a, b, H); }
|
|
|
|
|
|
|
|
expr mk_not_imp2_fn();
|
|
|
|
inline expr NotImp2(expr const & a, expr const & b, expr const & H) { return mk_app(mk_not_imp2_fn(), a, b, H); }
|
|
|
|
|
|
|
|
expr mk_conj_fn();
|
|
|
|
inline expr Conj(expr const & a, expr const & b, expr const & H1, expr const & H2) { return mk_app(mk_conj_fn(), a, b, H1, H2); }
|
|
|
|
|
|
|
|
expr mk_conjunct1_fn();
|
|
|
|
inline expr Conjunct1(expr const & a, expr const & b, expr const & H) { return mk_app(mk_conjunct1_fn(), a, b, H); }
|
|
|
|
|
|
|
|
expr mk_conjunct2_fn();
|
|
|
|
inline expr Conjunct2(expr const & a, expr const & b, expr const & H) { return mk_app(mk_conjunct2_fn(), a, b, H); }
|
|
|
|
|
|
|
|
expr mk_disj1_fn();
|
|
|
|
inline expr Disj1(expr const & a, expr const & H, expr const & b) { return mk_app(mk_disj1_fn(), a, H, b); }
|
|
|
|
|
|
|
|
expr mk_disj2_fn();
|
|
|
|
inline expr Disj2(expr const & b, expr const & a, expr const & H) { return mk_app(mk_disj2_fn(), b, a, H); }
|
|
|
|
|
|
|
|
expr mk_disj_cases_fn();
|
|
|
|
inline expr DisjCases(expr const & a, expr const & b, expr const & c, expr const & H1, expr const & H2, expr const & H3) { return mk_app({mk_disj_cases_fn(), a, b, c, H1, H2, H3}); }
|
|
|
|
|
|
|
|
expr mk_refute_fn();
|
|
|
|
inline expr Refute(expr const & a, expr const & H) { return mk_app({mk_refute_fn(), a, H}); }
|
|
|
|
|
|
|
|
expr mk_symm_fn();
|
|
|
|
inline expr Symm(expr const & A, expr const & a, expr const & b, expr const & H) { return mk_app(mk_symm_fn(), A, a, b, H); }
|
|
|
|
|
|
|
|
expr mk_trans_fn();
|
|
|
|
inline expr Trans(expr const & A, expr const & a, expr const & b, expr const & c, expr const & H1, expr const & H2) { return mk_app({mk_trans_fn(), A, a, b, c, H1, H2}); }
|
|
|
|
|
|
|
|
expr mk_eqt_elim_fn();
|
|
|
|
inline expr EqTElim(expr const & a, expr const & H) { return mk_app(mk_eqt_elim_fn(), a, H); }
|
|
|
|
|
|
|
|
expr mk_eqt_intro_fn();
|
|
|
|
inline expr EqTIntro(expr const & a, expr const & H) { return mk_app(mk_eqt_intro_fn(), a, H); }
|
|
|
|
|
|
|
|
expr mk_congr1_fn();
|
|
|
|
inline expr Congr1(expr const & A, expr const & B, expr const & f, expr const & g, expr const & a, expr const & H) { return mk_app({mk_congr1_fn(), A, B, f, g, a, H}); }
|
|
|
|
|
|
|
|
expr mk_congr2_fn();
|
|
|
|
inline expr Congr2(expr const & A, expr const & B, expr const & a, expr const & b, expr const & f, expr const & H) { return mk_app({mk_congr2_fn(), A, B, a, b, f, H}); }
|
|
|
|
|
|
|
|
expr mk_congr_fn();
|
|
|
|
inline expr Congr(expr const & A, expr const & B, expr const & f, expr const & g, expr const & a, expr const & b, expr const & H1, expr const & H2) { return mk_app({mk_congr_fn(), A, B, f, g, a, b, H1, H2}); }
|
|
|
|
|
|
|
|
expr mk_forall_elim_fn();
|
|
|
|
inline expr ForallElim(expr const & A, expr const & P, expr const & H, expr const & a) { return mk_app(mk_forall_elim_fn(), A, P, H, a); }
|
|
|
|
|
|
|
|
expr mk_forall_intro_fn();
|
|
|
|
inline expr ForallIntro(expr const & A, expr const & P, expr const & H) { return mk_app(mk_forall_intro_fn(), A, P, H); }
|
|
|
|
|
|
|
|
expr mk_exists_elim_fn();
|
|
|
|
inline expr ExistsElim(expr const & A, expr const & P, expr const & B, expr const & H1, expr const & H2) { return mk_app({mk_exists_elim_fn(), A, P, B, H1, H2}); }
|
|
|
|
|
|
|
|
expr mk_exists_intro_fn();
|
|
|
|
inline expr ExistsIntro(expr const & A, expr const & P, expr const & a, expr const & H) { return mk_app(mk_exists_intro_fn(), A, P, a, H); }
|
2014-01-02 21:03:25 +00:00
|
|
|
class io_state;
|
|
|
|
void import_kernel(environment const & env, io_state const & ios);
|
2013-08-04 16:37:52 +00:00
|
|
|
}
|