LSentence.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 
00038 package theoremprover;
00039 
00040 import java.lang.*;    // Java language classes 
00041 import java.util.*;
00042 import theoremprover.*;
00043 
00044 
00045 public class LSentence extends LObject
00046 {
00047     // Instance variables
00048 
00049     public ArrayList rules;
00050 
00051     // Instance creation and initialization
00052 
00053     public LSentence()
00054     {
00055         rules = new ArrayList();
00056     }
00057 
00058     public LSentence(ArrayList v)
00059         {
00060         rules = v;
00061     }
00062 
00063     public void addRules(ArrayList newRules) {
00064         this.rules.addAll(newRules);
00065     }
00066 
00067     public void addRules(LSentence new_sentence) {
00068         this.rules.addAll(new_sentence.rules);
00069     }
00070 
00071     // Accessing methods
00072 
00073     public String toString()
00074     {
00075         StringBuffer str = new StringBuffer();
00076         Iterator e = rules.iterator();
00077         while (e.hasNext()) {
00078             str.append((e.next()).toString());
00079             str.append("\n\r");
00080         }
00081         return str.toString();
00082     }
00083   
00084   public PropositionalTheoremProver asPropositionalSentence() 
00085   { 
00086     PropositionalTheoremProver tp = new PropositionalTheoremProver();
00087     Hashtable pd = new Hashtable();
00088 
00089     Iterator e = rules.iterator();
00090     while (e.hasNext()) {
00091       ((theoremprover.LObject)(e.next())).asPropositionalSentence(tp,pd);
00092     }
00093     return tp;
00094   }
00095 
00096 
00097   public ABTheoremProver asABPropositionalSentence(ABTheoremProver tp) 
00098   { 
00099     Hashtable pd = new Hashtable();
00100 
00101     Iterator e = rules.iterator();
00102     while (e.hasNext()) {
00103       if (((theoremprover.LObject)(e.next())).asABPropositionalSentence(tp,pd) == null) {
00104         return null;
00105       }
00106     }
00107     return tp;
00108   }
00109 
00110 
00111     // Returns a list of predicates of the form str(X)
00112     public ArrayList allPredicates(String str)
00113     {
00114         return allPredicates(str,1);
00115     }
00116 
00117     // Returns a list of predicates of the form str(X1,..,Xi)
00118     public ArrayList allPredicates(String str, int i)
00119     {
00120         ArrayList v = new ArrayList();
00121         Iterator e = rules.iterator();
00122         while (e.hasNext()) {
00123             v = ((theoremprover.LObject)(e.next())).allPredicates(str,i,v);
00124         }
00125         return v;
00126     }
00127 
00128 }


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