Skip to content

Implemented rewrite Pr [...] for mu_ge0 and mu_le1#2

Merged
strub merged 1 commit into
EasyCrypt:1.0from
alleystoughton:1.0
Nov 5, 2017
Merged

Implemented rewrite Pr [...] for mu_ge0 and mu_le1#2
strub merged 1 commit into
EasyCrypt:1.0from
alleystoughton:1.0

Conversation

@alleystoughton

Copy link
Copy Markdown
Member

Implemented rewrite Pr [...] for mu_ge0 and mu_le1, corresponding to the Distr.ec lemmas

lemma ge0_mu (d : 'a distr) p : 0%r <= mu d p.
lemma le1_mu (d : 'a distr) p : mu d p <= 1%r.

  rewrite Pr [...]

for mu_ge0 and mu_le1, corresponding to

lemma ge0_mu (d : 'a distr) p : 0%r <= mu d p.
lemma le1_mu (d : 'a distr) p : mu d p <= 1%r.

from Distr.ec
@strub strub merged commit 7721333 into EasyCrypt:1.0 Nov 5, 2017
Gustavo2622 added a commit that referenced this pull request Oct 25, 2025
strub added a commit that referenced this pull request Apr 30, 2026
…hange)

Splits the existing TcCtt resolution logic into three named local helpers — strat_tvar_via_tvtc, strat_abs_via_decl, strat_infer_by_carrier — corresponding to catalog modes #5, #6, and #1/#2 in doc/typeclasses-inference.md.

Behavior is identical: same dispatch order, same failures, same pickup of [Tvar a]/[Tconstr p] cases, same parking of univar carriers. The refactor exists so Phase 3 can drop a By-args strategy in without disturbing the existing logic.
strub added a commit that referenced this pull request May 6, 2026
Companion to the previous commit (bug #2: per-path synthesis +
tci_parents lookup). With multi-flavor inheritance, a single carrier
may have multiple synthesised instances of the same TC (e.g. a
comring on int has both an addmonoid- and a mulmonoid-derived monoid
instance). When applying a polymorphic monoid lemma to a goal whose
operator carries a SPECIFIC witness via an abbrev (e.g. [bigM] or
the [( * )] alias), the unifier was committing arbitrarily to one of
the candidates via [strat_infer_by_carrier], then failing later when
the goal's [TcTw] equation pinned the other view.

Fix: detect ambiguity at strategy-resolution time. When [infer_all]
returns more than one candidate witness for [(carrier, tc)], DEFER —
leave the witness univar unresolved instead of committing. A
subsequent [TcTw] equation from the surrounding goal will bind the
univar to the concrete witness via [bind_uni], picking the correct
view from context.

The dispatch in [select_op] gains a fourth case alongside (resolved
/ park-on-arg-deps / failure): if no resolution AND ambiguity
detected, hold the constraint live without failing. If unification
later doesn't narrow it, the resulting unbound univar surfaces as
the usual "type-ambiguous" error elsewhere.

Adds [EcTypeClass.infer_all : env -> ty -> typeclass -> tcwitness
list] (companion to [infer]).

Effect: with both bug fixes in place, [apply big_cat] (on
[monoid]) discharges goals stated with [bigA] / [bigM] wrappers at
concrete carriers — previously failing because the unifier picked
the wrong view. The full multi-flavor factory pattern (e.g.
[comring <: addgroup & (mulmonoid with idm = oner, (+) = ( * ))])
now works end-to-end: [\sum] and [\prod]-style notations both fold
correctly, and lemmas on [monoid] apply to either flavor without
needing per-flavor restatements.

Regression: all existing TC examples build clean under --profile=ci.
strub added a commit that referenced this pull request May 6, 2026
Update the inline comment in TcRing.ec to reflect investigation
findings: bugs #1 and #2 are fixed for concrete-carrier use cases
(e.g. [bigA] / [bigM] on [int]), but section-internal proofs with a
Tvar carrier and multi-parent inheritance hit a [TCIAbstract.lift]
representation limit — the [lift] field is a single integer that
can't disambiguate among multiple parent walks of different lengths
to the same target ancestor TC.

Practical effect: declaring a class as [comring <: addgroup &
(mulmonoid with ...)] would WORK for [bigA]/[bigM] on concrete
carriers but not for proofs of generic comring lemmas inside a
section. Until the witness representation supports multi-parent
walks (path-encoded lift), [comring] stays single-parent with
multiplicative axioms re-stated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants