In [1]:
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
}
)
}
Out[1]:
In [2]:
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)
Out[2]:
In [3]:
val lp1 = LocalProver(ts, tg = TermGenParams(sigmaW = 0), relativeEval = true).sharpen(10)
Out[3]:
In [4]:
import monix.execution.Scheduler.Implicits.global
val evT1 = lp1.expressionEval
evT1.map(_.finalTyps(MP)).runToFuture
In [5]:
evT1.map(_.finalTerms.filter(_.typ == MP)).runToFuture
In [6]:
val ts2 = TermState(FiniteDistribution(), FiniteDistribution.unif(Type), goals = FiniteDistribution.unif(MP))
Out[6]:
In [7]:
val lp2 = LocalProver(ts2, tg = TermGenParams(sigmaW = 0), relativeEval = true).sharpen(10)
Out[7]:
In [8]:
val evT2 = lp2.expressionEval
evT2.map(_.finalTerms.filter(_.typ == MP)).runToFuture
In [9]:
val mpPfsT = evT2.map(_.finalTerms.filter(_.typ == MP))
val mpEqsT = mpPfsT.map{pfs => pfs.support.flatMap(pf => DE.formalEquations(pf))}
Out[9]:
In [10]:
mpEqsT.runToFuture
In [14]:
val evT3 = for{
ev <- evT2
ev1 <- evT1
eqs <- mpEqsT
} yield ev.modify(equationsNew = ev1.equations union Equation.group(eqs union DE.termStateInit(ts)) )
Out[14]:
In [15]:
evT3.map(_.finalTerms.filter(_.typ == MP)).runToFuture
In [16]:
evT3.map(_.finalTyps(Type)).runToFuture
In [17]:
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})
Out[17]:
In [19]:
targT.runToFuture
In [21]:
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)
Out[21]:
In [22]:
val evU = ExpressionEval.fromInitEqs(tsU, Equation.group(eqNodesU), TermGenParams())
Out[22]:
In [23]:
evU.finalTerms
Out[23]:
In [25]:
evU.finalTerms(mpU)
Out[25]:
In [26]:
val eqNodesUT = mpEqsT.map (_ union DE.termStateInit(tsU))
Out[26]:
In [27]:
val evUT = eqNodesUT.map{nodes => ExpressionEval.fromInitEqs(tsU, Equation.group(nodes) , TermGenParams())}
Out[27]:
In [28]:
evUT.map(_.finalTerms(mpU)).runToFuture
In [30]:
evUT.map(_.finalTerms.filter(_.typ == MP)).runToFuture