Here we test generating final states with equations, including after merging equations from different local provers.
import $cp.bin.`provingground-core-jvm-0b2e2155ea.fat.jar`
import provingground._ , interface._, HoTT._, learning._
repl.pprinter() = {
val p = repl.pprinter()
p.copy(
additionalHandlers = p.additionalHandlers.orElse {
translation.FansiShow.fansiHandler
}
)
}
val M = "M" :: Type
val eqM = "eqM" :: M ->: M ->: Type
val mul = "mul" :: M ->: M ->: M
val m = "m" :: M
val n = "n" :: M
val sym = "sym" :: m ~>: (n ~>: (eqM(m)(n) ->: eqM(n)(m)))
val ts = TermState(FiniteDistribution.unif(M, eqM, mul, m, n, sym), FiniteDistribution.unif(M, Type, eqM.typ, mul.typ, sym.typ))
val lp = LocalProver(ts, decay = 0.95).noIsles
val nsT = lp.nextState.memoize
val evT = lp.expressionEval.memoize
import monix.execution.Scheduler.Implicits.global
val nsF = nsT.runToFuture
evT.map(_.decay).runToFuture
val terms1T = nsT.map(_.terms)
val terms2T = evT.map(_.finalTerms)
terms1T.map(_.entropyVec).runToFuture
terms2T.map(_.entropyVec).runToFuture
val suppDiffT =
for {
t1 <- terms1T
t2 <- terms2T
} yield (t1.support -- t2.support, t2.support -- t1.support)
suppDiffT.runToFuture
The same terms are generated using equations as those in the final distribution. Also (at least with decay) we get the result fairly quickly.
The next step will be to combine with equations from a more focussed generator and check supports.
val ts1 = TermState(FiniteDistribution.unif(mul, m, n), FiniteDistribution.unif(M, Type, mul.typ))
val lp1 = LocalProver(ts1).noIsles.sharpen(10)
val terms3T = lp1.nextState.map(_.terms).memoize
terms3T.runToFuture
val diff3T = for {
t3 <- terms3T
t1 <- terms1T
} yield t3.pmf.find(wt => t1(wt.elem) == 0)
val diff3F = diff3T.runToFuture
val eqs3T = lp1.equations.memoize
eqs3T.runToFuture
val eqs1T = lp.equations.memoize
val eqs1F = eqs1T.runToFuture
val eqsT = (for {
eq1 <- eqs1T
eq3 <- eqs3T
} yield Equation.merge(eq1, eq3)).memoize
eqsT.runToFuture
val evMergeT = eqsT.map(eqs => ExpressionEval.fromInitEqs(ts, eqs, lp.tg, decayS = 0.95)).memoize
val termsMergeT = evMergeT.map(_.finalTerms).memoize
val tmF = termsMergeT.runToFuture
val diffMergeT = for {
tM <- termsMergeT
t1 <- terms1T
} yield tM.pmf.find(wt => t1(wt.elem) == 0)
val dF = diffMergeT.runToFuture
val diffMerge3T = for {
tM <- termsMergeT
t3 <- terms3T
} yield tM.pmf.find(wt => t3(wt.elem) == 0)
val d3F = diffMerge3T.runToFuture
val diff3MergeT = for {
tM <- termsMergeT
t3 <- terms3T
} yield t3.pmf.find(wt => tM(wt.elem) == 0)
val dM3F = diff3MergeT.runToFuture
val diff1MergeT = for {
tM <- termsMergeT
t1 <- terms1T
} yield t1.pmf.find(wt => tM(wt.elem) == 0)
val dM1F = diff1MergeT.runToFuture