-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/arg2p-integration' into develop
- Loading branch information
Showing
27 changed files
with
511 additions
and
35 deletions.
There are no files selected for viewing
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
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
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
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
19 changes: 19 additions & 0 deletions
19
solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/RetractAll.kt
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,19 @@ | ||
package it.unibo.tuprolog.solve.stdlib.primitive | ||
|
||
import it.unibo.tuprolog.core.* | ||
import it.unibo.tuprolog.core.Var | ||
import it.unibo.tuprolog.solve.ExecutionContext | ||
import it.unibo.tuprolog.solve.Solve | ||
import it.unibo.tuprolog.solve.primitive.UnaryPredicate | ||
import it.unibo.tuprolog.theory.RetractResult | ||
import it.unibo.tuprolog.unify.Unificator.Companion.mguWith | ||
|
||
object RetractAll : UnaryPredicate.NonBacktrackable<ExecutionContext>("retractall") { | ||
override fun Solve.Request<ExecutionContext>.computeOne(first: Term): Solve.Response { | ||
ensuringArgumentIsStruct(0) | ||
val clause = if (first is Clause) first else Rule.of(first as Struct, Var.anonymous()) | ||
val dynamicKb = context.dynamicKb | ||
val result = dynamicKb.retractAll(clause) | ||
return replySuccess(dynamicKb = result.theory) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThan.kt
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,13 @@ | ||
package it.unibo.tuprolog.solve.stdlib.primitive | ||
|
||
import it.unibo.tuprolog.core.Term | ||
import it.unibo.tuprolog.solve.ExecutionContext | ||
import it.unibo.tuprolog.solve.Solve | ||
import it.unibo.tuprolog.solve.primitive.BinaryRelation | ||
|
||
/** Implementation of '@>'/2 predicate */ | ||
object TermGreaterThan : BinaryRelation.Predicative<ExecutionContext>("@>") { | ||
override fun Solve.Request<ExecutionContext>.compute(first: Term, second: Term): Boolean { | ||
return first > second | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...rc/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanOrEqualTo.kt
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,13 @@ | ||
package it.unibo.tuprolog.solve.stdlib.primitive | ||
|
||
import it.unibo.tuprolog.core.Term | ||
import it.unibo.tuprolog.solve.ExecutionContext | ||
import it.unibo.tuprolog.solve.Solve | ||
import it.unibo.tuprolog.solve.primitive.BinaryRelation | ||
|
||
/** Implementation of '@>='/2 predicate */ | ||
object TermGreaterThanOrEqualTo : BinaryRelation.Predicative<ExecutionContext>("@>=") { | ||
override fun Solve.Request<ExecutionContext>.compute(first: Term, second: Term): Boolean { | ||
return first >= second | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThan.kt
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,13 @@ | ||
package it.unibo.tuprolog.solve.stdlib.primitive | ||
|
||
import it.unibo.tuprolog.core.Term | ||
import it.unibo.tuprolog.solve.ExecutionContext | ||
import it.unibo.tuprolog.solve.Solve | ||
import it.unibo.tuprolog.solve.primitive.BinaryRelation | ||
|
||
/** Implementation of '@<'/2 predicate */ | ||
object TermLowerThan : BinaryRelation.Predicative<ExecutionContext>("@<") { | ||
override fun Solve.Request<ExecutionContext>.compute(first: Term, second: Term): Boolean { | ||
return first < second | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThanOrEqualTo.kt
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,13 @@ | ||
package it.unibo.tuprolog.solve.stdlib.primitive | ||
|
||
import it.unibo.tuprolog.core.Term | ||
import it.unibo.tuprolog.solve.ExecutionContext | ||
import it.unibo.tuprolog.solve.Solve | ||
import it.unibo.tuprolog.solve.primitive.BinaryRelation | ||
|
||
/** Implementation of '@=<'/2 predicate */ | ||
object TermLowerThanOrEqualTo : BinaryRelation.Predicative<ExecutionContext>("@=<") { | ||
override fun Solve.Request<ExecutionContext>.compute(first: Term, second: Term): Boolean { | ||
return first <= second | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Append.kt
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,42 @@ | ||
package it.unibo.tuprolog.solve.stdlib.rule | ||
|
||
import it.unibo.tuprolog.core.Scope | ||
import it.unibo.tuprolog.core.Term | ||
import it.unibo.tuprolog.solve.ExecutionContext | ||
import it.unibo.tuprolog.solve.Signature | ||
import it.unibo.tuprolog.solve.rule.RuleWrapper | ||
import kotlin.collections.List as KtList | ||
import kotlin.collections.listOf as ktListOf | ||
|
||
sealed class Append : RuleWrapper<ExecutionContext>(FUNCTOR, ARITY) { | ||
|
||
abstract override val Scope.head: KtList<Term> | ||
|
||
object Base : Append() { | ||
override val Scope.head: KtList<Term> | ||
get() = ktListOf( | ||
emptyList(), | ||
varOf("X"), | ||
varOf("X") | ||
) | ||
} | ||
|
||
object Recursive : Append() { | ||
override val Scope.head: KtList<Term> | ||
get() = ktListOf( | ||
consOf(varOf("X"), varOf("Y")), | ||
varOf("Z"), | ||
consOf(varOf("X"), varOf("W")) | ||
) | ||
|
||
override val Scope.body: Term | ||
get() = structOf("append", varOf("Y"), varOf("Z"), varOf("W")) | ||
} | ||
|
||
companion object { | ||
const val FUNCTOR: String = "append" | ||
const val ARITY: Int = 3 | ||
val SIGNATURE: Signature | ||
get() = Signature(FUNCTOR, ARITY) | ||
} | ||
} |
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
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
2 changes: 1 addition & 1 deletion
2
...lve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticEqualTest.kt
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
2 changes: 1 addition & 1 deletion
2
...est/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanOrEqualToTest.kt
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
2 changes: 1 addition & 1 deletion
2
...c/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanTest.kt
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
2 changes: 1 addition & 1 deletion
2
...nTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanOrEqualToTest.kt
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
2 changes: 1 addition & 1 deletion
2
...src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanTest.kt
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
2 changes: 1 addition & 1 deletion
2
.../src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticNotEqualTest.kt
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
19 changes: 19 additions & 0 deletions
19
...ommonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanOrEqualToTest.kt
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,19 @@ | ||
package it.unibo.tuprolog.solve.stdlib.primitive | ||
|
||
import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse | ||
import it.unibo.tuprolog.solve.stdlib.primitive.testutils.TermUtils.greaterOrEqualQueryToResult | ||
import kotlin.test.Test | ||
|
||
/** | ||
* Test class for [TermGreaterThanOrEqualTo] | ||
* | ||
*/ | ||
internal class TermGreaterThanOrEqualToTest { | ||
|
||
@Test | ||
fun computesCorrectResult() { | ||
greaterOrEqualQueryToResult.forEach { (input, result) -> | ||
assertCorrectResponse(TermGreaterThanOrEqualTo, input, result) | ||
} | ||
} | ||
} |
Oops, something went wrong.