Zulip Chat Archive

Stream: new members

Topic: How to get the proof of not equal to previous terms in match


ShatteredLead (Oct 17 2024 at 09:50):

  def g (x : ) :  :=
    match x with
      | 0 => 1
      | 1 => -- there's something requires x ≠ 0, and how can we prove it?

Edward van de Meent (Oct 17 2024 at 09:52):

do you mean match x with?

ShatteredLead (Oct 17 2024 at 09:52):

Edward van de Meent said:

do you mean match x with?

Yeah, sorry for the typo

Edward van de Meent (Oct 17 2024 at 09:53):

i think easiest way would be to use if h:x=0 then default else [insert term using h]

Daniel Weber (Oct 17 2024 at 09:58):

You can also do

import Mathlib

def g (x : ) :  :=
  match h : x with
    | 0 => 1
    | 1 =>
      -- h : x = 1
      sorry
    | _ => sorry

Edward van de Meent (Oct 17 2024 at 09:59):

ooh, i didn't know about that one, that does look better!

ShatteredLead (Oct 17 2024 at 10:00):

appreciate it!

ShatteredLead (Oct 17 2024 at 10:07):

Daniel Weber said:

You can also do

import Mathlib

def g (x : ) :  :=
  match h : x with
    | 0 => 1
    | 1 =>
      -- h : x = 1
      sorry
    | _ => sorry

  def g (x : ) :  :=
    match h: x with
      | 0 => -- ...
      | 1 => -- ...
      | 2 => -- ...
      | k => -- how to get x > 2 here?

But in this situation, it seems we only can know h : x = k

Yaël Dillies (Oct 17 2024 at 10:13):

def g (x : ) :  :=
  match h : x with
  | 0 => _
  | 1 => _
  | 2 => _
  | k + 3 => _

Last updated: May 02 2025 at 03:31 UTC