Draggable Proof

A Simple draggable proof.

Complete Code

Download file: DraggableProof.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'draggableProof.pl', 'PGcourse.pl');

Preamble

This problem uses the draggableProof.pl macro to display “buckets” that the student can drag statements to and from.

$proof = DraggableProof(
    # These are the correct statements of the proof in the correct order.
    [
        'Assume \(\sqrt{2} = \frac{a}{b}\) where \(a\) and \(b\) are integers with \(\gcd(a,b) = 1\).',
        'Then \(2 = \frac{a^2}{b^2}\).',
        'So \(a^2 = 2b^2\).',
        'Thus \(a^2\) is even which implies that \(a\) must also be even.',
        'Let \(a = 2k\) for \(k\) some integer.',
        'We can then write \(2 = \frac{4k^2}{b^2}\) which implies that \(b^2 = 2k^2\).',
        'Thus \(b^2\) is even, and so \(b\) must also be even.',
        'Hence \(a\) and \(b\) are both even, and this contradicts the initial assumption that \(\gcd(a,b) = 1\).',
        'Therefore \(\sqrt{2}\) is not rational.'
    ],
    # These are extra statements that are not needed.
    [
        'Then \(a\) is odd.',
        'Thus \(b^2\) cannot be rational.',
        'Therefore \(a = 2b\).'
    ]
);

Setup

The DraggableProof function takes an array reference of correct statements in the correct order, followed (optionally) by another array reference of extra statements. See the draggable proof documentation for more options.

BEGIN_PGML
Prove that [`\sqrt{2}`] is irrational.

[_]{$proof}
END_PGML

Statement

The line [_]{$proof} prints the statement and options in the proof and sets up the answer rule.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.