Skip to main content
×
Home
    • Aa
    • Aa

Sorted: Verifying the Problem of the Dutch National Flag in Agda

  • WOUTER SWIERSTRA (a1)
Abstract

The problem of the Dutch national flag was formulated by Dijkstra (1976) as follows:

There is a row of buckets numbered from 1 to n. It is given that: P1:

each bucket contains one pebble

P2:

each pebble is either red, white, or blue.

A minicomputer is placed in front of this row of buckets and has to be programmed in such a way that it will rearrange (if necessary) the pebbles in the order of the Dutch national flag.

The minicomputer in question should perform this rearrangement using two commands:

swapi j for 1≤in and 1≤jn exchanges the pebbles stored in the buckets numbered i and j;

read (i) for 1≤in returns the colour of the pebble currently lying in bucket number i. Dijkstra originally named this operation buck.

Copyright
Linked references
Hide All

This list contains references from the content that can be linked to their source. For a full set of references and notes please see the PDF or HTML where available.

A. Bove & V. Capretta (2005) Modelling general recursion in type theory. Math. Struct. Comput. Sci. 15 (4), 671708.

A. Bove & P. Dybjer (2009) Dependent types at work. In Language Engineering and Rigorous Software Development, A. Bove , L. Barbosa , A. Pardo & J. Pinto (eds), Lecture Notes in Computer Science, vol. 5520. Springer, pp. 5799.

C. McBride & J. McKinna (2004) The view from the left. J. Funct. Program. 14 (1), 69111.

Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×
Type Description Title
UNKNOWN
Supplementary Materials

Swierstra Supplementary Materials
Swierstra Supplementary Materials

 Unknown (5 KB)
5 KB

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 11 *
Loading metrics...

Abstract views

Total abstract views: 57 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 24th May 2017. This data will be updated every 24 hours.