math-exercises 3.0.202 → 3.0.204

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/lib/exercises/exercise.d.ts +4 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.js +1 -1
  4. package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.js +1 -1
  5. package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.d.ts.map +1 -1
  6. package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +1 -1
  7. package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
  8. package/lib/exercises/math/derivation/variations/index.js +1 -0
  9. package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.d.ts +9 -0
  10. package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.d.ts.map +1 -0
  11. package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.js +191 -0
  12. package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.d.ts +9 -0
  13. package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.d.ts.map +1 -0
  14. package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.js +176 -0
  15. package/lib/exercises/math/functions/continuity/index.d.ts +6 -0
  16. package/lib/exercises/math/functions/continuity/index.d.ts.map +1 -0
  17. package/lib/exercises/math/functions/continuity/index.js +5 -0
  18. package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.d.ts +9 -0
  19. package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.d.ts.map +1 -0
  20. package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.js +193 -0
  21. package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.d.ts +10 -0
  22. package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.d.ts.map +1 -0
  23. package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.js +150 -0
  24. package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.d.ts +9 -0
  25. package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.d.ts.map +1 -0
  26. package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.js +162 -0
  27. package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.d.ts +8 -0
  28. package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.d.ts.map +1 -0
  29. package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.js +194 -0
  30. package/lib/exercises/math/functions/index.d.ts +1 -0
  31. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  32. package/lib/exercises/math/functions/index.js +1 -0
  33. package/lib/exercises/math/functions/variations/index.d.ts.map +1 -1
  34. package/lib/exercises/math/functions/variations/index.js +1 -0
  35. package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.d.ts +9 -0
  36. package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.d.ts.map +1 -0
  37. package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.js +183 -0
  38. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts.map +1 -1
  39. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.js +172 -51
  40. package/lib/exercises/math/geometry/angles/index.d.ts +1 -0
  41. package/lib/exercises/math/geometry/angles/index.d.ts.map +1 -1
  42. package/lib/exercises/math/geometry/angles/index.js +1 -1
  43. package/lib/exercises/math/limits/index.d.ts +1 -5
  44. package/lib/exercises/math/limits/index.d.ts.map +1 -1
  45. package/lib/exercises/math/limits/index.js +1 -5
  46. package/lib/exercises/math/limits/limitReading.d.ts.map +1 -1
  47. package/lib/exercises/math/limits/limitReading.js +70 -0
  48. package/lib/exercises/math/limits/polynomLimit.d.ts.map +1 -1
  49. package/lib/exercises/math/limits/polynomLimit.js +55 -4
  50. package/lib/exercises/math/limits/polynomLimitNoFI.d.ts.map +1 -1
  51. package/lib/exercises/math/limits/polynomLimitNoFI.js +35 -2
  52. package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts.map +1 -1
  53. package/lib/exercises/math/limits/sequenceGeometricLimit.js +45 -9
  54. package/lib/exercises/math/limits/sequencePolynomLimit.d.ts.map +1 -1
  55. package/lib/exercises/math/limits/sequencePolynomLimit.js +56 -3
  56. package/lib/exercises/math/limits/sequencePolynomNoFILimit.d.ts.map +1 -1
  57. package/lib/exercises/math/limits/sequencePolynomNoFILimit.js +32 -0
  58. package/lib/exercises/math/limits/sequencePolynomProductLimit.d.ts.map +1 -1
  59. package/lib/exercises/math/limits/sequencePolynomProductLimit.js +33 -3
  60. package/lib/exercises/math/limits/sequenceRationalFracLimit.d.ts.map +1 -1
  61. package/lib/exercises/math/limits/sequenceRationalFracLimit.js +2 -2
  62. package/lib/exercises/math/limits/sequences/index.d.ts +6 -0
  63. package/lib/exercises/math/limits/sequences/index.d.ts.map +1 -0
  64. package/lib/exercises/math/limits/sequences/index.js +5 -0
  65. package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.d.ts +9 -0
  66. package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.d.ts.map +1 -0
  67. package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.js +110 -0
  68. package/lib/exercises/math/limits/sequences/sequencePolynomLimit.d.ts +7 -0
  69. package/lib/exercises/math/limits/sequences/sequencePolynomLimit.d.ts.map +1 -0
  70. package/lib/exercises/math/limits/sequences/sequencePolynomLimit.js +116 -0
  71. package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.d.ts +7 -0
  72. package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.d.ts.map +1 -0
  73. package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.js +95 -0
  74. package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.d.ts +8 -0
  75. package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.d.ts.map +1 -0
  76. package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.js +111 -0
  77. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts +8 -0
  78. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts.map +1 -0
  79. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.js +114 -0
  80. package/lib/exercises/math/sequences/index.d.ts +1 -0
  81. package/lib/exercises/math/sequences/index.d.ts.map +1 -1
  82. package/lib/exercises/math/sequences/index.js +1 -0
  83. package/lib/exercises/math/sequences/proofByInduction/index.d.ts +5 -0
  84. package/lib/exercises/math/sequences/proofByInduction/index.d.ts.map +1 -0
  85. package/lib/exercises/math/sequences/proofByInduction/index.js +4 -0
  86. package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.d.ts +10 -0
  87. package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.d.ts.map +1 -0
  88. package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.js +236 -0
  89. package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.d.ts +13 -0
  90. package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.d.ts.map +1 -0
  91. package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.js +244 -0
  92. package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.d.ts +98 -0
  93. package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.d.ts.map +1 -0
  94. package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.js +175 -0
  95. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.d.ts +13 -0
  96. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.d.ts.map +1 -0
  97. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.js +317 -0
  98. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts +13 -0
  99. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts.map +1 -0
  100. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.js +265 -0
  101. package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -1
  102. package/lib/exercises/vea/polynomialVEA.js +4 -0
  103. package/lib/index.d.ts +68 -13
  104. package/lib/index.d.ts.map +1 -1
  105. package/lib/math/geometry/point.d.ts.map +1 -1
  106. package/lib/math/geometry/point.js +1 -1
  107. package/lib/math/utils/functions/functionDecomposition.d.ts +2 -2
  108. package/lib/math/utils/functions/functionDecomposition.d.ts.map +1 -1
  109. package/lib/tests/exoTest.d.ts.map +1 -1
  110. package/lib/tests/exoTest.js +7 -11
  111. package/lib/tests/questionTest.d.ts.map +1 -1
  112. package/lib/tests/questionTest.js +7 -3
  113. package/lib/tests/singleExo.test.d.ts.map +1 -1
  114. package/lib/tests/singleExo.test.js +2 -2
  115. package/lib/tree/nodes/node.d.ts +2 -1
  116. package/lib/tree/nodes/node.d.ts.map +1 -1
  117. package/lib/tree/nodes/node.js +1 -0
  118. package/lib/tree/nodes/student/iDontKnowNode.d.ts +26 -0
  119. package/lib/tree/nodes/student/iDontKnowNode.d.ts.map +1 -0
  120. package/lib/tree/nodes/student/iDontKnowNode.js +63 -0
  121. package/lib/tree/parsers/latexParser.d.ts +3 -2
  122. package/lib/tree/parsers/latexParser.d.ts.map +1 -1
  123. package/lib/tree/parsers/latexParser.js +7 -0
  124. package/lib/tree/parsers/monomParser.d.ts +1 -1
  125. package/lib/tree/parsers/monomParser.d.ts.map +1 -1
  126. package/lib/tree/parsers/polynomialParser.d.ts +1 -1
  127. package/lib/tree/parsers/polynomialParser.d.ts.map +1 -1
  128. package/lib/tree/parsers/trinomParser.d.ts +1 -1
  129. package/lib/tree/parsers/trinomParser.d.ts.map +1 -1
  130. package/lib/tree/utilities/nodeComparator.d.ts +3 -1
  131. package/lib/tree/utilities/nodeComparator.d.ts.map +1 -1
  132. package/lib/tree/utilities/nodeComparator.js +63 -5
  133. package/package.json +1 -1
@@ -0,0 +1,317 @@
1
+ import { tryToAddWrongProp, addValidProp, shuffleProps, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { EqualNode, isEqualNode, } from "../../../../tree/nodes/equations/equalNode.js";
6
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
7
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
9
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
10
+ import { NodeComparator } from "../../../../tree/utilities/nodeComparator.js";
11
+ import { randomMany } from "../../../../utils/alea/random.js";
12
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
+ import { getArrProofByInductionSituationParams, getHydratedProofByInductionSituation, } from "./proofByInductionSituations.js";
14
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
15
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
16
+ import { splitAndKeep } from "../../../../utils/strings/splitAndKeep.js";
17
+ import { isFractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
18
+ import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
19
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
20
+ const getHydrated = (identifiers) => {
21
+ const { situationParams, isValid, indexForNodeProperty, nodeIdsVarStepDefinition, nodeIdsVarStepInduction, } = identifiers;
22
+ const situation = getHydratedProofByInductionSituation(situationParams);
23
+ const [nodeVarStepDefinition, nodeVarStepInduction] = [
24
+ nodeIdsVarStepDefinition,
25
+ nodeIdsVarStepInduction,
26
+ ].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
27
+ switch (situation.id) {
28
+ case "generalFormulaOfArithmeticoGeometricSequence": {
29
+ const { nodeA, nodeB } = situation;
30
+ function createNodeBySubstitutingVar(nodeCarrier, nodeInjected, variableNodeOfCarrier) {
31
+ return nodeBySubstitutingVar(nodeBySubstitutingVar(nodeBySubstitutingVar(nodeCarrier, nodeInjected, variableNodeOfCarrier), new VariableNode(`u_{${add(nodeInjected, 1).toTex()}}`), new VariableNode(`u_{${add(variableNodeOfCarrier, 1).toTex()}}`)), new VariableNode(`u_{${nodeInjected.toTex()}}`), new VariableNode(`u_{${variableNodeOfCarrier.toTex()}}`));
32
+ }
33
+ const nodePropertyWithN = (isValid ? situation.arrNodeValid : situation.arrNodeInvalid)[indexForNodeProperty];
34
+ const [nodePropertyDefinition, nodePropertyDefinitionPlus1, nodePropertyInduction, nodePropertyInductionPlus1,] = [
35
+ nodeVarStepDefinition,
36
+ add(nodeVarStepDefinition, 1),
37
+ nodeVarStepInduction,
38
+ add(nodeVarStepInduction, 1),
39
+ ].map((node) => createNodeBySubstitutingVar(nodePropertyWithN, node, new VariableNode("n")));
40
+ const nodeSequenceDefinition = new EqualNode(new VariableNode(`u_{${add(nodeVarStepDefinition, 1).toTex()}}`), add(multiply(nodeA, new VariableNode(`u_{${nodeVarStepDefinition.toTex()}}`)), nodeB));
41
+ const nodeSequenceDefinitionMinus1 = new EqualNode(new VariableNode(`u_{${nodeVarStepDefinition.toTex()}}`), add(multiply(nodeA, new VariableNode(`u_{${substract(nodeVarStepDefinition, 1).toTex()}}`)), nodeB));
42
+ const arrNodeInductionSteps = [
43
+ //by def:
44
+ createNodeBySubstitutingVar(nodeSequenceDefinition, nodeVarStepInduction, nodeVarStepDefinition),
45
+ //subst by using induction property
46
+ nodeBySubstitutingVar(nodeBySubstitutingVar(nodeSequenceDefinition, nodePropertyInduction.rightChild, new VariableNode(`u_{${nodeVarStepDefinition.toTex()}}`)), new VariableNode(`u_{${add(nodeVarStepInduction, 1).toTex()}}`), new VariableNode(`u_{${add(nodeVarStepDefinition, 1).toTex()}}`)),
47
+ //rewrite to exhibit induction + 1
48
+ nodePropertyInductionPlus1,
49
+ ];
50
+ return {
51
+ situation,
52
+ nodeVarStepDefinition,
53
+ nodeSequenceDefinition,
54
+ nodeVarStepInduction,
55
+ nodePropertyInduction,
56
+ nodePropertyDefinition,
57
+ nodePropertyDefinitionPlus1,
58
+ nodePropertyInductionPlus1,
59
+ arrNodeInductionSteps,
60
+ nodeSequenceDefinitionMinus1,
61
+ };
62
+ }
63
+ default:
64
+ throw new Error("Unsupported situation.id: " + situation.id);
65
+ }
66
+ };
67
+ const getInstruction = (identifiers) => {
68
+ const { situation, nodePropertyDefinition, nodeVarStepDefinition, nodeVarStepInduction, arrNodeInductionSteps, } = getHydrated(identifiers);
69
+ const { n0 } = situation;
70
+ switch (situation.id) {
71
+ case "generalFormulaOfArithmeticoGeometricSequence": {
72
+ return `${situation.strContext}
73
+
74
+ Pour $${nodeVarStepDefinition.toTex()} \\geq ${n0}$, on note $\\mathcal{P}(${nodeVarStepDefinition.toTex()})$ la propriété :
75
+
76
+ $$
77
+ \\mathcal{P}(${nodeVarStepDefinition.toTex()}) :\\ \\ ${nodePropertyDefinition.toTex()}
78
+ $$
79
+
80
+ Donner l'étape manquante de la démonstration de l'hérédité de $\\mathcal{P}$ :
81
+
82
+ Soit $${nodeVarStepInduction.toTex()}$ un entier tel que $${nodeVarStepInduction.toTex()} \\geq ${n0}$.
83
+ On suppose la propriété $\\mathcal{P}(${nodeVarStepInduction.toTex()})$ vraie.
84
+
85
+ ${alignTex([
86
+ arrNodeInductionSteps[0],
87
+ new VariableNode("..."),
88
+ arrNodeInductionSteps[2],
89
+ ].map((node) => splitAndKeep(node.toTex(), "=")))}
90
+
91
+ `;
92
+ }
93
+ default:
94
+ throw new Error("Unsupported situation.id: " + situation.id);
95
+ }
96
+ };
97
+ const getAnswerNode = (identifiers) => {
98
+ const { arrNodeInductionSteps } = getHydrated(identifiers);
99
+ return arrNodeInductionSteps[1];
100
+ };
101
+ const getAnswer = (identifiers) => {
102
+ return getAnswerNode(identifiers).toTex();
103
+ };
104
+ const getHint = (identifiers) => {
105
+ const { nodeIdsVarStepInduction } = identifiers;
106
+ const [nodeVarStepInduction] = [nodeIdsVarStepInduction].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
107
+ return `Utilise $\\mathcal{P}(${nodeVarStepInduction.toTex()})$ pour substituer $u_{${nodeVarStepInduction.toTex()}}$ dans l'égalité juste avant l'étape manquante.`;
108
+ };
109
+ const getCorrection = (identifiers) => {
110
+ const { situation, nodeVarStepInduction, arrNodeInductionSteps } = getHydrated(identifiers);
111
+ const { n0 } = situation;
112
+ switch (situation.id) {
113
+ case "generalFormulaOfArithmeticoGeometricSequence": {
114
+ return `Voici la rédaction complète de la démonstration de l'hérédité de $\\mathcal{P}$ :
115
+
116
+ Soit $${nodeVarStepInduction.toTex()}$ un entier tel que $${nodeVarStepInduction.toTex()} \\geq ${n0}$.
117
+ On suppose la propriété $\\mathcal{P}(${nodeVarStepInduction.toTex()})$ vraie.
118
+
119
+ Par définition :
120
+
121
+ $$
122
+ ${arrNodeInductionSteps[0].toTex()}
123
+ $$
124
+
125
+ On utilise $\\mathcal{P}(${nodeVarStepInduction.toTex()})$ :
126
+
127
+ $$
128
+ ${arrNodeInductionSteps[1].toTex()}
129
+ $$
130
+
131
+ On réécrit l'égalité pour faire apparaître $\\mathcal{P}(${add(nodeVarStepInduction, 1).toTex()})$ :
132
+
133
+ $$
134
+ ${arrNodeInductionSteps[2].toTex()}
135
+ $$
136
+
137
+ On vient de montrer que si $\\mathcal{P}(${nodeVarStepInduction.toTex()})$ est vraie alors $\\mathcal{P}(${add(nodeVarStepInduction, 1).toTex()})$ est vraie,
138
+ autrement dit que $\\mathcal{P}$ est héréditaire.
139
+
140
+ `;
141
+ }
142
+ default:
143
+ throw new Error("Unsupported situation.id: " + situation.id);
144
+ }
145
+ };
146
+ const getPropositions = (n, { answer, ...identifiers }) => {
147
+ const propositions = [];
148
+ addValidProp(propositions, answer);
149
+ const { nodeSequenceDefinition, nodePropertyDefinition, nodeSequenceDefinitionMinus1, nodeVarStepDefinition, nodeVarStepInduction, arrNodeInductionSteps, } = getHydrated(identifiers);
150
+ //student: uses def prop again
151
+ {
152
+ const equalNodeWrong = nodeBySubstitutingVar(nodeBySubstitutingVar(nodeSequenceDefinition, nodeSequenceDefinitionMinus1.rightChild, new VariableNode(`u_{${nodeVarStepDefinition.toTex()}}`)), new VariableNode(`u_{${add(nodeVarStepInduction, 1).toTex()}}`), new VariableNode(`u_{${add(nodeVarStepDefinition, 1).toTex()}}`));
153
+ tryToAddWrongProp(propositions, equalNodeWrong.toTex());
154
+ }
155
+ //student: wrong variable
156
+ {
157
+ const equalNodeWrong = nodeBySubstitutingVar(nodeBySubstitutingVar(nodeSequenceDefinition, nodePropertyDefinition.rightChild, new VariableNode(`u_{${nodeVarStepDefinition.toTex()}}`)), new VariableNode(`u_{${add(nodeVarStepInduction, 1).toTex()}}`), new VariableNode(`u_{${add(nodeVarStepDefinition, 1).toTex()}}`));
158
+ tryToAddWrongProp(propositions, equalNodeWrong.toTex());
159
+ }
160
+ //student: forgets to add b
161
+ {
162
+ const equalNodeValid = arrNodeInductionSteps[1];
163
+ const equalNodeWrong = new EqualNode(equalNodeValid.leftChild, equalNodeValid.rightChild.leftChild);
164
+ tryToAddWrongProp(propositions, equalNodeWrong.toTex());
165
+ }
166
+ return shuffleProps(propositions, n);
167
+ };
168
+ const getKeys = (identifiers) => {
169
+ const { nodeIdsVarStepDefinition, nodeIdsVarStepInduction } = identifiers;
170
+ const [nodeVarStepDefinition, nodeVarStepInduction] = [
171
+ nodeIdsVarStepDefinition,
172
+ nodeIdsVarStepInduction,
173
+ ].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
174
+ const arrLetter = [nodeVarStepDefinition, nodeVarStepInduction].map((nodeVar) => nodeVar.name);
175
+ return ["u", ...arrLetter, "underscore", "equal"];
176
+ };
177
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
178
+ try {
179
+ //TODO faire fonctionner parseAlgebraic("u_n=3+2n") (token _ not implemented)
180
+ const nodeAnswer = getAnswerNode(identifiers);
181
+ if (!ans.includes("=")) {
182
+ // return false;
183
+ ans = nodeAnswer.leftChild.toTex() + "=" + ans;
184
+ }
185
+ // const nodeAns = parseAlgebraic(ans);
186
+ const nodeAns = (() => {
187
+ const [lhs, rhs] = ans.split("=");
188
+ const nodeLhs = lhs.toTree();
189
+ const nodeRhs = parseAlgebraic(rhs);
190
+ return new EqualNode(nodeLhs, nodeRhs);
191
+ })();
192
+ if (!isEqualNode(nodeAns)) {
193
+ return false;
194
+ }
195
+ const isValidLhs = () => nodeAns.leftChild.toTex() === nodeAnswer.leftChild.toTex();
196
+ const isValidRhs = () => {
197
+ const nodeAnsRhs = nodeAns.rightChild;
198
+ const nodeAnswerRhs = nodeAnswer.rightChild;
199
+ const { nodeIdsVarStepInduction } = identifiers;
200
+ const [nodeVarStepInduction] = [nodeIdsVarStepInduction].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
201
+ return NodeComparator.isEqualViaRandomEvaluations(nodeAnsRhs, nodeAnswerRhs, 3, 6, nodeVarStepInduction, () => randint(0, 20));
202
+ };
203
+ return isValidLhs() && isValidRhs();
204
+ }
205
+ catch (e) {
206
+ handleVEAError(e);
207
+ return false;
208
+ }
209
+ };
210
+ const createRandomIdentifiers = () => {
211
+ const [situationParams] = getArrProofByInductionSituationParams([
212
+ "generalFormulaOfArithmeticoGeometricSequence",
213
+ ]);
214
+ const [isValid, indexForNodeProperty] = [true, 0];
215
+ const [nodeVarStepDefinition, nodeVarStepInduction] = randomMany(["n", "k", "p", "m"], 2).map((letter) => new VariableNode(letter));
216
+ const identifiers = {
217
+ situationParams,
218
+ isValid,
219
+ indexForNodeProperty,
220
+ nodeIdsVarStepDefinition: nodeVarStepDefinition.toIdentifiers(),
221
+ nodeIdsVarStepInduction: nodeVarStepInduction.toIdentifiers(),
222
+ };
223
+ return identifiers;
224
+ };
225
+ const isIdentifiersQCPassed = (identifiers) => {
226
+ const isExploding = (identifiers) => {
227
+ let isExploding = false;
228
+ try {
229
+ //ensure r is an integer
230
+ {
231
+ const { situationParams } = identifiers;
232
+ const situation = getHydratedProofByInductionSituation(situationParams);
233
+ switch (situation.id) {
234
+ case "generalFormulaOfArithmeticoGeometricSequence":
235
+ {
236
+ const { nodeR, nodeInitial } = situation;
237
+ if (isFractionNode(nodeR) ||
238
+ isFractionNode(opposite(nodeR).simplify())) {
239
+ isExploding = true;
240
+ }
241
+ if (NodeComparator.isEqualViaSub(nodeInitial, nodeR)) {
242
+ isExploding = true;
243
+ }
244
+ }
245
+ break;
246
+ default:
247
+ throw new Error("Unsupported situation.id: " + situation.id);
248
+ }
249
+ }
250
+ getAnswer(identifiers);
251
+ }
252
+ catch (_) {
253
+ isExploding = true;
254
+ }
255
+ return isExploding;
256
+ };
257
+ return !isExploding(identifiers);
258
+ };
259
+ const createQCPassedIdentifiers = () => {
260
+ let identifiers;
261
+ let counter = -1;
262
+ let isValid = false;
263
+ while (!isValid && counter < 100) {
264
+ counter++;
265
+ const identifiersCandidate = createRandomIdentifiers();
266
+ isValid = isIdentifiersQCPassed(identifiersCandidate);
267
+ if (isValid) {
268
+ identifiers = identifiersCandidate;
269
+ }
270
+ }
271
+ if (!isValid) {
272
+ const [situationParams] = getArrProofByInductionSituationParams([
273
+ "generalFormulaOfArithmeticoGeometricSequence",
274
+ ]);
275
+ const [nodeVarStepDefinition, nodeVarStepInduction] = randomMany(["n", "k", "p", "m"], 2).map((letter) => new VariableNode(letter));
276
+ const identifiersDefault = (() => {
277
+ return {
278
+ situationParams,
279
+ isValid: true,
280
+ indexForNodeProperty: 0,
281
+ nodeIdsVarStepDefinition: nodeVarStepDefinition.toIdentifiers(),
282
+ nodeIdsVarStepInduction: nodeVarStepInduction.toIdentifiers(),
283
+ };
284
+ })();
285
+ identifiers = identifiersDefault;
286
+ }
287
+ return identifiers;
288
+ };
289
+ const getProofByInductionWriteMissingStepQuestion = () => {
290
+ const identifiers = createQCPassedIdentifiers();
291
+ return getQuestionFromIdentifiers(identifiers);
292
+ };
293
+ const getQuestionFromIdentifiers = (identifiers) => {
294
+ return {
295
+ answer: getAnswer(identifiers),
296
+ instruction: getInstruction(identifiers),
297
+ keys: getKeys(identifiers),
298
+ answerFormat: "tex",
299
+ identifiers,
300
+ hint: getHint(identifiers),
301
+ correction: getCorrection(identifiers),
302
+ };
303
+ };
304
+ export const proofByInductionWriteMissingStep = {
305
+ id: "proofByInductionWriteMissingStep",
306
+ connector: "=",
307
+ label: "Hérédité : Compléter une étape manquante",
308
+ isSingleStep: true,
309
+ generator: (nb, opts) => getDistinctQuestions(() => getProofByInductionWriteMissingStepQuestion(opts), nb),
310
+ qcmTimer: 60,
311
+ freeTimer: 60,
312
+ isAnswerValid,
313
+ getPropositions,
314
+ subject: "Mathématiques",
315
+ getQuestionFromIdentifiers,
316
+ hasHintAndCorrection: true,
317
+ };
@@ -0,0 +1,13 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ import { ProofByInductionSituationParams } from "./proofByInductionSituations.js";
4
+ type Identifiers = {
5
+ situationParams: ProofByInductionSituationParams;
6
+ isValid: boolean;
7
+ indexForNodeProperty: number;
8
+ nodeIdsVarStepDefinition: NodeIdentifiers;
9
+ nodeIdsVarStepInduction: NodeIdentifiers;
10
+ };
11
+ export declare const proofByInductionWritePropAtRankKPlus1: Exercise<Identifiers>;
12
+ export {};
13
+ //# sourceMappingURL=proofByInductionWritePropAtRankKPlus1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofByInductionWritePropAtRankKPlus1.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAQ7C,OAAO,EAGL,+BAA+B,EAChC,MAAM,iCAAiC,CAAC;AAMzC,KAAK,WAAW,GAAG;IACjB,eAAe,EAAE,+BAA+B,CAAC;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,wBAAwB,EAAE,eAAe,CAAC;IAC1C,uBAAuB,EAAE,eAAe,CAAC;CAC1C,CAAC;AAwWF,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAAC,WAAW,CAiBvE,CAAC"}
@@ -0,0 +1,265 @@
1
+ import { tryToAddWrongProp, addValidProp, shuffleProps, propWhile, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { EqualNode, isEqualNode, } from "../../../../tree/nodes/equations/equalNode.js";
6
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
7
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
9
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
10
+ import { NodeComparator } from "../../../../tree/utilities/nodeComparator.js";
11
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
12
+ import { randomMany } from "../../../../utils/alea/random.js";
13
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
+ import { getArrProofByInductionSituationParams, getHydratedProofByInductionSituation, } from "./proofByInductionSituations.js";
15
+ import { getCartesiansProducts } from "../../../../utils/arrays/cartesianProducts.js";
16
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
17
+ const getHydrated = (identifiers) => {
18
+ const { situationParams, isValid, indexForNodeProperty, nodeIdsVarStepDefinition, nodeIdsVarStepInduction, } = identifiers;
19
+ const situation = getHydratedProofByInductionSituation(situationParams);
20
+ const [nodeVarStepDefinition, nodeVarStepInduction] = [
21
+ nodeIdsVarStepDefinition,
22
+ nodeIdsVarStepInduction,
23
+ ].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
24
+ switch (situation.id) {
25
+ case "generalFormulaOfArithmeticoGeometricSequence": {
26
+ const nodePropertyWithN = (isValid ? situation.arrNodeValid : situation.arrNodeInvalid)[indexForNodeProperty];
27
+ function createNodePropertySubstituted(nodeInjected) {
28
+ return nodeBySubstitutingVar(nodeBySubstitutingVar(nodePropertyWithN, nodeInjected, new VariableNode("n")), new VariableNode(`u_{${nodeInjected.toTex()}}`), new VariableNode("u_{n}"));
29
+ }
30
+ const [nodePropertyDefinition, nodePropertyDefinitionPlus1, nodePropertyInduction, nodePropertyInductionPlus1,] = [
31
+ nodeVarStepDefinition,
32
+ add(nodeVarStepDefinition, 1),
33
+ nodeVarStepInduction,
34
+ add(nodeVarStepInduction, 1),
35
+ ].map((node) => createNodePropertySubstituted(node));
36
+ return {
37
+ situation,
38
+ isValid,
39
+ nodeVarStepDefinition,
40
+ nodePropertyDefinition,
41
+ nodePropertyDefinitionPlus1,
42
+ nodeVarStepInduction,
43
+ nodePropertyInduction,
44
+ nodePropertyInductionPlus1,
45
+ };
46
+ }
47
+ default:
48
+ throw new Error("Unsupported situation.id: " + situation.id);
49
+ }
50
+ };
51
+ const getInstruction = (identifiers) => {
52
+ const { situation, nodePropertyDefinition, nodeVarStepDefinition, nodeVarStepInduction, } = getHydrated(identifiers);
53
+ const { n0 } = situation;
54
+ switch (situation.id) {
55
+ case "generalFormulaOfArithmeticoGeometricSequence": {
56
+ return `${situation.strContext}
57
+
58
+ Pour $${nodeVarStepDefinition.toTex()} \\geq ${n0}$, on note $\\mathcal{P}(${nodeVarStepDefinition.toTex()})$ la propriété :
59
+
60
+ $$
61
+ \\mathcal{P}(${nodeVarStepDefinition.toTex()}) :\\ \\ ${nodePropertyDefinition.toTex()}
62
+ $$
63
+
64
+ Soit $${nodeVarStepInduction.toTex()}$ un entier tel que $${nodeVarStepInduction.toTex()} \\geq ${n0}$.
65
+ On suppose la propriété $\\mathcal{P}(${nodeVarStepInduction.toTex()})$ vraie.
66
+
67
+ Quelle est l'égalité qui correspond à la propriété $\\mathcal{P}(${add(nodeVarStepInduction, 1).toTex()})$ ?
68
+ `;
69
+ }
70
+ default:
71
+ throw new Error("Unsupported situation.id: " + situation.id);
72
+ }
73
+ };
74
+ const getAnswer = (identifiers) => {
75
+ const { nodePropertyInductionPlus1 } = getHydrated(identifiers);
76
+ return nodePropertyInductionPlus1.toTex();
77
+ };
78
+ const getHint = (identifiers) => {
79
+ const { nodeIdsVarStepInduction } = identifiers;
80
+ const [nodeVarStepInduction] = [nodeIdsVarStepInduction].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
81
+ return `Substitue $${nodeVarStepInduction.toTex()}$ par $${add(nodeVarStepInduction, 1).toTex()}$ dans l'égalité proposée.`;
82
+ };
83
+ const getCorrection = (identifiers) => {
84
+ const { situation, nodePropertyInductionPlus1, nodeVarStepInduction } = getHydrated(identifiers);
85
+ switch (situation.id) {
86
+ case "generalFormulaOfArithmeticoGeometricSequence": {
87
+ return `Pour vérifier que la propriété est héréditaire,
88
+ il faut démontrer que si on suppose $\\mathcal{P}(${nodeVarStepInduction.toTex()})$ vraie alors $\\mathcal{P}(${add(nodeVarStepInduction, 1).toTex()})$ est vraie.
89
+
90
+ On s'intéresse donc à $\\mathcal{P}(${add(nodeVarStepInduction, 1).toTex()})$,
91
+ autrement dit à l'égalité :
92
+
93
+ $$
94
+ ${nodePropertyInductionPlus1.toTex()}
95
+ $$
96
+
97
+ `;
98
+ }
99
+ default:
100
+ throw new Error("Unsupported situation.id: " + situation.id);
101
+ }
102
+ };
103
+ const getPropositions = (n, { answer, ...identifiers }) => {
104
+ const propositions = [];
105
+ addValidProp(propositions, answer);
106
+ const { nodePropertyDefinition, nodePropertyDefinitionPlus1, nodePropertyInduction, nodePropertyInductionPlus1, } = getHydrated(identifiers);
107
+ tryToAddWrongProp(propositions, nodePropertyDefinitionPlus1.toTex());
108
+ const [arrLhs, arrRhs] = [0, 1].map((i) => [
109
+ nodePropertyDefinition,
110
+ nodePropertyInduction,
111
+ nodePropertyInductionPlus1,
112
+ nodePropertyDefinitionPlus1,
113
+ ].map((equalNode) => i === 0 ? equalNode.leftChild : equalNode.rightChild));
114
+ const arrEqualNode = shuffle(getCartesiansProducts([arrLhs, arrRhs]).map(([nodeLhs, nodeRhs]) => new EqualNode(nodeLhs, nodeRhs)));
115
+ propWhile(propositions, n, () => {
116
+ const equalNodeWrong = arrEqualNode.pop();
117
+ tryToAddWrongProp(propositions, equalNodeWrong.toTex());
118
+ });
119
+ return shuffleProps(propositions, n);
120
+ };
121
+ const getKeys = (identifiers) => {
122
+ const { nodeIdsVarStepDefinition, nodeIdsVarStepInduction } = identifiers;
123
+ const [nodeVarStepDefinition, nodeVarStepInduction] = [
124
+ nodeIdsVarStepDefinition,
125
+ nodeIdsVarStepInduction,
126
+ ].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
127
+ const arrLetter = [nodeVarStepDefinition, nodeVarStepInduction].map((nodeVar) => nodeVar.name);
128
+ return ["u", ...arrLetter, "underscore", "equal"];
129
+ };
130
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
131
+ try {
132
+ //TODO faire fonctionner parseAlgebraic("u_n=3+2n") (token _ not implemented)
133
+ const nodeAnswer = getHydrated(identifiers)
134
+ .nodePropertyInductionPlus1;
135
+ if (!ans.includes("=")) {
136
+ // return false;
137
+ ans = nodeAnswer.leftChild.toTex() + "=" + ans;
138
+ }
139
+ // const nodeAns = parseAlgebraic(ans);
140
+ const nodeAns = (() => {
141
+ const [lhs, rhs] = ans.split("=");
142
+ const nodeLhs = lhs.toTree();
143
+ const nodeRhs = parseAlgebraic(rhs);
144
+ return new EqualNode(nodeLhs, nodeRhs);
145
+ })();
146
+ if (!isEqualNode(nodeAns)) {
147
+ return false;
148
+ }
149
+ const isValidLhs = () => nodeAns.leftChild.toTex() === nodeAnswer.leftChild.toTex();
150
+ const isValidRhs = () => {
151
+ const nodeAnsRhs = nodeAns.rightChild;
152
+ const nodeAnswerRhs = nodeAnswer.rightChild;
153
+ const { nodeIdsVarStepInduction } = identifiers;
154
+ const [nodeVarStepInduction] = [nodeIdsVarStepInduction].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
155
+ return NodeComparator.isEqualViaRandomEvaluations(nodeAnsRhs, nodeAnswerRhs, 3, 6, nodeVarStepInduction, () => randint(0, 20));
156
+ };
157
+ return isValidLhs() && isValidRhs();
158
+ }
159
+ catch (e) {
160
+ handleVEAError(e);
161
+ return false;
162
+ }
163
+ };
164
+ const createRandomIdentifiers = () => {
165
+ const [situationParams] = getArrProofByInductionSituationParams([
166
+ "generalFormulaOfArithmeticoGeometricSequence",
167
+ ]);
168
+ const situation = getHydratedProofByInductionSituation(situationParams);
169
+ const [isValid, indexForNodeProperty] = (() => {
170
+ switch (situation.id) {
171
+ case "generalFormulaOfArithmeticoGeometricSequence": {
172
+ const isValid = coinFlip();
173
+ const indexForNodeProperty = randint(0, isValid
174
+ ? situation.arrNodeValid.length
175
+ : situation.arrNodeInvalid.length);
176
+ return [isValid, indexForNodeProperty];
177
+ }
178
+ default:
179
+ throw new Error("Unsupported situation.id: " + situation.id);
180
+ }
181
+ })();
182
+ const [nodeVarStepDefinition, nodeVarStepInduction] = randomMany(["n", "k", "p", "m"], 2).map((letter) => new VariableNode(letter));
183
+ const identifiers = {
184
+ situationParams,
185
+ isValid,
186
+ indexForNodeProperty,
187
+ nodeIdsVarStepDefinition: nodeVarStepDefinition.toIdentifiers(),
188
+ nodeIdsVarStepInduction: nodeVarStepInduction.toIdentifiers(),
189
+ };
190
+ return identifiers;
191
+ };
192
+ // const isIdentifiersQCPassed = (identifiers: Identifiers) => {
193
+ // const isExploding = (identifiers: Identifiers) => {
194
+ // let isExploding = false;
195
+ // try {
196
+ // getAnswer(identifiers);
197
+ // } catch (_) {
198
+ // isExploding = true;
199
+ // }
200
+ // return isExploding;
201
+ // };
202
+ // return !isExploding(identifiers);
203
+ // };
204
+ // const createQCPassedIdentifiers = () => {
205
+ // let identifiers: Identifiers;
206
+ // let counter = -1;
207
+ // let isValid = false;
208
+ // while (!isValid && counter < 100) {
209
+ // counter++;
210
+ // const identifiersCandidate = createRandomIdentifiers();
211
+ // isValid = isIdentifiersQCPassed(identifiersCandidate);
212
+ // if (isValid) {
213
+ // identifiers = identifiersCandidate;
214
+ // }
215
+ // }
216
+ // if (!isValid) {
217
+ // const [situationParams] = getArrProofByInductionSituationParams([
218
+ // "generalFormulaOfArithmeticoGeometricSequence",
219
+ // ]);
220
+ // const [nodeVarStepDefinition, nodeVarStepInduction] = randomMany(
221
+ // ["n", "k", "p", "m"],
222
+ // 2,
223
+ // ).map((letter) => new VariableNode(letter));
224
+ // const identifiersDefault: Identifiers = (() => {
225
+ // return {
226
+ // situationParams,
227
+ // isValid: true,
228
+ // indexForNodeProperty: 0,
229
+ // nodeIdsVarStepDefinition: nodeVarStepDefinition.toIdentifiers(),
230
+ // nodeIdsVarStepInduction: nodeVarStepInduction.toIdentifiers(),
231
+ // };
232
+ // })();
233
+ // identifiers = identifiersDefault;
234
+ // }
235
+ // return identifiers!;
236
+ // };
237
+ const getProofByInductionWritePropAtRankKPlus1Question = () => {
238
+ const identifiers = createRandomIdentifiers();
239
+ return getQuestionFromIdentifiers(identifiers);
240
+ };
241
+ const getQuestionFromIdentifiers = (identifiers) => {
242
+ return {
243
+ answer: getAnswer(identifiers),
244
+ instruction: getInstruction(identifiers),
245
+ keys: getKeys(identifiers),
246
+ answerFormat: "tex",
247
+ identifiers,
248
+ hint: getHint(identifiers),
249
+ correction: getCorrection(identifiers),
250
+ };
251
+ };
252
+ export const proofByInductionWritePropAtRankKPlus1 = {
253
+ id: "proofByInductionWritePropAtRankKPlus1",
254
+ connector: "=",
255
+ label: "Hérédité : Écrire au rang $k+1$ une propriété donnée au rang $k$",
256
+ isSingleStep: true,
257
+ generator: (nb, opts) => getDistinctQuestions(() => getProofByInductionWritePropAtRankKPlus1Question(opts), nb),
258
+ qcmTimer: 60,
259
+ freeTimer: 60,
260
+ isAnswerValid,
261
+ getPropositions,
262
+ subject: "Mathématiques",
263
+ getQuestionFromIdentifiers,
264
+ hasHintAndCorrection: true,
265
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"polynomialVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/polynomialVEA.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,QAAQ,MAAM,YAmBxD,CAAC"}
1
+ {"version":3,"file":"polynomialVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/polynomialVEA.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,QAAQ,MAAM,YAuBxD,CAAC"}
@@ -1,11 +1,15 @@
1
1
  import { getArrNodeCoeffOfPolynomialNode } from "../../math/utils/polynomial/polynomialUtils.js";
2
2
  import { substract } from "../../tree/nodes/operators/substractNode.js";
3
+ import { isIDontKnowNode } from "../../tree/nodes/student/iDontKnowNode.js";
3
4
  import { parseAlgebraic } from "../../tree/parsers/latexParser.js";
4
5
  import { zip } from "../../utils/arrays/arrayZip.js";
5
6
  import { handleVEAError } from "../../utils/errors/handleVEAError.js";
6
7
  export const polynomialVEA = (ans, answer) => {
7
8
  try {
8
9
  const nodeAns = parseAlgebraic(ans);
10
+ if (isIDontKnowNode(nodeAns)) {
11
+ return false;
12
+ }
9
13
  const nodeAnswer = parseAlgebraic(answer);
10
14
  const [arrNodeCoeffAns, arrNodeCoeffAnswer] = [nodeAns, nodeAnswer].map((node) => getArrNodeCoeffOfPolynomialNode(node));
11
15
  return (arrNodeCoeffAns.length === arrNodeCoeffAnswer.length &&