Skip to content

Commit 59831e2

Browse files
committed
proofs(coq): partial closure of build-oracle cascade (refs #49)
Fixes the first wave of errors uncovered while attempting to re-enable the verify-proofs CI oracle. Issue #49 catalogued 5 errors; this PR closes those + several deeper cascading failures in the same modules. Closed: - file_content_operations.v:133 redundant rewrite of Hntype after eqn: destruct already substituted - file_content_operations.v:137,140 exact (Hcontra eq_refl) replaced with destruct (False has no constructors) - file_content_operations.v:178 destruct (node_type node) missing eqn: (no substitution into RHS match) - file_content_operations.v:272 injection on un-reduced match — restructured with assert + destruct - filesystem_model.v added has_read_permission (referenced by copy_move_operations:38, never defined) - copy_move_operations.v reordered is_prefix definition before its use at line 62 Verified locally: filesystem_model.v, file_operations.v, file_content_operations.v compile against coqc 8.18.0. Remaining errors past line ~110 of copy_move_operations.v and downstream in filesystem_composition.v are tracked as continuation of #49. The verify-proofs CI job will be re-enabled in a follow-up PR once the full module set compiles end-to-end. Refs #49, #47.
1 parent 18dd4e1 commit 59831e2

3 files changed

Lines changed: 17 additions & 21 deletions

File tree

proofs/coq/copy_move_operations.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ Definition copy_file (src dst : Path) (fs : Filesystem) : Filesystem :=
4848

4949
(** * Move Operation *)
5050

51+
(** Helper: check if path is prefix of another *)
52+
Definition is_prefix (p1 p2 : Path) : Prop :=
53+
exists suffix, p2 = p1 ++ suffix.
54+
5155
(** Precondition for move/rename *)
5256
Definition move_precondition (src dst : Path) (fs : Filesystem) : Prop :=
5357
(* Source must exist *)
@@ -65,10 +69,6 @@ Definition move_precondition (src dst : Path) (fs : Filesystem) : Prop :=
6569
(* Must have write permission on destination parent *)
6670
has_write_permission (parent_path dst) fs.
6771

68-
(** Helper: check if path is prefix of another *)
69-
Definition is_prefix (p1 p2 : Path) : Prop :=
70-
exists suffix, p2 = p1 ++ suffix.
71-
7272
(** Move operation *)
7373
Definition move (src dst : Path) (fs : Filesystem) : Filesystem :=
7474
match fs src with

proofs/coq/file_content_operations.v

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,11 @@ Proof.
130130
unfold read_file in Hold.
131131
destruct (fs p) as [n|] eqn:Hfs; [|discriminate].
132132
destruct (node_type n) eqn:Hntype; [|discriminate].
133-
rewrite Hntype in Hold. simpl in Hold.
133+
simpl in Hold.
134134
destruct (node_content n) as [c|] eqn:Hcontent; [|discriminate].
135135
injection Hold as Heq. subst c.
136-
(* Both (list_eq_dec p p) branches are trivially left/right *)
137-
destruct (list_eq_dec String.string_dec p p) as [_|Hcontra]; [|exact (Hcontra eq_refl)].
138-
rewrite Hfs. rewrite Hntype.
139-
(* After inner write: result is Some {|...; node_content := Some new_content|} *)
140-
destruct (list_eq_dec String.string_dec p p) as [_|Hcontra]; [|exact (Hcontra eq_refl)].
141-
rewrite Hfs. rewrite Hntype. simpl.
142-
(* node_type of the intermediate node is File, so outer write applies old_content *)
136+
destruct (list_eq_dec String.string_dec p p) as [_|Hcontra]; [|destruct (Hcontra eq_refl)].
137+
destruct (list_eq_dec String.string_dec p p) as [_|Hcontra]; [|destruct (Hcontra eq_refl)].
143138
destruct n as [nt perms cont]; simpl in *.
144139
subst nt. subst cont.
145140
reflexivity.
@@ -180,7 +175,7 @@ Proof.
180175
unfold write_file.
181176
destruct (list_eq_dec String.string_dec p p) as [_|Hcontra].
182177
+ destruct (fs p) as [node|] eqn:Hfs.
183-
* simpl. destruct (node_type node); reflexivity.
178+
* destruct (node_type node) eqn:Hnt; cbn; try rewrite Hnt; reflexivity.
184179
* simpl. reflexivity.
185180
+ contradiction.
186181
- reflexivity.
@@ -271,15 +266,12 @@ Proof.
271266
subst p'.
272267
unfold read_file in Hread.
273268
destruct Hpre as [node [Hnode [Htype [perms [Hperms Hwrite]]]]].
274-
rewrite Hnode in Hread.
275-
rewrite Htype in Hread.
276-
simpl in Hread.
277-
injection Hread as Heq.
269+
assert (Hc : node_content node = Some content).
270+
{ rewrite Hnode in Hread. cbn in Hread.
271+
rewrite Htype in Hread. exact Hread. }
278272
rewrite Hnode.
279-
rewrite Htype.
280-
destruct node; simpl in *.
281-
subst node_type0.
282-
subst node_content0.
273+
destruct node as [nt nperms ncont]; simpl in *.
274+
subst nt. subst ncont.
283275
reflexivity.
284276
+ (* p <> p' *)
285277
reflexivity.

proofs/coq/filesystem_model.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ Definition parent_exists (p : Path) (fs : Filesystem) : Prop :=
9999
Definition has_write_permission (p : Path) (fs : Filesystem) : Prop :=
100100
exists node, fs p = Some node /\ writable (permissions node) = true.
101101

102+
(** Path has read permission *)
103+
Definition has_read_permission (p : Path) (fs : Filesystem) : Prop :=
104+
exists node, fs p = Some node /\ readable (permissions node) = true.
105+
102106
(** Directory is empty (has no children) *)
103107
Definition is_empty_dir (p : Path) (fs : Filesystem) : Prop :=
104108
is_directory p fs /\

0 commit comments

Comments
 (0)