decoration decoration
Stories

GROKLAW
When you want to know more...
decoration
For layout only
Home
Archives
Site Map
Search
About Groklaw
Awards
Legal Research
Timelines
ApplevSamsung
ApplevSamsung p.2
ArchiveExplorer
Autozone
Bilski
Cases
Cast: Lawyers
Comes v. MS
Contracts/Documents
Courts
DRM
Gordon v MS
GPL
Grokdoc
HTML How To
IPI v RH
IV v. Google
Legal Docs
Lodsys
MS Litigations
MSvB&N
News Picks
Novell v. MS
Novell-MS Deal
ODF/OOXML
OOXML Appeals
OraclevGoogle
Patents
ProjectMonterey
Psystar
Quote Database
Red Hat v SCO
Salus Book
SCEA v Hotz
SCO Appeals
SCO Bankruptcy
SCO Financials
SCO Overview
SCO v IBM
SCO v Novell
SCO:Soup2Nuts
SCOsource
Sean Daly
Software Patents
Switch to Linux
Transcripts
Unix Books

Gear

Groklaw Gear

Click here to send an email to the editor of this weblog.


You won't find me on Facebook


Donate

Donate Paypal


No Legal Advice

The information on Groklaw is not intended to constitute legal advice. While Mark is a lawyer and he has asked other lawyers and law students to contribute articles, all of these articles are offered to help educate, not to provide specific legal advice. They are not your lawyers.

Here's Groklaw's comments policy.


What's New

STORIES
No new stories

COMMENTS last 48 hrs
No new comments


Sponsors

Hosting:
hosted by ibiblio

On servers donated to ibiblio by AMD.

Webmaster
Dijkstra and Formal Programming. | 484 comments | Create New Account
Comments belong to whoever posts them. Please notify us of inappropriate comments.
Dijkstra and Formal Programming.
Authored by: bprice on Thursday, September 06 2012 @ 03:44 AM EDT
Let's define two different kinds of programming: goal-directed and play. (Or call them what you will.) Play programming is addressing the question "what can I do with this?" Just like any play, it's useful for learning about whatever you're playing with.When I was a young programmer, I had a need to express the contents of a binary tree in lexicographic order. My first solution was several pages of code (24 cards per page of the coding form we used). I decided to play with it, since I was not satisfied with the solution – it was ugly. I tried several more times, learning from each try. The last solution was three lines, but elegant – nowadays, preorder traversal is standard practice, but in 1965, the utility of recursion was not readily obvious, and there were no CS classes to learn it from.

Goal-directed programming is what's usually practised, at school or at work. The practitioner is given some input (usually as specifications) and given a goal of creating some output. (My tree traversal was play, in a goal-directed environment: I had input and a specified output, but I played with how to do it.)

What a programmer addresses is:

  • What have I got?
  • What should I end up with?
  • How can I derive what I need from what I've got?

    regardless of his approach, that's his thought patterns, his analysis. He may go top-down ("how" oriented), front-to-back (input-oriented), back-to-front (output-oriented), or some other direction or no direction at all, but he breaks the problem down into smaller problems and applies the same analysis to each of the smaller problems. The recursion ends at each branch when the smaller problem is directly soluble in the requisite programming language, that is, when the smaller problem admits of a solution synthesis. (Yes, PolR, what is being synthesised is a mathematical construct, some programming in a mathematical notation [programming language]. We must never forget that.)

    So let's look at "formal programming":

    To grossly oversimplify, formal programming goes roughly as follows:
    -- Describe a set of "preconditions" -- the state at the start of program execution.
    -- Describe a set of "postconditions" -- the desired state at the end of program execution.
    -- Mathematically derive the logic to go from pre to post.
    This is a formalization of the programming process:
  • What have I got? Preconditions.
  • What should I end up with? Postconditions.
  • How can I get from here to there? Derivation.
    Now in theory, this is a very powerful way to develop software. After you finish the software you have great confidence in its correctness, which has been proven by the development process.
    In practice, it's not just "a very powerful way to develop software." It's the way that goal-directed (and some play) programming is done, in all cases. If you have done the derivations correctly, the program is as correct as the input and output specifications.
    However formal programming never really caught on, except for a few small areas. One of the main problems is the complexity of the proofs. For anything more than a trivial project, the likelihood of errors in the proof approaches 100%.
    Let's correct that for the general case, applying to all goal-directed programming: "For anything more than a trivial project, the likelihood of errors in the proof derivation approaches 100%." Thus we have Windows, Java, Flash, and all the myriad of other programming errors in the wild.

    The basis of "formal programming" is the application of sound (formal) methods of analysis and synthesis to goal-directed programming — nothing more, nothing less. This is propounded as a substitute for the informal, error-prone methods most often used.

    I prefer to look at the more productive result: when a programmer is knowledgeable about the formal basis of his methods, he is better able to use the informal methods in a formal and correct fashion, thereby to greatly reduce the errors in his work. That's the way I've used the formal methods, anyway. It's not very different from arithmetic: the more you understand the formal bases for number fiddling, the better you can become at it.

    ---
    --Bill. NAL: question the answers, especially mine.

    [ Reply to This | Parent | # ]

  • Groklaw © Copyright 2003-2013 Pamela Jones.
    All trademarks and copyrights on this page are owned by their respective owners.
    Comments are owned by the individual posters.

    PJ's articles are licensed under a Creative Commons License. ( Details )