[英]How to prove something obviously logical - list_get problem in Prop
問題是我無法跳過步驟就不能對H進行歸納。 我應該得到一些instr0來應用標准引理:
Lemma get_Some {A} (l:list A) n x :
list_get l n = Some x -> n < length l.
Proof.
revert n. induction l; destruct n; simpl; try discriminate.
- auto with arith.
- intros. apply IHl in H. auto with arith.
Qed.
坦率地說,首先想到的是展開Step的定義,然后嘗試對list_get進行歸納。
Lemma getthatStep code m m' (n := List.length code):
Step code m m' -> pc m < length code .
1 subgoal
code : list instr
m, m' : machine
n := length code : nat
H : match list_get code (pc m) with
| Some instr0 => Stepi instr0 m m'
| None => False
end
______________________________________(1/1)
pc m < length code
似乎很明顯,但是我很受阻。
這里有一些關於類型的信息:
Record machine :=Mach {
(** Pointeur de code *)
pc : nat;
(** Pile principale *)
stack : list nat;
(** Pile de variables *)
vars : list nat
}.
Inductive instr :=
| Push : nat -> instr
| Pop : instr
| Op : op -> instr
| NewVar : instr
Inductive Stepi : instr -> machine -> machine -> Prop :=
| SPush pc stk vs n : Stepi (Push n) (Mach pc stk vs) (Mach (S pc) (n::stk) vs)
| SPop pc stk vs x : Stepi Pop (Mach pc (x::stk) vs) (Mach (S pc) stk vs)
| SOp pc stk vs o y x : Stepi (Op o) (Mach pc (y::x::stk) vs) (Mach (S pc) (eval_op o x y :: stk) vs). ```
(* Takes two machines and a list of instructions if their code
is valid it returns true else it returns false *)
Definition Step (code:list instr) (m m' : machine) : Prop :=
match list_get code m.(pc) with
| Some instr => Stepi instr m m'
| None => False
end.
您可以使用destruct (list_get code (pc m)) eqn:H'
獲得相關信息。 這將為您提供足夠的信息,以在一種情況下應用引理,並在另一種情況下通過exfalso
證明目標。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.