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
8be4f5cc
Commit
8be4f5cc
authored
9 years ago
by
Ravi
Browse files
Options
Downloads
Patches
Plain Diff
Supporting generics in Orb
parent
12f6330e
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
run-benchs.sh
+1
-0
1 addition, 0 deletions
run-benchs.sh
src/main/scala/leon/invariant/engine/RefinementEngine.scala
+26
-15
26 additions, 15 deletions
src/main/scala/leon/invariant/engine/RefinementEngine.scala
with
27 additions
and
15 deletions
run-benchs.sh
+
1
−
0
View file @
8be4f5cc
...
@@ -7,3 +7,4 @@
...
@@ -7,3 +7,4 @@
./leon
--lazy
./testcases/lazy-datastructures/conc/Conqueue.scala
--unfoldFactor
=
3 |
tee
Conqueue.out
./leon
--lazy
./testcases/lazy-datastructures/conc/Conqueue.scala
--unfoldFactor
=
3 |
tee
Conqueue.out
./leon
--lazy
./testcases/lazy-datastructures/memoization/Knapsack.scala |
tee
Knapsack.out
./leon
--lazy
./testcases/lazy-datastructures/memoization/Knapsack.scala |
tee
Knapsack.out
./leon
--lazy
./testcases/lazy-datastructures/memoization/PackratParsing.scala |
tee
Packrat.out
./leon
--lazy
./testcases/lazy-datastructures/memoization/PackratParsing.scala |
tee
Packrat.out
./leon
--lazy
./testcases/lazy-datastructures/memoization/WeightedScheduling.scala |
tee
Sched.out
This diff is collapsed.
Click to expand it.
src/main/scala/leon/invariant/engine/RefinementEngine.scala
+
26
−
15
View file @
8be4f5cc
...
@@ -5,6 +5,7 @@ import purescala.Common._
...
@@ -5,6 +5,7 @@ import purescala.Common._
import
purescala.Definitions._
import
purescala.Definitions._
import
purescala.Expressions._
import
purescala.Expressions._
import
purescala.ExprOps._
import
purescala.ExprOps._
import
purescala.TypeOps._
import
purescala.Extractors._
import
purescala.Extractors._
import
purescala.Types._
import
purescala.Types._
import
java.io._
import
java.io._
...
@@ -142,28 +143,35 @@ class RefinementEngine(ctx: InferenceContext, prog: Program, ctrTracker: Constra
...
@@ -142,28 +143,35 @@ class RefinementEngine(ctx: InferenceContext, prog: Program, ctrTracker: Constra
val
recFun
=
fi
.
tfd
.
fd
val
recFun
=
fi
.
tfd
.
fd
val
recFunTyped
=
fi
.
tfd
val
recFunTyped
=
fi
.
tfd
//check if we need to create a
constraint tree
for the call's target
//check if we need to create a
VC formula
for the call's target
if
(
shouldCreateVC
(
recFun
))
{
if
(
shouldCreateVC
(
recFun
))
{
//create a new verification condition for this recursive function
reporter
.
info
(
"Creating VC for "
+
recFun
.
id
)
reporter
.
info
(
"Creating VC for "
+
recFun
.
id
)
val
freshBody
=
freshenLocals
(
matchToIfThenElse
(
recFun
.
body
.
get
))
// instantiate the body with new types
val
tparamMap
=
(
recFun
.
tparams
zip
recFunTyped
.
tps
).
toMap
val
paramMap
=
recFun
.
params
.
map
{
pdef
=>
pdef
.
id
->
FreshIdentifier
(
pdef
.
id
.
name
,
instantiateType
(
pdef
.
id
.
getType
,
tparamMap
))
}.
toMap
val
newbody
=
freshenLocals
(
matchToIfThenElse
(
recFun
.
body
.
get
))
val
freshBody
=
instantiateType
(
newbody
,
tparamMap
,
paramMap
)
val
resvar
=
if
(
recFun
.
hasPostcondition
)
{
val
resvar
=
if
(
recFun
.
hasPostcondition
)
{
//create a new result variable here for the same reason as freshening the locals,
//create a new result variable here for the same reason as freshening the locals,
//which is to avoid variable capturing during unrolling
//which is to avoid variable capturing during unrolling
val
origRes
=
getResId
(
recFun
).
get
val
origRes
=
getResId
(
recFun
).
get
Variable
(
FreshIdentifier
(
origRes
.
name
,
origRes
.
get
Type
,
true
))
Variable
(
FreshIdentifier
(
origRes
.
name
,
recFunTyped
.
return
Type
,
true
))
}
else
{
}
else
{
//create a new resvar
//create a new resvar
Variable
(
FreshIdentifier
(
"res"
,
recFun
.
returnType
,
true
))
Variable
(
FreshIdentifier
(
"res"
,
recFun
Typed
.
returnType
,
true
))
}
}
val
plainBody
=
Equals
(
resvar
,
freshBody
)
val
plainBody
=
Equals
(
resvar
,
freshBody
)
val
bodyExpr
=
if
(
recFun
.
hasPrecondition
)
{
val
bodyExpr
=
And
(
matchToIfThenElse
(
recFun
.
precondition
.
get
),
plainBody
)
if
(
recFun
.
hasPrecondition
)
{
}
else
plainBody
val
pre
=
instantiateType
(
matchToIfThenElse
(
recFun
.
precondition
.
get
),
tparamMap
,
paramMap
)
And
(
pre
,
plainBody
)
//note: here we are only adding the template as the postcondition
}
else
plainBody
val
idmap
=
formalToActual
(
Call
(
resvar
,
FunctionInvocation
(
recFunTyped
,
recFun
.
params
.
map
(
_
.
toVariable
))))
//note: here we are only adding the template as the postcondition (other post need not be proved again)
val
idmap
=
formalToActual
(
Call
(
resvar
,
FunctionInvocation
(
recFunTyped
,
paramMap
.
values
.
toSeq
.
map
(
_
.
toVariable
))))
val
postTemp
=
replace
(
idmap
,
recFun
.
getTemplate
)
val
postTemp
=
replace
(
idmap
,
recFun
.
getTemplate
)
val
vcExpr
=
ExpressionTransformer
.
normalizeExpr
(
And
(
bodyExpr
,
Not
(
postTemp
)),
ctx
.
multOp
)
val
vcExpr
=
ExpressionTransformer
.
normalizeExpr
(
And
(
bodyExpr
,
Not
(
postTemp
)),
ctx
.
multOp
)
ctrTracker
.
addVC
(
recFun
,
vcExpr
)
ctrTracker
.
addVC
(
recFun
,
vcExpr
)
...
@@ -182,10 +190,13 @@ class RefinementEngine(ctx: InferenceContext, prog: Program, ctrTracker: Constra
...
@@ -182,10 +190,13 @@ class RefinementEngine(ctx: InferenceContext, prog: Program, ctrTracker: Constra
def
inilineCall
(
call
:
Call
,
formula
:
Formula
)
=
{
def
inilineCall
(
call
:
Call
,
formula
:
Formula
)
=
{
//here inline the body and conjoin it with the guard
//here inline the body and conjoin it with the guard
val
callee
=
call
.
fi
.
tfd
.
fd
val
tfd
=
call
.
fi
.
tfd
val
callee
=
tfd
.
fd
//Important: make sure we use a fresh body expression here
//Important: make sure we use a fresh body expression here, and freshenlocals
val
freshBody
=
freshenLocals
(
matchToIfThenElse
(
callee
.
body
.
get
))
val
tparamMap
=
(
callee
.
tparams
zip
tfd
.
tps
).
toMap
val
newbody
=
freshenLocals
(
matchToIfThenElse
(
callee
.
body
.
get
))
val
freshBody
=
instantiateType
(
newbody
,
tparamMap
,
Map
())
val
calleeSummary
=
val
calleeSummary
=
Equals
(
getFunctionReturnVariable
(
callee
),
freshBody
)
Equals
(
getFunctionReturnVariable
(
callee
),
freshBody
)
val
argmap1
=
formalToActual
(
call
)
val
argmap1
=
formalToActual
(
call
)
...
...
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