// Numbas version: finer_feedback_settings {"name": "Truth tables 1(v2)", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"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": {"disp": {"templateType": "anything", "group": "Truth values", "definition": "bool_to_label(p)", "description": "", "name": "disp"}, "q": {"templateType": "anything", "group": "Truth values", "definition": "[true,false,true,false]", "description": "", "name": "q"}, "p": {"templateType": "anything", "group": "Truth values", "definition": "[true,true,false,false]", "description": "", "name": "p"}, "b": {"templateType": "anything", "group": "First Bracket", "definition": "latex(latex_symbol_list[s[1]])", "description": "", "name": "b"}, "op": {"templateType": "anything", "group": "First Bracket", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "description": "", "name": "op"}, "latex_symbol_list": {"templateType": "anything", "group": "Lists of symbols", "definition": "[\"p\",\"q\",\"\\\\neg p\",\"\\\\neg q\"]", "description": "", "name": "latex_symbol_list"}, "b1": {"templateType": "anything", "group": "Second Bracket", "definition": "latex(latex_symbol_list[s[3]])", "description": "", "name": "b1"}, "a1": {"templateType": "anything", "group": "Second Bracket", "definition": "latex(latex_symbol_list[s[2]])", "description": "", "name": "a1"}, "op2": {"templateType": "anything", "group": "Second Bracket", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "description": "", "name": "op2"}, "op1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "description": "", "name": "op1"}, "disq": {"templateType": "anything", "group": "Truth values", "definition": "bool_to_label(q)", "description": "", "name": "disq"}, "pre_ev2": {"templateType": "anything", "group": "Second Bracket", "definition": "map(evaluate(convch(a1)+\" \"+conv(op2)+\" \"+convch(b1),[p[t],q[t]]),t,0..3)", "description": "", "name": "pre_ev2"}, "s": {"templateType": "anything", "group": "Lists of symbols", "definition": "repeat(random(0..3),4)", "description": "", "name": "s"}, "ev1": {"templateType": "anything", "group": "First Bracket", "definition": "bool_to_label(pre_ev1)", "description": "", "name": "ev1"}, "a": {"templateType": "anything", "group": "First Bracket", "definition": "latex(latex_symbol_list[s[0]])", "description": "", "name": "a"}, "t_value": {"templateType": "anything", "group": "Ungrouped variables", "definition": "bool_to_label(map(evaluate(pre_ev1[t]+\" \"+conv(op1)+\" \"+pre_ev2[t],[]),t,0..3))", "description": "", "name": "t_value"}, "pre_ev1": {"templateType": "anything", "group": "First Bracket", "definition": "map(evaluate(convch(a)+\" \"+conv(op)+\" \"+convch(b),[p[t],q[t]]),t,0..3)", "description": "", "name": "pre_ev1"}, "logic_symbol_list": {"templateType": "anything", "group": "Lists of symbols", "definition": "[\"p\",\"q\",\"not p\",\"not q\"]", "description": "", "name": "logic_symbol_list"}, "ev2": {"templateType": "anything", "group": "Second Bracket", "definition": "bool_to_label(pre_ev2)", "description": "", "name": "ev2"}}, "ungrouped_variables": ["op1", "t_value"], "rulesets": {}, "name": "Truth tables 1(v2)", "showQuestionGroupNames": false, "functions": {"convch": {"type": "string", "language": "jme", "definition": "switch(ch=\"\\\\neg p\",\"not p[t]\",ch=\"\\\\neg q\",\"not q[t]\",ch=\"p\",\"p[t]\",\"q[t]\")", "parameters": [["ch", "string"]]}, "evaluate": {"type": "number", "language": "javascript", "definition": "return scope.evaluate(expr);", "parameters": [["expr", "string"], ["dependencies", "list"]]}, "conv": {"type": "string", "language": "jme", "definition": "switch(op=\"\\\\land\",\"and\",op=\"\\\\lor\",\"or\",\"implies\")", "parameters": [["op", "string"]]}, "bool_to_label": {"type": "number", "language": "jme", "definition": "map(if(l[x],'T','F'),x,0..length(l)-1)", "parameters": [["l", "list"]]}}, "parts": [{"showCorrectAnswer": true, "scripts": {}, "gaps": [{"answer": "{ev1[0]}", "displayAnswer": "{ev1[0]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{ev1[1]}", "displayAnswer": "{ev1[1]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{ev1[2]}", "displayAnswer": "{ev1[2]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{ev1[3]}", "displayAnswer": "{ev1[3]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{ev2[0]}", "displayAnswer": "{ev2[0]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{ev2[1]}", "displayAnswer": "{ev2[1]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{ev2[2]}", "displayAnswer": "{ev2[2]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{ev2[3]}", "displayAnswer": "{ev2[3]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{t_value[0]}", "displayAnswer": "{t_value[0]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{t_value[1]}", "displayAnswer": "{t_value[1]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{t_value[2]}", "displayAnswer": "{t_value[2]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"answer": "{t_value[3]}", "displayAnswer": "{t_value[3]}", "scripts": {}, "type": "patternmatch", "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "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{disp[0]}$ | \n$\\var{disq[0]}$ | \n[[0]] | \n[[4]] | \n[[8]] | \n
$\\var{disp[1]}$ | \n$\\var{disq[1]}$ | \n[[1]] | \n[[5]] | \n[[9]] | \n
$\\var{disp[2]}$ | \n$\\var{disq[2]}$ | \n[[2]] | \n[[6]] | \n[[10]] | \n
$\\var{disp[3]}$ | \n$\\var{disq[3]}$ | \n[[3]] | \n[[7]] | \n[[11]] | \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}).\\]
\n\nEnter T if true, else enter F.
\n\n\n\n\n\n\n\n\n\n\n", "tags": [], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": "Create a truth table for a logical expression of the form $(a \\operatorname{op1} b) \\operatorname{op2}(c \\operatorname{op3} d)$ where $a, \\;b,\\;c,\\;d$ can be the Boolean variables $p,\\;q,\\;\\neg p,\\;\\neg q$ and each of $\\operatorname{op1},\\;\\operatorname{op2},\\;\\operatorname{op3}$ one of $\\lor,\\;\\land,\\;\\to$.
\nFor example: $(p \\lor \\neg q) \\land(q \\to \\neg p)$.
"}, "advice": "First we find the truth table for $\\var{a} \\var{op} \\var{b}$:
\n$p$ | $q$ | $\\var{a} \\var{op} \\var{b}$ |
---|---|---|
$\\var{disp[0]}$ | \n$\\var{disq[0]}$ | \n$\\var{ev1[0]}$ | \n
$\\var{disp[1]}$ | \n$\\var{disq[1]}$ | \n$\\var{ev1[1]}$ | \n
$\\var{disp[2]}$ | \n$\\var{disq[2]}$ | \n$\\var{ev1[2]}$ | \n
$\\var{disp[3]}$ | \n$\\var{disq[3]}$ | \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{disp[0]}$ | \n$\\var{disq[0]}$ | \n$\\var{ev2[0]}$ | \n
$\\var{disp[1]}$ | \n$\\var{disq[1]}$ | \n$\\var{ev2[1]}$ | \n
$\\var{disp[2]}$ | \n$\\var{disq[2]}$ | \n$\\var{ev2[2]}$ | \n
$\\var{disp[3]}$ | \n$\\var{disq[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$\\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{ev1[0]}$ | \n$\\var{ev2[0]}$ | \n$\\var{t_value[0]}$ | \n
$\\var{ev1[1]}$ | \n$\\var{ev2[1]}$ | \n$\\var{t_value[1]}$ | \n
$\\var{ev1[2]}$ | \n$\\var{ev2[2]}$ | \n$\\var{t_value[2]}$ | \n
$\\var{ev1[3]}$ | \n$\\var{ev2[3]}$ | \n$\\var{t_value[3]}$ | \n