AddVerification - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


VerifyTools

  

AddVerification

  

extend verification system with user-defined verification

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

AddVerification(verificationname, handler)

AddVerification(verificationname = handler)

Exists(verificationname)

GetVerification(verificationname)

GetVerifications()

GetVerifications('`global`')

GetVerifications('`local`')

RemoveVerification(verificationname)

Parameters

verificationname

-

symbol; name of the verification

handler

-

procedure or structured verification

'`global`'

-

the literal name '`global`'

'`local`'

-

the literal name '`local`'

Description

• 

AddVerification adds a new verification verificationname into the verification system.

• 

The handler argument is either a procedure, appliable module, or a structured verification describing the new verification.

• 

If handler is a procedure, then a call to verify of the form verify( expr1, expr2, verificationname ) results in a call to handler( expr1, expr2 ). Additional arguments can be passed to handler from a call to verify of the form verifyexpr1,expr2,verificationnamearg1,arg2,..., which results in the call handlerexpr1,expr2,arg1,arg2,.... The handler argument, if it is a procedure, must return either true, false, FAIL, [false, result], or [FAIL, result], where result is some expression or expression sequence which provides some information relating to or explaining the failure. It must also be prepared to handle any argument sequence that is passed to it.

• 

If the handler argument is a structured verification, then the verification test is defined by the structured verification interpreter as though the structured verification were used directly in a call to verify.

• 

Exists(verificationname) checks whether there is a verification named verificationname in the verification system. It returns true if so and false otherwise.

• 

GetVerification(verificationname) returns the value of the verification named verificationname if it exists in the verification system.

• 

GetVerifications() returns the list of verifications in the verification system. GetVerifications(`global`) returns the sublist of known verifications which have global names. GetVerifications(`local`) returns the sublist of known verifications whose names are not global.

• 

RemoveVerification(verificationname) removes the verification verificationname from the verification system.

• 

The AddVerification and RemoveVerification commands return NULL.

Examples

withVerifyTools:

Suppose you want to create a verification which will check that the length of a result has not increased compared to the expected result. We can do this using the AddVerification command:

AddVerificationlength_not_increased,a,bevalblengthalengthb

verifyx+1x,x2+1x,length_not_increased

true

(1)

verifyx2+1x,x+1x,length_not_increased

false

(2)

If we then realize that this verification is not sufficient because it doesn't also ensure that the new result is equivalent to the expected one, we can add an extra condition to the verification, that the normalized difference between expected and new results is 0:

AddVerificationbasic,Andnormal,length_not_increased

verifyx+1x,x2+1x,basic

true

(3)

verifyx2+1x,x+1x,basic

false

(4)

verifyx+1,x2+1x,basic

false

(5)

Some examples of the use of GetVerification, Exists, and RemoveVerification:

GetVerificationlength_not_increased

a,bevalblengthalengthb

(6)

Existsbasic

true

(7)

RemoveVerificationbasic

Existsbasic

false

(8)

GetVerifications returns the list of all verifications known to the system:

GetVerifications

&under,Array,FAIL,FrobeniusGroupId,Global,Matrix,MultiSet,PermGroup,RootOf,SmallGroupId,Vector,address,after,approx,array,as_list,as_multiset,as_set,attributes,boolean,box,cbox,curve,curves,dataframe,dataseries,default,default,dummyvariable,equal,evala,evalc,expand,false,float,function,function_bounds,function_curve,function_shells,greater_equal,greater_than,in_convex_polygon,indef_int,interval,length_not_increased,less_equal,less_than,list,listlist,matrix,member,multiset,neighborhood,neighbourhood,normal,permute_elements,plot,plot3d,plot_distance,plotthing_compile_result,polynom,procedure,ptbox,range,rational,record,relation,reverse,rifset,rifsimp,rtable,set,sign,simplify,sublist,subset,subtype,superlist,superset,supertype,symbol,table,table_indices,testeq,text,true,truefalse,type,undefined,units,vector,verifyfunc,wildcard,xmltree,xvm

(9)

GetVerifications('`local`') returns those whose names are not global (they may be exports rather than local though):

Complexitymodule_exportLength&comma;NumFunctions&comma;NumVars&semi;VerifyTools:-AddVerificationLength&comma;a&comma;b&rarr;evalblengtha<=lengthb&semi;VerifyTools:-AddVerificationNumVars&comma;a&comma;b&rarr;evalbnumelemsindetsa&comma;&apos;name&apos;<=numelemsindetsb&comma;&apos;name&apos;end module&colon;

verifyx+y&comma;x2+1&comma;Complexity:-Length

true

(10)

verifyx+y&comma;x2+1&comma;Complexity:-NumVars

false

(11)

GetVerifications`local`

Length&comma;NumVars&comma;curve&comma;curves&comma;default&comma;default

(12)

The extra names appearing in this list are verifications defined and used internally by Maple.

See Also

verify

verify[structured]

VerifyTools