// Numbas version: finer_feedback_settings {"name": "Truth tables 4", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"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\nEnter T if true, else enter F.
\n\n\n\n\n\n\n\n\n\n\n", "variables": {"bool_q": {"group": "Truth values", "description": "", "definition": "list_to_boolean(list(logic_values[1]))", "name": "bool_q", "templateType": "anything"}, "latex_symbol_list": {"group": "Lists of symbols", "description": "", "definition": "[\"p\",\"q\",\"\\\\neg p\",\"\\\\neg q\",\"r\",\"\\\\neg r\"]", "name": "latex_symbol_list", "templateType": "anything"}, "final_value": {"group": "Ungrouped variables", "description": "", "definition": "bool_to_label(pre_final_value)", "name": "final_value", "templateType": "anything"}, "ev1": {"group": "First Bracket", "description": "", "definition": "bool_to_label(pre_ev1)", "name": "ev1", "templateType": "anything"}, "ev2": {"group": "Second Bracket", "description": "", "definition": "bool_to_label(pre_ev2)", "name": "ev2", "templateType": "anything"}, "pre_t_value": {"group": "First and Second Brackets", "description": "", "definition": "map(evaluate(pre_ev1[t]+\" \"+conv(op1)+\" \"+pre_ev2[t],[]),t,0..7)", "name": "pre_t_value", "templateType": "anything"}, "ev3": {"group": "Last ", "description": "", "definition": "bool_to_label(pre_ev3)", "name": "ev3", "templateType": "anything"}, "op2": {"group": "Second Bracket", "description": "", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "name": "op2", "templateType": "anything"}, "pre_final_value": {"group": "Ungrouped variables", "description": "", "definition": "map(evaluate(pre_t_value[t]+\" \"+conv(op4)+\" \"+pre_ev3[t],[]),t,0..7)", "name": "pre_final_value", "templateType": "anything"}, "s": {"group": "Lists of symbols", "description": "", "definition": "repeat(random(0..5),6)", "name": "s", "templateType": "anything"}, "logic_values": {"group": "Ungrouped variables", "description": "", "definition": "transpose(matrix(cart(3)))", "name": "logic_values", "templateType": "anything"}, "bool_r": {"group": "Truth values", "description": "", "definition": "list_to_boolean(list(logic_values[2]))", "name": "bool_r", "templateType": "anything"}, "pre_ev1": {"group": "First Bracket", "description": "", "definition": "map(evaluate(convch(a)+\" \"+conv(op)+\" \"+convch(b),[bool_p[t],bool_q[t],bool_r[t]]),t,0..7)", "name": "pre_ev1", "templateType": "anything"}, "op4": {"group": "Ungrouped variables", "description": "", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "name": "op4", "templateType": "anything"}, "d2": {"group": "Last ", "description": "", "definition": "switch(a2=\"\\\\neg p\",p,a2=\"\\\\neg q\",q,r)", "name": "d2", "templateType": "anything"}, "a": {"group": "First Bracket", "description": "", "definition": "latex(latex_symbol_list[s[0]])", "name": "a", "templateType": "anything"}, "a1": {"group": "Second Bracket", "description": "", "definition": "latex(latex_symbol_list[s[2]])", "name": "a1", "templateType": "anything"}, "b": {"group": "First Bracket", "description": "", "definition": "latex(latex_symbol_list[s[1]])", "name": "b", "templateType": "anything"}, "t_value": {"group": "First and Second Brackets", "description": "", "definition": "bool_to_label(pre_t_value)", "name": "t_value", "templateType": "anything"}, "p": {"group": "Truth values", "description": "", "definition": "bool_to_label(list_to_boolean(list(logic_values[0])))", "name": "p", "templateType": "anything"}, "op": {"group": "First Bracket", "description": "", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "name": "op", "templateType": "anything"}, "pre_ev2": {"group": "Second Bracket", "description": "", "definition": "map(evaluate(convch(a1)+\" \"+conv(op2)+\" \"+convch(b1),[bool_p[t],bool_q[t],bool_r[t]]),t,0..7)", "name": "pre_ev2", "templateType": "anything"}, "a2": {"group": "Last ", "description": "", "definition": "latex(random(\"\\\\neg p\",\"\\\\neg q\",\"\\\\neg r\"))", "name": "a2", "templateType": "anything"}, "c2": {"group": "Last ", "description": "", "definition": "latex(switch(a2=\"\\\\neg p\",\"p\",a2=\"\\\\neg q\",\"q\",\"r\"))", "name": "c2", "templateType": "anything"}, "r": {"group": "Truth values", "description": "", "definition": "bool_to_label(list_to_boolean(list(logic_values[2])))", "name": "r", "templateType": "anything"}, "op1": {"group": "First and Second Brackets", "description": "", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "name": "op1", "templateType": "anything"}, "q": {"group": "Truth values", "description": "", "definition": "bool_to_label(list_to_boolean(list(logic_values[1])))", "name": "q", "templateType": "anything"}, "b1": {"group": "Second Bracket", "description": "", "definition": "latex(latex_symbol_list[s[3]])", "name": "b1", "templateType": "anything"}, "logic_symbol_list": {"group": "Lists of symbols", "description": "", "definition": "[\"p\",\"q\",\"not p\",\"not q\",\"r\",\"not r\"]", "name": "logic_symbol_list", "templateType": "anything"}, "bool_p": {"group": "Truth values", "description": "", "definition": "list_to_boolean(list(logic_values[0]))", "name": "bool_p", "templateType": "anything"}, "pre_ev3": {"group": "Last ", "description": "", "definition": "map(evaluate(convch(a2),[bool_p[t],bool_q[t],bool_r[t]]),t,0..7)", "name": "pre_ev3", "templateType": "anything"}}, "extensions": [], "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", "r", "bool_p", "bool_q", "bool_r"], "name": "Truth values"}, {"variables": ["a2", "pre_ev3", "c2", "d2", "ev3"], "name": "Last "}, {"variables": ["op1", "pre_t_value", "t_value"], "name": "First and Second Brackets"}], "tags": [], "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"}, "functions": {"evaluate": {"type": "number", "parameters": [["expr", "string"], ["dependencies", "list"]], "definition": "return scope.evaluate(expr);", "language": "javascript"}, "list_to_boolean": {"type": "list", "parameters": [["l", "list"]], "definition": "map(if(l[x]<>0,true,false),x,0..length(l)-1)", "language": "jme"}, "conv": {"type": "string", "parameters": [["op", "string"]], "definition": "switch(op=\"\\\\land\",\"and\",op=\"\\\\lor\",\"or\",\"implies\")", "language": "jme"}, "cart": {"type": "number", "parameters": [["n", "number"]], "definition": "if(n=2,[[true,true],[true,false],[false,true],[false,false]],map([true]+cart(n-1)[x],x,0..2^(n-1)-1)+map([false]+cart(n-1)[x],x,0..2^(n-1)-1))", "language": "jme"}, "convch": {"type": "string", "parameters": [["ch", "string"]], "definition": "switch(ch=\"\\\\neg p\",\"not bool_p[t]\",ch=\"\\\\neg q\",\"not bool_q[t]\",ch=\"p\",\"bool_p[t]\",ch=\"q\",\"bool_q[t]\",ch=\"r\",\"bool_r[t]\",\"not bool_r[t]\")", "language": "jme"}, "bool_to_label": {"type": "number", "parameters": [["l", "list"]], "definition": "map(if(l[x],'T','F'),x,0..length(l)-1)", "language": "jme"}}, "parts": [{"marks": 0, "customMarkingAlgorithm": "", "prompt": "Complete the following truth table:
\n$p$ | $q$ | $r$ | $((\\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{r[0]}$ | \n[[0]] | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n$\\var{r[1]}$ | \n[[1]] | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n$\\var{r[2]}$ | \n[[2]] | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n$\\var{r[3]}$ | \n[[3]] | \n
$\\var{p[4]}$ | \n$\\var{q[4]}$ | \n$\\var{r[4]}$ | \n[[4]] | \n
$\\var{p[5]}$ | \n$\\var{q[5]}$ | \n$\\var{r[5]}$ | \n[[5]] | \n
$\\var{p[6]}$ | \n$\\var{q[6]}$ | \n$\\var{r[6]}$ | \n[[6]] | \n
$\\var{p[7]}$ | \n$\\var{q[7]}$ | \n$\\var{r[7]}$ | \n[[7]] | \n
First we find the truth table for $\\var{a} \\var{op} \\var{b}$:
\n$p$ | $q$ | $r$ | $\\var{a} \\var{op} \\var{b}$ |
---|---|---|---|
$\\var{p[0]}$ | \n$\\var{q[0]}$ | \n$\\var{r[0]}$ | \n$\\var{ev1[0]}$ | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n$\\var{r[1]}$ | \n$\\var{ev1[1]}$ | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n$\\var{r[2]}$ | \n$\\var{ev1[2]}$ | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n$\\var{r[3]}$ | \n$\\var{ev1[3]}$ | \n
$\\var{p[4]}$ | \n$\\var{q[4]}$ | \n$\\var{r[4]}$ | \n$\\var{ev1[4]}$ | \n
$\\var{p[5]}$ | \n$\\var{q[5]}$ | \n$\\var{r[5]}$ | \n$\\var{ev1[5]}$ | \n
$\\var{p[6]}$ | \n$\\var{q[6]}$ | \n$\\var{r[6]}$ | \n$\\var{ev1[6]}$ | \n
$\\var{p[7]}$ | \n$\\var{q[7]}$ | \n$\\var{r[7]}$ | \n$\\var{ev1[7]}$ | \n
Then the truth table for $\\var{a1} \\var{op2} \\var{b1}$:
\n$p$ | $q$ | $r$ | $\\var{a1} \\var{op2} \\var{b1}$ |
---|---|---|---|
$\\var{p[0]}$ | \n$\\var{q[0]}$ | \n$\\var{r[0]}$ | \n$\\var{ev2[0]}$ | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n$\\var{r[1]}$ | \n$\\var{ev2[1]}$ | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n$\\var{r[2]}$ | \n$\\var{ev2[2]}$ | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n$\\var{r[3]}$ | \n$\\var{ev2[3]}$ | \n
$\\var{p[4]}$ | \n$\\var{q[4]}$ | \n$\\var{r[4]}$ | \n$\\var{ev2[4]}$ | \n
$\\var{p[5]}$ | \n$\\var{q[5]}$ | \n$\\var{r[5]}$ | \n$\\var{ev2[5]}$ | \n
$\\var{p[6]}$ | \n$\\var{q[6]}$ | \n$\\var{r[6]}$ | \n$\\var{ev2[6]}$ | \n
$\\var{p[7]}$ | \n$\\var{q[7]}$ | \n$\\var{r[7]}$ | \n$\\var{ev2[7]}$ | \n
Putting these together to find $(\\var{a} \\var{op} \\var{b})\\var{op1}(\\var{a1} \\var{op2} \\var{b1})$:
\n\n$p$ | $q$ | $r$ | $\\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{r[0]}$ | \n$\\var{ev1[0]}$ | \n$\\var{ev2[0]}$ | \n$\\var{t_value[0]}$ | \n
$\\var{p[1]}$ | \n$\\var{q[1]}$ | \n$\\var{r[1]}$ | \n$\\var{ev1[1]}$ | \n$\\var{ev2[1]}$ | \n$\\var{t_value[1]}$ | \n
$\\var{p[2]}$ | \n$\\var{q[2]}$ | \n$\\var{r[2]}$ | \n$\\var{ev1[2]}$ | \n$\\var{ev2[2]}$ | \n$\\var{t_value[2]}$ | \n
$\\var{p[3]}$ | \n$\\var{q[3]}$ | \n$\\var{r[3]}$ | \n$\\var{ev1[3]}$ | \n$\\var{ev2[3]}$ | \n$\\var{t_value[3]}$ | \n
$\\var{p[4]}$ | \n$\\var{q[4]}$ | \n$\\var{r[4]}$ | \n$\\var{ev1[4]}$ | \n$\\var{ev2[4]}$ | \n$\\var{t_value[4]}$ | \n
$\\var{p[5]}$ | \n$\\var{q[5]}$ | \n$\\var{r[5]}$ | \n$\\var{ev1[5]}$ | \n$\\var{ev2[5]}$ | \n$\\var{t_value[5]}$ | \n
$\\var{p[6]}$ | \n$\\var{q[6]}$ | \n$\\var{r[6]}$ | \n$\\var{ev1[6]}$ | \n$\\var{ev2[6]}$ | \n$\\var{t_value[6]}$ | \n
$\\var{p[7]}$ | \n$\\var{q[7]}$ | \n$\\var{r[7]}$ | \n$\\var{ev1[7]}$ | \n$\\var{ev2[7]}$ | \n$\\var{t_value[7]}$ | \n
Next we find the truth table for $\\var{a2}$:
\n$\\var{c2}$ | $\\var{a2}$ |
---|---|
$\\var{d2[0]}$ | \n$\\var{ev3[0]}$ | \n
$\\var{d2[1]}$ | \n\n$\\var{ev3[1]}$ | \n
$\\var{d2[2]}$ | \n\n$\\var{ev3[2]}$ | \n
$\\var{d2[3]}$ | \n\n$\\var{ev3[3]}$ | \n
$\\var{d2[4]}$ | \n\n$\\var{ev3[4]}$ | \n
$\\var{d2[5]}$ | \n\n$\\var{ev3[5]}$ | \n
$\\var{d2[6]}$ | \n\n$\\var{ev3[6]}$ | \n
$\\var{d2[7]}$ | \n\n$\\var{ev3[7]}$ | \n
Putting this all together to obtain the truth table we want:
\n$p$ | $q$ | $r$ | $(\\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{r[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{r[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{r[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{r[3]}$ | \n$\\var{t_value[3]}$ | \n$\\var{ev3[3]}$ | \n$\\var{final_value[3]}$ | \n
$\\var{p[4]}$ | \n$\\var{q[4]}$ | \n$\\var{r[4]}$ | \n$\\var{t_value[4]}$ | \n$\\var{ev3[4]}$ | \n$\\var{final_value[4]}$ | \n
$\\var{p[5]}$ | \n$\\var{q[5]}$ | \n$\\var{r[5]}$ | \n$\\var{t_value[5]}$ | \n$\\var{ev3[5]}$ | \n$\\var{final_value[5]}$ | \n
$\\var{p[6]}$ | \n$\\var{q[6]}$ | \n$\\var{r[6]}$ | \n$\\var{t_value[6]}$ | \n$\\var{ev3[6]}$ | \n$\\var{final_value[6]}$ | \n
$\\var{p[7]}$ | \n$\\var{q[7]}$ | \n$\\var{r[7]}$ | \n$\\var{t_value[7]}$ | \n$\\var{ev3[7]}$ | \n$\\var{final_value[7]}$ | \n
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,\\;r,\\;\\neg p,\\;\\neg q,\\;\\neg r$ and each of $\\operatorname{op1},\\;\\operatorname{op2},\\;\\operatorname{op3},\\;\\operatorname{op4}$ one of $\\lor,\\;\\land,\\;\\to$.
\nFor example: $((q \\lor \\neg r) \\to (p \\land \\neg q)) \\land \\neg r$
", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "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/"}]}