by mentalgear · 1mo ago · 0 comments
Verification: Code does what it says.
Validation: Code does what Specifications say.
Specifications: Were hopefully correctly modeled to the Problem.
In IEEE terms:
> Verification: "Are we building the product right?" > Validation: "Are we building the right product?")
You can write mathematically flawless code that highly efficiently solves the wrong problem.
---
While I think formal verification is the future (essential for cybersecurity), it's not a silver bullet for the other 2 items, which are way more ambiguous. I think however they can all iterate on each other and improve the project overall, but it still depends on competent steering
If you have had experiences with good approaches for verification Validation & Specification framework, do let us know about them.
Verification: code does what the specifications say
Validation: specifications describe something we wanted to build
where with formal verification, the specifications are lower-level, so validation is extra-important.I.e. a field in a government form for residence permit might validate if the date entered is between the applicant's arrival date and three months later. And screw the applicant who wanted to apply for the permit before they landed in the country (this is a not invented example).
Also, since I worked in "software validation", I feel like it's important to note that the dictionary definition is different from practice. For the most part, the task of validation is the one that should culminate in the testers OK'ing the shipment of the product. Typically, testers, as well as the rest of the company involved in the shipping, are painfully aware that the product doesn't meet the customer's requirements (or any formal or informal requirements). It is simply declared "valid" because the potential damage is assessed to be manageable. I.e. a product may as well be declared "valid" while having a list of "known defects".
> independent verification & validation (IV&V)
> A comprehensive review, analysis, and testing, (software and/or hardware) performed by an objective third party to confirm (i.e., verify) that the requirements are correctly defined, and to confirm (i.e., validate) that the system correctly implements the required functionality and security requirements.
In my experience it's more common to use "verify" for the lower-level "conforms to specs" and "validate" for the higher level "are the specs right" but in other areas it might be different.
In other fields (I'm more familiar with medicine), there are "bibles" that serve as a medium or the source of common language between professionals. If you are talking about radiology, then you open Basic Radiology by Chen, Pope and Ott on the designated page, and read the definition. And you know that another radiologist will do the same, and so you both have the same reference point.
In programming, even the basic stuff like variables, functions, types etc. aren't defined universally. Plenty of local environments will offer conflicting definitions (and often the definitions themselves are internally inconsistent).
Unfortunately, bodies like Wikipedia cannot serve as an authoritative source on such questions because instead they record the current state of events. They can't choose which definition to follow if there's no authority respected by the vast majority of programmers.
Specifications don't need to be lower-level. They also compose nicely. Ie you can figure out how to formally specify a 'this doesn't crash' requirement once, and then re-use it on all your projects.
Isn't this the exact opposite of what "formal verification" means? First sentence on Wikipedia [1]: "Formal verification is the act of proving or disproving the correctness of a system with respect to a certain formal specification or property."
In formal verification, "the specification" means the encoded claims that will be proved, i.e., the lemmas and theorems to which the proofs directly correspond. When we use proof assistant languages (e.g., Rocq, Lean) to accomplish the verification, this means the specification is given as a type.
I think this is not what the parent comment had meant by "specification"; it seemed to me that they meant that word to refer to the human-accessible document that states what the program ought to do.
The translation of an informal (human-readable) specification into a formal specification is not always straightforward, often due to issues on either (or both) end(s) of the process. You can write Rocq code that type-checks and thus "is verified" in the sense that the type-checked code conforms to the formal specification, but if the claims you proved are not what you had intended to claim, then that verification is not very helpful.
So that is where the parent comment introduces "validation" to mean (in my words) the process of ensuring that your formal specification matches the informal specification, such that any formal verification that occurs is useful and meaningful.
- Verification: Are we building the product right?
- Validation: Are we building the right product?
My intuition was different. To me verification is a process while validation is that the outcome of that process. As in: to validate the "+" operator, you verify that 1+2=3.
Looking at the Wikipedia article https://en.wikipedia.org/wiki/Verification_and_validation the definitions are not very clear and seem to depend on the context, tough the general idea is that of the LLM answer.
Funnily enough, the https://en.wikipedia.org/wiki/Engineering_validation_test Wikipedia article is introduced with "An engineering verification test (EVT)..."
It seems to be the kind of thing where everyone has a different idea and they are often conflated, making the distinction almost meaningless without context. You can give a precise definition for your project, but it may not apply elsewhere.
Note about using LLMs: I often like to use LLMs to settle these questions. Not because LLMs are flawless, far from it, but because they work by generalizing the content of their training dataset, they should do a pretty good job on extracting consensus. It fact, it is all they do; when a LLM tells the truth, as it is often the case, it is because the consensus is often the truth.
AI verification: AI meticulously abuses all available loopholes to deliver answer expected by operator, rather than actually responding to the problem.
Simplest example: proof that `x+1 > x` (borderline impossible)
The description was most likely given in a natural language, with many assumptions about the shared objective reality.
Today, we have LLMs, which de facto (but with significant flaws) formalize the interpretation of natural language, as well as the shared objective reality we inhabit. They are becoming closer to the truth than any individual human. (Their construction is a wittgensteinian program of sorts.)
So we can take an LLM with the prompt "Respond according to the following specification:" plus the original specification/requirement, in natural language, itself, as a program A.
Then we can take the written program itself, together with the emulator of the machine it runs on, as a program B.
We can feed both of these into some theorem prover - and formally prove that program A and program B give identical outputs on identical inputs. That's most likely the best we can do, ever.
(Or we can, in theory, develop programs this way, as a solution to the following question: Which program, when run on the given platform, gives provably identical answers to program A? That's a general program synthesis problem.)