rocq/theories/Diagnostics.v
GNU error has two different continuations: status zero returns void; nonzero requests soft exit after the diagnostic. Formatting, program name/strerror decoration, stream effects and their authority are imported obligations, not invented bytes or an unmodelled stdout acceptance.
A formatter must interpret the fixed W,W,P arguments and exact promoted varargs. Its ABI supplies the allowed classes for the variadic suffix.
Status and errno are canonical C-int bits, not a low-byte wait status. String validity and actual varargs interpretation belong to the formatter.
Only stderr acceptance is observable here. Stdout flushes may settle earlier output but cannot relabel diagnostic bytes as stdout acceptance.
No diagnostic prefix contains a host-termination observation.
Explore proof 4 tactics
Initial goal
intros trace H status Hin
unfold diagnostic_trace in H
rewrite Forall_forall in H
exact H_ Hin
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
In particular stderr output never becomes stdout acceptance.
Explore proof 5 tactics
Initial goal
intros trace bytes H Hin
unfold diagnostic_trace in H
rewrite Forall_forall in H
specialize H_ Hin
discriminate H
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
This contract summarizes only the diagnostic stage, before the status branch. Its virtual void result is NOT a normal return from error when status is nonzero; do not register it as error's ordinary contract. Resource prefixes retain no normal-completion facts. All capability sources, writes, releases, allocations and panic policy come from fmt.
Only status-zero error may use ordinary ExternalMachine dispatch. The caller's frame/locals/continuation are preserved by resume_external; libc state, errno and stream settlement may change under fmt's effects.
The normal-return shape is available without choosing a runtime instance.
Explore proof 2 tactics
Initial goal
intros world fmt xs m w born trace ending m′ w′ _ H
exact H
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Canonical argument lists determine status independently of behavior.
Explore proof 4 tactics
Initial goal
intros xs left right e & p & rest & Hl & _ e′ & p′ & rest′ & Hr & _
rewrite Hl in Hr
injection Hr
auto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
A nonzero diagnostic is never admitted as an ordinary returning error.
Explore proof 3 tactics
Initial goal
intros world fmt xs m w status Hstatus Hnonzero _ Hzero
apply Hnonzero
eapply error_words_status ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Diagnostics reuse the exact runtime, effects and current Linked world.
The selected error call is independently admitted even if no diagnostic invocation completes. This premise does not promise termination.
Caller admission is independent of a completed formatting stage.
A nonzero completed diagnostic requests exit with its CURRENT world, including any stdout flush/error and stderr settlement. It never reuses registration-time state, resumes the caller or emits ProcessExit.
Extension rules are disjoint from Ending's ordinary error dispatch. Status-zero returns and resources remain ordinary external outcomes; nonzero diagnostics have an exit-request edge or a resource leaf.
A diagnostic request carries only diagnostic events, not host exit.
Explore proof 4 tactics
Initial goal
intros ge c s w trace ms′ w′ H
destruct H
destruct E.invoke_prefix_ _ _ _ _ _ _ _ _ _ _ _ _ H2 as born _ _ Htrace
exact Htrace
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Every request keeps readiness and identities through the formatter's actual effect path; no final-return state is assumed for resources.
Explore proof 4 tactics
Initial goal
intros ge c s w trace ms′ w′ H Hr
destruct H
simpl
eapply E.invoke_preserve ; eauto
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.
Source script
Both diagnostic branches and their resource/unfinished leaves retain readiness and identities, using the imported formatter's exact effects.
Explore proof 8 tactics
Initial goal
intros registry ge b admitted st trace st′ Hfree H
destruct H ; intros Hr
6 openfocused goal
focused goal
focused goal
focused goal
focused goal
–eapply N.step_preserve ; eauto
5 opendeferred goal
deferred goal
deferred goal
deferred goal
deferred goal
–eapply E.invoke_preserve ; eauto
4 opendeferred goal
deferred goal
deferred goal
deferred goal
–eapply error_request_preserve ; eauto
3 opendeferred goal
deferred goal
deferred goal
–eapply E.invoke_preserve ; eauto
2 opendeferred goal
deferred goal
–eapply E.prefix_preserve ; eauto
deferred goal
–split ; auto using persists_refl
No remaining goals.
Qed
✓ Proof checked and closed by Rocq.