Exemplo n.º 1
0
 bool equalTo( const Formula & f) const
 {
   return f->getType() == this->getType() &&
     _op1->equalTo(((BinaryConjective *)f.get())->getOperand1())
     &&
     _op2->equalTo(((BinaryConjective *)f.get())->getOperand2());
 }
Exemplo n.º 2
0
  bool equalTo(const Formula & f) const
  {
    if(f->getType() != T_ATOM)
      return false;

    if(_p != ((Atom *) f.get())->getSymbol())
      return false;

    const vector<Term> & f_ops = ((Atom *) f.get())->getOperands();

    if(_ops.size() != f_ops.size())
      return false;

    for(unsigned i = 0; i < _ops.size(); i++)
      if(!_ops[i]->equalTo(f_ops[i]))
        return false;

      return true;
  }
Exemplo n.º 3
0
/*
* Special Copy Constructor
* Only pointers to free vars are retained
* Used for copying gamma formulas
*/
Formula::Formula(Formula &f)
{
	this->type = f.getType();
	this->cntv = f.getCntv();
	if (f.isAtomic()) {		
		TermList *list = new TermList();
		this->copy(f.getPredicate()->getTermList(), list);
		this->predicate = new Predicate(f.getPredicate()->getName(), list);
	}
	else if (f.isNegated()) {		
		this->nextFormula = new Formula(*f.getNext());
	}
	else if (f.isQuantified()) {
		this->qVar = new Term(*f.getQVar());		
		this->nextFormula = new Formula(*f.getNext());
	}
	else if (f.isCompound()) {
		this->formula1 = new Formula(*f.getLeft());
		this->formula2 = new Formula(*f.getRight());
	}
}
Exemplo n.º 4
0
 bool equalTo(const Formula & f) const
 {
   return f->getType() == getType() &&
     ((Quantifier *) f.get())->getVariable() == _v &&
     ((Quantifier *) f.get())->getOperand()->equalTo(_op);
 }
Exemplo n.º 5
0
 bool equalTo(const Formula & f) const
 {
   return f->getType() == this->getType() &&
     _op->equalTo(((UnaryConjective *)f.get())->getOperand());
 }
Exemplo n.º 6
0
 bool equalTo( const Formula & f) const
 {
   return f->getType() == this->getType();
 }
Exemplo n.º 7
0
void MainWindow::orEClicked()
{

    QList<QGraphicsItem *> selected_list = scene->selectedItems();
    Node* selected = (Node*)(selected_list.at(0));
    selected->setRule("orE");
    selected->update();
    int rect_x;
    int rect_y;

    bool ok;
    while(1){
             QString tekst = QInputDialog::getText(this, tr("QInputDialog::getText()"),
                                             tr("Unesite formulu:"), QLineEdit::Normal,
                                             QDir::home().dirName(), &ok);
             if (ok && !tekst.isEmpty()){
                qDebug() << "radi";
             }


            std::string formula = tekst.toUtf8().constData();
            formula += " ;";
            std::ostringstream stream;
            qDebug() << QString::fromStdString(formula);
            YY_BUFFER_STATE buffer = yy_scan_string(formula.c_str());

            if(yyparse() == 1){
                qDebug() << "Pa to ti ne radi";
             }

            if(parsed_formula->getType() == BaseFormula::T_OR){
                break;
            }
    }

    std::ostringstream stream;
    parsed_formula->printFormula(stream);
    qreal rect_width =  stream.str().length()*PARAMETER;
    qreal rect_height = 20;

    rect_x = selected->getx() - 20 - depth/2;
    rect_y = selected->gety() - 20 - depth/2;

    QVector<Formula> assumptions = selected->getAssumptions();
    assumptions.push_back(parsed_formula);

    Node* item3 = new Node( parsed_formula, rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item3);

    Formula op1 = ((Or*)parsed_formula.get())->getOperand1();
    Formula op2 = ((Or*)parsed_formula.get())->getOperand2();

    rect_x = selected->getx() + 25 + depth/2;
    rect_y = selected->gety() - 20 - depth/2;


    assumptions.push_back(op1);
    assumptions.push_back(op2);
    op1->printFormula(stream);
    rect_width = stream.str().length()*PARAMETER;
    Node* item1 = new Node( selected->getFormula(), rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item1);

    rect_x = selected->getx() + 50 + depth/2;
    rect_y = selected->gety() - 20 - depth/2;

    op2->printFormula(stream);
    rect_width = stream.str().length()*PARAMETER;
    Node* item2 = new Node(selected->getFormula(), rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item2);



}