コード例 #1
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
Clause* Master::select0()
{
    CALL("select0()");
    Clause* selected;
try_next_passive:
    selected = _passive.Next();
    if (!selected)
    {   // _passive is empty, try _reservedPassive
        _parameters.lrs = 0;
        _parameters.maxWeight = VampireKernelConst::MaxClauseSize;
        _freshClause.SetMaxWeight(_parameters.maxWeight);
        if ((_parameters.showWeightChange)
                && (_freshClause.PreviousMaxWeight() != _freshClause.MaxWeight()))
            _parameters.showWeightChange(_freshClause.PreviousMaxWeight(),_freshClause.MaxWeight());
        loadReservedClauses();
        selected = _passive.Next();
        if (selected)
        {
            ASSERT(selected->mainSet() == Clause::MainSetPassive);
            selected->setMainSet(Clause::MainSetFree);
        };
        return selected;
    };
    if (selected->MinResWeight() > _parameters.maxWeight)
    {
        makeReserved(selected);
        goto try_next_passive;
    };
    if (selected)
    {
        ASSERT(selected->mainSet() == Clause::MainSetPassive);
        selected->setMainSet(Clause::MainSetFree);
    };
    return selected;
}; // Clause* Master::select0()
コード例 #2
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::disposeObsolete()
{
    CALL("disposeObsolete()");
    Clause* disposedClause;
    while (_queueForDisposal.dequeue(disposedClause))
    {
        ASSERT(disposedClause->mainSet() == Clause::MainSetTrash);
        disposedClause->setMainSet(Clause::MainSetFree);
        disposeClause(disposedClause);
    };
}; // void Master::disposeObsolete()
コード例 #3
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::loadReservedClauses()
{
    CALL("loadReservedClauses()");
    Clause* cl;
    _reservedPassive.ResetIterator();
    while (!_reservedPassive.Empty())
    {
        cl = _reservedPassive.Pop();
        ASSERT(cl->mainSet() == Clause::MainSetReservedPassive);
        cl->setMainSet(Clause::MainSetPassive);
        _passive.Insert(cl);
    };
}; // void Master::loadReservedClauses()
コード例 #4
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::integrateIntoBackDemIndexFromQueue()
{
    CALL("integrateIntoBackDemIndexFromQueue()");
    ASSERT(!_backwardDemodulationSemaphore);
    Clause* cl;
    while (_queueForIntegrationIntoBackwardDemodIndex.dequeue(cl))
    {
        ASSERT(cl->flag(Clause::FlagInQueueForIntegrationIntoBackwardDemodIndex));
        ASSERT(cl->mainSet() == Clause::MainSetPassive);
        cl->clearFlag(Clause::FlagInQueueForIntegrationIntoBackwardDemodIndex);
        integrateIntoBackDemodulationIndex(cl);
    };
}; // void Master::integrateIntoBackDemIndexFromQueue()
コード例 #5
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::processCollectedInputQuery0()
{
    CALL("processCollectedInputQuery0()");
    Clause* newClause;

    switch (_continuation)
    {
    case Continuation_Init:
        break;
    case Continuation_InputQueryClause0_ProcessCollectedInput:
    // same as below
    case Continuation_EliminateDefinitions_ProcessCollectedInput:
        goto process_next_retained_clause;
    default:
        ICP("ICP0");
        RuntimeError::report("Bad _continuation in VK::Master::processCollectedInputQuery0()");
    };


    if (_parameters.outputStreamForGenerated)
        _freshClause.output(*_parameters.outputStreamForGenerated << "% GEN "
                            << statNumOfGeneratedCl() << ' ') << '\n';
    _freshClause.ProcessCollected(_retainedNewClauses);

process_next_retained_clause:
    while (_retainedNewClauses.dequeue(newClause))
    {
        ASSERT(newClause->mainSet() == Clause::MainSetNew);

        if (newClause->isAnswer())
        {
            rememberAnswer0(newClause);
            _proof = newClause;
            return;
        };
        _continuation = Continuation_Init;

        makePassive0(newClause);
        if (_parameters.backward_subsumption) backSubsumeBy(newClause);
        if (_parameters.backward_demodulation > 0)
        {
            ASSERT(!newClause->flag(Clause::FlagInQueueForBackSimplification));
            _queueForBackSimplification.enqueue(newClause);
            newClause->setFlag(Clause::FlagInQueueForBackSimplification);
        };
        integratePassive(newClause);
    };
    ASSERT(_retainedNewClauses.empty());
}; // void Master::processCollectedInputQuery0()
コード例 #6
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::recycleUnreachablePassive0()
{
    CALL("recycleUnreachablePassive0()");
    Clause* cl;
recycle_next:
    if (_passive.UnreachableKept() <= (_passive.CurrentlyKept()/5))
        return; // nothing to recycle
    cl = _passive.TheMostUnreachableClause();
    if (!cl) return;
    ASSERT(cl->mainSet() == Clause::MainSetPassive);
    _passive.Cancel(cl);
    cl->setMainSet(Clause::MainSetFree);
    enqueueForDisposal(cl);
    _statRecycled++;
    goto recycle_next;
}; // void Master::recycleUnreachablePassive0()
コード例 #7
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::processCollectedInputSupport0()
{
    CALL("processCollectedInputSupport0()");
    Clause* newClause;

    switch (_continuation)
    {
    case Continuation_Init:
        break;
    case Continuation_InputSupportClause0_ProcessCollectedInput:
        goto process_next_retained_clause;
    default:
        ICP("ICP0");
        RuntimeError::report("Bad _continuation in VK::Master::processCollectedInputSupport0()");
    };


    if (_parameters.outputStreamForGenerated)
        _freshClause.output(*_parameters.outputStreamForGenerated << "% GEN "
                            << statNumOfGeneratedCl() << ' ') << '\n';

    _freshClause.ProcessCollectedSupport(_retainedNewClauses);

process_next_retained_clause:
    while (_retainedNewClauses.dequeue(newClause))
    {
        ASSERT(newClause->mainSet() == Clause::MainSetNew);

        if (newClause->isAnswer())
        {
            rememberAnswer0(newClause);
            _proof = newClause;
            return;
        };
        _continuation = Continuation_Init;

        newClause->SetNumber(_clauseNumberGenerator->generate());
        INTERCEPT_BACKWARD_SUBSUMPTION_INDEXING_INTRODUCE_CLAUSE_ID(newClause);
        if (_parameters.useClauseNumIndex) _clauseNumIndex.insert(newClause);
        if (_parameters.showPassive) _parameters.showPassive(newClause);
        integratePassive(newClause);
        makeActive0(newClause);
    };
    ASSERT(_retainedNewClauses.empty());
}; // void Master::processCollectedInputSupport0()
コード例 #8
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
bool Master::backSubsumeBy(Clause* cl)
{
    CALL("backSubsumeBy(Clause* cl)");
    _backwardSubsumptionSemaphore = true;
    Clause* subsumedClause;
    bool usedSubsumed = false;
    if (_backSubsumption.query(cl))
    {
        while (_backSubsumption.subsumeNext())
        {
            _statBackSubsumed++;
            cl->MakeVIP();
            subsumedClause = _backSubsumption.subsumed();
            ASSERT(subsumedClause != cl);
            ASSERT(subsumedClause->Active());
            usedSubsumed = (usedSubsumed
                            || (subsumedClause->mainSet() == Clause::MainSetActive)
                            || (subsumedClause->mainSet() == Clause::MainSetDefinitions));
            enqueueForDisposal(subsumedClause);
        };
    };
    _backwardSubsumptionSemaphore = false;
    return (bool)usedSubsumed;
}; // bool Master::backSubsumeBy(Clause* cl)
コード例 #9
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::processCollected0()
{
    CALL("processCollected0()");
    Clause* newClause;
    switch (_continuation)
    {
    case Continuation_Init:
        break;
    case Continuation_InputQueryClause0_BackSimplify:
    // same as below
    case Continuation_EliminateDefinitions_BackSimplify:
    // same as below
    case Continuation_MainLoop0_ProcessNewInference:
    // same as below
    case Continuation_MainLoop0_BackSimplify:
        goto process_retained;
    default:
        ICP("ICP0");
        RuntimeError::report("Bad _continuation in VK::Master::processCollected0()");
    };

    if (_parameters.outputStreamForGenerated) _freshClause.output(*_parameters.outputStreamForGenerated << "% GEN " << statNumOfGeneratedCl() << ' ') << '\n';
    _freshClause.ProcessCollected(_retainedNewClauses);


process_retained:
    while (_retainedNewClauses.dequeue(newClause))
    {

        ASSERT(newClause->mainSet() == Clause::MainSetNew);
        if (newClause->isAnswer())
        {
            rememberAnswer0(newClause);
            _proof = newClause;
            return;
        };

        _continuation = Continuation_Init;

        makePassive0(newClause);
        if (newClause->weight() > _parameters.maxWeight)
        {

            enqueueForDisposal(newClause);
            _statRecycled++;

        }
        else
        {
            if (_parameters.backward_subsumption)
                if (backSubsumeBy(newClause))
                    if (_parameters.orphan_murder)
                        killActiveOrphans0();

            if (_parameters.backward_demodulation > 0)
            {
                ASSERT(!newClause->flag(Clause::FlagInQueueForBackSimplification));

                _queueForBackSimplification.enqueue(newClause);

                newClause->setFlag(Clause::FlagInQueueForBackSimplification);
            };

            integratePassive(newClause);

            eliminateAllocationBufferDeficit0();
        };
    };
}; // void Master::processCollected0()
コード例 #10
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::backSimplify()
{
    CALL("backSimplify()");
    Clause* backSimplified;
    bool someActiveSimplified;
    switch (_continuation)
    {
    case Continuation_Init:
        break;
    case Continuation_InputQueryClause0_BackSimplify:
    // same as below
    case Continuation_EliminateDefinitions_BackSimplify:
    // same as below
    case Continuation_MainLoop0_BackSimplify:
        someActiveSimplified = true;
        goto process_new_inference;
    default:
        ICP("ICP0");
        RuntimeError::report("Bad _continuation in VK::Master::backSimplify()");
    };

    ASSERT((_parameters.backward_demodulation > 0) ||
           _queueForBackSimplification.empty());
    _backwardDemodulationSemaphore = true;
    someActiveSimplified = false;
    if (_parameters.backward_demodulation > 0)
    {
next_simplifier:
        if (_queueForBackSimplification.dequeue(_currentSimplifier))
        {
            ASSERT(_currentSimplifier->flag(Clause::FlagInQueueForBackSimplification));
            _currentSimplifier->clearFlag(Clause::FlagInQueueForBackSimplification);
            if (backDemodulationQuery(_currentSimplifier))
            {
next_back_demodulated:
                if (nextBackDemodulated())
                {
                    _statBackSimplified++;

                    if (collectBackSimplified())
                    {
                        _currentSimplifier->setFlag(Clause::FlagHasChildren);
                        backSimplified = _backDemodulation.simplified();

                        someActiveSimplified = someActiveSimplified
                                               || (backSimplified->mainSet() == Clause::MainSetActive)
                                               || (backSimplified->mainSet() == Clause::MainSetDefinitions);

                        backSimplified->setFlag(Clause::FlagHasChildren);

                        enqueueForDisposal(backSimplified);

process_new_inference:
                        processCollected0(); // not before enqueueForDisposal(backSimplified)!

                        if (_proof)
                        {
                            terminate(Proof);
                            return;
                        };

                        _continuation = Continuation_Init;

                        if (_passive.Total() >= _parameters.maxPassive)
                        {
                            terminate(MaxPassive);
                            _backwardDemodulationSemaphore = false;
                            return;
                        };
                    }
                    else
                    {
                        if (_freshClause.WasTautology())
                        {
                            backSimplified = _backDemodulation.simplified();

                            enqueueForDisposal(backSimplified);
                        };
                    };
                    internalTick0();
                    goto next_back_demodulated;
                }; // if (nextBackDemodulated())
            };

            goto next_simplifier;
        }; // if (_queueForBackSimplification.dequeue(_currentSimplifier))
        if (_parameters.orphan_murder && someActiveSimplified) killActiveOrphans0();
    };
    _backwardDemodulationSemaphore = false;
}; // void Master::backSimplify()
コード例 #11
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::reset()
{
    CALL("reset()");
    _unifier.reset();
    Unifier::setCurrent(&_unifier);

    // sets of persistent clauses
    switch (_parameters.main_alg)
    {
    case 0:
        destroyPassive0();
        break;
    case 3:
        destroyPassive3();
        break;
    default:
        ICP("ICP0");
        break;
    };

    Clause* cl;
    while (_reservedPassive.Nonempty())
    {
        cl = _reservedPassive.Top();
        enqueueForDisposal(cl);
    };
    _reservedPassive.Purge(); // to make it clean()

    while (_active.Nonempty())
    {
        cl = _active.Top();
        enqueueForDisposal(cl);
    };
    _active.Purge(); // to make it clean()


    while (_answers.Nonempty())
    {
        cl = _answers.Top();
        enqueueForDisposal(cl);
    };
    _answers.Purge(); // to make it clean()

    ASSERT(_answers.clean());

    if (_reanimatedClause)
    {
        ASSERT(_reanimatedClause->mainSet() == Clause::MainSetFree);
        enqueueForDisposal(_reanimatedClause);
    };

    // queues
    Clause* retainedNewClause;

    while (_retainedNewClauses.dequeue(retainedNewClause))
    {

        ASSERT(retainedNewClause->mainSet() == Clause::MainSetNew);
        retainedNewClause->setMainSet(Clause::MainSetFree);
        disposeClause(retainedNewClause);
    };

    // queue for disposal
    // not after _history.DestroyAllClauses()!
    disposeObsolete();
    _history.DestroyAllClauses();  // not before disposeObsolete()!

    _queueForBackSimplification.reset();
    _queueForIntegrationIntoBackwardDemodIndex.reset();

    // indices and inference engines


    _infDispatcher.reset();
    _forwardSubsumption.reset();
    _backSubsumption.reset();
    _forwardDemodulation.reset();
    _backDemodulation.reset();
    _sharingIndex.reset();
    _clauseAssembler.reset();
    _clauseNumIndex.reset();

    options.reset();
    resetStatistics();
    _reanimatedClause = 0;
    setStrategy();
}; //  void Master::reset()
コード例 #12
0
ファイル: Master.cpp プロジェクト: kdgerring/sigma
void Master::destroy()
{
    CALL("destroy()");
    if (DestructionMode::isThorough())
    {
        // sets of persistent clauses
        switch (_parameters.main_alg)
        {
        case 0:
            destroyPassive0();
            break;
        case 3:
            destroyPassive3();
            break;
        default:
            ICP("ICP0");
            break;
        };

        Clause* cl;
        while (_reservedPassive.Nonempty())
        {
            cl = _reservedPassive.Top();
            enqueueForDisposal(cl);
        };
        _reservedPassive.Purge();

        while (_active.Nonempty())
        {
            cl = _active.Top();
            enqueueForDisposal(cl);
        };
        _active.Purge();

        while (_answers.Nonempty())
        {
            cl = _answers.Top();
            enqueueForDisposal(cl);
        };
        _answers.Purge();

        ASSERT(_answers.clean());

        if (_reanimatedClause)
        {
            ASSERT(_reanimatedClause->mainSet() == Clause::MainSetFree);
            enqueueForDisposal(_reanimatedClause);
        };

        // queues
        Clause* retainedNewClause;

        while (_retainedNewClauses.dequeue(retainedNewClause))
        {

            ASSERT(retainedNewClause->mainSet() == Clause::MainSetNew);
            retainedNewClause->setMainSet(Clause::MainSetFree);
            disposeClause(retainedNewClause);
        };

        // queue for disposal
        // not after _history.DestroyAllClauses()!
        disposeObsolete();
        _history.DestroyAllClauses();  // not before disposeObsolete()!
    };

    _clauseNumIndex.destroy();
    _freshClause.destroy();
    _clauseAssembler.destroy();
    _litOrdering.destroy();
    _litSelection.destroy();
    _sharingIndex.destroy();
    _componentName.destroy();
    _backDemodulation.destroy();
    _forwardDemodulation.destroy();
    _backSubsumption.destroy();
    _forwardSubsumption.destroy();
    _infDispatcher.destroy();
    _queueForIntegrationIntoBackwardDemodIndex.destroy();
    _queueForBackSimplification.destroy();
    _queueForDisposal.destroy();
    _retainedNewClauses.destroy();
    _answers.destroy();
    _history.destroy();
    _active.destroy();
    _reservedPassive.destroy();
    _pagedPassive.destroy();
    _passive.destroy();
    _unifier.destroy();
    _parameters.destroy();
    _timer.destroy();
    options.destroy();
    BK_CORRUPT(*this);
}; // void Master::destroy()