[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rm problematic variables under beta-redexes and evars for evar instantiation #19822

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Tragicus
Copy link
Contributor
@Tragicus Tragicus commented Nov 9, 2024

The unification algorithm sometimes fails on problems of the form ?a = t because variables that are not in the scope of ?a appear in t. There are two cases where we can easily solve the problem, namely the one where the variable appears in a beta-redex, as in (fun _ => t) x, and the one where the variable appears in an argument of an evar, e.g. ?b x, since we can instantiate the evar to forget the argument.
For instance, unifying forall x : ?T, f (?a x) and forall _ : ?T, ?b reduces to unifying f (?a x) and ?b, which fails because x is not available when instantiating ?b.
This PR adds these cases in pretyping/evarsolve.

Fixes / closes #????

  • Added / updated test-suite.
  • Added changelog.
  • Added / updated documentation.
    • Documented any new / changed user messages.
    • Updated documented syntax by running make doc_gram_rsts.
  • Opened overlay pull requests.

Overlays (to be merged before this)

@Tragicus Tragicus requested a review from a team as a code owner November 9, 2024 10:47
@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Nov 9, 2024
@SkySkimmer
Copy link
Contributor

@coqbot run full ci

@coqbot-app coqbot-app bot removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Nov 9, 2024
@SkySkimmer SkySkimmer added needs: test-suite update Test case should be added to / updated in the test-suite. needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. labels Nov 9, 2024
@ppedrot
Copy link
Member
ppedrot commented Nov 12, 2024

@coqbot ci minimize

Copy link
Contributor
coqbot-app bot commented Nov 12, 2024

I have initiated minimization at commit f592551 for the suggested targets ci-argosy, ci-elpi_test, ci-fiat_parsers, ci-hott, ci-iris, ci-perennial, ci-rewriter, ci-unimath as requested.

Copy link
Contributor
coqbot-app bot commented Nov 12, 2024

Error: Could not minimize file (from ci-elpi_test) (full log on GitHub Actions, cc @JasonGross)

build log (truncated to last 26KiB; full 8.0MiB file on GitHub Actions Artifacts under build.log)
flambda/lib/elpi/util -I /root/.opamcache/4.14.1+flambda/lib/findlib -I /root/.opamcache/4.14.1+flambda/lib/menhirLib -I /root/.opamcache/4.14.1+flambda/lib/ocaml -I /root/.opamcache/4.14.1+flambda/lib/ocaml/threads -I /root/.opamcache/4.14.1+flambda/lib/ppx_deriving/runtime -I /root/.opamcache/4.14.1+flambda/lib/re -I /root/.opamcache/4.14.1+flambda/lib/re/str -I /root/.opamcache/4.14.1+flambda/lib/seq -I /root/.opamcache/4.14.1+flambda/lib/stdlib-shims -I /root/.opamcache/4.14.1+flambda/lib/zarith -I src -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/btauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/cc -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/cc_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/derive -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/extraction -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/firstorder -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/firstorder_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/funind -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ltac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ltac2 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ltac2_ltac1 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/micromega -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/micromega_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/nsatz -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/nsatz_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/number_string_notation -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ring -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/rtauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ssreflect -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ssrmatching -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tutorial/p0 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tutorial/p1 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tutorial/p2 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tutorial/p3 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/zify -R /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/theories Coq -Q elpi elpi_elpi -Q theories elpi -R tests elpi.tests tests/test_API2.v)
Query assignments:
  X1 = «x1»
  X2 = «x2»
  X3 = «x3»
Query assignments:
  M = [[mode-ground], [mode-input]]
1
1
1.000000
1.2
Query assignments:
  C1 = «Nat.add»
  C2 = «times»
  X1 = tt
  X2 = ff
Query assignments:
  C1 = «x»
Query assignments:
  XX = «elpi.tests.test_API2.xx»
Query assignments:
  C1 = «x»
  M = «elpi.tests.test_API2.xx»
Query assignments:
  XX = «elpi.tests.test_API2.xx2»
Query assignments:
  C1 = «x»
  M = «elpi.tests.test_API2.xx2»
Query assignments:
  C1 = «x»
  M = «elpi.tests.test_API2.xx3»
Query assignments:
  _uvk_1_ = X0
  _uvk_2_ = X1
Syntactic constraints:
 evar (X1) (X2) (X1)  /* suspended on X1 */
 evar X3 (sort (typ «elpi.tests.test_API2.28»)) (X2)  /* suspended on X3, X2 */
 evar (X0) (X4) (X0)  /* suspended on X0 */
 evar X5 (sort (typ «elpi.tests.test_API2.27»)) (X4)  /* suspended on X5, X4 */
Universe constraints:
UNIVERSES:
 {elpi.tests.test_API2.28 elpi.tests.test_API2.27} |= 
ALGEBRAIC UNIVERSES:
 {}
FLEXIBLE UNIVERSES:
 
SORTS:
 α4
 α5
WEAK CONSTRAINTS:
 

Non-discriminated database
Unfoldable variable definitions: all
Unfoldable constant definitions: all
Unfoldable projection definitions: all
Cut: emp
For any goal ->   
For xeq ->   exact xxx (cost 0, pattern 0 = _, id 0)

Query assignments:
  _uvk_19_ = «T.T.u0»
Query assignments:
  Spilled_1 = «elpi.tests.test_API2.T»
Query assignments:
  GR = const const EXN PRINTING: Not_found
Query assignments:
  Spilled_1 = «elpi.tests.test_API2.F»
  Spilled_2 = «elpi.tests.test_API2.X»
«elpi.tests.test_API2.G»
Query assignments:
  G = «elpi.tests.test_API2.G»
Module G : Sig Definition id : X.T -> X.T. End := (F X)
Query assignments:
  Spilled_1 = «elpi.tests.test_API2.F»
  Spilled_2 = «elpi.tests.test_API2.X»
«elpi.tests.test_API2.H»
Query assignments:
  H = «elpi.tests.test_API2.H»
Module H : Sig Definition id : nat -> nat. End := (F X)
Query assignments:
  Spilled_1 = «elpi.tests.test_API2.T»
Query assignments:
  GR = const const EXN PRINTING: Not_found
Module Type FT = Funsig (P:T) Sig Parameter idT : P.T -> P.T. End
Query assignments:
  Spilled_1 = «elpi.tests.test_API2.FT»
  Spilled_2 = «elpi.tests.test_API2.X»
«elpi.tests.test_API2.GT»
Query assignments:
  G = «elpi.tests.test_API2.GT»
Module Type GT = Sig Parameter idT : X.T -> X.T. End
Query assignments:
  Spilled_1 = «elpi.tests.test_API2.FT»
  Spilled_2 = «elpi.tests.test_API2.X»
«elpi.tests.test_API2.HT»
Query assignments:
  H = «elpi.tests.test_API2.HT»
Module Type HT = Sig Parameter idT : nat -> nat. End
Query assignments:
  L = [«elpi.tests.test_API2.34», «elpi.tests.test_API2.35»]
  S = {{ elpi.tests.test_API2.34; elpi.tests.test_API2.35;  }}
  U = «elpi.tests.test_API2.34»
  UV = «elpi.tests.test_API2.34»
  V = «elpi.tests.test_API2.35»
  VV = «elpi.tests.test_API2.35»
Universe constraints:
UNIVERSES:
 {elpi.tests.test_API2.35 elpi.tests.test_API2.34} |= 
ALGEBRAIC UNIVERSES:
 {elpi.tests.test_API2.35 elpi.tests.test_API2.34}
FLEXIBLE UNIVERSES:
 elpi.tests.test_API2.35
 elpi.tests.test_API2.34
SORTS:
 
WEAK CONSTRAINTS:
 

Query assignments:
  _uvk_20_ = X0
  _uvk_21_ = X0
  _uvk_22_ = X1
  _uvk_23_ = X2
  _uvk_24_ = c0 \
X3 c0
  _uvk_25_ = X4
  _uvk_26_ = c0 \
X5 c0
  _uvk_27_ = X4
  _uvk_28_ = c0 \
X5 c0
  _uvk_29_ = X6
  _uvk_30_ = c0 \
X7 c0
  _uvk_31_ = c0 \ c1 \
X8 c0 c1
  _uvk_32_ = X9
  _uvk_33_ = c0 \
X10 c0
  _uvk_34_ = c0 \ c1 \
X11 c0 c1
  _uvk_35_ = X12
  _uvk_36_ = c0 \
X13 c0
  _uvk_37_ = c0 \ c1 \
X14 c0 c1
  _uvk_38_ = X12
Syntactic constraints:
 evar X12 (sort (typ «elpi.tests.test_API2.51»)) X12  /* suspended on X12 */
 evar X12 (sort (typ «elpi.tests.test_API2.54»)) X12  /* suspended on X12 */
 {c0 c1} : decl c1 `x` (X13 c0), decl c0 `z` X12
   ?- evar (X14 c0 c1) (sort (typ «elpi.tests.test_API2.53»)) (X14 c0 c1)  /* suspended on X14 */
 {c0} : decl c0 `z` X12
   ?- evar (X13 c0) (sort (typ «elpi.tests.test_API2.52»)) (X13 c0)  /* suspended on X13 */
 {c0 c1} : decl c1 `x` (X10 c0), decl c0 `z` X9
   ?- evar (X11 c0 c1) (sort (typ «elpi.tests.test_API2.50»)) (X11 c0 c1)  /* suspended on X11 */
 {c0} : decl c0 `z` X9
   ?- evar (X10 c0) (sort (typ «elpi.tests.test_API2.49»)) (X10 c0)  /* suspended on X10 */
 evar (X9) (sort (typ «elpi.tests.test_API2.48»)) (X9)  /* suspended on X9 */
 {c0 c1} : decl c1 `x` (X7 c0), decl c0 `z` X6
   ?- evar (X8 c0 c1) (sort (typ «elpi.tests.test_API2.47»)) (X8 c0 c1)  /* suspended on X8 */
 {c0} : decl c0 `z` X6
   ?- evar (X7 c0) (sort (typ «elpi.tests.test_API2.46»)) (X7 c0)  /* suspended on X7 */
 evar (X6) (sort (typ «elpi.tests.test_API2.45»)) (X6)  /* suspended on X6 */
 evar X4 (sort (typ «elpi.tests.test_API2.41»)) X4  /* suspended on X4 */
 evar X4 (sort (typ «elpi.tests.test_API2.43»)) X4  /* suspended on X4 */
 {c0} : decl c0 `x` X4
   ?- evar (X5 c0) (sort (typ «elpi.tests.test_API2.42»)) (X5 c0)  /* suspended on X5 */
 {c0} : decl c0 `x` X4
   ?- evar (X5 c0) (sort (typ «elpi.tests.test_API2.44»)) (X5 c0)  /* suspended on X5 */
 {c0} : decl c0 `x` X2
   ?- evar (X3 c0) (sort (typ «elpi.tests.test_API2.40»)) (X3 c0)  /* suspended on X3 */
 evar (X2) (sort (typ «elpi.tests.test_API2.39»)) (X2)  /* suspended on X2 */
 evar (X1) (sort (typ «elpi.tests.test_API2.38»)) (X1)  /* suspended on X1 */
 evar X0 (sort (typ «elpi.tests.test_API2.36»)) X0  /* suspended on X0 */
 evar X0 (sort (typ «elpi.tests.test_API2.37»)) X0  /* suspended on X0 */
Universe constraints:
UNIVERSES:
 {elpi.tests.test_API2.54 elpi.tests.test_API2.53 elpi.tests.test_API2.52
  elpi.tests.test_API2.51 elpi.tests.test_API2.50 elpi.tests.test_API2.49
  elpi.tests.test_API2.48 elpi.tests.test_API2.47 elpi.tests.test_API2.46
  elpi.tests.test_API2.45 elpi.tests.test_API2.44 elpi.tests.test_API2.43
  elpi.tests.test_API2.42 elpi.tests.test_API2.41 elpi.tests.test_API2.40
  elpi.tests.test_API2.39 elpi.tests.test_API2.38 elpi.tests.test_API2.37
  elpi.tests.test_API2.36} |= 
ALGEBRAIC UNIVERSES:
 {}
FLEXIBLE UNIVERSES:
 
SORTS:
 α6
 α7
 α8
 α9
 α10
 α11
 α12
 α13
 α14
 α15
 α16
 α17
 α18
 α19
 α20
 α21
 α22
 α23
 α24
WEAK CONSTRAINTS:
 

MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -q -w -deprecated-native-compiler-option -native-output-dir . -native-compiler on -nI /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/kernel -nI elpi -nI tests -nI theories -boot -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/boot -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/clib -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/config -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/engine -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/gramlib -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/interp -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/kernel -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/lib -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/library -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/parsing -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/perf -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ltac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/pretyping -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/printing -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/proofs -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/tactics -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/vernac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/vm -I /root/.opamcache/4.14.1+flambda/lib/elpi -I /root/.opamcache/4.14.1+flambda/lib/elpi/lexer_config -I /root/.opamcache/4.14.1+flambda/lib/elpi/parser -I /root/.opamcache/4.14.1+flambda/lib/elpi/trace/runtime -I /root/.opamcache/4.14.1+flambda/lib/elpi/util -I /root/.opamcache/4.14.1+flambda/lib/findlib -I /root/.opamcache/4.14.1+flambda/lib/menhirLib -I /root/.opamcache/4.14.1+flambda/lib/ocaml -I /root/.opamcache/4.14.1+flambda/lib/ocaml/threads -I /root/.opamcache/4.14.1+flambda/lib/ppx_deriving/runtime -I /root/.opamcache/4.14.1+flambda/lib/re -I /root/.opamcache/4.14.1+flambda/lib/re/str -I /root/.opamcache/4.14.1+flambda/lib/seq -I /root/.opamcache/4.14.1+flambda/lib/stdlib-shims -I /root/.opamcache/4.14.1+flambda/lib/zarith -I /github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default/src -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/btauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/cc -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/cc_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/derive -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/extraction -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/firstorder -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/firstorder_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/funind -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ltac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ltac2 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ltac2_ltac1 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/micromega -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/micromega_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/nsatz -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/nsatz_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/number_string_notation -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ring -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/rtauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ssreflect -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ssrmatching -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tutorial/p0 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tutorial/p1 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tutorial/p2 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tutorial/p3 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/zify -R /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/theories Coq -Q /github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default/elpi elpi_elpi -Q /github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default/theories elpi -R /github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default/tests elpi.tests tests/test_API2.v 
MINIMIZER_DEBUG: info: /tmp/build_1e9f6b_dune/tmp-coqbot-minimizer.DtdICkDq94
MINIMIZER_DEBUG: files:  tests/test_API2.v
File "./tests/test_API2.v", line 83, characters 0-41:
Warning: "From Coq" has been replaced by "From Stdlib".
[deprecated-from-Coq,deprecated-since-9.0,deprecated,default]
File "./tests/test_API2.v", line 127, characters 0-16:
Warning: Option Foo Bar is deprecated. elpi
[deprecated-option,deprecated,default]
File "./tests/test_API2.v", line 135, characters 0-14:
Warning: Option Foo Bar is deprecated. elpi
[deprecated-option,deprecated,default]
File "./tests/test_API2.v", line 373, characters 3-201:
Warning: constant test has no declared type. [elpi.typecheck,elpi,default]
(cd _build/default && /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc -q -w -deprecated-native-compiler-option -native-output-dir . -native-compiler on -nI /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/kernel -nI elpi -nI tests -nI theories -boot -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/boot -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/clib -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/config -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/engine -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/gramlib -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/interp -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/kernel -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/lib -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/library -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/parsing -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/perf -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ltac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/pretyping -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/printing -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/proofs -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/tactics -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/vernac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/vm -I /root/.opamcache/4.14.1+flambda/lib/elpi -I /root/.opamcache/4.14.1+flambda/lib/elpi/lexer_config -I /root/.opamcache/4.14.1+flambda/lib/elpi/parser -I /root/.opamcache/4.14.1+flambda/lib/elpi/trace/runtime -I /root/.opamcache/4.14.1+flambda/lib/elpi/util -I /root/.opamcache/4.14.1+flambda/lib/findlib -I /root/.opamcache/4.14.1+flambda/lib/menhirLib -I /root/.opamcache/4.14.1+flambda/lib/ocaml -I /root/.opamcache/4.14.1+flambda/lib/ocaml/threads -I /root/.opamcache/4.14.1+flambda/lib/ppx_deriving/runtime -I /root/.opamcache/4.14.1+flambda/lib/re -I /root/.opamcache/4.14.1+flambda/lib/re/str -I /root/.opamcache/4.14.1+flambda/lib/seq -I /root/.opamcache/4.14.1+flambda/lib/stdlib-shims -I /root/.opamcache/4.14.1+flambda/lib/zarith -I src -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/btauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/cc -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/cc_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/derive -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/extraction -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/firstorder -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/firstorder_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/funind -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ltac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ltac2 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ltac2_ltac1 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/micromega -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/micromega_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/nsatz -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/nsatz_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/number_string_notation -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ring -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/rtauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ssreflect -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/ssrmatching -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tutorial/p0 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tutorial/p1 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tutorial/p2 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/tutorial/p3 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/../coq-core/plugins/zify -R /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/theories Coq -Q elpi elpi_elpi -Q theories elpi -R tests elpi.tests tests/test_require_bad_order.v)
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -q -w -deprecated-native-compiler-option -native-output-dir . -native-compiler on -nI /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/kernel -nI elpi -nI tests -nI theories -boot -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/boot -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/clib -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/config -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/engine -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/gramlib -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/interp -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/kernel -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/lib -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/library -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/parsing -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/perf -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ltac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/pretyping -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/printing -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/proofs -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/tactics -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/vernac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/vm -I /root/.opamcache/4.14.1+flambda/lib/elpi -I /root/.opamcache/4.14.1+flambda/lib/elpi/lexer_config -I /root/.opamcache/4.14.1+flambda/lib/elpi/parser -I /root/.opamcache/4.14.1+flambda/lib/elpi/trace/runtime -I /root/.opamcache/4.14.1+flambda/lib/elpi/util -I /root/.opamcache/4.14.1+flambda/lib/findlib -I /root/.opamcache/4.14.1+flambda/lib/menhirLib -I /root/.opamcache/4.14.1+flambda/lib/ocaml -I /root/.opamcache/4.14.1+flambda/lib/ocaml/threads -I /root/.opamcache/4.14.1+flambda/lib/ppx_deriving/runtime -I /root/.opamcache/4.14.1+flambda/lib/re -I /root/.opamcache/4.14.1+flambda/lib/re/str -I /root/.opamcache/4.14.1+flambda/lib/seq -I /root/.opamcache/4.14.1+flambda/lib/stdlib-shims -I /root/.opamcache/4.14.1+flambda/lib/zarith -I /github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default/src -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/btauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/cc -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/cc_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/derive -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/extraction -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/firstorder -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/firstorder_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/funind -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ltac -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ltac2 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ltac2_ltac1 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/micromega -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/micromega_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/nsatz -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/nsatz_core -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/number_string_notation -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ring -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/rtauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ssreflect -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/ssrmatching -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tauto -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tutorial/p0 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tutorial/p1 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tutorial/p2 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/tutorial/p3 -I /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq-core/plugins/zify -R /github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/theories Coq -Q /github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default/elpi elpi_elpi -Q /github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default/theories elpi -R /github/workspace/builds/coq/coq-failing/_build_ci/elpi/_build/default/tests elpi.tests tests/test_require_bad_order.v 
MINIMIZER_DEBUG: info: /tmp/build_1e9f6b_dune/tmp-coqbot-minimizer.tQFBzn03jE
MINIMIZER_DEBUG: files:  tests/test_require_bad_order.v
make[1]: *** [Makefile:21: test-core] Error 1
make[1]: Leaving directory '/github/workspace/builds/coq/coq-failing/_build_ci/elpi'
+ code=2
+ printf '\n%s exit code: %s\n' elpi_test 2
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real elpi_test.log
No timing data
+ '[' '' ']'
+ exit 2
make: *** [Makefile.ci:192: ci-elpi_test] Error 2
/github/workspace/builds/coq /github/workspace
::endgroup::
minimizer log

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

This comment was marked as outdated.

Copy link
Contributor
coqbot-app bot commented Nov 12, 2024

Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/argosy/src/Examples/ReplicatedDisk/ReplicatedDiskImpl.v (from ci-argosy) (full log on GitHub Actions - verbose log)

We are collecting data on the user experience of the Coq Bug Minimizer.
If you haven't already filled the survey for this PR, please fill out our short survey!

🌟 Minimized Coq File (consider adding this file to the test-suite)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-w" "-deprecated-native-compiler-option,-native-compiler-disabled" "-native-compiler" "ondemand" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/argosy/src" "RecoveryRefinement" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/argosy/vendor/classes/src" "Classes" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/argosy/vendor/array/src" "Array" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/argosy/vendor/tactical/src" "Tactical" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-top" "RecoveryRefinement.Examples.ReplicatedDisk.ReplicatedDiskImpl") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 1103 lines to 98 lines, then from 111 lines to 305 lines, then from 310 lines to 129 lines, then from 142 lines to 260 lines, then from 264 lines to 134 lines, then from 147 lines to 207 lines, then from 212 lines to 137 lines, then from 150 lines to 357 lines, then from 362 lines to 156 lines, then from 169 lines to 657 lines, then from 661 lines to 162 lines, then from 175 lines to 665 lines, then from 668 lines to 227 lines, then from 240 lines to 379 lines, then from 384 lines to 271 lines, then from 284 lines to 1243 lines, then from 1247 lines to 302 lines, then from 315 lines to 413 lines, then from 416 lines to 311 lines, then from 324 lines to 862 lines, then from 867 lines to 320 lines, then from 333 lines to 440 lines, then from 445 lines to 322 lines, then from 327 lines to 323 lines *)
(* coqc version 9.0+alpha compiled with OCaml 4.09.0
   coqtop version runner-wbcqh1i1-project-4504-concurrent-0:/builds/coq/coq/_build/default,(HEAD detached at c04db99c8cfb) (c04db99c8cfbe3fa002bf604971eb5b0e09656d4)
   Expected coqc runtime on this file: 0.122 sec *)

Axiom proof_admitted : False.
Tactic Notation "admit" := abstract case proof_admitted.

Set Implicit Arguments.
Definition maybe_holds T (p:T -> Prop) : option T -> Prop.
Admitted.

Notation "m ?|= F" := (maybe_holds F m) (at level 20, F at level 50).

Section Array.
  Context (A:Type).
  Notation list := (list A).
  Implicit Types (l:list) (n:nat) (x:A).
Fixpoint assign l n x' : list.
Admitted.
Fixpoint index l n : option A.
Admitted.

End Array.

Axiom bytes : nat -> Type.

Definition blockbytes := 1024.

Definition block := bytes blockbytes.

Definition disk := list block.
Definition addr := nat.

Section OutputRelations.

  Definition relation A B T := A -> B -> T -> Prop.
Definition and_then {A B C} {T1 T2}
             (r1: relation A B T1)
             (r2: T1 -> relation B C T2) :
    relation A C T2.
Admitted.
Definition pure A T (o0:T) : relation A A T.
Admitted.
Definition rel_or A B T (r1 r2: relation A B T) : relation A B T.
Admitted.

  Definition rimpl {A B} {T} (r1 r2: relation A B T) :=
    forall x y o, r1 x y o -> r2 x y o.

End OutputRelations.

  Delimit Scope relation_scope with rel.
  Open Scope relation_scope.
  Notation "r1 ---> r2" := (rimpl r1 r2)
                             (at level 60, no associativity,
                              format "'[hv' r1  '/' ---> '/'  r2 ']'")
                           : relation_scope.
  Infix "+" := rel_or : relation_scope.

  Notation "p1 ;; p2" := (and_then p1 (fun _ => p2))
                           (at level 54, right associativity)
  : relation_scope.

  Notation "x <- p1 ; p2" := (and_then p1 (fun x => p2))
                              (at level 54, right associativity,
                               format "'[' x  <-  '[v    ' p1 ']' ; ']'  '/' p2")
                             : relation_scope.
Global Generalizable Variables T R Op State.

Inductive proc (Op: Type -> Type) (T : Type) : Type :=
| Call (op : Op T)
| Ret (v : T)
| Bind (T1 : Type) (p1 : proc Op T1) (p2 : T1 -> proc Op T).
Arguments Call {Op T}.
Arguments Ret {Op T} v.

Definition OpSemantics Op State := forall T, Op T -> relation State State T.
Definition CrashSemantics State := relation State State unit.

Record Dynamics Op State :=
  { step: OpSemantics Op State;
    crash_step: CrashSemantics State; }.

Section Dynamics.

  Context `(sem: Dynamics Op State).
  Notation proc := (proc Op).
  Notation step := sem.(step).
  Notation crash_step := sem.(crash_step).

  Fixpoint exec {T} (p: proc T) : relation State State T :=
    match p with
    | Ret v => pure v
    | Call op => step op
    | Bind p p' => v <- exec p; exec (p' v)
    end.

  Fixpoint exec_crash {T} (p: proc T) : relation State State unit :=
    match p with
    | Ret v => crash_step
    | Call op => crash_step + (step op;; crash_step)
    | Bind p p' =>
      exec_crash p +
      (v <- exec p;
         exec_crash (p' v))
    end.
Definition rexec {T R} (p: proc T) (rec: proc R) : relation State State R.
Admitted.

End Dynamics.

Record SpecProps T R State :=
  { pre: Prop;
    post: State -> T -> Prop;
    alternate: State -> R -> Prop; }.

Definition Specification T R State := State -> SpecProps T R State.
Definition spec_exec T R State (spec: Specification T R State) :
  relation State State T.
Admitted.
Definition spec_aexec T R State (spec: Specification T R State) :
  relation State State R.
Admitted.

Section Hoare.
  Context `(sem: Dynamics Op State).
  Notation proc := (proc Op).
  Notation exec := (exec sem).
  Notation exec_crash := (exec_crash sem).
  Notation rexec := (rexec sem).

  Definition proc_rspec T R
             (p: proc T) (rec: proc R)
             (spec: Specification T R State) :=
    exec p ---> spec_exec spec /\
    rexec p rec ---> spec_aexec spec.

  Definition proc_hspec T
             (p: proc T)
             (spec: Specification T unit State) :=
    exec p ---> spec_exec spec /\
    exec_crash p ---> spec_aexec spec.

  Definition idempotent A T R `(spec: A -> Specification T R State) :=
    forall a state,
      pre (spec a state) ->
      forall v state', alternate (spec a state) state' v ->
               exists a', pre (spec a' state') /\
                    forall rv state'', post (spec a' state') state'' rv ->
                                  post (spec a state) state'' rv.

  Theorem proc_hspec_to_rspec A' T R (p_hspec: Specification T unit State)
          `(rec_hspec: A' -> Specification R unit State)
          `(p_rspec: Specification T R State)
          `(p: proc T) `(rec: proc R):
    proc_hspec p p_hspec ->
    (forall a, proc_hspec rec (rec_hspec a)) ->
    idempotent rec_hspec ->
    (forall s, (p_rspec s).(pre) -> (p_hspec s).(pre) /\
               (forall s' v, (p_hspec s).(post) s' v ->
                             (p_rspec s).(post) s' v)) ->

    (forall state state' v,
        pre (p_hspec state) ->
        alternate (p_hspec state) state' v ->
        exists a, pre (rec_hspec a state')) ->

    (forall a s sc, (p_rspec s).(pre) ->
                    (forall sfin rv, (rec_hspec a sc).(post) sfin rv ->
                                     (p_rspec s).(alternate) sfin rv)) ->
    proc_rspec p rec p_rspec.
Admitted.

End Hoare.
Module Export Layer.

Record Layer Op :=
  { State: Type;
    sem: Dynamics Op State;
    initP: State -> Prop }.

Coercion sem : Layer >-> Dynamics.

Section Abstraction.
  Context (AState CState:Type).
  Context (absr: relation AState CState unit).
Definition refine_spec T R (spec: Specification T R AState)
    : AState -> Specification T R CState.
exact (fun s cs =>
      {| pre := absr s cs tt /\
                (spec s).(pre);
         post := fun cs' r =>
                   exists s', absr s' cs' tt /\
                         (spec s).(post) s' r;
         alternate := fun cs' r =>
                        exists s', absr s' cs' tt /\
                              (spec s).(alternate) s' r; |}).
Defined.

End Abstraction.
Module Export OneDiskAPI.

Module Export D.

  Definition State := disk.

End D.
Definition read_spec (a : addr) : Specification block unit D.State.
Admitted.
  Inductive diskId :=
  | d0
  | d1.

  Inductive DiskResult T :=
  | Working (v:T)
  | Failed.
Definition disk0 (state:State) : option disk.
Admitted.
Definition disk1 (state:State) : option disk.
Admitted.

  Inductive Op : Type -> Type :=
  | op_read (i : diskId) (a : addr) : Op (DiskResult block)
  | op_write (i : diskId) (a : addr) (b : block) : Op (DiskResult unit)
  | op_size (i : diskId) : Op (DiskResult nat).
Definition TDBaseDynamics : Dynamics Op State.
Admitted.

  Definition td_init (s: State) :=
    exists d_0' d_1',
      disk0 s ?|= eq d_0' /\
      disk1 s ?|= eq d_1'.
Definition TDLayer : Layer Op.
exact ({| Layer.State := State; sem := TDBaseDynamics; initP := td_init |}).
Defined.
Definition read (a:addr) : proc Op block.
Admitted.

  Theorem read_int_ok : forall a d,
      proc_hspec TDLayer
        (read a)
        (fun state =>
           {|
             pre := disk0 state ?|= eq d /\
                    disk1 state ?|= eq d;
             post :=
               fun state' r =>
                 index d a ?|= eq r /\
                 disk0 state' ?|= eq d /\
                 disk1 state' ?|= eq d;
             alternate :=
               fun state' _ =>
                 disk0 state' ?|= eq d /\
                 disk1 state' ?|= eq d;
           |}).
Admitted.

  Global Hint Resolve read_int_ok : core.
Definition Recover : proc Op unit.
Admitted.

  Inductive DiskStatus :=
  | FullySynced
  | OutOfSync (a:addr) (b:block).

  Definition Recover_spec : _ -> _ -> Specification unit unit State :=
    fun d s state =>
      {|
        pre :=
          match s with
          | FullySynced => disk0 state ?|= eq d /\
                          disk1 state ?|= eq d
          | OutOfSync a b => disk0 state ?|= eq (assign d a b) /\
                             disk1 state ?|= eq d
          end;
        post :=
          fun state' (_:unit) =>
            match s with
            | FullySynced => disk0 state' ?|= eq d /\
                            disk1 state' ?|= eq d
            | OutOfSync a b =>
              (disk0 state' ?|= eq d /\
               disk1 state' ?|= eq d) \/
              (disk0 state' ?|= eq (assign d a b) /\
               disk1 state' ?|= eq (assign d a b))
            end;
        alternate :=
          fun state' (_:unit) =>
            match s with
            | FullySynced => disk0 state' ?|= eq d /\
                            disk1 state' ?|= eq d
            | OutOfSync a b =>
              (disk0 state' ?|= eq d /\
               disk1 state' ?|= eq d) \/
              (disk0 state' ?|= eq (assign d a b) /\
               disk1 state' ?|= eq d) \/
              (disk0 state' ?|= eq (assign d a b) /\
               disk1 state' ?|= eq (assign d a b))
            end;
      |}.

  Theorem Recover_rok1 d s :
    proc_hspec TDLayer
      (Recover)
      (Recover_spec d s).
Admitted.

  Theorem Recover_spec_idempotent1 d :
    idempotent (fun (t : unit) => Recover_spec d (FullySynced)).
Admitted.
Definition rd_abstraction (d:D.State) (state: State) (u: unit) : Prop.
admit.
Defined.

  Theorem read_rec_ok :
    forall a d, proc_rspec TDLayer (read a) Recover
                           (refine_spec rd_abstraction (OneDiskAPI.read_spec a) d).
  Proof.
    intros a d.
    eapply proc_hspec_to_rspec; eauto using Recover_spec_idempotent1;
      unfold refine_spec, rd_abstraction in *.
    -
 intros [].
eapply Recover_rok1.
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 2.6MiB file on GitHub Actions Artifacts under build.log)
'[' -z x ']'
+ command make
+ make
make[1]: Entering directory '/builds/coq/coq/_build_ci/argosy'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/builds/coq/coq/_build_ci/argosy'
+ code=0
+ printf '\n%s exit code: %s\n' argosy 0
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real argosy.log
No timing data
+ '[' '' ']'
+ exit 0
/github/workspace/builds/coq /github/workspace
::endgroup::
::group::make ci-argosy (failing)
/builds/coq/coq /github/workspace/builds/coq /github/workspace
./dev/ci/ci-wrapper.sh argosy
+ CI_NAME=argosy
+ CI_SCRIPT=ci-argosy.sh
+++ dirname ./dev/ci/ci-wrapper.sh
++ cd ./dev/ci
++ pwd
+ DIR=/github/workspace/builds/coq/coq-failing/dev/ci
+ cd /github/workspace/builds/coq/coq-failing/dev/ci/../..
+ export TIMED=1
+ TIMED=1
+ '[' '' ']'
+ '[' -t 1 ']'
+ '[' '' ']'
+ COQ_CI_COLOR=
+ export GIT_PAGER=
+ GIT_PAGER=
+ '[' '' = 1 ']'
+ '[' '' = 1 ']'
+ bash /github/workspace/builds/coq/coq-failing/dev/ci/ci-argosy.sh
+ tee argosy.log
++ : 2
++ export NJOBS
++ which cygpath
++ OCAMLFINDSEP=:
++ '[' -n 1 ']'
++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin
++ export OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
++ OCAMLPATH=/github/workspace/builds/coq/coq-failing/_install_ci/lib:
++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.09.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.09.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ CI_INSTALL_DIR=/github/workspace/builds/coq/coq-failing/_install_ci
++ export CI_BRANCH=
++ CI_BRANCH=
++ [[ '' =~ ^[0-9]*$ ]]
++ export CI_PULL_REQUEST=
++ CI_PULL_REQUEST=
++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.09.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.09.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ ls -l /github/workspace/builds/coq/coq-failing/_install_ci/bin/
total 301852
-rwxr-xr-x 1 root root     2136 Nov 12 13:15 coq-tex
-rwxr-xr-x 1 root root  2068456 Nov 12 13:15 coq-tex.orig
-rwxr-xr-x 1 root root  3828176 Nov  9 10:57 coq_makefile
-rwxr-xr-x 1 root root     2133 Nov 12 13:15 coqc
-rwxr-xr-x 1 root root     2138 Nov 12 13:15 coqc.byte
-rwxr-xr-x 1 root root 36685276 Nov 12 13:15 coqc.byte.orig
-rwxr-xr-x 1 root root 27822136 Nov 12 13:15 coqc.orig
-rwxr-xr-x 1 root root 10245096 Nov  9 10:57 coqchk
-rwxr-xr-x 1 root root  4274464 Nov  9 10:57 coqdep
-rwxr-xr-x 1 root root     2135 Nov 12 13:15 coqdoc
-rwxr-xr-x 1 root root  4075000 Nov 12 13:15 coqdoc.orig
-rwxr-xr-x 1 root root     2135 Nov 12 13:15 coqide
-rwxr-xr-x 1 root root 12105584 Nov 12 13:15 coqide.orig
-rwxr-xr-x 1 root root     2143 Nov 12 13:15 coqidetop.byte
-rwxr-xr-x 1 root root 37204626 Nov 12 13:15 coqidetop.byte.orig
-rwxr-xr-x 1 root root     2142 Nov 12 13:15 coqidetop.opt
-rwxr-xr-x 1 root root 28279824 Nov 12 13:15 coqidetop.opt.orig
-rwxr-xr-x 1 root root     2138 Nov 12 13:15 coqnative
-rwxr-xr-x 1 root root 10402184 Nov 12 13:15 coqnative.orig
-rwxr-xr-x 1 root root     2134 Nov 12 13:15 coqpp
-rwxr-xr-x 1 root root  2522120 Nov 12 13:15 coqpp.orig
-rwxr-xr-x 1 root root     2144 Nov 12 13:15 coqtimelog2html
-rwxr-xr-x 1 root root  2940568 Nov 12 13:15 coqtimelog2html.orig
-rwxr-xr-x 1 root root     2135 Nov 12 13:15 coqtop
-rwxr-xr-x 1 root root     2140 Nov 12 13:15 coqtop.byte
-rwxr-xr-x 1 root root 56957355 Nov 12 13:15 coqtop.byte.orig
-rwxr-xr-x 1 root root 27822104 Nov 12 13:15 coqtop.orig
-rwxr-xr-x 1 root root     2134 Nov 12 13:15 coqwc
-rwxr-xr-x 1 root root  1789656 Nov 12 13:15 coqwc.orig
-rwxr-xr-x 1 root root     2142 Nov 12 13:15 coqworker.opt
-rwxr-xr-x 1 root root 27824232 Nov 12 13:15 coqworker.opt.orig
-rwxr-xr-x 1 root root     2139 Nov 12 13:15 coqworkmgr
-rwxr-xr-x 1 root root  2378168 Nov 12 13:15 coqworkmgr.orig
-rwxr-xr-x 1 root root     2137 Nov 12 13:15 csdpcert
-rwxr-xr-x 1 root root  3562704 Nov 12 13:15 csdpcert.orig
-rwxr-xr-x 1 root root     2140 Nov 12 13:15 ocamllibdep
-rwxr-xr-x 1 root root  2353864 Nov 12 13:15 ocamllibdep.orig
-rwxr-xr-x 1 root root     2135 Nov 12 13:15 votour
-rwxr-xr-x 1 root root  3845376 Nov 12 13:15 votour.orig
++ CI_BUILD_DIR=/github/workspace/builds/coq/coq-failing/_build_ci
++ ls -l /github/workspace/builds/coq/coq-failing/_build_ci
total 4
drwxr-xr-x 8 root root 4096 Nov  9 11:05 argosy
++ declare -A overlays
++ set +x
+ WITH_SUBMODULES=1
+ git_download argosy
+ local project=argosy
+ local dest=/github/workspace/builds/coq/coq-failing/_build_ci/argosy
+ local giturl_var=argosy_CI_GITURL
+ local giturl=https://github.com/mit-pdos/argosy
+ local ref_var=argosy_CI_REF
+ local ref=master
+ local parent_project_var=argosy_CI_PARENT_PROJECT
+ local parent_project=
+ local submodule_folder_var=argosy_CI_SUBMODULE_FOLDER
+ local submodule_folder=
+ local ov_url=
+ local ov_ref=
++ dirname /github/workspace/builds/coq/coq-failing/_build_ci/argosy
+ local dest_prefix=/github/workspace/builds/coq/coq-failing/_build_ci/
+ '[' '' = '' ']'
+ local parent_project_dest=/github/workspace/builds/coq/coq-failing/_build_ci/
+ local parent_project_relative_dest=
+ '[' -d /github/workspace/builds/coq/coq-failing/_build_ci/argosy ']'
+ echo 'Warning: download and unpacking of argosy skipped because /github/workspace/builds/coq/coq-failing/_build_ci/argosy already exists.'
Warning: download and unpacking of argosy skipped because /github/workspace/builds/coq/coq-failing/_build_ci/argosy already exists.
+ '[' '' ']'
+ cd /github/workspace/builds/coq/coq-failing/_build_ci/argosy
+ make
+ '[' -z x ']'
+ command make
+ make
make[1]: Entering directory '/github/workspace/builds/coq/coq-failing/_build_ci/argosy'
COQC src/Examples/ReplicatedDisk/ReplicatedDiskImpl.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/argosy
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -R /github/workspace/builds/coq/coq-failing/_build_ci/argosy/src RecoveryRefinement -R /github/workspace/builds/coq/coq-failing/_build_ci/argosy/vendor/classes/src Classes -R /github/workspace/builds/coq/coq-failing/_build_ci/argosy/vendor/array/src Array -R /github/workspace/builds/coq/coq-failing/_build_ci/argosy/vendor/tactical/src Tactical src/Examples/ReplicatedDisk/ReplicatedDiskImpl.v -o /github/workspace/builds/coq/coq-failing/_build_ci/argosy/src/Examples/ReplicatedDisk/ReplicatedDiskImpl.vo 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.xrmRYiSilL
MINIMIZER_DEBUG: files:  src/Examples/ReplicatedDisk/ReplicatedDiskImpl.v
File "./src/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 799, characters 8-44:
Warning:
"auto with *" was used through the default "intuition_solver" tactic.
This will be replaced by just "auto" in the future.
[intuition-auto-with-star,deprecated-since-8.17,deprecated,default]
File "./src/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 967, characters 24-36:
Error: Applied theorem does not have enough premises.

make[1]: *** [Makefile:36: src/Examples/ReplicatedDisk/ReplicatedDiskImpl.vo] Error 1
make[1]: Leaving directory '/github/workspace/builds/coq/coq-failing/_build_ci/argosy'
+ code=2
+ printf '\n%s exit code: %s\n' argosy 2
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real argosy.log
No timing data
+ '[' '' ']'
+ exit 2
make: *** [Makefile.ci:192: ci-argosy] Error 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 405KiB file on GitHub Actions Artifacts under bug.log)
fined.
�[92m
Admitting Qeds successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 57, characters 2-40:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope relation_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 274, characters 12-25:
Error: Unknown constructor: OutOfSync.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 57, characters 2-40:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope relation_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 274, characters 12-25:
Error: Unknown constructor: OutOfSync.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to admit [abstract ...]s
�[92m
Admitting [abstract ...] successful.�[0m
�[92m
Admitting [abstract ...] successful.�[0m
Admitting [abstract ...] unsuccessful.
Admitting [abstract ...] unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 57, characters 2-40:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope relation_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 274, characters 12-25:
Error: Unknown constructor: OutOfSync.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 57, characters 2-40:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope relation_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 274, characters 12-25:
Error: Unknown constructor: OutOfSync.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmp76dp3_r6/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 57, characters 2-40:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope relation_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp76dp3_r6/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 239, characters 26-31:
Error:
In environment
a : addr
d : ?T
state : Layer.State TDLayer
The term "state" has type "Layer.State TDLayer"
while it is expected to have type "State".


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmpx44c4rv2/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 57, characters 2-40:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope relation_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpx44c4rv2/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 241, characters 26-31:
Error:
In environment
a : addr
d : ?T
state : Layer.State TDLayer
The term "state" has type "Layer.State TDLayer"
while it is expected to have type "State".


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation unsuccessful.

I will now attempt to split imports and exports
Import/Export splitting unsuccessful.

I will now attempt to split := definitions
One-line definition splitting unsuccessful.

I will now attempt to remove all lines, one at a time
Line removal unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 57, characters 2-40:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope relation_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 274, characters 12-25:
Error: Unknown constructor: OutOfSync.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 57, characters 2-40:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope relation_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp89pr2f4v/RecoveryRefinement/Examples/ReplicatedDisk/ReplicatedDiskImpl.v", line 274, characters 12-25:
Error: Unknown constructor: OutOfSync.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to remove empty sections

No empty sections to remove.

Now, I will attempt to strip repeated newlines and trailing spaces from this file...
�[92m
Succeeded in stripping newlines and spaces.�[0m

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

Copy link
Contributor
coqbot-app bot commented Nov 12, 2024

Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/hott/theories/Algebra/Groups/FreeProduct.v (from ci-hott) (full log on GitHub Actions - verbose log)

We are collecting data on the user experience of the Coq Bug Minimizer.
If you haven't already filled the survey for this PR, please fill out our short survey!

🌟 Minimized Coq File (consider adding this file to the test-suite)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-noinit" "-indices-matter" "-w" "-deprecated-native-compiler-option" "-native-compiler" "no" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/hott/theories" "HoTT" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/hott/contrib" "HoTT.Contrib" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/hott/test" "HoTT.Tests" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-top" "HoTT.Algebra.Groups.FreeProduct") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 731 lines to 61 lines, then from 74 lines to 1249 lines, then from 1253 lines to 83 lines, then from 96 lines to 774 lines, then from 776 lines to 103 lines, then from 116 lines to 628 lines, then from 631 lines to 131 lines, then from 144 lines to 587 lines, then from 592 lines to 168 lines, then from 181 lines to 866 lines, then from 866 lines to 250 lines, then from 263 lines to 2527 lines, then from 2530 lines to 293 lines, then from 306 lines to 1165 lines, then from 1166 lines to 315 lines, then from 328 lines to 940 lines, then from 944 lines to 316 lines, then from 329 lines to 886 lines, then from 891 lines to 316 lines, then from 329 lines to 712 lines, then from 717 lines to 317 lines, then from 330 lines to 369 lines, then from 374 lines to 319 lines, then from 332 lines to 900 lines, then from 905 lines to 353 lines, then from 366 lines to 504 lines, then from 506 lines to 428 lines, then from 441 lines to 483 lines, then from 488 lines to 438 lines, then from 451 lines to 715 lines, then from 720 lines to 466 lines, then from 479 lines to 717 lines, then from 722 lines to 525 lines, then from 538 lines to 1221 lines, then from 1223 lines to 576 lines, then from 589 lines to 1371 lines, then from 1375 lines to 657 lines, then from 670 lines to 760 lines, then from 765 lines to 666 lines, then from 679 lines to 989 lines, then from 991 lines to 681 lines, then from 686 lines to 681 lines *)
(* coqc version 9.0+alpha compiled with OCaml 4.09.0
   coqtop version runner-wbcqh1i1-project-4504-concurrent-0:/builds/coq/coq/_build/default,(HEAD detached at c04db99c8cfb) (c04db99c8cfbe3fa002bf604971eb5b0e09656d4)
   Expected coqc runtime on this file: 0.181 sec *)

Declare Scope type_scope.

Reserved Notation "x -> y" (at level 99, right associativity, y at level 200).

Reserved Notation "x = y  :>  T"
(at level 70, y at next level, no associativity).

Reserved Notation "x + y" (at level 50, left associativity).
Reserved Notation "x * y" (at level 40, left associativity).
Reserved Notation "f == g" (at level 70, no associativity).
Reserved Notation "g 'o' f" (at level 40, left associativity).
Delimit Scope function_scope with function.
Delimit Scope trunc_scope with trunc.

Global Open Scope trunc_scope.
Global Open Scope type_scope.

Declare ML Module "ltac_plugin:coq-core.plugins.ltac".

Declare ML Module "number_string_notation_plugin:coq-core.plugins.number_string_notation".

Global Set Default Proof Mode "Classic".

Global Set Universe Polymorphism.

Global Unset Strict Universe Declaration.
Create HintDb typeclass_instances discriminated.

Notation "A -> B" := (forall (_ : A), B) : type_scope.

Inductive option (A : Type) : Type :=
| Some : A -> option A
| None : option A.

Register option as core.option.type.

Inductive sum (A B : Type) : Type :=
| inl : A -> sum A B
| inr : B -> sum A B.

Notation "x + y" := (sum x y) : type_scope.

Record prod (A B : Type) := pair { fst : A ; snd : B }.

Notation "x * y" := (prod x y) : type_scope.

Notation Type0 := Set.

Notation idmap := (fun x => x).

Record sig {A} (P : A -> Type) := exist {
  proj1 : A ;
  proj2 : P proj1 ;
}.

Notation compose := (fun g f x => g (f x)).

Notation "g 'o' f" := (compose g%function f%function) : function_scope.

Inductive paths {A : Type} (a : A) : A -> Type :=
  idpath : paths a a.

Notation "x = y :> A" := (@paths A x y) : type_scope.
Notation "x = y" := (x = y :>_) : type_scope.
Definition ap {A B : Type} (f : A -> B) {x y : A} (p : x = y) : f x = f y.
Admitted.

Definition pointwise_paths A (P : A -> Type) (f g : forall x, P x)
  := forall x, f x = g x.

Global Arguments pointwise_paths {A}%_type_scope {P} (f g)%_function_scope.

Notation "f == g" := (pointwise_paths f g) : type_scope.

Class IsEquiv {A B : Type} (f : A -> B) := {
  equiv_inv : B -> A ;
  eisretr : f o equiv_inv == idmap ;
  eissect : equiv_inv o f == idmap ;
  eisadj : forall x : A, eisretr (f x) = ap f (eissect x) ;
}.

Monomorphic Axiom Funext : Type0.
Existing Class Funext.

Inductive trunc_index : Type0 :=
| minus_two : trunc_index
| trunc_S : trunc_index -> trunc_index.

Notation "n .+1" := (trunc_S n) : trunc_scope.
Notation "n .+2" := (n.+1.+1)%trunc : trunc_scope.

Inductive IsTrunc_internal (A : Type@{u}) : trunc_index -> Type@{u} :=
| Build_Contr : forall (center : A) (contr : forall y, center = y), IsTrunc_internal A minus_two
| istrunc_S : forall {n:trunc_index}, (forall x y:A, IsTrunc_internal (x = y) n) -> IsTrunc_internal A (trunc_S n).

Existing Class IsTrunc_internal.

Notation IsTrunc n A := (IsTrunc_internal A n).
Notation IsHProp A := (IsTrunc minus_two.+1 A).
Notation IsHSet A := (IsTrunc minus_two.+2 A).

Inductive nat : Type0 :=
| O : nat
| S : nat -> nat.

Inductive Unit : Type0 := tt : Unit.

Tactic Notation "do_with_holes" tactic3(x) uconstr(p) :=
  x uconstr:(p) ||
  x uconstr:(p _) ||
  x uconstr:(p _ _) ||
  x uconstr:(p _ _ _) ||
  x uconstr:(p _ _ _ _) ||
  x uconstr:(p _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  x uconstr:(p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _).
Class IsGlobalAxiom (A : Type) : Type0 := {}.

Ltac is_global_axiom A := let _ := constr:(_ : IsGlobalAxiom A) in idtac.

Ltac global_axiom := try match goal with
    | |- ?G  => is_global_axiom G; exact _
end.

Tactic Notation "srefine" uconstr(term) := simple refine term.

Tactic Notation "snrefine" uconstr(term) := simple notypeclasses refine term; global_axiom.

Tactic Notation "rapply" uconstr(term)
  := do_with_holes ltac:(fun x => refine x) term.

Tactic Notation "srapply" uconstr(term)
  := do_with_holes ltac:(fun x => srefine x) term.

Tactic Notation "snrapply" uconstr(term)
  := do_with_holes ltac:(fun x => snrefine x) term.
Module Export Decimal.

Inductive uint : Type0 :=
 | Nil
 | D0 (_:uint)
 | D1 (_:uint)
 | D2 (_:uint)
 | D3 (_:uint)
 | D4 (_:uint)
 | D5 (_:uint)
 | D6 (_:uint)
 | D7 (_:uint)
 | D8 (_:uint)
 | D9 (_:uint).

Notation zero := (D0 Nil).

Variant int : Type0 := Pos (d:uint) | Neg (d:uint).

Variant decimal : Type0 :=
 | Decimal (i:int) (f:uint)
 | DecimalExp (i:int) (f:uint) (e:int).

Register uint as num.uint.type.
Register int as num.int.type.
Register decimal as num.decimal.type.

Fixpoint revapp (d d' : uint) :=
  match d with
  | Nil => d'
  | D0 d => revapp d (D0 d')
  | D1 d => revapp d (D1 d')
  | D2 d => revapp d (D2 d')
  | D3 d => revapp d (D3 d')
  | D4 d => revapp d (D4 d')
  | D5 d => revapp d (D5 d')
  | D6 d => revapp d (D6 d')
  | D7 d => revapp d (D7 d')
  | D8 d => revapp d (D8 d')
  | D9 d => revapp d (D9 d')
  end.

Definition rev d := revapp d Nil.

Module Export Little.

Fixpoint succ d :=
  match d with
  | Nil => D1 Nil
  | D0 d => D1 d
  | D1 d => D2 d
  | D2 d => D3 d
  | D3 d => D4 d
  | D4 d => D5 d
  | D5 d => D6 d
  | D6 d => D7 d
  | D7 d => D8 d
  | D8 d => D9 d
  | D9 d => D0 (succ d)
  end.
Module Export Hexadecimal.

Inductive uint : Type0 :=
 | Nil
 | D0 (_:uint)
 | D1 (_:uint)
 | D2 (_:uint)
 | D3 (_:uint)
 | D4 (_:uint)
 | D5 (_:uint)
 | D6 (_:uint)
 | D7 (_:uint)
 | D8 (_:uint)
 | D9 (_:uint)
 | Da (_:uint)
 | Db (_:uint)
 | Dc (_:uint)
 | Dd (_:uint)
 | De (_:uint)
 | Df (_:uint).

Variant hexadecimal : Type0 :=
 | Hexadecimal (i:int) (f:uint)
 | HexadecimalExp (i:int) (f:uint) (e:Decimal.int).

Register uint as num.hexadecimal_uint.type.
Register int as num.hexadecimal_int.type.
Register hexadecimal as num.hexadecimal.type.
Module Export Numeral.

Variant uint : Type0 := UIntDec (u:Decimal.uint) | UIntHex (u:Hexadecimal.uint).

Variant numeral : Type0 := Dec (d:Decimal.decimal) | Hex (h:Hexadecimal.hexadecimal).

Register uint as num.num_uint.type.
Register int as num.num_int.type.
Register numeral as num.number.type.

Fixpoint tail_add n m :=
  match n with
    | O => m
    | S n => tail_add n (S m)
  end.

Fixpoint tail_addmul r n m :=
  match n with
    | O => r
    | S n => tail_addmul (tail_add m r) n m
  end.

Definition tail_mul n m := tail_addmul O n m.

Local Notation ten := (S (S (S (S (S (S (S (S (S (S O)))))))))).

Fixpoint of_uint_acc (d:Decimal.uint)(acc:nat) :=
  match d with
  | Decimal.Nil => acc
  | Decimal.D0 d => of_uint_acc d (tail_mul ten acc)
  | Decimal.D1 d => of_uint_acc d (S (tail_mul ten acc))
  | Decimal.D2 d => of_uint_acc d (S (S (tail_mul ten acc)))
  | Decimal.D3 d => of_uint_acc d (S (S (S (tail_mul ten acc))))
  | Decimal.D4 d => of_uint_acc d (S (S (S (S (tail_mul ten acc)))))
  | Decimal.D5 d => of_uint_acc d (S (S (S (S (S (tail_mul ten acc))))))
  | Decimal.D6 d => of_uint_acc d (S (S (S (S (S (S (tail_mul ten acc)))))))
  | Decimal.D7 d => of_uint_acc d (S (S (S (S (S (S (S (tail_mul ten acc))))))))
  | Decimal.D8 d => of_uint_acc d (S (S (S (S (S (S (S (S (tail_mul ten acc)))))))))
  | Decimal.D9 d => of_uint_acc d (S (S (S (S (S (S (S (S (S (tail_mul ten acc))))))))))
  end.

Definition of_uint (d:Decimal.uint) := of_uint_acc d O.

Local Notation sixteen := (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S O)))))))))))))))).

Fixpoint of_hex_uint_acc (d:Hexadecimal.uint)(acc:nat) :=
  match d with
  | Hexadecimal.Nil => acc
  | Hexadecimal.D0 d => of_hex_uint_acc d (tail_mul sixteen acc)
  | Hexadecimal.D1 d => of_hex_uint_acc d (S (tail_mul sixteen acc))
  | Hexadecimal.D2 d => of_hex_uint_acc d (S (S (tail_mul sixteen acc)))
  | Hexadecimal.D3 d => of_hex_uint_acc d (S (S (S (tail_mul sixteen acc))))
  | Hexadecimal.D4 d => of_hex_uint_acc d (S (S (S (S (tail_mul sixteen acc)))))
  | Hexadecimal.D5 d => of_hex_uint_acc d (S (S (S (S (S (tail_mul sixteen acc))))))
  | Hexadecimal.D6 d => of_hex_uint_acc d (S (S (S (S (S (S (tail_mul sixteen acc)))))))
  | Hexadecimal.D7 d => of_hex_uint_acc d (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))
  | Hexadecimal.D8 d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (tail_mul sixteen acc)))))))))
  | Hexadecimal.D9 d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))))
  | Hexadecimal.Da d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc)))))))))))
  | Hexadecimal.Db d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))))))
  | Hexadecimal.Dc d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc)))))))))))))
  | Hexadecimal.Dd d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))))))))
  | Hexadecimal.De d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc)))))))))))))))
  | Hexadecimal.Df d => of_hex_uint_acc d (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (tail_mul sixteen acc))))))))))))))))
  end.

Definition of_hex_uint (d:Hexadecimal.uint) := of_hex_uint_acc d O.

Definition of_num_uint (d:Numeral.uint) :=
  match d with
  | Numeral.UIntDec d => of_uint d
  | Numeral.UIntHex d => of_hex_uint d
  end.

Fixpoint to_little_uint n acc :=
  match n with
  | O => acc
  | S n => to_little_uint n (Decimal.Little.succ acc)
  end.

Definition to_uint n :=
  Decimal.rev (to_little_uint n Decimal.zero).

Definition to_num_uint n := Numeral.UIntDec (to_uint n).

Number Notation nat of_num_uint to_num_uint (abstract after 5001) : nat_scope.

Module Export HoTT_DOT_Basics_DOT_Trunc_WRAPPED.
Module Export Trunc.
Generalizable Variables A B m n f.
Fixpoint trunc_index_inc@{} (k : trunc_index) (n : nat)
  : trunc_index.
exact (match n with
      | O => k
      | S m => (trunc_index_inc k m).+1
    end).
Defined.
Definition nat_to_trunc_index@{} (n : nat) : trunc_index.
exact ((trunc_index_inc minus_two n).+2).
Defined.

Coercion nat_to_trunc_index : nat >-> trunc_index.

Global Instance istrunc_paths' {n : trunc_index} {A : Type} `{IsTrunc n A}
  : forall x y : A, IsTrunc n (x = y) | 1000.
Admitted.

Definition istrunc_isequiv_istrunc A {B} (f : A -> B)
  `{IsTrunc n A} `{IsEquiv A B f}
  : IsTrunc n B.
Admitted.

Global Instance ishprop_istrunc `{Funext} (n : trunc_index) (A : Type)
  : IsHProp (IsTrunc n A) | 0.
Admitted.

End Trunc.

End HoTT_DOT_Basics_DOT_Trunc_WRAPPED.
Definition Coeq@{i j u} {B : Type@{i}} {A : Type@{j}} (f g : B -> A) : Type@{u}.
Admitted.

Local Open Scope nat_scope.

  Definition ExtensionAlong@{a b p m} {A : Type@{a}} {B : Type@{b}} (f : A -> B)
             (P : B -> Type@{p}) (d : forall x:A, P (f x))
    :=
       sig@{m m} (fun (s : forall y:B, P y) => forall x:A, s (f x) = d x).

  Fixpoint ExtendableAlong@{i j k l}
           (n : nat) {A : Type@{i}} {B : Type@{j}}
           (f : A -> B) (C : B -> Type@{k}) : Type@{l}
    := match n with
         | 0 => Unit
         | S n => (forall (g : forall a, C (f a)),
                     ExtensionAlong@{i j k l} f C g) *
                  forall (h k : forall b, C b),
                    ExtendableAlong n f (fun b => h b = k b)
       end.
Definition ooExtendableAlong@{i j k l}
             {A : Type@{i}} {B : Type@{j}}
             (f : A -> B) (C : B -> Type@{k}) : Type@{l}.
exact (forall n : nat, ExtendableAlong@{i j k l} n f C).
Defined.

Record Subuniverse@{i} :=
{
  In_internal : Type@{i} -> Type@{i} ;
  hprop_inO_internal : Funext -> forall (T : Type@{i}),
      IsHProp (In_internal T) ;
  inO_equiv_inO_internal : forall (T U : Type@{i}) (T_inO : In_internal T)
                                  (f : T -> U) {feq : IsEquiv f},
      In_internal U ;
}.

Class In (O : Subuniverse) (T : Type) := in_internal : In_internal O T.

Class PreReflects@{i} (O : Subuniverse@{i}) (T : Type@{i}) :=
{
  O_reflector : Type@{i} ;
  O_inO : In O O_reflector ;
  to : T -> O_reflector ;
}.

Arguments O_reflector O T {_}.
Arguments to O T {_}.

Class Reflects@{i} (O : Subuniverse@{i}) (T : Type@{i})
      `{PreReflects@{i} O T} :=
{
  extendable_to_O : forall {Q : Type@{i}} {Q_inO : In O Q},
      ooExtendableAlong (to O T) (fun _ => Q)
}.

Record ReflectiveSubuniverse@{i} :=
{
  rsu_subuniv : Subuniverse@{i} ;
  rsu_prereflects : forall (T : Type@{i}), PreReflects rsu_subuniv T ;
  rsu_reflects : forall (T : Type@{i}), Reflects rsu_subuniv T ;
}.

Coercion rsu_subuniv : ReflectiveSubuniverse >-> Subuniverse.
Global Existing Instance rsu_prereflects.
Definition rsu_reflector (O : ReflectiveSubuniverse) (T : Type) : Type.
exact (O_reflector O T).
Defined.

Coercion rsu_reflector : ReflectiveSubuniverse >-> Funclass.

Class ReflectsD@{i} (O' O : Subuniverse@{i}) (T : Type@{i})
      `{PreReflects@{i} O' T} :=
{
  extendable_to_OO :
    forall (Q : O_reflector O' T -> Type@{i}) {Q_inO : forall x, In O (Q x)},
      ooExtendableAlong (to O' T) Q
}.

Definition reflectsD_from_OO_ind@{i} {O' O : Subuniverse@{i}}
           {A : Type@{i}} `{PreReflects O' A}
           (OO_ind' : forall (B : O_reflector O' A -> Type@{i})
                             (B_inO : forall oa, In O (B oa))
                             (f : forall a, B (to O' A a))
                             oa, B oa)
           (OO_ind_beta' : forall (B : O_reflector O' A -> Type@{i})
                             (B_inO : forall oa, In O (B oa))
                             (f : forall a, B (to O' A a))
                             a, OO_ind' B B_inO f (to O' A a) = f a)
           (inO_paths' : forall (B : Type@{i}) (B_inO : In O B)
                      (z z' : B), In O (z = z'))
  : ReflectsD O' O A.
Admitted.

Record Modality@{i} := Build_Modality'
{
  modality_subuniv : Subuniverse@{i} ;
  modality_prereflects : forall (T : Type@{i}),
      PreReflects modality_subuniv T ;
  modality_reflectsD : forall (T : Type@{i}),
      ReflectsD modality_subuniv modality_subuniv T ;
}.

Global Existing Instance modality_reflectsD.

Definition modality_to_reflective_subuniverse (O : Modality@{i})
  : ReflectiveSubuniverse@{i}.
Proof.
  refine (Build_ReflectiveSubuniverse
            (modality_subuniv O) (modality_prereflects O) _).
  intros T; constructor.
  intros Q Q_inO.
  srapply extendable_to_OO.
Defined.

Coercion modality_to_reflective_subuniverse : Modality >-> ReflectiveSubuniverse.

Definition Build_Modality
           (In' : Type -> Type)
           (hprop_inO' : Funext -> forall T : Type, IsHProp (In' T))
           (inO_equiv_inO' : forall T U : Type,
               In' T -> forall f : T -> U, IsEquiv f -> In' U)
           (O_reflector' : Type -> Type)
           (O_inO' : forall T, In' (O_reflector' T))
           (to' : forall T, T -> O_reflector' T)
           (O_ind' : forall (A : Type) (B : O_reflector' A -> Type)
                            (B_inO : forall oa, In' (B oa))
                            (f : forall a, B (to' A a))
                            (z : O_reflector' A),
               B z)
           (O_ind_beta' : forall (A : Type) (B : O_reflector' A -> Type)
                                 (B_inO : forall oa, In' (B oa))
                                 (f : forall a, B (to' A a)) (a : A),
               O_ind' A B B_inO f (to' A a) = f a)
           (inO_paths' : forall (A : Type) (A_inO : In' A) (z z' : A),
               In' (z = z'))
  : Modality.
Proof.
  pose (O := Build_Subuniverse In' hprop_inO' inO_equiv_inO').
  simple refine (Build_Modality' O _ _); intros T.
  -
 exact (Build_PreReflects O T (O_reflector' T) (O_inO' T) (to' T)).
  -
 srapply reflectsD_from_OO_ind.
    +
 rapply O_ind'.
    +
 rapply O_ind_beta'.
    +
 rapply inO_paths'.
Defined.

Module Export Trunc.

  Cumulative Private Inductive Trunc (n : trunc_index) (A :Type) : Type :=
    tr : A -> Trunc n A.
  Arguments tr {n A} a.

  Global Instance istrunc_truncation (n : trunc_index) (A : Type@{i})
    : IsTrunc@{j} n (Trunc@{i} n A).
  Admitted.
Definition Trunc_ind {n A}
    (P : Trunc n A -> Type) {Pt : forall aa, IsTrunc n (P aa)}
    : (forall a, P (tr a)) -> (forall aa, P aa).
exact (fun f aa => match aa with tr a => fun _ => f a end Pt).
Defined.

End Trunc.

Definition Tr (n : trunc_index) : Modality.
Proof.
  srapply (Build_Modality (fun A => IsTrunc n A)); cbn.
  -
 intros A B ? f ?; rapply (istrunc_isequiv_istrunc A f).
  -
 exact (Trunc n).
  -
 intros; apply istrunc_truncation.
  -
 intros A; apply tr.
  -
 intros A B ? f oa; cbn in *.
    exact (Trunc_ind B f oa).
  -
 intros; reflexivity.
  -
 exact (@istrunc_paths' n).
Defined.

Declare Scope mc_scope.
Global Open Scope mc_scope.

Class SgOp A := sg_op: A -> A -> A.
Class MonUnit A := mon_unit: A.
Class Negate A := negate: A -> A.
Infix "*" := sg_op : mc_mult_scope.
Notation "(.*.)" := sg_op (only parsing) : mc_mult_scope.
Notation "(-)" := negate (only parsing) : mc_scope.

Class LeftIdentity {A B} (op : A -> B -> B) (x : A): Type
  := left_identity: forall y, op x y = y.
Class RightIdentity {A B} (op : A -> B -> A) (y : B): Type
  := right_identity: forall x, op x y = x.

Class LeftInverse {A} {B} {C} (op : A -> B -> C) (inv : B -> A) (unit : C)
  := left_inverse: forall x, op (inv x) x = unit.
Class RightInverse {A} {B} {C} (op : A -> B -> C) (inv : A -> B) (unit : C)
  := right_inverse: forall x, op x (inv x) = unit.

Class HeteroAssociative {A B C AB BC ABC}
  (fA_BC: A -> BC -> ABC) (fBC: B -> C -> BC)
  (fAB_C: AB -> C -> ABC) (fAB : A -> B -> AB): Type
  := associativity : forall x y z, fA_BC x (fBC y z) = fAB_C (fAB x y) z.
Class Associative {A} (f : A -> A -> A)
  := simple_associativity : HeteroAssociative f f f f.

Section upper_classes.
  Context (A : Type@{i}).

  Local Open Scope mc_mult_scope.

  Class IsSemiGroup {Aop: SgOp A} :=
    { sg_set : IsHSet A
    ; sg_ass : Associative (.*.) }.

  Class IsMonoid {Aop : SgOp A} {Aunit : MonUnit A} :=
    { monoid_semigroup : IsSemiGroup
    ; monoid_left_id : LeftIdentity (.*.) mon_unit
    ; monoid_right_id : RightIdentity (.*.) mon_unit }.

  Class IsGroup {Aop : SgOp A} {Aunit : MonUnit A} {Anegate : Negate A} :=
    { group_monoid : @IsMonoid (.*.) Aunit
    ; negate_l : LeftInverse (.*.) (-) mon_unit
    ; negate_r : RightInverse (.*.) (-) mon_unit }.

End upper_classes.

  Section sgmorphism_classes.
  Context {A B : Type} {Aop : SgOp A} {Bop : SgOp B}
    {Aunit : MonUnit A} {Bunit : MonUnit B}.

  Local Open Scope mc_mult_scope.

  Class IsSemiGroupPreserving (f : A -> B) :=
    preserves_sg_op : forall x y, f (x * y) = f x * f y.
  End sgmorphism_classes.

Record Group := {
  group_type :> Type;
  group_sgop :: SgOp group_type;
  group_unit :: MonUnit group_type;
  group_inverse :: Negate group_type;
  group_isgroup :: IsGroup group_type;
}.

Record GroupHomomorphism (G H : Group) := Build_GroupHomomorphism {
  grp_homo_map :> group_type G -> group_type H;
  issemigrouppreserving_grp_homo :: IsSemiGroupPreserving grp_homo_map;
}.

Section FreeProduct.

  Context (G H K : Group)
    (f : GroupHomomorphism G H) (g : GroupHomomorphism G K).
Local Definition Words : Type.
Admitted.
Local Definition pc1 : Type.
Admitted.
Local Definition pc2 : Type.
Admitted.
Local Definition pc3 : Type.
Admitted.
Local Definition pc4 : Type.
Admitted.
Local Definition pc5 : Type.
Admitted.

  Local Definition map1 : pc1 + pc2 + pc3 + pc4 + pc5 -> Words.
Admitted.

  Local Definition map2 : pc1 + pc2 + pc3 + pc4 + pc5 -> Words.
Admitted.
Definition amal_type : Type.
exact (Tr 0 (Coeq map1 map2)).
Defined.

  Global Instance sgop_amal_type : SgOp amal_type.
Admitted.

  Global Instance monunit_amal_type : MonUnit amal_type.
Admitted.

  Global Instance negate_amal_type : Negate amal_type.
Admitted.

  Global Instance associative_sgop_m : Associative sg_op.
Admitted.

  Global Instance leftidentity_sgop_amal_type : LeftIdentity sg_op mon_unit.
Admitted.

  Global Instance rightidentity_sgop_amal_type : RightIdentity sg_op mon_unit.
Admitted.

  Global Instance leftinverse_sgop_amal_type : LeftInverse sg_op negate mon_unit.
Admitted.

  Global Instance rightinverse_sgop_amal_type : RightInverse sg_op negate mon_unit.
Admitted.

  Definition AmalgamatedFreeProduct : Group.
  Proof.
    snrapply (Build_Group amal_type); repeat split; exact _.
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 3.1MiB file on GitHub Actions Artifacts under build.log)
space/builds/coq/coq-failing/_build_ci/hott/test HoTT.Tests -R /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories HoTT theories/Pointed/pSusp.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.e7zupljwzH
MINIMIZER_DEBUG: files:  theories/Pointed/pSusp.v
theories/Pointed/pSusp.vo (real: 1.05, user: 0.96, sys: 0.08, mem: 365760 ko)
COQC theories/Pointed.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/hott
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -time-file /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories/Pointed.v.timing -q -noinit -indices-matter -w -deprecated-native-compiler-option -native-compiler no -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/contrib HoTT.Contrib -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/test HoTT.Tests -R /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories HoTT theories/Pointed.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.FlUHeNKAqf
MINIMIZER_DEBUG: files:  theories/Pointed.v
theories/Pointed.vo (real: 0.15, user: 0.08, sys: 0.07, mem: 145960 ko)
COQC theories/Algebra/Groups/Image.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/hott
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -time-file /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories/Algebra/Groups/Image.v.timing -q -noinit -indices-matter -w -deprecated-native-compiler-option -native-compiler no -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/contrib HoTT.Contrib -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/test HoTT.Tests -R /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories HoTT theories/Algebra/Groups/Image.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.D9ir5vZC5W
MINIMIZER_DEBUG: files:  theories/Algebra/Groups/Image.v
theories/Algebra/Groups/Image.vo (real: 0.35, user: 0.24, sys: 0.11, mem: 350012 ko)
COQC theories/Algebra/Groups/Kernel.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/hott
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -time-file /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories/Algebra/Groups/Kernel.v.timing -q -noinit -indices-matter -w -deprecated-native-compiler-option -native-compiler no -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/contrib HoTT.Contrib -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/test HoTT.Tests -R /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories HoTT theories/Algebra/Groups/Kernel.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.OSmvZGDdqx
MINIMIZER_DEBUG: files:  theories/Algebra/Groups/Kernel.v
theories/Algebra/Groups/Kernel.vo (real: 0.27, user: 0.18, sys: 0.09, mem: 328956 ko)
COQC theories/Spaces/Finite/Finite.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/hott
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -time-file /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories/Spaces/Finite/Finite.v.timing -q -noinit -indices-matter -w -deprecated-native-compiler-option -native-compiler no -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/contrib HoTT.Contrib -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/test HoTT.Tests -R /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories HoTT theories/Spaces/Finite/Finite.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.WAAG86RNWz
MINIMIZER_DEBUG: files:  theories/Spaces/Finite/Finite.v
theories/Spaces/Finite/Finite.vo (real: 1.46, user: 1.35, sys: 0.11, mem: 343464 ko)
COQC theories/Algebra/Groups/QuotientGroup.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/hott
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -time-file /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories/Algebra/Groups/QuotientGroup.v.timing -q -noinit -indices-matter -w -deprecated-native-compiler-option -native-compiler no -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/contrib HoTT.Contrib -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/test HoTT.Tests -R /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories HoTT theories/Algebra/Groups/QuotientGroup.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.XhmygExVY8
MINIMIZER_DEBUG: files:  theories/Algebra/Groups/QuotientGroup.v
theories/Algebra/Groups/QuotientGroup.vo (real: 0.77, user: 0.69, sys: 0.08, mem: 359608 ko)
COQC theories/Algebra/Groups/FreeProduct.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/////coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/hott
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -time-file /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories/Algebra/Groups/FreeProduct.v.timing -q -noinit -indices-matter -w -deprecated-native-compiler-option -native-compiler no -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/contrib HoTT.Contrib -Q /github/workspace/builds/coq/coq-failing/_build_ci/hott/test HoTT.Tests -R /github/workspace/builds/coq/coq-failing/_build_ci/hott/theories HoTT theories/Algebra/Groups/FreeProduct.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.qyG0sRXRqq
MINIMIZER_DEBUG: files:  theories/Algebra/Groups/FreeProduct.v
File "./theories/Algebra/Groups/FreeProduct.v", line 522, characters 58-59:
Error: Could not find an instance for "Associative sg_op" in
environment:
G : Group
H : Group
K : Group
f : GroupHomomorphism G H
g : GroupHomomorphism G K


Command exited with non-zero status 1
theories/Algebra/Groups/FreeProduct.vo (real: 1.28, user: 1.15, sys: 0.12, mem: 368652 ko)
make[3]: *** [Makefile.coq:804: theories/Algebra/Groups/FreeProduct.vo] Error 1
make[2]: *** [Makefile.coq:417: all] Error 2
make[1]: *** [Makefile:21: invoke-coqmakefile] Error 2
make[1]: Leaving directory '/github/workspace/builds/coq/coq-failing/_build_ci/hott'
+ code=2
+ printf '\n%s exit code: %s\n' hott 2
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real hott.log
    Time |  Peak Mem | File Name                      
------------------------------------------------------
0m09.99s | 368652 ko | Total Time / Peak Mem          
------------------------------------------------------
0m01.46s | 343464 ko | Spaces/Finite/Finite.vo        
0m01.28s | 368652 ko | Algebra/Groups/FreeProduct.vo  
0m01.09s | 359736 ko | Pointed/Loops.vo               
0m01.05s | 365760 ko | Pointed/pSusp.vo               
0m01.00s | 361644 ko | Homotopy/BlakersMassey.vo      
0m00.95s | 353540 ko | Homotopy/Join/Core.vo          
0m00.83s | 358020 ko | Pointed/pFiber.vo              
0m00.77s | 359608 ko | Algebra/Groups/QuotientGroup.vo
0m00.40s | 346292 ko | Pointed/pTrunc.vo              
0m00.35s | 350012 ko | Algebra/Groups/Image.vo        
0m00.27s | 328956 ko | Algebra/Groups/Kernel.vo       
0m00.27s | 307076 ko | Homotopy/Freudenthal.vo        
0m00.15s | 145960 ko | Pointed.vo                     
0m00.12s |  99544 ko | Truncations.vo                 
+ '[' '' ']'
+ exit 2
make: *** [Makefile.ci:192: ci-hott] Error 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 721KiB file on GitHub Actions Artifacts under bug.log)
, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 22, characters 0-43:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope function_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 23, characters 0-37:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope trunc_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 343, characters 0-78:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope nat_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 571, characters 0-35:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope mc_mult_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 680, characters 58-59:
Error: Could not find an instance for "Associative sg_op".



�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmpw6vmmvzk/HoTT/Algebra/Groups/FreeProduct.v", line 22, characters 0-43:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope function_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpw6vmmvzk/HoTT/Algebra/Groups/FreeProduct.v", line 23, characters 0-37:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope trunc_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpw6vmmvzk/HoTT/Algebra/Groups/FreeProduct.v", line 343, characters 0-78:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope nat_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpw6vmmvzk/HoTT/Algebra/Groups/FreeProduct.v", line 419, characters 0-198:
Error:
Universe
HoTT.Algebra.Groups.FreeProduct.228 (File "/tmp/tmpw6vmmvzk/HoTT/Algebra/Groups/FreeProduct.v", line 423, characters 6-23)
is unbound.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmpip0ek_gl/HoTT/Algebra/Groups/FreeProduct.v", line 22, characters 0-43:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope function_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpip0ek_gl/HoTT/Algebra/Groups/FreeProduct.v", line 23, characters 0-37:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope trunc_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpip0ek_gl/HoTT/Algebra/Groups/FreeProduct.v", line 343, characters 0-78:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope nat_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpip0ek_gl/HoTT/Algebra/Groups/FreeProduct.v", line 351, characters 0-8:
Error:  (in proof trunc_index_inc): Attempt to save an incomplete proof
(the proof term is not complete because of given up (admitted) goals).
If this is really what you want to do, use Admitted in place of Qed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation unsuccessful.

I will now attempt to split imports and exports
Import/Export splitting unsuccessful.

I will now attempt to split := definitions
One-line definition splitting unsuccessful.

I will now attempt to remove all lines, one at a time
Line removal unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
File "/tmp/tmp5v6ohin1/HoTT/Algebra/Groups/FreeProduct.v", line 22, characters 0-43:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope function_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp5v6ohin1/HoTT/Algebra/Groups/FreeProduct.v", line 23, characters 0-37:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope trunc_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp5v6ohin1/HoTT/Algebra/Groups/FreeProduct.v", line 343, characters 0-78:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope nat_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp5v6ohin1/HoTT/Algebra/Groups/FreeProduct.v", line 545, characters 1-17:
Error: No product even after head-reduction.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 22, characters 0-43:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope function_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 23, characters 0-37:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope trunc_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 343, characters 0-78:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope nat_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 571, characters 0-35:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope mc_mult_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp_8pkwo_6/HoTT/Algebra/Groups/FreeProduct.v", line 680, characters 58-59:
Error: Could not find an instance for "Associative sg_op".



�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to remove empty sections

No empty sections to remove.

Now, I will attempt to strip repeated newlines and trailing spaces from this file...
�[92m
Succeeded in stripping newlines and spaces.�[0m

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

Copy link
Contributor
coqbot-app bot commented Nov 12, 2024

Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/fiat_parsers/src/Common/FMapExtensions/LiftRelationInstances.v (from ci-fiat_parsers) (full log on GitHub Actions - verbose log)

We are collecting data on the user experience of the Coq Bug Minimizer.
If you haven't already filled the survey for this PR, please fill out our short survey!

🌟 Minimized Coq File (consider adding this file to the test-suite)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-compat" "8.4" "-w" "unsupported-attributes" "-w" "-deprecated-native-compiler-option" "-native-compiler" "no" "-w" "-deprecated-appcontext -notation-overridden" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src" "Fiat" "-R" "/github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/Bedrock" "Bedrock" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-I" "/github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src/Common/Tactics" "-I" "/github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers" "-top" "Fiat.Common.FMapExtensions.LiftRelationInstances") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 891 lines to 51 lines, then from 64 lines to 185 lines, then from 190 lines to 52 lines, then from 65 lines to 2346 lines, then from 2343 lines to 74 lines, then from 87 lines to 1906 lines, then from 1906 lines to 76 lines, then from 89 lines to 247 lines, then from 252 lines to 170 lines, then from 183 lines to 236 lines, then from 241 lines to 185 lines, then from 190 lines to 186 lines *)
(* coqc version 9.0+alpha compiled with OCaml 4.09.0
   coqtop version runner-wbcqh1i1-project-4504-concurrent-0:/builds/coq/coq/_build/default,(HEAD detached at c04db99c8cfb) (c04db99c8cfbe3fa002bf604971eb5b0e09656d4)
   Expected coqc runtime on this file: 0.738 sec *)

Require Stdlib.FSets.FMapFacts.

Ltac split_in_context_by ident funl funr tac :=
  repeat match goal with
         | [ H : context p [ident] |- _ ] =>
           let H0 := context p[funl] in let H0' := eval simpl in H0 in assert H0' by (tac H);
                                          let H1 := context p[funr] in let H1' := eval simpl in H1 in assert H1' by (tac H);
                                                                         clear H
         end.
Ltac split_in_context ident funl funr :=
  split_in_context_by ident funl funr ltac:(fun H => apply H).

Ltac split_and' :=
  repeat match goal with
         | [ H : ?a /\ ?b |- _ ] => let H0 := fresh in let H1 := fresh in
                                                       assert (H0 := fst H); assert (H1 := snd H); clear H
         end.
Ltac split_and := split_and'; split_in_context and (fun a b : Type => a) (fun a b : Type => b).

Ltac set_match_refl v' only_when :=
  lazymatch goal with
  | [ |- context G[match ?e with _ => _ end eq_refl] ]
    => only_when e;
       let T := fresh in
       evar (T : Type); evar (v' : T);
       subst T;
       let vv := (eval cbv delta [v'] in v') in
       let G' := context G[vv] in
       let G''' := context G[v'] in
       lazymatch goal with |- ?G'' => unify G' G'' end;
       change G'''
  end.
Ltac set_match_refl_hyp v' only_when :=
  lazymatch goal with
  | [ H : context G[match ?e with _ => _ end eq_refl] |- _ ]
    => only_when e;
       let T := fresh in
       evar (T : Type); evar (v' : T);
       subst T;
       let vv := (eval cbv delta [v'] in v') in
       let G' := context G[vv] in
       let G''' := context G[v'] in
       let G'' := type of H in
       unify G' G'';
       change G''' in H
  end.
Ltac destruct_by_existing_equation match_refl_hyp :=
  let v := (eval cbv delta [match_refl_hyp] in match_refl_hyp) in
  lazymatch v with
  | match ?e with _ => _ end (@eq_refl ?T ?e)
    => let H := fresh in
       let e' := fresh in
       pose e as e';
       change e with e' in (value of match_refl_hyp) at 1;
       first [ pose (@eq_refl T e : e = e') as H;
               change (@eq_refl T e) with H in (value of match_refl_hyp);
               clearbody H e'
             | pose (@eq_refl T e : e' = e) as H;
               change (@eq_refl T e) with H in (value of match_refl_hyp);
               clearbody H e' ];
       destruct e'; subst match_refl_hyp
  end.
Ltac destruct_rewrite_sumbool e :=
  let H := fresh in
  destruct e as [H|H];
  try lazymatch type of H with
      | ?LHS = ?RHS
        => lazymatch RHS with
           | context[LHS] => fail
           | _ => idtac
           end;
           rewrite ?H; rewrite ?H in *;
           repeat match goal with
                  | [ |- context G[LHS] ]
                    => let LHS' := fresh in
                       pose LHS as LHS';
                       let G' := context G[LHS'] in
                       change G';
                       replace LHS' with RHS by (subst LHS'; symmetry; apply H);
                       subst LHS'
                  end
      end.
Ltac break_match_step only_when :=
  match goal with
  | [ |- context[match ?e with _ => _ end] ]
    => only_when e; is_var e; destruct e
  | [ |- context[match ?e with _ => _ end] ]
    => only_when e;
       match type of e with
       | sumbool _ _ => destruct_rewrite_sumbool e
       end
  | [ |- context[if ?e then _ else _] ]
    => only_when e; destruct e eqn:?
  | [ |- context[match ?e with _ => _ end] ]
    => only_when e; destruct e eqn:?
  | _ => let v := fresh in set_match_refl v only_when; destruct_by_existing_equation v
  end.
Ltac break_match_hyps_step only_when :=
  match goal with
  | [ H : context[match ?e with _ => _ end] |- _ ]
    => only_when e; is_var e; destruct e
  | [ H : context[match ?e with _ => _ end] |- _ ]
    => only_when e;
       match type of e with
       | sumbool _ _ => destruct_rewrite_sumbool e
       end
  | [ H : context[if ?e then _ else _] |- _ ]
    => only_when e; destruct e eqn:?
  | [ H : context[match ?e with _ => _ end] |- _ ]
    => only_when e; destruct e eqn:?
  | _ => let v := fresh in set_match_refl_hyp v only_when; destruct_by_existing_equation v
  end.
Ltac break_match := repeat break_match_step ltac:(fun _ => idtac).
Ltac break_match_hyps := repeat break_match_hyps_step ltac:(fun _ => idtac).
Export Coq.FSets.FMapInterface.

Module FMapExtensions_fun (E: DecidableType) (Import M: WSfun E).
Definition lift_relation_gen_hetero {A B P}
             (and : P -> P -> P) (True : P)
             (R : A -> B -> P) (defaultA : A) (defaultB : B)
    : t A -> t B -> P.
Admitted.

  Lemma lift_relation_gen_hetero_iff {A B P} and True' (Q : P -> Prop) R defaultA defaultB (m1 : t A) (m2 : t B)
        (QTrue_or_key : Q True' \/ exists k, find k m1 = None /\ find k m2 = None)
        (Qand : forall x y, Q (and x y) <-> Q x /\ Q y)
    : Q (lift_relation_gen_hetero and True' R defaultA defaultB m1 m2)
      <-> forall k, Q (match find k m1, find k m2 with
                       | Some x1, Some x2 => R x1 x2
                       | Some x, None => R x defaultB
                       | None, Some x => R defaultA x
                       | None, None => True'
                       end).
Admitted.

End FMapExtensions_fun.

Class pull_forall_able (iffR : Prop -> Prop -> Prop)
  := pull_forall_iffR : forall A P Q, (forall x : A, iffR (P x) (Q x)) -> iffR (forall x, P x) (forall x, Q x).

Module FMapExtensionsLiftRelationInstances_fun (E: DecidableType) (Import M: WSfun E).
  Module BasicExtensions := FMapExtensions_fun E M.
  Include BasicExtensions.

    Section rel.
    Context {P} {Q : P -> Prop} {and True'}
            (HTrue' : Q True')
            (Hand : forall x y, Q (and x y) <-> Q x /\ Q y)
            (iffP : P -> P -> Prop)
            (iffP_iff : forall x y, iffP x y <-> (Q x <-> Q y))
            {A} {default : A}.

    Local Coercion Q : P >-> Sortclass.

    Local Notation lift R := (@lift_relation_gen_hetero A A P and True' R default default).

    Local Ltac t :=
      repeat ((rewrite lift_relation_gen_hetero_iff by auto) || intro);
      repeat match goal with
             | [ H : forall k : key, _, k' : key |- _ ] => specialize (H k')
             | [ |- ?R (forall _, _) (forall _, _) ] => apply pull_forall_iffR; intro
             end;
      try solve [ break_match; break_match_hyps; eauto ].
      Context {R : A -> A -> P}.
        Context {R1 R2 : A -> A -> P}
                {R1_Reflexive : Reflexive R1}
                {R2_Reflexive : Reflexive R2}
                {R1_subrelation : subrelation R1 R}
                {R2_subrelation : subrelation R2 R}.

        Global Instance lift_relation_gen_hetero_homo_Proper_Proper_subrelation_iffR
               {iffR}
               {iffR_Proper : Proper (iff ==> iff ==> flip impl) iffR}
               {iffR_pull : pull_forall_able iffR}
               {R_Proper : Proper (R1 ==> R2 ==> iffR) R}
          : Proper (lift R1 ==> lift R2 ==> iffR) (lift R) | 2.
        Proof.
          pose proof (R1_Reflexive default).
          pose proof (R2_Reflexive default).
          t; compute in * |- ; split_and; break_match; try split;
            try solve [ eauto 3
                      | eapply iffR_Proper; [ | | eauto ]; [ | eauto ]; eauto ].
        Qed.
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 3.2MiB file on GitHub Actions Artifacts under build.log)
script like: for f in
$(find . -name '*.v'); do sed '/Arguments/ s/%/%_/g' -i $f ; done
[argument-scope-delimiter,deprecated-since-8.19,deprecated,default]
COQC src/ADTRefinement/BuildADTSetoidMorphisms.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin///coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -q -compat 8.4 -w unsupported-attributes -w -deprecated-native-compiler-option -native-compiler no -w -deprecated-appcontext\ -notation-overridden -I /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src/Common/Tactics -I /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers -R /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src Fiat -R /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/Bedrock Bedrock src/ADTRefinement/BuildADTSetoidMorphisms.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.yVfBYPx0A2
MINIMIZER_DEBUG: files:  src/ADTRefinement/BuildADTSetoidMorphisms.v
While loading initial state:
Warning: Did not find compatibility module Coq84 with prefix Stdlib.
[compatibility-module-not-found,filesystem,default]
File "./src/ADTRefinement/BuildADTSetoidMorphisms.v", line 1, characters 0-128:
Warning: Notations "Def Constructor0 _ : rep := _" defined at level 94
and "Def ADT { rep := _ , _ , .. , _ ,, _ , .. , _ }" defined at level 96
have incompatible prefixes. One of them will likely not work.
[notation-incompatible-prefix,parsing,default]
COQC src/ADTRefinement/GeneralBuildADTRefinements.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin///coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -q -compat 8.4 -w unsupported-attributes -w -deprecated-native-compiler-option -native-compiler no -w -deprecated-appcontext\ -notation-overridden -I /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src/Common/Tactics -I /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers -R /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src Fiat -R /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/Bedrock Bedrock src/ADTRefinement/GeneralBuildADTRefinements.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.aNXXBY9kGE
MINIMIZER_DEBUG: files:  src/ADTRefinement/GeneralBuildADTRefinements.v
While loading initial state:
Warning: Did not find compatibility module Coq84 with prefix Stdlib.
[compatibility-module-not-found,filesystem,default]
File "./src/ADTRefinement/GeneralBuildADTRefinements.v", line 1, characters 15-29:
Warning: Coq.Lists.List has been replaced by Stdlib.Lists.List.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "./src/ADTRefinement/GeneralBuildADTRefinements.v", line 1, characters 30-45:
Warning: Coq.Arith.Arith has been replaced by Stdlib.Arith.Arith.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "./src/ADTRefinement/GeneralBuildADTRefinements.v", line 1, characters 0-577:
Warning: Notations "Def Constructor0 _ : rep := _" defined at level 94
and "Def ADT { rep := _ , _ , .. , _ ,, _ , .. , _ }" defined at level 96
have incompatible prefixes. One of them will likely not work.
[notation-incompatible-prefix,parsing,default]
File "./src/ADTRefinement/GeneralBuildADTRefinements.v", line 19, characters 17-35:
Warning: Coq.Strings.String has been replaced by Stdlib.Strings.String.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "./src/ADTRefinement/GeneralBuildADTRefinements.v", line 19, characters 2-36:
Warning: Use of “Require” inside a section is fragile. It is not recommended
to use this functionality in finished proof scripts.
[require-in-section,fragile,default]
File "./src/ADTRefinement/GeneralBuildADTRefinements.v", line 20, characters 2-32:
Warning: Adding and removing hints in the core database implicitly is
deprecated. Please specify a hint database.
[implicit-core-hint-db,deprecated-since-8.10,deprecated,default]
COQC src/ADTRefinement/BuildADTRefinements/HoneRepresentation.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin///coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -q -compat 8.4 -w unsupported-attributes -w -deprecated-native-compiler-option -native-compiler no -w -deprecated-appcontext\ -notation-overridden -I /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src/Common/Tactics -I /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers -R /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src Fiat -R /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/Bedrock Bedrock src/ADTRefinement/BuildADTRefinements/HoneRepresentation.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.yxeBmBkrKc
MINIMIZER_DEBUG: files:  src/ADTRefinement/BuildADTRefinements/HoneRepresentation.v
While loading initial state:
Warning: Did not find compatibility module Coq84 with prefix Stdlib.
[compatibility-module-not-found,filesystem,default]
File "./src/ADTRefinement/BuildADTRefinements/HoneRepresentation.v", line 1, characters 15-29:
Warning: Coq.Lists.List has been replaced by Stdlib.Lists.List.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "./src/ADTRefinement/BuildADTRefinements/HoneRepresentation.v", line 1, characters 0-535:
Warning: Notations "Def Constructor0 _ : rep := _" defined at level 94
and "Def ADT { rep := _ , _ , .. , _ ,, _ , .. , _ }" defined at level 96
have incompatible prefixes. One of them will likely not work.
[notation-incompatible-prefix,parsing,default]
COQC src/Common/FMapExtensions/LiftRelationInstances.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin///coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -q -compat 8.4 -w unsupported-attributes -w -deprecated-native-compiler-option -native-compiler no -w -deprecated-appcontext\ -notation-overridden -I /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src/Common/Tactics -I /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers -R /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/src Fiat -R /github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers/Bedrock Bedrock src/Common/FMapExtensions/LiftRelationInstances.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.AxP1ug9IHm
MINIMIZER_DEBUG: files:  src/Common/FMapExtensions/LiftRelationInstances.v
While loading initial state:
Warning: Did not find compatibility module Coq84 with prefix Stdlib.
[compatibility-module-not-found,filesystem,default]
File "./src/Common/FMapExtensions/LiftRelationInstances.v", line 88, characters 8-12:
Error:
 (in proof lift_relation_gen_hetero_homo_Proper_Proper_subrelation_iffR): Attempt to save an incomplete proof
(there are remaining open goals).

make[1]: *** [Makefile.coq:804: src/Common/FMapExtensions/LiftRelationInstances.vo] Error 1
make[1]: Leaving directory '/github/workspace/builds/coq/coq-failing/_build_ci/fiat_parsers'
+ code=2
+ printf '\n%s exit code: %s\n' fiat_parsers 2
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real fiat_parsers.log
    Time | Peak Mem | File Name            
-------------------------------------------
0m00.02s | 19332 ko | Total Time / Peak Mem
-------------------------------------------
0m00.02s | 19332 ko | conftest.cmx         
+ '[' '' ']'
+ exit 2
make: *** [Makefile.ci:192: ci-fiat_parsers] Error 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 190KiB file on GitHub Actions Artifacts under bug.log)
d/bug_01.glob

No Requires to split.

In order to efficiently manipulate the file, I have to break it into statements.  I will attempt to do this by matching on periods.
�[92m
Splitting successful.�[0m

I will now attempt to remove any lines after the line which generates the error.
�[92m
Trimming successful.  We removed all lines after 189; the error was on line 189.�[0m

In order to efficiently manipulate the file, I have to break it into definitions.  I will now attempt to do this.
Sending statements to coqtop...
Done.  Splitting to definitions...
�[92m
Splitting to definitions successful.�[0m

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions
�[92m
Definition removal successful.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions
�[92m
Non-instance definition removal successful.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Qed Obligation with Admit Obligations
�[92m
Admitting Qed Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qed Obligations unsuccessful.
No successful changes.

I will now attempt to replace Qeds with Admitteds

Non-fatal error: Failed to admit Qeds and preserve the error.  
The new error was:
While loading initial state:
Warning: Did not find compatibility module Coq84 with prefix Stdlib.
[compatibility-module-not-found,filesystem,default]
File "/tmp/tmpar46hh1z/Fiat/Common/FMapExtensions/LiftRelationInstances.v", line 123, characters 7-30:
Warning: Coq.FSets.FMapInterface has been replaced by
Stdlib.FSets.FMapInterface.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
Error: The section rel and module FMapExtensionsLiftRelationInstances_fun
need to be closed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to replace Qeds with admit. Defined.

Non-fatal error: Failed to admit Qeds and preserve the error.  
The new error was:
While loading initial state:
Warning: Did not find compatibility module Coq84 with prefix Stdlib.
[compatibility-module-not-found,filesystem,default]
File "/tmp/tmpy3ac0bcc/Fiat/Common/FMapExtensions/LiftRelationInstances.v", line 123, characters 7-30:
Warning: Coq.FSets.FMapInterface has been replaced by
Stdlib.FSets.FMapInterface.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpy3ac0bcc/Fiat/Common/FMapExtensions/LiftRelationInstances.v", line 186, characters 0-8:
Error:
 (in proof lift_relation_gen_hetero_homo_Proper_Proper_subrelation_iffR): Attempt to save an incomplete proof
(the proof term is not complete because of given up (admitted) goals).
If this is really what you want to do, use Admitted in place of Qed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting Qeds unsuccessful.
No successful changes.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions
�[92m
Definition removal successful.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions
�[92m
Non-instance definition removal successful.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to admit [abstract ...]s
�[92m
Admitting [abstract ...] successful.�[0m
�[92m
Admitting [abstract ...] successful.�[0m
Admitting [abstract ...] unsuccessful.
Admitting [abstract ...] unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions
�[92m
Definition removal successful.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions
�[92m
Non-instance definition removal successful.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
While loading initial state:
Warning: Did not find compatibility module Coq84 with prefix Stdlib.
[compatibility-module-not-found,filesystem,default]
File "/tmp/tmpar46hh1z/Fiat/Common/FMapExtensions/LiftRelationInstances.v", line 123, characters 7-30:
Warning: Coq.FSets.FMapInterface has been replaced by
Stdlib.FSets.FMapInterface.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
Error: The section rel and module FMapExtensionsLiftRelationInstances_fun
need to be closed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined
�[92m
Admitting lemmas successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
While loading initial state:
Warning: Did not find compatibility module Coq84 with prefix Stdlib.
[compatibility-module-not-found,filesystem,default]
File "/tmp/tmpy3ac0bcc/Fiat/Common/FMapExtensions/LiftRelationInstances.v", line 123, characters 7-30:
Warning: Coq.FSets.FMapInterface has been replaced by
Stdlib.FSets.FMapInterface.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpy3ac0bcc/Fiat/Common/FMapExtensions/LiftRelationInstances.v", line 186, characters 0-8:
Error:
 (in proof lift_relation_gen_hetero_homo_Proper_Proper_subrelation_iffR): Attempt to save an incomplete proof
(the proof term is not complete because of given up (admitted) goals).
If this is really what you want to do, use Admitted in place of Qed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation unsuccessful.

I will now attempt to split imports and exports
Import/Export splitting unsuccessful.

I will now attempt to split := definitions
One-line definition splitting unsuccessful.

I will now attempt to remove all lines, one at a time
Line removal unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions
�[92m
Definition removal successful.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions
�[92m
Non-instance definition removal successful.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to remove empty sections

No empty sections to remove.

Now, I will attempt to strip repeated newlines and trailing spaces from this file...
�[92m
Succeeded in stripping newlines and spaces.�[0m

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

Copy link
Contributor
coqbot-app bot commented Nov 12, 2024

Partially Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/unimath/UniMath/AlgebraicTheories/Combinators.v (from ci-unimath) (full log on GitHub Actions - verbose log)

We are collecting data on the user experience of the Coq Bug Minimizer.
If you haven't already filled the survey for this PR, please fill out our short survey!

⭐ 🏗️ Partially Minimized Coq File (could not inline Ltac2.Notations)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-noinit" "-indices-matter" "-type-in-type" "-w" "-notation-overridden" "-w" "-deprecated-native-compiler-option" "-native-compiler" "no" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/unimath/UniMath" "UniMath" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-top" "UniMath.AlgebraicTheories.Combinators") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 2076 lines to 53 lines, then from 66 lines to 121 lines, then from 126 lines to 67 lines, then from 80 lines to 544 lines, then from 550 lines to 81 lines, then from 95 lines to 500 lines, then from 506 lines to 96 lines, then from 110 lines to 433 lines, then from 439 lines to 155 lines, then from 169 lines to 544 lines, then from 550 lines to 170 lines, then from 184 lines to 518 lines, then from 524 lines to 204 lines, then from 218 lines to 557 lines, then from 561 lines to 267 lines, then from 281 lines to 538 lines, then from 544 lines to 291 lines, then from 305 lines to 2633 lines, then from 2603 lines to 296 lines, then from 310 lines to 2483 lines, then from 2431 lines to 306 lines, then from 319 lines to 3402 lines, then from 3274 lines to 309 lines, then from 323 lines to 1112 lines, then from 1084 lines to 313 lines, then from 327 lines to 1494 lines, then from 1486 lines to 313 lines, then from 327 lines to 1690 lines, then from 1558 lines to 312 lines, then from 326 lines to 807 lines, then from 813 lines to 326 lines, then from 340 lines to 1732 lines, then from 1637 lines to 330 lines, then from 344 lines to 4387 lines, then from 4298 lines to 368 lines, then from 382 lines to 587 lines, then from 592 lines to 416 lines, then from 430 lines to 639 lines, then from 645 lines to 464 lines, then from 470 lines to 465 lines *)
(* coqc version 9.0+alpha compiled with OCaml 4.14.1
   coqtop version runner-t7b1znuaq-project-4504-concurrent-0:/builds/coq/coq/_build/default,(HEAD detached at c04db99c8cfbe3) (c04db99c8cfbe3fa002bf604971eb5b0e09656d4)
   Modules that could not be inlined: Ltac2.Notations
   Expected coqc runtime on this file: 0.213 sec *)
Require Ltac2.Notations.

Inductive False : Prop := .
Axiom proof_admitted : False.
Tactic Notation "admit" := abstract case proof_admitted.

Export Coq.Init.Notations.

Export Stdlib.Init.Ltac.

Notation "'∏'  x .. y , P" := (forall x, .. (forall y, P) ..)
  (at level 200, x binder, y binder, right associativity) : type_scope.

Notation "'λ' x .. y , t" := (fun x => .. (fun y => t) ..)
  (at level 200, x binder, y binder, right associativity).

Notation "A -> B" := (forall (_ : A), B) : type_scope.

Notation "x → y" := (x -> y)
  (at level 99, y at level 200, right associativity): type_scope.

Reserved Notation "X ≃ Y" (at level 80, no associativity).

Reserved Notation "f ~ g" (at level 70, no associativity).

Reserved Notation "p @ q" (at level 60, right associativity).

Reserved Notation "A × B" (at level 75, right associativity).

Reserved Notation "a --> b" (at level 55).

Reserved Notation "! p " (at level 50, left associativity).

Reserved Notation "X ⨿ Y" (at level 50, left associativity).

Reserved Notation "x ,, y" (at level 60, right associativity).

Ltac simple_rapply p :=
  simple refine p ||
  simple refine (p _) ||
  simple refine (p _ _) ||
  simple refine (p _ _ _) ||
  simple refine (p _ _ _ _) ||
  simple refine (p _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _ _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _ _ _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _ _ _ _ _ _ _ _ _) ||
  simple refine (p _ _ _ _ _ _ _ _ _ _ _ _ _ _ _).

Tactic Notation "use" uconstr(p) := simple_rapply p.

Definition UU := Type.

Identity Coercion fromUUtoType : UU >-> Sortclass.

Inductive unit : UU :=
    tt : unit.

Inductive coprod (A B:UU) : UU :=
| ii1 : A -> coprod A B
| ii2 : B -> coprod A B.
Arguments ii1 {_ _} _.
Arguments ii2 {_ _} _.

Notation inl := ii1.

Notation inr := ii2.

Notation "X ⨿ Y" := (coprod X Y).

Inductive nat : UU :=
  | O : nat
  | S : nat -> nat.
Open Scope nat_scope.

Fixpoint add n m :=
  match n with
  | O => m
  | S p => S (p + m)
  end
where "n + m" := (add n m) : nat_scope.

Notation  "0" := (O) : nat_scope.
Notation  "1" := (S 0) : nat_scope.

Inductive paths {A:UU} (a:A) : A -> UU := paths_refl : paths a a.
Notation "a = b" := (paths a b) : type_scope.

Record total2 { T: UU } ( P: T -> UU ) := tpair { pr1 : T; pr2 : P pr1 }.

Arguments tpair {_} _ _ _.
Arguments pr1 {_ _} _.
Arguments pr2 {_ _} _.

Notation "'∑'  x .. y , P" := (total2 (λ x, .. (total2 (λ y, P)) ..))
  (at level 200, x binder, y binder, right associativity) : type_scope.

Notation "x ,, y" := (tpair _ x y).

Definition idfun (T : UU) := λ t:T, t.

Definition funcomp {X Y : UU} {Z:Y->UU} (f : X -> Y) (g : ∏ y:Y, Z y) := λ x, g (f x).

Definition dirprod (X Y : UU) := ∑ x:X, Y.

Notation "A × B" := (dirprod A B) : type_scope.
Definition make_dirprod {X Y : UU} (x:X) (y:Y) : X × Y.
Admitted.

Definition pathscomp0 {X : UU} {a b c : X} (e1 : a = b) (e2 : b = c) : a = c.
Admitted.

Notation "p @ q" := (pathscomp0 p q).

Definition pathsinv0 {X : UU} {a b : X} (e : a = b) : b = a.
Admitted.

Notation "! p " := (pathsinv0 p).

Definition maponpaths {T1 T2 : UU} (f : T1 -> T2) {t1 t2 : T1}
           (e: t1 = t2) : f t1 = f t2.
Admitted.

Definition homot {X : UU} {P : X -> UU} (f g : ∏ x : X, P x) := ∏ x : X , f x = g x.

Notation "f ~ g" := (homot f g).
Definition isweq {X Y : UU} (f : X -> Y) : UU.
Admitted.
Definition weq (X Y : UU) : UU.
exact (∑ f:X->Y, isweq f).
Defined.

Notation "X ≃ Y" := (weq X%type Y%type) : type_scope.

Definition pr1weq {X Y : UU} := pr1 : X ≃ Y -> (X -> Y).
Coercion pr1weq : weq >-> Funclass.
Fixpoint isofhlevel (n : nat) (X : UU) : UU.
Admitted.

Definition isaprop := isofhlevel 1.

Definition funextsecStatement :=
  ∏ (T:UU) (P:T -> UU) (f g :∏ t:T, P t), f ~ g -> f = g.

Definition funextfunStatement :=
  ∏ (X Y:UU) (f g : X -> Y), f ~ g -> f = g.

Theorem funextfunImplication : funextsecStatement -> funextfunStatement.
Admitted.
Definition funextsec : funextsecStatement.
Admitted.

Definition funextfun := funextfunImplication (@funextsec).

Definition hProp := total2 (λ X : UU, isaprop X).
Definition hProptoType := @pr1 _ _ : hProp -> UU.
Coercion hProptoType : hProp >-> UU.
Definition hSet : UU.
Admitted.
Definition pr1hSet : hSet -> UU.
Admitted.
Coercion pr1hSet: hSet >-> UU.
Definition natgth (n m : nat) : hProp.
Admitted.

Notation " x > y " := (natgth x y) : nat_scope.

Definition natlth (n m : nat) := m > n.

Notation " x < y " := (natlth x y) : nat_scope.

Definition stn ( n : nat ) := ∑ m, m < n.

Notation "⟦ n ⟧" := (stn n) : stn.
Definition stnweq {n : nat}
  : stn n ⨿ unit ≃ stn (1 + n).
Admitted.

Definition extend_tuple
  {T : UU}
  {n : nat}
  (f : stn n → T)
  (last : T)
  : stn (S n) → T.
Admitted.

Lemma extend_tuple_inl
  {T : UU}
  {n : nat}
  (f : stn n → T)
  (last : T)
  (i : stn n)
  : extend_tuple f last (stnweq (inl i)) = f i.
Admitted.

Lemma extend_tuple_inr
  {T : UU}
  {n : nat}
  (f : stn n → T)
  (last : T)
  (t : unit)
  : extend_tuple f last (stnweq (inr t)) = last.
Admitted.
Definition precategory_ob_mor : UU.
exact (∑ ob : UU, ob -> ob -> UU).
Defined.
Definition make_precategory_ob_mor (ob : UU)(mor : ob -> ob -> UU) :
    precategory_ob_mor.
exact (tpair _ ob mor).
Defined.
Definition ob (C : precategory_ob_mor) : UU.
exact (@pr1 _ _ C).
Defined.
Coercion ob : precategory_ob_mor >-> UU.
Definition precategory_morphisms { C : precategory_ob_mor } :
       C ->  C -> UU.
exact (pr2 C).
Defined.

Declare Scope cat.

Local Open Scope cat.

Notation "a --> b" := (precategory_morphisms a b) : cat.
Definition precategory_id_comp (C : precategory_ob_mor) : UU.
exact ((∏ c : C, c --> c)
      ×
    (∏ a b c : C, a --> b -> b --> c -> a --> c)).
Defined.
Definition precategory_data : UU.
exact (∑ C : precategory_ob_mor, precategory_id_comp C).
Defined.
Definition make_precategory_data (C : precategory_ob_mor)
    (id : ∏ c : C, c --> c)
    (comp: ∏ a b c : C, a --> b -> b --> c -> a --> c)
  : precategory_data.
exact (tpair _ C (make_dirprod id comp)).
Defined.
Definition precategory_ob_mor_from_precategory_data (C : precategory_data) :
     precategory_ob_mor.
exact (pr1 C).
Defined.
Coercion precategory_ob_mor_from_precategory_data :
  precategory_data >-> precategory_ob_mor.
Definition is_precategory (C : precategory_data) : UU.
Admitted.

Definition precategory := total2 is_precategory.
Definition make_precategory (C : precategory_data) (H : is_precategory C)
  : precategory.
exact (tpair _ C H).
Defined.
Definition precategory_data_from_precategory (C : precategory) :
       precategory_data.
exact (pr1 C).
Defined.
Coercion precategory_data_from_precategory : precategory >-> precategory_data.
Definition has_homsets (C : precategory_ob_mor) : UU.
Admitted.

Definition category := ∑ C:precategory, has_homsets C.
Definition make_category C h : category := C,,h.
Definition category_to_precategory : category -> precategory.
exact (pr1).
Defined.
Coercion category_to_precategory : category >-> precategory.

Section IndexedSetCategory.

  Context (I : UU).

  Definition indexed_set_cat
    : category.
  Proof.
    use make_category.
    -
 use make_precategory.
      +
 use make_precategory_data.
        *
 use make_precategory_ob_mor.
          --
 exact (I → hSet).
          --
 intros X Y.
            exact (∏ i, X i → Y i).
        *
 intros X i.
          apply idfun.
        *
 intros X Y Z f g i.
          exact (funcomp (f i) (g i)).
      +
 admit.
    -
 admit.
  Defined.

  End IndexedSetCategory.
Definition var_ax
    (T : indexed_set_cat nat)
    (n : nat)
    (i : stn n)
    : UU.
exact (T n).
Defined.
Definition subst_ax
    (T : indexed_set_cat nat)
    (m n : nat)
    (f : T m)
    (g : stn m → T n)
    : UU.
exact (T n).
Defined.

Declare Scope algebraic_theories.
Local Open Scope algebraic_theories.
Definition algebraic_theory_data : UU.
Admitted.
Definition algebraic_theory_data_to_function
  (T : algebraic_theory_data)
  : nat → hSet.
Admitted.

Coercion algebraic_theory_data_to_function : algebraic_theory_data >-> Funclass.
Definition var
  {T : algebraic_theory_data}
  {n : nat}
  (i : stn n)
  : var_ax T n i.
Admitted.
Definition subst
  {T : algebraic_theory_data}
  {m n : nat}
  (f : T m)
  (g : stn m → T n)
  : subst_ax T m n f g.
admit.
Defined.

Notation "f • g" :=
  (subst f g)
  (at level 35) : algebraic_theories.
Definition algebraic_theory : UU.
Admitted.
Coercion algebraic_theory_to_algebraic_theory_data (T : algebraic_theory)
  : algebraic_theory_data.
Admitted.
Definition var_subst_ax
  (T : algebraic_theory_data)
  (m n : nat)
  (i : stn m)
  (f : stn m → T n)
  : UU.
exact (var i • f = f i).
Defined.
Definition var_subst
  (T : algebraic_theory)
  {m n : nat}
  (i : stn m)
  (f : stn m → T n)
  : var_subst_ax (T : algebraic_theory_data) m n i f.
Admitted.
Definition inflate {T : algebraic_theory_data} {n : nat} (f : T n) : T (S n).
Admitted.
Definition inflate_subst (T : algebraic_theory) {m n : nat} (f : T m) (g : stn m → T n)
  : inflate (subst f g) = subst f (λ i, inflate (g i)).
Admitted.

Lemma subst_inflate (T : algebraic_theory) {m n : nat} (f : T m) (g : stn (S m) → T n)
  : subst (inflate f) g = subst f (λ i, g (stnweq (inl i))).
Admitted.
Definition app_ax
    (T : algebraic_theory)
    (n : nat)
    (f : T n)
    : UU.
exact (T (S n)).
Defined.
Definition abs_ax
    (T : algebraic_theory)
    (n : nat)
    (f : T (S n))
    : UU.
exact (T n).
Defined.
Definition lambda_theory_data : UU.
Admitted.
Coercion lambda_theory_data_to_algebraic_theory (L : lambda_theory_data)
  : algebraic_theory.
Admitted.
Definition appx {L : lambda_theory_data} {n : nat} (f : L n) : app_ax L n f.
Admitted.
Definition abs {L : lambda_theory_data} {n : nat} (f : L (S n)) : abs_ax L n f.
Admitted.
Definition lambda_theory : UU.
Admitted.
Coercion lambda_theory_to_lambda_theory_data (L : lambda_theory) : lambda_theory_data.
Admitted.
Definition subst_abs (L : lambda_theory) {m n : nat} (f : L (S m)) (g : stn m → L n)
  : subst (abs f) g = abs (subst f (extend_tuple (λ i, inflate (g i)) (var (stnweq (inr tt))))).
Admitted.
Definition app {L : lambda_theory_data} {n : nat} (f g : L n) : L n.
exact (appx f • extend_tuple var g).
Defined.

Lemma subst_app (L : lambda_theory) {m n : nat} (f g : L m) (h : stn m → L n)
  : subst (app f g) h = app (subst f h) (subst g h).
Admitted.
  Notation "( a b )" := (app a b) (only printing) : lambda_calculus.
  Notation "(λ' n , x )" := (@abs _ n x) (only printing) : lambda_calculus.

Export Ltac2.Init.
Export Ltac2.Notations.
Local Open Scope stn.
Local Open Scope lambda_calculus.
Definition compose
  {L : lambda_theory}
  {n : nat}
  (a b : L n)
  : L n.
exact (abs
    (app
      (inflate a)
      (app
        (inflate b)
        (var (stnweq (inr tt)))))).
Defined.

Notation "a ∘ b" :=
  (compose a b)
  (at level 40, left associativity)
  : lambda_calculus.

Lemma subst_compose
  (L : lambda_theory)
  {m n : nat}
  (a b : L m)
  (c : stn m → L n)
  : subst (a ∘ b) c = compose (subst a c) (subst b c).
Proof.
  refine '(subst_abs _ _ _ @ _).
  refine '(maponpaths (λ x, (abs x)) (subst_app _ _ _ _) @ _).
  refine '(maponpaths (λ x, (abs (app x _))) (subst_inflate _ _ _) @ _).
  refine '(maponpaths (λ x, (abs (app _ x))) (subst_app _ _ _ _) @ _).
  refine '(maponpaths (λ x, (abs (app _ (app x _)))) (subst_inflate _ _ _) @ _).
  refine '(maponpaths (λ x, (abs (app _ (app _ x)))) (var_subst _ _ _) @ _).
  refine '(maponpaths (λ x, (abs (app _ (app _ x)))) (extend_tuple_inr _ _ _) @ _).
  refine '(_ @ !maponpaths (λ x, (abs (app x _))) (inflate_subst _ _ _)).
  refine '(_ @ !maponpaths (λ x, (abs (app _ (app x _)))) (inflate_subst _ _ _)).
  refine '(
    maponpaths (λ x, abs (app (_ x) _)) _ @
    maponpaths (λ x, abs (app _ (app (_ x) _))) _
  );
    apply funextfun;
    intro i;
    exact (extend_tuple_inl _ _ _).
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted) (truncated to 6.0KiB; full 22KiB file on GitHub Actions Artifacts under tmp.v)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-q" "-noinit" "-indices-matter" "-type-in-type" "-w" "-notation-overridden" "-w" "-deprecated-native-compiler-option" "-native-compiler" "no" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/unimath/UniMath" "UniMath" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-top" "UniMath.AlgebraicTheories.Combinators") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 2076 lines to 53 lines, then from 66 lines to 121 lines, then from 126 lines to 67 lines, then from 80 lines to 729 lines *)
(* coqc version 9.0+alpha compiled with OCaml 4.14.1
   coqtop version runner-t7b1znuaq-project-4504-concurrent-0:/builds/coq/coq/_build/default,(HEAD detached at c04db99c8cfbe3) (c04db99c8cfbe3fa002bf604971eb5b0e09656d4)
   Expected coqc runtime on this file: 0.000 sec *)
Require Coq.Init.Ltac.
Module Export AdmitTactic.
Module Import LocalFalse.
Inductive False : Prop := .
End LocalFalse.
Axiom proof_admitted : False.
Import Coq.Init.Ltac.
Tactic Notation "admit" := abstract case proof_admitted.
End AdmitTactic.
Require UniMath.AlgebraicTheories.LambdaTheories.
Require Ltac2.Init.
Require Ltac2.Bool.
Require Ltac2.Ind.
Require Ltac2.Int.
Require Ltac2.Message.
Require Ltac2.Std.
Require Ltac2.Control.
Require Ltac2.Option.
Require Ltac2.Pattern.
Require Ltac2.Array.
Require Ltac2.Constr.

Module Ltac2_DOT_Notations_WRAPPED.
Module Notations.
(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
Import Ltac2.Init.

(** Constr matching *)

Ltac2 Notation "lazy_match!" t(tactic(6)) "with" m(constr_matching) "end" :=
  Pattern.lazy_match0 t m.

Ltac2 Notation "multi_match!" t(tactic(6)) "with" m(constr_matching) "end" :=
  Pattern.multi_match0 t m.

Ltac2 Notation "match!" t(tactic(6)) "with" m(constr_matching) "end" :=
  Pattern.one_match0 t m.

(** Goal matching *)

Ltac2 Notation "lazy_match!" "goal" "with" m(goal_matching) "end" :=
  Pattern.lazy_goal_match0 false m.

Ltac2 Notation "multi_match!" "goal" "with" m(goal_matching) "end" :=
  Pattern.multi_goal_match0 false m.

Ltac2 Notation "match!" "goal" "with" m(goal_matching) "end" :=
  Pattern.one_goal_match0 false m.

Ltac2 Notation "lazy_match!" "reverse" "goal" "with" m(goal_matching) "end" :=
  Pattern.lazy_goal_match0 true m.

Ltac2 Notation "multi_match!" "reverse" "goal" "with" m(goal_matching) "end" :=
  Pattern.multi_goal_match0 true m.

Ltac2 Notation "match!" "reverse" "goal" "with" m(goal_matching) "end" :=
  Pattern.one_goal_match0 true m.

(** Tacticals *)

Ltac2 orelse t f :=
match Control.case t with
| Err e => f e
| Val ans =>
  let (x, k) := ans in
  Control.plus (fun _ => x) k
end.

Ltac2 ifcatch t s f :=
match Control.case t with
| Err e => f e
| Val ans =>
  let (x, k) := ans in
  Control.plus (fun _ => s x) (fun e => s (k e))
end.

Ltac2 fail0 (_ : unit) := Control.enter (fun _ => Control.zero (Tactic_failure None)).

Ltac2 Notation fail := fail0 ().

Ltac2 try0 t := Control.enter (fun _ => orelse t (fun _ => ())).

Ltac2 Notation try := try0.

Ltac2 rec repeat0 (t : unit -> unit) :=
  Control.enter (fun () =>
    ifcatch (fun _ => Control.progress t)
      (fun _ => Control.check_interrupt (); repeat0 t) (fun _ => ())).

Ltac2 Notation repeat := repeat0.

Ltac2 dispatch0 t (head, tail) :=
  match tail with
  | None => Control.enter (fun _ => t (); Control.dispatch head)
  | Some tacs =>
    let (def, rem) := tacs in
    Control.enter (fun _ => t (); Control.extend head def rem)
  end.

Ltac2 Notation t(thunk(self)) ">" "[" l(dispatch) "]" : 4 := dispatch0 t l.

Ltac2 do0 n t :=
  let rec aux n t := match Int.equal n 0 with
  | true => ()
  | false => t (); aux (Int.sub n 1) t
  end in
  aux (n ()) t.

Ltac2 Notation do := do0.

Ltac2 Notation once := Control.once.

Ltac2 Notation unshelve := Control.unshelve.

Ltac2 progress0 tac := Control.enter (fun _ => Control.progress tac).

Ltac2 Notation progress := progress0.

Ltac2 rec first0 tacs :=
match tacs with
| [] => Control.zero (Tactic_failure None)
| tac :: tacs => Control.enter (fun _ => orelse tac (fun _ => first0 tacs))
end.

Ltac2 Notation "first" "[" tacs(list0(thunk(tactic(6)), "|")) "]" := first0 tacs.

Ltac2 complete tac :=
  let ans := tac () in
  Control.enter (fun () => Control.zero (Tactic_failure None));
  ans.

Ltac2 rec solve0 tacs :=
match tacs with
| [] => Control.zero (Tactic_failure None)
| tac :: tacs =>
  Control.enter (fun _ => orelse (fun _ => complete tac) (fun _ => solve0 tacs))
end.

Ltac2 Notation "solve" "[" tacs(list0(thunk(tactic(6)), "|")) "]" := solve0 tacs.

Ltac2 time0 tac := Control.time None tac.

Ltac2 Notation time := time0.

Ltac2 abstract0 tac := Control.abstract None tac.

Ltac2 Notation abstract := abstract0.

(** Base tactics *)

(** Note that we redeclare notations that can be parsed as mere identifiers
    as abbreviations, so that it allows to parse them as function arguments
    without having to write them within parentheses. *)

(** Enter and check evar resolution *)
Ltac2 enter_h ev f arg :=
match ev with
| true => Control.enter (fun () => f ev (arg ()))
| false =>
  Control.enter (fun () =>
    Control.with_holes arg (fun x => f ev x))
end.

Ltac2 intros0 ev p :=
  Control.enter (fun () => Std.intros ev p).

Ltac2 Notation "intros" p(intropatterns) := intros0 false p.
Ltac2 Notation intros := intros.

Ltac2 Notation "eintros" p(intropatterns) := intros0 true p.
Ltac2 Notation eintros := eintros.

Ltac2 sp
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
File "/tmp/tmpgrj0jp8g/UniMath/AlgebraicTheories/Combinators.v", line 6, characters 8-21:
Warning: Coq.Init.Ltac has been replaced by Stdlib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpgrj0jp8g/UniMath/AlgebraicTheories/Combinators.v", line 12, characters 7-20:
Warning: Coq.Init.Ltac has been replaced by Stdlib.Init.Ltac.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpgrj0jp8g/UniMath/AlgebraicTheories/Combinators.v", line 645, characters 28-35:
Error: The reference f_equal was not found in the current environment.
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 4.3MiB file on GitHub Actions Artifacts under build.log)
oryTheory/Actegories/ConstructionOfActegoryMorphisms.vo              
 0m06.58s |  523108 ko | UniMath/CategoryTheory/EnrichedCats/Profunctors/Composition/WhiskerLaws.vo        
 0m06.32s |  463396 ko | UniMath/CategoryTheory/EnrichedCats/Profunctors/Composition/BicatLaws.vo          
 0m06.25s |  517036 ko | UniMath/CategoryTheory/EnrichedCats/Profunctors/Composition/OtherLaws.vo          
 0m06.20s |  477352 ko | UniMath/CategoryTheory/EnrichedCats/Examples/GraphEnriched.vo                     
 0m04.69s |  447784 ko | UniMath/CategoryTheory/EnrichedCats/YonedaLemma.vo                                
 0m04.05s |  413188 ko | UniMath/CategoryTheory/Monoidal/Examples/LiftPoset.vo                             
 0m04.04s |  424520 ko | UniMath/CategoryTheory/EnrichedCats/Profunctors/Composition/Unitors.vo            
 0m03.98s |  434468 ko | UniMath/CategoryTheory/EnrichedCats/Profunctors/Composition/Whiskering.vo         
 0m03.93s |  394256 ko | UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERConstantObjects.vo         
 0m03.25s |  419188 ko | UniMath/CategoryTheory/EnrichedCats/Profunctors/Composition/SquareComp.vo         
 0m03.18s |  466992 ko | UniMath/CategoryTheory/Monoidal/Examples/SmashProductMonoidal.vo                  
 0m02.93s |  393244 ko | UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERTerminal.vo                
 0m02.05s |  394144 ko | UniMath/CategoryTheory/DisplayedCats/Examples/PointedPosetStrict.vo               
 0m01.62s |  387196 ko | UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERInitial.vo                 
 0m01.62s |  398236 ko | UniMath/CategoryTheory/Limits/Examples/AlgebraStructuresColimits.vo               
 0m01.32s |  416024 ko | UniMath/CategoryTheory/EnrichedCats/Examples/CollageEnriched.vo                   
 0m01.22s |  399792 ko | UniMath/CategoryTheory/DisplayedCats/MonoCodomain/MonoCodRightAdjoint.vo          
 0m01.16s |  399904 ko | UniMath/CategoryTheory/Monoidal/Comonoids/Tensor.vo                               
 0m01.09s |  397464 ko | UniMath/AlgebraicTheories/Examples/ExtensionsTheory.vo                            
 0m01.03s |  401156 ko | UniMath/CategoryTheory/EnrichedCats/Limits/Examples/PosetEnrichedLimits.vo        
 0m00.98s |  394348 ko | UniMath/CategoryTheory/DisplayedCats/Examples/AlgebraStructures.vo                
 0m00.97s |  405852 ko | UniMath/CategoryTheory/EnrichedCats/Profunctors/RepresentableLaws.vo              
 0m00.93s |  396444 ko | UniMath/AlgebraicTheories/Examples/EndomorphismTheory.vo                          
 0m00.88s |  396484 ko | UniMath/CategoryTheory/Monoidal/Comonoids/Category.vo                             
 0m00.77s |  397916 ko | UniMath/CategoryTheory/EnrichedCats/Examples/SmashStructureEnriched.vo            
 0m00.73s |  391844 ko | UniMath/AlgebraicTheories/PresheafCategory.vo                                     
 0m00.66s |  398544 ko | UniMath/CategoryTheory/EnrichedCats/Colimits/Examples/PosetEnrichedColimits.vo    
 0m00.65s |  398252 ko | UniMath/CategoryTheory/Monoidal/Comonoids/Monoidal.vo                             
 0m00.61s |  394736 ko | UniMath/CategoryTheory/EnrichedCats/Examples/PosetEnriched.vo                     
 0m00.59s |  390140 ko | UniMath/CategoryTheory/DisplayedCats/Structures/StructureLimitsAndColimits.vo     
 0m00.58s |  516460 ko | UniMath/CategoryTheory/All.vo                                                     
 0m00.56s |  392408 ko | UniMath/CategoryTheory/EnrichedCats/Examples/StructureEnriched.vo                 
 0m00.50s |  395920 ko | UniMath/CategoryTheory/EnrichedCats/Profunctors/Invertible.vo                     
 0m00.49s |  387168 ko | UniMath/CategoryTheory/DisplayedCats/MonoCodomain/MonoCodLimits.vo                
 0m00.47s |  392752 ko | UniMath/CategoryTheory/Monoidal/Comonoids/MonoidalCartesianBuilder.vo             
 0m00.44s |  389972 ko | UniMath/CategoryTheory/Actegories/Examples/SelfActionInCATElementary.vo           
 0m00.43s |  397364 ko | UniMath/CategoryTheory/Monoidal/Comonoids/Symmetric.vo                            
 0m00.42s |  392904 ko | UniMath/AlgebraicTheories/Examples/FreeMonoidTheory.vo                            
 0m00.42s |  389216 ko | UniMath/CategoryTheory/Hyperdoctrines/PartialEqRels/PERExponentials.vo            
 0m00.40s |  388804 ko | UniMath/AlgebraicTheories/AlgebraCategory.vo                                      
 0m00.40s |  389572 ko | UniMath/AlgebraicTheories/Examples/FreeObjectTheory.vo                            
 0m00.40s |  392100 ko | UniMath/CategoryTheory/EnrichedCats/Examples/QuantaleEnriched.vo                  
 0m00.40s |  391388 ko | UniMath/CategoryTheory/Monoidal/Comonoids/TransportComonoidAlongRetraction.vo     
 0m00.39s |  393508 ko | UniMath/CategoryTheory/Monoidal/Comonoids/CartesianAsComonoids.vo                 
 0m00.38s |  388816 ko | UniMath/AlgebraicTheories/AlgebraicTheoryToLawvereTheory.vo                       
 0m00.38s |  385336 ko | UniMath/AlgebraicTheories/LambdaTheoryCategory.vo                                 
 0m00.37s |  392360 ko | UniMath/CategoryTheory/Monoidal/Comonoids/CommComonoidsCartesian.vo               
 0m00.36s |  388776 ko | UniMath/CategoryTheory/DisplayedCats/Structures/StructuresSmashProduct.vo         
 0m00.33s |  361184 ko | UniMath/AlgebraicTheories/Examples/FreeTheory.vo                                  
 0m00.30s |  372332 ko | UniMath/CategoryTheory/DisplayedCats/Examples/MonadAlgebras.vo                    
 0m00.29s |  369956 ko | UniMath/CategoryTheory/DisplayedCats/Examples/PointedSetStructures.vo             
 0m00.28s |  269620 ko | UniMath/AlgebraicTheories/AlgebraicTheoryToMonoid.vo                              
 0m00.27s |  299496 ko | UniMath/AlgebraicTheories/Combinators.vo                                          
 0m00.26s |  242908 ko | UniMath/AlgebraicTheories/Algebras.vo                                             
 0m00.26s |  254212 ko | UniMath/AlgebraicTheories/LambdaTheoryMorphisms.vo                                
 0m00.26s |  315988 ko | UniMath/AlgebraicTheories/PresheafMorphisms.vo                                    
 0m00.25s |  217748 ko | UniMath/CategoryTheory/DisplayedCats/Examples/DCPOStructures.vo                   
 0m00.25s |  228496 ko | UniMath/CategoryTheory/DisplayedCats/MonoCodomain/MonoHyperdoctrine.vo            
 0m00.24s |  223344 ko | UniMath/AlgebraicTheories/AlgebraMorphisms.vo                                     
 0m00.24s |  210944 ko | UniMath/CategoryTheory/DisplayedCats/Examples/PointedDCPOStrict.vo                
 0m00.24s |  211356 ko | UniMath/OrderTheory/All.vo                                                        
 0m00.23s |  188848 ko | UniMath/CategoryTheory/DisplayedCats/Examples/PointedDCPOStructures.vo            
 0m00.23s |  240256 ko | UniMath/CategoryTheory/DisplayedCats/Examples/PosetStructures.vo                  
 0m00.23s |  209740 ko | UniMath/CategoryTheory/EnrichedCats/RezkCompletion/RezkUniversalProperty.vo       
 0m00.22s |  170520 ko | UniMath/AlgebraicTheories/Examples/ProjectionsTheory.vo                           
 0m00.22s |  178268 ko | UniMath/CategoryTheory/EnrichedCats/RezkCompletion/EnrichedRezkCompletion.vo      
 0m00.22s |  168392 ko | UniMath/CategoryTheory/Monoidal/Examples/PosetsMonoidal.vo                        
 0m00.21s |  172728 ko | UniMath/AlgebraicTheories/Examples/OnePointTheory.vo                              
 0m00.21s |  179076 ko | UniMath/AlgebraicTheories/Examples/TheoryAlgebra.vo                               
 0m00.21s |  202460 ko | UniMath/CategoryTheory/DisplayedCats/Examples/SetStructures.vo                    
 0m00.21s |  189664 ko | UniMath/CategoryTheory/EnrichedCats/Profunctors/Composition.vo                    
 0m00.21s |  189540 ko | UniMath/CategoryTheory/Hyperdoctrines/TriposToTopos.vo                            
 0m00.21s |  164876 ko | UniMath/CategoryTheory/Monoidal/Examples/StructuresMonoidal.vo                    
 0m00.20s |  197868 ko | UniMath/CategoryTheory/DisplayedCats/Examples/PointedPosetStructures.vo           
+ '[' '' ']'
+ exit 2
make: *** [Makefile.ci:192: ci-unimath] Error 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 1.4MiB file on GitHub Actions Artifacts under bug.log)
tations.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 173, characters 0-38:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope stn.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 175, characters 28-33:
Error: Unknown interpretation for notation "_ + _".


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 7, characters 7-25:
Warning: Coq.Init.Notations has been replaced by Stdlib.Init.Notations.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 173, characters 0-38:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope stn.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 175, characters 28-33:
Error: Unknown interpretation for notation "_ + _".


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted

Non-fatal error: Failed to admit lemmas and preserve the error.  
The new error was:
File "/tmp/tmpyxrglxlc/UniMath/AlgebraicTheories/Combinators.v", line 7, characters 7-25:
Warning: Coq.Init.Notations has been replaced by Stdlib.Init.Notations.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpyxrglxlc/UniMath/AlgebraicTheories/Combinators.v", line 180, characters 0-38:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope stn.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpyxrglxlc/UniMath/AlgebraicTheories/Combinators.v", line 416, characters 2-68:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope lambda_calculus.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]

�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmp0bzzhfx2/UniMath/AlgebraicTheories/Combinators.v", line 7, characters 7-25:
Warning: Coq.Init.Notations has been replaced by Stdlib.Init.Notations.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmp0bzzhfx2/UniMath/AlgebraicTheories/Combinators.v", line 140, characters 32-35:
Error:
In environment
X : UU
Y : UU
The term "pr1" has type "(∑ y, ?P y) → ?T" while it is expected to have type
 "X ≃ Y → X → Y".


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined

Non-fatal error: Failed to admit lemmas and preserve the error.  
The new error was:
File "/tmp/tmpg4aem7sm/UniMath/AlgebraicTheories/Combinators.v", line 7, characters 7-25:
Warning: Coq.Init.Notations has been replaced by Stdlib.Init.Notations.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpg4aem7sm/UniMath/AlgebraicTheories/Combinators.v", line 180, characters 0-38:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope stn.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpg4aem7sm/UniMath/AlgebraicTheories/Combinators.v", line 416, characters 2-68:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope lambda_calculus.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpg4aem7sm/UniMath/AlgebraicTheories/Combinators.v", line 448, characters 0-8:
Error:  (in proof subst_compose): Attempt to save an incomplete proof
(the proof term is not complete because of given up (admitted) goals).
If this is really what you want to do, use Admitted in place of Qed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmpm0u0i1zp/UniMath/AlgebraicTheories/Combinators.v", line 7, characters 7-25:
Warning: Coq.Init.Notations has been replaced by Stdlib.Init.Notations.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpm0u0i1zp/UniMath/AlgebraicTheories/Combinators.v", line 141, characters 32-35:
Error:
In environment
X : UU
Y : UU
The term "pr1" has type "(∑ y, ?P y) → ?T" while it is expected to have type
 "X ≃ Y → X → Y".


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation unsuccessful.

I will now attempt to split imports and exports
Import/Export splitting unsuccessful.

I will now attempt to split := definitions
One-line definition splitting unsuccessful.

I will now attempt to remove all lines, one at a time
Line removal unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 7, characters 7-25:
Warning: Coq.Init.Notations has been replaced by Stdlib.Init.Notations.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 173, characters 0-38:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope stn.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 175, characters 28-33:
Error: Unknown interpretation for notation "_ + _".


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 7, characters 7-25:
Warning: Coq.Init.Notations has been replaced by Stdlib.Init.Notations.
[deprecated-dirpath-Coq,deprecated-since-9.0,deprecated,default]
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 173, characters 0-38:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope stn.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpbcqwg86h/UniMath/AlgebraicTheories/Combinators.v", line 175, characters 28-33:
Error: Unknown interpretation for notation "_ + _".


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to remove empty sections

No empty sections to remove.

Now, I will attempt to strip repeated newlines and trailing spaces from this file...

No strippable newlines or spaces.

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

cc @JasonGross

@ppedrot
Copy link
Member
ppedrot commented Nov 12, 2024

@Tragicus could you assess whether the minimized examples are legitimate changes in unification after your patch? Thanks.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

@JasonGross
Copy link
Member

bug minimizer should work on ci-iris now with coq-community/run-coq-bug-minimizer@5b6d818: @coqbot ci minimize ci-iris

This comment was marked as outdated.

This comment was marked as outdated.

@JasonGross

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

JasonGross added a commit to coq-community/run-coq-bug-minimizer that referenced this pull request Nov 13, 2024
@JasonGross
Copy link
Member

hopefully third time's the charm: @coqbot ci minimize ci-iris

This comment was marked as outdated.

@Tragicus Tragicus changed the title rm problematic variables under lambdas and evars for evar instantiation rm problematic variables under beta-redexes and evars for evar instantiation Nov 14, 2024
@Tragicus
Copy link
Contributor Author

Unfortunately, the variables that appear as arguments of evars are the main issue. I do see the example I give in the description of the PR, where f is opaque (or more precisely a projection), so the problem does not reduce (and we anyway do not want to delta-reduce).

This comment was marked as outdated.

@JasonGross
Copy link
Member

What are your thoughts then on guarding the behavior by Set Unification Heuristic Evar Restriction or similar? It seems fine to have it on by default, and disable it in the compat files & in the CI devs that are not otherwise easy to fix.

@Tragicus
Copy link
Contributor Author
Tragicus commented Nov 14, 2024

Considering that #19833 also fails and that it looks like there is the same typeclass issue in hott, we should first see what happens when things are fixed there. Maybe we will see that the applied evar case only triggers eauto to sometimes do too much and it may be easy to fix without introducing more options. I will also try removing the beta-redex case from here, just to see what happens.

This comment was marked as outdated.

This comment was marked as outdated.

@JasonGross
Copy link
Member

@coqbot run full ci

@coqbot-app coqbot-app bot removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Nov 15, 2024

This comment was marked as outdated.

This comment was marked as outdated.

@Tragicus
Copy link
Contributor Author

The error in the hott example looks like there is a repeat split at the end where some split succeeds while leaving out some unification constraints. Rocq fails to solve them outside of the repeat, so the error is not caught and the whole line fails.

This comment was marked as outdated.

Copy link
Contributor
coqbot-app bot commented Nov 15, 2024
Minimization interrupted by timeout, being automatically continued. Partially Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/perennial/src/base_logic/lib/wsat.v (from ci-perennial) (interrupted by timeout, being automatically continued) (full log on GitHub Actions - verbose log)
⭐ ⏱️ Partially Minimized Coq File (timeout) (truncated to first and last 32KiB; full 139KiB file on GitHub Actions Artifacts under bug.v)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-w" "-ssr-search-moved" "-w" "+deprecated-instance-without-locality" "-w" "+ambiguous-paths" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-deprecated-field-instance-without-locality" "-w" "+deprecated-tactic-notation" "-w" "-deprecated-since-8.19" "-w" "-deprecated-since-8.20" "-w" "-deprecated-from-Coq" "-w" "-deprecated-dirpath-Coq" "-w" "-notation-incompatible-prefix" "-w" "-deprecated-typeclasses-transparency-without-locality" "-w" "-notation-overridden,-redundant-canonical-projection,-unknown-warning,-argument-scope-delimiter" "-w" "-deprecated-native-compiler-option,-native-compiler-disabled" "-native-compiler" "ondemand" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/src" "Perennial" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp" "stdpp" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_unstable" "stdpp.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_bitvector" "stdpp.bitvector" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris" "iris" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_deprecated" "iris.deprecated" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_unstable" "iris.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_heap_lang" "iris.heap_lang" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coqutil/src/coqutil" "coqutil" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/Goose" "Goose" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/record-update/src" "RecordUpdate" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coq-tactical/src" "Tactical" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris-named-props/src" "iris_named_props" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_trusted_code" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_code_axioms" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_partial_axioms" "New.code_axioms" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new" "New" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-top" "Top.bug_01") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 1066 lines to 167 lines, then from 180 lines to 368 lines, then from 373 lines to 168 lines, then from 181 lines to 855 lines, then from 857 lines to 177 lines, then from 190 lines to 549 lines, then from 554 lines to 194 lines, then from 207 lines to 743 lines, then from 748 lines to 248 lines, then from 261 lines to 446 lines, then from 451 lines to 249 lines, then from 262 lines to 842 lines, then from 847 lines to 260 lines, then from 273 lines to 624 lines, then from 624 lines to 278 lines, then from 291 lines to 478 lines, then from 483 lines to 279 lines, then from 292 lines to 558 lines, then from 563 lines to 279 lines, then from 292 lines to 689 lines, then from 694 lines to 309 lines, then from 322 lines to 1312 lines, then from 1316 lines to 426 lines, then from 439 lines to 919 lines, then from 924 lines to 474 lines, then from 487 lines to 1254 lines, then from 1259 lines to 659 lines, then from 660 lines to 533 lines, then from 546 lines to 841 lines, then from 846 lines to 542 lines, then from 555 lines to 674 lines, then from 679 lines to 553 lines, then from 566 lines to 969 lines, then from 974 lines to 588 lines, then from 601 lines to 766 lines, then from 771 lines to 587 lines, then from 600 lines to 772 lines, then from 777 lines to 589 lines, then from 602 lines to 962 lines, then from 967 lines to 603 lines, then from 616 lines to 1930 lines, then from 1935 lines to 642 lines, then from 655 lines to 2993 lines, then from 2998 lines to 1687 lines, then from 1700 lines to 3137 lines, then from 3142 lines to 2116 lines, then from 2113 lines to 2095 lines, then from 2108 lines to 2312 lines, then from 2317 lines to 2128 lines, then from 2141 lines to 3107 lines, then from 3112 lines to 2290 lines, then from 2303 lines to 2595 lines, then from 2600 lines to 2456 lines, then from 2469 lines to 2615 lines, then from 2620 lines to 2482 lines, then from 2495 lines to 2697 lines, then from 2702 lines to 2566 lines, then from 2579 lines to 2772 lines, then from 2777 lines to 2812 lines, then from 2813 lines to 2659 lines, then from 2672 lines to 2841 lines, then from 2846 lines to 2719 lines, then from 2732 lines to 2821 lines, then from 2826 lines to 2723 lines, then from 2736 lines to 3351 lines, then from 3356 lines to 3168 lines, then from 3151 lines to 2792 lines, then from 2805 lines to 3604 lines, then from 3608 lines to 3348 lines, then from 3321 lines to 2867 lines, then from 2880 lines to 3175 lines, then from 3180 lines to 2909 lines, then from 2922 lines to 3120 lines, then from 3125 lines to 2914 lines, then from 2927 lines to 3193 lines, then from 3198 lines to 2974 lines, then from 2987 lines to 3042 lines, then from 3047 lines to 3001 lines, then from 3011 lines to 2993 lines, then from 3006 lines to 3655 lines, then from 3660 lines to 2996 lines, then from 3009 lines to 3093 lines, then from 3099 lines to 3005 lines, then from 3019 lines to 3684 lines, then from 3690 lines to 3015 lines, then from 3029 lines to 3058 lines, then from 3064 lines to 3021 lines, then from 3035 lines to 3069 lines, then from 3075 lines to 3028 lines, then from 3042 lines to 3070 lines, then from 3076 lines to 3073 lines, then from 3075 lines to 3036 lines, then from 3049 lines to 3118 lines, then from 3124 lines to 3057 lines, then from 3071 lines to 3261 lines, then from 3267 lines to 3065 lines, then from 3079 lines to 3341 lines, then from 3347 lines to 3122 lines, then from 3136 lines to 3421 lines, then from 3427 lines to 3131 lines, then from 3145 lines to 3388 lines, then from 3394 lines to 3312 lines, then from 3313 lines to 3135 lines, then from 3148 lines to 3251 lines, then from 3257 lines to 3136 lines, then from 3150 lines to 3895 lines, then from 3901 lines to 3154 lines, then from 3168 lines to 6507 lines, then from 6513 lines to 3196 lines, then from 3211 lines to 3158 lines, then from 3171 lines to 4044 lines, then from 4050 lines to 3196 lines, then from 3210 lines to 3543 lines, then from 3549 lines to 3216 lines, then from 3230 lines to 3505 lines, then from 3511 lines to 3468 lines, then from 3467 lines to 3228 lines, then from 3241 lines to 4292 lines, then from 4297 lines to 3239 lines, then from 3253 lines to 3809 lines, then from 3815 lines to 3240 lines, then from 3254 lines to 5079 lines, then from 5085 lines to 4133 lines, then from 4119 lines to 3252 lines, then from 3265 lines to 3373 lines, then from 3379 lines to 3255 lines, then from 3269 lines to 3465 lines, then from 3471 lines to 3293 lines, then from 3307 lines to 3880 lines, then from 3886 lines to 3482 lines, then from 3496 lines to 3703 lines, then from 3708 lines to 3526 lines, then from 3541 lines to 3522 lines, then from 3535 lines to 3730 lines, then from 3736 lines to 3550 lines, then from 3564 lines to 4093 lines, then from 4099 lines to 3561 lines, then from 3575 lines to 4478 lines, then from 4484 lines to 4162 lines, then from 4158 lines to 3594 lines, then from 3607 lines to 3799 lines, then from 3805 lines to 3614 lines, then from 3628 lines to 4139 lines, then from 4145 lines to 3615 lines, then from 3634 lines to 3613 lines, then from 3626 lines to 8522 lines, then from 8527 lines to 3653 lines, then from 3667 lines to 3914 lines, then from 3920 lines to 3871 lines *)
(* coqc version 9.0+alpha compiled with OCaml 4.14.1
   coqtop version runner-t7b1znuaq-project-4504-concurrent-0:/builds/coq/coq/_build/default,(HEAD detached at c04db99c8cfbe3) (c04db99c8cfbe3fa002bf604971eb5b0e09656d4)
   Modules that could not be inlined: Ltac2.Array, Ltac2.Pattern, Ltac2.Ltac1
   Expected coqc runtime on this file: 2.530 sec *)








Require Stdlib.Init.Ltac.
Require Stdlib.QArith.QArith_base.
Require Stdlib.QArith.Qcanon.
Require Stdlib.Sorting.Permutation.
Require Stdlib.Logic.EqdepFacts.
Require Stdlib.PArith.PArith.
Require Stdlib.NArith.NArith.
Require Stdlib.ZArith.ZArith.
Require Stdlib.QArith.QArith.
Require Stdlib.Classes.Morphisms.
Require Stdlib.Classes.RelationClasses.
Require Stdlib.Lists.List.
Require Stdlib.Bool.Bool.
Require Stdlib.Setoids.Setoid.
Require Stdlib.Init.Peano.
Require Stdlib.Unicode.Utf8.
Require Stdlib.Program.Basics.
Require Stdlib.Program.Syntax.
Require Stdlib.ssr.ssrfun.
Require stdpp.options.
Require stdpp.base.
Require stdpp.proof_irrel.
Require stdpp.decidable.
Require Stdlib.micromega.Lia.
Require stdpp.tactics.
Require stdpp.option.
Require stdpp.well_founded.
Require stdpp.numbers.
Require stdpp.list.
Require stdpp.list_numbers.
Require stdpp.fin.
Require stdpp.countable.
Require Stdlib.Vectors.Vector.
Require stdpp.vector.
Require stdpp.finite.
Require Stdlib.ssr.ssreflect.
Require stdpp.orders.
Require stdpp.sets.
Require stdpp.relations.
Require stdpp.fin_sets.
Require stdpp.listset.
Require stdpp.lexico.
Require stdpp.prelude.
Require stdpp.ssreflect.
Require iris.prelude.options.
Require iris.prelude.prelude.
Require iris.algebra.ofe.
Require iris.algebra.monoid.
Require iris.algebra.cmra.
Require Stdlib.Strings.Ascii.
Require Stdlib.Strings.String.
Require Ltac2.Init.
Require Ltac2.Std.
Require Ltac2.Message.
Require Ltac2.Control.
Require Ltac2.Ltac1.
Require Ltac2.Pattern.
Require Ltac2.Int.
Require Ltac2.Bool.
Require Ltac2.Array.

Module Export AdmitTactic.
Module Import LocalFalse.
Inductive False : Prop := .
End LocalFalse.
Axiom proof_admitted : False.
Import Coq.Init.Ltac.
Tactic Notation "admit" := abstract case proof_admitted.
End AdmitTactic.

Module Export stdpp_DOT_strings_WRAPPED.
Module Export strings.
Import Stdlib.Strings.Ascii.
Export stdpp.list.
Import stdpp.countable.
Import stdpp.options.




Export Stdlib.Strings.String (string(..)).
Export (notations) Stdlib.Strings.String.


String Notation string
  String.string_of_list_byte String.list_byte_of_string : stdpp_scope.

Infix "+:+" := String.append (at level 60, right associativity) : stdpp_scope.



Local Definition bool_cons_pos (b : bool) (p : positive) : positive :=
  if b then p~1 else p~0.
Local Definition ascii_cons_pos (c : ascii) (p : positive) : positive :=
  match c with
  | Ascii b0 b1 b2 b3 b4 b5 b6 b7 =>
     bool_cons_pos b0 $ bool_cons_pos b1 $ bool_cons_pos b2 $
       bool_cons_pos b3 $ bool_cons_pos b4 $ bool_cons_pos b5 $
       bool_cons_pos b6 $ bool_cons_pos b7 p
  end.
Local Fixpoint string_to_pos (s : string) : positive :=
  match s with
  | EmptyString => 1
  | String c s => ascii_cons_pos c (string_to_pos s)
  end.


Local Fixpoint pos_to_string (p : positive) : string.
Admitted.

Local Lemma pos_to_string_string_to_pos s : pos_to_string (string_to_pos s) = s.
Admitted.

Module Export Ascii.
  Global Instance eq_dec : EqDecision ascii := ascii_dec.

  Global Program Instance countable : Countable ascii := {|
    encode a := string_to_pos (String a EmptyString);
    decode p := match pos_to_string p return _ with String a _ => Some a | _ => None end
  |}.
Admit Obligations.

  Definition is_nat (x : ascii) : option nat :=
    match x with
    | "0" => Some 0
    | "1" => Some 1
    | "2" => Some 2
    | "3" => Some 3
    | "4" => Some 4
    | "5" => Some 5
    | "6" => Some 6
    | "7" => Some 7
    | "8" => Some 8
    | "9" => Some 9
    | _ => None
    end%char.

  Definition is_space (x : ascii) : bool :=
    match x with
    | "009" | "010" | "011" | "012" | "013" | " " => true | _ => false
    end%char.
End Ascii.

Module Export String.
  
  Notation app := String.append.

  
  Global Arguments app : simpl never.

  Global Instance eq_dec : EqDecision string.
Admitted.

  Global Instance inhabited : Inhabited string := populate "".

  Global Program Instance countable : Countable string := {|
    encode := string_to_pos;
    decode p := Some (pos_to_string p)
  |}.
  Solve Obligations with
    naive_solver eauto using pos_to_string_string_to_pos with f_equal.

  Definition le (s1 s2 : string) : Prop := String.leb s1 s2.

  Global Instance le_dec : RelDecision le.
Admitted.
  Global Instance le_pi s1 s2 : ProofIrrel (le s1 s2).
Admitted.

  Global Instance le_po : PartialOrder le.
Admitted.
  Global Instance le_total : Total le.
Admitted.

  Global Instance app_inj s1 : Inj (=) (=) (app s1).
Admitted.

  Fixpoint rev_app (s1 s2 : string) : string :=
    match s1 with
    | "" => s2
    | String a s1 => rev_app s1 (String a s2)
    end.
  Definition rev (s : string) : string := rev_app s "".

  
  Fixpoint words_go (cur : option string) (s : string) : list string :=
    match s with
    | "" => option_list (rev <$> cur)
    | String a s =>
       if Ascii.is_space a
       then option_list (rev <$> cur) ++ words_go None s
       else words_go (Some (from_option (String a) (String a "") cur)) s
    end.
  Definition words : string → list string := words_go None.
End String.

Infix "≤" := String.le : string_scope.
Notation "(≤)" := String.le (only parsing) : string_scope.
Notation "x ≤ y ≤ z" := (x ≤ y ∧ y ≤ z)%string : string_scope.
Notation "x ≤ y ≤ z ≤ z'" := (x ≤ y ∧ y ≤ z ∧ z ≤ z')%string : string_scope.

Global Hint Extern 0 (_ ≤ _)%string => reflexivity : core.

End strings.

End stdpp_DOT_strings_WRAPPED.
Module Export stdpp_DOT_strings.
Module Export stdpp.
Module Export strings.
Include stdpp_DOT_strings_WRAPPED.strings.
End strings.

End stdpp.

End stdpp_DOT_strings.
Axiom proof_admitted : False.
Tactic Notation "admit" := abstract case proof_admitted.
Export stdpp.relations.

Class MapFold K A M := map_fold B : (K → A → B → B) → B → M → B.
Global Arguments map_fold {_ _ _ _ _} _ _ _.
Definition diag_None {A B C} (f : option A → option B → option C)
    (mx : option A) (my : option B) : option C.
Admitted.
Global Instance map_insert `{PartialAlter K A M} : Insert K A M.
Admitted.

Class FinMap K M `{FMap M, ∀ A, Lookup K A (M A), ∀ A, Empty (M A), ∀ A,
    PartialAlter K A (M A), OMap M, Merge M, ∀ A, MapFold K A (M A),
    EqDecision K} := {
  map_eq {A} (m1 m2 : M A) : (∀ i, m1 !! i = m2 !! i) → m1 = m2;
  lookup_empty {A} i : (∅ : M A) !! i = None;
  lookup_partial_alter {A} f (m : M A) i :
    partial_alter f i m !! i = f (m !! i);
  lookup_partial_alter_ne {A} f (m : M A) i j :
    i ≠ j → partial_alter f i m !! j = m !! j;
  lookup_fmap {A B} (f : A → B) (m : M A) i : (f <$> m) !! i = f <$> m !! i;
  lookup_omap {A B} (f : A → option B) (m : M A) i :
    omap f m !! i = m !! i ≫= f;
  lookup_merge {A B C} (f : option A → option B → option C) (m1 : M A) (m2 : M B) i :
    merge f m1 m2 !! i = diag_None f (m1 !! i) (m2 !! i);
  map_fold_empty {A B} (f : K → A → B → B) (b : B) :
    map_fold f b ∅ = b;

  map_fold_fmap_ind {A} (P : M A → Prop) :
    P ∅ →
    (∀ i x m,
      m !! i = None →
      (∀ A' B (f : K → A' → B → B) (g : A → A') b x',
        map_fold f b (<[i:=x']> (g <$> m)) = f i x' (map_fold f b (g <$> m))) →
      P m →
      P (<[i:=x]> m)) →
    ∀ m, P m;
}.
Global Instance map_singleton `{PartialAlter K A M, Empty M} :
  SingletonM K A M.
Admitted.
Global Instance map_equiv `{∀ A, Lookup K A (M A), Equiv A} : Equiv (M A) | 20.
Admitted.

Export stdpp.countable.

Record mapset' (Munit : Type) : Type :=
  Mapset { mapset_car: Munit }.
Notation mapset M := (mapset' (M unit)).

Section mapset.
Context `{FinMap K M}.
Global Instance mapset_elem_of: ElemOf K (mapset M).
admit.
Defined.
Global Instance mapset_singleton: Singleton K (mapset M).
admit.
Defined.

End mapset.

Local Open Scope positive_scope.

Local Notation "P ~ 0" := (λ p, P p~0) : function_scope.
Local Notation "P ~ 1" := (λ p, P p~1) : function_scope.

Inductive gmap_dep_ne (A : Type) (P : positive → Prop) :=
  | GNode001 : gmap_dep_ne A P~1  → gmap_dep_ne A P
  | GNode010 : P 1 → A → gmap_dep_ne A P
  | GNode011 : P 1 → A → gmap_dep_ne A P~1 → gmap_dep_ne A P
  | GNode100 : gmap_dep_ne A P~0 → gmap_dep_ne A P
  | GNode101 : gmap_dep_ne A P~0 → gmap_dep_ne A P~1 → gmap_dep_ne A P
  | GNode110 : gmap_dep_ne A P~0 → P 1 → A → gmap_dep_ne A P
  | GNode111 : gmap_dep_ne A P~0 → P 1 → A → gmap_dep_ne A P~1 → gmap_dep_ne A P.

Variant gmap_dep (A : Type) (P : positive → Prop) :=
  | GEmpty : gmap_dep A P
  | GNodes : gmap_dep_ne A P → gmap_dep A P.

Record gmap_key K `{Countable K} (q : positive) :=
  GMapKey { _ : encode (A:=K) <$> decode q = Some q }.

Record gmap K `{Countable K} A := GMap { gmap_car : gmap_dep A (gmap_key K) }.
Global Instance gmap_lookup `{Countable K} {A} :
    Lookup K A (gmap K A).
Admitted.
Global Instance gmap_empty `{Countable K} {A} : Empty (gmap K A).
Admitted.
Global Instance gmap_partial_alter `{Countable K} {A} :
    PartialAlter K A (gmap K A).
Admitted.
Global Instance gmap_fmap `{Countable K} : FMap (gmap K).
Admitted.

Definition gset K `{Countable K} := mapset (gmap K).

Inductive coPset_raw :=
  | coPLeaf : bool → coPset_raw
  | coPNode : bool → coPset_raw → coPset_raw → coPset_raw.
Fixpoint coPset_wf (t : coPset_raw) : bool.
Admitted.

Definition coPset := { t | coPset_wf t }.
Global Instance coPset_singleton : Singleton positive coPset.
Admitted.

Module Export iris_DOT_algebra_DOT_coPset_WRAPPED.
Module Export coPset.
Export iris.algebra.cmra.

Inductive coPset_disj :=
  | CoPset : coPset → coPset_disj
  | CoPsetBot : coPset_disj.

Section coPset_disj.
  Canonical Structure coPset_disjO := leibnizO coPset_disj.
Local Instance coPset_disj_valid_instance : Valid coPset_disj.
Admitted.
Local Instance coPset_disj_op_instance : Op coPset_disj.
Admitted.
Local Instance coPset_disj_pcore_instance : PCore coPset_disj.
Admitted.

  Lemma coPset_disj_ra_mixin : RAMixin coPset_disj.
Admitted.
  Canonical Structure coPset_disjR := discreteR coPset_disj coPset_disj_ra_mixin.
End coPset_disj.

End coPset.
Module Export iris.
Module Export algebra.
Module Export coPset.
Include iris_DOT_algebra_DOT_coPset_WRAPPED.coPset.
End coPset.

Reserved Notation "P ⊢ Q" (at level 99, Q at level 200, right associativity).

Reserved Notation "P ⊣⊢ Q" (at level 95, no associativity).

Reserved Notation "⊢ Q" (at level 20, Q at level 200).
Reserved Notation "P ∗ Q" (at level 80, right associativity, format "P  ∗  '/' Q").
Reserved Notation "P -∗ Q"
  (at level 99, Q at level 200, right associativity,
   format "'[' P  -∗  '/' '[' Q ']' ']'").

Reserved Notation "'<pers>' P" (at level 20, right associativity).
Reserved Notation "'<pers>?' p P" (at level 20, p at level 9, P at level 20,
   right associativity, format "'<pers>?' p  P").

Reserved Notation "▷ P" (at level 20, right associativity).
Reserved Notation "▷^ n P" (at level 20, n at level 9, P at level 20,
   format "▷^ n  P").

Reserved Notation "'<affine>' P" (at level 20, right associativity).
Reserved Notation "'<affine>?' p P" (at level 20, p at level 9, P at level 20,
   right associativity, format "'<affine>?' p  P").

Reserved Notation "'<absorb>' P" (at level 20, right associativity).

Reserved Notation "□ P" (at level 20, right associativity).
Reserved Notation "'□?' p P" (at level 20, p at level 9, P at level 20,
   right associativity, format "'□?' p  P").

Reserved Notation "|==> Q" (at level 99, Q at level 200, format "'[  ' |==>  '/' Q ']'").
Reserved Notation "P ==∗ Q"
  (at level 99, Q at level 200, format "'[' P  ==∗  '/' Q ']'").

Reserved Notation "'[∗]' Ps" (at level 20).
Reserved Notation "'[∧' 'list]' x ∈ l , P"
  (at level 200, l at level 10, x binder, right associativity,
   format "[∧  list]  x  ∈  l ,  P").

Reserved Notation "'[∗' 'map]' k ↦ x ∈ m , P"
  (at level 200, m at level 10, k binder, x binder, right associativity,
   format "[∗  map]  k ↦ x  ∈  m ,  P").
Delimit Scope bi_scope with I.

Section bi_mixin.
  Context {PROP : Type} `{!Dist PROP, !Equiv PROP}.
  Context (bi_entails : PROP → PROP → Prop).
  Context (bi_emp : PROP).
  Context (bi_pure : Prop → PROP).
  Context (bi_and : PROP → PROP → PROP).
  Context (bi_or : PROP → PROP → PROP).
  Context (bi_impl : PROP → PROP → PROP).
  Context (bi_forall : ∀ A, (A → PROP) → PROP).
  Context (bi_exist : ∀ A, (A → PROP) → PROP).
  Context (bi_sep : PROP → PROP → PROP).
  Context (bi_wand : PROP → PROP → PROP).

  Bind Scope bi_scope with PROP.
  Local Infix "⊢" := bi_entails.
  Local Notation "'emp'" := bi_emp : bi_scope.
  Local Notation "'True'" := (bi_pure True) : bi_scope.
  Local Notation "'False'" := (bi_pure False) : bi_scope.
  Local Notation "'⌜' φ '⌝'" := (bi_pure φ%type%stdpp) : bi_scope.
  Local Infix "∧" := bi_and : bi_scope.
  Local Infix "∨" := bi_or : bi_scope.
  Local Infix "→" := bi_impl : bi_scope.
  Local Notation "∀ x .. y , P" :=
    (bi_forall _ (λ x, .. (bi_forall _ (λ y, P%I)) ..)) : bi_scope.
  Local Notation "∃ x .. y , P" :=
    (bi_exist _ (λ x, .. (bi_exist _ (λ y, P%I)) ..)) : bi_scope.
  Local Infix "∗" := bi_sep : bi_scope.
  Local Infix "-∗" := bi_wand : bi_scope.

  Record BiMixin := {
    bi_mixin_entails_po : PreOrder bi_entails;
    bi_mixin_equiv_entails P Q : (P ≡ Q) ↔ (P ⊢ Q) ∧ (Q ⊢ P);

    bi_mixin_pure_ne n : Proper (iff ==> dist n) bi_pure;
    bi_mixin_and_ne : NonExpansive2 bi_and;
    bi_mixin_or_ne : NonExpansive2 bi_or;
    bi_mixin_impl_ne : NonExpansive2 bi_impl;
    bi_mixin_forall_ne A n :
      Proper (pointwise_relation _ (dist n) ==> dist n) (bi_forall A);
    bi_mixin_exist_ne A n :
      Proper (pointwise_relation _ (dist n) ==> dist n) (bi_exist A);
    bi_mixin_sep_ne : NonExpansive2 bi_sep;
    bi_mixin_wand_ne : NonExpansive2 bi_wand;

    bi_mixin_pure_intro (φ : Prop) P : φ → P ⊢ ⌜ φ ⌝;
    bi_mixin_pure_elim' (φ : Prop) P : (φ → True ⊢ P) → ⌜ φ ⌝ ⊢ P;

    bi_mixin_and_elim_l P Q : P ∧ Q ⊢ P;
    bi_mixin_and_elim_r P Q : P ∧ Q ⊢ Q;
    bi_mixin_and_intro P Q R : (P ⊢ Q) → (P ⊢ R) → P ⊢ Q ∧ R;

    bi_mixin_or_intro_l P Q : P ⊢ P ∨ Q;
    bi_mixin_or_intro_r P Q : Q ⊢ P ∨ Q;
    bi_mixin_or_elim P Q R : (P ⊢ R) → (Q ⊢ R) → P ∨ Q ⊢ R;

    bi_mixin_impl_intro_r P Q R : (P ∧ Q ⊢ R) → P ⊢ Q → R;
    bi_mixin_impl_elim_l' P Q R : (P ⊢ Q → R) → P ∧ Q ⊢ R;

    bi_mixin_forall_intro {A} P (Ψ : A → PROP) : (∀ a, P ⊢ Ψ a) → P ⊢ ∀ a, Ψ a;
    bi_mixin_forall_elim {A} {Ψ : A → PROP} a : (∀ a, Ψ a) ⊢ Ψ a;

    bi_mixin_exist_intro {A} {Ψ : A → PROP} a : Ψ a ⊢ ∃ a, Ψ a;
    bi_mixin_exist_elim {A} (Φ : A → PROP) Q : (∀ a, Φ a ⊢ Q) → (∃ a, Φ a) ⊢ Q;

    bi_mixin_sep_mono P P' Q Q' : (P ⊢ Q) → (P' ⊢ Q') → P ∗ P' ⊢ Q ∗ Q';
    bi_mixin_emp_sep_1 P : P ⊢ emp ∗ P;
    bi_mixin_emp_sep_2 P : emp ∗ P ⊢ P;
    bi_mixin_sep_comm' P Q : P ∗ Q ⊢ Q ∗ P;
    bi_mixin_sep_assoc' P Q R : (P ∗ Q) ∗ R ⊢ P ∗ (Q ∗ R);
    bi_mixin_wand_intro_r P Q R : (P ∗ Q ⊢ R) → P ⊢ Q -∗ R;
    bi_mixin_wand_elim_l' P Q R : (P ⊢ Q -∗ R) → P ∗ Q ⊢ R;
  }.

  Context (bi_persistently : PROP → PROP).
  Local Notation "'<pers>' P" := (bi_persistently P) : bi_scope.

  Record BiPersistentlyMixin := {
    bi_mixin_persistently_ne : NonExpansive bi_persistently;

    bi_mixin_persistently_mono P Q : (P ⊢ Q) → <pers> P ⊢ <pers> Q;

    bi_mixin_persistently_idemp_2 P : <pers> P ⊢ <pers> <pers> P;

    bi_mixin_persistently_emp_2 : emp ⊢ <pers> emp;

    bi_mixin_persistently_and_2 (P Q : PROP) :
      (<pers> P) ∧ (<pers> Q) ⊢ <pers> (P ∧ Q);
    bi_mixin_persistently_exist_1 {A} (Ψ : A → PROP) :
      <pers> (∃ a, Ψ a) ⊢ ∃ a, <pers> (Ψ a);

    bi_mixin_persistently_absorbing P Q : <pers> P ∗ Q ⊢ <pers> P;

    bi_mixin_persistently_and_sep_elim P Q : <pers> P ∧ Q ⊢ P ∗ Q;
  }.

  Context (bi_later : PROP → PROP).
  Local Notation "▷ P" := (bi_later P) : bi_scope.

  Record BiLaterMixin := {
    bi_mixin_later_ne : NonExpansive bi_later;

    bi_mixin_later_mono P Q : (P ⊢ Q) → ▷ P ⊢ ▷ Q;
    bi_mixin_later_intro P : P ⊢ ▷ P;

    bi_mixin_later_forall_2 {A} (Φ : A → PROP) : (∀ a, ▷ Φ a) ⊢ ▷ ∀ a, Φ a;
    bi_mixin_later_exist_false {A} (Φ : A → PROP) :
      (▷ ∃ a, Φ a) ⊢ ▷ False ∨ (∃ a, ▷ Φ a);
    bi_mixin_later_sep_1 P Q : ▷ (P ∗ Q) ⊢ ▷ P ∗ ▷ Q;
    bi_mixin_later_sep_2 P Q : ▷ P ∗ ▷ Q ⊢ ▷ (P ∗ Q);
    bi_mixin_later_persistently_1 P : ▷ <pers> P ⊢ <pers> ▷ P;
    bi_mixin_later_persistently_2 P : <pers> ▷ P ⊢ ▷ <pers> P;

    bi_mixin_later_false_em P : ▷ P ⊢ ▷ False ∨ (▷ False → P);
  }.
End bi_mixin.

  Universe Logic.

  Universe Quant.

Structure bi := Bi {
  bi_car :> Type@{Logic};
  bi_dist : Dist bi_car;
  bi_equiv : Equiv bi_car;
  bi_entails : bi_car → bi_car → Prop;
  bi_emp : bi_car;
  bi_pure : Prop → bi_car;
  bi_and : bi_car → bi_car → bi_car;
  bi_or : bi_car → bi_car → bi_car;
  bi_impl : bi_car → bi_car → bi_car;
  bi_forall : ∀ A : Type@{Quant}, (A → bi_car) → bi_car;
  bi_exist : ∀ A : Type@{Quant}, (A → bi_car) → bi_car;
  bi_sep : bi_car → bi_car → bi_car;
  bi_wand : bi_car → bi_car → bi_car;
  bi_persistently : bi_car → bi_car;
  bi_later : bi_car → bi_car;
  bi_ofe_mixin : OfeMixin bi_car;
  bi_cofe_aux : Cofe (Ofe bi_car bi_ofe_mixin);
  bi_bi_mixin : BiMixin bi_entails bi_emp bi_pure bi_and bi_or bi_impl bi_forall
                        bi_exist bi_sep bi_wand;
  bi_bi_persistently_mixin :
    BiPersistentlyMixin bi_entails bi_emp bi_and bi_exist bi_sep bi_persistently;
  bi_bi_later_mixin : BiLaterMixin bi_entails bi_pure bi_or bi_impl
                                   bi_forall bi_exist bi_sep bi_persistently bi_later;
}.
Bind Scope bi_scope with bi_car.
Coercion bi_ofeO (PROP : bi) : ofe.
exact (Ofe PROP (bi_ofe_mixin PROP)).
Defined.
Canonical Structure bi_ofeO.
Global Arguments bi_entails {PROP} _ _ : simpl never, rename.
Global Arguments bi_emp {PROP} : simpl never, rename.
Global Arguments bi_pure {PROP} _%_stdpp : simpl never, rename.
Global Arguments bi_and {PROP} _ _ : simpl never, rename.
Global Arguments bi_or {PROP} _ _ : simpl never, rename.
Global Arguments bi_impl {PROP} _ _ : simpl never, rename.
Global Arguments bi_forall {PROP _} _%_I : simpl never, rename.
Global Arguments bi_exist {PROP _} _%_I : simpl never, rename.
Global Arguments bi_sep {PROP} _ _ : simpl never, rename.
Global Arguments bi_wand {PROP} _ _ : simpl never, rename.
Global Arguments bi_persistently {PROP} _ : simpl never, rename.
Global Arguments bi_later {PROP} _ : simpl never, rename.

Notation "'emp'" := (bi_emp) : bi_scope.
Notation "'⌜' φ '⌝'" := (bi_pure φ%type%stdpp) : bi_scope.
Notation "'True'" := (bi_pure True) : bi_scope.
Notation "'False'" := (bi_pure False) : bi_scope.
Infix "∧" := bi_and : bi_scope.
Infix "∨" := bi_or : bi_scope.
Infix "→" := bi_impl : bi_scope.
Infix "∗" := bi_sep : bi_scope.
Notation "P -∗ Q" := (bi_wand P Q) : bi_scope.
Notation "∀ x .. y , P" :=
  (bi_forall (λ x, .. (bi_forall (λ y, P%I)) ..)) : bi_scope.
Notation "∃ x .. y , P" :=
  (bi_exist (λ x, .. (bi_exist (λ y, P%I)) ..)) : bi_scope.
Notation "'<pers>' P" := (bi_persistently P) : bi_scope.

Notation "▷ P" := (bi_later P) : bi_scope.

Notation "P ⊢ Q" := (bi_entails P%I Q%I) : stdpp_scope.

Notation "P ⊣⊢ Q" := (equiv (A:=bi_car _) P%I Q%I) : stdpp_scope.
Definition bi_emp_valid {PROP : bi} (P : PROP) : Prop.
Admitted.

Notation "⊢ Q" := (bi_emp_valid Q%I) : stdpp_scope.

Notation "P -∗ Q" := (⊢ P -∗ Q) : stdpp_scope.
Class Persistent {PROP : bi} (P : PROP) := persistent : P ⊢ <pers> P.

Definition bi_affinely {PROP : bi} (P : PROP) : PROP := emp ∧ P.
Notation "'<affine>' P" := (bi_affinely P) : bi_scope.

Class Affine {PROP : bi} (Q : PROP) := affine : Q ⊢ emp.

Definition bi_absorbingly {PROP : bi} (P : PROP) : PROP := True ∗ P.
Notation "'<absorb>' P" := (bi_absorbingly P) : bi_scope.

Class Absorbing {PROP : bi} (P : PROP) := absorbing : <absorb> P ⊢ P.
Definition bi_persistently_if {PROP : bi} (p : bool) (P : PROP) : PROP.
Admitted.
Notation "'<pers>?' p P" := (bi_persistently_if p P) : bi_scope.
Definition bi_affinely_if {PROP : bi} (p : bool) (P : PROP) : PROP.
Admitted.
Notation "'<affine>?' p P" := (bi_affinely_if p P) : bi_scope.
Definition bi_absorbingly_if {PROP : bi} (p : bool) (P : PROP) : PROP.
Admitted.
Definition bi_intuitionistically {PROP : bi} (P : PROP) : PROP.
Admitted.
Notation "□ P" := (bi_intuitionistically P) : bi_scope.
Definition bi_intuitionistically_if {PROP : bi} (p : bool) (P : PROP) : PROP.
Admitted.
Notation "'□?' p P" := (bi_intuitionistically_if p P) : bi_scope.

Fixpoint bi_laterN {PROP : bi} (n : nat) (P : PROP) : PROP :=
  match n with
  | O => P
  | S n' => ▷ ▷^n' P
  end
where "▷^ n P" := (bi_laterN n P) : bi_scope.

Definition bi_wandM {PROP : bi} (mP : option PROP) (Q : PROP) : PROP :=
  match mP with
  | None => Q
  | Some P => P -∗ Q
  end.

Class BiAffine (PROP : bi) := absorbing_bi (Q : PROP) : Affine Q.
Section derived.
Context {PROP : bi}.
Implicit Types P Q R : PROP.

Global Instance intuitionistically_affine P : Affine (□ P).
Admitted.

Global Instance bi_and_monoid : Monoid (@bi_and PROP).
Admitted.
Global Instance bi_sep_monoid : Monoid (@bi_sep PROP).
Admitted.
End derived.

Fixpoint big_opL {M : ofe} {o : M → M → M} `{!Monoid o} {A} (f : nat → A → M) (xs : list A) : M :=
  match xs with
  | [] => monoid_unit
  | x :: xs => o (f 0 x) (big_opL (λ n, f (S n)) xs)
  end.
Global Arguments big_opL {M} o {_ A} _ !_ /.
Local Definition big_opM_def {M : ofe} {o : M → M → M} `{!Monoid o} `{Countable K} {A} (f : K → A → M)
  (m : gmap K A) : M.
Admitted.
Local Definition big_opM_aux : seal (@big_opM_def).
Admitted.
Definition big_opM := big_opM_aux.(unseal).
Global Arguments big_opM {M} o {_ K _ _ A} _ _.

Section ofe.
Context {A : ofe}.
Local Instance list_dist : Dist (list A).
Admitted.

Definition list_ofe_mixin : OfeMixin (list A).
Admitted.
Canonical Structure listO := Ofe (list A) list_ofe_mixin.
End ofe.

Global Arguments listO : clear implicits.

Inductive gset_disj K `{Countable K} :=
  | GSet : gset K → gset_disj K
  | GSetBot : gset_disj K.

Section gset_disj.
  Context `{Countable K}.

  Canonical Structure gset_disjO := leibnizO (gset_disj K).
Local Instance gset_disj_valid_instance : Valid (gset_disj K).
Admitted.
Local Instance gset_disj_op_instance : Op (gset_disj K).
Admitted.
Local Instance gset_disj_pcore_instance : PCore (gset_disj K).
Admitted.

  Lemma gset_disj_ra_mixin : RAMixin (gset_disj K).
Admitted.
  Canonical Structure gset_disjR := discreteR (gset_disj K) gset_disj_ra_mixin.

  End gset_disj.
Global Arguments gset_disjR _ {_ _}.

Section ofe.
Context `{Countable K} {A : ofe}.
Local Instance gmap_dist : Dist (gmap K A).
Admitted.
Definition gmap_ofe_mixin : OfeMixin (gmap K A).
Admitted.
Canonical Structure gmapO : ofe.
exact (Ofe (gmap K A) gmap_ofe_mixin).
Defined.
End ofe.

Section cmra.
Context `{Countable K} {A : cmra}.
Local Instance gmap_unit_instance : Unit (gmap K A).
Admitted.
Local Instance gmap_op_instance : Op (gmap K A).
Admitted.
Local Instance gmap_pcore_instance : PCore (gmap K A).
Admitted.
Local Instance gmap_valid_instance : Valid (gmap K A).
Admitted.
Local Instance gmap_validN_instance : ValidN (gmap K A).
Admitted.

Lemma gmap_cmra_mixin : CmraMixin (gmap K A).
Admitted.
Canonical Structure gmapR := Cmra (gmap K A) gmap_cmra_mixin.

Lemma gmap_ucmra_mixin : UcmraMixin (gmap K A).
Admitted.
Canonical Structure gmapUR := Ucmra (gmap K A) gmap_ucmra_mixin.

End cmra.
Global Arguments gmapUR _ {_ _} _.
Notation "'[∗]' Ps" := (big_opL bi_sep (λ _ x, x) Ps%I) : bi_scope.
Notation "'[∧' 'list]' x ∈ l , P" :=
  (big_opL bi_and (λ _ x, P%I) l) : bi_scope.

Notation "'[∗' 'map]' k ↦ x ∈ m , P" := (big_opM bi_sep (λ k x, P%I) m) : bi_scope.

Class BUpd (PROP : Type) : Type := bupd : PROP → PROP.

Notation "|==> Q" := (bupd Q) : bi_scope.
Notation "P ==∗ Q" := (P -∗ |==> Q)%I : bi_scope.
Notation "P ==∗ Q" := (P -∗ |==> Q) : stdpp_scope.

Record BiBUpdMixin (PROP : bi) 

[...]

 xs pat as p
    | _ => fail "iSpecialize:" t "should be a proof mode term"
    end
  end.

Tactic Notation "iPoseProofCore" open_constr(lem)
    "as" constr(p) tactic3(tac) :=
  iStartProof;
  let t := lazymatch lem with ITrm ?t ?xs ?pat => t | _ => lem end in
  let t := lazymatch type of t with string => constr:(INamed t) | _ => t end in
  let spec_tac Htmp :=
    lazymatch lem with
    | ITrm _ ?xs ?pat => iSpecializeCore (ITrm Htmp xs pat) as p
    | _ => idtac
    end in
  lazymatch type of t with
  | ident =>
     let Htmp := iFresh in
     iPoseProofCoreHyp t as Htmp; spec_tac Htmp; [..|tac Htmp]
  | _ => iPoseProofCoreLem t as (fun Htmp => spec_tac Htmp; [..|tac Htmp])
  end.

Tactic Notation "iOrDestruct" constr(H) "as" constr(H1) constr(H2) :=
  eapply tac_or_destruct with H _ H1 H2 _ _ _;
    [pm_reflexivity ||
     let H := pretty_ident H in
     fail "iOrDestruct:" H "not found"
    |tc_solve ||
     let P := match goal with |- IntoOr ?P _ _ => P end in
     fail "iOrDestruct: cannot destruct" P
    | pm_reduce;
      lazymatch goal with
      | |- False =>
        let H1 := pretty_ident H1 in
        let H2 := pretty_ident H2 in
        fail "iOrDestruct:" H1 "or" H2 "not fresh"
      |  _ => split
      end].

Local Tactic Notation "iAndDestruct" constr(H) "as" constr(H1) constr(H2) :=
  eapply tac_and_destruct with H _ H1 H2 _ _ _;
    [pm_reflexivity ||
     let H := pretty_ident H in
     fail "iAndDestruct:" H "not found"
    |pm_reduce; tc_solve ||
     let P :=
       lazymatch goal with
       | |- IntoSep ?P _ _ => P
       | |- IntoAnd _ ?P _ _ => P
       end in
     fail "iAndDestruct: cannot destruct" P
    |pm_reduce;
     lazymatch goal with
       | |- False =>
         let H1 := pretty_ident H1 in
         let H2 := pretty_ident H2 in
         fail "iAndDestruct:" H1 "or" H2 "not fresh"
       | _ => idtac
     end].

Local Tactic Notation "iAndDestructChoice" constr(H) "as" constr(d) constr(H') :=
  eapply tac_and_destruct_choice with H _ d H' _ _ _;
    [pm_reflexivity || fail "iAndDestructChoice:" H "not found"
    |pm_reduce; tc_solve ||
     let P := match goal with |- TCOr (IntoAnd _ ?P _ _) _ => P end in
     fail "iAndDestructChoice: cannot destruct" P
    |pm_reduce;
     lazymatch goal with
     | |- False =>
       let H' := pretty_ident H' in
       fail "iAndDestructChoice:" H' "not fresh"
     | _ => idtac
     end].

Ltac _iExists x :=
  iStartProof;
  eapply tac_exist;
    [tc_solve ||
     let P := match goal with |- FromExist ?P _ => P end in
     fail "iExists:" P "not an existential"
    |pm_prettify; eexists x
      ].

Tactic Notation "iExists" ne_uconstr_list_sep(xs,",") :=
  ltac1_list_iter _iExists xs.

Local Tactic Notation "iExistDestruct" constr(H)
    "as" simple_intropattern(x) constr(Hx) :=
  eapply tac_exist_destruct with H _ Hx _ _ _;
    [pm_reflexivity ||
     let H := pretty_ident H in
     fail "iExistDestruct:" H "not found"
    |tc_solve ||
     let P := match goal with |- IntoExist ?P _ _ => P end in
     fail "iExistDestruct: cannot destruct" P|];
    let name := lazymatch goal with
                | |- let _ := (λ name, _) in _ => name
                end in
    intros _;
    let y := fresh name in
    intros y; pm_reduce;
    lazymatch goal with
    | |- False =>
      let Hx := pretty_ident Hx in
      fail "iExistDestruct:" Hx "not fresh"
    | _ => revert y; intros x
    end.

Tactic Notation "iModIntro" uconstr(sel) :=
  iStartProof;
  notypeclasses refine (tac_modal_intro _ _ sel _ _ _ _ _ _ _ _ _ _ _ _ _ _);
    [tc_solve ||
     fail "iModIntro: the goal is not a modality"
    |tc_solve ||
     let s := lazymatch goal with |- IntoModalIntuitionisticEnv _ _ _ ?s => s end in
     lazymatch eval hnf in s with
     | MIEnvForall ?C => fail "iModIntro: intuitionistic context does not satisfy" C
     | MIEnvIsEmpty => fail "iModIntro: intuitionistic context is non-empty"
     end
    |tc_solve ||
     let s := lazymatch goal with |- IntoModalSpatialEnv _ _ _ ?s _ => s end in
     lazymatch eval hnf in s with
     | MIEnvForall ?C => fail "iModIntro: spatial context does not satisfy" C
     | MIEnvIsEmpty => fail "iModIntro: spatial context is non-empty"
     end
    |pm_reduce; tc_solve ||
     fail "iModIntro: cannot filter spatial context when goal is not absorbing"
    |iSolveSideCondition
    |pm_prettify
      ].
Tactic Notation "iModIntro" := iModIntro _.

Tactic Notation "iModCore" constr(H) "as" constr(H') :=
  eapply tac_modal_elim with H H' _ _ _ _ _ _;
    [pm_reflexivity || fail "iMod:" H "not found"
    |tc_solve ||
     let P := match goal with |- ElimModal _ _ _ ?P _ _ _ => P end in
     let Q := match goal with |- ElimModal _ _ _ _ _ ?Q _ => Q end in
     fail "iMod: cannot eliminate modality" P "in" Q
    |iSolveSideCondition
    |pm_reduce;
     lazymatch goal with
     | |- False =>
       let H' := pretty_ident H' in
       fail "iMod:" H' "not fresh"
     | _ => pm_prettify
     end].

Local Ltac ident_for_pat pat :=
  lazymatch pat with
  | IIdent ?x => x
  | _ => let x := iFresh in x
  end.

Local Ltac ident_for_pat_default pat default :=
  lazymatch pat with
  | IIdent ?x => x
  | _ =>
    lazymatch default with
    | IAnon _ => default
    | _ => let x := iFresh in x
    end
  end.

Local Ltac iDestructHypGo Hz pat0 pat :=
  lazymatch pat with
  | IFresh =>
     lazymatch Hz with
     | IAnon _ => idtac
     | INamed ?Hz => let Hz' := iFresh in iRename Hz into Hz'
     end
  | IDrop => iClearHyp Hz
  | IFrame => iFrameHyp Hz
  | IIdent Hz => idtac
  | IIdent ?y => iRename Hz into y
  | IList [[]] => iExFalso; iExact Hz

  | IList [[?pat1; IDrop]] =>
     let x := ident_for_pat_default pat1 Hz in
     iAndDestructChoice Hz as Left x;
     iDestructHypGo x pat0 pat1
  | IList [[IDrop; ?pat2]] =>
     let x := ident_for_pat_default pat2 Hz in
     iAndDestructChoice Hz as Right x;
     iDestructHypGo x pat0 pat2

  | IList [[IPure IGallinaAnon; ?pat2]] =>
     let x := ident_for_pat_default pat2 Hz in
     iExistDestruct Hz as ? x; iDestructHypGo x pat0 pat2
  | IList [[IPure (IGallinaNamed ?s); ?pat2]] =>
     let x := fresh in
     let y := ident_for_pat_default pat2 Hz in
     iExistDestruct Hz as x y;
     rename_by_string x s;
     iDestructHypGo y pat0 pat2
  | IList [[?pat1; ?pat2]] =>

     let x1 := ident_for_pat_default pat1 Hz in
     let x2 := ident_for_pat pat2 in
     iAndDestruct Hz as x1 x2;
     iDestructHypGo x1 pat0 pat1; iDestructHypGo x2 pat0 pat2
  | IList [_ :: _ :: _] => fail "iDestruct:" pat0 "has too many conjuncts"
  | IList [[_]] => fail "iDestruct:" pat0 "has just a single conjunct"

  | IList [[?pat1];[?pat2]] =>
     let x1 := ident_for_pat_default pat1 Hz in
     let x2 := ident_for_pat_default pat2 Hz in
     iOrDestruct Hz as x1 x2;
     [iDestructHypGo x1 pat0 pat1|iDestructHypGo x2 pat0 pat2]

  | IList (_ :: _ :: _ :: _) => fail "iDestruct:" pat0 "has too many disjuncts"

  | IList [_;_] => fail "iDestruct: in" pat0 "a disjunct has multiple patterns"

  | IPure IGallinaAnon => iPure Hz as ?
  | IPure (IGallinaNamed ?s) =>
     let x := fresh in
     iPure Hz as x;
     rename_by_string x s
  | IRewrite Right => iPure Hz as ->
  | IRewrite Left => iPure Hz as <-
  | IIntuitionistic ?pat =>
    let x := ident_for_pat_default pat Hz in
    iIntuitionistic Hz as x; iDestructHypGo x pat0 pat
  | ISpatial ?pat =>
    let x := ident_for_pat_default pat Hz in
    iSpatial Hz as x; iDestructHypGo x pat0 pat
  | IModalElim ?pat =>
    let x := ident_for_pat_default pat Hz in
    iModCore Hz as x; iDestructHypGo x pat0 pat
  | _ => fail "iDestruct:" pat0 "is not supported due to" pat
  end.
Local Ltac iDestructHypFindPat Hgo pat found pats :=
  lazymatch pats with
  | [] =>
    lazymatch found with
    | true => pm_prettify
    | false => fail "iDestruct:" pat "should contain exactly one proper introduction pattern"
    end
  | ISimpl :: ?pats => simpl; iDestructHypFindPat Hgo pat found pats
  | IClear ?H :: ?pats => iClear H; iDestructHypFindPat Hgo pat found pats
  | IClearFrame ?H :: ?pats => iFrame H; iDestructHypFindPat Hgo pat found pats
  | ?pat1 :: ?pats =>
     lazymatch found with
     | false => iDestructHypGo Hgo pat pat1; iDestructHypFindPat Hgo pat true pats
     | true => fail "iDestruct:" pat "should contain exactly one proper introduction pattern"
     end
  end.

Ltac _iDestructHyp0 H pat :=
  let pats := intro_pat.parse pat in
  iDestructHypFindPat H pat false pats.
Ltac _iDestructHyp H xs pat :=
  ltac1_list_iter ltac:(fun x => iExistDestruct H as x H) xs;
  _iDestructHyp0 H pat.

Tactic Notation "iDestructHyp" constr(H) "as" constr(pat) :=
  _iDestructHyp0 H pat.

Ltac _iIntros_go pats startproof :=
  lazymatch pats with
  | [] =>
    lazymatch startproof with
    | true => iStartProof
    | false => idtac
    end

  | IPure (IGallinaNamed ?s) :: ?pats =>
     let i := fresh in
     iIntro (i);
     rename_by_string i s;
     _iIntros_go pats startproof
  | IPure IGallinaAnon :: ?pats => iIntro (?); _iIntros_go pats startproof
  | IIntuitionistic (IIdent ?H) :: ?pats => iIntro #H; _iIntros_go pats false
  | IDrop :: ?pats => iIntro _; _iIntros_go pats startproof
  | IIdent ?H :: ?pats => iIntro H; _iIntros_go pats startproof

  | IPureIntro :: ?pats => iPureIntro; _iIntros_go pats false
  | IModalIntro :: ?pats => iModIntro; _iIntros_go pats false
  | IForall :: ?pats => repeat iIntroForall; _iIntros_go pats startproof
  | IAll :: ?pats => repeat (iIntroForall || iIntro); _iIntros_go pats startproof

  | ISimpl :: ?pats => simpl; _iIntros_go pats startproof
  | IClear ?H :: ?pats => iClear H; _iIntros_go pats false
  | IClearFrame ?H :: ?pats => iFrame H; _iIntros_go pats false
  | IDone :: ?pats => try done; _iIntros_go pats startproof

  | IIntuitionistic ?pat :: ?pats =>
     let H := iFresh in iIntro #H; iDestructHyp H as pat; _iIntros_go pats false
  | ?pat :: ?pats =>
     let H := iFresh in iIntro H; iDestructHyp H as pat; _iIntros_go pats false
  end.

Ltac _iIntros0 pat :=
  let pats := intro_pat.parse pat in

  lazymatch pats with
  | [] => idtac
  | _ => _iIntros_go pats true
  end.
Ltac _iIntros xs pat :=
  ltac1_list_iter ltac:(fun x => iIntro (x)) xs;
  _iIntros0 pat.
Tactic Notation "iIntros" "(" ne_simple_intropattern_list(xs) ")" constr(pat) :=
  _iIntros xs pat.

Tactic Notation "iDestructCore" open_constr(lem) "as" constr(p) tactic3(tac) :=
  let intro_destruct n :=
    let rec go n' :=
      lazymatch n' with
      | 0 => fail "iDestruct: cannot introduce" n "hypotheses"
      | 1 => repeat iIntroForall; let H := iFresh in iIntro H; tac H
      | S ?n' => repeat iIntroForall; let H := iFresh in iIntro H; go n'
      end in
    intros; go n in
  lazymatch type of lem with
  | nat => intro_destruct lem
  | Z =>

     let n := eval cbv in (Z.to_nat lem) in intro_destruct n
  | ident => tac lem
  | string => tac constr:(INamed lem)
  | _ => iPoseProofCore lem as p tac
  end.
Tactic Notation "iMod" open_constr(lem) "as" "(" ne_simple_intropattern_list(xs) ")"
    constr(pat) :=
  iDestructCore lem as false (fun H => iModCore H as H; last _iDestructHyp H xs pat).

Global Hint Extern 0 (envs_entails _ _) => iPureIntro; try done : core.

Lemma from_assumption_exact {PROP : bi} p (P : PROP) : FromAssumption p P P.
Admitted.
Global Hint Extern 0 (FromAssumption _ _ _) =>
  notypeclasses refine (from_assumption_exact _ _); shelve : typeclass_instances.

Lemma from_exist_exist {PROP : bi} {A} (Φ : A → PROP) : FromExist (∃ a, Φ a) Φ.
Admitted.
Global Hint Extern 0 (FromExist _ _) =>
  notypeclasses refine (from_exist_exist _) : typeclass_instances.

Section class_instances.
Context {PROP : bi}.
Implicit Types P Q R : PROP.

Global Instance as_emp_valid_emp_valid P : AsEmpValid0 (⊢ P) P | 0.
Admitted.
Global Instance from_pure_pure φ : @FromPure PROP false ⌜φ⌝ φ.
Admitted.
Global Instance into_persistent_intuitionistically p P Q :
  IntoPersistent true P Q → IntoPersistent p (□ P) Q | 0.
Admitted.
Global Instance into_persistent_here P : IntoPersistent true P P | 1.
Admitted.

Global Instance into_wand_wand p q P Q P' :
  FromAssumption q P P' → IntoWand p q (P' -∗ Q) P Q.
Admitted.

Global Instance from_wand_wand P1 P2 : FromWand (P1 -∗ P2) P1 P2.
Admitted.

Global Instance into_sep_sep P Q : IntoSep (P ∗ Q) P Q.
Admitted.

Global Instance into_exist_exist {A} (Φ : A → PROP) name :
  AsIdentName Φ name → IntoExist (bi_exist Φ) Φ name.
Admitted.
End class_instances.

Section class_instances_updates.

Global Instance from_modal_bupd `{!BiBUpd PROP} P :
  FromModal True modality_id (|==> P) (|==> P) P.
Admitted.

Global Instance elim_modal_bupd `{!BiBUpd PROP} p P Q :
  ElimModal True p false (|==> P) P (|==> Q) (|==> Q).
Admitted.
End class_instances_updates.

Record agree (A : Type) : Type := {
  agree_car : list A;
  agree_not_nil : bool_decide (agree_car = []) = false
}.
Global Arguments agree_car {_} _.
Definition to_agree {A} (a : A) : agree A.
Admitted.

Section agree.
Context {A : ofe}.
Local Instance agree_dist : Dist (agree A).
Admitted.
Local Instance agree_equiv : Equiv (agree A).
Admitted.

Definition agree_ofe_mixin : OfeMixin (agree A).
Admitted.
Canonical Structure agreeO := Ofe (agree A) agree_ofe_mixin.
Local Instance agree_validN_instance : ValidN (agree A).
Admitted.
Local Instance agree_valid_instance : Valid (agree A).
Admitted.

Local Program Instance agree_op_instance : Op (agree A) := λ x y,
  {| agree_car := agree_car x ++ agree_car y |}.
Admit Obligations.
Local Instance agree_pcore_instance : PCore (agree A).
Admitted.

Definition agree_cmra_mixin : CmraMixin (agree A).
Admitted.
Canonical Structure agreeR : cmra.
exact (Cmra (agree A) agree_cmra_mixin).
Defined.

End agree.
Global Arguments agreeR : clear implicits.

Notation frac := Qp (only parsing).
  Canonical Structure fracO := leibnizO frac.
Local Instance frac_valid_instance : Valid frac.
Admitted.
Local Instance frac_pcore_instance : PCore frac.
Admitted.
Local Instance frac_op_instance : Op frac.
Admitted.

  Definition frac_ra_mixin : RAMixin frac.
Admitted.
  Canonical Structure fracR := discreteR frac frac_ra_mixin.

Inductive dfrac :=
  | DfracOwn : Qp → dfrac
  | DfracDiscarded : dfrac
  | DfracBoth : Qp → dfrac.

Declare Custom Entry dfrac.
Notation "" := (DfracOwn 1) (in custom dfrac).

Structure view_rel (A : ofe) (B : ucmra) := ViewRel {
  view_rel_holds :> nat → A → B → Prop;
  view_rel_mono n1 n2 a1 a2 b1 b2 :
    view_rel_holds n1 a1 b1 →
    a1 ≡{n2}≡ a2 →
    b2 ≼{n2} b1 →
    n2 ≤ n1 →
    view_rel_holds n2 a2 b2;
  view_rel_validN n a b :
    view_rel_holds n a b → ✓{n} b;
  view_rel_unit n :
    ∃ a, view_rel_holds n a ε
}.
Global Arguments ViewRel {_ _} _ _.

Record view {A B} (rel : nat → A → B → Prop) :=
  View { view_auth_proj : option (dfrac * agree A) ; view_frag_proj : B }.

Section ofe.
  Context {A B : ofe} (rel : nat → A → B → Prop).
Local Instance view_equiv : Equiv (view rel).
Admitted.
Local Instance view_dist : Dist (view rel).
Admitted.

  Definition view_ofe_mixin : OfeMixin (view rel).
Admitted.
  Canonical Structure viewO := Ofe (view rel) view_ofe_mixin.
End ofe.

Section cmra.
  Context {A B} (rel : view_rel A B).
Local Instance view_valid_instance : Valid (view rel).
Admitted.
Local Instance view_validN_instance : ValidN (view rel).
Admitted.
Local Instance view_pcore_instance : PCore (view rel).
Admitted.
Local Instance view_op_instance : Op (view rel).
Admitted.

  Lemma view_cmra_mixin : CmraMixin (view rel).
Admitted.
  Canonical Structure viewR := Cmra (view rel) view_cmra_mixin.
Local Instance view_empty_instance : Unit (view rel).
Admitted.
  Lemma view_ucmra_mixin : UcmraMixin (view rel).
Admitted.
  Canonical Structure viewUR := Ucmra (view rel) view_ucmra_mixin.

End cmra.
Definition viewO_map {A A' B B' : ofe}
    {rel : nat → A → B → Prop} {rel' : nat → A' → B' → Prop}
    (f : A -n> A') (g : B -n> B') : viewO rel -n> viewO rel'.
Admitted.
Definition auth_view_rel_raw {A : ucmra} (n : nat) (a b : A) : Prop.
Admitted.
Lemma auth_view_rel_raw_mono (A : ucmra) n1 n2 (a1 a2 b1 b2 : A) :
  auth_view_rel_raw n1 a1 b1 →
  a1 ≡{n2}≡ a2 →
  b2 ≼{n2} b1 →
  n2 ≤ n1 →
  auth_view_rel_raw n2 a2 b2.
Admitted.
Lemma auth_view_rel_raw_valid (A : ucmra) n (a b : A) :
  auth_view_rel_raw n a b → ✓{n} b.
Admitted.
Lemma auth_view_rel_raw_unit (A : ucmra) n :
  ∃ a : A, auth_view_rel_raw n a ε.
Admitted.
Canonical Structure auth_view_rel {A : ucmra} : view_rel A A.
exact (ViewRel auth_view_rel_raw (auth_view_rel_raw_mono A)
          (auth_view_rel_raw_valid A) (auth_view_rel_raw_unit A)).
Defined.

Notation auth A := (view (A:=A) (B:=A) auth_view_rel_raw).
Definition authR (A : ucmra) : cmra.
exact (viewR (A:=A) (B:=A) auth_view_rel).
Defined.
Definition authUR (A : ucmra) : ucmra.
exact (viewUR (A:=A) (B:=A) auth_view_rel).
Defined.
Definition auth_auth {A: ucmra} : dfrac → A → auth A.
Admitted.
Definition auth_frag {A: ucmra} : A → auth A.
Admitted.

Notation "● dq a" := (auth_auth dq a)
  (at level 20, dq custom dfrac at level 1, format "● dq  a").
Notation "◯ a" := (auth_frag a) (at level 20).

Program Definition authURF (F : urFunctor) : urFunctor := {|
  urFunctor_car A _ B _ := authUR (urFunctor_car F A B);
  urFunctor_map A1 _ A2 _ B1 _ B2 _ fg :=
    viewO_map (urFunctor_map F fg) (urFunctor_map F fg)
|}.
Admit Obligations.

Program Definition authRF (F : urFunctor) : rFunctor := {|
  rFunctor_car A _ B _ := authR (urFunctor_car F A B);
  rFunctor_map A1 _ A2 _ B1 _ B2 _ fg :=
    viewO_map (urFunctor_map F fg) (urFunctor_map F fg)
|}.
Solve Obligations with apply authURF.

Record uPred (M : ucmra) : Type := UPred {
  uPred_holds : nat → M → Prop;

  uPred_mono n1 n2 x1 x2 :
    uPred_holds n1 x1 → x1 ≼{n2} x2 → n2 ≤ n1 → uPred_holds n2 x2
}.

Local Coercion uPred_holds : uPred >-> Funclass.
Bind Scope bi_scope with uPred.

Section cofe.
  Context {M : ucmra}.
Local Instance uPred_equiv : Equiv (uPred M).
Admitted.
Local Instance uPred_dist : Dist (uPred M).
Admitted.
  Definition uPred_ofe_mixin : OfeMixin (uPred M).
Admitted.
Canonical Structure uPredO : ofe.
exact (Ofe (uPred M) uPred_ofe_mixin).
Defined.

  Program Definition uPred_compl : Compl uPredO := λ c,
    {| uPred_holds n x := ∀ n', n' ≤ n → ✓{n'} x → c n' n' x |}.
Admit Obligations.
  Global Program Instance uPred_cofe : Cofe uPredO := {| compl := uPred_compl |}.
Admit Obligations.
End cofe.
Global Arguments uPredO : clear implicits.

Inductive uPred_entails {M} (P Q : uPred M) : Prop :=
  { uPred_in_entails : ∀ n x, ✓{n} x → P n x → Q n x }.
Global Hint Resolve uPred_mono : uPred_def.

Local Program Definition uPred_pure_def {M} (φ : Prop) : uPred M :=
  {| uPred_holds n x := φ |}.
Solve Obligations with done.
Local Definition uPred_pure_aux : seal (@uPred_pure_def).
Admitted.
Definition uPred_pure := uPred_pure_aux.(unseal).
Global Arguments uPred_pure {M}.

Local Program Definition uPred_and_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := P n x ∧ Q n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_and_aux : seal (@uPred_and_def).
Admitted.
Definition uPred_and := uPred_and_aux.(unseal).
Global Arguments uPred_and {M}.

Local Program Definition uPred_or_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := P n x ∨ Q n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_or_aux : seal (@uPred_or_def).
Admitted.
Definition uPred_or := uPred_or_aux.(unseal).
Global Arguments uPred_or {M}.

Local Program Definition uPred_impl_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := ∀ n' x',
       x ≼ x' → n' ≤ n → ✓{n'} x' → P n' x' → Q n' x' |}.
Admit Obligations.
Local Definition uPred_impl_aux : seal (@uPred_impl_def).
Admitted.
Definition uPred_impl := uPred_impl_aux.(unseal).
Global Arguments uPred_impl {M}.

Local Program Definition uPred_forall_def {M A} (Ψ : A → uPred M) : uPred M :=
  {| uPred_holds n x := ∀ a, Ψ a n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_forall_aux : seal (@uPred_forall_def).
Admitted.
Definition uPred_forall := uPred_forall_aux.(unseal).

Local Program Definition uPred_exist_def {M A} (Ψ : A → uPred M) : uPred M :=
  {| uPred_holds n x := ∃ a, Ψ a n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_exist_aux : seal (@uPred_exist_def).
Admitted.
Definition uPred_exist := uPred_exist_aux.(unseal).

Local Program Definition uPred_sep_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := ∃ x1 x2, x ≡{n}≡ x1 ⋅ x2 ∧ P n x1 ∧ Q n x2 |}.
Admit Obligations.
Local Definition uPred_sep_aux : seal (@uPred_sep_def).
Admitted.
Definition uPred_sep := uPred_sep_aux.(unseal).
Global Arguments uPred_sep {M}.

Local Program Definition uPred_wand_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := ∀ n' x',
       n' ≤ n → ✓{n'} (x ⋅ x') → P n' x' → Q n' (x ⋅ x') |}.
Admit Obligations.
Local Definition uPred_wand_aux : seal (@uPred_wand_def).
Admitted.
Definition uPred_wand := uPred_wand_aux.(unseal).
Global Arguments uPred_wand {M}.

Local Program Definition uPred_plainly_def {M} (P : uPred M) : uPred M :=
  {| uPred_holds n x := P n ε |}.
Solve Obligations with naive_solver eauto using uPred_mono, ucmra_unit_validN.

Local Program Definition uPred_persistently_def {M} (P : uPred M) : uPred M :=
  {| uPred_holds n x := P n (core x) |}.
Solve Obligations with naive_solver eauto using uPred_mono, cmra_core_monoN.
Local Definition uPred_persistently_aux : seal (@uPred_persistently_def).
Admitted.
Definition uPred_persistently := uPred_persistently_aux.(unseal).
Global Arguments uPred_persistently {M}.

Local Program Definition uPred_later_def {M} (P : uPred M) : uPred M :=
  {| uPred_holds n x := match n return _ with 0 => True | S n' => P n' x end |}.
Admit Obligations.
Local Definition uPred_later_aux : seal (@uPred_later_def).
Admitted.
Definition uPred_later := uPred_later_aux.(unseal).
Global Arguments uPred_later {M}.
Definition uPred_emp {M} : uPred M.
Admitted.

Lemma uPred_bi_mixin (M : ucmra) :
  BiMixin
    uPred_entails uPred_emp uPred_pure uPred_and uPred_or uPred_impl
    (@uPred_forall M) (@uPred_exist M) uPred_sep uPred_wand.
Admitted.

Lemma uPred_bi_persistently_mixin (M : ucmra) :
  BiPersistentlyMixin
    uPred_entails uPred_emp uPred_and
    (@uPred_exist M) uPred_sep uPred_persistently.
Admitted.

Lemma uPred_bi_later_mixin (M : ucmra) :
  BiLaterMixin
    uPred_entails uPred_pure uPred_or uPred_impl
    (@uPred_forall M) (@uPred_exist M) uPred_sep uPred_persistently uPred_later.
Admitted.
Canonical Structure uPredI (M : ucmra) : bi.
exact ({| bi_ofe_mixin := ofe_mixin_of (uPred M);
     bi_bi_mixin := uPred_bi_mixin M;
     bi_bi_later_mixin := uPred_bi_later_mixin M;
     bi_bi_persistently_mixin := uPred_bi_persistently_mixin M |}).
Defined.
Global Instance uPred_bi_bupd M : BiBUpd (uPredI M).
Admitted.

Structure gFunctor := GFunctor {
  gFunctor_F :> rFunctor;
  gFunctor_map_contractive : rFunctorContractive gFunctor_F;
}.

Record gFunctors := GFunctors {
  gFunctors_len : nat;
  gFunctors_lookup : fin gFunctors_len → gFunctor
}.

Definition gid (Σ : gFunctors) := fin (gFunctors_len Σ).

Definition gname := positive.
Definition iResUR (Σ : gFunctors) : ucmra.
Admitted.
  Notation iProp Σ := (uPred (iResUR Σ)).
  Notation iPropO Σ := (uPredO (iResUR Σ)).

Class inG (Σ : gFunctors) (A : cmra) := InG {
  inG_id : gid Σ;
  inG_apply := rFunctor_apply (gFunctors_lookup Σ inG_id);
  inG_prf : A = inG_apply (iPropO Σ) _;
}.
Local Definition own_def `{!inG Σ A} (γ : gname) (a : A) : iProp Σ.
Admitted.
Local Definition own_aux : seal (@own_def).
Admitted.
Definition own := own_aux.(unseal).
Global Arguments own {Σ A _} γ a.

Section cmra_mlist.

  Context (A: Type) `{EqDecision A}.
  Implicit Types (D: list A).

  Inductive mlist :=
    | MList D : mlist
    | MListBot : mlist.

  Inductive mlist_equiv : Equiv mlist :=
    | MList_equiv D1 D2:
        D1 = D2 → MList D1 ≡ MList D2
    | MListBot_equiv : MListBot ≡ MListBot.

  Existing Instance mlist_equiv.
  Local Instance mlist_equiv_Equivalence : @Equivalence mlist equiv.
Admitted.
Canonical Structure mlistC : ofe.
exact (discreteO mlist).
Defined.
Local Instance mlist_valid : Valid mlist.
Admitted.
Local Instance mlist_op : Op mlist.
Admitted.
Local Instance mlist_PCore : PCore mlist.
Admitted.
Local Instance mlist_unit : Unit mlist.
Admitted.

  Definition mlist_ra_mixin : RAMixin mlist.
Admitted.

  Canonical Structure mlistR := discreteR mlist mlist_ra_mixin.

  Definition mlist_ucmra_mixin : UcmraMixin mlist.
Admitted.

  Canonical Structure mlistUR :=
    Ucmra mlist mlist_ucmra_mixin.

End cmra_mlist.

Global Arguments MList {_} _.

Definition fmlistUR (A: Type) {Heq: EqDecision A} := authUR (mlistUR A).
Class fmlistG (A: Type) {Heq: EqDecision A} Σ :=
  { #[global] fmlist_inG :: inG Σ (fmlistUR A) }.

Section fmlist_props.
Context `{fmlistG A Σ}.
Definition fmlist_lb γ l := own γ (◯ (MList l)).
Definition fmlist_idx γ i a := (∃ l, ⌜ l !! i = Some a ⌝ ∗ fmlist_lb γ l)%I.

End fmlist_props.
Local Instance nat_valid_instance : Valid nat.
Admitted.
Local Instance nat_pcore_instance : PCore nat.
Admitted.
Local Instance nat_op_instance : Op nat.
Admitted.
  Lemma nat_ra_mixin : RAMixin nat.
Admitted.
Canonical Structure natR : cmra.
exact (discreteR nat nat_ra_mixin).
Defined.
Local Instance nat_unit_instance : Unit nat.
Admitted.
  Lemma nat_ucmra_mixin : UcmraMixin nat.
Admitted.
Canonical Structure natUR : ucmra.
exact (Ucmra nat nat_ucmra_mixin).
Defined.

Class lcGpreS (Σ : gFunctors) := LcGpreS {
  #[local] lcGpreS_inG :: inG Σ (authR natUR)
}.

Class lcGS (Σ : gFunctors) := LcGS {
  #[local] lcGS_inG :: inG Σ (authR natUR);
  lcGS_name : gname;
}.
Import iris.algebra.coPset.

Inductive bi_schema :=
| bi_sch_emp : bi_schema
| bi_sch_pure : Prop → bi_schema
| bi_sch_and : bi_schema → bi_schema → bi_schema
| bi_sch_or : bi_schema → bi_schema → bi_schema
| bi_sch_forall : ∀ A, (A → bi_schema) → bi_schema
| bi_sch_exist : ∀ A, (A → bi_schema) → bi_schema
| bi_sch_sep : bi_schema → bi_schema → bi_schema
| bi_sch_wand : bi_schema → bi_schema → bi_schema
| bi_sch_persistently : bi_schema → bi_schema
| bi_sch_later : bi_schema → bi_schema
| bi_sch_bupd : bi_schema → bi_schema

| bi_sch_var_fixed : nat → bi_schema
| bi_sch_var_mut : nat → bi_schema
| bi_sch_wsat : bi_schema
| bi_sch_ownE : (nat → coPset) → bi_schema.

Canonical Structure bi_schemaO := leibnizO bi_schema.

Record invariant_level_names := { invariant_name : gname; }.

Global Instance invariant_level_names_eq_dec : EqDecision (invariant_level_names).
Admitted.
  Class invGpreS (Σ : gFunctors) : Set := WsatPreG {
    #[global] inv_inPreG :: inG Σ (authR (gmapUR positive
                                    (prodR (agreeR (prodO (listO (laterO (iPropO Σ))) bi_schemaO))
                                           (optionR (prodR fracR (agreeR (listO (laterO (iPropO Σ)))))))));
    #[global] enabled_inPreG :: inG Σ coPset_disjR;
    #[global] disabled_inPreG :: inG Σ (gset_disjR positive);
    #[global] mlist_inPreG :: fmlistG (invariant_level_names) Σ;
    inv_lcPreG : lcGpreS Σ;
  }.

  Class invGS (Σ : gFunctors) : Set := WsatG {
    #[global] inv_inG :: invGpreS Σ;
    #[global] invGS_lc :: lcGS Σ;
    inv_list_name : gname;
    enabled_name : gname;
    disabled_name : gname;
  }.

Definition invariant_unfold {Σ} {n} sch (Ps : vec (iProp Σ) n) : agree (list (later (iPropO Σ)) * bi_schema) :=
  to_agree ((λ P, Next P) <$> (vec_to_list Ps), sch).
Definition inv_mut_unfold {Σ} {n} q (Ps : vec (iProp Σ) n) : option (frac * (agree (list (later (iPropO Σ))))) :=
  Some (q%Qp, to_agree ((λ P, Next P) <$> (vec_to_list Ps))).
Definition ownI `{!invGS Σ} {n} (lvl: nat) (i : positive) (sch: bi_schema) (Ps : vec (iProp Σ) n) : iProp Σ :=
  (∃ γs, fmlist_idx inv_list_name lvl γs ∗
         own (invariant_name γs) (◯ {[ i := (invariant_unfold sch Ps, ε) ]})).

Definition ownI_mut `{!invGS Σ} {n} (lvl: nat) (i : positive) q (Qs : vec (iProp Σ) n) : iProp Σ :=
  (∃ (l: agree (list (later (iPropO Σ)) * bi_schema)) γs, fmlist_idx inv_list_name lvl γs ∗
         own (invariant_name γs) (◯ {[ i := (l, inv_mut_unfold q Qs) ]})).
Definition ownE `{!invGS Σ} (E : coPset) : iProp Σ.
Admitted.
Definition ownD `{!invGS Σ} (E : gset positive) : iProp Σ.
Admitted.

Definition inv_cmra_fmap `{!invGS Σ} (v: (list (iProp Σ) * bi_schema) * list (iProp Σ)) :=
  let '((Ps, sch), Qs) := v in
  (invariant_unfold sch (list_to_vec Ps), inv_mut_unfold 1%Qp (list_to_vec Qs)).

Fixpoint bi_schema_pre `{!invGS Σ} n (Ps Ps_mut: list (iProp Σ)) wsat (sch: bi_schema) :=
  match sch with
  | bi_sch_emp => emp
  | bi_sch_pure φ => ⌜φ⌝
  | bi_sch_and sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 ∧ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_or sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 ∨ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_forall A sch => ∀ (a: A),  bi_schema_pre n Ps Ps_mut wsat (sch a)
  | bi_sch_exist A sch => ∃ (a: A),  bi_schema_pre n Ps Ps_mut wsat (sch a)
  | bi_sch_sep sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 ∗ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_wand sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 -∗ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_persistently sch => <pers> bi_schema_pre n Ps Ps_mut wsat sch
  | bi_sch_later sch => ▷ bi_schema_pre n Ps Ps_mut wsat sch
  | bi_sch_bupd sch => |==> bi_schema_pre n Ps Ps_mut wsat sch
  | bi_sch_var_fixed i =>
    match (Ps !! i) with
    | None => emp
    | Some P => P
    end
  | bi_sch_var_mut i =>
    match (Ps_mut !! i) with
    | None => emp
    | Some P => P
    end
  | bi_sch_wsat => wsat
  | bi_sch_ownE E => ownE (E n)
  end%I.

Definition wsat_pre `{!invGS Σ} n bi_schema_interp :=
  (∃ I : gmap positive ((list (iProp Σ) * bi_schema) * list (iProp Σ)),
        (∃ γs, fmlist_idx inv_list_name n γs ∗
             own (invariant_name γs) (● (inv_cmra_fmap <$> I : gmap _ _))) ∗
        [∗ map] i ↦ Qs ∈ I, (bi_schema_interp (bi_later <$> Qs.1.1) (bi_later <$> Qs.2) Qs.1.2 ∗
                             ownI_mut n i (1/2)%Qp (list_to_vec Qs.2) ∗
                             ownD {[i]}) ∨
                            ownE {[i]})%I.

Fixpoint bi_schema_interp `{!invGS Σ} n (Ps Ps_mut: list (iProp Σ)) sch {struct n} :=
  match n with
  | O => bi_schema_pre O Ps Ps_mut True%I sch
  | S n' => bi_schema_pre (S n') Ps Ps_mut (wsat_pre n' (bi_schema_interp n') ∗ wsat n')%I sch
  end
  with
  wsat `{!invGS Σ} n :=
  match n with
    | S n =>
  (∃ I : gmap positive ((list (iProp Σ) * bi_schema) * list (iProp Σ)),
        (∃ γs, fmlist_idx inv_list_name n γs ∗
             own (invariant_name γs) (● (inv_cmra_fmap <$> I : gmap _ _))) ∗
        [∗ map] i ↦ Qs ∈ I, (bi_schema_interp n (bi_later <$> Qs.1.1) (bi_later <$> Qs.2) Qs.1.2 ∗
                             ownI_mut n i (1/2)%Qp (list_to_vec Qs.2) ∗
                             ownD {[i]}) ∨
                            ownE {[i]})
    ∗ wsat n
    | O => True
  end%I.

Section wsat.
Context `{!invGS Σ}.

Lemma ownI_alloc {n m} φ sch lvl (Ps: vec _ n) (Ps_mut: vec _ m):
  (∀ E : gset positive, ∃ i, i ∉ E ∧ φ i) →
  wsat (S lvl) ∗
  bi_schema_interp lvl (bi_later <$> (vec_to_list Ps)) (bi_later <$> (vec_to_list Ps_mut)) sch ==∗
  ∃ i, ⌜φ i⌝ ∗ wsat (S lvl) ∗ ownI lvl i sch Ps ∗ ownI_mut lvl i (1/2)%Qp Ps_mut.
Admitted.

End wsat.

Section schema_test_mut.
Context `{!invGS Σ}.
Definition bi_sch_bupd_factory (Q P: bi_schema) : bi_schema.
Admitted.

Definition ownI_full_bupd_factory lvl i q Q P :=
  (∃ n (Qs: vec _ n), ownI lvl i (bi_sch_bupd_factory (bi_sch_var_mut O) (bi_sch_var_fixed O)) (list_to_vec [P]) ∗
   ownI_mut lvl i q Qs ∗ ⌜ default True%I (vec_to_list Qs !! 0) = Q ⌝)%I.

Lemma ownI_bupd_factory_alloc lvl φ Q P :
  (∀ E : gset positive, ∃ i, i ∉ E ∧ φ i) →
  wsat (S lvl) ∗ (▷ Q ∗ □ (▷ Q ==∗ ▷ Q ∗ ▷ P))
       ==∗ ∃ i, ⌜φ i⌝ ∗ wsat (S lvl) ∗ ownI_full_bupd_factory lvl i (1/2)%Qp Q P.
Proof.
  iIntros (?) "(Hw&(HQ&#Hfactory))".
iMod (ownI_alloc with "[$Hw HQ]") as (i) "(?&?&?&?)"; eauto; last first.
  {
 iModIntro.
iExists i.
iFrame.
instantiate (1:= list_to_vec [Q]).
rewrite //=.
}
  repeat (rewrite ?bi_schema_interp_unfold //=).
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted) (truncated to 6.0KiB; full 136KiB file on GitHub Actions Artifacts under tmp.v)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-w" "-ssr-search-moved" "-w" "+deprecated-instance-without-locality" "-w" "+ambiguous-paths" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-deprecated-field-instance-without-locality" "-w" "+deprecated-tactic-notation" "-w" "-deprecated-since-8.19" "-w" "-deprecated-since-8.20" "-w" "-deprecated-from-Coq" "-w" "-deprecated-dirpath-Coq" "-w" "-notation-incompatible-prefix" "-w" "-deprecated-typeclasses-transparency-without-locality" "-w" "-notation-overridden,-redundant-canonical-projection,-unknown-warning,-argument-scope-delimiter" "-w" "-deprecated-native-compiler-option,-native-compiler-disabled" "-native-compiler" "ondemand" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/src" "Perennial" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp" "stdpp" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_unstable" "stdpp.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_bitvector" "stdpp.bitvector" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris" "iris" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_deprecated" "iris.deprecated" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_unstable" "iris.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_heap_lang" "iris.heap_lang" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coqutil/src/coqutil" "coqutil" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/Goose" "Goose" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/record-update/src" "RecordUpdate" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coq-tactical/src" "Tactical" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris-named-props/src" "iris_named_props" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_trusted_code" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_code_axioms" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_partial_axioms" "New.code_axioms" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new" "New" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-top" "Top.bug_01") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 1066 lines to 167 lines, then from 180 lines to 368 lines, then from 373 lines to 168 lines, then from 181 lines to 855 lines, then from 857 lines to 177 lines, then from 190 lines to 549 lines, then from 554 lines to 194 lines, then from 207 lines to 743 lines, then from 748 lines to 248 lines, then from 261 lines to 446 lines, then from 451 lines to 249 lines, then from 262 lines to 842 lines, then from 847 lines to 260 lines, then from 273 lines to 624 lines, then from 624 lines to 278 lines, then from 291 lines to 478 lines, then from 483 lines to 279 lines, then from 292 lines to 558 lines, then from 563 lines to 279 lines, then from 292 lines to 689 lines, then from 694 lines to 309 lines, then from 322 lines to 1312 lines, then from 1316 lines to 426 lines, then from 439 lines to 919 lines, then from 924 lines to 474 lines, then from 487 lines to 1254 lines, then from 1259 lines to 659 lines, then from 660 lines to 533 lines, then from 546 lines to 841 lines, then from 846 lines to 542 lines, then from 555 lines to 674 lines, then from 679 lines to 553 lines, then from 566 lines to 969 lines, then from 974 lines to 588 lines, then from 601 lines to 766 lines, then from 771 lines to 587 lines, then from 600 lines to 772 lines, then from 777 lines to 589 lines, then from 602 lines to 962 lines, then from 967 lines to 603 lines, then from 616 lines to 1930 lines, then from 1935 lines to 642 lines, then from 655 lines to 2993 lines, then from 2998 lines to 1687 lines, then from 1700 lines to 3137 lines, then from 3142 lines to 2116 lines, then from 2113 lines to 2095 lines, then from 2108 lines to 2312 lines, then from 2317 lines to 2128 lines, then from 2141 lines to 3107 lines, then from 3112 lines to 2290 lines, then from 2303 lines to 2595 lines, then from 2600 lines to 2456 lines, then from 2469 lines to 2615 lines, then from 2620 lines to 2482 lines, then from 2495 lines to 2697 lines, then from 2702 lines to 2566 lines, then from 2579 lines to 2772 lines, then from 2777 lines to 2812 lines, then from 2813 lines to 2659 lines, then from 2672 lines to 2841 lines, then from 2846 lines to 2719 lines, then from 2732 lines to 2821 lines, then from 2826 lines to 2723 lines, then from 2736 lines to 3351 lines, then from 3356 lines to 3168 lines, then from 3151 lines to 2792 lines, then from 2805 lines to 3604 lines, then from 3608 lines to 3348 lines, then from 3321 lines to 2867 lines, then from 2880 lines to 3175 lines, then from 3180 lines to 2909 lines, then from 2922 lines to 3120 lines, then from 3125 lines to 2914 lines, then from 2927 lines to 3193 lines, then from 3198 lines to 2974 lines, then from 2987 lines to 3042 lines, then from 3047 lines to 3001 lines, then from 3011 lines to 2993 lines, then from 3006 lines to 3655 lines, then from 3660 lines to 2996 lines, then from 3009 lines to 3093 lines, then from 3099 lines to 3005 lines, then from 3019 lines to 3684 lines, then from 3690 lines to 3015 lines, then from 3029 lines to 3058 lines, then from 3064 lines to 3021 lines, then from 3035 lines to 3069 lines, then from 3075 lines to 3028 lines, then from 3042 lines to 3070 lines, then from 3076 lines to 3073 lines, then from 3075 lines to 3036 lines, then from 3049 lines to 3118 lines, then from 3124 lines to 3057 lines, then from 3071 lines to 3261 lines, then from 3267 lines to 3065 lines, then from 3079 lines to 3341 lines, then from 3347 lines to 3122 lines, then from 3136 lines to 3421 lines,
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 3.9MiB file on GitHub Actions Artifacts under build.log)
da/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ CI_INSTALL_DIR=/github/workspace/builds/coq/coq-failing/_install_ci
++ export CI_BRANCH=
++ CI_BRANCH=
++ [[ '' =~ ^[0-9]*$ ]]
++ export CI_PULL_REQUEST=
++ CI_PULL_REQUEST=
++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.1+flambda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.1+flambda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ ls -l /github/workspace/builds/coq/coq-failing/_install_ci/bin/
total 557760
-rwxr-xr-x 1 root root     2393 Nov 15 15:38 coq-tex
-rwxr-xr-x 1 root root  2741424 Nov 15 15:38 coq-tex.orig
-rwxr-xr-x 1 root root  6566064 Nov  9 11:03 coq_makefile
-rwxr-xr-x 1 root root     2390 Nov 15 15:38 coqc
-rwxr-xr-x 1 root root     2395 Nov 15 15:38 coqc.byte
-rwxr-xr-x 1 root root 44090557 Nov 15 15:38 coqc.byte.orig
-rwxr-xr-x 1 root root 73356776 Nov 15 15:38 coqc.orig
-rwxr-xr-x 1 root root 22433128 Nov  9 11:03 coqchk
-rwxr-xr-x 1 root root  7234144 Nov  9 11:03 coqdep
-rwxr-xr-x 1 root root     2392 Nov 15 15:38 coqdoc
-rwxr-xr-x 1 root root  7006456 Nov 15 15:38 coqdoc.orig
-rwxr-xr-x 1 root root     2392 Nov 15 15:38 coqide
-rwxr-xr-x 1 root root 19186344 Nov 15 15:38 coqide.orig
-rwxr-xr-x 1 root root     2400 Nov 15 15:38 coqidetop.byte
-rwxr-xr-x 1 root root 44654513 Nov 15 15:38 coqidetop.byte.orig
-rwxr-xr-x 1 root root     2399 Nov 15 15:38 coqidetop.opt
-rwxr-xr-x 1 root root 74288208 Nov 15 15:38 coqidetop.opt.orig
-rwxr-xr-x 1 root root     2395 Nov 15 15:38 coqnative
-rwxr-xr-x 1 root root 22349952 Nov 15 15:38 coqnative.orig
-rwxr-xr-x 1 root root     2391 Nov 15 15:38 coqpp
-rwxr-xr-x 1 root root  3501504 Nov 15 15:38 coqpp.orig
-rwxr-xr-x 1 root root     2401 Nov 15 15:38 coqtimelog2html
-rwxr-xr-x 1 root root  4591944 Nov 15 15:38 coqtimelog2html.orig
-rwxr-xr-x 1 root root     2392 Nov 15 15:38 coqtop
-rwxr-xr-x 1 root root     2397 Nov 15 15:38 coqtop.byte
-rwxr-xr-x 1 root root 69507600 Nov 15 15:38 coqtop.byte.orig
-rwxr-xr-x 1 root root 73585464 Nov 15 15:38 coqtop.orig
-rwxr-xr-x 1 root root     2391 Nov 15 15:38 coqwc
-rwxr-xr-x 1 root root  2325600 Nov 15 15:38 coqwc.orig
-rwxr-xr-x 1 root root     2399 Nov 15 15:38 coqworker.opt
-rwxr-xr-x 1 root root 73577920 Nov 15 15:38 coqworker.opt.orig
-rwxr-xr-x 1 root root     2396 Nov 15 15:38 coqworkmgr
-rwxr-xr-x 1 root root  3401152 Nov 15 15:38 coqworkmgr.orig
-rwxr-xr-x 1 root root     2394 Nov 15 15:38 csdpcert
-rwxr-xr-x 1 root root  5999128 Nov 15 15:38 csdpcert.orig
-rwxr-xr-x 1 root root     2397 Nov 15 15:38 ocamllibdep
-rwxr-xr-x 1 root root  3489704 Nov 15 15:38 ocamllibdep.orig
-rwxr-xr-x 1 root root     2392 Nov 15 15:38 votour
-rwxr-xr-x 1 root root  7142888 Nov 15 15:38 votour.orig
++ CI_BUILD_DIR=/github/workspace/builds/coq/coq-failing/_build_ci
++ ls -l /github/workspace/builds/coq/coq-failing/_build_ci
total 4
drwxr-xr-x 10 root root 4096 Nov  9 11:13 perennial
++ declare -A overlays
++ set +x
+ WITH_SUBMODULES=1
+ git_download perennial
+ local project=perennial
+ local dest=/github/workspace/builds/coq/coq-failing/_build_ci/perennial
+ local giturl_var=perennial_CI_GITURL
+ local giturl=https://github.com/mit-pdos/perennial
+ local ref_var=perennial_CI_REF
+ local ref=coq/tested
+ local parent_project_var=perennial_CI_PARENT_PROJECT
+ local parent_project=
+ local submodule_folder_var=perennial_CI_SUBMODULE_FOLDER
+ local submodule_folder=
+ local ov_url=
+ local ov_ref=
++ dirname /github/workspace/builds/coq/coq-failing/_build_ci/perennial
+ local dest_prefix=/github/workspace/builds/coq/coq-failing/_build_ci/
+ '[' '' = '' ']'
+ local parent_project_dest=/github/workspace/builds/coq/coq-failing/_build_ci/
+ local parent_project_relative_dest=
+ '[' -d /github/workspace/builds/coq/coq-failing/_build_ci/perennial ']'
+ echo 'Warning: download and unpacking of perennial skipped because /github/workspace/builds/coq/coq-failing/_build_ci/perennial already exists.'
Warning: download and unpacking of perennial skipped because /github/workspace/builds/coq/coq-failing/_build_ci/perennial already exists.
+ '[' '' ']'
+ ulimit -s
16384
+ ulimit -s 65536
+ ulimit -s
65536
+ cd /github/workspace/builds/coq/coq-failing/_build_ci/perennial
+ make TIMED=false lite
+ '[' -z x ']'
+ command make TIMED=false lite
make[1]: Entering directory '/github/workspace/builds/coq/coq-failing/_build_ci/perennial'
COQC src/base_logic/lib/wsat.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/perennial
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/src Perennial -w -ssr-search-moved -w +deprecated-instance-without-locality -w +ambiguous-paths -w +deprecated-hint-rewrite-without-locality -w -deprecated-field-instance-without-locality -w +deprecated-tactic-notation -w -deprecated-since-8.19 -w -deprecated-since-8.20 -w -deprecated-from-Coq -w -deprecated-dirpath-Coq -w -notation-incompatible-prefix -w -deprecated-typeclasses-transparency-without-locality -w -notation-overridden\,-redundant-canonical-projection\,-unknown-warning\,-argument-scope-delimiter -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp stdpp -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_unstable stdpp.unstable -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_bitvector stdpp.bitvector -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris iris -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_deprecated iris.deprecated -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_unstable iris.unstable -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_heap_lang iris.heap_lang -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coqutil/src/coqutil coqutil -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/Goose Goose -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/record-update/src RecordUpdate -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coq-tactical/src Tactical -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris-named-props/src iris_named_props -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_trusted_code New.code -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_code_axioms New.code -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_partial_axioms New.code_axioms -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/new New -o /github/workspace/builds/coq/coq-failing/_build_ci/perennial/src/base_logic/lib/wsat.vo src/base_logic/lib/wsat.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.2XXzo37aW2
MINIMIZER_DEBUG: files:  src/base_logic/lib/wsat.v /github/workspace/builds/coq/coq-failing/_build_ci/perennial/src/base_logic/lib/wsat.v
File "./src/base_logic/lib/wsat.v", line 966, characters 82-83:
Error: This proof is focused, but cannot be unfocused this way

make[1]: *** [Makefile:59: src/base_logic/lib/wsat.vo] Error 1
make[1]: Leaving directory '/github/workspace/builds/coq/coq-failing/_build_ci/perennial'
+ code=2
+ printf '\n%s exit code: %s\n' perennial 2
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real perennial.log
No timing data
+ '[' '' ']'
+ exit 2
make: *** [Makefile.ci:192: ci-perennial] Error 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 2.7MiB file on GitHub Actions Artifacts under bug.log)
he error.  
The new error was:
File "/tmp/tmp4q5juhhl/Top/bug_01.v", line 41, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmp4q5juhhl/Top/bug_01.v", line 409, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp4q5juhhl/Top/bug_01.v", line 2604, characters 17-21:
Error: The reference ITrm was not found in the current environment.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to admit [abstract ...]s
�[92m
Admitting [abstract ...] successful.�[0m
�[92m
Admitting [abstract ...] successful.�[0m
Admitting [abstract ...] unsuccessful.
Admitting [abstract ...] unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
File "/tmp/tmpr6ov8k8f/Top/bug_01.v", line 41, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmpr6ov8k8f/Top/bug_01.v", line 241, characters 0-1181:
Error: UNDEFINED EVARS:
 ?X198==[FinMap K M H H0 H1 H2 H3 H4 H5 EqDecision0 map_eq lookup_empty
          lookup_partial_alter lookup_partial_alter_ne lookup_fmap
          lookup_omap lookup_merge map_fold_empty A P i x m A' B f g b x' |-
          Insert K A' (M A')] (parameter Insert of insert) {?Insert}
 ?X219==[FinMap K M H H0 H1 H2 H3 H4 H5 EqDecision0 map_eq lookup_empty
          lookup_partial_alter lookup_partial_alter_ne lookup_fmap
          lookup_omap lookup_merge map_fold_empty A P i x m |-
          Insert K
            ?A@{FinMap:=FinMap; K:=K; M:=M; H:=H; H0:=H0; H1:=H1; H2:=H2;
                H3:=H3; H4:=H4; H5:=H5; EqDecision0:=EqDecision0}
            (M A)]
          (parameter Insert of insert) {?Insert0}
TYPECLASSES:?X198 ?X219
SHELF:
FUTURE GOALS STACK:?X220 ?X219 ?X198



�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmp4q5juhhl/Top/bug_01.v", line 41, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmp4q5juhhl/Top/bug_01.v", line 409, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp4q5juhhl/Top/bug_01.v", line 2604, characters 17-21:
Error: The reference ITrm was not found in the current environment.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted

Non-fatal error: Failed to admit lemmas and preserve the error.  
The new error was:
File "/tmp/tmp0dpblime/Top/bug_01.v", line 41, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmp0dpblime/Top/bug_01.v", line 420, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
Error: The section schema_test_mut, module intro_pat, module sel_pat, module
spec_pat, module base, module Ltac2, module algebra, module iris and module
iris_DOT_algebra_DOT_coPset_WRAPPED need to be closed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmpxsjcx9w6/Top/bug_01.v", line 41, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmpxsjcx9w6/Top/bug_01.v", line 398, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpxsjcx9w6/Top/bug_01.v", line 547, characters 0-9:
Error:
New coercion path [bi_ofeO; ofe_car] : bi >-> Sortclass is ambiguous with existing 
[bi_car] : bi >-> Sortclass (reversible). [ambiguous-paths,coercions,default]


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions successful
Success!

I will now attempt to admit lemmas with admit. Defined

Non-fatal error: Failed to admit lemmas and preserve the error.  
The new error was:
File "/tmp/tmpvf7wnkwd/Top/bug_01.v", line 41, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmpvf7wnkwd/Top/bug_01.v", line 400, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
Error: The section schema_test_mut, module intro_pat, module sel_pat, module
spec_pat, module base, module Ltac2, module algebra, module iris and module
iris_DOT_algebra_DOT_coPset_WRAPPED need to be closed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmp_h64vcrk/Top/bug_01.v", line 41, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmp_h64vcrk/Top/bug_01.v", line 400, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmp_h64vcrk/Top/bug_01.v", line 550, characters 0-8:
Error:
New coercion path [bi_ofeO; ofe_car] : bi >-> Sortclass is ambiguous with existing 
[bi_car] : bi >-> Sortclass (reversible). [ambiguous-paths,coercions,default]


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation successful

I will now attempt to split imports and exports
Import/Export splitting unsuccessful.

I will now attempt to split := definitions

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

cc @JasonGross

@JasonGross
Copy link
Member

The error in the hott example looks like there is a repeat split at the end where some split succeeds while leaving out some unification constraints. Rocq fails to solve them outside of the repeat, so the error is not caught and the whole line fails.

@Tragicus could you minimize this to a smaller example that displays the change in behavior? I presume that the issue is something like that we have Class Foo := bar : forall x y, baz = qux and split on a goal of type Foo would previously fail, resulting in typeclass resolution picking up the goal, whereas now split tries to apply eq_refl which succeeds but leaves over unsolved constraints?

Plausibly tactics that have both an e variant and a non-e variant (split vs esplit, apply vs eapply) should call solve_unification_constraints on the non-e variant? I think this might lead to more predictable behavior overall, though I'm not sure.

Copy link
Contributor
coqbot-app bot commented Nov 16, 2024
Minimization interrupted by timeout, being automatically continued. Partially Minimized File /home/runner/work/run-coq-bug-minimizer/run-coq-bug-minimizer/builds/coq/coq-failing/_build_ci/perennial/src/base_logic/lib/wsat.v (from ci-perennial) (interrupted by timeout, being automatically continued) (full log on GitHub Actions - verbose log)
⭐ ⏱️ Partially Minimized Coq File (timeout) (truncated to first and last 32KiB; full 147KiB file on GitHub Actions Artifacts under bug.v)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-w" "-ssr-search-moved" "-w" "+deprecated-instance-without-locality" "-w" "+ambiguous-paths" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-deprecated-field-instance-without-locality" "-w" "+deprecated-tactic-notation" "-w" "-deprecated-since-8.19" "-w" "-deprecated-since-8.20" "-w" "-deprecated-from-Coq" "-w" "-deprecated-dirpath-Coq" "-w" "-notation-incompatible-prefix" "-w" "-deprecated-typeclasses-transparency-without-locality" "-w" "-notation-overridden,-redundant-canonical-projection,-unknown-warning,-argument-scope-delimiter" "-w" "-deprecated-native-compiler-option,-native-compiler-disabled" "-native-compiler" "ondemand" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/src" "Perennial" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp" "stdpp" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_unstable" "stdpp.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_bitvector" "stdpp.bitvector" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris" "iris" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_deprecated" "iris.deprecated" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_unstable" "iris.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_heap_lang" "iris.heap_lang" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coqutil/src/coqutil" "coqutil" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/Goose" "Goose" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/record-update/src" "RecordUpdate" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coq-tactical/src" "Tactical" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris-named-props/src" "iris_named_props" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_trusted_code" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_code_axioms" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_partial_axioms" "New.code_axioms" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new" "New" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-top" "Top.bug_01") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 1066 lines to 167 lines, then from 180 lines to 368 lines, then from 373 lines to 168 lines, then from 181 lines to 855 lines, then from 857 lines to 177 lines, then from 190 lines to 549 lines, then from 554 lines to 194 lines, then from 207 lines to 743 lines, then from 748 lines to 248 lines, then from 261 lines to 446 lines, then from 451 lines to 249 lines, then from 262 lines to 842 lines, then from 847 lines to 260 lines, then from 273 lines to 624 lines, then from 624 lines to 278 lines, then from 291 lines to 478 lines, then from 483 lines to 279 lines, then from 292 lines to 558 lines, then from 563 lines to 279 lines, then from 292 lines to 689 lines, then from 694 lines to 309 lines, then from 322 lines to 1312 lines, then from 1316 lines to 426 lines, then from 439 lines to 919 lines, then from 924 lines to 474 lines, then from 487 lines to 1254 lines, then from 1259 lines to 659 lines, then from 660 lines to 533 lines, then from 546 lines to 841 lines, then from 846 lines to 542 lines, then from 555 lines to 674 lines, then from 679 lines to 553 lines, then from 566 lines to 969 lines, then from 974 lines to 588 lines, then from 601 lines to 766 lines, then from 771 lines to 587 lines, then from 600 lines to 772 lines, then from 777 lines to 589 lines, then from 602 lines to 962 lines, then from 967 lines to 603 lines, then from 616 lines to 1930 lines, then from 1935 lines to 642 lines, then from 655 lines to 2993 lines, then from 2998 lines to 1687 lines, then from 1700 lines to 3137 lines, then from 3142 lines to 2116 lines, then from 2113 lines to 2095 lines, then from 2108 lines to 2312 lines, then from 2317 lines to 2128 lines, then from 2141 lines to 3107 lines, then from 3112 lines to 2290 lines, then from 2303 lines to 2595 lines, then from 2600 lines to 2456 lines, then from 2469 lines to 2615 lines, then from 2620 lines to 2482 lines, then from 2495 lines to 2697 lines, then from 2702 lines to 2566 lines, then from 2579 lines to 2772 lines, then from 2777 lines to 2812 lines, then from 2813 lines to 2659 lines, then from 2672 lines to 2841 lines, then from 2846 lines to 2719 lines, then from 2732 lines to 2821 lines, then from 2826 lines to 2723 lines, then from 2736 lines to 3351 lines, then from 3356 lines to 3168 lines, then from 3151 lines to 2792 lines, then from 2805 lines to 3604 lines, then from 3608 lines to 3348 lines, then from 3321 lines to 2867 lines, then from 2880 lines to 3175 lines, then from 3180 lines to 2909 lines, then from 2922 lines to 3120 lines, then from 3125 lines to 2914 lines, then from 2927 lines to 3193 lines, then from 3198 lines to 2974 lines, then from 2987 lines to 3042 lines, then from 3047 lines to 3001 lines, then from 3011 lines to 2993 lines, then from 3006 lines to 3655 lines, then from 3660 lines to 2996 lines, then from 3009 lines to 3093 lines, then from 3099 lines to 3005 lines, then from 3019 lines to 3684 lines, then from 3690 lines to 3015 lines, then from 3029 lines to 3058 lines, then from 3064 lines to 3021 lines, then from 3035 lines to 3069 lines, then from 3075 lines to 3028 lines, then from 3042 lines to 3070 lines, then from 3076 lines to 3073 lines, then from 3075 lines to 3036 lines, then from 3049 lines to 3118 lines, then from 3124 lines to 3057 lines, then from 3071 lines to 3261 lines, then from 3267 lines to 3065 lines, then from 3079 lines to 3341 lines, then from 3347 lines to 3122 lines, then from 3136 lines to 3421 lines, then from 3427 lines to 3131 lines, then from 3145 lines to 3388 lines, then from 3394 lines to 3312 lines, then from 3313 lines to 3135 lines, then from 3148 lines to 3251 lines, then from 3257 lines to 3136 lines, then from 3150 lines to 3895 lines, then from 3901 lines to 3154 lines, then from 3168 lines to 6507 lines, then from 6513 lines to 3196 lines, then from 3211 lines to 3158 lines, then from 3171 lines to 4044 lines, then from 4050 lines to 3196 lines, then from 3210 lines to 3543 lines, then from 3549 lines to 3216 lines, then from 3230 lines to 3505 lines, then from 3511 lines to 3468 lines, then from 3467 lines to 3228 lines, then from 3241 lines to 4292 lines, then from 4297 lines to 3239 lines, then from 3253 lines to 3809 lines, then from 3815 lines to 3240 lines, then from 3254 lines to 5079 lines, then from 5085 lines to 4133 lines, then from 4119 lines to 3252 lines, then from 3265 lines to 3373 lines, then from 3379 lines to 3255 lines, then from 3269 lines to 3465 lines, then from 3471 lines to 3293 lines, then from 3307 lines to 3880 lines, then from 3886 lines to 3482 lines, then from 3496 lines to 3703 lines, then from 3708 lines to 3526 lines, then from 3541 lines to 3522 lines, then from 3535 lines to 3730 lines, then from 3736 lines to 3550 lines, then from 3564 lines to 4093 lines, then from 4099 lines to 3561 lines, then from 3575 lines to 4478 lines, then from 4484 lines to 4162 lines, then from 4158 lines to 3594 lines, then from 3607 lines to 3799 lines, then from 3805 lines to 3614 lines, then from 3628 lines to 4139 lines, then from 4145 lines to 3615 lines, then from 3634 lines to 3613 lines, then from 3626 lines to 8522 lines, then from 8527 lines to 3653 lines, then from 3667 lines to 3914 lines, then from 3920 lines to 3871 lines, then from 3864 lines to 3690 lines, then from 3703 lines to 5752 lines, then from 5758 lines to 3949 lines, then from 3963 lines to 4076 lines, then from 4082 lines to 4065 lines *)
(* coqc version 9.0+alpha compiled with OCaml 4.14.1
   coqtop version runner-t7b1znuaq-project-4504-concurrent-0:/builds/coq/coq/_build/default,(HEAD detached at c04db99c8cfbe3) (c04db99c8cfbe3fa002bf604971eb5b0e09656d4)
   Modules that could not be inlined: Ltac2.Array, Ltac2.Pattern, Ltac2.Ltac1
   Expected coqc runtime on this file: 2.569 sec *)








Require Stdlib.Init.Ltac.
Require Stdlib.Bool.Bool.
Require Stdlib.Classes.Morphisms.
Require Stdlib.Classes.RelationClasses.
Require Stdlib.Init.Peano.
Require Stdlib.Lists.List.
Require Stdlib.Logic.EqdepFacts.
Require Stdlib.NArith.NArith.
Require Stdlib.PArith.PArith.
Require Stdlib.Program.Basics.
Require Stdlib.Program.Syntax.
Require Stdlib.QArith.QArith.
Require Stdlib.QArith.QArith_base.
Require Stdlib.QArith.Qcanon.
Require Stdlib.Setoids.Setoid.
Require Stdlib.Sorting.Permutation.
Require Stdlib.Unicode.Utf8.
Require Stdlib.Vectors.Vector.
Require Stdlib.ZArith.ZArith.
Require Stdlib.micromega.Lia.
Require Stdlib.ssr.ssreflect.
Require Stdlib.ssr.ssrfun.
Require stdpp.options.
Require iris.prelude.options.
Require stdpp.base.
Require stdpp.proof_irrel.
Require stdpp.well_founded.
Require stdpp.decidable.
Require stdpp.tactics.
Require stdpp.fin.
Require stdpp.option.
Require stdpp.orders.
Require stdpp.numbers.
Require stdpp.lexico.
Require stdpp.list.
Require stdpp.list_numbers.
Require stdpp.countable.
Require stdpp.vector.
Require stdpp.finite.
Require stdpp.sets.
Require stdpp.listset.
Require stdpp.relations.
Require stdpp.fin_sets.
Require stdpp.prelude.
Require stdpp.ssreflect.
Require iris.prelude.prelude.
Require iris.algebra.ofe.
Require Stdlib.Strings.String.
Require Ltac2.Init.
Require Ltac2.Std.
Require Ltac2.Message.
Require Ltac2.Control.
Require Ltac2.Ltac1.
Require Ltac2.Pattern.
Require Ltac2.Int.
Require Ltac2.Bool.
Require Ltac2.Array.

Module Export AdmitTactic.
Module Import LocalFalse.
Inductive False : Prop := .
End LocalFalse.
Axiom proof_admitted : False.
Import Coq.Init.Ltac.
Tactic Notation "admit" := abstract case proof_admitted.
End AdmitTactic.

Module Export iris_DOT_algebra_DOT_monoid_WRAPPED.
Module Export monoid.
Export iris.algebra.ofe.
Import iris.prelude.options.


Class Monoid {M : ofe} (o : M → M → M) := {
  monoid_unit : M;
  monoid_ne : NonExpansive2 o;
  monoid_assoc : Assoc (≡) o;
  monoid_comm : Comm (≡) o;
  monoid_left_id : LeftId (≡) monoid_unit o;
}.
Lemma monoid_proper {M : ofe} {o : M → M → M} `{!Monoid o} : Proper ((≡) ==> (≡) ==> (≡)) o.
Admitted.
Lemma monoid_right_id {M : ofe} {o : M → M → M} `{!Monoid o} : RightId (≡) monoid_unit o.
Admitted.


Class WeakMonoidHomomorphism {M1 M2 : ofe}
    (o1 : M1 → M1 → M1) (o2 : M2 → M2 → M2) `{!Monoid o1, !Monoid o2}
    (R : relation M2) (f : M1 → M2) := {
  monoid_homomorphism_rel_po : PreOrder R;
  monoid_homomorphism_rel_proper : Proper ((≡) ==> (≡) ==> iff) R;
  monoid_homomorphism_op_proper : Proper (R ==> R ==> R) o2;
  monoid_homomorphism_ne : NonExpansive f;
  monoid_homomorphism x y : R (f (o1 x y)) (o2 (f x) (f y))
}.

Class MonoidHomomorphism {M1 M2 : ofe}
    (o1 : M1 → M1 → M1) (o2 : M2 → M2 → M2) `{!Monoid o1, !Monoid o2}
    (R : relation M2) (f : M1 → M2) := {
  #[global] monoid_homomorphism_weak :: WeakMonoidHomomorphism o1 o2 R f;
  monoid_homomorphism_unit : R (f monoid_unit) monoid_unit
}.

Lemma weak_monoid_homomorphism_proper
  `{WeakMonoidHomomorphism M1 M2 o1 o2 R f} : Proper ((≡) ==> (≡)) f.
Admitted.

End monoid.

End iris_DOT_algebra_DOT_monoid_WRAPPED.
Module Export iris.
Module Export algebra.
Module Export monoid.
Include iris_DOT_algebra_DOT_monoid_WRAPPED.monoid.
End monoid.

Module Export iris_DOT_algebra_DOT_cmra_WRAPPED.
Module Export cmra.
Export iris.algebra.monoid.

Class PCore (A : Type) := pcore : A → option A.

Class Op (A : Type) := op : A → A → A.
Infix "⋅" := op (at level 50, left associativity) : stdpp_scope.
Notation "(⋅)" := op (only parsing) : stdpp_scope.

Definition included {A} `{!Equiv A, !Op A} (x y : A) := ∃ z, y ≡ x ⋅ z.
Infix "≼" := included (at level 70) : stdpp_scope.

Class ValidN (A : Type) := validN : nat → A → Prop.
Notation "✓{ n } x" := (validN n x)
  (at level 20, n at next level, format "✓{ n }  x").

Class Valid (A : Type) := valid : A → Prop.
Notation "✓ x" := (valid x) (at level 20) : stdpp_scope.

Definition includedN `{!Dist A, !Op A} (n : nat) (x y : A) := ∃ z, y ≡{n}≡ x ⋅ z.
Notation "x ≼{ n } y" := (includedN n x y)
  (at level 70, n at next level, format "x  ≼{ n }  y") : stdpp_scope.
Global Hint Extern 0 (_ ≼{_} _) => reflexivity : core.

Section mixin.
  Record CmraMixin A `{!Dist A, !Equiv A, !PCore A, !Op A, !Valid A, !ValidN A} := {

    mixin_cmra_op_ne (x : A) : NonExpansive (op x);
    mixin_cmra_pcore_ne n (x y : A) cx :
      x ≡{n}≡ y → pcore x = Some cx → ∃ cy, pcore y = Some cy ∧ cx ≡{n}≡ cy;
    mixin_cmra_validN_ne n : Proper (dist (A := A) n ==> impl) (validN n);

    mixin_cmra_valid_validN (x : A) : ✓ x ↔ ∀ n, ✓{n} x;
    mixin_cmra_validN_S n (x : A) : ✓{S n} x → ✓{n} x;

    mixin_cmra_assoc : Assoc (≡@{A}) (⋅);
    mixin_cmra_comm : Comm (≡@{A}) (⋅);
    mixin_cmra_pcore_l (x : A) cx : pcore x = Some cx → cx ⋅ x ≡ x;
    mixin_cmra_pcore_idemp (x : A) cx : pcore x = Some cx → pcore cx ≡ Some cx;
    mixin_cmra_pcore_mono (x y : A) cx :
      x ≼ y → pcore x = Some cx → ∃ cy, pcore y = Some cy ∧ cx ≼ cy;
    mixin_cmra_validN_op_l n (x y : A) : ✓{n} (x ⋅ y) → ✓{n} x;
    mixin_cmra_extend n (x y1 y2 : A) :
      ✓{n} x → x ≡{n}≡ y1 ⋅ y2 →
      { z1 : A & { z2 | x ≡ z1 ⋅ z2 ∧ z1 ≡{n}≡ y1 ∧ z2 ≡{n}≡ y2 } }
  }.
End mixin.

#[projections(primitive=no)]
Structure cmra := Cmra' {
  cmra_car :> Type;
  cmra_equiv : Equiv cmra_car;
  cmra_dist : Dist cmra_car;
  cmra_pcore : PCore cmra_car;
  cmra_op : Op cmra_car;
  cmra_valid : Valid cmra_car;
  cmra_validN : ValidN cmra_car;
  cmra_ofe_mixin : OfeMixin cmra_car;
  cmra_mixin : CmraMixin cmra_car;
}.
Global Arguments Cmra' _ {_ _ _ _ _ _} _ _.

Notation Cmra A m := (Cmra' A (ofe_mixin_of A%type) m) (only parsing).

Global Hint Extern 0 (PCore _) => refine (cmra_pcore _); shelve : typeclass_instances.
Global Hint Extern 0 (Op _) => refine (cmra_op _); shelve : typeclass_instances.
Global Hint Extern 0 (Valid _) => refine (cmra_valid _); shelve : typeclass_instances.
Global Hint Extern 0 (ValidN _) => refine (cmra_validN _); shelve : typeclass_instances.
Coercion cmra_ofeO (A : cmra) : ofe.
exact (Ofe A (cmra_ofe_mixin A)).
Defined.
Canonical Structure cmra_ofeO.
Definition cmra_mixin_of' A {Ac : cmra} (f : Ac → A) : CmraMixin Ac.
exact (cmra_mixin Ac).
Defined.
Notation cmra_mixin_of A :=
  ltac:(let H := eval hnf in (cmra_mixin_of' A id) in exact H) (only parsing).

Definition core {A} `{!PCore A} (x : A) : A.
Admitted.

Class Unit (A : Type) := ε : A.

Record UcmraMixin A `{!Dist A, !Equiv A, !PCore A, !Op A, !Valid A, !Unit A} := {
  mixin_ucmra_unit_valid : ✓ (ε : A);
  mixin_ucmra_unit_left_id : LeftId (≡@{A}) ε (⋅);
  mixin_ucmra_pcore_unit : pcore ε ≡@{option A} Some ε
}.

#[projections(primitive=no)]
Structure ucmra := Ucmra' {
  ucmra_car :> Type;
  ucmra_equiv : Equiv ucmra_car;
  ucmra_dist : Dist ucmra_car;
  ucmra_pcore : PCore ucmra_car;
  ucmra_op : Op ucmra_car;
  ucmra_valid : Valid ucmra_car;
  ucmra_validN : ValidN ucmra_car;
  ucmra_unit : Unit ucmra_car;
  ucmra_ofe_mixin : OfeMixin ucmra_car;
  ucmra_cmra_mixin : CmraMixin ucmra_car;
  ucmra_mixin : UcmraMixin ucmra_car;
}.
Global Arguments Ucmra' _ {_ _ _ _ _ _ _} _ _ _.
Notation Ucmra A m :=
  (Ucmra' A (ofe_mixin_of A%type) (cmra_mixin_of A%type) m) (only parsing).

Global Hint Extern 0 (Unit _) => refine (ucmra_unit _); shelve : typeclass_instances.
Coercion ucmra_ofeO (A : ucmra) : ofe.
exact (Ofe A (ucmra_ofe_mixin A)).
Defined.
Canonical Structure ucmra_ofeO.
Coercion ucmra_cmraR (A : ucmra) : cmra.
exact (Cmra' A (ucmra_ofe_mixin A) (ucmra_cmra_mixin A)).
Defined.
Canonical Structure ucmra_cmraR.

Class CmraMorphism {A B : cmra} (f : A → B) := {
  #[global] cmra_morphism_ne :: NonExpansive f;
  cmra_morphism_validN n x : ✓{n} x → ✓{n} f x;
  cmra_morphism_pcore x : f <$> pcore x ≡ pcore (f x);
  cmra_morphism_op x y : f (x ⋅ y) ≡ f x ⋅ f y
}.

Section cmra.
Context {A : cmra}.
Implicit Types x y z : A.

Section total_core.
  Global Instance cmra_includedN_preorder n : PreOrder (@includedN A _ _ n).
Admitted.
  Lemma cmra_core_monoN n x y : x ≼{n} y → core x ≼{n} core y.
Admitted.
End total_core.
End cmra.

Section ucmra.
  Context {A : ucmra}.

  Lemma ucmra_unit_validN n : ✓{n} (ε:A).
Admitted.
End ucmra.

Record rFunctor := RFunctor {
  rFunctor_car : ∀ A `{!Cofe A} B `{!Cofe B}, cmra;
  rFunctor_map `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} :
    ((A2 -n> A1) * (B1 -n> B2)) → rFunctor_car A1 B1 -n> rFunctor_car A2 B2;
  rFunctor_map_ne `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} :
    NonExpansive (@rFunctor_map A1 _ A2 _ B1 _ B2 _);
  rFunctor_map_id `{!Cofe A, !Cofe B} (x : rFunctor_car A B) :
    rFunctor_map (cid,cid) x ≡ x;
  rFunctor_map_compose `{!Cofe A1, !Cofe A2, !Cofe A3, !Cofe B1, !Cofe B2, !Cofe B3}
      (f : A2 -n> A1) (g : A3 -n> A2) (f' : B1 -n> B2) (g' : B2 -n> B3) x :
    rFunctor_map (f◎g, g'◎f') x ≡ rFunctor_map (g,g') (rFunctor_map (f,f') x);
  rFunctor_mor `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2}
      (fg : (A2 -n> A1) * (B1 -n> B2)) :
    CmraMorphism (rFunctor_map fg)
}.

Class rFunctorContractive (F : rFunctor) :=
  #[global] rFunctor_map_contractive `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} ::
    Contractive (@rFunctor_map F A1 _ A2 _ B1 _ B2 _).
Definition rFunctor_apply (F: rFunctor) (A: ofe) `{!Cofe A} : cmra.
Admitted.

Record urFunctor := URFunctor {
  urFunctor_car : ∀ A `{!Cofe A} B `{!Cofe B}, ucmra;
  urFunctor_map `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} :
    ((A2 -n> A1) * (B1 -n> B2)) → urFunctor_car A1 B1 -n> urFunctor_car A2 B2;
  urFunctor_map_ne `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} :
    NonExpansive (@urFunctor_map A1 _ A2 _ B1 _ B2 _);
  urFunctor_map_id `{!Cofe A, !Cofe B} (x : urFunctor_car A B) :
    urFunctor_map (cid,cid) x ≡ x;
  urFunctor_map_compose `{!Cofe A1, !Cofe A2, !Cofe A3, !Cofe B1, !Cofe B2, !Cofe B3}
      (f : A2 -n> A1) (g : A3 -n> A2) (f' : B1 -n> B2) (g' : B2 -n> B3) x :
    urFunctor_map (f◎g, g'◎f') x ≡ urFunctor_map (g,g') (urFunctor_map (f,f') x);
  urFunctor_mor `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2}
      (fg : (A2 -n> A1) * (B1 -n> B2)) :
    CmraMorphism (urFunctor_map fg)
}.

Record RAMixin A `{Equiv A, PCore A, Op A, Valid A} := {

  ra_op_proper (x : A) : Proper ((≡) ==> (≡)) (op x);
  ra_core_proper (x y : A) cx :
    x ≡ y → pcore x = Some cx → ∃ cy, pcore y = Some cy ∧ cx ≡ cy;
  ra_validN_proper : Proper ((≡@{A}) ==> impl) valid;

  ra_assoc : Assoc (≡@{A}) (⋅);
  ra_comm : Comm (≡@{A}) (⋅);
  ra_pcore_l (x : A) cx : pcore x = Some cx → cx ⋅ x ≡ x;
  ra_pcore_idemp (x : A) cx : pcore x = Some cx → pcore cx ≡ Some cx;
  ra_pcore_mono (x y : A) cx :
    x ≼ y → pcore x = Some cx → ∃ cy, pcore y = Some cy ∧ cx ≼ cy;
  ra_valid_op_l (x y : A) : ✓ (x ⋅ y) → ✓ x
}.

Section discrete.
  Context `{!Equiv A, !PCore A, !Op A, !Valid A} (Heq : @Equivalence A (≡)).
  Context (ra_mix : RAMixin A).
  Existing Instances discrete_dist.
Local Instance discrete_validN_instance : ValidN A.
Admitted.
  Definition discrete_cmra_mixin : CmraMixin A.
Admitted.
End discrete.

Notation discreteR A ra_mix :=
  (Cmra A (discrete_cmra_mixin (discrete_ofe_equivalence_of A%type) ra_mix))
  (only parsing).

Section prod.
  Context {A B : cmra}.
Local Instance prod_op_instance : Op (A * B).
Admitted.
Local Instance prod_pcore_instance : PCore (A * B).
Admitted.
Local Instance prod_valid_instance : Valid (A * B).
Admitted.
Local Instance prod_validN_instance : ValidN (A * B).
Admitted.

  Definition prod_cmra_mixin : CmraMixin (A * B).
Admitted.
  Canonical Structure prodR := Cmra (prod A B) prod_cmra_mixin.
End prod.

Global Arguments prodR : clear implicits.

Section option.
  Context {A : cmra}.
Local Instance option_valid_instance : Valid (option A).
Admitted.
Local Instance option_validN_instance : ValidN (option A).
Admitted.
Local Instance option_pcore_instance : PCore (option A).
Admitted.
Local Instance option_op_instance : Op (option A).
Admitted.

  Lemma option_cmra_mixin : CmraMixin (option A).
Admitted.
  Canonical Structure optionR := Cmra (option A) option_cmra_mixin.
Local Instance option_unit_instance : Unit (option A).
Admitted.
  Lemma option_ucmra_mixin : UcmraMixin optionR.
Admitted.
  Canonical Structure optionUR := Ucmra (option A) option_ucmra_mixin.
End option.

Global Arguments optionR : clear implicits.

End cmra.
Module Export iris.
Module Export algebra.
Module Export cmra.
Include iris_DOT_algebra_DOT_cmra_WRAPPED.cmra.
End cmra.
Import Stdlib.Strings.Ascii.

Export Stdlib.Strings.String (string(..)).

String Notation string
  String.string_of_list_byte String.list_byte_of_string : stdpp_scope.

Module Export Ascii.
Definition is_nat (x : ascii) : option nat.
exact (match x with
    | "0" => Some 0
    | "1" => Some 1
    | "2" => Some 2
    | "3" => Some 3
    | "4" => Some 4
    | "5" => Some 5
    | "6" => Some 6
    | "7" => Some 7
    | "8" => Some 8
    | "9" => Some 9
    | _ => None
    end%char).
Defined.
Definition is_space (x : ascii) : bool.
exact (match x with
    | "009" | "010" | "011" | "012" | "013" | " " => true | _ => false
    end%char).
Defined.

Module Export String.
Fixpoint rev_app (s1 s2 : string) : string.
exact (match s1 with
    | "" => s2
    | String a s1 => rev_app s1 (String a s2)
    end).
Defined.
Definition rev (s : string) : string.
exact (rev_app s "").
Defined.

Class MapFold K A M := map_fold B : (K → A → B → B) → B → M → B.
Global Arguments map_fold {_ _ _ _ _} _ _ _.
Definition diag_None {A B C} (f : option A → option B → option C)
    (mx : option A) (my : option B) : option C.
Admitted.
Global Instance map_insert `{PartialAlter K A M} : Insert K A M.
Admitted.

Class FinMap K M `{FMap M, ∀ A, Lookup K A (M A), ∀ A, Empty (M A), ∀ A,
    PartialAlter K A (M A), OMap M, Merge M, ∀ A, MapFold K A (M A),
    EqDecision K} := {
  map_eq {A} (m1 m2 : M A) : (∀ i, m1 !! i = m2 !! i) → m1 = m2;
  lookup_empty {A} i : (∅ : M A) !! i = None;
  lookup_partial_alter {A} f (m : M A) i :
    partial_alter f i m !! i = f (m !! i);
  lookup_partial_alter_ne {A} f (m : M A) i j :
    i ≠ j → partial_alter f i m !! j = m !! j;
  lookup_fmap {A B} (f : A → B) (m : M A) i : (f <$> m) !! i = f <$> m !! i;
  lookup_omap {A B} (f : A → option B) (m : M A) i :
    omap f m !! i = m !! i ≫= f;
  lookup_merge {A B C} (f : option A → option B → option C) (m1 : M A) (m2 : M B) i :
    merge f m1 m2 !! i = diag_None f (m1 !! i) (m2 !! i);
  map_fold_empty {A B} (f : K → A → B → B) (b : B) :
    map_fold f b ∅ = b;

  map_fold_fmap_ind {A} (P : M A → Prop) :
    P ∅ →
    (∀ i x m,
      m !! i = None →
      (∀ A' B (f : K → A' → B → B) (g : A → A') b x',
        map_fold f b (<[i:=x']> (g <$> m)) = f i x' (map_fold f b (g <$> m))) →
      P m →
      P (<[i:=x]> m)) →
    ∀ m, P m;
}.
Global Instance map_singleton `{PartialAlter K A M, Empty M} :
  SingletonM K A M.
Admitted.
Global Instance map_equiv `{∀ A, Lookup K A (M A), Equiv A} : Equiv (M A) | 20.
Admitted.

Export stdpp.countable.

Record mapset' (Munit : Type) : Type :=
  Mapset { mapset_car: Munit }.
Notation mapset M := (mapset' (M unit)).

Section mapset.
Context `{FinMap K M}.
Global Instance mapset_elem_of: ElemOf K (mapset M).
admit.
Defined.
Global Instance mapset_singleton: Singleton K (mapset M).
admit.
Defined.

End mapset.

Local Open Scope positive_scope.

Local Notation "P ~ 0" := (λ p, P p~0) : function_scope.
Local Notation "P ~ 1" := (λ p, P p~1) : function_scope.

Inductive gmap_dep_ne (A : Type) (P : positive → Prop) :=
  | GNode001 : gmap_dep_ne A P~1  → gmap_dep_ne A P
  | GNode010 : P 1 → A → gmap_dep_ne A P
  | GNode011 : P 1 → A → gmap_dep_ne A P~1 → gmap_dep_ne A P
  | GNode100 : gmap_dep_ne A P~0 → gmap_dep_ne A P
  | GNode101 : gmap_dep_ne A P~0 → gmap_dep_ne A P~1 → gmap_dep_ne A P
  | GNode110 : gmap_dep_ne A P~0 → P 1 → A → gmap_dep_ne A P
  | GNode111 : gmap_dep_ne A P~0 → P 1 → A → gmap_dep_ne A P~1 → gmap_dep_ne A P.

Variant gmap_dep (A : Type) (P : positive → Prop) :=
  | GEmpty : gmap_dep A P
  | GNodes : gmap_dep_ne A P → gmap_dep A P.

Record gmap_key K `{Countable K} (q : positive) :=
  GMapKey { _ : encode (A:=K) <$> decode q = Some q }.

Record gmap K `{Countable K} A := GMap { gmap_car : gmap_dep A (gmap_key K) }.
Global Instance gmap_lookup `{Countable K} {A} :
    Lookup K A (gmap K A).
Admitted.
Global Instance gmap_empty `{Countable K} {A} : Empty (gmap K A).
Admitted.
Global Instance gmap_partial_alter `{Countable K} {A} :
    PartialAlter K A (gmap K A).
Admitted.
Global Instance gmap_fmap `{Countable K} : FMap (gmap K).
Admitted.

Definition gset K `{Countable K} := mapset (gmap K).

Inductive coPset_raw :=
  | coPLeaf : bool → coPset_raw
  | coPNode : bool → coPset_raw → coPset_raw → coPset_raw.
Fixpoint coPset_wf (t : coPset_raw) : bool.
Admitted.

Definition coPset := { t | coPset_wf t }.
Global Instance coPset_singleton : Singleton positive coPset.
Admitted.

Module Export iris_DOT_algebra_DOT_coPset_WRAPPED.
Module Export coPset.
Export iris.algebra.cmra.

Inductive coPset_disj :=
  | CoPset : coPset → coPset_disj
  | CoPsetBot : coPset_disj.

Section coPset_disj.
  Canonical Structure coPset_disjO := leibnizO coPset_disj.
Local Instance coPset_disj_valid_instance : Valid coPset_disj.
Admitted.
Local Instance coPset_disj_op_instance : Op coPset_disj.
Admitted.
Local Instance coPset_disj_pcore_instance : PCore coPset_disj.
Admitted.

  Lemma coPset_disj_ra_mixin : RAMixin coPset_disj.
Admitted.
  Canonical Structure coPset_disjR := discreteR coPset_disj coPset_disj_ra_mixin.
End coPset_disj.

End coPset.
Module Export iris.
Module Export algebra.
Module Export coPset.
Include iris_DOT_algebra_DOT_coPset_WRAPPED.coPset.
End coPset.

Reserved Notation "P ⊢ Q" (at level 99, Q at level 200, right associativity).

Reserved Notation "P ⊣⊢ Q" (at level 95, no associativity).

Reserved Notation "⊢ Q" (at level 20, Q at level 200).
Reserved Notation "P ∗ Q" (at level 80, right associativity, format "P  ∗  '/' Q").
Reserved Notation "P -∗ Q"
  (at level 99, Q at level 200, right associativity,
   format "'[' P  -∗  '/' '[' Q ']' ']'").

Reserved Notation "'<pers>' P" (at level 20, right associativity).
Reserved Notation "'<pers>?' p P" (at level 20, p at level 9, P at level 20,
   right associativity, format "'<pers>?' p  P").

Reserved Notation "▷ P" (at level 20, right associativity).
Reserved Notation "▷^ n P" (at level 20, n at level 9, P at level 20,
   format "▷^ n  P").

Reserved Notation "'<affine>' P" (at level 20, right associativity).
Reserved Notation "'<affine>?' p P" (at level 20, p at level 9, P at level 20,
   right associativity, format "'<affine>?' p  P").

Reserved Notation "'<absorb>' P" (at level 20, right associativity).

Reserved Notation "□ P" (at level 20, right associativity).
Reserved Notation "'□?' p P" (at level 20, p at level 9, P at level 20,
   right associativity, format "'□?' p  P").

Reserved Notation "|==> Q" (at level 99, Q at level 200, format "'[  ' |==>  '/' Q ']'").
Reserved Notation "P ==∗ Q"
  (at level 99, Q at level 200, format "'[' P  ==∗  '/' Q ']'").

Reserved Notation "'[∗]' Ps" (at level 20).
Reserved Notation "'[∧' 'list]' x ∈ l , P"
  (at level 200, l at level 10, x binder, right associativity,
   format "[∧  list]  x  ∈  l ,  P").

Reserved Notation "'[∗' 'map]' k ↦ x ∈ m , P"
  (at level 200, m at level 10, k binder, x binder, right associativity,
   format "[∗  map]  k ↦ x  ∈  m ,  P").
Delimit Scope bi_scope with I.

Section bi_mixin.
  Context {PROP : Type} `{!Dist PROP, !Equiv PROP}.
  Context (bi_entails : PROP → PROP → Prop).
  Context (bi_emp : PROP).
  Context (bi_pure : Prop → PROP).
  Context (bi_and : PROP → PROP → PROP).
  Context (bi_or : PROP → PROP → PROP).
  Context (bi_impl : PROP → PROP → PROP).
  Context (bi_forall : ∀ A, (A → PROP) → PROP).
  Context (bi_exist : ∀ A, (A → PROP) → PROP).
  Context (bi_sep : PROP → PROP → PROP).
  Context (bi_wand : PROP → PROP → PROP).

  Bind Scope bi_scope with PROP.
  Local Infix "⊢" := bi_entails.
  Local Notation "'emp'" := bi_emp : bi_scope.
  Local Notation "'True'" := (bi_pure True) : bi_scope.
  Local Notation "'False'" := (bi_pure False) : bi_scope.
  Local Notation "'⌜' φ '⌝'" := (bi_pure φ%type%stdpp) : bi_scope.
  Local Infix "∧" := bi_and : bi_scope.
  Local Infix "∨" := bi_or : bi_scope.
  Local Infix "→" := bi_impl : bi_scope.
  Local Notation "∀ x .. y , P" :=
    (bi_forall _ (λ x, .. (bi_forall _ (λ y, P%I)) ..)) : bi_scope.
  Local Notation "∃ x .. y , P" :=
    (bi_exist _ (λ x, .. (bi_exist _ (λ y, P%I)) ..)) : bi_scope.
  Local Infix "∗" := bi_sep : bi_scope.
  Local Infix "-∗" := bi_wand : bi_scope.

  Record BiMixin := {
    bi_mixin_entails_po : PreOrder bi_entails;
    bi_mixin_equiv_entails P Q : (P ≡ Q) ↔ (P ⊢ Q) ∧ (Q ⊢ P);

    bi_mixin_pure_ne n : Proper (iff ==> dist n) bi_pure;
    bi_mixin_and_ne : NonExpansive2 bi_and;
    bi_mixin_or_ne : NonExpansive2 bi_or;
    bi_mixin_impl_ne : NonExpansive2 bi_impl;
    bi_mixin_forall_ne A n :
      Proper (pointwise_relation _ (dist n) ==> dist n) (bi_forall A);
    bi_mixin_exist_ne A n :
      Proper (pointwise_relation _ (dist n) ==> dist n) (bi_exist A);
    bi_mixin_sep_ne : NonExpansive2 bi_sep;
    bi_mixin_wand_ne : NonExpansive2 bi_wand;

    bi_mixin_pure_intro (φ : Prop) P : φ → P ⊢ ⌜ φ ⌝;
    bi_mixin_pure_elim' (φ : Prop) P : (φ → True ⊢ P) → ⌜ φ ⌝ ⊢ P;

    bi_mixin_and_elim_l P Q : P ∧ Q ⊢ P;
    bi_mixin_and_elim_r P Q : P ∧ Q ⊢ Q;
    bi_mixin_and_intro P Q R : (P ⊢ Q) → (P ⊢ R) → P ⊢ Q ∧ R;

    bi_mixin_or_intro_l P Q : P ⊢ P ∨ Q;
    bi_mixin_or_intro_r P Q : Q ⊢ P ∨ Q;
    bi_mixin_or_elim P Q R : (P ⊢ R) → (Q ⊢ R) → P ∨ Q ⊢ R;

    bi_mixin_impl_intro_r P Q R : (P ∧ Q ⊢ R) → P ⊢ Q → R;
    bi_mixin_impl_elim_l' P Q R : (P ⊢ Q → R) → P ∧ Q ⊢ R;

    bi_mixin_forall_intro {A} P (Ψ : A → PROP) : (∀ a, P ⊢ Ψ a) → P ⊢ ∀ a, Ψ a;
    bi_mixin_forall_elim {A} {Ψ : A → PROP} a : (∀ a, Ψ a) ⊢ Ψ a;

    bi_mixin_exist_intro {A} {Ψ : A → PROP} a : Ψ a ⊢ ∃ a, Ψ a;
    bi_mixin_exist_elim {A} (Φ : A → PROP) Q : (∀ a, Φ a ⊢ Q) → (∃ a, Φ a) ⊢ Q;

    bi_mixin_sep_mono P P' Q Q' : (P ⊢ Q) → (P' ⊢ Q') → P ∗ P' ⊢ Q ∗ Q';
    bi_mixin_emp_sep_1 P : P ⊢ emp ∗ P;
    bi_mixin_emp_sep_2 P : emp ∗ P ⊢ P;
    bi_mixin_sep_comm' P Q : P ∗ Q ⊢ Q ∗ P;
    bi_mixin_sep_assoc' P Q R : (P ∗ Q) ∗ R ⊢ P ∗ (Q ∗ R);
    bi_mixin_wand_intro_r P Q R : (P ∗ Q ⊢ R) → P ⊢ Q -∗ R;
    bi_mixin_wand_elim_l' P Q R : (P ⊢ Q -∗ R) → P ∗ Q ⊢ R;
  }.

  Context (bi_persistently : PROP → PROP).
  Local Notation "'<pers>' P" := (bi_persistently P) : bi_scope.

  Record BiPersistentlyMixin := {
    bi_mixin_persistently_ne : NonExpansive bi_persistently;

    bi_mixin_persistently_mono P Q : (P ⊢ Q) → <pers> P ⊢ <pers> Q;

    bi_mixin_persistently_idemp_2 P : <pers> P ⊢ <pers> <pers> P;

    bi_mixin_persistently_emp_2 : emp ⊢ <pers> emp;

    bi_mixin_persistently_and_2 (P Q : PROP) :
      (<pers> P) ∧ (<pers> Q) ⊢ <pers> (P ∧ Q);
    bi_mixin_persistently_exist_1 {A} (Ψ : A → PROP) :
      <pers> (∃ a, Ψ a) ⊢ ∃ a, <pers> (Ψ a);

    bi_mixin_persistently_absorbing P Q : <pers> P ∗ Q ⊢ <pers> P;

    bi_mixin_persistently_and_sep_elim P Q : <pers> P ∧ Q ⊢ P ∗ Q;
  }.

  Context (bi_later : PROP → PROP).
  Local Notation "▷ P" := (bi_later P) : bi_scope.

  Record BiLaterMixin := {
    bi_mixin_later_ne : NonExpansive bi_later;

    bi_mixin_later_mono P Q : (P ⊢ Q) → ▷ P ⊢ ▷ Q;
    bi_mixin_later_intro P : P ⊢ ▷ P;

    bi_mixin_later_forall_2 {A} (Φ : A → PROP) : (∀ a, ▷ Φ a) ⊢ ▷ ∀ a, Φ a;
    bi_mix

[...]

 xs pat as p
    | _ => fail "iSpecialize:" t "should be a proof mode term"
    end
  end.

Tactic Notation "iPoseProofCore" open_constr(lem)
    "as" constr(p) tactic3(tac) :=
  iStartProof;
  let t := lazymatch lem with ITrm ?t ?xs ?pat => t | _ => lem end in
  let t := lazymatch type of t with string => constr:(INamed t) | _ => t end in
  let spec_tac Htmp :=
    lazymatch lem with
    | ITrm _ ?xs ?pat => iSpecializeCore (ITrm Htmp xs pat) as p
    | _ => idtac
    end in
  lazymatch type of t with
  | ident =>
     let Htmp := iFresh in
     iPoseProofCoreHyp t as Htmp; spec_tac Htmp; [..|tac Htmp]
  | _ => iPoseProofCoreLem t as (fun Htmp => spec_tac Htmp; [..|tac Htmp])
  end.

Tactic Notation "iOrDestruct" constr(H) "as" constr(H1) constr(H2) :=
  eapply tac_or_destruct with H _ H1 H2 _ _ _;
    [pm_reflexivity ||
     let H := pretty_ident H in
     fail "iOrDestruct:" H "not found"
    |tc_solve ||
     let P := match goal with |- IntoOr ?P _ _ => P end in
     fail "iOrDestruct: cannot destruct" P
    | pm_reduce;
      lazymatch goal with
      | |- False =>
        let H1 := pretty_ident H1 in
        let H2 := pretty_ident H2 in
        fail "iOrDestruct:" H1 "or" H2 "not fresh"
      |  _ => split
      end].

Local Tactic Notation "iAndDestruct" constr(H) "as" constr(H1) constr(H2) :=
  eapply tac_and_destruct with H _ H1 H2 _ _ _;
    [pm_reflexivity ||
     let H := pretty_ident H in
     fail "iAndDestruct:" H "not found"
    |pm_reduce; tc_solve ||
     let P :=
       lazymatch goal with
       | |- IntoSep ?P _ _ => P
       | |- IntoAnd _ ?P _ _ => P
       end in
     fail "iAndDestruct: cannot destruct" P
    |pm_reduce;
     lazymatch goal with
       | |- False =>
         let H1 := pretty_ident H1 in
         let H2 := pretty_ident H2 in
         fail "iAndDestruct:" H1 "or" H2 "not fresh"
       | _ => idtac
     end].

Local Tactic Notation "iAndDestructChoice" constr(H) "as" constr(d) constr(H') :=
  eapply tac_and_destruct_choice with H _ d H' _ _ _;
    [pm_reflexivity || fail "iAndDestructChoice:" H "not found"
    |pm_reduce; tc_solve ||
     let P := match goal with |- TCOr (IntoAnd _ ?P _ _) _ => P end in
     fail "iAndDestructChoice: cannot destruct" P
    |pm_reduce;
     lazymatch goal with
     | |- False =>
       let H' := pretty_ident H' in
       fail "iAndDestructChoice:" H' "not fresh"
     | _ => idtac
     end].

Ltac _iExists x :=
  iStartProof;
  eapply tac_exist;
    [tc_solve ||
     let P := match goal with |- FromExist ?P _ => P end in
     fail "iExists:" P "not an existential"
    |pm_prettify; eexists x
      ].

Tactic Notation "iExists" ne_uconstr_list_sep(xs,",") :=
  ltac1_list_iter _iExists xs.

Local Tactic Notation "iExistDestruct" constr(H)
    "as" simple_intropattern(x) constr(Hx) :=
  eapply tac_exist_destruct with H _ Hx _ _ _;
    [pm_reflexivity ||
     let H := pretty_ident H in
     fail "iExistDestruct:" H "not found"
    |tc_solve ||
     let P := match goal with |- IntoExist ?P _ _ => P end in
     fail "iExistDestruct: cannot destruct" P|];
    let name := lazymatch goal with
                | |- let _ := (λ name, _) in _ => name
                end in
    intros _;
    let y := fresh name in
    intros y; pm_reduce;
    lazymatch goal with
    | |- False =>
      let Hx := pretty_ident Hx in
      fail "iExistDestruct:" Hx "not fresh"
    | _ => revert y; intros x
    end.

Tactic Notation "iModIntro" uconstr(sel) :=
  iStartProof;
  notypeclasses refine (tac_modal_intro _ _ sel _ _ _ _ _ _ _ _ _ _ _ _ _ _);
    [tc_solve ||
     fail "iModIntro: the goal is not a modality"
    |tc_solve ||
     let s := lazymatch goal with |- IntoModalIntuitionisticEnv _ _ _ ?s => s end in
     lazymatch eval hnf in s with
     | MIEnvForall ?C => fail "iModIntro: intuitionistic context does not satisfy" C
     | MIEnvIsEmpty => fail "iModIntro: intuitionistic context is non-empty"
     end
    |tc_solve ||
     let s := lazymatch goal with |- IntoModalSpatialEnv _ _ _ ?s _ => s end in
     lazymatch eval hnf in s with
     | MIEnvForall ?C => fail "iModIntro: spatial context does not satisfy" C
     | MIEnvIsEmpty => fail "iModIntro: spatial context is non-empty"
     end
    |pm_reduce; tc_solve ||
     fail "iModIntro: cannot filter spatial context when goal is not absorbing"
    |iSolveSideCondition
    |pm_prettify
      ].
Tactic Notation "iModIntro" := iModIntro _.

Tactic Notation "iModCore" constr(H) "as" constr(H') :=
  eapply tac_modal_elim with H H' _ _ _ _ _ _;
    [pm_reflexivity || fail "iMod:" H "not found"
    |tc_solve ||
     let P := match goal with |- ElimModal _ _ _ ?P _ _ _ => P end in
     let Q := match goal with |- ElimModal _ _ _ _ _ ?Q _ => Q end in
     fail "iMod: cannot eliminate modality" P "in" Q
    |iSolveSideCondition
    |pm_reduce;
     lazymatch goal with
     | |- False =>
       let H' := pretty_ident H' in
       fail "iMod:" H' "not fresh"
     | _ => pm_prettify
     end].

Local Ltac ident_for_pat pat :=
  lazymatch pat with
  | IIdent ?x => x
  | _ => let x := iFresh in x
  end.

Local Ltac ident_for_pat_default pat default :=
  lazymatch pat with
  | IIdent ?x => x
  | _ =>
    lazymatch default with
    | IAnon _ => default
    | _ => let x := iFresh in x
    end
  end.

Local Ltac iDestructHypGo Hz pat0 pat :=
  lazymatch pat with
  | IFresh =>
     lazymatch Hz with
     | IAnon _ => idtac
     | INamed ?Hz => let Hz' := iFresh in iRename Hz into Hz'
     end
  | IDrop => iClearHyp Hz
  | IFrame => iFrameHyp Hz
  | IIdent Hz => idtac
  | IIdent ?y => iRename Hz into y
  | IList [[]] => iExFalso; iExact Hz

  | IList [[?pat1; IDrop]] =>
     let x := ident_for_pat_default pat1 Hz in
     iAndDestructChoice Hz as Left x;
     iDestructHypGo x pat0 pat1
  | IList [[IDrop; ?pat2]] =>
     let x := ident_for_pat_default pat2 Hz in
     iAndDestructChoice Hz as Right x;
     iDestructHypGo x pat0 pat2

  | IList [[IPure IGallinaAnon; ?pat2]] =>
     let x := ident_for_pat_default pat2 Hz in
     iExistDestruct Hz as ? x; iDestructHypGo x pat0 pat2
  | IList [[IPure (IGallinaNamed ?s); ?pat2]] =>
     let x := fresh in
     let y := ident_for_pat_default pat2 Hz in
     iExistDestruct Hz as x y;
     rename_by_string x s;
     iDestructHypGo y pat0 pat2
  | IList [[?pat1; ?pat2]] =>

     let x1 := ident_for_pat_default pat1 Hz in
     let x2 := ident_for_pat pat2 in
     iAndDestruct Hz as x1 x2;
     iDestructHypGo x1 pat0 pat1; iDestructHypGo x2 pat0 pat2
  | IList [_ :: _ :: _] => fail "iDestruct:" pat0 "has too many conjuncts"
  | IList [[_]] => fail "iDestruct:" pat0 "has just a single conjunct"

  | IList [[?pat1];[?pat2]] =>
     let x1 := ident_for_pat_default pat1 Hz in
     let x2 := ident_for_pat_default pat2 Hz in
     iOrDestruct Hz as x1 x2;
     [iDestructHypGo x1 pat0 pat1|iDestructHypGo x2 pat0 pat2]

  | IList (_ :: _ :: _ :: _) => fail "iDestruct:" pat0 "has too many disjuncts"

  | IList [_;_] => fail "iDestruct: in" pat0 "a disjunct has multiple patterns"

  | IPure IGallinaAnon => iPure Hz as ?
  | IPure (IGallinaNamed ?s) =>
     let x := fresh in
     iPure Hz as x;
     rename_by_string x s
  | IRewrite Right => iPure Hz as ->
  | IRewrite Left => iPure Hz as <-
  | IIntuitionistic ?pat =>
    let x := ident_for_pat_default pat Hz in
    iIntuitionistic Hz as x; iDestructHypGo x pat0 pat
  | ISpatial ?pat =>
    let x := ident_for_pat_default pat Hz in
    iSpatial Hz as x; iDestructHypGo x pat0 pat
  | IModalElim ?pat =>
    let x := ident_for_pat_default pat Hz in
    iModCore Hz as x; iDestructHypGo x pat0 pat
  | _ => fail "iDestruct:" pat0 "is not supported due to" pat
  end.
Local Ltac iDestructHypFindPat Hgo pat found pats :=
  lazymatch pats with
  | [] =>
    lazymatch found with
    | true => pm_prettify
    | false => fail "iDestruct:" pat "should contain exactly one proper introduction pattern"
    end
  | ISimpl :: ?pats => simpl; iDestructHypFindPat Hgo pat found pats
  | IClear ?H :: ?pats => iClear H; iDestructHypFindPat Hgo pat found pats
  | IClearFrame ?H :: ?pats => iFrame H; iDestructHypFindPat Hgo pat found pats
  | ?pat1 :: ?pats =>
     lazymatch found with
     | false => iDestructHypGo Hgo pat pat1; iDestructHypFindPat Hgo pat true pats
     | true => fail "iDestruct:" pat "should contain exactly one proper introduction pattern"
     end
  end.

Ltac _iDestructHyp0 H pat :=
  let pats := intro_pat.parse pat in
  iDestructHypFindPat H pat false pats.
Ltac _iDestructHyp H xs pat :=
  ltac1_list_iter ltac:(fun x => iExistDestruct H as x H) xs;
  _iDestructHyp0 H pat.

Tactic Notation "iDestructHyp" constr(H) "as" constr(pat) :=
  _iDestructHyp0 H pat.

Ltac _iIntros_go pats startproof :=
  lazymatch pats with
  | [] =>
    lazymatch startproof with
    | true => iStartProof
    | false => idtac
    end

  | IPure (IGallinaNamed ?s) :: ?pats =>
     let i := fresh in
     iIntro (i);
     rename_by_string i s;
     _iIntros_go pats startproof
  | IPure IGallinaAnon :: ?pats => iIntro (?); _iIntros_go pats startproof
  | IIntuitionistic (IIdent ?H) :: ?pats => iIntro #H; _iIntros_go pats false
  | IDrop :: ?pats => iIntro _; _iIntros_go pats startproof
  | IIdent ?H :: ?pats => iIntro H; _iIntros_go pats startproof

  | IPureIntro :: ?pats => iPureIntro; _iIntros_go pats false
  | IModalIntro :: ?pats => iModIntro; _iIntros_go pats false
  | IForall :: ?pats => repeat iIntroForall; _iIntros_go pats startproof
  | IAll :: ?pats => repeat (iIntroForall || iIntro); _iIntros_go pats startproof

  | ISimpl :: ?pats => simpl; _iIntros_go pats startproof
  | IClear ?H :: ?pats => iClear H; _iIntros_go pats false
  | IClearFrame ?H :: ?pats => iFrame H; _iIntros_go pats false
  | IDone :: ?pats => try done; _iIntros_go pats startproof

  | IIntuitionistic ?pat :: ?pats =>
     let H := iFresh in iIntro #H; iDestructHyp H as pat; _iIntros_go pats false
  | ?pat :: ?pats =>
     let H := iFresh in iIntro H; iDestructHyp H as pat; _iIntros_go pats false
  end.

Ltac _iIntros0 pat :=
  let pats := intro_pat.parse pat in

  lazymatch pats with
  | [] => idtac
  | _ => _iIntros_go pats true
  end.
Ltac _iIntros xs pat :=
  ltac1_list_iter ltac:(fun x => iIntro (x)) xs;
  _iIntros0 pat.
Tactic Notation "iIntros" "(" ne_simple_intropattern_list(xs) ")" constr(pat) :=
  _iIntros xs pat.

Tactic Notation "iDestructCore" open_constr(lem) "as" constr(p) tactic3(tac) :=
  let intro_destruct n :=
    let rec go n' :=
      lazymatch n' with
      | 0 => fail "iDestruct: cannot introduce" n "hypotheses"
      | 1 => repeat iIntroForall; let H := iFresh in iIntro H; tac H
      | S ?n' => repeat iIntroForall; let H := iFresh in iIntro H; go n'
      end in
    intros; go n in
  lazymatch type of lem with
  | nat => intro_destruct lem
  | Z =>

     let n := eval cbv in (Z.to_nat lem) in intro_destruct n
  | ident => tac lem
  | string => tac constr:(INamed lem)
  | _ => iPoseProofCore lem as p tac
  end.
Tactic Notation "iMod" open_constr(lem) "as" "(" ne_simple_intropattern_list(xs) ")"
    constr(pat) :=
  iDestructCore lem as false (fun H => iModCore H as H; last _iDestructHyp H xs pat).

Global Hint Extern 0 (envs_entails _ _) => iPureIntro; try done : core.

Lemma from_assumption_exact {PROP : bi} p (P : PROP) : FromAssumption p P P.
Admitted.
Global Hint Extern 0 (FromAssumption _ _ _) =>
  notypeclasses refine (from_assumption_exact _ _); shelve : typeclass_instances.

Lemma from_exist_exist {PROP : bi} {A} (Φ : A → PROP) : FromExist (∃ a, Φ a) Φ.
Admitted.
Global Hint Extern 0 (FromExist _ _) =>
  notypeclasses refine (from_exist_exist _) : typeclass_instances.

Section class_instances.
Context {PROP : bi}.
Implicit Types P Q R : PROP.

Global Instance as_emp_valid_emp_valid P : AsEmpValid0 (⊢ P) P | 0.
Admitted.
Global Instance from_pure_pure φ : @FromPure PROP false ⌜φ⌝ φ.
Admitted.
Global Instance into_persistent_intuitionistically p P Q :
  IntoPersistent true P Q → IntoPersistent p (□ P) Q | 0.
Admitted.
Global Instance into_persistent_here P : IntoPersistent true P P | 1.
Admitted.

Global Instance into_wand_wand p q P Q P' :
  FromAssumption q P P' → IntoWand p q (P' -∗ Q) P Q.
Admitted.

Global Instance from_wand_wand P1 P2 : FromWand (P1 -∗ P2) P1 P2.
Admitted.

Global Instance into_sep_sep P Q : IntoSep (P ∗ Q) P Q.
Admitted.

Global Instance into_exist_exist {A} (Φ : A → PROP) name :
  AsIdentName Φ name → IntoExist (bi_exist Φ) Φ name.
Admitted.
End class_instances.

Section class_instances_updates.

Global Instance from_modal_bupd `{!BiBUpd PROP} P :
  FromModal True modality_id (|==> P) (|==> P) P.
Admitted.

Global Instance elim_modal_bupd `{!BiBUpd PROP} p P Q :
  ElimModal True p false (|==> P) P (|==> Q) (|==> Q).
Admitted.
End class_instances_updates.

Record agree (A : Type) : Type := {
  agree_car : list A;
  agree_not_nil : bool_decide (agree_car = []) = false
}.
Global Arguments agree_car {_} _.
Definition to_agree {A} (a : A) : agree A.
Admitted.

Section agree.
Context {A : ofe}.
Local Instance agree_dist : Dist (agree A).
Admitted.
Local Instance agree_equiv : Equiv (agree A).
Admitted.

Definition agree_ofe_mixin : OfeMixin (agree A).
Admitted.
Canonical Structure agreeO := Ofe (agree A) agree_ofe_mixin.
Local Instance agree_validN_instance : ValidN (agree A).
Admitted.
Local Instance agree_valid_instance : Valid (agree A).
Admitted.

Local Program Instance agree_op_instance : Op (agree A) := λ x y,
  {| agree_car := agree_car x ++ agree_car y |}.
Admit Obligations.
Local Instance agree_pcore_instance : PCore (agree A).
Admitted.

Definition agree_cmra_mixin : CmraMixin (agree A).
Admitted.
Canonical Structure agreeR : cmra.
exact (Cmra (agree A) agree_cmra_mixin).
Defined.

End agree.
Global Arguments agreeR : clear implicits.

Notation frac := Qp (only parsing).
  Canonical Structure fracO := leibnizO frac.
Local Instance frac_valid_instance : Valid frac.
Admitted.
Local Instance frac_pcore_instance : PCore frac.
Admitted.
Local Instance frac_op_instance : Op frac.
Admitted.

  Definition frac_ra_mixin : RAMixin frac.
Admitted.
  Canonical Structure fracR := discreteR frac frac_ra_mixin.

Inductive dfrac :=
  | DfracOwn : Qp → dfrac
  | DfracDiscarded : dfrac
  | DfracBoth : Qp → dfrac.

Declare Custom Entry dfrac.
Notation "" := (DfracOwn 1) (in custom dfrac).

Structure view_rel (A : ofe) (B : ucmra) := ViewRel {
  view_rel_holds :> nat → A → B → Prop;
  view_rel_mono n1 n2 a1 a2 b1 b2 :
    view_rel_holds n1 a1 b1 →
    a1 ≡{n2}≡ a2 →
    b2 ≼{n2} b1 →
    n2 ≤ n1 →
    view_rel_holds n2 a2 b2;
  view_rel_validN n a b :
    view_rel_holds n a b → ✓{n} b;
  view_rel_unit n :
    ∃ a, view_rel_holds n a ε
}.
Global Arguments ViewRel {_ _} _ _.

Record view {A B} (rel : nat → A → B → Prop) :=
  View { view_auth_proj : option (dfrac * agree A) ; view_frag_proj : B }.

Section ofe.
  Context {A B : ofe} (rel : nat → A → B → Prop).
Local Instance view_equiv : Equiv (view rel).
Admitted.
Local Instance view_dist : Dist (view rel).
Admitted.

  Definition view_ofe_mixin : OfeMixin (view rel).
Admitted.
  Canonical Structure viewO := Ofe (view rel) view_ofe_mixin.
End ofe.

Section cmra.
  Context {A B} (rel : view_rel A B).
Local Instance view_valid_instance : Valid (view rel).
Admitted.
Local Instance view_validN_instance : ValidN (view rel).
Admitted.
Local Instance view_pcore_instance : PCore (view rel).
Admitted.
Local Instance view_op_instance : Op (view rel).
Admitted.

  Lemma view_cmra_mixin : CmraMixin (view rel).
Admitted.
  Canonical Structure viewR := Cmra (view rel) view_cmra_mixin.
Local Instance view_empty_instance : Unit (view rel).
Admitted.
  Lemma view_ucmra_mixin : UcmraMixin (view rel).
Admitted.
  Canonical Structure viewUR := Ucmra (view rel) view_ucmra_mixin.

End cmra.
Definition viewO_map {A A' B B' : ofe}
    {rel : nat → A → B → Prop} {rel' : nat → A' → B' → Prop}
    (f : A -n> A') (g : B -n> B') : viewO rel -n> viewO rel'.
Admitted.
Definition auth_view_rel_raw {A : ucmra} (n : nat) (a b : A) : Prop.
Admitted.
Lemma auth_view_rel_raw_mono (A : ucmra) n1 n2 (a1 a2 b1 b2 : A) :
  auth_view_rel_raw n1 a1 b1 →
  a1 ≡{n2}≡ a2 →
  b2 ≼{n2} b1 →
  n2 ≤ n1 →
  auth_view_rel_raw n2 a2 b2.
Admitted.
Lemma auth_view_rel_raw_valid (A : ucmra) n (a b : A) :
  auth_view_rel_raw n a b → ✓{n} b.
Admitted.
Lemma auth_view_rel_raw_unit (A : ucmra) n :
  ∃ a : A, auth_view_rel_raw n a ε.
Admitted.
Canonical Structure auth_view_rel {A : ucmra} : view_rel A A.
exact (ViewRel auth_view_rel_raw (auth_view_rel_raw_mono A)
          (auth_view_rel_raw_valid A) (auth_view_rel_raw_unit A)).
Defined.

Notation auth A := (view (A:=A) (B:=A) auth_view_rel_raw).
Definition authR (A : ucmra) : cmra.
exact (viewR (A:=A) (B:=A) auth_view_rel).
Defined.
Definition authUR (A : ucmra) : ucmra.
exact (viewUR (A:=A) (B:=A) auth_view_rel).
Defined.
Definition auth_auth {A: ucmra} : dfrac → A → auth A.
Admitted.
Definition auth_frag {A: ucmra} : A → auth A.
Admitted.

Notation "● dq a" := (auth_auth dq a)
  (at level 20, dq custom dfrac at level 1, format "● dq  a").
Notation "◯ a" := (auth_frag a) (at level 20).

Program Definition authURF (F : urFunctor) : urFunctor := {|
  urFunctor_car A _ B _ := authUR (urFunctor_car F A B);
  urFunctor_map A1 _ A2 _ B1 _ B2 _ fg :=
    viewO_map (urFunctor_map F fg) (urFunctor_map F fg)
|}.
Admit Obligations.

Program Definition authRF (F : urFunctor) : rFunctor := {|
  rFunctor_car A _ B _ := authR (urFunctor_car F A B);
  rFunctor_map A1 _ A2 _ B1 _ B2 _ fg :=
    viewO_map (urFunctor_map F fg) (urFunctor_map F fg)
|}.
Solve Obligations with apply authURF.

Record uPred (M : ucmra) : Type := UPred {
  uPred_holds : nat → M → Prop;

  uPred_mono n1 n2 x1 x2 :
    uPred_holds n1 x1 → x1 ≼{n2} x2 → n2 ≤ n1 → uPred_holds n2 x2
}.

Local Coercion uPred_holds : uPred >-> Funclass.
Bind Scope bi_scope with uPred.

Section cofe.
  Context {M : ucmra}.
Local Instance uPred_equiv : Equiv (uPred M).
Admitted.
Local Instance uPred_dist : Dist (uPred M).
Admitted.
  Definition uPred_ofe_mixin : OfeMixin (uPred M).
Admitted.
Canonical Structure uPredO : ofe.
exact (Ofe (uPred M) uPred_ofe_mixin).
Defined.

  Program Definition uPred_compl : Compl uPredO := λ c,
    {| uPred_holds n x := ∀ n', n' ≤ n → ✓{n'} x → c n' n' x |}.
Admit Obligations.
  Global Program Instance uPred_cofe : Cofe uPredO := {| compl := uPred_compl |}.
Admit Obligations.
End cofe.
Global Arguments uPredO : clear implicits.

Inductive uPred_entails {M} (P Q : uPred M) : Prop :=
  { uPred_in_entails : ∀ n x, ✓{n} x → P n x → Q n x }.
Global Hint Resolve uPred_mono : uPred_def.

Local Program Definition uPred_pure_def {M} (φ : Prop) : uPred M :=
  {| uPred_holds n x := φ |}.
Solve Obligations with done.
Local Definition uPred_pure_aux : seal (@uPred_pure_def).
Admitted.
Definition uPred_pure := uPred_pure_aux.(unseal).
Global Arguments uPred_pure {M}.

Local Program Definition uPred_and_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := P n x ∧ Q n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_and_aux : seal (@uPred_and_def).
Admitted.
Definition uPred_and := uPred_and_aux.(unseal).
Global Arguments uPred_and {M}.

Local Program Definition uPred_or_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := P n x ∨ Q n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_or_aux : seal (@uPred_or_def).
Admitted.
Definition uPred_or := uPred_or_aux.(unseal).
Global Arguments uPred_or {M}.

Local Program Definition uPred_impl_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := ∀ n' x',
       x ≼ x' → n' ≤ n → ✓{n'} x' → P n' x' → Q n' x' |}.
Admit Obligations.
Local Definition uPred_impl_aux : seal (@uPred_impl_def).
Admitted.
Definition uPred_impl := uPred_impl_aux.(unseal).
Global Arguments uPred_impl {M}.

Local Program Definition uPred_forall_def {M A} (Ψ : A → uPred M) : uPred M :=
  {| uPred_holds n x := ∀ a, Ψ a n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_forall_aux : seal (@uPred_forall_def).
Admitted.
Definition uPred_forall := uPred_forall_aux.(unseal).

Local Program Definition uPred_exist_def {M A} (Ψ : A → uPred M) : uPred M :=
  {| uPred_holds n x := ∃ a, Ψ a n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_exist_aux : seal (@uPred_exist_def).
Admitted.
Definition uPred_exist := uPred_exist_aux.(unseal).

Local Program Definition uPred_sep_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := ∃ x1 x2, x ≡{n}≡ x1 ⋅ x2 ∧ P n x1 ∧ Q n x2 |}.
Admit Obligations.
Local Definition uPred_sep_aux : seal (@uPred_sep_def).
Admitted.
Definition uPred_sep := uPred_sep_aux.(unseal).
Global Arguments uPred_sep {M}.

Local Program Definition uPred_wand_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := ∀ n' x',
       n' ≤ n → ✓{n'} (x ⋅ x') → P n' x' → Q n' (x ⋅ x') |}.
Admit Obligations.
Local Definition uPred_wand_aux : seal (@uPred_wand_def).
Admitted.
Definition uPred_wand := uPred_wand_aux.(unseal).
Global Arguments uPred_wand {M}.

Local Program Definition uPred_plainly_def {M} (P : uPred M) : uPred M :=
  {| uPred_holds n x := P n ε |}.
Solve Obligations with naive_solver eauto using uPred_mono, ucmra_unit_validN.

Local Program Definition uPred_persistently_def {M} (P : uPred M) : uPred M :=
  {| uPred_holds n x := P n (core x) |}.
Solve Obligations with naive_solver eauto using uPred_mono, cmra_core_monoN.
Local Definition uPred_persistently_aux : seal (@uPred_persistently_def).
Admitted.
Definition uPred_persistently := uPred_persistently_aux.(unseal).
Global Arguments uPred_persistently {M}.

Local Program Definition uPred_later_def {M} (P : uPred M) : uPred M :=
  {| uPred_holds n x := match n return _ with 0 => True | S n' => P n' x end |}.
Admit Obligations.
Local Definition uPred_later_aux : seal (@uPred_later_def).
Admitted.
Definition uPred_later := uPred_later_aux.(unseal).
Global Arguments uPred_later {M}.
Definition uPred_emp {M} : uPred M.
Admitted.

Lemma uPred_bi_mixin (M : ucmra) :
  BiMixin
    uPred_entails uPred_emp uPred_pure uPred_and uPred_or uPred_impl
    (@uPred_forall M) (@uPred_exist M) uPred_sep uPred_wand.
Admitted.

Lemma uPred_bi_persistently_mixin (M : ucmra) :
  BiPersistentlyMixin
    uPred_entails uPred_emp uPred_and
    (@uPred_exist M) uPred_sep uPred_persistently.
Admitted.

Lemma uPred_bi_later_mixin (M : ucmra) :
  BiLaterMixin
    uPred_entails uPred_pure uPred_or uPred_impl
    (@uPred_forall M) (@uPred_exist M) uPred_sep uPred_persistently uPred_later.
Admitted.
Canonical Structure uPredI (M : ucmra) : bi.
exact ({| bi_ofe_mixin := ofe_mixin_of (uPred M);
     bi_bi_mixin := uPred_bi_mixin M;
     bi_bi_later_mixin := uPred_bi_later_mixin M;
     bi_bi_persistently_mixin := uPred_bi_persistently_mixin M |}).
Defined.
Global Instance uPred_bi_bupd M : BiBUpd (uPredI M).
Admitted.

Structure gFunctor := GFunctor {
  gFunctor_F :> rFunctor;
  gFunctor_map_contractive : rFunctorContractive gFunctor_F;
}.

Record gFunctors := GFunctors {
  gFunctors_len : nat;
  gFunctors_lookup : fin gFunctors_len → gFunctor
}.

Definition gid (Σ : gFunctors) := fin (gFunctors_len Σ).

Definition gname := positive.
Definition iResUR (Σ : gFunctors) : ucmra.
Admitted.
  Notation iProp Σ := (uPred (iResUR Σ)).
  Notation iPropO Σ := (uPredO (iResUR Σ)).

Class inG (Σ : gFunctors) (A : cmra) := InG {
  inG_id : gid Σ;
  inG_apply := rFunctor_apply (gFunctors_lookup Σ inG_id);
  inG_prf : A = inG_apply (iPropO Σ) _;
}.
Local Definition own_def `{!inG Σ A} (γ : gname) (a : A) : iProp Σ.
Admitted.
Local Definition own_aux : seal (@own_def).
Admitted.
Definition own := own_aux.(unseal).
Global Arguments own {Σ A _} γ a.

Section cmra_mlist.

  Context (A: Type) `{EqDecision A}.
  Implicit Types (D: list A).

  Inductive mlist :=
    | MList D : mlist
    | MListBot : mlist.

  Inductive mlist_equiv : Equiv mlist :=
    | MList_equiv D1 D2:
        D1 = D2 → MList D1 ≡ MList D2
    | MListBot_equiv : MListBot ≡ MListBot.

  Existing Instance mlist_equiv.
  Local Instance mlist_equiv_Equivalence : @Equivalence mlist equiv.
Admitted.
Canonical Structure mlistC : ofe.
exact (discreteO mlist).
Defined.
Local Instance mlist_valid : Valid mlist.
Admitted.
Local Instance mlist_op : Op mlist.
Admitted.
Local Instance mlist_PCore : PCore mlist.
Admitted.
Local Instance mlist_unit : Unit mlist.
Admitted.

  Definition mlist_ra_mixin : RAMixin mlist.
Admitted.

  Canonical Structure mlistR := discreteR mlist mlist_ra_mixin.

  Definition mlist_ucmra_mixin : UcmraMixin mlist.
Admitted.

  Canonical Structure mlistUR :=
    Ucmra mlist mlist_ucmra_mixin.

End cmra_mlist.

Global Arguments MList {_} _.

Definition fmlistUR (A: Type) {Heq: EqDecision A} := authUR (mlistUR A).
Class fmlistG (A: Type) {Heq: EqDecision A} Σ :=
  { #[global] fmlist_inG :: inG Σ (fmlistUR A) }.

Section fmlist_props.
Context `{fmlistG A Σ}.
Definition fmlist_lb γ l := own γ (◯ (MList l)).
Definition fmlist_idx γ i a := (∃ l, ⌜ l !! i = Some a ⌝ ∗ fmlist_lb γ l)%I.

End fmlist_props.
Local Instance nat_valid_instance : Valid nat.
Admitted.
Local Instance nat_pcore_instance : PCore nat.
Admitted.
Local Instance nat_op_instance : Op nat.
Admitted.
  Lemma nat_ra_mixin : RAMixin nat.
Admitted.
Canonical Structure natR : cmra.
exact (discreteR nat nat_ra_mixin).
Defined.
Local Instance nat_unit_instance : Unit nat.
Admitted.
  Lemma nat_ucmra_mixin : UcmraMixin nat.
Admitted.
Canonical Structure natUR : ucmra.
exact (Ucmra nat nat_ucmra_mixin).
Defined.

Class lcGpreS (Σ : gFunctors) := LcGpreS {
  #[local] lcGpreS_inG :: inG Σ (authR natUR)
}.

Class lcGS (Σ : gFunctors) := LcGS {
  #[local] lcGS_inG :: inG Σ (authR natUR);
  lcGS_name : gname;
}.
Import iris.algebra.coPset.

Inductive bi_schema :=
| bi_sch_emp : bi_schema
| bi_sch_pure : Prop → bi_schema
| bi_sch_and : bi_schema → bi_schema → bi_schema
| bi_sch_or : bi_schema → bi_schema → bi_schema
| bi_sch_forall : ∀ A, (A → bi_schema) → bi_schema
| bi_sch_exist : ∀ A, (A → bi_schema) → bi_schema
| bi_sch_sep : bi_schema → bi_schema → bi_schema
| bi_sch_wand : bi_schema → bi_schema → bi_schema
| bi_sch_persistently : bi_schema → bi_schema
| bi_sch_later : bi_schema → bi_schema
| bi_sch_bupd : bi_schema → bi_schema

| bi_sch_var_fixed : nat → bi_schema
| bi_sch_var_mut : nat → bi_schema
| bi_sch_wsat : bi_schema
| bi_sch_ownE : (nat → coPset) → bi_schema.

Canonical Structure bi_schemaO := leibnizO bi_schema.

Record invariant_level_names := { invariant_name : gname; }.

Global Instance invariant_level_names_eq_dec : EqDecision (invariant_level_names).
Admitted.
  Class invGpreS (Σ : gFunctors) : Set := WsatPreG {
    #[global] inv_inPreG :: inG Σ (authR (gmapUR positive
                                    (prodR (agreeR (prodO (listO (laterO (iPropO Σ))) bi_schemaO))
                                           (optionR (prodR fracR (agreeR (listO (laterO (iPropO Σ)))))))));
    #[global] enabled_inPreG :: inG Σ coPset_disjR;
    #[global] disabled_inPreG :: inG Σ (gset_disjR positive);
    #[global] mlist_inPreG :: fmlistG (invariant_level_names) Σ;
    inv_lcPreG : lcGpreS Σ;
  }.

  Class invGS (Σ : gFunctors) : Set := WsatG {
    #[global] inv_inG :: invGpreS Σ;
    #[global] invGS_lc :: lcGS Σ;
    inv_list_name : gname;
    enabled_name : gname;
    disabled_name : gname;
  }.

Definition invariant_unfold {Σ} {n} sch (Ps : vec (iProp Σ) n) : agree (list (later (iPropO Σ)) * bi_schema) :=
  to_agree ((λ P, Next P) <$> (vec_to_list Ps), sch).
Definition inv_mut_unfold {Σ} {n} q (Ps : vec (iProp Σ) n) : option (frac * (agree (list (later (iPropO Σ))))) :=
  Some (q%Qp, to_agree ((λ P, Next P) <$> (vec_to_list Ps))).
Definition ownI `{!invGS Σ} {n} (lvl: nat) (i : positive) (sch: bi_schema) (Ps : vec (iProp Σ) n) : iProp Σ :=
  (∃ γs, fmlist_idx inv_list_name lvl γs ∗
         own (invariant_name γs) (◯ {[ i := (invariant_unfold sch Ps, ε) ]})).

Definition ownI_mut `{!invGS Σ} {n} (lvl: nat) (i : positive) q (Qs : vec (iProp Σ) n) : iProp Σ :=
  (∃ (l: agree (list (later (iPropO Σ)) * bi_schema)) γs, fmlist_idx inv_list_name lvl γs ∗
         own (invariant_name γs) (◯ {[ i := (l, inv_mut_unfold q Qs) ]})).
Definition ownE `{!invGS Σ} (E : coPset) : iProp Σ.
Admitted.
Definition ownD `{!invGS Σ} (E : gset positive) : iProp Σ.
Admitted.

Definition inv_cmra_fmap `{!invGS Σ} (v: (list (iProp Σ) * bi_schema) * list (iProp Σ)) :=
  let '((Ps, sch), Qs) := v in
  (invariant_unfold sch (list_to_vec Ps), inv_mut_unfold 1%Qp (list_to_vec Qs)).

Fixpoint bi_schema_pre `{!invGS Σ} n (Ps Ps_mut: list (iProp Σ)) wsat (sch: bi_schema) :=
  match sch with
  | bi_sch_emp => emp
  | bi_sch_pure φ => ⌜φ⌝
  | bi_sch_and sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 ∧ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_or sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 ∨ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_forall A sch => ∀ (a: A),  bi_schema_pre n Ps Ps_mut wsat (sch a)
  | bi_sch_exist A sch => ∃ (a: A),  bi_schema_pre n Ps Ps_mut wsat (sch a)
  | bi_sch_sep sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 ∗ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_wand sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 -∗ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_persistently sch => <pers> bi_schema_pre n Ps Ps_mut wsat sch
  | bi_sch_later sch => ▷ bi_schema_pre n Ps Ps_mut wsat sch
  | bi_sch_bupd sch => |==> bi_schema_pre n Ps Ps_mut wsat sch
  | bi_sch_var_fixed i =>
    match (Ps !! i) with
    | None => emp
    | Some P => P
    end
  | bi_sch_var_mut i =>
    match (Ps_mut !! i) with
    | None => emp
    | Some P => P
    end
  | bi_sch_wsat => wsat
  | bi_sch_ownE E => ownE (E n)
  end%I.

Definition wsat_pre `{!invGS Σ} n bi_schema_interp :=
  (∃ I : gmap positive ((list (iProp Σ) * bi_schema) * list (iProp Σ)),
        (∃ γs, fmlist_idx inv_list_name n γs ∗
             own (invariant_name γs) (● (inv_cmra_fmap <$> I : gmap _ _))) ∗
        [∗ map] i ↦ Qs ∈ I, (bi_schema_interp (bi_later <$> Qs.1.1) (bi_later <$> Qs.2) Qs.1.2 ∗
                             ownI_mut n i (1/2)%Qp (list_to_vec Qs.2) ∗
                             ownD {[i]}) ∨
                            ownE {[i]})%I.

Fixpoint bi_schema_interp `{!invGS Σ} n (Ps Ps_mut: list (iProp Σ)) sch {struct n} :=
  match n with
  | O => bi_schema_pre O Ps Ps_mut True%I sch
  | S n' => bi_schema_pre (S n') Ps Ps_mut (wsat_pre n' (bi_schema_interp n') ∗ wsat n')%I sch
  end
  with
  wsat `{!invGS Σ} n :=
  match n with
    | S n =>
  (∃ I : gmap positive ((list (iProp Σ) * bi_schema) * list (iProp Σ)),
        (∃ γs, fmlist_idx inv_list_name n γs ∗
             own (invariant_name γs) (● (inv_cmra_fmap <$> I : gmap _ _))) ∗
        [∗ map] i ↦ Qs ∈ I, (bi_schema_interp n (bi_later <$> Qs.1.1) (bi_later <$> Qs.2) Qs.1.2 ∗
                             ownI_mut n i (1/2)%Qp (list_to_vec Qs.2) ∗
                             ownD {[i]}) ∨
                            ownE {[i]})
    ∗ wsat n
    | O => True
  end%I.

Section wsat.
Context `{!invGS Σ}.

Lemma ownI_alloc {n m} φ sch lvl (Ps: vec _ n) (Ps_mut: vec _ m):
  (∀ E : gset positive, ∃ i, i ∉ E ∧ φ i) →
  wsat (S lvl) ∗
  bi_schema_interp lvl (bi_later <$> (vec_to_list Ps)) (bi_later <$> (vec_to_list Ps_mut)) sch ==∗
  ∃ i, ⌜φ i⌝ ∗ wsat (S lvl) ∗ ownI lvl i sch Ps ∗ ownI_mut lvl i (1/2)%Qp Ps_mut.
Admitted.

End wsat.

Section schema_test_mut.
Context `{!invGS Σ}.
Definition bi_sch_bupd_factory (Q P: bi_schema) : bi_schema.
Admitted.

Definition ownI_full_bupd_factory lvl i q Q P :=
  (∃ n (Qs: vec _ n), ownI lvl i (bi_sch_bupd_factory (bi_sch_var_mut O) (bi_sch_var_fixed O)) (list_to_vec [P]) ∗
   ownI_mut lvl i q Qs ∗ ⌜ default True%I (vec_to_list Qs !! 0) = Q ⌝)%I.

Lemma ownI_bupd_factory_alloc lvl φ Q P :
  (∀ E : gset positive, ∃ i, i ∉ E ∧ φ i) →
  wsat (S lvl) ∗ (▷ Q ∗ □ (▷ Q ==∗ ▷ Q ∗ ▷ P))
       ==∗ ∃ i, ⌜φ i⌝ ∗ wsat (S lvl) ∗ ownI_full_bupd_factory lvl i (1/2)%Qp Q P.
Proof.
  iIntros (?) "(Hw&(HQ&#Hfactory))".
iMod (ownI_alloc with "[$Hw HQ]") as (i) "(?&?&?&?)"; eauto; last first.
  {
 iModIntro.
iExists i.
iFrame.
instantiate (1:= list_to_vec [Q]).
rewrite //=.
}
  repeat (rewrite ?bi_schema_interp_unfold //=).
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted) (truncated to 6.0KiB; full 139KiB file on GitHub Actions Artifacts under tmp.v)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-w" "-ssr-search-moved" "-w" "+deprecated-instance-without-locality" "-w" "+ambiguous-paths" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-deprecated-field-instance-without-locality" "-w" "+deprecated-tactic-notation" "-w" "-deprecated-since-8.19" "-w" "-deprecated-since-8.20" "-w" "-deprecated-from-Coq" "-w" "-deprecated-dirpath-Coq" "-w" "-notation-incompatible-prefix" "-w" "-deprecated-typeclasses-transparency-without-locality" "-w" "-notation-overridden,-redundant-canonical-projection,-unknown-warning,-argument-scope-delimiter" "-w" "-deprecated-native-compiler-option,-native-compiler-disabled" "-native-compiler" "ondemand" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/src" "Perennial" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp" "stdpp" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_unstable" "stdpp.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_bitvector" "stdpp.bitvector" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris" "iris" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_deprecated" "iris.deprecated" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_unstable" "iris.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_heap_lang" "iris.heap_lang" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coqutil/src/coqutil" "coqutil" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/Goose" "Goose" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/record-update/src" "RecordUpdate" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coq-tactical/src" "Tactical" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris-named-props/src" "iris_named_props" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_trusted_code" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_code_axioms" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_partial_axioms" "New.code_axioms" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new" "New" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-top" "Top.bug_01") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 1066 lines to 167 lines, then from 180 lines to 368 lines, then from 373 lines to 168 lines, then from 181 lines to 855 lines, then from 857 lines to 177 lines, then from 190 lines to 549 lines, then from 554 lines to 194 lines, then from 207 lines to 743 lines, then from 748 lines to 248 lines, then from 261 lines to 446 lines, then from 451 lines to 249 lines, then from 262 lines to 842 lines, then from 847 lines to 260 lines, then from 273 lines to 624 lines, then from 624 lines to 278 lines, then from 291 lines to 478 lines, then from 483 lines to 279 lines, then from 292 lines to 558 lines, then from 563 lines to 279 lines, then from 292 lines to 689 lines, then from 694 lines to 309 lines, then from 322 lines to 1312 lines, then from 1316 lines to 426 lines, then from 439 lines to 919 lines, then from 924 lines to 474 lines, then from 487 lines to 1254 lines, then from 1259 lines to 659 lines, then from 660 lines to 533 lines, then from 546 lines to 841 lines, then from 846 lines to 542 lines, then from 555 lines to 674 lines, then from 679 lines to 553 lines, then from 566 lines to 969 lines, then from 974 lines to 588 lines, then from 601 lines to 766 lines, then from 771 lines to 587 lines, then from 600 lines to 772 lines, then from 777 lines to 589 lines, then from 602 lines to 962 lines, then from 967 lines to 603 lines, then from 616 lines to 1930 lines, then from 1935 lines to 642 lines, then from 655 lines to 2993 lines, then from 2998 lines to 1687 lines, then from 1700 lines to 3137 lines, then from 3142 lines to 2116 lines, then from 2113 lines to 2095 lines, then from 2108 lines to 2312 lines, then from 2317 lines to 2128 lines, then from 2141 lines to 3107 lines, then from 3112 lines to 2290 lines, then from 2303 lines to 2595 lines, then from 2600 lines to 2456 lines, then from 2469 lines to 2615 lines, then from 2620 lines to 2482 lines, then from 2495 lines to 2697 lines, then from 2702 lines to 2566 lines, then from 2579 lines to 2772 lines, then from 2777 lines to 2812 lines, then from 2813 lines to 2659 lines, then from 2672 lines to 2841 lines, then from 2846 lines to 2719 lines, then from 2732 lines to 2821 lines, then from 2826 lines to 2723 lines, then from 2736 lines to 3351 lines, then from 3356 lines to 3168 lines, then from 3151 lines to 2792 lines, then from 2805 lines to 3604 lines, then from 3608 lines to 3348 lines, then from 3321 lines to 2867 lines, then from 2880 lines to 3175 lines, then from 3180 lines to 2909 lines, then from 2922 lines to 3120 lines, then from 3125 lines to 2914 lines, then from 2927 lines to 3193 lines, then from 3198 lines to 2974 lines, then from 2987 lines to 3042 lines, then from 3047 lines to 3001 lines, then from 3011 lines to 2993 lines, then from 3006 lines to 3655 lines, then from 3660 lines to 2996 lines, then from 3009 lines to 3093 lines, then from 3099 lines to 3005 lines, then from 3019 lines to 3684 lines, then from 3690 lines to 3015 lines, then from 3029 lines to 3058 lines, then from 3064 lines to 3021 lines, then from 3035 lines to 3069 lines, then from 3075 lines to 3028 lines, then from 3042 lines to 3070 lines, then from 3076 lines to 3073 lines, then from 3075 lines to 3036 lines, then from 3049 lines to 3118 lines, then from 3124 lines to 3057 lines, then from 3071 lines to 3261 lines, then from 3267 lines to 3065 lines, then from 3079 lines to 3341 lines, then from 3347 lines to 3122 lines, then from 3136 lines to 3421 lines,
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 3.9MiB file on GitHub Actions Artifacts under build.log)
da/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ CI_INSTALL_DIR=/github/workspace/builds/coq/coq-failing/_install_ci
++ export CI_BRANCH=
++ CI_BRANCH=
++ [[ '' =~ ^[0-9]*$ ]]
++ export CI_PULL_REQUEST=
++ CI_PULL_REQUEST=
++ export PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.1+flambda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/github/workspace/builds/coq/coq-failing/_install_ci/bin:/github/workspace/builds/coq/coq-failing/_install_ci/bin:/root/.opamcache/4.14.1+flambda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ COQBIN=/github/workspace/builds/coq/coq-failing/_install_ci/bin/
++ ls -l /github/workspace/builds/coq/coq-failing/_install_ci/bin/
total 557764
-rwxr-xr-x 1 root root     2393 Nov 15 20:54 coq-tex
-rwxr-xr-x 1 root root  2741424 Nov 15 20:54 coq-tex.orig
-rwxr-xr-x 1 root root  6566064 Nov  9 11:03 coq_makefile
-rwxr-xr-x 1 root root     2390 Nov 15 20:54 coqc
-rwxr-xr-x 1 root root     2395 Nov 15 20:54 coqc.byte
-rwxr-xr-x 1 root root 44090557 Nov 15 20:54 coqc.byte.orig
-rwxr-xr-x 1 root root 73356776 Nov 15 20:54 coqc.orig
-rwxr-xr-x 1 root root 22433128 Nov  9 11:03 coqchk
-rwxr-xr-x 1 root root  7234144 Nov  9 11:03 coqdep
-rwxr-xr-x 1 root root     2392 Nov 15 20:54 coqdoc
-rwxr-xr-x 1 root root  7006456 Nov 15 20:54 coqdoc.orig
-rwxr-xr-x 1 root root     2392 Nov 15 20:54 coqide
-rwxr-xr-x 1 root root 19186344 Nov 15 20:54 coqide.orig
-rwxr-xr-x 1 root root     2400 Nov 15 20:54 coqidetop.byte
-rwxr-xr-x 1 root root 44654513 Nov 15 20:54 coqidetop.byte.orig
-rwxr-xr-x 1 root root     2399 Nov 15 20:54 coqidetop.opt
-rwxr-xr-x 1 root root 74288208 Nov 15 20:54 coqidetop.opt.orig
-rwxr-xr-x 1 root root     2395 Nov 15 20:54 coqnative
-rwxr-xr-x 1 root root 22349952 Nov 15 20:54 coqnative.orig
-rwxr-xr-x 1 root root     2391 Nov 15 20:54 coqpp
-rwxr-xr-x 1 root root  3501504 Nov 15 20:54 coqpp.orig
-rwxr-xr-x 1 root root     2401 Nov 15 20:54 coqtimelog2html
-rwxr-xr-x 1 root root  4591944 Nov 15 20:54 coqtimelog2html.orig
-rwxr-xr-x 1 root root     2392 Nov 15 20:54 coqtop
-rwxr-xr-x 1 root root     2397 Nov 15 20:54 coqtop.byte
-rwxr-xr-x 1 root root 69507600 Nov 15 20:54 coqtop.byte.orig
-rwxr-xr-x 1 root root 73585464 Nov 15 20:54 coqtop.orig
-rwxr-xr-x 1 root root     2391 Nov 15 20:54 coqwc
-rwxr-xr-x 1 root root  2325600 Nov 15 20:54 coqwc.orig
-rwxr-xr-x 1 root root     2399 Nov 15 20:54 coqworker.opt
-rwxr-xr-x 1 root root 73577920 Nov 15 20:54 coqworker.opt.orig
-rwxr-xr-x 1 root root     2396 Nov 15 20:54 coqworkmgr
-rwxr-xr-x 1 root root  3401152 Nov 15 20:54 coqworkmgr.orig
-rwxr-xr-x 1 root root     2394 Nov 15 20:54 csdpcert
-rwxr-xr-x 1 root root  5999128 Nov 15 20:54 csdpcert.orig
-rwxr-xr-x 1 root root     2397 Nov 15 20:54 ocamllibdep
-rwxr-xr-x 1 root root  3489704 Nov 15 20:54 ocamllibdep.orig
-rwxr-xr-x 1 root root     2392 Nov 15 20:54 votour
-rwxr-xr-x 1 root root  7142888 Nov 15 20:54 votour.orig
++ CI_BUILD_DIR=/github/workspace/builds/coq/coq-failing/_build_ci
++ ls -l /github/workspace/builds/coq/coq-failing/_build_ci
total 4
drwxr-xr-x 10 root root 4096 Nov  9 11:13 perennial
++ declare -A overlays
++ set +x
+ WITH_SUBMODULES=1
+ git_download perennial
+ local project=perennial
+ local dest=/github/workspace/builds/coq/coq-failing/_build_ci/perennial
+ local giturl_var=perennial_CI_GITURL
+ local giturl=https://github.com/mit-pdos/perennial
+ local ref_var=perennial_CI_REF
+ local ref=coq/tested
+ local parent_project_var=perennial_CI_PARENT_PROJECT
+ local parent_project=
+ local submodule_folder_var=perennial_CI_SUBMODULE_FOLDER
+ local submodule_folder=
+ local ov_url=
+ local ov_ref=
++ dirname /github/workspace/builds/coq/coq-failing/_build_ci/perennial
+ local dest_prefix=/github/workspace/builds/coq/coq-failing/_build_ci/
+ '[' '' = '' ']'
+ local parent_project_dest=/github/workspace/builds/coq/coq-failing/_build_ci/
+ local parent_project_relative_dest=
+ '[' -d /github/workspace/builds/coq/coq-failing/_build_ci/perennial ']'
+ echo 'Warning: download and unpacking of perennial skipped because /github/workspace/builds/coq/coq-failing/_build_ci/perennial already exists.'
Warning: download and unpacking of perennial skipped because /github/workspace/builds/coq/coq-failing/_build_ci/perennial already exists.
+ '[' '' ']'
+ ulimit -s
16384
+ ulimit -s 65536
+ ulimit -s
65536
+ cd /github/workspace/builds/coq/coq-failing/_build_ci/perennial
+ make TIMED=false lite
+ '[' -z x ']'
+ command make TIMED=false lite
make[1]: Entering directory '/github/workspace/builds/coq/coq-failing/_build_ci/perennial'
COQC src/base_logic/lib/wsat.v
MINIMIZER_DEBUG_EXTRA: coqc: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc
MINIMIZER_DEBUG_EXTRA: coqpath: 
MINIMIZER_DEBUG_EXTRA: pwd: PWD=/github/workspace/builds/coq/coq-failing/_build_ci/perennial
MINIMIZER_DEBUG_EXTRA: exec: /github/workspace/builds/coq/coq-failing/_install_ci/bin/coqc.orig -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/src Perennial -w -ssr-search-moved -w +deprecated-instance-without-locality -w +ambiguous-paths -w +deprecated-hint-rewrite-without-locality -w -deprecated-field-instance-without-locality -w +deprecated-tactic-notation -w -deprecated-since-8.19 -w -deprecated-since-8.20 -w -deprecated-from-Coq -w -deprecated-dirpath-Coq -w -notation-incompatible-prefix -w -deprecated-typeclasses-transparency-without-locality -w -notation-overridden\,-redundant-canonical-projection\,-unknown-warning\,-argument-scope-delimiter -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp stdpp -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_unstable stdpp.unstable -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_bitvector stdpp.bitvector -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris iris -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_deprecated iris.deprecated -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_unstable iris.unstable -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_heap_lang iris.heap_lang -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coqutil/src/coqutil coqutil -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/Goose Goose -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/record-update/src RecordUpdate -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coq-tactical/src Tactical -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris-named-props/src iris_named_props -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_trusted_code New.code -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_code_axioms New.code -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_partial_axioms New.code_axioms -Q /github/workspace/builds/coq/coq-failing/_build_ci/perennial/new New -o /github/workspace/builds/coq/coq-failing/_build_ci/perennial/src/base_logic/lib/wsat.vo src/base_logic/lib/wsat.v 
MINIMIZER_DEBUG: info: /tmp/tmp-coqbot-minimizer.1LUxsypkl2
MINIMIZER_DEBUG: files:  src/base_logic/lib/wsat.v /github/workspace/builds/coq/coq-failing/_build_ci/perennial/src/base_logic/lib/wsat.v
File "./src/base_logic/lib/wsat.v", line 966, characters 82-83:
Error: This proof is focused, but cannot be unfocused this way

make[1]: *** [Makefile:59: src/base_logic/lib/wsat.vo] Error 1
make[1]: Leaving directory '/github/workspace/builds/coq/coq-failing/_build_ci/perennial'
+ code=2
+ printf '\n%s exit code: %s\n' perennial 2
+ echo 'Aggregating timing log...'
Aggregating timing log...
+ echo

+ tools/make-one-time-file.py --real perennial.log
No timing data
+ '[' '' ']'
+ exit 2
make: *** [Makefile.ci:192: ci-perennial] Error 2
/github/workspace/builds/coq /github/workspace
::endgroup::
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 2.8MiB file on GitHub Actions Artifacts under bug.log)
the error.  
The new error was:
File "/tmp/tmpwyen_x0m/Top/bug_01.v", line 26, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmpwyen_x0m/Top/bug_01.v", line 324, characters 35-44:
Error: Could not find an instance for "ValidN A" in
environment:
A : Type
Equiv0 : Equiv A
PCore0 : PCore A
Op0 : Op A
Valid0 : Valid A
Heq : Equivalence equiv
ra_mix : RAMixin A



�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmpb61wdddv/Top/bug_01.v", line 26, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmpb61wdddv/Top/bug_01.v", line 595, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpb61wdddv/Top/bug_01.v", line 2788, characters 17-21:
Error: The reference ITrm was not found in the current environment.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to admit [abstract ...]s
�[92m
Admitting [abstract ...] successful.�[0m
�[92m
Admitting [abstract ...] successful.�[0m
Admitting [abstract ...] unsuccessful.
Admitting [abstract ...] unsuccessful.

I will now attempt to remove goals ending in [Abort.]
�[92m
Aborted removal successful.�[0m

I will now attempt to remove unused Ltacs
�[92m
Ltac removal successful.�[0m

I will now attempt to remove unused definitions

Non-fatal error: Failed to remove definitions and preserve the error.  
The new error was:
File "/tmp/tmpwyen_x0m/Top/bug_01.v", line 26, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmpwyen_x0m/Top/bug_01.v", line 324, characters 35-44:
Error: Could not find an instance for "ValidN A" in
environment:
A : Type
Equiv0 : Equiv A
PCore0 : PCore A
Op0 : Op A
Valid0 : Valid A
Heq : Equivalence equiv
ra_mix : RAMixin A



�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused non-instance, non-canonical structure definitions

Non-fatal error: Failed to remove non-instance definitions and preserve the error.  
The new error was:
File "/tmp/tmpb61wdddv/Top/bug_01.v", line 26, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmpb61wdddv/Top/bug_01.v", line 595, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
File "/tmp/tmpb61wdddv/Top/bug_01.v", line 2788, characters 17-21:
Error: The reference ITrm was not found in the current environment.


�[93mIntermediate code not saved.�[0m

I will now attempt to remove unused variables
�[92m
Variable removal successful.�[0m

I will now attempt to remove unused contexts
�[92m
Context removal successful.�[0m

I will now attempt to replace Obligation with Admit Obligations
�[92m
Admitting Obligations successful.�[0m
Failed to do everything at once; trying one at a time.
Admitting Obligations unsuccessful.
No successful changes.

I will now attempt to admit lemmas with Admitted

Non-fatal error: Failed to admit lemmas and preserve the error.  
The new error was:
File "/tmp/tmpy_u4qvei/Top/bug_01.v", line 26, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmpy_u4qvei/Top/bug_01.v", line 605, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
Error: The section schema_test_mut, module intro_pat, module sel_pat, module
spec_pat, module base, module Ltac2, module algebra, module iris, module
iris_DOT_algebra_DOT_coPset_WRAPPED, module String, module Ascii, module
algebra, module iris and module iris_DOT_algebra_DOT_cmra_WRAPPED
need to be closed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with Admitted

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmp958q50_n/Top/bug_01.v", line 26, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmp958q50_n/Top/bug_01.v", line 204, characters 0-9:
Error:
New coercion path [cmra_ofeO; ofe_car] : cmra >-> Sortclass is ambiguous with existing 
[cmra_car] : cmra >-> Sortclass (reversible).
[ambiguous-paths,coercions,default]


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to admit lemmas with admit. Defined

Non-fatal error: Failed to admit lemmas and preserve the error.  
The new error was:
File "/tmp/tmpblm7k595/Top/bug_01.v", line 26, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmpblm7k595/Top/bug_01.v", line 605, characters 0-30:
Warning: Declaring a scope implicitly is deprecated; use in advance an
explicit "Declare Scope bi_scope.".
[undeclared-scope,deprecated-since-8.10,deprecated,default]
Error: The section schema_test_mut, module intro_pat, module sel_pat, module
spec_pat, module base, module Ltac2, module algebra, module iris, module
iris_DOT_algebra_DOT_coPset_WRAPPED, module String, module Ascii, module
algebra, module iris and module iris_DOT_algebra_DOT_cmra_WRAPPED
need to be closed.


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting lemmas unsuccessful.
No successful changes.

I will now attempt to admit definitions with admit. Defined

Non-fatal error: Failed to admit definitions and preserve the error.  
The new error was:
File "/tmp/tmp8hbw4274/Top/bug_01.v", line 26, characters 0-30:
Warning: Using Vector.t is known to be technically difficult, see
<https://github.com/coq/coq/blob/master/theories/Vectors/Vector.v>.
[warn-library-file-stdlib-vector,stdlib-vector,warn-library-file,user-warn,default]
File "/tmp/tmp8hbw4274/Top/bug_01.v", line 205, characters 0-8:
Error:
New coercion path [cmra_ofeO; ofe_car] : cmra >-> Sortclass is ambiguous with existing 
[cmra_car] : cmra >-> Sortclass (reversible).
[ambiguous-paths,coercions,default]


�[93mIntermediate code not saved.�[0m
Failed to do everything at once; trying one at a time.
Admitting definitions unsuccessful.
No successful changes.

I will now attempt to export modules
Module exportation successful

I will now attempt to split imports and exports
Import/Export splitting unsuccessful.

I will now attempt to split := definitions
One-line definition splitting unsuccessful.

I will now attempt to remove all lines, one at a time

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

cc @JasonGross

Copy link
Contributor
coqbot-app bot commented Nov 16, 2024

Partially Minimized File (from ci-perennial) (full log on GitHub Actions)

We are collecting data on the user experience of the Coq Bug Minimizer.
If you haven't already filled the survey for this PR, please fill out our short survey!

⭐ 🏗️ Partially Minimized Coq File (could not inline Ltac2.Array, Ltac2.Pattern, Ltac2.Ltac1) (truncated to first and last 32KiB; full 147KiB file on GitHub Actions Artifacts under bug.v)
(* -*- mode: coq; coq-prog-args: ("-emacs" "-w" "-ssr-search-moved" "-w" "+deprecated-instance-without-locality" "-w" "+ambiguous-paths" "-w" "+deprecated-hint-rewrite-without-locality" "-w" "-deprecated-field-instance-without-locality" "-w" "+deprecated-tactic-notation" "-w" "-deprecated-since-8.19" "-w" "-deprecated-since-8.20" "-w" "-deprecated-from-Coq" "-w" "-deprecated-dirpath-Coq" "-w" "-notation-incompatible-prefix" "-w" "-deprecated-typeclasses-transparency-without-locality" "-w" "-notation-overridden,-redundant-canonical-projection,-unknown-warning,-argument-scope-delimiter" "-w" "-deprecated-native-compiler-option,-native-compiler-disabled" "-native-compiler" "ondemand" "-Q" "/github/workspace/cwd" "Top" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/src" "Perennial" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp" "stdpp" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_unstable" "stdpp.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/stdpp/stdpp_bitvector" "stdpp.bitvector" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris" "iris" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_deprecated" "iris.deprecated" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_unstable" "iris.unstable" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris/iris_heap_lang" "iris.heap_lang" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coqutil/src/coqutil" "coqutil" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/Goose" "Goose" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/record-update/src" "RecordUpdate" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/coq-tactical/src" "Tactical" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/external/iris-named-props/src" "iris_named_props" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_trusted_code" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_code_axioms" "New.code" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new_partial_axioms" "New.code_axioms" "-Q" "/github/workspace/builds/coq/coq-failing/_build_ci/perennial/new" "New" "-Q" "/github/workspace/builds/coq/coq-failing/_install_ci/lib/coq/user-contrib/Ltac2" "Ltac2" "-top" "Top.bug_01") -*- *)
(* File reduced by coq-bug-minimizer from original input, then from 1066 lines to 167 lines, then from 180 lines to 368 lines, then from 373 lines to 168 lines, then from 181 lines to 855 lines, then from 857 lines to 177 lines, then from 190 lines to 549 lines, then from 554 lines to 194 lines, then from 207 lines to 743 lines, then from 748 lines to 248 lines, then from 261 lines to 446 lines, then from 451 lines to 249 lines, then from 262 lines to 842 lines, then from 847 lines to 260 lines, then from 273 lines to 624 lines, then from 624 lines to 278 lines, then from 291 lines to 478 lines, then from 483 lines to 279 lines, then from 292 lines to 558 lines, then from 563 lines to 279 lines, then from 292 lines to 689 lines, then from 694 lines to 309 lines, then from 322 lines to 1312 lines, then from 1316 lines to 426 lines, then from 439 lines to 919 lines, then from 924 lines to 474 lines, then from 487 lines to 1254 lines, then from 1259 lines to 659 lines, then from 660 lines to 533 lines, then from 546 lines to 841 lines, then from 846 lines to 542 lines, then from 555 lines to 674 lines, then from 679 lines to 553 lines, then from 566 lines to 969 lines, then from 974 lines to 588 lines, then from 601 lines to 766 lines, then from 771 lines to 587 lines, then from 600 lines to 772 lines, then from 777 lines to 589 lines, then from 602 lines to 962 lines, then from 967 lines to 603 lines, then from 616 lines to 1930 lines, then from 1935 lines to 642 lines, then from 655 lines to 2993 lines, then from 2998 lines to 1687 lines, then from 1700 lines to 3137 lines, then from 3142 lines to 2116 lines, then from 2113 lines to 2095 lines, then from 2108 lines to 2312 lines, then from 2317 lines to 2128 lines, then from 2141 lines to 3107 lines, then from 3112 lines to 2290 lines, then from 2303 lines to 2595 lines, then from 2600 lines to 2456 lines, then from 2469 lines to 2615 lines, then from 2620 lines to 2482 lines, then from 2495 lines to 2697 lines, then from 2702 lines to 2566 lines, then from 2579 lines to 2772 lines, then from 2777 lines to 2812 lines, then from 2813 lines to 2659 lines, then from 2672 lines to 2841 lines, then from 2846 lines to 2719 lines, then from 2732 lines to 2821 lines, then from 2826 lines to 2723 lines, then from 2736 lines to 3351 lines, then from 3356 lines to 3168 lines, then from 3151 lines to 2792 lines, then from 2805 lines to 3604 lines, then from 3608 lines to 3348 lines, then from 3321 lines to 2867 lines, then from 2880 lines to 3175 lines, then from 3180 lines to 2909 lines, then from 2922 lines to 3120 lines, then from 3125 lines to 2914 lines, then from 2927 lines to 3193 lines, then from 3198 lines to 2974 lines, then from 2987 lines to 3042 lines, then from 3047 lines to 3001 lines, then from 3011 lines to 2993 lines, then from 3006 lines to 3655 lines, then from 3660 lines to 2996 lines, then from 3009 lines to 3093 lines, then from 3099 lines to 3005 lines, then from 3019 lines to 3684 lines, then from 3690 lines to 3015 lines, then from 3029 lines to 3058 lines, then from 3064 lines to 3021 lines, then from 3035 lines to 3069 lines, then from 3075 lines to 3028 lines, then from 3042 lines to 3070 lines, then from 3076 lines to 3073 lines, then from 3075 lines to 3036 lines, then from 3049 lines to 3118 lines, then from 3124 lines to 3057 lines, then from 3071 lines to 3261 lines, then from 3267 lines to 3065 lines, then from 3079 lines to 3341 lines, then from 3347 lines to 3122 lines, then from 3136 lines to 3421 lines, then from 3427 lines to 3131 lines, then from 3145 lines to 3388 lines, then from 3394 lines to 3312 lines, then from 3313 lines to 3135 lines, then from 3148 lines to 3251 lines, then from 3257 lines to 3136 lines, then from 3150 lines to 3895 lines, then from 3901 lines to 3154 lines, then from 3168 lines to 6507 lines, then from 6513 lines to 3196 lines, then from 3211 lines to 3158 lines, then from 3171 lines to 4044 lines, then from 4050 lines to 3196 lines, then from 3210 lines to 3543 lines, then from 3549 lines to 3216 lines, then from 3230 lines to 3505 lines, then from 3511 lines to 3468 lines, then from 3467 lines to 3228 lines, then from 3241 lines to 4292 lines, then from 4297 lines to 3239 lines, then from 3253 lines to 3809 lines, then from 3815 lines to 3240 lines, then from 3254 lines to 5079 lines, then from 5085 lines to 4133 lines, then from 4119 lines to 3252 lines, then from 3265 lines to 3373 lines, then from 3379 lines to 3255 lines, then from 3269 lines to 3465 lines, then from 3471 lines to 3293 lines, then from 3307 lines to 3880 lines, then from 3886 lines to 3482 lines, then from 3496 lines to 3703 lines, then from 3708 lines to 3526 lines, then from 3541 lines to 3522 lines, then from 3535 lines to 3730 lines, then from 3736 lines to 3550 lines, then from 3564 lines to 4093 lines, then from 4099 lines to 3561 lines, then from 3575 lines to 4478 lines, then from 4484 lines to 4162 lines, then from 4158 lines to 3594 lines, then from 3607 lines to 3799 lines, then from 3805 lines to 3614 lines, then from 3628 lines to 4139 lines, then from 4145 lines to 3615 lines, then from 3634 lines to 3613 lines, then from 3626 lines to 8522 lines, then from 8527 lines to 3653 lines, then from 3667 lines to 3914 lines, then from 3920 lines to 3871 lines, then from 3864 lines to 3690 lines, then from 3703 lines to 5752 lines, then from 5758 lines to 3949 lines, then from 3963 lines to 4076 lines, then from 4082 lines to 4065 lines *)
(* coqc version 9.0+alpha compiled with OCaml 4.14.1
   coqtop version runner-t7b1znuaq-project-4504-concurrent-0:/builds/coq/coq/_build/default,(HEAD detached at c04db99c8cfbe3) (c04db99c8cfbe3fa002bf604971eb5b0e09656d4)
   Modules that could not be inlined: Ltac2.Array, Ltac2.Pattern, Ltac2.Ltac1
   Expected coqc runtime on this file: 2.569 sec *)








Require Stdlib.Init.Ltac.
Require Stdlib.Bool.Bool.
Require Stdlib.Classes.Morphisms.
Require Stdlib.Classes.RelationClasses.
Require Stdlib.Init.Peano.
Require Stdlib.Lists.List.
Require Stdlib.Logic.EqdepFacts.
Require Stdlib.NArith.NArith.
Require Stdlib.PArith.PArith.
Require Stdlib.Program.Basics.
Require Stdlib.Program.Syntax.
Require Stdlib.QArith.QArith.
Require Stdlib.QArith.QArith_base.
Require Stdlib.QArith.Qcanon.
Require Stdlib.Setoids.Setoid.
Require Stdlib.Sorting.Permutation.
Require Stdlib.Unicode.Utf8.
Require Stdlib.Vectors.Vector.
Require Stdlib.ZArith.ZArith.
Require Stdlib.micromega.Lia.
Require Stdlib.ssr.ssreflect.
Require Stdlib.ssr.ssrfun.
Require stdpp.options.
Require iris.prelude.options.
Require stdpp.base.
Require stdpp.proof_irrel.
Require stdpp.well_founded.
Require stdpp.decidable.
Require stdpp.tactics.
Require stdpp.fin.
Require stdpp.option.
Require stdpp.orders.
Require stdpp.numbers.
Require stdpp.lexico.
Require stdpp.list.
Require stdpp.list_numbers.
Require stdpp.countable.
Require stdpp.vector.
Require stdpp.finite.
Require stdpp.sets.
Require stdpp.listset.
Require stdpp.relations.
Require stdpp.fin_sets.
Require stdpp.prelude.
Require stdpp.ssreflect.
Require iris.prelude.prelude.
Require iris.algebra.ofe.
Require Stdlib.Strings.String.
Require Ltac2.Init.
Require Ltac2.Std.
Require Ltac2.Message.
Require Ltac2.Control.
Require Ltac2.Ltac1.
Require Ltac2.Pattern.
Require Ltac2.Int.
Require Ltac2.Bool.
Require Ltac2.Array.

Module Export AdmitTactic.
Module Import LocalFalse.
Inductive False : Prop := .
End LocalFalse.
Axiom proof_admitted : False.
Import Coq.Init.Ltac.
Tactic Notation "admit" := abstract case proof_admitted.
End AdmitTactic.

Module Export iris_DOT_algebra_DOT_monoid_WRAPPED.
Module Export monoid.
Export iris.algebra.ofe.
Import iris.prelude.options.


Class Monoid {M : ofe} (o : M → M → M) := {
  monoid_unit : M;
  monoid_ne : NonExpansive2 o;
  monoid_assoc : Assoc (≡) o;
  monoid_comm : Comm (≡) o;
  monoid_left_id : LeftId (≡) monoid_unit o;
}.
Lemma monoid_proper {M : ofe} {o : M → M → M} `{!Monoid o} : Proper ((≡) ==> (≡) ==> (≡)) o.
Admitted.
Lemma monoid_right_id {M : ofe} {o : M → M → M} `{!Monoid o} : RightId (≡) monoid_unit o.
Admitted.


Class WeakMonoidHomomorphism {M1 M2 : ofe}
    (o1 : M1 → M1 → M1) (o2 : M2 → M2 → M2) `{!Monoid o1, !Monoid o2}
    (R : relation M2) (f : M1 → M2) := {
  monoid_homomorphism_rel_po : PreOrder R;
  monoid_homomorphism_rel_proper : Proper ((≡) ==> (≡) ==> iff) R;
  monoid_homomorphism_op_proper : Proper (R ==> R ==> R) o2;
  monoid_homomorphism_ne : NonExpansive f;
  monoid_homomorphism x y : R (f (o1 x y)) (o2 (f x) (f y))
}.

Class MonoidHomomorphism {M1 M2 : ofe}
    (o1 : M1 → M1 → M1) (o2 : M2 → M2 → M2) `{!Monoid o1, !Monoid o2}
    (R : relation M2) (f : M1 → M2) := {
  #[global] monoid_homomorphism_weak :: WeakMonoidHomomorphism o1 o2 R f;
  monoid_homomorphism_unit : R (f monoid_unit) monoid_unit
}.

Lemma weak_monoid_homomorphism_proper
  `{WeakMonoidHomomorphism M1 M2 o1 o2 R f} : Proper ((≡) ==> (≡)) f.
Admitted.

End monoid.

End iris_DOT_algebra_DOT_monoid_WRAPPED.
Module Export iris.
Module Export algebra.
Module Export monoid.
Include iris_DOT_algebra_DOT_monoid_WRAPPED.monoid.
End monoid.

Module Export iris_DOT_algebra_DOT_cmra_WRAPPED.
Module Export cmra.
Export iris.algebra.monoid.

Class PCore (A : Type) := pcore : A → option A.

Class Op (A : Type) := op : A → A → A.
Infix "⋅" := op (at level 50, left associativity) : stdpp_scope.
Notation "(⋅)" := op (only parsing) : stdpp_scope.

Definition included {A} `{!Equiv A, !Op A} (x y : A) := ∃ z, y ≡ x ⋅ z.
Infix "≼" := included (at level 70) : stdpp_scope.

Class ValidN (A : Type) := validN : nat → A → Prop.
Notation "✓{ n } x" := (validN n x)
  (at level 20, n at next level, format "✓{ n }  x").

Class Valid (A : Type) := valid : A → Prop.
Notation "✓ x" := (valid x) (at level 20) : stdpp_scope.

Definition includedN `{!Dist A, !Op A} (n : nat) (x y : A) := ∃ z, y ≡{n}≡ x ⋅ z.
Notation "x ≼{ n } y" := (includedN n x y)
  (at level 70, n at next level, format "x  ≼{ n }  y") : stdpp_scope.
Global Hint Extern 0 (_ ≼{_} _) => reflexivity : core.

Section mixin.
  Record CmraMixin A `{!Dist A, !Equiv A, !PCore A, !Op A, !Valid A, !ValidN A} := {

    mixin_cmra_op_ne (x : A) : NonExpansive (op x);
    mixin_cmra_pcore_ne n (x y : A) cx :
      x ≡{n}≡ y → pcore x = Some cx → ∃ cy, pcore y = Some cy ∧ cx ≡{n}≡ cy;
    mixin_cmra_validN_ne n : Proper (dist (A := A) n ==> impl) (validN n);

    mixin_cmra_valid_validN (x : A) : ✓ x ↔ ∀ n, ✓{n} x;
    mixin_cmra_validN_S n (x : A) : ✓{S n} x → ✓{n} x;

    mixin_cmra_assoc : Assoc (≡@{A}) (⋅);
    mixin_cmra_comm : Comm (≡@{A}) (⋅);
    mixin_cmra_pcore_l (x : A) cx : pcore x = Some cx → cx ⋅ x ≡ x;
    mixin_cmra_pcore_idemp (x : A) cx : pcore x = Some cx → pcore cx ≡ Some cx;
    mixin_cmra_pcore_mono (x y : A) cx :
      x ≼ y → pcore x = Some cx → ∃ cy, pcore y = Some cy ∧ cx ≼ cy;
    mixin_cmra_validN_op_l n (x y : A) : ✓{n} (x ⋅ y) → ✓{n} x;
    mixin_cmra_extend n (x y1 y2 : A) :
      ✓{n} x → x ≡{n}≡ y1 ⋅ y2 →
      { z1 : A & { z2 | x ≡ z1 ⋅ z2 ∧ z1 ≡{n}≡ y1 ∧ z2 ≡{n}≡ y2 } }
  }.
End mixin.

#[projections(primitive=no)]
Structure cmra := Cmra' {
  cmra_car :> Type;
  cmra_equiv : Equiv cmra_car;
  cmra_dist : Dist cmra_car;
  cmra_pcore : PCore cmra_car;
  cmra_op : Op cmra_car;
  cmra_valid : Valid cmra_car;
  cmra_validN : ValidN cmra_car;
  cmra_ofe_mixin : OfeMixin cmra_car;
  cmra_mixin : CmraMixin cmra_car;
}.
Global Arguments Cmra' _ {_ _ _ _ _ _} _ _.

Notation Cmra A m := (Cmra' A (ofe_mixin_of A%type) m) (only parsing).

Global Hint Extern 0 (PCore _) => refine (cmra_pcore _); shelve : typeclass_instances.
Global Hint Extern 0 (Op _) => refine (cmra_op _); shelve : typeclass_instances.
Global Hint Extern 0 (Valid _) => refine (cmra_valid _); shelve : typeclass_instances.
Global Hint Extern 0 (ValidN _) => refine (cmra_validN _); shelve : typeclass_instances.
Coercion cmra_ofeO (A : cmra) : ofe.
exact (Ofe A (cmra_ofe_mixin A)).
Defined.
Canonical Structure cmra_ofeO.
Definition cmra_mixin_of' A {Ac : cmra} (f : Ac → A) : CmraMixin Ac.
exact (cmra_mixin Ac).
Defined.
Notation cmra_mixin_of A :=
  ltac:(let H := eval hnf in (cmra_mixin_of' A id) in exact H) (only parsing).

Definition core {A} `{!PCore A} (x : A) : A.
Admitted.

Class Unit (A : Type) := ε : A.

Record UcmraMixin A `{!Dist A, !Equiv A, !PCore A, !Op A, !Valid A, !Unit A} := {
  mixin_ucmra_unit_valid : ✓ (ε : A);
  mixin_ucmra_unit_left_id : LeftId (≡@{A}) ε (⋅);
  mixin_ucmra_pcore_unit : pcore ε ≡@{option A} Some ε
}.

#[projections(primitive=no)]
Structure ucmra := Ucmra' {
  ucmra_car :> Type;
  ucmra_equiv : Equiv ucmra_car;
  ucmra_dist : Dist ucmra_car;
  ucmra_pcore : PCore ucmra_car;
  ucmra_op : Op ucmra_car;
  ucmra_valid : Valid ucmra_car;
  ucmra_validN : ValidN ucmra_car;
  ucmra_unit : Unit ucmra_car;
  ucmra_ofe_mixin : OfeMixin ucmra_car;
  ucmra_cmra_mixin : CmraMixin ucmra_car;
  ucmra_mixin : UcmraMixin ucmra_car;
}.
Global Arguments Ucmra' _ {_ _ _ _ _ _ _} _ _ _.
Notation Ucmra A m :=
  (Ucmra' A (ofe_mixin_of A%type) (cmra_mixin_of A%type) m) (only parsing).

Global Hint Extern 0 (Unit _) => refine (ucmra_unit _); shelve : typeclass_instances.
Coercion ucmra_ofeO (A : ucmra) : ofe.
exact (Ofe A (ucmra_ofe_mixin A)).
Defined.
Canonical Structure ucmra_ofeO.
Coercion ucmra_cmraR (A : ucmra) : cmra.
exact (Cmra' A (ucmra_ofe_mixin A) (ucmra_cmra_mixin A)).
Defined.
Canonical Structure ucmra_cmraR.

Class CmraMorphism {A B : cmra} (f : A → B) := {
  #[global] cmra_morphism_ne :: NonExpansive f;
  cmra_morphism_validN n x : ✓{n} x → ✓{n} f x;
  cmra_morphism_pcore x : f <$> pcore x ≡ pcore (f x);
  cmra_morphism_op x y : f (x ⋅ y) ≡ f x ⋅ f y
}.

Section cmra.
Context {A : cmra}.
Implicit Types x y z : A.

Section total_core.
  Global Instance cmra_includedN_preorder n : PreOrder (@includedN A _ _ n).
Admitted.
  Lemma cmra_core_monoN n x y : x ≼{n} y → core x ≼{n} core y.
Admitted.
End total_core.
End cmra.

Section ucmra.
  Context {A : ucmra}.

  Lemma ucmra_unit_validN n : ✓{n} (ε:A).
Admitted.
End ucmra.

Record rFunctor := RFunctor {
  rFunctor_car : ∀ A `{!Cofe A} B `{!Cofe B}, cmra;
  rFunctor_map `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} :
    ((A2 -n> A1) * (B1 -n> B2)) → rFunctor_car A1 B1 -n> rFunctor_car A2 B2;
  rFunctor_map_ne `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} :
    NonExpansive (@rFunctor_map A1 _ A2 _ B1 _ B2 _);
  rFunctor_map_id `{!Cofe A, !Cofe B} (x : rFunctor_car A B) :
    rFunctor_map (cid,cid) x ≡ x;
  rFunctor_map_compose `{!Cofe A1, !Cofe A2, !Cofe A3, !Cofe B1, !Cofe B2, !Cofe B3}
      (f : A2 -n> A1) (g : A3 -n> A2) (f' : B1 -n> B2) (g' : B2 -n> B3) x :
    rFunctor_map (f◎g, g'◎f') x ≡ rFunctor_map (g,g') (rFunctor_map (f,f') x);
  rFunctor_mor `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2}
      (fg : (A2 -n> A1) * (B1 -n> B2)) :
    CmraMorphism (rFunctor_map fg)
}.

Class rFunctorContractive (F : rFunctor) :=
  #[global] rFunctor_map_contractive `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} ::
    Contractive (@rFunctor_map F A1 _ A2 _ B1 _ B2 _).
Definition rFunctor_apply (F: rFunctor) (A: ofe) `{!Cofe A} : cmra.
Admitted.

Record urFunctor := URFunctor {
  urFunctor_car : ∀ A `{!Cofe A} B `{!Cofe B}, ucmra;
  urFunctor_map `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} :
    ((A2 -n> A1) * (B1 -n> B2)) → urFunctor_car A1 B1 -n> urFunctor_car A2 B2;
  urFunctor_map_ne `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2} :
    NonExpansive (@urFunctor_map A1 _ A2 _ B1 _ B2 _);
  urFunctor_map_id `{!Cofe A, !Cofe B} (x : urFunctor_car A B) :
    urFunctor_map (cid,cid) x ≡ x;
  urFunctor_map_compose `{!Cofe A1, !Cofe A2, !Cofe A3, !Cofe B1, !Cofe B2, !Cofe B3}
      (f : A2 -n> A1) (g : A3 -n> A2) (f' : B1 -n> B2) (g' : B2 -n> B3) x :
    urFunctor_map (f◎g, g'◎f') x ≡ urFunctor_map (g,g') (urFunctor_map (f,f') x);
  urFunctor_mor `{!Cofe A1, !Cofe A2, !Cofe B1, !Cofe B2}
      (fg : (A2 -n> A1) * (B1 -n> B2)) :
    CmraMorphism (urFunctor_map fg)
}.

Record RAMixin A `{Equiv A, PCore A, Op A, Valid A} := {

  ra_op_proper (x : A) : Proper ((≡) ==> (≡)) (op x);
  ra_core_proper (x y : A) cx :
    x ≡ y → pcore x = Some cx → ∃ cy, pcore y = Some cy ∧ cx ≡ cy;
  ra_validN_proper : Proper ((≡@{A}) ==> impl) valid;

  ra_assoc : Assoc (≡@{A}) (⋅);
  ra_comm : Comm (≡@{A}) (⋅);
  ra_pcore_l (x : A) cx : pcore x = Some cx → cx ⋅ x ≡ x;
  ra_pcore_idemp (x : A) cx : pcore x = Some cx → pcore cx ≡ Some cx;
  ra_pcore_mono (x y : A) cx :
    x ≼ y → pcore x = Some cx → ∃ cy, pcore y = Some cy ∧ cx ≼ cy;
  ra_valid_op_l (x y : A) : ✓ (x ⋅ y) → ✓ x
}.

Section discrete.
  Context `{!Equiv A, !PCore A, !Op A, !Valid A} (Heq : @Equivalence A (≡)).
  Context (ra_mix : RAMixin A).
  Existing Instances discrete_dist.
Local Instance discrete_validN_instance : ValidN A.
Admitted.
  Definition discrete_cmra_mixin : CmraMixin A.
Admitted.
End discrete.

Notation discreteR A ra_mix :=
  (Cmra A (discrete_cmra_mixin (discrete_ofe_equivalence_of A%type) ra_mix))
  (only parsing).

Section prod.
  Context {A B : cmra}.
Local Instance prod_op_instance : Op (A * B).
Admitted.
Local Instance prod_pcore_instance : PCore (A * B).
Admitted.
Local Instance prod_valid_instance : Valid (A * B).
Admitted.
Local Instance prod_validN_instance : ValidN (A * B).
Admitted.

  Definition prod_cmra_mixin : CmraMixin (A * B).
Admitted.
  Canonical Structure prodR := Cmra (prod A B) prod_cmra_mixin.
End prod.

Global Arguments prodR : clear implicits.

Section option.
  Context {A : cmra}.
Local Instance option_valid_instance : Valid (option A).
Admitted.
Local Instance option_validN_instance : ValidN (option A).
Admitted.
Local Instance option_pcore_instance : PCore (option A).
Admitted.
Local Instance option_op_instance : Op (option A).
Admitted.

  Lemma option_cmra_mixin : CmraMixin (option A).
Admitted.
  Canonical Structure optionR := Cmra (option A) option_cmra_mixin.
Local Instance option_unit_instance : Unit (option A).
Admitted.
  Lemma option_ucmra_mixin : UcmraMixin optionR.
Admitted.
  Canonical Structure optionUR := Ucmra (option A) option_ucmra_mixin.
End option.

Global Arguments optionR : clear implicits.

End cmra.
Module Export iris.
Module Export algebra.
Module Export cmra.
Include iris_DOT_algebra_DOT_cmra_WRAPPED.cmra.
End cmra.
Import Stdlib.Strings.Ascii.

Export Stdlib.Strings.String (string(..)).

String Notation string
  String.string_of_list_byte String.list_byte_of_string : stdpp_scope.

Module Export Ascii.
Definition is_nat (x : ascii) : option nat.
exact (match x with
    | "0" => Some 0
    | "1" => Some 1
    | "2" => Some 2
    | "3" => Some 3
    | "4" => Some 4
    | "5" => Some 5
    | "6" => Some 6
    | "7" => Some 7
    | "8" => Some 8
    | "9" => Some 9
    | _ => None
    end%char).
Defined.
Definition is_space (x : ascii) : bool.
exact (match x with
    | "009" | "010" | "011" | "012" | "013" | " " => true | _ => false
    end%char).
Defined.

Module Export String.
Fixpoint rev_app (s1 s2 : string) : string.
exact (match s1 with
    | "" => s2
    | String a s1 => rev_app s1 (String a s2)
    end).
Defined.
Definition rev (s : string) : string.
exact (rev_app s "").
Defined.

Class MapFold K A M := map_fold B : (K → A → B → B) → B → M → B.
Global Arguments map_fold {_ _ _ _ _} _ _ _.
Definition diag_None {A B C} (f : option A → option B → option C)
    (mx : option A) (my : option B) : option C.
Admitted.
Global Instance map_insert `{PartialAlter K A M} : Insert K A M.
Admitted.

Class FinMap K M `{FMap M, ∀ A, Lookup K A (M A), ∀ A, Empty (M A), ∀ A,
    PartialAlter K A (M A), OMap M, Merge M, ∀ A, MapFold K A (M A),
    EqDecision K} := {
  map_eq {A} (m1 m2 : M A) : (∀ i, m1 !! i = m2 !! i) → m1 = m2;
  lookup_empty {A} i : (∅ : M A) !! i = None;
  lookup_partial_alter {A} f (m : M A) i :
    partial_alter f i m !! i = f (m !! i);
  lookup_partial_alter_ne {A} f (m : M A) i j :
    i ≠ j → partial_alter f i m !! j = m !! j;
  lookup_fmap {A B} (f : A → B) (m : M A) i : (f <$> m) !! i = f <$> m !! i;
  lookup_omap {A B} (f : A → option B) (m : M A) i :
    omap f m !! i = m !! i ≫= f;
  lookup_merge {A B C} (f : option A → option B → option C) (m1 : M A) (m2 : M B) i :
    merge f m1 m2 !! i = diag_None f (m1 !! i) (m2 !! i);
  map_fold_empty {A B} (f : K → A → B → B) (b : B) :
    map_fold f b ∅ = b;

  map_fold_fmap_ind {A} (P : M A → Prop) :
    P ∅ →
    (∀ i x m,
      m !! i = None →
      (∀ A' B (f : K → A' → B → B) (g : A → A') b x',
        map_fold f b (<[i:=x']> (g <$> m)) = f i x' (map_fold f b (g <$> m))) →
      P m →
      P (<[i:=x]> m)) →
    ∀ m, P m;
}.
Global Instance map_singleton `{PartialAlter K A M, Empty M} :
  SingletonM K A M.
Admitted.
Global Instance map_equiv `{∀ A, Lookup K A (M A), Equiv A} : Equiv (M A) | 20.
Admitted.

Export stdpp.countable.

Record mapset' (Munit : Type) : Type :=
  Mapset { mapset_car: Munit }.
Notation mapset M := (mapset' (M unit)).

Section mapset.
Context `{FinMap K M}.
Global Instance mapset_elem_of: ElemOf K (mapset M).
admit.
Defined.
Global Instance mapset_singleton: Singleton K (mapset M).
admit.
Defined.

End mapset.

Local Open Scope positive_scope.

Local Notation "P ~ 0" := (λ p, P p~0) : function_scope.
Local Notation "P ~ 1" := (λ p, P p~1) : function_scope.

Inductive gmap_dep_ne (A : Type) (P : positive → Prop) :=
  | GNode001 : gmap_dep_ne A P~1  → gmap_dep_ne A P
  | GNode010 : P 1 → A → gmap_dep_ne A P
  | GNode011 : P 1 → A → gmap_dep_ne A P~1 → gmap_dep_ne A P
  | GNode100 : gmap_dep_ne A P~0 → gmap_dep_ne A P
  | GNode101 : gmap_dep_ne A P~0 → gmap_dep_ne A P~1 → gmap_dep_ne A P
  | GNode110 : gmap_dep_ne A P~0 → P 1 → A → gmap_dep_ne A P
  | GNode111 : gmap_dep_ne A P~0 → P 1 → A → gmap_dep_ne A P~1 → gmap_dep_ne A P.

Variant gmap_dep (A : Type) (P : positive → Prop) :=
  | GEmpty : gmap_dep A P
  | GNodes : gmap_dep_ne A P → gmap_dep A P.

Record gmap_key K `{Countable K} (q : positive) :=
  GMapKey { _ : encode (A:=K) <$> decode q = Some q }.

Record gmap K `{Countable K} A := GMap { gmap_car : gmap_dep A (gmap_key K) }.
Global Instance gmap_lookup `{Countable K} {A} :
    Lookup K A (gmap K A).
Admitted.
Global Instance gmap_empty `{Countable K} {A} : Empty (gmap K A).
Admitted.
Global Instance gmap_partial_alter `{Countable K} {A} :
    PartialAlter K A (gmap K A).
Admitted.
Global Instance gmap_fmap `{Countable K} : FMap (gmap K).
Admitted.

Definition gset K `{Countable K} := mapset (gmap K).

Inductive coPset_raw :=
  | coPLeaf : bool → coPset_raw
  | coPNode : bool → coPset_raw → coPset_raw → coPset_raw.
Fixpoint coPset_wf (t : coPset_raw) : bool.
Admitted.

Definition coPset := { t | coPset_wf t }.
Global Instance coPset_singleton : Singleton positive coPset.
Admitted.

Module Export iris_DOT_algebra_DOT_coPset_WRAPPED.
Module Export coPset.
Export iris.algebra.cmra.

Inductive coPset_disj :=
  | CoPset : coPset → coPset_disj
  | CoPsetBot : coPset_disj.

Section coPset_disj.
  Canonical Structure coPset_disjO := leibnizO coPset_disj.
Local Instance coPset_disj_valid_instance : Valid coPset_disj.
Admitted.
Local Instance coPset_disj_op_instance : Op coPset_disj.
Admitted.
Local Instance coPset_disj_pcore_instance : PCore coPset_disj.
Admitted.

  Lemma coPset_disj_ra_mixin : RAMixin coPset_disj.
Admitted.
  Canonical Structure coPset_disjR := discreteR coPset_disj coPset_disj_ra_mixin.
End coPset_disj.

End coPset.
Module Export iris.
Module Export algebra.
Module Export coPset.
Include iris_DOT_algebra_DOT_coPset_WRAPPED.coPset.
End coPset.

Reserved Notation "P ⊢ Q" (at level 99, Q at level 200, right associativity).

Reserved Notation "P ⊣⊢ Q" (at level 95, no associativity).

Reserved Notation "⊢ Q" (at level 20, Q at level 200).
Reserved Notation "P ∗ Q" (at level 80, right associativity, format "P  ∗  '/' Q").
Reserved Notation "P -∗ Q"
  (at level 99, Q at level 200, right associativity,
   format "'[' P  -∗  '/' '[' Q ']' ']'").

Reserved Notation "'<pers>' P" (at level 20, right associativity).
Reserved Notation "'<pers>?' p P" (at level 20, p at level 9, P at level 20,
   right associativity, format "'<pers>?' p  P").

Reserved Notation "▷ P" (at level 20, right associativity).
Reserved Notation "▷^ n P" (at level 20, n at level 9, P at level 20,
   format "▷^ n  P").

Reserved Notation "'<affine>' P" (at level 20, right associativity).
Reserved Notation "'<affine>?' p P" (at level 20, p at level 9, P at level 20,
   right associativity, format "'<affine>?' p  P").

Reserved Notation "'<absorb>' P" (at level 20, right associativity).

Reserved Notation "□ P" (at level 20, right associativity).
Reserved Notation "'□?' p P" (at level 20, p at level 9, P at level 20,
   right associativity, format "'□?' p  P").

Reserved Notation "|==> Q" (at level 99, Q at level 200, format "'[  ' |==>  '/' Q ']'").
Reserved Notation "P ==∗ Q"
  (at level 99, Q at level 200, format "'[' P  ==∗  '/' Q ']'").

Reserved Notation "'[∗]' Ps" (at level 20).
Reserved Notation "'[∧' 'list]' x ∈ l , P"
  (at level 200, l at level 10, x binder, right associativity,
   format "[∧  list]  x  ∈  l ,  P").

Reserved Notation "'[∗' 'map]' k ↦ x ∈ m , P"
  (at level 200, m at level 10, k binder, x binder, right associativity,
   format "[∗  map]  k ↦ x  ∈  m ,  P").
Delimit Scope bi_scope with I.

Section bi_mixin.
  Context {PROP : Type} `{!Dist PROP, !Equiv PROP}.
  Context (bi_entails : PROP → PROP → Prop).
  Context (bi_emp : PROP).
  Context (bi_pure : Prop → PROP).
  Context (bi_and : PROP → PROP → PROP).
  Context (bi_or : PROP → PROP → PROP).
  Context (bi_impl : PROP → PROP → PROP).
  Context (bi_forall : ∀ A, (A → PROP) → PROP).
  Context (bi_exist : ∀ A, (A → PROP) → PROP).
  Context (bi_sep : PROP → PROP → PROP).
  Context (bi_wand : PROP → PROP → PROP).

  Bind Scope bi_scope with PROP.
  Local Infix "⊢" := bi_entails.
  Local Notation "'emp'" := bi_emp : bi_scope.
  Local Notation "'True'" := (bi_pure True) : bi_scope.
  Local Notation "'False'" := (bi_pure False) : bi_scope.
  Local Notation "'⌜' φ '⌝'" := (bi_pure φ%type%stdpp) : bi_scope.
  Local Infix "∧" := bi_and : bi_scope.
  Local Infix "∨" := bi_or : bi_scope.
  Local Infix "→" := bi_impl : bi_scope.
  Local Notation "∀ x .. y , P" :=
    (bi_forall _ (λ x, .. (bi_forall _ (λ y, P%I)) ..)) : bi_scope.
  Local Notation "∃ x .. y , P" :=
    (bi_exist _ (λ x, .. (bi_exist _ (λ y, P%I)) ..)) : bi_scope.
  Local Infix "∗" := bi_sep : bi_scope.
  Local Infix "-∗" := bi_wand : bi_scope.

  Record BiMixin := {
    bi_mixin_entails_po : PreOrder bi_entails;
    bi_mixin_equiv_entails P Q : (P ≡ Q) ↔ (P ⊢ Q) ∧ (Q ⊢ P);

    bi_mixin_pure_ne n : Proper (iff ==> dist n) bi_pure;
    bi_mixin_and_ne : NonExpansive2 bi_and;
    bi_mixin_or_ne : NonExpansive2 bi_or;
    bi_mixin_impl_ne : NonExpansive2 bi_impl;
    bi_mixin_forall_ne A n :
      Proper (pointwise_relation _ (dist n) ==> dist n) (bi_forall A);
    bi_mixin_exist_ne A n :
      Proper (pointwise_relation _ (dist n) ==> dist n) (bi_exist A);
    bi_mixin_sep_ne : NonExpansive2 bi_sep;
    bi_mixin_wand_ne : NonExpansive2 bi_wand;

    bi_mixin_pure_intro (φ : Prop) P : φ → P ⊢ ⌜ φ ⌝;
    bi_mixin_pure_elim' (φ : Prop) P : (φ → True ⊢ P) → ⌜ φ ⌝ ⊢ P;

    bi_mixin_and_elim_l P Q : P ∧ Q ⊢ P;
    bi_mixin_and_elim_r P Q : P ∧ Q ⊢ Q;
    bi_mixin_and_intro P Q R : (P ⊢ Q) → (P ⊢ R) → P ⊢ Q ∧ R;

    bi_mixin_or_intro_l P Q : P ⊢ P ∨ Q;
    bi_mixin_or_intro_r P Q : Q ⊢ P ∨ Q;
    bi_mixin_or_elim P Q R : (P ⊢ R) → (Q ⊢ R) → P ∨ Q ⊢ R;

    bi_mixin_impl_intro_r P Q R : (P ∧ Q ⊢ R) → P ⊢ Q → R;
    bi_mixin_impl_elim_l' P Q R : (P ⊢ Q → R) → P ∧ Q ⊢ R;

    bi_mixin_forall_intro {A} P (Ψ : A → PROP) : (∀ a, P ⊢ Ψ a) → P ⊢ ∀ a, Ψ a;
    bi_mixin_forall_elim {A} {Ψ : A → PROP} a : (∀ a, Ψ a) ⊢ Ψ a;

    bi_mixin_exist_intro {A} {Ψ : A → PROP} a : Ψ a ⊢ ∃ a, Ψ a;
    bi_mixin_exist_elim {A} (Φ : A → PROP) Q : (∀ a, Φ a ⊢ Q) → (∃ a, Φ a) ⊢ Q;

    bi_mixin_sep_mono P P' Q Q' : (P ⊢ Q) → (P' ⊢ Q') → P ∗ P' ⊢ Q ∗ Q';
    bi_mixin_emp_sep_1 P : P ⊢ emp ∗ P;
    bi_mixin_emp_sep_2 P : emp ∗ P ⊢ P;
    bi_mixin_sep_comm' P Q : P ∗ Q ⊢ Q ∗ P;
    bi_mixin_sep_assoc' P Q R : (P ∗ Q) ∗ R ⊢ P ∗ (Q ∗ R);
    bi_mixin_wand_intro_r P Q R : (P ∗ Q ⊢ R) → P ⊢ Q -∗ R;
    bi_mixin_wand_elim_l' P Q R : (P ⊢ Q -∗ R) → P ∗ Q ⊢ R;
  }.

  Context (bi_persistently : PROP → PROP).
  Local Notation "'<pers>' P" := (bi_persistently P) : bi_scope.

  Record BiPersistentlyMixin := {
    bi_mixin_persistently_ne : NonExpansive bi_persistently;

    bi_mixin_persistently_mono P Q : (P ⊢ Q) → <pers> P ⊢ <pers> Q;

    bi_mixin_persistently_idemp_2 P : <pers> P ⊢ <pers> <pers> P;

    bi_mixin_persistently_emp_2 : emp ⊢ <pers> emp;

    bi_mixin_persistently_and_2 (P Q : PROP) :
      (<pers> P) ∧ (<pers> Q) ⊢ <pers> (P ∧ Q);
    bi_mixin_persistently_exist_1 {A} (Ψ : A → PROP) :
      <pers> (∃ a, Ψ a) ⊢ ∃ a, <pers> (Ψ a);

    bi_mixin_persistently_absorbing P Q : <pers> P ∗ Q ⊢ <pers> P;

    bi_mixin_persistently_and_sep_elim P Q : <pers> P ∧ Q ⊢ P ∗ Q;
  }.

  Context (bi_later : PROP → PROP).
  Local Notation "▷ P" := (bi_later P) : bi_scope.

  Record BiLaterMixin := {
    bi_mixin_later_ne : NonExpansive bi_later;

    bi_mixin_later_mono P Q : (P ⊢ Q) → ▷ P ⊢ ▷ Q;
    bi_mixin_later_intro P : P ⊢ ▷ P;

    bi_mixin_later_forall_2 {A} (Φ : A → PROP) : (∀ a, ▷ Φ a) ⊢ ▷ ∀ a, Φ a;
    bi_mi

[...]

h xs pat as p
    | _ => fail "iSpecialize:" t "should be a proof mode term"
    end
  end.

Tactic Notation "iPoseProofCore" open_constr(lem)
    "as" constr(p) tactic3(tac) :=
  iStartProof;
  let t := lazymatch lem with ITrm ?t ?xs ?pat => t | _ => lem end in
  let t := lazymatch type of t with string => constr:(INamed t) | _ => t end in
  let spec_tac Htmp :=
    lazymatch lem with
    | ITrm _ ?xs ?pat => iSpecializeCore (ITrm Htmp xs pat) as p
    | _ => idtac
    end in
  lazymatch type of t with
  | ident =>
     let Htmp := iFresh in
     iPoseProofCoreHyp t as Htmp; spec_tac Htmp; [..|tac Htmp]
  | _ => iPoseProofCoreLem t as (fun Htmp => spec_tac Htmp; [..|tac Htmp])
  end.

Tactic Notation "iOrDestruct" constr(H) "as" constr(H1) constr(H2) :=
  eapply tac_or_destruct with H _ H1 H2 _ _ _;
    [pm_reflexivity ||
     let H := pretty_ident H in
     fail "iOrDestruct:" H "not found"
    |tc_solve ||
     let P := match goal with |- IntoOr ?P _ _ => P end in
     fail "iOrDestruct: cannot destruct" P
    | pm_reduce;
      lazymatch goal with
      | |- False =>
        let H1 := pretty_ident H1 in
        let H2 := pretty_ident H2 in
        fail "iOrDestruct:" H1 "or" H2 "not fresh"
      |  _ => split
      end].

Local Tactic Notation "iAndDestruct" constr(H) "as" constr(H1) constr(H2) :=
  eapply tac_and_destruct with H _ H1 H2 _ _ _;
    [pm_reflexivity ||
     let H := pretty_ident H in
     fail "iAndDestruct:" H "not found"
    |pm_reduce; tc_solve ||
     let P :=
       lazymatch goal with
       | |- IntoSep ?P _ _ => P
       | |- IntoAnd _ ?P _ _ => P
       end in
     fail "iAndDestruct: cannot destruct" P
    |pm_reduce;
     lazymatch goal with
       | |- False =>
         let H1 := pretty_ident H1 in
         let H2 := pretty_ident H2 in
         fail "iAndDestruct:" H1 "or" H2 "not fresh"
       | _ => idtac
     end].

Local Tactic Notation "iAndDestructChoice" constr(H) "as" constr(d) constr(H') :=
  eapply tac_and_destruct_choice with H _ d H' _ _ _;
    [pm_reflexivity || fail "iAndDestructChoice:" H "not found"
    |pm_reduce; tc_solve ||
     let P := match goal with |- TCOr (IntoAnd _ ?P _ _) _ => P end in
     fail "iAndDestructChoice: cannot destruct" P
    |pm_reduce;
     lazymatch goal with
     | |- False =>
       let H' := pretty_ident H' in
       fail "iAndDestructChoice:" H' "not fresh"
     | _ => idtac
     end].

Ltac _iExists x :=
  iStartProof;
  eapply tac_exist;
    [tc_solve ||
     let P := match goal with |- FromExist ?P _ => P end in
     fail "iExists:" P "not an existential"
    |pm_prettify; eexists x
      ].

Tactic Notation "iExists" ne_uconstr_list_sep(xs,",") :=
  ltac1_list_iter _iExists xs.

Local Tactic Notation "iExistDestruct" constr(H)
    "as" simple_intropattern(x) constr(Hx) :=
  eapply tac_exist_destruct with H _ Hx _ _ _;
    [pm_reflexivity ||
     let H := pretty_ident H in
     fail "iExistDestruct:" H "not found"
    |tc_solve ||
     let P := match goal with |- IntoExist ?P _ _ => P end in
     fail "iExistDestruct: cannot destruct" P|];
    let name := lazymatch goal with
                | |- let _ := (λ name, _) in _ => name
                end in
    intros _;
    let y := fresh name in
    intros y; pm_reduce;
    lazymatch goal with
    | |- False =>
      let Hx := pretty_ident Hx in
      fail "iExistDestruct:" Hx "not fresh"
    | _ => revert y; intros x
    end.

Tactic Notation "iModIntro" uconstr(sel) :=
  iStartProof;
  notypeclasses refine (tac_modal_intro _ _ sel _ _ _ _ _ _ _ _ _ _ _ _ _ _);
    [tc_solve ||
     fail "iModIntro: the goal is not a modality"
    |tc_solve ||
     let s := lazymatch goal with |- IntoModalIntuitionisticEnv _ _ _ ?s => s end in
     lazymatch eval hnf in s with
     | MIEnvForall ?C => fail "iModIntro: intuitionistic context does not satisfy" C
     | MIEnvIsEmpty => fail "iModIntro: intuitionistic context is non-empty"
     end
    |tc_solve ||
     let s := lazymatch goal with |- IntoModalSpatialEnv _ _ _ ?s _ => s end in
     lazymatch eval hnf in s with
     | MIEnvForall ?C => fail "iModIntro: spatial context does not satisfy" C
     | MIEnvIsEmpty => fail "iModIntro: spatial context is non-empty"
     end
    |pm_reduce; tc_solve ||
     fail "iModIntro: cannot filter spatial context when goal is not absorbing"
    |iSolveSideCondition
    |pm_prettify
      ].
Tactic Notation "iModIntro" := iModIntro _.

Tactic Notation "iModCore" constr(H) "as" constr(H') :=
  eapply tac_modal_elim with H H' _ _ _ _ _ _;
    [pm_reflexivity || fail "iMod:" H "not found"
    |tc_solve ||
     let P := match goal with |- ElimModal _ _ _ ?P _ _ _ => P end in
     let Q := match goal with |- ElimModal _ _ _ _ _ ?Q _ => Q end in
     fail "iMod: cannot eliminate modality" P "in" Q
    |iSolveSideCondition
    |pm_reduce;
     lazymatch goal with
     | |- False =>
       let H' := pretty_ident H' in
       fail "iMod:" H' "not fresh"
     | _ => pm_prettify
     end].

Local Ltac ident_for_pat pat :=
  lazymatch pat with
  | IIdent ?x => x
  | _ => let x := iFresh in x
  end.

Local Ltac ident_for_pat_default pat default :=
  lazymatch pat with
  | IIdent ?x => x
  | _ =>
    lazymatch default with
    | IAnon _ => default
    | _ => let x := iFresh in x
    end
  end.

Local Ltac iDestructHypGo Hz pat0 pat :=
  lazymatch pat with
  | IFresh =>
     lazymatch Hz with
     | IAnon _ => idtac
     | INamed ?Hz => let Hz' := iFresh in iRename Hz into Hz'
     end
  | IDrop => iClearHyp Hz
  | IFrame => iFrameHyp Hz
  | IIdent Hz => idtac
  | IIdent ?y => iRename Hz into y
  | IList [[]] => iExFalso; iExact Hz

  | IList [[?pat1; IDrop]] =>
     let x := ident_for_pat_default pat1 Hz in
     iAndDestructChoice Hz as Left x;
     iDestructHypGo x pat0 pat1
  | IList [[IDrop; ?pat2]] =>
     let x := ident_for_pat_default pat2 Hz in
     iAndDestructChoice Hz as Right x;
     iDestructHypGo x pat0 pat2

  | IList [[IPure IGallinaAnon; ?pat2]] =>
     let x := ident_for_pat_default pat2 Hz in
     iExistDestruct Hz as ? x; iDestructHypGo x pat0 pat2
  | IList [[IPure (IGallinaNamed ?s); ?pat2]] =>
     let x := fresh in
     let y := ident_for_pat_default pat2 Hz in
     iExistDestruct Hz as x y;
     rename_by_string x s;
     iDestructHypGo y pat0 pat2
  | IList [[?pat1; ?pat2]] =>

     let x1 := ident_for_pat_default pat1 Hz in
     let x2 := ident_for_pat pat2 in
     iAndDestruct Hz as x1 x2;
     iDestructHypGo x1 pat0 pat1; iDestructHypGo x2 pat0 pat2
  | IList [_ :: _ :: _] => fail "iDestruct:" pat0 "has too many conjuncts"
  | IList [[_]] => fail "iDestruct:" pat0 "has just a single conjunct"

  | IList [[?pat1];[?pat2]] =>
     let x1 := ident_for_pat_default pat1 Hz in
     let x2 := ident_for_pat_default pat2 Hz in
     iOrDestruct Hz as x1 x2;
     [iDestructHypGo x1 pat0 pat1|iDestructHypGo x2 pat0 pat2]

  | IList (_ :: _ :: _ :: _) => fail "iDestruct:" pat0 "has too many disjuncts"

  | IList [_;_] => fail "iDestruct: in" pat0 "a disjunct has multiple patterns"

  | IPure IGallinaAnon => iPure Hz as ?
  | IPure (IGallinaNamed ?s) =>
     let x := fresh in
     iPure Hz as x;
     rename_by_string x s
  | IRewrite Right => iPure Hz as ->
  | IRewrite Left => iPure Hz as <-
  | IIntuitionistic ?pat =>
    let x := ident_for_pat_default pat Hz in
    iIntuitionistic Hz as x; iDestructHypGo x pat0 pat
  | ISpatial ?pat =>
    let x := ident_for_pat_default pat Hz in
    iSpatial Hz as x; iDestructHypGo x pat0 pat
  | IModalElim ?pat =>
    let x := ident_for_pat_default pat Hz in
    iModCore Hz as x; iDestructHypGo x pat0 pat
  | _ => fail "iDestruct:" pat0 "is not supported due to" pat
  end.
Local Ltac iDestructHypFindPat Hgo pat found pats :=
  lazymatch pats with
  | [] =>
    lazymatch found with
    | true => pm_prettify
    | false => fail "iDestruct:" pat "should contain exactly one proper introduction pattern"
    end
  | ISimpl :: ?pats => simpl; iDestructHypFindPat Hgo pat found pats
  | IClear ?H :: ?pats => iClear H; iDestructHypFindPat Hgo pat found pats
  | IClearFrame ?H :: ?pats => iFrame H; iDestructHypFindPat Hgo pat found pats
  | ?pat1 :: ?pats =>
     lazymatch found with
     | false => iDestructHypGo Hgo pat pat1; iDestructHypFindPat Hgo pat true pats
     | true => fail "iDestruct:" pat "should contain exactly one proper introduction pattern"
     end
  end.

Ltac _iDestructHyp0 H pat :=
  let pats := intro_pat.parse pat in
  iDestructHypFindPat H pat false pats.
Ltac _iDestructHyp H xs pat :=
  ltac1_list_iter ltac:(fun x => iExistDestruct H as x H) xs;
  _iDestructHyp0 H pat.

Tactic Notation "iDestructHyp" constr(H) "as" constr(pat) :=
  _iDestructHyp0 H pat.

Ltac _iIntros_go pats startproof :=
  lazymatch pats with
  | [] =>
    lazymatch startproof with
    | true => iStartProof
    | false => idtac
    end

  | IPure (IGallinaNamed ?s) :: ?pats =>
     let i := fresh in
     iIntro (i);
     rename_by_string i s;
     _iIntros_go pats startproof
  | IPure IGallinaAnon :: ?pats => iIntro (?); _iIntros_go pats startproof
  | IIntuitionistic (IIdent ?H) :: ?pats => iIntro #H; _iIntros_go pats false
  | IDrop :: ?pats => iIntro _; _iIntros_go pats startproof
  | IIdent ?H :: ?pats => iIntro H; _iIntros_go pats startproof

  | IPureIntro :: ?pats => iPureIntro; _iIntros_go pats false
  | IModalIntro :: ?pats => iModIntro; _iIntros_go pats false
  | IForall :: ?pats => repeat iIntroForall; _iIntros_go pats startproof
  | IAll :: ?pats => repeat (iIntroForall || iIntro); _iIntros_go pats startproof

  | ISimpl :: ?pats => simpl; _iIntros_go pats startproof
  | IClear ?H :: ?pats => iClear H; _iIntros_go pats false
  | IClearFrame ?H :: ?pats => iFrame H; _iIntros_go pats false
  | IDone :: ?pats => try done; _iIntros_go pats startproof

  | IIntuitionistic ?pat :: ?pats =>
     let H := iFresh in iIntro #H; iDestructHyp H as pat; _iIntros_go pats false
  | ?pat :: ?pats =>
     let H := iFresh in iIntro H; iDestructHyp H as pat; _iIntros_go pats false
  end.

Ltac _iIntros0 pat :=
  let pats := intro_pat.parse pat in

  lazymatch pats with
  | [] => idtac
  | _ => _iIntros_go pats true
  end.
Ltac _iIntros xs pat :=
  ltac1_list_iter ltac:(fun x => iIntro (x)) xs;
  _iIntros0 pat.
Tactic Notation "iIntros" "(" ne_simple_intropattern_list(xs) ")" constr(pat) :=
  _iIntros xs pat.

Tactic Notation "iDestructCore" open_constr(lem) "as" constr(p) tactic3(tac) :=
  let intro_destruct n :=
    let rec go n' :=
      lazymatch n' with
      | 0 => fail "iDestruct: cannot introduce" n "hypotheses"
      | 1 => repeat iIntroForall; let H := iFresh in iIntro H; tac H
      | S ?n' => repeat iIntroForall; let H := iFresh in iIntro H; go n'
      end in
    intros; go n in
  lazymatch type of lem with
  | nat => intro_destruct lem
  | Z =>

     let n := eval cbv in (Z.to_nat lem) in intro_destruct n
  | ident => tac lem
  | string => tac constr:(INamed lem)
  | _ => iPoseProofCore lem as p tac
  end.
Tactic Notation "iMod" open_constr(lem) "as" "(" ne_simple_intropattern_list(xs) ")"
    constr(pat) :=
  iDestructCore lem as false (fun H => iModCore H as H; last _iDestructHyp H xs pat).

Global Hint Extern 0 (envs_entails _ _) => iPureIntro; try done : core.

Lemma from_assumption_exact {PROP : bi} p (P : PROP) : FromAssumption p P P.
Admitted.
Global Hint Extern 0 (FromAssumption _ _ _) =>
  notypeclasses refine (from_assumption_exact _ _); shelve : typeclass_instances.

Lemma from_exist_exist {PROP : bi} {A} (Φ : A → PROP) : FromExist (∃ a, Φ a) Φ.
Admitted.
Global Hint Extern 0 (FromExist _ _) =>
  notypeclasses refine (from_exist_exist _) : typeclass_instances.

Section class_instances.
Context {PROP : bi}.
Implicit Types P Q R : PROP.

Global Instance as_emp_valid_emp_valid P : AsEmpValid0 (⊢ P) P | 0.
Admitted.
Global Instance from_pure_pure φ : @FromPure PROP false ⌜φ⌝ φ.
Admitted.
Global Instance into_persistent_intuitionistically p P Q :
  IntoPersistent true P Q → IntoPersistent p (□ P) Q | 0.
Admitted.
Global Instance into_persistent_here P : IntoPersistent true P P | 1.
Admitted.

Global Instance into_wand_wand p q P Q P' :
  FromAssumption q P P' → IntoWand p q (P' -∗ Q) P Q.
Admitted.

Global Instance from_wand_wand P1 P2 : FromWand (P1 -∗ P2) P1 P2.
Admitted.

Global Instance into_sep_sep P Q : IntoSep (P ∗ Q) P Q.
Admitted.

Global Instance into_exist_exist {A} (Φ : A → PROP) name :
  AsIdentName Φ name → IntoExist (bi_exist Φ) Φ name.
Admitted.
End class_instances.

Section class_instances_updates.

Global Instance from_modal_bupd `{!BiBUpd PROP} P :
  FromModal True modality_id (|==> P) (|==> P) P.
Admitted.

Global Instance elim_modal_bupd `{!BiBUpd PROP} p P Q :
  ElimModal True p false (|==> P) P (|==> Q) (|==> Q).
Admitted.
End class_instances_updates.

Record agree (A : Type) : Type := {
  agree_car : list A;
  agree_not_nil : bool_decide (agree_car = []) = false
}.
Global Arguments agree_car {_} _.
Definition to_agree {A} (a : A) : agree A.
Admitted.

Section agree.
Context {A : ofe}.
Local Instance agree_dist : Dist (agree A).
Admitted.
Local Instance agree_equiv : Equiv (agree A).
Admitted.

Definition agree_ofe_mixin : OfeMixin (agree A).
Admitted.
Canonical Structure agreeO := Ofe (agree A) agree_ofe_mixin.
Local Instance agree_validN_instance : ValidN (agree A).
Admitted.
Local Instance agree_valid_instance : Valid (agree A).
Admitted.

Local Program Instance agree_op_instance : Op (agree A) := λ x y,
  {| agree_car := agree_car x ++ agree_car y |}.
Admit Obligations.
Local Instance agree_pcore_instance : PCore (agree A).
Admitted.

Definition agree_cmra_mixin : CmraMixin (agree A).
Admitted.
Canonical Structure agreeR : cmra.
exact (Cmra (agree A) agree_cmra_mixin).
Defined.

End agree.
Global Arguments agreeR : clear implicits.

Notation frac := Qp (only parsing).
  Canonical Structure fracO := leibnizO frac.
Local Instance frac_valid_instance : Valid frac.
Admitted.
Local Instance frac_pcore_instance : PCore frac.
Admitted.
Local Instance frac_op_instance : Op frac.
Admitted.

  Definition frac_ra_mixin : RAMixin frac.
Admitted.
  Canonical Structure fracR := discreteR frac frac_ra_mixin.

Inductive dfrac :=
  | DfracOwn : Qp → dfrac
  | DfracDiscarded : dfrac
  | DfracBoth : Qp → dfrac.

Declare Custom Entry dfrac.
Notation "" := (DfracOwn 1) (in custom dfrac).

Structure view_rel (A : ofe) (B : ucmra) := ViewRel {
  view_rel_holds :> nat → A → B → Prop;
  view_rel_mono n1 n2 a1 a2 b1 b2 :
    view_rel_holds n1 a1 b1 →
    a1 ≡{n2}≡ a2 →
    b2 ≼{n2} b1 →
    n2 ≤ n1 →
    view_rel_holds n2 a2 b2;
  view_rel_validN n a b :
    view_rel_holds n a b → ✓{n} b;
  view_rel_unit n :
    ∃ a, view_rel_holds n a ε
}.
Global Arguments ViewRel {_ _} _ _.

Record view {A B} (rel : nat → A → B → Prop) :=
  View { view_auth_proj : option (dfrac * agree A) ; view_frag_proj : B }.

Section ofe.
  Context {A B : ofe} (rel : nat → A → B → Prop).
Local Instance view_equiv : Equiv (view rel).
Admitted.
Local Instance view_dist : Dist (view rel).
Admitted.

  Definition view_ofe_mixin : OfeMixin (view rel).
Admitted.
  Canonical Structure viewO := Ofe (view rel) view_ofe_mixin.
End ofe.

Section cmra.
  Context {A B} (rel : view_rel A B).
Local Instance view_valid_instance : Valid (view rel).
Admitted.
Local Instance view_validN_instance : ValidN (view rel).
Admitted.
Local Instance view_pcore_instance : PCore (view rel).
Admitted.
Local Instance view_op_instance : Op (view rel).
Admitted.

  Lemma view_cmra_mixin : CmraMixin (view rel).
Admitted.
  Canonical Structure viewR := Cmra (view rel) view_cmra_mixin.
Local Instance view_empty_instance : Unit (view rel).
Admitted.
  Lemma view_ucmra_mixin : UcmraMixin (view rel).
Admitted.
  Canonical Structure viewUR := Ucmra (view rel) view_ucmra_mixin.

End cmra.
Definition viewO_map {A A' B B' : ofe}
    {rel : nat → A → B → Prop} {rel' : nat → A' → B' → Prop}
    (f : A -n> A') (g : B -n> B') : viewO rel -n> viewO rel'.
Admitted.
Definition auth_view_rel_raw {A : ucmra} (n : nat) (a b : A) : Prop.
Admitted.
Lemma auth_view_rel_raw_mono (A : ucmra) n1 n2 (a1 a2 b1 b2 : A) :
  auth_view_rel_raw n1 a1 b1 →
  a1 ≡{n2}≡ a2 →
  b2 ≼{n2} b1 →
  n2 ≤ n1 →
  auth_view_rel_raw n2 a2 b2.
Admitted.
Lemma auth_view_rel_raw_valid (A : ucmra) n (a b : A) :
  auth_view_rel_raw n a b → ✓{n} b.
Admitted.
Lemma auth_view_rel_raw_unit (A : ucmra) n :
  ∃ a : A, auth_view_rel_raw n a ε.
Admitted.
Canonical Structure auth_view_rel {A : ucmra} : view_rel A A.
exact (ViewRel auth_view_rel_raw (auth_view_rel_raw_mono A)
          (auth_view_rel_raw_valid A) (auth_view_rel_raw_unit A)).
Defined.

Notation auth A := (view (A:=A) (B:=A) auth_view_rel_raw).
Definition authR (A : ucmra) : cmra.
exact (viewR (A:=A) (B:=A) auth_view_rel).
Defined.
Definition authUR (A : ucmra) : ucmra.
exact (viewUR (A:=A) (B:=A) auth_view_rel).
Defined.
Definition auth_auth {A: ucmra} : dfrac → A → auth A.
Admitted.
Definition auth_frag {A: ucmra} : A → auth A.
Admitted.

Notation "● dq a" := (auth_auth dq a)
  (at level 20, dq custom dfrac at level 1, format "● dq  a").
Notation "◯ a" := (auth_frag a) (at level 20).

Program Definition authURF (F : urFunctor) : urFunctor := {|
  urFunctor_car A _ B _ := authUR (urFunctor_car F A B);
  urFunctor_map A1 _ A2 _ B1 _ B2 _ fg :=
    viewO_map (urFunctor_map F fg) (urFunctor_map F fg)
|}.
Admit Obligations.

Program Definition authRF (F : urFunctor) : rFunctor := {|
  rFunctor_car A _ B _ := authR (urFunctor_car F A B);
  rFunctor_map A1 _ A2 _ B1 _ B2 _ fg :=
    viewO_map (urFunctor_map F fg) (urFunctor_map F fg)
|}.
Solve Obligations with apply authURF.

Record uPred (M : ucmra) : Type := UPred {
  uPred_holds : nat → M → Prop;

  uPred_mono n1 n2 x1 x2 :
    uPred_holds n1 x1 → x1 ≼{n2} x2 → n2 ≤ n1 → uPred_holds n2 x2
}.

Local Coercion uPred_holds : uPred >-> Funclass.
Bind Scope bi_scope with uPred.

Section cofe.
  Context {M : ucmra}.
Local Instance uPred_equiv : Equiv (uPred M).
Admitted.
Local Instance uPred_dist : Dist (uPred M).
Admitted.
  Definition uPred_ofe_mixin : OfeMixin (uPred M).
Admitted.
Canonical Structure uPredO : ofe.
exact (Ofe (uPred M) uPred_ofe_mixin).
Defined.

  Program Definition uPred_compl : Compl uPredO := λ c,
    {| uPred_holds n x := ∀ n', n' ≤ n → ✓{n'} x → c n' n' x |}.
Admit Obligations.
  Global Program Instance uPred_cofe : Cofe uPredO := {| compl := uPred_compl |}.
Admit Obligations.
End cofe.
Global Arguments uPredO : clear implicits.

Inductive uPred_entails {M} (P Q : uPred M) : Prop :=
  { uPred_in_entails : ∀ n x, ✓{n} x → P n x → Q n x }.
Global Hint Resolve uPred_mono : uPred_def.

Local Program Definition uPred_pure_def {M} (φ : Prop) : uPred M :=
  {| uPred_holds n x := φ |}.
Solve Obligations with done.
Local Definition uPred_pure_aux : seal (@uPred_pure_def).
Admitted.
Definition uPred_pure := uPred_pure_aux.(unseal).
Global Arguments uPred_pure {M}.

Local Program Definition uPred_and_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := P n x ∧ Q n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_and_aux : seal (@uPred_and_def).
Admitted.
Definition uPred_and := uPred_and_aux.(unseal).
Global Arguments uPred_and {M}.

Local Program Definition uPred_or_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := P n x ∨ Q n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_or_aux : seal (@uPred_or_def).
Admitted.
Definition uPred_or := uPred_or_aux.(unseal).
Global Arguments uPred_or {M}.

Local Program Definition uPred_impl_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := ∀ n' x',
       x ≼ x' → n' ≤ n → ✓{n'} x' → P n' x' → Q n' x' |}.
Admit Obligations.
Local Definition uPred_impl_aux : seal (@uPred_impl_def).
Admitted.
Definition uPred_impl := uPred_impl_aux.(unseal).
Global Arguments uPred_impl {M}.

Local Program Definition uPred_forall_def {M A} (Ψ : A → uPred M) : uPred M :=
  {| uPred_holds n x := ∀ a, Ψ a n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_forall_aux : seal (@uPred_forall_def).
Admitted.
Definition uPred_forall := uPred_forall_aux.(unseal).

Local Program Definition uPred_exist_def {M A} (Ψ : A → uPred M) : uPred M :=
  {| uPred_holds n x := ∃ a, Ψ a n x |}.
Solve Obligations with naive_solver eauto 2 with uPred_def.
Local Definition uPred_exist_aux : seal (@uPred_exist_def).
Admitted.
Definition uPred_exist := uPred_exist_aux.(unseal).

Local Program Definition uPred_sep_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := ∃ x1 x2, x ≡{n}≡ x1 ⋅ x2 ∧ P n x1 ∧ Q n x2 |}.
Admit Obligations.
Local Definition uPred_sep_aux : seal (@uPred_sep_def).
Admitted.
Definition uPred_sep := uPred_sep_aux.(unseal).
Global Arguments uPred_sep {M}.

Local Program Definition uPred_wand_def {M} (P Q : uPred M) : uPred M :=
  {| uPred_holds n x := ∀ n' x',
       n' ≤ n → ✓{n'} (x ⋅ x') → P n' x' → Q n' (x ⋅ x') |}.
Admit Obligations.
Local Definition uPred_wand_aux : seal (@uPred_wand_def).
Admitted.
Definition uPred_wand := uPred_wand_aux.(unseal).
Global Arguments uPred_wand {M}.

Local Program Definition uPred_plainly_def {M} (P : uPred M) : uPred M :=
  {| uPred_holds n x := P n ε |}.
Solve Obligations with naive_solver eauto using uPred_mono, ucmra_unit_validN.

Local Program Definition uPred_persistently_def {M} (P : uPred M) : uPred M :=
  {| uPred_holds n x := P n (core x) |}.
Solve Obligations with naive_solver eauto using uPred_mono, cmra_core_monoN.
Local Definition uPred_persistently_aux : seal (@uPred_persistently_def).
Admitted.
Definition uPred_persistently := uPred_persistently_aux.(unseal).
Global Arguments uPred_persistently {M}.

Local Program Definition uPred_later_def {M} (P : uPred M) : uPred M :=
  {| uPred_holds n x := match n return _ with 0 => True | S n' => P n' x end |}.
Admit Obligations.
Local Definition uPred_later_aux : seal (@uPred_later_def).
Admitted.
Definition uPred_later := uPred_later_aux.(unseal).
Global Arguments uPred_later {M}.
Definition uPred_emp {M} : uPred M.
Admitted.

Lemma uPred_bi_mixin (M : ucmra) :
  BiMixin
    uPred_entails uPred_emp uPred_pure uPred_and uPred_or uPred_impl
    (@uPred_forall M) (@uPred_exist M) uPred_sep uPred_wand.
Admitted.

Lemma uPred_bi_persistently_mixin (M : ucmra) :
  BiPersistentlyMixin
    uPred_entails uPred_emp uPred_and
    (@uPred_exist M) uPred_sep uPred_persistently.
Admitted.

Lemma uPred_bi_later_mixin (M : ucmra) :
  BiLaterMixin
    uPred_entails uPred_pure uPred_or uPred_impl
    (@uPred_forall M) (@uPred_exist M) uPred_sep uPred_persistently uPred_later.
Admitted.
Canonical Structure uPredI (M : ucmra) : bi.
exact ({| bi_ofe_mixin := ofe_mixin_of (uPred M);
     bi_bi_mixin := uPred_bi_mixin M;
     bi_bi_later_mixin := uPred_bi_later_mixin M;
     bi_bi_persistently_mixin := uPred_bi_persistently_mixin M |}).
Defined.
Global Instance uPred_bi_bupd M : BiBUpd (uPredI M).
Admitted.

Structure gFunctor := GFunctor {
  gFunctor_F :> rFunctor;
  gFunctor_map_contractive : rFunctorContractive gFunctor_F;
}.

Record gFunctors := GFunctors {
  gFunctors_len : nat;
  gFunctors_lookup : fin gFunctors_len → gFunctor
}.

Definition gid (Σ : gFunctors) := fin (gFunctors_len Σ).

Definition gname := positive.
Definition iResUR (Σ : gFunctors) : ucmra.
Admitted.
  Notation iProp Σ := (uPred (iResUR Σ)).
  Notation iPropO Σ := (uPredO (iResUR Σ)).

Class inG (Σ : gFunctors) (A : cmra) := InG {
  inG_id : gid Σ;
  inG_apply := rFunctor_apply (gFunctors_lookup Σ inG_id);
  inG_prf : A = inG_apply (iPropO Σ) _;
}.
Local Definition own_def `{!inG Σ A} (γ : gname) (a : A) : iProp Σ.
Admitted.
Local Definition own_aux : seal (@own_def).
Admitted.
Definition own := own_aux.(unseal).
Global Arguments own {Σ A _} γ a.

Section cmra_mlist.

  Context (A: Type) `{EqDecision A}.
  Implicit Types (D: list A).

  Inductive mlist :=
    | MList D : mlist
    | MListBot : mlist.

  Inductive mlist_equiv : Equiv mlist :=
    | MList_equiv D1 D2:
        D1 = D2 → MList D1 ≡ MList D2
    | MListBot_equiv : MListBot ≡ MListBot.

  Existing Instance mlist_equiv.
  Local Instance mlist_equiv_Equivalence : @Equivalence mlist equiv.
Admitted.
Canonical Structure mlistC : ofe.
exact (discreteO mlist).
Defined.
Local Instance mlist_valid : Valid mlist.
Admitted.
Local Instance mlist_op : Op mlist.
Admitted.
Local Instance mlist_PCore : PCore mlist.
Admitted.
Local Instance mlist_unit : Unit mlist.
Admitted.

  Definition mlist_ra_mixin : RAMixin mlist.
Admitted.

  Canonical Structure mlistR := discreteR mlist mlist_ra_mixin.

  Definition mlist_ucmra_mixin : UcmraMixin mlist.
Admitted.

  Canonical Structure mlistUR :=
    Ucmra mlist mlist_ucmra_mixin.

End cmra_mlist.

Global Arguments MList {_} _.

Definition fmlistUR (A: Type) {Heq: EqDecision A} := authUR (mlistUR A).
Class fmlistG (A: Type) {Heq: EqDecision A} Σ :=
  { #[global] fmlist_inG :: inG Σ (fmlistUR A) }.

Section fmlist_props.
Context `{fmlistG A Σ}.
Definition fmlist_lb γ l := own γ (◯ (MList l)).
Definition fmlist_idx γ i a := (∃ l, ⌜ l !! i = Some a ⌝ ∗ fmlist_lb γ l)%I.

End fmlist_props.
Local Instance nat_valid_instance : Valid nat.
Admitted.
Local Instance nat_pcore_instance : PCore nat.
Admitted.
Local Instance nat_op_instance : Op nat.
Admitted.
  Lemma nat_ra_mixin : RAMixin nat.
Admitted.
Canonical Structure natR : cmra.
exact (discreteR nat nat_ra_mixin).
Defined.
Local Instance nat_unit_instance : Unit nat.
Admitted.
  Lemma nat_ucmra_mixin : UcmraMixin nat.
Admitted.
Canonical Structure natUR : ucmra.
exact (Ucmra nat nat_ucmra_mixin).
Defined.

Class lcGpreS (Σ : gFunctors) := LcGpreS {
  #[local] lcGpreS_inG :: inG Σ (authR natUR)
}.

Class lcGS (Σ : gFunctors) := LcGS {
  #[local] lcGS_inG :: inG Σ (authR natUR);
  lcGS_name : gname;
}.
Import iris.algebra.coPset.

Inductive bi_schema :=
| bi_sch_emp : bi_schema
| bi_sch_pure : Prop → bi_schema
| bi_sch_and : bi_schema → bi_schema → bi_schema
| bi_sch_or : bi_schema → bi_schema → bi_schema
| bi_sch_forall : ∀ A, (A → bi_schema) → bi_schema
| bi_sch_exist : ∀ A, (A → bi_schema) → bi_schema
| bi_sch_sep : bi_schema → bi_schema → bi_schema
| bi_sch_wand : bi_schema → bi_schema → bi_schema
| bi_sch_persistently : bi_schema → bi_schema
| bi_sch_later : bi_schema → bi_schema
| bi_sch_bupd : bi_schema → bi_schema

| bi_sch_var_fixed : nat → bi_schema
| bi_sch_var_mut : nat → bi_schema
| bi_sch_wsat : bi_schema
| bi_sch_ownE : (nat → coPset) → bi_schema.

Canonical Structure bi_schemaO := leibnizO bi_schema.

Record invariant_level_names := { invariant_name : gname; }.

Global Instance invariant_level_names_eq_dec : EqDecision (invariant_level_names).
Admitted.
  Class invGpreS (Σ : gFunctors) : Set := WsatPreG {
    #[global] inv_inPreG :: inG Σ (authR (gmapUR positive
                                    (prodR (agreeR (prodO (listO (laterO (iPropO Σ))) bi_schemaO))
                                           (optionR (prodR fracR (agreeR (listO (laterO (iPropO Σ)))))))));
    #[global] enabled_inPreG :: inG Σ coPset_disjR;
    #[global] disabled_inPreG :: inG Σ (gset_disjR positive);
    #[global] mlist_inPreG :: fmlistG (invariant_level_names) Σ;
    inv_lcPreG : lcGpreS Σ;
  }.

  Class invGS (Σ : gFunctors) : Set := WsatG {
    #[global] inv_inG :: invGpreS Σ;
    #[global] invGS_lc :: lcGS Σ;
    inv_list_name : gname;
    enabled_name : gname;
    disabled_name : gname;
  }.

Definition invariant_unfold {Σ} {n} sch (Ps : vec (iProp Σ) n) : agree (list (later (iPropO Σ)) * bi_schema) :=
  to_agree ((λ P, Next P) <$> (vec_to_list Ps), sch).
Definition inv_mut_unfold {Σ} {n} q (Ps : vec (iProp Σ) n) : option (frac * (agree (list (later (iPropO Σ))))) :=
  Some (q%Qp, to_agree ((λ P, Next P) <$> (vec_to_list Ps))).
Definition ownI `{!invGS Σ} {n} (lvl: nat) (i : positive) (sch: bi_schema) (Ps : vec (iProp Σ) n) : iProp Σ :=
  (∃ γs, fmlist_idx inv_list_name lvl γs ∗
         own (invariant_name γs) (◯ {[ i := (invariant_unfold sch Ps, ε) ]})).

Definition ownI_mut `{!invGS Σ} {n} (lvl: nat) (i : positive) q (Qs : vec (iProp Σ) n) : iProp Σ :=
  (∃ (l: agree (list (later (iPropO Σ)) * bi_schema)) γs, fmlist_idx inv_list_name lvl γs ∗
         own (invariant_name γs) (◯ {[ i := (l, inv_mut_unfold q Qs) ]})).
Definition ownE `{!invGS Σ} (E : coPset) : iProp Σ.
Admitted.
Definition ownD `{!invGS Σ} (E : gset positive) : iProp Σ.
Admitted.

Definition inv_cmra_fmap `{!invGS Σ} (v: (list (iProp Σ) * bi_schema) * list (iProp Σ)) :=
  let '((Ps, sch), Qs) := v in
  (invariant_unfold sch (list_to_vec Ps), inv_mut_unfold 1%Qp (list_to_vec Qs)).

Fixpoint bi_schema_pre `{!invGS Σ} n (Ps Ps_mut: list (iProp Σ)) wsat (sch: bi_schema) :=
  match sch with
  | bi_sch_emp => emp
  | bi_sch_pure φ => ⌜φ⌝
  | bi_sch_and sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 ∧ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_or sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 ∨ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_forall A sch => ∀ (a: A),  bi_schema_pre n Ps Ps_mut wsat (sch a)
  | bi_sch_exist A sch => ∃ (a: A),  bi_schema_pre n Ps Ps_mut wsat (sch a)
  | bi_sch_sep sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 ∗ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_wand sch1 sch2 => bi_schema_pre n Ps Ps_mut wsat sch1 -∗ bi_schema_pre n Ps Ps_mut wsat sch2
  | bi_sch_persistently sch => <pers> bi_schema_pre n Ps Ps_mut wsat sch
  | bi_sch_later sch => ▷ bi_schema_pre n Ps Ps_mut wsat sch
  | bi_sch_bupd sch => |==> bi_schema_pre n Ps Ps_mut wsat sch
  | bi_sch_var_fixed i =>
    match (Ps !! i) with
    | None => emp
    | Some P => P
    end
  | bi_sch_var_mut i =>
    match (Ps_mut !! i) with
    | None => emp
    | Some P => P
    end
  | bi_sch_wsat => wsat
  | bi_sch_ownE E => ownE (E n)
  end%I.

Definition wsat_pre `{!invGS Σ} n bi_schema_interp :=
  (∃ I : gmap positive ((list (iProp Σ) * bi_schema) * list (iProp Σ)),
        (∃ γs, fmlist_idx inv_list_name n γs ∗
             own (invariant_name γs) (● (inv_cmra_fmap <$> I : gmap _ _))) ∗
        [∗ map] i ↦ Qs ∈ I, (bi_schema_interp (bi_later <$> Qs.1.1) (bi_later <$> Qs.2) Qs.1.2 ∗
                             ownI_mut n i (1/2)%Qp (list_to_vec Qs.2) ∗
                             ownD {[i]}) ∨
                            ownE {[i]})%I.

Fixpoint bi_schema_interp `{!invGS Σ} n (Ps Ps_mut: list (iProp Σ)) sch {struct n} :=
  match n with
  | O => bi_schema_pre O Ps Ps_mut True%I sch
  | S n' => bi_schema_pre (S n') Ps Ps_mut (wsat_pre n' (bi_schema_interp n') ∗ wsat n')%I sch
  end
  with
  wsat `{!invGS Σ} n :=
  match n with
    | S n =>
  (∃ I : gmap positive ((list (iProp Σ) * bi_schema) * list (iProp Σ)),
        (∃ γs, fmlist_idx inv_list_name n γs ∗
             own (invariant_name γs) (● (inv_cmra_fmap <$> I : gmap _ _))) ∗
        [∗ map] i ↦ Qs ∈ I, (bi_schema_interp n (bi_later <$> Qs.1.1) (bi_later <$> Qs.2) Qs.1.2 ∗
                             ownI_mut n i (1/2)%Qp (list_to_vec Qs.2) ∗
                             ownD {[i]}) ∨
                            ownE {[i]})
    ∗ wsat n
    | O => True
  end%I.

Section wsat.
Context `{!invGS Σ}.

Lemma ownI_alloc {n m} φ sch lvl (Ps: vec _ n) (Ps_mut: vec _ m):
  (∀ E : gset positive, ∃ i, i ∉ E ∧ φ i) →
  wsat (S lvl) ∗
  bi_schema_interp lvl (bi_later <$> (vec_to_list Ps)) (bi_later <$> (vec_to_list Ps_mut)) sch ==∗
  ∃ i, ⌜φ i⌝ ∗ wsat (S lvl) ∗ ownI lvl i sch Ps ∗ ownI_mut lvl i (1/2)%Qp Ps_mut.
Admitted.

End wsat.

Section schema_test_mut.
Context `{!invGS Σ}.
Definition bi_sch_bupd_factory (Q P: bi_schema) : bi_schema.
Admitted.

Definition ownI_full_bupd_factory lvl i q Q P :=
  (∃ n (Qs: vec _ n), ownI lvl i (bi_sch_bupd_factory (bi_sch_var_mut O) (bi_sch_var_fixed O)) (list_to_vec [P]) ∗
   ownI_mut lvl i q Qs ∗ ⌜ default True%I (vec_to_list Qs !! 0) = Q ⌝)%I.

Lemma ownI_bupd_factory_alloc lvl φ Q P :
  (∀ E : gset positive, ∃ i, i ∉ E ∧ φ i) →
  wsat (S lvl) ∗ (▷ Q ∗ □ (▷ Q ==∗ ▷ Q ∗ ▷ P))
       ==∗ ∃ i, ⌜φ i⌝ ∗ wsat (S lvl) ∗ ownI_full_bupd_factory lvl i (1/2)%Qp Q P.
Proof.
  iIntros (?) "(Hw&(HQ&#Hfactory))".
iMod (ownI_alloc with "[$Hw HQ]") as (i) "(?&?&?&?)"; eauto; last first.
  {
 iModIntro.
iExists i.
iFrame.
instantiate (1:= list_to_vec [Q]).
rewrite //=.
}
  repeat (rewrite ?bi_schema_interp_unfold //=).
🛠️ Intermediate Coq File (useful for debugging if minimization did not go as far as you wanted)
🛠️ 📜 Intermediate Coq File log (useful for debugging if minimization did not go as far as you wanted)
📜 Build Log (contains the Coq error message) (truncated to last 8.0KiB; full 2.2MiB file on GitHub Actions Artifacts under build.log)
build_ci/perennial/src/program_proof/vrsm/notes.txt  
   creating: _build_ci/perennial/src/program_proof/vrsm/paxos/
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/applyasfollower_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/becomeleader_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/clerk_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/definitions.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/enternewepoch_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/init_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/marshal_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/protocol_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/start_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/tryacquire_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/weakread_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/withlock_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/proph_proof.v  
   creating: _build_ci/perennial/src/program_proof/vrsm/reconfig/
  inflating: _build_ci/perennial/src/program_proof/vrsm/reconfig/proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/renewable_lease.v  
   creating: _build_ci/perennial/src/program_proof/vrsm/replica/
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/apply_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/applybackup_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/becomeprimary_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/config_protocol_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/definitions.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/getstate_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/increasecommit_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/init_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/leaserenewal_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/makeclerk_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/marshal_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/preread_protocol.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/primary_protocol.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/protocol.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/roapply_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/sendcommitthread_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/setstate_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/start_proof.v  
   creating: _build_ci/perennial/src/program_proof/vrsm/storage/
  inflating: _build_ci/perennial/src/program_proof/vrsm/storage/proof.v  
   creating: _build_ci/perennial/src/program_proof/wal/
  inflating: _build_ci/perennial/src/program_proof/wal/abstraction.v  
  inflating: _build_ci/perennial/src/program_proof/wal/boundaries.v  
  inflating: _build_ci/perennial/src/program_proof/wal/circ_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/circ_proof_crash.v  
  inflating: _build_ci/perennial/src/program_proof/wal/common_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/flush_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/heapspec.v  
  inflating: _build_ci/perennial/src/program_proof/wal/heapspec_lib.v  
  inflating: _build_ci/perennial/src/program_proof/wal/heapspec_list.v  
  inflating: _build_ci/perennial/src/program_proof/wal/highest.v  
  inflating: _build_ci/perennial/src/program_proof/wal/installer_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/invariant.v  
  inflating: _build_ci/perennial/src/program_proof/wal/lib.v  
  inflating: _build_ci/perennial/src/program_proof/wal/logger_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/read_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/recovery_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/sliding.v  
  inflating: _build_ci/perennial/src/program_proof/wal/sliding_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/specs.v  
  inflating: _build_ci/perennial/src/program_proof/wal/thread_owned.v  
  inflating: _build_ci/perennial/src/program_proof/wal/transitions.v  
  inflating: _build_ci/perennial/src/program_proof/wal/txns_ctx.v  
  inflating: _build_ci/perennial/src/program_proof/wal/write_proof.v  
   creating: _build_ci/perennial/src/program_proof/wp_auto/
  inflating: _build_ci/perennial/src/program_proof/wp_auto/experiments.v  
  inflating: _build_ci/perennial/src/program_proof/wp_to_wpc.v  
   creating: _build_ci/perennial/src/tutorial/
  inflating: _build_ci/perennial/src/tutorial/ipm_extensions.org  
  inflating: _build_ci/perennial/src/tutorial/ipm_extensions.v  
++ popd
/github/workspace/builds/coq /github/workspace
++ printf '::endgroup::\n'
::endgroup::
++ printf '::group::df -h\n'
::group::df -h
++ df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay          73G   60G   14G  82% /
tmpfs            64M     0   64M   0% /dev
shm              64M     0   64M   0% /dev/shm
/dev/root        73G   60G   14G  82% /usr/sbin/docker-init
tmpfs           7.9G     0  7.9G   0% /proc/acpi
tmpfs           7.9G     0  7.9G   0% /proc/scsi
tmpfs           7.9G     0  7.9G   0% /sys/firmware
++ printf '::endgroup::\n'
::endgroup::
++ printf '::group::download passing artifacts @ %s %s\n' 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708 'https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download https://gitlab.inria.fr/coq/coq/-/jobs/4939699/artifacts/download'
::group::download passing artifacts @ 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708 https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download https://gitlab.inria.fr/coq/coq/-/jobs/4939699/artifacts/download
++ printf '::warning::download passing artifacts @ %s %s\n' 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708 'https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download https://gitlab.inria.fr/coq/coq/-/jobs/4939699/artifacts/download'
::warning::download passing artifacts @ 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708 https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download https://gitlab.inria.fr/coq/coq/-/jobs/4939699/artifacts/download
++ pushd coq-passing
/github/workspace/builds/coq/coq-passing /github/workspace/builds/coq /github/workspace
++ git checkout 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708
Note: switching to '146ae4a4b460e5d0c27eb9ec36c7f49105c9f708'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 146ae4a4b4 Merge PR #19807: Apparently missing “if” in plugins/extraction/scheme.ml
++ for i in ${PASSING_ARTIFACT_URLS}
+++ printf %s https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download
+++ sha1sum
+++ cut '-d ' -f1
++ hash=3f2e901160ace91ecc913741aac99e5fa4659069
++ wget https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download -O artifact-3f2e901160ace91ecc913741aac99e5fa4659069.zip
--2024-11-16 02:11:40--  https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download
Resolving gitlab.inria.fr (gitlab.inria.fr)... 128.93.193.23
Connecting to gitlab.inria.fr (gitlab.inria.fr)|128.93.193.23|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2024-11-16 02:11:41 ERROR 404: Not Found.
📜 🔎 Minimization Log (truncated to last 8.0KiB; full 2.2MiB file on GitHub Actions Artifacts under bug.log)
build_ci/perennial/src/program_proof/vrsm/notes.txt  
   creating: _build_ci/perennial/src/program_proof/vrsm/paxos/
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/applyasfollower_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/becomeleader_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/clerk_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/definitions.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/enternewepoch_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/init_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/marshal_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/protocol_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/start_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/tryacquire_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/weakread_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/paxos/withlock_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/proph_proof.v  
   creating: _build_ci/perennial/src/program_proof/vrsm/reconfig/
  inflating: _build_ci/perennial/src/program_proof/vrsm/reconfig/proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/renewable_lease.v  
   creating: _build_ci/perennial/src/program_proof/vrsm/replica/
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/apply_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/applybackup_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/becomeprimary_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/config_protocol_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/definitions.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/getstate_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/increasecommit_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/init_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/leaserenewal_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/makeclerk_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/marshal_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/preread_protocol.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/primary_protocol.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/protocol.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/roapply_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/sendcommitthread_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/setstate_proof.v  
  inflating: _build_ci/perennial/src/program_proof/vrsm/replica/start_proof.v  
   creating: _build_ci/perennial/src/program_proof/vrsm/storage/
  inflating: _build_ci/perennial/src/program_proof/vrsm/storage/proof.v  
   creating: _build_ci/perennial/src/program_proof/wal/
  inflating: _build_ci/perennial/src/program_proof/wal/abstraction.v  
  inflating: _build_ci/perennial/src/program_proof/wal/boundaries.v  
  inflating: _build_ci/perennial/src/program_proof/wal/circ_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/circ_proof_crash.v  
  inflating: _build_ci/perennial/src/program_proof/wal/common_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/flush_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/heapspec.v  
  inflating: _build_ci/perennial/src/program_proof/wal/heapspec_lib.v  
  inflating: _build_ci/perennial/src/program_proof/wal/heapspec_list.v  
  inflating: _build_ci/perennial/src/program_proof/wal/highest.v  
  inflating: _build_ci/perennial/src/program_proof/wal/installer_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/invariant.v  
  inflating: _build_ci/perennial/src/program_proof/wal/lib.v  
  inflating: _build_ci/perennial/src/program_proof/wal/logger_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/read_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/recovery_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/sliding.v  
  inflating: _build_ci/perennial/src/program_proof/wal/sliding_proof.v  
  inflating: _build_ci/perennial/src/program_proof/wal/specs.v  
  inflating: _build_ci/perennial/src/program_proof/wal/thread_owned.v  
  inflating: _build_ci/perennial/src/program_proof/wal/transitions.v  
  inflating: _build_ci/perennial/src/program_proof/wal/txns_ctx.v  
  inflating: _build_ci/perennial/src/program_proof/wal/write_proof.v  
   creating: _build_ci/perennial/src/program_proof/wp_auto/
  inflating: _build_ci/perennial/src/program_proof/wp_auto/experiments.v  
  inflating: _build_ci/perennial/src/program_proof/wp_to_wpc.v  
   creating: _build_ci/perennial/src/tutorial/
  inflating: _build_ci/perennial/src/tutorial/ipm_extensions.org  
  inflating: _build_ci/perennial/src/tutorial/ipm_extensions.v  
++ popd
/github/workspace/builds/coq /github/workspace
++ printf '::endgroup::\n'
::endgroup::
++ printf '::group::df -h\n'
::group::df -h
++ df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay          73G   60G   14G  82% /
tmpfs            64M     0   64M   0% /dev
shm              64M     0   64M   0% /dev/shm
/dev/root        73G   60G   14G  82% /usr/sbin/docker-init
tmpfs           7.9G     0  7.9G   0% /proc/acpi
tmpfs           7.9G     0  7.9G   0% /proc/scsi
tmpfs           7.9G     0  7.9G   0% /sys/firmware
++ printf '::endgroup::\n'
::endgroup::
++ printf '::group::download passing artifacts @ %s %s\n' 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708 'https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download https://gitlab.inria.fr/coq/coq/-/jobs/4939699/artifacts/download'
::group::download passing artifacts @ 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708 https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download https://gitlab.inria.fr/coq/coq/-/jobs/4939699/artifacts/download
++ printf '::warning::download passing artifacts @ %s %s\n' 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708 'https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download https://gitlab.inria.fr/coq/coq/-/jobs/4939699/artifacts/download'
::warning::download passing artifacts @ 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708 https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download https://gitlab.inria.fr/coq/coq/-/jobs/4939699/artifacts/download
++ pushd coq-passing
/github/workspace/builds/coq/coq-passing /github/workspace/builds/coq /github/workspace
++ git checkout 146ae4a4b460e5d0c27eb9ec36c7f49105c9f708
Note: switching to '146ae4a4b460e5d0c27eb9ec36c7f49105c9f708'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 146ae4a4b4 Merge PR #19807: Apparently missing “if” in plugins/extraction/scheme.ml
++ for i in ${PASSING_ARTIFACT_URLS}
+++ printf %s https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download
+++ sha1sum
+++ cut '-d ' -f1
++ hash=3f2e901160ace91ecc913741aac99e5fa4659069
++ wget https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download -O artifact-3f2e901160ace91ecc913741aac99e5fa4659069.zip
--2024-11-16 02:11:40--  https://gitlab.inria.fr/coq/coq/-/jobs/4939642/artifacts/download
Resolving gitlab.inria.fr (gitlab.inria.fr)... 128.93.193.23
Connecting to gitlab.inria.fr (gitlab.inria.fr)|128.93.193.23|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2024-11-16 02:11:41 ERROR 404: Not Found.

If you have any comments on your experience of the minimizer, please share them in a reply (possibly tagging @JasonGross).
If you believe there's a bug in the bug minimizer, please report it on the bug minimizer issue tracker.

cc @JasonGross

nmvdw added a commit to UniMath/UniMath that referenced this pull request Nov 18, 2024
coq/coq#19822 strengthens the unification
algorithm, so we need a few annotations to force some particular
instantiations of evars.

Co-authored-by: Niels van der Weide <nnmvdw@gmail.com>
@Tragicus
Copy link
Contributor Author

I guess given the name of the job and the message trace that ci-elpi_test does the tests in coq-elpi. However, I can not find any test_quotation.v in the repo. Where should I look at?

@Tragicus
Copy link
Contributor Author

The error in the hott example looks like there is a repeat split at the end where some split succeeds while leaving out some unification constraints. Rocq fails to solve them outside of the repeat, so the error is not caught and the whole line fails.

@Tragicus could you minimize this to a smaller example that displays the change in behavior? I presume that the issue is something like that we have Class Foo := bar : forall x y, baz = qux and split on a goal of type Foo would previously fail, resulting in typeclass resolution picking up the goal, whereas now split tries to apply eq_refl which succeeds but leaves over unsolved constraints?

Plausibly tactics that have both an e variant and a non-e variant (split vs esplit, apply vs eapply) should call solve_unification_constraints on the non-e variant? I think this might lead to more predictable behavior overall, though I'm not sure.

Here is the minimized version of the minimized hott example:

Declare ML Module "ltac_plugin:coq-core.plugins.ltac".

Class SgOp A := sg_op: forall (_ _ : A), A.
Class MonUnit A := mon_unit: A.
Class Negate A := negate: forall _ : A, A.

Class RightInverse {A} {B} {C} (op : forall (_ : A) (_ : B), C) (inv : forall _ : A, B) (unit : C)
  := right_inverse: forall x, op x (inv x) = unit.



Class IsGroup A {Aop : SgOp A} {Aunit : MonUnit A} {Anegate : Negate A} :=
  { negate_r : RightInverse sg_op negate mon_unit }.

Record Group := {
  group_type :> Type;
  group_sgop :: SgOp group_type;
  group_unit :: MonUnit group_type;
  group_inverse :: Negate group_type;
  group_isgroup :: IsGroup group_type;
}.


Section FreeProduct.

Context (G H K : Group).
Definition amal_type : Type.
Admitted.

Definition AmalgamatedFreeProduct : Group.
Proof.
  simple notypeclasses refine (Build_Group amal_type _ _ _ _).
  4: split.
  4: split.

@JasonGross
Copy link
Member
JasonGross commented Nov 18, 2024

Is there something even simpler, like

Record Foo {A} (f g : A -> A) y := { foo : forall x,  f (g x) = y }.
Goal forall A, { f : _ & { g : _ & { y : _ & @Foo A f g y } } }.
do 3 eexists.
repeat split.

has different behavior in master vs this branch? (I haven't tested this)

@JasonGross
Copy link
Member

Maybe I'm just suggesting inlining SgOp, MonUnit, Negate, RightInverse; making amal_type a context variable, and dropping G, H, K. (I want to be able to understand what unification problem is being run, without having to run the code in Coq).

@Tragicus
Copy link
Contributor Author

The behavior is indeed different, although the difference is not the same, here it simply solves the goal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: test-suite update Test case should be added to / updated in the test-suite.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants