lean2/src/library/choice_iterator.h

29 lines
988 B
C
Raw Normal View History

/*
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include "util/lazy_list.h"
#include "kernel/constraint.h"
namespace lean {
/** \brief Abstract (helper) class for creating lazy_list<constraints> */
class choice_iterator {
bool m_ignore_failure;
public:
choice_iterator(bool ignore_failure = false):m_ignore_failure(ignore_failure) {}
virtual ~choice_iterator() {}
virtual optional<constraints> next() = 0;
bool ignore_failure() const { return m_ignore_failure; }
};
/** \brief Convert a choice_iterator into a lazy_list<constraints>
The lazy list is generated by invoking the method \c choice_iterator::next.
If c->ignore_failure() is true AND \c c does not produce any result,
then the singleton lazy_list is produced with an empty set of constraints.
*/
lazy_list<constraints> choose(std::shared_ptr<choice_iterator> c);
}