use strict;
use AI::Proplog;
my $p = new AI::Proplog;
#
# assert some facts:
#
# cs requirements are basic cs, math, advanced cs, an engr rec and nat. sc\
i.
$p->a( cs_req => qw(basic_cs math_req advanced_cs engr_rec natural_science\
));
# basic cs requires an intro req, comp org, advanced programming and theor\
y
$p->a( basic_cs => qw(intro_req comp_org adv_prog theory) );
# and so forth
$p->a( intro_req => 'intro_cs');
$p->a( intro_req => qw(introI introII) );
$p->a( math_req => qw(calc_req finite_req alg_req) );
$p->a( calc_req => qw(basic_calc adv_calc) );
$p->a( basic_calc => qw(calcI calcII) );
$p->a( basic_calc => qw(calcA calcB calcC) );
$p->a( adv_calc => 'lin_alg');
$p->a( adv_calc => 'honors_linalg');
$p->a( finite_req => qw(fin_structI stat) );
$p->a( alg_req => 'fin_structII');
$p->a( alg_req => 'abs_alg');
$p->a( alg_req => 'abs_alg');
# here we assert a bunch of facts:
# the following things have been taken:
# cs intro, computer org, advanced programming, and theory
$p->apl( qw(intro_cs comp_org adv_prog theory) );
# now do a bottom up search of the fact/rule space to see if the
# basic cs requirements have been met
my $R = $p->bottom_up('basic_cs');
# or: my $R = $p->top_down('basic_cs');
ok($R);
####
$p->a( x => 'y' );
$p->a( y => 'x' );
####
# there is a 0.6 chance that a souffle rises is beaten well and it is quie\
t
$p->a( souffle_rises(0.6) => qw(beaten_well quiet_while_cooking) ) ;
# there is a 0.1 chance that it will rise based on luck
$p->a( souffle_rise(0.1 ) => 'have_luck');
# there is thus 0.3 chance that it will NOT rise
$p->a( beaten_well(0.4) => 'use_whisk');
$p->a( beaten_well(0.6) => 'use_mixer');
$p->a( quiet_while_cooking(0.8) => 'kids_outside');
$p->a( have_luck(0.3) => 'knock_on_wood');
# tell me what the chances are of this souffle rising if the kids are
# outside and I use whisk...
$p->apl( qw(use_whisk kids_outside) );
$p->top_down('souffle_rise')