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

develop #12

Open
wants to merge 411 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
411 commits
Select commit Hold shift + click to select a range
d8694db
add todo
cos Jul 18, 2017
3d22bef
remove ugly messages
cos Jul 18, 2017
5651c14
formatting
cos Jul 18, 2017
5c2c37d
rename
cos Jul 18, 2017
5289ae7
convert non-hooked symbols first
cos Jul 18, 2017
b74899b
Map.concat hook
cos Jul 18, 2017
00d0cf3
raise warning for missing hooks
cos Jul 18, 2017
62f7912
refactor: inline hook methods
cos Jul 18, 2017
60dfb2c
organize imports
cos Jul 18, 2017
0d222e8
allow hooks to not instantiate when their dependencies are not ready
cos Jul 18, 2017
e172a9f
map lookup -- hooked directly
cos Jul 18, 2017
eeeb139
use documentation comment style
cos Jul 18, 2017
3804794
hooks Map.keys, Set.in
cos Jul 18, 2017
ad99e37
fix Pretty autoflatting bug
cos Jul 18, 2017
62874bb
hook Set.concat
cos Jul 19, 2017
c71709a
fix for Map builtin to work with Next
cos Jul 19, 2017
8823353
fix for Rewriter to work with nested Nexts
cos Jul 19, 2017
61303f1
remove memoization as it seems to be buggy
cos Jul 19, 2017
cff5f01
allow missing Att encoders
cos Jul 20, 2017
a6e4863
add Leaf unapplier
cos Jul 20, 2017
43b336a
toConstructor for Term
cos Jul 20, 2017
3e1877d
clean up dependencies
cos Jul 20, 2017
4db2a9d
fix sbt
cos Jul 20, 2017
84f2d51
Give the correct name for string concatenation
ayberkt Jul 20, 2017
49d9872
Get rid of commented-out code
ayberkt Jul 20, 2017
031f8f7
Some formatting and enforcement of 80 characters
ayberkt Jul 20, 2017
5fe04e2
remove debuggin printlns
cos Jul 20, 2017
1cac9a4
toConstructor assumes vars are declarated already
cos Jul 20, 2017
ae9372a
minor
cos Jul 21, 2017
3a71135
Map.update hook
cos Jul 21, 2017
6d1c8de
executeRule
cos Jul 22, 2017
0effa2e
delete empty file
cos Jul 22, 2017
0ee9ee0
Assoc.unapply
cos Jul 22, 2017
f1536b5
dsl for explicit context
cos Jul 23, 2017
a50ae20
equals fix
cos Jul 23, 2017
5eb1d8b
minor
cos Jul 23, 2017
ae480a8
activate bottomize
cos Jul 23, 2017
0f452ed
truth is not a predicate -- this is tricky
cos Jul 23, 2017
4b7a36e
safety checks for prettywrapper
cos Jul 23, 2017
f5934ab
fix bug -- not should not bottomize
cos Jul 23, 2017
a0a903c
more explicit next matchers -- still no logic for them
cos Jul 23, 2017
9665a6d
better next is now
cos Jul 23, 2017
8a271d0
fix and test for toConstructor
cos Jul 23, 2017
bd7c2be
have DomainValues toConstructors be explicit
cos Jul 23, 2017
ebe52c9
have the string wrapped in """
cos Jul 23, 2017
be51c59
fix -- toConstructor should be recursive for assoc
cos Jul 24, 2017
70d9d7e
refactor formatting
cos Jul 24, 2017
25bffca
add missing matchers for higher arity free labels
cos Jul 24, 2017
a662407
gather labels referenced by hooks
cos Jul 24, 2017
7bf7516
fix map update hook
cos Jul 24, 2017
df99083
rudimentary implementation for substitution
ayberkt Jul 24, 2017
b314d02
Round of minor cleanups
ayberkt Jul 25, 2017
ec1d677
fixes for equals
cos Jul 25, 2017
2c37449
Merge branch 'develop' of https://github.com/kframework/kale into dev…
ayberkt Jul 26, 2017
e9084a9
formatting
cos Jul 31, 2017
b78076d
more tuples
cos Jul 31, 2017
f1939b0
remove assertion until we have proper binders
cos Jul 31, 2017
d3905e5
more flexible macro implementation
cos Jul 31, 2017
736b0de
Tuple0
cos Aug 1, 2017
8574347
error message format fix
cos Aug 1, 2017
ecdfe0f
fix sort registration
cos Aug 1, 2017
c2dab58
no more infix toString
cos Aug 1, 2017
b1d4293
fix
cos Aug 1, 2017
42231f6
rename strategy labels
cos Aug 1, 2017
27163f5
Get rid of some `println`s
ayberkt Aug 2, 2017
c61c172
Merge branch 'develop' of https://github.com/kframework/kale into dev…
ayberkt Aug 2, 2017
00082ce
macroIsDefined method
cos Aug 7, 2017
c4a712d
Include kore as a submodule instead of via sbt's resolvers
nishantjr Jul 20, 2017
f6370aa
Merge pull request #20 from kframework/submodule
cos Aug 17, 2017
03f33c1
rename variable name to fix outer multi-build
cos Aug 24, 2017
a434e7b
refactoring
cos Sep 1, 2017
c278b04
optimization for macros with 0 children
cos Sep 8, 2017
f42b2e1
fix documentation
cos Sep 8, 2017
9efab40
fix for variable encoding/decoding
cos Sep 13, 2017
8720baf
allow macro redefinition
cos Sep 14, 2017
c0d97bf
lazy subsitution on rhs of Rewrite
cos Sep 15, 2017
040d2e8
extra tests
cos Sep 15, 2017
53a732a
de morgan for equality
cos Sep 15, 2017
4b40dd7
fix for publishing
cos Sep 19, 2017
b396559
latest kore
cos Sep 19, 2017
9689c73
should track kore develop actually
cos Sep 19, 2017
80b6475
update kore submodule version
cos Sep 19, 2017
da5de2b
specialize exception for macros
cos Sep 19, 2017
4774384
assoc.toString should preserve order
cos Sep 20, 2017
61d47a1
makeMatcher is now explicitly invoked by seal
cos Sep 21, 2017
664e4e4
remove unification as default, and add extra test
cos Sep 21, 2017
a32078a
explicitate path
cos Sep 26, 2017
35225cd
explain new method
cos Sep 26, 2017
d413b74
depend on cats and kittens
cos Sep 26, 2017
85ebcfe
fix typo
cos Sep 26, 2017
1fcc949
update circe dependency
cos Sep 26, 2017
cd53dca
add laws and discipline for testing
cos Sep 26, 2017
ac87f36
cats.Eq implementation for Term
cos Sep 26, 2017
615f8b4
start work on encode-decode
cos Sep 26, 2017
dbc01d9
add support for representing scala lists
cos Sep 26, 2017
9c73e87
Up -- takes Ts into Terms
cos Sep 26, 2017
85258cb
our assoc as a cats.Semigroup
cos Sep 26, 2017
93e8871
rename AssocWithId to Monoid
cos Sep 26, 2017
4ef55d5
more precise return type for FreeLabel0
cos Sep 27, 2017
685585f
up for scala list
cos Sep 27, 2017
02db9a0
assert that PrettyWrapper has String-ish margins
cos Sep 27, 2017
5a8b4ed
configurable isValidWrapper
cos Oct 2, 2017
87e5169
anywhere := assoc change: see comment in MatchSpec
cos Oct 2, 2017
847b978
move path in standard
cos Oct 2, 2017
2f755fb
enforce that Mixin is only mixed in Environments
cos Oct 2, 2017
2037806
fix imports for PathTest
cos Oct 2, 2017
f28857f
flatten/cleanup mixin hierarchy
cos Oct 2, 2017
9508c68
refactor: rename
cos Oct 2, 2017
7aa9f7f
remove HasUnifier
cos Oct 2, 2017
bf339c1
refactor builtins
cos Oct 2, 2017
6d257b6
refactor: make Mixin style uniform
cos Oct 2, 2017
60c7827
*Mixing => Mixin
cos Oct 2, 2017
f6983e4
refactor primitive builtins to use to new Up
cos Oct 2, 2017
6bc2ae5
refactor builtins
cos Oct 2, 2017
03bd94c
delete unused
cos Oct 3, 2017
fb811fc
make more precise
cos Oct 3, 2017
3ffb881
more strict pretty check
cos Oct 3, 2017
2b469da
start work on path
cos Oct 3, 2017
3d96ba9
refactroing: cats going up and down
cos Oct 4, 2017
e9ad557
Path UpDown
cos Oct 4, 2017
82fe88a
delete traversableTerm
cos Oct 4, 2017
8a0f959
fix for unsat
cos Oct 4, 2017
5fb2867
configurable indices to avoid in Anywhere
cos Oct 4, 2017
e93027b
fold operations for Term
cos Oct 5, 2017
9955039
principled merge for nested PrettyWrapper spacing
cos Oct 6, 2017
685c731
STRING.concat is a monoid, and PrettyWrapper uses it
cos Oct 6, 2017
655cf68
remove unused foldLeftTD
cos Oct 8, 2017
20a9ae2
alpha equivalence implementation
cos Oct 8, 2017
c7b7c4c
tests and fix to equiv
cos Oct 8, 2017
1d158d3
doesNotMatch will wait for Rewrites to be solved
cos Oct 8, 2017
d7e93a9
filter for substitution
cos Oct 8, 2017
499ea62
filter for collection-like terms
cos Oct 8, 2017
61e1136
asIterable moved to all monoids
cos Oct 8, 2017
405b845
AssocCommWithId is a Monoid
cos Oct 8, 2017
13011dc
anywhere matches keep traversal information
cos Oct 8, 2017
3ff819d
filter for And
cos Oct 8, 2017
855fa1f
Next self-flattens
cos Oct 8, 2017
b37f08b
utilities for Next
cos Oct 8, 2017
9aa11fe
fix for nextIsNow
cos Oct 8, 2017
02d01c0
solve unsat via doesNotMatch
cos Oct 8, 2017
7c9b6e2
better matching for next
cos Oct 8, 2017
594ac4e
renames
cos Oct 8, 2017
32ccbf8
refactoring
cos Oct 8, 2017
b412c33
fix
cos Oct 8, 2017
6e5ff84
basic implementation for rewrite on right
cos Oct 8, 2017
3cd8325
fix
cos Oct 8, 2017
9580aaf
rename intentional typo
cos Oct 8, 2017
2425a7c
fix
cos Oct 9, 2017
856b816
measure time with measureTime
cos Oct 9, 2017
1f40095
expriments -- leave here for future
cos Oct 9, 2017
a607e3d
add benchmarking
cos Oct 9, 2017
e39cb53
add benchmarking
cos Oct 9, 2017
c1fcc61
add roaringbitmap dependency
cos Oct 9, 2017
14064eb
fix
cos Oct 9, 2017
57a97c9
add but do not activate roaring
cos Oct 9, 2017
12dd02c
activate roaring but do not use it yet
cos Oct 10, 2017
594ccc2
fix for DomainValue registration bug
cos Oct 10, 2017
9e07c3c
activate roaring...
cos Oct 10, 2017
56562ff
faaaaasst! :-)
cos Oct 10, 2017
f01c635
refactor measureTime (renamte to timer)
cos Oct 10, 2017
5ba5756
get timer only once
cos Oct 10, 2017
b2237d3
use duration
cos Oct 10, 2017
8fbba50
remove assertion from reeentrant timer
cos Oct 10, 2017
385fd2e
send warning to err
cos Oct 10, 2017
ea30b18
get for timer
cos Oct 10, 2017
4b59096
reports all timers
cos Oct 10, 2017
24ceb94
make ReentrantTimer a case class
cos Oct 10, 2017
8e190f2
don't monitor assoc
cos Oct 10, 2017
03dfe92
timer repors speed as well
cos Oct 10, 2017
688e540
better speed computation
cos Oct 10, 2017
b2ba661
refactor timer
cos Oct 11, 2017
b36c83d
refactoring
cos Oct 11, 2017
e6004bb
rename file
cos Oct 11, 2017
06f6e62
refactoring
cos Oct 11, 2017
65e7576
more metrics
cos Oct 11, 2017
bfbf88a
remove safety assertion
cos Oct 11, 2017
56fca35
fix
cos Oct 11, 2017
226f284
fix warning
cos Oct 12, 2017
5767039
fix warning
cos Oct 12, 2017
865c679
fix warning
cos Oct 12, 2017
fe61ac0
sbt takes latest patch releases for dependencies
cos Oct 13, 2017
2b47dc2
.
cos Oct 13, 2017
68f5fbd
rename things
cos Oct 13, 2017
708fcf1
Named -> LabelNamed
cos Oct 13, 2017
9b6652f
rename up down functions
cos Oct 13, 2017
77a4a11
add free high cats
cos Oct 14, 2017
5d68846
Path uses the new free
cos Oct 14, 2017
8b78a92
move highcats code
cos Oct 14, 2017
bf20bf3
use squats for processing rates
cos Oct 14, 2017
2a97b75
fix timer
cos Oct 15, 2017
30b2ea5
remote memoization improves performance by 2x
cos Oct 15, 2017
ef72d09
optional unificationSpeed for timer
cos Oct 15, 2017
6171e94
small fixes
cos Oct 15, 2017
dba8c47
unify speed optimization
cos Oct 15, 2017
bf7f961
speed optimization
cos Oct 15, 2017
a4d1e9a
special case for common labels
cos Oct 15, 2017
b8ac918
sparser stats
cos Oct 15, 2017
c5d3cd4
most hashCode caching
cos Oct 15, 2017
9351f74
.
cos Oct 15, 2017
ac69637
measuring performance + caching for cxt
cos Oct 15, 2017
9fe6a53
orElse shortcircuit
cos Oct 16, 2017
c92103c
assoc optimization
cos Oct 16, 2017
c0b6229
new test
cos Oct 16, 2017
6c23455
more corner case optimization for assoc
cos Oct 16, 2017
137f85d
further optimization of assoc => 5x speed :-)
cos Oct 16, 2017
cd717ec
warning instead of exception
cos Oct 16, 2017
48611f6
recover information on timeout and timer spec
cos Oct 16, 2017
6240f69
add figs from presentation last summer to the doc
cos Oct 18, 2017
8d1b24a
string unescape
cos Oct 23, 2017
b1ccaa2
reset timers after timer spec
cos Oct 24, 2017
2e12337
fix timeouts
cos Oct 24, 2017
2d24b0a
ignore timeout tests
cos Oct 24, 2017
d350fde
isGround is not lazy enough
cos Oct 24, 2017
abc1401
same apply for all Monoids
cos Oct 24, 2017
7cc9c06
fix datatype problem
cos Oct 24, 2017
21434d2
replace Exists with HoleBinder
cos Oct 25, 2017
956d4d6
fix for unsat
cos Oct 25, 2017
63c196e
Show Term
cos Oct 27, 2017
d936e91
forget variable in context predicate
cos Oct 27, 2017
45c58fa
^oneSolution strategy
cos Oct 27, 2017
d2b0342
SemigroupLabel apply on Iterable implementation
cos Nov 16, 2017
fdc8a93
^orElse is semigroup
cos Nov 16, 2017
45155d7
make explicit to go around weird bug
cos Nov 17, 2017
64fa170
relax timing spec to prevent flakiness
cos Nov 17, 2017
c470776
minor
cos Nov 21, 2017
dfd45ba
topDown with Bottom strategy
cos Nov 22, 2017
e085c28
compose is Semigroup
cos Nov 22, 2017
e4e812c
bump Scala version
cos Nov 27, 2017
c7c9660
better error
cos Dec 19, 2017
42b80ca
add license file -- as the rest of the k framework
cos Dec 26, 2017
fd1b193
remove dependency on kore for now
cos Dec 26, 2017
4551a29
remove the kore git submodule dependency
cos Dec 26, 2017
568dc8d
remove lots of redundant code
cos Dec 26, 2017
f15498e
FreeNode => SimpleNode
cos Dec 26, 2017
8e55e95
small explanation
cos Dec 26, 2017
d7a7543
simplify registering
cos Dec 26, 2017
a858d73
rename
cos Dec 26, 2017
5f9c147
make priorities explicit
cos Dec 26, 2017
c054f0d
remove redundant rewrite
cos Dec 27, 2017
8a09c8a
Update LICENSE.md
cos Jan 8, 2018
81e16ee
Merge pull request #23 from kframework/add-license-file
cos Jan 8, 2018
fec7d46
remove the kore git submodule dependency
cos Dec 26, 2017
1bcd340
remove lots of redundant code
cos Dec 26, 2017
0c3f44c
Merge branch 'stripped-down' into develop
cos Jan 9, 2018
1491716
String concat can handle format infer
horiaradu Feb 6, 2018
36a78c1
minor
cos Mar 27, 2018
a0a1e48
several fixes to allow ForAll
cos Mar 29, 2018
00300eb
compose preserves variables
cos Mar 29, 2018
fa582fb
Revert "compose preserves variables"
cos Mar 29, 2018
dbdf9d2
refactor
cos Mar 29, 2018
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
target
.idea

/z3
.DS_Store
/src/test/scala/org/kframework/test.sc
/npm-debug.log
Empty file added .gitmodules
Empty file.
50 changes: 50 additions & 0 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## Building

Clone the repository (recursively to include submodules) and then build using
`sbt`. Use the `develop` branch if you intend to create pull requests:

```
git clone --recurse-submodules https://github.com/kframework/kale --branch develop
sbt compile
```

These git configuration settings smoothen out working with submodules:

```
git config --global push.recurseSubmodules check
git config --global fetch.recurseSubmodules true
```

If you intend to push to the `kore` repository too, using you SSH adding:

```
[url "[email protected].:"]
pushInsteadOf = https://github.com/
```

to your `~/.gitconfig` will let you do that.


## Guide on adding a new feature to terms/labels

In an `if-then-elseif-...` style:

#### Is it very specific to your use/project?

Leave it in your project / out of the Scala backend.

#### It it only invoked occasionally, performance is not critical?

Put it in Rich* (`org.kframework.kale` package object)

#### Performance is important?

Create an `Environment` `Mixin` and use `Unary` or `Binary`.

#### Do you think the feature is extremely important and should be in the main trait hierarchy, not a mixin?

**Talk with a few other developers before putting it there!!!**

#### Do you an idea of how we could move functionality out of the main trait hierarchy into a Mixin?

**Let's talk about it!**
61 changes: 61 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!-- Copyright (c) 2010-2016 K Team. All Rights Reserved. -->
==============================================================================
The K Release License
==============================================================================
University of Illinois/NCSA
Open Source License

Copyright (c) 2009-2015 University of Illinois at Urbana-Champaign.
All rights reserved.

Developed by:

K Team

University of Illinois at Urbana-Champaign
Runtime Verification, Inc.
Iuvo AI, Inc.

http://kframework.org

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.

* Neither the names of the K Team, the University of Illinois at
Urbana-Champaign, the University Alexandru-Ioan Cuza, nor the names of
its contributors may be used to endorse or promote products derived from
this Software without specific prior written permission.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.

==============================================================================
Copyrights and Licenses for Third Party Software Distributed with K:
==============================================================================
The K software contains code written by third parties. Such software will have
its own individual LICENSE file in the directory in which it appears. This
file will describe the copyrights, license, and restrictions which apply to
that code.

The disclaimer of warranty in the University of Illinois Open Source License
applies to all code in the K Distribution, and nothing in any of the other
licenses gives permission to use the names of the K Team, the
University of Illinois, or the University Alexandru-Ioan Cuza to endorse or
promote products derived from this Software.

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[ ![Codeship Status for kframework/kale](https://app.codeship.com/projects/8a5162d0-1588-0135-d42f-6a6f9a84ad3f/status?branch=develop)](https://app.codeship.com/projects/217943)

# K Scala Backend

# Install

# Use

# Contribute
33 changes: 26 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,37 @@ organization := "org.kframework"

name := "kale"

scalaVersion := "2.12.2"
scalaVersion := "2.12.4"

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

resolvers += "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository"
resolvers += Resolver.mavenLocal

lazy val kale = project.in(file("."))

libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.1" % "test",
"org.typelevel" %% "discipline" % "0.7.+" % "test",
"org.scalatest" %% "scalatest" % "3.0.+" % "test",

"org.typelevel" %% "cats-core" % "1.0.+",
"org.typelevel" %% "cats-laws" % "1.0.+" % "test",
"org.typelevel" %% "kittens" % "1.0.+",

"io.circe" %% "circe-core" % "0.7.0",
"io.circe" %% "circe-generic" % "0.7.0",
"io.circe" %% "circe-parser" % "0.7.0",
"org.typelevel" %% "squants" % "1.3.0",

"org.kframework.k" %% "kore" % "1.0-SNAPSHOT"
"org.roaringbitmap" % "RoaringBitmap" % "0.6.+",

"io.circe" %% "circe-core" % "0.9.+",
"io.circe" %% "circe-parser" % "0.9.+"
)

lazy val installZ3 = taskKey[Unit]("Install Z3 theorem prover")

installZ3 := {
"./installZ3.sh" !
}

(test in Test) := (test in Test).dependsOn(installZ3).value

// Your profile name of the sonatype account. The default is the same with the organization value
sonatypeProfileName := "org.kframework.kale"
Binary file modified docs/graphs.graffle
Binary file not shown.
18 changes: 18 additions & 0 deletions installZ3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

if [ ! -d ./z3 ]; then

URL="https://github.com/Z3Prover/z3/releases/download/z3-4.5.0/"
FORMAT=".zip"

if [ `uname` = "Linux" ]; then
EXECUTABLE="z3-4.5.0-x64-ubuntu-14.04"


elif [ `uname` = "Darwin" ]; then
EXECUTABLE="z3-4.5.0-x64-osx-10.11.6"
fi

curl -OL $URL$EXECUTABLE$FORMAT && unzip $EXECUTABLE$FORMAT && mv $EXECUTABLE"/" z3 && rm $EXECUTABLE$FORMAT

fi
1 change: 0 additions & 1 deletion project/Build.scala

This file was deleted.

1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=0.13.15
2 changes: 0 additions & 2 deletions sonatype.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Your profile name of the sonatype account. The default is the same with the organization value
sonatypeProfileName := "org.kframework.kale"

// To sync with Maven central, you need to supply the following information:
pomExtra in Global := {
Expand Down
103 changes: 73 additions & 30 deletions src/main/scala/org/kframework/kale/Environment.scala
Original file line number Diff line number Diff line change
@@ -1,30 +1,50 @@
package org.kframework.kale

import org.kframework.kale.standard.{Bottomize, Name, Sort}
import org.kframework.kore
import org.kframework.kale.highcats.LiftedCatsMixin
import org.kframework.kale.standard.BottomizeMixin
import org.kframework.kale.transformer.Binary.{Apply, ProcessingFunctions}
import org.kframework.kale.transformer.{Binary, Unary}

import scala.collection._
trait Environment extends Foundation with RoaringMixin with HasMatcher with MatchingLogicMixin with LiftedCatsMixin with BottomizeMixin

trait Environment extends KORELabels with Bottomize {
trait Foundation {
_: Environment =>

trait HasEnvironment {
val env = Environment.this
}
implicit protected val env: this.type = this

val uniqueLabels = mutable.Map[String, Label]()
val uniqueLabels = collection.mutable.Map[String, Label]()

def labels = uniqueLabels.values.toSet
def labels: Set[Label] = if (isSealed) {
labelSet
} else {
uniqueLabels.values.toSet
}

private lazy val labelSet = uniqueLabels.values.toSet
private var pisSealed = false

def seal(): Unit = pisSealed = true
var _matcher: Binary.Apply = _

def seal(): Unit = {
pisSealed = true
}

def isSealed = pisSealed

def unaryProcessingFunctions: Unary.ProcessingFunctions = Unary.processingFunctions

val substitutionMaker: Substitution => SubstitutionApply

final val unify: Label2 = lift("unify", {
(a: Term, b: Term) =>
assert(this.isSealed)
unifier(a, b)
})

def unifier: Binary.Apply

def register(label: Label): Int = {
assert(!isSealed, "The environment is sealed")
assert(!isSealed, "Cannot register label " + label + " because the environment is sealed")
assert(label != null)

if (uniqueLabels.contains(label.name))
Expand All @@ -36,29 +56,52 @@ trait Environment extends KORELabels with Bottomize {

def label(labelName: String): Label = uniqueLabels(labelName)

def sort(l: Label, children: Seq[Term]): Sort

def sortArgs(l: Label): Seq[Sort]

def sortTarget(l: Label): Sort
lazy val labelForIndex: Map[Int, Label] = labels map { l => (l.id, l) } toMap

override def toString = {
"nextId: " + uniqueLabels.size + "\n" + uniqueLabels.mkString("\n")
}
}

trait KORELabels {
// Constants
val Bottom: Truth with kore.Bottom
val Top: Truth with Substitution with kore.Top

// Labels
val Variable: VariableLabel
val And: AndLabel
val Or: OrLabel
val Rewrite: RewriteLabel
val Equality: EqualityLabel
val Truth: TruthLabel
val Not: NotLabel
def rewrite(rule: Term, obj: Term): Term

}

trait HasMatcher extends Mixin {
env: Environment =>

case class NoMatch(solver: Apply) extends Binary.F({ (a: Term, b: Term) => Bottom })

case class LeaveAlone(solver: Apply) extends Binary.F({ (a: Term, b: Term) => And(a, b) })

case class AssertNotPossible(solver: Apply) extends Binary.F({ (a: Term, b: Term) => throw new AssertionError("Should not try to match " + a + " with " + b) })

private var _registeredMatchers: Map[Binary.ProcessingFunctions, Int] = collection.immutable.ListMap()

object Priority {
val low = 30
val medium = 50
val high = 80
val ultimate = 200
}

def registeredMatchers = _registeredMatchers

def registerInner(matcher: Binary.ProcessingFunctions, priority: Int) {
_registeredMatchers = _registeredMatchers + (matcher -> priority)
}

def registerMatcher[Process <: Apply, A <: Term, B <: Term](f: PartialFunction[(Label, Label), Process => (A, B) => Term], priority: Int) = {
registerInner(Binary.definePartialFunction(f), priority)
}

final lazy val makeMatcher: Binary.ProcessingFunctions = {
registeredMatchers
.groupBy(_._2)
.mapValues(_.keySet)
.toList
.sortBy(-_._1)
.map(_._2)
.map(_.reduce(_ orElse _))
.reduceLeft(_ orElse _)
}
}
Loading