// Numbas version: exam_results_page_options {"name": "Relations: Partial Ordering and Hasse Diagram", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [["question-resources/hasse.png", "/srv/numbas/media/question-resources/hasse.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Relations: Partial Ordering and Hasse Diagram", "tags": [], "metadata": {"description": "", "licence": "None specified"}, "statement": "

Another important relation is called a partial order. We say that a relation $\\leq$ is a partial order when it has the three characteristic qualities:

\n\n

Typically, we take a set together with partial ordering such as \"less than or equal to\" $\\leq$, \"subset\" $\\subseteq$ or \"divides\" $|$. Together, the partial ordering and set are called a partially ordered set or poset.

\n

Instead of an arrow diagram, we use a Hasse Diagram to visualise a poset. This communicates the relation between elements of the set with as few edges as possible.

\n

Consider the set

\n

$A = \\left\\{ \\left\\{1\\right\\} ,\\left\\{2 \\right\\} ,\\left\\{3 \\right\\},\\left\\{1,2 \\right\\} ,\\left\\{ 3,4\\right\\},\\left\\{1,2,4 \\right\\},\\left\\{1,3,4 \\right\\},\\left\\{1,2,4,5 \\right\\},\\left\\{ 1,2,3,5 \\right\\} \\right\\} $

\n

together with the partial ordering $\\subseteq$.

", "advice": "

See the steps section above for a general description for how to design Hasse diagrams.

\n

A good rule of thumb is to work from the bottom up. Join all 1-element sets to those 2-element sets that contain them as a subset. Then do the same for 2-element sets to 3-element sets, and 3-element sets to 4-element sets.

\n

Next check if any of the 1-element sets are contained in any of the 3-element sets that they are not already connected to by a path of edges. If they are, join these vertices. Do the same for 2-element sets contained in 4-element sets.

\n

Finally, check if any of the 1-element sets are contained in any of the 4-element sets that they are not already connected to by a path of edges.

", "rulesets": {}, "extensions": ["jsxgraph"], "variables": {"b": {"name": "b", "group": "Ungrouped variables", "definition": "random(0.1 .. 1#0.1)", "description": "", "templateType": "randrange"}, "a": {"name": "a", "group": "Ungrouped variables", "definition": "random(0.1 .. 1#0.1)", "description": "", "templateType": "randrange"}}, "variablesTest": {"condition": "a<>b", "maxRuns": 100}, "ungrouped_variables": ["a", "b"], "variable_groups": [], "functions": {"createNetwork": {"parameters": [], "type": "html", "language": "javascript", "definition": "// This function creates the board and sets it up, then returns an\n// HTML div tag containing the board.\n \n// The line is described by the equation \n// y = a*x + b\n\n// This function takes as its parameters the coefficients a and b,\n// and the coordinates (x2,y2) of a point on the line.\n\n// First, make the JSXGraph board.\n// The function provided by the JSXGraph extension wraps the board up in \n// a div tag so that it's easier to embed in the page.\nvar div = Numbas.extensions.jsxgraph.makeBoard('300px','400px',\n{boundingBox: [0,4.5,1,0.5],\n axis: false,\n showNavigation: false,\n grid: false\n});\n\n//console.log(\"Extensions\")\n//console.log(Numbas.extensions);\n\n// div.board is the object created by JSXGraph, which you use to \n// manipulate elements\n\nvar redColor='#ff0000';\nvar blueColor='#0000ff';\nvar grayColor='#9b9b9b';\n\nvar PointStyle={face:'o', size:4, fixed:false,label:{fontSize:20}};\nvar LineStyle={fixed:true,straightFirst:false,straightLast:false,strokeWidth:2,dash:0,strokeColor:blueColor};\n\n\nquestion.parts[0].trueEdges=new Set([\"{1,2,4,5}gt{1,2,4}\", \"{1,2,3,5}gt{1,2}\", \"{1,2,3,5}gt{3}\", \"{1,3,4}gt{3,4}\", \"{1,3,4}gt{1}\", \"{1,2,4}gt{1,2}\", \"{1,2}gt{1}\", \"{1,2}gt{2}\", \"{3,4}gt{3}\"]);\n\nquestion.parts[0].allEdges = new Set([\"{1,2,4,5}gt{1,2,4}\", \"{1,2,4,5}gt{1,2}\", \"{1,2,4,5}gt{1}\", \"{1,2,4,5}gt{2}\", \"{1,2,3,5}gt{1,2}\", \"{1,2,3,5}gt{1}\", \"{1,2,3,5}gt{2}\", \"{1,2,3,5}gt{3}\", \"{1,3,4}gt{3,4}\", \"{1,3,4}gt{1}\", \"{1,3,4}gt{3}\", \"{1,2,4}gt{1,2}\", \"{1,2,4}gt{1}\", \"{1,2,4}gt{2}\", \"{1,2}gt{1}\", \"{1,2}gt{2}\", \"{3,4}gt{3}\"]);\n\nquestion.parts[0].removableEdges = new Set([\"{1,2,4,5}gt{1,2}\", \"{1,2,4,5}gt{1}\", \"{1,2,4,5}gt{2}\", \"{1,2,4,5}gt{1}\", \"{1,2,4,5}gt{2}\", \"{1,2,3,5}gt{1}\", \"{1,2,3,5}gt{2}\", \"{1,3,4}gt{3}\", \"{1,2,4}gt{1}\", \"{1,2,4}gt{2}\"]);\n\nquestion.parts[0].constructedEdges=new Set();\n\nvar lineDict={};\n\nvar point0selected=false\nvar point0\n\n\nfunction changePointStyle(){\n //console.log(this);\n if(this.selected==true){\n this.selected=false;\n this.setAttribute({fillColor:redColor,strokeColor:redColor});\n \n point0selected=false\n \n } else {\n this.selected=true ;\n this.setAttribute({fillColor:blueColor,strokeColor:blueColor});\n \n if(point0selected==false){\n point0selected=true\n point0=this\n } else {\n if(point0.Y()>this.Y()){\n lineName=point0.name+\"gt\"+this.name;\n } else if (point0.Y() this.trueEdges.has(x))); \n\nvar fractionOfTrue=Math.round(100*goodSet.size/totalTrue)/100;\nvar runningGrade=fractionOfTrue;\n\nif (fractionOfTrue==0){\n var ratioPhrase=\"none\"\n} else if (fractionOfTrue<0.3){\n var ratioPhrase=\"a few\"\n} else if (fractionOfTrue<0.6){\n var ratioPhrase=\"some\"\n} else if (fractionOfTrue<0.9){\n var ratioPhrase=\"many\"\n} else if (fractionOfTrue<1){\n var ratioPhrase=\"almost all\"\n} else {\n var ratioPhrase=\"all\"\n}\nthis.setCredit(runningGrade,\"You have created \"+ratioPhrase+\" of the correct edges.\");\n\nif (fractionOfTrue<1){\n var missingSet = new Set([...this.trueEdges].filter(x => !this.constructedEdges.has(x))); \n // Just double checking there really is a missing element\n if (missingSet.size>0) {\n this.setCredit(runningGrade,\"You are missing some vital edges, for example from \"+missingSet.values().next()['value'].replace(\"gt\", \" to \")+\".\");\n }\n}\n\nvar badSet = new Set([...this.constructedEdges].filter(x => !this.allEdges.has(x))); \nvar badReduction=0;\n\nfor (let item of badSet) {\n //console.log(item);\n runningGrade=Math.max(runningGrade-0.25,0);\n this.setCredit(runningGrade,\"You have edges that are do not represent a partial order, \"+item.replace(\"gt\", \" is connected to \")+\".\")\n};\n\nvar preredundantSet = new Set([...this.constructedEdges].filter(x => this.allEdges.has(x))); \n//console.log(\"prered\");\n//console.log(preredundantSet);\n\nvar redundantSet = new Set([...preredundantSet].filter(x => !this.trueEdges.has(x))); \n\nfor (let item of redundantSet) {\n //console.log(item);\n runningGrade=Math.max(runningGrade-0.125,0);\n\n this.setCredit(runningGrade,\"The edge from \"+item.replace(\"gt\", \" to \")+\" can be reduced.\");\n};\n\nthis.answered = true;", "order": "instead"}, "validate": {"script": "return true", "order": "instead"}}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Make a Hasse Diagram for this poset. Click on two verticies to make or destroy the edge between them.

\n

{createNetwork()}

", "stepsPenalty": 0, "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "\n

For example, the poset $(\\left\\{1,2,3,4,5,6\\right\\},|)$ is a poset. Its corresponding Hasse diagram is

\n

"}]}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Sean Gardiner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2443/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Sean Gardiner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2443/"}]}