// Numbas version: exam_results_page_options {"name": "Truth tables quiz", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Truth tables quiz", "tags": [], "metadata": {"description": "

Create a truth table for a logical expression of the form $((a \\operatorname{op1} b) \\operatorname{op2}(c \\operatorname{op3} d))\\operatorname{op4}e $ where each of $a, \\;b,\\;c,\\;d,\\;e$ can be one the Boolean variables $p,\\;q,\\;\\neg p,\\;\\neg q$ and each of $\\operatorname{op1},\\;\\operatorname{op2},\\;\\operatorname{op3},\\;\\operatorname{op4}$ one of $\\lor,\\;\\land,\\;\\to$.

\n

For example: $((q \\lor \\neg p) \\to (p \\land \\neg q)) \\lor \\neg q$

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

In the following question you are asked to construct a truth table for:

\n

\\[((\\var{a} \\var{op} \\var{b})\\var{op1}(\\var{a1} \\var{op2} \\var{b1}))\\var{op4}\\var{a2}.\\]

\n

\n

Enter T if true, else enter F.

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n

", "advice": "

First we find the truth table for $\\var{a} \\var{op} \\var{b}$:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$p$$q$$\\var{a} \\var{op} \\var{b}$
$\\var{p[0]}$$\\var{q[0]}$$\\var{ev1[0]}$
$\\var{p[1]}$$\\var{q[1]}$$\\var{ev1[1]}$
$\\var{p[2]}$$\\var{q[2]}$$\\var{ev1[2]}$
$\\var{p[3]}$$\\var{q[3]}$$\\var{ev1[3]}$
\n

Then the truth table for $\\var{a1} \\var{op2} \\var{b1}$:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$p$$q$$\\var{a1} \\var{op2} \\var{b1}$
$\\var{p[0]}$$\\var{q[0]}$$\\var{ev2[0]}$
$\\var{p[1]}$$\\var{q[1]}$$\\var{ev2[1]}$
$\\var{p[2]}$$\\var{q[2]}$$\\var{ev2[2]}$
$\\var{p[3]}$$\\var{q[3]}$$\\var{ev2[3]}$
\n

Putting these together to find $(\\var{a} \\var{op} \\var{b})\\var{op1}(\\var{a1} \\var{op2} \\var{b1})$:

\n

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$p$$q$$\\var{a} \\var{op} \\var{b}$$\\var{a1} \\var{op2} \\var{b1}$$(\\var{a} \\var{op} \\var{b})\\var{op1}(\\var{a1} \\var{op2} \\var{b1})$
$\\var{p[0]}$$\\var{q[0]}$$\\var{ev1[0]}$$\\var{ev2[0]}$$\\var{t_value[0]}$
$\\var{p[1]}$$\\var{q[1]}$$\\var{ev1[1]}$$\\var{ev2[1]}$$\\var{t_value[1]}$
$\\var{p[2]}$$\\var{q[2]}$$\\var{ev1[2]}$$\\var{ev2[2]}$$\\var{t_value[2]}$
$\\var{p[3]}$$\\var{q[3]}$$\\var{ev1[3]}$$\\var{ev2[3]}$$\\var{t_value[3]}$
\n

Next we find the truth table for $\\var{a2}$:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$p$$q$$\\var{a2}$
$\\var{p[0]}$$\\var{q[0]}$$\\var{ev3[0]}$
$\\var{p[1]}$$\\var{q[1]}$$\\var{ev3[1]}$
$\\var{p[2]}$$\\var{q[2]}$$\\var{ev3[2]}$
$\\var{p[3]}$$\\var{q[3]}$$\\var{ev3[3]}$
\n

Putting this all together to obtain the truth table we want:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$p$$q$$(\\var{a} \\var{op} \\var{b})\\var{op1}(\\var{a1} \\var{op2} \\var{b1})$$\\var{a2}$$((\\var{a} \\var{op} \\var{b})\\var{op1}(\\var{a1} \\var{op2} \\var{b1}))\\var{op4}\\var{a2} $
$\\var{p[0]}$$\\var{q[0]}$$\\var{t_value[0]}$$\\var{ev3[0]}$$\\var{final_value[0]}$
$\\var{p[1]}$$\\var{q[1]}$$\\var{t_value[1]}$$\\var{ev3[1]}$$\\var{final_value[1]}$
$\\var{p[2]}$$\\var{q[2]}$$\\var{t_value[2]}$$\\var{ev3[2]}$$\\var{final_value[2]}$
$\\var{p[3]}$$\\var{q[3]}$$\\var{t_value[3]}$$\\var{ev3[3]}$$\\var{final_value[3]}$
", "rulesets": {}, "extensions": [], "variables": {"op4": {"name": "op4", "group": "Ungrouped variables", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "description": "", "templateType": "anything"}, "pre_ev3": {"name": "pre_ev3", "group": "Last ", "definition": "map(evaluate(convch(a2),[bool_p[t],bool_q[t]]),t,0..3)", "description": "", "templateType": "anything"}, "latex_symbol_list": {"name": "latex_symbol_list", "group": "Lists of symbols", "definition": "[\"p\",\"q\",\"\\\\neg p\",\"\\\\neg q\"]", "description": "", "templateType": "anything"}, "bool_p": {"name": "bool_p", "group": "Truth values", "definition": "[true,true,false,false]", "description": "", "templateType": "anything"}, "q": {"name": "q", "group": "Truth values", "definition": "bool_to_label([true,false,true,false])", "description": "", "templateType": "anything"}, "ev1": {"name": "ev1", "group": "First Bracket", "definition": "bool_to_label(pre_ev1)", "description": "", "templateType": "anything"}, "pre_ev1": {"name": "pre_ev1", "group": "First Bracket", "definition": "map(evaluate(convch(a)+\" \"+conv(op)+\" \"+convch(b),[bool_p[t],bool_q[t]]),t,0..3)", "description": "", "templateType": "anything"}, "a": {"name": "a", "group": "First Bracket", "definition": "latex(latex_symbol_list[s[0]])", "description": "", "templateType": "anything"}, "ev2": {"name": "ev2", "group": "Second Bracket", "definition": "bool_to_label(pre_ev2)", "description": "", "templateType": "anything"}, "logic_symbol_list": {"name": "logic_symbol_list", "group": "Lists of symbols", "definition": "[\"p\",\"q\",\"not p\",\"not q\"]", "description": "", "templateType": "anything"}, "op1": {"name": "op1", "group": "First and Second Brackets", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "description": "", "templateType": "anything"}, "ev3": {"name": "ev3", "group": "Last ", "definition": "bool_to_label(pre_ev3)", "description": "", "templateType": "anything"}, "s": {"name": "s", "group": "Lists of symbols", "definition": "repeat(random(0..3),6)", "description": "", "templateType": "anything"}, "final_value": {"name": "final_value", "group": "Ungrouped variables", "definition": "bool_to_label(pre_final_value)", "description": "", "templateType": "anything"}, "bool_q": {"name": "bool_q", "group": "Truth values", "definition": "[true,false,true,false]", "description": "", "templateType": "anything"}, "b": {"name": "b", "group": "First Bracket", "definition": "latex(latex_symbol_list[s[1]])", "description": "", "templateType": "anything"}, "op": {"name": "op", "group": "First Bracket", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "description": "", "templateType": "anything"}, "pre_t_value": {"name": "pre_t_value", "group": "First and Second Brackets", "definition": "map(evaluate(pre_ev1[t]+\" \"+conv(op1)+\" \"+pre_ev2[t],[]),t,0..3)", "description": "", "templateType": "anything"}, "t_value": {"name": "t_value", "group": "First and Second Brackets", "definition": "bool_to_label(pre_t_value)", "description": "", "templateType": "anything"}, "pre_ev2": {"name": "pre_ev2", "group": "Second Bracket", "definition": "map(evaluate(convch(a1)+\" \"+conv(op2)+\" \"+convch(b1),[bool_p[t],bool_q[t]]),t,0..3)", "description": "", "templateType": "anything"}, "op2": {"name": "op2", "group": "Second Bracket", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "description": "", "templateType": "anything"}, "b1": {"name": "b1", "group": "Second Bracket", "definition": "latex(latex_symbol_list[s[3]])", "description": "", "templateType": "anything"}, "a2": {"name": "a2", "group": "Last ", "definition": "latex(random(\"\\\\neg p\",\"\\\\neg q\"))", "description": "", "templateType": "anything"}, "a1": {"name": "a1", "group": "Second Bracket", "definition": "latex(latex_symbol_list[s[2]])", "description": "", "templateType": "anything"}, "pre_final_value": {"name": "pre_final_value", "group": "Ungrouped variables", "definition": "map(evaluate(pre_t_value[t]+\" \"+conv(op4)+\" \"+pre_ev3[t],[]),t,0..3)", "description": "", "templateType": "anything"}, "p": {"name": "p", "group": "Truth values", "definition": "bool_to_label([true,true,false,false])", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "a1 <>b1 and\nif(a='p' or a='\\\\neg p',b=random('q','\\\\neg q'),b=random('p','\\\\neg p'))\n", "maxRuns": "150"}, "ungrouped_variables": ["pre_final_value", "op4", "final_value"], "variable_groups": [{"name": "Lists of symbols", "variables": ["logic_symbol_list", "latex_symbol_list", "s"]}, {"name": "First Bracket", "variables": ["a", "b", "op", "pre_ev1", "ev1"]}, {"name": "Second Bracket", "variables": ["a1", "b1", "op2", "pre_ev2", "ev2"]}, {"name": "Truth values", "variables": ["p", "q", "bool_p", "bool_q"]}, {"name": "Last ", "variables": ["a2", "pre_ev3", "ev3"]}, {"name": "First and Second Brackets", "variables": ["op1", "pre_t_value", "t_value"]}], "functions": {"conv": {"parameters": [["op", "string"]], "type": "string", "language": "jme", "definition": "switch(op=\"\\\\land\",\"and\",op=\"\\\\lor\",\"or\",\"implies\")"}, "convch": {"parameters": [["ch", "string"]], "type": "string", "language": "jme", "definition": "switch(ch=\"\\\\neg p\",\"not bool_p[t]\",ch=\"\\\\neg q\",\"not bool_q[t]\",ch=\"p\",\"bool_p[t]\",\"bool_q[t]\")"}, "bool_to_label": {"parameters": [["l", "list"]], "type": "number", "language": "jme", "definition": "map(if(l[x],'T','F'),x,0..length(l)-1)"}, "evaluate": {"parameters": [["expr", "string"], ["dependencies", "list"]], "type": "number", "language": "javascript", "definition": "return scope.evaluate(expr);"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Complete the following truth table:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$p$$q$$\\var{a} \\var{op} \\var{b}$$\\var{a1} \\var{op2} \\var{b1}$$(\\var{a} \\var{op} \\var{b}) \\var{op1} (\\var{a1} \\var{op2} \\var{b1})$$\\var{a2} $$((\\var{a} \\var{op} \\var{b})\\var{op1}(\\var{a1} \\var{op2} \\var{b1}))\\var{op4}\\var{a2} $
$\\var{p[0]}$$\\var{q[0]}$[[0]][[4]][[8]][[12]][[16]]
$\\var{p[1]}$$\\var{q[1]}$[[1]][[5]][[9]][[13]][[17]]
$\\var{p[2]}$$\\var{q[2]}$[[2]][[6]][[10]][[14]][[18]]
$\\var{p[3]}$$\\var{q[3]}$[[3]][[7]][[11]][[15]][[19]]
", "gaps": [{"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev1[0]}", "displayAnswer": "{ev1[0]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev1[1]}", "displayAnswer": "{ev1[1]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev1[2]}", "displayAnswer": "{ev1[2]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev1[3]}", "displayAnswer": "{ev1[3]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev2[0]}", "displayAnswer": "{ev2[0]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev2[1]}", "displayAnswer": "{ev2[1]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev2[2]}", "displayAnswer": "{ev2[2]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev2[3]}", "displayAnswer": "{ev2[3]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{t_value[0]}", "displayAnswer": "{t_value[0]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{t_value[1]}", "displayAnswer": "{t_value[1]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{t_value[2]}", "displayAnswer": "{t_value[2]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{t_value[3]}", "displayAnswer": "{t_value[3]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev3[0]}", "displayAnswer": "{ev3[0]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev3[1]}", "displayAnswer": "{ev3[1]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev3[2]}", "displayAnswer": "{ev3[2]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{ev3[3]}", "displayAnswer": "{ev3[3]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{final_value[0]}", "displayAnswer": "{final_value[0]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{final_value[1]}", "displayAnswer": "{final_value[1]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{final_value[2]}", "displayAnswer": "{final_value[2]}", "matchMode": "regex"}, {"type": "patternmatch", "useCustomName": false, "customName": "", "marks": "0.5", "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{final_value[3]}", "displayAnswer": "{final_value[3]}", "matchMode": "regex"}], "sortAnswers": false}], "contributors": [{"name": "Marie Nicholson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1799/"}]}]}], "contributors": [{"name": "Marie Nicholson", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1799/"}]}