Package org.mizartools.dli

Examples of org.mizartools.dli.Formula


    VariableId vid2 = new VariableId();
    vid2.setId(vid.getId());
    for (org.mizartools.system.xml.PartialDef partialDef : defMeaning.getPartialDefList()){
      partList.add(getPart(abstractSignature, partialDef, vid2));
    }
    Formula formula = getFormula(abstractSignature, defMeaning.getFormula(), vid2);
    Term term = getTerm(abstractSignature, defMeaning.getTerm(), vid2);
    ProperDefiniens properDefiniens = new ProperDefiniens(partList , formula, term);
    return properDefiniens;
  }
View Full Code Here


  static Formula getFormula(AbstractSignature abstractSignature,
      org.mizartools.system.xml.Formula formula,
      VariableId vid) throws DliException {
    if (formula == null) return null;
    Formula formulaDli = null;
    if (formula instanceof org.mizartools.system.xml.For){
      Integer vid1 = ((org.mizartools.system.xml.For) formula).getVid();
      if (vid1 == null) {
        vid.increment();
        vid1 = vid.getId();
      }
      Variable variable = new Variable(vid1);
      Type type = getType(abstractSignature, ((org.mizartools.system.xml.For) formula).getTyp());
      VariableId vid2 = new VariableId();
      vid2.setId(vid.getId());
      Formula formula1 = getFormula(abstractSignature, ((org.mizartools.system.xml.For) formula).getFormula(), vid2);
      formulaDli = new For(variable, type, formula1);
    } else if (formula instanceof org.mizartools.system.xml.And){
        LinkedList<Formula> formulaList = new LinkedList<Formula>();
      for (org.mizartools.system.xml.Formula formula1 : ((org.mizartools.system.xml.And) formula).getFormulaList()) {
        VariableId vid2 = new VariableId();
View Full Code Here

    return compress(formula, new Changed());
  }

  private static Formula compress(Formula formula, Changed changed) throws DliException{
    Changed changed1 = new Changed();
    Formula formula1 = formula;
    formula1 = insertEx(formula1, changed1);
    formula1 = insertOr(formula1, changed1);
    formula1 = insertImplies(formula1, changed1);
    formula1 = insertIff(formula1, changed1);
    formula1 = deleteNotNot(formula1, changed1);
    if (formula instanceof And) {
      And and = (And)formula;
      Changed changed2 = new Changed();
      boolean compress = false;
      LinkedList<Formula> formulaList = new LinkedList<Formula>();
      for (Formula formula2 : and.getFormulaList()){
        formulaList.add(compress(formula2, changed2));
        if (changed2.isChanged) compress = true;
      }
      if (compress) {
        formula1 = new And(formulaList);
        changed1.isChanged = true
      }
    } else if (formula instanceof Or) {
      Or or = (Or)formula;
      Changed changed2 = new Changed();
      boolean compress = false;
      LinkedList<Formula> formulaList = new LinkedList<Formula>();
      for (Formula formula2 : or.getFormulaList()){
        formulaList.add(compress(formula2, changed2));
        if (changed2.isChanged) compress = true;
      }
      if (compress) {
        formula1 = new Or(formulaList);
        changed1.isChanged = true
      }
    } else if (formula instanceof For){
      For for1 = (For)formula;
      Changed changed2 = new Changed();
      Formula formula2 = compress(for1.getFormula(), changed2);
      if (changed2.isChanged) {
        formula1 = new For(for1.getVariable(), for1.getType(), formula2);
        changed1.isChanged = true
      }
    } else if (formula instanceof Ex){
      Ex ex = (Ex)formula;
      Changed changed2 = new Changed();
      Formula formula2 = compress(ex.getFormula(), changed2);
      if (changed2.isChanged){
        formula1 = new Ex(ex.getVariable(), ex.getType(), formula2);
        changed1.isChanged = true
      }
    }
View Full Code Here

  private static Formula insertImplies(Formula formula, Changed changed) throws DliException {
    // $or($not($formula1),$formula2) -> $implies($formula1,$formula2)
    if (formula instanceof Or) {
        Or or = (Or)formula;
        if (or.getFormulaList().size() == 2){
          Formula formula1 = or.getFormulaList().getFirst();
          Formula formula2 = or.getFormulaList().getLast();
          Formula hypothesis = null;
          Formula conclusion = null;
          if (formula1 instanceof Not && !(formula2 instanceof Not)){
            hypothesis = ((Not)formula1).getFormula();
            conclusion = formula2;
          }
          if (!(formula1 instanceof Not) && formula2 instanceof Not){
            hypothesis = ((Not)formula2).getFormula();
            conclusion = formula1;
          }
          if (hypothesis != null && conclusion != null){
            changed.isChanged = true;
            return new Implies(hypothesis, conclusion);
          }
        }
    }
    // $not($and($formula1,...,$not($formula_n)) -> $implies($and($formula1,...),$formula_n)
    if (formula instanceof Not) {
        Not not = (Not)formula;
        Formula formula1 = not.getFormula();
      if (formula1 instanceof And) {
        And and = (And)formula1;
        Formula formula2 = and.getFormulaList().getLast();
        if (formula2 instanceof Not) {
          LinkedList<Formula> formulaList = new LinkedList<Formula>();
          for (Formula formula3 : and.getFormulaList()){
            formulaList.add(formula3);
          }
          formulaList.pollLast();
          Formula hypothesis = null;
          if (formulaList.size() == 1){
            hypothesis = formulaList.getFirst();
          } else {
            hypothesis = new And(formulaList);
          }
          Formula conclusion = ((Not)formula2).getFormula();
            changed.isChanged = true;
            return new Implies(hypothesis, conclusion);
        }
      }       
    }
View Full Code Here

  private static Formula insertIff(Formula formula, Changed changed) throws DliException {
    // $and($implies($formula1,$formula2),$implies($formula2,$formula1)) -> $iff($formula1,$formula2)
    if (formula instanceof And) {
        And and = (And)formula;
        if (and.getFormulaList().size() == 2){
          Formula formula1 = and.getFormulaList().getFirst();
          Formula formula2 = and.getFormulaList().getLast();
          if (formula1 instanceof Implies && formula2 instanceof Implies){
            Implies implies1 = (Implies)formula1;
            Implies implies2 = (Implies)formula2;
            if (implies1.getConclusion().toString().equals(implies2.getHypothesis().toString()) &&
              implies2.getConclusion().toString().equals(implies1.getHypothesis().toString())  ){
View Full Code Here

 
  private static Formula deleteNotNot(Formula formula, Changed changed) {
    // $not($not($formula)) -> $formula
    if (formula instanceof Not) {
        Not not1 = (Not)formula;
        Formula formula1 = not1.getFormula();
        if (formula1 instanceof Not) {
          Not not2 = (Not)formula1;
          changed.isChanged = true;
          return not2.getFormula();
        }
View Full Code Here

  private static Formula insertOr(Formula formula, Changed changed) throws DliException {
    // $not($and(list_formula)) -> $or(not(list_formula))
    if (formula instanceof Not) {
        Not not = (Not)formula;
        Formula formula1 = not.getFormula();
        if (formula1 instanceof And) {
          And and = (And)not.getFormula();
        LinkedList<Formula> formulaList = new LinkedList<Formula>();
        int nrNot = 0;
        for (Formula formula2 : and.getFormulaList()){
View Full Code Here

  private static Formula insertEx(Formula formula, Changed changed) throws DliException {
    // $not($for($variable,$type,$not($formula))) -> $ex($variable,$type,$formula)
    if (formula instanceof Not) {
        Not not = (Not)formula;
        Formula formula1 = not.getFormula();
        if (formula1 instanceof For) {
          For for1 = (For)formula1;
          Formula formula2 = for1.getFormula();
          if (formula2 instanceof Not) {
            Formula formula3 = ((Not)formula2).getFormula();
            Ex ex = new Ex(for1.getVariable(), for1.getType(),formula3);
            changed.isChanged = true;
          return ex;
          }
        }
View Full Code Here

    VariableId vid2 = new VariableId();
    vid2.setId(vid.getId());
    for (org.mizartools.system.xml.PartialDef partialDef : defMeaning.getPartialDefList()){
      partList.add(getPart(abstractSignature, partialDef, vid2));
    }
    Formula formula = getFormula(abstractSignature, defMeaning.getFormula(), vid2);
    Term term = getTerm(abstractSignature, defMeaning.getTerm(), vid2);
    ProperDefiniens properDefiniens = new ProperDefiniens(partList , formula, term);
    return properDefiniens;
  }
View Full Code Here

  static Formula getFormula(AbstractSignature abstractSignature,
      org.mizartools.system.xml.Formula formula,
      VariableId vid) throws DliException {
    if (formula == null) return null;
    Formula formulaDli = null;
    if (formula instanceof org.mizartools.system.xml.For){
      Integer vid1 = ((org.mizartools.system.xml.For) formula).getVid();
      if (vid1 == null) {
        vid.increment();
        vid1 = vid.getId();
      }
      Variable variable = new Variable(vid1);
      Type type = getType(abstractSignature, ((org.mizartools.system.xml.For) formula).getTyp());
      VariableId vid2 = new VariableId();
      vid2.setId(vid.getId());
      Formula formula1 = getFormula(abstractSignature, ((org.mizartools.system.xml.For) formula).getFormula(), vid2);
      formulaDli = new For(variable, type, formula1);
    } else if (formula instanceof org.mizartools.system.xml.And){
        LinkedList<Formula> formulaList = new LinkedList<Formula>();
      for (org.mizartools.system.xml.Formula formula1 : ((org.mizartools.system.xml.And) formula).getFormulaList()) {
        VariableId vid2 = new VariableId();
View Full Code Here

TOP

Related Classes of org.mizartools.dli.Formula

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.