-
Notifications
You must be signed in to change notification settings - Fork 58
Feature exception #806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feature exception #806
Conversation
86c4195 to
00cfe75
Compare
415a5d1 to
b415379
Compare
b717865 to
7e145ca
Compare
cac4299 to
8a1385e
Compare
1185838 to
ee89281
Compare
ee89281 to
85bc11d
Compare
ae978f0 to
2fa2c24
Compare
2fa2c24 to
ee9b68e
Compare
ee9b68e to
2719b38
Compare
| proof. | ||
| proc. | ||
| wp. | ||
| auto => &hr <- />. smt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use smt(). instead of smt.
or
auto => /> /#.
| proof. | ||
| proc. | ||
| wp. | ||
| auto => &hr <- />. smt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| es_sr : stmt; | ||
| es_po : form; } | ||
|
|
||
| and post = (form * (EcPath.path, form) DMap.t * form option) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can remove form option if we create a special path "_".
Having special path can be useful also if we want to have return anywhere in the code: we can have a return exception. Similarly if we want to add "break".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to use a different name than post. Maybe hoare_post.
|
|
||
| let lift_hs_ss_inv (f: ss_inv -> hs_inv -> 'a) : inv -> inv -> 'a = | ||
| let f inv1 inv2 = match inv1, inv2 with | ||
| | Inv_ss ss1, Inv_hs ss2 -> f ss1 ss2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ss2 seems to be a strange name for a hs_inv
| let lift_hs_ss_inv (f: ss_inv -> hs_inv -> 'a) : inv -> inv -> 'a = | ||
| let f inv1 inv2 = match inv1, inv2 with | ||
| | Inv_ss ss1, Inv_hs ss2 -> f ss1 ss2 | ||
| | _ -> failwith "expected only single sided invariants" in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message does not reflect the pattern matching.
| ~tbh:err | ||
| ~te:(t_equiv_case ?simplify f) | ||
| tc | ||
| | _ -> tc_error !!tc "exception are not supported" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an assert false
| if not (Mpv2.subset eqm eqXs) then raise EqObsInError; | ||
| let eqi = Mpv2.union eqIs eqnm in | ||
| (fhyps, Mpv2.add_eqs env el er eqi) | ||
| | Sraise _e1, Sraise _e2 -> assert false (* FIXME *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a good error message.
| let check_branch (_, s) = check_bad_true env bad s.s_node in | ||
| List.iter (check_branch) bs | ||
| | Sassert _ -> () | ||
| | Sraise _ -> assert false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a correct error message
|
|
||
| | Sassert e -> | ||
| (w, e_read_r env r e, c) | ||
| | Sraise _ -> assert false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a correct error message
| | Not_found -> | ||
| match d with | ||
| | Some d -> d | ||
| | None -> tacuerror "unknow exception %a" EcPrinting.pp_path e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve error message
This PR introduce exceptions for Hoare Logic.
We can define exception :
We can raise exception using
raise assumeorraise (x = 3) assert(raise an exception when a condition is not true):We can define postconditions for each exception and a default postcondition:
Examples are available in
examples/exception.ec.