Question: Data science/coding question: def forward chain(belief, rules): Fully execute a set of given rules that match a given belief, until no more new rules are

Data science/coding question:Data science/coding question: def forward chain(belief, rules): "Fully execute a set of

def forward chain(belief, rules): "Fully execute a set of given rules that match a given belief, until no more new rules are triggered. That is, this function should: (i) Scan through the rules until it finds rule (s) which are applicable, (ii) trigger such rules and update beliefs, (iii) repeat (i) and (ii) until no further rules can be triggered. Returns a new set of beliefs (without changing the original set of beliefs) based on which rules were triggered. Note: this function should employ a while loop and should call the match function you implemented in the first part of this problem. Hint: you should be able to do this in 8 lines of code, including the return statement. ParameterS belief: set A set of true propositions. rules list of tuple A list of tuples, such that for each tuple, the first element implies the second (but not vice versa). Returns tuple of (new belief, triggered rules): new_belief is an updated set of true propositions, and triggered_rules is the list of rules that were triggered, in order. # YOUR CODE HERE raise NotImplementedError() b, r-forward chain(f'a'}, [('a', "b', 'b, c') print-rules (r) # should print both 'a --> b' and 'b --> c' # should be {'a', 'b', 'c'} def forward chain(belief, rules): "Fully execute a set of given rules that match a given belief, until no more new rules are triggered. That is, this function should: (i) Scan through the rules until it finds rule (s) which are applicable, (ii) trigger such rules and update beliefs, (iii) repeat (i) and (ii) until no further rules can be triggered. Returns a new set of beliefs (without changing the original set of beliefs) based on which rules were triggered. Note: this function should employ a while loop and should call the match function you implemented in the first part of this problem. Hint: you should be able to do this in 8 lines of code, including the return statement. ParameterS belief: set A set of true propositions. rules list of tuple A list of tuples, such that for each tuple, the first element implies the second (but not vice versa). Returns tuple of (new belief, triggered rules): new_belief is an updated set of true propositions, and triggered_rules is the list of rules that were triggered, in order. # YOUR CODE HERE raise NotImplementedError() b, r-forward chain(f'a'}, [('a', "b', 'b, c') print-rules (r) # should print both 'a --> b' and 'b --> c' # should be {'a', 'b', 'c'}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!