Skip to content

Commit d8bf37e

Browse files
committed
rename placeholder to universal
1 parent b47b7bc commit d8bf37e

File tree

13 files changed

+36
-178
lines changed

13 files changed

+36
-178
lines changed

crates/formality-prove/src/prove/env.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use formality_types::{
55
collections::Set,
66
fold::Fold,
77
grammar::{
8-
Binder, InferenceVar, ParameterKind, PlaceholderVar, VarIndex, VarSubstitution, Variable,
8+
Binder, InferenceVar, ParameterKind, UniversalVar, VarIndex, VarSubstitution, Variable,
99
},
1010
visit::Visit,
1111
};
@@ -59,7 +59,7 @@ impl Env {
5959
.variables
6060
.iter()
6161
.map(|v| match v {
62-
Variable::PlaceholderVar(pv) => pv.var_index.index,
62+
Variable::UniversalVar(pv) => pv.var_index.index,
6363
Variable::InferenceVar(iv) => iv.var_index.index,
6464
Variable::BoundVar(_) => panic!(),
6565
})
@@ -137,12 +137,12 @@ impl Env {
137137
vars
138138
}
139139

140-
pub fn universal_substitution<T>(&self, b: &Binder<T>) -> (Env, Vec<PlaceholderVar>)
140+
pub fn universal_substitution<T>(&self, b: &Binder<T>) -> (Env, Vec<UniversalVar>)
141141
where
142142
T: Fold,
143143
{
144144
let mut env = self.clone();
145-
let subst = env.fresh_substituion(b.kinds(), |kind, var_index| PlaceholderVar {
145+
let subst = env.fresh_substituion(b.kinds(), |kind, var_index| UniversalVar {
146146
kind,
147147
var_index,
148148
});
@@ -153,7 +153,7 @@ impl Env {
153153
where
154154
T: Fold,
155155
{
156-
let subst = self.fresh_substituion(b.kinds(), |kind, var_index| PlaceholderVar {
156+
let subst = self.fresh_substituion(b.kinds(), |kind, var_index| UniversalVar {
157157
kind,
158158
var_index,
159159
});

crates/formality-prove/src/prove/minimize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use formality_types::{
22
cast::{Downcast, Upcast},
33
collections::Deduplicate,
44
grammar::{
5-
InferenceVar, Parameter, PlaceholderVar, Substitution, VarIndex, VarSubstitution, Variable,
5+
InferenceVar, Parameter, Substitution, UniversalVar, VarIndex, VarSubstitution, Variable,
66
},
77
term::Term,
88
};
@@ -24,7 +24,7 @@ pub fn minimize<T: Term>(env_max: Env, term: T) -> (Env, T, Minimization) {
2424
.iter()
2525
.zip(0..)
2626
.map(|(&fv, index)| match fv {
27-
Variable::PlaceholderVar(PlaceholderVar { kind, var_index: _ }) => PlaceholderVar {
27+
Variable::UniversalVar(UniversalVar { kind, var_index: _ }) => UniversalVar {
2828
kind,
2929
var_index: VarIndex { index },
3030
}

crates/formality-prove/src/prove/prove_eq.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use formality_types::{
22
cast::{Downcast, Upcast, Upcasted},
33
collections::{Deduplicate, Set},
44
grammar::{
5-
AliasTy, InferenceVar, Parameter, PlaceholderVar, Relation, RigidTy, Substitution, TyData,
5+
AliasTy, InferenceVar, Parameter, Relation, RigidTy, Substitution, TyData, UniversalVar,
66
Variable, Wcs,
77
},
88
judgment_fn, set,
@@ -103,7 +103,7 @@ judgment_fn! {
103103
(
104104
(if env.universe(p) < env.universe(v))
105105
----------------------------- ("existential-placeholder")
106-
(prove_existential_var_eq(_decls, env, _assumptions, v, Variable::PlaceholderVar(p)) => (env, (v, p)))
106+
(prove_existential_var_eq(_decls, env, _assumptions, v, Variable::UniversalVar(p)) => (env, (v, p)))
107107
)
108108
}
109109
}
@@ -165,13 +165,13 @@ fn equate_variable(
165165
.chain(Some((x, universe_subst.apply(&p)).upcast())),
166166
);
167167

168-
// For each placeholder variable that we replaced with an inference variable
168+
// For each universal variable that we replaced with an inference variable
169169
// above, we now have to prove that goal. e.g., if we had `X = Vec<!Y>`, we would replace `!Y` with `?Z`
170170
// (where `?Z` is in a lower universe than `X`), but now we must prove that `!Y = ?Z`
171171
// (this may be posible due to assumptions).
172172
let goals: Wcs = universe_subst
173173
.iter()
174-
.filter(|(v, _)| v.is_a::<PlaceholderVar>())
174+
.filter(|(v, _)| v.is_a::<UniversalVar>())
175175
.map(|(v, p)| eq(v, p))
176176
.upcasted()
177177
.collect();

crates/formality-prove/src/prove/prove_wf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use formality_types::{
2-
grammar::{Parameter, PlaceholderVar, RigidName, RigidTy, Wcs},
2+
grammar::{Parameter, RigidName, RigidTy, UniversalVar, Wcs},
33
judgment_fn,
44
};
55

@@ -24,9 +24,9 @@ judgment_fn! {
2424
// are WF. An alternative would be to add explicit assumptions into the environment
2525
// for every universal variable. That just seems tedious.
2626
--- ("universal variables")
27-
(prove_wf(_decls, env, _assumptions, PlaceholderVar { .. }) => Constraints::none(env))
27+
(prove_wf(_decls, env, _assumptions, UniversalVar { .. }) => Constraints::none(env))
2828
)
29-
29+
3030
(
3131
(for_all(&decls, &env, &assumptions, &parameters, &prove_wf) => c)
3232
--- ("tuples")

crates/formality-prove/src/test/eq_partial_eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn not_partial_eq_implies_eq() {
4949
}
5050

5151
#[test]
52-
fn placeholders_not_eq() {
52+
fn universals_not_eq() {
5353
let goal: Wc = term("for<ty T, ty U> if {Eq(T)} PartialEq(U)");
5454
let constraints = prove(decls(), (), (), goal);
5555
expect![[r#"

crates/formality-types/src/grammar/ty.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ pub enum PredicateTy {
242242
ForAll(Binder<Ty>),
243243
}
244244

245-
/// A *placeholder* is a dummy variable about which nothing is known except
245+
/// A *universal variable* is a dummy variable about which nothing is known except
246246
/// that which we see in the environment. When we want to prove something
247-
/// is true for all `T` (`∀T`), we replace `T` with a placeholder.
247+
/// is true for all `T` (`∀T`), we replace `T` with a universal variable.
248248
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
249-
pub struct PlaceholderVar {
249+
pub struct UniversalVar {
250250
pub kind: ParameterKind,
251251
pub var_index: VarIndex,
252252
}
@@ -406,7 +406,7 @@ impl Visit for LtData {
406406

407407
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
408408
pub enum Variable {
409-
PlaceholderVar(PlaceholderVar),
409+
UniversalVar(UniversalVar),
410410
InferenceVar(InferenceVar),
411411
BoundVar(BoundVar),
412412
}
@@ -416,7 +416,7 @@ cast_impl!(Variable);
416416
impl Variable {
417417
pub fn kind(&self) -> ParameterKind {
418418
match self {
419-
Variable::PlaceholderVar(v) => v.kind,
419+
Variable::UniversalVar(v) => v.kind,
420420
Variable::InferenceVar(v) => v.kind,
421421
Variable::BoundVar(v) => v.kind,
422422
}
@@ -466,12 +466,12 @@ impl Variable {
466466
}
467467

468468
/// A variable is *free* (i.e., not bound by any internal binder)
469-
/// if it is an inference variable, a placeholder, or has a debruijn
469+
/// if it is an inference variable, a universal, or has a debruijn
470470
/// index of `None`. The latter occurs when you `open` a binder (and before
471471
/// you close it back up again).
472472
pub fn is_free(&self) -> bool {
473473
match self {
474-
Variable::PlaceholderVar(_)
474+
Variable::UniversalVar(_)
475475
| Variable::InferenceVar(_)
476476
| Variable::BoundVar(BoundVar {
477477
debruijn: None,
@@ -489,7 +489,7 @@ impl Variable {
489489

490490
pub fn is_universal(&self) -> bool {
491491
match self {
492-
Variable::PlaceholderVar(_) => true,
492+
Variable::UniversalVar(_) => true,
493493
Variable::InferenceVar(_) => false,
494494
Variable::BoundVar(_) => false,
495495
}
@@ -530,7 +530,7 @@ impl DowncastTo<Variable> for Parameter {
530530
cast_impl!(BoundVar);
531531
cast_impl!((InferenceVar) <: (Variable) <: (Parameter));
532532
cast_impl!((BoundVar) <: (Variable) <: (Parameter));
533-
cast_impl!((PlaceholderVar) <: (Variable) <: (Parameter));
533+
cast_impl!((UniversalVar) <: (Variable) <: (Parameter));
534534

535535
/// Identifies a bound variable.
536536
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -824,21 +824,21 @@ cast_impl!(TyData::AliasTy(AliasTy));
824824
cast_impl!(TyData::PredicateTy(PredicateTy));
825825
cast_impl!(TyData::Variable(Variable));
826826
cast_impl!((Variable) <: (TyData) <: (Ty));
827-
cast_impl!((PlaceholderVar) <: (Variable) <: (TyData));
827+
cast_impl!((UniversalVar) <: (Variable) <: (TyData));
828828
cast_impl!((InferenceVar) <: (Variable) <: (TyData));
829829
cast_impl!((BoundVar) <: (Variable) <: (TyData));
830830
cast_impl!((ScalarId) <: (RigidTy) <: (TyData));
831-
cast_impl!((PlaceholderVar) <: (Variable) <: (Ty));
831+
cast_impl!((UniversalVar) <: (Variable) <: (Ty));
832832
cast_impl!((InferenceVar) <: (Variable) <: (Ty));
833833
cast_impl!((BoundVar) <: (Variable) <: (Ty));
834834
cast_impl!(Lt);
835835
cast_impl!(LtData::Variable(Variable));
836836
cast_impl!((InferenceVar) <: (Variable) <: (LtData));
837-
cast_impl!((PlaceholderVar) <: (Variable) <: (LtData));
837+
cast_impl!((UniversalVar) <: (Variable) <: (LtData));
838838
cast_impl!((BoundVar) <: (Variable) <: (LtData));
839-
cast_impl!((PlaceholderVar) <: (LtData) <: (Lt));
839+
cast_impl!((UniversalVar) <: (LtData) <: (Lt));
840840
cast_impl!((InferenceVar) <: (LtData) <: (Lt));
841841
cast_impl!((BoundVar) <: (LtData) <: (Lt));
842-
cast_impl!(Variable::PlaceholderVar(PlaceholderVar));
842+
cast_impl!(Variable::UniversalVar(UniversalVar));
843843
cast_impl!(Variable::InferenceVar(InferenceVar));
844844
cast_impl!(Variable::BoundVar(BoundVar));

crates/formality-types/src/grammar/ty/debug_impls.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,23 @@ impl std::fmt::Debug for super::Lt {
2121
impl std::fmt::Debug for super::Variable {
2222
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2323
match self {
24-
Self::PlaceholderVar(arg0) => write!(f, "{:?}", arg0),
24+
Self::UniversalVar(arg0) => write!(f, "{:?}", arg0),
2525
Self::InferenceVar(arg0) => write!(f, "{:?}", arg0),
2626
Self::BoundVar(arg0) => write!(f, "{:?}", arg0),
2727
}
2828
}
2929
}
3030

31-
impl std::fmt::Debug for super::PlaceholderVar {
31+
impl std::fmt::Debug for super::UniversalVar {
3232
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33-
let super::PlaceholderVar {
34-
var_index,
35-
kind,
36-
} = self;
33+
let super::UniversalVar { var_index, kind } = self;
3734
write!(f, "!{:?}_{:?}", kind, var_index)
3835
}
3936
}
4037

4138
impl std::fmt::Debug for super::InferenceVar {
4239
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43-
let super::InferenceVar {
44-
var_index,
45-
kind,
46-
} = self;
40+
let super::InferenceVar { var_index, kind } = self;
4741
write!(f, "?{:?}_{:?}", kind, var_index)
4842
}
4943
}

crates/formality-types/src/visit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ pub trait Visit {
2626
/// This is to aid with fuzzing and bug detection.
2727
fn assert_valid(&self);
2828

29-
/// True if this term references only placeholder variables.
29+
/// True if this term references only universal variables.
3030
/// This means that it contains no inference variables.
3131
/// If this is a goal, then when we prove it true, we don't expect any substitution.
3232
/// This is similar, but not *identical*, to the commonly used term "ground term",
3333
/// which in Prolog refers to a term that contains no variables. The difference here
3434
/// is that the term may contain variables, but only those instantiated universally (∀).
35-
fn references_only_placeholder_variables(&self) -> bool {
35+
fn references_only_universal_variables(&self) -> bool {
3636
self.free_variables().iter().all(|v| match v {
37-
Variable::PlaceholderVar(_) => true,
37+
Variable::UniversalVar(_) => true,
3838
Variable::InferenceVar(_) => false,
3939
Variable::BoundVar(_) => false,
4040
})

crates/macros/Cargo.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.

crates/macros/src/lib.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)