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-a0afa6a903.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))
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
evN.init
import ExpressionEval._
evN.equations
val m1 = nextMap(evN.init, evN.equations)
val exp = m1.find(_._2 < 0)
Now we do not get negative values. We should check for evolution.
val termsN = evN.finalTerms
evN.finalDist
evN.finalDist.keys
import Expression._
evN.finalDist.get(FinalVal(Elem(Type, Typs)))
normEqs.filter(_.lhs == FinalVal(Elem(Type, Typs)))
eqs.filter(_.lhs == FinalVal(Elem(Type, Typs)))
ev.finalDist.get(FinalVal(Elem(Type, Typs)))
val t = termsT.support.head
eqs.find(_.lhs == Elem(t, Terms))
eqs.collect{case eqq @ EquationNode(FinalVal(Elem(_, _)), _) => eqq}
val eqn0 = eqs.find(_.lhs == FinalVal(Elem(t, Terms))).get
TermRandomVars.isleNormalize(eqn0)
val rhs0 = varVals(eqn0.rhs).head
ev.finalDist.get(rhs0)
val eqn1 = eqs.filter(_.lhs == rhs0).head
import TermRandomVars._
isleNormalize(eqn1)
normEqs.filter(_.lhs == FinalVal(Elem(t, Terms)))
There is still an equation at this stage. May not be one at the next stage.
val rhsN= normEqs.filter(_.lhs == FinalVal(Elem(t, Terms))).head.rhs