Skip to content

fix first_hyp and all_hyps bugs - #1518

Open
bodeveix wants to merge 2 commits into
Deducteam:masterfrom
bodeveix:fix-iters
Open

bodeveix wants to merge 2 commits into
Deducteam:masterfrom
bodeveix:fix-iters

Conversation

@bodeveix

Copy link
Copy Markdown
Collaborator

This patch fixes errors linked to the \eta profiles and allows tactics without side effects to be considered as successful by first_hyp.

@fblanqui fblanqui left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jean-Paul for your PR. Here are my comments:

Comment thread tests/OK/first_hyp.lp Outdated
begin
assume T a b h1 h2;
first_hyp (λ _ _ ph, #apply ph);
debug +t;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be removed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Comment thread tests/OK/first_hyp.lp
assume T a b h1 h2;
first_hyp (λ _ _ ph, #apply ph);
debug +t;
first_hyp (λ l (v: U l) (ph: η v), #apply ph);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are type annotations necessary?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes and this is why I declared #first_hyp parameters mandatory in Tactic.lp even it concerns first_hyp.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are type annotations necessary?

Comment thread tests/OK/Tactic.lp
builtin "fail" ≔ #fail;

constant symbol #first_hyp: (Π [l] [a:U l], η a → Tactic) → Tactic;
constant symbol #first_hyp: (Π l (a:U l), η a → Tactic) → Tactic;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why l is not declared as implicit?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to recall they are mandatory in first_hyp (without the '#').

Comment thread CHANGES.md Outdated
of underlining the whole command or tactic (symbol body, rule right-hand
side, proof, etc.).
- Tactics first_hyp and all_hyps made compatible with \eta signatures.
Tactic first_hyp considers #nothing has a success.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add anything in CHANGES (CHANGES record main changes wrt the previous release, not the commit history).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Comment thread src/handle/tactic.ml Outdated
let p = new_problem() in
let ml = mk_Meta(LibMeta.fresh p (Env.to_prod env mk_Level) n,args) in
let mt = mk_Meta(LibMeta.fresh p (Env.to_prod env (mk_univ ml)) n,args) in
let t = mk_Appl(mk_Appl(mk_Appl(t,ml),mt),mk_Vari v) in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use add_args instead if you want.

Comment thread tests/OK/all_hyps.lp
begin
assume T a b c h1 h2;
all_hyps (λ _ h ph, #rewrite "" "" ph);
all_hyps (λ l (h:U l) (ph: η h), #rewrite "" "" ph);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are type annotations necessary?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, in all_hyps

Comment thread tests/OK/first_hyp.lp Outdated
@@ -1,17 +1,16 @@
require open tests.OK.Tactic;
require open tests.OK.Prop tests.OK.Set tests.OK.Univ tests.OK.Tactic;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please minimize the number of required files.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Comment thread tests/OK/first_hyp.lp Outdated
begin
assume T a b h1 h2;
eval #first_hyp (λ _ _ ph, #apply ph);
eval (#first_hyp (λ l (v: U l) ph, #apply ph));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are type annotations and outer parentheses necessary?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK type annotations are useless in #first_hyp

Comment thread src/handle/tactic.ml Outdated
let check id =
if Env.mem id.elt env then fatal id.pos "Identifier already in use." in
(* tries to apply tactic t on context variable v *)
let apply_context ps c g v t =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name does not really correspond to the comment. What about apply_hyp?

I would also precise in the comment that t is a tactic term.

The function apply_hyp is iterated many times but many let's below are identical in each call. It would be better to compute them only once. The let's below should be done before calling the function and passed as arguments. This creates some duplication in the code below but that's ok I think.
In the end, we would get:

(* tries to apply tactic term t on context variable v *)
let apply_hyp ps g c t v level univ n args = ...

where:

 let level = mk_Symb(Builtin.get ss pos [] "Level") in
 let univ = mk_Symb(Builtin.get ss pos [] "Univ") in
 let n = List.length env in
 let args = Env.to_terms env in

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants