当前位置: 首页>>代码示例>>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;未经允许,请勿转载。