coq field tactic fails to simplify, yeilds “m <> 0%R”

痞子三分冷 提交于 2020-07-23 06:15:29

问题


I'm new to Coq. I've been working through Pierce's Logical Foundations. I'm stepping into new ground.

I'm trying use of the field tactic for the first time. I use it thrice in the below theorem. Twice it fails, yielding m <> 0%R where m is a term in context.

I'm sure I just fail to understand proper use. May someone enlighten me? (I tried reading this doc page but didn't gain much understanding!)

From Coq Require Import Reals.Reals. 
Require Import Field.

Definition simple_compound (A r n m : R) : R :=
  A * (Rpower (1 + r / m) (m * n)). 
Definition continuous_compound (A r n: R) : R :=
  A * (exp (r * n)).
Definition simple_to_continuous_interest (Rs n m: R) : R :=
  m * ln (1 + Rs / m). 
Definition continuous_to_simple_interest (Rc n m: R) : R :=
  m * ((exp (Rc / m)) - 1). 

Theorem continuous_to_simple_works : forall (A Rc n m : R),
  continuous_compound A Rc n = simple_compound A (continuous_to_simple_interest Rc n m) n m. 
Proof.
  intros A Rc n m.
  unfold continuous_compound. unfold simple_compound. unfold continuous_to_simple_interest.
  unfold Rpower. apply f_equal.
  assert (H: (m * (exp (Rc / m) - 1) / m)%R = (exp (Rc / m) - 1)%R). {
    field. admit.
  }
  rewrite -> H. 
  assert (H2: (1 + (exp (Rc / m) - 1))%R = (exp (Rc / m))%R). {
    field. 
  }
  rewrite -> H2. 
  assert (H3: (m * n * ln (exp (Rc / m)))%R = (ln (exp (Rc / m)) * m * n)%R). {
    rewrite -> Rmult_comm. rewrite -> Rmult_assoc. reflexivity. 
  }
  rewrite -> H3. 
  rewrite -> ln_exp. 
  assert (H4: (Rc / m * m)%R = Rc%R). {
    field. admit. 
  }
  rewrite -> H4. 
  reflexivity. 
Admitted. 

回答1:


That is expected. Your first use of field is on a goal akin to (m * x) / m = x. There is absolutely no way of defining the division over real numbers so that this equality holds for all real numbers x when m is equal to 0. So, the field tactic is able to prove this equality only if you are able to prove m <> 0. Your third use of field is on an equality (x / m) * m = x, and again, it can only hold for any x if you know that m is nonzero.



来源:https://stackoverflow.com/questions/62922088/coq-field-tactic-fails-to-simplify-yeilds-m-0r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!