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
93563906
Commit
93563906
authored
9 years ago
by
Mikaël Mayer
Browse files
Options
Downloads
Patches
Plain Diff
Added ability to filter alternatives according to the previous alternatives.
parent
6bff8ded
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
src/main/scala/leon/synthesis/disambiguation/QuestionBuilder.scala
+19
-8
19 additions, 8 deletions
...scala/leon/synthesis/disambiguation/QuestionBuilder.scala
src/main/scala/leon/synthesis/rules/StringRender.scala
+1
-1
1 addition, 1 deletion
src/main/scala/leon/synthesis/rules/StringRender.scala
with
20 additions
and
9 deletions
src/main/scala/leon/synthesis/disambiguation/QuestionBuilder.scala
+
19
−
8
View file @
93563906
...
...
@@ -81,10 +81,15 @@ object QuestionBuilder {
* @param input The identifier of the unique function's input. Must be typed or the type should be defined by setArgumentType
* @param ruleApplication The set of solutions for the body of f
* @param filter A function filtering which outputs should be considered for comparison.
* It takes as input the sequence of outputs already considered for comparison, and the new output.
* It should return Some(result) if the result can be shown, and None else.
* @return An ordered
*
*/
class
QuestionBuilder
[
T
<:
Expr
](
input
:
Seq
[
Identifier
],
solutions
:
Stream
[
Solution
],
filter
:
Expr
=>
Option
[
T
])(
implicit
c
:
LeonContext
,
p
:
Program
)
{
class
QuestionBuilder
[
T
<:
Expr
](
input
:
Seq
[
Identifier
],
solutions
:
Stream
[
Solution
],
filter
:
(
Seq
[
T
],
Expr
)
=>
Option
[
T
])(
implicit
c
:
LeonContext
,
p
:
Program
)
{
import
QuestionBuilder._
private
var
_argTypes
=
input
.
map
(
_
.
getType
)
private
var
_questionSorMethod
:
QuestionSortingType
=
QuestionSortingType
.
IncreasingInputSize
...
...
@@ -132,13 +137,19 @@ class QuestionBuilder[T <: Expr](input: Seq[Identifier], solutions: Stream[Solut
val
questions
=
ListBuffer
[
Question
[
T
]]()
for
{
possible_input
<-
enumerated_inputs
current_output_nonfiltered
<-
run
(
solution
,
possible_input
)
current_output
<-
filter
(
current_output_nonfiltered
)}
{
val
alternative_outputs
=
(
for
{
alternative
<-
alternatives
alternative_output
<-
run
(
alternative
,
possible_input
)
alternative_output_filtered
<-
filter
(
alternative_output
)
if
alternative_output
!=
current_output
}
yield
alternative_output_filtered
).
distinct
current_output
<-
filter
(
Seq
(),
current_output_nonfiltered
)}
{
val
alternative_outputs
=
((
ListBuffer
[
T
](
current_output
)
/:
alternatives
)
{
(
prev
,
alternative
)
=>
run
(
alternative
,
possible_input
)
match
{
case
Some
(
alternative_output
)
if
alternative_output
!=
current_output
=>
filter
(
prev
,
alternative_output
)
match
{
case
Some
(
alternative_output_filtered
)
=>
prev
+=
alternative_output_filtered
case
_
=>
prev
}
case
_
=>
prev
}
}).
drop
(
1
).
toList
.
distinct
if
(
alternative_outputs
.
nonEmpty
||
keepEmptyAlternativeQuestions
(
current_output
))
{
questions
+=
Question
(
possible_input
.
map
(
_
.
_2
),
current_output
,
alternative_outputs
.
sortWith
((
e
,
f
)
=>
_alternativeSortMethod
.
compare
(
e
,
f
)
<=
0
))
}
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/leon/synthesis/rules/StringRender.scala
+
1
−
1
View file @
93563906
...
...
@@ -189,7 +189,7 @@ case object StringRender extends Rule("StringRender") {
/** Find ambiguities not containing _edit_me_ to ask to the user */
def
askQuestion
(
input
:
List
[
Identifier
],
r
:
RuleClosed
)(
implicit
c
:
LeonContext
,
p
:
Program
)
:
List
[
disambiguation.Question
[
StringLiteral
]]
=
{
//if !s.contains(EDIT_ME)
val
qb
=
new
disambiguation
.
QuestionBuilder
(
input
,
r
.
solutions
,
(
expr
:
Expr
)
=>
expr
match
{
val
qb
=
new
disambiguation
.
QuestionBuilder
(
input
,
r
.
solutions
,
(
seq
:
Seq
[
Expr
],
expr
:
Expr
)
=>
expr
match
{
case
s
@StringLiteral
(
slv
)
if
!
slv
.
contains
(
EDIT_ME
)
=>
Some
(
s
)
case
_
=>
None
})
...
...
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