From 1ac18ec115fb6980cf86e2d3659a9ce1f1e3b305 Mon Sep 17 00:00:00 2001 From: Peter Staab Date: Tue, 4 Aug 2026 07:39:50 -0400 Subject: [PATCH] updates to problems. --- .../ch1s1_propositions/ifthen1.pg | 44 ++-- .../ch1s1_propositions/ifthen2.pg | 43 ++-- .../DiscreteMath/ch1s1_propositions/prop1.pg | 23 +- .../ch1s2_statements/truthtable1.pg | 18 +- .../ch1s2_statements/truthtable2.pg | 19 +- .../ch1s2_statements/truthtable3.pg | 19 +- .../ch1s2_statements/truthtable4.pg | 19 +- .../ch1s2_statements/truthtable5.pg | 19 +- .../ch1s2_statements/truthtable6.pg | 19 +- .../ch1s2_statements/truthtable7.pg | 19 +- .../ch1s2_statements/truthtable8.pg | 19 +- .../ch1s3_quantifiers/quantifiers1.pg | 44 ++-- .../ch1s3_quantifiers/quantifiers2.pg | 18 +- .../ch1s3_quantifiers/quantifiers3.pg | 17 +- .../ch1s4_rulesofinference/roi1.pg | 47 ++-- .../ch1s4_rulesofinference/roi2.pg | 47 ++-- .../ch1s4_rulesofinference/roi3.pg | 57 +++-- .../ch1s4_rulesofinference/roi4.pg | 59 +++-- .../ch1s4_rulesofinference/roi5.pg | 47 ++-- .../ch1s4_rulesofinference/roi6.pg | 69 +++--- .../DiscreteMath/ch1s5_proofs/proof1.pg | 63 +++--- .../LaTech/DiscreteMath/ch2s1_sets/set1.pg | 18 +- .../LaTech/DiscreteMath/ch2s1_sets/set2.pg | 18 +- .../LaTech/DiscreteMath/ch2s1_sets/set3.pg | 18 +- .../DiscreteMath/ch2s1_sets/setsize1.pg | 28 +-- .../DiscreteMath/ch2s1_sets/setsize2.pg | 27 +-- .../ch2s2_setoperations/setops1.pg | 34 +-- .../ch2s2_setoperations/setops2.pg | 36 ++- .../ch2s2_setoperations/setops3.pg | 70 +++--- .../ch2s2_setoperations/setops4.pg | 45 ++-- .../ch2s2_setoperations/setops5.pg | 39 ++-- .../DiscreteMath/ch2s3_functions/fun1.pg | 15 +- .../DiscreteMath/ch2s3_functions/fun2.pg | 15 +- .../DiscreteMath/ch2s3_functions/fun3.pg | 14 +- .../ch3s4_recurrencerelations/recrel1.pg | 205 +++++++++--------- .../ch3s4_recurrencerelations/recrel2.pg | 203 +++++++++-------- .../ch3s4_recurrencerelations/recrel3.pg | 165 +++++++------- .../ch3s4_recurrencerelations/recrel4.pg | 166 +++++++------- .../ch4As1_matrices/boolmatrix1.pg | 45 ++-- .../ch4As1_matrices/boolmatrix2.pg | 38 ++-- .../ch4As3_relations/boolmatrixrep1.pg | 47 ++-- .../ch4As3_relations/boolmatrixrep2.pg | 41 ++-- .../ch4As3_relations/boolmatrixrep3.pg | 27 +-- .../strings_language1.pg | 22 +- .../strings_language2.pg | 24 +- .../strings_language3.pg | 24 +- .../strings_language4.pg | 20 +- .../LaTech/DiscreteMath/ch4Cs2_dfa/dfa1.pg | 24 +- .../LaTech/DiscreteMath/ch4Cs2_dfa/dfa2.pg | 24 +- .../LaTech/DiscreteMath/ch4Cs2_dfa/dfa3.pg | 24 +- .../LaTech/DiscreteMath/ch4Cs3_nfa/nfa1.pg | 29 ++- 51 files changed, 948 insertions(+), 1286 deletions(-) diff --git a/Contrib/LaTech/DiscreteMath/ch1s1_propositions/ifthen1.pg b/Contrib/LaTech/DiscreteMath/ch1s1_propositions/ifthen1.pg index db4b99438a..a0c7007cb6 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s1_propositions/ifthen1.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s1_propositions/ifthen1.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives the if-then statement "If you strike me down, then I become more powerful." -## and asks for its propositional variations from a popup menu of statements. +## and asks for its propositional variations from a popup menu of statements. ## ENDDESCRIPTION ## DBsubject(Discrete Math) @@ -11,36 +11,32 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','propositional logic','converse','contrapositive') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible statement variations -$a = ["You don't strike me down or I become more powerful.", - "You strike me down and I don't become more powerful.", - "If I don't become more powerful, then you don't strike me down.", - "If I become more powerful, then you strike me down.", - "I become more powerful if you strike me down.", - "You strike me down if I become more powerful.", - "I don't become more powerful and you don't strike me down.", - "You strike me down and I become more powerful."]; +$a = [ + "You don't strike me down or I become more powerful.", + "You strike me down and I don't become more powerful.", + "If I don't become more powerful, then you don't strike me down.", + "If I become more powerful, then you strike me down.", + "I become more powerful if you strike me down.", + "You strike me down if I become more powerful.", + "I don't become more powerful and you don't strike me down.", + "You strike me down and I become more powerful." +]; ## Create the popup menus with the correct answers -$pop1 = PopUp(["Choose...",$a], 1); -$pop2 = PopUp(["Choose...",$a], 2); -$pop3 = PopUp(["Choose...",$a], 3); -$pop4 = PopUp(["Choose...",$a], 4); -$pop5 = PopUp(["Choose...",$a], 5); - -## Display question -TEXT(beginproblem()); +$pop1 = PopUp([ "Choose...", $a ], 1); +$pop2 = PopUp([ "Choose...", $a ], 2); +$pop3 = PopUp([ "Choose...", $a ], 3); +$pop4 = PopUp([ "Choose...", $a ], 4); +$pop5 = PopUp([ "Choose...", $a ], 5); + BEGIN_PGML Consider the following statement: diff --git a/Contrib/LaTech/DiscreteMath/ch1s1_propositions/ifthen2.pg b/Contrib/LaTech/DiscreteMath/ch1s1_propositions/ifthen2.pg index f28eb992a6..91a729ad62 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s1_propositions/ifthen2.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s1_propositions/ifthen2.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives the if-then statement "If it bleeds, then we can kill it." -## and asks for its propositional variations from a popup menu of statements. +## and asks for its propositional variations from a popup menu of statements. ## ENDDESCRIPTION ## DBsubject(Discrete Math) @@ -11,36 +11,31 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','propositional logic','converse','contrapositive') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible statement variations -$a = ["We can kill it or it doesn't bleed.", - "We can't kill it and it bleeds.", - "If we can't kill it, then it doesn't bleed.", - "If we can kill it, then it bleeds.", - "We can kill it if it bleeds.", - "It bleeds if we can kill it.", - "It doesn't bleed and we can't kill it.", - "It bleeds and we can kill it."]; +$a = [ + "We can kill it or it doesn't bleed.", + "We can't kill it and it bleeds.", + "If we can't kill it, then it doesn't bleed.", + "If we can kill it, then it bleeds.", + "We can kill it if it bleeds.", + "It bleeds if we can kill it.", + "It doesn't bleed and we can't kill it.", + "It bleeds and we can kill it." +]; ## Create the popup menus with the correct answers -$pop1 = PopUp(["Choose...",$a], 1); -$pop2 = PopUp(["Choose...",$a], 2); -$pop3 = PopUp(["Choose...",$a], 3); -$pop4 = PopUp(["Choose...",$a], 4); -$pop5 = PopUp(["Choose...",$a], 5); - -## Display question -TEXT(beginproblem()); +$pop1 = PopUp([ "Choose...", $a ], 1); +$pop2 = PopUp([ "Choose...", $a ], 2); +$pop3 = PopUp([ "Choose...", $a ], 3); +$pop4 = PopUp([ "Choose...", $a ], 4); +$pop5 = PopUp([ "Choose...", $a ], 5); BEGIN_PGML Consider the following statement: diff --git a/Contrib/LaTech/DiscreteMath/ch1s1_propositions/prop1.pg b/Contrib/LaTech/DiscreteMath/ch1s1_propositions/prop1.pg index da3337bf2c..5c1d526343 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s1_propositions/prop1.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s1_propositions/prop1.pg @@ -11,34 +11,27 @@ ## Level(2) ## KEYWORDS('discrete math','logic','propositional logic','and','or','implication','negation','true','false') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create random parameters for a false statement -$a = random(-5,-1,1); -$b = random(1,5,1); +$a = random(-5, -1, 1); +$b = random( 1, 5, 1); ## Create random parameters for a true statement -$n = random(2,5,1); +$n = random(2, 5, 1); $nf = fact($n); ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Determine the truth value of the following statements. *To discourage random guessing, you must answer all problems correctly to receive credit.* diff --git a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable1.pg b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable1.pg index ca52ae451a..b193ee82cf 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable1.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable1.pg @@ -10,27 +10,18 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','truth table') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"niceTables.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Complete the following truth table. @@ -48,7 +39,6 @@ midrules => 1, align => '| c | c |' END_PGML BEGIN_PGML_SOLUTION -Solution: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable2.pg b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable2.pg index b5a759d575..782454d7fa 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable2.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable2.pg @@ -10,27 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','truth table') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"niceTables.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Complete the following truth table. @@ -48,7 +40,6 @@ midrules => 1, align => '| c | c |' END_PGML BEGIN_PGML_SOLUTION -Solution: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable3.pg b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable3.pg index 2c8a0e9bea..81a28d9443 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable3.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable3.pg @@ -10,27 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','truth table') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"niceTables.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Complete the following truth table. @@ -50,7 +42,6 @@ midrules => 1, align => '| c | c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solution: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable4.pg b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable4.pg index 53217b390f..8293bd904d 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable4.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable4.pg @@ -10,27 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','truth table') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"niceTables.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Complete the following truth table. @@ -50,7 +42,6 @@ midrules => 1, align => '| c | c | c | c | c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solution: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable5.pg b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable5.pg index c82779b04d..0162b0aa71 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable5.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable5.pg @@ -10,27 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','truth table') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"niceTables.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Complete the following truth table. @@ -50,7 +42,6 @@ midrules => 1, align => '| c | c | c | c | c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solution: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable6.pg b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable6.pg index bd3a98108c..356c1d7cda 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable6.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable6.pg @@ -10,27 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','truth table') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"niceTables.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Complete the following truth table. @@ -50,7 +42,6 @@ midrules => 1, align => '| c | c | c | c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solution: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable7.pg b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable7.pg index 23767520e0..f91f1fc693 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable7.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable7.pg @@ -10,27 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','truth table') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"niceTables.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Complete the following truth table. @@ -50,7 +42,6 @@ midrules => 1, align => '| c | c | c | c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solution: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable8.pg b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable8.pg index bcc6e450e1..05421ce8ba 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable8.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s2_statements/truthtable8.pg @@ -10,27 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','truth table') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"niceTables.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Complete the following truth table. @@ -54,7 +46,6 @@ midrules => 1, align => '| c | c | c | c | c | c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solution: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers1.pg b/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers1.pg index 24e62d451f..fde19c7ef3 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers1.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers1.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives the open statement C(x,y): "Student x has taken math course y" -## and asks for its quantified variations from a popup menu of statements. +## and asks for its quantified variations from a popup menu of statements. ## ENDDESCRIPTION ## DBsubject(Discrete Math) @@ -11,36 +11,31 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','quantifiers','open statements') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible statement variations -$a = ["There is a student that has taken a math course.", - "No student has ever taken a math course.", - "There is a student that has taken discrete math.", - "Every student has taken discrete math.", - "No student has taken discrete math.", - "There is a student that has not taken discrete math.", - "There is a student that has taken every math course.", - "Every student has taken every math course."]; +$a = [ + "There is a student that has taken a math course.", + "No student has ever taken a math course.", + "There is a student that has taken discrete math.", + "Every student has taken discrete math.", + "No student has taken discrete math.", + "There is a student that has not taken discrete math.", + "There is a student that has taken every math course.", + "Every student has taken every math course." +]; ## Create the popup menus with the correct answers -$pop1 = PopUp(["Choose...",$a], 1); -$pop2 = PopUp(["Choose...",$a], 2); -$pop3 = PopUp(["Choose...",$a], 3); -$pop4 = PopUp(["Choose...",$a], 4); -$pop5 = PopUp(["Choose...",$a], 5); - -## Display question -TEXT(beginproblem()); +$pop1 = PopUp([ "Choose...", $a ], 1); +$pop2 = PopUp([ "Choose...", $a ], 2); +$pop3 = PopUp([ "Choose...", $a ], 3); +$pop4 = PopUp([ "Choose...", $a ], 4); +$pop5 = PopUp([ "Choose...", $a ], 5); BEGIN_PGML Consider the open statement *C(x,y): "Student x has taken math course y,"* where the domain for [``x``] is all students at your school and the domain for [``y``] is all math courses at your school. @@ -60,7 +55,6 @@ Match the following statements containing quantifiers to their corresponding Eng END_PGML BEGIN_PGML_SOLUTION -Solutions: [`` \exists x \exists y \hspace{1em} C(x,y) ``]: [$pop1] diff --git a/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers2.pg b/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers2.pg index 27aefb3781..47556795d1 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers2.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers2.pg @@ -10,26 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','quantifiers','open statements') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Suppose the domain for all variables is all real numbers. Determine the truth value of the following statements. @@ -61,5 +54,4 @@ The truth value of the statements are: END_PGML_SOLUTION - ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers3.pg b/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers3.pg index 5d8a81ff17..fd1459c569 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers3.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s3_quantifiers/quantifiers3.pg @@ -10,26 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','quantifiers','open statements') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Suppose the domain for all variables is all real numbers. Determine the truth value of the following statements. diff --git a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi1.pg b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi1.pg index 8e212191a0..1a64f4ad44 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi1.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi1.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives a proof as a list of statements and reasons and asks to choose the correct reasons -## for each step of the proof from a popup menu of options. +## for each step of the proof from a popup menu of options. ## Premises: not(P) and R, not(P) implies Q ## Conclusion: Q ## ENDDESCRIPTION @@ -13,38 +13,32 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','propositional logic','rules of inference','argument','proof') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"niceTables.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible reasons -$a = ["Premise", - "Step 1", - "Step 2", - "Step 3", - "Step 4", - "Steps 1 and 2", - "Steps 1 and 3", - "Steps 1 and 4", - "Steps 2 and 3", - "Steps 2 and 4", - "Steps 3 and 4"]; +$a = [ + "Premise", + "Step 1", + "Step 2", + "Step 3", + "Step 4", + "Steps 1 and 2", + "Steps 1 and 3", + "Steps 1 and 4", + "Steps 2 and 3", + "Steps 2 and 4", + "Steps 3 and 4" +]; ## Create the popup menus with the correct answers -$popPremise = PopUp(["Choose...",$a], 1); -$popStep1 = PopUp(["Choose...",$a], 2); -$popStep23 = PopUp(["Choose...",$a], 9); - -## Display question -TEXT(beginproblem()); +$popPremise = PopUp([ "Choose...", $a ], 1); +$popStep1 = PopUp([ "Choose...", $a ], 2); +$popStep23 = PopUp([ "Choose...", $a ], 9); BEGIN_PGML Consider the following premises and conclusion. @@ -73,7 +67,6 @@ midrules => 1, align => '| c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solutions: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi2.pg b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi2.pg index ac548d6ee3..0f853a77c4 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi2.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi2.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives a proof as a list of statements and reasons and asks to choose the correct reasons -## for each step of the proof from a popup menu of options. +## for each step of the proof from a popup menu of options. ## Premises: not(R), Q implies R, P implies Q ## Conclusion: not(P) ## ENDDESCRIPTION @@ -13,38 +13,32 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','propositional logic','rules of inference','argument','proof') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"niceTables.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible reasons -$a = ["Premise", - "Step 1", - "Step 2", - "Step 3", - "Step 4", - "Steps 1 and 2", - "Steps 1 and 3", - "Steps 1 and 4", - "Steps 2 and 3", - "Steps 2 and 4", - "Steps 3 and 4"]; +$a = [ + "Premise", + "Step 1", + "Step 2", + "Step 3", + "Step 4", + "Steps 1 and 2", + "Steps 1 and 3", + "Steps 1 and 4", + "Steps 2 and 3", + "Steps 2 and 4", + "Steps 3 and 4" +]; ## Create the popup menus with the correct answers -$popPremise = PopUp(["Choose...",$a], 1); -$popStep12 = PopUp(["Choose...",$a], 6); -$popStep34 = PopUp(["Choose...",$a], 11); - -## Display question -TEXT(beginproblem()); +$popPremise = PopUp([ "Choose...", $a ], 1); +$popStep12 = PopUp([ "Choose...", $a ], 6); +$popStep34 = PopUp([ "Choose...", $a ], 11); BEGIN_PGML Consider the following premises and conclusion. @@ -75,7 +69,6 @@ midrules => 1, align => '| c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solutions: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi3.pg b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi3.pg index 622f7932d1..60a302ab3d 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi3.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi3.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives a proof as a list of statements and reasons and asks to choose the correct reasons -## for each step of the proof from a popup menu of options. +## for each step of the proof from a popup menu of options. ## Premises: P implies Q, not(P) implies R, R implies S ## Conclusion: not(Q) implies S ## ENDDESCRIPTION @@ -13,43 +13,37 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','propositional logic','rules of inference','argument','proof') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"niceTables.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible reasons -$a = ["Premise", - "Step 1", - "Step 2", - "Step 3", - "Step 4", - "Step 5", - "Steps 2 and 3", - "Steps 2 and 4", - "Steps 2 and 5", - "Steps 3 and 4", - "Steps 3 and 5", - "Steps 3 and 6", - "Steps 4 and 5", - "Steps 4 and 6", - "Steps 5 and 6"]; +$a = [ + "Premise", + "Step 1", + "Step 2", + "Step 3", + "Step 4", + "Step 5", + "Steps 2 and 3", + "Steps 2 and 4", + "Steps 2 and 5", + "Steps 3 and 4", + "Steps 3 and 5", + "Steps 3 and 6", + "Steps 4 and 5", + "Steps 4 and 6", + "Steps 5 and 6" +]; ## Create the popup menus with the correct answers -$popPremise = PopUp(["Choose...",$a], 1); -$popStep1 = PopUp(["Choose...",$a], 2); -$popStep23 = PopUp(["Choose...",$a], 7); -$popStep45 = PopUp(["Choose...",$a], 13); - -## Display question -TEXT(beginproblem()); +$popPremise = PopUp([ "Choose...", $a ], 1); +$popStep1 = PopUp([ "Choose...", $a ], 2); +$popStep23 = PopUp([ "Choose...", $a ], 7); +$popStep45 = PopUp([ "Choose...", $a ], 13); BEGIN_PGML Consider the following premises and conclusion. @@ -81,7 +75,6 @@ midrules => 1, align => '| c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solutions: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi4.pg b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi4.pg index 6e26815e70..da18b315a1 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi4.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi4.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives a proof as a list of statements and reasons and asks to choose the correct reasons -## for each step of the proof from a popup menu of options. +## for each step of the proof from a popup menu of options. ## Premises: not(P) and Q, R implies P, not(R) implies S, S implies T ## Conclusion: T ## ENDDESCRIPTION @@ -13,44 +13,38 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','propositional logic','rules of inference','argument','proof') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"niceTables.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible reasons -$a = ["Premise", - "Step 1", - "Step 2", - "Step 3", - "Step 4", - "Step 5", - "Steps 2 and 3", - "Steps 2 and 4", - "Steps 2 and 5", - "Steps 3 and 4", - "Steps 3 and 5", - "Steps 4 and 5", - "Steps 4 and 6", - "Steps 4 and 7", - "Steps 6 and 7"]; +$a = [ + "Premise", + "Step 1", + "Step 2", + "Step 3", + "Step 4", + "Step 5", + "Steps 2 and 3", + "Steps 2 and 4", + "Steps 2 and 5", + "Steps 3 and 4", + "Steps 3 and 5", + "Steps 4 and 5", + "Steps 4 and 6", + "Steps 4 and 7", + "Steps 6 and 7" +]; ## Create the popup menus with the correct answers -$popPremise = PopUp(["Choose...",$a], 1); -$popStep1 = PopUp(["Choose...",$a], 2); -$popStep23 = PopUp(["Choose...",$a], 7); -$popStep45 = PopUp(["Choose...",$a], 12); -$popStep67 = PopUp(["Choose...",$a], 15); - -## Display question -TEXT(beginproblem()); +$popPremise = PopUp([ "Choose...", $a ], 1); +$popStep1 = PopUp([ "Choose...", $a ], 2); +$popStep23 = PopUp([ "Choose...", $a ], 7); +$popStep45 = PopUp([ "Choose...", $a ], 12); +$popStep67 = PopUp([ "Choose...", $a ], 15); BEGIN_PGML Consider the following premises and conclusion. @@ -85,7 +79,6 @@ midrules => 1, align => '| c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solutions: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi5.pg b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi5.pg index 9d4b37d28f..a106b23cc1 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi5.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi5.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives a proof as a list of statements and reasons and asks to choose the correct reasons -## for each step of the proof from a popup menu of options. +## for each step of the proof from a popup menu of options. ## Premises: Forall x [P(x) implies Q(x)], P(a) ## Conclusion: Q(a) ## ENDDESCRIPTION @@ -13,38 +13,32 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','propositional logic','rules of inference','argument','proof','quantifiers') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"niceTables.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible reasons -$a = ["Premise", - "Step 1", - "Step 2", - "Step 3", - "Step 4", - "Steps 1 and 2", - "Steps 1 and 3", - "Steps 1 and 4", - "Steps 2 and 3", - "Steps 2 and 4", - "Steps 3 and 4"]; +$a = [ + "Premise", + "Step 1", + "Step 2", + "Step 3", + "Step 4", + "Steps 1 and 2", + "Steps 1 and 3", + "Steps 1 and 4", + "Steps 2 and 3", + "Steps 2 and 4", + "Steps 3 and 4" +]; ## Create the popup menus with the correct answers -$popPremise = PopUp(["Choose...",$a], 1); -$popStep1 = PopUp(["Choose...",$a], 2); -$popStep23 = PopUp(["Choose...",$a], 9); - -## Display question -TEXT(beginproblem()); +$popPremise = PopUp([ "Choose...", $a ], 1); +$popStep1 = PopUp([ "Choose...", $a ], 2); +$popStep23 = PopUp([ "Choose...", $a ], 9); BEGIN_PGML Consider the following premises and conclusion. @@ -73,7 +67,6 @@ midrules => 1, align => '| c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solutions: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi6.pg b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi6.pg index 70e8674e6a..a5946ef1a6 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi6.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s4_rulesofinference/roi6.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives a proof as a list of statements and reasons and asks to choose the correct reasons -## for each step of the proof from a popup menu of options. +## for each step of the proof from a popup menu of options. ## Premises: Forall x [P(x) or Q(x)], Forall x [R(x) implies not(Q(x))], Exists x [not(P(x))] ## Conclusion: Exists x [not(R(x))] ## ENDDESCRIPTION @@ -13,49 +13,43 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','propositional logic','rules of inference','argument','proof','quantifiers') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"niceTables.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible reasons -$a = ["Premise", - "Step 1", - "Step 2", - "Step 3", - "Step 6", - "Step 7", - "Step 8", - "Step 9", - "Steps 2 and 3", - "Steps 2 and 4", - "Steps 2 and 5", - "Steps 3 and 4", - "Steps 3 and 5", - "Steps 5 and 6", - "Steps 5 and 7", - "Steps 5 and 8", - "Steps 8 and 9"]; +$a = [ + "Premise", + "Step 1", + "Step 2", + "Step 3", + "Step 6", + "Step 7", + "Step 8", + "Step 9", + "Steps 2 and 3", + "Steps 2 and 4", + "Steps 2 and 5", + "Steps 3 and 4", + "Steps 3 and 5", + "Steps 5 and 6", + "Steps 5 and 7", + "Steps 5 and 8", + "Steps 8 and 9" +]; ## Create the popup menus with the correct answers -$popPremise = PopUp(["Choose...",$a], 1); -$popStep1 = PopUp(["Choose...",$a], 2); -$popStep3 = PopUp(["Choose...",$a], 4); -$popStep6 = PopUp(["Choose...",$a], 5); -$popStep7 = PopUp(["Choose...",$a], 6); -$popStep9 = PopUp(["Choose...",$a], 8); -$popStep24 = PopUp(["Choose...",$a], 10); -$popStep58 = PopUp(["Choose...",$a], 16); - -## Display question -TEXT(beginproblem()); +$popPremise = PopUp([ "Choose...", $a ], 1); +$popStep1 = PopUp([ "Choose...", $a ], 2); +$popStep3 = PopUp([ "Choose...", $a ], 4); +$popStep6 = PopUp([ "Choose...", $a ], 5); +$popStep7 = PopUp([ "Choose...", $a ], 6); +$popStep9 = PopUp([ "Choose...", $a ], 8); +$popStep24 = PopUp([ "Choose...", $a ], 10); +$popStep58 = PopUp([ "Choose...", $a ], 16); BEGIN_PGML Consider the following premises and conclusion. @@ -91,7 +85,6 @@ midrules => 1, align => '| c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solutions: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch1s5_proofs/proof1.pg b/Contrib/LaTech/DiscreteMath/ch1s5_proofs/proof1.pg index 369d86bc0e..bd58f7bc2d 100644 --- a/Contrib/LaTech/DiscreteMath/ch1s5_proofs/proof1.pg +++ b/Contrib/LaTech/DiscreteMath/ch1s5_proofs/proof1.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives a proof as a list of statements and reasons and asks to choose the correct reasons -## for each step of the proof from a popup menu of options. +## for each step of the proof from a popup menu of options. ## Problem: An integer n cannot be both even and odd simultaneously ## ENDDESCRIPTION @@ -12,46 +12,40 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','logic','argument','proof','parity') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"niceTables.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible reasons -$a = ["Begin a proof by contradiction", - "Step 1", - "Step 2", - "Step 3", - "Step 4", - "Step 5", - "Step 6", - "Steps 2 and 3", - "Steps 2 and 4", - "Steps 2 and 5", - "Steps 3 and 4", - "Steps 3 and 5", - "Steps 3 and 6", - "Steps 4 and 5", - "Steps 4 and 6", - "Steps 5 and 6"]; +$a = [ + "Begin a proof by contradiction", + "Step 1", + "Step 2", + "Step 3", + "Step 4", + "Step 5", + "Step 6", + "Steps 2 and 3", + "Steps 2 and 4", + "Steps 2 and 5", + "Steps 3 and 4", + "Steps 3 and 5", + "Steps 3 and 6", + "Steps 4 and 5", + "Steps 4 and 6", + "Steps 5 and 6" +]; ## Create the popup menus with the correct answers -$popPremise = PopUp(["Choose...",$a], 1); -$popStep1 = PopUp(["Choose...",$a], 2); -$popStep23 = PopUp(["Choose...",$a], 8); -$popStep4 = PopUp(["Choose...",$a], 5); -$popStep5 = PopUp(["Choose...",$a], 6); -$popStep6 = PopUp(["Choose...",$a], 7); - -## Display question -TEXT(beginproblem()); +$popPremise = PopUp([ "Choose...", $a ], 1); +$popStep1 = PopUp([ "Choose...", $a ], 2); +$popStep23 = PopUp([ "Choose...", $a ], 8); +$popStep4 = PopUp([ "Choose...", $a ], 5); +$popStep5 = PopUp([ "Choose...", $a ], 6); +$popStep6 = PopUp([ "Choose...", $a ], 7); BEGIN_PGML Consider the following statement to be proved. @@ -78,7 +72,6 @@ midrules => 1, align => '| c | c | c |' END_PGML BEGIN_PGML_SOLUTION -Solutions: [@ DataTable([ diff --git a/Contrib/LaTech/DiscreteMath/ch2s1_sets/set1.pg b/Contrib/LaTech/DiscreteMath/ch2s1_sets/set1.pg index b74a8c471a..9ddaa3bad9 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s1_sets/set1.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s1_sets/set1.pg @@ -10,26 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','sets','subset','element','empty set','singleton') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Determine the truth value of the following statements. @@ -53,7 +46,6 @@ Determine the truth value of the following statements. END_PGML BEGIN_PGML_SOLUTION -Solutions: [$popFalse] : [`` 0 \in \emptyset ``] diff --git a/Contrib/LaTech/DiscreteMath/ch2s1_sets/set2.pg b/Contrib/LaTech/DiscreteMath/ch2s1_sets/set2.pg index d66d6f0658..f7d5443dfb 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s1_sets/set2.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s1_sets/set2.pg @@ -10,26 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','sets','subset','element','empty set','singleton') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Determine the truth value of the following statements. @@ -53,7 +46,6 @@ Determine the truth value of the following statements. END_PGML BEGIN_PGML_SOLUTION -Solutions: [$popTrue] : [`` \{x\} \in \{\{x\}\} ``] diff --git a/Contrib/LaTech/DiscreteMath/ch2s1_sets/set3.pg b/Contrib/LaTech/DiscreteMath/ch2s1_sets/set3.pg index d6de17ec44..bf06cea4cb 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s1_sets/set3.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s1_sets/set3.pg @@ -10,26 +10,19 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','sets','subset','element','common sets','cross product') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserPopUp.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Do not reveal partial solutions for True/False questions. $showPartialCorrectAnswers = 0; ## Create the popup menus with the correct answers -$popTrue = PopUp(["Choose...","T","F"], 1); -$popFalse = PopUp(["Choose...","T","F"], 2); - -## Display question -TEXT(beginproblem()); +$popTrue = PopUp([ "Choose...", "T", "F" ], 1); +$popFalse = PopUp([ "Choose...", "T", "F" ], 2); BEGIN_PGML Recall the following commonly used sets. @@ -73,7 +66,6 @@ Determine the truth value of the following statements. END_PGML BEGIN_PGML_SOLUTION -Solutions: [$popTrue] : [`` x + 1 \in P_{2} ``] diff --git a/Contrib/LaTech/DiscreteMath/ch2s1_sets/setsize1.pg b/Contrib/LaTech/DiscreteMath/ch2s1_sets/setsize1.pg index a1a9861df4..d0c048319f 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s1_sets/setsize1.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s1_sets/setsize1.pg @@ -10,37 +10,31 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','sets','size','cardinality') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create parameters and solutions to predetermined problems -$n1 = random(15,29,2); -$size1 = ($n1+1)/2; +$n1 = random(15, 29, 2); +$size1 = ($n1 + 1) / 2; -$n2 = random(17,24,1); +$n2 = random(17, 24, 1); $size2 = 0; -$n3 = random(1,10,1); +$n3 = random(1, 10, 1); $size3 = 2; -$n4 = random(6,10,1); -$m = 2**$n4; +$n4 = random(6, 10, 1); +$m = 2**$n4; $size4 = $n4 + 1; -$n5 = random(1,5,1); -$p = random(9,15,1); +$n5 = random(1, 5, 1); +$p = random(9, 15, 1); $size5 = $p - $n5 - 1; -## Display question -TEXT(beginproblem()); - BEGIN_PGML Compute the size of the following sets. diff --git a/Contrib/LaTech/DiscreteMath/ch2s1_sets/setsize2.pg b/Contrib/LaTech/DiscreteMath/ch2s1_sets/setsize2.pg index 60fd378ce0..affa3a4c06 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s1_sets/setsize2.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s1_sets/setsize2.pg @@ -11,29 +11,23 @@ ## Level(2) ## KEYWORDS('discrete math','sets','size','cardinality') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); -## Create parameters and solutions to predetermined problems -$j = random(8,20,2); -$ans1 = $j/2; +Context('Numeric'); -$k = random(4,10,1); -$ans2 = 2*$k - 1; +## Create parameters and solutions to predetermined problems +$j = random(8, 20, 2); +$ans1 = $j / 2; -$i = random(7,12,1); -@primes = (2,3,5,7,11,13,17,19,23,29,31,37); -$p = $primes[$i-1]; +$k = random(4, 10, 1); +$ans2 = 2 * $k - 1; -## Display question -TEXT(beginproblem()); +$i = random(7, 12, 1); +@primes = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37); +$p = $primes[ $i - 1 ]; BEGIN_PGML Compute the size of the following sets. (In this context, [` \mathbb{N} `] is the set of natural numbers, [` \mathbb{Z} `] is the set of integers, @@ -52,7 +46,6 @@ Compute the size of the following sets. (In this context, [` \mathbb{N} `] is th END_PGML BEGIN_PGML_SOLUTION -Solutions: [`` |\{ \emptyset \}| ``] = 1 diff --git a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops1.pg b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops1.pg index 8898129334..d29c35bceb 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops1.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops1.pg @@ -12,45 +12,36 @@ ## Level(2) ## KEYWORDS('discrete math','sets','operations','union','intersect','difference') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for sets and intervals Context("Interval"); ## Initialize given sets $A = Interval("(0,infinity)"); -$B = Set(2,4,8,16,32); -$C = Set(2,4,6,8,10,12,14); +$B = Set(2, 4, 8, 16, 32); +$C = Set(2, 4, 6, 8, 10, 12, 14); $D = Interval("(-3,9)"); $E = Interval("(-infinity,1]"); ## Create solutions to predetermined problems -$BcupC = Union($B,$C); -$BcapC = $B->intersect($C); -$BmC = $B - $C; -$CmB = $C - $B; -$DcupE = Union($D,$E); -$DcapE = $D->intersect($E); -$BcapE = $B->intersect($E); -$AcupE = Union($A,$E); -$AmD = $A - $D; +$BcupC = Union($B, $C); +$BcapC = $B->intersect($C); +$BmC = $B - $C; +$CmB = $C - $B; +$DcupE = Union($D, $E); +$DcapE = $D->intersect($E); +$BcapE = $B->intersect($E); +$AcupE = Union($A, $E); +$AmD = $A - $D; $AcapofDcupE = $A->intersect($DcupE); ## Do not allow students to "cheat" using the difference operator by removing it from the context Context()->operators->undefine("-"); -## Display question -TEXT(beginproblem()); - BEGIN_PGML Consider the following sets. @@ -92,7 +83,6 @@ Note: For the symbol [` \infty `], you may type the word _inf_. For an empty set END_PGML BEGIN_PGML_SOLUTION -Solutions: [`` B \cup C ``] = [$BcupC] diff --git a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops2.pg b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops2.pg index 0b316fb0f5..060b606334 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops2.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops2.pg @@ -11,24 +11,18 @@ ## Level(2) ## KEYWORDS('discrete math','sets','interval','operations','union','intersect','difference') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for sets and intervals Context("Interval"); ## Generate random distinct numbers for interval endpoints. -$n1 = random(-6,-3,1); -$n2 = random(-2,2,1); -$n3 = random(3,6,1); +$n1 = random(-6, -3, 1); +$n2 = random(-2, 2, 1); +$n3 = random( 3, 6, 1); ## Initialize given sets $A = Interval("(-infinity,$n1]"); @@ -38,23 +32,20 @@ $D = Interval("[$n1,$n3)"); $E = Interval("($n3,infinity)"); ## Create solutions to predetermined problems -$BcupC = Union($B,$C); -$BcapC = $B->intersect($C); -$BmC = $B - $C; -$CmB = $C - $B; -$DcupE = Union($D,$E); -$DcapE = $D->intersect($E); -$BcapE = $B->intersect($E); -$AcupE = Union($A,$E); -$AmD = $A - $D; +$BcupC = Union($B, $C); +$BcapC = $B->intersect($C); +$BmC = $B - $C; +$CmB = $C - $B; +$DcupE = Union($D, $E); +$DcapE = $D->intersect($E); +$BcapE = $B->intersect($E); +$AcupE = Union($A, $E); +$AmD = $A - $D; $AcapofDcupE = $A->intersect($DcupE); ## Do not allow students to "cheat" using the difference operator by removing it from the context Context()->operators->undefine("-"); -## Display question -TEXT(beginproblem()); - BEGIN_PGML Consider the following sets. @@ -96,7 +87,6 @@ Note: For the symbol [` \infty `], you may type the word _inf_. For an empty set END_PGML BEGIN_PGML_SOLUTION -Solutions: [`` B \cup C ``] = [$BcupC] diff --git a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops3.pg b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops3.pg index a073157d0b..d2282eb4b2 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops3.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops3.pg @@ -11,50 +11,59 @@ ## Level(2) ## KEYWORDS('discrete math','sets','power set','operations','cross','product') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for sets and intervals Context("Interval"); ## Generate random distinct numbers for set elements. -$n1 = random(-6,-4,1); -$n2 = random(-1,1,1); -$n3 = random(2,3,1); -$n4 = random(7,9,1); +$n1 = random(-6, -4, 1); +$n2 = random(-1, 1, 1); +$n3 = random( 2, 3, 1); +$n4 = random( 7, 9, 1); ## Initialize given sets -$A = Set($n1,$n2); -$B = Set($n1,$n2,$n3); -$C = Set($n1,$n2,$n3,$n4); +$A = Set($n1, $n2); +$B = Set($n1, $n2, $n3); +$C = Set($n1, $n2, $n3, $n4); ## Create solutions to predetermined problems -$s1 = Set($n1); -$s2 = Set($n2); -$s3 = Set($n3); -$s12 = Set($n1,$n2); -$s13 = Set($n1,$n3); -$s23 = Set($n2,$n3); -$s123 = Set($n1,$n2,$n3); -$se = Set("{}"); - -$powA = List($s1,$s2,$s12,$se); -$powB = List($s1,$s2,$s3,$s12,$s13,$s23,$s123,$se); +$s1 = Set($n1); +$s2 = Set($n2); +$s3 = Set($n3); +$s12 = Set($n1, $n2); +$s13 = Set($n1, $n3); +$s23 = Set($n2, $n3); +$s123 = Set($n1, $n2, $n3); +$se = Set("{}"); + +$powA = List($s1, $s2, $s12, $se); +$powB = List($s1, $s2, $s3, $s12, $s13, $s23, $s123, $se); $powEmpty = List($se); Context("Point"); -$AcrossC = List(Point($n1,$n1),Point($n1,$n2),Point($n1,$n3),Point($n1,$n4),Point($n2,$n1),Point($n2,$n2),Point($n2,$n3),Point($n2,$n4)); -$CcrossA = List(Point($n1,$n1),Point($n1,$n2),Point($n2,$n1),Point($n2,$n2),Point($n3,$n1),Point($n3,$n2),Point($n4,$n1),Point($n4,$n2)); - -## Display question -TEXT(beginproblem()); +$AcrossC = List( + Point($n1, $n1), + Point($n1, $n2), + Point($n1, $n3), + Point($n1, $n4), + Point($n2, $n1), + Point($n2, $n2), + Point($n2, $n3), + Point($n2, $n4) +); +$CcrossA = List( + Point($n1, $n1), + Point($n1, $n2), + Point($n2, $n1), + Point($n2, $n2), + Point($n3, $n1), + Point($n3, $n2), + Point($n4, $n1), + Point($n4, $n2) +); BEGIN_PGML @@ -84,7 +93,6 @@ Note: *The outermost curly braces are written for you!* You must use the remaini END_PGML BEGIN_PGML_SOLUTION -Solutions: [`` P(A) = \Bigg\{ ``] [$powA] [`` \Bigg\} ``] diff --git a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops4.pg b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops4.pg index 21a570646e..a75d051dc6 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops4.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops4.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives the set (-inf,i] and asks to compute big unions, big intersections, -## and complements of this set from multiple choice options. +## and complements of this set from multiple choice options. ## ENDDESCRIPTION ## DBsubject(Discrete Math) @@ -11,37 +11,32 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','sets','operations','union','intersection','complement','interval') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserRadioButtons.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserRadioButtons.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible answers -$a = ["\( (-\infty,\infty) \)", - "\( \emptyset \) (Empty Set)", - "\( (-\infty,n] \)", - "\( (-\infty,1] \)", - "\( (1,\infty) \)", - "\( (n,\infty) \)", - "\( [n,\infty) \)", - "\( (-\infty,n) \)", - "\( (-\infty,1) \)"]; +$a = [ + "\( (-\infty,\infty) \)", + "\( \emptyset \) (Empty Set)", + "\( (-\infty,n] \)", + "\( (-\infty,1] \)", + "\( (1,\infty) \)", + "\( (n,\infty) \)", + "\( [n,\infty) \)", + "\( (-\infty,n) \)", + "\( (-\infty,1) \)" +]; ## Create the radio buttons with the correct answers -$radio1 = RadioButtons([$a,"None of the other choices."], 0); -$radio2 = RadioButtons([$a,"None of the other choices."], 1); -$radio3 = RadioButtons([$a,"None of the other choices."], 2); -$radio4 = RadioButtons([$a,"None of the other choices."], 3); -$radio5 = RadioButtons([$a,"None of the other choices."], 4); - -## Display question -TEXT(beginproblem()); +$radio1 = RadioButtons([ $a, "None of the other choices." ], 0); +$radio2 = RadioButtons([ $a, "None of the other choices." ], 1); +$radio3 = RadioButtons([ $a, "None of the other choices." ], 2); +$radio4 = RadioButtons([ $a, "None of the other choices." ], 3); +$radio5 = RadioButtons([ $a, "None of the other choices." ], 4); BEGIN_PGML Choose the correct set that corresponds to the operation given below. (The universal set is all real numbers.) diff --git a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops5.pg b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops5.pg index 9b65181c1a..553c21e909 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops5.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s2_setoperations/setops5.pg @@ -1,6 +1,6 @@ ## DESCRIPTION ## Gives the set [-i,i] and asks to compute big unions, big intersections, -## and complements of this set from multiple choice options. +## and complements of this set from multiple choice options. ## ENDDESCRIPTION ## DBsubject(Discrete Math) @@ -11,34 +11,29 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','sets','operations','union','intersection','complement','interval') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"parserRadioButtons.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserRadioButtons.pl', 'PGcourse.pl'); + +Context('Numeric'); ## Create an array of possible answers -$a = ["\( (-\infty,\infty) \)", - "\( \emptyset \) (Empty Set)", - "\( [-n,n] \)", - "\( [-1,1] \)", - "\( (-1,1) \)", - "\( (-n,n) \)", - "\( \{0\} \)"]; +$a = [ + "\( (-\infty,\infty) \)", + "\( \emptyset \) (Empty Set)", + "\( [-n,n] \)", + "\( [-1,1] \)", + "\( (-1,1) \)", + "\( (-n,n) \)", + "\( \{0\} \)" +]; ## Create the radio buttons with the correct answers -$radio1 = RadioButtons([$a,"None of the other choices."], 0); -$radio2 = RadioButtons([$a,"None of the other choices."], 1); -$radio3 = RadioButtons([$a,"None of the other choices."], 2); -$radio4 = RadioButtons([$a,"None of the other choices."], 3); - -## Display question -TEXT(beginproblem()); +$radio1 = RadioButtons([ $a, "None of the other choices." ], 0); +$radio2 = RadioButtons([ $a, "None of the other choices." ], 1); +$radio3 = RadioButtons([ $a, "None of the other choices." ], 2); +$radio4 = RadioButtons([ $a, "None of the other choices." ], 3); BEGIN_PGML Choose the correct set that corresponds to the operation given below. (The universal set is all real numbers.) diff --git a/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun1.pg b/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun1.pg index 7b334dd701..31059cc11e 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun1.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun1.pg @@ -10,30 +10,21 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','sets','functions','image','inverse','floor') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for sets and intervals Context("Interval"); ## Create solutions to predetermined problems -$ans1 = Set(0,1); +$ans1 = Set(0, 1); $ans2 = Set(0); $ans3 = Set("{}"); $ans4 = Interval("[0,1)"); $ans5 = Interval("[-1,1)"); -## Display question -TEXT(beginproblem()); - BEGIN_PGML Consider the function [`` g:\mathbb{R} \to \mathbb{R}``] given by [`` g(x)=\text{floor}(x) ``]. (Recall that the ceiling function rounds a number up to the nearest integer and that [`` \mathbb{R} ``] represents the set of all real numbers.) @@ -56,8 +47,6 @@ Note: For an empty set, you may type [` \{\} `]. END_PGML BEGIN_PGML_SOLUTION -Solutions: - [`` g([0,1]) ``] = [$ans1] [`` g(\{x : 0 < x < 1\}) ``] = [$ans2] diff --git a/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun2.pg b/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun2.pg index e4bc62dbe1..ef201c4b32 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun2.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun2.pg @@ -10,30 +10,21 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','sets','functions','image','inverse','ceiling') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for sets and intervals Context("Interval"); ## Create solutions to predetermined problems -$ans1 = Set(0,1); +$ans1 = Set(0, 1); $ans2 = Set(1); $ans3 = Set("{}"); $ans4 = Interval("(-1,0]"); $ans5 = Interval("(-1,1]"); -## Display question -TEXT(beginproblem()); - BEGIN_PGML Consider the function [`` g:\mathbb{R} \to \mathbb{R}``] given by [`` g(x)=\text{ceil}(x) ``]. (Recall that the ceiling function rounds a number up to the nearest integer and that [`` \mathbb{R} ``] represents the set of all real numbers.) @@ -55,7 +46,7 @@ Note: For an empty set, you may type [` \{\} `]. END_PGML BEGIN_PGML_SOLUTION -Solutions: + [`` g([0,1]) ``] = [$ans1] diff --git a/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun3.pg b/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun3.pg index 0be0e0f45f..781abb8faf 100644 --- a/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun3.pg +++ b/Contrib/LaTech/DiscreteMath/ch2s3_functions/fun3.pg @@ -10,16 +10,10 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','sets','functions','image','inverse','square') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for sets and intervals Context("Interval"); @@ -27,13 +21,10 @@ Context("Interval"); ## Create solutions to predetermined problems $ans1 = Interval("[0,4)"); $ans2 = Interval("[0,infinity)"); -$ans3 = Set(-1,1); +$ans3 = Set(-1, 1); $ans4 = Interval("(-1,1)"); $ans5 = Interval("(-infinity,-2]U[2,infinity)"); -## Display question -TEXT(beginproblem()); - BEGIN_PGML Consider the function [`` f:\mathbb{R} \to \mathbb{R}``] given by [`` f(x) = x^{2} ``]. (Recall that [`` \mathbb{R} ``] represents the set of all real numbers.) @@ -55,7 +46,6 @@ Note: For the symbol [` \infty `], you may type the word _infinity_. For an empt END_PGML BEGIN_PGML_SOLUTION -Solutions: [`` f((-2,2)) ``] = [$ans1] diff --git a/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel1.pg b/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel1.pg index 1367904a61..21f135e5c2 100644 --- a/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel1.pg +++ b/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel1.pg @@ -1,105 +1,100 @@ -## DESCRIPTION -## Generates a 2nd degree constant coefficient homogeneous recurrence relation. -## The characteristic equation will have two distinct nonzero real roots. -## A multianswer parser will check both homogeneous solutions in any order entered. -## The problem has the form: a_n = p*a_(n-1) + q*a_(n-2), a_0 = c, a_1 = d -## ENDDESCRIPTION - -## DBsubject(Discrete Math) -## DBchapter(Sequences) -## DBsection(Recurrence Relations) -## Date(06/03/2026) -## Institution(Louisiana Tech University) -## Author(Jason Terry) -## Level(3) -## KEYWORDS('discrete math','recurrence relation','2nd degree','homogeneous','constant coefficient','distinct roots') - -DOCUMENT(); - -## Load libraries -loadMacros("PGstandard.pl", - "MathObjects.pl", - "parserMultiAnswer.pl", - "PGML.pl", - "PGcourse.pl", - "contextFraction.pl"); - -## Set the context: no decimal input, absolute tolerance, variable "n", and integer test points for answer checker -Context("Fraction-NoDecimals"); -Context()->flags->set( tolerance => 0.01, tolType => "absolute"); -Context()->variables->are(n=>["Real",limits=>[0,15],resolution=>1]); - -## Randomly generate two distinct nonzero roots of the characteristic equation -$r1 = non_zero_random(-6,6,1); -do {$r2 = non_zero_random(-6,6,1);} until ($r2 != $r1); - -## Randomly generate initial conditions -$c = random(-4,4,1); -$d = random(-4,4,1); - -## Compute the coefficients of the problem based on roots -$p = $r1 + $r2; -$q = -$r1*$r2; - -## Compute the particular solution constants based on initial conditions -$c1 = Compute("($c*$r2 - $d)/($r2 - $r1)"); -$c2 = Compute("($d - $c*$r1)/($r2 - $r1)"); - -## Construct the solution of the recurrence relation -$n = Formula("n"); -$y1 = ($r1**$n)->reduce; -$y2 = ($r2**$n)->reduce; -$y = ($c1*$y1 + $c2*$y2)->reduce; - -## Construct the answer parser for the general solution -$ans = MultiAnswer($y1, $y2)->with( - singleResult => 1, - checker => sub { - my ( $correct, $student, $self ) = @_; - my ( $f1stu, $f2stu ) = @{$student}; - my ( $f1, $f2 ) = @{$correct}; - if ( - ($f1 == $f1stu && $f2 == $f2stu ) || - ($f1 == $f2stu && $f2 == $f1stu ) - ) { - return 1; - } else { - return 0; - } - } -); - - -## Display problem -TEXT(beginproblem()); - -BEGIN_PGML -For the recurrence relation: - - [`` a_{n} = [$p]a_{n-1} + [$q]a_{n-2} ``], - -The general solution has the form: - - [`` a_{n} = c_{1} ``] [____________________]{$ans} [`` + c_{2} ``] [____________________]{$ans} - -*Note: The arbitrary constants are placed for you, so your answer functions should have no other constants included (except 1). Both functions must be correct to receive credit.* - -Given the initial conditions [`` a_{0} = [$c] ``] and [`` a_{1} = [$d] ``], solve for [`` c_{1} ``] and [`` c_{2} ``]. The final solution is: - - [`` a_{n} = ``] [________________________________________]{$y} - -END_PGML - -BEGIN_PGML_SOLUTION - -The general solution is: - - [`` a_{n} = c_{1} \cdot [$y1] + c_{2} \cdot [$y2] ``] - -Given the initial conditions [`` a_{0} = [$c] ``] and [`` a_{1} = [$d] ``], the final solution is: - - [`` a_{n} = [$y] ``] - -END_PGML_SOLUTION - -ENDDOCUMENT(); \ No newline at end of file +## DESCRIPTION +## Generates a 2nd degree constant coefficient homogeneous recurrence relation. +## The characteristic equation will have two distinct nonzero real roots. +## A multianswer parser will check both homogeneous solutions in any order entered. +## The problem has the form: a_n = p*a_(n-1) + q*a_(n-2), a_0 = c, a_1 = d +## ENDDESCRIPTION + +## DBsubject(Discrete Math) +## DBchapter(Sequences) +## DBsection(Recurrence Relations) +## Date(06/03/2026) +## Institution(Louisiana Tech University) +## Author(Jason Terry) +## Level(3) +## KEYWORDS('discrete math','recurrence relation','2nd degree','homogeneous','constant coefficient','distinct roots') + +DOCUMENT(); + +## Load libraries +loadMacros( + "PGstandard.pl", 'PGML.pl', + 'contextFraction.pl', "parserMultiAnswer.pl", + "PGcourse.pl", +); + +## Set the context: no decimal input, absolute tolerance, variable "n", and integer test points for answer checker +Context("Fraction-NoDecimals"); +Context()->flags->set(tolerance => 0.01, tolType => "absolute"); +Context() + ->variables->are(n => [ "Real", limits => [ 0, 15 ], resolution => 1 ]); + +## Randomly generate two distinct nonzero roots of the characteristic equation +$r1 = non_zero_random(-6, 6, 1); +do { $r2 = non_zero_random(-6, 6, 1); } until ($r2 != $r1); + +## Randomly generate initial conditions +$c = random(-4, 4, 1); +$d = random(-4, 4, 1); + +## Compute the coefficients of the problem based on roots +$p = $r1 + $r2; +$q = -$r1 * $r2; + +## Compute the particular solution constants based on initial conditions +$c1 = Compute("($c*$r2 - $d)/($r2 - $r1)"); +$c2 = Compute("($d - $c*$r1)/($r2 - $r1)"); + +## Construct the solution of the recurrence relation +$n = Formula("n"); +$y1 = ($r1**$n)->reduce; +$y2 = ($r2**$n)->reduce; +$y = ($c1 * $y1 + $c2 * $y2)->reduce; + +## Construct the answer parser for the general solution +$ans = MultiAnswer($y1, $y2)->with( + singleResult => 1, + checker => sub { + my ($correct, $student, $self) = @_; + my ($f1stu, $f2stu) = @{$student}; + my ($f1, $f2) = @{$correct}; + if (($f1 == $f1stu && $f2 == $f2stu) + || ($f1 == $f2stu && $f2 == $f1stu)) + { + return 1; + } else { + return 0; + } + } +); + +BEGIN_PGML +For the recurrence relation: + + [`` a_{n} = [$p]a_{n-1} + [$q]a_{n-2} ``], + +The general solution has the form: + + [`` a_{n} = c_{1} ``] [____________________]{$ans} [`` + c_{2} ``] [____________________]{$ans} + +*Note: The arbitrary constants are placed for you, so your answer functions should have no other constants included (except 1). Both functions must be correct to receive credit.* + +Given the initial conditions [`` a_{0} = [$c] ``] and [`` a_{1} = [$d] ``], solve for [`` c_{1} ``] and [`` c_{2} ``]. The final solution is: + + [`` a_{n} = ``] [________________________________________]{$y} + +END_PGML + +BEGIN_PGML_SOLUTION + +The general solution is: + + [`` a_{n} = c_{1} \cdot [$y1] + c_{2} \cdot [$y2] ``] + +Given the initial conditions [`` a_{0} = [$c] ``] and [`` a_{1} = [$d] ``], the final solution is: + + [`` a_{n} = [$y] ``] + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel2.pg b/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel2.pg index 3543247f91..a487ad3766 100644 --- a/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel2.pg +++ b/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel2.pg @@ -1,104 +1,99 @@ -## DESCRIPTION -## Generates a 2nd degree constant coefficient homogeneous recurrence relation. -## The characteristic equation will have one repeated nonzero real root. -## A multianswer parser will check both homogeneous solutions in any order entered. -## The problem has the form: a_n = p*a_(n-1) + q*a_(n-2), a_0 = c, a_1 = d -## ENDDESCRIPTION - -## DBsubject(Discrete Math) -## DBchapter(Sequences) -## DBsection(Recurrence Relations) -## Date(06/03/2026) -## Institution(Louisiana Tech University) -## Author(Jason Terry) -## Level(3) -## KEYWORDS('discrete math','recurrence relation','2nd degree','homogeneous','constant coefficient','distinct roots') - -DOCUMENT(); - -## Load libraries -loadMacros("PGstandard.pl", - "MathObjects.pl", - "parserMultiAnswer.pl", - "PGML.pl", - "PGcourse.pl", - "contextFraction.pl"); - -## Set the context: no decimal input, absolute tolerance, variable "n", and integer test points for answer checker -Context("Fraction-NoDecimals"); -Context()->flags->set( tolerance => 0.01, tolType => "absolute"); -Context()->variables->are(n=>["Real",limits=>[0,15],resolution=>1]); - -## Randomly generate a nonzero root of the characteristic equation -$r = non_zero_random(-6,6,1); - -## Randomly generate initial conditions -$c = random(-4,4,1); -$d = random(-4,4,1); - -## Compute the coefficients of the problem based on root -$p = 2*$r; -$q = -$r**2; - -## Compute the particular solution constants based on initial conditions -$c1 = $c; -$c2 = Compute("($d - $c*$r)/$r"); - -## Construct the solution of the recurrence relation -$n = Formula("n"); -$y1 = ($r**$n)->reduce; -$y2 = $n*($r**$n)->reduce; -$y = ($c1*$y1 + $c2*$y2)->reduce; - -## Construct the answer parser for the general solution -$ans = MultiAnswer($y1, $y2)->with( - singleResult => 1, - checker => sub { - my ( $correct, $student, $self ) = @_; - my ( $f1stu, $f2stu ) = @{$student}; - my ( $f1, $f2 ) = @{$correct}; - if ( - ($f1 == $f1stu && $f2 == $f2stu ) || - ($f1 == $f2stu && $f2 == $f1stu ) - ) { - return 1; - } else { - return 0; - } - } -); - - -## Display problem -TEXT(beginproblem()); - -BEGIN_PGML -For the recurrence relation: - - [`` a_{n} = [$p]a_{n-1} + [$q]a_{n-2} ``], - -The general solution has the form: - - [`` a_{n} = c_{1} ``] [____________________]{$ans} [`` + c_{2} ``] [____________________]{$ans} - -*Note: The arbitrary constants are placed for you, so your answer functions should have no other constants included (except 1). Both functions must be correct to receive credit.* - -Given the initial conditions [`` a_{0} = [$c] ``] and [`` a_{1} = [$d] ``], solve for [`` c_{1} ``] and [`` c_{2} ``]. The final solution is: - - [`` a_{n} = ``] [________________________________________]{$y} - -END_PGML - -BEGIN_PGML_SOLUTION - -The general solution is: - - [`` a_{n} = c_{1} \cdot [$y1] + c_{2} \cdot [$y2] ``] - -Given the initial conditions [`` a_{0} = [$c] ``] and [`` a_{1} = [$d] ``], the final solution is: - - [`` a_{n} = [$y] ``] - -END_PGML_SOLUTION - -ENDDOCUMENT(); \ No newline at end of file +## DESCRIPTION +## Generates a 2nd degree constant coefficient homogeneous recurrence relation. +## The characteristic equation will have one repeated nonzero real root. +## A multianswer parser will check both homogeneous solutions in any order entered. +## The problem has the form: a_n = p*a_(n-1) + q*a_(n-2), a_0 = c, a_1 = d +## ENDDESCRIPTION + +## DBsubject(Discrete Math) +## DBchapter(Sequences) +## DBsection(Recurrence Relations) +## Date(06/03/2026) +## Institution(Louisiana Tech University) +## Author(Jason Terry) +## Level(3) +## KEYWORDS('discrete math','recurrence relation','2nd degree','homogeneous','constant coefficient','distinct roots') + +DOCUMENT(); + +## Load libraries +loadMacros( + "PGstandard.pl", 'PGML.pl', + 'contextFraction.pl', "parserMultiAnswer.pl", + "PGcourse.pl", +); + +## Set the context: no decimal input, absolute tolerance, variable "n", and integer test points for answer checker +Context("Fraction-NoDecimals"); +Context()->flags->set(tolerance => 0.01, tolType => "absolute"); +Context() + ->variables->are(n => [ "Real", limits => [ 0, 15 ], resolution => 1 ]); + +## Randomly generate a nonzero root of the characteristic equation +$r = non_zero_random(-6, 6, 1); + +## Randomly generate initial conditions +$c = random(-4, 4, 1); +$d = random(-4, 4, 1); + +## Compute the coefficients of the problem based on root +$p = 2 * $r; +$q = -$r**2; + +## Compute the particular solution constants based on initial conditions +$c1 = $c; +$c2 = Compute("($d - $c*$r)/$r"); + +## Construct the solution of the recurrence relation +$n = Formula("n"); +$y1 = ($r**$n)->reduce; +$y2 = $n * ($r**$n)->reduce; +$y = ($c1 * $y1 + $c2 * $y2)->reduce; + +## Construct the answer parser for the general solution +$ans = MultiAnswer($y1, $y2)->with( + singleResult => 1, + checker => sub { + my ($correct, $student, $self) = @_; + my ($f1stu, $f2stu) = @{$student}; + my ($f1, $f2) = @{$correct}; + if (($f1 == $f1stu && $f2 == $f2stu) + || ($f1 == $f2stu && $f2 == $f1stu)) + { + return 1; + } else { + return 0; + } + } +); + +BEGIN_PGML +For the recurrence relation: + + [`` a_{n} = [$p]a_{n-1} + [$q]a_{n-2} ``], + +The general solution has the form: + + [`` a_{n} = c_{1} ``] [____________________]{$ans} [`` + c_{2} ``] [____________________]{$ans} + +*Note: The arbitrary constants are placed for you, so your answer functions should have no other constants included (except 1). Both functions must be correct to receive credit.* + +Given the initial conditions [`` a_{0} = [$c] ``] and [`` a_{1} = [$d] ``], solve for [`` c_{1} ``] and [`` c_{2} ``]. The final solution is: + + [`` a_{n} = ``] [________________________________________]{$y} + +END_PGML + +BEGIN_PGML_SOLUTION + +The general solution is: + + [`` a_{n} = c_{1} \cdot [$y1] + c_{2} \cdot [$y2] ``] + +Given the initial conditions [`` a_{0} = [$c] ``] and [`` a_{1} = [$d] ``], the final solution is: + + [`` a_{n} = [$y] ``] + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel3.pg b/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel3.pg index 745e407206..576e427339 100644 --- a/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel3.pg +++ b/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel3.pg @@ -1,86 +1,79 @@ -## DESCRIPTION -## Generates a 1st degree constant coefficient nonhomogeneous recurrence relation. -## The nonhomogeneous function will be linear. -## The problem has the form: a_n = r*a_(n-1) + pn + q, a_0 = c -## ENDDESCRIPTION - -## DBsubject(Discrete Math) -## DBchapter(Sequences) -## DBsection(Recurrence Relations) -## Date(06/03/2026) -## Institution(Louisiana Tech University) -## Author(Jason Terry) -## Level(3) -## KEYWORDS('discrete math','recurrence relation','1st degree','nonhomogeneous','constant coefficient') - -DOCUMENT(); - -## Load libraries -loadMacros("PGstandard.pl", - "MathObjects.pl", - "PGML.pl", - "PGcourse.pl", - "contextFraction.pl"); - -## Set the context: no decimal input, absolute tolerance, variable "n", and integer test points for answer checker -Context("Fraction-NoDecimals"); -Context()->flags->set( tolerance => 0.01, tolType => "absolute"); -Context()->variables->are(n=>["Real",limits=>[0,15],resolution=>1]); - -## Randomly generate a root of the characteristic equation -do {$r = non_zero_random(-6,6,1);} until ($r != 1); - -## Randomly generate initial condition -$c = random(-4,4,1); - -## Randomly generate the coefficients of the specific solution -$A = non_zero_random(-4,4,1); -$B = non_zero_random(-4,4,1); - -## Compute the coefficients of the nonrecursive function based on the specific solution -$p = $A*(1 - $r); -$q = $B*(1 - $r) + $r*$A; - -## Compute the particular solution constant based on the initial conditions -$c1 = $c - $B; - -## Construct the solution of the recurrence relation -$n = Formula("n"); -$y1 = ($r**$n)->reduce; -$s = ($A*$n + $B)->reduce; -$y = ($c1*$y1 + $s)->reduce; - -## Display problem -TEXT(beginproblem()); - -BEGIN_PGML -For the recurrence relation: - - [`` a_{n} = [$r]a_{n-1} + [$p]n + [$q] ``], - -The general solution has the form: - - [`` a_{n} = c_{1} ``] [____________________]{$y1} [`` + ``] [____________________]{$s} - -*Note: The first blank should have the exponential (homogeneous) function. The second blank should have the specific solution.* - -Given the initial condition [`` a_{0} = [$c] ``] and solving for [`` c_{1} ``], the final solution is: - - [`` a_{n} = ``] [________________________________________]{$y} - -END_PGML - -BEGIN_PGML_SOLUTION - -The general solution is: - - [`` a_{n} = c_{1} \cdot [$y1] + [$s] ``] - -Given the initial condition [`` a_{0} = [$c] ``] and solving for [`` c_{1} ``], the final solution is: - - [`` a_{n} = [$y] ``] - -END_PGML_SOLUTION - - -ENDDOCUMENT(); \ No newline at end of file +## DESCRIPTION +## Generates a 1st degree constant coefficient nonhomogeneous recurrence relation. +## The nonhomogeneous function will be linear. +## The problem has the form: a_n = r*a_(n-1) + pn + q, a_0 = c +## ENDDESCRIPTION + +## DBsubject(Discrete Math) +## DBchapter(Sequences) +## DBsection(Recurrence Relations) +## Date(06/03/2026) +## Institution(Louisiana Tech University) +## Author(Jason Terry) +## Level(3) +## KEYWORDS('discrete math','recurrence relation','1st degree','nonhomogeneous','constant coefficient') + +DOCUMENT(); + +## Load libraries +loadMacros("PGstandard.pl", 'PGML.pl', 'contextFraction.pl', "PGcourse.pl",); + +## Set the context: no decimal input, absolute tolerance, variable "n", and integer test points for answer checker +Context("Fraction-NoDecimals"); +Context()->flags->set(tolerance => 0.01, tolType => "absolute"); +Context() + ->variables->are(n => [ "Real", limits => [ 0, 15 ], resolution => 1 ]); + +## Randomly generate a root of the characteristic equation +do { $r = non_zero_random(-6, 6, 1); } until ($r != 1); + +## Randomly generate initial condition +$c = random(-4, 4, 1); + +## Randomly generate the coefficients of the specific solution +$A = non_zero_random(-4, 4, 1); +$B = non_zero_random(-4, 4, 1); + +## Compute the coefficients of the nonrecursive function based on the specific solution +$p = $A * (1 - $r); +$q = $B * (1 - $r) + $r * $A; + +## Compute the particular solution constant based on the initial conditions +$c1 = $c - $B; + +## Construct the solution of the recurrence relation +$n = Formula("n"); +$y1 = ($r**$n)->reduce; +$s = ($A * $n + $B)->reduce; +$y = ($c1 * $y1 + $s)->reduce; + +BEGIN_PGML +For the recurrence relation: + + [`` a_{n} = [$r]a_{n-1} + [$p]n + [$q] ``], + +The general solution has the form: + + [`` a_{n} = c_{1} ``] [____________________]{$y1} [`` + ``] [____________________]{$s} + +*Note: The first blank should have the exponential (homogeneous) function. The second blank should have the specific solution.* + +Given the initial condition [`` a_{0} = [$c] ``] and solving for [`` c_{1} ``], the final solution is: + + [`` a_{n} = ``] [________________________________________]{$y} + +END_PGML + +BEGIN_PGML_SOLUTION + +The general solution is: + + [`` a_{n} = c_{1} \cdot [$y1] + [$s] ``] + +Given the initial condition [`` a_{0} = [$c] ``] and solving for [`` c_{1} ``], the final solution is: + + [`` a_{n} = [$y] ``] + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel4.pg b/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel4.pg index f52e020f72..eafb0386f9 100644 --- a/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel4.pg +++ b/Contrib/LaTech/DiscreteMath/ch3s4_recurrencerelations/recrel4.pg @@ -1,86 +1,80 @@ -## DESCRIPTION -## Generates a 1st degree constant coefficient nonhomogeneous recurrence relation. -## The nonhomogeneous function will be exponential. -## The problem has the form: a_n = r*a_(n-1) + k(p^n), a_0 = c -## ENDDESCRIPTION - -## DBsubject(Discrete Math) -## DBchapter(Sequences) -## DBsection(Recurrence Relations) -## Date(06/03/2026) -## Institution(Louisiana Tech University) -## Author(Jason Terry) -## Level(3) -## KEYWORDS('discrete math','recurrence relation','1st degree','nonhomogeneous','constant coefficient') - -DOCUMENT(); - -## Load libraries -loadMacros("PGstandard.pl", - "MathObjects.pl", - "PGML.pl", - "PGcourse.pl", - "contextFraction.pl"); - -## Set the context: no decimal input, absolute tolerance, variable "n", and integer test points for answer checker -Context("Fraction-NoDecimals"); -Context()->flags->set( tolerance => 0.01, tolType => "absolute"); -Context()->variables->are(n=>["Real",limits=>[0,15],resolution=>1]); - -## Randomly generate a root of the characteristic equation -do {$r = non_zero_random(-6,6,1);} until ($r != 1); - -## Randomly generate the base of the nonrecursive exponential function -do {$p = non_zero_random(-6,6,1);} until ($p != $r && $p != 1); - -## Randomly generate an initial condition -$c = random(-4,4,1); - -## Randomly generate the coefficient of the nonrecursive function -$k = non_zero_random(-4,4,1); - -## Compute the coefficient of the specific solution -$A = Compute("($k*$p)/($p-$r)"); - -## Compute the particular solution constant based on the initial conditions -$c1 = $c - $A; - -## Construct the solution of the recurrence relation -$n = Formula("n"); -$y1 = ($r**$n)->reduce; -$s = ($A*($p**$n))->reduce; -$y = ($c1*$y1 + $s)->reduce; - -## Display problem -TEXT(beginproblem()); - -BEGIN_PGML -For the recurrence relation: - - [`` a_{n} = [$r]a_{n-1} + [$k]([$p])^{n} ``], - -The general solution has the form: - - [`` a_{n} = c_{1} ``] [____________________]{$y1} [`` + ``] [____________________]{$s} - -*Note: The first blank should have the exponential (homogeneous) function. The second blank should have the specific solution.* - -Given the initial condition [`` a_{0} = [$c] ``] and solving for [`` c_{1} ``], the final solution is: - - [`` a_{n} = ``] [________________________________________]{$y} - -END_PGML - -BEGIN_PGML_SOLUTION - -The general solution is: - - [`` a_{n} = c_{1} \cdot [$y1] + [$s] ``] - -Given the initial condition [`` a_{0} = [$c] ``] and solving for [`` c_{1} ``], the final solution is: - - [`` a_{n} = [$y] ``] - -END_PGML_SOLUTION - -ENDDOCUMENT(); \ No newline at end of file +## DESCRIPTION +## Generates a 1st degree constant coefficient nonhomogeneous recurrence relation. +## The nonhomogeneous function will be exponential. +## The problem has the form: a_n = r*a_(n-1) + k(p^n), a_0 = c +## ENDDESCRIPTION + +## DBsubject(Discrete Math) +## DBchapter(Sequences) +## DBsection(Recurrence Relations) +## Date(06/03/2026) +## Institution(Louisiana Tech University) +## Author(Jason Terry) +## Level(3) +## KEYWORDS('discrete math','recurrence relation','1st degree','nonhomogeneous','constant coefficient') + +DOCUMENT(); + +## Load libraries +loadMacros("PGstandard.pl", 'PGML.pl', 'contextFraction.pl', "PGcourse.pl",); + +## Set the context: no decimal input, absolute tolerance, variable "n", and integer test points for answer checker +Context("Fraction-NoDecimals"); +Context()->flags->set(tolerance => 0.01, tolType => "absolute"); +Context() + ->variables->are(n => [ "Real", limits => [ 0, 15 ], resolution => 1 ]); + +## Randomly generate a root of the characteristic equation +do { $r = non_zero_random(-6, 6, 1); } until ($r != 1); + +## Randomly generate the base of the nonrecursive exponential function +do { $p = non_zero_random(-6, 6, 1); } until ($p != $r && $p != 1); + +## Randomly generate an initial condition +$c = random(-4, 4, 1); + +## Randomly generate the coefficient of the nonrecursive function +$k = non_zero_random(-4, 4, 1); + +## Compute the coefficient of the specific solution +$A = Compute("($k*$p)/($p-$r)"); + +## Compute the particular solution constant based on the initial conditions +$c1 = $c - $A; + +## Construct the solution of the recurrence relation +$n = Formula("n"); +$y1 = ($r**$n)->reduce; +$s = ($A * ($p**$n))->reduce; +$y = ($c1 * $y1 + $s)->reduce; + +BEGIN_PGML +For the recurrence relation: + + [`` a_{n} = [$r]a_{n-1} + [$k]([$p])^{n} ``], + +The general solution has the form: + + [`` a_{n} = c_{1} ``] [____________________]{$y1} [`` + ``] [____________________]{$s} + +*Note: The first blank should have the exponential (homogeneous) function. The second blank should have the specific solution.* + +Given the initial condition [`` a_{0} = [$c] ``] and solving for [`` c_{1} ``], the final solution is: + + [`` a_{n} = ``] [________________________________________]{$y} + +END_PGML + +BEGIN_PGML_SOLUTION + +The general solution is: + + [`` a_{n} = c_{1} \cdot [$y1] + [$s] ``] + +Given the initial condition [`` a_{0} = [$c] ``] and solving for [`` c_{1} ``], the final solution is: + + [`` a_{n} = [$y] ``] + +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch4As1_matrices/boolmatrix1.pg b/Contrib/LaTech/DiscreteMath/ch4As1_matrices/boolmatrix1.pg index 65799a4827..96dcd9587d 100644 --- a/Contrib/LaTech/DiscreteMath/ch4As1_matrices/boolmatrix1.pg +++ b/Contrib/LaTech/DiscreteMath/ch4As1_matrices/boolmatrix1.pg @@ -10,56 +10,47 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','matrix','boolean','meet','join','zero-one') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for matrices Context("Matrix"); ## Create random 3x3 boolean matrices $A = Matrix([ -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)] + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ] ]); $B = Matrix([ -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)] + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ] ]); ## Create their meet and join -for my $i (1..3) { - for my $j (1..3) { - $temp1[$i][$j] = $A->element($i,$j)*$B->element($i,$j); - $temp2[$i][$j] = min($A->element($i,$j)+$B->element($i,$j), 1); - } +for my $i (1 .. 3) { + for my $j (1 .. 3) { + $temp1[$i][$j] = $A->element($i, $j) * $B->element($i, $j); + $temp2[$i][$j] = min($A->element($i, $j) + $B->element($i, $j), 1); + } } $meet = Matrix([ -[$temp1[1][1],$temp1[1][2],$temp1[1][3]], -[$temp1[2][1],$temp1[2][2],$temp1[2][3]], -[$temp1[3][1],$temp1[3][2],$temp1[3][3]] + [ $temp1[1][1], $temp1[1][2], $temp1[1][3] ], + [ $temp1[2][1], $temp1[2][2], $temp1[2][3] ], + [ $temp1[3][1], $temp1[3][2], $temp1[3][3] ] ]); $join = Matrix([ -[$temp2[1][1],$temp2[1][2],$temp2[1][3]], -[$temp2[2][1],$temp2[2][2],$temp2[2][3]], -[$temp2[3][1],$temp2[3][2],$temp2[3][3]] + [ $temp2[1][1], $temp2[1][2], $temp2[1][3] ], + [ $temp2[2][1], $temp2[2][2], $temp2[2][3] ], + [ $temp2[3][1], $temp2[3][2], $temp2[3][3] ] ]); -## Display question -TEXT(beginproblem()); - BEGIN_PGML For the matrices [` A = [$A] `] and [` B = [$B] `], their meet is: diff --git a/Contrib/LaTech/DiscreteMath/ch4As1_matrices/boolmatrix2.pg b/Contrib/LaTech/DiscreteMath/ch4As1_matrices/boolmatrix2.pg index 38a18913d6..0b526b6454 100644 --- a/Contrib/LaTech/DiscreteMath/ch4As1_matrices/boolmatrix2.pg +++ b/Contrib/LaTech/DiscreteMath/ch4As1_matrices/boolmatrix2.pg @@ -10,50 +10,40 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','matrix','boolean product') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for matrices Context("Matrix"); ## Create random 3x3 boolean matrices $A = Matrix([ -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)] + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ] ]); $B = Matrix([ -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)] + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ] ]); ## Create their boolean product -for my $i (1..3) { - for my $j (1..3) { - $temp[$i][$j] = min(($A->row($i)*$B->column($j))->element(1,1), 1); - } +for my $i (1 .. 3) { + for my $j (1 .. 3) { + $temp[$i][$j] = min(($A->row($i) * $B->column($j))->element(1, 1), 1); + } } $prod = Matrix([ -[$temp[1][1],$temp[1][2],$temp[1][3]], -[$temp[2][1],$temp[2][2],$temp[2][3]], -[$temp[3][1],$temp[3][2],$temp[3][3]] + [ $temp[1][1], $temp[1][2], $temp[1][3] ], + [ $temp[2][1], $temp[2][2], $temp[2][3] ], + [ $temp[3][1], $temp[3][2], $temp[3][3] ] ]); - -## Display question -TEXT(beginproblem()); - BEGIN_PGML For the matrices [` A = [$A] `] and [` B = [$B] `], their boolean product is: diff --git a/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep1.pg b/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep1.pg index 749d8b6f25..e77e1bab33 100644 --- a/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep1.pg +++ b/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep1.pg @@ -1,5 +1,5 @@ ## DESCRIPTION -## Generates two random 3x3 zero-one matrices representing relations and asks to compute the +## Generates two random 3x3 zero-one matrices representing relations and asks to compute the ## matrix representation of the union and intersection of the relations. ## ENDDESCRIPTION @@ -11,56 +11,47 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','matrix','boolean','meet','join','relation','union','intersection') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for matrices Context("Matrix"); ## Create random 3x3 boolean matrices $A = Matrix([ -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)] + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ] ]); $B = Matrix([ -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)] + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ] ]); ## Create their meet and join -for my $i (1..3) { - for my $j (1..3) { - $temp1[$i][$j] = $A->element($i,$j)*$B->element($i,$j); - $temp2[$i][$j] = min($A->element($i,$j)+$B->element($i,$j), 1); - } +for my $i (1 .. 3) { + for my $j (1 .. 3) { + $temp1[$i][$j] = $A->element($i, $j) * $B->element($i, $j); + $temp2[$i][$j] = min($A->element($i, $j) + $B->element($i, $j), 1); + } } $meet = Matrix([ -[$temp1[1][1],$temp1[1][2],$temp1[1][3]], -[$temp1[2][1],$temp1[2][2],$temp1[2][3]], -[$temp1[3][1],$temp1[3][2],$temp1[3][3]] + [ $temp1[1][1], $temp1[1][2], $temp1[1][3] ], + [ $temp1[2][1], $temp1[2][2], $temp1[2][3] ], + [ $temp1[3][1], $temp1[3][2], $temp1[3][3] ] ]); $join = Matrix([ -[$temp2[1][1],$temp2[1][2],$temp2[1][3]], -[$temp2[2][1],$temp2[2][2],$temp2[2][3]], -[$temp2[3][1],$temp2[3][2],$temp2[3][3]] + [ $temp2[1][1], $temp2[1][2], $temp2[1][3] ], + [ $temp2[2][1], $temp2[2][2], $temp2[2][3] ], + [ $temp2[3][1], $temp2[3][2], $temp2[3][3] ] ]); -## Display question -TEXT(beginproblem()); - BEGIN_PGML Suppose the matrix representation for relations [` R `] and [` S `] are [` M_{R} = [$A] `] and [` M_{S} = [$B] `]. Compute the matrix represenation for [` M_{R \cap S} `] and [` M_{R \cup S} `]. diff --git a/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep2.pg b/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep2.pg index 095bb92965..3dddce97ae 100644 --- a/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep2.pg +++ b/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep2.pg @@ -1,5 +1,5 @@ ## DESCRIPTION -## Generates two random 3x3 zero-one matrices representing relations and asks to compute the +## Generates two random 3x3 zero-one matrices representing relations and asks to compute the ## matrix representation of the composition of the relations. ## ENDDESCRIPTION @@ -11,50 +11,40 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','matrix','boolean product','relation','composition') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for matrices Context("Matrix"); ## Create random 3x3 boolean matrices $A = Matrix([ -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)] + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ] ]); $B = Matrix([ -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)] + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ] ]); ## Create their boolean product -for my $i (1..3) { - for my $j (1..3) { - $temp[$i][$j] = min(($A->row($i)*$B->column($j))->element(1,1), 1); - } +for my $i (1 .. 3) { + for my $j (1 .. 3) { + $temp[$i][$j] = min(($A->row($i) * $B->column($j))->element(1, 1), 1); + } } $prod = Matrix([ -[$temp[1][1],$temp[1][2],$temp[1][3]], -[$temp[2][1],$temp[2][2],$temp[2][3]], -[$temp[3][1],$temp[3][2],$temp[3][3]] + [ $temp[1][1], $temp[1][2], $temp[1][3] ], + [ $temp[2][1], $temp[2][2], $temp[2][3] ], + [ $temp[3][1], $temp[3][2], $temp[3][3] ] ]); - -## Display question -TEXT(beginproblem()); - BEGIN_PGML Suppose the matrix representation for relations [` R `] and [` S `] are [` M_{R} = [$A] `] and [` M_{S} = [$B] `]. Compute the matrix represenation for [` M_{S \circ R} `]. @@ -64,7 +54,6 @@ Suppose the matrix representation for relations [` R `] and [` S `] are [` M_{R} END_PGML BEGIN_PGML_SOLUTION -Solutions: [`` M_{S \circ R} = [$prod] ``] diff --git a/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep3.pg b/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep3.pg index ebeecc82f8..e31d627416 100644 --- a/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep3.pg +++ b/Contrib/LaTech/DiscreteMath/ch4As3_relations/boolmatrixrep3.pg @@ -1,5 +1,5 @@ ## DESCRIPTION -## Generates a random 3x3 zero-one matrix representing a relation and asks to compute the +## Generates a random 3x3 zero-one matrix representing a relation and asks to compute the ## matrix representation of the inverse and complement of the relation. ## ENDDESCRIPTION @@ -11,43 +11,28 @@ ## Author(Jason Terry) ## KEYWORDS('discrete math','matrix','boolean','inverse','complement','relation') - DOCUMENT(); ## Load libraries -loadMacros( -"PGstandard.pl", -"MathObjects.pl", -"PGcourse.pl", -"PGML.pl" -); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); ## Set the context for matrices Context("Matrix"); ## Create a random 3x3 boolean matrix $A = Matrix([ -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)], -[random(0,1,1),random(0,1,1),random(0,1,1)] + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ], + [ random(0, 1, 1), random(0, 1, 1), random(0, 1, 1) ] ]); - ## Create the matrices representing the inverse and complement relation $inverse = $A->transpose; -$ones = Matrix([ -[1,1,1], -[1,1,1], -[1,1,1] -]); +$ones = Matrix([ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ]); $comp = $ones - $A; - -## Display question -TEXT(beginproblem()); - BEGIN_PGML Suppose the matrix representation for relation [` R `] is [` M_{R} = [$A] `]. Compute the matrix represenation for the inverse relation [` M_{R^{-1}} `] and the complement relation [` M_{\overline{R}} `]. diff --git a/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language1.pg b/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language1.pg index ed1461442f..947d0d2730 100644 --- a/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language1.pg +++ b/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language1.pg @@ -12,25 +12,21 @@ DOCUMENT(); -loadMacros( - "PGstandard.pl", - "MathObjects.pl", - "PGML.pl", - "parserPopUp.pl", -); +## Load libraries +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); -TEXT(beginproblem()); +Context('Numeric'); # Generate a random binary string $alphabet = "01"; -$length = random(4, 8, 1); -$string = ""; +$length = random(4, 8, 1); +$string = ""; for ($i = 0; $i < $length; $i++) { $string .= substr($alphabet, random(0, 1, 1), 1); } # Language: strings of even length $answer = ($length % 2 == 0) ? "Yes" : "No"; -$popup = PopUp(['Choose...','Yes', 'No'], $answer); +$popup = PopUp([ 'Choose...', 'Yes', 'No' ], $answer); BEGIN_PGML Consider the language [`` L ``] over the alphabet [`` \{0, 1\} ``] that consists of all strings of even length. Determine if the following string belongs to [`` L ``]: @@ -40,4 +36,8 @@ String: [$string] Does the string belong to the language? [________]{$popup} END_PGML -ENDDOCUMENT(); \ No newline at end of file +BEGIN_PGML_SOLUTION +Does the string [$string] belongs to the language? [$popup] +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language2.pg b/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language2.pg index 175d7de965..4fb466a130 100644 --- a/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language2.pg +++ b/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language2.pg @@ -12,26 +12,22 @@ DOCUMENT(); -loadMacros( - "PGstandard.pl", - "MathObjects.pl", - "PGML.pl", - "parserPopUp.pl", -); +## Load libraries +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); -TEXT(beginproblem()); +Context('Numeric'); # Generate a random binary string $alphabet = "01"; -$length = random(3, 7, 1); -$start = random(0, 1, 1); -$string = $start; +$length = random(3, 7, 1); +$start = random(0, 1, 1); +$string = $start; for ($i = 1; $i < $length; $i++) { $string .= substr($alphabet, random(0, 1, 1), 1); } # Language: strings starting with 0 $answer = ($start eq "0") ? "Yes" : "No"; -$popup = PopUp(['Choose...','Yes', 'No'], $answer); +$popup = PopUp([ 'Choose...', 'Yes', 'No' ], $answer); BEGIN_PGML Consider the language [`` L ``] over the alphabet [`` \{0, 1\} ``] that consists of all strings starting with 0. Determine if the following string belongs to [`` L ``]: @@ -41,4 +37,8 @@ String: [$string] Does the string belong to the language? [________]{$popup} END_PGML -ENDDOCUMENT(); \ No newline at end of file +BEGIN_PGML_SOLUTION +Does the string [$string] belongs to the language? [$popup] +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language3.pg b/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language3.pg index c1381f343a..ae4fec537e 100644 --- a/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language3.pg +++ b/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language3.pg @@ -12,26 +12,22 @@ DOCUMENT(); -loadMacros( - "PGstandard.pl", - "MathObjects.pl", - "PGML.pl", - "parserPopUp.pl", -); +## Load libraries +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); -TEXT(beginproblem()); +Context('Numeric'); # Generate a random binary string $alphabet = "01"; -$length = random(5, 10, 1); -$string = ""; +$length = random(5, 10, 1); +$string = ""; for ($i = 0; $i < $length; $i++) { $string .= substr($alphabet, random(0, 1, 1), 1); } # Language: strings where the number of 1's is divisible by 3 $one_count = () = $string =~ /1/g; -$answer = ($one_count % 3 == 0) ? "Yes" : "No"; -$popup = PopUp(['Choose...','Yes', 'No'], $answer); +$answer = ($one_count % 3 == 0) ? "Yes" : "No"; +$popup = PopUp([ 'Choose...', 'Yes', 'No' ], $answer); BEGIN_PGML Consider the language [`` L ``] over the alphabet [`` \{0, 1\} ``] that consists of all strings where the number of 1's is divisible by 3. Determine if the following string belongs to [`` L ``]: @@ -41,4 +37,8 @@ String: [$string] Does the string belong to the language? [________]{$popup} END_PGML -ENDDOCUMENT(); \ No newline at end of file +BEGIN_PGML_SOLUTION +Does the string [$string] belongs to the language? [$popup] +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language4.pg b/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language4.pg index 5c904366cf..0f75d977a1 100644 --- a/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language4.pg +++ b/Contrib/LaTech/DiscreteMath/ch4Cs1_stringslanguages/strings_language4.pg @@ -12,28 +12,22 @@ DOCUMENT(); -loadMacros( - "PGstandard.pl", - "PGML.pl", - "parserMultiAnswer.pl" -); - -TEXT(beginproblem()); +## Load libraries +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); # Enable set context with string elements Context()->strings->add("ab" => {}, "abb" => {}, "abbb" => {}); Context()->lists->set( - separator => ',', - start => '{', - end => '}', - list_type => 'set', + separator => ',', + start => '{', + end => '}', + list_type => 'set', ); # The correct set of strings $answer = List("ab", "abb", "abbb"); - BEGIN_PGML Let [`` L_{1} = \{a,ab\} ``] and [`` L_{2} = \{b,bb\} ``]. @@ -46,4 +40,4 @@ BEGIN_PGML_SOLUTION Distinct results: [`` ab,abb,abbb ``] END_PGML_SOLUTION -ENDDOCUMENT(); \ No newline at end of file +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa1.pg b/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa1.pg index c222a4015e..a08e58cb2f 100644 --- a/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa1.pg +++ b/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa1.pg @@ -12,20 +12,15 @@ DOCUMENT(); -loadMacros( - "PGstandard.pl", - "MathObjects.pl", - "niceTables.pl", - "PGML.pl", - "parserPopUp.pl", -); +## Load libraries +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); -TEXT(beginproblem()); +Context('Numeric'); # Generate a random binary string $alphabet = "01"; -$length = random(4, 8, 1); -$string = ""; +$length = random(4, 8, 1); +$string = ""; for ($i = 0; $i < $length; $i++) { $string .= substr($alphabet, random(0, 1, 1), 1); } @@ -41,10 +36,10 @@ foreach my $char (split //, $string) { } } $answer = ($current_state eq "q2") ? "Accept" : "Reject"; -$popup = PopUp(['Choose...','Accept', 'Reject'], $answer); +$popup = PopUp([ 'Choose...', 'Accept', 'Reject' ], $answer); BEGIN_PGML -Consider a DFA over the alphabet \{0, 1\} that has states [` q_0 `], [` q_1 `], and [` q_2 `]. The transition table is: +Consider a DFA over the alphabet [`\{0, 1\}`] that has states [` q_0 `], [` q_1 `], and [` q_2 `]. The transition table is: [@ DataTable([ @@ -62,5 +57,8 @@ Given the input string [$string], what is the outcome? [________]{$popup} END_PGML +BEGIN_PGML_SOLUTION +Does the string [$string] belongs to the language? [$popup] +END_PGML_SOLUTION -ENDDOCUMENT(); \ No newline at end of file +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa2.pg b/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa2.pg index 85a8243160..0734eeb24f 100644 --- a/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa2.pg +++ b/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa2.pg @@ -12,22 +12,17 @@ DOCUMENT(); -loadMacros( - "PGstandard.pl", - "MathObjects.pl", - "niceTables.pl", - "PGML.pl", - "parserPopUp.pl", -); +## Load libraries +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); -TEXT(beginproblem()); +Context('Numeric'); # Generate a random binary string $alphabet = "01"; -$length = random(4, 8, 1); -$string = ""; +$length = random(4, 8, 1); +$string = ""; for ($i = 0; $i < $length; $i++) { - $string .= substr($alphabet, random(0, 1, 1), 1); + $string .= substr($alphabet, random(0, 1), 1); } # DFA states: q0 (even 0's, accepting), q1 (odd 0's) $current_state = "q0"; @@ -37,7 +32,7 @@ foreach my $char (split //, $string) { } } $answer = ($current_state eq "q0") ? "Accept" : "Reject"; -$popup = PopUp(['Choose...','Accept', 'Reject'], $answer); +$popup = PopUp([ 'Choose...', 'Accept', 'Reject' ], $answer); BEGIN_PGML Consider a DFA over the alphabet \{0, 1\} that has states [` q_0 `], [` q_1 `]. The transition table is: @@ -57,5 +52,8 @@ Given the input string [$string], what is the outcome? [________]{$popup} END_PGML +BEGIN_PGML_SOLUTION +Does the string [$string] belongs to the language? [$popup] +END_PGML_SOLUTION -ENDDOCUMENT(); \ No newline at end of file +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa3.pg b/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa3.pg index 15d3cbf8ad..10ff7ed627 100644 --- a/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa3.pg +++ b/Contrib/LaTech/DiscreteMath/ch4Cs2_dfa/dfa3.pg @@ -12,22 +12,17 @@ DOCUMENT(); -loadMacros( - "PGstandard.pl", - "MathObjects.pl", - "niceTables.pl", - "PGML.pl", - "parserPopUp.pl", -); +## Load libraries +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); -TEXT(beginproblem()); +Context('Numeric'); # Generate a random binary string $alphabet = "01"; -$length = random(3, 7, 1); -$string = ""; +$length = random(3, 7, 1); +$string = ""; for ($i = 0; $i < $length; $i++) { - $string .= substr($alphabet, random(0, 1, 1), 1); + $string .= substr($alphabet, random(0, 1), 1); } # DFA states: q0 (initial), q1, q2 (accepting) $current_state = "q0"; @@ -41,7 +36,7 @@ foreach my $char (split //, $string) { } } $answer = $current_state; -$popup = PopUp(['Choose...','q0', 'q1', 'q2'], $answer); +$popup = PopUp([ 'Choose...', 'q0', 'q1', 'q2' ], $answer); BEGIN_PGML Consider a DFA over the alphabet \{0, 1\} with states [` q_0 `], [` q_1 `], and [` q_2 `]. The transition table is: @@ -62,5 +57,8 @@ Given the input string [$string], what is the final state? [________]{$popup} END_PGML +BEGIN_PGML_SOLUTION +Does the string [$string] belongs to the language? [$popup] +END_PGML_SOLUTION -ENDDOCUMENT(); \ No newline at end of file +ENDDOCUMENT(); diff --git a/Contrib/LaTech/DiscreteMath/ch4Cs3_nfa/nfa1.pg b/Contrib/LaTech/DiscreteMath/ch4Cs3_nfa/nfa1.pg index 353c0f35f1..2c8ee25fbd 100644 --- a/Contrib/LaTech/DiscreteMath/ch4Cs3_nfa/nfa1.pg +++ b/Contrib/LaTech/DiscreteMath/ch4Cs3_nfa/nfa1.pg @@ -12,25 +12,20 @@ DOCUMENT(); -loadMacros( - "PGstandard.pl", - "MathObjects.pl", - "niceTables.pl", - "PGML.pl", - "parserPopUp.pl", -); +## Load libraries +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); -TEXT(beginproblem()); +Context('Numeric'); # Generate a random binary string $alphabet = "01"; -$length = random(4, 8, 1); -$string = ""; +$length = random(4, 8); +$string = ""; for ($i = 0; $i < $length; $i++) { - $string .= substr($alphabet, random(0, 1, 1), 1); + $string .= substr($alphabet, random(0, 1), 1); } # NFA states: q0 (initial), q1 (seen 0), q2 (seen 00, accepting) -@states = ("q0"); +@states = ("q0"); $new_states = []; foreach my $char (split //, $string) { $new_states = []; @@ -46,10 +41,10 @@ foreach my $char (split //, $string) { } @states = @$new_states; } -%seen = (); +%seen = (); @states = grep { !$seen{$_}++ } @states; $answer = (grep { $_ eq "q2" } @states) ? "Accept" : "Reject"; -$popup = PopUp(['Choose...','Accept', 'Reject'], $answer); +$popup = PopUp([ 'Choose...', 'Accept', 'Reject' ], $answer); BEGIN_PGML Consider an NFA over the alphabet \{0, 1\}. The NFA has states [` q_0 `], [` q_1 `], [` q_2 `]. The transition table is: @@ -70,4 +65,8 @@ Given the input string [$string], what is the outcome? [________]{$popup} END_PGML -ENDDOCUMENT(); \ No newline at end of file +BEGIN_PGML_SOLUTION +Does the string [$string] belongs to the language? [$popup] +END_PGML_SOLUTION + +ENDDOCUMENT();