This correctly scales up cutoff (but perhaps too much, we also scale within Pi
and PiOpt
)
import $ivy.`io.github.siddhartha-gadgil::provingground-core-jvm:0.1.0`
import $ivy.$
import provingground._ , interface._, HoTT._
import provingground.{FiniteDistribution => FD}
import learning._
import provingground._ , interface._, HoTT._ import provingground.{FiniteDistribution => FD} import learning._
val A = Type.sym
val B = Type.sym
val MP = A ~>: B ~>: (A ->: (A ->: B) ->: B)
val ts = TermState(FD.unif(Type), FD.unif(Type), goals = FD.unif(MP))
val tg = TermGenParams()
val mfeq = MonixFiniteDistributionEq(tg.nodeCoeffSeq)
A: Typ[Term] = SymbTyp(Name("A"), 0) B: Typ[Term] = SymbTyp(Name("B"), 0) MP: GenFuncTyp[Typ[Term], FuncLike[Typ[Term], Func[Term, Func[Func[Term, Term], Term]]]] = PiDefn( SymbTyp(A, 0), PiDefn( SymbTyp(B, 0), FuncTyp( SymbTyp(A, 0), FuncTyp(FuncTyp(SymbTyp(A, 0), SymbTyp(B, 0)), SymbTyp(B, 0)) ) ) ) ts: TermState = TermState( FiniteDistribution(Vector(Weighted(Universe(0), 1.0))), FiniteDistribution(Vector(Weighted(Universe(0), 1.0))), Vector(), FiniteDistribution(Vector()), FiniteDistribution( Vector( Weighted( PiDefn( SymbTyp(A, 0), PiDefn( SymbTyp(B, 0), FuncTyp( SymbTyp(A, 0), FuncTyp(FuncTyp(SymbTyp(A, 0), SymbTyp(B, 0)), SymbTyp(B, 0)) ) ) ), 1.0 ) ) ), Empty ) tg: TermGenParams = TermGenParams( 0.1, 0.1, 0.1, 0.1, 0.1, 0.05, 0.05, 0.05, 0.3, 0.7, 0.5 ) mfeq: MonixFiniteDistributionEq[TermState, Term] = MonixFiniteDistributionEq( Cons( BaseCons( BasePi( provingground.learning.RandomVarFamily$$Lambda$3554/221246939@4aa1ee39, FuncsWithDomain ), 0.55, BaseCons( BasePi( provingground.learning.GeneratorNode$$Lambda$3557/663473340@6729cd9, FuncsWithDomain ), 0.1, BaseCons( BasePi( provingground.learning.GeneratorNode$$Lambda$3557/663473340@5bb9a681, FuncsWithDomain ), 0.1, BaseCons( BasePi( provingground.learning.GeneratorNode$$Lambda$3557/663473340@4c9bcba1, FuncsWithDomain ), 0.1, BaseCons( BasePi( provingground.learning.TermGeneratorNodes$$Lambda$3548/391798791@67b57543, FuncsWithDomain ), 0.1, Target(FuncsWithDomain) ) ) ) ...
import TermRandomVars._
val getMPhard = mfeq.varDist(ts)(Terms, 0.0001)
import TermRandomVars._ getMPhard: monix.eval.Task[(FiniteDistribution[Term], Set[GeneratorVariables.EquationTerm])] = FlatMap( Async(<function2>, true, true, true), monix.eval.Task$$Lambda$3706/1986317742@217b0f83 )
import monix.execution.Scheduler.Implicits.global
val (fd, eqs) = getMPhard.runSyncUnsafe()
import monix.execution.Scheduler.Implicits.global fd: FiniteDistribution[Term] = FiniteDistribution( Vector( Weighted( LambdaFixed( PiSymbolicFunc(Name("_"), SymbTyp(@a, 0), SymbTyp(@a, 0)), LambdaFixed(SymbTyp(Name("_"), 0), Universe(0)) ), 2.489207011819105E-4 ), Weighted( LambdaFixed( SymbTyp(Name("_"), 0), LambdaFixed( PiSymbolicFunc(Name("_"), SymbTyp(@b, 0), SymbTyp(@b, 0)), Universe(0) ) ), 1.4161641559025961E-4 ), Weighted( LambdaFixed( PairTerm( SymbTyp(LeftProjSym(Name("_")), 0), SymbolicFunc(RightProjSym(Name("_")), Universe(0), Universe(0)) ), Universe(0) ), 2.3119896721372646E-4 ), Weighted( LambdaFixed( PairTerm( SymbTyp(LeftProjSym(Name("_")), 0), SymbTyp(RightProjSym(Name("_")), 0) ), LambdaFixed(SymbTyp(Name("_"), 0), Universe(0)) ), 3.1505650767257745E-4 ), ... eqs: Set[GeneratorVariables.EquationTerm] = Set( EquationTerm( FinalVal( Elem(ProdTyp(Universe(0), FuncTyp(Universe(0), Universe(0))), Typs) ), Product( Coeff( FlatMap( Typs, provingground.learning.TermGeneratorNodes$$Lambda$3550/841967481@1bb34c77, Typs ), Typs ), FinalVal( InIsle( Elem(FuncTyp(Universe(0), Universe(0)), Typs), SymbTyp(Name("@a"), 0), Island(Typs, ConstRandVar(Typs), AddVar(Universe(0), 0.3), Sigma, InIsle) ) ) ) ), EquationTerm( InitialVal( InIsle( InIsle( Elem(Universe(0), Typs), SymbTyp(Name("@b"), 0), Island(Typs, ConstRandVar(Typs), AddVar(Universe(0), 0.3), Sigma, InIsle) ), SymbTyp(Name("@a"), 0), Island(Typs, ConstRandVar(Typs), AddVar(Universe(0), 0.3), Pi, InIsle) ) ), Product( IsleScale(SymbTyp(Name("@b"), 0), Elem(Universe(0), Typs)), InitialVal( ...
repl.pprinter.bind(translation.FansiShow.fansiPrint)
fd.filter(_.typ == MP)
res5_1: FiniteDistribution[Term] = FiniteDistribution( Vector( Weighted((@a : 𝒰 ) ↦ (@b : 𝒰 ) ↦ (@a : @a) ↦ (@a : (@a → @b)) ↦ @a(@a), 0.03928111738491071) ) )
, Expression._
val mpEqs = eqs.collect{case eq @ EquationTerm(FinalVal(Elem(t : Term, _)), _) if t.typ == MP => eq}
import GeneratorVariables._ mpEqs: Set[EquationTerm] = Set( EquationTerm( FinalVal(Elem((@a : 𝒰 ) ↦ (@b : 𝒰 ) ↦ (@a : @a) ↦ (@a : (@a → @b)) ↦ @a(@a), Terms)), Product( Product( Coeff(ZipFlatMap(TargetTyps, TermsWithTyp, Proj2, Terms), Terms), FinalVal(Elem(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }, TargetTyps)) ), FinalVal( Elem( (@a : 𝒰 ) ↦ (@b : 𝒰 ) ↦ (@a : @a) ↦ (@a : (@a → @b)) ↦ @a(@a), AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil) ) ) ) ), EquationTerm( FinalVal( Elem( (@a : 𝒰 ) ↦ (@b : 𝒰 ) ↦ (@a : @a) ↦ (@a : (@a → @b)) ↦ @a(@a), AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil) ) ), Product( Coeff( Island( AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil), PiOutput(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }), AddVar(𝒰 , 0.3), Lambda, InIsle ), AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil) ), FinalVal( InIsle( Elem( (@b : 𝒰 ) ↦ (@a : @a) ↦ (@a : (@a → @b)) ↦ @a(@a), AtCoord(TermsWithTyp, ∏(B : 𝒰 ){ (@a → ((@a → B) → B)) } :: HNil) ), @a, Island( AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil), PiOutput(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }), AddVar(𝒰 , 0.3), Lambda, InIsle ) ) ...
val ats = mpEqs.map(_.rhs).flatMap(Expression.atoms)
ats: Set[Expression] = Set( Coeff(ZipFlatMap(TargetTyps, TermsWithTyp, Proj2, Terms), Terms), FinalVal( Elem( (@a : 𝒰 ) ↦ (@b : 𝒰 ) ↦ (@a : @a) ↦ (@a : (@a → @b)) ↦ @a(@a), AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil) ) ), Coeff( Island( AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil), PiOutput(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }), AddVar(𝒰 , 0.3), Lambda, InIsle ), AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil) ), FinalVal(Elem(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }, TargetTyps)), FinalVal( InIsle( Elem( (@b : 𝒰 ) ↦ (@a : @a) ↦ (@a : (@a → @b)) ↦ @a(@a), AtCoord(TermsWithTyp, ∏(B : 𝒰 ){ (@a → ((@a → B) → B)) } :: HNil) ), @a, Island( AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil), PiOutput(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }), AddVar(𝒰 , 0.3), Lambda, InIsle ) ) ) )
val coeffs = ats.collect{case cf @ Coeff(_, _) => cf}.toVector
coeffs: Vector[Coeff[Any]] = Vector( Coeff(ZipFlatMap(TargetTyps, TermsWithTyp, Proj2, Terms), Terms), Coeff( Island( AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil), PiOutput(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }), AddVar(𝒰 , 0.3), Lambda, InIsle ), AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil) ) )
coeffs.map(_.get(tg.nodeCoeffSeq))
res9: Vector[Option[Double]] = Vector(Some(0.05), Some(0.485))
coeffs.map(_.expand)
res10: Vector[RandomVarFamily[_, Any] forSome { type _ <: shapeless.HList }] = Vector( Terms, TermsWithTyp )
tg.nodeCoeffSeq.find(TermsWithTyp)
res11: Option[NodeCoeffs[TermState, Term, Double, shapeless.::[Typ[Term], shapeless.HNil], Term]] = Some( BaseCons( BasePi(provingground.learning.RandomVarFamily$$Lambda$3554/221246939@25eb7b07, TermsWithTyp), 0.16500000000000004, BaseCons( BasePi(provingground.learning.GeneratorNode$$Lambda$3557/663473340@3320e553, TermsWithTyp), 0.1, BaseCons( BasePi(provingground.learning.GeneratorNode$$Lambda$3557/663473340@4a372e85, TermsWithTyp), 0.1, BaseCons( BasePi(provingground.learning.GeneratorNode$$Lambda$3557/663473340@522883d5, TermsWithTyp), 0.1, BaseCons( BasePiOpt( provingground.learning.TermGeneratorNodes$$Lambda$3547/887487836@25367d65, TermsWithTyp ), 0.485, Target(TermsWithTyp) ) ) ) ) ) )
coeffs.map(_.rv)
res12: Vector[RandomVar[Any]] = Vector( Terms, AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil) )
coeffs.map(_.node)
res13: Vector[GeneratorNode[Any]] = Vector( ZipFlatMap(TargetTyps, TermsWithTyp, Proj2, Terms), Island( AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil), PiOutput(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }), AddVar(𝒰 , 0.3), Lambda, InIsle ) )
val eqgs = Equation.group(eqs)
eqgs: Set[Equation] = Set( Equation( InitialVal( InIsle( InIsle(Elem(𝒰 , Typs), @b, Island(Typs, ConstRandVar(Typs), AddVar(𝒰 , 0.3), Sigma, InIsle)), @a, Island(Typs, ConstRandVar(Typs), AddVar(𝒰 , 0.3), Pi, InIsle) ) ), Product( IsleScale(@b, Elem(𝒰 , Typs)), InitialVal(InIsle(Elem(𝒰 , Typs), @a, Island(Typs, ConstRandVar(Typs), AddVar(𝒰 , 0.3), Pi, InIsle))) ) ), Equation( FinalVal( InIsle( InIsle(Elem(@a, Typs), @b, Island(Typs, ConstRandVar(Typs), AddVar(𝒰 , 0.3), Pi, InIsle)), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ), Product( Coeff(Init(Typs), Typs), InitialVal( InIsle( InIsle(Elem(@a, Typs), @b, Island(Typs, ConstRandVar(Typs), AddVar(𝒰 , 0.3), Pi, InIsle)), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) ) ), Equation( InitialVal(InIsle(Elem(𝒰 , Typs), @a, Island(Typs, ConstRandVar(Typs), AddVar(𝒰 , 0.3), Pi, InIsle))), Product(IsleScale(@a, Elem(𝒰 , Typs)), InitialVal(Elem(𝒰 , Typs))) ), Equation( FinalVal(Elem(Wrap((@a : 𝒰 ) ↦ (_ : @a) ↦ 𝒰 ), AtCoord(FuncsWithDomain, 𝒰 :: HNil))), Product( Coeff( Island(AtCoord(FuncsWithDomain, 𝒰 :: HNil), ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle), AtCoord(FuncsWithDomain, 𝒰 :: HNil) ), FinalVal( InIsle( Elem((_ : @a) ↦ 𝒰 , Terms), @a, Island( ...
val atoms = eqs.map(_.rhs).flatMap(Expression.atoms)
atoms: Set[Expression] = Set( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))), InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ), IsleScale(@b, Elem(@b, Typs)), IsleScale(@a, Elem(@a, Terms)), InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ), FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ), InitialVal(Elem(@a, Terms)), FinalVal( InIsle( Elem(∏(@b : 𝒰 ){ @b }, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ), FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)), InitialVal( InIsle( InIsle( InIsle( InIsle( Elem(@b, Terms), @a, Island( AtCoord(TermsWithTyp, ((@a → @b) → @b) :: HNil), ConstRandVar(AtCoord(TermsWithTyp, @b :: HNil)), AddVar((@a → @b), 0.3), Lambda, InIsle ) ), @a, Island( AtCoord(TermsWithTyp, (@a → ((@a → @b) → @b)) :: HNil), ...
import ExpressionEval._
import ExpressionEval._
val init = initMap(atoms, tg, ts)
init: Map[Expression, Double] = Map( IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, Coeff( Map( provingground.learning.TermRandomVars$TargetTyps$$$Lambda$3560/1853403043@4a496499, Goals, TargetTyps ), TargetTyps ) -> 0.7, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, IsleScale(@a, Elem(𝒰 , Terms)) -> 0.7, Coeff( Island( AtCoord(TermsWithTyp, ((@a → @b) → @b) :: HNil), ConstRandVar(AtCoord(TermsWithTyp, @b :: HNil)), AddVar((@a → @b), 0.3), Lambda, InIsle ), AtCoord(TermsWithTyp, ((@a → @b) → @b) :: HNil) ) -> 0.485, InitialVal(Elem((@a_1 , @a_2), Terms)) -> 0.4285714285714286, IsleScale(@a, Elem(@a, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Typs)) -> 0.7, IsleScale(@a, Elem(@a, AtCoord(TermsWithTyp, 𝒰 :: HNil))) -> 0.7, IsleScale(@a, Elem(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }, Goals)) -> 0.7, IsleScale((@a_1 , @a_2), Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(∏(B : 𝒰 ){ (@a → ((@a → B) → B)) }, Goals)) -> 0.7, Coeff( Island( AtCoord(TermsWithTyp, (𝒰 → 𝒰 ) :: HNil), ConstRandVar(AtCoord(TermsWithTyp, 𝒰 :: HNil)), AddVar(𝒰 , 0.3), Lambda, InIsle ), AtCoord(TermsWithTyp, (𝒰 → 𝒰 ) :: HNil) ) -> 0.485, ...
init.size
res18: Int = 176
val m2 = nextMap(init, eqgs)
m2: Map[Expression, Double] = Map( InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, Coeff( Map( provingground.learning.TermRandomVars$TargetTyps$$$Lambda$3560/1853403043@4a496499, Goals, TargetTyps ), TargetTyps ) -> 0.7, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, IsleScale(@a, Elem(𝒰 , Terms)) -> 0.7, Coeff( Island( AtCoord(TermsWithTyp, ((@a → @b) → @b) :: HNil), ConstRandVar(AtCoord(TermsWithTyp, @b :: HNil)), AddVar((@a → @b), 0.3), Lambda, InIsle ), AtCoord(TermsWithTyp, ((@a → @b) → @b) :: HNil) ) -> 0.485, InitialVal(Elem((@a_1 , @a_2), Terms)) -> 0.4285714285714286, InitialVal( InIsle( Elem(∏(B : 𝒰 ){ (@a → ((@a → B) → B)) }, Goals), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ...
m2.size
res20: Int = 282
val m3 = nextMap(m2, eqgs)
m3: Map[Expression, Double] = Map( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))) -> 0.42, InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.42, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, Coeff( Map( provingground.learning.TermRandomVars$TargetTyps$$$Lambda$3560/1853403043@4a496499, Goals, TargetTyps ), TargetTyps ) -> 0.7, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, InitialVal( InIsle( InIsle(Elem(@a, Terms), @a, Island(Terms, ConstRandVar(Terms), AddVar(@a, 0.3), Lambda, InIsle)), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.21, IsleScale(@a, Elem(𝒰 , Terms)) -> 0.7, Coeff( ...
m3.size
res22: Int = 437
eqgs.map(_.lhs).toSet -- m3.keySet
res23: Set[Expression] = Set( FinalVal( InIsle( InIsle( Elem((@a → ((@a → @b) → @b)), TargetTyps), @b, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ), FinalVal( InIsle( Elem(∏(@b : 𝒰 ){ @b }, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ), FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)), FinalVal( InIsle( InIsle( InIsle( InIsle( Elem(@b, Terms), @a, Island( AtCoord(TermsWithTyp, ((@a → @b) → @b) :: HNil), ConstRandVar(AtCoord(TermsWithTyp, @b :: HNil)), AddVar((@a → @b), 0.3), Lambda, InIsle ) ), @a, Island( AtCoord(TermsWithTyp, (@a → ((@a → @b) → @b)) :: HNil), ConstRandVar(AtCoord(TermsWithTyp, ((@a → @b) → @b) :: HNil)), AddVar(@a, 0.3), Lambda, InIsle ) ), @b, Island( AtCoord(TermsWithTyp, ∏(B : 𝒰 ){ (@a → ((@a → B) → B)) } :: HNil), PiOutput(∏(B : 𝒰 ){ (@a → ((@a → B) → B)) }), AddVar(𝒰 , 0.3), ...
val zeroFirst = eqs.map(_.rhs).filter(exp => recExp(init, exp) == 0)
zeroFirst: Set[Expression] = Set( Product( Coeff( FlatMap(Typs, provingground.learning.TermGeneratorNodes$$Lambda$3549/1725945319@607b497, Typs), Typs ), FinalVal( InIsle( InIsle(Elem(𝒰 , Typs), @a, Island(Typs, ConstRandVar(Typs), AddVar(@a, 0.3), Pi, InIsle)), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) ), Product( IsleScale(@a, Elem(@a, Terms)), InitialVal( InIsle( InIsle( InIsle( Elem(@a, Terms), @a, Island( AtCoord(TermsWithTyp, (@a → ((@a → @b) → @b)) :: HNil), ConstRandVar(AtCoord(TermsWithTyp, ((@a → @b) → @b) :: HNil)), AddVar(@a, 0.3), Lambda, InIsle ) ), @b, Island( AtCoord(TermsWithTyp, ∏(B : 𝒰 ){ (@a → ((@a → B) → B)) } :: HNil), PiOutput(∏(B : 𝒰 ){ (@a → ((@a → B) → B)) }), AddVar(𝒰 , 0.3), Lambda, InIsle ) ), @a, Island( AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil), PiOutput(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }), AddVar(𝒰 , 0.3), Lambda, InIsle ) ) ...
zeroFirst.size
res25: Int = 587
val step2 = zeroFirst.filter(exp => recExp(m2, exp) != 0)
step2: Set[Expression] = Set( Product( IsleScale(@b, Elem(@a, Typs)), InitialVal( InIsle(Elem(@a, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) ), Product( IsleScale(@a, Elem(@a, Typs)), InitialVal(InIsle(Elem(@a, Typs), @a, Island(Typs, ConstRandVar(Typs), AddVar(𝒰 , 0.3), Pi, InIsle))) ), Product( Coeff(Init(Typs), Typs), InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) ), Product( Coeff(Init(Terms), Terms), InitialVal( InIsle( Elem(𝒰 , Terms), @a, Island( AtCoord(TermsWithTyp, ∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } } :: HNil), PiOutput(∏(A : 𝒰 ){ ∏(B : 𝒰 ){ (A → ((A → B) → B)) } }), AddVar(𝒰 , 0.3), Lambda, InIsle ) ) ) ), Product( Coeff(Init(Terms), Terms), InitialVal( InIsle( Elem((@a_1 , @a_2), Terms), (@a_1 , @a_2), Island(Terms, ConstRandVar(Terms), AddVar(∏(@a : 𝒰 ){ @a }×𝒰 , 0.3), Lambda, InIsle) ) ) ), Product( IsleScale(@a, Elem(@a, Terms)), ...
step2.size
res27: Int = 141
m2.filter(_._2 == 0).size
m3.filter(_._2 == 0).size
res28_0: Int = 0 res28_1: Int = 0
val ms = stableSupportMap(init, eqgs)
ms: Map[Expression, Double] = Map( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))) -> 0.42, InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, FinalVal( InIsle( InIsle( Elem((@a → ((@a → @b) → @b)), TargetTyps), @b, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.147, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.42, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, FinalVal( InIsle( Elem(∏(@b : 𝒰 ){ @b }, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.013150807492591156, FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)) -> 0.0385060355554574, FinalVal( InIsle( InIsle( InIsle( InIsle( Elem(@b, Terms), @a, ...
m2.filter(_._2 == 0)
res30: Map[Expression, Double] = Map()
m3.filter(_._2 == 0)
res31: Map[Expression, Double] = Map()
val m4 = nextMap(m3, eqgs)
m4: Map[Expression, Double] = Map( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))) -> 0.42, InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.42, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)) -> 0.038500000000000006, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, Coeff( Map( provingground.learning.TermRandomVars$TargetTyps$$$Lambda$3560/1853403043@4a496499, Goals, TargetTyps ), TargetTyps ) -> 0.7, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, InitialVal( InIsle( InIsle(Elem(@a, Terms), @a, Island(Terms, ConstRandVar(Terms), AddVar(@a, 0.3), Lambda, InIsle)), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.21, FinalVal( ...
val ms = stableSupportMap(init, eqgs)
ms: Map[Expression, Double] = Map( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))) -> 0.42, InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, FinalVal( InIsle( InIsle( Elem((@a → ((@a → @b) → @b)), TargetTyps), @b, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.147, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.42, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, FinalVal( InIsle( Elem(∏(@b : 𝒰 ){ @b }, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.013150807492591156, FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)) -> 0.0385060355554574, FinalVal( InIsle( InIsle( InIsle( InIsle( Elem(@b, Terms), @a, ...
val mss = nextMap(ms, eqgs)
mss: Map[Expression, Double] = Map( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))) -> 0.42, InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, FinalVal( InIsle( InIsle( Elem((@a → ((@a → @b) → @b)), TargetTyps), @b, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.147, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.42, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, FinalVal( InIsle( Elem(∏(@b : 𝒰 ){ @b }, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.013151570681494687, FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)) -> 0.03850605967906028, FinalVal( InIsle( InIsle( InIsle( InIsle( Elem(@b, Terms), @a, ...
mapRatio(ms, mss)
res35: Double = 3.1003174836561977
val m100 = iterateMap(ms, eqgs, 100)
m100: Map[Expression, Double] = Map( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))) -> 0.42, InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, FinalVal( InIsle( InIsle( Elem((@a → ((@a → @b) → @b)), TargetTyps), @b, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.147, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.42, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, FinalVal( InIsle( Elem(∏(@b : 𝒰 ){ @b }, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.013152400835073068, FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)) -> 0.03850609129352404, FinalVal( InIsle( InIsle( InIsle( InIsle( Elem(@b, Terms), @a, ...
val m200 = iterateMap(m100, eqgs, 100)
m200: Map[Expression, Double] = Map( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))) -> 0.42, InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, FinalVal( InIsle( InIsle( Elem((@a → ((@a → @b) → @b)), TargetTyps), @b, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.147, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.42, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, FinalVal( InIsle( Elem(∏(@b : 𝒰 ){ @b }, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.013152400835073068, FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)) -> 0.03850609129352404, FinalVal( InIsle( InIsle( InIsle( InIsle( Elem(@b, Terms), @a, ...
mapRatio(m100, m200)
res38: Double = 1.0000000000000013
val m201 = nextMap(m200, eqgs)
m201: Map[Expression, Double] = Map( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))) -> 0.42, InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, FinalVal( InIsle( InIsle( Elem((@a → ((@a → @b) → @b)), TargetTyps), @b, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.147, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.42, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, FinalVal( InIsle( Elem(∏(@b : 𝒰 ){ @b }, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.013152400835073068, FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)) -> 0.03850609129352404, FinalVal( InIsle( InIsle( InIsle( InIsle( Elem(@b, Terms), @a, ...
stableMap(init, eqgs)
res45: Map[Expression, Double] = Map( FinalVal(InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle))) -> 0.42, InitialVal( InIsle(Elem(𝒰 , Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle)) ) -> 0.7, IsleScale(@b, Elem(@b, Typs)) -> 0.7, IsleScale(@a, Elem(@a, Terms)) -> 0.7, FinalVal( InIsle( InIsle( Elem((@a → ((@a → @b) → @b)), TargetTyps), @b, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.147, InitialVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.7, FinalVal( InIsle( Elem(𝒰 , Typs), (@a_1 , @a_2), Island(Typs, ConstRandVar(Typs), AddVar(∑(@a : { @a }, 0.3), Pi, InIsle) ) ) -> 0.42, InitialVal(Elem(@a, Terms)) -> 0.4285714285714286, FinalVal( InIsle( Elem(∏(@b : 𝒰 ){ @b }, Typs), @a, Island(Terms, ConstRandVar(Terms), AddVar(𝒰 , 0.3), Lambda, InIsle) ) ) -> 0.013152400788112117, FinalVal(Elem(((__1 , __2) : 𝒰 ×(𝒰 → 𝒰 )) ↦ 𝒰 , Terms)) -> 0.03850609128852615, FinalVal( InIsle( InIsle( InIsle( InIsle( Elem(@b, Terms), @a, ...