Skip to content

Commit

Permalink
pred -> op
Browse files Browse the repository at this point in the history
  • Loading branch information
strub committed Jan 17, 2025
1 parent 402f680 commit 3bffb26
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 20 deletions.
4 changes: 2 additions & 2 deletions examples/ChaChaPoly/chacha_poly.ec
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ theory C.
clone include Subtype with
type sT <- counter,
type T <- int,
pred P <- fun (i:int) => 0 <= i < max_counter + 1
op P <- fun (i:int) => 0 <= i < max_counter + 1
rename [op] "insubd" as "ofint"
proof *.

Expand Down Expand Up @@ -124,7 +124,7 @@ abstract theory GenBlock.
clone include Subtype with
type sT <- block,
type T <- bytes,
pred P <- fun (l:bytes) => size l = block_size
op P <- fun (l:bytes) => size l = block_size
rename [op] "val" as "bytes_of_block"
proof *.

Expand Down
2 changes: 1 addition & 1 deletion src/ecScope.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1982,7 +1982,7 @@ module Ty = struct
evc_types = Msym.of_list [
"T", loced (`ByPath carrier, `Inline `Clear)
];
evc_preds = Msym.of_list [
evc_ops = Msym.of_list [
"P", loced (`Direct pred, `Inline `Clear)
];
evc_lemmas = {
Expand Down
12 changes: 6 additions & 6 deletions src/ecThCloning.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,19 @@ type axclone = {
}

(* ------------------------------------------------------------------ *)
type xty_override = ty_override
type xop_override = op_override
type xnt_override = nt_override
type xop_override =
[op_override_def genoverride | `Direct of EcAst.form] * clmode

(* ------------------------------------------------------------------ *)
type xpr_override =
[pr_override_def genoverride | `Direct of EcAst.form] * clmode

(* ------------------------------------------------------------------ *)
type evclone = {
evc_types : (xty_override located) Msym.t;
evc_types : (ty_override located) Msym.t;
evc_ops : (xop_override located) Msym.t;
evc_preds : (xpr_override located) Msym.t;
evc_abbrevs : (xnt_override located) Msym.t;
evc_abbrevs : (nt_override located) Msym.t;
evc_modexprs : (me_override located) Msym.t;
evc_modtypes : (mt_override located) Msym.t;
evc_lemmas : evlemma;
Expand Down Expand Up @@ -298,7 +297,8 @@ end = struct
(fun evc ->
if Msym.mem x evc.evc_ops then
clone_error oc.oc_env (CE_DupOverride (OVK_Operator, name));
{ evc with evc_ops = Msym.add x (mk_loc lc opd) evc.evc_ops })
{ evc with evc_ops =
Msym.add x (mk_loc lc opd :> xop_override located) evc.evc_ops })
nm evc

in (proofs, evc)
Expand Down
9 changes: 4 additions & 5 deletions src/ecThCloning.mli
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@ exception CloneError of EcEnv.env * clone_error
val clone_error : EcEnv.env -> clone_error -> 'a

(* ------------------------------------------------------------------ *)
type xty_override = ty_override
type xop_override = op_override
type xnt_override = nt_override
type xop_override =
[ op_override_def genoverride | `Direct of EcAst.form ] * clmode

(* ------------------------------------------------------------------ *)
type xpr_override =
[ pr_override_def genoverride | `Direct of EcAst.form ] * clmode

(* -------------------------------------------------------------------- *)
type evclone = {
evc_types : (xty_override located) Msym.t;
evc_types : (ty_override located) Msym.t;
evc_ops : (xop_override located) Msym.t;
evc_preds : (xpr_override located) Msym.t;
evc_abbrevs : (xnt_override located) Msym.t;
evc_abbrevs : (nt_override located) Msym.t;
evc_modexprs : (me_override located) Msym.t;
evc_modtypes : (mt_override located) Msym.t;
evc_lemmas : evlemma;
Expand Down
9 changes: 9 additions & 0 deletions src/ecTheoryReplay.ml
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,15 @@ and replay_opd (ove : _ ovrenv) (subst, ops, proofs, scope) (import, x, oopd) =

| _ -> clone_error env (CE_UnkOverride(OVK_Operator, EcPath.toqsymbol p))
end

| `Direct body ->
assert (List.is_empty refop.op_tparams);
let newop =
mk_op
~opaque:optransparent ~clinline:(opmode <> `Alias)
[] body.f_ty (Some (OP_Plain body)) refop.op_loca in
(newop, body)

in
match opmode with
| `Alias ->
Expand Down
2 changes: 1 addition & 1 deletion theories/algebra/Poly.ec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type poly.
clone include Subtype
with type sT <- poly,
type T <- prepoly,
pred P <- ispoly
op P <- ispoly
rename "insub" as "to_poly"
rename "val" as "of_poly"
proof *.
Expand Down
2 changes: 1 addition & 1 deletion theories/algebra/ZModP.ec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type zmod.
clone Subtype as Sub with
type sT <- zmod,
type T <- int,
pred P <- fun (x : int) => 0 <= x < p
op P <- fun (x : int) => 0 <= x < p
proof *.

realize inhabited.
Expand Down
2 changes: 1 addition & 1 deletion theories/datatypes/Word.eca
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type word.
clone include Subtype with
type sT <- word,
type T <- t list,
pred P <- fun w => size w = n
op P <- fun w => size w = n
proof *.

realize inhabited.
Expand Down
2 changes: 1 addition & 1 deletion theories/datatypes/Xreal.ec
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type realp.
clone include Subtype with
type sT <- realp,
type T <- real,
pred P <- fun x => 0.0 <= x
op P <- fun x => 0.0 <= x
rename "insubd" as "of_real"
rename "val" as "to_real"
proof *.
Expand Down
2 changes: 1 addition & 1 deletion theories/structure/Quotient.ec
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type qT.
clone import Subtype with
type sT <- qT,
type T <- T,
pred P <- iscanon
op P <- iscanon
proof *.

realize inhabited.
Expand Down
3 changes: 2 additions & 1 deletion theories/structure/Subtype.eca
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ pragma +implicits.
require import AllCore.

type T, sT.
pred P : T.

op P : T -> bool.

op insub : T -> sT option.
op val : sT -> T.
Expand Down

0 comments on commit 3bffb26

Please sign in to comment.