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,244 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
3
+ import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
4
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
5
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
6
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
7
+ import { NodeComparator } from "../../../../tree/utilities/nodeComparator.js";
8
+ import { randomMany } from "../../../../utils/alea/random.js";
9
+ import { getArrProofByInductionSituationParams, getHydratedProofByInductionSituation, } from "./proofByInductionSituations.js";
10
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
11
+ import { isFractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
12
+ import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
13
+ import { uuid } from "uuidv4";
14
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
15
+ const getHydrated = (identifiers) => {
16
+ const { situationParams, isValid, indexForNodeProperty, nodeIdsVarStepDefinition, nodeIdsVarStepInduction, } = identifiers;
17
+ const situation = getHydratedProofByInductionSituation(situationParams);
18
+ const [nodeVarStepDefinition, nodeVarStepInduction] = [
19
+ nodeIdsVarStepDefinition,
20
+ nodeIdsVarStepInduction,
21
+ ].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
22
+ switch (situation.id) {
23
+ case "generalFormulaOfArithmeticoGeometricSequence": {
24
+ const { nodeA, nodeB, n0, nodeInitial } = situation;
25
+ function createNodeBySubstitutingVar(nodeCarrier, nodeInjected, variableNodeOfCarrier) {
26
+ 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()}}`));
27
+ }
28
+ const nodePropertyWithN = (isValid ? situation.arrNodeValid : situation.arrNodeInvalid)[indexForNodeProperty];
29
+ const [nodePropertyDefinition, nodePropertyInduction, nodePropertyInductionPlus1,] = [
30
+ nodeVarStepDefinition,
31
+ nodeVarStepInduction,
32
+ add(nodeVarStepInduction, 1),
33
+ ].map((node) => createNodeBySubstitutingVar(nodePropertyWithN, node, new VariableNode("n")));
34
+ const nodeSequenceDefinition = new EqualNode(new VariableNode(`u_{${add(nodeVarStepDefinition, 1).toTex()}}`), add(multiply(nodeA, new VariableNode(`u_{${nodeVarStepDefinition.toTex()}}`)), nodeB));
35
+ const arrNodeBaseCaseSteps = [
36
+ new EqualNode(new EqualNode(nodeBySubstitutingVar(nodePropertyWithN.rightChild, n0.toTree(), new VariableNode("n")), nodeInitial), new VariableNode(`u_{${n0}}`)),
37
+ ];
38
+ const arrNodeInductionSteps = [
39
+ //by def:
40
+ createNodeBySubstitutingVar(nodeSequenceDefinition, nodeVarStepInduction, nodeVarStepDefinition),
41
+ //subst by using induction property
42
+ nodeBySubstitutingVar(nodeBySubstitutingVar(nodeSequenceDefinition, nodePropertyInduction.rightChild, new VariableNode(`u_{${nodeVarStepDefinition.toTex()}}`)), new VariableNode(`u_{${add(nodeVarStepInduction, 1).toTex()}}`), new VariableNode(`u_{${add(nodeVarStepDefinition, 1).toTex()}}`)),
43
+ //rewrite to exhibit induction + 1
44
+ nodePropertyInductionPlus1,
45
+ ];
46
+ return {
47
+ situation,
48
+ nodeVarStepDefinition,
49
+ nodeSequenceDefinition,
50
+ nodeVarStepInduction,
51
+ nodePropertyInduction,
52
+ nodePropertyDefinition,
53
+ nodePropertyInductionPlus1,
54
+ arrNodeBaseCaseSteps,
55
+ arrNodeInductionSteps,
56
+ };
57
+ }
58
+ default:
59
+ throw new Error("Unsupported situation.id: " + situation.id);
60
+ }
61
+ };
62
+ const getInstruction = (identifiers) => {
63
+ const { situation, nodePropertyDefinition, nodeVarStepDefinition } = getHydrated(identifiers);
64
+ const { n0 } = situation;
65
+ switch (situation.id) {
66
+ case "generalFormulaOfArithmeticoGeometricSequence": {
67
+ return `${situation.strContext}
68
+
69
+ Pour $${nodeVarStepDefinition.toTex()} \\geq ${n0}$, on note $\\mathcal{P}(${nodeVarStepDefinition.toTex()})$ la propriété :
70
+
71
+ $$
72
+ \\mathcal{P}(${nodeVarStepDefinition.toTex()}) :\\ \\ ${nodePropertyDefinition.toTex()}
73
+ $$
74
+
75
+ On veut démontrer que, pour tout $${nodeVarStepDefinition.toTex()} \\geq ${n0}$, $\\mathcal{P}(${nodeVarStepDefinition.toTex()})$ est vraie.
76
+
77
+ Reconstruire la démonstration par récurrence en réordonnant les éléments.`;
78
+ }
79
+ default:
80
+ throw new Error("Unsupported situation.id: " + situation.id);
81
+ }
82
+ };
83
+ const getHint = (identifiers) => {
84
+ const { nodeIdsVarStepInduction } = identifiers;
85
+ const [nodeVarStepInduction] = [nodeIdsVarStepInduction].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
86
+ return `Une démonstration par récurrence d'une propriété $\\mathcal{P}$ s'écrit en $3$ étapes :
87
+ - l'initialisation, où l'on s'assure que $\\mathcal{P}$ est vraie au rang initial
88
+ - l'hérédité, où l'on s'assure que,
89
+ pour un rang $${nodeVarStepInduction.toTex()}$ supérieur ou égal au rang initial,
90
+ si $\\mathcal{P}(${nodeVarStepInduction.toTex()})$ est vraie
91
+ alors $\\mathcal(${add(nodeVarStepInduction, 1).toTex()})$ est vraie
92
+ - la conclusion, où l'on déduit de l'initialisation et de l'hérédité que $\\mathcal{P}$ est vraie à partir du rang initial (jusqu'à l'infini)`;
93
+ };
94
+ const getCorrection = (identifiers) => {
95
+ const orderedItemsSorted = getOrderedItems(-1, {
96
+ answer: "",
97
+ ...identifiers,
98
+ }).sort((item1, item2) => item1.rightIndex - item2.rightIndex);
99
+ return `Voici le raisonnement par récurrence qu'il fallait reconstruire :
100
+
101
+
102
+ ${orderedItemsSorted.map((item) => item.statement).join(`
103
+
104
+ `)}`;
105
+ };
106
+ const getOrderedItems = (_n, { answer, ...identifiers }) => {
107
+ const { situationParams } = identifiers;
108
+ const orderedItems = (() => {
109
+ switch (situationParams.id) {
110
+ case "generalFormulaOfArithmeticoGeometricSequence": {
111
+ const { situation, nodeVarStepDefinition, nodeVarStepInduction, arrNodeBaseCaseSteps, arrNodeInductionSteps, } = getHydrated(identifiers);
112
+ const { n0 } = situation;
113
+ return [
114
+ "Initialisation :",
115
+ ...arrNodeBaseCaseSteps.map((node) => `$${node.toTex()}$`),
116
+ `donc $\\mathcal{P}(${n0})$ est vraie`,
117
+ "Hérédité :",
118
+ `Soit $${nodeVarStepInduction.toTex()}$ un entier tel que $${nodeVarStepInduction.toTex()} \\geq ${n0}$.`,
119
+ `On suppose la propriété $\\mathcal{P}(${nodeVarStepInduction.toTex()})$ vraie.`,
120
+ ...arrNodeInductionSteps.map((node) => `$${node.toTex()}$`),
121
+ `donc $\\mathcal{P}(${add(nodeVarStepInduction, 1).toTex()})$ est vraie`,
122
+ `donc $\\mathcal{P}$ est héréditaire`,
123
+ "Conclusion :",
124
+ `Pour tout $${nodeVarStepDefinition.toTex()} \\geq ${n0}$, $\\mathcal{P}(${nodeVarStepDefinition.toTex()})$ est vraie.`,
125
+ ].map((statement, i) => ({
126
+ id: uuid(),
127
+ statement: statement,
128
+ rightIndex: i,
129
+ format: "raw",
130
+ }));
131
+ }
132
+ default:
133
+ throw new Error("Unsupported situationParams.id: " + situationParams.id);
134
+ }
135
+ })();
136
+ return shuffle(orderedItems);
137
+ };
138
+ const createRandomIdentifiers = () => {
139
+ const [situationParams] = getArrProofByInductionSituationParams([
140
+ "generalFormulaOfArithmeticoGeometricSequence",
141
+ ]);
142
+ const [isValid, indexForNodeProperty] = [true, 0];
143
+ const [nodeVarStepDefinition, nodeVarStepInduction] = randomMany(["n", "k", "p", "m"], 2).map((letter) => new VariableNode(letter));
144
+ const identifiers = {
145
+ situationParams,
146
+ isValid,
147
+ indexForNodeProperty,
148
+ nodeIdsVarStepDefinition: nodeVarStepDefinition.toIdentifiers(),
149
+ nodeIdsVarStepInduction: nodeVarStepInduction.toIdentifiers(),
150
+ };
151
+ return identifiers;
152
+ };
153
+ const isIdentifiersQCPassed = (identifiers) => {
154
+ const isExploding = (identifiers) => {
155
+ let isExploding = false;
156
+ try {
157
+ //ensure r is an integer
158
+ {
159
+ const { situationParams } = identifiers;
160
+ const situation = getHydratedProofByInductionSituation(situationParams);
161
+ switch (situation.id) {
162
+ case "generalFormulaOfArithmeticoGeometricSequence":
163
+ {
164
+ const { nodeR, nodeInitial } = situation;
165
+ if (isFractionNode(nodeR) ||
166
+ isFractionNode(opposite(nodeR).simplify())) {
167
+ isExploding = true;
168
+ }
169
+ if (NodeComparator.isEqualViaSub(nodeInitial, nodeR)) {
170
+ isExploding = true;
171
+ }
172
+ }
173
+ break;
174
+ default:
175
+ throw new Error("Unsupported situation.id: " + situation.id);
176
+ }
177
+ }
178
+ // getAnswer(identifiers);
179
+ }
180
+ catch (_) {
181
+ isExploding = true;
182
+ }
183
+ return isExploding;
184
+ };
185
+ return !isExploding(identifiers);
186
+ };
187
+ const createQCPassedIdentifiers = () => {
188
+ let identifiers;
189
+ let counter = -1;
190
+ let isValid = false;
191
+ while (!isValid && counter < 100) {
192
+ counter++;
193
+ const identifiersCandidate = createRandomIdentifiers();
194
+ isValid = isIdentifiersQCPassed(identifiersCandidate);
195
+ if (isValid) {
196
+ identifiers = identifiersCandidate;
197
+ }
198
+ }
199
+ if (!isValid) {
200
+ const [situationParams] = getArrProofByInductionSituationParams([
201
+ "generalFormulaOfArithmeticoGeometricSequence",
202
+ ]);
203
+ const [nodeVarStepDefinition, nodeVarStepInduction] = randomMany(["n", "k", "p", "m"], 2).map((letter) => new VariableNode(letter));
204
+ const identifiersDefault = (() => {
205
+ return {
206
+ situationParams,
207
+ isValid: true,
208
+ indexForNodeProperty: 0,
209
+ nodeIdsVarStepDefinition: nodeVarStepDefinition.toIdentifiers(),
210
+ nodeIdsVarStepInduction: nodeVarStepInduction.toIdentifiers(),
211
+ };
212
+ })();
213
+ identifiers = identifiersDefault;
214
+ }
215
+ return identifiers;
216
+ };
217
+ const getProofByInductionReorderProofQuestion = () => {
218
+ const identifiers = createQCPassedIdentifiers();
219
+ return getQuestionFromIdentifiers(identifiers);
220
+ };
221
+ const getQuestionFromIdentifiers = (identifiers) => {
222
+ return {
223
+ instruction: getInstruction(identifiers),
224
+ answerFormat: "tex",
225
+ keys: [],
226
+ identifiers,
227
+ hint: getHint(identifiers),
228
+ correction: getCorrection(identifiers),
229
+ };
230
+ };
231
+ export const proofByInductionReorderProof = {
232
+ id: "proofByInductionReorderProof",
233
+ connector: "=",
234
+ label: "Reconstruire une démonstration par récurrence",
235
+ isSingleStep: true,
236
+ generator: (nb, opts) => getDistinctQuestions(() => getProofByInductionReorderProofQuestion(opts), nb),
237
+ qcmTimer: 60,
238
+ freeTimer: 60,
239
+ answerType: "reorder",
240
+ getOrderedItems,
241
+ subject: "Mathématiques",
242
+ getQuestionFromIdentifiers,
243
+ hasHintAndCorrection: true,
244
+ };
@@ -0,0 +1,98 @@
1
+ import { AlgebraicNode } from "../../../../tree/nodes/algebraicNode.js";
2
+ import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
3
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
4
+ import { KeyId } from "../../../../types/keyIds.js";
5
+ import { KeyProps } from "../../../../types/keyProps.js";
6
+ export type ProofByInductionSituationParams = (GeneralFormulaOfArithmeticoGeometricSequenceParams & {
7
+ id: "generalFormulaOfArithmeticoGeometricSequence";
8
+ }) | (MultipleFromPolynomialParams & {
9
+ id: "multipleFromPolynomial";
10
+ });
11
+ export type ProofByInductionSituation = {
12
+ id: string;
13
+ strContext: string;
14
+ n0: number;
15
+ baseCase: string;
16
+ inductionHypothesis: string;
17
+ inductionStep: string;
18
+ conclusion: string;
19
+ keys: (KeyId | KeyProps)[];
20
+ params: ProofByInductionSituationParams;
21
+ arrNodeValid: AlgebraicNode[];
22
+ arrNodeInvalid: AlgebraicNode[];
23
+ };
24
+ type GeneralFormulaOfArithmeticoGeometricSequenceParams = {
25
+ n0: number;
26
+ nodeIdsInitial: NodeIdentifiers;
27
+ nodeIdsA: NodeIdentifiers;
28
+ nodeIdsB: NodeIdentifiers;
29
+ };
30
+ export declare const getGeneralFormulaOfArithmeticoGeometricSequenceSituation: (params: ProofByInductionSituationParams) => {
31
+ id: string;
32
+ strContext: string;
33
+ n0: number;
34
+ baseCase: string;
35
+ inductionHypothesis: string;
36
+ inductionStep: string;
37
+ conclusion: string;
38
+ keys: never[];
39
+ params: ProofByInductionSituationParams;
40
+ arrNodeValid: EqualNode[];
41
+ arrNodeInvalid: EqualNode[];
42
+ nodeA: AlgebraicNode;
43
+ nodeB: AlgebraicNode;
44
+ nodeR: AlgebraicNode;
45
+ nodeInitial: AlgebraicNode;
46
+ };
47
+ type MultipleFromPolynomialParams = {
48
+ n0: number;
49
+ isValid: boolean;
50
+ nbMod: number;
51
+ arrValueRoot: number[];
52
+ };
53
+ export declare const getMultipleFromPolynomialSituation: (params: ProofByInductionSituationParams) => {
54
+ id: string;
55
+ strContext: string;
56
+ n0: number;
57
+ baseCase: string;
58
+ inductionHypothesis: string;
59
+ inductionStep: string;
60
+ conclusion: string;
61
+ keys: never[];
62
+ params: ProofByInductionSituationParams;
63
+ arrNodeValid: AlgebraicNode[];
64
+ arrNodeInvalid: AlgebraicNode[];
65
+ };
66
+ export declare const getHydratedProofByInductionSituation: (params: ProofByInductionSituationParams) => {
67
+ id: string;
68
+ strContext: string;
69
+ n0: number;
70
+ baseCase: string;
71
+ inductionHypothesis: string;
72
+ inductionStep: string;
73
+ conclusion: string;
74
+ keys: never[];
75
+ params: ProofByInductionSituationParams;
76
+ arrNodeValid: EqualNode[];
77
+ arrNodeInvalid: EqualNode[];
78
+ nodeA: AlgebraicNode;
79
+ nodeB: AlgebraicNode;
80
+ nodeR: AlgebraicNode;
81
+ nodeInitial: AlgebraicNode;
82
+ } | {
83
+ id: string;
84
+ strContext: string;
85
+ n0: number;
86
+ baseCase: string;
87
+ inductionHypothesis: string;
88
+ inductionStep: string;
89
+ conclusion: string;
90
+ keys: never[];
91
+ params: ProofByInductionSituationParams;
92
+ arrNodeValid: AlgebraicNode[];
93
+ arrNodeInvalid: AlgebraicNode[];
94
+ };
95
+ export declare const getRandomProofByInductionSituationParams: () => ProofByInductionSituationParams;
96
+ export declare const getArrProofByInductionSituationParams: (arrId: string[]) => ProofByInductionSituationParams[];
97
+ export {};
98
+ //# sourceMappingURL=proofByInductionSituations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofByInductionSituations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/proofByInduction/proofByInductionSituations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAWnD,MAAM,MAAM,+BAA+B,GACvC,CAAC,kDAAkD,GAAG;IACpD,EAAE,EAAE,8CAA8C,CAAC;CACpD,CAAC,GAEF,CAAC,4BAA4B,GAAG;IAAE,EAAE,EAAE,wBAAwB,CAAA;CAAE,CAAC,CAAC;AAEtE,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IAEX,UAAU,EAAE,MAAM,CAAC;IAEnB,EAAE,EAAE,MAAM,CAAC;IAEX,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IAEnB,IAAI,EAAE,CAAC,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC;IAC3B,MAAM,EAAE,+BAA+B,CAAC;IAGxC,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,cAAc,EAAE,aAAa,EAAE,CAAC;CACjC,CAAC;AAWF,KAAK,kDAAkD,GAAG;IACxD,EAAE,EAAE,MAAM,CAAC;IAEX,cAAc,EAAE,eAAe,CAAC;IAChC,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAoBF,eAAO,MAAM,wDAAwD,GACnE,QAAQ,+BAA+B;;;;;;;;;;;;;;;;CAmKxC,CAAC;AAuKF,KAAK,4BAA4B,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IAEX,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAmBF,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,+BAA+B;;;;;;;;;;;;CA8CxC,CAAC;AAEF,eAAO,MAAM,oCAAoC,GAC/C,QAAQ,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQxC,CAAC;AAEF,eAAO,MAAM,wCAAwC,QAC/C,+BAYH,CAAC;AAEJ,eAAO,MAAM,qCAAqC,GAChD,OAAO,MAAM,EAAE,KACd,+BAA+B,EAYjC,CAAC"}
@@ -0,0 +1,175 @@
1
+ import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
2
+ import { randint } from "../../../../math/utils/random/randint.js";
3
+ import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
4
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
5
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
6
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { power } from "../../../../tree/nodes/operators/powerNode.js";
9
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
11
+ import { NodeComparator } from "../../../../tree/utilities/nodeComparator.js";
12
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
13
+ import { random } from "../../../../utils/alea/random.js";
14
+ const buildGeneralFormulaOfArithmeticoGeometricSequenceParams = () => {
15
+ const n0 = randint(0, 3);
16
+ const valueInitial = randint(-5, 6, [0]);
17
+ const a = randint(-5, 6, [0, 1, valueInitial]);
18
+ const b = randint(-5, 6, [0, valueInitial, a]);
19
+ const nodeInitial = valueInitial.toTree();
20
+ const nodeA = a.toTree();
21
+ const nodeB = b.toTree();
22
+ return {
23
+ n0,
24
+ nodeIdsInitial: nodeInitial.toIdentifiers(),
25
+ nodeIdsA: nodeA.toIdentifiers(),
26
+ nodeIdsB: nodeB.toIdentifiers(),
27
+ };
28
+ };
29
+ export const getGeneralFormulaOfArithmeticoGeometricSequenceSituation = (params) => {
30
+ const { n0, nodeIdsInitial, nodeIdsA, nodeIdsB } = params;
31
+ const [nodeInitial, nodeA, nodeB] = [nodeIdsInitial, nodeIdsA, nodeIdsB].map((nodeIds) => reifyAlgebraic(nodeIds));
32
+ const nodeR = frac(nodeB, substract(1, nodeA).simplify()).simplify();
33
+ const nodeUN = new VariableNode("u_{n}");
34
+ const nodeVarN = new VariableNode("n");
35
+ const arrNodeAlid = [
36
+ new EqualNode(nodeUN, add(multiply(power(nodeA, substract(nodeVarN, n0).simplify()), substract(nodeInitial, nodeR).simplify()), nodeR)),
37
+ new EqualNode(nodeUN, add(nodeR, multiply(power(nodeA, substract(nodeVarN, n0).simplify()), substract(nodeInitial, nodeR).simplify()))),
38
+ new EqualNode(nodeUN, add(multiply(power(nodeA, substract(nodeVarN, n0).simplify()), nodeInitial), multiply(nodeR, substract(1, power(nodeA, substract(nodeVarN, n0).simplify()))))),
39
+ new EqualNode(nodeUN, add(multiply(nodeR, substract(1, power(nodeA, substract(nodeVarN, n0).simplify()))), multiply(power(nodeA, substract(nodeVarN, n0).simplify()), nodeInitial))),
40
+ new EqualNode(nodeUN, substract(multiply(power(nodeA, substract(nodeVarN, n0).simplify()), add(nodeInitial, nodeR).simplify()), nodeR)),
41
+ new EqualNode(nodeUN, add(add(nodeR, nodeInitial).simplify(), multiply(power(nodeA, substract(nodeVarN, n0).simplify()), substract(nodeInitial, nodeR).simplify()))),
42
+ new EqualNode(nodeUN, multiply(power(nodeA, substract(nodeVarN, n0).simplify()), add(nodeInitial, nodeR).simplify())),
43
+ new EqualNode(nodeUN, add(multiply(nodeR, substract(1, power(add(nodeA, nodeInitial).simplify(), substract(nodeVarN, n0).simplify()))), multiply(power(nodeA, substract(nodeVarN, n0).simplify()), nodeInitial))),
44
+ ];
45
+ const { arrNodeValid, arrNodeInvalid } = arrNodeAlid.reduce((acc, equalNode) => {
46
+ const nodeSubstituted = nodeBySubstitutingVar(equalNode.rightChild, n0.toTree(), nodeVarN);
47
+ if (NodeComparator.isEqualViaSub(nodeSubstituted, nodeInitial) ||
48
+ NodeComparator.isEqualViaFrac(nodeSubstituted, nodeInitial)) {
49
+ acc.arrNodeValid.push(equalNode);
50
+ }
51
+ else {
52
+ acc.arrNodeInvalid.push(equalNode);
53
+ }
54
+ return acc;
55
+ }, {
56
+ arrNodeValid: [],
57
+ arrNodeInvalid: [],
58
+ });
59
+ return {
60
+ id: "generalFormulaOfArithmeticoGeometricSequence",
61
+ strContext: `Soit $u$ la suite définie par :
62
+
63
+ $$
64
+ u_{${n0.frenchify()}} = ${nodeInitial.toTex()}
65
+ $$
66
+
67
+ et, pour tout $n \\geq ${n0}$ :
68
+
69
+ $$
70
+ u_{n+1} = ${add(multiply(nodeA, new VariableNode("u_{n}")), nodeB).toTex()}
71
+ $$
72
+
73
+ `,
74
+ n0,
75
+ baseCase: "",
76
+ inductionHypothesis: "",
77
+ inductionStep: "",
78
+ conclusion: "",
79
+ keys: [],
80
+ params,
81
+ arrNodeValid,
82
+ arrNodeInvalid,
83
+ //specific
84
+ nodeA,
85
+ nodeB,
86
+ nodeR,
87
+ nodeInitial,
88
+ };
89
+ };
90
+ const buildMultipleFromPolynomialParams = () => {
91
+ const n0 = randint(0, 3);
92
+ const nbMod = randint(2, 4);
93
+ const isValid = coinFlip();
94
+ const rootMin = randint(-4, 5);
95
+ const arrValueRoot = [...Array(nbMod).keys()].map((i) => i + rootMin);
96
+ return {
97
+ n0,
98
+ isValid,
99
+ nbMod,
100
+ arrValueRoot,
101
+ };
102
+ };
103
+ export const getMultipleFromPolynomialSituation = (params) => {
104
+ const { n0, isValid, arrValueRoot } = params;
105
+ const nodeVarN = new VariableNode("n");
106
+ const nodeP = (() => {
107
+ const nodeP = arrValueRoot.reduce((acc, valueRoot, i) => {
108
+ const nodeFactor = substract(nodeVarN, valueRoot);
109
+ if (i === 0) {
110
+ return nodeFactor;
111
+ }
112
+ else {
113
+ return multiply(acc, nodeFactor);
114
+ }
115
+ }, (0).toTree());
116
+ return (isValid ? nodeP : add(nodeP, 1)).simplify({
117
+ towardsDistribute: true,
118
+ calculatePowers: true,
119
+ forbidFactorize: true,
120
+ });
121
+ })();
122
+ return {
123
+ id: "multipleFromPolynomial",
124
+ strContext: `Soit $f$ la fonction définie pour tout $n \\geq ${n0}$ par :
125
+
126
+ $$
127
+ f(n) = ${nodeP.toTex()}
128
+ $$
129
+
130
+ `,
131
+ n0,
132
+ baseCase: "",
133
+ inductionHypothesis: "",
134
+ inductionStep: "",
135
+ conclusion: "",
136
+ keys: [],
137
+ params,
138
+ arrNodeValid: isValid ? [nodeP] : [],
139
+ arrNodeInvalid: isValid ? [] : [nodeP],
140
+ };
141
+ };
142
+ export const getHydratedProofByInductionSituation = (params) => {
143
+ switch (params.id) {
144
+ case "generalFormulaOfArithmeticoGeometricSequence":
145
+ return getGeneralFormulaOfArithmeticoGeometricSequenceSituation(params);
146
+ case "multipleFromPolynomial":
147
+ return getMultipleFromPolynomialSituation(params);
148
+ }
149
+ };
150
+ export const getRandomProofByInductionSituationParams = () => {
151
+ return random([
152
+ {
153
+ ...buildGeneralFormulaOfArithmeticoGeometricSequenceParams(),
154
+ id: "generalFormulaOfArithmeticoGeometricSequence",
155
+ },
156
+ // { ...buildIneqOfConsecutiveTermsParams(), id: "ineqOfConsecutiveTerms" },
157
+ {
158
+ ...buildMultipleFromPolynomialParams(),
159
+ id: "multipleFromPolynomial",
160
+ },
161
+ ]);
162
+ };
163
+ export const getArrProofByInductionSituationParams = (arrId) => {
164
+ return [
165
+ {
166
+ ...buildGeneralFormulaOfArithmeticoGeometricSequenceParams(),
167
+ id: "generalFormulaOfArithmeticoGeometricSequence",
168
+ },
169
+ // { ...buildIneqOfConsecutiveTermsParams(), id: "ineqOfConsecutiveTerms" },
170
+ {
171
+ ...buildMultipleFromPolynomialParams(),
172
+ id: "multipleFromPolynomial",
173
+ },
174
+ ].filter(({ id }) => arrId.includes(id));
175
+ };
@@ -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 proofByInductionWriteMissingStep: Exercise<Identifiers>;
12
+ export {};
13
+ //# sourceMappingURL=proofByInductionWriteMissingStep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofByInductionWriteMissingStep.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAO7C,OAAO,EAGL,+BAA+B,EAChC,MAAM,iCAAiC,CAAC;AAWzC,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;AAweF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAiBlE,CAAC"}