VerifyTools
AddVerification
extend verification system with user-defined verification
Calling Sequence
Parameters
Description
Examples
AddVerification(verificationname, handler)
AddVerification(verificationname = handler)
Exists(verificationname)
GetVerification(verificationname)
GetVerifications()
GetVerifications('`global`')
GetVerifications('`local`')
RemoveVerification(verificationname)
verificationname
-
symbol; name of the verification
handler
procedure or structured verification
'`global`'
the literal name '`global`'
'`local`'
the literal name '`local`'
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 verify⁡expr1,expr2,verificationname⁡arg1,arg2,..., which results in the call handler⁡expr1,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.
with⁡VerifyTools:
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:
AddVerification⁡length_not_increased,a,b↦evalb⁡length⁡a≤length⁡b
verify⁡x+1x,x2+1x,length_not_increased
true
verify⁡x2+1x,x+1x,length_not_increased
false
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:
AddVerification⁡basic,And⁡normal,length_not_increased
verify⁡x+1x,x2+1x,basic
verify⁡x2+1x,x+1x,basic
verify⁡x+1,x2+1x,basic
Some examples of the use of GetVerification, Exists, and RemoveVerification:
GetVerification⁡length_not_increased
a,b↦evalb⁡length⁡a≤length⁡b
Exists⁡basic
RemoveVerification⁡basic
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
GetVerifications('`local`') returns those whose names are not global (they may be exports rather than local though):
Complexity ≔ module_export⁡Length,NumFunctions,NumVars;VerifyTools:-AddVerification⁡Length,a,b→evalb⁡length⁡a<=length⁡b;VerifyTools:-AddVerification⁡NumVars,a,b→evalb⁡numelems⁡indets⁡a,'name'<=numelems⁡indets⁡b,'name'end module:
verify⁡x+y,x2+1,Complexity:-Length
verify⁡x+y,x2+1,Complexity:-NumVars
GetVerifications⁡`local`
Length,NumVars,curve,curves,default,default
The extra names appearing in this list are verifications defined and used internally by Maple.
See Also
verify
verify[structured]
Download Help Document