~ubuntu-branches/ubuntu/wily/clasp/wily

« back to all changes in this revision

Viewing changes to libclasp/src/asp_preprocessor.cpp

  • Committer: Package Import Robot
  • Author(s): Thomas Krennwallner
  • Date: 2015-05-12 07:18:25 UTC
  • mfrom: (20.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20150512071825-vlgtxbw5245d6wni
Tags: 3.1.2-1
* Imported Upstream version 3.1.2
* Fix dep5-copyright-license-name-not-unique and
  missing-license-paragraph-in-dep5-copyright lintian warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
189
189
                prg_->setConflict();
190
190
                return body;
191
191
        }
192
 
        if ((!body->hasHeads() && body->value() != value_false) || !body->relevant()) {
 
192
        if (superfluous(body)) {
193
193
                body->markRemoved();
194
194
                return body;
195
195
        }
208
208
                                Var dualAtom = getRootAtom(body->literal());
209
209
                                aEq = dualAtom != varMax ? prg_->getAtom(dualAtom) : 0;
210
210
                        }
211
 
                        if (aEq && aEq->supps_begin()->isBody()) {
 
211
                        if (aEq && aEq->supports() && aEq->supps_begin()->isBody()) {
212
212
                                rId = aEq->supps_begin()->node();
213
213
                                r   = prg_->getBody(rId);       
214
214
                                if (r && r->var() == aEq->var()) {
381
381
                && getRootAtom(body->literal()) == varMax
382
382
                && getRootAtom(~body->literal())== varMax;
383
383
}
 
384
// Pre: body is simplified!
 
385
bool Preprocessor::superfluous(PrgBody* body) const {
 
386
        if (!body->relevant()) { return true; }
 
387
        if (!body->hasHeads()) {
 
388
                if (body->value() == value_free) { return true; }
 
389
                if (body->bound() <= 0)          { return true; }
 
390
                if (body->size() == 1)           { 
 
391
                        // unit constraint
 
392
                        ValueRep exp = body->value() ^ (int)body->goal(0).sign();
 
393
                        ValueRep got = prg_->getAtom(body->goal(0).var())->value();
 
394
                        assert(got != value_free || !prg_->options().backprop);
 
395
                        return got != value_free && (got&value_true) == (exp&value_true);
 
396
                }
 
397
        }
 
398
        return false;
 
399
}
384
400
 
385
401
// Simplify the classified body with the given id.
386
402
// Return:
407
423
                                b->clearLiteral(true);
408
424
                        }
409
425
                }
410
 
                else if (!b->hasHeads() && b->value() != value_false && b->var() != 0) {
 
426
                else if (b->var() != 0 && superfluous(b)) {
411
427
                        // Body is no longer needed. All heads are either superfluous or equivalent
412
428
                        // to other atoms. 
413
429
                        // Reclassify only if var is not used