Skip to content

Commit

Permalink
rename methods incompatible with android
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed Nov 6, 2021
1 parent c94640c commit fec568d
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,38 +134,29 @@ interface PrologStdLibScope : PrologAwareScope {
infix fun Any.univ(other: Any): Struct = structOf("=..", this.toTerm(), other.toTerm())

@JsName("eq2")
infix fun Any.`=`(right: Any): Struct =
infix fun Any.eq(right: Any): Struct =
structOf("=", this.toTerm(), right.toTerm())

@JsName("neq2")
infix fun Any.`!=`(right: Any): Struct =
infix fun Any.neq(right: Any): Struct =
structOf("\\=", this.toTerm(), right.toTerm())

@JsName("id2")
infix fun Any.`==`(right: Any): Struct =
infix fun Any.id(right: Any): Struct =
structOf("==", this.toTerm(), right.toTerm())

@JsName("nid2")
infix fun Any.`!==`(right: Any): Struct =
infix fun Any.nid(right: Any): Struct =
structOf("\\==", this.toTerm(), right.toTerm())

@JsName("arithEq2")
infix fun Any.`===`(right: Any): Struct =
infix fun Any.arithEq(right: Any): Struct =
structOf("=:=", this.toTerm(), right.toTerm())

@JsName("arithNeq2")
infix fun Any.`=!=`(right: Any): Struct =
infix fun Any.arithNeq(right: Any): Struct =
structOf("=\\=", this.toTerm(), right.toTerm())

@Suppress("DANGEROUS_CHARACTERS")
@JsName("power")
infix fun Any.`**`(right: Any): Struct =
structOf("**", this.toTerm(), right.toTerm())

@JsName("pow")
infix fun Any.`^`(right: Any): Struct =
structOf("^", this.toTerm(), right.toTerm())

@JsName("member2")
fun member(item: Any, list: Any): Struct =
structOf("member", item.toTerm(), list.toTerm())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class TestNQueens {
staticKb(
rule {
"no_attack"(("X1" and "Y1"), ("X2" and "Y2")) `if` (
("X1" `=!=` "X2") and
("Y1" `=!=` "Y2") and
(("Y2" - "Y1") `=!=` ("X2" - "X1")) and
(("Y2" - "Y1") `=!=` ("X1" - "X2"))
("X1" arithNeq "X2") and
("Y1" arithNeq "Y2") and
(("Y2" - "Y1") arithNeq ("X2" - "X1")) and
(("Y2" - "Y1") arithNeq ("X1" - "X2"))
)
},
fact { "no_attack_all"(`_`, emptyList) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class TestAndImpl(private val solverFactory: SolverFactory) : TestAnd {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = "X" `=` 1 and `var`("X")
val query = "X" eq 1 and `var`("X")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -25,7 +25,7 @@ internal class TestAndImpl(private val solverFactory: SolverFactory) : TestAnd {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = `var`("X") and ("X" `=` 1)
val query = `var`("X") and ("X" eq 1)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down Expand Up @@ -76,7 +76,7 @@ internal class TestAndImpl(private val solverFactory: SolverFactory) : TestAnd {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = "X" `=` true and call("X")
val query = "X" eq true and call("X")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ internal class TestArithImpl(private val solverFactory: SolverFactory) : TestAri
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

var query = 0 `=!=` 1
var query = 0 arithNeq 1
var solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
ktListOf(query.yes()),
solutions
)

query = 1.0 `=!=` 1
query = 1.0 arithNeq 1
solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
ktListOf(query.no()),
solutions
)

query = (numOf(3) * 2) `=!=` (numOf(7) - 1)
query = (numOf(3) * 2) arithNeq (numOf(7) - 1)
solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
ktListOf(query.no()),
solutions
)

query = "N" `=!=` 5
query = "N" arithNeq 5
solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -53,7 +53,7 @@ internal class TestArithImpl(private val solverFactory: SolverFactory) : TestAri
solutions
)

query = "floot"(1) `=!=` 5
query = "floot"(1) arithNeq 5
solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -77,31 +77,31 @@ internal class TestArithImpl(private val solverFactory: SolverFactory) : TestAri
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

var query = 0 `===` 1
var query = 0 arithEq 1
var solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
ktListOf(query.no()),
solutions
)

query = 1.0 `===` 1
query = 1.0 arithEq 1
solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
ktListOf(query.yes()),
solutions
)

query = (numOf(3) * 2) `===` (numOf(7) - 1)
query = (numOf(3) * 2) arithEq (numOf(7) - 1)
solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
ktListOf(query.yes()),
solutions
)

query = "N" `===` 5
query = "N" arithEq 5
solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -118,7 +118,7 @@ internal class TestArithImpl(private val solverFactory: SolverFactory) : TestAri
solutions
)

query = "floot"(1) `===` 5
query = "floot"(1) arithEq 5
solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -136,7 +136,7 @@ internal class TestArithImpl(private val solverFactory: SolverFactory) : TestAri
solutions
)

query = 0.333 `===` (numOf(1) / 3)
query = 0.333 arithEq (numOf(1) / 3)
solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TestBagOfImpl(private val solverFactory: SolverFactory) : TestBagOf {
override fun testBagXInDifferentValues() {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()
val query = bagof("X", ("X" `=` 1) or ("X" `=` 2), "S")
val query = bagof("X", ("X" eq 1) or ("X" eq 2), "S")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -23,7 +23,7 @@ class TestBagOfImpl(private val solverFactory: SolverFactory) : TestBagOf {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = bagof("X", ("X" `=` 1) or ("X" `=` 2), "X")
val query = bagof("X", ("X" eq 1) or ("X" eq 2), "X")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -37,7 +37,7 @@ class TestBagOfImpl(private val solverFactory: SolverFactory) : TestBagOf {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = bagof("X", ("X" `=` "Y") or ("X" `=` "Z"), "L")
val query = bagof("X", ("X" eq "Y") or ("X" eq "Z"), "L")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down Expand Up @@ -65,7 +65,7 @@ class TestBagOfImpl(private val solverFactory: SolverFactory) : TestBagOf {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = bagof("X", "Y" `^` (("X" `=` 1) or ("Y" `=` 2)), "S")
val query = bagof("X", "Y" sup (("X" eq 1) or ("Y" eq 2)), "S")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class TestFindAllImpl(
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = findall("X", ("X" `=` 1) or ("X" `=` 2), "S")
val query = findall("X", ("X" eq 1) or ("X" eq 2), "S")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -28,7 +28,7 @@ internal class TestFindAllImpl(
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = findall("+"("X", "Y"), "X" `=` 1, "S")
val query = findall("+"("X", "Y"), "X" eq 1, "S")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down Expand Up @@ -56,7 +56,7 @@ internal class TestFindAllImpl(
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = findall("X", ("X" `=` 1) or ("X" `=` 1), "S")
val query = findall("X", ("X" eq 1) or ("X" eq 1), "S")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -70,7 +70,7 @@ internal class TestFindAllImpl(
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = findall("X", ("X" `=` 2) or ("X" `=` 1), listOf(1, 2))
val query = findall("X", ("X" eq 2) or ("X" eq 1), listOf(1, 2))
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -84,7 +84,7 @@ internal class TestFindAllImpl(
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = findall("X", ("X" `=` 1) or ("X" `=` 2), listOf("X", "Y"))
val query = findall("X", ("X" eq 1) or ("X" eq 2), listOf("X", "Y"))
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal class TestIfThenElseImpl(private val solverFactory: SolverFactory) : Te
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = ";"("->"(true, ("X" `=` 1)), "X" `=` 2)
val query = ";"("->"(true, ("X" eq 1)), "X" eq 2)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -77,7 +77,7 @@ internal class TestIfThenElseImpl(private val solverFactory: SolverFactory) : Te
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = ";"("->"(fail, ("X" `=` 1)), "X" `=` 2)
val query = ";"("->"(fail, ("X" eq 1)), "X" eq 2)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -91,7 +91,7 @@ internal class TestIfThenElseImpl(private val solverFactory: SolverFactory) : Te
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = ";"("->"(true, ("X" `=` 1) or ("X" `=` 2)), true)
val query = ";"("->"(true, ("X" eq 1) or ("X" eq 2)), true)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -110,7 +110,7 @@ internal class TestIfThenElseImpl(private val solverFactory: SolverFactory) : Te
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = ";"("->"(("X" `=` 1) or ("X" `=` 2), true), true)
val query = ";"("->"(("X" eq 1) or ("X" eq 2), true), true)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal class TestIfThenImpl(private val solverFactory: SolverFactory) : TestIf
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = "->"(true, "X" `=` 1)
val query = "->"(true, "X" eq 1)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -63,7 +63,7 @@ internal class TestIfThenImpl(private val solverFactory: SolverFactory) : TestIf
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = "->"(("X" `=` 1) or ("X" `=` 2), true)
val query = "->"(("X" eq 1) or ("X" eq 2), true)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -77,7 +77,7 @@ internal class TestIfThenImpl(private val solverFactory: SolverFactory) : TestIf
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = "->"(true, ("X" `=` 1) or ("X" `=` 2))
val query = "->"(true, ("X" eq 1) or ("X" eq 2))
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class TestIsImpl(private val solverFactory: SolverFactory) : TestIs {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = ("X" `=` (intOf(1) + intOf(2))) and ("Y" `is` ("X" * intOf(3)))
val query = ("X" eq (intOf(1) + intOf(2))) and ("Y" `is` ("X" * intOf(3)))
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ internal class TestNonVarImpl(private val solverFactory: SolverFactory) : TestNo
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = ("foo" `=` "Foo") and nonvar("Foo")
val query = ("foo" eq "Foo") and nonvar("Foo")
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TestNotProvableImpl(
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = ((("X" `=` 1) or ("X" `=` 2)) and "not"(("!" and fail)))
val query = ((("X" eq 1) or ("X" eq 2)) and "not"(("!" and fail)))
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -79,7 +79,7 @@ class TestNotProvableImpl(
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = "not"(4 `=` 5)
val query = "not"(4 eq 5)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class TestOnceImpl(
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

val query = ("once"("!") and (("X" `=` 1) or ("X" `=` 2)))
val query = ("once"("!") and (("X" eq 1) or ("X" eq 2)))
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ internal class TestOrImpl(private val solverFactory: SolverFactory) : TestOr {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

// val query = ";"(("X" `=` 1 and "!"), "X" `=` 2)
val query = ("X" `=` 1 and "!") or ("X" `=` 2)
// val query = ";"(("X" eq 1 and "!"), "X" eq 2)
val query = ("X" eq 1 and "!") or ("X" eq 2)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand All @@ -73,8 +73,8 @@ internal class TestOrImpl(private val solverFactory: SolverFactory) : TestOr {
prolog {
val solver = solverFactory.solverWithDefaultBuiltins()

// val query = ";"("X" `=` 1, "X" `=` 2)
val query = ("X" `=` 1) or ("X" `=` 2)
// val query = ";"("X" eq 1, "X" eq 2)
val query = ("X" eq 1) or ("X" eq 2)
val solutions = solver.solve(query, mediumDuration).toList()

assertSolutionEquals(
Expand Down
Loading

0 comments on commit fec568d

Please sign in to comment.