@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; KApp kApp = (KApp) o; if (!child.equals(kApp.child)) return false; if (!label.equals(kApp.label)) return false; return true; }
public List<Term> computeRenamingVars(Variable x) { List<Term> vars = new ArrayList<Term>(); for (Atom atom : body) { // Need to deal with inverse role if (atom.getTerms().contains(x) && atom.getPredicate().getArity() == 2) { for (Term term : atom.getTerms()) if (!term.equals(x)) vars.add(term); } } return vars; }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj == null || obj.getClass() != this.getClass()) { return false; } TermAndYear other = (TermAndYear) obj; return term.equals(other.term) && year == other.year; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PostingList other = (PostingList) obj; if (term == null) { if (other.term != null) return false; } else if (!term.equals(other.term)) return false; return true; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Functor other = (Functor) obj; if (arity != other.arity) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; }
@Override public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof Cell)) { return false; } Cell cell = (Cell) object; return cellLabel.equals(cell.cellLabel) && content.equals(cell.content); }
@Override public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof ConstrainedTerm)) { return false; } ConstrainedTerm constrainedTerm = (ConstrainedTerm) object; return term.equals(constrainedTerm.term) && lookups.equals(constrainedTerm.lookups) && constraint.equals(constrainedTerm.constraint); }
@Override public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof MapLookup)) { return false; } MapLookup mapLookup = (MapLookup) object; return base().equals(mapLookup.base()) && key().equals(mapLookup.key()) && value.equals(mapLookup.value); }
@Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final LetBinding that = (LetBinding) o; if (!name.equals(that.name)) return false; if (scope != that.scope) return false; if (hasDeclaredType() ? !declaredType.equals(that.declaredType) : that.hasDeclaredType()) return false; if (value != null ? !value.equals(that.value) : that.value != null) return false; return true; }
public Set getGenFuncsApplied(Term subject) { Set genFuncsApplied = new HashSet(); for (int i = 0; i < args.length; ++i) { if (args[i] instanceof Term) { Term arg = (Term) args[i]; if (arg.equals(subject) && (f instanceof OriginFunction)) { genFuncsApplied.add(f); } else { genFuncsApplied.addAll(arg.getGenFuncsApplied(subject)); } } } return Collections.unmodifiableSet(genFuncsApplied); }
public ArgSpec replace(Term t, ArgSpec another) { if (t.equals(this)) return another; Term[] newArgs = new Term[args.length]; boolean replacement = false; for (int i = 0; i != args.length; i++) { Term newArg = (Term) args[i].replace(t, another); replacement = replacement || newArg != args[i]; newArgs[i] = newArg; } if (replacement) { Term result = new FuncAppTerm(f, Arrays.asList(newArgs)); if (compiled) result.compile(new LinkedHashSet()); return result; } return this; }
@Override public boolean equals(Object o) { if (!(o instanceof Freezer)) return false; Freezer f = (Freezer) o; return term.equals(f.term); }
/** * {<M ==> S>, <M ==> P>} |- {<S ==> P>, * * <P ==>S>, <S <=> P>} * * @param task1 The first premise * @param task2 The second premise * @param order Temporal order of the terms in conclusion */ public static void temporalIndCom(Task task1, Task task2, TemporalValue order) { Judgment judg1 = (Judgment) task1.getSentence(); Judgment judg2 = (Judgment) task2.getSentence(); Stamp stamp = Stamp.make(judg1.getStamp(), judg2.getStamp()); if (stamp == null) { return; } Memory.currentStamp = stamp; Term term1 = judg1.getContent(); Term term2 = judg2.getContent(); if ((term1 instanceof Inheritance) && (term2 instanceof Inheritance)) { RDFStatement s1 = (RDFStatement) term1; RDFStatement s2 = (RDFStatement) term2; Variable var1 = new Variable(Symbols.VARIABLE_TAG + "0"); Variable var2 = new Variable(Symbols.VARIABLE_TAG + "0"); if (s1.getSubject().equals(s2.getSubject())) { term1 = RDFStatement.make(s1, var1, s1.getPredicate()); term2 = RDFStatement.make(s2, var2, s2.getPredicate()); } else if (s1.getPredicate().equals(s2.getPredicate())) { term1 = RDFStatement.make(s1, s1.getSubject(), var1); term2 = RDFStatement.make(s2, s2.getSubject(), var2); } } else { // to generalize Term condition; if ((term1 instanceof Implication) && (term2 instanceof Inheritance)) { condition = ((Implication) term1).getSubject(); if (condition.equals(term2)) { return; } if ((condition instanceof Conjunction) && ((Conjunction) condition).containComponent(term2)) { return; } } else if ((term1 instanceof Inheritance) && (term2 instanceof Implication)) { condition = ((Implication) term2).getSubject(); if (condition.equals(term1)) { return; } if ((condition instanceof Conjunction) && ((Conjunction) condition).containComponent(term1)) { return; } } } RDFStatement statement1 = Implication.make(term1, term2, order); RDFStatement statement2 = Implication.make(term2, term1, TemporalValue.getReverse(order)); RDFStatement statement3 = Equivalence.make(term1, term2, order); TruthValue value1 = judg1.getTruth(); TruthValue value2 = judg2.getTruth(); TruthValue truth1 = TruthFunctions.induction(value1, value2); TruthValue truth2 = TruthFunctions.induction(value2, value1); TruthValue truth3 = TruthFunctions.comparison(value1, value2); BudgetValue budget1 = BudgetFunctions.temporalIndCom(task1.getBudget(), task2.getBudget(), truth1); BudgetValue budget2 = BudgetFunctions.temporalIndCom(task1.getBudget(), task2.getBudget(), truth2); BudgetValue budget3 = BudgetFunctions.temporalIndCom(task1.getBudget(), task2.getBudget(), truth3); Memory.currentTense = new TemporalValue(0); Memory.doublePremiseTask(budget1, statement1, truth1); Memory.doublePremiseTask(budget2, statement2, truth2); Memory.doublePremiseTask(budget3, statement3, truth3); }
/** * {<<M --> S> ==> <M --> P>>, <M --> S>} |- <M --> P> {<<M --> S> ==> <M --> P>>, <M --> P>} |- * <M --> S> * * @param mainSentence The implication/equivalence premise * @param subSentence The premise on part of s1 * @param s The location of s2 in s1 */ static void detachment(Sentence mainSentence, Sentence subSentence, int s) { RDFStatement statement = (RDFStatement) mainSentence.getContent(); Term subject = statement.getSubject(); Term predicate = statement.getPredicate(); Term term = subSentence.getContent(); Term content; int side; if (term.equals(subject)) { side = 0; content = predicate; } else if (term.equals(predicate)) { side = 1; content = subject; } else { return; } if ((content instanceof RDFStatement) && ((RDFStatement) content).invalid()) { return; } Sentence taskSentence = Memory.currentTask.getSentence(); Sentence beliefSentence = Memory.currentBelief; TruthValue beliefTruth = beliefSentence.getTruth(); TruthValue truth1 = mainSentence.getTruth(); TruthValue truth2 = subSentence.getTruth(); TruthValue truth = null; BudgetValue budget; if (taskSentence instanceof Question) { if (statement instanceof Equivalence) { budget = BudgetFunctions.backward(beliefTruth); } else if (side == 0) { budget = BudgetFunctions.backwardWeak(beliefTruth); } else { budget = BudgetFunctions.backward(beliefTruth); } } else { if (taskSentence instanceof Goal) { if (statement instanceof Equivalence) { truth = TruthFunctions.desireStrong(truth1, truth2); } else if (side == 0) { truth = TruthFunctions.desireInd(truth1, truth2); } else { truth = TruthFunctions.desireDed(truth1, truth2); } } else { if (statement instanceof Equivalence) { truth = TruthFunctions.analogy(truth1, truth2); } else if (side == 0) { truth = TruthFunctions.deduction(truth1, truth2); } else { truth = TruthFunctions.abduction(truth2, truth1); } } budget = BudgetFunctions.forward(truth); } TemporalValue tense0 = subSentence.getTense(); TemporalValue order0 = statement.getOrder(); TemporalValue tense; if (order0 == null) { tense = tense0; } else if (side == 0) { tense = TemporalRules.tenseSyllogistic(tense0, subSentence.getCreationTime(), order0); } else { tense = TemporalRules.tenseSyllogistic( tense0, subSentence.getCreationTime(), TemporalValue.getReverse(order0)); } Memory.currentTense = tense; Memory.doublePremiseTask(budget, content, truth); }