// Numbas version: finer_feedback_settings {"name": "Truth tables 3 (v2)", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {"evaluate": {"definition": "return scope.evaluate(expr);", "type": "number", "language": "javascript", "parameters": [["expr", "string"], ["dependencies", "list"]]}, "conv": {"definition": "switch(op=\"\\\\land\",\"and\",op=\"\\\\lor\",\"or\",\"implies\")", "type": "string", "language": "jme", "parameters": [["op", "string"]]}, "bool_to_label": {"definition": "map(if(l[x],'T','F'),x,0..length(l)-1)", "type": "number", "language": "jme", "parameters": [["l", "list"]]}, "convch": {"definition": "switch(ch=\"\\\\neg p\",\"not p[t]\",ch=\"\\\\neg q\",\"not q[t]\",ch=\"p\",\"p[t]\",\"q[t]\")", "type": "string", "language": "jme", "parameters": [["ch", "string"]]}}, "ungrouped_variables": ["final_value", "op4"], "name": "Truth tables 3 (v2)", "tags": [], "preamble": {"css": "", "js": ""}, "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
$p$$q$$\\var{a} \\var{op} \\var{b}$
$\\var{disp[0]}$$\\var{disq[0]}$$\\var{ev1[0]}$
$\\var{disp[1]}$$\\var{disq[1]}$$\\var{ev1[1]}$
$\\var{disp[2]}$$\\var{disq[2]}$$\\var{ev1[2]}$
$\\var{disp[3]}$$\\var{disq[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{disp[0]}$$\\var{disq[0]}$$\\var{ev2[0]}$
$\\var{disp[1]}$$\\var{disq[1]}$$\\var{ev2[1]}$
$\\var{disp[2]}$$\\var{disq[2]}$$\\var{ev2[2]}$
$\\var{disp[3]}$$\\var{disq[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{disp[0]}$$\\var{disq[0]}$$\\var{ev1[0]}$$\\var{ev2[0]}$$\\var{t_value[0]}$
$\\var{disp[1]}$$\\var{disq[1]}$$\\var{ev1[1]}$$\\var{ev2[1]}$$\\var{t_value[1]}$
$\\var{disp[2]}$$\\var{disq[2]}$$\\var{ev1[2]}$$\\var{ev2[2]}$$\\var{t_value[2]}$
$\\var{disp[3]}$$\\var{disq[3]}$$\\var{ev1[3]}$$\\var{ev2[3]}$$\\var{t_value[3]}$
\n

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

\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{op3} \\var{b2}$
$\\var{disp[0]}$$\\var{disq[0]}$$\\var{ev3[0]}$
$\\var{disp[1]}$$\\var{disq[1]}$$\\var{ev3[1]}$
$\\var{disp[2]}$$\\var{disq[2]}$$\\var{ev3[2]}$
$\\var{disp[3]}$$\\var{disq[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{op3} \\var{b2}$$((\\var{a} \\var{op} \\var{b})\\var{op1}(\\var{a1} \\var{op2} \\var{b1}))\\var{op4}(\\var{a2} \\var{op3} \\var{b2})$
$\\var{disp[0]}$$\\var{disq[0]}$$\\var{t_value[0]}$$\\var{ev3[0]}$$\\var{final_value[0]}$
$\\var{disp[1]}$$\\var{disq[1]}$$\\var{t_value[1]}$$\\var{ev3[1]}$$\\var{final_value[1]}$
$\\var{disp[2]}$$\\var{disq[2]}$$\\var{t_value[2]}$$\\var{ev3[2]}$$\\var{final_value[2]}$
$\\var{disp[3]}$$\\var{disq[3]}$$\\var{t_value[3]}$$\\var{ev3[3]}$$\\var{final_value[3]}$
", "rulesets": {}, "parts": [{"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{op3} \\var{b2}$$((\\var{a} \\var{op} \\var{b})\\var{op1}(\\var{a1} \\var{op2} \\var{b1}))\\var{op4}(\\var{a2} \\var{op3} \\var{b2})$
$\\var{disp[0]}$$\\var{disq[0]}$[[0]][[4]][[8]][[12]][[16]]
$\\var{disp[1]}$$\\var{disq[1]}$[[1]][[5]][[9]][[13]][[17]]
$\\var{disp[2]}$$\\var{disq[2]}$[[2]][[6]][[10]][[14]][[18]]
$\\var{disp[3]}$$\\var{disq[3]}$[[3]][[7]][[11]][[15]][[19]]
", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev1[0]}", "scripts": {}, "answer": "{ev1[0]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev1[1]}", "scripts": {}, "answer": "{ev1[1]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev1[2]}", "scripts": {}, "answer": "{ev1[2]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev1[3]}", "scripts": {}, "answer": "{ev1[3]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev2[0]}", "scripts": {}, "answer": "{ev2[0]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev2[1]}", "scripts": {}, "answer": "{ev2[1]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev2[2]}", "scripts": {}, "answer": "{ev2[2]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev2[3]}", "scripts": {}, "answer": "{ev2[3]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{t_value[0]}", "scripts": {}, "answer": "{t_value[0]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{t_value[1]}", "scripts": {}, "answer": "{t_value[1]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{t_value[2]}", "scripts": {}, "answer": "{t_value[2]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{t_value[3]}", "scripts": {}, "answer": "{t_value[3]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev3[0]}", "scripts": {}, "answer": "{ev3[0]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev3[1]}", "scripts": {}, "answer": "{ev3[1]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev3[2]}", "scripts": {}, "answer": "{ev3[2]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{ev3[3]}", "scripts": {}, "answer": "{ev3[3]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{final_value[0]}", "scripts": {}, "answer": "{final_value[0]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{final_value[1]}", "scripts": {}, "answer": "{final_value[1]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{final_value[2]}", "scripts": {}, "answer": "{final_value[2]}", "marks": 1, "type": "patternmatch"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "displayAnswer": "{final_value[3]}", "scripts": {}, "answer": "{final_value[3]}", "marks": 1, "type": "patternmatch"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "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} \\var{op3} \\var{b2}).\\]

\n

\n

Enter T if true, else enter F.

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n

\n

", "variable_groups": [{"variables": ["logic_symbol_list", "latex_symbol_list", "s"], "name": "Lists of symbols"}, {"variables": ["a", "b", "op", "pre_ev1", "ev1"], "name": "First Bracket"}, {"variables": ["a1", "b1", "op2", "pre_ev2", "ev2"], "name": "Second Bracket"}, {"variables": ["p", "q", "disp", "disq"], "name": "Truth values"}, {"variables": ["a2", "b2", "op3", "pre_ev3", "ev3"], "name": "Third Bracket"}, {"variables": ["op1", "pre_t_value", "t_value"], "name": "First and Second Brackets"}], "variablesTest": {"maxRuns": "150", "condition": "a1 <>b1 and a2<>b2 and\nif(a='p' or a='\\\\neg p',b=random('q','\\\\neg q'),b=random('p','\\\\neg p'))\n"}, "variables": {"op4": {"definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "templateType": "anything", "group": "Ungrouped variables", "name": "op4", "description": ""}, "disp": {"definition": "bool_to_label(p)", "templateType": "anything", "group": "Truth values", "name": "disp", "description": ""}, "op1": {"definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "templateType": "anything", "group": "First and Second Brackets", "name": "op1", "description": ""}, "op2": {"definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "templateType": "anything", "group": "Second Bracket", "name": "op2", "description": ""}, "disq": {"definition": "bool_to_label(q)", "templateType": "anything", "group": "Truth values", "name": "disq", "description": ""}, "b1": {"definition": "latex(latex_symbol_list[s[3]])", "templateType": "anything", "group": "Second Bracket", "name": "b1", "description": ""}, "b2": {"definition": "latex(latex_symbol_list[s[5]])", "templateType": "anything", "group": "Third Bracket", "name": "b2", "description": ""}, "final_value": {"definition": "bool_to_label(map(evaluate(pre_t_value[t]+\" \"+conv(op4)+\" \"+pre_ev3[t],[]),t,0..3))", "templateType": "anything", "group": "Ungrouped variables", "name": "final_value", "description": ""}, "latex_symbol_list": {"definition": "[\"p\",\"q\",\"\\\\neg p\",\"\\\\neg q\"]", "templateType": "anything", "group": "Lists of symbols", "name": "latex_symbol_list", "description": ""}, "op3": {"definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "templateType": "anything", "group": "Third Bracket", "name": "op3", "description": ""}, "pre_t_value": {"definition": "map(evaluate(pre_ev1[t]+\" \"+conv(op1)+\" \"+pre_ev2[t],[]),t,0..3)", "templateType": "anything", "group": "First and Second Brackets", "name": "pre_t_value", "description": ""}, "t_value": {"definition": "bool_to_label(pre_t_value)", "templateType": "anything", "group": "First and Second Brackets", "name": "t_value", "description": ""}, "ev1": {"definition": "bool_to_label(pre_ev1)", "templateType": "anything", "group": "First Bracket", "name": "ev1", "description": ""}, "ev2": {"definition": "bool_to_label(pre_ev2)", "templateType": "anything", "group": "Second Bracket", "name": "ev2", "description": ""}, "ev3": {"definition": "bool_to_label(pre_ev3)", "templateType": "anything", "group": "Third Bracket", "name": "ev3", "description": ""}, "pre_ev2": {"definition": "map(evaluate(convch(a1)+\" \"+conv(op2)+\" \"+convch(b1),[p[t],q[t]]),t,0..3)", "templateType": "anything", "group": "Second Bracket", "name": "pre_ev2", "description": ""}, "logic_symbol_list": {"definition": "[\"p\",\"q\",\"not p\",\"not q\"]", "templateType": "anything", "group": "Lists of symbols", "name": "logic_symbol_list", "description": ""}, "pre_ev1": {"definition": "map(evaluate(convch(a)+\" \"+conv(op)+\" \"+convch(b),[p[t],q[t]]),t,0..3)", "templateType": "anything", "group": "First Bracket", "name": "pre_ev1", "description": ""}, "a1": {"definition": "latex(latex_symbol_list[s[2]])", "templateType": "anything", "group": "Second Bracket", "name": "a1", "description": ""}, "a2": {"definition": "latex(latex_symbol_list[s[4]])", "templateType": "anything", "group": "Third Bracket", "name": "a2", "description": ""}, "a": {"definition": "latex(latex_symbol_list[s[0]])", "templateType": "anything", "group": "First Bracket", "name": "a", "description": ""}, "b": {"definition": "latex(latex_symbol_list[s[1]])", "templateType": "anything", "group": "First Bracket", "name": "b", "description": ""}, "pre_ev3": {"definition": "map(evaluate(convch(a2)+\" \"+conv(op3)+\" \"+convch(b2),[p[t],q[t]]),t,0..3)", "templateType": "anything", "group": "Third Bracket", "name": "pre_ev3", "description": ""}, "q": {"definition": "[true,false,true,false]", "templateType": "anything", "group": "Truth values", "name": "q", "description": ""}, "p": {"definition": "[true,true,false,false]", "templateType": "anything", "group": "Truth values", "name": "p", "description": ""}, "s": {"definition": "repeat(random(0..3),6)", "templateType": "anything", "group": "Lists of symbols", "name": "s", "description": ""}, "op": {"definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "templateType": "anything", "group": "First Bracket", "name": "op", "description": ""}}, "metadata": {"notes": "", "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 \\operatorname{op5} f) $ where each of $a, \\;b,\\;c,\\;d,\\;e,\\;f$ can be one the Boolean variables $p,\\;q,\\;\\neg p,\\;\\neg q$ and each of $\\operatorname{op1},\\;\\operatorname{op2},\\;\\operatorname{op3},\\;\\operatorname{op4},\\;\\operatorname{op5}$ one of $\\lor,\\;\\land,\\;\\to$.

\n

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

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}]}]}], "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}]}