Skip to content

Commit

Permalink
fix sampler incompleteness and test
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Dec 16, 2024
1 parent 13d4924 commit 0f5ad69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class BigLFSR(primitivePoly: BigInteger, val start: BigInteger = BigInteger.ONE)

fun sequence() = sequence {
var last = start
yield(last)
var next: BigInteger
while (true) {
val shiftedOutA1: Boolean = last.bitAt(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ai.hypergraph.kaliningraph.parsing
import Grammars
import Grammars.toyArith
import ai.hypergraph.kaliningraph.*
import ai.hypergraph.kaliningraph.types.*
import ai.hypergraph.kaliningraph.repair.vanillaS2PCFG
import ai.hypergraph.kaliningraph.tensor.seekFixpoint
import ai.hypergraph.kaliningraph.types.π2
Expand All @@ -15,6 +16,20 @@ import kotlin.time.*
./gradlew jvmTest --tests "ai.hypergraph.kaliningraph.parsing.SetValiantTest"
*/
class SetValiantTest {
/*
./gradlew jvmTest --tests "ai.hypergraph.kaliningraph.parsing.SetValiantTest.testCompleteness"
*/
@Test
fun testCompleteness() {
val g = Grammars.toyArith
val sols = g.enumSeq("_ + _".tokenizeByWhitespace()).toSet()

val all = g.terminals.filter { it.all { it.isLetterOrDigit() && it.code < 128 } }
.toSet().let { it * it }.map { (a, b) -> "$a + $b" }.toSet()

assertEquals(all, sols)
}

/*
./gradlew jvmTest --tests "ai.hypergraph.kaliningraph.parsing.SetValiantTest.testStressRecognizer"
*/
Expand Down

0 comments on commit 0f5ad69

Please sign in to comment.