Answered step by step
Verified Expert Solution
Link Copied!

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:image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

2. Identify five movie characters who embody the renegade cop type.

Answered: 1 week ago

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago