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
a454d391
Commit
a454d391
authored
10 years ago
by
Manos Koukoutos
Browse files
Options
Downloads
Patches
Plain Diff
Fix some bugs in new z3 solver
parent
8cf3422c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/leon/solvers/smtlib/SMTLIBZ3QuantifiedTarget.scala
+49
-49
49 additions, 49 deletions
.../scala/leon/solvers/smtlib/SMTLIBZ3QuantifiedTarget.scala
with
49 additions
and
49 deletions
src/main/scala/leon/solvers/smtlib/SMTLIBZ3QuantifiedTarget.scala
+
49
−
49
View file @
a454d391
...
...
@@ -3,9 +3,10 @@ package leon.solvers.smtlib
import
leon.purescala.DefOps._
import
leon.purescala.Definitions.TypedFunDef
import
leon.purescala.ExprOps._
import
leon.purescala.Expressions.
{
Equals
,
FunctionInvocation
}
import
leon.purescala.Expressions._
import
leon.purescala.Constructors._
import
smtlib.parser.Commands.
{
DeclareFun
,
Assert
}
import
smtlib.parser.Terms.
{
Term
,
SortedVar
,
SSymbol
,
ForAl
l
}
import
smtlib.parser.Terms.
{
ForAll
=>
SMTForall
,
SSymbo
l
}
/**
* This solver models function definitions as universally quantified formulas.
...
...
@@ -20,57 +21,56 @@ trait SMTLIBZ3QuantifiedTarget extends SMTLIBZ3Target {
override
def
targetName
=
"z3-quantified"
override
def
declareFunction
(
tfd
:
TypedFunDef
)
:
SSymbol
=
{
if
(
tfd
.
params
.
isEmpty
)
{
super
[
SMTLIBZ3Target
].
declareFunction
(
tfd
)
}
else
{
val
(
funs
,
exploredAll
)
=
typedTransitiveCallees
(
Set
(
tfd
),
Some
(
typedFunDefExplorationLimit
))
if
(!
exploredAll
)
{
reporter
.
warning
(
s
"Did not manage to explore the space of typed functions called from ${tfd.id}. The solver may fail"
)
}
val
smtFunDecls
=
funs
.
toSeq
.
collect
{
case
tfd
if
!
functions
.
containsA
(
tfd
)
&&
tfd
.
params
.
nonEmpty
=>
val
id
=
if
(
tfd
.
tps
.
isEmpty
)
{
tfd
.
id
}
else
{
tfd
.
id
.
freshen
}
val
sym
=
id2sym
(
id
)
functions
+=(
tfd
,
sym
)
sendCommand
(
DeclareFun
(
sym
,
tfd
.
params
map
{
p
=>
declareSort
(
p
.
getType
)
},
declareSort
(
tfd
.
returnType
)
))
sym
}
smtFunDecls
foreach
{
sym
=>
val
tfd
=
functions
.
toA
(
sym
)
val
sortedVars
=
tfd
.
params
.
map
{
p
=>
SortedVar
(
id2sym
(
p
.
id
),
declareSort
(
p
.
getType
))
}
val
term
=
if
(
sortedVars
.
isEmpty
)
{
toSMT
(
Equals
(
FunctionInvocation
(
tfd
,
Seq
()),
tfd
.
body
.
get
))(
Map
())
}
else
{
ForAll
(
sortedVars
.
head
,
sortedVars
.
tail
,
toSMT
(
Equals
(
FunctionInvocation
(
tfd
,
tfd
.
params
.
map
{
_
.
toVariable
}),
matchToIfThenElse
(
tfd
.
body
.
get
)
))(
tfd
.
params
.
map
{
p
=>
(
p
.
id
,
id2sym
(
p
.
id
)
:
Term
)
}.
toMap
)
)
val
(
funs
,
exploredAll
)
=
typedTransitiveCallees
(
Set
(
tfd
),
Some
(
typedFunDefExplorationLimit
))
if
(!
exploredAll
)
{
reporter
.
warning
(
s
"Did not manage to explore the space of typed functions called from ${tfd.id}. The solver may fail"
)
}
val
smtFunDecls
=
funs
.
toSeq
.
collect
{
case
tfd
if
!
functions
.
containsA
(
tfd
)
=>
val
id
=
if
(
tfd
.
tps
.
isEmpty
)
{
tfd
.
id
}
else
{
tfd
.
id
.
freshen
}
sendCommand
(
Assert
(
term
))
}
val
sym
=
id2sym
(
id
)
functions
+=(
tfd
,
sym
)
sendCommand
(
DeclareFun
(
sym
,
tfd
.
params
map
{
p
=>
declareSort
(
p
.
getType
)
},
declareSort
(
tfd
.
returnType
)
))
sym
}
smtFunDecls
foreach
{
sym
=>
val
tfd
=
functions
.
toA
(
sym
)
val
term
=
quantifiedTerm
(
SMTForall
,
tfd
.
params
map
{
_
.
id
},
matchToIfThenElse
(
Equals
(
FunctionInvocation
(
tfd
,
tfd
.
params
.
map
{
_
.
toVariable
}),
matchToIfThenElse
(
tfd
.
body
.
get
)
))
)
sendCommand
(
Assert
(
term
))
functions
.
toB
(
tfd
)
tfd
.
postcondition
foreach
{
post
=>
val
axiom
=
matchToIfThenElse
(
implies
(
tfd
.
precondition
getOrElse
BooleanLiteral
(
true
),
application
(
post
,
Seq
(
FunctionInvocation
(
tfd
,
tfd
.
params
map
{
_
.
toVariable
}))
)
))
sendCommand
(
Assert
(
quantifiedTerm
(
SMTForall
,
axiom
)))
}
}
functions
.
toB
(
tfd
)
}
}
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