Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
130487b7
Commit
130487b7
authored
9 years ago
by
Etienne Kneuss
Browse files
Options
Downloads
Patches
Plain Diff
Some intro on synthesis
parent
acb2f8d3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/conf.py
+1
-1
1 addition, 1 deletion
doc/conf.py
doc/intro.rst
+57
-0
57 additions, 0 deletions
doc/intro.rst
with
58 additions
and
1 deletion
doc/conf.py
+
1
−
1
View file @
130487b7
...
...
@@ -139,7 +139,7 @@ html_short_title = "Leon Documentation"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path
=
[
'
_static
'
]
#
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
...
...
This diff is collapsed.
Click to expand it.
doc/intro.rst
+
57
−
0
View file @
130487b7
...
...
@@ -66,6 +66,63 @@ sections :ref:`Pure Scala <purescala>` and :ref:`XLang <xlang>`.
Program Synthesis
-----------------
As seen with verification, specifications provide an alternative and more
descriptive way of caracterizing the behavior of a function.
Leon defines ways to use specifications instead of an actual implementation
within your programs:
* a ``choose`` construct that describes explicitly a value with a
specification. For instance, one could synthesize a function inserting into a
sorted list by:
.. code-block:: scala
def insert1(in: List, v: BigInt) = {
require(isSorted(in1))
choose { (out: List) =>
(content(out) == content(in1) ++ Set(v)) && isSorted(out)
}
}
* a hole (``???``) that can be placed anywhere in a specified function. Leon
will fill it with values such that the overall specification is satisfied.
This construct is especially useful when only a small part of the function
is missing.
.. code-block:: scala
def insert2(in: List, v: BigInt) = {
require(isSorted(in1))
in match {
case Cons(h, t) =>
if (h < v) {
Cons(h, in)
} else if (h == v) {
in
} else {
???[List]
}
case Nil =>
Nil
}
} ensuring { out =>
(content(out) == content(in1) ++ Set(v)) && isSorted(out)
}
Given such programs, Leon can:
1) Execute them: when the evaluator encounters a ``choose`` construct, it
solves the constraint at runtime by invoking an SMT solver. This allows some
form of constraint solving programming.
2) Attempt to translate specifications to a traditional implementation by
applying program synthesis. In our case, Leon will automatically synthesize
the hole in ``insert2`` with ``Cons(h, insert2(v, t))``. This automated
translation is described in further details in the section on :ref:`synthesis
<Synthesis>`.
Program Repair
--------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment