// Numbas version: finer_feedback_settings {"name": "Truth tables 1", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"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"}, "tags": [], "variables": {"latex_symbol_list": {"description": "", "templateType": "anything", "group": "Lists of symbols", "definition": "[\"p\",\"q\",\"\\\\neg p\",\"\\\\neg q\"]", "name": "latex_symbol_list"}, "p": {"description": "", "templateType": "anything", "group": "Truth values", "definition": "[true,true,false,false]", "name": "p"}, "pre_ev1": {"description": "", "templateType": "anything", "group": "First Bracket", "definition": "map(evaluate(convch(a)+\" \"+conv(op)+\" \"+convch(b),[p[t],q[t]]),t,0..3)", "name": "pre_ev1"}, "t_value": {"description": "", "templateType": "anything", "group": "Ungrouped variables", "definition": "bool_to_label(map(evaluate(pre_ev1[t]+\" \"+conv(op1)+\" \"+pre_ev2[t],[]),t,0..3))", "name": "t_value"}, "a": {"description": "", "templateType": "anything", "group": "First Bracket", "definition": "latex(latex_symbol_list[s[0]])", "name": "a"}, "logic_symbol_list": {"description": "", "templateType": "anything", "group": "Lists of symbols", "definition": "[\"p\",\"q\",\"not p\",\"not q\"]", "name": "logic_symbol_list"}, "disq": {"description": "", "templateType": "anything", "group": "Truth values", "definition": "bool_to_label(q)", "name": "disq"}, "disp": {"description": "", "templateType": "anything", "group": "Truth values", "definition": "bool_to_label(p)", "name": "disp"}, "s": {"description": "", "templateType": "anything", "group": "Lists of symbols", "definition": "repeat(random(0..3),4)", "name": "s"}, "b1": {"description": "", "templateType": "anything", "group": "Second Bracket", "definition": "latex(latex_symbol_list[s[3]])", "name": "b1"}, "ev1": {"description": "", "templateType": "anything", "group": "First Bracket", "definition": "bool_to_label(pre_ev1)", "name": "ev1"}, "b": {"description": "", "templateType": "anything", "group": "First Bracket", "definition": "latex(latex_symbol_list[s[1]])", "name": "b"}, "a1": {"description": "", "templateType": "anything", "group": "Second Bracket", "definition": "latex(latex_symbol_list[s[2]])", "name": "a1"}, "op2": {"description": "", "templateType": "anything", "group": "Second Bracket", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "name": "op2"}, "op1": {"description": "", "templateType": "anything", "group": "Ungrouped variables", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "name": "op1"}, "op": {"description": "", "templateType": "anything", "group": "First Bracket", "definition": "latex(random(\"\\\\lor\",\"\\\\land\",\"\\\\to\"))", "name": "op"}, "ev2": {"description": "", "templateType": "anything", "group": "Second Bracket", "definition": "bool_to_label(pre_ev2)", "name": "ev2"}, "q": {"description": "", "templateType": "anything", "group": "Truth values", "definition": "[true,false,true,false]", "name": "q"}, "pre_ev2": {"description": "", "templateType": "anything", "group": "Second Bracket", "definition": "map(evaluate(convch(a1)+\" \"+conv(op2)+\" \"+convch(b1),[p[t],q[t]]),t,0..3)", "name": "pre_ev2"}}, "name": "Truth tables 1", "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
$\\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]}$$\\var{ev2[0]}$$\\var{t_value[0]}$
$\\var{ev1[1]}$$\\var{ev2[1]}$$\\var{t_value[1]}$
$\\var{ev1[2]}$$\\var{ev2[2]}$$\\var{t_value[2]}$
$\\var{ev1[3]}$$\\var{ev2[3]}$$\\var{t_value[3]}$
", "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}).\\]

\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"}], "metadata": {"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$.

\n

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

", "licence": "Creative Commons Attribution 4.0 International"}, "parts": [{"showCorrectAnswer": true, "marks": 0, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "gaps": [{"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{ev1[0]}", "showFeedbackIcon": true, "answer": "{ev1[0]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{ev1[1]}", "showFeedbackIcon": true, "answer": "{ev1[1]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{ev1[2]}", "showFeedbackIcon": true, "answer": "{ev1[2]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{ev1[3]}", "showFeedbackIcon": true, "answer": "{ev1[3]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{ev2[0]}", "showFeedbackIcon": true, "answer": "{ev2[0]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{ev2[1]}", "showFeedbackIcon": true, "answer": "{ev2[1]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{ev2[2]}", "showFeedbackIcon": true, "answer": "{ev2[2]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{ev2[3]}", "showFeedbackIcon": true, "answer": "{ev2[3]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{t_value[0]}", "showFeedbackIcon": true, "answer": "{t_value[0]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{t_value[1]}", "showFeedbackIcon": true, "answer": "{t_value[1]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{t_value[2]}", "showFeedbackIcon": true, "answer": "{t_value[2]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}, {"showCorrectAnswer": true, "marks": 1, "customMarkingAlgorithm": "", "scripts": {}, "variableReplacements": [], "extendBaseMarkingAlgorithm": true, "type": "patternmatch", "matchMode": "regex", "displayAnswer": "{t_value[3]}", "showFeedbackIcon": true, "answer": "{t_value[3]}", "variableReplacementStrategy": "originalfirst", "unitTests": []}], "type": "gapfill", "unitTests": [], "sortAnswers": false, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "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
$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]}$[[0]][[4]][[8]]
$\\var{disp[1]}$$\\var{disq[1]}$[[1]][[5]][[9]]
$\\var{disp[2]}$$\\var{disq[2]}$[[2]][[6]][[10]]
$\\var{disp[3]}$$\\var{disq[3]}$[[3]][[7]][[11]]
"}], "ungrouped_variables": ["op1", "t_value"], "preamble": {"js": "", "css": ""}, "functions": {"bool_to_label": {"language": "jme", "type": "number", "definition": "map(if(l[x],'T','F'),x,0..length(l)-1)", "parameters": [["l", "list"]]}, "evaluate": {"language": "javascript", "type": "number", "definition": "return scope.evaluate(expr);", "parameters": [["expr", "string"], ["dependencies", "list"]]}, "convch": {"language": "jme", "type": "string", "definition": "switch(ch=\"\\\\neg p\",\"not p[t]\",ch=\"\\\\neg q\",\"not q[t]\",ch=\"p\",\"p[t]\",\"q[t]\")", "parameters": [["ch", "string"]]}, "conv": {"language": "jme", "type": "string", "definition": "switch(op=\"\\\\land\",\"and\",op=\"\\\\lor\",\"or\",\"implies\")", "parameters": [["op", "string"]]}}, "extensions": [], "rulesets": {}, "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/"}]}