-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leiqi concrete simulator #260
base: master
Are you sure you want to change the base?
Conversation
a816b70
to
d8c1f73
Compare
add autotester fix up bugs
add setup sbt
95353a9
to
6cd8952
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I have some questions about the comments that have been left in, and specifically what is a ConcreteUndef, and when do we encounter this.
Also, please add tests for
- all configuration options of the simulator
- testing violated assertions
- testing assumptions
- printing the trace
var varMap: scala.collection.mutable.Map[Identifier, ConcreteValue] = collection.mutable.Map(); | ||
var varTypeMap: scala.collection.mutable.Map[Identifier, Type] = collection.mutable.Map(); | ||
//var functionMap: scala.collection.mutable.Map[Identifier, ConcreteValue] = collection.mutable.Map(); | ||
var inputMap: scala.collection.mutable.Map[Identifier, ConcreteValue] = collection.mutable.Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the functionMap no longer needed? If so, can you delete this commented out line please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was in the todo list. So, I left the function Map here.
sealed abstract class ConcreteValue{ | ||
def valueClone: ConcreteValue; | ||
} | ||
case class ConcreteUndef () extends ConcreteValue{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is an Undef? Could you add a comment above this saying what it is? (The others are all obvious)
|
||
object ConcreteSimulator { | ||
//debug useful flag | ||
var isPrintResult: Boolean = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug printing should go via a logger (see the logger in symbolic simulator:
val defaultLog = Logger(classOf[SymbolicSimulator]) |
defaultLog.debug("eqStates: {}", eqStates.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you can use UclidMain.printError, UclidMain.printStatus etc
def write (variable: Identifier, value: ConcreteValue) { | ||
if (varMap.contains(variable)) varMap(variable) = value | ||
else if (inputMap.contains(variable)) inputMap(variable) = value | ||
// else throw new Error(f"Variable ${variable.toString} not found in context") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we still be throwing this error?
} | ||
// TODO: ... fill in | ||
case ArrayType(inType, outType) => { | ||
// TODO: outType could be complex type like another array or record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this TODO still relevant? If not, can you delete it
new smt.SynthLibInterface(config.synthesizer, config.sygusFormat) | ||
val isConcrete = config.simulate && module.cmds.exists(p => p.name.toString == "concrete") | ||
if (isConcrete) { | ||
UclidMain.printVerbose("Begining Concrete Simulation") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: Beginning
property jump_a: a!=3; | ||
|
||
control { | ||
v = bmc(5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test does bmc, not concrete
@@ -113,6 +114,10 @@ object UclidMain { | |||
(exec, c) => c.copy(synthesizer = exec.split(" ").toList) | |||
}.text("Command line to invoke SyGuS synthesizer.") | |||
|
|||
opt[String]('c', "simulate").valueName("<Cmd>").action{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to use this, we have to use simulate and the command "concrete" in the control block? What happens if i use simulate without the command "concrete" in the control block?
control { | ||
v = concrete (5); | ||
check; | ||
// v.print_concrete_trace(a,numbers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none of your tests actually run print_concrete_trace.
ConcreteSpec.expectedFails("./test/concrete/concrete-9.ucl", 1) | ||
} | ||
"concrete-10.ucl" should "fail one assertion." in { | ||
ConcreteSpec.expectedFails("./test/concrete/concrete-10.ucl", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test that prints the concrete trace, and checks the length of it at least (there are some tests in VerifierSpec that do this that you can copy).
Also make sure at least one test runs each of the configuration options
Also, test what should happen if an assertion is violated by the concrete trace
And test that assumptions block the concrete values correctly
This pull request will merge the concrete engine into the master respority.
The code does not change the main work flow of the Uclid5.
When "-c" is called, we will run concrete Simulator to simulate the uclid file.
There is still lots of util to be supported , but a early version will be helpful for testing.