Proof Assistant Projects
Collection
Digesting proof assistant libraries for AI ingestion.
•
84 items
•
Updated
•
2
fact
stringlengths 7
47.5k
| type
stringclasses 15
values | library
stringclasses 5
values | imports
listlengths 0
49
| filename
stringclasses 182
values | symbolic_name
stringlengths 1
54
| docstring
stringclasses 1
value |
|---|---|---|---|---|---|---|
Z__range_adda0 a a1 (Ha: a0 <= a < a1) b0 b b1 (Hb : b0 <= b < b1)
: a0+b0 <= a+b < a1 + b1 - 1.
Proof. Lia.nia. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
Z__range_add
| |
Z__range_suba0 a a1 (Ha: a0 <= a < a1) b0 b b1 (Hb : b0 <= b < b1)
: a0-b1+1 <= a-b < a1 - b0.
Proof. Lia.nia. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
Z__range_sub
| |
Z__range_div_pos_const_rn0 n n1 (Hn : n0 <= n < n1) d (Hd : 0 < d)
: n0/d <= n/d < n1/d + 1.
Proof. Z.div_mod_to_equations. Lia.nia. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
Z__range_div_pos_const_r
| |
Z__range_mul_nonnega0 a a1 (Ha: a0 <= a < a1) b0 b b1 (Hb : b0 <= b < b1) (Ha0 : 0 <= a0) (Hb0 : 0 <= b0)
: a0*b0 <= a*b < (a1-1)*(b1-1) + 1.
Proof. Lia.nia. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
Z__range_mul_nonneg
| |
boundscheck{x0 x x1} (H: x0 <= x < x1) {X0 X1} (Hcheck : andb (X0 <=? x0) (x1 <=? X1) = true) : X0 <= x < X1.
Proof. eapply andb_prop in Hcheck; case Hcheck; intros H1 H2; eapply Z.leb_le in H1; eapply Z.leb_le in H2. blia. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
boundscheck
| |
boundscheck_lt{x0 x x1} (H: x0 <= x < x1) {X1} (Hcheck: Z.ltb x1 X1 = true) : x < X1.
Proof. eapply Z.ltb_lt in Hcheck. blia. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
boundscheck_lt
| |
bounded_constantc : c <= c < c+1. Proof. blia. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
bounded_constant
| |
named_pose_proofpf :=
let H := fresh in
let __ := match constr:(Set) with _ => pose proof pf as H end in
H.
|
Ltac
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
named_pose_proof
| |
named_posepf :=
let H := fresh in
let __ := match constr:(Set) with _ => pose pf as H end in
H.
|
Ltac
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
named_pose
| |
named_pose_asfreshpf x :=
let H := fresh x in
let __ := match constr:(Set) with _ => pose pf as H end in
H.
|
Ltac
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
named_pose_asfresh
| |
named_pose_asfresh_or_idx n :=
let y := match constr:(Set) with _ => named_pose_asfresh x n | _ => x end in
y.
|
Ltac
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
named_pose_asfresh_or_id
| |
requireZcstz :=
lazymatch Coq.setoid_ring.InitialRing.isZcst z with
| true => idtac
end.
|
Ltac
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
requireZcst
| |
requireZcstExpre :=
match e with
| Z.pred ?x => requireZcstExpr x
| Z.succ ?x => requireZcstExpr x
| Z.ones ?x => requireZcstExpr x
| Z.opp ?x => requireZcstExpr x
| Z.lnot ?x => requireZcstExpr x
| Z.log2 ?x => requireZcstExpr x
| Z.log2_up ?x => requireZcstExpr x
| Z.add ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.sub ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.mul ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.div ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.modulo ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.quot ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.rem ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.pow ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.shiftl ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.shiftr ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.land ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.lor ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.lxor ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.ldiff ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.clearbit ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.setbit ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.min ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.max ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.gcd ?x ?y => requireZcstExpr x; requireZcstExpr y
| Z.lcm ?x ?y => requireZcstExpr x; requireZcstExpr y
| _ => requireZcst e
end.
|
Ltac
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
requireZcstExpr
| |
zsimpx :=
match constr:(Set) with
| _ => let __ := requireZcstExpr x in let y := eval cbv in x in y
| _ => x
end.
Local Notation "zbsimp! H" :=
(ltac:(
lazymatch type of H with
?L <= ?X < ?R =>
let L := zsimp L in
let R := zsimp R in
exact ((H : L <= X < R))
end
)) (at level 10, only parsing).
|
Ltac
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
zsimp
| |
rboundede :=
let re := rdelta e in
match goal with
| H : _ <= e < _ |- _ => H
| _ =>
match re with
| word.unsigned ?a =>
named_pose_proof (zbsimp! (Properties.word.unsigned_range a : _ <= e < _))
| Z.div ?a ?b => (* TODO: non-constant denominator? *)
let __ := match constr:(Set) with _ => requireZcstExpr b end in
let Ha := rbounded a in
named_pose_proof (zbsimp! (Z__range_div_pos_const_r _ a _ Ha b ltac:(eapply Z.ltb_lt; exact eq_refl) : _ <= e < _))
| Z.modulo ?a ?b => (* TODO: non-constant denominator? *)
let __ := match constr:(Set) with _ => requireZcstExpr b end in
named_pose_proof (zbsimp! (Z.mod_pos_bound a b ltac:(eapply Z.ltb_lt; exact eq_refl) : _ <= e < _))
| ?op ?a ?b =>
let Ha := rbounded a in
let Hb := rbounded b in
let a0 := match type of Ha with ?a0 <= _ < ?a1 => a0 end in
let a1 := match type of Ha with ?a0 <= _ < ?a1 => a1 end in
let b0 := match type of Hb with ?b0 <= _ < ?b1 => b0 end in
let b1 := match type of Hb with ?b0 <= _ < ?b1 => b1 end in
match op with
| Z.add => named_pose_proof (zbsimp! (Z__range_add a0 a a1 Ha b0 b b1 Hb : a0 + b0 <= e < a1 + b1 - 1))
| Z.sub => named_pose_proof (zbsimp! (Z__range_sub a0 a a1 Ha b0 b b1 Hb : a0-b1+1 <= e < a1-b0))
| Z.mul => named_pose_proof (zbsimp! (Z__range_mul_nonneg a0 a a1 Ha b0 b b1 Hb (Zle_bool_imp_le 0 a0 eq_refl) (Zle_bool_imp_le 0 b0 eq_refl) : _ <= e < _))
end
end
| _ =>
let __ := match constr:(Set) with _ => requireZcstExpr re end in
constr:(zbsimp! (bounded_constant e))
end.
|
Ltac
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
rbounded
| |
absint_eq{T} := @eq T.
|
Definition
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
absint_eq
| |
absint_eq_refl{T} v := ((@eq_refl T v) : @absint_eq T v v).
Local Infix "=~>" := absint_eq (at level 70, no associativity).
|
Definition
|
bedrock2
|
[
"Require Import Coq.Strings.String Coq.ZArith.ZArith",
"From coqutil Require Import Word.Interface Word.Properties",
"From coqutil Require Import Tactics.rdelta Z.div_mod_to_equations",
"Require Import coqutil.Z.Lia"
] |
bedrock2/src/bedrock2/AbsintWordToZ.v
|
absint_eq_refl
| |
anyval{word mem T: Type}(p: T -> word -> mem -> Prop)(a: word): mem -> Prop :=
ex1 (fun v => p v a).
(* makes __ a keyword, so "let __ := uselessvalue in blah" in Ltac
doesn't parse any more!
Notation "p '__' a" := (anyval p a) (at level 20, a at level 9).
Infix "__" := anyval (at level 20).
*)
Notation "p ? a" := (anyval p a) (at level 20, a at level 9).
|
Definition
|
bedrock2
|
[
"Require Import bedrock2.Lift1Prop"
] |
bedrock2/src/bedrock2/anyval.v
|
anyval
| |
recis_positive_literal(e: constr): bool :=
lazy_match! e with
| xI ?p => is_positive_literal p
| xO ?p => is_positive_literal p
| xH => true
| _ => false
end.
(* Note: Not the same as Coq.setoid_ring.InitialRing.isZcst, because
isZcst considers (Z.of_nat n) and (Z.of_N n) constant if n is constant *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
is_Z_literal(n: constr): bool :=
lazy_match! n with
| 0 => true
| Z.pos ?p => is_positive_literal p
| Z.neg ?p => is_positive_literal p
| _ => false
end.
(* needed for compatibility with simplification strategies that choose not
to simplify powers of 2 *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
is_Z_literal
| |
is_Z_const(n: constr): bool :=
lazy_match! n with
| 2 ^ ?x => is_Z_literal x
| _ => is_Z_literal n
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
is_Z_const
| |
recis_nat_const(n: constr): bool :=
lazy_match! n with
| O => true
| S ?p => is_nat_const p
| _ => false
end.
(* To be treated opaquely and only manipulated through the API that follows.
Alternative representations to try out:
- Ltac2 records
- uconstr
- resulting term of simplification as constr, proof term as uconstr or custom type *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
Typeres :=
[ ResNop(constr) (* new and old term *)
| ResConvertible(constr) (* new term *)
| ResRewrite(constr, constr) (* new term, proof *) ].
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
Type
| |
new_term(r: res): constr :=
match r with
| ResNop t => t
| ResConvertible t => t
| ResRewrite t _ => t
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
new_term
| |
eq_proof(r: res): constr :=
match r with
| ResNop t => '(@eq_refl _ $t)
| ResConvertible t => '(@eq_refl _ $t)
| ResRewrite _ pf => pf
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
eq_proof
| |
did_something(r: res): bool :=
match r with
| ResNop _ => false
| ResConvertible _ => true
| ResRewrite _ _ => true
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
did_something
| |
is_convertible(r: res): bool :=
match r with
| ResNop _ => true
| ResConvertible _ => true
| ResRewrite _ _ => false
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
is_convertible
| |
res_convertible(new_term: constr): res :=
ResConvertible new_term.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
res_convertible
| |
res_rewrite_to(new_term: constr)(eq_proof: constr): res :=
ResRewrite new_term eq_proof.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
res_rewrite_to
| |
res_rewrite(eq_proof: constr): res :=
lazy_match! Constr.type eq_proof with
| _ = ?rhs => ResRewrite rhs eq_proof
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
res_rewrite
| |
res_nothing_to_simpl(original_term: constr): res :=
ResNop original_term.
(* original: term of shape (f a)
f: constr
r: result whose lhs is a *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
res_nothing_to_simpl
| |
lift_res1(original: constr)(f: constr)(r: res): res :=
if did_something r then
let t := new_term r in
if is_convertible r then
res_convertible '($f $t)
else
let pf := eq_proof r in res_rewrite '(@f_equal _ _ $f _ $t $pf)
else res_nothing_to_simpl original.
(* If we just used f_equal with f := (fun x => g (h x)), the RHS would be
((fun x => g (h x)) a') instead of (g (h a')). *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
lift_res1
| |
f_equal11[A B C: Type](h: A -> B)(g: B -> C)[a a': A]: a = a' -> g (h a) = g (h a').
Proof. exact (@f_equal A C (fun x => g (h x)) a a'). Qed.
(* original: term of shape (f (g a))
f: constr
g: constr
r: result whose lhs is a *)
|
Lemma
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
f_equal11
| |
lift_res11(original: constr)(f: constr)(g: constr)(r: res): res :=
if did_something r then
let t := new_term r in
if is_convertible r then
res_convertible '($f ($g $t))
else
let pf := eq_proof r in res_rewrite '(f_equal11 $f $g $pf)
else res_nothing_to_simpl original.
(* original: term of shape (f a1 a2)
f: constr
r1: result whose lhs is a1
r2: result whose lhs is a2 *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
lift_res11
| |
lift_res2(original: constr)(f: constr)(r1: res)(r2: res): res :=
let t1 := new_term r1 in
let t2 := new_term r2 in
if did_something r1 then
if is_convertible r1 then
if is_convertible r2 then
res_convertible '($f $t1 $t2)
else
let pf1 := eq_proof r1 in
let pf2 := eq_proof r2 in
res_rewrite '(@f_equal2 _ _ _ $f _ $t1 _ $t2 $pf1 $pf2)
else
let pf1 := eq_proof r1 in
let pf2 := eq_proof r2 in
res_rewrite '(@f_equal2 _ _ _ $f _ $t1 _ $t2 $pf1 $pf2)
else if did_something r2 then
if is_convertible r2 then
res_convertible '($f $t1 $t2)
else
let pf2 := eq_proof r2 in
res_rewrite '(@f_equal _ _ ($f $t1) _ $t2 $pf2)
else
res_nothing_to_simpl original.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
lift_res2
| |
app_cong[A B: Type][f g: A -> B][x y: A]: f = g -> x = y -> f x = g y.
Proof. intros. subst. reflexivity. Qed.
(* original: term of shape (f a)
r1: result whose lhs is f
r2: result whose lhs is a *)
|
Lemma
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
app_cong
| |
lift_res_app(original: constr)(r1: res)(r2: res): res :=
let t1 := new_term r1 in
let t2 := new_term r2 in
if did_something r1 then
if is_convertible r1 then
if is_convertible r2 then
res_convertible '($t1 $t2)
else
let pf1 := eq_proof r1 in
let pf2 := eq_proof r2 in
res_rewrite '(@app_cong _ _ _ $t1 _ $t2 $pf1 $pf2)
else
let pf1 := eq_proof r1 in
let pf2 := eq_proof r2 in
res_rewrite '(@app_cong _ _ _ $t1 _ $t2 $pf1 $pf2)
else if did_something r2 then
if is_convertible r2 then
res_convertible '($t1 $t2)
else
let pf2 := eq_proof r2 in
res_rewrite '(@f_equal _ _ $t1 _ $t2 $pf2)
else
res_nothing_to_simpl original.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
lift_res_app
| |
if_cong[A: Type][b b': bool][thn thn' els els': A]:
b = b' ->
thn = thn' ->
els = els' ->
(if b then thn else els) = (if b' then thn' else els').
Proof. intros. subst. reflexivity. Qed.
(* original: term of shape (if b then a1 else a2)
r0: result whose lhs is b
r1: result whose lhs is a1
r2: result whose lhs is a2 *)
|
Lemma
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
if_cong
| |
lift_res_if(original: constr)(r0: res)(r1: res)(r2: res): res :=
let t0 := new_term r0 in
let t1 := new_term r1 in
let t2 := new_term r2 in
if did_something r0 || did_something r1 || did_something r2 then
if is_convertible r0 && is_convertible r1 && is_convertible r2 then
res_convertible '(if $t0 then $t1 else $t2)
else
let pf0 := eq_proof r0 in
let pf1 := eq_proof r1 in
let pf2 := eq_proof r2 in
res_rewrite '(if_cong $pf0 $pf1 $pf2)
else
res_nothing_to_simpl original.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
lift_res_if
| |
impl_cong[P P' Q Q': Prop]:
P = P' ->
Q = Q' ->
(P -> Q) = (P' -> Q').
Proof. intros. subst. reflexivity. Qed.
(* original: term of shape (P -> Q)
r1: result whose lhs is P
r2: result whose lhs is Q *)
|
Lemma
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
impl_cong
| |
lift_res_impl(original: constr)(r1: res)(r2: res): res :=
let t1 := new_term r1 in
let t2 := new_term r2 in
if did_something r1 || did_something r2 then
if is_convertible r1 && is_convertible r2 then
res_convertible '($t1 -> $t2)
else
let pf1 := eq_proof r1 in
let pf2 := eq_proof r2 in
res_rewrite '(impl_cong $pf1 $pf2)
else
res_nothing_to_simpl original.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
lift_res_impl
| |
chain_rewrite_res(r1: res)(r2: res): res :=
let t1 := new_term r1 in
let pf1 := eq_proof r1 in
let t2 := new_term r2 in
let pf2 := eq_proof r2 in
res_rewrite '(@eq_trans _ _ $t1 $t2 $pf1 $pf2).
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
chain_rewrite_res
| |
chain_res(r1: res)(r2: res): res :=
if did_something r1 then
if did_something r2 then
if is_convertible r1 then r2
else
if is_convertible r2
then res_rewrite_to (new_term r2) (eq_proof r1)
else chain_rewrite_res r1 r2
else r1
else r2.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
chain_res
| |
xlia(P: Prop){pf: P}: P := pf.
|
Definition
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
xlia
| |
mutablebottom_up_simpl_sidecond_hook () :=
ltac1:(lia). (* OR xlia zchecker if already zified *)
(* local_X_simpl tactics:
Given a term with already simplified subterms, produce new simplified term and
equality proof (or set flag indicating that it's convertible).
Failing means no simplification opportunity. *)
(* inh: inhabited instance
l: any number of cons followed by nil or an abstract tail
i: fully simplified Z literal
Returns an element or a List.get with a smaller index *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
mutable
| |
recconvertible_list_get inh l i :=
lazy_match! l with
| nil => '(@Inhabited.default _ $inh)
| cons ?h ?t =>
lazy_match! i with
| Z0 => h
| Zpos _ => let j := eval cbv in (Z.pred $i) in convertible_list_get inh t j
| Zneg _ => '(@Inhabited.default _ $inh)
end
| _ => '(@List.get _ $inh $l $i)
end.
(* l: any number of cons followed by nil or an abstract tail
i: fully simplified Z literal
Returns a prefix of l or a few cons followed by a List.upto with a smaller index,
eg (a :: b :: c :: l)[:5] --> a :: b :: c :: (l[:2]) *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recconvertible_list_upto(i: constr)(l: constr): constr :=
lazy_match! l with
| nil => l
| @cons ?tp ?h ?t =>
lazy_match! i with
| Zpos _ => let j := eval cbv in (Z.pred $i) in
let r := convertible_list_upto j t in
'(@cons $tp $h $r)
| _ => '(@nil $tp)
end
| _ => lazy_match! i with
| Zpos _ => '(List.upto $i $l)
| Z0 => '(@nil _)
| Zneg _ => '(@nil _)
end
end.
(* l: any number of cons followed by nil or an abstract tail
i: fully simplified Z literal
Returns a suffix of l or a List.from with a smaller index *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recconvertible_list_from i l :=
lazy_match! l with
| nil => l
| @cons ?tp ?h ?t =>
lazy_match! i with
| Zpos _ => let j := eval cbv in (Z.pred $i) in convertible_list_from j t
| _ => l
end
| _ => lazy_match! i with
| Zpos _ => '(List.from $i $l)
| Z0 => l
| Zneg _ => l
end
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recprepend_concrete_list l1 l2 :=
lazy_match! l1 with
| cons ?h ?t => let r := prepend_concrete_list t l2 in '(cons $h $r)
| nil => l2
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
is_concrete_enough(i: constr)(l: constr)(is_nonpos_concrete_enough: bool): bool :=
lazy_match! l with
| nil => is_Z_literal i
| cons _ _ => is_Z_literal i
| _ => lazy_match! i with
| Z0 => is_nonpos_concrete_enough
| Zneg _ => is_nonpos_concrete_enough
| _ => false
end
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
is_concrete_enough
| |
non_ring_expr_size(e: constr): int :=
lazy_match! e with
| Zneg _ => 2
| _ => if is_Z_const e then 1 else 2
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
non_ring_expr_size
| |
recring_expr_size(e: constr): int :=
let r1 x :=
let s := ring_expr_size x in Int.add 1 s in
let r2 x y :=
let s1 := ring_expr_size x in let s2 := ring_expr_size y in Int.add 1 (Int.add s1 s2) in
lazy_match! e with
| Z.add ?x ?y => r2 x y
| Z.sub ?x ?y => r2 x y
| Z.mul ?x ?y => r2 x y
| Z.opp ?x => r1 x
| word.add ?x ?y => r2 x y
| word.sub ?x ?y => r2 x y
| word.mul ?x ?y => r2 x y
| word.opp ?x => r1 x
| word.of_Z ?x => non_ring_expr_size x
| _ => non_ring_expr_size e
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
Typeexpr_kind := [ WordRingExpr | ZRingExpr | OtherExpr ].
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
Type
| |
expr_kind_eqk1 k2 :=
match k1 with
| WordRingExpr => match k2 with WordRingExpr => true | _ => false end
| ZRingExpr => match k2 with ZRingExpr => true | _ => false end
| OtherExpr => match k2 with OtherExpr => true | _ => false end
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
expr_kind_eq
| |
get_expr_kind(e: constr): expr_kind :=
lazy_match! e with
| Z.add _ _ => ZRingExpr
| Z.sub _ _ => ZRingExpr
| Z.mul _ _ => ZRingExpr
| Z.opp _ => ZRingExpr
| word.add _ _ => WordRingExpr
| word.sub _ _ => WordRingExpr
| word.mul _ _ => WordRingExpr
| word.opp _ => WordRingExpr
| _ => OtherExpr
end.
(* To hide the ring_simplify proof when printing the proof term, and
to provide a let so that the preprocessing of ring_simplify doesn't mess with
the evar, while also making sure that the type as seen from the outside is a
(_ = _) rather than a let. *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
get_expr_kind
| |
ring_simplify_proof[A: Type](lhs rhs: A){pf: let x := rhs in lhs = x}: lhs = rhs.
Proof. exact pf. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
ring_simplify_proof
| |
ring_simplify_res_forcing_progress(e: constr): res :=
let rhs := '(_) in
res_rewrite '(@ring_simplify_proof _ $e $rhs
(* to invoke ring_simplify, we need to switch to Ltac1 anyways, so we just do this
whole line in Ltac1 *)
ltac:(let x := fresh "x" in intro x; progress ring_simplify; subst x; reflexivity)).
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
ring_simplify_res_forcing_progress
| |
ring_simplify_res_or_nothing_to_simpl(e: constr): res :=
first_val [ ring_simplify_res_forcing_progress e
| res_nothing_to_simpl e ].
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
ring_simplify_res_or_nothing_to_simpl
| |
local_ring_simplify(parent: expr_kind)(e: constr): res :=
if expr_kind_eq (get_expr_kind e) parent then
gfail "nothing to do here because parent will be ring_simplified too"
else
let r := ring_simplify_res_forcing_progress e in
if Int.lt (ring_expr_size (new_term r)) (ring_expr_size e) then r
else gfail "ring_simplify does not shrink the expression size".
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
local_ring_simplify
| |
try_elset1 t2 := orelse t1 (fun _ => t2 ()).
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
try_else
| |
Notation"try" t1(thunk(tactic(5))) "else" t2(thunk(tactic(5))) := try_else t1 t2.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
Notation
| |
Notation"try" t1(thunk(tactic(5))) := try0 t1.
Goal True.
try fail "nope".
try fail "ooh" else pose 1.
try (pose 2; fail) else pose 3.
try () else pose 1; pose 2.
let r := try '(1%nat + 1%Z) else '(tt) in pose $r.
Fail let r := try '(1%nat + 1%Z) else 2 in pose $r.
Fail try fail "msg1" else fail "msg2". (* msg2 *)
Fail first [ fail "msg1" | fail "msg2" ]. (* Tactic_failure (None) *)
Abort.
(* gen_stmt: ltac function taking a nat and returning a Prop
tac: tactic to prove stmt, takes a dummy unit
lower: min n to try
upper: max n to try
Returns the biggest possible n and the associated proof term *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
Notation
| |
max_n_st(gen_stmt: constr -> constr)(tac: unit -> unit)
(lower: constr)(upper: constr): (constr * constr) :=
let rec loop n :=
let stmt := gen_stmt n in
try (n, '(ltac2:(tac ()) : $stmt))
else if Constr.equal n lower then
gfail "stmt does not hold for any n within the bounds"
else
lazy_match! n with
| S ?m => loop m
| _ => anomaly "expected a nat above %t, got %t" lower n
end in
loop upper.
Goal forall (b: nat), b = 12%nat -> (3 * 3 < b)%nat.
intros.
let tac := (fun _ =>
lazy_match! goal with
| [ |- ?g ] => () (* printf "goal: %t" g *)
end;
cbn; lia) in
let (_, pf) := max_n_st (fun n => '(($n * $n < b)%nat)) tac '2%nat '7%nat in
pose $pf as A.
exact A.
Succeed Qed. Abort.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
max_n_st
| |
reclist_length_as_nat(l: constr): constr :=
lazy_match! l with
| nil => '(0%nat)
| cons _ ?tail => let r := list_length_as_nat tail in '((S $r))
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
panic_if_failure(f: unit -> 'a): 'a :=
match Control.case f with
| Val p => let (r, _) := p in r
| Err e => Control.throw e
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
panic_if_failure
| |
mutablebottom_up_simpl_recurse(e: constr): res := Control.throw Assertion_failure.
(* returns a proof whose LHS is (List.upto i l) and an RHS where the upto has been
pushed down as far as nicely possible *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
mutable
| |
recpush_down_upto(force_progress: bool)(treat_app: bool)
(tp: constr)(i: constr)(l: constr): res :=
let nop := fun (_: unit) =>
if force_progress then gfail "no progress"
else res_nothing_to_simpl '(@List.upto $tp $i $l) in
match! l with
| _ => res_rewrite '(List.upto_beginning $l $i ltac2:(bottom_up_simpl_sidecond_hook ()))
| _ => res_rewrite '(List.upto_pastend $l $i ltac2:(bottom_up_simpl_sidecond_hook ()))
| List.app _ _ =>
if treat_app then
let xss := List.reify_apps l in
let (nL, nL_pf) := max_n_st (* might fail *)
(fun n => '(List.cbn_len_sum (List.cbn_firstn $n $xss) <= $i))
(fun _ => cbn [List.cbn_len_sum List.cbn_firstn];
bottom_up_simpl_sidecond_hook ())
'0%nat
(list_length_as_nat xss) in
let (nR, nR_pf) := max_n_st (* might fail *)
(fun n => '($i <= List.cbn_len_sum (List.cbn_dropRight $n $xss)))
(fun _ => cbn [List.cbn_len_sum List.cbn_dropRight];
bottom_up_simpl_sidecond_hook ())
'0%nat
(list_length_as_nat xss) in
if Constr.equal nL '0%nat && Constr.equal nR '0%nat then nop () else
match Control.case (fun _ => '(eq_refl: Nat.add $nL $nR = length $xss)) with
| Val p => let (pf, _) := p in
res_rewrite '(List.upto_apps_at_boundary $nL $nR $i _ _ $xss _ $pf $nL_pf $nR_pf
ltac2:(cbn [List.cbn_firstn]; reflexivity)
ltac2:(cbn [List.cbn_concat]; reflexivity)
ltac2:(cbn [List.cbn_concat]; reflexivity))
| Err _ =>
res_rewrite '(List.upto_apps $nL $nR $i _ $l _ _ $xss _ _ _ _ $nL_pf $nR_pf
ltac2:(cbn [List.cbn_firstn]; reflexivity)
ltac2:(cbn [List.cbn_len_sum];
lazy_match! goal with
| [ |- ?diff = _ ] =>
let res := bottom_up_simpl_recurse diff in
let pf := eq_proof res in
exact $pf
end)
ltac2:(cbn [List.cbn_dropRight List.cbn_skipn]; reflexivity)
ltac2:(cbn [List.cbn_concat]; reflexivity)
ltac2:(cbn [List.cbn_concat]; reflexivity)
ltac2:(lazy_match! goal with
| [ |- List.upto ?j ?xs2 = _] =>
let res_rec := push_down_upto false false tp j xs2 in
let pf := eq_proof res_rec in
exact $pf
end)
ltac2:(cbn [List.cbn_app]; reflexivity)
ltac2:(cbn [List.cbn_concat]; reflexivity))
end
else gfail "try next match branch"
| List.from ?j ?l =>
let n := i in (* sized slice of size n: l[j:][:n] *)
let r_sum := ring_simplify_res_or_nothing_to_simpl '(Z.add $j $n) in
let sum := new_term r_sum in
if Int.lt (ring_expr_size sum) (ring_expr_size n) then
let pf_sum := eq_proof r_sum in
res_rewrite '(sized_slice_to_indexed_slice $l $j $n $sum
ltac2:(bottom_up_simpl_sidecond_hook ()) $pf_sum)
else gfail "ring_simplify does not shrink the expression size"
| List.upto ?j ?ll =>
let r1 := res_rewrite '(List.upto_upto_subsume $j $i $ll
ltac2:(bottom_up_simpl_sidecond_hook ())) in
let r2 := push_down_upto false true tp i ll in
chain_res r1 r2
| List.repeatz ?x ?n =>
res_rewrite '(List.push_down_upto_repeatz $i $x $n
ltac2:(bottom_up_simpl_sidecond_hook ())) (* might fail! *)
| _ => if is_concrete_enough i l true then
let l' := convertible_list_upto i l in res_convertible l'
else nop ()
end.
(* returns a proof whose LHS is (List.from i l) and an RHS where the from has been
pushed down as far as nicely possible. *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recpush_down_from(force_progress: bool)(treat_app: bool)
(tp: constr)(i: constr)(l: constr): res :=
(*non-lazy*)match! l with
| _ => res_rewrite '(List.from_beginning $l $i ltac2:(bottom_up_simpl_sidecond_hook ()))
| _ => res_rewrite '(List.from_pastend $l $i ltac2:(bottom_up_simpl_sidecond_hook ()))
| List.app _ _ =>
if treat_app then
let xss := List.reify_apps l in
let (nL, nL_pf) := max_n_st (* might fail *)
(fun n => '(List.cbn_len_sum (List.cbn_firstn $n $xss) <= $i))
(fun _ => cbn [List.cbn_len_sum List.cbn_firstn];
bottom_up_simpl_sidecond_hook ())
'0%nat
(list_length_as_nat xss) in
let (nR, nR_pf) := max_n_st (* might fail *)
(fun n => '($i <= List.cbn_len_sum (List.cbn_dropRight $n $xss)))
(fun _ => cbn [List.cbn_len_sum List.cbn_dropRight];
bottom_up_simpl_sidecond_hook ())
'0%nat
(list_length_as_nat xss) in
match Control.case (fun _ => '(eq_refl: Nat.add $nL $nR = length $xss)) with
| Val p => let (pf, _) := p in
res_rewrite '(List.from_apps_at_boundary $nL $nR $i _ _ $xss _ $pf $nL_pf $nR_pf
ltac2:(cbn [List.cbn_skipn]; reflexivity)
ltac2:(cbn [List.cbn_concat]; reflexivity)
ltac2:(cbn [List.cbn_concat]; reflexivity))
| Err _ =>
lazy_match! nL with
| O => lazy_match! nR with
| O => gfail "fall-through to last default case at end of match"
| S _ => res_rewrite '(List.from_apps_pullout_r $nR $i _ _ _ _ $xss _ _
$nR_pf
ltac2:(cbn[List.cbn_dropRight]; reflexivity)
ltac2:(cbn[List.cbn_takeRight]; reflexivity)
ltac2:(cbn[List.cbn_concat]; reflexivity)
ltac2:(cbn[List.cbn_concat]; reflexivity)
ltac2:(cbn[List.cbn_concat]; reflexivity)
ltac2:(lazy_match! goal with
| [ |- List.from _ ?xs1 = _] =>
let res_rec := push_down_from false false tp i xs1 in
let pf := eq_proof res_rec in
exact $pf
end))
end
| S _ => lazy_match! nR with
| O => res_rewrite '(List.from_apps_drop_l $nL $i _ _ _ _ $xss _
$nL_pf
ltac2:(cbn [List.cbn_len_sum List.cbn_firstn];
lazy_match! goal with
| [ |- ?diff = _ ] =>
let res := bottom_up_simpl_recurse diff in
let pf := eq_proof res in
exact $pf
end)
ltac2:(cbn[List.cbn_skipn]; reflexivity)
ltac2:(cbn[List.cbn_concat]; reflexivity)
ltac2:(cbn[List.cbn_concat]; reflexivity)
ltac2:(
lazy_match! goal with
| [ |- List.from ?j ?xs2 = _] =>
let res_rec := push_down_from false false tp j xs2 in
let pf := eq_proof res_rec in
exact $pf
end))
| S _ => res_rewrite '(List.from_apps $nL $nR $i _ _ _ _ _ $xss _ _
$nL_pf $nR_pf
ltac2:(cbn [List.cbn_len_sum List.cbn_firstn];
lazy_match! goal with
| [ |- ?diff = _ ] =>
let res := bottom_up_simpl_recurse diff in
let pf := eq_proof res in
exact $pf
end)
ltac2:(cbn[List.cbn_skipn List.cbn_dropRight]; reflexivity)
ltac2:(cbn[List.cbn_takeRight]; reflexivity)
ltac2:(cbn[List.cbn_concat]; reflexivity)
ltac2:(cbn[List.cbn_concat]; reflexivity)
ltac2:(cbn[List.cbn_concat]; reflexivity)
ltac2:(
lazy_match! goal with
| [ |- List.from ?j ?xs2 = _] =>
let res_rec := push_down_from false false tp j xs2 in
let pf := eq_proof res_rec in
exact $pf
end))
end
end
end
else gfail "try next match branch"
| List.upto ?j ?l =>
let r_diff := ring_simplify_res_or_nothing_to_simpl '(Z.sub $j $i) in
let diff := new_term r_diff in
if Int.lt (ring_expr_size diff) (ring_expr_size j) then
let pf_diff := eq_proof r_diff in
res_rewrite '(indexed_slice_to_sized_slice $l $i $j $diff
ltac2:(bottom_up_simpl_sidecond_hook ()) $pf_diff)
else gfail "ring_simplify does not shrink the expression size"
| List.from ?j ?ll =>
let r1 := res_rewrite '(List.from_from $ll $j $i
ltac2:(bottom_up_simpl_sidecond_hook ())
ltac2:(bottom_up_simpl_sidecond_hook ())) in
let r2 := push_down_from false true tp '($j + $i) ll in
chain_res r1 r2
| List.repeatz ?x ?n =>
res_rewrite '(List.push_down_from_repeatz $i $x $n _
ltac2:(bottom_up_simpl_sidecond_hook ()) (* <- might fail! *)
ltac2:(lazy_match! goal with
| [ |- ?diff = _ ] =>
let res := bottom_up_simpl_recurse diff in
let pf := eq_proof res in
exact $pf
end))
| _ => if is_concrete_enough i l true then
let l' := convertible_list_from i l in res_convertible l'
else if force_progress
then gfail "no progress"
else res_nothing_to_simpl '(@List.from $tp $i $l)
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recpush_down_get(inh: constr)(l0: constr)(n: constr): res :=
let with_sidecond_pf := fun (c: constr) (k: constr -> res) =>
match Control.case (fun _ => '(ltac2:(bottom_up_simpl_sidecond_hook ()): $c)) with
| Val p => let (s, _) := p in k s
| Err _ => res_nothing_to_simpl '(@List.get _ $inh $l0 $n)
end in
let with_sidecond_pf2 := fun (c1: constr) (k1: constr -> res)
(c2: constr) (k2: constr -> res) =>
match Control.case (fun _ => '(ltac2:(bottom_up_simpl_sidecond_hook ()): $c1)) with
| Val p => let (s, _) := p in k1 s
| Err _ =>
match Control.case (fun _ => '(ltac2:(bottom_up_simpl_sidecond_hook ()): $c2)) with
| Val p => let (s, _) := p in k2 s
| Err _ => res_nothing_to_simpl '(@List.get _ $inh $l0 $n)
end
end in
lazy_match! l0 with
| List.from ?i ?l => with_sidecond_pf
'(0 <= $i < Z.of_nat (List.length $l) /\ 0 <= $n < Z.of_nat (List.length $l) - $i)
(fun s =>
let res := push_down_get inh l '($i + $n) in
let rhs := new_term res in
let pf := eq_proof res in
res_rewrite '(@push_down_get_from _ $inh $l $n $i $rhs $s $pf))
| List.upto ?i ?l => with_sidecond_pf '(0 <= $n < $i) (fun s =>
let res := push_down_get inh l n in
let rhs := new_term res in
let pf := eq_proof res in
res_rewrite '(@push_down_get_upto _ $inh $l $n $i $rhs $s $pf))
| cons ?h ?t => with_sidecond_pf2
'($n = 0) (fun s => res_rewrite '(@push_down_get_head _ $inh $h $t $n $s))
'(0 < $n) (fun s => let res := push_down_get inh t '($n - 1) in
let rhs := new_term res in
let pf := eq_proof res in
res_rewrite '(@push_down_get_tail _ $inh $h $t $n $rhs $s $pf))
| List.app ?l1 ?l2 => with_sidecond_pf2
'(0 <= $n < Z.of_nat (length $l1)) (fun s =>
let res := push_down_get inh l1 n in
let rhs := new_term res in
let pf := eq_proof res in
res_rewrite '(@push_down_get_app_l _ $inh $l1 $l2 $n $rhs $s $pf))
'(Z.of_nat (length $l1) <= $n) (fun s =>
let res := push_down_get inh l2 '($n - Z.of_nat (length $l1)) in
let rhs := new_term res in
let pf := eq_proof res in
res_rewrite '(@push_down_get_app_r _ $inh $l1 $l2 $n $rhs $s $pf))
| List.set ?l ?i ?x => with_sidecond_pf '(0 <= $i < Z.of_nat (length $l)) (fun b =>
with_sidecond_pf2
'($n = $i) (fun s => res_rewrite '(@push_down_get_set_same _ $inh $l $i $n $x $b $s))
'($n <> $i) (fun s =>
let res := push_down_get inh l n in
let rhs := new_term res in
let pf := eq_proof res in
res_rewrite '(@push_down_get_set_diff _ $inh $l $i $n $x $rhs $b $s $pf)))
| List.repeatz ?x ?c => with_sidecond_pf '(0 <= $n < $c) (fun s =>
res_rewrite '(@push_down_get_repeatz _ $inh $x $c $n $s))
| _ => res_nothing_to_simpl '(@List.get _ $inh $l0 $n)
end.
(* We view the push_down_get procedure as computing a new index
At the end of the toplevel call, if the index changed, we ring_simplify it once. *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recpush_down_get_top(inh: constr)(l0: constr)(n: constr): res :=
panic_if_failure (fun _ =>
let res := push_down_get inh l0 n in
if did_something res then
let rhs := new_term res in
lazy_match! rhs with
| @List.get ?tp2 ?inh2 ?l2 ?i2 =>
let resi := ring_simplify_res_or_nothing_to_simpl i2 in
let resiLifted := lift_res1 rhs '(@List.get $tp2 $inh2 $l2) resi in
chain_res res resiLifted
| _ => res
end
else res).
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recis_concrete_list(e: constr): bool :=
lazy_match! e with
| nil => true
| cons _ ?tl => is_concrete_list tl
| _ => false
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recconstr_list_length(e: constr): int :=
lazy_match! e with
| nil => 0
| cons _ ?tl => Int.add 1 (constr_list_length tl)
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recunsnoc_constr_list(e: constr): constr * constr :=
lazy_match! e with
| cons ?x (@nil ?tp) => ('(@nil $tp), x)
| cons ?h ?tl => let (l, last) := unsnoc_constr_list tl in
('(cons $h $l), last)
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
uncons_constr_list(e: constr): constr * constr :=
lazy_match! e with
| cons ?h ?tl => (h, tl)
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
uncons_constr_list
| |
local_zlist_simpl(e: constr): res :=
match! e with
| @List.upto ?tp ?i ?l => push_down_upto true true tp i l
| @List.from ?tp ?i ?l => push_down_from true true tp i l
| @List.get _ ?inh ?l ?i =>
if is_concrete_enough i l false
then res_convertible (convertible_list_get inh l i)
else push_down_get_top inh l i
| @List.repeatz ?tp _ Z0 => res_convertible '(@nil $tp)
| List.app ?xs nil => res_rewrite '(List.app_nil_r $xs)
| List.app nil ?xs => res_convertible xs
| List.app (cons ?x nil) (List.repeatz ?x ?n) =>
res_rewrite '(List.repeatz_singleton_l $x $n ltac2:(bottom_up_simpl_sidecond_hook ()))
| List.app (List.repeatz ?x ?n) (cons ?x nil) =>
res_rewrite '(List.repeatz_singleton_r $x $n ltac2:(bottom_up_simpl_sidecond_hook ()))
| List.app ?xs ?ys =>
if is_concrete_list xs && is_concrete_list ys then
(* Note: (is_concrete_list ys) is not necessary for prepend_concrete_list
to work, but we want to use cons only for list literals, ie. we don't
want lists like (e1 :: e2 :: non_concrete_tail) *)
res_convertible (prepend_concrete_list xs ys)
else
let xss := List.reify_apps_and_cons xs in
let yss := List.reify_apps_and_cons ys in
if Int.lt 2 (Int.add (constr_list_length xss) (constr_list_length yss)) then
let (xss', last_xs) := unsnoc_constr_list xss in
let (first_ys, yss') := uncons_constr_list yss in
let res := bottom_up_simpl_recurse '(List.app $last_xs $first_ys) in
let combined := new_term res in
let pf := eq_proof res in
if Int.equal 1 (constr_list_length (List.reify_apps_and_cons combined)) then
res_rewrite '(List.reassoc_app_mergeable_in_middle $xss' $yss'
$last_xs $first_ys $combined $xs $ys _ eq_refl eq_refl $pf
ltac2:(cbn[List.cbn_concat List.cbn_app]; reflexivity))
else
lazy_match! xss' with
| nil => gfail "nothing to simplify" (* already a right-leaning ++ *)
| cons _ _ => (* reassociate ((xss1 ++ .. ++ xssN) ++ (yss1 ++ .. ++ yssN))
into (xss1 ++ .. ++ xssN ++ yss1 ++ .. ++ yssN) *)
res_rewrite '(List.reassoc_app $xss $yss $xs $ys _ eq_refl eq_refl
ltac2:(cbn [List.cbn_concat List.cbn_app]; reflexivity))
end
else (* xss and yss both consist of only one listlet *)
gfail "nothing to simplify"
| @cons ?tp ?x ?xs =>
if is_concrete_list xs then gfail "nothing to simplify" else
lazy_match! xs with
| List.app ?xs1 ?xs2 =>
if is_concrete_list xs1
then res_convertible '(List.app (cons $x $xs1) $xs2)
else res_convertible '(List.app (cons $x nil) $xs)
| _ => res_convertible '(List.app (cons $x nil) $xs)
end
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
local_zlist_simpl
| |
is_unary_Z_op(op: constr): bool :=
lazy_match! op with
| Z.of_nat => true
| Z.to_nat => true
| Z.succ => true
| Z.pred => true
| Z.opp => true
| Z.log2 => true
| Z.log2_up => true
| _ => false
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
is_unary_Z_op
| |
is_unary_nat_op(op: constr): bool :=
lazy_match! op with
| Nat.succ => true
| Nat.pred => true
| _ => false
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
is_unary_nat_op
| |
is_binary_Z_op(op: constr): bool :=
lazy_match! op with
| Z.add => true
| Z.sub => true
| Z.mul => true
| Z.div => true
| Z.modulo => true
| Z.quot => true
| Z.rem => true
| Z.pow => true
| Z.shiftl => true
| Z.shiftr => true
| Z.land => true
| Z.lor => true
| Z.lxor => true
| Z.ldiff => true
| Z.clearbit => true
| Z.setbit => true
| Z.min => true
| Z.max => true
| _ => false
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
is_binary_Z_op
| |
is_binary_nat_op(op: constr): bool :=
lazy_match! op with
| Nat.add => true
| Nat.sub => true
| Nat.mul => true
| Nat.div => true
| Nat.min => true
| Nat.max => true
| _ => false
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
is_binary_nat_op
| |
local_ground_number_simpl(e: constr): res :=
lazy_match! e with
| ?f ?x ?y =>
if Constr.is_const f then
if is_binary_Z_op f then
lazy_match! e with
| Z.pow 2 _ => gfail "not simplifying powers of 2"
| _ => if is_Z_const x && is_Z_const y
then res_convertible (eval cbv in $e)
else gfail "not constant"
end
else if is_binary_nat_op f && is_nat_const x && is_nat_const y
then res_convertible (eval cbv in $e)
else gfail "not constant"
else gfail "not constant"
| ?f ?x =>
if Constr.is_const f &&
(is_unary_Z_op f && is_Z_const x || is_unary_nat_op f && is_nat_const x)
then res_convertible (eval cbv in $e)
else gfail "not constant"
end.
Goal forall (a b c: Z), a + b - 2 * a = c -> -a + b = c.
Proof.
intros.
lazy_match! Constr.type 'H with
| ?e = _ =>
let r := local_ring_simplify OtherExpr e in
let n := new_term r in
let pf := eq_proof r in
eassert ($n = c) as H' by (etransitivity > [symmetry; exact $pf | exact H])
end.
exact H'.
Succeed Qed. Abort.
Goal forall (a b: Z), True.
Proof.
intros.
Fail let e := '(a + b) in let r := local_ring_simplify OtherExpr e in ().
Abort.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
local_ground_number_simpl
| |
mutablerec is_substitutable_rhs(rhs: constr): bool :=
Constr.is_var rhs ||
Constr.is_const rhs ||
is_Z_const rhs ||
lazy_match! rhs with
| word.of_Z ?x => is_substitutable_rhs x
| word.unsigned ?x => is_substitutable_rhs x
| _ => false
end.
(* After following a series of `var1 = var2` equations, we arrive at an equation
of the form `var = rhs` with `rhs` not a var, but potentially small enough
to be substituted. This function tells if `rhs` is indeed "small enough". *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
mutable
| |
mutableis_small_terminal_rhs(rhs: constr): bool :=
neg (Constr.is_var rhs) && is_substitutable_rhs rhs.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
mutable
| |
constr_to_var_ref(c: constr): Std.reference option :=
match Constr.Unsafe.kind c with
| Constr.Unsafe.Var id => Some (Std.VarRef id)
| _ => None
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
constr_to_var_ref
| |
recunfold_to_const(seen: constr list)(e: constr): res :=
let exploit_eq := fun (new: constr)(r: res) =>
if List.exist (Constr.equal new) seen then Control.zero Not_applicable else
if is_small_terminal_rhs new then r else
chain_res r (unfold_to_const (new :: seen) new) in
match constr_to_var_ref e with
| Some ref =>
(* Beware: Ltac2's Std.eval_cbv does not match Ltac1's `eval cbv in`!
https://github.com/coq/coq/issues/14303
Ltac2 silently does nothing if r is not unfoldable. *)
let e' := Std.eval_cbv_delta [ref] e in
if Constr.equal e e' then
match! goal with
| [ h: ?lhs = ?rhs |- _ ] =>
if Constr.equal lhs e
then exploit_eq rhs (res_rewrite (Control.hyp h))
else if Constr.equal rhs e
then exploit_eq lhs (res_rewrite (let h := Control.hyp h in constr:(eq_sym $h)))
else Control.zero Not_applicable
end
else exploit_eq e' (res_convertible e')
| None => Control.zero Not_applicable
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
local_follow_eqs_until_const_val(e: constr): res :=
unfold_to_const [] e.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
local_follow_eqs_until_const_val
| |
local_nonring_nonground_Z_simple :=
lazy_match! e with
| Z.div ?x 1 => res_rewrite '(Z.div_1_r $x)
| Z.div ?x ?d =>
let x_eq_prod_pf := cancel_div_rec d x in
res_rewrite '(cancel_div_done $d $x _
ltac2:(bottom_up_simpl_sidecond_hook ()) $x_eq_prod_pf)
end.
(* Note: we use '(...) most of the time, but when we rely on typeclass search,
(eg to find a word.ok), we have to use constr:(...), because '(...) does not
run typeclass search, and instead just creates and shelves an evar. *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
local_nonring_nonground_Z_simpl
| |
recpush_down_unsigned(w: constr): res :=
lazy_match! w with
| ?f1 ?a0 =>
lazy_match! f1 with
| @word.of_Z ?width ?word =>
first_val
[ res_rewrite constr:(@word.unsigned_of_Z_nowrap $width $word _ $a0
ltac2:(bottom_up_simpl_sidecond_hook ()))
| res_rewrite constr:(@word.unsigned_of_Z_modwrap $width $word _ $a0) ]
| @word.opp ?width ?word =>
let r_a0 := push_down_unsigned a0 in
let pf0 := eq_proof r_a0 in
lazy_match! new_term r_a0 with
| 0 => res_rewrite constr:(word.unsigned_opp_0 $a0 $pf0)
| _ => first_val [ res_rewrite constr:(word.unsigned_opp_eq_nowrap $pf0
ltac2:(bottom_up_simpl_sidecond_hook ()))
| res_nothing_to_simpl constr:(word.unsigned $w) ]
end
| ?f2 ?a1 =>
lazy_match! f2 with
| word.add => push_down_unsigned_app2 w 'word.unsigned_add_eq_nowrap a1 a0
| word.sub => push_down_unsigned_app2 w 'word.unsigned_sub_eq_nowrap a1 a0
| word.mul => push_down_unsigned_app2 w 'word.unsigned_mul_eq_nowrap a1 a0
| _ => res_nothing_to_simpl constr:(word.unsigned $w)
end
| _ => res_nothing_to_simpl constr:(word.unsigned $w)
end
| _ => res_nothing_to_simpl constr:(word.unsigned $w)
end
with push_down_unsigned_app2(w: constr)(lem: constr)(a1: constr)(a0: constr): res :=
let pf0 := eq_proof (push_down_unsigned a0) in
let pf1 := eq_proof (push_down_unsigned a1) in
first_val
[ res_rewrite constr:($lem _ _ _ _ _ _ _ $pf1 $pf0 ltac2:(bottom_up_simpl_sidecond_hook ()))
| res_nothing_to_simpl constr:(word.unsigned $w) ].
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
local_word_simpl(e: constr): res :=
lazy_match! e with
| word.unsigned ?w => push_down_unsigned w
(* Not sure if we want this one:
It's useful as a preprocessing step for ring_simplify on words, but if we have
\[/[z1 + z2]] where 0 <= z1 + z2 < 2^32, we don't want to push down the of_Z,
so we can do the unsigned_of_Z rewrite.
--> TODO maybe reactivate, but then, also, in (word.of_Z (word.unsigned (a ^+ b))),
prevent push_down of word.unsigned! (because here, we don't even need a
sidecondition to get rid of the roundtrip
| @word.of_Z ?width ?word ?z => push_down_of_Z width word z *)
| @word.of_Z ?width ?word (?z mod 2 ^ ?width) =>
res_rewrite constr:(@word.of_Z_mod $width $word _ $z)
| @word.of_Z ?width ?word (word.unsigned ?w) =>
res_rewrite constr:(@word.of_Z_unsigned $width $word _ $w)
end.
(* Nodes like eg (List.length (cons a (cons b (app (cons c xs) ys)))) can
require an arbitrary number of simplification steps at the same node.
---> but that's more of a "push down List.length" algorithm, because once
we have (len (cons c xs) + len ys), we need to recurse not at the current
node, but down into the args of + !
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
local_word_simpl
| |
saturate_local_simplparent_kind e :=
let r := local_simpl_hook parent_kind e in
lazy_match! r SimplAgain with
| true => saturate_local_simpl parent_kind e'
| false => r
end.
-->
treat push-down separately:
- List.length/len
- word.unsigned
and don't treat them as push-down, but as "compute len/unsigned of given expression
in a bottom-up way"
OR treat them as "local_simpl has access to an API to indicate how/where to continue
simplifying the new term"?
(would also work for (xs ++ ys)[i:] = xs[i:] ++ ys[i - len xs :],
where we have to indicate that (i - len xs) might need further simplification
set, app, repeatz, from, upto
Lemma len_set: forall (l: list A) i x, 0 <= i < len l -> len (set l i x) = len l.
Lemma len_app: forall (l1 l2: list A), len (l1 ++ l2) = len l1 + len l2.
Lemma len_repeatz: forall (x: A) (n: Z), 0 <= n -> len (repeatz x n) = n.
Lemma len_from: forall (l: list A) i, 0 <= i <= len l -> len (from i l) = len l - i.
Lemma len_upto: forall (l: list A) i, 0 <= i <= len l -> len (upto i l) = i.
pre-order vs post-order traversal:
len lemmas need to be applied before descending recursively, while others
need to be applied after descending recursively
some need intertwined application:
len_from should first simplify i (so that it's already simplified in the sidecond solving),
then simplify (len l) in a reusable way so that it appears simplified in the sidecondition
and in the rhs, and then apply len_from, and then simplify locally the rhs
(simplified_len_l - simplified_i)
*)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
saturate_local_simpl
| |
recconcrete_list_length_err(l: constr): constr option :=
lazy_match! l with
| nil => Some 'O
| cons _ ?t =>
match concrete_list_length_err t with
| Some r => Some '(S $r)
| None => None
end
| _ => None
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
recpush_down_len(x: constr): res :=
lazy_match! x with
| List.from ?i ?l =>
let r_len_l := push_down_len l in
let len_l := new_term r_len_l in
let pf_len_l := eq_proof r_len_l in
first_val
[ (* Case: index i is within bounds *)
let sidecond := '(ltac2:(bottom_up_simpl_sidecond_hook ()): 0 <= $i <= $len_l) in
let r_diff := ring_simplify_res_or_nothing_to_simpl '(Z.sub $len_l $i) in
let diff := new_term r_diff in
let pf_diff := eq_proof r_diff in
res_rewrite
'(push_down_len_from $l $i $len_l $diff $pf_len_l $sidecond $pf_diff)
| (* Case: index i is too big *)
let sidecond := '(ltac2:(bottom_up_simpl_sidecond_hook ()): $len_l <= $i) in
res_rewrite '(push_down_len_from_pastend $l $i $len_l $pf_len_l $sidecond)
| (* Case: index i is too small *)
let sidecond := '(ltac2:(bottom_up_simpl_sidecond_hook ()): $i <= 0) in
res_rewrite '(push_down_len_from_negative $l $i $len_l $pf_len_l $sidecond)
| (* Case: unknown whether index is is within bounds, so the List.from remains *)
res_nothing_to_simpl '(Z.of_nat (List.length $x)) ]
| @List.upto ?tp ?i ?l =>
let r_len_l := push_down_len l in
let len_l := new_term r_len_l in
let pf_len_l := eq_proof r_len_l in
first_val
[ (* Case: index i is within bounds *)
let sidecond := '(ltac2:(bottom_up_simpl_sidecond_hook ()): 0 <= $i <= $len_l) in
res_rewrite '(push_down_len_upto $l $i $len_l $pf_len_l $sidecond)
| (* Case: index i is too big *)
let sidecond := '(ltac2:(bottom_up_simpl_sidecond_hook ()): $len_l <= $i) in
res_rewrite '(push_down_len_upto_pastend $i $len_l $pf_len_l $sidecond)
| (* Case: index i is too small *)
let sidecond := '(ltac2:(bottom_up_simpl_sidecond_hook ()): $i <= 0) in
res_rewrite '(push_down_len_upto_negative $l $i $len_l $pf_len_l $sidecond)
| (* Case: unknown whether index is is within bounds, so the List.upto remains *)
res_nothing_to_simpl '(Z.of_nat (List.length $x)) ]
| nil => res_convertible 'Z0
| cons ?h ?t =>
match concrete_list_length_err t with
| Some n => let z := eval cbv in (Z.of_nat (S $n)) in res_convertible z
| None =>
let r_len_t := push_down_len t in
let len_t := new_term r_len_t in
let pf_len_t := eq_proof r_len_t in
let r_oneplus := ring_simplify_res_or_nothing_to_simpl '(Z.add 1 $len_t) in
let oneplus := new_term r_oneplus in
let pf_oneplus := eq_proof r_oneplus in
res_rewrite '(push_down_len_cons $h $t $oneplus $pf_oneplus)
end
| @List.app ?tp ?l1 ?l2 =>
let r_len_l1 := push_down_len l1 in
let r_len_l2 := push_down_len l2 in
let len_l1 := new_term r_len_l1 in
let len_l2 := new_term r_len_l2 in
let r_sum_lens := ring_simplify_res_or_nothing_to_simpl '(Z.add $len_l1 $len_l2) in
let sum_lens := new_term r_sum_lens in
let pf_len_l1 := eq_proof r_len_l1 in
let pf_len_l2 := eq_proof r_len_l2 in
let pf_sum_lens := eq_proof r_sum_lens in
res_rewrite '(push_down_len_app $l1 $l2 $len_l1 $len_l2 $sum_lens
$pf_len_l1 $pf_len_l2 $pf_sum_lens)
| @List.set ?tp ?l ?i ?x =>
let r_len_l := push_down_len l in
let len_l := new_term r_len_l in
let pf_len_l := eq_proof r_len_l in
let g := '(0 <= $i < $len_l) in
first_val
[ let s := '(ltac2:(bottom_up_simpl_sidecond_hook ()) : $g) in
res_rewrite '(push_down_len_set $l $i $len_l $x $pf_len_l $s)
| (* TODO Should we fail here (and in more places)? *)
res_nothing_to_simpl '(Z.of_nat (List.length $x)) ]
| List.repeatz ?a ?n =>
first_val
[ (* Case: n is provably nonnegative *)
let sidecond := '(ltac2:(bottom_up_simpl_sidecond_hook ()): 0 <= $n) in
res_rewrite '(push_down_len_repeatz $a $n $sidecond)
| (* Case: n might be negative *)
res_rewrite '(push_down_len_repeatz_max $a $n) ]
| _ => res_nothing_to_simpl '(Z.of_nat (List.length $x))
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
push_down_len_top(e: constr): res :=
lazy_match! e with
| Z.of_nat (List.length ?l) => push_down_len l
end.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
push_down_len_top
| |
mutablelocal_simpl_hook(parent_kind: expr_kind)(e: constr): res :=
first_val
[ local_follow_eqs_until_const_val e
| local_zlist_simpl e
| local_ring_simplify parent_kind e
| local_ground_number_simpl e
| push_down_len_top e
| local_word_simpl e (* <-- not strictly local, might do a whole traversal *)
| local_nonring_nonground_Z_simpl e
| res_nothing_to_simpl e ].
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
mutable
| |
recbottom_up_simpl(parent_kind: expr_kind)(e: constr): res :=
let current_kind := get_expr_kind e in
let r_rec :=
match current_kind with
| OtherExpr =>
lazy_match! e with
| ?f ?x => lift_res_app e
(bottom_up_simpl OtherExpr f)
(bottom_up_simpl OtherExpr x)
| match ?b with
| true => ?thn
| false => ?els
end => lift_res_if e (bottom_up_simpl OtherExpr b)
(bottom_up_simpl OtherExpr thn)
(bottom_up_simpl OtherExpr els)
| ?p -> ?q => lift_res_impl e (bottom_up_simpl OtherExpr p)
(bottom_up_simpl OtherExpr q)
| _ => res_nothing_to_simpl e
end
| _ => (* head of app is a known function symbol that doesn't need to be simplified *)
lazy_match! e with
| ?f ?x ?y => lift_res2 e f
(bottom_up_simpl current_kind x)
(bottom_up_simpl current_kind y)
| ?f ?x => lift_res1 e f (bottom_up_simpl current_kind x)
| _ => res_nothing_to_simpl e
end
end in
let r_loc := local_simpl_hook parent_kind (new_term r_rec) in
chain_res r_rec r_loc.
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rec
| |
Setbottom_up_simpl_recurse := fun e => bottom_up_simpl OtherExpr e.
(* Consider `word.unsigned (foo (a + 0) ^+ x ^- foo a ^+ y)`:
The argument of word.unsigned needs a first full bottom-up traversal to simplify
it into `x ^+ y`, and after that, another push-down-word.unsigned traversal to
obtain `word.unsigned x + word.unsigned y` (if no overflow).
On the other hand, if you start pushing down len too early, not a problem,
because list operations don't cancel like word.sub does.
Therefore, pushing down len could be integrated into bottom_up_simpl, whereas
pushing down word.unsigned runs *after* it in local_simpl_hook *)
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
Set
| |
protect_conclusion(P: Prop) := P.
(* protect_conclusion is needed because if P2 is an implication,
`apply ... in ...` creates subgoals for everything on the left of a -> in P2 *)
|
Definition
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
protect_conclusion
| |
rew_Prop_hyp: forall (P1 P2: Prop) (pf: P1 = P2), P1 -> protect_conclusion P2.
Proof. intros. subst. assumption. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rew_Prop_hyp
| |
rew_Prop_goal: forall (P1 P2: Prop) (pf: P1 = P2), P2 -> P1.
Proof. intros. subst. assumption. Qed.
|
Lemma
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
rew_Prop_goal
| |
forbidden(P: Prop) := P.
|
Definition
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
forbidden
| |
Typeexn ::= [ Nothing_to_simplify ].
|
Ltac2
|
bedrock2
|
[
"Require Import coqutil.Ltac2Lib.Ltac2",
"Require Import coqutil.Ltac2Lib.Failf coqutil.Ltac2Lib.rdelta coqutil.Ltac2Lib.Lia",
"Require Import Coq.ZArith.ZArith. Local Open Scope Z_scope",
"Require Import Coq.micromega.Lia",
"Require Import coqutil.Word.Interface coqutil.Word.Properties",
"Require Import coqutil.Datatypes.Inhabited",
"Require Import coqutil.Datatypes.ZList",
"Require Import coqutil.Tactics.Tactics",
"Require Import coqutil.Tactics.ltac_list_ops",
"Require Import coqutil.Tactics.rdelta",
"Require Import coqutil.Tactics.foreach_hyp",
"Require Import bedrock2.WordPushDownLemmas",
"Require Import bedrock2.cancel_div",
"Require Import bedrock2.LogSidecond"
] |
bedrock2/src/bedrock2/bottom_up_simpl.v
|
Type
|
A work-in-progress language and compiler for verified low-level programming targeting RISC-V.
| Property | Value |
|---|---|
| Total Entries | 2,187 |
| Files Processed | 289 |
| Type | Count |
|---|---|
| Definition | 760 |
| Ltac | 702 |
| Lemma | 428 |
| Ltac2 | 132 |
| Fixpoint | 46 |
| Inductive | 35 |
| Record | 27 |
| Axiom | 13 |
| Class | 11 |
| Instance | 11 |
| Example | 7 |
| Coercion | 5 |
| Parameter | 5 |
| Remark | 4 |
| Theorem | 1 |
| Column | Type | Description |
|---|---|---|
fact |
string | Declaration body (name, signature, proof) |
type |
string | Declaration type |
library |
string | Library component |
imports |
list[string] | Import statements |
filename |
string | Source file path |
symbolic_name |
string | Declaration identifier |
docstring |
string | Documentation comment (if present) |
Charles Norton (phanerozoic)