-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: SidonieBouthors <[email protected]> Co-authored-by: Mai-LinhC <[email protected]>
- Loading branch information
1 parent
ed8082e
commit f657ddb
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
frontends/benchmarks/extraction/valid/PatternAlternative1 copy.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
object PatternAlternative1 { | ||
sealed trait SignSet | ||
case object None extends SignSet | ||
case object Any extends SignSet | ||
case object Neg extends SignSet | ||
case object Zer extends SignSet | ||
case object Pos extends SignSet | ||
case object NegZer extends SignSet | ||
case object NotZer extends SignSet | ||
case object PosZer extends SignSet | ||
|
||
def subsetOf(a: SignSet, b: SignSet): Boolean = (a, b) match { | ||
case (None, _) => true | ||
case (_, Any) => true | ||
case (Neg, NegZer | NotZer) => true | ||
case (Zer, NegZer | PosZer) => true | ||
case (Pos, NotZer | PosZer) => true | ||
case _ => false | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
frontends/benchmarks/extraction/valid/PatternAlternative2.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
object PatternAlternative2 { | ||
sealed trait Tree | ||
case class Node(left: Tree, right: Tree) extends Tree | ||
case class IntLeaf(value: Int) extends Tree | ||
case class StringLeaf(value: String) extends Tree | ||
case class NoneLeaf() extends Tree | ||
|
||
def containsNoneLeaf(tree: Tree): Boolean = { | ||
tree match { | ||
case Node(left, right) => containsNoneLeaf(left) || containsNoneLeaf(right) | ||
case NoneLeaf() => true | ||
case _ => false | ||
} | ||
} | ||
|
||
def containsOnlyBinaryLeaves(tree: Tree): Boolean = { | ||
tree match { | ||
case Node(left, right) => containsOnlyBinaryLeaves(left) && containsOnlyBinaryLeaves(right) | ||
case IntLeaf(v) => v == 0 || v == 1 | ||
case StringLeaf(v) => v == "0" || v == "1" | ||
case _ => true | ||
} | ||
} | ||
|
||
def hasBinaryLeaves(tree: Tree): Boolean = { | ||
require(!containsNoneLeaf(tree) && containsOnlyBinaryLeaves(tree)) | ||
tree match { | ||
case a @ Node(left: (IntLeaf | StringLeaf), right: (IntLeaf | StringLeaf)) => hasBinaryLeaves(left) && hasBinaryLeaves(right) | ||
case b @ (IntLeaf(0 | 1) | StringLeaf("0" | "1")) => true | ||
case _ => false | ||
} | ||
} ensuring { res => res } | ||
} |
33 changes: 33 additions & 0 deletions
33
frontends/benchmarks/verification/valid/PatternAlternative.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
object PatternAlternative { | ||
sealed trait Tree | ||
case class Node(left: Tree, right: Tree) extends Tree | ||
case class IntLeaf(value: Int) extends Tree | ||
case class StringLeaf(value: String) extends Tree | ||
case class NoneLeaf() extends Tree | ||
|
||
def containsNoneLeaf(tree: Tree): Boolean = { | ||
tree match { | ||
case Node(left, right) => containsNoneLeaf(left) || containsNoneLeaf(right) | ||
case NoneLeaf() => true | ||
case _ => false | ||
} | ||
} | ||
|
||
def containsOnlyBinaryLeaves(tree: Tree): Boolean = { | ||
tree match { | ||
case Node(left, right) => containsOnlyBinaryLeaves(left) && containsOnlyBinaryLeaves(right) | ||
case IntLeaf(v) => v == 0 || v == 1 | ||
case StringLeaf(v) => v == "0" || v == "1" | ||
case _ => true | ||
} | ||
} | ||
|
||
def hasBinaryLeaves(tree: Tree): Boolean = { | ||
require(!containsNoneLeaf(tree) && containsOnlyBinaryLeaves(tree)) | ||
tree match { | ||
case a @ Node(left: (IntLeaf | StringLeaf), right: (IntLeaf | StringLeaf)) => hasBinaryLeaves(left) && hasBinaryLeaves(right) | ||
case b @ (IntLeaf(0 | 1) | StringLeaf("0" | "1")) => true | ||
case _ => false | ||
} | ||
} ensuring { res => res } | ||
} |