leanprover / leanprover/lean4

RFC: Induction should (like cases) allow non-variable targets

Open
#9,303 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-low RFC
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Proposal

Reasoning about e.g. Big-Step Semantics needs induction over a Predicate containing a tuple.
Cases works nicely with this, however induction doesn't, and sometimes one really needs the induction hypothesis:

def State : Type :=
  String → Nat

inductive Stmt : Type where
  | skip       : Stmt
  | seq        : Stmt → Stmt → Stmt

infixr:90 "; " => Stmt.seq

inductive BigStep : Stmt × State → State → Prop where
  | skip (s) :
    BigStep (Stmt.skip, s) s
  | seq (S T s t u) (hS : BigStep (S, s) t)
      (hT : BigStep (T, t) u) :
    BigStep (S; T, s) u

infix:110 " ⟹ " => BigStep

theorem BigStep_deterministic {S s l r} (hl : (S,s) ⟹ l)
      (hr : (S,s) ⟹ r) :
    l = r :=
  by
    induction hl --fails, but cases is not enough here (for the 2nd goal)

The only workaround i know for this, is to express everything in terms of a tuple Ss.

Impact

Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failing induction hl example and compare it with cases. The payload names no source file or test; trace the induction elaboration path and define done as making the theorem work with a non-variable target while preserving existing cases behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.