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
270dad44
Commit
270dad44
authored
9 years ago
by
Viktor Kuncak
Browse files
Options
Downloads
Patches
Plain Diff
doc tutorial: Minor formating and extra versions of synthesis problems
parent
ffce1c47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testcases/web/demos/00_Tutorial.scala
+18
-9
18 additions, 9 deletions
testcases/web/demos/00_Tutorial.scala
with
18 additions
and
9 deletions
testcases/web/demos/00_Tutorial.scala
+
18
−
9
View file @
270dad44
...
...
@@ -70,10 +70,19 @@ def max(x: Int, y: Int): Int = {
}
*/
/*
def sort2(x : BigInt, y : BigInt) = {
???[(BigInt, BigInt)]
} ensuring{(res: (BigInt,BigInt)) =>
Set(x,y) == Set(res._1, res._2) && res._1 <= res._2
}
*/
// def testSort2 = sort2(30, 4)
/*
def sort2(x
: BigInt, y
: BigInt) = choose{(res: (BigInt,BigInt)) =>
def sort2(x: BigInt, y: BigInt) = choose{(res: (BigInt,BigInt)) =>
sort2spec(x,y,res)
}
...
...
@@ -90,14 +99,14 @@ def max(x: Int, y: Int): Int = {
*/
/*
def sort3spec(x: BigInt, y: BigInt, z: BigInt, res: (BigInt,
BigInt,
BigInt)): Boolean = {
def sort3spec(x: BigInt, y: BigInt, z: BigInt, res: (BigInt,BigInt,BigInt)): Boolean = {
Set(x,y,z) == Set(res._1, res._2, res._3) &&
res._1 <= res._2 && res._2 <= res._3
}
def unique3(x: BigInt, y: BigInt, z: BigInt,
res1: (BigInt,
BigInt,
BigInt),
res2: (BigInt,
BigInt,
BigInt)): Boolean = {
res1: (BigInt,BigInt,BigInt),
res2: (BigInt,BigInt,BigInt)): Boolean = {
require(sort3spec(x,y,z,res1) && sort3spec(x,y,z,res2))
res1 == res2
}.holds
...
...
@@ -112,7 +121,7 @@ def max(x: Int, y: Int): Int = {
case object Nil extends List
case class Cons(head: BigInt, tail: List) extends List
def size(l: List)
: BigInt = (l match {
def size(l: List): BigInt = (l match {
case Nil => 0
case Cons(x, rest) => x + size(rest)
})
...
...
@@ -129,7 +138,7 @@ def max(x: Int, y: Int): Int = {
*/
/*
def isSorted(l
: List)
: Boolean = l match {
def isSorted(l: List): Boolean = l match {
case Nil => true
case Cons(_,Nil) => true
case Cons(x1, Cons(x2, rest)) =>
...
...
@@ -140,7 +149,7 @@ def max(x: Int, y: Int): Int = {
//def t2 = isSorted(Cons(15, Cons(15, Nil)))
/*
def sInsert(x
: BigInt, l
: List)
: List = {
def sInsert(x: BigInt, l: List): List = {
require(isSorted(l))
l match {
case Nil => Cons(x, Nil)
...
...
@@ -166,7 +175,7 @@ def max(x: Int, y: Int): Int = {
//def m = insertMagic(17, Cons(10, Cons(15, Cons(20, Nil))))
/*
def sortMagic(l
: List) = {
def sortMagic(l: List) = {
???[List]
} ensuring((res:List) =>
isSorted(res) && content(res) == content(l))
...
...
@@ -175,7 +184,7 @@ def max(x: Int, y: Int): Int = {
// def mm = sortMagic(Cons(20, Cons(5, Cons(50, Cons(2, Nil)))))
/*
def sInsert(x
: BigInt, l
: List)
: List = {
def sInsert(x: BigInt, l: List): List = {
require(isSorted(l))
l match {
case Nil => Cons(x, Nil)
...
...
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