當前位置: 首頁>>代碼示例>>Java>>正文


Java Expressions.FALSE屬性代碼示例

本文整理匯總了Java中com.sri.ai.expresso.helper.Expressions.FALSE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Expressions.FALSE屬性的具體用法?Java Expressions.FALSE怎麽用?Java Expressions.FALSE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.sri.ai.expresso.helper.Expressions的用法示例。


在下文中一共展示了Expressions.FALSE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: inExtensionalSet

public static Expression inExtensionalSet(Expression element, Expression eSet, Context context) {
	// e in { e1, ..., en } 
	// ---> 
    // evaluate(e = e1) or ... or evaluate(e = en) 
    // (evaluate each equality as you go along for potential short-circuiting 
    //  -- note this covers e in {} if n = 0).
	Expression result;
	List<Expression> eSetElements = ExtensionalSets.getElements(eSet);
	if (eSetElements.size() == 0) { // can't be in the empty set.
		result = Expressions.FALSE;
	}
	else {
		List<Expression> disjuncts    = new ArrayList<>();
		for (Expression eSetElement : eSetElements) {
			Expression elementEquality = Equality.make(element, eSetElement);
			Expression inCondition     = context.getTheory().evaluate(elementEquality, context);
			disjuncts.add(inCondition);
			if (inCondition.equals(true)) {
				break; // short-circuit
			}
		}
		result = Or.simplify(Or.make(disjuncts));
	}
	
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:26,代碼來源:IntersectionExtensionalSetSimplifier.java

示例2: simplify

public static Expression simplify(Expression expression, Context context) {
	Expression result = expression;
	if (Equality.isEquality(expression) && expression.numberOfArguments() == 2) {
		Expression extensionalSet = null;
		Expression emptySet       = null;
		for (Expression arg : expression.getArguments()) {
			if (emptySet == null && Sets.isEmptySet(arg)) {
				emptySet = arg;
			}
			else if (extensionalSet == null && Sets.isExtensionalSet(arg)) {
				extensionalSet = arg;
			}
		}
		if (extensionalSet != null && emptySet != null) {
			if (extensionalSet.numberOfArguments() == 0) {
				result = Expressions.TRUE;
			}
			else {
				result = Expressions.FALSE;
			}
		}
	}
	
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:25,代碼來源:ExtensionalSetEqualEmptySetSimplifier.java

示例3: simplify

public static Expression simplify(Expression formula) {
	Expression result;
	if (formula.get(0).equals(Expressions.TRUE)) {
		result = Expressions.FALSE;
	}
	else if (formula.get(0).equals(Expressions.FALSE)) {
		result = Expressions.TRUE;
	}
	else if (formula.get(0).hasFunctor(FunctorConstants.NOT)) {
		result = formula.get(0).get(0);
	}
	else {
		result = formula;
	}
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:16,代碼來源:Not.java

示例4: simplify

public static Expression simplify(Expression disjunction) {
	Expression result = disjunction;
	if (disjunction.getArguments().contains(Expressions.TRUE)) {
		result = Expressions.TRUE;
	}
	else {
		LinkedHashSet<Expression> distinctArgumentsNotEqualToFalse = new LinkedHashSet<Expression>();
		Util.collect(disjunction.getArguments(), distinctArgumentsNotEqualToFalse, e -> ! e.equals(Expressions.FALSE));
		if (distinctArgumentsNotEqualToFalse.size() != disjunction.getArguments().size()) {
			if (distinctArgumentsNotEqualToFalse.size() == 0) {
				result = Expressions.FALSE;
			}
			else if (distinctArgumentsNotEqualToFalse.size() == 1) {
				result = Util.getFirst(distinctArgumentsNotEqualToFalse);
			}
			else if (distinctArgumentsNotEqualToFalse.size() != disjunction.numberOfArguments()) {
				result = Expressions.apply(FunctorConstants.OR, distinctArgumentsNotEqualToFalse);
			}
		}
	}
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:22,代碼來源:Or.java

示例5: simplify

public static Expression simplify(Expression conjunction) {
	Expression result = conjunction;
	if (conjunction.getArguments().contains(Expressions.FALSE)) {
		result = Expressions.FALSE;
	}
	else {
		LinkedHashSet<Expression> distinctArgumentsNotEqualToTrue = new LinkedHashSet<Expression>();
		Util.collect(conjunction.getArguments(), distinctArgumentsNotEqualToTrue, e -> ! e.equals(Expressions.TRUE));
		if (distinctArgumentsNotEqualToTrue.size() != conjunction.getArguments().size()) {
			if (distinctArgumentsNotEqualToTrue.size() == 0) {
				result = Expressions.TRUE;
			}
			else if (distinctArgumentsNotEqualToTrue.size() == 1) {
				result = Util.getFirst(distinctArgumentsNotEqualToTrue);
			}
			else if (distinctArgumentsNotEqualToTrue.size() != conjunction.numberOfArguments()) {
				result = Expressions.apply(FunctorConstants.AND, distinctArgumentsNotEqualToTrue);
			}
		}
	}
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:22,代碼來源:And.java

示例6: simplify

/**
 * Returns FALSE if given disequality has equal arguments, TRUE if they contain distinct constants,
 * and the disequality itself otherwise.
 */
public static Expression simplify(Expression disequality, Context context) {
	Expression result;
	if (disequality.get(0).equals(disequality.get(1))) {
		result = Expressions.FALSE;
	}
	else {
		Set<Expression> constants = new LinkedHashSet<Expression>();
		Set<Expression> nonConstants = new LinkedHashSet<Expression>();
		Util.collect(disequality.getArguments(), constants, context.getIsUniquelyNamedConstantPredicate(), nonConstants);
		if (constants.size() > 1) {
			result = Expressions.TRUE;
		}
		else if (constants.size() == 1 && constants.contains(Expressions.FALSE)) {
			result = And.make(new ArrayList<Expression>(nonConstants));
		}
		else if (constants.size() == 1 && constants.contains(Expressions.TRUE)) {
			ArrayList<Expression> negatedNonConstants = Util.mapIntoArrayList(nonConstants, e -> Not.make(e));
			result = And.make(new ArrayList<Expression>(negatedNonConstants));
		}
		else {
			result = disequality;
		}
	}
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:29,代碼來源:Disequality.java

示例7: simplify

/**
 * Returns TRUE if given equality has all-equal arguments, FALSE if they contain distinct constants,
 * and the equality itself otherwise.
 * Note that this is much faster than eliminating duplicates as well, which requires constructing another equality.
 */
public static Expression simplify(Expression equality, Context context) {
	Expression result;
	if (Util.allEqual(equality.getArguments())) {
		result = Expressions.TRUE;
	}
	else {
		Set<Expression> constants = new LinkedHashSet<Expression>();
		Set<Expression> nonConstants = new LinkedHashSet<Expression>();
		Util.collect(equality.getArguments(), constants, context.getIsUniquelyNamedConstantPredicate(), nonConstants);
		if (constants.size() > 1) {
			result = Expressions.FALSE;
		}
		else if (constants.size() == 1 && constants.contains(Expressions.TRUE)) {
			result = And.make(new ArrayList<Expression>(nonConstants));
		}
		else if (constants.size() == 1 && constants.contains(Expressions.FALSE)) {
			ArrayList<Expression> negatedNonConstants = Util.mapIntoArrayList(nonConstants, e -> Not.make(e));
			result = And.make(new ArrayList<Expression>(negatedNonConstants));
		}
		else {
			result = equality;
		}
	}
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:30,代碼來源:Equality.java

示例8: updatePossibleLeaf

private static Expression updatePossibleLeaf(Expression possibleLeaf) {
	Expression result = possibleLeaf;
	if (!IfThenElse.isIfThenElse(possibleLeaf) 
			&& !Expressions.TRUE.equals(possibleLeaf) 
			&& !Expressions.FALSE.equals(possibleLeaf)) {
		if (Sets.isEmptySet(possibleLeaf)) {
			result = Expressions.TRUE;
		}
		else {
			result = Expressions.FALSE;
		}
	}
	
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:15,代碼來源:SetExpressionIsEqualToEmptySet.java

示例9: simplify

public static Expression simplify(Expression expression, Context context) {
	Expression result = expression;
	
	if (Expressions.hasFunctor(expression, FunctorConstants.IN) && expression.numberOfArguments() == 2) {
		Expression t   = expression.get(0);
		Expression set = expression.get(1);
		if (Sets.isExtensionalSet(set)) {
			// if empty set
			if (set.numberOfArguments() == 0) {
				result = Expressions.FALSE;
			}
			else if (set.numberOfArguments() == 1) {
				// (t = t<sub>1</sub>)
				result = Equality.make(t, set.get(0));
			}
			else { // > 1 element to test
				// (t = t<sub>1</sub>)
				Expression tEqualsT1         = Equality.make(t, set.get(0));
				// {t<sub>2</sub>,&hellip;,t<sub>n</sub>}
				Expression tailSet           = ExtensionalSets.makeOfSameTypeAs(set, set.getArguments().subList(1, set.numberOfArguments()));
				// t &isin; {t<sub>2</sub>,&hellip;,t<sub>n</sub>}
				Expression tElementOfTailSet = Expressions.apply(FunctorConstants.IN, t, tailSet);
				// (t = t<sub>1</sub>) &or; t &isin; {t<sub>2</sub>,&hellip;,t<sub>n</sub>}
				result = Or.make(tEqualsT1, tElementOfTailSet);
			}
		}
	}
	
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:30,代碼來源:ElementOfExtensionalSetSimplifier.java

示例10: make

/** Make a "not" application on given expression. */
public static Expression make(Expression expression) {
	if (expression.equals(Expressions.TRUE)) {
		return Expressions.FALSE;
	}
	if (expression.equals(Expressions.FALSE)) {
		return Expressions.TRUE;
	}
	return Expressions.apply("not", expression);
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:10,代碼來源:Not.java

示例11: makeWithConstantSimplification

/**
 * Makes a disequality application on two terms possibly simplifying it (taking constants into account).
 */
public static Expression makeWithConstantSimplification(Expression term1, Expression term2, Context context) {
	Expression result;
	if (term1.equals(term2)) {
		result = Expressions.FALSE;
	}
	else if (context.isUniquelyNamedConstant(term1) && context.isUniquelyNamedConstant(term2)) {
		result = Expressions.TRUE;
	}
	else {
		result = make(term1, term2);
	}
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:16,代碼來源:Disequality.java

示例12: make

/**
 * Makes a disequality of two expressions, returning Expressions.FALSE if
 * the expressions are identical.
 */
public static Expression make(Object expression1Object,
		Object expression2Object) {
	Expression expression1 = Expressions.wrap(expression1Object);
	Expression expression2 = Expressions.wrap(expression2Object);
	if (expression1.equals(expression2)) {
		return Expressions.FALSE;
	}
	return Expressions.apply(DISEQUALITY, expression1, expression2);
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:13,代碼來源:Disequality.java

示例13: simplifyGivenEquality

/**
 * Returns an expression equivalent to disequality (and perhaps simpler) given equality between a variable and another term.
 */
public static Expression simplifyGivenEquality(Expression disequality, Expression variable, Expression otherTerm) {
	Expression result;
	if (disequality.getArguments().contains(variable) && disequality.getArguments().contains(otherTerm)) {
		result = Expressions.FALSE;
	}
	else {
		result = disequality;
	}
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:13,代碼來源:Disequality.java

示例14: makeWithConstantSimplification

/**
 * Makes an equality application on two terms possibly simplifying it (taking constants into account).
 */
public static Expression makeWithConstantSimplification(Expression term1, Expression term2, Context context) {
	Expression result;
	if (term1.equals(term2)) {
		result = Expressions.TRUE;
	}
	else if (context.isUniquelyNamedConstant(term1) && context.isUniquelyNamedConstant(term2)) {
		result = Expressions.FALSE;
	}
	else {
		result = make(term1, term2);
	}
	return result;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:16,代碼來源:Equality.java

示例15: makePairwiseEquality

/**
 * Returns a conjunction of equalities between the corresponding elements of two lists
 * (two elements are corresponding if they have the indices).
 * Returns false if the lists have different sizes.
 */
public static Expression makePairwiseEquality(List<Expression> list1, List<Expression> list2) {
	if (list1.size() == list2.size()) {
		Expression result = And.make(Expressions.makePairwiseApplications(FunctorConstants.EQUAL, list1, list2));
		return result;
	}
	return Expressions.FALSE;
}
 
開發者ID:aic-sri-international,項目名稱:aic-expresso,代碼行數:12,代碼來源:Equality.java


注:本文中的com.sri.ai.expresso.helper.Expressions.FALSE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。