import $cp.bin.`provingground-core-jvm-b8c7356944.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 ts = TermState(FiniteDistribution.unif(A, B), FiniteDistribution.unif(A, B, Type), vars = Vector(A, B))
val MPAB = A ->: (A ->: B) ->: B
val MP = A ~>: (B ~>: MPAB)
val lp1 = LocalProver(ts, tg = TermGenParams(sigmaW = 0), relativeEval = true).sharpen(10)
import monix.execution.Scheduler.Implicits.global
val evT1 = lp1.expressionEval
evT1.map(_.finalTyps(MP)).runToFuture
evT1.map(_.finalTerms.filter(_.typ == MP)).runToFuture
val ts2 = TermState(FiniteDistribution(), FiniteDistribution.unif(Type), goals = FiniteDistribution.unif(MP))
val lp2 = LocalProver(ts2, tg = TermGenParams(sigmaW = 0), relativeEval = true).sharpen(10)
val evT2 = lp2.expressionEval
evT2.map(_.finalTerms.filter(_.typ == MP)).runToFuture
val mpPfsT = evT2.map(_.finalTerms.filter(_.typ == MP))
val mpEqsT = mpPfsT.map{pfs => pfs.support.flatMap(pf => DE.formalEquations(pf))}
mpEqsT.runToFuture
val evT3 = for{
ev <- evT2
ev1 <- evT1
eqs <- mpEqsT
} yield ev.modify(equationsNew = ev1.equations union Equation.group(eqs union DE.termStateInit(ts)) )
evT3.map(_.finalTerms.filter(_.typ == MP)).runToFuture
evT3.map(_.finalTyps(Type)).runToFuture
import GeneratorVariables._, Expression._, TermRandomVars._
val targT = evT3.map(ev => ev.equations.collect{case eq @ Equation(FinalVal(Elem(t : Term, Terms)), _) if t.typ == MP => eq})
targT.runToFuture
val tsU = TermState(FiniteDistribution(), FiniteDistribution.unif(Type))
val a = "a" :: A
val f = "f" :: (A ->: B)
val mp = a :-> (f :-> f(a))
val mpU = A :~> (B :~> mp)
val eqNodesU = DE.formalEquations(mpU) union DE.termStateInit(tsU)
val evU = ExpressionEval.fromInitEqs(tsU, Equation.group(eqNodesU), TermGenParams())
evU.finalTerms
evU.finalTerms(mpU)
val eqNodesUT = mpEqsT.map (_ union DE.termStateInit(tsU))
val evUT = eqNodesUT.map{nodes => ExpressionEval.fromInitEqs(tsU, Equation.group(nodes) , TermGenParams())}
evUT.map(_.finalTerms(mpU)).runToFuture
evUT.map(_.finalTerms.filter(_.typ == MP)).runToFuture