BayesianLogic / blog

The BLOG programming language
http://bayesianlogic.github.io/
BSD 4-Clause "Original" or "Old" License
98 stars 31 forks source link

Examples in tutorial do not complete successfully #341

Open clbarnes opened 8 years ago

clbarnes commented 8 years ago

e.g. first example

random Real strength(Person p) ~ Gaussian(10, 2);
random Boolean lazy(Person p, Match m)
 ~ BooleanDistrib(0.1);
random Real pulling_power(Person p, Match m) ~
 if lazy(p, m) then strength(p) / 2.0
 else strength(p); 

gives output

Using fixed random seed for repeatability.
tst.blog::1.22: Type Person undefined!
tst.blog::2.21: Type Person undefined!
tst.blog::2.31: Type Match undefined!
tst.blog::4.27: Type Person undefined!
tst.blog::4.37: Type Match undefined!
tst.blog::1.22: Type Person undefined!
tst.blog::2.21: Type Person undefined!
tst.blog::2.31: Type Match undefined!
tst.blog::4.27: Type Person undefined!
tst.blog::4.37: Type Match undefined!
clbarnes commented 8 years ago

Types must be explicitly defined, e.g.

type Match;
type Person;

in this example.

Obviously, this needs adding to the tutorial.

clbarnes commented 8 years ago

There are further issues with the first example: adding the lines from the next few pages

random Boolean team1win(Match m) ~
 sum([pulling_power(p, m) for Person p in team1(m)])
 > sum([pulling_power(p, m) for Person p in team2(m)]) ;

obs team1(M0) = {James, David};
obs team2(M0) = {Brian, John};
obs team1win(M0) = true;
obs team1(M1) = {James, David};
obs team2(M1) = {Bob, Andrew};

query strength(James) > strength(Brian);

returns

Using fixed random seed for repeatability.
tst.blog::12.40: syntax error at Symbol: in (tst.blog:12/40(320) - tst.blog:12/42(322))
tst.blog::12.6: error in body of function call
tst.blog::13.42: syntax error at Symbol: in (tst.blog:13/42(375) - tst.blog:13/44(377))
tst.blog::13.8: error in body of function call
jxwuyi commented 8 years ago

Hi @clbarnes, the slides use a simplified syntax for demonstration purpose during the course. It just shows how generally a BLOG program looks like. For the full version, you can check out https://github.com/BayesianLogic/blog/blob/master/example/tugwar.blog

I will update the slides to emphasize this.

clbarnes commented 8 years ago

Right. What is the recommended trajectory for someone learning the language from scratch? The user manual is clearly intended as a manual for usage of the blog binary, rather than the language (and even then, isn't as concise or rich as a man page), and the 'comprehensive tutorial about BLOG motivation, syntax, semantics, and examples' contains non-functional examples, only explaining them 50 pages later. The language reference is a single PDF. I appreciate the variety of examples in the examples directory but it's not like they have rich comments to make them approachable to a beginner, or a clear reading order.