Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Wrong implication evaluation in OCL 5
Wrong implication evaluation in OCL 5 [message #1276301] Mon, 24 March 2014 07:09 Go to next message
Denis Nikiforov is currently offline Denis Nikiforov
Messages: 59
Registered: August 2013
Member
Hi

It's seems that OCL 5 evaluates implication consequence even if premise is false.

Here is a test model (TTDataModel.uml):
https://github.com/AresEkb/uml2xsd/tree/master/model

You can open it in a UML Model Editor, select a BusinessAreas package and try to evaluate a following expression:
let standardId : String = getValue(getAppliedStereotype('EECProfile::EECDataModel'), 'standardId').oclAsType(String) in
let ns : Package = allOwningPackages()->any(getAppliedStereotype('EECProfile::Namespace') <> null) in
standardId <> null and standardId.size() > 0 and ns <> null
implies
ns.allOwnedElements()->notEmpty()

BusinessAreas doesn't have a parent Package with a Namespace stereotype and therefore premise equals false and implication equals true. It works as expected in OCL 4.

But in OCL 5 it returns nothing. It seems that it throws a following exception (You can see it if you'll run an uml2xsd project):
org.eclipse.ocl.examples.domain.values.impl.InvalidValueException
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:654)
	at org.eclipse.ocl.examples.pivot.internal.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:432)
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitLetExp(EvaluationVisitorImpl.java:608)
	at org.eclipse.ocl.examples.pivot.internal.impl.LetExpImpl.accept(LetExpImpl.java:434)
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitLetExp(EvaluationVisitorImpl.java:608)
	at org.eclipse.ocl.examples.pivot.internal.impl.LetExpImpl.accept(LetExpImpl.java:434)
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.safeVisit(EvaluationVisitorImpl.java:196)
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitExpressionInOCL(EvaluationVisitorImpl.java:416)
	at org.eclipse.ocl.examples.pivot.internal.impl.ExpressionInOCLImpl.accept(ExpressionInOCLImpl.java:527)
	at org.eclipse.ocl.examples.pivot.OCL.evaluate(OCL.java:431)
	at uml2xsd.Main.validateModel(Main.java:203)
	at uml2xsd.Main.main(Main.java:125)
Caused by: org.eclipse.ocl.examples.domain.values.impl.InvalidValueException
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:711)
	at org.eclipse.ocl.examples.pivot.internal.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:432)
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:651)
	... 11 more
Caused by: org.eclipse.ocl.examples.domain.values.impl.InvalidValueException
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitLetExp(EvaluationVisitorImpl.java:603)
	... 9 more
Caused by: org.eclipse.ocl.examples.domain.values.impl.InvalidValueException: No matching content for any
	at org.eclipse.ocl.examples.library.iterator.AnyIteration.resolveTerminalValue(AnyIteration.java:42)
	at org.eclipse.ocl.examples.domain.library.AbstractIteration.evaluateIteration(AbstractIteration.java:75)
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitIteratorExp(EvaluationVisitorImpl.java:577)
	at org.eclipse.ocl.examples.pivot.internal.impl.IteratorExpImpl.accept(IteratorExpImpl.java:4092)
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitVariable(EvaluationVisitorImpl.java:924)
	at org.eclipse.ocl.examples.pivot.internal.impl.VariableImpl.accept(VariableImpl.java:571)
	at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitLetExp(EvaluationVisitorImpl.java:600)
	... 9 more


I guess that OCL 5 try to evaluate ns.allOwnedElements()->notEmpty() and throws the exception because ns is null

[Updated on: Mon, 24 March 2014 07:45]

Report message to a moderator

Re: Wrong implication evalution in OCL 5 [message #1320235 is a reply to message #1276301] Mon, 28 April 2014 13:24 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi

https://bugs.eclipse.org/bugs/show_bug.cgi?id=433103

The Library Operation evaluate API has been augmented with a dispatch
API that allows operations to take control of argument fetching and so
allows premature short circuit returns from and/or/implies.

Regards

Ed Willink

On 24/03/2014 11:09, Denis Nikiforov wrote:
> Hi
>
> It's seems that OCL 5 evaluates implication consequence even if
> premise is false.
>
> Here is a test model (TTDataModel.uml):
> https://github.com/AresEkb/uml2xsd/tree/master/model
>
> You can open it in a UML Model Editor, select a BusinessAreas package
> and try to evaluate a following expression:
> let standardId : String =
> getValue(getAppliedStereotype('EECProfile::EECDataModel'),
> 'standardId').oclAsType(String) in
> let ns : Package =
> allOwningPackages()->any(getAppliedStereotype('EECProfile::Namespace')
> <> null) in
> standardId <> null and standardId.size() > 0 and ns <> null
> implies
> ns.allOwnedElements()->notEmpty()
> BusinessAreas doesn't have a Package with a Namespace stereotype and
> therefore premise equals false and implication equals true. It works
> as expected in OCL 4.
>
> But in OCL 5 it returns nothing. It seems that it throws a following
> exception (You can see it if you'll run an uml2xsd project):
> org.eclipse.ocl.examples.domain.values.impl.InvalidValueException
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:654)
> at
> org.eclipse.ocl.examples.pivot.internal.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:432)
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitLetExp(EvaluationVisitorImpl.java:608)
> at
> org.eclipse.ocl.examples.pivot.internal.impl.LetExpImpl.accept(LetExpImpl.java:434)
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitLetExp(EvaluationVisitorImpl.java:608)
> at
> org.eclipse.ocl.examples.pivot.internal.impl.LetExpImpl.accept(LetExpImpl.java:434)
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.safeVisit(EvaluationVisitorImpl.java:196)
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitExpressionInOCL(EvaluationVisitorImpl.java:416)
> at
> org.eclipse.ocl.examples.pivot.internal.impl.ExpressionInOCLImpl.accept(ExpressionInOCLImpl.java:527)
> at org.eclipse.ocl.examples.pivot.OCL.evaluate(OCL.java:431)
> at uml2xsd.Main.validateModel(Main.java:203)
> at uml2xsd.Main.main(Main.java:125)
> Caused by:
> org.eclipse.ocl.examples.domain.values.impl.InvalidValueException
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:711)
> at
> org.eclipse.ocl.examples.pivot.internal.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:432)
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:651)
> ... 11 more
> Caused by:
> org.eclipse.ocl.examples.domain.values.impl.InvalidValueException
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitLetExp(EvaluationVisitorImpl.java:603)
> ... 9 more
> Caused by:
> org.eclipse.ocl.examples.domain.values.impl.InvalidValueException: No
> matching content for any
> at
> org.eclipse.ocl.examples.library.iterator.AnyIteration.resolveTerminalValue(AnyIteration.java:42)
> at
> org.eclipse.ocl.examples.domain.library.AbstractIteration.evaluateIteration(AbstractIteration.java:75)
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitIteratorExp(EvaluationVisitorImpl.java:577)
> at
> org.eclipse.ocl.examples.pivot.internal.impl.IteratorExpImpl.accept(IteratorExpImpl.java:4092)
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitVariable(EvaluationVisitorImpl.java:924)
> at
> org.eclipse.ocl.examples.pivot.internal.impl.VariableImpl.accept(VariableImpl.java:571)
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitLetExp(EvaluationVisitorImpl.java:600)
> ... 9 more
>
> I guess that OCL 5 try to evaluate ns.allOwnedElements()->notEmpty()
> and throws the exception because ns is null
Previous Topic:oclAsType in xtext console
Next Topic:Reflection example
Goto Forum:
  


Current Time: Fri Aug 29 16:28:51 EDT 2014

Powered by FUDForum. Page generated in 0.02135 seconds