Skip to content
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

[WIP] Use a separate Parikh Theory for handling length abstractions #46

Open
wants to merge 28 commits into
base: parikh-theory
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b7cc66f
fixed case of character classes starting with a -
pruemmer Mar 25, 2021
29bd540
optimized formula reduction; add a [+-]minimizeAutomata flag to choos…
pruemmer Mar 29, 2021
648161b
handle large strings defined using define-fun correctly
pruemmer Apr 8, 2021
6388893
error message
pruemmer Apr 19, 2021
5fffc22
removed a left-over println
pruemmer Apr 22, 2021
6a60338
support for octal escape sequences
pruemmer Apr 22, 2021
7bb9303
added missing cases
pruemmer May 6, 2021
9a1bc38
better handling of prefixof, substr
pruemmer May 10, 2021
0c5a64a
Merge branch 'master' of https://github.com/uuverifiers/ostrich
pruemmer May 10, 2021
77de50c
handling of further str.at cases
pruemmer May 10, 2021
fde80cf
add length information for some standard string functions
pruemmer May 12, 2021
989c7e6
some experimental code
pruemmer May 12, 2021
7794cf7
Create scala.yml
Jun 28, 2021
b7be8dc
Delete build.properties
Jun 28, 2021
02179c5
Update README.md
Jun 28, 2021
c33eb97
Base version (before upgrade)
amandasystems Mar 19, 2021
f1185a1
Port to scala 2.13 (with 24 warnings...)
amandasystems Mar 22, 2021
0891558
Roll back the use of the Parikh theory. This is now a clean 2.13 port.
amandasystems Mar 23, 2021
b2c5e6e
Make the SMTLib tests more verbose on failure
amandasystems Mar 23, 2021
7077ec1
Add a gitignore file
amandasystems Mar 24, 2021
6168f15
Bug: can't match against Seq for ArrayBuffer in 2.13
amandasystems Mar 24, 2021
919d59a
Add back the Parikh Theory
amandasystems Mar 23, 2021
92e6296
Slightly cleaner theory invocation (that still doesn't work)
amandasystems Mar 23, 2021
89dc003
Change the generation of length constraints to support new variant
amandasystems Mar 24, 2021
9ae315f
More adaptations for the new parikh theory
amandasystems Jun 24, 2021
9148260
Hack in support for labels
amandasystems Jul 1, 2021
8c0cfa2
Fix the latest upstream delta for Scala 2.13
amandasystems Jul 1, 2021
3787229
Fix compatibility issues, finish integrating into parikh theory
amandasystems Jul 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Scala CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Run tests
run: sbt test
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/target
.bloop
/.bsp
/.metals
.DS_Store
/project/project
/project/target
3 changes: 3 additions & 0 deletions .sbtconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SBT_OPTS="-Xms4G -Xmx4G -Xss2M
-XX:+CMSClassUnloadingEnabled
-XX:MaxPermSize=4G"
6 changes: 6 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
maxColumn = 80
version=2.2.1
project.git = true
docstrings = "JavaDoc"
# rewrite.rules = [SortImports]
spaces.beforeContextBoundColon=Always
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "scala",
"request": "launch",
"name": "Run tests",
"testClass": "ostrich.APITest",
"buildTarget": "root"
},
{
"type": "scala",
"name": "Debug ostrich.OstrichMain",
"request": "launch",
"mainClass": "ostrich.OstrichMain",
"buildTarget": "root",
"args": ["+quiet", "-stringSolver=ostrich.OstrichStringTheory:+eager", "tests/concat-regex.smt2"]
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.watcherExclude": {
"**/target": true
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OSTRICH [![Build Status](https://travis-ci.org/uuverifiers/ostrich.svg?branch=master)](https://travis-ci.org/uuverifiers/ostrich)
# OSTRICH
## An SMT Solver for String Constraints

OSTRICH is an SMT solver for string constraints.
Expand Down
47 changes: 30 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,36 @@ lazy val commonSettings = Seq(
name := "ostrich",
organization := "uuverifiers",
version := "1.0",
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12", "2.12.10"),
publishTo := Some(Resolver.file("file", new File( "/home/wv/public_html/maven/" )) ),
scalacOptions += "-deprecation",
resolvers += ("uuverifiers" at "http://logicrunch.research.it.uu.se/maven/").withAllowInsecureProtocol(true),
libraryDependencies += "uuverifiers" %% "princess" % "nightly-SNAPSHOT",
libraryDependencies += "uuverifiers" % "ecma2020-regex-parser" % "0.4-SNAPSHOT",
libraryDependencies += "org.sat4j" % "org.sat4j.core" % "2.3.1",
scalaVersion := "2.13.5",
publishTo := Some(
Resolver.file("file", new File("/home/wv/public_html/maven/"))
),
scalacOptions ++= Seq(
"-deprecation",
//"-Xfatal-warnings",
"-unchecked",
"-Xlint",
"-Xelide-below",
"INFO",
"-feature",
"-opt-inline-from:**",
"-opt:l:method",
"-opt:l:inline",
"-Ywarn-dead-code",
"-Ywarn-unused"
),
resolvers += ("uuverifiers" at "http://logicrunch.research.it.uu.se/maven/")
.withAllowInsecureProtocol(true),
libraryDependencies += "uuverifiers" %% "princess" % "nightlySNAPSHOT",
libraryDependencies += "uuverifiers" % "ecma2020-regex-parser" % "0.5",
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.0" % "test",
libraryDependencies += "dk.brics.automaton" % "automaton" % "1.11-8"
libraryDependencies += "dk.brics.automaton" % "automaton" % "1.11-8",
libraryDependencies += "uuverifiers" %% "parikh-theory" % "0.1.0-SNAPSHOT"
)

lazy val root = (project in file(".")).
settings(commonSettings: _*).
settings(
mainClass in Compile := Some("ostrich.OstrichMain"),
unmanagedSourceDirectories in Test += baseDirectory.value / "replaceall-benchmarks" / "src" / "test" / "scala"
)


lazy val root = (project in file("."))
.settings(commonSettings: _*)
.settings(
Compile / mainClass := Some("ostrich.OstrichMain"),
Test / unmanagedSourceDirectories += baseDirectory.value / "replaceall-benchmarks" / "src" / "test" / "scala"
)
2 changes: 1 addition & 1 deletion ostrich
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ostrichParams=""

for p; do
case "$p" in
[+-]eager | [+-]forward | -length=*)
[+-]eager | [+-]forward | -length=* | [+-]minimizeAutomata)
if [ x"$ostrichParams" = x"" ]; then
ostrichParams=$p
else
Expand Down
2 changes: 1 addition & 1 deletion ostrich-client
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ until [ $success -eq 0 ]; do

for var; do
case "$var" in
[+-]eager | [+-]forward | -length=*)
[+-]eager | [+-]forward | -length=* | [+-]minimizeAutomata)
if [ x"$ostrichParams" = x"" ]; then
ostrichParams=$var
else
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.0
sbt.version=1.5.3
4 changes: 4 additions & 0 deletions project/metals.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// DO NOT EDIT! This file is auto-generated.
// This file enables sbt-bloop to create bloop config files.

addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.8-19-4d9f966b")
70 changes: 67 additions & 3 deletions src/main/scala/ostrich/AutDatabase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ object AutDatabase {
* regular expressions. The database will assign a unique id to regular
* expressions, and will compute the resulting automaton on demand.
*/
class AutDatabase(theory : OstrichStringTheory) {
class AutDatabase(theory : OstrichStringTheory,
minimizeAutomata : Boolean) {

import AutDatabase._

private val regex2Aut = new Regex2Aut(theory)

private var nextId = 0

private val regexes = new MHashMap[ITerm, Int]
private val id2Regex = new MHashMap[Int, ITerm]
private val id2Aut = new MHashMap[Int, Automaton]
Expand All @@ -77,11 +80,23 @@ class AutDatabase(theory : OstrichStringTheory) {
def regex2Id(regexTerm : ITerm) : Int =
synchronized {
regexes.getOrElseUpdate(regexTerm, {
val id = regexes.size
val id = nextId
nextId = nextId + 1
id2Regex.put(id, regexTerm)
id })
}

/**
* Add a new automaton to the database.
*/
def automaton2Id(aut : Automaton) : Int =
synchronized {
val id = nextId
nextId = nextId + 1
id2Aut.put(id, aut)
id
}

/**
* Query the id of a regular expression.
*/
Expand All @@ -100,7 +115,7 @@ class AutDatabase(theory : OstrichStringTheory) {
case None =>
(id2Regex get id) match {
case Some(regex) => {
val aut = regex2Aut buildAut regex
val aut = regex2Aut.buildAut(regex, minimizeAutomata)
id2Aut.put(id, aut)
Some(aut)
}
Expand All @@ -110,6 +125,13 @@ class AutDatabase(theory : OstrichStringTheory) {
}
}

/**
* Query the automaton that belongs to the regular expression with given id;
* return the automaton only if it is already in the database.
*/
def id2AutomatonBE(id : Int) : Option[Automaton] =
synchronized { id2Aut get id }

/**
* Query the complemented automaton that belongs to the regular
* expression with given id.
Expand All @@ -131,6 +153,14 @@ class AutDatabase(theory : OstrichStringTheory) {
}
}

/**
* Query the complemented automaton that belongs to the regular
* expression with given id;
* return the automaton only if it is already in the database.
*/
def id2ComplementedAutomatonBE(id : Int) : Option[Automaton] =
synchronized { id2CompAut get id }

/**
* Query the automaton that belongs to the regular expression with
* given id.
Expand All @@ -140,6 +170,16 @@ class AutDatabase(theory : OstrichStringTheory) {
case ComplementedAut(id) => id2ComplementedAutomaton(id)
}

/**
* Query the automaton that belongs to the regular expression with
* given id;
* return the automaton only if it is already in the database.
*/
def id2AutomatonBE(id : NamedAutomaton) : Option[Automaton] = id match {
case PositiveAut(id) => id2AutomatonBE(id)
case ComplementedAut(id) => id2ComplementedAutomatonBE(id)
}

/**
* Check whether <code>aut1</code> specifies a subset of <code>aut2</code>.
*/
Expand All @@ -160,6 +200,30 @@ class AutDatabase(theory : OstrichStringTheory) {
true
}

/**
* Check whether <code>aut1</code> specifies a subset of <code>aut2</code>;
* the check is only carried out when all required automata are already in
* the database.
*/
def isSubsetOfBE(aut1 : NamedAutomaton,
aut2 : NamedAutomaton) : Option[Boolean] =
if (aut1.id < aut2.id) {
synchronized {
// aut1 <= aut2
// <==>
// (aut1 & aut2.complement) = empty
for (a1 <- id2AutomatonBE(aut1);
a2 <- id2AutomatonBE(aut2.complement)) yield
subsetRel.getOrElseUpdate((aut1, aut2),
!AutomataUtils.areConsistentAutomata(
List(a1, a2)))
}
} else if (aut1.id > aut2.id) {
isSubsetOfBE(aut2.complement, aut1.complement)
} else {
Some(true)
}

/**
* Check whether <code>aut1</code> and <code>aut2</code> have empty
* intersection.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/ostrich/AutomataAdapters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ abstract class AtomicStateAutomatonAdapter[A <: AtomicStateAutomaton]
def unary_! : Automaton =
!intern(this)

def isEmpty : Boolean =
override def isEmpty : Boolean =
!AutomataUtils.areConsistentAtomicAutomata(List(this))

def apply(word : Seq[Int]) : Boolean =
Expand Down
Loading