本文整理汇总了Java中com.sri.ai.expresso.helper.Expressions.TRUE属性的典型用法代码示例。如果您正苦于以下问题:Java Expressions.TRUE属性的具体用法?Java Expressions.TRUE怎么用?Java Expressions.TRUE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sri.ai.expresso.helper.Expressions
的用法示例。
在下文中一共展示了Expressions.TRUE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructComponentIntensionalSet
private static Expression constructComponentIntensionalSet(Type indexType, IntensionalSet intensionalSet, Expression additiveIdentityElement, Context intensionalSetContext) {
Expression conditionedBody = IfThenElse.make(intensionalSet.getCondition(), intensionalSet.getHead(), additiveIdentityElement);
Expression componentIndex = Expressions.makeUniqueVariable("C", conditionedBody, intensionalSetContext);
Expression indexExpression = IndexExpressions.makeIndexExpression(componentIndex, Expressions.parse(indexType.getName()));
Expression intensionalCondition = Expressions.TRUE;
// NOTE: handle the REAL cases where an SingleVariableLinearRealArithmeticConstraint is expected.
if (indexType instanceof RealExpressoType || indexType instanceof RealInterval) {
SingleVariableLinearRealArithmeticConstraint svlraConstraint = new SingleVariableLinearRealArithmeticConstraint(componentIndex, true, intensionalSetContext.getTheory());
intensionalCondition = svlraConstraint;
}
Expression result = IntensionalSet.make(Sets.isMultiSet(intensionalSet) ? IntensionalSet.MULTI_SET_LABEL : IntensionalSet.UNI_SET_LABEL,
new ExtensionalIndexExpressionsSet(Arrays.asList(indexExpression)),
componentIndex,
intensionalCondition);
return result;
}
示例2: getQuantifierCondition
private static Expression getQuantifierCondition(Expression quantifier) {
Expression result;
if (quantifier instanceof IntensionalSet) {
result = ((IntensionalSet)quantifier).getCondition();
}
else if (quantifier instanceof CountingFormula) {
result = ((CountingFormula)quantifier).getBody();
}
else if (ForAll.isForAll(quantifier)
|| ThereExists.isThereExists(quantifier)
|| quantifier instanceof LambdaExpression) {
// No conditions on these quantifiers, just default to true
result = Expressions.TRUE;
}
else {
throw new UnsupportedOperationException("Quantifer currently not supported: "+quantifier);
}
return result;
}
开发者ID:aic-sri-international,项目名称:aic-expresso,代码行数:20,代码来源:SetOfArgumentTuplesForFunctionOccurringInExpression.java
示例3: 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
示例4: 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;
}
示例5: 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;
}
示例6: simplify
public static Expression simplify(Expression expression) {
if (expression.get(0).equals(expression.get(1))) {
return Expressions.TRUE;
}
if (expression.get(0).equals(Expressions.TRUE)) {
return expression.get(1);
}
else if (expression.get(0).equals(Expressions.FALSE)) {
return Expressions.TRUE;
}
if (expression.get(1).equals(Expressions.TRUE)) {
return Expressions.TRUE;
}
else if (expression.get(1).equals(Expressions.FALSE)) {
return Not.make(expression.get(0));
}
return expression;
}
示例7: 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;
}
示例8: simplify
public static Expression simplify(Expression expression) {
if (expression.get(0).equals(expression.get(1))) {
return Expressions.TRUE;
}
if (expression.get(0).equals(Expressions.TRUE)) {
return expression.get(1);
}
else if (expression.get(0).equals(Expressions.FALSE)) {
return Not.make(expression.get(1));
}
if (expression.get(1).equals(Expressions.TRUE)) {
return expression.get(0);
}
else if (expression.get(1).equals(Expressions.FALSE)) {
return Not.make(expression.get(0));
}
return expression;
}
示例9: 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;
}
示例10: 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;
}
示例11: makeIntensionalSet
protected Expression makeIntensionalSet(Object label, Token scope, List<AntlrGrinderParser.ExprContext> scopeargs,
AntlrGrinderParser.ExprContext head, AntlrGrinderParser.ExprContext condition) {
List<Expression> indexExpressionsList = Util.list();
if (scope != null) {
indexExpressionsList = expressionsList(scopeargs);
}
Expression headExpression = visit(head);
Expression conditionExpression = null;
if (condition != null) {
conditionExpression = Expressions.makeExpressionOnSyntaxTreeWithLabelAndSubTrees(IntensionalSet.CONDITION_LABEL, visit(condition));
}
Expression result = null;
if (scope == null && conditionExpression == null) {
// We need to construct an extensional set in this case
if (label.equals(IntensionalSet.UNI_SET_LABEL)) {
result = ExtensionalSets.makeUniSet(headExpression);
}
else {
result = ExtensionalSets.makeMultiSet(Arrays.asList(headExpression));
}
}
else {
conditionExpression = conditionExpression == null? Expressions.TRUE : conditionExpression.get(0); // contains the "|";
result = IntensionalSet.make(label, new ExtensionalIndexExpressionsSet(indexExpressionsList), headExpression, conditionExpression);
}
return result;
}
示例12: 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;
}
示例13: 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);
}
示例14: 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;
}
示例15: simplifyGivenDisequality
/**
* Returns an expression equivalent to disequality (and perhaps simpler) given a disequality.
*/
public static Expression simplifyGivenDisequality(Expression disequality, Expression variable, Expression otherTerm) {
Expression result;
if (disequality.getArguments().contains(variable) && disequality.getArguments().contains(otherTerm)) {
result = Expressions.TRUE;
}
else {
result = disequality;
}
return result;
}