Generally speaking to perform "mathematical" proofs, you need to express 
your functions in mathematical language.

If you can do that, then yes, there are ways to "prove" equivalence. But 
the code you show is string processing, and I'm not up on my math 
representations. That might border on Matrix Algerbra - oh the joys of 
eigenvalues, eigenvectors, and eigenspace.

But unless there's some specific project requirement to provide such a 
proof (don't laugh, some Gov work I've done would require it), you could 
just do a fairly exhaustive test (as someone else mentioned).

For example, you could set something up like this:

------------------------------------------------------
FUNCTION CompareStripFuncs

*-- assumes you have your StripCharsNew and StripCharsOld already defined,
*--      and that cValidChars has been defined
*-- build a cursor of string values you want to check. E.g. if you 
archived/logged
*--      the old values that "failed" in some table/file somewhere

CREATE CURSOR curResultCompare (checked_string C(100), result_old C(100), 
result_new C(100))

*-- curValues2Check is the cursor that has all the strings that you want to 
check - I'll assume the
*--     name of the field that holds the string is cBadCharString

SELECT curValues2Check
SCAN
         INSERT INTO curResultCompare ;
                 (cChecked_string, ;
                 cRresult_old, ;
                 cRresult_new) ;
         VALUES ;
                 (cBadCharString, ;
                 StripCharsOld(cBadCharString, cValidChars), ;
                 StripCharsNew(cBadCharString, cValidChars))
ENDSCAN

SELECT COUNT(*) as num_not_match FROM cResultCompare ;
         WHERE cResult_old <> cResult_new ;
         INTO CURSOR curNumFailed NOFILTER

m.nReturnNonMatch = curNumFailed.num_not_match
*-- Or you could pull the actual values that didn't compare right, BROWSE 
it, REPORT it, etc.

USE IN (SELECT('curResultCompare'))
USE IN (SELECT('curNumFailed'))

RETURN m.nReturnNonMatch
------------------------------------------------------

If you don't have a set of strings from past events, you could write up a 
program to generate a few million variations, interspersing bad character 
values in various positions. Note, you could probably reduce the required 
number of bad char positions to 1st, last, and randomly in middle (and 
cases where all characters are bad). If you need to document the results 
(aka for a project requirement) you could "check in" the test data and a 
report of the results. If you just need it for your peace of mind, you can 
be satisfied when you see they gave the same result.

-Charlie


At 07:02 PM 7/17/2009 +0300, Paul Newton wrote:
>Hi
>
>Is it ever possible to prove, scientifically or mathematically, that two 
>functions are exactly equivalent ?
>For example, these two functions:
>
>Function StripCharsNew(tcInvalidValue, tcValidCharSet)
>Local lcValidValue, lnCharNo
>lcValidValue = tcInvalidValue
>For lnCharNo = 1 to Len(tcInvalidValue)
>         If At(Substr(tcInvalidValue, lnCharNo, 1), tcValidCharSet) = 0
>                 lcValidValue = 
> ChrTran(lcValidValue,Substr(tcInvalidValue, lnCharNo, 1),tcReplaceChar)
>         EndIf
>Next
>Return lcValidValue
>EndFunc
>
>Function StripCharsOld(tcInvalidValue, tcValidCharSet)
>Local lcValidValue, lnCharNo
>lcValidValue    = ""
>For lnCharNo = 1 to Len(tcInvalidValue)
>         If At(Substr(tcInvalidValue, lnCharNo, 1), tcValidCharSet) > 0
>                 lcValidValue = lcValidValue + Substr(tcInvalidValue, 
> lnCharNo, 1)
>         EndIf
>Next
>Return lcValidValue
>EndFunc
>
>Thanks
>
>Paul Newton



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to