This is after correcting the issue with context variables. There are still a couple of things to test and correct.
When we have variables such as $A: Type$, $a : A$ and $B: Type$, we test whether we correctly:
This time the test is more refined. Namely,
import $cp.bin.`provingground-core-jvm-38c4a5770c.fat.jar`
import provingground._ , interface._, HoTT._, learning._
repl.pprinter() = {
val p = repl.pprinter()
p.copy(
additionalHandlers = p.additionalHandlers.orElse {
translation.FansiShow.fansiHandler
}
)
}
val A = "A" :: Type
val B = "B" :: Type
val a = "a" :: A
val ts = TermState(FiniteDistribution.unif(a), FiniteDistribution.unif(A, B), vars = Vector(A, B, a))
val lp = LocalProver(ts)
ts.vars
import TermData._
val datT = termData(lp)
import monix.execution.Scheduler.Implicits.global
val td = datT.runSyncUnsafe()
val (ns, eqs) = td
val nonDetOpt = eqs.find(eq => TermData.isleNormalize(eq) != TermData.isleNormalize(eq))
val atoms = (eqs.map(_.rhs).flatMap(Expression.varVals(_)) union eqs.map(_.lhs).flatMap(Expression.varVals(_))).map(_.variable)
import TermRandomVars._, GeneratorVariables._
val elemTerms = atoms.collect{case Elem(t: Term, Terms) => t}
elemTerms.exists(_.dependsOn(A))
atoms.size
val elemTyps = atoms.collect{case Elem(t: Typ[Term], Typs) => t}
val normEqs = eqs.map(eq => TermData.isleNormalize(eq))
val normAtoms = (normEqs.map(_.rhs).flatMap(Expression.varVals(_)) union normEqs.map(_.lhs).flatMap(Expression.varVals(_))).map(_.variable)
val normElemTerms = normAtoms.collect{case Elem(t: Term, Terms) => t}
elemTerms == normElemTerms
val ts0 = TermState(FiniteDistribution.empty, FiniteDistribution.unif(Type))
val ev = ExpressionEval.fromInitEqs(ts0, Equation.group(eqs), TermGenParams(), decayS = 0.95)
val termsT = ev.finalTerms
val evN = ExpressionEval.fromInitEqs(ts0, Equation.group(normEqs), TermGenParams(), decayS = 0.95)
// val termsN = evN.finalTerms
import ExpressionEval._
val m1 = nextMap(evN.init, evN.equations)
m1.values
val exp = m1.find(_._2 < 0).get._1
val rhs = evN.equations.find(_.lhs == exp).map(_.rhs).get
normEqs.filter(_.lhs == exp)
normEqs.filter(_.lhs == exp).size
val baseEqs = eqs.filter(eq => TermData.isleNormalize(eq).lhs == exp)
baseEqs.size
show(baseEqs.map(_.rhs))
show(baseEqs.map(_.lhs))
show(normEqs.filter(_.lhs == exp))
val baseGps = baseEqs.groupBy(eq => TermData.isleNormalize(eq))
show(baseGps.head)
baseGps.head._2.size
baseGps.size
baseGps.values.map(_.size)
show(baseGps.tail.head)
show(baseGps.tail.tail.head)
import TermRandomVars._, TermGeneratorNodes._
val rvA = termsWithTyp(A)
randomVarSubs(A, B)(rvA)
val eqn = baseGps.toVector(2)._2.head
TermData.isleNormalize(eqn)
@a
got replaced with %boat
, both of type B
, is fine. B
got replaced by @a
, we should have had a change in the random variable.