Built with Alectryon, running vsrocq-language-server v9.4+alpha 5.4.1 / 2.5.0. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑Ctrl+↓ to navigate, Ctrl+🖱️ to focus. On Mac, use ⌘ instead of Ctrl.
(** Lesson 2 -- What makes a native rule a valid pattern? (~20 minutes.) This file is independent of Lesson 1. Keep the diagnostic for each [Fail] visible. Ask which check explains it: a head restriction, pattern-variable binding, or ordinary typing? See the matching manual's "Pattern syntax" section. The fragment used here is first order. Lambda/match patterns, explicit hole substitutions, and universes belong to the later reading plan.*)From Corelib Require Import Init.Nat.Set Guard Checking.SetUniverseChecking.Definitionordinary_identity (n : nat) := n.(** A defined constant cannot be the head of a native rule. *)
The command has indeed failed with message:
Subterm not recognised as pattern: ordinary_identity
(** A constructor can occur INSIDE a pattern, but the head of the rule must be a symbol. This cannot install a reduction for [S] itself. *)
The command has indeed failed with message:
Head head-patternis not a symbol.
Symbol peel : nat -> nat.Rewrite Rule peel_successor := peel (S ?n) => ?n.Definitionpeel_example : foralln, peel (S n) = n :=
funn => eq_refl.
= peel 0
: nat
(** There is no completeness/coverage obligation requiring a rule for [peel 0]. With no applicable rule this term remains stuck. *)
The command has indeed failed with message:
The term "eq_refl" has type "peel 0 = peel 0"
while it is expected to have type "peel 0 = 0" (cannot unify"peel 0"and"0").
Symbol choose : nat -> nat -> nat.(** A repeated named hole does not mean "compare these arguments". Named pattern holes must be bound at most once (left-linearity). *)
The command has indeed failed with message:
Variable?nis bound multiple times in the pattern (holes number 1and2).
(** A replacement cannot invent an unbound hole. This checkout may warn during elaboration before reporting the final binding error. *)
This rewrite rule breaks subject reduction
(the replacement term doesn't have the type of the pattern).
Unknown existential variable. [rewrite-rules-break-SR,rewrite-rules,default]
The command has indeed failed with message:
Unknown existential variable.
(** Separate [_] holes discard independently matched arguments. *)Rewrite Rule choose_first := choose ?n _ => ?n.Definitionchoose_example : forallnm, choose n m = n :=
funnm => eq_refl.Symbol inspect : nat -> nat.(** A hole also cannot be the head of an application inside a pattern. The elaborator can type this application; the pattern check rejects its shape. *)
The command has indeed failed with message:
Subterm not recognised as pattern: ?f
(** Rules in sections are not supported by this checkout. Even a rule which does not mention any section variable is rejected there. *)SectionUnsupportedSection.
The command has indeed failed with message:
Adding rewrite rules not supported in sections.
reflexivity.Qed.(** Checkpoint Classify each failure above. Then explain why accepting [peel] does not establish coverage, and why checking left-linearity does not by itself establish confluence of a collection of rules. Cues: symbol heads and rigid patterns restrict matching; holes must be bound once and available on the right; sections are unsupported; none of these checks compares all possible reductions of a term. Next: L03_Admission.v -- what is registered and later reused?*)