Check claims against fresh evidence
Implement check_claim(evidence, claim, now, max_age). A claim names evidence_id, field, unit, and finite numeric minimum. Evidence records have time, unit, and a fields dictionary. Return unsupported for a missing record or field; stale when age is negative or greater than max_age; unit_mismatch for different units; otherwise supported or contradicted by value >= minimum. Apply checks in that stated order. Invalid nonnegative integer time controls or nonnumeric included values raise ValueError. Booleans are not numbers.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
Inputcheck_claim({"o1":{"time":10,"unit":"items","fields":{"stock":2}}}, {"evidence_id":"o1","field":"stock","unit":"items","minimum":3}, 12, 5)
Output"contradicted"
InputThe same claim at now=20, max_age=5
Output"stale"
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor