Skip to content
Snippets Groups Projects
Commit 301ea497 authored by Viktor Kuncak's avatar Viktor Kuncak
Browse files

doc: small crosscutting changes while tutoring sort

parent 459863da
No related branches found
No related tags found
No related merge requests found
.. _cmdlineoptions: .. _cmdlineoptions:
Command Line Options Command Line
==================== ============
Here is an overview of the command-line options that Leon recognizes: Here is an overview of the command-line options that Leon recognizes:
......
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
Pure Scala Pure Scala
========== ==========
The input to Leon is a purely functional subset of Scala, The input to Leon is a purely functional **subset** of Scala
which we call **Pure Scala**. Constructs specific for Leon (http://www.scala-lang.org/), which we call
are defined inside Leon's libraries in package `leon` and **Pure Scala**. Constructs specific for Leon are defined inside
its subpackages. Leon invokes standard `scalac` compiler on Leon's libraries in package `leon` and its subpackages. Leon
the input file, then performs additional checks to ensure invokes standard `scalac` compiler on the input file, then
that the given program belongs to Pure Scala. performs additional checks to ensure that the given program
belongs to Pure Scala.
Pure Scala supports two kinds of top-level declarations: Pure Scala supports two kinds of top-level declarations:
......
...@@ -92,8 +92,8 @@ parameters, such as ...@@ -92,8 +92,8 @@ parameters, such as
def test1 = sort2(30, 4) def test1 = sort2(30, 4)
Hovering over the definition of test1 should display Hovering over `test1` should display the computed result
the computed tuple `(4,30)`. `(4,30)`. From :ref:`cmdlineoptions`, use `--eval`.
This shows that Leon's evaluator can also execute `choose` This shows that Leon's evaluator can also execute `choose`
constructs. In other words, it supports programming constructs. In other words, it supports programming
...@@ -136,16 +136,23 @@ Depending on the particular run, Leon may also produce a solution such as ...@@ -136,16 +136,23 @@ Depending on the particular run, Leon may also produce a solution such as
This code performs some unnecessary case analysis, but still This code performs some unnecessary case analysis, but still
satisfies our specification. In this case, the specification satisfies our specification. In this case, the specification
is unambiguous, so all programs that one can synthesize of the program output is unambiguous, so all programs that
compute the same results for all inputs. one can synthesize compute the same results for all inputs.
Defining Unbounded Lists Defining Lists and Their Properties
------------------------ -----------------------------------
Let us now consider sorting of any number of elements. We next consider sorting an unbounded number of elements.
For this purpose, we define the data structure of lists of For this purpose, we define a data structure for lists of
(big) integers. Leon has a built-in data type of integers. Leon has a built-in data type of parametric
polymorphic lists, see :ref:`Leon Library <library>`, but lists, see :ref:`Leon Library <library>`, but here we define
here we define our own variant. our own variant instead. We use a recursive algebraic data type
definition, expressed using Scala's **case classes**.
.. code-block:: scala
sealed abstract class List
case object Nil extends List
case class Cons(head: BigInt, tail: List) extends List
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment