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

Unable to figure the term when destructing an inductive proposition #5700

Closed
fduxiao opened this issue Oct 14, 2024 · 2 comments
Closed

Unable to figure the term when destructing an inductive proposition #5700

fduxiao opened this issue Oct 14, 2024 · 2 comments

Comments

@fduxiao
Copy link

fduxiao commented Oct 14, 2024

I defined a simple type and a simple relation.

inductive Three: Type where
  | a | b | c

inductive Rel3: Three -> Three -> Prop where
  | ab: Rel3 a b
  | cb: Rel3 c b

Rel3 is obviously transitive.

theorem rel3_trans: forall {x y z: Three}, Rel3 x y -> Rel3 y z -> Rel3 x z := sorry

I tried to prove it. But lean failed to figure out the correct term if you destruct some of type Rel3 x y

theorem rel3_trans: forall {x y z: Three}, Rel3 x y -> Rel3 y z -> Rel3 x z := by
  intros x y z Hxy Hyz
  cases Hxy
  case ab =>
    -- Here in case ab, Hyz should be `Rel3 b z`, but lean sticked to `Rel3 y z`.
    -- And, you are unable to destruct `Hyz` again by `cases Hyz`
    admit
  case cb =>
    admit

If you use cases Hyz in the above, lean will complain that tactic 'induction' failed, major premise type is not an inductive type.

Meanwhile, you can prove this in Coq.

Inductive Three :=
  | a | b | c.

Inductive Rel3: Three -> Three -> Prop :=
  | ab: Rel3 a b
  | cb: Rel3 c b.


Theorem rel3_trans: forall x y z: Three, Rel3 x y -> Rel3 y z -> Rel3 x z.
Proof.
  intros x y z Hxz Hyz.
  destruct Hxz.
  - destruct Hyz.
    + apply ab.
    + apply ab.
  - destruct Hyz.
    + apply cb.
    + apply cb.
Qed.

Am I using the correct strategy to prove that? In lean, how do you prove it?

@fduxiao
Copy link
Author

fduxiao commented Oct 14, 2024

What about this one even simpler?

inductive T: Type where
  | a | b

inductive R: T -> T -> Prop where
  | r: R a b

example: Not (R b a) := by
  intros H
  cases H
  admit

@digama0
Copy link
Collaborator

digama0 commented Oct 14, 2024

Questions of this nature are better suited for the Zulip, please use issues on this repo only to report actual issues in lean.

The error in your code is that a and b in Rel3 are being interpreted as variables, not elements of Three, because they are namespaced as Three.a and Three.b, so you can either write that or use .a and .b in the definition of Rel3. If you would like to avoid the implicit introduction of a and b as variables, you should use set_option autoImplicit true or add it as a global setting in the lakefile.

inductive Three: Type where
  | a | b | c

inductive Rel3: Three -> Three -> Prop where
  | ab: Rel3 .a .b
  | cb: Rel3 .c .b

theorem rel3_trans: forall {x y z: Three}, Rel3 x y -> Rel3 y z -> Rel3 x z := by
  intros x y z Hxy Hyz
  cases Hxy <;> cases Hyz

@digama0 digama0 closed this as completed Oct 14, 2024
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

No branches or pull requests

2 participants