tinycodinglm / reason /reason-0000.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame Contribute Delete
1.58 kB
opencode trace
System 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 c...

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.

User

Explain logic reasoning with concrete examples and common pitfalls. Include a runnable code example with its expected output.

Assistant

Propositional Logic:

  • P ∧ Q (AND): true only if both true
  • P ∨ Q (OR): true if either true
  • ¬P (NOT): negation
  • P → Q (IF-THEN): false only if P true, Q false
  • P ↔ Q (IF AND ONLY IF): true if same truth value
python
from itertools import product

def truth_table(op):
    print('P | Q | P→Q')
    for p, q in product([True, False], repeat=2):
        result = op(p, q)
        print(f'{p} | {q} | {result}')

def implies(p, q):
    return (not p) or q

truth_table(implies)
# Output:
# True  | True  | True
# True  | False | False
# False | True  | True
# False | False | True

De Morgan's Laws:

  • ¬(P ∧ Q) = ¬P ∨ ¬Q
  • ¬(P ∨ Q) = ¬P ∧ ¬Q

Modus Ponens: If P→Q and P, then Q.
Modus Tollens: If P→Q and ¬Q, then ¬P.