feat: iinduction#430
Open
alvinylt wants to merge 184 commits into
Open
Conversation
…sses.lean and its type class instances to Instances.lean
This also requires generalisation of ProofModeContinuation
…ext into Iris proof state
To-do: 1. Bug: Some kernel mismatch error when the tactic is used 2. Bug: The variable being performed induction on becomes unnamed 3. Bug: The induction hypotheses are unnamed 4. Feature: Introduction patterns
…bility regarding IH naming
To-do: 1. Prove that the spatial context is empty after reverting hypotheses 2. Remaining tactic syntax 3. Remaining two IntoIH instance
…on of dependent hypotheses
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements the
iinductiontactic.Addresses #360.
This tactic uses the type class
IntoIHand its instances, which are ported fromcoq_tactics.vin the Rocq version.TwoOne of them (intoIH_listForallandintoIH_listForall₂)areis newly created in this PR. The type class itself and other instances were already created by @HaleOIC, and have now been moved from Induction.lean to Classes.lean and Instances.lean, respectively.IntoIHIntoIHintoIH_entailsinto_ih_entailsintoIH_forallinto_ih_forallintoIH_impinto_ih_implintoIH_listForallInstances.leaninto_ih_ForallintoIH_listForall₂into_ih_Forall2The mechanism is basically the same as those in Rocq, but the tactic syntax for induction is quite different in Lean. The implementation of
iinductiontherefore intends to follow the syntax ofinductionas detailed in the language specifications of Lean:iinduction eiinduction e using riinduction e generalizing z₁ ... zₙ: note thatz₁ ... zₙis implemented as selection patterns (SelPat) and, as a result, there are no restrictions regarding the order of regular Lean variables and Iris hypothesis names.iinduction e with | constr₁ => tac₁ | ... | constrₙ => tacₙ: the constructor names can either be long (e.g.,Nat.zero) or short (e.g.,zero). Arguments are optionally given names or otherwise remain inaccessible.In a nutshell, the
iinductiontactic performs the following steps:eif it does not directly correspond to anFVarIdvalue.generalizingis used) Revert Iris hypotheses explicitly specified by the user.generalizingis used) Revert pure Lean variables explicitly specified by the user.withis used) Check that the constructor patterns (alternative names) provided by the user are valid.Lean.Meta.Tactic.inductionto obtain the induction subgoals.withis used) Handle the tactic sequences for each induction subgoal.The tactic syntax can be used in combination:
iinduction e using r with | constr₁ => tac₁ | ... | constrₙ => tacₙiinduction e using r generalizing z₁ ... zₙiinduction e generalizing z₁ ... zₙ with | constr₁ => tac₁ | ... | constrₙ => tacₙiinduction e using r generalizing z₁ ... zₙ with | constr₁ => tac₁ | ... | constrₙ => tacₙSimilar to the built-in
inductiontactic in Lean, the variables and induction hypotheses are assigned inaccessible names unless the user specifies them using thewithsyntax. For example, by usingiinduction nwheren : Nat, one may getn✝andn_ih✝in the step case. Meanwhile, the following assigns the variable and the induction hypothesis the namesnandih, respectively.iinduction n with | zero => ... | succ n ih => ...One can also use underscores for the variables to remain inaccessible. This is made possible with Lean's
binderIdent. For example, one can get the unnamed variablen✝and the named induction hypothesisih:Several functions in Induction.lean are introduced to parse the syntax and handle the constructor names properly. This handles subtle caveats such as duplicate, missing and/or invalid constructor names.
Checklist
authorssection of any appropriate files