Skip to content

Commit

Permalink
format code in :theory
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed Sep 14, 2020
1 parent e8c97fd commit a873b66
Show file tree
Hide file tree
Showing 87 changed files with 351 additions and 280 deletions.
20 changes: 0 additions & 20 deletions theory/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
kotlin {

sourceSets {
val commonMain by getting {
dependencies {
api(project(":core"))
api(project(":unify"))
}
}

// Default source set for JVM-specific sources and dependencies:
jvm {
compilations["main"].defaultSourceSet {
dependencies {
// api(project(":core"))
// api(project(":unify"))
}
}
}

js {
compilations["main"].defaultSourceSet {
dependencies {
// api(project(":core"))
// api(project(":unify"))
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package it.unibo.tuprolog.collections

import it.unibo.tuprolog.collections.rete.custom.ReteTree
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.theory.TheoryUtils

internal abstract class AbstractClauseCollection<Self : AbstractClauseCollection<Self>>
protected constructor(protected val rete: ReteTree) : ClauseCollection {
Expand Down Expand Up @@ -33,6 +32,4 @@ protected constructor(protected val rete: ReteTree) : ClauseCollection {
override fun toString(): String {
return "${this::class.simpleName}(${this.joinToString(", ")})"
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package it.unibo.tuprolog.collections

import it.unibo.tuprolog.collections.rete.custom.ReteTree
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.theory.TheoryUtils

internal abstract class AbstractMutableReteClauseCollection<Self : AbstractMutableReteClauseCollection<Self>>
protected constructor(
Expand Down Expand Up @@ -50,4 +49,4 @@ protected constructor(
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ protected constructor(
RetrieveResult.Failure(this as Self)
else ->
RetrieveResult.Success(
newCollectionBuilder(newTheory), retracted.toList()
newCollectionBuilder(newTheory),
retracted.toList()
)
}
}
Expand All @@ -52,8 +53,9 @@ protected constructor(
RetrieveResult.Failure(this as Self)
else ->
RetrieveResult.Success(
newCollectionBuilder(newTheory), retracted.toList()
newCollectionBuilder(newTheory),
retracted.toList()
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ interface ClauseCollection : Iterable<Clause> {
@JvmStatic
@JsName("multiSetOfScopes")
fun multiSetOf(vararg clause: Scope.() -> Clause): ClauseMultiSet =
multiSetOf(clause.map {
Scope.empty(it)
})
multiSetOf(
clause.map {
Scope.empty(it)
}
)

/** Creates a [ClauseQueue] from the given [Sequence] of [Clause] */
@JvmStatic
Expand All @@ -88,9 +90,11 @@ interface ClauseCollection : Iterable<Clause> {
@JvmStatic
@JsName("queueOfScopes")
fun queueOf(vararg clause: Scope.() -> Clause): ClauseQueue =
queueOf(clause.map {
Scope.empty(it)
})
queueOf(
clause.map {
Scope.empty(it)
}
)

/** Creates a [ClauseQueue] from the given [Sequence] of [Clause] */
@JvmStatic
Expand All @@ -104,6 +108,3 @@ interface ClauseCollection : Iterable<Clause> {
ClauseQueue.of(clauses)
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ interface ClauseMultiSet : ClauseCollection {
@JvmStatic
@JsName("ofScopes")
fun of(vararg clause: Scope.() -> Clause): ClauseMultiSet =
of(clause.map {
Scope.empty(it)
})
of(
clause.map {
Scope.empty(it)
}
)

/** Creates a [ClauseMultiSet] from the given [Sequence] of [Clause] */
@JvmStatic
Expand Down Expand Up @@ -82,4 +84,3 @@ interface ClauseMultiSet : ClauseCollection {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ interface ClauseQueue : ClauseCollection {
@JvmStatic
@JsName("ofScopes")
fun of(vararg clause: Scope.() -> Clause): ClauseQueue =
of(clause.map {
Scope.empty(it)
})
of(
clause.map {
Scope.empty(it)
}
)

/** Creates a [ClauseQueue] from the given [Sequence] of [Clause] */
@JvmStatic
Expand Down Expand Up @@ -99,6 +101,4 @@ interface ClauseQueue : ClauseCollection {
)
}
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ interface MutableClauseCollection : ClauseCollection {
@JvmStatic
@JsName("multiSetOfScopes")
fun multiSetOf(vararg clause: Scope.() -> Clause): MutableClauseMultiSet =
multiSetOf(clause.map {
Scope.empty(it)
})
multiSetOf(
clause.map {
Scope.empty(it)
}
)

/** Creates a [MutableClauseQueue] from the given [Sequence] of [Clause] */
@JvmStatic
Expand All @@ -64,9 +66,11 @@ interface MutableClauseCollection : ClauseCollection {
@JvmStatic
@JsName("queueOfScopes")
fun queueOf(vararg clause: Scope.() -> Clause): MutableClauseQueue =
queueOf(clause.map {
Scope.empty(it)
})
queueOf(
clause.map {
Scope.empty(it)
}
)

/** Creates a [MutableClauseQueue] from the given [Sequence] of [Clause] */
@JvmStatic
Expand All @@ -79,4 +83,4 @@ interface MutableClauseCollection : ClauseCollection {
fun queueOf(clauses: Iterable<Clause>): MutableClauseQueue =
MutableClauseQueue.of(clauses)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import it.unibo.tuprolog.collections.impl.MutableReteClauseMultiSet
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.core.Scope
import it.unibo.tuprolog.core.TermComparator
import it.unibo.tuprolog.utils.itemWiseEquals
import it.unibo.tuprolog.utils.itemWiseHashCode
import kotlin.js.JsName
import kotlin.jvm.JvmStatic
Expand Down Expand Up @@ -39,9 +38,11 @@ interface MutableClauseMultiSet : ClauseMultiSet {
@JvmStatic
@JsName("ofScopes")
fun of(vararg clause: Scope.() -> Clause): MutableClauseMultiSet =
of(clause.map {
Scope.empty(it)
})
of(
clause.map {
Scope.empty(it)
}
)

/** Creates a [MutableClauseMultiSet] from the given [Sequence] of [Clause] */
@JvmStatic
Expand Down Expand Up @@ -69,5 +70,4 @@ interface MutableClauseMultiSet : ClauseMultiSet {
)
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package it.unibo.tuprolog.collections
import it.unibo.tuprolog.collections.impl.MutableReteClauseQueue
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.core.Scope
import it.unibo.tuprolog.utils.itemWiseEquals
import it.unibo.tuprolog.utils.itemWiseHashCode
import kotlin.js.JsName
import kotlin.jvm.JvmStatic
Expand Down Expand Up @@ -47,9 +46,11 @@ interface MutableClauseQueue : ClauseQueue {
@JvmStatic
@JsName("ofScopes")
fun of(vararg clause: Scope.() -> Clause): MutableClauseQueue =
of(clause.map {
Scope.empty(it)
})
of(
clause.map {
Scope.empty(it)
}
)

/** Creates a [MutableClauseQueue] from the given [Sequence] of [Clause] */
@JvmStatic
Expand Down Expand Up @@ -77,5 +78,4 @@ interface MutableClauseQueue : ClauseQueue {
)
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ sealed class RetrieveResult<C : ClauseCollection> {
}

data class Failure<C : ClauseCollection>(override val collection: C) : RetrieveResult<C>()
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package it.unibo.tuprolog.collections.impl

import it.unibo.tuprolog.collections.*
import it.unibo.tuprolog.collections.AbstractMutableReteClauseCollection
import it.unibo.tuprolog.collections.MutableClauseMultiSet
import it.unibo.tuprolog.collections.rete.custom.ReteTree
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.theory.TheoryUtils
Expand All @@ -22,7 +22,6 @@ internal class MutableReteClauseMultiSet private constructor(
override fun count(clause: Clause): Long =
rete.get(clause).count().toLong()


override fun get(clause: Clause): Sequence<Clause> =
rete.get(clause)

Expand All @@ -37,4 +36,4 @@ internal class MutableReteClauseMultiSet private constructor(
override fun hashCode(): Int {
return MutableClauseMultiSet.hashCode(this)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package it.unibo.tuprolog.collections.impl

import it.unibo.tuprolog.collections.AbstractMutableReteClauseCollection
import it.unibo.tuprolog.collections.ClauseQueue
import it.unibo.tuprolog.collections.MutableClauseQueue
import it.unibo.tuprolog.collections.RetrieveResult
import it.unibo.tuprolog.collections.rete.custom.ReteTree
Expand Down Expand Up @@ -45,7 +44,8 @@ internal class MutableReteClauseQueue private constructor(
RetrieveResult.Failure(this)
else ->
RetrieveResult.Success(
this, retracted.toList()
this,
retracted.toList()
)
}
}
Expand All @@ -61,4 +61,4 @@ internal class MutableReteClauseQueue private constructor(
override fun hashCode(): Int {
return MutableClauseQueue.hashCode(this)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package it.unibo.tuprolog.collections.impl

import it.unibo.tuprolog.collections.*
import it.unibo.tuprolog.collections.AbstractReteClauseCollection
import it.unibo.tuprolog.collections.ClauseMultiSet
import it.unibo.tuprolog.collections.MutableClauseMultiSet
import it.unibo.tuprolog.collections.rete.custom.ReteTree
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.theory.TheoryUtils
import it.unibo.tuprolog.utils.itemWiseHashCode

internal class ReteClauseMultiSet private constructor(
rete: ReteTree
Expand Down Expand Up @@ -43,5 +43,4 @@ internal class ReteClauseMultiSet private constructor(
}

override fun hashCode(): Int = hashCodeCache

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import it.unibo.tuprolog.collections.RetrieveResult
import it.unibo.tuprolog.collections.rete.custom.ReteTree
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.theory.TheoryUtils
import it.unibo.tuprolog.utils.itemWiseHashCode

internal class ReteClauseQueue private constructor(
rete: ReteTree
Expand Down Expand Up @@ -69,5 +68,4 @@ internal class ReteClauseQueue private constructor(
override fun hashCode(): Int {
return hashCodeCache
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ internal interface Cacheable<T> {

/**Forcefully invalidate the node cache and all of its subtree cache*/
fun invalidateCache()

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ internal interface IndexingLeaf : ReteNode {
/**Variant of [getIndexed] aimed at preventing a proper traversal of the children of this node,
* retrieving all the clauses matching the given [Clause] without performing any branch selection*/
fun extractGlobalIndexedSequence(clause: Clause): Sequence<SituatedIndexedClause>

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package it.unibo.tuprolog.collections.rete.custom

/**Marker interface to expand the capabilites of a [ReteNode] to behave as an [IndexingLeaf
*/
internal interface IndexingNode : ReteNode, IndexingLeaf
internal interface IndexingNode : ReteNode, IndexingLeaf
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ internal interface ReteNode : Cacheable<SituatedIndexedClause> {

/**Removes all the clauses matching the given [Clause], returning all of them as a [Sequence] of [Clause]*/
fun retractAll(clause: Clause): Sequence<Clause>

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ interface ReteTree {
fun ordered(vararg clauses: Clause): ReteTree =
ordered(listOf(*clauses))
}
}
}
Loading

0 comments on commit a873b66

Please sign in to comment.