Skip to content

Commit cfc6423

Browse files
committed
Add proof3 in_channel reader
1 parent e3baf4d commit cfc6423

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

src/lib/proof3/entrypoint.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(** Entrypoint of a proof file.
22
33
This is the record containing the actual proof. *)
4-
type t = { tree: Tree_node.t (** The proof tree *) }
4+
type t = { tree: Tree_node.t Types.offset_for (** The proof tree *) }
55
[@@deriving twine, make, typereg, show { with_path = false }]
66
(** This is the entrypoint into a proof file, from which we explore proof steps,
77
the proof tree, etc. *)

src/lib/proof3/gen/proof_spec.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,20 @@
513513
"DeepProofStep"
514514
]
515515
},
516-
"doc": "Takes `A1…An,B ||- G` (main) and `C_i ||- A_i` (sides) and returns `B, C1…Cn ||- G`."
516+
"doc": "Takes `A1…An, B ||- G` (main) and `C_i ||- A_i` (sides) and returns `B, C1…Cn ||- G`."
517517
},
518518
{
519519
"name": "deep_intro",
520520
"ret": "DeepProofStep",
521521
"args": {
522522
"concl": "DeepSequent",
523-
"assumptions": ["List", "Sequent"],
523+
"assumptions": [
524+
"List",
525+
"Sequent"
526+
],
524527
"last_step": "ProofStep"
525528
},
526-
"doc": "Takes last step `A |- B`, a list of assumptions C1…Cn used to prove that last step, and returns `C1…Cn ||- (A |- B)`."
529+
"doc": "Takes last step `A |- B`, a list of assumptions [C1…Cn] used to prove that last step, and returns `C1…Cn ||- (A |- B)`."
527530
},
528531
{
529532
"name": "deep_subst",
@@ -553,4 +556,4 @@
553556
"doc": "Takes some form of reference to another proof file, and an offset `p` within that file. Intended to be used for subtasks."
554557
}
555558
]
556-
}
559+
}

src/lib/proof3/reader.ml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,23 @@ class twine ~(mt : Mir.Term.State.t) (str : string) : t =
6565
let off = Imandrakit_twine.Decode.get_entrypoint dec in
6666
Entrypoint.of_twine dec off
6767
end
68+
69+
class twine_in_channel ~(mt : Mir.Term.State.t) (ic : in_channel) : t =
70+
let dec = Imandrakit_twine.Decode.of_in_channel ic in
71+
let () = Mir.Term.State.add_to_dec dec mt in
72+
object
73+
method descr = "<twine in_channel reader>"
74+
75+
method read_step (p : Types.proof_step offset_for) : Types.proof_step =
76+
Imandrakit_twine.Decode.read_ref dec Types.proof_step_of_twine p
77+
78+
method read_deep_step (p : Types.deep_proof_step offset_for) =
79+
Imandrakit_twine.Decode.read_ref dec Types.deep_proof_step_of_twine p
80+
81+
method read_tree (p : Tree_node.t offset_for) =
82+
Imandrakit_twine.Decode.read_ref dec Tree_node.of_twine p
83+
84+
method read_entrypoint () : Entrypoint.t =
85+
let off = Imandrakit_twine.Decode.get_entrypoint dec in
86+
Entrypoint.of_twine dec off
87+
end

src/lib/proof3/types.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ and deep_proof_step =
248248
main: deep_proof_step offset_for;
249249
sides: deep_proof_step offset_for list
250250
}
251-
(** Takes [A1…An,B ||- G] (main) and [C_i ||- A_i] (sides) and returns [B, C1…Cn ||- G]. *)
251+
(** Takes [A1…An, B ||- G] (main) and [C_i ||- A_i] (sides) and returns [B, C1…Cn ||- G]. *)
252252
| Deep_intro of {
253253
concl: Deep_sequent.t;
254254
assumptions: Imandrax_api_mir.Sequent.t list;
255255
last_step: proof_step offset_for
256256
}
257-
(** Takes last step [A |- B], a list of assumptions C1…Cn used to prove that last step, and returns [C1…Cn ||- (A |- B)]. *)
257+
(** Takes last step [A |- B], a list of assumptions [C1…Cn] used to prove that last step, and returns [C1…Cn ||- (A |- B)]. *)
258258
| Deep_subst of {
259259
concl: Deep_sequent.t;
260260
p: deep_proof_step offset_for;

0 commit comments

Comments
 (0)