Advertisement
xi_arma

Rule of Inference Code

Nov 26th, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.39 KB | None | 0 0
  1. print("\n")
  2. p = input("Give the value of p: ")
  3. q = input("Give the value of q: ")
  4. r = input("Give the value of r: ")
  5. s = input("Give the value of s: ")
  6.  
  7.  
  8. prompt_inference = int(input("""
  9. Rule of Inference:
  10. (1) Modus Ponens    (6) Hypothetical Syllogism
  11. (2) Modus Tollens   (7) Disjunctive Syllogism
  12. (3) Addition        (8) Constructive Dilemma
  13. (4) Simplification  (9) Destructive Dilemma
  14. (5) Conjunction
  15.  
  16. Choose your desired rule of inference: """))
  17.  
  18. # MODUS PONENS
  19. if prompt_inference == 1:
  20.     print(
  21. f"""        
  22. You chose Modus Ponens
  23.  
  24. Result:
  25. If {p}, then {q}.
  26. {p.title()}.
  27. ----------------------------
  28. Therefore, {q}.
  29. """)
  30.  
  31. # MODUS TOLLENS
  32. elif prompt_inference == 2:
  33.     print(
  34. f"""        
  35. You chose Modus Tollens
  36.  
  37. Result:
  38. If {p}, then {q}.
  39. not {q}.
  40. ----------------------------
  41. Therefore, not {p}.
  42. """)
  43.  
  44. # ADDITION
  45. elif prompt_inference == 3:
  46.     print(
  47. f"""        
  48. You chose Addition
  49.  
  50. Result:
  51. {p.title()}.
  52. ----------------------------
  53. Therefore, either {p} or {q}.
  54. """)
  55.  
  56. # SIMPLIFICATION
  57. elif prompt_inference == 4:
  58.     print(
  59. f"""        
  60. You chose Simplification
  61.  
  62. Result:
  63. {p.title()} and {q}.
  64. ----------------------------
  65. Therefore, {p}.
  66. """)
  67.  
  68. # CONJUNCTION
  69. elif prompt_inference == 5:
  70.     print(
  71. f"""        
  72. You chose Conjunction
  73.  
  74. Result:
  75. {p.title()}.
  76. {q.title()}.
  77. ----------------------------
  78. Therefore, {p} and {q}.
  79. """)
  80.  
  81. # HYPOTHETICAL SYLLOGISM
  82. elif prompt_inference == 6:
  83.     print(
  84. f"""        
  85. You chose Hypothetical Syllogism
  86.  
  87. Result:
  88. If {p}, then {q}.
  89. If {q}, then {r}.
  90. ----------------------------
  91. Therefore, if {p}, then {r}.
  92. """)
  93.    
  94. # DISJUNCTIVE SYLLOGISM
  95. elif prompt_inference == 7:
  96.     print(
  97. f"""        
  98. You chose Disjunctive Syllogism
  99.  
  100. Result:
  101. {p.title()} or {q}.
  102. Not {p}.
  103. ----------------------------
  104. Therefore, {q}.
  105. """)
  106.  
  107. # CONSTRUCTIVE DILEMMA
  108. elif prompt_inference == 8:
  109.     print(
  110. f"""        
  111. You chose Constructive Dilemma
  112.  
  113. Result:
  114. If {p}, then {q} and if {r}, then {s}.
  115. Either {p} or {r}.
  116. ----------------------------
  117. Therefore, either {q} or {s}.
  118. """)
  119.  
  120. # DESTRUCTIVE DILEMMA
  121. elif prompt_inference == 9:
  122.     print(
  123. f"""        
  124. You chose Destructive Dilemma
  125.  
  126. Result:
  127. If {p}, then {q} and if {r}, then {s}.
  128. Either not {q} or {s}.
  129. ----------------------------
  130. Therefore, either not {p} or {r}.
  131. """)
  132.    
  133. else:
  134.     print("Incorrect input. Only input numbers from (1-9).")
  135.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement