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,
In [1]:
import $cp.bin.`provingground-core-jvm-9fbe6a3410.fat.jar`
import provingground._ , interface._, HoTT._, learning._
repl.pprinter() = {
val p = repl.pprinter()
p.copy(
additionalHandlers = p.additionalHandlers.orElse {
translation.FansiShow.fansiHandler
}
)
}
Out[1]:
In [2]:
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))
Out[2]:
In [3]:
val lp = LocalProver(ts)
Out[3]:
In [4]:
ts.vars
import TermData._
val datT = termData(lp)
Out[4]:
In [5]:
import monix.execution.Scheduler.Implicits.global
val td = datT.runSyncUnsafe()
Out[5]:
In [6]:
val (ns, eqs) = td
Out[6]:
In [7]:
val nonDetOpt = eqs.find(eq => TermData.isleNormalize(eq) != TermData.isleNormalize(eq))
Out[7]:
In [8]:
val atoms = (eqs.map(_.rhs).flatMap(Expression.varVals(_)) union eqs.map(_.lhs).flatMap(Expression.varVals(_))).map(_.variable)
Out[8]:
In [9]:
import TermRandomVars._, GeneratorVariables._
val elemTerms = atoms.collect{case Elem(t: Term, Terms) => t}
Out[9]:
In [10]:
elemTerms.exists(_.dependsOn(A))
Out[10]:
In [11]:
val normEqs = eqs.map(eq => TermData.isleNormalize(eq))
Out[11]:
In [12]:
val normAtoms = (normEqs.map(_.rhs).flatMap(Expression.varVals(_)) union normEqs.map(_.lhs).flatMap(Expression.varVals(_))).map(_.variable)
Out[12]:
In [13]:
val normElemTerms = normAtoms.collect{case Elem(t: Term, Terms) => t}
Out[13]:
In [14]:
elemTerms == normElemTerms
Out[14]:
In [15]:
val ts0 = TermState(FiniteDistribution.empty, FiniteDistribution.unif(Type))
Out[15]:
In [16]:
val ev = ExpressionEval.fromInitEqs(ts0, Equation.group(eqs), TermGenParams(), decayS = 0.95)
Out[16]:
In [17]:
val termsT = ev.finalTerms
Out[17]:
In [18]:
val evN = ExpressionEval.fromInitEqs(ts0, Equation.group(normEqs), TermGenParams(), decayS = 0.95)
Out[18]:
In [18]:
// val termsN = evN.finalTerms
In [19]:
evN.init
Out[19]:
In [20]:
import ExpressionEval._
Out[20]:
In [21]:
evN.equations
Out[21]:
In [22]:
val m1 = nextMap(evN.init, evN.equations)
Out[22]:
In [23]:
val exp = m1.find(_._2 < 0)
Out[23]:
In [24]:
val termsN = evN.finalTerms
Out[24]:
In [25]:
evN.finalDist
Out[25]:
In [26]:
evN.finalDist.keys
Out[26]:
In [27]:
import Expression._
evN.finalDist.get(FinalVal(Elem(Type, Typs)))
Out[27]:
In [28]:
normEqs.filter(_.lhs == FinalVal(Elem(Type, Typs)))
Out[28]:
In [29]:
eqs.filter(_.lhs == FinalVal(Elem(Type, Typs)))
Out[29]:
In [30]:
ev.finalDist.get(FinalVal(Elem(Type, Typs)))
Out[30]:
In [31]:
val t = termsT.support.head
Out[31]:
In [32]:
eqs.find(_.lhs == Elem(t, Terms))
Out[32]:
In [33]:
eqs.collect{case eqq @ EquationNode(FinalVal(Elem(_, _)), _) => eqq}
Out[33]:
In [34]:
val eqn0 = eqs.find(_.lhs == FinalVal(Elem(t, Terms))).get
Out[34]:
In [35]:
TermRandomVars.isleNormalize(eqn0)
Out[35]:
In [36]:
val rhs0 = varVals(eqn0.rhs).head
Out[36]:
In [37]:
ev.finalDist.get(rhs0)
Out[37]:
In [38]:
val eqn1 = eqs.filter(_.lhs == rhs0).head
Out[38]:
In [39]:
import TermRandomVars._
isleNormalize(eqn1)
Out[39]:
In [40]:
normEqs.filter(_.lhs == FinalVal(Elem(t, Terms)))
Out[40]:
There is still an equation at this stage. May not be one at the next stage.
In [41]:
val rhsN= varVals(normEqs.filter(_.lhs == FinalVal(Elem(t, Terms))).head.rhs).head
Out[41]:
In [42]:
normEqs.filter(_.lhs == rhsN)
Out[42]:
In [43]:
isleNormalize(eqn1).rhs
Out[43]:
In [44]:
rhsN
Out[44]:
In [45]:
isleNormalize(eqn1).lhs
Out[45]:
In [46]:
val rhsN2 = varVals((normEqs.filter(_.lhs == rhsN)).head.rhs).head
Out[46]:
In [47]:
normEqs.filter(_.lhs == rhsN2)
Out[47]:
In [48]:
val rhs2 = varVals((eqs.filter(_.lhs == rhs0)).head.rhs).head
Out[48]:
In [49]:
eqs.filter(_.lhs == rhs2)
Out[49]:
In [50]:
ev.finalTerms.support -- termsT.support
Out[50]:
In [51]:
ev.finalTerms.support == termsT.support
Out[51]:
In [52]:
ExpressionEval.mapRatio(ev.finalTerms.toMap, termsT.toMap)
Out[52]:
In [53]:
evN.finalTyps.support
Out[53]:
In [ ]:
In [ ]: