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-8dd937ec3a.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), context = Context.Empty.addVariable(A).addVariable(B).addVariable(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 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))
None of the terms depends on the variables
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
termsT.support == termsN.support
ExpressionEval.mapRatio(termsT.toMap, termsN.toMap)
val bigT = termsT.support.maxBy(t => termsT(t) / termsN(t))
termsT(bigT)
termsN(bigT)
val bigN = termsT.support.maxBy(t => termsN(t) / termsT(t))
termsT(bigN)
termsN(bigN)
val ns = lp.nextState.runSyncUnsafe()
The error is clearly present here too. The next check is where we change the context.
val ts1 = ts.copy(context = Context.Empty)
val lp1 = lp.copy(initState = ts1)
val ns1 = lp1.nextState.runSyncUnsafe()
ns1.terms.support -- ns.terms.support
ns.terms.support -- ns1.terms.support
val t = ns.terms.pmf(13).elem
val tOpt = ns1.terms.support.find(x => x == t)
tOpt.get == t
t == tOpt.get
val x = nextVar(A, Vector(A, B, a))
val ctx = ts.context.addVariable(x)
val y = nextVar(A, ctx.variables)
ts.context
ts.context.variables
ctx.variables
It is evident what caused the error - the variable in a context changed its type. The code has been corrected to no longer use contexts, and the stuff should be run without contexts.