// Numbas version: finer_feedback_settings {"name": "Daniel's copy of Truth tables 2 (v2) -", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"ungrouped_variables": ["pre_final_value", "op4", "final_value"], "extensions": [], "name": "Daniel's copy of Truth tables 2 (v2) -", "functions": {"evaluate": {"type": "number", "parameters": [["expr", "string"], ["dependencies", "list"]], "language": "javascript", "definition": "return scope.evaluate(expr);"}, "conv": {"type": "string", "parameters": [["op", "string"]], "language": "jme", "definition": "switch(op=\"\\\\land\",\"and\",op=\"\\\\lor\",\"or\",\"implies\")"}, "bool_to_label": {"type": "number", "parameters": [["l", "list"]], "language": "jme", "definition": "map(if(l[x],'T','F'),x,0..length(l)-1)"}, "convch": {"type": "string", "parameters": [["ch", "string"]], "language": "jme", "definition": "switch(ch=\"\\{\\\\sim \\}p\",\"not bool_p[t]\",ch=\"\\{\\\\sim \\}q\",\"not bool_q[t]\",ch=\"p\",\"bool_p[t]\",\"bool_q[t]\")"}}, "preamble": {"css": "", "js": ""}, "variables": {"p": {"description": "", "name": "p", "group": "Truth values", "templateType": "anything", "definition": "bool_to_label([true,true,false,false])"}, "b1": {"description": "", "name": "b1", "group": "Second Bracket", "templateType": "anything", "definition": "latex(latex_symbol_list[s[3]])"}, "pre_ev3": {"description": "", "name": "pre_ev3", "group": "Last ", "templateType": "anything", "definition": "map(evaluate(convch(a2),[bool_p[t],bool_q[t]]),t,0..3)"}, "a1": {"description": "", "name": "a1", "group": "Second Bracket", "templateType": "anything", "definition": "latex(latex_symbol_list[s[2]])"}, "bool_p": {"description": "", "name": "bool_p", "group": "Truth values", "templateType": "anything", "definition": "[true,true,false,false]"}, "a": {"description": "", "name": "a", "group": "First Bracket", "templateType": "anything", "definition": "latex(latex_symbol_list[s[0]])"}, "logic_symbol_list": {"description": "", "name": "logic_symbol_list", "group": "Lists of symbols", "templateType": "anything", "definition": "[\"p\",\"q\",\"not p\",\"not q\"]"}, "pre_final_value": {"description": "", "name": "pre_final_value", "group": "Ungrouped variables", "templateType": "anything", "definition": "map(evaluate(pre_t_value[t]+\" \"+conv(op4)+\" \"+pre_ev3[t],[]),t,0..3)"}, "a2": {"description": "", "name": "a2", "group": "Last ", "templateType": "anything", "definition": "latex(random(\"\\{\\\\sim \\}p\",\"\\{\\\\sim \\}q\"))"}, "op1": {"description": "", "name": "op1", "group": "First and Second Brackets", "templateType": "anything", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))"}, "op2": {"description": "", "name": "op2", "group": "Second Bracket", "templateType": "anything", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))"}, "pre_ev1": {"description": "", "name": "pre_ev1", "group": "First Bracket", "templateType": "anything", "definition": "map(evaluate(convch(a)+\" \"+conv(op)+\" \"+convch(b),[bool_p[t],bool_q[t]]),t,0..3)"}, "b": {"description": "", "name": "b", "group": "First Bracket", "templateType": "anything", "definition": "latex(latex_symbol_list[s[1]])"}, "ev2": {"description": "", "name": "ev2", "group": "Second Bracket", "templateType": "anything", "definition": "bool_to_label(pre_ev2)"}, "q": {"description": "", "name": "q", "group": "Truth values", "templateType": "anything", "definition": "bool_to_label([true,false,true,false])"}, "pre_t_value": {"description": "", "name": "pre_t_value", "group": "First and Second Brackets", "templateType": "anything", "definition": "map(evaluate(pre_ev1[t]+\" \"+conv(op1)+\" \"+pre_ev2[t],[]),t,0..3)"}, "bool_q": {"description": "", "name": "bool_q", "group": "Truth values", "templateType": "anything", "definition": "[true,false,true,false]"}, "t_value": {"description": "", "name": "t_value", "group": "First and Second Brackets", "templateType": "anything", "definition": "bool_to_label(pre_t_value)"}, "pre_ev2": {"description": "", "name": "pre_ev2", "group": "Second Bracket", "templateType": "anything", "definition": "map(evaluate(convch(a1)+\" \"+conv(op2)+\" \"+convch(b1),[bool_p[t],bool_q[t]]),t,0..3)"}, "ev3": {"description": "", "name": "ev3", "group": "Last ", "templateType": "anything", "definition": "bool_to_label(pre_ev3)"}, "latex_symbol_list": {"description": "", "name": "latex_symbol_list", "group": "Lists of symbols", "templateType": "anything", "definition": "[\"p\",\"q\",\"\\{\\\\sim \\}p\",\"\\{\\\\sim \\}q\"]"}, "ev1": {"description": "", "name": "ev1", "group": "First Bracket", "templateType": "anything", "definition": "bool_to_label(pre_ev1)"}, "final_value": {"description": "", "name": "final_value", "group": "Ungrouped variables", "templateType": "anything", "definition": "bool_to_label(pre_final_value)"}, "s": {"description": "", "name": "s", "group": "Lists of symbols", "templateType": "anything", "definition": "repeat(random(0..3),6)"}, "op4": {"description": "", "name": "op4", "group": "Ungrouped variables", "templateType": "anything", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))"}, "op": {"description": "", "name": "op", "group": "First Bracket", "templateType": "anything", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))"}}, "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$.
\nFor example: $((q \\lor \\neg p) \\to (p \\land \\neg q)) \\lor \\neg q$
", "licence": "Creative Commons Attribution 4.0 International"}, "parts": [{"type": "gapfill", "scripts": {}, "prompt": "Complete the following truth table:
\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]}$ | \n$\\var{q[0]}$ | \n[[0]] | \n[[4]] | \n[[8]] | \n[[12]] | \n[[16]] | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n[[1]] | \n[[5]] | \n[[9]] | \n[[13]] | \n[[17]] | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n[[2]] | \n[[6]] | \n[[10]] | \n[[14]] | \n[[18]] | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n[[3]] | \n[[7]] | \n[[11]] | \n[[15]] | \n[[19]] | \n
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\nEnter T if true, else enter F.
\n\n\n\n\n\n\n\n\n\n\n", "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"}, "advice": "First we find the truth table for $\\var{a} \\var{op} \\var{b}$:
\n$p$ | $q$ | $\\var{a} \\var{op} \\var{b}$ |
---|---|---|
$\\var{p[0]}$ | \n$\\var{q[0]}$ | \n\n$\\var{ev1[0]}$ | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n\n$\\var{ev1[1]}$ | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n\n$\\var{ev1[2]}$ | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n\n$\\var{ev1[3]}$ | \n
Then the truth table for $\\var{a1} \\var{op2} \\var{b1}$:
\n$p$ | $q$ | $\\var{a1} \\var{op2} \\var{b1}$ |
---|---|---|
$\\var{p[0]}$ | \n$\\var{q[0]}$ | \n$\\var{ev2[0]}$ | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n$\\var{ev2[1]}$ | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n$\\var{ev2[2]}$ | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n$\\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$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]}$ | \n$\\var{q[0]}$ | \n$\\var{ev1[0]}$ | \n$\\var{ev2[0]}$ | \n$\\var{t_value[0]}$ | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n$\\var{ev1[1]}$ | \n$\\var{ev2[1]}$ | \n$\\var{t_value[1]}$ | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n$\\var{ev1[2]}$ | \n$\\var{ev2[2]}$ | \n$\\var{t_value[2]}$ | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n$\\var{ev1[3]}$ | \n$\\var{ev2[3]}$ | \n$\\var{t_value[3]}$ | \n
Next we find the truth table for $\\var{a2}$:
\n$p$ | $q$ | $\\var{a2}$ |
---|---|---|
$\\var{p[0]}$ | \n$\\var{q[0]}$ | \n$\\var{ev3[0]}$ | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n$\\var{ev3[1]}$ | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n$\\var{ev3[2]}$ | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n$\\var{ev3[3]}$ | \n
Putting this all together to obtain the truth table we want:
\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]}$ | \n$\\var{q[0]}$ | \n$\\var{t_value[0]}$ | \n$\\var{ev3[0]}$ | \n$\\var{final_value[0]}$ | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n$\\var{t_value[1]}$ | \n$\\var{ev3[1]}$ | \n$\\var{final_value[1]}$ | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n$\\var{t_value[2]}$ | \n$\\var{ev3[2]}$ | \n$\\var{final_value[2]}$ | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n$\\var{t_value[3]}$ | \n$\\var{ev3[3]}$ | \n$\\var{final_value[3]}$ | \n