We illustrate in a simple case deriving equations to generate a term. This is useful if terms and types have come externally, for instance by experimentation or from the literature.
import $cp.bin.`provingground-core-jvm-e0f46c1def.fat.jar`
import provingground._ , interface._, HoTT._, learning._
repl.pprinter() = {
val p = repl.pprinter()
p.copy(
additionalHandlers = p.additionalHandlers.orElse {
translation.FansiShow.fansiHandler
}
)
}
First we define some terms and types
val A = Type.sym
val B = Type.sym
val a = A.sym
val f = "f" :: A ->: B
val mp = a :-> (f :-> f(a))
We derive equations and construct an expression evaluator
val de = new DerivedEquations
val tg = TermGenParams()
val ts = TermState(FiniteDistribution(), FiniteDistribution.unif(A, B))
val eqNodes = de.formalEquations(mp) union de.termStateInit(ts)
val ev = ExpressionEval.fromInitEqs(ts, Equation.group(eqNodes), tg)
We check that we can generate mp
ev.finalTerms
First conclusion: We successfully generated modus ponens depending on $A$ and $B$.
We next turn to Modus Ponens, but in its full (universal) form
val mpU = A :~> (B :~> mp)
val tsU = TermState(FiniteDistribution(), FiniteDistribution.unif(Type))
val eqNodesU = de.formalEquations(mpU) union de.termStateInit(tsU)
val evU = ExpressionEval.fromInitEqs(tsU, Equation.group(eqNodesU), tg)
evU.finalTerms
We see that derived equations allow us to generate Modus Ponens.