Fleet  0.0.9
Inference in the LOT
Functions
Builtins Namespace Reference

Functions

template<typename Grammar_t >
Builtin< Combinators::CLCL_I (Op::CL_I, BUILTIN_LAMBDA {assert(false);})
 
template<typename Grammar_t >
Builtin< Combinators::CLCL_S (Op::CL_S, BUILTIN_LAMBDA {assert(false);})
 
template<typename Grammar_t >
Builtin< Combinators::CLCL_K (Op::CL_K, BUILTIN_LAMBDA {assert(false);})
 
template<typename Grammar_t >
Builtin< Combinators::CL, Combinators::CL, Combinators::CLCL_Apply (Op::CL_Apply, BUILTIN_LAMBDA {assert(false);})
 
template<typename Grammar_t >
Primitive< typename Grammar_t::input_t > X (Op::X, BUILTIN_LAMBDA { assert(!vms->xstack.empty());vms->template push< typename Grammar_t::input_t >(vms->xstack.top());})
 
template<typename Grammar_t >
Primitive< bool, bool, bool > And (Op::And, BUILTIN_LAMBDA { bool b=vms->template getpop< bool >();if(!b) { vms->program.popn(arg);vms->template push< bool >(false);} else { } })
 
template<typename Grammar_t >
Primitive< bool, bool, bool > Or (Op::Or, BUILTIN_LAMBDA { bool b=vms->template getpop< bool >();if(b) { vms->program.popn(arg);vms->template push< bool >(true);} else { } })
 
template<typename Grammar_t >
Primitive< bool, bool > Not (Op::Not, BUILTIN_LAMBDA { vms->push(not vms->template getpop< bool >());})
 
template<typename Grammar_t , typename T >
Primitive< T, bool, T, T > If (Op::If, BUILTIN_LAMBDA { bool b=vms->template getpop< bool >();if(!b) vms->program.popn(arg);else {};})
 
template<typename Grammar_t >
Primitive Jmp (Op::Jmp, BUILTIN_LAMBDA { vms->program.popn(arg);})
 
template<typename Grammar_t >
Primitive PopX (Op::PopX, BUILTIN_LAMBDA { vms->xstack.pop();})
 
template<typename Grammar_t >
Primitive< bool > Flip (Op::Flip, BUILTIN_LAMBDA { assert(vms->pool !=nullptr);vms->pool->copy_increment_push(vms, true, -LOG2);bool b=vms->pool->increment_push(vms, false, -LOG2);if(b) { vms->status=vmstatus_t::RANDOM_CHOICE_NO_DELETE;} else { vms->status=vmstatus_t::RANDOM_CHOICE;} })
 
template<typename Grammar_t >
Primitive< bool, double > FlipP (Op::FlipP, BUILTIN_LAMBDA { assert(vms->pool !=nullptr);double p=vms->template getpop< double >();if(std::isnan(p)) { p=0.0;} assert(p<=1.0 and p >=0.0);vms->pool->copy_increment_push(vms, true, log(p));bool b=vms->pool->increment_push(vms, false, log(1.0-p));if(b) { vms->status=vmstatus_t::RANDOM_CHOICE_NO_DELETE;} else { vms->status=vmstatus_t::RANDOM_CHOICE;} })
 
template<typename Grammar_t >
Primitive< bool, double > SafeFlipP (Op::SafeFlipP, BUILTIN_LAMBDA { assert(vms->pool !=nullptr);double p=vms->template getpop< double >();if(std::isnan(p)) p=0.0;else if(p > 1.0) p=1.0;else if(p< 0.0) p=0.0;vms->pool->copy_increment_push(vms, true, log(p));bool b=vms->pool->increment_push(vms, false, log(1.0-p));if(b) { vms->status=vmstatus_t::RANDOM_CHOICE_NO_DELETE;} else { vms->status=vmstatus_t::RANDOM_CHOICE;} })
 
template<typename Grammar_t , typename key_t , typename output_t = typename Grammar_t::output_t>
Primitive Mem (Op::Mem, BUILTIN_LAMBDA { auto memindex=vms->template memstack< key_t >().top();vms->template memstack< key_t >().pop();if(vms->template mem< key_t >().count(memindex)==0) { vms->template mem< key_t >()[memindex]=vms->template gettop< output_t >();} })
 
template<typename Grammar_t >
Primitive NoOp (Op::NoOp, BUILTIN_LAMBDA { })
 
template<typename Grammar_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive< output_t, input_t > Recurse (Op::Recurse, BUILTIN_LAMBDA { assert(vms->program.loader !=nullptr);if(vms->recursion_depth++> vms->MAX_RECURSE) { vms->status=vmstatus_t::RECURSION_DEPTH;return;} auto mynewx=vms->template getpop< input_t >();vms->xstack.push(std::move(mynewx));vms->program.push(Builtins::PopX< Grammar_t >.makeInstruction());vms->program.loader->push_program(vms->program);})
 
template<typename Grammar_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive< output_t, input_t > SafeRecurse (Op::SafeRecurse, BUILTIN_LAMBDA { assert(not vms->template stack< input_t >().empty());if(vms->template stack< input_t >().top().size()==0) { vms->template getpop< input_t >();vms->template push< output_t >(output_t{});} else { Recurse< Grammar_t >.call(vms, arg);} })
 
template<typename Grammar_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive< output_t, input_t > MemRecurse (Op::MemRecurse, BUILTIN_LAMBDA { assert(vms->program.loader !=nullptr);using mykey_t=short;if(vms->recursion_depth++> vms->MAX_RECURSE) { vms->status=vmstatus_t::RECURSION_DEPTH;return;} auto x=vms->template getpop< input_t >();auto memindex=std::make_pair(arg, x);if(vms->template mem< mykey_t >().count(memindex)){ vms->push(vms->template mem< mykey_t >()[memindex]);} else { vms->xstack.push(x);vms->program.push(Builtins::PopX< Grammar_t >.makeInstruction());vms->template memstack< mykey_t >().push(memindex);vms->program.push(Builtins::Mem< Grammar_t, mykey_t, output_t >.makeInstruction());vms->program.loader->push_program(vms->program);} })
 
template<typename Grammar_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive< output_t, input_t > SafeMemRecurse (Op::SafeMemRecurse, BUILTIN_LAMBDA { assert(not vms->template stack< input_t >().empty());if(vms->template stack< input_t >().top().size()==0) { vms->template getpop< input_t >();vms->template push< output_t >(output_t{});} else { MemRecurse< Grammar_t >.call(vms, arg);} })
 
template<typename Grammar_t , typename key_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive< output_t, key_t, input_t > LexiconRecurse (Op::LexiconRecurse, BUILTIN_LAMBDA { assert(vms->program.loader !=nullptr);if(vms->recursion_depth++> vms->MAX_RECURSE) { vms->status=vmstatus_t::RECURSION_DEPTH;return;} auto key=vms->template getpop< key_t >();auto mynewx=vms->template getpop< input_t >();vms->xstack.push(std::move(mynewx));vms->program.push(Builtins::PopX< Grammar_t >.makeInstruction());vms->program.loader->push_program(vms->program, key);})
 
template<typename Grammar_t , typename key_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive< output_t, key_t, input_t > LexiconSafeRecurse (Op::LexiconSafeRecurse, BUILTIN_LAMBDA { assert(not vms->template stack< input_t >().empty());assert(vms->program.loader !=nullptr);if(vms->template stack< input_t >().top().size()==0) { vms->template getpop< key_t >();vms->template getpop< input_t >();vms->template push< output_t >(output_t{});} else { LexiconRecurse< Grammar_t, key_t >.call(vms, arg);} })
 
template<typename Grammar_t , typename key_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive< output_t, key_t, input_t > LexiconMemRecurse (Op::LexiconMemRecurse, BUILTIN_LAMBDA { assert(vms->program.loader !=nullptr);if(vms->recursion_depth++> vms->MAX_RECURSE) { vms->status=vmstatus_t::RECURSION_DEPTH;return;} auto key=vms->template getpop< key_t >();auto x=vms->template getpop< input_t >();auto memindex=std::make_pair(key, x);if(vms->template mem< key_t >().count(memindex)){ vms->push(vms->template mem< key_t >()[memindex]);} else { vms->xstack.push(x);vms->program.push(Builtins::PopX< Grammar_t >.makeInstruction());vms->template memstack< key_t >().push(memindex);vms->program.push(Builtins::Mem< Grammar_t, key_t, output_t >.makeInstruction());vms->program.loader->push_program(vms->program, key);} })
 
template<typename Grammar_t , typename key_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive< output_t, key_t, input_t > LexiconSafeMemRecurse (Op::LexiconSafeMemRecurse, BUILTIN_LAMBDA { assert(not vms->template stack< input_t >().empty());assert(vms->program.loader !=nullptr);if(vms->template stack< input_t >().top().size()==0) { vms->template getpop< key_t >();vms->template getpop< input_t >();vms->template push< output_t >(output_t{});} else { LexiconMemRecurse< Grammar_t, key_t >.call(vms, arg);} })
 

Function Documentation

◆ And()

template<typename Grammar_t >
Primitive<bool,bool,bool> Builtins::And ( Op::And  ,
BUILTIN_LAMBDA { bool b=vms->template getpop< bool >();if(!b) { vms->program.popn(arg);vms->template push< bool >(false);} else { } }   
)

◆ CL_Apply()

template<typename Grammar_t >
Builtin<Combinators::CL, Combinators::CL, Combinators::CL> Builtins::CL_Apply ( Op::CL_Apply  ,
BUILTIN_LAMBDA {assert(false);}   
)

◆ CL_I()

template<typename Grammar_t >
Builtin<Combinators::CL> Builtins::CL_I ( Op::CL_I  ,
BUILTIN_LAMBDA {assert(false);}   
)

◆ CL_K()

template<typename Grammar_t >
Builtin<Combinators::CL> Builtins::CL_K ( Op::CL_K  ,
BUILTIN_LAMBDA {assert(false);}   
)

◆ CL_S()

template<typename Grammar_t >
Builtin<Combinators::CL> Builtins::CL_S ( Op::CL_S  ,
BUILTIN_LAMBDA {assert(false);}   
)

◆ Flip()

template<typename Grammar_t >
Primitive<bool> Builtins::Flip ( Op::Flip  ,
BUILTIN_LAMBDA { assert(vms->pool !=nullptr);vms->pool->copy_increment_push(vms, true, -LOG2);bool b=vms->pool->increment_push(vms, false, -LOG2);if(b) { vms->status=vmstatus_t::RANDOM_CHOICE_NO_DELETE;} else { vms->status=vmstatus_t::RANDOM_CHOICE;} }   
)

◆ FlipP()

template<typename Grammar_t >
Primitive<bool,double> Builtins::FlipP ( Op::FlipP  ,
BUILTIN_LAMBDA { assert(vms->pool !=nullptr);double p=vms->template getpop< double >();if(std::isnan(p)) { p=0.0;} assert(p<=1.0 and p >=0.0);vms->pool->copy_increment_push(vms, true, log(p));bool b=vms->pool->increment_push(vms, false, log(1.0-p));if(b) { vms->status=vmstatus_t::RANDOM_CHOICE_NO_DELETE;} else { vms->status=vmstatus_t::RANDOM_CHOICE;} }   
)

◆ If()

template<typename Grammar_t , typename T >
Primitive<T,bool,T,T> Builtins::If ( Op::If  ,
BUILTIN_LAMBDA { bool b=vms->template getpop< bool >();if(!b) vms->program.popn(arg);else {};}   
)

◆ Jmp()

template<typename Grammar_t >
Primitive Builtins::Jmp ( Op::Jmp  ,
BUILTIN_LAMBDA { vms->program.popn(arg);}   
)

◆ LexiconMemRecurse()

template<typename Grammar_t , typename key_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive<output_t,key_t,input_t> Builtins::LexiconMemRecurse ( Op::LexiconMemRecurse  ,
BUILTIN_LAMBDA { assert(vms->program.loader !=nullptr);if(vms->recursion_depth++> vms->MAX_RECURSE) { vms->status=vmstatus_t::RECURSION_DEPTH;return;} auto key=vms->template getpop< key_t >();auto x=vms->template getpop< input_t >();auto memindex=std::make_pair(key, x);if(vms->template mem< key_t >().count(memindex)){ vms->push(vms->template mem< key_t >()[memindex]);} else { vms->xstack.push(x);vms->program.push(Builtins::PopX< Grammar_t >.makeInstruction());vms->template memstack< key_t >().push(memindex);vms->program.push(Builtins::Mem< Grammar_t, key_t, output_t >.makeInstruction());vms->program.loader->push_program(vms->program, key);} }   
)

◆ LexiconRecurse()

template<typename Grammar_t , typename key_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive<output_t,key_t,input_t> Builtins::LexiconRecurse ( Op::LexiconRecurse  ,
BUILTIN_LAMBDA { assert(vms->program.loader !=nullptr);if(vms->recursion_depth++> vms->MAX_RECURSE) { vms->status=vmstatus_t::RECURSION_DEPTH;return;} auto key=vms->template getpop< key_t >();auto mynewx=vms->template getpop< input_t >();vms->xstack.push(std::move(mynewx));vms->program.push(Builtins::PopX< Grammar_t >.makeInstruction());vms->program.loader->push_program(vms->program, key);}   
)

◆ LexiconSafeMemRecurse()

template<typename Grammar_t , typename key_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive<output_t,key_t,input_t> Builtins::LexiconSafeMemRecurse ( Op::LexiconSafeMemRecurse  ,
BUILTIN_LAMBDA { assert(not vms->template stack< input_t >().empty());assert(vms->program.loader !=nullptr);if(vms->template stack< input_t >().top().size()==0) { vms->template getpop< key_t >();vms->template getpop< input_t >();vms->template push< output_t >(output_t{});} else { LexiconMemRecurse< Grammar_t, key_t >.call(vms, arg);} }   
)

◆ LexiconSafeRecurse()

template<typename Grammar_t , typename key_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive<output_t,key_t,input_t> Builtins::LexiconSafeRecurse ( Op::LexiconSafeRecurse  ,
BUILTIN_LAMBDA { assert(not vms->template stack< input_t >().empty());assert(vms->program.loader !=nullptr);if(vms->template stack< input_t >().top().size()==0) { vms->template getpop< key_t >();vms->template getpop< input_t >();vms->template push< output_t >(output_t{});} else { LexiconRecurse< Grammar_t, key_t >.call(vms, arg);} }   
)

◆ Mem()

template<typename Grammar_t , typename key_t , typename output_t = typename Grammar_t::output_t>
Primitive Builtins::Mem ( Op::Mem  ,
BUILTIN_LAMBDA { auto memindex=vms->template memstack< key_t >().top();vms->template memstack< key_t >().pop();if(vms->template mem< key_t >().count(memindex)==0) { vms->template mem< key_t >()[memindex]=vms->template gettop< output_t >();} }   
)

◆ MemRecurse()

template<typename Grammar_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive<output_t,input_t> Builtins::MemRecurse ( Op::MemRecurse  ,
BUILTIN_LAMBDA { assert(vms->program.loader !=nullptr);using mykey_t=short;if(vms->recursion_depth++> vms->MAX_RECURSE) { vms->status=vmstatus_t::RECURSION_DEPTH;return;} auto x=vms->template getpop< input_t >();auto memindex=std::make_pair(arg, x);if(vms->template mem< mykey_t >().count(memindex)){ vms->push(vms->template mem< mykey_t >()[memindex]);} else { vms->xstack.push(x);vms->program.push(Builtins::PopX< Grammar_t >.makeInstruction());vms->template memstack< mykey_t >().push(memindex);vms->program.push(Builtins::Mem< Grammar_t, mykey_t, output_t >.makeInstruction());vms->program.loader->push_program(vms->program);} }   
)

◆ NoOp()

template<typename Grammar_t >
Primitive Builtins::NoOp ( Op::NoOp  ,
BUILTIN_LAMBDA { }   
)

◆ Not()

template<typename Grammar_t >
Primitive<bool,bool> Builtins::Not ( Op::Not  ,
BUILTIN_LAMBDA { vms->push(not vms->template getpop< bool >());}   
)

◆ Or()

template<typename Grammar_t >
Primitive<bool,bool,bool> Builtins::Or ( Op::Or  ,
BUILTIN_LAMBDA { bool b=vms->template getpop< bool >();if(b) { vms->program.popn(arg);vms->template push< bool >(true);} else { } }   
)

◆ PopX()

template<typename Grammar_t >
Primitive Builtins::PopX ( Op::PopX  ,
BUILTIN_LAMBDA { vms->xstack.pop();}   
)

◆ Recurse()

template<typename Grammar_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive<output_t,input_t> Builtins::Recurse ( Op::Recurse  ,
BUILTIN_LAMBDA { assert(vms->program.loader !=nullptr);if(vms->recursion_depth++> vms->MAX_RECURSE) { vms->status=vmstatus_t::RECURSION_DEPTH;return;} auto mynewx=vms->template getpop< input_t >();vms->xstack.push(std::move(mynewx));vms->program.push(Builtins::PopX< Grammar_t >.makeInstruction());vms->program.loader->push_program(vms->program);}   
)

◆ SafeFlipP()

template<typename Grammar_t >
Primitive<bool,double> Builtins::SafeFlipP ( Op::SafeFlipP  ,
BUILTIN_LAMBDA { assert(vms->pool !=nullptr);double p=vms->template getpop< double >();if(std::isnan(p)) p=0.0;else if(p > 1.0) p=1.0;else if(p< 0.0) p=0.0;vms->pool->copy_increment_push(vms, true, log(p));bool b=vms->pool->increment_push(vms, false, log(1.0-p));if(b) { vms->status=vmstatus_t::RANDOM_CHOICE_NO_DELETE;} else { vms->status=vmstatus_t::RANDOM_CHOICE;} }   
)

◆ SafeMemRecurse()

template<typename Grammar_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive<output_t,input_t> Builtins::SafeMemRecurse ( Op::SafeMemRecurse  ,
BUILTIN_LAMBDA { assert(not vms->template stack< input_t >().empty());if(vms->template stack< input_t >().top().size()==0) { vms->template getpop< input_t >();vms->template push< output_t >(output_t{});} else { MemRecurse< Grammar_t >.call(vms, arg);} }   
)

◆ SafeRecurse()

template<typename Grammar_t , typename input_t = typename Grammar_t::input_t, typename output_t = typename Grammar_t::output_t>
Primitive<output_t, input_t> Builtins::SafeRecurse ( Op::SafeRecurse  ,
BUILTIN_LAMBDA { assert(not vms->template stack< input_t >().empty());if(vms->template stack< input_t >().top().size()==0) { vms->template getpop< input_t >();vms->template push< output_t >(output_t{});} else { Recurse< Grammar_t >.call(vms, arg);} }   
)

◆ X()

template<typename Grammar_t >
Primitive<typename Grammar_t::input_t> Builtins::X ( Op::X  ,
BUILTIN_LAMBDA { assert(!vms->xstack.empty());vms->template push< typename Grammar_t::input_t >(vms->xstack.top());}   
)