mportcom.cra.figaro.language._importcom.cra.figaro.library.compound.Ifimportcom.cra.figaro.algorithm.factored.VariableEliminationobjectMain{valsunnyToday=Flip(0.2)valgreetingToday=If(sunnyToday,Select(0.6->"Hello World",0.4->"Howdy universe"),Select(0.2->"Hello World",0.8->"no not again!"))valsunnyTomorrow=If(sunnyToday,Flip(0.8),Flip(0.05))valgreetingTomorrow=If(sunnyTomorrow,Select(0.6->"Hello World",0.4->"Howdy universe"),Select(0.6->"Hello World",0.4->"no not again"))defpredict:Unit={valresult=VariableElimination.probability(greetingToday,"Hello World")println("Today's greeting is \"Hello World!\" "+" with probability "+result+".")}definfer:Unit={valgreeting="Hello World"greetingToday.observe(greeting)valresult=VariableElimination.probability(sunnyToday,true)println(s"If today's greeting is $greeting with probability $result.")}deflearnAndPredict:Unit={valgreeting="Hello World"greetingToday.observe(greeting)valresult=VariableElimination.probability(greetingTomorrow,greeting)println(s"If today's greeting is $greeting,tomorrow's greeting will be $greeting\n"+s"with probability $result.")}defmain(args:Array[String]):Unit={predictinferlearnAndPredict}