math-exercises 3.0.201 → 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/dataRepresentations/scatterPlot/index.d.ts +2 -0
- package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/scatterPlot/index.js +2 -2
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.js +2 -2
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.js +9 -2
- package/lib/exercises/math/derivation/derivative/exp/secondDerivativeOfExpoFunction.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/index.d.ts +1 -0
- package/lib/exercises/math/derivation/derivative/trigo/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/index.js +1 -1
- 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.js +1 -1
- package/lib/exercises/math/derivation/problems/index.d.ts +1 -0
- package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/index.js +1 -1
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +31 -21
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts.map +1 -1
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.js +8 -128
- package/lib/exercises/math/derivation/tangent/index.d.ts +1 -0
- package/lib/exercises/math/derivation/tangent/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/tangent/index.js +1 -1
- package/lib/exercises/math/derivation/variations/index.d.ts +1 -0
- package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/index.js +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +47 -20
- package/lib/exercises/math/equaDiff/equaDiffAyPlusB.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/equaDiffAyPlusB.js +29 -6
- package/lib/exercises/math/equaDiff/equaDiffCheckSolutionFirstOrder.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/equaDiffCheckSolutionFirstOrder.js +33 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquation.d.ts +7 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquation.d.ts.map +1 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquation.js +86 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquationWithIC.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquationWithIC.js +35 -7
- package/lib/exercises/math/equaDiff/index.d.ts +1 -1
- package/lib/exercises/math/equaDiff/index.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/index.js +1 -1
- package/lib/exercises/math/functions/integral/integralExpU.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralExpU.js +48 -0
- package/lib/exercises/math/functions/integral/integralFractions.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralFractions.js +52 -0
- package/lib/exercises/math/functions/integral/integralTrinomials.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralTrinomials.js +40 -0
- package/lib/exercises/math/functions/logarithm/log10Simplifying.js +2 -2
- package/lib/exercises/math/functions/logarithm/powerEquation.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/geometry/parametric/extractVectorFromParametricLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.js +30 -25
- package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/parametric/pointFromParametricLine.js +52 -5
- package/lib/exercises/math/integration/fromExpr/areaBetweenCrossingCurvesFixedPosFromExpr.d.ts.map +1 -1
- package/lib/exercises/math/integration/fromExpr/areaBetweenCrossingCurvesFixedPosFromExpr.js +26 -35
- package/lib/exercises/math/integration/fromExpr/index.d.ts +1 -0
- package/lib/exercises/math/integration/fromExpr/index.d.ts.map +1 -1
- package/lib/exercises/math/integration/fromExpr/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/primitive/constantPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/constantPrimitive.js +25 -1
- package/lib/exercises/math/primitive/exponentialPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/exponentialPrimitive.js +17 -0
- package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/polynomialPrimitive.js +17 -1
- package/lib/exercises/math/primitive/sinCosPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/sinCosPrimitive.js +20 -1
- package/lib/exercises/math/primitive/usualPrimitives.d.ts.map +1 -1
- package/lib/exercises/math/primitive/usualPrimitives.js +1 -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/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.js +4 -4
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSetsFromSituation.js +3 -3
- package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.js +4 -4
- package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesOfPointInCubeCoordSystemFromVecPath.js +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/findOrthogonalProjectionOfPointOnPlane.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/findOrthogonalProjectionOfPointOnPlane.js +12 -25
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/index.d.ts +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/index.js +1 -2
- package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlanePointsCoords.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlanePointsCoords.js +11 -26
- package/lib/exercises/math/spaceGeometry/planes/index.d.ts +1 -0
- package/lib/exercises/math/spaceGeometry/planes/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/index.js +1 -1
- package/lib/exercises/math/spaceGeometry/planes/planePlaneRelativePositions.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/planePlaneRelativePositions.js +11 -25
- package/lib/exercises/math/spaceGeometry/scalarProduct/angleFromScalarProductFromSpacePointCoords.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/scalarProduct/angleFromScalarProductFromSpacePointCoords.js +25 -5
- package/lib/exercises/math/spaceGeometry/scalarProduct/index.d.ts +1 -0
- package/lib/exercises/math/spaceGeometry/scalarProduct/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/scalarProduct/index.js +1 -1
- package/lib/exercises/math/spaceGeometry/vectors/findLinearDecompositionWrtCoplanarUVFromCoords.js +2 -2
- package/lib/exercises/math/trigonometry/functions/equationCosOnRandomInterval.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/functions/equationCosOnRandomInterval.js +87 -24
- package/lib/exercises/pc/mathExosInPC.d.ts +1 -1
- package/lib/exercises/pc/mathExosInPC.d.ts.map +1 -1
- package/lib/exercises/pc/mathExosInPC.js +1 -1
- package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -1
- package/lib/exercises/vea/polynomialVEA.js +4 -0
- package/lib/index.d.ts +104 -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/geometry/spaceVector.d.ts +2 -0
- package/lib/math/geometry/spaceVector.d.ts.map +1 -1
- package/lib/math/geometry/spaceVector.js +40 -0
- package/lib/math/utils/functions/functionDecomposition.d.ts +2 -2
- package/lib/math/utils/functions/functionDecomposition.d.ts.map +1 -1
- package/lib/math/utils/polynomial/polynomialUtils.d.ts +2 -2
- package/lib/math/utils/polynomial/polynomialUtils.d.ts.map +1 -1
- package/lib/math/utils/polynomial/polynomialUtils.js +5 -2
- package/lib/tests/exoTest.d.ts.map +1 -1
- package/lib/tests/exoTest.js +8 -12
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +14 -6
- 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 +68 -8
- package/lib/tree/utilities/nodeSimplifier.d.ts +1 -0
- package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -1
- package/lib/tree/utilities/nodeSimplifier.js +40 -0
- 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
|
+
};
|
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"}
|
package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.js
ADDED
|
@@ -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
|
+
};
|
package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.js
CHANGED
|
@@ -75,21 +75,21 @@ avec comme premier élément un élement de $D$, et comme deuxième élément un
|
|
|
75
75
|
Voici un exemple :
|
|
76
76
|
|
|
77
77
|
$$
|
|
78
|
-
C = \\lbrace 32
|
|
78
|
+
C = \\lbrace 32 ; 42 ; 52 \\rbrace
|
|
79
79
|
$$
|
|
80
80
|
|
|
81
81
|
$$
|
|
82
|
-
D = \\lbrace u
|
|
82
|
+
D = \\lbrace u ; v \\rbrace
|
|
83
83
|
$$
|
|
84
84
|
|
|
85
85
|
Voici les couples appartenant à $D \\times C$ :
|
|
86
86
|
|
|
87
87
|
$$
|
|
88
|
-
(u
|
|
88
|
+
(u;32),(u;42),(u;52),
|
|
89
89
|
$$
|
|
90
90
|
|
|
91
91
|
$$
|
|
92
|
-
(v
|
|
92
|
+
(v;32),(v;42),(v;52)
|
|
93
93
|
$$
|
|
94
94
|
|
|
95
95
|
Le cardinal de $D \\times C$ est donc $2\\times3=6$.`;
|
|
@@ -108,15 +108,15 @@ Chaque carte peut être soit Pique, soit Coeur.
|
|
|
108
108
|
Voici toutes les cartes possibles :
|
|
109
109
|
|
|
110
110
|
$$
|
|
111
|
-
(\\text{Valet}
|
|
111
|
+
(\\text{Valet};\\text{Pique}),(\\text{Valet};\\text{Coeur})
|
|
112
112
|
$$
|
|
113
113
|
|
|
114
114
|
$$
|
|
115
|
-
(\\text{Dame}
|
|
115
|
+
(\\text{Dame};\\text{Pique}),(\\text{Dame};\\text{Coeur})
|
|
116
116
|
$$
|
|
117
117
|
|
|
118
118
|
$$
|
|
119
|
-
(\\text{Roi}
|
|
119
|
+
(\\text{Roi};\\text{Pique}),(\\text{Roi};\\text{Coeur})
|
|
120
120
|
$$
|
|
121
121
|
|
|
122
122
|
Il y en a $3\\times2=6$.`;
|
package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.js
CHANGED
|
@@ -54,21 +54,21 @@ avec comme premier élément un élement de $D$, et comme deuxième élément un
|
|
|
54
54
|
Voici un exemple :
|
|
55
55
|
|
|
56
56
|
$$
|
|
57
|
-
C = \\lbrace 32
|
|
57
|
+
C = \\lbrace 32 ; 42 ; 52 \\rbrace
|
|
58
58
|
$$
|
|
59
59
|
|
|
60
60
|
$$
|
|
61
|
-
D = \\lbrace u
|
|
61
|
+
D = \\lbrace u ; v \\rbrace
|
|
62
62
|
$$
|
|
63
63
|
|
|
64
64
|
Voici les couples appartenant à $D \\times C$ :
|
|
65
65
|
|
|
66
66
|
$$
|
|
67
|
-
(u
|
|
67
|
+
(u;32),(u;42),(u;52),
|
|
68
68
|
$$
|
|
69
69
|
|
|
70
70
|
$$
|
|
71
|
-
(v
|
|
71
|
+
(v;32),(v;42),(v;52)
|
|
72
72
|
$$
|
|
73
73
|
|
|
74
74
|
`;
|