Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started