We test backward reasoning for the $e_l = e_r$ in a monoid.
import $ivy.`io.github.siddhartha-gadgil::provingground-core-jvm:0.1.1-SNAPSHOT`
import provingground._ , interface._, HoTT._
import learning._
import library._, MonoidSimple._
repl.pprinter.bind(translation.FansiShow.fansiPrint)
val tg = TermGenParams(lmW=0, piW=0)
val ts = TermState(dist1, dist1.map(_.typ))
val mfd = tg.monixFD
val tgT = mfd.nodeDist(ts)(tg.Gen.codomainNode(eqM(l)(r)), 0.0001)
The above is looking at backward reasoning for $e_l = e_r$. We see that
import monix.execution.Scheduler.Implicits.global
val tgD = tgT.runSyncUnsafe()
val tgT1 = mfd.nodeDist(ts)(tg.Gen.codomainNode(eqM(op(l)(r))(r)), 0.0001)
We are next targeting $e_l * e_r = e_r$. Here the main thing we see is we get a proof with weight $0.3$ straightaway. We also get symmetry and transitivity as before.
val tgD1 = tgT1.runSyncUnsafe()
ts.terms
tgD1.filter(_.typ == eqM(op(l)(r))(r))
val tgT2 = mfd.nodeDist(ts)(tg.Gen.codomainNode(eqM(r)(op(l)(r))), 0.0001)
This is essentially the same as above. Just verifies that we get symmetry. If this is chained with the previous example, we get a proof directly.
val tgD2 = tgT2.runSyncUnsafe()
val tgtT2 = mfd.nodeDist(ts)(tg.Gen.foldedTargetFunctionNode(eqM(r)(op(l)(r))), 0.0001)
And indeed, here is a proof of the lemma.
val tgtD2 = tgtT2.runSyncUnsafe()
We test backward reasoning using the standard equality instead of a custom equality type. This now works.
import IdentityTyp._
symmTerm
transTerm
symmTerm (M) (l) (r)
symmTerm(M)(l)(r).typ
transTerm(M).typ
val ts0 = TermState(FiniteDistribution.unif(symmTerm, transTerm, l, r), FiniteDistribution.unif(M))
val tgT0 = mfd.nodeDist(ts0)(tg.Gen.codomainNode(l =:= r), 0.001)
Unify.targetCodomain(symmTerm, l =:= r)