|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| LogicalEquivalence.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 | /* $Id: LogicalEquivalence.java,v 1.4 2006/10/20 20:23:03 m31 Exp $ | |
| 2 | * | |
| 3 | * This file is part of the project "Hilbert II" - http://www.qedeq.org | |
| 4 | * | |
| 5 | * Copyright 2000-2006, Michael Meyling <mime@qedeq.org>. | |
| 6 | * | |
| 7 | * "Hilbert II" is free software; you can redistribute | |
| 8 | * it and/or modify it under the terms of the GNU General Public | |
| 9 | * License as published by the Free Software Foundation; either | |
| 10 | * version 2 of the License, or (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | */ | |
| 17 | ||
| 18 | package org.qedeq.kernel.bo.logic; | |
| 19 | ||
| 20 | import org.qedeq.kernel.base.list.Element; | |
| 21 | ||
| 22 | ||
| 23 | /** | |
| 24 | * This class deals with {@link org.qedeq.kernel.base.list.Element}s and could check | |
| 25 | * if two formulas are logically equivalent. | |
| 26 | * | |
| 27 | * TODO mime 20050205: work in progress | |
| 28 | * | |
| 29 | * @version $Revision: 1.4 $ | |
| 30 | * @author Michael Meyling | |
| 31 | */ | |
| 32 | public final class LogicalEquivalence { | |
| 33 | ||
| 34 | /** | |
| 35 | * Constructor. | |
| 36 | */ | |
| 37 | 0 | private LogicalEquivalence() { |
| 38 | // nothing to do | |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * Assures that two words are logically equivalent. | |
| 43 | * | |
| 44 | * @param formula1 First formula. | |
| 45 | * @param formula2 Second formula. | |
| 46 | * @throws CheckException Check failed. | |
| 47 | */ | |
| 48 | 0 | public static final void checkEquivalence(final Element formula1, |
| 49 | final Element formula2) | |
| 50 | throws CheckException { | |
| 51 | 0 | if (formula1.equals(formula2)) { |
| 52 | 0 | return; |
| 53 | } | |
| 54 | 0 | if (formula1.isAtom() || formula2.isAtom()) { |
| 55 | 0 | return; // TODO mime 20050330: where is the check??? |
| 56 | } | |
| 57 | 0 | final String op1 = formula1.getList().getOperator(); |
| 58 | 0 | final String op2 = formula2.getList().getOperator(); |
| 59 | 0 | if (op1.equals(op2) && (op1.equals(Operators.CONJUNCTION_OPERATOR) |
| 60 | || op1.equals(Operators.DISJUNCTION_OPERATOR))) { | |
| 61 | 0 | final EqualFormulaSet sub1 = new EqualFormulaSet(formula1.getList()); |
| 62 | 0 | final EqualFormulaSet sub2 = new EqualFormulaSet(formula2.getList()); |
| 63 | 0 | if (sub1.equals(sub2)) { |
| 64 | 0 | return; |
| 65 | } | |
| 66 | ||
| 67 | } | |
| 68 | 0 | throw new FormulaCheckException(61, "no logical equivalence found", formula2, null); |
| 69 | } | |
| 70 | ||
| 71 | } |
|
||||||||||