1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
|
(* Simpl with patterns *)
Goal forall x, 0+x = 1+x.
intro x.
simpl (_ + x).
Show.
change (0+x = 1+x).
simpl (_ + x) at 2.
Show.
change (0+x = 1+x).
simpl (0 + _).
Show.
Abort.
From Stdlib Require Import String.
Open Scope string_scope.
Module NonRecursiveDefinition.
Check "** NonRecursiveDefinition".
Open Scope bool_scope.
Eval simpl in true && true. (* -> true *)
Eval cbn in true && true. (* -> true *)
Eval hnf in true && true. (* -> true *)
Arguments andb : simpl never.
Eval simpl in true && true. (* -> true && true *)
Eval cbn in true && true. (* -> true && true *)
Eval hnf in true && true. (* -> true *)
End NonRecursiveDefinition.
Module RecursiveDefinition.
Check "** RecursiveDefinition".
Eval simpl in 0 + 0. (* -> 0 *)
Eval cbn in 0 + 0. (* -> 0 *)
Eval hnf in 0 + 0. (* -> 0 *)
Arguments Nat.add : simpl never.
Eval simpl in 0 + 0. (* -> 0 + 0 *)
Eval cbn in 0 + 0. (* -> 0 + 0 *)
Eval hnf in 0 + 0. (* -> 0 + 0 *) (* hnf modified by simpl never, bug never 2 *)
End RecursiveDefinition.
Set Printing Projections.
Module NonPrimitiveProjection.
Check "** NonPrimitiveProjection".
Module DirectTuple.
Check "DirectTuple (NonPrimitiveProjection)".
Record T := {p:nat}.
Notation TUPLE := {|p:=0|}.
Eval simpl in TUPLE.(p). (* -> 0 *)
Eval cbn in TUPLE.(p). (* -> 0 *)
Eval hnf in TUPLE.(p). (* -> 0 *)
Arguments p : simpl never.
Eval simpl in TUPLE.(p). (* -> TUPLE.(p) *)
Eval cbn in TUPLE.(p). (* -> TUPLE.(p) *)
Eval hnf in TUPLE.(p). (* -> 0 *)
End DirectTuple.
Module NamedTuple.
Check "NamedTuple (NonPrimitiveProjection)".
Record T := {p:nat}.
Definition a := {|p:=0|}.
Eval simpl in a.(p). (* -> 0 *)
Eval cbn in a.(p). (* -> 0 *)
Eval hnf in a.(p). (* -> 0 *)
Arguments p : simpl never.
Eval simpl in a.(p). (* -> a.(p) *)
Eval cbn in a.(p). (* -> a.(p) *)
Eval hnf in a.(p). (* -> 0 *)
Arguments p : simpl nomatch.
Arguments a : simpl never.
Eval simpl in a.(p). (* -> 0 *) (* never not respected on purpose [*] *)
Eval cbn in a.(p). (* -> a.(p) *)
Eval hnf in a.(p). (* -> 0 *)
End NamedTuple.
(* [*] Enrico: https://github.com/coq/coq/pull/18581#issuecomment-1914325999 *)
Module DirectCoFix.
Check "DirectCoFix (NonPrimitiveProjection)".
CoInductive U := {p:U}.
Notation COFIX := (cofix a := {|p:=a|}).
Eval simpl in COFIX.(p). (* -> COFIX *)
Eval cbn in COFIX.(p). (* -> COFIX *)
Eval hnf in COFIX.(p). (* -> COFIX *)
Arguments p : simpl never.
Eval simpl in COFIX.(p). (* -> COFIX.(p) *)
Eval cbn in COFIX.(p). (* -> COFIX.(p) *)
Eval hnf in COFIX.(p). (* -> COFIX *)
End DirectCoFix.
Module NamedCoFix.
Check "NamedCoFix (NonPrimitiveProjection)".
CoInductive U := {p:U}.
CoFixpoint a := {|p:=a|}.
Eval simpl in a.(p). (* -> a *)
Eval cbn in a.(p). (* -> a *)
Eval hnf in a.(p). (* -> a *)
Arguments p : simpl never.
Eval simpl in a.(p). (* -> a.(p) *)
Eval cbn in a.(p). (* -> a.(p) *)
Eval hnf in a.(p). (* -> a *)
Arguments p : simpl nomatch.
Arguments a : simpl never.
Eval simpl in a.(p). (* -> a *) (* never not respected on purpose *)
Eval cbn in a.(p). (* -> a.(p) *)
Eval hnf in a.(p). (* -> a *)
End NamedCoFix.
End NonPrimitiveProjection.
Module PrimitiveProjectionFolded.
Check "** PrimitiveProjectionFolded".
Set Primitive Projections.
Module DirectTuple.
Check "DirectTuple (PrimitiveProjectionFolded)".
Record T := {p:nat}.
Notation TUPLE := {|p:=0|}.
Eval simpl in TUPLE.(p). (* -> 0 *)
Eval cbn in TUPLE.(p). (* -> 0 *)
Eval hnf in TUPLE.(p). (* -> 0 *)
Arguments p : simpl never.
Eval simpl in TUPLE.(p). (* -> TUPLE.(p) *)
Eval cbn in TUPLE.(p). (* -> TUPLE.(p) *)
Eval hnf in TUPLE.(p). (* -> 0 *)
End DirectTuple.
Module NamedTuple.
Check "NamedTuple (PrimitiveProjectionFolded)".
Record T := {p:nat}.
Definition a := {|p:=0|}.
Eval simpl in a.(p). (* -> 0 *)
Eval cbn in a.(p). (* -> 0 *)
Eval hnf in a.(p). (* -> 0 *)
Arguments p : simpl never.
Eval simpl in a.(p). (* -> a.(p) *)
Eval cbn in a.(p). (* -> a.(p) *)
Eval hnf in a.(p). (* -> 0 *)
Arguments p : simpl nomatch.
Arguments a : simpl never.
Eval simpl in a.(p). (* -> ) *) (* never not respected on purpose *)
Eval cbn in a.(p). (* -> a.(p) *)
Eval hnf in a.(p). (* -> 0 *)
End NamedTuple.
Module DirectCoFix.
Check "DirectCoFix (PrimitiveProjectionFolded)".
CoInductive U := {p:U}.
Notation COFIX := (cofix a := {|p:=a|}).
Eval simpl in COFIX.(p). (* -> COFIX *)
Eval cbn in COFIX.(p). (* -> COFIX *)
Eval hnf in COFIX.(p). (* -> COFIX *)
Arguments p : simpl never.
Eval simpl in COFIX.(p). (* -> COFIX.(p) *)
Eval cbn in COFIX.(p). (* -> COFIX.(p) *)
Eval hnf in COFIX.(p). (* -> COFIX *)
End DirectCoFix.
Module NamedCoFix.
Check "NamedCoFix (PrimitiveProjectionFolded)".
CoInductive U := {p:U}.
CoFixpoint a := {|p:=a|}.
Eval simpl in a.(p). (* -> a *)
Eval cbn in a.(p). (* -> a *)
Eval hnf in a.(p). (* -> a *)
Arguments p : simpl never.
Eval simpl in a.(p). (* -> a.(p) *)
Eval cbn in a.(p). (* -> a.(p) *)
Eval hnf in a.(p). (* -> a *)
Arguments p : simpl nomatch.
Arguments a : simpl never.
Eval simpl in a.(p). (* -> a *) (* never not respected on purpose *)
Eval cbn in a.(p). (* -> a.(p) *)
Eval hnf in a.(p). (* -> a *)
End NamedCoFix.
End PrimitiveProjectionFolded.
Module PrimitiveProjectionUnfolded.
Check "** PrimitiveProjectionUnfolded".
(* we use an unfold trick to create an unfolded projection *)
Set Primitive Projections.
Module DirectTuple.
Check "DirectTuple (PrimitiveProjectionUnfolded)".
Record T := {p:nat}.
Definition a := {|p:=0|}.
Axiom P : nat -> Prop.
Goal P a.(p). unfold p. cbv delta [a]. simpl. Show. Abort. (* -> 0 *)
Goal P a.(p). unfold p. cbv delta [a]. cbn. Show. Abort. (* -> 0 *)
Goal P a.(p). unfold p. cbv delta [a]. hnf. Show. Abort. (* -> 0 *)
Arguments p : simpl never.
Goal P a.(p). unfold p. cbv delta [a]. simpl. Show. Abort. (* -> 0 *) (* bug never 3 *)
Goal P a.(p). unfold p. cbv delta [a]. cbn. Show. Abort. (* -> {| p := 0 |}.(p) *)
Goal P a.(p). unfold p. cbv delta [a]. hnf. Show. Abort. (* -> 0 *)
End DirectTuple.
Module NamedTuple.
Check "NamedTuple (PrimitiveProjectionUnfolded)".
Record T := {p:nat}.
Definition a := {|p:=0|}.
Axiom P : nat -> Prop.
Goal P a.(p). unfold p. simpl. Show. Abort. (* -> 0 *)
Goal P a.(p). unfold p. cbn. Show. Abort. (* -> 0 *)
Goal P a.(p). unfold p. hnf. Show. Abort. (* -> a.(p) *) (* bug primproj 2 *)
Arguments p : simpl never.
Goal P a.(p). unfold p. simpl. Show. Abort. (* -> 0 *) (* bug never 3 *)
Goal P a.(p). unfold p. cbn. Show. Abort. (* -> a.(p) *)
Goal P a.(p). unfold p. hnf. Show. Abort. (* -> a.(p) *) (* bug primproj 2 *)
Arguments p : simpl nomatch.
Arguments a : simpl never.
Goal P a.(p). unfold p. simpl. Show. Abort. (* -> 0 *) (* bug never 1 *)
Goal P a.(p). unfold p. cbn. Show. Abort. (* -> a.(p) *)
Goal P a.(p). unfold p. hnf. Show. Abort. (* -> a.(p) *) (* bug primproj 2 *)
End NamedTuple.
Module DirectCoFix.
Check "DirectCoFix (PrimitiveProjectionUnfolded)".
CoInductive U := {q:U}.
CoFixpoint a := {|q:=a|}.
Notation COFIX := (cofix a := {|q:=a|}).
Axiom P : U -> Prop.
Goal P a.(q). unfold q. cbv delta [a]. simpl. Show. Abort. (* -> COFIX *)
Goal P a.(q). unfold q. cbv delta [a]. cbn. Show. Abort. (* -> COFIX *)
Goal P a.(q). unfold q. cbv delta [a]. hnf. Show. Abort. (* -> COFIX *)
Arguments q : simpl never.
Goal P a.(q). unfold q. cbv delta [a]. simpl. Show. Abort. (* -> COFIX *) (* never not respected on purpose *)
Goal P a.(q). unfold q. cbv delta [a]. cbn. Show. Abort. (* -> COFIX.(q) *)
Goal P a.(q). unfold q. cbv delta [a]. hnf. Show. Abort. (* -> COFIX *)
End DirectCoFix.
Module NamedCoFix.
Check "NamedCoFix (PrimitiveProjectionUnfolded)".
CoInductive U := {q:U}.
CoFixpoint a := {|q:=a|}.
Notation COFIX := (cofix a := {|q:=a|}).
Axiom P : U -> Prop.
Goal P a.(q). unfold q. simpl. Show. Abort. (* -> a *)
Goal P a.(q). unfold q. cbn. Show. Abort. (* -> a *)
Goal P a.(q). unfold q. hnf. Show. Abort. (* -> a.(q) *) (* bug primproj 4 *)
Arguments q : simpl never.
Goal P a.(q). unfold q. simpl. Show. Abort. (* -> a *)
Goal P a.(q). unfold q. cbn. Show. Abort. (* -> a.(q) *)
Goal P a.(q). unfold q. hnf. Show. Abort. (* -> a.(q) *) (* bug primproj 4 *)
Arguments q : simpl nomatch.
Arguments a : simpl never.
Goal P a.(q). unfold q. simpl. Show. Abort. (* -> a *)
Goal P a.(q). unfold q. cbn. Show. Abort. (* -> a.(q) *)
Goal P a.(q). unfold q. hnf. Show. Abort. (* -> a.(q) *) (* bug primproj 4 *)
End NamedCoFix.
End PrimitiveProjectionUnfolded.
Module PrimitiveProjectionConstant.
Check "** PrimitiveProjectionConstant".
(* we use a partial application to create a projection constant *)
Set Primitive Projections.
Module DirectTuple.
Check "DirectTuple (PrimitiveProjectionConstant)".
Record T := {p:nat}.
Notation TUPLE := {|p:=0|}.
Definition a := {|p:=0|}.
Axiom P : nat -> Prop.
Goal P (id p a). unfold id. cbv delta [a]. simpl. Show. Abort. (* -> 0 *)
Goal P (id p a). unfold id. cbv delta [a]. cbn. Show. Abort. (* -> 0 *)
Goal P (id p a). unfold id. cbv delta [a]. hnf. Show. Abort. (* -> TUPLE.(p) *) (* bug primproj 1 *)
Arguments p : simpl never.
Goal P (id p a). unfold id. cbv delta [a]. simpl. Show. Abort. (* -> TUPLE.(p) *)
Goal P (id p a). unfold id. cbv delta [a]. cbn. Show. Abort. (* -> TUPLE.(p) *)
Goal P (id p a). unfold id. cbv delta [a]. hnf. Show. Abort. (* -> TUPLE.(p) *) (* bug primproj 1 *)
End DirectTuple.
Module NamedTuple.
Check "NamedTuple (PrimitiveProjectionConstant)".
Record T := {p:nat}.
Definition a := {|p:=0|}.
Axiom P : nat -> Prop.
Goal P (id p a). unfold id. simpl. Show. Abort. (* -> 0 *)
Goal P (id p a). unfold id. cbn. Show. Abort. (* -> 0 *)
Goal P (id p a). unfold id. hnf. Show. Abort. (* -> a.(p) *) (* bug primproj 2 *)
Arguments p : simpl never.
Goal P (id p a). unfold id. simpl. Show. Abort. (* -> a.(p) *)
Goal P (id p a). unfold id. cbn. Show. Abort. (* -> a.(p) *)
Goal P (id p a). unfold id. hnf. Show. Abort. (* -> a.(p) *) (* bug primproj 2 *)
Arguments p : simpl nomatch.
Arguments a : simpl never.
Goal P (id p a). unfold id. simpl. Show. Abort. (* -> 0 *) (* never not respected on purpose *)
Goal P (id p a). unfold id. cbn. Show. Abort. (* -> a.(p) *)
Goal P (id p a). unfold id. hnf. Show. Abort. (* -> a.(p) *)
End NamedTuple.
Module DirectCoFix.
Check "DirectCoFix (PrimitiveProjectionConstant)".
CoInductive U := {q:U}.
Notation COFIX := (cofix a := {|q:=a|}).
Axiom P : U -> Prop.
Goal P (id q COFIX). unfold id. simpl. Show. Abort. (* -> COFIX *)
Goal P (id q COFIX). unfold id. cbn. Show. Abort. (* -> COFIX *)
Goal P (id q COFIX). unfold id. hnf. Show. Abort. (* -> COFIX.(q) *) (* bug primproj 3 *)
Arguments q : simpl never.
Goal P (id q COFIX). unfold id. simpl. Show. Abort. (* -> COFIX.(q) *)
Goal P (id q COFIX). unfold id. cbn. Show. Abort. (* -> COFIX.(q) *)
Goal P (id q COFIX). unfold id. hnf. Show. Abort. (* -> COFIX.(q) *) (* bug primproj 3 *)
End DirectCoFix.
Module NamedCoFix.
Check "NamedCoFix (PrimitiveProjectionConstant)".
CoInductive U := {q:U}.
CoFixpoint a := {|q:=a|}.
Axiom P : U -> Prop.
Goal P (id q a). unfold id. simpl. Show. Abort. (* -> a *)
Goal P (id q a). unfold id. cbn. Show. Abort. (* -> a *)
Goal P (id q a). unfold id. hnf. Show. Abort. (* -> a.(q) *) (* bug primproj 4 *)
Arguments q : simpl never.
Goal P (id q a). unfold id. simpl. Show. Abort. (* -> a.(q) *)
Goal P (id q a). unfold id. cbn. Show. Abort. (* -> a.(q) *)
Goal P (id q a). unfold id. hnf. Show. Abort. (* -> a.(q) *) (* bug primproj 4 *)
Arguments q : simpl nomatch.
Arguments a : simpl never.
Goal P (id q a). unfold id. simpl. Show. Abort. (* -> a *) (* never not respected on purpose *)
Goal P (id q a). unfold id. cbn. Show. Abort. (* -> a.(q) *)
Goal P (id q a). unfold id. hnf. Show. Abort. (* -> a.(q) *) (* bug primproj 4 *)
End NamedCoFix.
End PrimitiveProjectionConstant.
|