File size: 2,014 Bytes
d517dc9 | 1 2 3 4 5 | {"type": "session", "harness": "opencode", "id": "reason-0015", "name": "deductive"}
{"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}}
{"type": "message", "message": {"role": "user", "content": "Explain deductive reasoning with concrete examples and common pitfalls. Include a runnable code example with its expected output."}}
{"type": "message", "message": {"role": "assistant", "content": "**Syllogism Analysis:**\n\n**Premise 1:** All roses are flowers. (All A are B)\n**Premise 2:** Some flowers fade quickly. (Some B are C)\n\n**Conclusion:** Some roses fade quickly? — INVALID\n\nThe middle term 'flowers' is not distributed in either premise.\nThe 'some flowers' that fade might not include roses.\n\n**Valid syllogistic forms:**\n- Barbara: All A are B, All B are C → All A are C\n- Celarent: No A are B, All B are C → No A are C\n- Darii: All A are B, Some B are C → Some A are C\n\n```python\n# Formal verification of syllogisms\ndef test_syllogism(premise1, premise2, conclusion, domain):\n for model in domain:\n if premise1(model) and premise2(model):\n if not conclusion(model):\n return False # Invalid\n return True # Valid\n\n# Counter-example: domain of 3 objects\ndomain = [{'type': 'rose'}, {'type': 'tulip'}, {'type': 'lily'}]\np1 = lambda m: m['type'] in ['rose', 'tulip', 'lily'] # All roses are flowers\np2 = lambda m: m['type'] == 'tulip' # Some flowers fade quickly\ncon = lambda m: m['type'] == 'rose' # Some roses fade quickly\n\nprint(test_syllogism(p1, p2, con, domain)) # False - invalid\n```\n\n**The fallacy:** Undistributed middle term."}}
|