diff --git a/src/main/scala/leon/repair/rules/Focus.scala b/src/main/scala/leon/repair/rules/Focus.scala index e1f2f0cbd3b994a127425bfe1b3e9da17ee9ec3d..99a248d708367fcc0f68ba7dfe1bb1bd7816289a 100644 --- a/src/main/scala/leon/repair/rules/Focus.scala +++ b/src/main/scala/leon/repair/rules/Focus.scala @@ -165,7 +165,7 @@ case object Focus extends PreprocessingRule("Focus") { } val eb3 = if (vars.nonEmpty) { - eb2.mapIns(ebF) + eb2.flatMapIns(ebF) } else { eb2.eb } @@ -243,7 +243,7 @@ case object Focus extends PreprocessingRule("Focus") { }.toList } - val np = Problem(p.as, ws(body), p.pc withBinding (id -> value), p.phi, p.xs, qeb.mapIns(ebF)) + val np = Problem(p.as, ws(body), p.pc withBinding (id -> value), p.phi, p.xs, qeb.flatMapIns(ebF)) Some(decomp(List(np), termWrap(Let(id, value, _)), s"Focus on let-body")(p)) diff --git a/src/main/scala/leon/synthesis/ExamplesBank.scala b/src/main/scala/leon/synthesis/ExamplesBank.scala index e8d831a5c60f86c02e6faa3c7f7def2d766e8220..ad75eaace4937ec1403e5523f176489717b7a20b 100644 --- a/src/main/scala/leon/synthesis/ExamplesBank.scala +++ b/src/main/scala/leon/synthesis/ExamplesBank.scala @@ -76,7 +76,7 @@ case class ExamplesBank(valids: Seq[Example], invalids: Seq[Example]) { } /** Expands each input example through the function f */ - def mapIns(f: Seq[Expr] => List[Seq[Expr]]) = { + def flatMapIns(f: Seq[Expr] => List[Seq[Expr]]) = { map { case InExample(in) => f(in).map(InExample) @@ -87,7 +87,7 @@ case class ExamplesBank(valids: Seq[Example], invalids: Seq[Example]) { } /** Expands each output example through the function f */ - def mapOuts(f: Seq[Expr] => List[Seq[Expr]]) = { + def flatMapOuts(f: Seq[Expr] => List[Seq[Expr]]) = { map { case InOutExample(in, out) => f(out).map(InOutExample(in, _)) @@ -174,14 +174,14 @@ case class QualifiedExamplesBank(as: List[Identifier], xs: List[Identifier], eb: val nxs = xs.filterNot(toRemove) val toKeep = xs.zipWithIndex.filterNot(x => toRemove(x._1)).map(_._2) - QualifiedExamplesBank(as, nxs, eb mapOuts { out => List(toKeep.map(out)) }) + QualifiedExamplesBank(as, nxs, eb flatMapOuts { out => List(toKeep.map(out)) }) } def removeIns(toRemove: Set[Identifier]) = { val nas = as.filterNot(toRemove) val toKeep: List[Int] = as.zipWithIndex.filterNot(a => toRemove(a._1)).map(_._2) - QualifiedExamplesBank(nas, xs, eb mapIns { (in: Seq[Expr]) => List(toKeep.map(in)) }) + QualifiedExamplesBank(nas, xs, eb flatMapIns { (in: Seq[Expr]) => List(toKeep.map(in)) }) } /** Filter inputs through expr which is an expression evaluating to a boolean */ @@ -192,7 +192,7 @@ case class QualifiedExamplesBank(as: List[Identifier], xs: List[Identifier], eb: /** Filters inputs through the predicate pred, with an assignment of input variables to expressions. */ def filterIns(pred: Map[Identifier, Expr] => Boolean): QualifiedExamplesBank = { QualifiedExamplesBank(as, xs, - eb mapIns { in => + eb flatMapIns { in => val m = (as zip in).toMap if(pred(m)) { List(in) diff --git a/src/main/scala/leon/synthesis/rules/IndependentSplit.scala b/src/main/scala/leon/synthesis/rules/IndependentSplit.scala index 41d4c24b299a0fc9936c8dd0762bbd8131c9854c..6c7c0904108a4ef9137a6b14419ce90492300ab5 100644 --- a/src/main/scala/leon/synthesis/rules/IndependentSplit.scala +++ b/src/main/scala/leon/synthesis/rules/IndependentSplit.scala @@ -53,7 +53,7 @@ case object IndependentSplit extends NormalizingRule("IndependentSplit") { val newOuts = subOuts.flatten - val newEb = p.qeb.eb.mapOuts{ xs => List( (xs zip p.xs) flatMap { + val newEb = p.qeb.eb.flatMapOuts{ xs => List( (xs zip p.xs) flatMap { case (CaseClass(_, args), id) if isDecomposable(id) => args.toList case (Tuple(args), _) => args.toList case (other, _) => List(other)