void forward_branch_extension::index_expr(expr const & e) {
    // TODO(dhs): index the target when it gets updated

    if (auto head_idx = to_head_index(e)) {
        m_index.insert(head_index(e), e);
    }
    switch (e.kind()) {
    case expr_kind::Var:
        lean_unreachable();  // LCOV_EXCL_LINE
    case expr_kind::Local:
    case expr_kind::Meta:
    case expr_kind::Sort:
    case expr_kind::Constant:
    case expr_kind::Macro: // TODO(dhs): do I unfold macros?
        break;
    case expr_kind::Lambda:
    case expr_kind::Pi:
        // TODO(dhs): confirm that I only index quantified-free hypotheses
        break;
    case expr_kind::Let:
        // Let-expressions must be unfolded before invoking this method
        lean_unreachable();
    case expr_kind::App:
        index_expr(app_fn(e));
        index_expr(app_arg(e));
        break;
    }
}
示例#2
0
optional<head_index> get_head_index(unsigned num, transition const * ts, expr const & a) {
    if (is_simple(num, ts)) {
        expr n = expand_pp_pattern(num, ts, a);
        if (!is_var(n))
            return some(head_index(n));
    }
    return optional<head_index>();
}
static optional<head_index> to_head_index(expr type) {
    // TODO(dhs): we will want to filter this set,
    // because some constants are treated specially by this module
    // (e.g. [eq] and [not])
    expr const & f = get_app_fn(type);
    if (is_constant(f) || is_local(f))
        return optional<head_index>(head_index(f));
    else
        return optional<head_index>();
}
action_result grinder_intro_action() {
    grinder_branch_extension & ext = get_ext();
    state & s                      = curr_state();
    expr const & target            = s.get_target();
    expr const & f                 = get_app_fn(target);
    if (!is_constant(f))
        return action_result::failed();
    list<gexpr> const * lemmas = ext.m_intro_lemmas.find(head_index(f));
    if (!lemmas)
        return action_result::failed();
    return backward_cut_action(*lemmas);
}
示例#5
0
void SnakeObject::draw(const DrawContext& gc) {
    _program_p->begin();
    _program_p->arg("snakeSkin",_tex_p->index());
    _tex_p->activate();
	glBegin(GL_QUADS);
	auto index = tail_index();
	int previous_point = index;
	--index;
	for (; index != head_index(); --index) {
		const auto &p = points()[previous_point];
		const auto &q = points()[index];
		const auto &t0 = p.bottomLeft().c_elems();
		const auto &t1 = p.topMiddle().c_elems();
		const auto &t2 = p.bottomRight().c_elems();
		const auto &u0 = q.bottomLeft().c_elems();
		const auto &u1 = q.topMiddle().c_elems();
		const auto &u2 = q.bottomRight().c_elems();

		// quad on side 0
		glTexCoord2d(previous_point,0);
		glVertex3fv(t0);
		glTexCoord2d(index,0);
		glVertex3fv(u0);
		glTexCoord2d(index,0.5);
		glVertex3fv(u1);
		glTexCoord2d(previous_point,0.5);
		glVertex3fv(t1);

		// quad on other side
		glTexCoord2d(previous_point,1.0);
		glVertex3fv(t2);
		glTexCoord2d(previous_point,0.5);
		glVertex3fv(t1);
		glTexCoord2d(index,0.5);
		glVertex3fv(u1);
		glTexCoord2d(index,1.0);
		glVertex3fv(u2);

		previous_point = index;
	}
	glEnd();

	_program_p->end();

}