New Memoized Liberal goal chomping

  • We run a variant of the most basic strategic prover - a goal chomper that keeps trying a succession of goals.
  • The change from the last time is that terms are remembered and looked up but with a map.
  • Termination is when all goals are finished; with failures recorded.
  • Proving is only by generation, with the generation including backward reasoning rules.
  • So far the goal chomper is untested; we test this.
  • We also test updating displays etc.
In [1]:
import $cp.bin.`provingground-core-jvm-bcec456d48.fat.jar`
import provingground._ , interface._, HoTT._, learning._ 
repl.pprinter() = {
  val p = repl.pprinter()
  p.copy(
    additionalHandlers = p.additionalHandlers.orElse {
      translation.FansiShow.fansiHandler
    }
  )
}
Out[1]:
import $cp.$                                              

import provingground._ , interface._, HoTT._, learning._ 
In [2]:
val terms = FiniteDistribution.unif[Term](Unit, Zero, Star)
val typs = FiniteDistribution.unif[Typ[Term]](Type, Unit, Zero)
val ts = TermState(terms, typs)
val ts0 = TermState(FiniteDistribution(), FiniteDistribution.unif(Type))
val tg = TermGenParams(solverW = 0.05)
Out[2]:
terms: FiniteDistribution[Term] = FiniteDistribution(
  Vector(
    Weighted(Unit, 0.3333333333333333),
    Weighted(Zero, 0.3333333333333333),
    Weighted(Star, 0.3333333333333333)
  )
)
typs: FiniteDistribution[Typ[Term]] = FiniteDistribution(
  Vector(
    Weighted(š’° , 0.3333333333333333),
    Weighted(Unit, 0.3333333333333333),
    Weighted(Zero, 0.3333333333333333)
  )
)
ts: TermState = TermState(
  FiniteDistribution(
    Vector(
      Weighted(Unit, 0.3333333333333333),
      Weighted(Zero, 0.3333333333333333),
      Weighted(Star, 0.3333333333333333)
    )
  ),
  FiniteDistribution(
    Vector(
      Weighted(š’° , 0.3333333333333333),
      Weighted(Unit, 0.3333333333333333),
      Weighted(Zero, 0.3333333333333333)
    )
  ),
  Vector(),
  FiniteDistribution(Vector()),
  FiniteDistribution(Vector()),
  Empty
)
ts0: TermState = TermState(
  FiniteDistribution(Vector()),
  FiniteDistribution(Vector(Weighted(š’° , 1.0))),
  Vector(),
  FiniteDistribution(Vector()),
  FiniteDistribution(Vector()),
  Empty
)
tg: TermGenParams = TermGenParams(
  0.1,
  0.1,
  0.1,
  0.1,
  0.1,
  0.05,
  0.05,
  0.05,
  0.0,
  0.0,
  0.0,
  0.0,
  0.3,
  0.7,
  0.5,
  0.0,
  0.05,
  0.0,
  OrElse(
    OrElse(OrElse(OrElse(<function1>, <function1>), <function1>), <function1>),
    <function1>
  )
)
In [3]:
import monix.execution.Scheduler.Implicits.global
val lp = LocalProver(ts, tg).sharpen(10)
val lp0 = LocalProver(ts0).sharpen(10)
Out[3]:
import monix.execution.Scheduler.Implicits.global

lp: LocalProver = LocalProver(
  TermState(
    FiniteDistribution(
      Vector(
        Weighted(Unit, 0.3333333333333333),
        Weighted(Zero, 0.3333333333333333),
        Weighted(Star, 0.3333333333333333)
      )
    ),
    FiniteDistribution(
      Vector(
        Weighted(š’° , 0.3333333333333333),
        Weighted(Unit, 0.3333333333333333),
        Weighted(Zero, 0.3333333333333333)
      )
    ),
    Vector(),
    FiniteDistribution(Vector()),
    FiniteDistribution(Vector()),
    Empty
  ),
  TermGenParams(
    0.1,
    0.1,
    0.1,
    0.1,
    0.1,
    0.05,
    0.05,
    0.05,
    0.0,
    0.0,
    0.0,
    0.0,
    0.3,
    0.7,
    0.5,
    0.0,
    0.05,
...
lp0: LocalProver = LocalProver(
  TermState(
    FiniteDistribution(Vector()),
    FiniteDistribution(Vector(Weighted(š’° , 1.0))),
    Vector(),
    FiniteDistribution(Vector()),
    FiniteDistribution(Vector()),
    Empty
  ),
  TermGenParams(
    0.1,
    0.1,
    0.1,
    0.1,
    0.1,
    0.05,
    0.05,
    0.05,
    0.0,
    0.0,
    0.0,
    0.0,
    0.3,
    0.7,
    0.5,
    0.0,
    0.0,
    0.0,
    OrElse(
      OrElse(OrElse(OrElse(<function1>, <function1>), <function1>), <function1>),
      <function1>
    )
  ),
  1.0E-5,
  12 minutes,
  1.01,
  1.0,
  10000,
...
In [4]:
val unknownsT = lp0.unknownStatements.map(_.entropyVec.map(_.elem)).memoize
val unF = unknownsT.runToFuture
In [5]:
import StrategicProvers._
import almond.display._
val chompView = Markdown("## Results from Goal chomping\n")

Goal chomping status

  • current goal : Some(((@a : š’° _0 ) ~> (((@a) ā†’ (š’° _0)) ā†’ (š’° _0))) ā†’ (š’° _0))
  • successes : 146
  • failures : 29
  • terms : 35368
  • equation-nodes: 3011386
  • last success : Some(Vector((āˆ‘((@a : š’° _0) ā†¦ ((@a) ā†’ (Zero))),0.5,[((Zero) , (rec(Zero)(Zero))) : 0.01127994556862484, ((Zero) , ((@a : Zero) ā†¦ (@a))) : 0.00974783102948558])))
  • last failure : Some((š’° _0) ā†’ ((@b : š’° _0 ) ~> (@b)))
Out[5]:
import StrategicProvers._

import almond.display._
In [6]:
update = (_) => chompView.withContent(md).update()
update(())
In [7]:
val chT = unknownsT.flatMap(typs => liberalChomper(lp, typs, accumTerms = Set())).memoize
val chF = chT.runToFuture
In [8]:
val failHandle = Markdown(failures.reverse.mkString("## Failures\n\n * ", "\n * ", "\n"))

Failures

  • āˆ‘((@a : š’° _0) ā†¦ ((@a) ā†’ ((š’° _0) ā†’ (`@a))))
  • (((š’° _0) ā†’ (š’° _0)) ā†’ (š’° _0)) ā†’ ((@a : š’° _0 ) ~> (@a))
  • (((@a : š’° _0 ) ~> ((š’° _0) ā†’ (@a))) ā†’ (š’° _0)) ā†’ (š’° _0)
  • āˆ‘((@a : š’° _0) ā†¦ ((@a) ā†’ (((š’° _0) , (š’° _0)))))
  • āˆ‘((@a : š’° _0) ā†¦ ((@a : (š’° _0) ā†’ (š’° _0) ) ~> ((@a) (@a))))
  • (š’° _0) ā†’ (āˆ‘((@b : š’° _0) ā†¦ ((@b) ā†’ (`@b))))
  • āˆ‘((@a : š’° _0) ā†¦ ((((š’° _0) , (@a))) ā†’ (š’° _0)))
  • āˆ‘((@a : š’° _0) ā†¦ ((@a) ā†’ ((`@a) ā†’ (š’° _0))))
  • āˆ‘((@a : š’° _0) ā†¦ ((š’° _0) ā†’ ((@a) ā†’ (š’° _0))))
  • (š’° _0) ā†’ ((@b : š’° _0 ) ~> (((@b) , (`@b))))
  • (@a : š’° _0 ) ~> ((@a : (š’° _0) ā†’ (š’° _0) ) ~> ((@a) (@a)))
  • (š’° _0) ā†’ ((@b : š’° _0 ) ~> (((š’° _0) , (@b))))
  • (āˆ‘((@a : š’° _0) ā†¦ (@a))) ā†’ ((@a : š’° _0 ) ~> (@a))
  • āˆ‘((@a : š’° _0) ā†¦ ((((@a) , (š’° _0))) ā†’ (š’° _0)))
  • āˆ‘((@a : š’° _0) ā†¦ ((((@a) ā†’ (š’° _0)) , (š’° _0))))
  • (@a : (š’° _0) ā†’ (š’° _0) ) ~> (āˆ‘((@a : š’° _0) ā†¦ ((@a) (@a))))
  • (š’° _0) ā†’ (āˆ‘((@b : š’° _0) ā†¦ ((@b) ā†’ (š’° _0))))
  • (š’° _0) ā†’ (((š’° _0) , ((@c : š’° _0 ) ~> (@c))))
  • (āˆ‘((@a : š’° _0) ā†¦ ((@a) ā†’ (`@a)))) ā†’ (š’° _0)
  • āˆ‘((@a : š’° _0) ā†¦ ((@a) ā†’ ((š’° _0) ā†’ (š’° _0))))
  • (š’° _0) ā†’ ((@b : š’° _0 ) ~> (((@b) , (š’° _0))))
  • (š’° _0) ā†’ ((@b : š’° _0 ) ~> ((š’° _0) ā†’ (@b)))
  • (š’° _0) ā†’ ((((@b : š’° _0 ) ~> (@b)) , (š’° _0)))
  • (@a : (š’° _0) ā†’ (š’° _0) ) ~> ((@a : š’° _0 ) ~> ((@a) (@a)))
  • (((š’° _0) , (š’° _0))) ā†’ ((@a : š’° _0 ) ~> (@a))
  • (š’° _0) ā†’ ((š’° _0) ā†’ ((@c : š’° _0 ) ~> (@c)))
  • ((@a : š’° _0 ) ~> ((š’° _0) ā†’ (@a))) ā†’ (š’° _0)
  • ((š’° _0) ā†’ (š’° _0)) ā†’ ((@a : š’° _0 ) ~> (@a))
  • (š’° _0) ā†’ ((@b : š’° _0 ) ~> (@b))
In [9]:
update = (_) => {
    chompView.withContent(md).update()  
    failHandle.withContent(failures.reverse.mkString("## Failures\n\n * ", "\n * ", "\n")).update()
}
In [10]:
update(())
In [ ]: