Skip to content
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

Add (un)set_then_multiple_subgoals to control the behavior of THEN #113

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

aqjune-aws
Copy link
Contributor

This patch adds unset_then_multiple_subgoals and set_then_multiple_subgoals that controls the behavior of THEN with respect to the number of subgoals that its first tactic generated.

This is useful when one wants to check whether a proof written using THEN can be syntactically converted to the e-g form.
If this flag is set to true, t1 THEN t2 THEN .. can be converted to e(t1);; e(t2);; ... (modulo the validity check). To roll back the behavior of THEN to the default version, use set_then_multiple_subgoals.

  # prove(`x + 1 = 1 + x /\ x + 2 = 2 + x`, CONJ_TAC THEN ARITH_TAC);;
  val it : thm = |- x + 1 = 1 + x /\ x + 2 = 2 + x

  # unset_then_multiple_subgoals;;
  val it : bool = false
  # prove(`x + 1 = 1 + x /\ x + 2 = 2 + x`, CONJ_TAC THEN ARITH_TAC);;
  Exception: Failure "seqapply: Length mismatch".
  # prove(`x + 1 = 1 + x /\ x + 2 = 2 + x`, CONJ_TAC THENL [ARITH_TAC; ARITH_TAC]);;
  val it : thm = |- x + 1 = 1 + x /\ x + 2 = 2 + x
  # prove(`x + 1 = 1 + x /\ x + 2 = 2 + x`, CONJ_TAC THENL (replicate ARITH_TAC 2));;
  val it : thm = |- x + 1 = 1 + x /\ x + 2 = 2 + x

Also, this patch adds a Help document for unset_jrh_lexer which was missing (but not set_jrh_lexer for brevity; the command is simply mentioned in unset_jrh_lexer).

@aqjune-aws
Copy link
Contributor Author

As a sanity check I turned this flag on and ran BIGNUM_COPY_CORRECT and it worked well. :)

Copy link
Owner

@jrh13 jrh13 left a comment

Choose a reason for hiding this comment

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

Indeed, this might be quite helpful for those finding the THEN structure with multiple subgoals confusing. And thanks for catching the missing Help file for unset_jrh_lexer!
These are rather special cases where the preprocessor is doing something magical, so maybe it is worth emphasizing that they are not exactly Boolean variables in the usual sense but also not functions, perhaps more like Boolean constants. The latter means that saying "is called" may be a bit confusing without further explanation, even though the example shows it quite explicitly. On the other hand, I am not sure myself how to best clarify it.

@aqjune-aws
Copy link
Contributor Author

aqjune-aws commented Oct 7, 2024

This is my trial to change their types from bool to (preprocessor keyword). :) I omitted their actual OCaml type which is bool because it seemed less important. Also slightly edited the sentences from called to read by a preprocessor.

--

Slightly updated the sentences further to remove usage of 'flag'.

This patch adds `unset_then_multiple_subgoals` and `set_then_multiple_subgoals` that
controls the behavior of `THEN` with respect to the number of subgoals that its first
tactic generated.

This is useful when one wants to check whether a proof written using `THEN` can
be syntactically converted to the `e`-`g` form.
If this flag is set to true, `t1 THEN t2 THEN ..` can be converted to
`e(t1);; e(t2);; ...` (modulo the validity check).
To roll back the behavior of `THEN` to the default version, use `set_then_multiple_subgoals`.

```
  # prove(`x + 1 = 1 + x /\ x + 2 = 2 + x`, CONJ_TAC THEN ARITH_TAC);;
  val it : thm = |- x + 1 = 1 + x /\ x + 2 = 2 + x

  # unset_then_multiple_subgoals;;
  val it : bool = false
  # prove(`x + 1 = 1 + x /\ x + 2 = 2 + x`, CONJ_TAC THEN ARITH_TAC);;
  Exception: Failure "seqapply: Length mismatch".
  # prove(`x + 1 = 1 + x /\ x + 2 = 2 + x`, CONJ_TAC THENL [ARITH_TAC; ARITH_TAC]);;
  val it : thm = |- x + 1 = 1 + x /\ x + 2 = 2 + x
  # prove(`x + 1 = 1 + x /\ x + 2 = 2 + x`, CONJ_TAC THENL (replicate ARITH_TAC 2));;
  val it : thm = |- x + 1 = 1 + x /\ x + 2 = 2 + x
```

Also, this patch adds a Help document for `unset_jrh_lexer` which was missing
(but not `set_jrh_lexer` for brevity; the command is simply mentioned in `unset_jrh_lexer`).
Copy link
Owner

@jrh13 jrh13 left a comment

Choose a reason for hiding this comment

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

Thank you, this all looks good now!

@jrh13 jrh13 merged commit 4563ae5 into jrh13:master Oct 8, 2024
2 checks passed
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