Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jscoq-light
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Rousselin
jscoq-light
Commits
d00fb16a
Commit
d00fb16a
authored
3 years ago
by
Shachar Itzhaky
Browse files
Options
Downloads
Patches
Plain Diff
[doc] Embedded `sqrt_2` proof + walkthrough.
parent
4dbb4bc2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
index.html
+70
-2
70 additions, 2 deletions
index.html
ui-css/landing-page.css
+11
-0
11 additions, 0 deletions
ui-css/landing-page.css
with
81 additions
and
2 deletions
index.html
+
70
−
2
View file @
d00fb16a
...
...
@@ -71,6 +71,73 @@
feedback at
<a
href=
"https://github.com/jscoq/jscoq"
>
GitHub
</a>
and
<a
href=
"https://coq.zulipchat.com/#narrow/stream/256336-jsCoq"
>
Zulip
</a>
.
</p>
<h4>
A First Example: √2 ∉
<span
class=
"symbol-Q"
>
ℚ
</span></h4>
<p>
The following is a simple proof that
<img
class=
"symbol-sqrt"
src=
"ui-images/sqrt.svg"
>
2
cannot be expressed as the ratio of two integers; that is, for every two integers
<i>
p
</i>
and
<i>
q
</i>
, (
<i>
p/q
</i>
)
<sup>
2
</sup>
≠ 2.
</p>
<p>
Use
<kbd>
Alt
</kbd>
+
<kbd>
↓
</kbd>
/
<kbd>
↑
</kbd>
to step through the proof,
and observe the proof state in the right pane.
</p>
<textarea
class=
"snippet"
>
From Coq Require Import Utf8 Arith Lia.
From Examples Require Import sqrt_2.
Theorem sqrt2_not_rational :
forall p q : nat, q
<>
0 -> ¬ p ^ 2 = 2 * (q ^ 2).
</textarea>
<p
class=
"interim"
>
First, we simplify the goal a bit by inlining the
definition of □
<sup>
2
</sup>
.
</p>
<textarea
class=
"snippet"
>
Proof.
assert (forall x, x ^ 2 = x * x) as sq by (simpl; lia).
intros p q; rewrite! sq; clear sq.
</textarea>
<p
class=
"interim"
>
The proof proceeds by
<a
href=
"https://en.wikipedia.org/wiki/Mathematical_induction#Complete_(strong)_induction"
></https:>
complete induction
</a>
on
<span
class=
"math"
><i>
q
</i></span>
, generalizing over
<span
class=
"math"
><i>
p
</i></code>
.
</p>
<textarea
class=
"snippet"
>
revert p.
induction q as [q IH] using (well_founded_ind lt_wf).
intros p Hneq.
</textarea>
<p
class=
"interim"
>
The gist of the proof is realizing that it can be obtained by
instantiating the induction hypothesis with values
3
<i>
q
</i><span
class=
"symbol-minus"
>
–
</span>
2
<i>
p
</i>
and
3
<i>
p
</i><span
class=
"symbol-minus"
>
–
</span>
4
<i>
q
</i>
.
</p>
<textarea
class=
"snippet"
>
specialize IH with (y := 3 * q - 2 * p) (p := 3 * p - 4 * q).
</textarea>
<p
class=
"interim"
>
The rest follows from simpler inequalities,
<span
class=
"math"
>
2
<i>
p
</i>
<
<span
class=
"math"
>
3
<i>
q
</i>
<
2
<i>
p
</i><span
class=
"symbol-plus"
>
+
</span>
q
</span>
and
<span
class=
"math"
>
4
<i>
q
</i>
<
<span
class=
"math"
>
3
<i>
p
</i>
.
These are not included in the example; for details, see
<a
href=
"examples/sqrt_2.html"
>
the full proof
</a>
.
</p>
<textarea
class=
"snippet"
>
intro Heq; apply IH.
- apply comparison_3q2p. all: auto.
- apply Nat.sub_gt. apply comparison_2p3q. all: auto.
- rewrite! sub_square_identity.
+ clear IH; lia.
+ auto using comparison_2p3q, lt_le_weak.
+ auto using comparison_4q3p, lt_le_weak.
Qed.
</textarea>
<h4>
Instructions:
</h4>
<p>
The following document contains embedded Coq code.
...
...
@@ -232,14 +299,15 @@ Qed.</textarea>
<script
src=
"ui-js/jscoq-loader.js"
type=
"text/javascript"
></script>
<script
type=
"text/javascript"
>
var
jscoq_ids
=
[
'
addnC
'
,
'
prime_above1
'
,
'
prime_above2
'
,
'
prime_above3
'
,
'
prime_above4
'
];
var
jscoq_ids
=
[
'
.snippet
'
,
'
addnC
'
,
'
prime_above1
'
,
'
prime_above2
'
,
'
prime_above3
'
,
'
prime_above4
'
];
var
jscoq_opts
=
{
implicit_libs
:
false
,
focus
:
false
,
base_path
:
'
./
'
,
editor
:
{
mode
:
{
'
company-coq
'
:
true
}
},
init_pkgs
:
[
'
init
'
],
all_pkgs
:
[
'
coq
'
,
'
mathcomp
'
,
'
equations
'
,
'
elpi
'
,
'
quickchick
'
,
'
lf
'
,
'
plf
'
]
all_pkgs
:
{
'
+
'
:
[
'
coq
'
,
'
mathcomp
'
,
'
equations
'
,
'
elpi
'
,
'
quickchick
'
,
'
lf
'
,
'
plf
'
],
'
./examples
'
:
[
'
examples
'
]}
};
/* Global reference */
...
...
This diff is collapsed.
Click to expand it.
ui-css/landing-page.css
+
11
−
0
View file @
d00fb16a
...
...
@@ -14,6 +14,17 @@ h5 {
color
:
#089
;
}
p
.interim
{
margin
:
.5em
0
.5em
2em
;
line-height
:
1.2
;
}
span
.symbol-minus
,
span
.symbol-plus
{
margin
:
0
0.2em
;
}
span
.symbol-Q
{
font-family
:
'Arial Unicode MS'
,
'Times New Roman'
,
Times
,
serif
;
}
span
.jscoq-name
{
color
:
#363
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment