Incomplete Information

These are probabilistic variants of examples from some papers on reasoning with incomplete information and possible worlds.

Company Takeover

% example from % Antova, Koch, Olteanu % From complete to incomplete information and back % SIGMOD 07 % import uniform distributions :- use_module(library(lists)). %%%%%%%%%%%%%% % DATABASE %%%%%%%%%%%%%% % two companies & their employees company_emp(acme, e1). company_emp(acme, e2). company_emp(hal, e3). company_emp(hal, e4). company_emp(hal, e5). % employee's skills emp_skill(e1,web). emp_skill(e2,web). emp_skill(e3,java). emp_skill(e3,web). emp_skill(e4,sql). emp_skill(e5,java). %%%%%%%%%%%%%% % RANDOM EVENTS %%%%%%%%%%%%%%% % we'll buy one of the companies 0.5::buy(acme); 0.5::buy(hal). % if we buy a company, a random employee will leave that company leaves(E) :- buy(C), findall(P,company_emp(C,P),List), select_uniform(l(C),List,E,_). %%%%%%%%%%%%%% % RULES %%%%%%%%%%%%%%% % when do we have an employee with a certain skill? have_skill(S,C) :- buy(C), company_emp(C,E), \+ leaves(E), emp_skill(E,S). have_skill(S) :- have_skill(S,_). % auxiliaries for debugging world(X,L) :- buy(X), findall(Y,(company_emp(X,Y), \+ leaves(Y)),L). skillworld(X,L) :- buy(X), findall(S,(company_emp(X,Y), \+ leaves(Y), emp_skill(Y,S)),L). %%%%%%%%%%%%%% % QUERIES %%%%%%%%%%%%%%% % query 1: if I buy X, which skills do I get? (use commenting to change evidence) query(have_skill(_)). % evidence(buy(acme)). evidence(buy(hal)). % query 2: which company should I buy to have someone with web skills for sure? % using meta-reasoning (uncomment query and comment out query and evidence above to run) buy_skill(C,S) :- company_emp(C,_), emp_skill(_,S), subquery(have_skill(S),Prob,[buy(C)]), Prob =:= 1.0. %query(buy_skill(_,web)).

Whale Watching

% example from % Antova, Koch, Olteanu % Query language support for incomplete information in the MayBMS system % VLDB 2007 % % - 3 whales are seen in three closeby locations a,b,c % - the one on position a is an adult orca (with identifier 3) % - the other two are an adult and calf sperm whale (with IDs 2 and 1) % - there are six possibilities for gender of the adults and positions of the sperm whales % information shared by all worlds: species(1,sperm). gender(1,calf). species(2,sperm). species(3,orca). position(3,a). % information differing per world position(1,b) :- world(a). position(2,c) :- world(a). gender(2,cow) :- world(a). gender(3,cow) :- world(a). position(1,b) :- world(b). position(2,c) :- world(b). gender(2,cow) :- world(b). gender(3,bull) :- world(b). position(1,b) :- world(c). position(2,c) :- world(c). gender(2,bull) :- world(c). gender(3,cow) :- world(c). position(1,b) :- world(d). position(2,c) :- world(d). gender(2,bull) :- world(d). gender(3,bull) :- world(d). position(1,c) :- world(e). position(2,b) :- world(e). gender(2,cow) :- world(e). gender(3,cow) :- world(e). position(1,c) :- world(f). position(2,b) :- world(f). gender(2,bull) :- world(f). gender(3,cow) :- world(f). % assume uniform dist over worlds (this is not in the original paper) 1/6::world(a); 1/6::world(b); 1/6::world(c); 1/6::world(d); 1/6::world(e); 1/6::world(f). % query 1: does the orca attack the calf? (this happens if the calf is at position b) attack :- position(1,b). query(attack). % query 2: same query, but under the constraint that sperm cows move in between their calf and an orca (uncomment evidence to run) constraint1 :- not (gender(2,cow), not position(2,b)). %evidence(constraint1). % query 3: does the adult sperm abandon the calf? (and in which gender combinations does this happen) abandon(S,O) :- gender(2,S), gender(3,O), position(2,c). query(abandon(_,_)).

Or, without naming the worlds:

% example from % Antova, Koch, Olteanu % Query language support for incomplete information in the MayBMS system % VLDB 2007 % % - 3 whales are seen in three closeby locations a,b,c % - the one on position a is an adult orca (with identifier 3) % - the other two are an adult and calf sperm whale (with IDs 2 and 1) % - there are six possibilities for gender of the adults and positions of the sperm whales % information shared by all worlds: species(1,sperm). gender(1,calf). species(2,sperm). species(3,orca). position(3,a). % information differing per world, written more compactly % 4 of 6 worlds have 1 in b and 2 in c 2/3::relpos(b,c); 1/3::relpos(c,b). position(1,P) :- relpos(P,_). position(2,P) :- relpos(_,P). % 3 of 6 worlds have 2 as bull 0.5::gender(2,bull); 0.5::gender(2,cow). % 2 of the 4 (1,b) worlds have 3 as bull 0.5::gender(3,bull); 0.5::gender(3,cow) :- position(1,b). % 2 of the 2 (1,c) worlds have 3 as cow gender(3,cow) :- position(1,c). % query 1: does the orca attack the calf? (this happens if the calf is at position b) attack :- position(1,b). query(attack). % query 2: same query, but under the constraint that sperm cows move in between their calf and an orca (uncomment evidence to run) constraint1 :- not (gender(2,cow), not position(2,b)). %evidence(constraint1). % query 3: does the adult sperm abandon the calf? (and in which gender combinations does this happen) abandon(S,O) :- gender(2,S), gender(3,O), position(2,c). query(abandon(_,_)).

Fixing Key Constraint Violations

% example from % Antova, Koch, Olteanu % Query language support for incomplete information in the MayBMS system % VLDB 2007 % % given table: % SSN TEL % 123 456 % 789 123 % % numbers have possibly been swapped (in each tuple), but there is a uniqueness constraint on SSNs -- what are the possible assignments? 0.5::ssn_tel(1,123,456); 0.5::ssn_tel(1,456,123). 0.5::ssn_tel(2,789,123); 0.5::ssn_tel(2,123,789). wrong :- ssn_tel(1,S,_), ssn_tel(2,S,_). evidence(wrong,false). table(S1,T1,S2,T2) :- ssn_tel(1,S1,T1),ssn_tel(2,S2,T2). query(table(_,_,_,_)).