1 · Curtain Up
How do I run a program, and what does proving it mean?
The theatre is ready. The curtain is ready. Puck, our stage manager, has put on a cravat large enough to qualify as scenery. For the first rehearsal, he wants the machine to say one line on cue. We'll write the program that supplies the line.
Before you begin. You'll need a working veradic installation and an ordinary text editor. The installation guide has the setup instructions.
Verada can check a program's shape and types, prove its safety checks and written promises, and turn it into running machine code. We'll meet those jobs separately as Puck rehearses his cue.
“Excellent rehearsal,” said Puck. “Next time, dialogue.”
One line on stage
Create an empty folder for your chosen version. Save the file below as main.vadb, main.va, or main.vb. Choose one panel; the prose after the panels belongs to everyone.
Predict first: what exact line will this program print? Does the source's punctuation become part of the output?
Example 1-1 · A first entrance
Vada · Ada · Example 1-1
main.vadb · Link to this version
with Ada.Text_IO;
procedure Main is
begin
Ada.Text_IO.Put_Line ("The play's the thing.");
end Main;
Varc · C-family · Example 1-1
main.va · Link to this version
import Ada.Text_IO;
fn Main() {
Ada.Text_IO.Put_Line("The play's the thing.");
}
Vibe · Python · Example 1-1
main.vb · Link to this version
def main() -> None:
print("The play's the thing.")
if __name__ == "__main__":
main()Syntax note: Vada and Varc use Ada.Text_IO.Put_Line, a library operation that prints text and ends the line. Vibe uses print. Three spellings, one line on stage. Whichever costume you choose, Verada applies the same checks: braces and indentation are not a way round them.
The quoted text is a string literal: text we have written directly into the program. The outer quotes mark its beginning and end. They are not printed. The apostrophe in play's is an ordinary character inside those double quotes.
The enclosing Main or main is the entry point, where this program starts. Its body contains one statement, an instruction to do something. The imports in Vada and Varc make the printing library available. Vibe's final two lines arrange for main() to run when the file is the entry script; copy that little scaffold for now.
Vada's procedure, is, begin, and end mark the program's structure. Varc uses fn and braces; Vibe uses def, a colon and indentation. In Vibe, -> None says that this operation returns no result. You need to recognize this wrapper, not memorize a grammar.
Places, please. The program starts at line one, whatever Puck had in mind.
Give the cue
Open a terminal in your new folder. Use the command matching your file:
veradic run main.vadbFor Varc use veradic run main.va; for Vibe use veradic run main.vb. All three print:
The play's the thing.
Before executing the program, run checked it and proved it. Our program has little to prove, but the same routine will matter when arithmetic and contracts arrive. A successful run here means the source was accepted and that this execution printed our sentence.
A proof addresses the generated checks and the properties we actually specify. It does not read our mind. The program could solemnly print “The potato's the thing,” and Verada would have no reason to object. The machine has not attended the play.
Three useful verbs
Replace the filename below if you chose Varc or Vibe:
veradic check main.vadb
veradic prove main.vadb
veradic run main.vadbcheckreads the program for mistakes that show without running it: a misspelt name, text where a number belongs, a variable read before it has a value. It does not ask the prover about arithmetic or promises.provealso asks the prover to establish the generated safety and contract checks. It does not execute the program.runexecutes the program. Given a single file, as here, it checks and proves first.
check and run say nothing extra when all is well. prove ends with a summary, and for our one-liner it reads:
proved 0 of 0 checks in 0 subprograms (0 statically, 0 by the solver)
A perfect score on an exam with no questions. One fixed line gives Verada nothing that could overflow or break a promise. The counts grow when arithmetic arrives, and the exact numbers are never the point of an exercise: what matters is whether every check was established.
The example projects you can copy each come with a verada.toml file, which makes their folder a project. In a project, run doesn't wait for the prover. It uses the proofs prove has already recorded, and keeps any check not yet proved as a check made while the program runs, with warning B8012 to say so. So in a project the routine is prove, then run. A fourth verb, build, proves first and then writes a program you can start without veradic at all.
The pen is mightier than the bird.
Your cue
- Change the line to something a nervous stage manager might say. Predict the output, then run it.
- Add a second printing statement inside the same body. Which line comes first?
- Explain why a successful proof would not catch a misspelled word in the dialogue.
Prompter's notes · hints and answers
The text inside the quotes is yours to change. Keep both outer quotes and the statement's punctuation. Add the second instruction immediately after the first; in Vibe, keep the same indentation. Statements here run in written order.
Verada checks the obligations generated by the program and its specifications. We have not specified correct spelling or the desired sentence, so a different legal string can pass. The expected dialogue still needs a human decision or a suitably written test/specification.
You can now run a complete program and distinguish checking, proving, and executing it. Next, Puck takes the idea to the box office, where the line has to tell customers how many seats are left.