Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
46a0789
Start implementing iinduction: move IntoIH from Induction.lean to Cla…
alvinylt May 26, 2026
5421a78
Simple iinduction test
alvinylt May 28, 2026
562fd64
Use evalTacticAt for iinduction
alvinylt May 28, 2026
9af4f6f
Try using iRevertCore and iIntroCore separately
alvinylt May 28, 2026
72fd7a0
Finish the proof for iinduction
alvinylt May 28, 2026
a7aeae1
Use iRevertIntro instead of iRevertCore and iIntroCore separately
alvinylt May 28, 2026
6203c5f
Remove redundant Iris entailment in Lean context
alvinylt May 28, 2026
7035695
Avoid unnamed variable in generated induction subgoals
alvinylt May 28, 2026
e963f76
Revert all hypotheses in the intuitionistic context
alvinylt May 28, 2026
d9fa30a
Towards using IntoIH for moving induction hypothesis from Lean's cont…
alvinylt May 28, 2026
ffcdbb3
Revert only spatial and intuitionistic hypotheses that contain x
alvinylt May 29, 2026
e94141b
Use the result of IntoIH synthesis in addIntoIH
alvinylt May 29, 2026
8ba460a
Iteratively add induction hypotheses into the Iris proof state
alvinylt May 29, 2026
8524a82
Towards implementing findIHs
alvinylt May 29, 2026
998ffb8
Implement findIHs
alvinylt May 29, 2026
4bc644c
Remove induction hypotheses from the regular Lean context
alvinylt May 29, 2026
4f6817a
Adjust iHypsContaining
alvinylt May 29, 2026
ff5ea5c
Introducing IHs into the Iris intuitionstic context
alvinylt May 29, 2026
2f47ceb
Use Lean.Meta.Tactic.induction instead of evalTacticAt for more flexi…
alvinylt May 30, 2026
a9be948
Generalisation to find recursor name for induction
alvinylt May 30, 2026
c627c24
Towards having explicit variable names for induction hypotheses
alvinylt May 30, 2026
a11f967
Solve kernel mismatch, currently using a placeholder theorem
alvinylt May 30, 2026
b304c88
Implement InductionState, towards finishing the placeholder theorem
alvinylt May 30, 2026
7395139
Finish revert_IH proof, more assumptions required
alvinylt May 30, 2026
cbdadb6
Towards completing the use of InductionState
alvinylt May 30, 2026
5a5beaa
Port type class instances into_ih_Forall and into_ih_Forall2
alvinylt May 30, 2026
aa5f430
Finish proof for intoIH_listForall
alvinylt May 30, 2026
eab9ccf
Finish proof for intoIH_listForall2
alvinylt May 30, 2026
b6b03a1
Code refactoring and comments
alvinylt May 30, 2026
783ad43
Remove goal from InductionState, simplifications
alvinylt May 30, 2026
31e5633
Add test for iinduction
alvinylt May 31, 2026
bfd3e59
Obtain constructor names from inductInfo: towards allowing user-given…
alvinylt May 31, 2026
e5c7a22
Towards implementing the `with` syntax
alvinylt May 31, 2026
7d1cb7c
Pretty variables for cases in the `with` syntax
alvinylt May 31, 2026
b826e7f
Check for invalid alternative names and throw pretty error
alvinylt May 31, 2026
43b8215
Move most of elaboration code into iInductionCore for reusability
alvinylt May 31, 2026
48945d9
iInductionCore: alternative names being optional, use pattern matching
alvinylt May 31, 2026
7378f8d
Code refactoring
alvinylt May 31, 2026
3632223
More code refactoring
alvinylt May 31, 2026
1dbd7ac
More code refactoring 2 and fix tests
alvinylt May 31, 2026
e376e70
More code refactoring and formatting
alvinylt May 31, 2026
bff359b
Implement iinduction ... using ... (user-supplied recursor name)
alvinylt Jun 1, 2026
e87b607
Implement iinduction ... using ... with
alvinylt Jun 1, 2026
a8daced
Implement iinduction ... generalizing ...
alvinylt Jun 1, 2026
ab75206
Fix iinduction ... generalizing ...
alvinylt Jun 1, 2026
34fece6
Use binderIdent instead of ident for `with` syntax to support undersc…
alvinylt Jun 1, 2026
cc81368
Catch invalid, missing and duplicate constructor names when `with` sy…
alvinylt Jun 1, 2026
1525cd2
Hypotheses explicitly reverted by the user using the `generalized` sy…
alvinylt Jun 1, 2026
559ba5a
Consolidate tests for iinduction
alvinylt Jun 1, 2026
10589a5
Define new function isIrisGoalWithForalls for findIHs: search for Iri…
alvinylt Jun 1, 2026
58efe2c
Fix priority of IntoIH instances
alvinylt Jun 1, 2026
062ec01
More iinduction tests
alvinylt Jun 1, 2026
9a17cba
Generalisation to provide support for expressions, not just idents
alvinylt Jun 1, 2026
18a9e31
Code formatting
alvinylt Jun 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Iris/Iris/ProofMode/Classes.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2022 Lars König. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Lars König, Michael Sammler, Alvin Tang
Authors: Lars König, Michael Sammler, Yunsong Yang, Alvin Tang
-/
module

Expand Down Expand Up @@ -208,18 +208,27 @@ class IntoLaterN {PROP} [BI PROP] (only_head : Bool) (n : Nat) (P : PROP) (Q : o
export IntoLaterN (into_laterN)

/-- `CombineSepAs` combines two propositions `P` and `Q` into `R` -/
@[ipm_class]
@[ipm_class, rocq_alias CombineSepAs]
class CombineSepAs [BI PROP] (P Q : PROP) (R : outParam PROP) where
combine_sep_as : P ∗ Q ⊢ R
export CombineSepAs (combine_sep_as)

/-- `CombineSepGives` combines two propositions `P` and `Q` for a proposition
with the `<pers>` modality -/
@[ipm_class]
@[ipm_class, rocq_alias CombineSepGives]
class CombineSepGives [BI PROP] (P Q : PROP) (R : outParam PROP) where
combine_sep_gives : P ∗ Q ⊢ <pers> R
export CombineSepGives (combine_sep_gives)

/-
`IntoIH φ P Q` describes how to turn a pure induction hypothesis `φ` into a proofmode
hypothesis `Q` under an intuitionistic BI context `□ P`.
-/
@[ipm_class, rocq_alias IntoIH]
class IntoIH [BI PROP] (φ : Prop) (P : PROP) (Q : outParam PROP) where
into_ih : φ → □ P ⊢ Q
export IntoIH (into_ih)

#rocq_ignore elim_inv_tc_opaque "No tc_opaque in Lean"
#rocq_ignore elim_modal_tc_opaque "No tc_opaque in Lean"
#rocq_ignore from_and_tc_opaque "No tc_opaque in Lean"
Expand Down
11 changes: 11 additions & 0 deletions Iris/Iris/ProofMode/Expr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ partial def Hyps.intuitionisticIVarIds {u prop bi} :
| _, .hyp _ _ ivar p _ _ => if isTrue p then [ivar] else []
| _, .sep _ _ _ _ lhs rhs => lhs.intuitionisticIVarIds ++ rhs.intuitionisticIVarIds

partial def Hyps.intuitionisticProps {u prop bi} :
∀ {s}, @Hyps u prop bi s → List Q($prop)
| _, .emp _ => []
| _, .hyp tm _ _ p _ _ => if isTrue p then [tm] else []
| _, .sep _ _ _ _ lhs rhs => lhs.intuitionisticProps ++ rhs.intuitionisticProps

variable (oldIVar : IVarId) (new : Name) {prop : Q(Type u)} {bi : Q(BI $prop)} in
def Hyps.rename : ∀ {e}, Hyps bi e → Option (Hyps bi e)
| _, .emp _ => none
Expand Down Expand Up @@ -484,6 +490,11 @@ structure IrisGoal where

def isIrisGoal (expr : Expr) : Bool := isAppOfArity expr ``Entails' 4

partial def isIrisGoalWithForalls (expr : Expr) : Bool :=
match expr.consumeMData with
| .forallE _ _ e _ => isIrisGoalWithForalls e
| e => isIrisGoal e

def parseIrisGoal? (expr : Expr) : Option IrisGoal := do
-- remove top-level metadata when matching on the goal
let expr := expr.consumeMData
Expand Down
67 changes: 67 additions & 0 deletions Iris/Iris/ProofMode/Instances.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module

public import Iris.BI
public import Iris.ProofMode.Classes
public import Iris.ProofMode.ClassesMake
public import Iris.ProofMode.ModalityInstances
public import Iris.Std.TC
public import Iris.Std.RocqPorting
Expand Down Expand Up @@ -917,3 +918,69 @@ instance combineSepGives_persistently [BI PROP] (Q1 Q2 P : PROP)
[h : CombineSepGives Q1 Q2 P] :
CombineSepGives iprop(<pers> Q1) iprop(<pers> Q2) iprop(<pers> P) where
combine_sep_gives := persistently_sep_2.trans (persistently_mono h.combine_sep_gives)

@[rocq_alias into_ih_entails]
instance intoIH_entails [BI PROP] (P Q : PROP) : IntoIH (P ⊢ Q) P Q where
into_ih := λ hpq => intuitionistically_elim.trans hpq

@[rocq_alias into_ih_forall]
instance (priority := default - 2) intoIH_forall [BI PROP] (φ : α → Prop) (P : PROP) (Φ : α → PROP)
[h : ∀ x, IntoIH (φ x) P (Φ x)] :
IntoIH (∀ x, φ x) P (BI.forall Φ) where
into_ih := by
intro hφ
apply forall_intro
intro x
exact (h x).into_ih (hφ x)

@[rocq_alias into_ih_impl]
instance (priority := default - 1) intoIH_imp [BI PROP] (φ ψ : Prop) (Δ P Q : PROP)
[h1 : MakeAffinely iprop(⌜φ⌝) P]
[h2 : IntoIH ψ Δ Q] :
IntoIH (φ → ψ) Δ iprop(P -∗ Q) where
into_ih := by
intro hImp
apply wand_intro
refine (sep_mono_r h1.make_affinely.mpr).trans ?_
refine persistent_and_affinely_sep_r.2.trans ?_
exact pure_elim_r (fun hφ => h2.into_ih (hImp hφ))

/-- Support for induction principles whose IH is guarded by `List.Forall`, e.g.
`∀ l, Forall P l → P (Tree l)` arising from nested inductive types like
`inductive ntree := Tree : List ntree → ntree`. -/
@[rocq_alias into_ih_Forall]
instance intoIH_listForall [BI PROP] (φ : α → Bool) (l : List α) (P : PROP) (Φ : α → PROP)
[h : ∀ x, IntoIH (φ x) P (Φ x)] :
IntoIH (l.all φ) P (bigSepL (fun _ a => iprop(□ Φ a)) l) where
into_ih := by
intro h1
induction l generalizing Φ with
| nil =>
simp [affine]
| cons x xs ih =>
simp [List.all, bigSepL] at h1 ⊢
rcases h1 with ⟨hx, hxs⟩
apply intuitionistically_sep_idem.mpr.trans
refine sep_mono ?_ ?_
· exact intuitionistically_intro' ((h x).into_ih hx)
· apply ih
apply (List.all_eq_true.mpr)
apply hxs

/-- Support for induction principles whose IH is guarded by `List.Forall₂`, e.g.
arising from mutual inductive types relating two lists element-wise. -/
@[rocq_alias into_ih_Forall2]
instance intoIH_listForall₂ [BI PROP] (φ : α → β → Prop) (l1 : List α) (l2 : List β)
(P : PROP) (Φ : α → β → PROP)
[h : ∀ x1 x2, IntoIH (φ x1 x2) P (Φ x1 x2)] :
IntoIH (List.Forall₂ φ l1 l2) P (bigSepL2 (fun _ x1 x2 => iprop(□ Φ x1 x2)) l1 l2) where
into_ih := by
intro h
induction h with
| nil => simp [bigSepL2, affine]
| cons x xs ih =>
simp [bigSepL2] at ⊢
apply intuitionistically_sep_idem.mpr.trans
refine sep_mono ?_ ?_
· exact intuitionistically_intro' ((h _ _).into_ih x)
· exact ih
1 change: 1 addition & 0 deletions Iris/Iris/ProofMode/Tactics.lean
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public meta import Iris.ProofMode.Tactics.ExFalso
public meta import Iris.ProofMode.Tactics.Exists
public meta import Iris.ProofMode.Tactics.Frame
public meta import Iris.ProofMode.Tactics.Have
public meta import Iris.ProofMode.Tactics.Induction
public meta import Iris.ProofMode.Tactics.Intro
public meta import Iris.ProofMode.Tactics.LeftRight
public meta import Iris.ProofMode.Tactics.Loeb
Expand Down
Loading