LRule.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 LRule extends LObject
00046 {
00047     // Instance variables
00048 
00049     public ArrayList tail;
00050     public LObject head;
00051 
00052     // Instance creation and initialization
00053 
00054     LRule()
00055     {
00056         tail = new ArrayList();
00057         head = null;
00058     }
00059 
00060     LRule(ArrayList v, LObject h)
00061     {
00062         tail = v;
00063         head = h;
00064     }
00065 
00066     // Accessing methods
00067 
00068     public String toString()
00069     {
00070         StringBuffer str = new StringBuffer();
00071         Iterator e = tail.iterator();
00072         int i = tail.size();
00073         while (e.hasNext()) {
00074             str.append((e.next()).toString());
00075             i--;
00076             if (i>0) { str.append(", ");}
00077         }
00078         str.append(" -> ");
00079         str.append(head.toString());
00080         str.append(".");
00081         return str.toString();
00082     }
00083 
00084   public PropositionalTheoremProver asPropositionalSentence()
00085   {
00086     return null;
00087   }
00088 
00089 
00090   public PropositionalTheoremProver 
00091     asPropositionalSentence(
00092                             PropositionalTheoremProver tp, 
00093                             Hashtable pd)
00094   {
00095     String str;
00096     Proposition p;
00097     ArrayList ant = new ArrayList();
00098     Iterator e = tail.iterator();
00099 
00100     while (e.hasNext()) {
00101       str = (e.next()).toString();
00102       if (pd.containsKey(str)) {
00103         p = (Proposition)pd.get(str);
00104       } else {
00105         p = new Proposition();
00106         p.setIdentifier(str);
00107         pd.put(str,p);
00108         tp.addProposition(p);
00109       }
00110       ant.add(p);
00111     }
00112     str = head.toString();
00113     if (str.equalsIgnoreCase("false")) {
00114       p = tp.contradiction();
00115     } else if (pd.containsKey(str)) {
00116       p = (Proposition)pd.get(str);
00117     } else {
00118       p = new Proposition();
00119       p.setIdentifier(str);
00120       pd.put(str,p);
00121       tp.addProposition(p);
00122     }
00123     tp.add(ant,p);
00124     return tp;
00125   }
00126 
00127 
00128   public ABTheoremProver asABPropositionalSentence()
00129   {
00130     return null;
00131   }
00132 
00133 
00134   public ABTheoremProver 
00135     asABPropositionalSentence(
00136                             ABTheoremProver tp, 
00137                             Hashtable pd)
00138   {
00139     String str;
00140     Assumption p;
00141     ArrayList ant = new ArrayList();
00142     Iterator e = tail.iterator();
00143 
00144     while (e.hasNext()) {
00145       str = (e.next()).toString();
00146       if (pd.containsKey(str)) {
00147         p = (Assumption)pd.get(str);
00148       } else {
00149         if ((str.length() > 0) &&
00150             ((Character.isUpperCase(str.charAt(0))) || (str.charAt(0) == '!'))) {
00151             
00152             p = new Assumption();
00153             p.setIdentifier(str);
00154             if (!tp.addAssumption(p)) return null;
00155             pd.put(str,p);
00156         } else {
00157           p = new Proposition();
00158           tp.addProposition((Proposition)p);    
00159           p.setIdentifier(str);
00160           pd.put(str,(Proposition)p);
00161         }
00162       }
00163       ant.add(p);
00164     }
00165     str = head.toString();
00166 
00167     if ((str.length() > 0) && (Character.isUpperCase(str.charAt(0)))) {
00168       return null; // No assumption is allowed as succedence
00169     }
00170 
00171     if (str.equalsIgnoreCase("false")) {
00172       p = tp.contradiction();
00173     } else if (pd.containsKey(str)) {
00174       p = (Proposition)pd.get(str);
00175     } else {
00176       p = new Proposition();
00177       p.setIdentifier(str);
00178       pd.put(str,(Proposition)p);
00179       tp.addProposition((Proposition)p);
00180     }
00181     tp.add(ant,(Proposition)p);
00182     return tp;
00183   }
00184 
00185 
00186     public ArrayList allPredicates(String str, int i, ArrayList v)
00187     {
00188         Iterator e = tail.iterator();
00189         while (e.hasNext()) {
00190             v = ((LPredicate)(e.next())).allPredicates(str,i,v);
00191         }
00192         v = head.allPredicates(str,i,v);
00193         return v;
00194     }
00195 }


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