math-exercises 3.0.202 → 3.0.203
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.
- package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +1 -1
- package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts.map +1 -1
- package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.js +172 -51
- package/lib/exercises/math/geometry/angles/index.d.ts +1 -0
- package/lib/exercises/math/geometry/angles/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/angles/index.js +1 -1
- package/lib/exercises/math/limits/index.d.ts +1 -5
- package/lib/exercises/math/limits/index.d.ts.map +1 -1
- package/lib/exercises/math/limits/index.js +1 -5
- package/lib/exercises/math/limits/limitReading.d.ts.map +1 -1
- package/lib/exercises/math/limits/limitReading.js +70 -0
- package/lib/exercises/math/limits/polynomLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/polynomLimit.js +55 -4
- package/lib/exercises/math/limits/polynomLimitNoFI.d.ts.map +1 -1
- package/lib/exercises/math/limits/polynomLimitNoFI.js +35 -2
- package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequenceGeometricLimit.js +45 -9
- package/lib/exercises/math/limits/sequencePolynomLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequencePolynomLimit.js +56 -3
- package/lib/exercises/math/limits/sequencePolynomNoFILimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequencePolynomNoFILimit.js +32 -0
- package/lib/exercises/math/limits/sequencePolynomProductLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequencePolynomProductLimit.js +33 -3
- package/lib/exercises/math/limits/sequenceRationalFracLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequenceRationalFracLimit.js +2 -2
- package/lib/exercises/math/limits/sequences/index.d.ts +6 -0
- package/lib/exercises/math/limits/sequences/index.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/index.js +5 -0
- package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.d.ts +9 -0
- package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.js +110 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomLimit.d.ts +7 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomLimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomLimit.js +116 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.d.ts +7 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.js +95 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.d.ts +8 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.js +111 -0
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts +8 -0
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.js +114 -0
- package/lib/exercises/math/sequences/index.d.ts +1 -0
- package/lib/exercises/math/sequences/index.d.ts.map +1 -1
- package/lib/exercises/math/sequences/index.js +1 -0
- package/lib/exercises/math/sequences/proofByInduction/index.d.ts +5 -0
- package/lib/exercises/math/sequences/proofByInduction/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/index.js +4 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.d.ts +10 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.js +236 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.d.ts +13 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.js +244 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.d.ts +98 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.js +175 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.d.ts +13 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.js +317 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts +13 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.js +265 -0
- package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -1
- package/lib/exercises/vea/polynomialVEA.js +4 -0
- package/lib/index.d.ts +49 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +1 -1
- package/lib/math/utils/functions/functionDecomposition.d.ts +2 -2
- package/lib/math/utils/functions/functionDecomposition.d.ts.map +1 -1
- package/lib/tests/exoTest.d.ts.map +1 -1
- package/lib/tests/exoTest.js +7 -11
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +7 -3
- package/lib/tests/singleExo.test.d.ts.map +1 -1
- package/lib/tests/singleExo.test.js +2 -2
- package/lib/tree/nodes/node.d.ts +2 -1
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/node.js +1 -0
- package/lib/tree/nodes/student/iDontKnowNode.d.ts +26 -0
- package/lib/tree/nodes/student/iDontKnowNode.d.ts.map +1 -0
- package/lib/tree/nodes/student/iDontKnowNode.js +63 -0
- package/lib/tree/parsers/latexParser.d.ts +3 -2
- package/lib/tree/parsers/latexParser.d.ts.map +1 -1
- package/lib/tree/parsers/latexParser.js +7 -0
- package/lib/tree/parsers/monomParser.d.ts +1 -1
- package/lib/tree/parsers/monomParser.d.ts.map +1 -1
- package/lib/tree/parsers/polynomialParser.d.ts +1 -1
- package/lib/tree/parsers/polynomialParser.d.ts.map +1 -1
- package/lib/tree/parsers/trinomParser.d.ts +1 -1
- package/lib/tree/parsers/trinomParser.d.ts.map +1 -1
- package/lib/tree/utilities/nodeComparator.d.ts +3 -1
- package/lib/tree/utilities/nodeComparator.d.ts.map +1 -1
- package/lib/tree/utilities/nodeComparator.js +63 -5
- package/package.json +1 -1
|
@@ -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
|
package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.d.ts.map
ADDED
|
@@ -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"}
|
|
@@ -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
|
+
};
|
package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts
ADDED
|
@@ -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
|
package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts.map
ADDED
|
@@ -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"}
|