Assumption.java
Go to the documentation of this file.
00001 /*
00002  * (c) copyright 2008, Technische Universitaet Graz and Technische Universitaet Wien
00003  *
00004  * This file is part of jdiagengine.
00005  *
00006  * jdiagengine is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation, either version 3 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * jdiagengine is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * You should have received a copy of the GNU General Public License
00016  * along with jdiagengine. If not, see <http://www.gnu.org/licenses/>.
00017  *
00018  * Authors: Joerg Weber, Franz Wotawa
00019  * Contact: jweber@ist.tugraz.at (preferred), or fwotawa@ist.tugraz.at
00020  *
00021  */
00022 
00023 
00036 package theoremprover;
00037 
00038 import java.lang.*;    // Java language classes 
00039 import java.util.*;    // Java util..
00040 
00041 import theoremprover.*;
00042 
00043 public class Assumption extends Object 
00044 {
00045 
00046   // Instance variables ...
00047 
00048   public Object identifier;
00049   public boolean label;
00050   public ArrayList antecedence;
00051 
00052     // tags; can be used for any purpose
00053     public Object objTag;
00054     public int intTag;
00055 
00056   // Instance creation and initialization
00057 
00058   Assumption ()
00059   {
00060     super();
00061     identifier = null;
00062     antecedence = new ArrayList();
00063     label = false;
00064   }
00065 
00066 
00067     public int getIntTag() {
00068         return intTag;
00069     }
00070 
00071     public void setIntTag(int tag) {
00072         intTag = tag;
00073     }
00074 
00075     /*
00076     public int compareTo(Object o) {
00077         Assumption other = (Assumption)o;
00078         if (intTag < other.intTag) return -1;
00079         else if (intTag > other.intTag) return 1;
00080         else return 0;
00081         }*/
00082 
00083 
00084   public Object getIdentifier ()
00085   {
00086     return identifier;
00087   }
00088 
00089   public ArrayList getAntecedence ()
00090   {
00091     return antecedence;
00092   }
00093 
00094   public boolean getLabel()
00095   {
00096     return label;
00097   }
00098 
00099   public String toString()
00100   {
00101     if (identifier == null) {
00102       return new String("");
00103     } else {
00104       return identifier.toString();
00105     }
00106   }
00107 
00108   // Accessing and maintaining structure
00109 
00110   public void addAntecedence (PropositionalRule r)
00111   {
00112     antecedence.add(r);
00113   }
00114 
00115   public void setLabel(boolean l)
00116   {
00117     label = l;
00118   }
00119 
00120     public void setIdentifier(Object id)
00121     {
00122         identifier = id;
00123     }
00124 
00125     // Testing...
00126 
00127     public boolean isAssumption ()
00128     {
00129       return true;
00130     }
00131 
00132     // Theorem proving...
00133 
00134     public void propagateTrue()
00135     {
00136         Iterator e = antecedence.iterator();
00137         while (e.hasNext()) {
00138             PropositionalRule r = (PropositionalRule)e.next();
00139             r.counter(r.counter()-1);
00140             if (r.counter() == 0) {
00141                 PropositionInterface s = (PropositionInterface)r.succedence();
00142                 s.addSupport(r);
00143                 if (s.getLabel() != true) {
00144                     s.setLabel(true);
00145                     s.activeRule(r);
00146                     s.propagateTrue();
00147                 }
00148             }
00149         }
00150     }
00151 
00152     public void propagateFalse() {
00153         ArrayList v = new ArrayList();
00154         v = propagateFalse(v);
00155         Iterator ve = v.iterator();
00156         while (ve.hasNext()) {
00157             PropositionInterface p = (PropositionInterface)ve.next();
00158             p.correctLabels();
00159         }
00160     }
00161 
00162 
00163     public ArrayList propagateFalse(ArrayList v)
00164     {
00165         if (label == true) {
00166             label = false;
00167             Iterator e = antecedence.iterator();
00168             while (e.hasNext()) {
00169                 PropositionalRule r = (PropositionalRule)e.next();
00170                 r.counter(r.counter()+1);
00171                 PropositionInterface p = (PropositionInterface)r.succedence();
00172                 p.removeSupport(r);
00173                 if (p.activeRule() == r) {
00174                     v = p.propagateFalse(v);
00175                 }
00176             }
00177         }
00178         return v;
00179     }
00180 
00181     public void correctLabels()
00182     {
00183     }
00184 
00185     // Return the set of assumptions causing self to be true.
00186     public ArrayList collectAssumptions() {
00187         ArrayList result = new ArrayList();
00188         return collectAssumptions(result);
00189     }
00190 
00191     public ArrayList collectAssumptions(ArrayList assumptions) {
00192         if (! assumptions.contains(this)) {
00193             assumptions.add(this);
00194         }
00195         return assumptions;
00196     }
00197 
00198     public TreeSet collectAllAssumptions() {
00199         TreeSet result = new TreeSet();
00200         return collectAllAssumptions(result);
00201     }
00202 
00203     public TreeSet collectAllAssumptions(TreeSet assumptions) {
00204         if (! assumptions.contains(this)) {
00205             assumptions.add(this);
00206         }
00207         return assumptions;
00208     }
00209 
00210 }


tug_ist_diagnosis_engine
Author(s): Safdar Zaman, Gerald Steinbauer
autogenerated on Mon Jan 6 2014 11:51:16